exynos_omx: multi_thread: set crop only if frame dimensions change
authorRobert Shih <robertshih@google.com>
Wed, 24 Sep 2014 16:15:48 +0000 (09:15 -0700)
committerRobert Shih <robertshih@google.com>
Wed, 24 Sep 2014 22:06:55 +0000 (15:06 -0700)
Bug: 17609133
Change-Id: I2293c7501b33cade04443f631b2ca6f356932082

exynos_omx/openmax/exynos_omx/component/video/dec/Exynos_OMX_VdecControl.c

index 29b50361e13b51eb112717edbd5b03572acfcafc..80c3b633adf5bbcf0f2e1b264047974e3dec865a 100644 (file)
@@ -1214,6 +1214,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;
@@ -1239,6 +1240,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
@@ -1260,10 +1263,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];
@@ -1271,6 +1276,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: