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

Commit 1302f9dd authored by Hangyu Kuang's avatar Hangyu Kuang Committed by Android (Google) Code Review
Browse files

Merge "Stagefright: Add HDRStaticInfo support for encoder." into nyc-dev

parents 507ed029 5e2f5c10
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -425,10 +425,10 @@ private:
    // gets index or sets it to 0 on error. Returns error from codec.
    status_t initDescribeHDRStaticInfoIndex();

    // sets HDR static information for the decoder based on |configFormat|, and
    // set resulting HDRStaticInfo config into |outputFormat|. Returns error from the codec.
    status_t setHDRStaticInfoForVideoDecoder(
            const sp<AMessage> &configFormat, sp<AMessage> &outputFormat);
    // sets HDR static metadata for the video encoder/decoder based on |configFormat|, and
    // sets resulting HDRStaticInfo config into |outputFormat|. Returns error from the codec.
    status_t setHDRStaticInfoForVideoCodec(
            OMX_U32 portIndex, const sp<AMessage> &configFormat, sp<AMessage> &outputFormat);

    // sets |params|. Returns the codec error.
    status_t setHDRStaticInfo(const DescribeHDRStaticInfoParams &params);
@@ -436,8 +436,8 @@ private:
    // gets |params|. Returns the codec error.
    status_t getHDRStaticInfo(DescribeHDRStaticInfoParams &params);

    // gets HDR static information for the video decoder port and sets them into |format|.
    status_t getHDRStaticInfoForVideoDecoder(sp<AMessage> &format);
    // gets HDR static information for the video encoder/decoder port and sets them into |format|.
    status_t getHDRStaticInfoForVideoCodec(OMX_U32 portIndex, sp<AMessage> &format);

    typedef struct drcParams {
        int32_t drcCut;
+37 −21
Original line number Diff line number Diff line
@@ -3192,7 +3192,7 @@ status_t ACodec::setupVideoDecoder(
        return err;
    }

    err = setHDRStaticInfoForVideoDecoder(msg, outputFormat);
    err = setHDRStaticInfoForVideoCodec(kPortIndexOutput, msg, outputFormat);
    if (err == ERROR_UNSUPPORTED) { // support is optional
        err = OK;
    }
@@ -3392,6 +3392,25 @@ status_t ACodec::setColorAspectsForVideoEncoder(
    return OK;
}

status_t ACodec::setHDRStaticInfoForVideoCodec(
        OMX_U32 portIndex, const sp<AMessage> &configFormat, sp<AMessage> &outputFormat) {
    CHECK(portIndex == kPortIndexInput || portIndex == kPortIndexOutput);

    DescribeHDRStaticInfoParams params;
    InitOMXParams(&params);
    params.nPortIndex = portIndex;

    HDRStaticInfo *info = &params.sInfo;
    if (getHDRStaticInfoFromFormat(configFormat, info)) {
        setHDRStaticInfoIntoFormat(params.sInfo, outputFormat);
    }

    (void)initDescribeHDRStaticInfoIndex();

    // communicate HDR static Info to codec
    return setHDRStaticInfo(params);
}

// subsequent initial video encoder setup for surface mode
status_t ACodec::setInitialColorAspectsForVideoEncoderSurfaceAndGetDataSpace(
        android_dataspace *dataSpace /* nonnull */) {
@@ -3444,10 +3463,11 @@ status_t ACodec::setInitialColorAspectsForVideoEncoderSurfaceAndGetDataSpace(
    return err;
}

status_t ACodec::getHDRStaticInfoForVideoDecoder(sp<AMessage> &format) {
status_t ACodec::getHDRStaticInfoForVideoCodec(OMX_U32 portIndex, sp<AMessage> &format) {
    CHECK(portIndex == kPortIndexInput || portIndex == kPortIndexOutput);
    DescribeHDRStaticInfoParams params;
    InitOMXParams(&params);
    params.nPortIndex = kPortIndexOutput;
    params.nPortIndex = portIndex;

    status_t err = getHDRStaticInfo(params);
    if (err == OK) {
@@ -3466,23 +3486,6 @@ status_t ACodec::initDescribeHDRStaticInfoIndex() {
    return err;
}

status_t ACodec::setHDRStaticInfoForVideoDecoder(
        const sp<AMessage> &configFormat, sp<AMessage> &outputFormat) {
    DescribeHDRStaticInfoParams params;
    InitOMXParams(&params);
    params.nPortIndex = kPortIndexOutput;

    HDRStaticInfo *info = &params.sInfo;
    if (getHDRStaticInfoFromFormat(configFormat, info)) {
        setHDRStaticInfoIntoFormat(params.sInfo, outputFormat);
    }

    (void)initDescribeHDRStaticInfoIndex();

    // communicate HDR static Info to codec
    return setHDRStaticInfo(params);
}

status_t ACodec::setHDRStaticInfo(const DescribeHDRStaticInfoParams &params) {
    status_t err = ERROR_UNSUPPORTED;
    if (mDescribeHDRStaticInfoIndex) {
@@ -3697,6 +3700,16 @@ status_t ACodec::setupVideoEncoder(
        err = OK;
    }

    if (err != OK) {
        return err;
    }

    err = setHDRStaticInfoForVideoCodec(kPortIndexInput, msg, outputFormat);
    if (err == ERROR_UNSUPPORTED) { // support is optional
        ALOGI("[%s] cannot encode HDR static metadata. Ignoring.", mComponentName.c_str());
        err = OK;
    }

    if (err == OK) {
        ALOGI("setupVideoEncoder succeeded");
    }
@@ -4729,9 +4742,12 @@ status_t ACodec::getPortFormat(OMX_U32 portIndex, sp<AMessage> &notify) {
                        if (mUsingNativeWindow) {
                            notify->setInt32("android._dataspace", dataSpace);
                        }
                        (void)getHDRStaticInfoForVideoDecoder(notify);
                        (void)getHDRStaticInfoForVideoCodec(kPortIndexOutput, notify);
                    } else {
                        (void)getInputColorAspectsForVideoEncoder(notify);
                        if (mConfigFormat->contains("hdr-static-info")) {
                            (void)getHDRStaticInfoForVideoCodec(kPortIndexInput, notify);
                        }
                    }

                    break;