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

Commit 094e025e authored by Ram Mohan's avatar Ram Mohan
Browse files

Fix configuring of unrecognized level values

If bad or unrecognized or unsupported level values are configured,
it is possible that they get sent to encoder during configuration.
Avoid this and choose an appropriate level basing on encoder config
settings

Bug: 278199885
Test: atest android.mediav2.cts.EncoderProfileLevelTest

Change-Id: I24e3f36487d8f801fa30bdea4c17fb71557f1a95
parent d78c656e
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -334,7 +334,10 @@ public:
        // By default needsUpdate = false in case the supplied level does meet
        // the requirements. For Level 1b, we want to update the level anyway,
        // so we set it to true in that case.
        bool needsUpdate = (me.v.level == LEVEL_AVC_1B);
        bool needsUpdate = false;
        if (me.v.level == LEVEL_AVC_1B || !me.F(me.v.level).supportsAtAll(me.v.level)) {
            needsUpdate = true;
        }
        for (const LevelLimits &limit : kLimits) {
            if (mbs <= limit.mbs && mbsPerSec <= limit.mbsPerSec &&
                    bitrate.v.value <= limit.bitrate) {
+3 −0
Original line number Diff line number Diff line
@@ -341,6 +341,9 @@ class C2SoftHevcEnc::IntfImpl : public SimpleInterface<void>::BaseParams {
        // By default needsUpdate = false in case the supplied level does meet
        // the requirements.
        bool needsUpdate = false;
        if (!me.F(me.v.level).supportsAtAll(me.v.level)) {
            needsUpdate = true;
        }
        for (const LevelLimits &limit : kLimits) {
            if (samples <= limit.samples && samplesPerSec <= limit.samplesPerSec &&
                    bitrate.v.value <= limit.bitrate) {
+3 −0
Original line number Diff line number Diff line
@@ -243,6 +243,9 @@ class C2SoftMpeg4Enc::IntfImpl : public SimpleInterface<void>::BaseParams {
            needsUpdate = true;
        }
#endif
        if (!me.F(me.v.level).supportsAtAll(me.v.level)) {
            needsUpdate = true;
        }
        for (const LevelLimits &limit : kLimits) {
            if (sampleRate <= limit.sampleRate && size.v.width <= limit.width &&
                    vbvSize <= limit.vbvSize && size.v.height <= limit.height &&
+3 −0
Original line number Diff line number Diff line
@@ -263,6 +263,9 @@ C2R C2SoftVpxEnc::IntfImpl::ProfileLevelSetter(bool mayBlock,
    // By default needsUpdate = false in case the supplied level does meet
    // the requirements.
    bool needsUpdate = false;
    if (!me.F(me.v.level).supportsAtAll(me.v.level)) {
        needsUpdate = true;
    }
    for (const LevelLimits& limit : kLimits) {
        if (samples <= limit.samples && samplesPerSec <= limit.samplesPerSec &&
            bitrate.v.value <= limit.bitrate && dimension <= limit.dimension) {