From 3dbf44037307916afd0193e705a9300bf0b9d7e5 Mon Sep 17 00:00:00 2001 From: Hyunjun Ko Date: Wed, 13 Sep 2017 11:37:33 +0900 Subject: [PATCH] libs: encoder: h265: add refs property Users can provide the number of reference frame by this property, which is exaclty same as h264. The value of the property will be considered as the number of reference picture list0 and will add 1 reference frame more to the reference picture list1 internally if b-frame encoding. If the value provided is bigger than the number of refrence frames supported in the driver, it will be lowered. The maximum value is aligned to the value of the driver supported now. https://bugzilla.gnome.org/show_bug.cgi?id=783804 --- gst-libs/gst/vaapi/gstvaapiencoder_h265.c | 16 ++++++++++++++++ gst-libs/gst/vaapi/gstvaapiencoder_h265.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h265.c b/gst-libs/gst/vaapi/gstvaapiencoder_h265.c index 6c40517088..5bf7cc497a 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_h265.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder_h265.c @@ -118,6 +118,7 @@ struct _GstVaapiEncoderH265 guint32 max_pic_order_cnt; guint32 log2_max_pic_order_cnt; guint32 idr_num; + guint num_ref_frames; GstBuffer *vps_data; GstBuffer *sps_data; @@ -2502,6 +2503,9 @@ gst_vaapi_encoder_h265_set_property (GstVaapiEncoder * base_encoder, case GST_VAAPI_ENCODER_H265_PROP_CPB_LENGTH: encoder->cpb_length = g_value_get_uint (value); break; + case GST_VAAPI_ENCODER_H265_PROP_NUM_REF_FRAMES: + encoder->num_ref_frames = g_value_get_uint (value); + break; default: return GST_VAAPI_ENCODER_STATUS_ERROR_INVALID_PARAMETER; } @@ -2568,6 +2572,18 @@ gst_vaapi_encoder_h265_get_default_properties (void) "Max B-Frames", "Number of B-frames between I and P", 0, 10, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** + * GstVaapiEncoderH265:refs: + * + * The number of reference frames. + * If B frame is encoded, it will add 1 reference frame more. + */ + GST_VAAPI_ENCODER_PROPERTIES_APPEND (props, + GST_VAAPI_ENCODER_H265_PROP_NUM_REF_FRAMES, + g_param_spec_uint ("refs", + "Number of Reference Frames", "Number of reference frames", 1, 3, 1, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** * GstVaapiEncoderH265:init-qp: * diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h265.h b/gst-libs/gst/vaapi/gstvaapiencoder_h265.h index ec8483e5b7..dbac0f9a7f 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_h265.h +++ b/gst-libs/gst/vaapi/gstvaapiencoder_h265.h @@ -40,6 +40,7 @@ typedef struct _GstVaapiEncoderH265 GstVaapiEncoderH265; * @GST_VAAPI_ENCODER_H265_PROP_INIT_QP: Initial quantizer value (uint). * @GST_VAAPI_ENCODER_H265_PROP_MIN_QP: Minimal quantizer value (uint). * @GST_VAAPI_ENCODER_H265_PROP_NUM_SLICES: Number of slices per frame (uint). + * @GST_VAAPI_ENCODER_H265_PROP_NUM_REF_FRAMES: Maximum number of reference frames. * @GST_VAAPI_ENCODER_H265_PROP_CPB_LENGTH: Length of the CPB buffer * in milliseconds (uint). * @@ -50,6 +51,7 @@ typedef enum { GST_VAAPI_ENCODER_H265_PROP_INIT_QP = -2, GST_VAAPI_ENCODER_H265_PROP_MIN_QP = -3, GST_VAAPI_ENCODER_H265_PROP_NUM_SLICES = -4, + GST_VAAPI_ENCODER_H265_PROP_NUM_REF_FRAMES = -5, GST_VAAPI_ENCODER_H265_PROP_CPB_LENGTH = -7 } GstVaapiEncoderH265Prop;