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

Commit 32ca6520 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5588664 from 940ec51a to qt-c2f2-release

Change-Id: If8d25c0476c54f9266e65181c8d9f320d553b58c
parents 25e5f8a2 940ec51a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -86,8 +86,8 @@ class C2SoftHevcEnc::IntfImpl : public SimpleInterface<void>::BaseParams {
            DefineParam(mSize, C2_PARAMKEY_PICTURE_SIZE)
                .withDefault(new C2StreamPictureSizeInfo::input(0u, 320, 240))
                .withFields({
                    C2F(mSize, width).inRange(320, 1920, 2),
                    C2F(mSize, height).inRange(128, 1088, 2),
                    C2F(mSize, width).inRange(2, 1920, 2),
                    C2F(mSize, height).inRange(2, 1088, 2),
                })
                .withSetter(SizeSetter)
                .build());
+6 −0
Original line number Diff line number Diff line
@@ -1993,6 +1993,12 @@ void MatroskaExtractor::addTracks() {
                    }
                } else if (!strcmp("V_AV1", codecID)) {
                    AMediaFormat_setString(meta, AMEDIAFORMAT_KEY_MIME, MEDIA_MIMETYPE_VIDEO_AV1);
                    if (codecPrivateSize > 0) {
                        // 'csd-0' for AV1 is the Blob of Codec Private data as
                        // specified in https://aomediacodec.github.io/av1-isobmff/.
                        AMediaFormat_setBuffer(
                                meta, AMEDIAFORMAT_KEY_CSD_0, codecPrivate, codecPrivateSize);
                    }
                } else if (!strcmp("V_MPEG2", codecID) || !strcmp("V_MPEG1", codecID)) {
                        AMediaFormat_setString(meta, AMEDIAFORMAT_KEY_MIME,
                                MEDIA_MIMETYPE_VIDEO_MPEG2);
+64 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@
#include <media/stagefright/foundation/ByteUtils.h>
#include <media/stagefright/foundation/OpusHeader.h>
#include <media/stagefright/MetaData.h>
#include <media/stagefright/MediaCodecConstants.h>
#include <media/stagefright/MediaDefs.h>
#include <media/AudioSystem.h>
#include <media/MediaPlayerInterface.h>
@@ -573,6 +574,68 @@ static void parseVp9ProfileLevelFromCsd(const sp<ABuffer> &csd, sp<AMessage> &fo
    }
}

static void parseAV1ProfileLevelFromCsd(const sp<ABuffer> &csd, sp<AMessage> &format) {
    // Parse CSD structure to extract profile level information
    // https://aomediacodec.github.io/av1-isobmff/#av1codecconfigurationbox
    const uint8_t *data = csd->data();
    size_t remaining = csd->size();
    if (remaining < 4 || data[0] != 0x81) {  // configurationVersion == 1
        return;
    }
    uint8_t profileData = (data[1] & 0xE0) >> 5;
    uint8_t levelData = data[1] & 0x1F;
    uint8_t highBitDepth = (data[2] & 0x40) >> 6;

    const static ALookup<std::pair<uint8_t, uint8_t>, int32_t> profiles {
        { { 0, 0 }, AV1ProfileMain8 },
        { { 1, 0 }, AV1ProfileMain10 },
    };

    int32_t profile;
    if (profiles.map(std::make_pair(highBitDepth, profileData), &profile)) {
        // bump to HDR profile
        if (isHdr(format) && profile == AV1ProfileMain10) {
            if (format->contains("hdr10-plus-info")) {
                profile = AV1ProfileMain10HDR10Plus;
            } else {
                profile = AV1ProfileMain10HDR10;
            }
        }
        format->setInt32("profile", profile);
    }
    const static ALookup<uint8_t, int32_t> levels {
        { 0, AV1Level2   },
        { 1, AV1Level21  },
        { 2, AV1Level22  },
        { 3, AV1Level23  },
        { 4, AV1Level3   },
        { 5, AV1Level31  },
        { 6, AV1Level32  },
        { 7, AV1Level33  },
        { 8, AV1Level4   },
        { 9, AV1Level41  },
        { 10, AV1Level42  },
        { 11, AV1Level43  },
        { 12, AV1Level5   },
        { 13, AV1Level51  },
        { 14, AV1Level52  },
        { 15, AV1Level53  },
        { 16, AV1Level6   },
        { 17, AV1Level61  },
        { 18, AV1Level62  },
        { 19, AV1Level63  },
        { 20, AV1Level7   },
        { 21, AV1Level71  },
        { 22, AV1Level72  },
        { 23, AV1Level73  },
    };

    int32_t level;
    if (levels.map(levelData, &level)) {
        format->setInt32("level", level);
    }
}


static std::vector<std::pair<const char *, uint32_t>> stringMappings {
    {
@@ -1234,6 +1297,7 @@ status_t convertMetaDataToMessage(
        buffer->meta()->setInt32("csd", true);
        buffer->meta()->setInt64("timeUs", 0);
        msg->setBuffer("csd-0", buffer);
        parseAV1ProfileLevelFromCsd(buffer, msg);
    } else if (meta->findData(kKeyESDS, &type, &data, &size)) {
        ESDS esds((const char *)data, size);
        if (esds.InitCheck() != (status_t)OK) {
+2 −1
Original line number Diff line number Diff line
@@ -109,11 +109,12 @@
        </MediaCodec>
        <MediaCodec name="c2.android.hevc.encoder" type="video/hevc">
            <!-- profiles and levels:  ProfileMain : MainTierLevel51 -->
            <Limit name="size" min="320x128" max="512x512" />
            <Limit name="size" min="2x2" max="512x512" />
            <Limit name="alignment" value="2x2" />
            <Limit name="block-size" value="8x8" />
            <Limit name="block-count" range="1-4096" /> <!-- max 512x512 -->
            <Limit name="blocks-per-second" range="1-122880" />
            <Limit name="frame-rate" range="1-120" />
            <Limit name="bitrate" range="1-10000000" />
            <Limit name="complexity" range="0-10"  default="0" />
            <Limit name="quality" range="0-100"  default="80" />
+2 −1
Original line number Diff line number Diff line
@@ -296,11 +296,12 @@
        </MediaCodec>
        <MediaCodec name="c2.android.hevc.encoder" type="video/hevc" variant="!slow-cpu">
            <!-- profiles and levels:  ProfileMain : MainTierLevel51 -->
            <Limit name="size" min="320x128" max="512x512" />
            <Limit name="size" min="2x2" max="512x512" />
            <Limit name="alignment" value="2x2" />
            <Limit name="block-size" value="8x8" />
            <Limit name="block-count" range="1-4096" /> <!-- max 512x512 -->
            <Limit name="blocks-per-second" range="1-122880" />
            <Limit name="frame-rate" range="1-120" />
            <Limit name="bitrate" range="1-10000000" />
            <Limit name="complexity" range="0-10"  default="0" />
            <Limit name="quality" range="0-100"  default="80" />