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

Commit f249d724 authored by Lajos Molnar's avatar Lajos Molnar Committed by android-build-merger
Browse files

CodecCapabilities: advertise constrained profiles for decoders

am: 06e98369

Change-Id: I98ced1fa0ec577bba872192cc25ae60e8ff91f17
parents 8bf0fede 06e98369
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -105,11 +105,17 @@ void MediaCodecInfo::CapabilitiesBuilder::addProfileLevel(uint32_t profile, uint
    ProfileLevel profileLevel;
    profileLevel.mProfile = profile;
    profileLevel.mLevel = level;
    if (mProfileLevelsSorted.indexOf(profileLevel) < 0) {
        mProfileLevels.push_back(profileLevel);
        mProfileLevelsSorted.add(profileLevel);
    }
}

void MediaCodecInfo::CapabilitiesBuilder::addColorFormat(uint32_t format) {
    if (mColorFormatsSorted.indexOf(format) < 0) {
        mColorFormats.push(format);
        mColorFormatsSorted.add(format);
    }
}

void MediaCodecInfo::CapabilitiesBuilder::addFlags(uint32_t flags) {
+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@

#include <media/openmax/OMX_Core.h>
#include <media/openmax/OMX_Video.h>
#include <media/openmax/OMX_VideoExt.h>

namespace android {

+5 −0
Original line number Diff line number Diff line
@@ -40,6 +40,9 @@ struct MediaCodecInfo : public RefBase {
    struct ProfileLevel {
        uint32_t mProfile;
        uint32_t mLevel;
        bool operator <(const ProfileLevel &o) const {
            return mProfile < o.mProfile || (mProfile == o.mProfile && mLevel < o.mLevel);
        }
    };

    struct Capabilities : public RefBase {
@@ -61,7 +64,9 @@ struct MediaCodecInfo : public RefBase {

    protected:
        Vector<ProfileLevel> mProfileLevels;
        SortedVector<ProfileLevel> mProfileLevelsSorted;
        Vector<uint32_t> mColorFormats;
        SortedVector<uint32_t> mColorFormatsSorted;
        uint32_t mFlags;
        sp<AMessage> mDetails;

+15 −15
Original line number Diff line number Diff line
@@ -4173,11 +4173,12 @@ status_t ACodec::setupH263EncoderParameters(const sp<AMessage> &msg) {
// static
int /* OMX_VIDEO_AVCLEVELTYPE */ ACodec::getAVCLevelFor(
        int width, int height, int rate, int bitrate,
        OMX_VIDEO_AVCPROFILETYPE profile) {
        OMX_VIDEO_AVCPROFILEEXTTYPE profile) {
    // convert bitrate to main/baseline profile kbps equivalent
    switch (profile) {
    switch ((uint32_t)profile) {
        case OMX_VIDEO_AVCProfileHigh10:
            bitrate = divUp(bitrate, 3000); break;
        case OMX_VIDEO_AVCProfileConstrainedHigh:
        case OMX_VIDEO_AVCProfileHigh:
            bitrate = divUp(bitrate, 1250); break;
        default:
@@ -8262,6 +8263,17 @@ status_t ACodec::queryCapabilities(
            }
            builder->addProfileLevel(param.eProfile, param.eLevel);

            // AVC components may not list the constrained profiles explicitly, but
            // decoders that support a profile also support its constrained version.
            // Encoders must explicitly support constrained profiles.
            if (!isEncoder && mime.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_AVC)) {
                if (param.eProfile == OMX_VIDEO_AVCProfileHigh) {
                    builder->addProfileLevel(OMX_VIDEO_AVCProfileConstrainedHigh, param.eLevel);
                } else if (param.eProfile == OMX_VIDEO_AVCProfileBaseline) {
                    builder->addProfileLevel(OMX_VIDEO_AVCProfileConstrainedBaseline, param.eLevel);
                }
            }

            if (index == kMaxIndicesToCheck) {
                ALOGW("[%s] stopping checking profiles after %u: %x/%x",
                        name.c_str(), index,
@@ -8275,7 +8287,6 @@ status_t ACodec::queryCapabilities(
        OMX_VIDEO_PARAM_PORTFORMATTYPE portFormat;
        InitOMXParams(&portFormat);
        portFormat.nPortIndex = isEncoder ? kPortIndexInput : kPortIndexOutput;
        Vector<uint32_t> supportedColors; // shadow copy to check for duplicates
        for (OMX_U32 index = 0; index <= kMaxIndicesToCheck; ++index) {
            portFormat.nIndex = index;
            status_t err = omxNode->getParameter(
@@ -8289,19 +8300,8 @@ status_t ACodec::queryCapabilities(
            if (IsFlexibleColorFormat(
                    omxNode, portFormat.eColorFormat, false /* usingNativeWindow */,
                    &flexibleEquivalent)) {
                bool marked = false;
                for (size_t i = 0; i < supportedColors.size(); ++i) {
                    if (supportedColors[i] == flexibleEquivalent) {
                        marked = true;
                        break;
                    }
                }
                if (!marked) {
                    supportedColors.push(flexibleEquivalent);
                builder->addColorFormat(flexibleEquivalent);
            }
            }
            supportedColors.push(portFormat.eColorFormat);
            builder->addColorFormat(portFormat.eColorFormat);

            if (index == kMaxIndicesToCheck) {
+2 −1
Original line number Diff line number Diff line
@@ -94,7 +94,8 @@ struct ACodec : public AHierarchicalStateMachine, public CodecBase {
    // some OMX components as auto level, and by others as invalid level.
    static int /* OMX_VIDEO_AVCLEVELTYPE */ getAVCLevelFor(
            int width, int height, int rate, int bitrate,
            OMX_VIDEO_AVCPROFILETYPE profile = OMX_VIDEO_AVCProfileBaseline);
            OMX_VIDEO_AVCPROFILEEXTTYPE profile =
                (OMX_VIDEO_AVCPROFILEEXTTYPE)OMX_VIDEO_AVCProfileBaseline);

    // Quirk still supported, even though deprecated
    enum Quirks {