diff options
author | Sunita Nadampalli <sunitan@ti.com> | 2011-10-24 09:39:54 -0500 |
---|---|---|
committer | Sunita Nadampalli <sunitan@ti.com> | 2011-10-24 09:39:54 -0500 |
commit | 342147cf2ff8cbbd9face26c6e8e839c5fc2af73 (patch) | |
tree | e1cf2034141105fddbd1fbb793b490749a10c16f | |
parent | 55df4303a845466104fbb9dc62e429578db8087b (diff) | |
download | hardware_ti_omap4-342147cf2ff8cbbd9face26c6e8e839c5fc2af73.zip hardware_ti_omap4-342147cf2ff8cbbd9face26c6e8e839c5fc2af73.tar.gz hardware_ti_omap4-342147cf2ff8cbbd9face26c6e8e839c5fc2af73.tar.bz2 |
OMX_proxy: Add support for VC-1 video format
After installation of the parser, it's require to handle the
information received from the initial frame and send it
to codec according to the requirement.
Change-Id: If1dd6eb82a2ce403f9062d659d824b76079d5605
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>
-rwxr-xr-x | omx_core/src/OMX_Core.c | 3 | ||||
-rw-r--r-- | omx_proxy_component/Android.mk | 4 | ||||
-rwxr-xr-x | omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c | 4 | ||||
-rwxr-xr-x | omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_utils.c | 197 |
4 files changed, 207 insertions, 1 deletions
diff --git a/omx_core/src/OMX_Core.c b/omx_core/src/OMX_Core.c index d76ca17..be6e323 100755 --- a/omx_core/src/OMX_Core.c +++ b/omx_core/src/OMX_Core.c @@ -94,6 +94,9 @@ char *tComponentName[MAXCOMP][MAX_ROLES] = { {"OMX.TI.DUCATI1.VIDEO.VP7D", "video_decoder.vp7", NULL}, {"OMX.TI.DUCATI1.IMAGE.JPEGD", "jpeg_decoder.jpeg", NULL}, {"OMX.TI.DUCATI1.VIDEO.CAMERA", "camera.omx", NULL}, + {"OMX.ITTIAM.WMA.decode", "audio_decoder.wma", NULL}, + {"OMX.ITTIAM.WMALSL.decode", "audio_decoder.wmalsl", NULL}, + {"OMX.ITTIAM.WMAPRO.decode", "audio_decoder.wmapro", NULL}, /* terminate the table */ {NULL, NULL}, }; diff --git a/omx_proxy_component/Android.mk b/omx_proxy_component/Android.mk index e747773..8c3e459 100644 --- a/omx_proxy_component/Android.mk +++ b/omx_proxy_component/Android.mk @@ -27,7 +27,9 @@ LOCAL_CFLAGS += -D_Android -DSET_STRIDE_PADDING_FROM_PROXY -DANDROID_QUIRK_CHANG LOCAL_CFLAGS += -DANDROID_QUIRK_LOCK_BUFFER -DUSE_ION -DENABLE_GRALLOC_BUFFERS LOCAL_MODULE_TAGS:= optional -LOCAL_SRC_FILES:= omx_video_dec/src/omx_proxy_videodec.c +LOCAL_SRC_FILES:= omx_video_dec/src/omx_proxy_videodec.c \ + omx_video_dec/src/omx_proxy_videodec_utils.c + LOCAL_MODULE:= libOMX.TI.DUCATI1.VIDEO.DECODER include $(BUILD_HEAPTRACKED_SHARED_LIBRARY) diff --git a/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c b/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c index 572592b..c733cec 100755 --- a/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c +++ b/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c @@ -116,6 +116,8 @@ OMX_ERRORTYPE PROXY_VIDDEC_FillBufferDone(OMX_HANDLETYPE hComponent, OMX_PTR pMarkData); #endif +extern OMX_ERRORTYPE PrearrageEmptyThisBuffer(OMX_HANDLETYPE hComponent, + OMX_BUFFERHEADERTYPE * pBufferHdr); OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) { @@ -231,6 +233,8 @@ OMX_ERRORTYPE OMX_ProxyViddecInit(OMX_HANDLETYPE hComponent) PROXY_assert(eError == OMX_ErrorNone, eError," Error in Proxy SetParameter for Enhanced port reconfig usage"); #endif + /* This is required to handle WMV/VC-1 content */ + pHandle->EmptyThisBuffer = PrearrageEmptyThisBuffer; EXIT: if (eError != OMX_ErrorNone) diff --git a/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_utils.c b/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_utils.c new file mode 100755 index 0000000..33f092d --- /dev/null +++ b/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_utils.c @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2010, Texas Instruments Incorporated + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/*============================================================== + *! Revision History + *! ============================ + *! 21-Oct-2011 Rajesh vandanapu sarthav@ti.com: Initial Version + *================================================================*/ + +/****************************************************************** + * INCLUDE FILES + ******************************************************************/ +#include <stdio.h> +#include <string.h> +#include <assert.h> +#include "omx_proxy_common.h" +#include <timm_osal_interfaces.h> +#include "OMX_TI_IVCommon.h" +#include "OMX_TI_Video.h" +#include "OMX_TI_Index.h" + +#define COMPONENT_NAME "OMX.TI.DUCATI1.VIDEO.DECODER" +/* needs to be specific for every configuration wrapper */ + +/* DEFINITIONS for parsing the config information & sequence header for WMV*/ +#define VIDDEC_GetUnalignedDword( pb, dw ) \ + (dw) = ((OMX_U32) *(pb + 3) << 24) + \ + ((OMX_U32) *(pb + 2) << 16) + \ + ((OMX_U16) *(pb + 1) << 8) + *pb; + +#define VIDDEC_GetUnalignedDwordEx( pb, dw ) VIDDEC_GetUnalignedDword( pb, dw ); (pb) += sizeof(OMX_U32); +#define VIDDEC_LoadDWORD( dw, p ) VIDDEC_GetUnalignedDwordEx( p, dw ) +#define VIDDEC_MAKEFOURCC(ch0, ch1, ch2, ch3) \ + ((OMX_U32)(OMX_U8)(ch0) | ((OMX_U32)(OMX_U8)(ch1) << 8) | \ + ((OMX_U32)(OMX_U8)(ch2) << 16) | ((OMX_U32)(OMX_U8)(ch3) << 24 )) + +#define VIDDEC_FOURCC(ch0, ch1, ch2, ch3) VIDDEC_MAKEFOURCC(ch0, ch1, ch2, ch3) + +#define FOURCC_WMV3 VIDDEC_FOURCC('W','M','V','3') +#define FOURCC_WMV2 VIDDEC_FOURCC('W','M','V','2') +#define FOURCC_WMV1 VIDDEC_FOURCC('W','M','V','1') +#define FOURCC_WVC1 VIDDEC_FOURCC('W','V','C','1') + +#define CSD_POSITION 51 /*Codec Specific Data position on the "stream propierties object"(ASF spec)*/ + +typedef struct VIDDEC_WMV_RCV_struct { + OMX_U32 nNumFrames : 24; + OMX_U32 nFrameType : 8; + OMX_U32 nID : 32; + OMX_U32 nStructData : 32; //STRUCT_C + OMX_U32 nVertSize; //STRUCT_A-1 + OMX_U32 nHorizSize; //STRUCT_A-2 + OMX_U32 nID2 : 32; + OMX_U32 nSequenceHdr : 32; //STRUCT_B +} VIDDEC_WMV_RCV_struct; + +typedef struct VIDDEC_WMV_VC1_struct { + OMX_U32 nNumFrames : 24; + OMX_U32 nFrameType : 8; + OMX_U32 nID : 32; + OMX_U32 nStructData : 32; //STRUCT_C + OMX_U32 nVertSize; //STRUCT_A-1 + OMX_U32 nHorizSize; //STRUCT_A-2 + OMX_U32 nID2 : 32; + OMX_U32 nSequenceHdr : 32; //STRUCT_B +} VIDDEC_WMV_VC1_struct; + + +OMX_ERRORTYPE PrearrageEmptyThisBuffer(OMX_HANDLETYPE hComponent, + OMX_BUFFERHEADERTYPE * pBufferHdr) +{ + OMX_ERRORTYPE eError = OMX_ErrorNone; + PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; + OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; + OMX_U8* pBuffer = NULL; + OMX_U8* pData = NULL; + OMX_U32 nValue = 0; + OMX_U32 nWidth = 0; + OMX_U32 nHeight = 0; + OMX_U32 nActualCompression = 0; + OMX_U8* pCSD = NULL; + OMX_U32 nSize_CSD = 0; + DOMX_ENTER(""); + + PROXY_assert(pBufferHdr != NULL, OMX_ErrorBadParameter, NULL); + + if (pBufferHdr->nFlags & OMX_BUFFERFLAG_CODECCONFIG){ + PROXY_assert(hComp->pComponentPrivate != NULL, OMX_ErrorBadParameter, NULL); + + pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; + /* Get component role */ + OMX_PARAM_COMPONENTROLETYPE compRole; + compRole.nSize = sizeof(OMX_PARAM_COMPONENTROLETYPE); + compRole.nVersion.s.nVersionMajor = 1; + compRole.nVersion.s.nVersionMinor = 1; //Ducati OMX version + compRole.nVersion.s.nRevision = 0; + compRole.nVersion.s.nStep = 0; + + eError = PROXY_GetParameter(hComp, OMX_IndexParamStandardComponentRole, &compRole); + if(eError != OMX_ErrorNone){ + DOMX_ERROR("Error getting OMX_IndexParamStandardComponentRole"); + } + + if(!strcmp(compRole.cRole, "video_decoder.wmv")){ + pBuffer = pBufferHdr->pBuffer; + + VIDDEC_WMV_RCV_struct sStructRCV; + + DOMX_DEBUG("nFlags: %x", pBufferHdr->nFlags); + + pData = pBufferHdr->pBuffer + 15; /*Position to Width & Height*/ + VIDDEC_LoadDWORD(nValue, pData); + nWidth = nValue; + VIDDEC_LoadDWORD(nValue, pData); + nHeight = nValue; + + pData += 4; /*Position to compression type*/ + VIDDEC_LoadDWORD(nValue, pData); + nActualCompression = nValue; + + /*Seting pCSD to proper position*/ + pCSD = pBufferHdr->pBuffer; + pCSD += CSD_POSITION; + nSize_CSD = pBufferHdr->nFilledLen - CSD_POSITION; + + if(nActualCompression == FOURCC_WMV3){ + + //From VC-1 spec: Table 265: Sequence Layer Data Structure + sStructRCV.nNumFrames = 0xFFFFFF; /*Infinite frame number*/ + sStructRCV.nFrameType = 0xc5; /*0x85 is the value given by ASF to rcv converter*/ + sStructRCV.nID = 0x04; /*WMV3*/ + sStructRCV.nStructData = 0x018a3106; /*0x06318a01zero fill 0x018a3106*/ + sStructRCV.nVertSize = nHeight; + sStructRCV.nHorizSize = nWidth; + sStructRCV.nID2 = 0x0c; /* Fix value */ + sStructRCV.nSequenceHdr = 0x00002a9f; /* This value is not provided by parser, so giving a value from a video*/ + + DOMX_DEBUG("initial: nStructData: %x", sStructRCV.nStructData); + DOMX_DEBUG("pCSD = %x", (OMX_U32)*pCSD); + + sStructRCV.nStructData = (OMX_U32)pCSD[0] << 0 | + pCSD[1] << 8 | + pCSD[2] << 16 | + pCSD[3] << 24; + + DOMX_DEBUG("FINAL: nStructData: %x", sStructRCV.nStructData); + + //Copy RCV structure to actual buffer + assert(pBufferHdr->nFilledLen < pBufferHdr->nAllocLen); + pBufferHdr->nFilledLen = sizeof(VIDDEC_WMV_RCV_struct); + TIMM_OSAL_Memcpy(pBufferHdr->pBuffer, (OMX_U8*)(&sStructRCV), + pBufferHdr->nFilledLen); + + } + else if (nActualCompression == FOURCC_WVC1){ + DOMX_DEBUG("VC-1 Advance Profile prearrange"); + pBufferHdr->nOffset = pBufferHdr->nOffset+52; + pBufferHdr->nFilledLen= pBufferHdr->nFilledLen-52; + } + } + } + + EXIT: + DOMX_EXIT("eError: %d", eError); + + return PROXY_EmptyThisBuffer(hComponent, pBufferHdr); +} + |