diff options
author | Ronghua Wu <ronghuawu@google.com> | 2014-08-22 12:49:26 -0700 |
---|---|---|
committer | Ronghua Wu <ronghuawu@google.com> | 2014-08-28 10:28:36 -0700 |
commit | 031be0f358b07732092a4d1bf02fc99f109a63c4 (patch) | |
tree | 0f43a8d5f0bd944969863403517ba52d210904b8 /media/libstagefright/codecs/on2/dec/SoftVPX.cpp | |
parent | d42173a44721af1a600b9c8599bc736394fcc724 (diff) | |
download | frameworks_av-031be0f358b07732092a4d1bf02fc99f109a63c4.zip frameworks_av-031be0f358b07732092a4d1bf02fc99f109a63c4.tar.gz frameworks_av-031be0f358b07732092a4d1bf02fc99f109a63c4.tar.bz2 |
Add adaptive playback support to VPX decoder.
Bug: 13842676
Change-Id: I9c054ea489fd3a71b3b2394f15a85b84d42edb5a
Diffstat (limited to 'media/libstagefright/codecs/on2/dec/SoftVPX.cpp')
-rw-r--r-- | media/libstagefright/codecs/on2/dec/SoftVPX.cpp | 59 |
1 files changed, 39 insertions, 20 deletions
diff --git a/media/libstagefright/codecs/on2/dec/SoftVPX.cpp b/media/libstagefright/codecs/on2/dec/SoftVPX.cpp index 423a057..a4258dd 100644 --- a/media/libstagefright/codecs/on2/dec/SoftVPX.cpp +++ b/media/libstagefright/codecs/on2/dec/SoftVPX.cpp @@ -143,11 +143,24 @@ void SoftVPX::onQueueFilled(OMX_U32 /* portIndex */) { mWidth = width; mHeight = height; - updatePortDefinitions(); - - notify(OMX_EventPortSettingsChanged, 1, 0, NULL); - mOutputPortSettingsChange = AWAITING_DISABLED; - return; + if (!mIsAdaptive || width > mAdaptiveMaxWidth || height > mAdaptiveMaxHeight) { + if (mIsAdaptive) { + if (width > mAdaptiveMaxWidth) { + mAdaptiveMaxWidth = width; + } + if (height > mAdaptiveMaxHeight) { + mAdaptiveMaxHeight = height; + } + } + updatePortDefinitions(); + notify(OMX_EventPortSettingsChanged, kOutputPortIndex, 0, NULL); + mOutputPortSettingsChange = AWAITING_DISABLED; + return; + } else { + updatePortDefinitions(); + notify(OMX_EventPortSettingsChanged, kOutputPortIndex, + OMX_IndexConfigCommonOutputCrop, NULL); + } } outHeader->nOffset = 0; @@ -155,29 +168,35 @@ void SoftVPX::onQueueFilled(OMX_U32 /* portIndex */) { outHeader->nFlags = EOSseen ? OMX_BUFFERFLAG_EOS : 0; outHeader->nTimeStamp = inHeader->nTimeStamp; + uint32_t buffer_stride = mIsAdaptive ? mAdaptiveMaxWidth : mWidth; + uint32_t buffer_height = mIsAdaptive ? mAdaptiveMaxHeight : mHeight; + const uint8_t *srcLine = (const uint8_t *)img->planes[PLANE_Y]; uint8_t *dst = outHeader->pBuffer; - for (size_t i = 0; i < img->d_h; ++i) { - memcpy(dst, srcLine, img->d_w); - - srcLine += img->stride[PLANE_Y]; - dst += img->d_w; + for (size_t i = 0; i < buffer_height; ++i) { + if (i < img->d_h) { + memcpy(dst, srcLine, img->d_w); + srcLine += img->stride[PLANE_Y]; + } + dst += buffer_stride; } srcLine = (const uint8_t *)img->planes[PLANE_U]; - for (size_t i = 0; i < img->d_h / 2; ++i) { - memcpy(dst, srcLine, img->d_w / 2); - - srcLine += img->stride[PLANE_U]; - dst += img->d_w / 2; + for (size_t i = 0; i < buffer_height / 2; ++i) { + if (i < img->d_h / 2) { + memcpy(dst, srcLine, img->d_w / 2); + srcLine += img->stride[PLANE_U]; + } + dst += buffer_stride / 2; } srcLine = (const uint8_t *)img->planes[PLANE_V]; - for (size_t i = 0; i < img->d_h / 2; ++i) { - memcpy(dst, srcLine, img->d_w / 2); - - srcLine += img->stride[PLANE_V]; - dst += img->d_w / 2; + for (size_t i = 0; i < buffer_height / 2; ++i) { + if (i < img->d_h / 2) { + memcpy(dst, srcLine, img->d_w / 2); + srcLine += img->stride[PLANE_V]; + } + dst += buffer_stride / 2; } outInfo->mOwnedByUs = false; |