exynos_omx: multi_thread: Fix bug for video encode tests.

If the output buffer that has been entered is invalid,
OMX component may experience problems in Flush operation.
This patch performs the following actions.
If invalid output buffer has been entered in the codec setup process, OMX Component will return an error.

Bug: 17785600
Bug: 17811083
Change-Id: Ida0939fae2b7102ab87d5242c8c71e732aba10a2
Signed-off-by: SeungBeom Kim <sbcrux.kim@samsung.com>
diff --git a/exynos_omx/openmax/exynos_omx/component/video/enc/h264/Exynos_OMX_H264enc.c b/exynos_omx/openmax/exynos_omx/component/video/enc/h264/Exynos_OMX_H264enc.c
index ee60500..518ed7c 100644
--- a/exynos_omx/openmax/exynos_omx/component/video/enc/h264/Exynos_OMX_H264enc.c
+++ b/exynos_omx/openmax/exynos_omx/component/video/enc/h264/Exynos_OMX_H264enc.c
@@ -1008,6 +1008,7 @@
         /*************/
         /*    TBD    */
         /*************/
+        ExynosVideoErrorType codecReturn = VIDEO_ERROR_NONE;
         ExynosVideoPlane plane;
         for (i = 0; i < pExynosOutputPort->portDefinition.nBufferCountActual; i++) {
             plane.addr = pExynosOutputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer;
@@ -1018,8 +1019,13 @@
                 ret = OMX_ErrorInsufficientResources;
                 goto EXIT;
             }
-            pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)&pExynosOutputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer,
+            codecReturn = pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)&pExynosOutputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer,
                                    (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL);
+            if (codecReturn != VIDEO_ERROR_NONE) {
+                Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Output buffer that has been entered is invalid.");
+                ret = OMX_ErrorUndefined;
+                goto EXIT;
+            }
         }
     }
 
@@ -1735,6 +1741,9 @@
     }
     if (pH264Enc->hMFCH264Handle.bConfiguredMFCDst == OMX_FALSE) {
         ret = H264CodecDstSetup(pOMXComponent);
+        if (ret != OMX_ErrorNone) {
+            goto EXIT;
+        }
     }
 
     if (pVideoEnc->configChange == OMX_TRUE) {
diff --git a/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c b/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c
index e915304..98480f8 100644
--- a/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c
+++ b/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c
@@ -1136,10 +1136,11 @@
                                 (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL);
         }
     } else if ((pExynosOutputPort->bufferProcessType & BUFFER_SHARE) == BUFFER_SHARE) {
-        /* Register input buffer */
+        /* Register output buffer */
         /*************/
         /*    TBD    */
         /*************/
+        ExynosVideoErrorType codecReturn = VIDEO_ERROR_NONE;
         ExynosVideoPlane plane;
         for (i = 0; i < pExynosOutputPort->portDefinition.nBufferCountActual; i++) {
             plane.addr = pExynosOutputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer;
@@ -1150,8 +1151,13 @@
                 ret = OMX_ErrorInsufficientResources;
                 goto EXIT;
             }
-            pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)&pExynosOutputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer,
+            codecReturn = pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)&pExynosOutputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer,
                                    (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL);
+            if (codecReturn != VIDEO_ERROR_NONE) {
+                Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Output buffer that has been entered is invalid.");
+                ret = OMX_ErrorUndefined;
+                goto EXIT;
+            }
         }
     }
 
@@ -1933,6 +1939,9 @@
     }
     if (pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFCDst == OMX_FALSE) {
         ret = Mpeg4CodecDstSetup(pOMXComponent);
+        if (ret != OMX_ErrorNone) {
+            goto EXIT;
+        }
     }
 
     if (pVideoEnc->configChange == OMX_TRUE) {