From 2feaa394227991f4e0a81ba808dba6ec70cc2264 Mon Sep 17 00:00:00 2001 From: PacketVideo CM Date: Wed, 7 Oct 2009 22:45:39 -0700 Subject: [PATCH] RIO-7648: Improve OMX Dec BufferSize Negotiation during PortReConfig for non-multiple of 16 clip (RV and WMV) --- .../omx/omx_baseclass/include/pv_omxcomponent.h | 3 +- .../omx/omx_baseclass/src/pv_omxcomponent.cpp | 98 +++++++++++----------- .../src/pv_video_config_parser.cpp | 34 +------- engines/2way/src/pv_2way_sdkinfo.h | 2 +- engines/author/src/pv_author_sdkinfo.h | 2 +- engines/player/src/pv_player_sdkinfo.h | 2 +- 6 files changed, 59 insertions(+), 82 deletions(-) diff --git a/codecs_v2/omx/omx_baseclass/include/pv_omxcomponent.h b/codecs_v2/omx/omx_baseclass/include/pv_omxcomponent.h index b7c6f55b..ec55bafc 100644 --- a/codecs_v2/omx/omx_baseclass/include/pv_omxcomponent.h +++ b/codecs_v2/omx/omx_baseclass/include/pv_omxcomponent.h @@ -549,6 +549,7 @@ class OmxComponentBase : public OsclActiveObject OSCL_IMPORT_REF void Run(); + OMX_CALLBACKTYPE* ipCallbacks; OMX_PTR iCallbackData; OMX_STATETYPE iState; @@ -673,7 +674,7 @@ class OmxComponentVideo : public OmxComponentBase OMX_IN OMX_INDEXTYPE nParamIndex, OMX_IN OMX_PTR ComponentParameterStructure); - + OSCL_IMPORT_REF virtual void CalculateBufferParameters(OMX_U32 PortIndex); }; diff --git a/codecs_v2/omx/omx_baseclass/src/pv_omxcomponent.cpp b/codecs_v2/omx/omx_baseclass/src/pv_omxcomponent.cpp index 2ca72e26..d5a05029 100644 --- a/codecs_v2/omx/omx_baseclass/src/pv_omxcomponent.cpp +++ b/codecs_v2/omx/omx_baseclass/src/pv_omxcomponent.cpp @@ -4516,53 +4516,8 @@ OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentVideo::SetParameter( OMX_VIDEO_PORTDEFINITIONTYPE *videoformat = &(ipPorts[PortIndex]->PortParam.format.video); if (videoformat->eCompressionFormat == OMX_VIDEO_CodingUnused) { - // check if stride needs to be adjusted - stride should be at least the 16 byte aligned width - // WMV is special case that requires 4 bytes alignment - - OMX_U32 min_stride = ((videoformat->nFrameWidth + 15) & (~15)); - OMX_U32 min_sliceheight = ((videoformat->nFrameHeight + 15) & (~15)); - - if (oscl_strcmp("video/wmv", videoformat->cMIMEType) == 0) - { - min_stride = ((videoformat->nFrameWidth + 3) & (~3)); - min_sliceheight = ((videoformat->nFrameHeight + 1) & (~1)); - } - - - videoformat->nStride = min_stride; - videoformat->nSliceHeight = min_sliceheight; - - - // finally, compute the new minimum buffer size. - - // Encoder components can have different formats - (rely on the client to provide the correct size) - if (OMX_PORT_OUTPUTPORT_INDEX == PortIndex) - { - // Decoder components always output YUV420 format - ipPorts[PortIndex]->PortParam.nBufferSize = (videoformat->nSliceHeight * videoformat->nStride * 3) >> 1; - - } - - if (OMX_PORT_INPUTPORT_INDEX == PortIndex) - { - // Encoder components may have different formats - if (videoformat->eColorFormat == OMX_COLOR_Format24bitRGB888) - { - ipPorts[PortIndex]->PortParam.nBufferSize = videoformat->nSliceHeight * videoformat->nStride * 3; - } - else if (videoformat->eColorFormat == OMX_COLOR_Format12bitRGB444) - { - ipPorts[PortIndex]->PortParam.nBufferSize = videoformat->nSliceHeight * videoformat->nStride * 2; - - } - else if (videoformat->eColorFormat == OMX_COLOR_FormatYUV420Planar) - { - ipPorts[PortIndex]->PortParam.nBufferSize = (videoformat->nSliceHeight * videoformat->nStride * 3) >> 1; - - } - - } - + // call components to calculate nStride, nSliceHeight and nBufferSize of videoformat. + CalculateBufferParameters(PortIndex); } } @@ -4737,6 +4692,55 @@ OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentVideo::SetParameter( return ErrorType; } + +// This virtual function can be overwritten by component according to the buffer requirement. + +OSCL_EXPORT_REF void OmxComponentVideo::CalculateBufferParameters(OMX_U32 PortIndex) +{ + OMX_VIDEO_PORTDEFINITIONTYPE *videoformat = &(ipPorts[PortIndex]->PortParam.format.video); + + // check if stride needs to be adjusted - stride should be at least the 16 byte aligned width + OMX_U32 min_stride = ((videoformat->nFrameWidth + 15) & (~15)); + OMX_U32 min_sliceheight = ((videoformat->nFrameHeight + 15) & (~15)); + + + videoformat->nStride = min_stride; + videoformat->nSliceHeight = min_sliceheight; + + + // finally, compute the new minimum buffer size. + + // Encoder components can have different formats - (rely on the client to provide the correct size) + if (OMX_PORT_OUTPUTPORT_INDEX == PortIndex) + { + // Decoder components always output YUV420 format + ipPorts[PortIndex]->PortParam.nBufferSize = (videoformat->nSliceHeight * videoformat->nStride * 3) >> 1; + + } + + if (OMX_PORT_INPUTPORT_INDEX == PortIndex) + { + // Encoder components may have different formats + if (videoformat->eColorFormat == OMX_COLOR_Format24bitRGB888) + { + ipPorts[PortIndex]->PortParam.nBufferSize = videoformat->nSliceHeight * videoformat->nStride * 3; + } + else if (videoformat->eColorFormat == OMX_COLOR_Format12bitRGB444) + { + ipPorts[PortIndex]->PortParam.nBufferSize = videoformat->nSliceHeight * videoformat->nStride * 2; + + } + else if (videoformat->eColorFormat == OMX_COLOR_FormatYUV420Planar) + { + ipPorts[PortIndex]->PortParam.nBufferSize = (videoformat->nSliceHeight * videoformat->nStride * 3) >> 1; + + } + + } + + return ; +} + #if PROXY_INTERFACE /** Component entry points declarations with proxy interface*/ diff --git a/codecs_v2/utilities/pv_config_parser/src/pv_video_config_parser.cpp b/codecs_v2/utilities/pv_config_parser/src/pv_video_config_parser.cpp index aa261c98..077ced57 100644 --- a/codecs_v2/utilities/pv_config_parser/src/pv_video_config_parser.cpp +++ b/codecs_v2/utilities/pv_config_parser/src/pv_video_config_parser.cpp @@ -70,21 +70,7 @@ enum { NOT_WMV3 = -1, WMV3_SIMPLE_PROFILE, WMV3_MAIN_PROFILE, WMV3_PC_PROFILE, W #define SC_SEQ 0x0F #define SC_ENTRY 0x0E -//For Real Video Decoder -#define GetUnalignedWordRv( pb, w ) \ - (w) = ((uint16) *(pb) << 8) + *(pb+1); - -#define GetUnalignedDwordRv( pb, dw ) \ - (dw) = ((uint32) *(pb + 3)) + \ - ((uint32) *(pb + 2) << 8) + \ - ((uint32) *(pb + 1) << 16) + ((uint32) (*pb) << 24); - -#define GetUnalignedWordExRv( pb, w ) GetUnalignedWordRv( pb, w ); (pb) += sizeof(uint16); -#define GetUnalignedDwordExRv( pb, dw ) GetUnalignedDwordRv( pb, dw ); (pb) += sizeof(uint32); - -#define LoadWORDRv( w, p ) GetUnalignedWordExRv( p, w ) -#define LoadDWORDRv( dw, p ) GetUnalignedDwordExRv( p, dw ) OSCL_DLL_ENTRY_POINT_DEFAULT() @@ -371,23 +357,9 @@ OSCL_EXPORT_REF int16 pv_video_config_parser(pvVideoConfigParserInputs *aInputs, } else if (aInputs->iMimeType == PVMF_MIME_REAL_VIDEO) //rv { - uint32 dwdat; - uint16 wdat; - - uint8 *pData = aInputs->inPtr; - - // Init frame contains: HX_FORMAT_VIDEO + extra_data= 26 bytes + 4(SPO) + 4(stream_version) + RPRsizeinfo (variable) - - // HX_FORMAT_VIDEO - LoadDWORDRv(dwdat, pData); - LoadDWORDRv(dwdat, pData); - LoadDWORDRv(dwdat, pData); - LoadWORDRv(wdat, pData); - aOutputs->width = (int32) wdat; // size of data below - - LoadWORDRv(wdat, pData); - aOutputs->height = (int32) wdat; - + // use this as default value, let decoder discover the actual size and perform port reconfig + aOutputs->width = 128; + aOutputs->height = 96; aOutputs->profile = 0; aOutputs->level = 0; } diff --git a/engines/2way/src/pv_2way_sdkinfo.h b/engines/2way/src/pv_2way_sdkinfo.h index 1d584582..d3b753c8 100644 --- a/engines/2way/src/pv_2way_sdkinfo.h +++ b/engines/2way/src/pv_2way_sdkinfo.h @@ -21,7 +21,7 @@ // This header file is automatically generated at build-time // *** OFFICIAL RELEASE INFO -- Will not auto update -#define PV2WAY_ENGINE_SDKINFO_LABEL "997505" +#define PV2WAY_ENGINE_SDKINFO_LABEL "997976" #define PV2WAY_ENGINE_SDKINFO_DATE 0x20091002 #endif //PV_2WAY_SDKINFO_H_INCLUDED diff --git a/engines/author/src/pv_author_sdkinfo.h b/engines/author/src/pv_author_sdkinfo.h index d1ffbc3a..1ab22af8 100644 --- a/engines/author/src/pv_author_sdkinfo.h +++ b/engines/author/src/pv_author_sdkinfo.h @@ -21,7 +21,7 @@ // This header file is automatically generated at build-time // *** OFFICIAL RELEASE INFO -- Will not auto update -#define PVAUTHOR_ENGINE_SDKINFO_LABEL "997505" +#define PVAUTHOR_ENGINE_SDKINFO_LABEL "997976" #define PVAUTHOR_ENGINE_SDKINFO_DATE 0x20091002 #endif //PV_AUTHOR_SDKINFO_H_INCLUDED diff --git a/engines/player/src/pv_player_sdkinfo.h b/engines/player/src/pv_player_sdkinfo.h index 0c8894ba..b5226dad 100644 --- a/engines/player/src/pv_player_sdkinfo.h +++ b/engines/player/src/pv_player_sdkinfo.h @@ -21,7 +21,7 @@ // This header file is automatically generated at build-time // *** OFFICIAL RELEASE INFO -- Will not auto update -#define PVPLAYER_ENGINE_SDKINFO_LABEL "997505" +#define PVPLAYER_ENGINE_SDKINFO_LABEL "997976" #define PVPLAYER_ENGINE_SDKINFO_DATE 0x20091002 #endif //PV_PLAYER_SDKINFO_H_INCLUDED -- 2.11.0