From cd6a9736bd289157bb1dbf4358f1439365ce289d Mon Sep 17 00:00:00 2001 From: Hyunjun Ko Date: Wed, 2 Aug 2017 14:53:34 +0900 Subject: [PATCH] libs: encoder: h264: add refs property Users can provide the number of reference frame by this property. 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. https://bugzilla.gnome.org/show_bug.cgi?id=783803 --- gst-libs/gst/vaapi/gstvaapiencoder_h264.c | 16 ++++++++++++++++ gst-libs/gst/vaapi/gstvaapiencoder_h264.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c index a382412456..34018286bf 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c @@ -730,6 +730,7 @@ struct _GstVaapiEncoderH264 guint32 idr_num; guint8 pic_order_cnt_type; guint8 delta_pic_order_always_zero_flag; + guint num_ref_frames; GstBuffer *sps_data; GstBuffer *subset_sps_data; @@ -3104,6 +3105,9 @@ gst_vaapi_encoder_h264_set_property (GstVaapiEncoder * base_encoder, case GST_VAAPI_ENCODER_H264_PROP_COMPLIANCE_MODE: encoder->compliance_mode = g_value_get_enum (value); break; + case GST_VAAPI_ENCODER_H264_PROP_NUM_REF_FRAMES: + encoder->num_ref_frames = g_value_get_uint (value); + break; default: return GST_VAAPI_ENCODER_STATUS_ERROR_INVALID_PARAMETER; @@ -3171,6 +3175,18 @@ gst_vaapi_encoder_h264_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)); + /** + * GstVaapiEncoderH264: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_H264_PROP_NUM_REF_FRAMES, + g_param_spec_uint ("refs", "Number of Reference Frames", + "Number of reference frames", 1, 8, 1, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** * GstVaapiEncoderH264:init-qp: * diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h264.h b/gst-libs/gst/vaapi/gstvaapiencoder_h264.h index dec2ea974a..181cadec18 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_h264.h +++ b/gst-libs/gst/vaapi/gstvaapiencoder_h264.h @@ -49,6 +49,7 @@ typedef struct _GstVaapiEncoderH264 GstVaapiEncoderH264; * @GST_VAAPI_ENCODER_H264_PROP_NUM_VIEWS: Number of views per frame. * @GST_VAAPI_ENCODER_H264_PROP_VIEW_IDS: View IDs * @GST_VAAPI_ENCODER_H264_PROP_COMPLIANCE_MODE: Relax Compliance restrictions + * @GST_VAAPI_ENCODER_H264_PROP_NUM_REF_FRAMES: Maximum number of reference frames. * * The set of H.264 encoder specific configurable properties. */ @@ -64,6 +65,7 @@ typedef enum { GST_VAAPI_ENCODER_H264_PROP_VIEW_IDS = -9, GST_VAAPI_ENCODER_H264_PROP_AUD = -10, GST_VAAPI_ENCODER_H264_PROP_COMPLIANCE_MODE = -11, + GST_VAAPI_ENCODER_H264_PROP_NUM_REF_FRAMES = -12, } GstVaapiEncoderH264Prop; GstVaapiEncoder *