summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2010-10-18 09:57:42 -0700
committerAndreas Huber <andih@google.com>2010-10-18 10:16:08 -0700
commitf3712f026aad1fc46b1df18d1dba718281e39726 (patch)
tree8bc7bbfef7a223939d093cd5595d4ccfe8fdac5e
parent56cfa2376ae87cba730ea7ce4a9e0ca4f0d07627 (diff)
downloadframeworks_av-f3712f026aad1fc46b1df18d1dba718281e39726.zip
frameworks_av-f3712f026aad1fc46b1df18d1dba718281e39726.tar.gz
frameworks_av-f3712f026aad1fc46b1df18d1dba718281e39726.tar.bz2
For thumbnail extraction make sure we instantiate a decoder that allows access to the framebuffer. Implement the samsung workaround to support this by reconfiguring the decoder.
related-to-bug: 3106534 Change-Id: Ie28d72af2f9e93818d1840ac83aa7bc11fa57b3b
-rw-r--r--include/media/stagefright/OMXCodec.h6
-rw-r--r--media/libstagefright/OMXCodec.cpp46
-rw-r--r--media/libstagefright/StagefrightMetadataRetriever.cpp2
3 files changed, 51 insertions, 3 deletions
diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h
index 2bb7783..1d94160 100644
--- a/include/media/stagefright/OMXCodec.h
+++ b/include/media/stagefright/OMXCodec.h
@@ -33,7 +33,11 @@ struct OMXCodec : public MediaSource,
public MediaBufferObserver {
enum CreationFlags {
kPreferSoftwareCodecs = 1,
- kIgnoreCodecSpecificData = 2
+ kIgnoreCodecSpecificData = 2,
+
+ // The client wants to access the output buffer's video
+ // data for example for thumbnail extraction.
+ kClientNeedsFramebuffer = 4,
};
static sp<MediaSource> Create(
const sp<IOMX> &omx,
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 4648ad3..9a49a9b 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -493,12 +493,29 @@ sp<MediaSource> OMXCodec::Create(
LOGV("Attempting to allocate OMX node '%s'", componentName);
+ uint32_t quirks = getComponentQuirks(componentName, createEncoder);
+
+ if (!createEncoder
+ && (quirks & kOutputBuffersAreUnreadable)
+ && (flags & kClientNeedsFramebuffer)) {
+ if (strncmp(componentName, "OMX.SEC.", 8)) {
+ // For OMX.SEC.* decoders we can enable a special mode that
+ // gives the client access to the framebuffer contents.
+
+ LOGW("Component '%s' does not give the client access to "
+ "the framebuffer contents. Skipping.",
+ componentName);
+
+ continue;
+ }
+ }
+
status_t err = omx->allocateNode(componentName, observer, &node);
if (err == OK) {
LOGV("Successfully allocated OMX node '%s'", componentName);
sp<OMXCodec> codec = new OMXCodec(
- omx, node, getComponentQuirks(componentName, createEncoder),
+ omx, node, quirks,
createEncoder, mime, componentName,
source);
@@ -681,6 +698,33 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta, uint32_t flags) {
initOutputFormat(meta);
+ if ((flags & kClientNeedsFramebuffer)
+ && !strncmp(mComponentName, "OMX.SEC.", 8)) {
+ OMX_INDEXTYPE index;
+
+ status_t err =
+ mOMX->getExtensionIndex(
+ mNode,
+ "OMX.SEC.index.ThumbnailMode",
+ &index);
+
+ if (err != OK) {
+ return err;
+ }
+
+ OMX_BOOL enable = OMX_TRUE;
+ err = mOMX->setConfig(mNode, index, &enable, sizeof(enable));
+
+ if (err != OK) {
+ CODEC_LOGE("setConfig('OMX.SEC.index.ThumbnailMode') "
+ "returned error 0x%08x", err);
+
+ return err;
+ }
+
+ mQuirks &= ~kOutputBuffersAreUnreadable;
+ }
+
return OK;
}
diff --git a/media/libstagefright/StagefrightMetadataRetriever.cpp b/media/libstagefright/StagefrightMetadataRetriever.cpp
index af9c70c..a800a93 100644
--- a/media/libstagefright/StagefrightMetadataRetriever.cpp
+++ b/media/libstagefright/StagefrightMetadataRetriever.cpp
@@ -112,7 +112,7 @@ static VideoFrame *extractVideoFrameWithCodecFlags(
sp<MediaSource> decoder =
OMXCodec::Create(
client->interface(), source->getFormat(), false, source,
- NULL, flags);
+ NULL, flags | OMXCodec::kClientNeedsFramebuffer);
if (decoder.get() == NULL) {
LOGV("unable to instantiate video decoder.");