diff options
author | Hyunjun Ko <zzoon@igalia.com> | 2017-07-28 15:27:20 +0900 |
---|---|---|
committer | Víctor Manuel Jáquez Leal <vjaquez@igalia.com> | 2017-08-02 11:17:39 +0200 |
commit | ec76a9a7e3eb1da58190799c15854897daa2898e (patch) | |
tree | 310c1512bf7a4954e8439d0bee2eab94e3afd497 | |
parent | 7d6a80e13d41e1863f9e4f188adba80187fd57ea (diff) |
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
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapiencoder.c | 43 | ||||
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapiencoder_priv.h | 10 |
2 files changed, 53 insertions, 0 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder.c b/gst-libs/gst/vaapi/gstvaapiencoder.c index bdb8d9ef..d761bfa2 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder.c @@ -1512,6 +1512,49 @@ gst_vaapi_encoder_ensure_num_slices (GstVaapiEncoder * encoder, } /** + * 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 * @roi: (transfer none): a #GstVaapiROI diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_priv.h b/gst-libs/gst/vaapi/gstvaapiencoder_priv.h index 598aabf2..d73689e4 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_priv.h +++ b/gst-libs/gst/vaapi/gstvaapiencoder_priv.h @@ -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 */ |