nvenc: Respect display aspect ratio and set to encoding parameter

It should be written in VUI parameter for proper rendering
This commit is contained in:
Seungha Yang 2019-05-09 15:11:17 +09:00
parent 39c8c206be
commit a512f5b6cd

View file

@ -1099,6 +1099,7 @@ gst_nv_base_enc_set_format (GstVideoEncoder * enc, GstVideoCodecState * state)
NV_ENC_INITIALIZE_PARAMS *params; NV_ENC_INITIALIZE_PARAMS *params;
NV_ENC_PRESET_CONFIG preset_config = { 0, }; NV_ENC_PRESET_CONFIG preset_config = { 0, };
NVENCSTATUS nv_ret; NVENCSTATUS nv_ret;
gint dar_n, dar_d;
g_atomic_int_set (&nvenc->reconfig, FALSE); g_atomic_int_set (&nvenc->reconfig, FALSE);
@ -1206,6 +1207,14 @@ gst_nv_base_enc_set_format (GstVideoEncoder * enc, GstVideoCodecState * state)
GST_FIXME_OBJECT (nvenc, "variable framerate"); GST_FIXME_OBJECT (nvenc, "variable framerate");
} }
if (gst_util_fraction_multiply (GST_VIDEO_INFO_WIDTH (info),
GST_VIDEO_INFO_HEIGHT (info), GST_VIDEO_INFO_PAR_N (info),
GST_VIDEO_INFO_PAR_D (info), &dar_n, &dar_d) && dar_n > 0
&& dar_d > 0) {
params->darWidth = dar_n;
params->darHeight = dar_d;
}
if (nvenc->rate_control_mode != GST_NV_RC_MODE_DEFAULT) { if (nvenc->rate_control_mode != GST_NV_RC_MODE_DEFAULT) {
params->encodeConfig->rcParams.rateControlMode = params->encodeConfig->rcParams.rateControlMode =
_rc_mode_to_nv (nvenc->rate_control_mode); _rc_mode_to_nv (nvenc->rate_control_mode);