Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b5cf9ea7 authored by qiang yin's avatar qiang yin Committed by Ray Essick
Browse files

Add for Dolby thubmnail

There are many Dolby components.
If the right component is at the back of the codec list,
it will take much time to show thumbnail.

Test: Dolby thumbnail show in time.

Bug: 197069927
Change-Id: Id196493ccbdc0a67764458cf14de651b8935d363
parent a9e60472
Loading
Loading
Loading
Loading
+14 −0
Original line number Original line Diff line number Diff line
@@ -225,10 +225,17 @@ sp<IMemory> StagefrightMetadataRetriever::getImageInternal(
            "media.stagefright.thumbnail.prefer_hw_codecs", false);
            "media.stagefright.thumbnail.prefer_hw_codecs", false);
    uint32_t flags = preferhw ? 0 : MediaCodecList::kPreferSoftwareCodecs;
    uint32_t flags = preferhw ? 0 : MediaCodecList::kPreferSoftwareCodecs;
    Vector<AString> matchingCodecs;
    Vector<AString> matchingCodecs;
    sp<AMessage> format = new AMessage;
    status_t err = convertMetaDataToMessage(trackMeta, &format);
    if (err != OK) {
        format = NULL;
    }

    MediaCodecList::findMatchingCodecs(
    MediaCodecList::findMatchingCodecs(
            mime,
            mime,
            false, /* encoder */
            false, /* encoder */
            flags,
            flags,
            format,
            &matchingCodecs);
            &matchingCodecs);


    for (size_t i = 0; i < matchingCodecs.size(); ++i) {
    for (size_t i = 0; i < matchingCodecs.size(); ++i) {
@@ -348,11 +355,18 @@ sp<IMemory> StagefrightMetadataRetriever::getFrameInternal(
    bool preferhw = property_get_bool(
    bool preferhw = property_get_bool(
            "media.stagefright.thumbnail.prefer_hw_codecs", false);
            "media.stagefright.thumbnail.prefer_hw_codecs", false);
    uint32_t flags = preferhw ? 0 : MediaCodecList::kPreferSoftwareCodecs;
    uint32_t flags = preferhw ? 0 : MediaCodecList::kPreferSoftwareCodecs;
    sp<AMessage> format = new AMessage;
    status_t err = convertMetaDataToMessage(trackMeta, &format);
    if (err != OK) {
        format = NULL;
    }

    Vector<AString> matchingCodecs;
    Vector<AString> matchingCodecs;
    MediaCodecList::findMatchingCodecs(
    MediaCodecList::findMatchingCodecs(
            mime,
            mime,
            false, /* encoder */
            false, /* encoder */
            flags,
            flags,
            format,
            &matchingCodecs);
            &matchingCodecs);


    for (size_t i = 0; i < matchingCodecs.size(); ++i) {
    for (size_t i = 0; i < matchingCodecs.size(); ++i) {
+23 −0
Original line number Original line Diff line number Diff line
@@ -509,6 +509,29 @@ bool MediaCodecList::codecHandlesFormat(const char *mime, sp<MediaCodecInfo> inf
                }
                }
            }
            }
        }
        }

        int32_t profile = -1;
        if (format->findInt32("profile", &profile)) {
            int32_t level = -1;
            format->findInt32("level", &level);
            Vector<MediaCodecInfo::ProfileLevel> profileLevels;
            capabilities->getSupportedProfileLevels(&profileLevels);
            auto it = profileLevels.begin();
            for (; it != profileLevels.end(); ++it) {
                if (profile != it->mProfile) {
                    continue;
                }
                if (level > -1 && level > it->mLevel) {
                    continue;
                }
                break;
            }

            if (it == profileLevels.end()) {
                ALOGV("Codec does not support profile %d with level %d", profile, level);
                return false;
            }
        }
    }
    }


    // haven't found a reason to discard this one
    // haven't found a reason to discard this one