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

Commit 913d85bd authored by Harish Mahendrakar's avatar Harish Mahendrakar Committed by Cherrypicker Worker
Browse files

C2SoftDav1dDec: Drain and signal resolution change based on seq header

When resolution change is detected based on seq header, drain all
the pictures from the decoder and signal resolution change.

This ensures output format change is signaled correctly when decoder
returns buffer corresponding to new resolution.

Bug: 317306503
Test: atest CtsMediaDecoderTestCases -- --module-arg \
CtsMediaDecoderTestCases:instrumentation-arg:\
codec-prefix:=c2.android.av1

Test: atest CtsMediaV2TestCases --  --module-arg \
CtsMediaV2TestCases:instrumentation-arg:codec-prefix:=c2.android.av1
(cherry picked from https://android-review.googlesource.com/q/commit:d74f2f061bacbb93e57b152aa79484117d300909)
Merged-In: I627380e916aa5bc3aa4b50e3396ade352ec60715
Change-Id: I627380e916aa5bc3aa4b50e3396ade352ec60715
parent 1b4b7371
Loading
Loading
Loading
Loading
+18 −20
Original line number Diff line number Diff line
@@ -648,6 +648,24 @@ void C2SoftDav1dDec::process(const std::unique_ptr<C2Work>& work,
            if (res == 0) {
                ALOGV("dav1d found a sequenceHeader (%dx%d) for in_frameIndex=%ld.", seq.max_width,
                      seq.max_height, (long)in_frameIndex);
                if (seq.max_width != mWidth || seq.max_height != mHeight) {
                    drainInternal(DRAIN_COMPONENT_NO_EOS, pool, work);
                    mWidth = seq.max_width;
                    mHeight = seq.max_height;

                    C2StreamPictureSizeInfo::output size(0u, mWidth, mHeight);
                    std::vector<std::unique_ptr<C2SettingResult>> failures;
                    c2_status_t err = mIntf->config({&size}, C2_MAY_BLOCK, &failures);
                    if (err == C2_OK) {
                        work->worklets.front()->output.configUpdate.push_back(C2Param::Copy(size));
                    } else {
                        ALOGE("Config update size failed");
                        mSignalledError = true;
                        work->result = C2_CORRUPTED;
                        work->workletsProcessed = 1u;
                        return;
                    }
                }
            }

            // insert OBU TD if it is not present.
@@ -921,26 +939,6 @@ bool C2SoftDav1dDec::outputBuffer(const std::shared_ptr<C2BlockPool>& pool,
        return false;
    }

    const int width = img.p.w;
    const int height = img.p.h;
    if (width != mWidth || height != mHeight) {
        mWidth = width;
        mHeight = height;

        C2StreamPictureSizeInfo::output size(0u, mWidth, mHeight);
        std::vector<std::unique_ptr<C2SettingResult>> failures;
        c2_status_t err = mIntf->config({&size}, C2_MAY_BLOCK, &failures);
        if (err == C2_OK) {
            work->worklets.front()->output.configUpdate.push_back(C2Param::Copy(size));
        } else {
            ALOGE("Config update size failed");
            mSignalledError = true;
            work->result = C2_CORRUPTED;
            work->workletsProcessed = 1u;
            return false;
        }
    }

    getVuiParams(&img);

    // out_frameIndex that the decoded picture returns from dav1d.