nvenc: Add property for AUD insertion
authorSeungha Yang <seungha.yang@navercorp.com>
Fri, 26 Jul 2019 07:46:30 +0000 (16:46 +0900)
committerSeungha Yang <seungha.yang@navercorp.com>
Wed, 11 Sep 2019 04:18:12 +0000 (13:18 +0900)
Make AUD insertion configurable option

sys/nvcodec/gstnvbaseenc.c
sys/nvcodec/gstnvbaseenc.h
sys/nvcodec/gstnvh264enc.c
sys/nvcodec/gstnvh264enc.h
sys/nvcodec/gstnvh265enc.c
sys/nvcodec/gstnvh265enc.h

index 5c2fca5..f203e0d 100644 (file)
@@ -2157,7 +2157,7 @@ gst_nv_base_enc_flush (GstVideoEncoder * enc)
 }
 #endif
 
-static void
+void
 gst_nv_base_enc_schedule_reconfig (GstNvBaseEnc * nvenc)
 {
   g_atomic_int_set (&nvenc->reconfig, TRUE);
index b03d504..1e9d365 100644 (file)
@@ -131,5 +131,7 @@ GType gst_nv_base_enc_get_type (void);
 GType gst_nv_base_enc_register                (const char * codec,
                                                guint device_id);
 
+void gst_nv_base_enc_schedule_reconfig        (GstNvBaseEnc * nvenc);
+
 
 #endif /* __GST_NV_BASE_ENC_H_INCLUDED__ */
index 4a900c6..b63442b 100644 (file)
@@ -39,6 +39,14 @@ GST_DEBUG_CATEGORY_STATIC (gst_nv_h264_enc_debug);
 
 static GstElementClass *parent_class = NULL;
 
+enum
+{
+  PROP_0,
+  PROP_AUD,
+};
+
+#define DEFAULT_AUD TRUE
+
 static gboolean gst_nv_h264_enc_open (GstVideoEncoder * enc);
 static gboolean gst_nv_h264_enc_close (GstVideoEncoder * enc);
 static gboolean gst_nv_h264_enc_set_src_caps (GstNvBaseEnc * nvenc,
@@ -77,6 +85,12 @@ gst_nv_h264_enc_class_init (GstNvH264EncClass * klass, gpointer data)
   nvenc_class->set_src_caps = gst_nv_h264_enc_set_src_caps;
   nvenc_class->set_pic_params = gst_nv_h264_enc_set_pic_params;
 
+  g_object_class_install_property (gobject_class, PROP_AUD,
+      g_param_spec_boolean ("aud", "AUD",
+          "Use AU (Access Unit) delimiter", DEFAULT_AUD,
+          G_PARAM_READWRITE | GST_PARAM_MUTABLE_PLAYING |
+          G_PARAM_STATIC_STRINGS));
+
   if (cdata->is_default)
     long_name = g_strdup ("NVENC H.264 Video Encoder");
   else
@@ -109,6 +123,7 @@ gst_nv_h264_enc_class_init (GstNvH264EncClass * klass, gpointer data)
 static void
 gst_nv_h264_enc_init (GstNvH264Enc * nvenc)
 {
+  nvenc->aud = DEFAULT_AUD;
 }
 
 static void
@@ -343,9 +358,7 @@ gst_nv_h264_enc_set_encoder_config (GstNvBaseEnc * nvenc,
   }
 
   h264_config->idrPeriod = config->gopLength;
-
-  /* FIXME: make property */
-  h264_config->outputAUD = 1;
+  h264_config->outputAUD = h264enc->aud;
 
   vui->videoSignalTypePresentFlag = 1;
   /* NOTE: vui::video_format represents the video format before
@@ -386,18 +399,40 @@ static void
 gst_nv_h264_enc_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec)
 {
+  GstNvH264Enc *self = (GstNvH264Enc *) object;
+  gboolean reconfig = FALSE;
+
   switch (prop_id) {
+    case PROP_AUD:
+    {
+      gboolean aud;
+
+      aud = g_value_get_boolean (value);
+      if (aud != self->aud) {
+        self->aud = aud;
+        reconfig = TRUE;
+      }
+      break;
+    }
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
   }
+
+  if (reconfig)
+    gst_nv_base_enc_schedule_reconfig (GST_NV_BASE_ENC (self));
 }
 
 static void
 gst_nv_h264_enc_get_property (GObject * object, guint prop_id, GValue * value,
     GParamSpec * pspec)
 {
+  GstNvH264Enc *self = (GstNvH264Enc *) object;
+
   switch (prop_id) {
+    case PROP_AUD:
+      g_value_set_boolean (value, self->aud);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
index c7722e0..a6ab4e4 100644 (file)
@@ -24,6 +24,8 @@
 
 typedef struct {
   GstNvBaseEnc base_nvenc;
+  /* properties */
+  gboolean aud;
 } GstNvH264Enc;
 
 typedef struct {
index 0779a18..fc4a506 100644 (file)
@@ -41,6 +41,14 @@ GST_DEBUG_CATEGORY_STATIC (gst_nv_h265_enc_debug);
 
 static GstElementClass *parent_class = NULL;
 
+enum
+{
+  PROP_0,
+  PROP_AUD,
+};
+
+#define DEFAULT_AUD TRUE
+
 static gboolean gst_nv_h265_enc_open (GstVideoEncoder * enc);
 static gboolean gst_nv_h265_enc_close (GstVideoEncoder * enc);
 static gboolean gst_nv_h265_enc_stop (GstVideoEncoder * enc);
@@ -81,6 +89,12 @@ gst_nv_h265_enc_class_init (GstNvH265EncClass * klass, gpointer data)
   nvenc_class->set_src_caps = gst_nv_h265_enc_set_src_caps;
   nvenc_class->set_pic_params = gst_nv_h265_enc_set_pic_params;
 
+  g_object_class_install_property (gobject_class, PROP_AUD,
+      g_param_spec_boolean ("aud", "AUD",
+          "Use AU (Access Unit) delimiter", DEFAULT_AUD,
+          G_PARAM_READWRITE | GST_PARAM_MUTABLE_PLAYING |
+          G_PARAM_STATIC_STRINGS));
+
   if (cdata->is_default)
     long_name = g_strdup ("NVENC HEVC Video Encoder");
   else
@@ -113,6 +127,7 @@ gst_nv_h265_enc_class_init (GstNvH265EncClass * klass, gpointer data)
 static void
 gst_nv_h265_enc_init (GstNvH265Enc * nvenc)
 {
+  nvenc->aud = DEFAULT_AUD;
 }
 
 static void
@@ -449,8 +464,7 @@ gst_nv_h265_enc_set_encoder_config (GstNvBaseEnc * nvenc,
     config->encodeCodecConfig.hevcConfig.pixelBitDepthMinus8 = 2;
   }
 
-  /* FIXME: make property */
-  hevc_config->outputAUD = 1;
+  hevc_config->outputAUD = h265enc->aud;
 
   vui->videoSignalTypePresentFlag = 1;
   /* NOTE: vui::video_format represents the video format before
@@ -540,18 +554,40 @@ static void
 gst_nv_h265_enc_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec)
 {
+  GstNvH265Enc *self = (GstNvH265Enc *) object;
+  gboolean reconfig = FALSE;
+
   switch (prop_id) {
+    case PROP_AUD:
+    {
+      gboolean aud;
+
+      aud = g_value_get_boolean (value);
+      if (aud != self->aud) {
+        self->aud = aud;
+        reconfig = TRUE;
+      }
+      break;
+    }
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
   }
+
+  if (reconfig)
+    gst_nv_base_enc_schedule_reconfig (GST_NV_BASE_ENC (self));
 }
 
 static void
 gst_nv_h265_enc_get_property (GObject * object, guint prop_id, GValue * value,
     GParamSpec * pspec)
 {
+  GstNvH265Enc *self = (GstNvH265Enc *) object;
+
   switch (prop_id) {
+    case PROP_AUD:
+      g_value_set_boolean (value, self->aud);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
index bb8dbeb..22daa3f 100644 (file)
@@ -28,6 +28,9 @@ typedef struct {
 
   NV_ENC_SEI_PAYLOAD *sei_payload;
   guint num_sei_payload;
+
+  /* properties */
+  gboolean aud;
 } GstNvH265Enc;
 
 typedef struct {