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

Commit 4b7bb0ac authored by Wonsik Kim's avatar Wonsik Kim
Browse files

codec2: recognize AV1Main10 profile support

Bug: 191687652
Test: cts/media/device-small
Change-Id: Ic0026d72c659ae51aea973315e9875e019107c32
parent 16f2a93c
Loading
Loading
Loading
Loading
+14 −1
Original line number Original line Diff line number Diff line
@@ -96,9 +96,12 @@ bool addSupportedProfileLevels(
        return false;
        return false;
    }
    }


    // determine if codec supports HDR
    // determine if codec supports HDR; imply 10-bit support
    bool supportsHdr = false;
    bool supportsHdr = false;
    // determine if codec supports HDR10Plus; imply 10-bit support
    bool supportsHdr10Plus = false;
    bool supportsHdr10Plus = false;
    // determine if codec supports 10-bit format
    bool supports10Bit = false;


    std::vector<std::shared_ptr<C2ParamDescriptor>> paramDescs;
    std::vector<std::shared_ptr<C2ParamDescriptor>> paramDescs;
    c2_status_t err1 = intf->querySupportedParams(&paramDescs);
    c2_status_t err1 = intf->querySupportedParams(&paramDescs);
@@ -126,6 +129,10 @@ bool addSupportedProfileLevels(
    supportsHdr |= (mediaType == MIMETYPE_VIDEO_VP9);
    supportsHdr |= (mediaType == MIMETYPE_VIDEO_VP9);
    supportsHdr |= (mediaType == MIMETYPE_VIDEO_AV1);
    supportsHdr |= (mediaType == MIMETYPE_VIDEO_AV1);


    // HDR support implies 10-bit support.
    // TODO: directly check this from the component interface
    supports10Bit = (supportsHdr || supportsHdr10Plus);

    bool added = false;
    bool added = false;


    for (C2Value::Primitive profile : profileQuery[0].values.values) {
    for (C2Value::Primitive profile : profileQuery[0].values.values) {
@@ -165,6 +172,12 @@ bool addSupportedProfileLevels(
                    }
                    }
                }
                }
            }
            }
            if (supports10Bit) {
                auto bitnessMapper = C2Mapper::GetBitDepthProfileLevelMapper(trait.mediaType, 10);
                if (bitnessMapper && bitnessMapper->mapProfile(pl.profile, &sdkProfile)) {
                    caps->addProfileLevel((uint32_t)sdkProfile, (uint32_t)sdkLevel);
                }
            }
        } else if (!mapper) {
        } else if (!mapper) {
            caps->addProfileLevel(pl.profile, pl.level);
            caps->addProfileLevel(pl.profile, pl.level);
        }
        }
+27 −10
Original line number Original line Diff line number Diff line
@@ -381,15 +381,17 @@ ALookup<C2Config::level_t, int32_t> sAv1Levels = {
    { C2Config::LEVEL_AV1_7_3,  AV1Level73 },
    { C2Config::LEVEL_AV1_7_3,  AV1Level73 },
};
};



ALookup<C2Config::profile_t, int32_t> sAv1Profiles = {
ALookup<C2Config::profile_t, int32_t> sAv1Profiles = {
    // TODO: will need to disambiguate between Main8 and Main10
    { C2Config::PROFILE_AV1_0, AV1ProfileMain8 },
    { C2Config::PROFILE_AV1_0, AV1ProfileMain8 },
    { C2Config::PROFILE_AV1_0, AV1ProfileMain10 },
    { C2Config::PROFILE_AV1_0, AV1ProfileMain10 },
    { C2Config::PROFILE_AV1_0, AV1ProfileMain10HDR10 },
    { C2Config::PROFILE_AV1_0, AV1ProfileMain10HDR10 },
    { C2Config::PROFILE_AV1_0, AV1ProfileMain10HDR10Plus },
    { C2Config::PROFILE_AV1_0, AV1ProfileMain10HDR10Plus },
};
};


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

ALookup<C2Config::profile_t, int32_t> sAv1HdrProfiles = {
ALookup<C2Config::profile_t, int32_t> sAv1HdrProfiles = {
    { C2Config::PROFILE_AV1_0, AV1ProfileMain10HDR10 },
    { C2Config::PROFILE_AV1_0, AV1ProfileMain10HDR10 },
};
};
@@ -603,9 +605,9 @@ private:
};
};


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


    virtual bool simpleMap(C2Config::level_t from, int32_t *to) {
    virtual bool simpleMap(C2Config::level_t from, int32_t *to) {
        return sAv1Levels.map(from, to);
        return sAv1Levels.map(from, to);
@@ -614,12 +616,14 @@ struct Av1ProfileLevelMapper : ProfileLevelMapperHelper {
        return sAv1Levels.map(from, to);
        return sAv1Levels.map(from, to);
    }
    }
    virtual bool simpleMap(C2Config::profile_t from, int32_t *to) {
    virtual bool simpleMap(C2Config::profile_t from, int32_t *to) {
        return mIsHdr10Plus ? sAv1Hdr10PlusProfiles.map(from, to) :
        return (mBitDepth == 10) ? sAv1TenbitProfiles.map(from, to) :
                    mIsHdr10Plus ? sAv1Hdr10PlusProfiles.map(from, to) :
                          mIsHdr ? sAv1HdrProfiles.map(from, to) :
                          mIsHdr ? sAv1HdrProfiles.map(from, to) :
                                   sAv1Profiles.map(from, to);
                                   sAv1Profiles.map(from, to);
    }
    }
    virtual bool simpleMap(int32_t from, C2Config::profile_t *to) {
    virtual bool simpleMap(int32_t from, C2Config::profile_t *to) {
        return mIsHdr10Plus ? sAv1Hdr10PlusProfiles.map(from, to) :
        return (mBitDepth == 10) ? sAv1TenbitProfiles.map(from, to) :
                    mIsHdr10Plus ? sAv1Hdr10PlusProfiles.map(from, to) :
                          mIsHdr ? sAv1HdrProfiles.map(from, to) :
                          mIsHdr ? sAv1HdrProfiles.map(from, to) :
                                   sAv1Profiles.map(from, to);
                                   sAv1Profiles.map(from, to);
    }
    }
@@ -627,6 +631,7 @@ struct Av1ProfileLevelMapper : ProfileLevelMapperHelper {
private:
private:
    bool mIsHdr;
    bool mIsHdr;
    bool mIsHdr10Plus;
    bool mIsHdr10Plus;
    int32_t mBitDepth;
};
};


} // namespace
} // namespace
@@ -673,6 +678,18 @@ C2Mapper::GetHdrProfileLevelMapper(std::string mediaType, bool isHdr10Plus) {
    return nullptr;
    return nullptr;
}
}


// static
std::shared_ptr<C2Mapper::ProfileLevelMapper>
C2Mapper::GetBitDepthProfileLevelMapper(std::string mediaType, int32_t bitDepth) {
    std::transform(mediaType.begin(), mediaType.end(), mediaType.begin(), ::tolower);
    if (bitDepth == 8) {
        return GetProfileLevelMapper(mediaType);
    } else if (mediaType == MIMETYPE_VIDEO_AV1 && bitDepth == 10) {
        return std::make_shared<Av1ProfileLevelMapper>(false, false, bitDepth);
    }
    return nullptr;
}

// static
// static
bool C2Mapper::map(C2Config::bitrate_mode_t from, int32_t *to) {
bool C2Mapper::map(C2Config::bitrate_mode_t from, int32_t *to) {
    return sBitrateModes.map(from, to);
    return sBitrateModes.map(from, to);
+3 −0
Original line number Original line Diff line number Diff line
@@ -43,6 +43,9 @@ namespace android {
        static std::shared_ptr<ProfileLevelMapper>
        static std::shared_ptr<ProfileLevelMapper>
        GetHdrProfileLevelMapper(std::string mediaType, bool isHdr10Plus = false);
        GetHdrProfileLevelMapper(std::string mediaType, bool isHdr10Plus = false);


        static std::shared_ptr<ProfileLevelMapper>
        GetBitDepthProfileLevelMapper(std::string mediaType, int32_t bitDepth = 8);

        // convert between bitrates
        // convert between bitrates
        static bool map(C2Config::bitrate_mode_t, int32_t*);
        static bool map(C2Config::bitrate_mode_t, int32_t*);
        static bool map(int32_t, C2Config::bitrate_mode_t*);
        static bool map(int32_t, C2Config::bitrate_mode_t*);
+1 −1
Original line number Original line Diff line number Diff line
@@ -364,7 +364,7 @@ constexpr int32_t AV1ProfileMain10HDR10Plus = 0x2000;
inline static const char *asString_AV1Profile(int32_t i, const char *def = "??") {
inline static const char *asString_AV1Profile(int32_t i, const char *def = "??") {
    switch (i) {
    switch (i) {
        case AV1ProfileMain8:           return "Main8";
        case AV1ProfileMain8:           return "Main8";
        case AV1ProfileMain10:          return "Main10HDR";
        case AV1ProfileMain10:          return "Main10";
        case AV1ProfileMain10HDR10:     return "Main10HDR10";
        case AV1ProfileMain10HDR10:     return "Main10HDR10";
        case AV1ProfileMain10HDR10Plus: return "Main10HDRPlus";
        case AV1ProfileMain10HDR10Plus: return "Main10HDRPlus";
        default:                        return def;
        default:                        return def;