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

Commit f93a4542 authored by Rakesh Kumar's avatar Rakesh Kumar Committed by Lajos Molnar
Browse files

Update to new AV1 profile definitions and support HDR info

Test: cts-tradefed run commandAndExit cts-dev -m CtsMediaTestCases \
 -t android.media.cts.DecoderTest#testAV1HdrStaticMetadata

Bug: 123756486
Change-Id: I673f91e7b6bd3c0f31fd67f035b5ece7f6a71844
parent 5448dc22
Loading
Loading
Loading
Loading
+58 −1
Original line number Diff line number Diff line
@@ -78,6 +78,26 @@ class C2SoftAomDec::IntfImpl : public SimpleInterface<void>::BaseParams {
                .withSetter(ProfileLevelSetter, mSize)
                .build());

        mHdr10PlusInfoInput = C2StreamHdr10PlusInfo::input::AllocShared(0);
        addParameter(
                DefineParam(mHdr10PlusInfoInput, C2_PARAMKEY_INPUT_HDR10_PLUS_INFO)
                .withDefault(mHdr10PlusInfoInput)
                .withFields({
                    C2F(mHdr10PlusInfoInput, m.value).any(),
                })
                .withSetter(Hdr10PlusInfoInputSetter)
                .build());

        mHdr10PlusInfoOutput = C2StreamHdr10PlusInfo::output::AllocShared(0);
        addParameter(
                DefineParam(mHdr10PlusInfoOutput, C2_PARAMKEY_OUTPUT_HDR10_PLUS_INFO)
                .withDefault(mHdr10PlusInfoOutput)
                .withFields({
                    C2F(mHdr10PlusInfoOutput, m.value).any(),
                })
                .withSetter(Hdr10PlusInfoOutputSetter)
                .build());

        addParameter(DefineParam(mMaxSize, C2_PARAMKEY_MAX_PICTURE_SIZE)
                         .withDefault(new C2StreamMaxPictureSizeTuning::output(
                             0u, 320, 240))
@@ -203,6 +223,18 @@ class C2SoftAomDec::IntfImpl : public SimpleInterface<void>::BaseParams {
        return mDefaultColorAspects;
    }

    static C2R Hdr10PlusInfoInputSetter(bool mayBlock, C2P<C2StreamHdr10PlusInfo::input> &me) {
        (void)mayBlock;
        (void)me;  // TODO: validate
        return C2R::Ok();
    }

    static C2R Hdr10PlusInfoOutputSetter(bool mayBlock, C2P<C2StreamHdr10PlusInfo::output> &me) {
        (void)mayBlock;
        (void)me;  // TODO: validate
        return C2R::Ok();
    }

  private:
    std::shared_ptr<C2StreamProfileLevelInfo::input> mProfileLevel;
    std::shared_ptr<C2StreamPictureSizeInfo::output> mSize;
@@ -211,6 +243,8 @@ class C2SoftAomDec::IntfImpl : public SimpleInterface<void>::BaseParams {
    std::shared_ptr<C2StreamColorInfo::output> mColorInfo;
    std::shared_ptr<C2StreamPixelFormatInfo::output> mPixelFormat;
    std::shared_ptr<C2StreamColorAspectsTuning::output> mDefaultColorAspects;
    std::shared_ptr<C2StreamHdr10PlusInfo::input> mHdr10PlusInfoInput;
    std::shared_ptr<C2StreamHdr10PlusInfo::output> mHdr10PlusInfoOutput;
};

C2SoftAomDec::C2SoftAomDec(const char* name, c2_node_id_t id,
@@ -341,7 +375,8 @@ void C2SoftAomDec::finishWork(uint64_t index,
                              const std::shared_ptr<C2GraphicBlock>& block) {
    std::shared_ptr<C2Buffer> buffer =
        createGraphicBuffer(block, C2Rect(mWidth, mHeight));
    auto fillWork = [buffer, index](const std::unique_ptr<C2Work>& work) {
    auto fillWork = [buffer, index, intf = this->mIntf](
            const std::unique_ptr<C2Work>& work) {
        uint32_t flags = 0;
        if ((work->input.flags & C2FrameData::FLAG_END_OF_STREAM) &&
            (c2_cntr64_t(index) == work->input.ordinal.frameIndex)) {
@@ -353,6 +388,28 @@ void C2SoftAomDec::finishWork(uint64_t index,
        work->worklets.front()->output.buffers.push_back(buffer);
        work->worklets.front()->output.ordinal = work->input.ordinal;
        work->workletsProcessed = 1u;

        for (const std::unique_ptr<C2Param> &param: work->input.configUpdate) {
            if (param) {
                C2StreamHdr10PlusInfo::input *hdr10PlusInfo =
                        C2StreamHdr10PlusInfo::input::From(param.get());

                if (hdr10PlusInfo != nullptr) {
                    std::vector<std::unique_ptr<C2SettingResult>> failures;
                    std::unique_ptr<C2Param> outParam = C2Param::CopyAsStream(
                            *param.get(), true /*output*/, param->stream());
                    c2_status_t err = intf->config(
                            { outParam.get() }, C2_MAY_BLOCK, &failures);
                    if (err == C2_OK) {
                        work->worklets.front()->output.configUpdate.push_back(
                                C2Param::Copy(*outParam.get()));
                    } else {
                        ALOGE("finishWork: Config update size failed");
                    }
                    break;
                }
            }
        }
    };
    if (work && c2_cntr64_t(index) == work->input.ordinal.frameIndex) {
        fillWork(work);
+25 −5
Original line number Diff line number Diff line
@@ -379,11 +379,19 @@ ALookup<C2Config::level_t, int32_t> sAv1Levels = {


ALookup<C2Config::profile_t, int32_t> sAv1Profiles = {
    { C2Config::PROFILE_AV1_0, AV1Profile0 },
    { C2Config::PROFILE_AV1_1, AV1Profile1 },
    { C2Config::PROFILE_AV1_2, AV1Profile2 },
    // TODO: will need to disambiguate between Main8 and Main10
    { C2Config::PROFILE_AV1_0, AV1ProfileMain8 },
    { C2Config::PROFILE_AV1_0, AV1ProfileMain10 },
};

ALookup<C2Config::profile_t, int32_t> sAv1HdrProfiles = {
    { C2Config::PROFILE_AV1_0, AV1ProfileMain10 },
    { C2Config::PROFILE_AV1_0, AV1ProfileMain10HDR10 },
};

ALookup<C2Config::profile_t, int32_t> sAv1Hdr10PlusProfiles = {
    { C2Config::PROFILE_AV1_0, AV1ProfileMain10HDR10Plus },
};

/**
 * A helper that passes through vendor extension profile and level values.
@@ -590,6 +598,10 @@ private:
};

struct Av1ProfileLevelMapper : ProfileLevelMapperHelper {
    Av1ProfileLevelMapper(bool isHdr = false, bool isHdr10Plus = false) :
        ProfileLevelMapperHelper(),
        mIsHdr(isHdr), mIsHdr10Plus(isHdr10Plus) {}

    virtual bool simpleMap(C2Config::level_t from, int32_t *to) {
        return sAv1Levels.map(from, to);
    }
@@ -597,11 +609,19 @@ struct Av1ProfileLevelMapper : ProfileLevelMapperHelper {
        return sAv1Levels.map(from, to);
    }
    virtual bool simpleMap(C2Config::profile_t from, int32_t *to) {
        return sAv1Profiles.map(from, to);
        return mIsHdr10Plus ? sAv1Hdr10PlusProfiles.map(from, to) :
                     mIsHdr ? sAv1HdrProfiles.map(from, to) :
                              sAv1Profiles.map(from, to);
    }
    virtual bool simpleMap(int32_t from, C2Config::profile_t *to) {
        return sAv1Profiles.map(from, to);
        return mIsHdr10Plus ? sAv1Hdr10PlusProfiles.map(from, to) :
                     mIsHdr ? sAv1HdrProfiles.map(from, to) :
                              sAv1Profiles.map(from, to);
    }

private:
    bool mIsHdr;
    bool mIsHdr10Plus;
};

} // namespace
+9 −7
Original line number Diff line number Diff line
@@ -356,15 +356,17 @@ inline static const char *asString_VP9Level(int32_t i, const char *def = "??") {
    }
}

constexpr int32_t AV1Profile0 = 0x01;
constexpr int32_t AV1Profile1 = 0x02;
constexpr int32_t AV1Profile2 = 0x04;
constexpr int32_t AV1ProfileMain8 = 0x1;
constexpr int32_t AV1ProfileMain10 = 0x2;
constexpr int32_t AV1ProfileMain10HDR10 = 0x1000;
constexpr int32_t AV1ProfileMain10HDR10Plus = 0x2000;

inline static const char *asString_AV1Profile(int32_t i, const char *def = "??") {
    switch (i) {
        case AV1Profile0:       return "0";
        case AV1Profile1:       return "1";
        case AV1Profile2:       return "2";
        case AV1ProfileMain8:           return "Main8";
        case AV1ProfileMain10:          return "Main10HDR";
        case AV1ProfileMain10HDR10:     return "Main10HDR10";
        case AV1ProfileMain10HDR10Plus: return "Main10HDRPlus";
        default:                        return def;
    }
}