video_dec: Set crop only if frame dimensions change
authorSeungBeom Kim <sbcrux.kim@samsung.com>
Mon, 30 Mar 2015 16:36:13 +0000 (18:36 +0200)
committerGerrit Code Review <gerrit@cyanogenmod.org>
Tue, 31 Mar 2015 17:19:13 +0000 (17:19 +0000)
Backported-from: hardware/samsung_slsi/exynos5

Change-Id: Ic8c8a59f799334210a7c51bfaceb272b94ba7602
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
component/video/dec/Exynos_OMX_VdecControl.c

index 5863ab97f55cf4021dc29189ea34e547024adb84..501136309b43373489e44d2c05e4b233141a3a96 100644 (file)
@@ -1255,6 +1255,7 @@ OMX_ERRORTYPE Exynos_OMX_VideoDecodeSetParameter(
         EXYNOS_OMX_BASEPORT           *pExynosPort;
         OMX_U32 width, height, size;
         OMX_U32 realWidth, realHeight;
+        OMX_U32 originalWidth, originalHeight;
 
         if (portIndex >= pExynosComponent->portParam.nPorts) {
             ret = OMX_ErrorBadPortIndex;
@@ -1280,6 +1281,8 @@ OMX_ERRORTYPE Exynos_OMX_VideoDecodeSetParameter(
             goto EXIT;
         }
 
+        originalWidth = pExynosPort->portDefinition.format.video.nFrameWidth;
+        originalHeight = pExynosPort->portDefinition.format.video.nFrameHeight;
         Exynos_OSAL_Memcpy(&pExynosPort->portDefinition, pPortDefinition, pPortDefinition->nSize);
 
 #ifdef USE_ANB // Modified by Google engineer
@@ -1300,10 +1303,12 @@ OMX_ERRORTYPE Exynos_OMX_VideoDecodeSetParameter(
         pExynosPort->portDefinition.format.video.nSliceHeight = height;
         pExynosPort->portDefinition.nBufferSize = (size > pExynosPort->portDefinition.nBufferSize) ? size : pExynosPort->portDefinition.nBufferSize;
 
-        pExynosPort->cropRectangle.nTop = 0;
-        pExynosPort->cropRectangle.nLeft = 0;
-        pExynosPort->cropRectangle.nWidth = realWidth;
-        pExynosPort->cropRectangle.nHeight = realHeight;
+        if (realWidth != originalWidth || realHeight != originalHeight) {
+            pExynosPort->cropRectangle.nTop = 0;
+            pExynosPort->cropRectangle.nLeft = 0;
+            pExynosPort->cropRectangle.nWidth = realWidth;
+            pExynosPort->cropRectangle.nHeight = realHeight;
+        }
 
         if (portIndex == INPUT_PORT_INDEX) {
             EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
@@ -1311,6 +1316,15 @@ OMX_ERRORTYPE Exynos_OMX_VideoDecodeSetParameter(
             pExynosOutputPort->portDefinition.format.video.nFrameHeight = pExynosPort->portDefinition.format.video.nFrameHeight;
             pExynosOutputPort->portDefinition.format.video.nStride = width;
             pExynosOutputPort->portDefinition.format.video.nSliceHeight = height;
+            // if resetting the output port size, also reset the crop size for the output port;
+            // otherwise, output crop will not be updated when setting up the output port because
+            // the output size would not have changed after we updated it here
+            if (realWidth != originalWidth || realHeight != originalHeight) {
+                pExynosOutputPort->cropRectangle.nTop = 0;
+                pExynosOutputPort->cropRectangle.nLeft = 0;
+                pExynosOutputPort->cropRectangle.nWidth = realWidth;
+                pExynosOutputPort->cropRectangle.nHeight = realHeight;
+            }
 
             switch (pExynosOutputPort->portDefinition.format.video.eColorFormat) {
             case OMX_COLOR_FormatYUV420Planar: