diff options
author | Alistair Strachan <alistair.strachan@imgtec.com> | 2016-06-02 20:55:24 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-06-02 20:55:24 +0000 |
commit | adf9dbc532d9370ded04c9225daa14afe7a342ce (patch) | |
tree | 7b299f689b2df2e7633c2d34e31ed900fe169778 | |
parent | d495ffce9eb40b09a3c82191bbb39056f010181a (diff) | |
parent | 3caaacf958abb55445a5c4c12e668bbd95f7e871 (diff) | |
download | omx-components-adf9dbc532d9370ded04c9225daa14afe7a342ce.tar.gz |
Introduce independent hstride and vstride, and use them. am: 7caaf88cf4 am: a6001c6555
am: 3caaacf958
* commit '3caaacf958abb55445a5c4c12e668bbd95f7e871':
Introduce independent hstride and vstride, and use them.
Change-Id: I14dbb8b4dab3b33e6c4489608da8ba1cda0e7d35
-rwxr-xr-x | videocodec/Android.mk | 2 | ||||
-rwxr-xr-x | videocodec/OMXVideoDecoderBase.cpp | 14 | ||||
-rwxr-xr-x | videocodec/OMXVideoDecoderBase.h | 3 | ||||
-rw-r--r-- | videocodec/OMXVideoDecoderVP9HWR.cpp | 19 | ||||
-rw-r--r-- | videocodec/OMXVideoDecoderVP9Hybrid.cpp | 74 |
5 files changed, 66 insertions, 46 deletions
diff --git a/videocodec/Android.mk b/videocodec/Android.mk index 07fbc2a..2c5a9ef 100755 --- a/videocodec/Android.mk +++ b/videocodec/Android.mk @@ -228,6 +228,8 @@ LOCAL_C_INCLUDES := \ ifeq ($(TARGET_BOARD_PLATFORM),baytrail) LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/ufo +else + LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/pvr/hal endif LOCAL_SRC_FILES := \ diff --git a/videocodec/OMXVideoDecoderBase.cpp b/videocodec/OMXVideoDecoderBase.cpp index 97ea7ca..31c6a48 100755 --- a/videocodec/OMXVideoDecoderBase.cpp +++ b/videocodec/OMXVideoDecoderBase.cpp @@ -499,9 +499,10 @@ OMX_ERRORTYPE OMXVideoDecoderBase::PrepareConfigBuffer(VideoConfigBuffer *p) { mOMXBufferHeaderTypePtrNum = 0; mGraphicBufferParam.graphicBufferColorFormat = def_output->format.video.eColorFormat; - mGraphicBufferParam.graphicBufferStride = getStride(def_output->format.video.nFrameWidth); + mGraphicBufferParam.graphicBufferHStride = getStride(def_output->format.video.nFrameWidth); + mGraphicBufferParam.graphicBufferVStride = (def_output->format.video.nFrameHeight + 0x1f) & ~0x1f; mGraphicBufferParam.graphicBufferWidth = def_output->format.video.nFrameWidth; - mGraphicBufferParam.graphicBufferHeight = (def_output->format.video.nFrameHeight + 0xf) & ~0xf; + mGraphicBufferParam.graphicBufferHeight = def_output->format.video.nFrameHeight; p->surfaceNumber = mMetaDataBuffersNum; for (int i = 0; i < MAX_GRAPHIC_BUFFER_NUM; i++) { @@ -517,10 +518,11 @@ OMX_ERRORTYPE OMXVideoDecoderBase::PrepareConfigBuffer(VideoConfigBuffer *p) { } } p->flag |= USE_NATIVE_GRAPHIC_BUFFER; - p->graphicBufferStride = mGraphicBufferParam.graphicBufferStride; - p->graphicBufferColorFormat = mGraphicBufferParam.graphicBufferColorFormat; + p->graphicBufferHStride = mGraphicBufferParam.graphicBufferHStride; + p->graphicBufferVStride = mGraphicBufferParam.graphicBufferVStride; p->graphicBufferWidth = mGraphicBufferParam.graphicBufferWidth; p->graphicBufferHeight = mGraphicBufferParam.graphicBufferHeight; + p->graphicBufferColorFormat = mGraphicBufferParam.graphicBufferColorFormat; if (p->graphicBufferColorFormat == OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar_Tiled #ifdef USE_GEN_HW || p->graphicBufferColorFormat == HAL_PIXEL_FORMAT_NV12_X_TILED_INTEL @@ -1031,7 +1033,9 @@ OMX_ERRORTYPE OMXVideoDecoderBase::SetNativeBuffer(OMX_PTR pStructure) { if (mOMXBufferHeaderTypePtrNum == 1) { mGraphicBufferParam.graphicBufferColorFormat = param->nativeBuffer->format; - mGraphicBufferParam.graphicBufferStride = param->nativeBuffer->stride; + mGraphicBufferParam.graphicBufferHStride = param->nativeBuffer->stride; + // FIXME: use IMG_native_handle_t->aiVStride[0] instead.. + mGraphicBufferParam.graphicBufferVStride = param->nativeBuffer->height; mGraphicBufferParam.graphicBufferWidth = param->nativeBuffer->width; mGraphicBufferParam.graphicBufferHeight = param->nativeBuffer->height; } diff --git a/videocodec/OMXVideoDecoderBase.h b/videocodec/OMXVideoDecoderBase.h index a9b2cdf..2cd60ad 100755 --- a/videocodec/OMXVideoDecoderBase.h +++ b/videocodec/OMXVideoDecoderBase.h @@ -105,7 +105,8 @@ private: }; struct GraphicBufferParam { - uint32_t graphicBufferStride; + uint32_t graphicBufferHStride; + uint32_t graphicBufferVStride; uint32_t graphicBufferWidth; uint32_t graphicBufferHeight; uint32_t graphicBufferColorFormat; diff --git a/videocodec/OMXVideoDecoderVP9HWR.cpp b/videocodec/OMXVideoDecoderVP9HWR.cpp index 4482c37..684993d 100644 --- a/videocodec/OMXVideoDecoderVP9HWR.cpp +++ b/videocodec/OMXVideoDecoderVP9HWR.cpp @@ -256,11 +256,12 @@ OMX_ERRORTYPE OMXVideoDecoderVP9HWR::ProcessorInit(void) int surfaceWidth = mGraphicBufferParam.graphicBufferWidth; int surfaceHeight = mGraphicBufferParam.graphicBufferHeight; - int surfaceStride = mGraphicBufferParam.graphicBufferStride; - extNativeBufferSize = mGraphicBufferParam.graphicBufferStride * - mGraphicBufferParam.graphicBufferHeight * 1.5; - extActualBufferStride = surfaceStride; - extActualBufferHeightStride = surfaceHeight; + int surfaceHStride = mGraphicBufferParam.graphicBufferHStride; + int surfaceVStride = mGraphicBufferParam.graphicBufferVStride; + extNativeBufferSize = mGraphicBufferParam.graphicBufferHStride * + mGraphicBufferParam.graphicBufferVStride * 1.5; + extActualBufferStride = surfaceHStride; + extActualBufferHeightStride = surfaceVStride; for (i = 0; i < mOMXBufferHeaderTypePtrNum; i++) { OMX_BUFFERHEADERTYPE *buf_hdr = mOMXBufferHeaderTypePtrArray[i]; @@ -280,14 +281,14 @@ OMX_ERRORTYPE OMXVideoDecoderVP9HWR::ProcessorInit(void) surfExtBuf->pixel_format = VA_FOURCC_NV12; surfExtBuf->width = surfaceWidth; surfExtBuf->height = surfaceHeight; - surfExtBuf->data_size = surfaceStride * surfaceHeight * 1.5; + surfExtBuf->data_size = surfaceHStride * surfaceVStride * 1.5; surfExtBuf->num_planes = 2; - surfExtBuf->pitches[0] = surfaceStride; - surfExtBuf->pitches[1] = surfaceStride; + surfExtBuf->pitches[0] = surfaceHStride; + surfExtBuf->pitches[1] = surfaceHStride; surfExtBuf->pitches[2] = 0; surfExtBuf->pitches[3] = 0; surfExtBuf->offsets[0] = 0; - surfExtBuf->offsets[1] = surfaceStride * surfaceHeight; + surfExtBuf->offsets[1] = surfaceHStride * surfaceVStride; surfExtBuf->offsets[2] = 0; surfExtBuf->offsets[3] = 0; surfExtBuf->flags = VA_SURFACE_ATTRIB_MEM_TYPE_ANDROID_GRALLOC; diff --git a/videocodec/OMXVideoDecoderVP9Hybrid.cpp b/videocodec/OMXVideoDecoderVP9Hybrid.cpp index 1360ca2..f6211f7 100644 --- a/videocodec/OMXVideoDecoderVP9Hybrid.cpp +++ b/videocodec/OMXVideoDecoderVP9Hybrid.cpp @@ -25,6 +25,8 @@ #include <hardware/gralloc.h> #include <system/graphics.h> +#include <hal_public.h> + #define VP9_YV12_ALIGN (128-1) static const char* VP9_MIME_TYPE = "video/x-vnd.on2.vp9"; @@ -70,12 +72,12 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorInit(void) { uint32_t buff[MAX_GRAPHIC_BUFFER_NUM]; uint32_t i, bufferCount; bool gralloc_mode = (mWorkingMode == GRAPHICBUFFER_MODE); - uint32_t bufferSize, bufferStride, bufferHeight, bufferWidth; + uint32_t bufferSize, bufferHStride, bufferVStride, bufferWidth; if (!gralloc_mode) { - bufferSize = 1920 * 1088 * 1.5; - bufferStride = 1920; + bufferHStride = 1920; + bufferVStride = 1088; bufferWidth = 1920; - bufferHeight = 1088; + //bufferHeight = 1080; bufferCount = 12; } else { if (mAPMode == METADATA_MODE) { @@ -87,9 +89,10 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorInit(void) { mOMXBufferHeaderTypePtrNum = 0; mGraphicBufferParam.graphicBufferColorFormat = def_output->format.video.eColorFormat; - mGraphicBufferParam.graphicBufferStride = (def_output->format.video.nFrameWidth + VP9_YV12_ALIGN) & ~VP9_YV12_ALIGN; + mGraphicBufferParam.graphicBufferHStride = (def_output->format.video.nFrameWidth + VP9_YV12_ALIGN) & ~VP9_YV12_ALIGN; + mGraphicBufferParam.graphicBufferVStride = (def_output->format.video.nFrameHeight + 0x1f) & ~0x1f; mGraphicBufferParam.graphicBufferWidth = def_output->format.video.nFrameWidth; - mGraphicBufferParam.graphicBufferHeight = (def_output->format.video.nFrameHeight + 0x1f) & ~0x1f; + mGraphicBufferParam.graphicBufferHeight = def_output->format.video.nFrameHeight; mDecodedImageWidth = def_output->format.video.nFrameWidth; mDecodedImageHeight = def_output->format.video.nFrameHeight; } else{ @@ -101,12 +104,14 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorInit(void) { } } - bufferSize = mGraphicBufferParam.graphicBufferStride * - mGraphicBufferParam.graphicBufferHeight * 1.5; - bufferStride = mGraphicBufferParam.graphicBufferStride; - bufferHeight = mGraphicBufferParam.graphicBufferHeight; + bufferHStride = mGraphicBufferParam.graphicBufferHStride; + bufferVStride = mGraphicBufferParam.graphicBufferVStride; bufferWidth = mGraphicBufferParam.graphicBufferWidth; + //bufferHeight = mGraphicBufferParam.graphicBufferHeight; } + + bufferSize = bufferHStride * bufferVStride * 1.5; + mLibHandle = dlopen("libDecoderVP9Hybrid.so", RTLD_NOW); if (mLibHandle == NULL) { LOGE("dlopen libDecoderVP9Hybrid.so fail\n"); @@ -137,7 +142,11 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorInit(void) { return OMX_ErrorBadParameter; } - mInitDecoder(mHybridCtx,bufferSize,bufferStride,bufferWidth, bufferHeight,bufferCount,gralloc_mode, buff, (uint32_t)mAPMode); + // FIXME: The proprietary part of the vp9hybrid decoder should be updated + // to take VStride as well as Height. For now it's convenient to + // use VStride as that was effectively what was done before.. + mInitDecoder(mHybridCtx, bufferSize, bufferHStride, bufferWidth, + bufferVStride, bufferCount, gralloc_mode, buff, (uint32_t)mAPMode); return OMX_ErrorNone; } @@ -146,12 +155,13 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorReset(void) uint32_t buff[MAX_GRAPHIC_BUFFER_NUM]; uint32_t i, bufferCount; bool gralloc_mode = (mWorkingMode == GRAPHICBUFFER_MODE); - uint32_t bufferSize, bufferStride, bufferHeight, bufferWidth; + uint32_t bufferSize, bufferHStride, bufferVStride, bufferWidth; if (!gralloc_mode) { - bufferSize = mDecodedImageWidth * mDecodedImageHeight * 1.5; - bufferStride = mDecodedImageWidth; + bufferHStride = mDecodedImageWidth; + bufferVStride = mDecodedImageHeight; bufferWidth = mDecodedImageWidth; - bufferHeight = mDecodedImageHeight; + //bufferHeight = mDecodedImageHeight; + bufferSize = bufferHStride * bufferVStride * 1.5; bufferCount = 12; } else { if (mAPMode == METADATA_MODE) { @@ -163,9 +173,10 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorReset(void) mOMXBufferHeaderTypePtrNum = 0; mGraphicBufferParam.graphicBufferColorFormat = def_output->format.video.eColorFormat; - mGraphicBufferParam.graphicBufferStride = (def_output->format.video.nFrameWidth + VP9_YV12_ALIGN) & ~VP9_YV12_ALIGN; + mGraphicBufferParam.graphicBufferHStride = (def_output->format.video.nFrameWidth + VP9_YV12_ALIGN) & ~VP9_YV12_ALIGN; + mGraphicBufferParam.graphicBufferVStride = (def_output->format.video.nFrameHeight + 0x1f) & ~0x1f; mGraphicBufferParam.graphicBufferWidth = def_output->format.video.nFrameWidth; - mGraphicBufferParam.graphicBufferHeight = (def_output->format.video.nFrameHeight + 0x1f) & ~0x1f; + mGraphicBufferParam.graphicBufferHeight = def_output->format.video.nFrameHeight; } else{ bufferCount = mOMXBufferHeaderTypePtrNum; @@ -174,14 +185,19 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorReset(void) buff[i] = (uint32_t)(buf_hdr->pBuffer); } } - bufferSize = mGraphicBufferParam.graphicBufferStride * - mGraphicBufferParam.graphicBufferHeight * 1.5; - bufferStride = mGraphicBufferParam.graphicBufferStride; - bufferHeight = mGraphicBufferParam.graphicBufferHeight; + bufferHStride = mGraphicBufferParam.graphicBufferHStride; + bufferVStride = mGraphicBufferParam.graphicBufferVStride; bufferWidth = mGraphicBufferParam.graphicBufferWidth; + //bufferHeight = mGraphicBufferParam.graphicBufferHeight; } - mInitDecoder(mHybridCtx,bufferSize,bufferStride,bufferWidth,bufferHeight,bufferCount,gralloc_mode, buff, (uint32_t)mAPMode); + bufferSize = bufferHStride * bufferVStride * 1.5; + + // FIXME: The proprietary part of the vp9hybrid decoder should be updated + // to take VStride as well as Height. For now it's convenient to + // use VStride as that was effectively what was done before.. + mInitDecoder(mHybridCtx, bufferSize, bufferHStride, bufferWidth, + bufferVStride, bufferCount, gralloc_mode, buff, (uint32_t)mAPMode); mFormatChanged = false; return OMX_ErrorNone; } @@ -475,7 +491,7 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::SetParamVideoVp9(OMX_PTR) { OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::HandleFormatChange(void) { - ALOGI("handle format change from %dx%d to %dx%d", + ALOGE("handle format change from %dx%d to %dx%d", mDecodedImageWidth,mDecodedImageHeight,mDecodedImageNewWidth,mDecodedImageNewHeight); mDecodedImageWidth = mDecodedImageNewWidth; mDecodedImageHeight = mDecodedImageNewHeight; @@ -540,10 +556,7 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::HandleFormatChange(void) // for graphic buffer reallocation // when the width and height parsed from ES are larger than allocated graphic buffer in outport, paramPortDefinitionOutput.format.video.nFrameWidth = width; - if (mAPMode == METADATA_MODE) - paramPortDefinitionOutput.format.video.nFrameHeight = (height + 0x1f) & ~0x1f; - else - paramPortDefinitionOutput.format.video.nFrameHeight = (height + 0x1f) & ~0x1f; + paramPortDefinitionOutput.format.video.nFrameHeight = height; paramPortDefinitionOutput.format.video.eColorFormat = GetOutputColorFormat( paramPortDefinitionOutput.format.video.nFrameWidth); paramPortDefinitionOutput.format.video.nStride = stride; @@ -566,8 +579,8 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::HandleFormatChange(void) OMX_COLOR_FORMATTYPE OMXVideoDecoderVP9Hybrid::GetOutputColorFormat(int) { - LOGV("Output color format is HAL_PIXEL_FORMAT_YV12."); - return (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_YV12; + LOGV("Output color format is HAL_PIXEL_FORMAT_INTEL_YV12."); + return (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_INTEL_YV12; } OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::GetDecoderOutputCropSpecific(OMX_PTR pStructure) { @@ -628,10 +641,9 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::SetNativeBufferModeSpecific(OMX_PTR pStr port_def.format.video.cMIMEType = (OMX_STRING)VA_VED_RAW_MIME_TYPE; // add borders for libvpx decode need. port_def.format.video.nFrameWidth += VPX_DECODE_BORDER * 2; + port_def.format.video.nFrameHeight += VPX_DECODE_BORDER * 2; mDecodedImageWidth = port_def.format.video.nFrameWidth; mDecodedImageHeight = port_def.format.video.nFrameHeight; - // make heigth 32bit align - port_def.format.video.nFrameHeight = (port_def.format.video.nFrameHeight + 0x1f) & ~0x1f; port_def.format.video.eColorFormat = GetOutputColorFormat(port_def.format.video.nFrameWidth); port->SetPortDefinition(&port_def,true); |