libs: encoder: h265: Set encoder paramters base on entrypoint.

When the tune is NONE, we now can choose entrypoint freely. So the
GST_VAAPI_ENCODER_TUNE macro may not return the correct current
entrypoint.
We also delay CTU size calculation after entrypoint has been decided.
This commit is contained in:
He Junyan 2019-12-26 16:45:51 +08:00 committed by Víctor Manuel Jáquez Leal
parent 9da5196b5a
commit 6c7d445010

View file

@ -1577,7 +1577,7 @@ fill_sequence (GstVaapiEncoderH265 * encoder, GstVaapiEncSequence * sequence)
/* Based on 32x32 CTU (64x64 when using lowpower mode for hardware limitation) */
seq_param->log2_min_luma_coding_block_size_minus3 = 0;
if (GST_VAAPI_ENCODER_TUNE (encoder) == GST_VAAPI_ENCODER_TUNE_LOW_POWER)
if (encoder->entrypoint == GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_LP)
seq_param->log2_diff_max_min_luma_coding_block_size = 3;
else
seq_param->log2_diff_max_min_luma_coding_block_size = 2;
@ -1677,7 +1677,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
|| GST_VAAPI_ENCODER_TUNE (encoder) == GST_VAAPI_ENCODER_TUNE_LOW_POWER)
|| encoder->entrypoint == GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_LP)
pic_param->pic_fields.bits.cu_qp_delta_enabled_flag = 1;
/* XXX: Intel's media-driver, when using low-power mode, requires
@ -1686,7 +1686,7 @@ fill_picture (GstVaapiEncoderH265 * encoder, GstVaapiEncPicture * picture,
*
* For now we assume that on only Intel's media-drivers supports
* H265 low-power */
if ((GST_VAAPI_ENCODER_TUNE (encoder) == GST_VAAPI_ENCODER_TUNE_LOW_POWER) &&
if ((encoder->entrypoint == GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_LP) &&
(pic_param->pic_fields.bits.cu_qp_delta_enabled_flag))
pic_param->diff_cu_qp_delta_depth = 3;
@ -2605,13 +2605,6 @@ gst_vaapi_encoder_h265_reconfigure (GstVaapiEncoder * base_encoder)
GST_VAAPI_ENCODER_HEIGHT (encoder));
encoder->luma_width = GST_ROUND_UP_16 (luma_width);
encoder->luma_height = GST_ROUND_UP_16 (luma_height);
if (GST_VAAPI_ENCODER_TUNE (encoder) == GST_VAAPI_ENCODER_TUNE_LOW_POWER) {
encoder->ctu_width = (encoder->luma_width + 63) / 64;
encoder->ctu_height = (encoder->luma_height + 63) / 64;
} else {
encoder->ctu_width = (encoder->luma_width + 31) / 32;
encoder->ctu_height = (encoder->luma_height + 31) / 32;
}
encoder->config_changed = TRUE;
/* Frame Cropping */
if ((GST_VAAPI_ENCODER_WIDTH (encoder) & 15) ||
@ -2634,6 +2627,15 @@ gst_vaapi_encoder_h265_reconfigure (GstVaapiEncoder * base_encoder)
if (status != GST_VAAPI_ENCODER_STATUS_SUCCESS)
return status;
/* Set ctu size based on entrypoint. */
if (encoder->entrypoint == GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_LP) {
encoder->ctu_width = (encoder->luma_width + 63) / 64;
encoder->ctu_height = (encoder->luma_height + 63) / 64;
} else {
encoder->ctu_width = (encoder->luma_width + 31) / 32;
encoder->ctu_height = (encoder->luma_height + 31) / 32;
}
reset_properties (encoder);
ensure_control_rate_params (encoder);
return set_context_info (base_encoder);