msdkenc: Add a property to insert pic timing SEI for avc and hevc

User can decide whether to insert pic timing sei with pic_struct
syntax via oneVPL API mfxExtCodingOption.PicTimingSEI.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4673>
This commit is contained in:
Mengkejiergeli Ba 2023-04-27 13:10:33 +08:00 committed by GStreamer Marge Bot
parent f94d1c4e93
commit a15a16c99b
5 changed files with 80 additions and 6 deletions

View file

@ -215037,6 +215037,18 @@
"type": "gboolean",
"writable": true
},
"pic-timing-sei": {
"blurb": "Insert picture timing SEI with pic_struct syntax",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"default": "true",
"mutable": "null",
"readable": true,
"type": "gboolean",
"writable": true
},
"rc-lookahead-ds": {
"blurb": "Down sampling mode in look ahead bitrate control",
"conditionally-available": false,
@ -215361,6 +215373,18 @@
"type": "gboolean",
"writable": true
},
"pic-timing-sei": {
"blurb": "Insert picture timing SEI with pic_struct syntax",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"default": "true",
"mutable": "null",
"readable": true,
"type": "gboolean",
"writable": true
},
"transform-skip": {
"blurb": "Transform Skip option",
"conditionally-available": false,

View file

@ -93,6 +93,7 @@ enum
PROP_INTRA_REFRESH_QP_DELTA,
PROP_INTRA_REFRESH_CYCLE_DIST,
PROP_DBLK_IDC,
PROP_PIC_TIMING_SEI,
};
enum
@ -117,6 +118,7 @@ enum
#define PROP_INTRA_REFRESH_QP_DELTA_DEFAULT 0
#define PROP_INTRA_REFRESH_CYCLE_DIST_DEFAULT 0
#define PROP_DBLK_IDC_DEFAULT 0
#define PROP_PIC_TIMING_SEI_DEFAULT TRUE
/* *INDENT-OFF* */
static const gchar *doc_sink_caps_str =
@ -425,6 +427,9 @@ gst_msdkh264enc_configure (GstMsdkEnc * encoder)
thiz->option.NalHrdConformance = MFX_CODINGOPTION_OFF;
}
thiz->option.PicTimingSEI =
(thiz->pic_timing_sei ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF);
gst_msdkenc_add_extra_param (encoder, (mfxExtBuffer *) & thiz->option);
encoder->option2.Trellis = thiz->trellis ? thiz->trellis : MFX_TRELLIS_OFF;
@ -677,6 +682,9 @@ gst_msdkh264enc_set_property (GObject * object, guint prop_id,
case PROP_DBLK_IDC:
thiz->dblk_idc = g_value_get_uint (value);
break;
case PROP_PIC_TIMING_SEI:
thiz->pic_timing_sei = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -764,6 +772,9 @@ gst_msdkh264enc_get_property (GObject * object, guint prop_id, GValue * value,
case PROP_DBLK_IDC:
g_value_set_uint (value, thiz->dblk_idc);
break;
case PROP_PIC_TIMING_SEI:
g_value_set_boolean (value, thiz->pic_timing_sei);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -973,6 +984,17 @@ _msdkh264enc_install_properties (GObjectClass * gobject_class,
"Option of disable deblocking idc",
0, 2, PROP_DBLK_IDC_DEFAULT,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstMsdkH264Enc:pic-timing-sei:
*
* Since: 1.24
*/
g_object_class_install_property (gobject_class, PROP_PIC_TIMING_SEI,
g_param_spec_boolean ("pic-timing-sei", "Picture Timing SEI",
"Insert picture timing SEI with pic_struct syntax",
PROP_PIC_TIMING_SEI_DEFAULT,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
static void
@ -1046,6 +1068,7 @@ gst_msdkh264enc_init (GTypeInstance * instance, gpointer g_class)
thiz->intra_refresh_qp_delta = PROP_INTRA_REFRESH_QP_DELTA_DEFAULT;
thiz->intra_refresh_cycle_dist = PROP_INTRA_REFRESH_CYCLE_DIST_DEFAULT;
thiz->dblk_idc = PROP_DBLK_IDC_DEFAULT;
thiz->pic_timing_sei = PROP_PIC_TIMING_SEI_DEFAULT;
}
gboolean

View file

@ -74,6 +74,7 @@ struct _GstMsdkH264Enc
gint intra_refresh_qp_delta;
guint intra_refresh_cycle_dist;
guint dblk_idc;
gboolean pic_timing_sei;
GstH264NalParser *parser;
GArray *cc_sei_array;

View file

@ -92,6 +92,7 @@ enum
PROP_INTRA_REFRESH_QP_DELTA,
PROP_INTRA_REFRESH_CYCLE_DIST,
PROP_DBLK_IDC,
PROP_PIC_TIMING_SEI,
};
enum
@ -115,6 +116,7 @@ enum
#define PROP_INTRA_REFRESH_QP_DELTA_DEFAULT 0
#define PROP_INTRA_REFRESH_CYCLE_DIST_DEFAULT 0
#define PROP_DBLK_IDC_DEFAULT 0
#define PROP_PIC_TIMING_SEI_DEFAULT TRUE
/* *INDENT-OFF* */
static const gchar *doc_sink_caps_str =
@ -468,7 +470,6 @@ gst_msdkh265enc_configure (GstMsdkEnc * encoder)
* "i-frames" by incrementing the value by one in each case*/
encoder->param.mfx.IdrInterval += 1;
/* Enable Extended coding options */
encoder->option2.MaxSliceSize = h265enc->max_slice_size;
encoder->option2.MinQPI = h265enc->min_qp_i;
encoder->option2.MinQPP = h265enc->min_qp_p;
@ -512,12 +513,16 @@ gst_msdkh265enc_configure (GstMsdkEnc * encoder)
encoder->enable_extopt3 = TRUE;
}
if (encoder->option3.LowDelayBRC == MFX_CODINGOPTION_ON) {
h265enc->option.Header.BufferId = MFX_EXTBUFF_CODING_OPTION;
h265enc->option.Header.BufferSz = sizeof (h265enc->option);
/* Fill Extended coding options */
h265enc->option.Header.BufferId = MFX_EXTBUFF_CODING_OPTION;
h265enc->option.Header.BufferSz = sizeof (h265enc->option);
h265enc->option.PicTimingSEI =
(h265enc->pic_timing_sei ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF);
if (encoder->option3.LowDelayBRC == MFX_CODINGOPTION_ON)
h265enc->option.NalHrdConformance = MFX_CODINGOPTION_OFF;
gst_msdkenc_add_extra_param (encoder, (mfxExtBuffer *) & h265enc->option);
}
gst_msdkenc_add_extra_param (encoder, (mfxExtBuffer *) & h265enc->option);
gst_msdkenc_ensure_extended_coding_options (encoder);
@ -768,6 +773,10 @@ gst_msdkh265enc_set_property (GObject * object, guint prop_id,
thiz->dblk_idc = g_value_get_uint (value);
break;
case PROP_PIC_TIMING_SEI:
thiz->pic_timing_sei = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -872,6 +881,10 @@ gst_msdkh265enc_get_property (GObject * object, guint prop_id, GValue * value,
g_value_set_uint (value, thiz->dblk_idc);
break;
case PROP_PIC_TIMING_SEI:
g_value_set_boolean (value, thiz->pic_timing_sei);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -1092,6 +1105,17 @@ _msdkh265enc_install_properties (GObjectClass * gobject_class,
"Option of disable deblocking idc",
0, 2, PROP_DBLK_IDC_DEFAULT,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstMsdkH265Enc:pic-timing-sei:
*
* Since: 1.24
*/
g_object_class_install_property (gobject_class, PROP_PIC_TIMING_SEI,
g_param_spec_boolean ("pic-timing-sei", "Picture Timing SEI",
"Insert picture timing SEI with pic_struct syntax",
PROP_PIC_TIMING_SEI_DEFAULT,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
static void
@ -1165,6 +1189,7 @@ gst_msdkh265enc_init (GTypeInstance * instance, gpointer g_class)
thiz->intra_refresh_qp_delta = PROP_INTRA_REFRESH_QP_DELTA_DEFAULT;
thiz->intra_refresh_cycle_dist = PROP_INTRA_REFRESH_CYCLE_DIST_DEFAULT;
thiz->dblk_idc = PROP_DBLK_IDC_DEFAULT;
thiz->pic_timing_sei = PROP_PIC_TIMING_SEI_DEFAULT;
msdk_enc->num_extra_frames = 1;
}

View file

@ -67,6 +67,7 @@ struct _GstMsdkH265Enc
gint intra_refresh_qp_delta;
guint intra_refresh_cycle_dist;
guint dblk_idc;
gboolean pic_timing_sei;
mfxExtHEVCTiles ext_tiles;
mfxExtHEVCParam ext_param;