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

Commit 65a07864 authored by Fyodor Kyslov's avatar Fyodor Kyslov
Browse files

APV: Correctly report format change

Correctly report resolution and color aspect change in the middle of the
stream

Bug: 397914686
Test: atest MctsMediaV2TestCases
Change-Id: Iad7187d8d1dae7bb09163fa05767d6425ab04566
parent f46f9b70
Loading
Loading
Loading
Loading
+36 −3
Original line number Diff line number Diff line
@@ -959,6 +959,7 @@ void C2SoftApvDec::process(const std::unique_ptr<C2Work>& work,
            return;
        }

        bool reportResolutionChange = false;
        for (int i = 0; i < mOutFrames.num_frms; i++) {
            oapv_frm_info_t* finfo = &aui.frm_info[i];
            oapv_frm_t* frm = &mOutFrames.frm[i];
@@ -966,6 +967,7 @@ void C2SoftApvDec::process(const std::unique_ptr<C2Work>& work,
            if (mWidth != finfo->w || mHeight != finfo->h) {
                mWidth = finfo->w;
                mHeight = finfo->h;
                reportResolutionChange = true;
            }

            if (mWidth > MAX_SUPPORTED_WIDTH || mHeight > MAX_SUPPORTED_HEIGHT) {
@@ -994,6 +996,22 @@ void C2SoftApvDec::process(const std::unique_ptr<C2Work>& work,
            }
        }

        if (reportResolutionChange) {
            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->workletsProcessed = 1u;
                work->result = C2_CORRUPTED;
                return;
            }
        }

        oapvd_stat_t stat;
        ret = oapvd_decode(mDecHandle, &bitb, &mOutFrames, mMetadataHandle, &stat);
        if (bitb.ssize != stat.read) {
@@ -1041,7 +1059,7 @@ void C2SoftApvDec::process(const std::unique_ptr<C2Work>& work,
    }
}

void C2SoftApvDec::getVuiParams() {
void C2SoftApvDec::getVuiParams(const std::unique_ptr<C2Work> &work) {
    // convert vui aspects to C2 values if changed
    if (!(vuiColorAspects == mBitstreamColorAspects)) {
        mBitstreamColorAspects = vuiColorAspects;
@@ -1066,7 +1084,17 @@ void C2SoftApvDec::getVuiParams() {
                codedAspects.primaries, codedAspects.transfer, codedAspects.matrix,
                codedAspects.range);
        std::vector<std::unique_ptr<C2SettingResult>> failures;
        mIntf->config({&codedAspects}, C2_MAY_BLOCK, &failures);
        c2_status_t err = mIntf->config({&codedAspects}, C2_MAY_BLOCK, &failures);
        if (err == C2_OK) {
            work->worklets.front()->output.configUpdate.push_back(
              C2Param::Copy(codedAspects));
        } else {
            ALOGE("Config update colorAspect failed");
            mSignalledError = true;
            work->workletsProcessed = 1u;
            work->result = C2_CORRUPTED;
            return;
        }
    }
}

@@ -1245,12 +1273,17 @@ status_t C2SoftApvDec::outputBuffer(const std::shared_ptr<C2BlockPool>& pool,
    }
    bool isMonochrome = OAPV_CS_GET_FORMAT(imgbOutput->cs) == OAPV_CS_YCBCR400;

    getVuiParams();
    getVuiParams(work);
    struct ApvHdrInfo hdrInfo = {};
    getHdrInfo(&hdrInfo, groupId);
    getHDRStaticParams(&hdrInfo, work);
    getHDR10PlusInfoData(&hdrInfo, work);

    if (mSignalledError) {
        // 'work' should already have signalled error at this point
        return C2_CORRUPTED;
    }

    uint32_t format = HAL_PIXEL_FORMAT_YV12;
    if (mPixelFormatInfo->value != HAL_PIXEL_FORMAT_YCBCR_420_888) {
        if (isHalPixelFormatSupported((AHardwareBuffer_Format)AHARDWAREBUFFER_FORMAT_YCbCr_P210)) {
+1 −1
Original line number Diff line number Diff line
@@ -146,7 +146,7 @@ struct C2SoftApvDec final : public SimpleC2Component {

    int mOutCsp;

    void getVuiParams();
    void getVuiParams(const std::unique_ptr<C2Work> &work);
    void getHdrInfo(struct ApvHdrInfo *buffer, int id);
    void getHDRStaticParams(const struct ApvHdrInfo *buffer, const std::unique_ptr<C2Work>& work);
    void getHDR10PlusInfoData(const struct ApvHdrInfo *buffer, const std::unique_ptr<C2Work>& work);