From f16a0b73993c5a8cc14a36521abaa50d501d9044 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Tue, 20 Oct 2009 10:43:48 -0700 Subject: do not merge: The qcom video decoders always output yuv data after adjusting dimensions to be a multiple of 16. Add a quirk mode to OMXCodec that makes it aware of this fact for proper display. Also integrate back a change from eclair-mr2 that delays releasing an output buffer briefly after posting it to surface flinger, as we don't know how long it'll take it to actually display the buffer's content. --- include/media/stagefright/OMXCodec.h | 1 + media/libstagefright/OMXCodec.cpp | 4 +++- media/libstagefright/omx/QComHardwareRenderer.cpp | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h index ff7e34a..3f3dcf9 100644 --- a/include/media/stagefright/OMXCodec.h +++ b/include/media/stagefright/OMXCodec.h @@ -90,6 +90,7 @@ private: kRequiresFlushCompleteEmulation = 16, kRequiresAllocateBufferOnOutputPorts = 32, kRequiresFlushBeforeShutdown = 64, + kOutputDimensionsAre16Aligned = 128, }; struct BufferInfo { diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp index c4c6149..1a23fb2 100644 --- a/media/libstagefright/OMXCodec.cpp +++ b/media/libstagefright/OMXCodec.cpp @@ -210,6 +210,7 @@ sp OMXCodec::Create( uint32_t quirks = 0; if (!strcmp(componentName, "OMX.PV.avcdec")) { quirks |= kWantsNALFragments; + quirks |= kOutputDimensionsAre16Aligned; } if (!strcmp(componentName, "OMX.TI.MP3.decode")) { quirks |= kNeedsFlushBeforeDisable; @@ -231,6 +232,7 @@ sp OMXCodec::Create( // XXX Required on P....on only. quirks |= kRequiresAllocateBufferOnInputPorts; quirks |= kRequiresAllocateBufferOnOutputPorts; + quirks |= kOutputDimensionsAre16Aligned; } if (!strncmp(componentName, "OMX.TI.", 7)) { @@ -2386,7 +2388,7 @@ void OMXCodec::initOutputFormat(const sp &inputFormat) { CHECK(!"Unknown compression format."); } - if (!strcmp(mComponentName, "OMX.PV.avcdec")) { + if (mQuirks & kOutputDimensionsAre16Aligned) { // This component appears to be lying to me. mOutputFormat->setInt32( kKeyWidth, (video_def->nFrameWidth + 15) & -16); diff --git a/media/libstagefright/omx/QComHardwareRenderer.cpp b/media/libstagefright/omx/QComHardwareRenderer.cpp index e9930be..7dc368f 100644 --- a/media/libstagefright/omx/QComHardwareRenderer.cpp +++ b/media/libstagefright/omx/QComHardwareRenderer.cpp @@ -83,6 +83,11 @@ void QComHardwareRenderer::render( } mISurface->postBuffer(offset); + + // Since we cannot tell how long it'll take until surface flinger + // has displayed the data onscreen, we'll just have to guess... + // We must not return the buffer to the decoder before it's been displayed. + usleep(25000); } bool QComHardwareRenderer::getOffset(void *platformPrivate, size_t *offset) { -- cgit v1.1