exynos_omx: multi_thread: Fix for dynamic resolution change timing issue.
authorSeungBeom Kim <sbcrux.kim@samsung.com>
Tue, 17 Sep 2013 01:03:40 +0000 (10:03 +0900)
committerLajos Molnar <lajos@google.com>
Wed, 18 Sep 2013 14:37:16 +0000 (07:37 -0700)
Change-Id: I302de465745513a29dcacb33fe623c3cad7f6b1d
Signed-off-by: SeungBeom Kim <sbcrux.kim@samsung.com>
Bug: 10192533

exynos_omx/openmax/exynos_omx/component/common/Exynos_OMX_Baseport.h
exynos_omx/openmax/exynos_omx/component/video/dec/Exynos_OMX_Vdec.c
exynos_omx/openmax/exynos_omx/component/video/dec/Exynos_OMX_Vdec.h
exynos_omx/openmax/exynos_omx/component/video/dec/Exynos_OMX_VdecControl.c
exynos_omx/openmax/exynos_omx/component/video/dec/h264/Exynos_OMX_H264dec.c
exynos_omx/openmax/exynos_omx/component/video/dec/mpeg4/Exynos_OMX_Mpeg4dec.c
exynos_omx/openmax/exynos_omx/component/video/dec/vp8/Exynos_OMX_Vp8dec.c

index 1cc43a86877b9d2da235849926c0f439e1fb2b9d..598b7ab36ee00161a8f0b49b56eba5e9237e0830 100644 (file)
@@ -191,6 +191,9 @@ typedef struct _EXYNOS_OMX_BASEPORT
     OMX_HANDLETYPE                 hAllCodecBufferReturnEvent;
     OMX_HANDLETYPE                 hPortMutex;
     EXYNOS_OMX_EXCEPTION_STATE     exceptionFlag;
+
+    OMX_PARAM_PORTDEFINITIONTYPE   newPortDefinition;
+    OMX_CONFIG_RECTTYPE            newCropRectangle;
 } EXYNOS_OMX_BASEPORT;
 
 
index eed7bf1f50a4e724a24b3416fc2e9a8f215f108c..3f072c56d105628ae1f66227cd5e15b857bf3972 100644 (file)
@@ -1232,7 +1232,6 @@ OMX_ERRORTYPE Exynos_OMX_VideoDecodeComponentInit(OMX_IN OMX_HANDLETYPE hCompone
 
     Exynos_OSAL_Memset(pVideoDec, 0, sizeof(EXYNOS_OMX_VIDEODEC_COMPONENT));
     pVideoDec->bReconfigDPB = OMX_FALSE;
-    pVideoDec->nSavedDPBCnt = 0;
     pExynosComponent->hComponentHandle = (OMX_HANDLETYPE)pVideoDec;
 
     pExynosComponent->bSaveFlagEOS = OMX_FALSE;
index 468bbd242a0dfacefa701b15548b95e02a122bc9..ac78794c109d6880689fcba8b09204ac4d9abfb8 100644 (file)
@@ -61,7 +61,6 @@
 #define MFC_OUTPUT_BUFFER_PLANE             2
 
 #define MAX_OUTPUTBUFFER_NUM_DYNAMIC        0 /* Dynamic number of metadata buffer */
-#define PLATFORM_DISPLAY_BUFFER             1
 
 typedef struct
 {
@@ -109,7 +108,6 @@ typedef struct _EXYNOS_OMX_VIDEODEC_COMPONENT
 
     /* For Reconfiguration DPB */
     OMX_BOOL bReconfigDPB;
-    OMX_U32  nSavedDPBCnt;
 
     /* CSC handle */
     OMX_PTR csc_handle;
index cc512de9faf096d26f6aadf5924771ced1e2c8cc..cd97b44cb4b17a129df82a2a56372b6c3f33f3e3 100644 (file)
@@ -470,10 +470,7 @@ OMX_ERRORTYPE Exynos_OMX_FlushPort(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 por
             }
             Exynos_ResetCodecData(&pExynosPort->processData);
 
-            if (pVideoDec->bReconfigDPB == OMX_TRUE)
-                maxBufferNum = pVideoDec->nSavedDPBCnt;
-            else
-                maxBufferNum = pExynosPort->portDefinition.nBufferCountActual;
+            maxBufferNum = pExynosPort->portDefinition.nBufferCountActual;
             for (i = 0; i < maxBufferNum; i++) {
                 if (pExynosPort->extendBufferHeader[i].bBufferInOMX == OMX_TRUE) {
                     if (portIndex == OUTPUT_PORT_INDEX) {
@@ -609,6 +606,32 @@ EXIT:
     return ret;
 }
 
+OMX_ERRORTYPE Exynos_ResolutionUpdate(OMX_COMPONENTTYPE *pOMXComponent)
+{
+    OMX_ERRORTYPE                  ret                = OMX_ErrorNone;
+    EXYNOS_OMX_BASECOMPONENT      *pExynosComponent   = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+    EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec          = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
+    EXYNOS_OMX_BASEPORT           *pInputPort         = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
+    EXYNOS_OMX_BASEPORT           *pOutputPort        = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
+
+    pOutputPort->cropRectangle.nTop     = pOutputPort->newCropRectangle.nTop;
+    pOutputPort->cropRectangle.nLeft    = pOutputPort->newCropRectangle.nLeft;
+    pOutputPort->cropRectangle.nWidth   = pOutputPort->newCropRectangle.nWidth;
+    pOutputPort->cropRectangle.nHeight  = pOutputPort->newCropRectangle.nHeight;
+
+    pInputPort->portDefinition.format.video.nFrameWidth     = pInputPort->newPortDefinition.format.video.nFrameWidth;
+    pInputPort->portDefinition.format.video.nFrameHeight    = pInputPort->newPortDefinition.format.video.nFrameHeight;
+    pInputPort->portDefinition.format.video.nStride         = pInputPort->newPortDefinition.format.video.nStride;
+    pInputPort->portDefinition.format.video.nSliceHeight    = pInputPort->newPortDefinition.format.video.nSliceHeight;
+
+    pOutputPort->portDefinition.nBufferCountActual  = pOutputPort->newPortDefinition.nBufferCountActual;
+    pOutputPort->portDefinition.nBufferCountMin     = pOutputPort->newPortDefinition.nBufferCountMin;
+
+    Exynos_UpdateFrameSize(pOMXComponent);
+
+    return ret;
+}
+
 OMX_ERRORTYPE Exynos_InputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATABUFFER *dataBuffer)
 {
     OMX_ERRORTYPE          ret = OMX_ErrorNone;
index ec3eef27982c6286a6685f067fa806639b12200c..10d0a1d429421630713c3d5e475ef43f01a62375 100644 (file)
@@ -634,6 +634,8 @@ OMX_ERRORTYPE H264CodecReconfigAllBuffers(
             pBufferOps->Clear_RegisteredBuffer(hMFCHandle);
             pBufferOps->Cleanup_Buffer(hMFCHandle);
         }
+
+        Exynos_ResolutionUpdate(pOMXComponent);
     } else {
         ret = OMX_ErrorBadParameter;
         goto EXIT;
@@ -715,6 +717,10 @@ OMX_ERRORTYPE H264CodecCheckResolutionChange(OMX_COMPONENTTYPE *pOMXComponent)
     ExynosVideoDecOps             *pDecOps            = pH264Dec->hMFCH264Handle.pDecOps;
     ExynosVideoDecBufferOps       *pOutbufOps         = pH264Dec->hMFCH264Handle.pOutbufOps;
 
+    OMX_CONFIG_RECTTYPE *pCropRectangle = NULL;
+    OMX_PARAM_PORTDEFINITIONTYPE *pInputPortDefinition = NULL;
+    OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDefinition = NULL;
+
     FunctionIn();
     /* get geometry for output */
     Exynos_OSAL_Memset(&pH264Dec->hMFCH264Handle.codecOutbufConf, 0, sizeof(ExynosVideoGeometry));
@@ -732,24 +738,33 @@ OMX_ERRORTYPE H264CodecCheckResolutionChange(OMX_COMPONENTTYPE *pOMXComponent)
 
     pH264Dec->hMFCH264Handle.bConfiguredMFCSrc = OMX_TRUE;
 
-    pOutputPort->cropRectangle.nTop     = pH264Dec->hMFCH264Handle.codecOutbufConf.cropRect.nTop;
-    pOutputPort->cropRectangle.nLeft    = pH264Dec->hMFCH264Handle.codecOutbufConf.cropRect.nLeft;
-    pOutputPort->cropRectangle.nWidth   = pH264Dec->hMFCH264Handle.codecOutbufConf.cropRect.nWidth;
-    pOutputPort->cropRectangle.nHeight  = pH264Dec->hMFCH264Handle.codecOutbufConf.cropRect.nHeight;
+    if (pVideoDec->bReconfigDPB != OMX_TRUE) {
+        pCropRectangle = &(pOutputPort->cropRectangle);
+        pInputPortDefinition = &(pInputPort->portDefinition);
+        pOutputPortDefinition = &(pOutputPort->portDefinition);
+    } else {
+        pCropRectangle = &(pOutputPort->newCropRectangle);
+        pInputPortDefinition = &(pInputPort->newPortDefinition);
+        pOutputPortDefinition = &(pOutputPort->newPortDefinition);
+    }
 
-    if (pVideoDec->bReconfigDPB == OMX_TRUE)
-        pVideoDec->nSavedDPBCnt = pOutputPort->portDefinition.nBufferCountActual;
+    pCropRectangle->nTop     = pH264Dec->hMFCH264Handle.codecOutbufConf.cropRect.nTop;
+    pCropRectangle->nLeft    = pH264Dec->hMFCH264Handle.codecOutbufConf.cropRect.nLeft;
+    pCropRectangle->nWidth   = pH264Dec->hMFCH264Handle.codecOutbufConf.cropRect.nWidth;
+    pCropRectangle->nHeight  = pH264Dec->hMFCH264Handle.codecOutbufConf.cropRect.nHeight;
 
     if (pOutputPort->bufferProcessType & BUFFER_COPY) {
         if ((pVideoDec->bReconfigDPB) ||
             (pInputPort->portDefinition.format.video.nFrameWidth != pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth) ||
             (pInputPort->portDefinition.format.video.nFrameHeight != pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight)) {
-            pInputPort->portDefinition.format.video.nFrameWidth     = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth;
-            pInputPort->portDefinition.format.video.nFrameHeight    = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight;
-            pInputPort->portDefinition.format.video.nStride         = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth + 15) & (~15));
-            pInputPort->portDefinition.format.video.nSliceHeight    = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight + 15) & (~15));
-
-            Exynos_UpdateFrameSize(pOMXComponent);
+            pInputPortDefinition->format.video.nFrameWidth  = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth;
+            pInputPortDefinition->format.video.nFrameHeight = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight;
+            pInputPortDefinition->format.video.nStride      = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth + 15) & (~15));
+            pInputPortDefinition->format.video.nSliceHeight = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight + 15) & (~15));
+            pOutputPortDefinition->nBufferCountActual       = pOutputPort->portDefinition.nBufferCountActual;
+            pOutputPortDefinition->nBufferCountMin          = pOutputPort->portDefinition.nBufferCountMin;
+            if (pVideoDec->bReconfigDPB != OMX_TRUE)
+                Exynos_UpdateFrameSize(pOMXComponent);
             pOutputPort->exceptionFlag = NEED_PORT_DISABLE;
 
             /** Send Port Settings changed call back **/
@@ -766,15 +781,14 @@ OMX_ERRORTYPE H264CodecCheckResolutionChange(OMX_COMPONENTTYPE *pOMXComponent)
             (pInputPort->portDefinition.format.video.nFrameWidth != pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth) ||
             (pInputPort->portDefinition.format.video.nFrameHeight != pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight) ||
             (pOutputPort->portDefinition.nBufferCountActual != pH264Dec->hMFCH264Handle.maxDPBNum)) {
-            pInputPort->portDefinition.format.video.nFrameWidth     = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth;
-            pInputPort->portDefinition.format.video.nFrameHeight    = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight;
-            pInputPort->portDefinition.format.video.nStride         = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth + 15) & (~15));
-            pInputPort->portDefinition.format.video.nSliceHeight    = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight + 15) & (~15));
-
-            pOutputPort->portDefinition.nBufferCountActual  = pH264Dec->hMFCH264Handle.maxDPBNum - 2;
-            pOutputPort->portDefinition.nBufferCountMin     = pH264Dec->hMFCH264Handle.maxDPBNum - 2;
-
-            Exynos_UpdateFrameSize(pOMXComponent);
+            pInputPortDefinition->format.video.nFrameWidth  = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth;
+            pInputPortDefinition->format.video.nFrameHeight = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight;
+            pInputPortDefinition->format.video.nStride      = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth + 15) & (~15));
+            pInputPortDefinition->format.video.nSliceHeight = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight + 15) & (~15));
+            pOutputPortDefinition->nBufferCountActual       = pH264Dec->hMFCH264Handle.maxDPBNum;
+            pOutputPortDefinition->nBufferCountMin          = pH264Dec->hMFCH264Handle.maxDPBNum;
+            if (pVideoDec->bReconfigDPB != OMX_TRUE)
+                Exynos_UpdateFrameSize(pOMXComponent);
             pOutputPort->exceptionFlag = NEED_PORT_DISABLE;
 
             /** Send Port Settings changed call back **/
@@ -791,11 +805,12 @@ OMX_ERRORTYPE H264CodecCheckResolutionChange(OMX_COMPONENTTYPE *pOMXComponent)
         (pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth != pH264Dec->hMFCH264Handle.codecOutbufConf.cropRect.nWidth) ||
         (pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight != pH264Dec->hMFCH264Handle.codecOutbufConf.cropRect.nHeight)) {
         /* Check Crop */
-        pInputPort->portDefinition.format.video.nFrameWidth     = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth;
-        pInputPort->portDefinition.format.video.nFrameHeight    = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight;
-        pInputPort->portDefinition.format.video.nStride         = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth + 15) & (~15));
-        pInputPort->portDefinition.format.video.nSliceHeight    = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight + 15) & (~15));
-        Exynos_UpdateFrameSize(pOMXComponent);
+        pInputPortDefinition->format.video.nFrameWidth  = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth;
+        pInputPortDefinition->format.video.nFrameHeight = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight;
+        pInputPortDefinition->format.video.nStride      = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth + 15) & (~15));
+        pInputPortDefinition->format.video.nSliceHeight = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight + 15) & (~15));
+        if (pVideoDec->bReconfigDPB != OMX_TRUE)
+            Exynos_UpdateFrameSize(pOMXComponent);
 
         /** Send crop info call back **/
         (*(pExynosComponent->pCallbacks->EventHandler))
@@ -967,15 +982,18 @@ OMX_ERRORTYPE H264CodecDstSetup(OMX_COMPONENTTYPE *pOMXComponent)
 
     FunctionIn();
 
-    /* get dpb count */
-    nOutbufs = pH264Dec->hMFCH264Handle.maxDPBNum;
-
     if ((pExynosOutputPort->bufferProcessType & BUFFER_COPY) == BUFFER_COPY) {
+        /* BUFFER_COPY, get dpb count */
+        nOutbufs = pH264Dec->hMFCH264Handle.maxDPBNum;
+
         /* should be done before prepare output buffer */
         if (pOutbufOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE) {
             ret = OMX_ErrorInsufficientResources;
             goto EXIT;
         }
+    } else {
+        /*BUFFER_SHERE case, get dpb count */
+        nOutbufs = pExynosOutputPort->portDefinition.nBufferCountActual;
     }
     if (pOutbufOps->Enable_DynamicDPB(hMFCHandle) != VIDEO_ERROR_NONE) {
         ret = OMX_ErrorUndefined;
index d72a7d2ad6af831d080d11c2efcfe8b4f45290c5..bae0f2f8a89beb43e6b1bff5b0c2533a3f53864e 100644 (file)
@@ -885,8 +885,6 @@ OMX_ERRORTYPE Mpeg4CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DA
     pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum = pDecOps->Get_ActualBufferCount(hMFCHandle);
     if (pVideoDec->bThumbnailMode == OMX_FALSE)
         pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum += EXTRA_DPB_NUM;
-    else
-        pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum += PLATFORM_DISPLAY_BUFFER;
     Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Mpeg4CodecSetup nOutbufs: %d", pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum);
 
     pMpeg4Dec->hMFCMpeg4Handle.bConfiguredMFCSrc = OMX_TRUE;
@@ -920,8 +918,8 @@ OMX_ERRORTYPE Mpeg4CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DA
             pExynosInputPort->portDefinition.format.video.nStride = ((pMpeg4Dec->hMFCMpeg4Handle.codecOutbufConf.nFrameWidth + 15) & (~15));
             pExynosInputPort->portDefinition.format.video.nSliceHeight = ((pMpeg4Dec->hMFCMpeg4Handle.codecOutbufConf.nFrameHeight + 15) & (~15));
 
-            pExynosOutputPort->portDefinition.nBufferCountActual = pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum - PLATFORM_DISPLAY_BUFFER;
-            pExynosOutputPort->portDefinition.nBufferCountMin = pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum - PLATFORM_DISPLAY_BUFFER;
+            pExynosOutputPort->portDefinition.nBufferCountActual = pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum;
+            pExynosOutputPort->portDefinition.nBufferCountMin = pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum;
 
             Exynos_UpdateFrameSize(pOMXComponent);
             pExynosOutputPort->exceptionFlag = NEED_PORT_DISABLE;
@@ -964,16 +962,20 @@ OMX_ERRORTYPE Mpeg4CodecDstSetup(OMX_COMPONENTTYPE *pOMXComponent)
 
     FunctionIn();
 
-    /* get dpb count */
-    nOutbufs = pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum;
-
     if ((pExynosOutputPort->bufferProcessType & BUFFER_COPY) == BUFFER_COPY) {
+        /* BUFFER_COPY case, get dpb count */
+        nOutbufs = pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum;
+
         /* should be done before prepare output buffer */
         if (pOutbufOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE) {
             ret = OMX_ErrorInsufficientResources;
             goto EXIT;
         }
+    } else {
+        /*BUFFER_SHERE case, get dpb count */
+        nOutbufs = pExynosOutputPort->portDefinition.nBufferCountActual;
     }
+
     if (pOutbufOps->Enable_DynamicDPB(hMFCHandle) != VIDEO_ERROR_NONE) {
         ret = OMX_ErrorUndefined;
         goto EXIT;
index 746799c45c0b1cde3a7ce9fd733fcdd1a358884a..e2980bbaec65d3239fbd4e1e9e539f43092a4158 100644 (file)
@@ -696,8 +696,6 @@ OMX_ERRORTYPE VP8CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA
     pVp8Dec->hMFCVp8Handle.maxDPBNum = pDecOps->Get_ActualBufferCount(hMFCHandle);
     if (pVideoDec->bThumbnailMode == OMX_FALSE)
         pVp8Dec->hMFCVp8Handle.maxDPBNum += EXTRA_DPB_NUM;
-    else
-        pVp8Dec->hMFCVp8Handle.maxDPBNum += PLATFORM_DISPLAY_BUFFER;
     Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Vp8CodecSetup nOutbufs: %d", pVp8Dec->hMFCVp8Handle.maxDPBNum);
 
     pVp8Dec->hMFCVp8Handle.bConfiguredMFCSrc = OMX_TRUE;
@@ -731,8 +729,8 @@ OMX_ERRORTYPE VP8CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA
             pExynosInputPort->portDefinition.format.video.nStride = ((pVp8Dec->hMFCVp8Handle.codecOutbufConf.nFrameWidth + 15) & (~15));
             pExynosInputPort->portDefinition.format.video.nSliceHeight = ((pVp8Dec->hMFCVp8Handle.codecOutbufConf.nFrameHeight + 15) & (~15));
 
-            pExynosOutputPort->portDefinition.nBufferCountActual = pVp8Dec->hMFCVp8Handle.maxDPBNum - PLATFORM_DISPLAY_BUFFER;
-            pExynosOutputPort->portDefinition.nBufferCountMin = pVp8Dec->hMFCVp8Handle.maxDPBNum - PLATFORM_DISPLAY_BUFFER;
+            pExynosOutputPort->portDefinition.nBufferCountActual = pVp8Dec->hMFCVp8Handle.maxDPBNum;
+            pExynosOutputPort->portDefinition.nBufferCountMin = pVp8Dec->hMFCVp8Handle.maxDPBNum;
 
             Exynos_UpdateFrameSize(pOMXComponent);
             pExynosOutputPort->exceptionFlag = NEED_PORT_DISABLE;
@@ -775,15 +773,18 @@ OMX_ERRORTYPE VP8CodecDstSetup(OMX_COMPONENTTYPE *pOMXComponent)
 
     FunctionIn();
 
-    /* get dpb count */
-    nOutbufs = pVp8Dec->hMFCVp8Handle.maxDPBNum;
-
     if ((pExynosOutputPort->bufferProcessType & BUFFER_COPY) == BUFFER_COPY) {
+        /* BUFFER_COPY case, get dpb count */
+        nOutbufs = pVp8Dec->hMFCVp8Handle.maxDPBNum;
+
         /* should be done before prepare output buffer */
         if (pOutbufOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE) {
             ret = OMX_ErrorInsufficientResources;
             goto EXIT;
         }
+    } else {
+        /*BUFFER_SHERE case, get dpb count */
+        nOutbufs = pExynosOutputPort->portDefinition.nBufferCountActual;
     }
     if (pOutbufOps->Enable_DynamicDPB(hMFCHandle) != VIDEO_ERROR_NONE) {
         ret = OMX_ErrorUndefined;