From e671207115fac3914134c61b336d5fa0242c68ca Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Tue, 26 Jun 2012 10:56:14 -0700 Subject: Make sure codec names and corresponding quirks are returned together. Previously they were returned in separate vectors and only one of them was sorted if software codecs were preferred, leaving the quirks no longer matching the codec name at the same index. Change-Id: Id3f1e6f9f7f8c9cc4b6ebfb86a203b4d59de8604 related-to-bug: 6737884 --- media/libstagefright/ACodec.cpp | 20 +++++++++--------- media/libstagefright/OMXCodec.cpp | 44 +++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 33 deletions(-) (limited to 'media/libstagefright') diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index f96a429..c37d2ca 100644 --- a/media/libstagefright/ACodec.cpp +++ b/media/libstagefright/ACodec.cpp @@ -2886,20 +2886,21 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp &msg) { sp omx = client.interface(); - Vector matchingCodecs; - Vector matchingCodecQuirks; + Vector matchingCodecs; AString mime; AString componentName; uint32_t quirks; if (msg->findString("componentName", &componentName)) { - matchingCodecs.push_back(String8(componentName.c_str())); + ssize_t index = matchingCodecs.add(); + OMXCodec::CodecNameAndQuirks *entry = &matchingCodecs.editItemAt(index); + entry->mName = String8(componentName.c_str()); - if (!OMXCodec::findCodecQuirks(componentName.c_str(), &quirks)) { - quirks = 0; + if (!OMXCodec::findCodecQuirks( + componentName.c_str(), &entry->mQuirks)) { + entry->mQuirks = 0; } - matchingCodecQuirks.push_back(quirks); } else { CHECK(msg->findString("mime", &mime)); @@ -2913,8 +2914,7 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp &msg) { encoder, // createEncoder NULL, // matchComponentName 0, // flags - &matchingCodecs, - &matchingCodecQuirks); + &matchingCodecs); } sp observer = new CodecObserver; @@ -2922,8 +2922,8 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp &msg) { for (size_t matchIndex = 0; matchIndex < matchingCodecs.size(); ++matchIndex) { - componentName = matchingCodecs.itemAt(matchIndex).string(); - quirks = matchingCodecQuirks.itemAt(matchIndex); + componentName = matchingCodecs.itemAt(matchIndex).mName.string(); + quirks = matchingCodecs.itemAt(matchIndex).mQuirks; pid_t tid = androidGetTid(); int prevPriority = androidGetThreadPriority(tid); diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp index e8cb9d5..5615d0f 100755 --- a/media/libstagefright/OMXCodec.cpp +++ b/media/libstagefright/OMXCodec.cpp @@ -147,12 +147,13 @@ static bool IsSoftwareCodec(const char *componentName) { // A sort order in which OMX software codecs are first, followed // by other (non-OMX) software codecs, followed by everything else. static int CompareSoftwareCodecsFirst( - const String8 *elem1, const String8 *elem2) { - bool isOMX1 = !strncmp(elem1->string(), "OMX.", 4); - bool isOMX2 = !strncmp(elem2->string(), "OMX.", 4); + const OMXCodec::CodecNameAndQuirks *elem1, + const OMXCodec::CodecNameAndQuirks *elem2) { + bool isOMX1 = !strncmp(elem1->mName.string(), "OMX.", 4); + bool isOMX2 = !strncmp(elem2->mName.string(), "OMX.", 4); - bool isSoftwareCodec1 = IsSoftwareCodec(elem1->string()); - bool isSoftwareCodec2 = IsSoftwareCodec(elem2->string()); + bool isSoftwareCodec1 = IsSoftwareCodec(elem1->mName.string()); + bool isSoftwareCodec2 = IsSoftwareCodec(elem2->mName.string()); if (isSoftwareCodec1) { if (!isSoftwareCodec2) { return -1; } @@ -182,14 +183,9 @@ void OMXCodec::findMatchingCodecs( const char *mime, bool createEncoder, const char *matchComponentName, uint32_t flags, - Vector *matchingCodecs, - Vector *matchingCodecQuirks) { + Vector *matchingCodecs) { matchingCodecs->clear(); - if (matchingCodecQuirks) { - matchingCodecQuirks->clear(); - } - const MediaCodecList *list = MediaCodecList::getInstance(); if (list == NULL) { return; @@ -221,11 +217,13 @@ void OMXCodec::findMatchingCodecs( ((flags & kHardwareCodecsOnly) && !IsSoftwareCodec(componentName)) || (!(flags & (kSoftwareCodecsOnly | kHardwareCodecsOnly)))) { - matchingCodecs->push(String8(componentName)); + ssize_t index = matchingCodecs->add(); + CodecNameAndQuirks *entry = &matchingCodecs->editItemAt(index); + entry->mName = String8(componentName); + entry->mQuirks = getComponentQuirks(list, matchIndex); - if (matchingCodecQuirks) { - matchingCodecQuirks->push(getComponentQuirks(list, matchIndex)); - } + ALOGV("matching '%s' quirks 0x%08x", + entry->mName.string(), entry->mQuirks); } } @@ -294,11 +292,9 @@ sp OMXCodec::Create( bool success = meta->findCString(kKeyMIMEType, &mime); CHECK(success); - Vector matchingCodecs; - Vector matchingCodecQuirks; + Vector matchingCodecs; findMatchingCodecs( - mime, createEncoder, matchComponentName, flags, - &matchingCodecs, &matchingCodecQuirks); + mime, createEncoder, matchComponentName, flags, &matchingCodecs); if (matchingCodecs.isEmpty()) { ALOGV("No matching codecs! (mime: %s, createEncoder: %s, " @@ -311,8 +307,8 @@ sp OMXCodec::Create( IOMX::node_id node = 0; for (size_t i = 0; i < matchingCodecs.size(); ++i) { - const char *componentNameBase = matchingCodecs[i].string(); - uint32_t quirks = matchingCodecQuirks[i]; + const char *componentNameBase = matchingCodecs[i].mName.string(); + uint32_t quirks = matchingCodecs[i].mQuirks; const char *componentName = componentNameBase; AString tmp; @@ -572,6 +568,8 @@ status_t OMXCodec::configureCodec(const sp &meta) { if ((mFlags & kClientNeedsFramebuffer) && !strncmp(mComponentName, "OMX.SEC.", 8)) { + // This appears to no longer be needed??? + OMX_INDEXTYPE index; status_t err = @@ -4489,7 +4487,7 @@ status_t QueryCodecs( const sp &omx, const char *mime, bool queryDecoders, bool hwCodecOnly, Vector *results) { - Vector matchingCodecs; + Vector matchingCodecs; results->clear(); OMXCodec::findMatchingCodecs(mime, @@ -4499,7 +4497,7 @@ status_t QueryCodecs( &matchingCodecs); for (size_t c = 0; c < matchingCodecs.size(); c++) { - const char *componentName = matchingCodecs.itemAt(c).string(); + const char *componentName = matchingCodecs.itemAt(c).mName.string(); results->push(); CodecCapabilities *caps = &results->editItemAt(results->size() - 1); -- cgit v1.1