diff options
author | Lajos Molnar <lajos@google.com> | 2013-05-02 16:46:41 -0700 |
---|---|---|
committer | Lajos Molnar <lajos@google.com> | 2013-10-03 09:55:25 -0700 |
commit | fce0d1883cdbcb7d501625fb43844043cd28a267 (patch) | |
tree | 378f7e3451987e2cdf26d5884db41d9291485f4b /media/libstagefright/ACodec.cpp | |
parent | 56ce726019f700a95ce5b45beebceadae4836e30 (diff) | |
download | frameworks_av-fce0d1883cdbcb7d501625fb43844043cd28a267.zip frameworks_av-fce0d1883cdbcb7d501625fb43844043cd28a267.tar.gz frameworks_av-fce0d1883cdbcb7d501625fb43844043cd28a267.tar.bz2 |
stagefright: enable adaptive playback based on codec format key
Added support for prepareForAdaptivePlayback() call in
configureCodec, if max-width and max-height keys are specified
in the format. It is OK for this call to fail, if component
does not implement adaptive playback.
Change-Id: Ie15892bc666df103b635890a0fda799b204bb06c
Signed-off-by: Lajos Molnar <lajos@google.com>
Bug: 7093648
Bug: 10192531
Diffstat (limited to 'media/libstagefright/ACodec.cpp')
-rw-r--r-- | media/libstagefright/ACodec.cpp | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index bfb730c..9fa8a00 100644 --- a/media/libstagefright/ACodec.cpp +++ b/media/libstagefright/ACodec.cpp @@ -1106,9 +1106,49 @@ status_t ACodec::configureCodec( if (!encoder && video && haveNativeWindow) { err = mOMX->storeMetaDataInBuffers(mNode, kPortIndexOutput, OMX_TRUE); if (err != OK) { - // allow failure ALOGE("[%s] storeMetaDataInBuffers failed w/ err %d", mComponentName.c_str(), err); + + // if adaptive playback has been requested, try JB fallback + // NOTE: THIS FALLBACK MECHANISM WILL BE REMOVED DUE TO ITS + // LARGE MEMORY REQUIREMENT + + // we will not do adaptive playback on software accessed + // surfaces as they never had to respond to changes in the + // crop window, and we don't trust that they will be able to. + int usageBits = 0; + bool canDoAdaptivePlayback; + + sp<NativeWindowWrapper> windowWrapper( + static_cast<NativeWindowWrapper *>(obj.get())); + sp<ANativeWindow> nativeWindow = windowWrapper->getNativeWindow(); + + if (nativeWindow->query( + nativeWindow.get(), + NATIVE_WINDOW_CONSUMER_USAGE_BITS, + &usageBits) != OK) { + canDoAdaptivePlayback = false; + } else { + canDoAdaptivePlayback = + (usageBits & + (GRALLOC_USAGE_SW_READ_MASK | + GRALLOC_USAGE_SW_WRITE_MASK)) == 0; + } + + int32_t maxWidth = 0, maxHeight = 0; + if (canDoAdaptivePlayback && + msg->findInt32("max-width", &maxWidth) && + msg->findInt32("max-height", &maxHeight)) { + ALOGV("[%s] prepareForAdaptivePlayback(%ldx%ld)", + mComponentName.c_str(), maxWidth, maxHeight); + + err = mOMX->prepareForAdaptivePlayback( + mNode, kPortIndexOutput, OMX_TRUE, maxWidth, maxHeight); + ALOGW_IF(err != OK, + "[%s] prepareForAdaptivePlayback failed w/ err %d", + mComponentName.c_str(), err); + } + // allow failure err = OK; } else { ALOGV("[%s] storeMetaDataInBuffers succeeded", mComponentName.c_str()); |