summaryrefslogtreecommitdiff
path: root/gst-libs/gst/vaapi/gstvaapiencoder.c
diff options
context:
space:
mode:
authorHyunjun Ko <zzoon@igalia.com>2017-07-28 15:27:20 +0900
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2017-08-02 11:17:39 +0200
commitec76a9a7e3eb1da58190799c15854897daa2898e (patch)
tree310c1512bf7a4954e8439d0bee2eab94e3afd497 /gst-libs/gst/vaapi/gstvaapiencoder.c
parent7d6a80e13d41e1863f9e4f188adba80187fd57ea (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
Diffstat (limited to 'gst-libs/gst/vaapi/gstvaapiencoder.c')
-rw-r--r--gst-libs/gst/vaapi/gstvaapiencoder.c43
1 files changed, 43 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