libs: encoder: implements gst_vaapi_encoder_ensure_max_num_ref_frames

This function will query VAConfigAttribEncMaxRefFrames to get the
maximum number of reference frames supported in the driver.
This will be used for h264/h265 encoding.

https://bugzilla.gnome.org/show_bug.cgi?id=783803
This commit is contained in:
Hyunjun Ko 2017-07-28 15:27:20 +09:00 committed by Víctor Manuel Jáquez Leal
parent 7d6a80e13d
commit ec76a9a7e3
2 changed files with 53 additions and 0 deletions

View file

@ -1511,6 +1511,49 @@ gst_vaapi_encoder_ensure_num_slices (GstVaapiEncoder * encoder,
return TRUE;
}
/**
* gst_vaapi_encoder_ensure_max_num_ref_frames:
* @encoder: a #GstVaapiEncoder
* @profile: a #GstVaapiProfile
* @entrypoint: a #GstVaapiEntrypoint
*
* This function will query VAConfigAttribEncMaxRefFrames to get the
* maximum number of reference frames in the driver,
* for both the reference picture list 0 (bottom 16 bits) and
* the reference picture list 1 (top 16 bits).
*
* We need to pass the @profile and the @entrypoint, because at the
* moment the encoder base class, still doesn't have them assigned,
* and this function is meant to be called by the derived classes
* while they are configured.
*
* Returns: %TRUE if the number of reference frames is different than zero.
**/
gboolean
gst_vaapi_encoder_ensure_max_num_ref_frames (GstVaapiEncoder * encoder,
GstVaapiProfile profile, GstVaapiEntrypoint entrypoint)
{
VAProfile va_profile;
VAEntrypoint va_entrypoint;
guint max_ref_frames;
va_profile = gst_vaapi_profile_get_va_profile (profile);
va_entrypoint = gst_vaapi_entrypoint_get_va_entrypoint (entrypoint);
if (!gst_vaapi_get_config_attribute (encoder->display, va_profile,
va_entrypoint, VAConfigAttribEncMaxRefFrames, &max_ref_frames)) {
/* Set the default the number of reference frames */
encoder->max_num_ref_frames_0 = 1;
encoder->max_num_ref_frames_1 = 0;
return TRUE;
}
encoder->max_num_ref_frames_0 = max_ref_frames & 0xffff;
encoder->max_num_ref_frames_1 = (max_ref_frames >> 16) & 0xffff;
return TRUE;
}
/**
* gst_vaapi_encoder_add_roi:
* @encoder: a #GstVaapiEncoder

View file

@ -261,6 +261,11 @@ struct _GstVaapiEncoder
guint bitrate; /* kbps */
guint keyframe_period;
/* Maximum number of reference frames supported
* for the reference picture list 0 and list 2 */
guint max_num_ref_frames_0;
guint max_num_ref_frames_1;
/* parameters */
VAEncMiscParameterBufferQualityLevel va_quality_level;
@ -411,6 +416,11 @@ gst_vaapi_encoder_ensure_num_slices (GstVaapiEncoder * encoder,
GstVaapiProfile profile, GstVaapiEntrypoint entrypoint,
guint media_max_slices, guint * num_slices);
G_GNUC_INTERNAL
gboolean
gst_vaapi_encoder_ensure_max_num_ref_frames (GstVaapiEncoder * encoder,
GstVaapiProfile profile, GstVaapiEntrypoint entrypoint);
G_END_DECLS
#endif /* GST_VAAPI_ENCODER_PRIV_H */