vdec: changed buffer count related with MAX DPB
[GitHub/LineageOS/android_hardware_samsung_slsi_openmax.git] / component / video / dec / vc1 / Exynos_OMX_Wmvdec.c
index 2a3c158d54c487561c60b564aadcbc214fd2ecbb..3491a8d8fff4ac5b314a875ee9823fbf22676517 100644 (file)
@@ -1006,9 +1006,6 @@ OMX_ERRORTYPE WmvCodecDstSetup(OMX_COMPONENTTYPE *pOMXComponent)
 
     FunctionIn();
 
-    /* get dpb count */
-    nOutbufs = pWmvDec->hMFCWmvHandle.maxDPBNum;
-
     if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
         /* should be done before prepare output buffer */
         if (pOutbufOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE) {
@@ -1018,11 +1015,6 @@ OMX_ERRORTYPE WmvCodecDstSetup(OMX_COMPONENTTYPE *pOMXComponent)
     }
 
     pOutbufOps->Set_Shareable(hMFCHandle);
-    if (pOutbufOps->Setup(hMFCHandle, nOutbufs) != VIDEO_ERROR_NONE) {
-        Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup output buffer");
-        ret = OMX_ErrorInsufficientResources;
-        goto EXIT;
-    }
 
     ExynosVideoPlane planes[MFC_OUTPUT_BUFFER_PLANE];
     OMX_U32 nAllocLen[MFC_OUTPUT_BUFFER_PLANE] = {0, 0};
@@ -1033,6 +1025,14 @@ OMX_ERRORTYPE WmvCodecDstSetup(OMX_COMPONENTTYPE *pOMXComponent)
     nAllocLen[1] = pWmvDec->hMFCWmvHandle.codecOutbufConf.nAlignPlaneSize[1];
 
     if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
+        /* get dpb count */
+        nOutbufs = pWmvDec->hMFCWmvHandle.maxDPBNum;
+        if (pOutbufOps->Setup(hMFCHandle, nOutbufs) != VIDEO_ERROR_NONE) {
+            Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup output buffer");
+            ret = OMX_ErrorInsufficientResources;
+            goto EXIT;
+        }
+
         ret = Exynos_Allocate_CodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX, nOutbufs, nAllocLen);
         if (ret != OMX_ErrorNone)
             goto EXIT;
@@ -1047,6 +1047,14 @@ OMX_ERRORTYPE WmvCodecDstSetup(OMX_COMPONENTTYPE *pOMXComponent)
                             (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL);
         }
     } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) {
+        /* get dpb count */
+        nOutbufs = pExynosOutputPort->portDefinition.nBufferCountActual;
+        if (pOutbufOps->Setup(hMFCHandle, nOutbufs) != VIDEO_ERROR_NONE) {
+            Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup output buffer");
+            ret = OMX_ErrorInsufficientResources;
+            goto EXIT;
+        }
+
         /* Register output buffer */
         /*************/
         /*    TBD    */