video_dec: Add ThumbnailMode decoding to h264
authorSeungBeom Kim <sbcrux.kim@samsung.com>
Sun, 29 Mar 2015 11:30:08 +0000 (13:30 +0200)
committerGerrit Code Review <gerrit@cyanogenmod.org>
Tue, 31 Mar 2015 17:19:13 +0000 (17:19 +0000)
Extension name:
 - EXYNOS_INDEX_PARAM_ENABLE_THUMBNAIL "OMX.SEC.index.enableThumbnailMode"

Backported-from: hardware/samsung_slsi/exynos5

Change-Id: I630cfa54de361dccfde1f8b56e7b8ba2f534654f
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
component/video/dec/Exynos_OMX_Vdec.h
component/video/dec/Exynos_OMX_VdecControl.c
component/video/dec/h264/Exynos_OMX_H264dec.c
component/video/dec/mpeg4/Exynos_OMX_Mpeg4dec.c
component/video/dec/vp8/Exynos_OMX_Vp8dec.c
include/exynos/Exynos_OMX_Def.h

index b4fb164b0ef3401a7c636a5f3a80701bd9dd67b8..7e05fbf2fb9d4a743bef764d5c9720ec742f14cb 100644 (file)
@@ -65,6 +65,8 @@
 
 #define MAX_INPUTBUFFER_NUM_DYNAMIC         0 /* Dynamic number of metadata buffer */
 
+#define PLATFORM_DISPLAY_BUFFER             2
+
 typedef struct
 {
     void *pAddrY;
index 4357ae8bea10b769b93000e9878f5c4bee28c771..90e3214b96032532147a66f5df68da978bccf440 100644 (file)
@@ -1342,6 +1342,26 @@ OMX_ERRORTYPE Exynos_OMX_VideoDecodeSetParameter(
         pVideoDec->bDTSMode = pDTSParam->bDTSMode;
     }
         break;
+    case OMX_IndexParamEnableThumbnailMode:
+    {
+        EXYNOS_OMX_VIDEO_THUMBNAILMODE *pThumbnailMode = (EXYNOS_OMX_VIDEO_THUMBNAILMODE *)ComponentParameterStructure;
+        EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
+
+        ret = Exynos_OMX_Check_SizeVersion(pThumbnailMode, sizeof(EXYNOS_OMX_VIDEO_THUMBNAILMODE));
+        if (ret != OMX_ErrorNone) {
+            goto EXIT;
+        }
+
+        pVideoDec->bThumbnailMode = pThumbnailMode->bEnable;
+        if (pVideoDec->bThumbnailMode == OMX_TRUE) {
+            EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
+            pExynosOutputPort->portDefinition.nBufferCountMin = 1;
+            pExynosOutputPort->portDefinition.nBufferCountActual = 1;
+        }
+
+        ret = OMX_ErrorNone;
+    }
+        break;
     default:
     {
         ret = Exynos_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure);
@@ -1448,14 +1468,6 @@ OMX_ERRORTYPE Exynos_OMX_VideoDecodeSetConfig(
     }
 
     switch (nIndex) {
-    case OMX_IndexVendorThumbnailMode:
-    {
-        EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
-        pVideoDec->bThumbnailMode = *((OMX_BOOL *)pComponentConfigStructure);
-
-        ret = OMX_ErrorNone;
-    }
-        break;
 #ifdef USE_QOS_CTRL
     case OMX_IndexVendorSetQosRatio:
     {
@@ -1542,18 +1554,27 @@ OMX_ERRORTYPE Exynos_OMX_VideoDecodeGetExtensionIndex(
 #endif
 
 #ifdef USE_ANB
-    if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_ENABLE_ANB) == 0)
+    if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_ENABLE_ANB) == 0) {
         *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamEnableAndroidBuffers;
-    else if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_GET_ANB) == 0)
+        goto EXIT;
+    }
+    if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_GET_ANB) == 0) {
         *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamGetAndroidNativeBuffer;
-    else if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_USE_ANB) == 0)
+        goto EXIT;
+    }
+    if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_USE_ANB) == 0) {
         *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamUseAndroidNativeBuffer;
-    else
-        ret = Exynos_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
-#else
-    ret = Exynos_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
+        goto EXIT;
+    }
 #endif
 
+    if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_ENABLE_THUMBNAIL) == 0) {
+        *pIndexType = OMX_IndexParamEnableThumbnailMode;
+        goto EXIT;
+    }
+
+    ret = Exynos_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
+
 EXIT:
     FunctionOut();
 
index 3d99689e7812880586586e006e6afd0d6a33a0e5..1b42a88fc3435cb0ccbf00f802b331f8a0d3a1a1 100644 (file)
@@ -787,8 +787,11 @@ OMX_ERRORTYPE H264CodecCheckResolutionChange(OMX_COMPONENTTYPE *pOMXComponent)
 
     /* get dpb count */
     pH264Dec->hMFCH264Handle.maxDPBNum = pDecOps->Get_ActualBufferCount(hMFCHandle);
-    if (pVideoDec->bThumbnailMode == OMX_FALSE)
+    if (pVideoDec->bThumbnailMode == OMX_FALSE) {
         pH264Dec->hMFCH264Handle.maxDPBNum += EXTRA_DPB_NUM;
+    } else {
+        pH264Dec->hMFCH264Handle.maxDPBNum += PLATFORM_DISPLAY_BUFFER;
+    }
     Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "H264CodecSetup nOutbufs: %d", pH264Dec->hMFCH264Handle.maxDPBNum);
 
     pH264Dec->hMFCH264Handle.bConfiguredMFCSrc = OMX_TRUE;
@@ -835,8 +838,8 @@ OMX_ERRORTYPE H264CodecCheckResolutionChange(OMX_COMPONENTTYPE *pOMXComponent)
             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;
+            pOutputPort->portDefinition.nBufferCountActual  = pH264Dec->hMFCH264Handle.maxDPBNum - PLATFORM_DISPLAY_BUFFER;
+            pOutputPort->portDefinition.nBufferCountMin     = pH264Dec->hMFCH264Handle.maxDPBNum - PLATFORM_DISPLAY_BUFFER;
 
             Exynos_UpdateFrameSize(pOMXComponent);
 
@@ -914,8 +917,9 @@ OMX_ERRORTYPE H264CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DAT
         goto EXIT;
     }
 
-    if (pVideoDec->bThumbnailMode == OMX_TRUE)
-        pDecOps->Set_DisplayDelay(hMFCHandle, 0);
+    if (pVideoDec->bThumbnailMode == OMX_TRUE) {
+        pDecOps->Set_IFrameDecoding(hMFCHandle);
+    }
 
     if ((pDecOps->Enable_DTSMode != NULL) &&
         (pVideoDec->bDTSMode == OMX_TRUE))
@@ -1612,20 +1616,15 @@ OMX_ERRORTYPE Exynos_H264Dec_GetExtensionIndex(
         goto EXIT;
     }
 
-    if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_ENABLE_THUMBNAIL) == 0) {
-        EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
-        *pIndexType = OMX_IndexVendorThumbnailMode;
-        ret = OMX_ErrorNone;
-    }
 #ifdef USE_S3D_SUPPORT
-    else if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_GET_S3D) == 0) {
+    if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_GET_S3D) == 0) {
         *pIndexType = OMX_IndexVendorS3DMode;
         ret = OMX_ErrorNone;
+        goto EXIT;
     }
 #endif
-    else {
-        ret = Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent, cParameterName, pIndexType);
-    }
+
+    ret = Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent, cParameterName, pIndexType);
 
 EXIT:
     FunctionOut();
index d81b2e52368fcdc05b3e7ab053aa915fde57be72..342f01fbb86637e5d624c5db5fc5add652c0a4f6 100644 (file)
@@ -787,8 +787,9 @@ OMX_ERRORTYPE Mpeg4CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DA
         goto EXIT;
     }
 
-    if (pVideoDec->bThumbnailMode == OMX_TRUE)
-        pDecOps->Set_DisplayDelay(hMFCHandle, 0);
+    if (pVideoDec->bThumbnailMode == OMX_TRUE) {
+        pDecOps->Set_IFrameDecoding(hMFCHandle);
+    }
 
     if ((pDecOps->Enable_DTSMode != NULL) &&
         (pVideoDec->bDTSMode == OMX_TRUE))
@@ -910,8 +911,11 @@ OMX_ERRORTYPE Mpeg4CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DA
 
     /* get dpb count */
     pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum = pDecOps->Get_ActualBufferCount(hMFCHandle);
-    if (pVideoDec->bThumbnailMode == OMX_FALSE)
+    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;
@@ -1580,13 +1584,7 @@ OMX_ERRORTYPE Exynos_Mpeg4Dec_GetExtensionIndex(
         goto EXIT;
     }
 
-    if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_ENABLE_THUMBNAIL) == 0) {
-        EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
-        *pIndexType = OMX_IndexVendorThumbnailMode;
-        ret = OMX_ErrorNone;
-    } else {
-        ret = Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent, cParameterName, pIndexType);
-    }
+    ret = Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent, cParameterName, pIndexType);
 
 EXIT:
     FunctionOut();
index 21d4177480181cd3decdb54c98ff2ab107553c64..7f659815234eefaa5c5a222238bccc9cf9ef72fe 100644 (file)
@@ -602,8 +602,9 @@ OMX_ERRORTYPE VP8CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA
         goto EXIT;
     }
 
-    if (pVideoDec->bThumbnailMode == OMX_TRUE)
-        pDecOps->Set_DisplayDelay(hMFCHandle, 0);
+    if (pVideoDec->bThumbnailMode == OMX_TRUE) {
+        pDecOps->Set_IFrameDecoding(hMFCHandle);
+    }
 
     if ((pDecOps->Enable_DTSMode != NULL) &&
         (pVideoDec->bDTSMode == OMX_TRUE))
@@ -721,8 +722,11 @@ OMX_ERRORTYPE VP8CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA
 
     /* get dpb count */
     pVp8Dec->hMFCVp8Handle.maxDPBNum = pDecOps->Get_ActualBufferCount(hMFCHandle);
-    if (pVideoDec->bThumbnailMode == OMX_FALSE)
+    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;
@@ -759,8 +763,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 - 2;
-            pExynosOutputPort->portDefinition.nBufferCountMin = pVp8Dec->hMFCVp8Handle.maxDPBNum - 2;
+            pExynosOutputPort->portDefinition.nBufferCountActual = pVp8Dec->hMFCVp8Handle.maxDPBNum - PLATFORM_DISPLAY_BUFFER;
+            pExynosOutputPort->portDefinition.nBufferCountMin = pVp8Dec->hMFCVp8Handle.maxDPBNum - PLATFORM_DISPLAY_BUFFER;
 
             Exynos_UpdateFrameSize(pOMXComponent);
 
@@ -1190,13 +1194,7 @@ OMX_ERRORTYPE Exynos_VP8Dec_GetExtensionIndex(
         goto EXIT;
     }
 
-    if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_ENABLE_THUMBNAIL) == 0) {
-        EXYNOS_VP8DEC_HANDLE *pVp8Dec = (EXYNOS_VP8DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
-        *pIndexType = OMX_IndexVendorThumbnailMode;
-        ret = OMX_ErrorNone;
-    } else {
-        ret = Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent, cParameterName, pIndexType);
-    }
+    ret = Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent, cParameterName, pIndexType);
 
 EXIT:
     FunctionOut();
index 46b2741a4a29a5742bcf4c7b9133d14289287037..6fa28a13d64f93042d0a5e4d43f86f9729e356df 100644 (file)
@@ -147,8 +147,8 @@ typedef struct OMX_VIDEO_VP8REFERENCEFRAMEINFOTYPE {
 
 typedef enum _EXYNOS_OMX_INDEXTYPE
 {
-#define EXYNOS_INDEX_PARAM_ENABLE_THUMBNAIL "OMX.SEC.index.ThumbnailMode"
-    OMX_IndexVendorThumbnailMode            = 0x7F000001,
+#define EXYNOS_INDEX_PARAM_ENABLE_THUMBNAIL "OMX.SEC.index.enableThumbnailMode"
+    OMX_IndexParamEnableThumbnailMode       = 0x7F000001,
 #define EXYNOS_INDEX_CONFIG_VIDEO_INTRAPERIOD "OMX.SEC.index.VideoIntraPeriod"
     OMX_IndexConfigVideoIntraPeriod         = 0x7F000002,
 #ifdef USE_S3D_SUPPORT
@@ -265,6 +265,13 @@ typedef struct _EXYNOS_OMX_VIDEO_PROFILELEVEL
     OMX_S32  level;
 } EXYNOS_OMX_VIDEO_PROFILELEVEL;
 
+typedef struct _EXYNOS_OMX_VIDEO_THUMBNAILMODE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_BOOL bEnable;
+} EXYNOS_OMX_VIDEO_THUMBNAILMODE;
+
 #ifdef USE_S3D_SUPPORT
 typedef enum _EXYNOS_OMX_FPARGMT_TYPE
 {