omx: move csc (de)initialization to common venc

Change-Id: I495816ec592ecebdcceae760b1c1e90c26b223da
Signed-off-by: Greg Hackmann <ghackmann@google.com>
diff --git a/exynos_omx/openmax/exynos_omx/component/video/enc/Exynos_OMX_Venc.c b/exynos_omx/openmax/exynos_omx/component/video/enc/Exynos_OMX_Venc.c
index 82ef205..3537228 100644
--- a/exynos_omx/openmax/exynos_omx/component/video/enc/Exynos_OMX_Venc.c
+++ b/exynos_omx/openmax/exynos_omx/component/video/enc/Exynos_OMX_Venc.c
@@ -1091,6 +1091,8 @@
     EXYNOS_OMX_BASEPORT           *pExynosPort = NULL;
     EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
 
+    CSC_METHOD csc_method = CSC_METHOD_SW;
+
     FunctionIn();
 
     if (hComponent == NULL) {
@@ -1139,6 +1141,19 @@
     pVideoEnc->quantization.nQpP = 5; // P frame quantization parameter
     pVideoEnc->quantization.nQpB = 5; // B frame quantization parameter
 
+#if 0//defined(USE_CSC_GSCALER)
+    csc_method = CSC_METHOD_HW; //in case of Use ION buffer.
+#endif
+    pVideoEnc->csc_handle = csc_init(csc_method);
+    if (pVideoEnc->csc_handle == NULL) {
+        Exynos_OSAL_Free(pVideoEnc);
+        Exynos_OMX_BaseComponent_Destructor(pOMXComponent);
+        ret = OMX_ErrorInsufficientResources;
+        Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+        goto EXIT;
+    }
+    pVideoEnc->csc_set_format = OMX_FALSE;
+
     pExynosComponent->bMultiThreadProcess = OMX_TRUE;
 
     /* Input port */
@@ -1235,6 +1250,11 @@
 
     pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
 
+    if (pVideoEnc->csc_handle != NULL) {
+        csc_deinit(pVideoEnc->csc_handle);
+        pVideoEnc->csc_handle = NULL;
+    }
+
     Exynos_OSAL_Free(pVideoEnc);
     pExynosComponent->hComponentHandle = pVideoEnc = NULL;
 
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 6b4bc8b..0806f03 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
@@ -1533,7 +1533,6 @@
     ExynosVideoEncBufferOps *pInbufOps  = NULL;
     ExynosVideoEncBufferOps *pOutbufOps = NULL;
 
-    CSC_METHOD csc_method = CSC_METHOD_SW;
     int i = 0;
 
     FunctionIn();
@@ -1632,16 +1631,6 @@
 
     pExynosComponent->getAllDelayBuffer = OMX_FALSE;
 
-#if 0//defined(USE_CSC_GSCALER)
-    csc_method = CSC_METHOD_HW; //in case of Use ION buffer.
-#endif
-    pVideoEnc->csc_handle = csc_init(csc_method);
-    if (pVideoEnc->csc_handle == NULL) {
-        ret = OMX_ErrorInsufficientResources;
-        goto EXIT;
-    }
-    pVideoEnc->csc_set_format = OMX_FALSE;
-
 EXIT:
     FunctionOut();
 
@@ -1667,11 +1656,6 @@
 
     FunctionIn();
 
-    if (pVideoEnc->csc_handle != NULL) {
-        csc_deinit(pVideoEnc->csc_handle);
-        pVideoEnc->csc_handle = NULL;
-    }
-
     Exynos_OSAL_SignalTerminate(pH264Enc->hDestinationStartEvent);
     pH264Enc->hDestinationStartEvent = NULL;
     pH264Enc->bDestinationStart = OMX_FALSE;
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 b98db5b..c6bafc4 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
@@ -1749,7 +1749,6 @@
     ExynosVideoEncBufferOps *pInbufOps  = NULL;
     ExynosVideoEncBufferOps *pOutbufOps = NULL;
 
-    CSC_METHOD csc_method = CSC_METHOD_SW;
     int i = 0;
 
     FunctionIn();
@@ -1848,16 +1847,6 @@
 
     pExynosComponent->getAllDelayBuffer = OMX_FALSE;
 
-#if 0//defined(USE_CSC_GSCALER)
-    csc_method = CSC_METHOD_HW; //in case of Use ION buffer.
-#endif
-    pVideoEnc->csc_handle = csc_init(csc_method);
-    if (pVideoEnc->csc_handle == NULL) {
-        ret = OMX_ErrorInsufficientResources;
-        goto EXIT;
-    }
-    pVideoEnc->csc_set_format = OMX_FALSE;
-
 EXIT:
     FunctionOut();
 
@@ -1883,11 +1872,6 @@
 
     FunctionIn();
 
-    if (pVideoEnc->csc_handle != NULL) {
-        csc_deinit(pVideoEnc->csc_handle);
-        pVideoEnc->csc_handle = NULL;
-    }
-
     Exynos_OSAL_SignalTerminate(pMpeg4Enc->hDestinationStartEvent);
     pMpeg4Enc->hDestinationStartEvent = NULL;
     pMpeg4Enc->bDestinationStart = OMX_FALSE;