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

Commit a76683e1 authored by Hangyu Kuang's avatar Hangyu Kuang Committed by android-build-merger
Browse files

media: Add colorAspect support to SoftHEVC decoder.

am: af9e7c44

Change-Id: I1d8e6c6e75fa3586dd52b74aaa8d964432c6b72b
parents 146de8a3 af9e7c44
Loading
Loading
Loading
Loading
+55 −0
Original line number Diff line number Diff line
@@ -182,6 +182,48 @@ status_t SoftHEVC::resetPlugin() {
    return OK;
}

bool SoftHEVC::getVUIParams() {
    IV_API_CALL_STATUS_T status;
    ihevcd_cxa_ctl_get_vui_params_ip_t s_ctl_get_vui_params_ip;
    ihevcd_cxa_ctl_get_vui_params_op_t s_ctl_get_vui_params_op;

    s_ctl_get_vui_params_ip.e_cmd = IVD_CMD_VIDEO_CTL;
    s_ctl_get_vui_params_ip.e_sub_cmd =
        (IVD_CONTROL_API_COMMAND_TYPE_T)IHEVCD_CXA_CMD_CTL_GET_VUI_PARAMS;

    s_ctl_get_vui_params_ip.u4_size =
        sizeof(ihevcd_cxa_ctl_get_vui_params_ip_t);

    s_ctl_get_vui_params_op.u4_size = sizeof(ihevcd_cxa_ctl_get_vui_params_op_t);

    status = ivdec_api_function(
            (iv_obj_t *)mCodecCtx, (void *)&s_ctl_get_vui_params_ip,
            (void *)&s_ctl_get_vui_params_op);

    if (status != IV_SUCCESS) {
        ALOGW("Error in getting VUI params: 0x%x",
                s_ctl_get_vui_params_op.u4_error_code);
        return false;
    }

    int32_t primaries = s_ctl_get_vui_params_op.u1_colour_primaries;
    int32_t transfer = s_ctl_get_vui_params_op.u1_transfer_characteristics;
    int32_t coeffs = s_ctl_get_vui_params_op.u1_matrix_coefficients;
    bool fullRange = s_ctl_get_vui_params_op.u1_video_full_range_flag;

    ColorAspects colorAspects;
    ColorUtils::convertIsoColorAspectsToCodecAspects(
            primaries, transfer, coeffs, fullRange, colorAspects);

    // Update color aspects if necessary.
    if (colorAspectsDiffer(colorAspects, mBitstreamColorAspects)) {
        mBitstreamColorAspects = colorAspects;
        status_t err = handleColorAspectsChange();
        CHECK(err == OK);
    }
    return true;
}

status_t SoftHEVC::resetDecoder() {
    ivd_ctl_reset_ip_t s_ctl_ip;
    ivd_ctl_reset_op_t s_ctl_op;
@@ -554,6 +596,8 @@ void SoftHEVC::onQueueFilled(OMX_U32 portIndex) {

            bool resChanged = (IVD_RES_CHANGED == (s_dec_op.u4_error_code & 0xFF));

            getVUIParams();

            GETTIME(&mTimeEnd, NULL);
            /* Compute time taken for decode() */
            TIME_DIFF(mTimeStart, mTimeEnd, timeTaken);
@@ -589,6 +633,8 @@ void SoftHEVC::onQueueFilled(OMX_U32 portIndex) {
                continue;
            }

            // Combine the resolution change and coloraspects change in one PortSettingChange event
            // if necessary.
            if ((0 < s_dec_op.u4_pic_wd) && (0 < s_dec_op.u4_pic_ht)) {
                uint32_t width = s_dec_op.u4_pic_wd;
                uint32_t height = s_dec_op.u4_pic_ht;
@@ -599,6 +645,11 @@ void SoftHEVC::onQueueFilled(OMX_U32 portIndex) {
                    resetDecoder();
                    return;
                }
            } else if (mUpdateColorAspects) {
                notify(OMX_EventPortSettingsChanged, kOutputPortIndex,
                    kDescribeColorAspectsIndex, NULL);
                mUpdateColorAspects = false;
                return;
            }

            if (s_dec_op.u4_output_present) {
@@ -654,6 +705,10 @@ void SoftHEVC::onQueueFilled(OMX_U32 portIndex) {
    }
}

int SoftHEVC::getColorAspectPreference() {
    return kPreferBitstream;
}

}  // namespace android

android::SoftOMXComponent *createSoftOMXComponent(const char *name,
+3 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ protected:
    virtual void onQueueFilled(OMX_U32 portIndex);
    virtual void onPortFlushCompleted(OMX_U32 portIndex);
    virtual void onReset();
    virtual int getColorAspectPreference();
private:
    // Number of input and output buffers
    enum {
@@ -112,6 +113,8 @@ private:
        OMX_BUFFERHEADERTYPE *outHeader,
        size_t timeStampIx);

    bool getVUIParams();

    DISALLOW_EVIL_CONSTRUCTORS (SoftHEVC);
};