From 8d627f768e040970dbdf96007ea5c595a11f2989 Mon Sep 17 00:00:00 2001 From: Austin Hu Date: Wed, 6 Apr 2016 17:25:02 +0800 Subject: Workaround: don't align video output frame height with 32 lines. Need to check why the output frame info can be set correctly later. Bug: 27688967 Change-Id: I60f9776a86791c1d1a2bdb225e3576f62d21bbf8 Signed-off-by: Austin Hu --- videocodec/OMXVideoDecoderBase.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/videocodec/OMXVideoDecoderBase.cpp b/videocodec/OMXVideoDecoderBase.cpp index f3071cc..265f285 100755 --- a/videocodec/OMXVideoDecoderBase.cpp +++ b/videocodec/OMXVideoDecoderBase.cpp @@ -778,7 +778,7 @@ OMX_ERRORTYPE OMXVideoDecoderBase::HandleFormatChange(void) { paramPortDefinitionInput.format.video.nSliceHeight = sliceHeight; // output port paramPortDefinitionOutput.format.video.nFrameWidth = width; - 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; paramPortDefinitionOutput.format.video.nSliceHeight = sliceHeight; @@ -1084,7 +1084,8 @@ OMX_ERRORTYPE OMXVideoDecoderBase::SetNativeBufferModeSpecific(OMX_PTR pStructur } port_def.format.video.cMIMEType = (OMX_STRING)VA_VED_RAW_MIME_TYPE; port_def.format.video.eColorFormat = OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar; - port_def.format.video.nFrameHeight = (port_def.format.video.nFrameHeight + 0x1f) & ~0x1f; + port_def.format.video.nFrameHeight = port_def.format.video.nFrameHeight; + port_def.format.video.eColorFormat = GetOutputColorFormat( port_def.format.video.nFrameWidth); port->SetPortDefinition(&port_def,true); -- cgit v1.2.3 From 5b4825a93743c9531ee8e82c089d374d1325ebd6 Mon Sep 17 00:00:00 2001 From: Hyunchang Choi Date: Mon, 25 Apr 2016 06:53:38 -0700 Subject: Fixed the Netflix crash issue with SIGSEGV Added buffer handling for multiple concurrent sessions bug: 28215724 Change-Id: I7f12b26358237fb6a80d560734fd0d259716d5c0 Signed-off-by: Hyunchang Choi --- videocodec/securevideo/moorefield/OMXVideoDecoderAVCSecure.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/videocodec/securevideo/moorefield/OMXVideoDecoderAVCSecure.cpp b/videocodec/securevideo/moorefield/OMXVideoDecoderAVCSecure.cpp index c8abdfd..7ec2d48 100755 --- a/videocodec/securevideo/moorefield/OMXVideoDecoderAVCSecure.cpp +++ b/videocodec/securevideo/moorefield/OMXVideoDecoderAVCSecure.cpp @@ -619,7 +619,8 @@ OMX_U8* OMXVideoDecoderAVCSecure::MemAllocDataBuffer(OMX_U32 nSizeBytes) { return NULL; } native->data[1] = (int) pBuffer; - native->data[2] = 0; + // Use a random value as the buffer id + native->data[2] = rand(); ++mNumInportBuffers; Init_ProtectedDataBuffer(pBuffer); -- cgit v1.2.3 From 461a367c262ea27c2f7b3b83f6effe80f0fcf3b3 Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Thu, 5 May 2016 05:46:49 +0800 Subject: Change crop for h264 to fix cts bug:27589011 bug:IMINAN-49451 Change-Id: I0d649f62128fbe109427e3ada2a2abcaff48b54d Signed-off-by: Xin Wang --- videocodec/OMXVideoDecoderBase.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/videocodec/OMXVideoDecoderBase.cpp b/videocodec/OMXVideoDecoderBase.cpp index b12fd97..97ea7ca 100755 --- a/videocodec/OMXVideoDecoderBase.cpp +++ b/videocodec/OMXVideoDecoderBase.cpp @@ -757,6 +757,10 @@ OMX_ERRORTYPE OMXVideoDecoderBase::HandleFormatChange(void) { uint32_t widthCropped = formatInfo->width - formatInfo->cropLeft - formatInfo->cropRight; uint32_t heightCropped = formatInfo->height - formatInfo->cropTop - formatInfo->cropBottom; + if (strcasecmp(formatInfo->mimeType,"video/avc") == 0 || + strcasecmp(formatInfo->mimeType,"video/h264") == 0) { + heightCropped = formatInfo->height; + } uint32_t strideCropped = widthCropped; uint32_t sliceHeightCropped = heightCropped; int force_realloc = 0; @@ -1178,8 +1182,12 @@ OMX_ERRORTYPE OMXVideoDecoderBase::GetDecoderOutputCropSpecific(OMX_PTR pStructu if (formatInfo->valid == true) { rectParams->nLeft = formatInfo->cropLeft; rectParams->nTop = formatInfo->cropTop; - rectParams->nWidth = formatInfo->surfaceWidth - formatInfo->cropLeft - formatInfo->cropRight; - rectParams->nHeight = formatInfo->surfaceHeight - formatInfo->cropTop - formatInfo->cropBottom; + rectParams->nWidth = formatInfo->width - formatInfo->cropLeft - formatInfo->cropRight; + rectParams->nHeight = formatInfo->height - formatInfo->cropTop - formatInfo->cropBottom; + if (strcasecmp(formatInfo->mimeType,"video/avc") == 0 || + strcasecmp(formatInfo->mimeType,"video/h264") == 0) { + rectParams->nHeight = formatInfo->height; + } // if port width parsed from extractor is not as same as from SPS/PPS nalu header, // align it. -- cgit v1.2.3 From b281494c03f58eb2a4beb11eda281e0146ec8f0a Mon Sep 17 00:00:00 2001 From: Alistair Strachan Date: Thu, 12 May 2016 17:26:28 -0700 Subject: Introduce independent hstride and vstride, and use them. Bug: 27589011 Bug: IMINAN-49451 Change-Id: Ib0efa883a4e4a88598d1d85a1ee5f50659be4bae Signed-off-by: Alistair Strachan Signed-off-by: Austin Hu --- videocodec/Android.mk | 2 + videocodec/OMXVideoDecoderBase.cpp | 14 ++++--- videocodec/OMXVideoDecoderBase.h | 3 +- videocodec/OMXVideoDecoderVP9HWR.cpp | 19 +++++---- 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 #include +#include + #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); -- cgit v1.2.3 From 9b61b52a4ba4d0cc2a4a6fe923458c1c426693d0 Mon Sep 17 00:00:00 2001 From: Austin Hu Date: Thu, 19 May 2016 10:38:58 +0800 Subject: Keep return HAL_PIXEL_FORMAT_YV12 format, keep bufferHeight without 32 align. Bug: 27589011 Bug: IMINAN-49451 Change-Id: Ifa31304b7725ace3cc9907c578fbe043d9bcbdd1 Signed-off-by: Lily Ouyang Signed-off-by: Austin Hu --- videocodec/OMXVideoDecoderVP9Hybrid.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/videocodec/OMXVideoDecoderVP9Hybrid.cpp b/videocodec/OMXVideoDecoderVP9Hybrid.cpp index f6211f7..4c2b296 100644 --- a/videocodec/OMXVideoDecoderVP9Hybrid.cpp +++ b/videocodec/OMXVideoDecoderVP9Hybrid.cpp @@ -72,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, bufferHStride, bufferVStride, bufferWidth; + uint32_t bufferSize, bufferHStride, bufferHeight, bufferVStride, bufferWidth; if (!gralloc_mode) { bufferHStride = 1920; bufferVStride = 1088; bufferWidth = 1920; - //bufferHeight = 1080; + bufferHeight = 1080; bufferCount = 12; } else { if (mAPMode == METADATA_MODE) { @@ -107,7 +107,7 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorInit(void) { bufferHStride = mGraphicBufferParam.graphicBufferHStride; bufferVStride = mGraphicBufferParam.graphicBufferVStride; bufferWidth = mGraphicBufferParam.graphicBufferWidth; - //bufferHeight = mGraphicBufferParam.graphicBufferHeight; + bufferHeight = mGraphicBufferParam.graphicBufferHeight; } bufferSize = bufferHStride * bufferVStride * 1.5; @@ -146,7 +146,7 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorInit(void) { // 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); + bufferHeight, bufferCount, gralloc_mode, buff, (uint32_t)mAPMode); return OMX_ErrorNone; } @@ -155,12 +155,12 @@ 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, bufferHStride, bufferVStride, bufferWidth; + uint32_t bufferSize, bufferHStride, bufferHeight, bufferVStride, bufferWidth; if (!gralloc_mode) { bufferHStride = mDecodedImageWidth; bufferVStride = mDecodedImageHeight; bufferWidth = mDecodedImageWidth; - //bufferHeight = mDecodedImageHeight; + bufferHeight = mDecodedImageHeight; bufferSize = bufferHStride * bufferVStride * 1.5; bufferCount = 12; } else { @@ -188,7 +188,7 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorReset(void) bufferHStride = mGraphicBufferParam.graphicBufferHStride; bufferVStride = mGraphicBufferParam.graphicBufferVStride; bufferWidth = mGraphicBufferParam.graphicBufferWidth; - //bufferHeight = mGraphicBufferParam.graphicBufferHeight; + bufferHeight = mGraphicBufferParam.graphicBufferHeight; } bufferSize = bufferHStride * bufferVStride * 1.5; @@ -197,7 +197,7 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorReset(void) // 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); + bufferHeight, bufferCount, gralloc_mode, buff, (uint32_t)mAPMode); mFormatChanged = false; return OMX_ErrorNone; } @@ -579,8 +579,8 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::HandleFormatChange(void) OMX_COLOR_FORMATTYPE OMXVideoDecoderVP9Hybrid::GetOutputColorFormat(int) { - LOGV("Output color format is HAL_PIXEL_FORMAT_INTEL_YV12."); - return (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_INTEL_YV12; + LOGV("Output color format is HAL_PIXEL_FORMAT_YV12."); + return (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_YV12; } OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::GetDecoderOutputCropSpecific(OMX_PTR pStructure) { -- cgit v1.2.3 From 1aa2377f0cc21cad6d44baf77be410b940a2f30a Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Sat, 21 May 2016 08:31:10 +0800 Subject: Fixed the frameworks crashing issue when running testOtherVP9ImageReader. Bug: 27589011 Bug: IMINAN-49451 Fixed by setting back to the default color format, otherwise the Intel specific YV12 format couldn't pass in ACodec::describeDefaultColorFormat, followed by the frameworks crashing later. Change-Id: Ie765a4933620010d3009423e2780fefd559598fa Signed-off-by: Xin Wang Signed-off-by: Austin Hu --- videocodec/OMXVideoDecoderVP9Hybrid.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/videocodec/OMXVideoDecoderVP9Hybrid.cpp b/videocodec/OMXVideoDecoderVP9Hybrid.cpp index 4c2b296..1d6b0e1 100644 --- a/videocodec/OMXVideoDecoderVP9Hybrid.cpp +++ b/videocodec/OMXVideoDecoderVP9Hybrid.cpp @@ -625,17 +625,25 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::SetNativeBufferModeSpecific(OMX_PTR pStr CHECK_PORT_INDEX_RANGE(param); CHECK_SET_PARAM_STATE(); + PortVideo *port = NULL; + port = static_cast(this->ports[OUTPORT_INDEX]); + OMX_PARAM_PORTDEFINITIONTYPE port_def; + memcpy(&port_def,port->GetPortDefinition(),sizeof(port_def)); + if (!param->enable) { mWorkingMode = RAWDATA_MODE; LOGI("Raw data mode is used"); + // If it is fallback from native mode the color format has been + // already set to INTEL format. + // We need to set back the default color format and Native stuff. + port_def.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; + port_def.format.video.pNativeRender = NULL; + port_def.format.video.pNativeWindow = NULL; + port->SetPortDefinition(&port_def,true); return OMX_ErrorNone; } - mWorkingMode = GRAPHICBUFFER_MODE; - PortVideo *port = NULL; - port = static_cast(this->ports[OUTPORT_INDEX]); - OMX_PARAM_PORTDEFINITIONTYPE port_def; - memcpy(&port_def,port->GetPortDefinition(),sizeof(port_def)); + mWorkingMode = GRAPHICBUFFER_MODE; port_def.nBufferCountMin = mNativeBufferCount - 4; port_def.nBufferCountActual = mNativeBufferCount; port_def.format.video.cMIMEType = (OMX_STRING)VA_VED_RAW_MIME_TYPE; -- cgit v1.2.3 From 05f365f4db0916dc81fd6b6fbb5840cb3f689033 Mon Sep 17 00:00:00 2001 From: Lang Dai Date: Wed, 25 May 2016 17:00:58 +0800 Subject: Insert an empty buffer when format change to avoid frame dropping Bug: 28083088 BZ: 49736 Change-Id: I49a90c23ea955695484e6403d0e759ea739cf1be Signed-off-by: Lily Ouyang Signed-off-by: Austin Hu --- videocodec/OMXVideoDecoderBase.cpp | 42 ++++++++++++++++++++++++++++++-------- videocodec/OMXVideoDecoderBase.h | 1 + 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/videocodec/OMXVideoDecoderBase.cpp b/videocodec/OMXVideoDecoderBase.cpp index 31c6a48..323739b 100755 --- a/videocodec/OMXVideoDecoderBase.cpp +++ b/videocodec/OMXVideoDecoderBase.cpp @@ -40,6 +40,7 @@ OMXVideoDecoderBase::OMXVideoDecoderBase() mWorkingMode(RAWDATA_MODE), mErrorReportEnabled (false), mAPMode(LEGACY_MODE), + mFlushMode(false), mFormatChanged(false) { mOMXBufferHeaderTypePtrNum = 0; mMetaDataBuffersNum = 0; @@ -352,10 +353,18 @@ OMX_ERRORTYPE OMXVideoDecoderBase::ProcessorProcess( HandleFormatChange(); } - // Actually, if mAPMode is set, mWorkingMode should be GRAPHICBUFFER_MODE. - if (((mAPMode == METADATA_MODE) && (mWorkingMode == GRAPHICBUFFER_MODE)) && mFormatChanged) { - if (((*pBuffers[OUTPORT_INDEX])->nFlags & OMX_BUFFERFLAG_EOS) || (mVideoDecoder->getOutputQueueLength() == 0)) { - HandleFormatChange(); + if (mFlushMode) { + LOGI("in mFlushMode, do HandleFormatChange."); + HandleFormatChange(); + } else { + // Actually, if mAPMode is set, mWorkingMode should be GRAPHICBUFFER_MODE. + if (((mAPMode == METADATA_MODE) && (mWorkingMode == GRAPHICBUFFER_MODE)) && mFormatChanged) { + if (((*pBuffers[OUTPORT_INDEX])->nFlags & OMX_BUFFERFLAG_EOS) || (mVideoDecoder->getOutputQueueLength() == 0)) { + // Format changed, set mFlushMode, clear eos + mFlushMode = true; + mFormatChanged = false; + (*pBuffers[OUTPORT_INDEX])->nFlags &= ~OMX_BUFFERFLAG_EOS; + } } } @@ -436,9 +445,17 @@ OMX_ERRORTYPE OMXVideoDecoderBase::ProcessorProcess( HandleFormatChange(); } - if (((mAPMode == METADATA_MODE) && (mWorkingMode == GRAPHICBUFFER_MODE)) && mFormatChanged) { - if (((*pBuffers[OUTPORT_INDEX])->nFlags & OMX_BUFFERFLAG_EOS) || (mVideoDecoder->getOutputQueueLength() == 0)) { - HandleFormatChange(); + if (mFlushMode) { + LOGI("in mFlushMode, do HandleFormatChange."); + HandleFormatChange(); + } else { + if (((mAPMode == METADATA_MODE) && (mWorkingMode == GRAPHICBUFFER_MODE)) && mFormatChanged) { + if (((*pBuffers[OUTPORT_INDEX])->nFlags & OMX_BUFFERFLAG_EOS) || (mVideoDecoder->getOutputQueueLength() == 0)) { + // Format changed, set mFlushMode, clear eos. + mFlushMode = true; + mFormatChanged = false; + (*pBuffers[OUTPORT_INDEX])->nFlags &= ~OMX_BUFFERFLAG_EOS; + } } } @@ -678,8 +695,15 @@ OMX_ERRORTYPE OMXVideoDecoderBase::FillRenderBuffer(OMX_BUFFERHEADERTYPE **pBuff bool draining = (inportBufferFlags & OMX_BUFFERFLAG_EOS); //pthread_mutex_lock(&mSerializationLock); - const VideoRenderBuffer *renderBuffer; + const VideoRenderBuffer *renderBuffer = NULL; //pthread_mutex_unlock(&mSerializationLock); + + // in mFlushMode, provide empty buffer. + if (mFlushMode) { + buffer->nFilledLen = 0; + return OMX_ErrorNone; + } + if (((mAPMode == METADATA_MODE) && (mWorkingMode == GRAPHICBUFFER_MODE)) && mFormatChanged) { renderBuffer = mVideoDecoder->getOutput(true, ErrBufPtr); } else { @@ -803,7 +827,7 @@ OMX_ERRORTYPE OMXVideoDecoderBase::HandleFormatChange(void) { this->ports[OUTPORT_INDEX]->ReportPortSettingsChanged(); - mFormatChanged = false; + mFlushMode = false; return OMX_ErrorNone; } diff --git a/videocodec/OMXVideoDecoderBase.h b/videocodec/OMXVideoDecoderBase.h index 2cd60ad..8df593e 100755 --- a/videocodec/OMXVideoDecoderBase.h +++ b/videocodec/OMXVideoDecoderBase.h @@ -145,6 +145,7 @@ protected: }; AdaptivePlaybackMode mAPMode; uint32_t mMetaDataBuffersNum; + OMX_TICKS mFlushMode; bool mFormatChanged; uint32_t getStride(uint32_t width); }; -- cgit v1.2.3 From 5945497adb45caee10717b41cb01e4c09dee05bd Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Mon, 30 May 2016 10:56:25 +0800 Subject: Fixed the CTS DecodeAccuracyTest LargerWidth/Height issue. Bug: 27589011 Bug: IMINAN-49451 By handling format change, in case that the port definition set by OMX client mismatches with the real dimension of a video clip/stream. Change-Id: Id081b351c29137360045397b06b9f12398aa5ffe Signed-off-by: Austin Hu --- videocodec/OMXVideoDecoderVP9Hybrid.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/videocodec/OMXVideoDecoderVP9Hybrid.cpp b/videocodec/OMXVideoDecoderVP9Hybrid.cpp index 1d6b0e1..76b1d9d 100644 --- a/videocodec/OMXVideoDecoderVP9Hybrid.cpp +++ b/videocodec/OMXVideoDecoderVP9Hybrid.cpp @@ -209,6 +209,9 @@ bool OMXVideoDecoderVP9Hybrid::isReallocateNeeded(const uint8_t * data,uint32_t bool ret = true; if (gralloc_mode) { ret = mGetFrameResolution(data,data_sz, &width, &height); + if (width == 0 || height == 0) + return false; + if (ret) { if (mAPMode == METADATA_MODE) { ret = (width != mDecodedImageWidth) @@ -292,6 +295,21 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorProcess( OMX_ERRORTYPE ret; OMX_BUFFERHEADERTYPE *inBuffer = *pBuffers[INPORT_INDEX]; OMX_BUFFERHEADERTYPE *outBuffer = *pBuffers[OUTPORT_INDEX]; + + if ((mWorkingMode == GRAPHICBUFFER_MODE) && (mAPMode == METADATA_MODE) && + (mLastTimeStamp == 0) && (!mFormatChanged)) { + bool mRet = mGetFrameResolution(inBuffer->pBuffer + inBuffer->nOffset, inBuffer->nFilledLen, + &mDecodedImageNewWidth,&mDecodedImageNewHeight); + + if (mRet && ((mDecodedImageNewWidth != 0) && (mDecodedImageNewHeight != 0)) && + ((mDecodedImageWidth != 0) && (mDecodedImageHeight != 0)) && + ((mDecodedImageNewWidth != mDecodedImageWidth || mDecodedImageNewHeight != mDecodedImageHeight))) { + retains[INPORT_INDEX] = BUFFER_RETAIN_GETAGAIN; + HandleFormatChange(); + return OMX_ErrorNone; + } + } + bool eos = (inBuffer->nFlags & OMX_BUFFERFLAG_EOS)? true:false; OMX_BOOL isResolutionChange = OMX_FALSE; bool formatChange = false; -- cgit v1.2.3 From b4081012cae95f51b57d8891dd62050c74b95f27 Mon Sep 17 00:00:00 2001 From: Austin Hu Date: Thu, 19 May 2016 13:38:22 +0800 Subject: Make VP9 decoder render into gralloc buffer with HAL_PIXEL_FORMAT_INTEL_YV12 format. Bug: 27589011 Bug: IMINAN-49451 Change-Id: I86056f95a6c96fcd1afcc77d9bd859a2860c2d10 Signed-off-by: Austin Hu --- videocodec/OMXVideoDecoderVP9Hybrid.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/videocodec/OMXVideoDecoderVP9Hybrid.cpp b/videocodec/OMXVideoDecoderVP9Hybrid.cpp index 76b1d9d..aef9821 100644 --- a/videocodec/OMXVideoDecoderVP9Hybrid.cpp +++ b/videocodec/OMXVideoDecoderVP9Hybrid.cpp @@ -597,8 +597,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) { -- cgit v1.2.3