libs: encoder: h265: add refs property
authorHyunjun Ko <zzoon@igalia.com>
Wed, 13 Sep 2017 02:37:33 +0000 (11:37 +0900)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Wed, 13 Sep 2017 08:36:34 +0000 (10:36 +0200)
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
gst-libs/gst/vaapi/gstvaapiencoder_h265.h

index 6c40517..5bf7cc4 100644 (file)
@@ -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;
   }
@@ -2569,6 +2573,18 @@ gst_vaapi_encoder_h265_get_default_properties (void)
           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:
    *
    * The initial quantizer value.
index ec8483e..dbac0f9 100644 (file)
@@ -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;