From 993d46bb2ff28169b269e4a9f951539cc2da6f24 Mon Sep 17 00:00:00 2001 From: He Junyan Date: Mon, 22 Mar 2021 13:41:13 +0800 Subject: [PATCH] decoder: H265: Enable cu_qp_delta_enabled_flag when ROI If ROI is enabled, the CUs within the ROI region may have different QP from the other part of the picture. This needs us to enable the cu_qp_delta_enabled_flag even in the CQP mode. Part-of: --- gst-libs/gst/vaapi/gstvaapiencoder.c | 6 +++++- gst-libs/gst/vaapi/gstvaapiencoder_h265.c | 1 + gst-libs/gst/vaapi/gstvaapiencoder_objects.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/vaapi/gstvaapiencoder.c b/gst-libs/gst/vaapi/gstvaapiencoder.c index 6c103acec9..8ab33ca545 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder.c @@ -193,6 +193,8 @@ gst_vaapi_encoder_ensure_param_roi_regions (GstVaapiEncoder * encoder, g_quark_to_string (roi->roi_type), roi->id, roi->x, roi->y, roi->w, roi->h); + picture->has_roi = TRUE; + region_roi[i].roi_rectangle.x = roi->x; region_roi[i].roi_rectangle.y = roi->y; region_roi[i].roi_rectangle.width = roi->w; @@ -214,7 +216,9 @@ gst_vaapi_encoder_ensure_param_roi_regions (GstVaapiEncoder * encoder, } } - gst_vaapi_enc_picture_add_misc_param (picture, misc); + if (picture->has_roi) + gst_vaapi_enc_picture_add_misc_param (picture, misc); + gst_vaapi_codec_object_replace (&misc, NULL); #endif return TRUE; diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h265.c b/gst-libs/gst/vaapi/gstvaapiencoder_h265.c index 46db870c3c..caec85f041 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_h265.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder_h265.c @@ -2033,6 +2033,7 @@ fill_picture (GstVaapiEncoderH265 * encoder, GstVaapiEncPicture * picture, /* it seems driver requires enablement of cu_qp_delta_enabled_flag * to modifiy QP values in CBR mode or low power encoding */ if (GST_VAAPI_ENCODER_RATE_CONTROL (encoder) != GST_VAAPI_RATECONTROL_CQP + || picture->has_roi || encoder->entrypoint == GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_LP) pic_param->pic_fields.bits.cu_qp_delta_enabled_flag = 1; diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_objects.h b/gst-libs/gst/vaapi/gstvaapiencoder_objects.h index 8037c1842d..49f271dcd9 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_objects.h +++ b/gst-libs/gst/vaapi/gstvaapiencoder_objects.h @@ -266,6 +266,7 @@ struct _GstVaapiEncPicture guint frame_num; guint poc; guint temporal_id; + gboolean has_roi; }; G_GNUC_INTERNAL