summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/StagefrightMetadataRetriever.cpp
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2012-09-07 17:27:50 -0700
committerJames Dong <jdong@google.com>2012-09-10 16:37:26 -0700
commit8fa80e3be63ffde5ef029afa713877440856b663 (patch)
tree2e04f6299435b089a2b8c45cfb2be756d27739c9 /media/libstagefright/StagefrightMetadataRetriever.cpp
parente148910dfb3f69cdf1a078066724cb32b18e7b8a (diff)
downloadframeworks_av-8fa80e3be63ffde5ef029afa713877440856b663.zip
frameworks_av-8fa80e3be63ffde5ef029afa713877440856b663.tar.gz
frameworks_av-8fa80e3be63ffde5ef029afa713877440856b663.tar.bz2
Allow OMXCodec to specify an output color format for OMX decoder component
The output color format is specified via the meta argument in OMXCodec::Create() o related-to-bug: 7122195 Change-Id: Id3247686b893af25cc190685201e53ad34b0399c
Diffstat (limited to 'media/libstagefright/StagefrightMetadataRetriever.cpp')
-rw-r--r--media/libstagefright/StagefrightMetadataRetriever.cpp37
1 files changed, 36 insertions, 1 deletions
diff --git a/media/libstagefright/StagefrightMetadataRetriever.cpp b/media/libstagefright/StagefrightMetadataRetriever.cpp
index c9ef4d9..a2f3f13 100644
--- a/media/libstagefright/StagefrightMetadataRetriever.cpp
+++ b/media/libstagefright/StagefrightMetadataRetriever.cpp
@@ -110,6 +110,31 @@ status_t StagefrightMetadataRetriever::setDataSource(
return OK;
}
+static bool isYUV420PlanarSupported(
+ OMXClient *client,
+ const sp<MetaData> &trackMeta) {
+
+ const char *mime;
+ CHECK(trackMeta->findCString(kKeyMIMEType, &mime));
+
+ Vector<CodecCapabilities> caps;
+ if (QueryCodecs(client->interface(), mime,
+ true, /* queryDecoders */
+ true, /* hwCodecOnly */
+ &caps) == OK) {
+
+ for (size_t j = 0; j < caps.size(); ++j) {
+ CodecCapabilities cap = caps[j];
+ for (size_t i = 0; i < cap.mColorFormats.size(); ++i) {
+ if (cap.mColorFormats[i] == OMX_COLOR_FormatYUV420Planar) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
static VideoFrame *extractVideoFrameWithCodecFlags(
OMXClient *client,
const sp<MetaData> &trackMeta,
@@ -117,9 +142,19 @@ static VideoFrame *extractVideoFrameWithCodecFlags(
uint32_t flags,
int64_t frameTimeUs,
int seekMode) {
+
+ sp<MetaData> format = source->getFormat();
+
+ // XXX:
+ // Once all vendors support OMX_COLOR_FormatYUV420Planar, we can
+ // remove this check and always set the decoder output color format
+ if (isYUV420PlanarSupported(client, trackMeta)) {
+ format->setInt32(kKeyColorFormat, OMX_COLOR_FormatYUV420Planar);
+ }
+
sp<MediaSource> decoder =
OMXCodec::Create(
- client->interface(), source->getFormat(), false, source,
+ client->interface(), format, false, source,
NULL, flags | OMXCodec::kClientNeedsFramebuffer);
if (decoder.get() == NULL) {