libs: encoder: vp8,h264,h265,mpeg2: set misc param once

Instead of recalculating the miscellaneous buffer parameters for
every buffer, it is only done once, when the encoder is configured.
And for every buffer, the same structures are just copied.

https://bugzilla.gnome.org/show_bug.cgi?id=783449
This commit is contained in:
Víctor Manuel Jáquez Leal 2017-06-05 20:30:07 +02:00
parent acf106e1a7
commit 846c276e26
4 changed files with 16 additions and 20 deletions

View file

@ -2154,11 +2154,8 @@ error_create_packed_seq_hdr:
}
static gboolean
ensure_control_rate_params (GstVaapiEncoderH264 * encoder,
GstVaapiEncPicture * picture)
ensure_control_rate_params (GstVaapiEncoderH264 * encoder)
{
GstVaapiEncoder *const base_encoder = GST_VAAPI_ENCODER_CAST (encoder);
if (GST_VAAPI_ENCODER_RATE_CONTROL (encoder) == GST_VAAPI_RATECONTROL_CQP)
return TRUE;
@ -2176,7 +2173,7 @@ ensure_control_rate_params (GstVaapiEncoderH264 * encoder,
fill_hrd_params (encoder, &GST_VAAPI_ENCODER_VA_HRD (encoder));
/* *INDENT-ON* */
return gst_vaapi_encoder_ensure_param_control_rate (base_encoder, picture);
return TRUE;
}
/* Generates additional control parameters */
@ -2187,7 +2184,7 @@ ensure_misc_params (GstVaapiEncoderH264 * encoder, GstVaapiEncPicture * picture)
GstVaapiEncMiscParam *misc;
guint num_roi;
if (!ensure_control_rate_params (encoder, picture))
if (!gst_vaapi_encoder_ensure_param_control_rate (base_encoder, picture))
return FALSE;
if (GST_VAAPI_ENCODER_RATE_CONTROL (encoder) == GST_VAAPI_RATECONTROL_CBR ||
@ -2848,6 +2845,7 @@ gst_vaapi_encoder_h264_reconfigure (GstVaapiEncoder * base_encoder)
return status;
reset_properties (encoder);
ensure_control_rate_params (encoder);
return set_context_info (base_encoder);
}

View file

@ -1766,18 +1766,15 @@ error_create_packed_seq_hdr:
}
static gboolean
ensure_control_rate_params (GstVaapiEncoderH265 * encoder,
GstVaapiEncPicture * picture)
ensure_control_rate_params (GstVaapiEncoderH265 * encoder)
{
GstVaapiEncoder *const base_encoder = GST_VAAPI_ENCODER_CAST (encoder);
if (GST_VAAPI_ENCODER_RATE_CONTROL (encoder) == GST_VAAPI_RATECONTROL_CQP)
return TRUE;
/* HRD params */
fill_hrd_params (encoder, &GST_VAAPI_ENCODER_VA_HRD (encoder));
return gst_vaapi_encoder_ensure_param_control_rate (base_encoder, picture);
return TRUE;
}
static gboolean
@ -1785,7 +1782,7 @@ ensure_misc_params (GstVaapiEncoderH265 * encoder, GstVaapiEncPicture * picture)
{
GstVaapiEncoder *const base_encoder = GST_VAAPI_ENCODER_CAST (encoder);
if (!ensure_control_rate_params (encoder, picture))
if (!gst_vaapi_encoder_ensure_param_control_rate (base_encoder, picture))
return FALSE;
if (!gst_vaapi_encoder_ensure_param_quality_level (base_encoder, picture))
return FALSE;
@ -2413,6 +2410,7 @@ gst_vaapi_encoder_h265_reconfigure (GstVaapiEncoder * base_encoder)
return status;
reset_properties (encoder);
ensure_control_rate_params (encoder);
return set_context_info (base_encoder);
}

View file

@ -452,8 +452,7 @@ ensure_picture (GstVaapiEncoderMpeg2 * encoder, GstVaapiEncPicture * picture,
}
static gboolean
ensure_control_rate_params (GstVaapiEncoderMpeg2 * encoder,
GstVaapiEncPicture * picture)
ensure_control_rate_params (GstVaapiEncoderMpeg2 * encoder)
{
GstVaapiEncoder *const base_encoder = GST_VAAPI_ENCODER_CAST (encoder);
@ -476,7 +475,7 @@ ensure_control_rate_params (GstVaapiEncoderMpeg2 * encoder,
};
/* *INDENT-ON* */
return gst_vaapi_encoder_ensure_param_control_rate (base_encoder, picture);
return TRUE;
}
static gboolean
@ -485,7 +484,7 @@ set_misc_parameters (GstVaapiEncoderMpeg2 * encoder,
{
GstVaapiEncoder *const base_encoder = GST_VAAPI_ENCODER_CAST (encoder);
if (!ensure_control_rate_params (encoder, picture))
if (!gst_vaapi_encoder_ensure_param_control_rate (base_encoder, picture))
return FALSE;
if (!gst_vaapi_encoder_ensure_param_quality_level (base_encoder, picture))
return FALSE;
@ -713,6 +712,7 @@ gst_vaapi_encoder_mpeg2_reconfigure (GstVaapiEncoder * base_encoder)
if (!ensure_bitrate (encoder))
goto error;
ensure_control_rate_params (encoder);
return set_context_info (base_encoder);
/* ERRORS */

View file

@ -258,8 +258,7 @@ error:
}
static gboolean
ensure_control_rate_params (GstVaapiEncoderVP8 * encoder,
GstVaapiEncPicture * picture)
ensure_control_rate_params (GstVaapiEncoderVP8 * encoder)
{
GstVaapiEncoder *const base_encoder = GST_VAAPI_ENCODER_CAST (encoder);
@ -291,7 +290,7 @@ ensure_control_rate_params (GstVaapiEncoderVP8 * encoder,
};
/* *INDENT-ON* */
return gst_vaapi_encoder_ensure_param_control_rate (base_encoder, picture);
return TRUE;
}
static gboolean
@ -302,7 +301,7 @@ ensure_misc_params (GstVaapiEncoderVP8 * encoder, GstVaapiEncPicture * picture)
if (!gst_vaapi_encoder_ensure_param_quality_level (base_encoder, picture))
return FALSE;
if (!ensure_control_rate_params (encoder, picture))
if (!gst_vaapi_encoder_ensure_param_control_rate (base_encoder, picture))
return FALSE;
return TRUE;
@ -510,6 +509,7 @@ gst_vaapi_encoder_vp8_reconfigure (GstVaapiEncoder * base_encoder)
if (!ensure_bitrate (encoder))
goto error;
ensure_control_rate_params (encoder);
return set_context_info (base_encoder);
/* ERRORS */