From b9ff4b4f631239a6a37fe6588e025cb387150c0e Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Mon, 24 Jan 2011 13:36:30 -0800 Subject: Support non-multiple-of-16 dimensions in MPEG4/H.263 software decoder Change-Id: Ia22ebce66d9c35de4b04c3eedc9495847796901d related-to-bug: 3384367 --- .../codecs/m4v_h263/dec/M4vH263Decoder.cpp | 25 +++++++++++++++------- .../codecs/m4v_h263/dec/include/mp4dec_api.h | 1 + .../codecs/m4v_h263/dec/src/pvdec_api.cpp | 6 ++++++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/media/libstagefright/codecs/m4v_h263/dec/M4vH263Decoder.cpp b/media/libstagefright/codecs/m4v_h263/dec/M4vH263Decoder.cpp index 38778fb..2bdb3ef 100644 --- a/media/libstagefright/codecs/m4v_h263/dec/M4vH263Decoder.cpp +++ b/media/libstagefright/codecs/m4v_h263/dec/M4vH263Decoder.cpp @@ -23,8 +23,8 @@ #include "mp4dec_api.h" #include +#include #include -#include #include #include #include @@ -106,7 +106,7 @@ status_t M4vH263Decoder::start(MetaData *) { int32_t vol_size = 0; if (meta->findData(kKeyESDS, &type, &data, &size)) { ESDS esds((const uint8_t *)data, size); - CHECK_EQ(esds.InitCheck(), OK); + CHECK_EQ(esds.InitCheck(), (status_t)OK); const void *codec_specific_data; size_t codec_specific_data_size; @@ -185,7 +185,7 @@ status_t M4vH263Decoder::read( ReadOptions::SeekMode mode; if (options && options->getSeekTo(&seekTimeUs, &mode)) { seeking = true; - CHECK_EQ(PVResetVideoDecoder(mHandle), PV_TRUE); + CHECK_EQ((int)PVResetVideoDecoder(mHandle), PV_TRUE); } MediaBuffer *inputBuffer = NULL; @@ -223,19 +223,28 @@ status_t M4vH263Decoder::read( return UNKNOWN_ERROR; } - int32_t width, height; - PVGetVideoDimensions(mHandle, &width, &height); - if (width != mWidth || height != mHeight) { + int32_t disp_width, disp_height; + PVGetVideoDimensions(mHandle, &disp_width, &disp_height); + + int32_t buf_width, buf_height; + PVGetBufferDimensions(mHandle, &buf_width, &buf_height); + + if (buf_width != mWidth || buf_height != mHeight) { ++mNumSamplesOutput; // The client will never get to see this frame. inputBuffer->release(); inputBuffer = NULL; - mWidth = width; - mHeight = height; + mWidth = buf_width; + mHeight = buf_height; mFormat->setInt32(kKeyWidth, mWidth); mFormat->setInt32(kKeyHeight, mHeight); + CHECK_LE(disp_width, buf_width); + CHECK_LE(disp_height, buf_height); + + mFormat->setRect(kKeyCropRect, 0, 0, disp_width - 1, disp_height - 1); + return INFO_FORMAT_CHANGED; } diff --git a/media/libstagefright/codecs/m4v_h263/dec/include/mp4dec_api.h b/media/libstagefright/codecs/m4v_h263/dec/include/mp4dec_api.h index ef09900..24a50ce 100644 --- a/media/libstagefright/codecs/m4v_h263/dec/include/mp4dec_api.h +++ b/media/libstagefright/codecs/m4v_h263/dec/include/mp4dec_api.h @@ -159,6 +159,7 @@ extern "C" Bool PVDecodeVopBody(VideoDecControls *decCtrl, int32 buffer_size[]); void PVDecPostProcess(VideoDecControls *decCtrl, uint8 *outputYUV); OSCL_IMPORT_REF void PVGetVideoDimensions(VideoDecControls *decCtrl, int32 *display_width, int32 *display_height); + OSCL_IMPORT_REF void PVGetBufferDimensions(VideoDecControls *decCtrl, int32 *buf_width, int32 *buf_height); OSCL_IMPORT_REF void PVSetPostProcType(VideoDecControls *decCtrl, int mode); uint32 PVGetVideoTimeStamp(VideoDecControls *decoderControl); int PVGetDecBitrate(VideoDecControls *decCtrl); diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/pvdec_api.cpp b/media/libstagefright/codecs/m4v_h263/dec/src/pvdec_api.cpp index 0c354d9..844bd14 100644 --- a/media/libstagefright/codecs/m4v_h263/dec/src/pvdec_api.cpp +++ b/media/libstagefright/codecs/m4v_h263/dec/src/pvdec_api.cpp @@ -722,6 +722,12 @@ OSCL_EXPORT_REF void PVGetVideoDimensions(VideoDecControls *decCtrl, int32 *disp *display_height = video->displayHeight; } +OSCL_EXPORT_REF void PVGetBufferDimensions(VideoDecControls *decCtrl, int32 *width, int32 *height) { + VideoDecData *video = (VideoDecData *)decCtrl->videoDecoderData; + *width = video->width; + *height = video->height; +} + /* ======================================================================== */ /* Function : PVGetVideoTimeStamp() */ /* Date : 04/27/2000, 08/29/2000 */ -- cgit v1.1