+#if USE(ACCELERATED_VIDEO_VAAPI)
+// Other device doesn't prefer such optimization, so enclose it in USE(ACCELERATED_VIDEO_VAAPI) macro
+IntSize MediaPlayerPrivateGStreamer::scaleHDVideoToDisplaySize(int videoWidth, int videoHeight, int displayWidth, int displayHeight) const
+{
+ int fitWidth, fitHeight;
+
+#if ENABLE(TIZEN_DLOG_SUPPORT)
+ TIZEN_LOGI("videoWidth: %d, videoHeight: %d, displayWidth: %d, displayHeight: %d ", videoWidth, videoHeight, displayWidth, displayHeight);
+#endif
+ fitWidth = videoWidth;
+ fitHeight = videoHeight;
+ if (displayWidth > 0 && displayHeight > 0) {
+ // In case video is rotated, we always use a 'better'
+ // orientation (landscape or portrait) to calculate fitWidth/fitHeight.
+ // It means we use a bigger size which doesn't lose quality
+ // in either landscape or portrait orientation
+ if ((videoWidth > videoHeight && displayWidth < displayHeight)
+ || (videoWidth < videoHeight && displayWidth > displayHeight)) {
+ int tmp;
+ tmp = displayWidth;
+ displayWidth = displayHeight;
+ displayHeight = tmp;
+ }
+
+ if (videoWidth > displayWidth || videoHeight > displayHeight) {
+ if (videoWidth * displayHeight > videoHeight * displayWidth) {
+ fitWidth = displayWidth;
+ fitHeight = videoHeight * displayWidth / videoWidth;
+ ASSERT(fitHeight <= displayHeight);
+ } else {
+ fitWidth = videoWidth * displayHeight / videoHeight;
+ fitHeight = displayHeight;
+ ASSERT(fitWidth <= displayWidth);
+ }
+ }
+ }
+
+ return IntSize(fitWidth, fitHeight);
+}
+#endif