nvenc: Add property for AUD insertion

Make AUD insertion configurable option
This commit is contained in:
Seungha Yang 2019-07-26 16:46:30 +09:00
parent b3b723462e
commit d05cbdbd72
6 changed files with 84 additions and 6 deletions

View File

@ -2157,7 +2157,7 @@ gst_nv_base_enc_flush (GstVideoEncoder * enc)
} }
#endif #endif
static void void
gst_nv_base_enc_schedule_reconfig (GstNvBaseEnc * nvenc) gst_nv_base_enc_schedule_reconfig (GstNvBaseEnc * nvenc)
{ {
g_atomic_int_set (&nvenc->reconfig, TRUE); g_atomic_int_set (&nvenc->reconfig, TRUE);

View File

@ -131,5 +131,7 @@ GType gst_nv_base_enc_get_type (void);
GType gst_nv_base_enc_register (const char * codec, GType gst_nv_base_enc_register (const char * codec,
guint device_id); guint device_id);
void gst_nv_base_enc_schedule_reconfig (GstNvBaseEnc * nvenc);
#endif /* __GST_NV_BASE_ENC_H_INCLUDED__ */ #endif /* __GST_NV_BASE_ENC_H_INCLUDED__ */

View File

@ -39,6 +39,14 @@ GST_DEBUG_CATEGORY_STATIC (gst_nv_h264_enc_debug);
static GstElementClass *parent_class = NULL; 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_open (GstVideoEncoder * enc);
static gboolean gst_nv_h264_enc_close (GstVideoEncoder * enc); static gboolean gst_nv_h264_enc_close (GstVideoEncoder * enc);
static gboolean gst_nv_h264_enc_set_src_caps (GstNvBaseEnc * nvenc, 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_src_caps = gst_nv_h264_enc_set_src_caps;
nvenc_class->set_pic_params = gst_nv_h264_enc_set_pic_params; 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) if (cdata->is_default)
long_name = g_strdup ("NVENC H.264 Video Encoder"); long_name = g_strdup ("NVENC H.264 Video Encoder");
else else
@ -109,6 +123,7 @@ gst_nv_h264_enc_class_init (GstNvH264EncClass * klass, gpointer data)
static void static void
gst_nv_h264_enc_init (GstNvH264Enc * nvenc) gst_nv_h264_enc_init (GstNvH264Enc * nvenc)
{ {
nvenc->aud = DEFAULT_AUD;
} }
static void static void
@ -343,9 +358,7 @@ gst_nv_h264_enc_set_encoder_config (GstNvBaseEnc * nvenc,
} }
h264_config->idrPeriod = config->gopLength; h264_config->idrPeriod = config->gopLength;
h264_config->outputAUD = h264enc->aud;
/* FIXME: make property */
h264_config->outputAUD = 1;
vui->videoSignalTypePresentFlag = 1; vui->videoSignalTypePresentFlag = 1;
/* NOTE: vui::video_format represents the video format before /* 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, gst_nv_h264_enc_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec) const GValue * value, GParamSpec * pspec)
{ {
GstNvH264Enc *self = (GstNvH264Enc *) object;
gboolean reconfig = FALSE;
switch (prop_id) { 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: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
} }
if (reconfig)
gst_nv_base_enc_schedule_reconfig (GST_NV_BASE_ENC (self));
} }
static void static void
gst_nv_h264_enc_get_property (GObject * object, guint prop_id, GValue * value, gst_nv_h264_enc_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec) GParamSpec * pspec)
{ {
GstNvH264Enc *self = (GstNvH264Enc *) object;
switch (prop_id) { switch (prop_id) {
case PROP_AUD:
g_value_set_boolean (value, self->aud);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;

View File

@ -24,6 +24,8 @@
typedef struct { typedef struct {
GstNvBaseEnc base_nvenc; GstNvBaseEnc base_nvenc;
/* properties */
gboolean aud;
} GstNvH264Enc; } GstNvH264Enc;
typedef struct { typedef struct {

View File

@ -41,6 +41,14 @@ GST_DEBUG_CATEGORY_STATIC (gst_nv_h265_enc_debug);
static GstElementClass *parent_class = NULL; 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_open (GstVideoEncoder * enc);
static gboolean gst_nv_h265_enc_close (GstVideoEncoder * enc); static gboolean gst_nv_h265_enc_close (GstVideoEncoder * enc);
static gboolean gst_nv_h265_enc_stop (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_src_caps = gst_nv_h265_enc_set_src_caps;
nvenc_class->set_pic_params = gst_nv_h265_enc_set_pic_params; 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) if (cdata->is_default)
long_name = g_strdup ("NVENC HEVC Video Encoder"); long_name = g_strdup ("NVENC HEVC Video Encoder");
else else
@ -113,6 +127,7 @@ gst_nv_h265_enc_class_init (GstNvH265EncClass * klass, gpointer data)
static void static void
gst_nv_h265_enc_init (GstNvH265Enc * nvenc) gst_nv_h265_enc_init (GstNvH265Enc * nvenc)
{ {
nvenc->aud = DEFAULT_AUD;
} }
static void static void
@ -449,8 +464,7 @@ gst_nv_h265_enc_set_encoder_config (GstNvBaseEnc * nvenc,
config->encodeCodecConfig.hevcConfig.pixelBitDepthMinus8 = 2; config->encodeCodecConfig.hevcConfig.pixelBitDepthMinus8 = 2;
} }
/* FIXME: make property */ hevc_config->outputAUD = h265enc->aud;
hevc_config->outputAUD = 1;
vui->videoSignalTypePresentFlag = 1; vui->videoSignalTypePresentFlag = 1;
/* NOTE: vui::video_format represents the video format before /* 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, gst_nv_h265_enc_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec) const GValue * value, GParamSpec * pspec)
{ {
GstNvH265Enc *self = (GstNvH265Enc *) object;
gboolean reconfig = FALSE;
switch (prop_id) { 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: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
} }
if (reconfig)
gst_nv_base_enc_schedule_reconfig (GST_NV_BASE_ENC (self));
} }
static void static void
gst_nv_h265_enc_get_property (GObject * object, guint prop_id, GValue * value, gst_nv_h265_enc_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec) GParamSpec * pspec)
{ {
GstNvH265Enc *self = (GstNvH265Enc *) object;
switch (prop_id) { switch (prop_id) {
case PROP_AUD:
g_value_set_boolean (value, self->aud);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;

View File

@ -28,6 +28,9 @@ typedef struct {
NV_ENC_SEI_PAYLOAD *sei_payload; NV_ENC_SEI_PAYLOAD *sei_payload;
guint num_sei_payload; guint num_sei_payload;
/* properties */
gboolean aud;
} GstNvH265Enc; } GstNvH265Enc;
typedef struct { typedef struct {