mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-21 14:48:14 +00:00
x264enc: expose nal-hrd property
It can be used to force true CBR, and will cause the encoder to output null padding packets. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/908>
This commit is contained in:
parent
05985247d1
commit
9cb2eb4b9b
4 changed files with 104 additions and 3 deletions
|
@ -1014,6 +1014,18 @@
|
||||||
"type": "gchararray",
|
"type": "gchararray",
|
||||||
"writable": true
|
"writable": true
|
||||||
},
|
},
|
||||||
|
"nal-hrd": {
|
||||||
|
"blurb": "Signal Hypothetical Reference Decoder information",
|
||||||
|
"conditionally-available": false,
|
||||||
|
"construct": false,
|
||||||
|
"construct-only": false,
|
||||||
|
"controllable": false,
|
||||||
|
"default": "none (0)",
|
||||||
|
"mutable": "null",
|
||||||
|
"readable": true,
|
||||||
|
"type": "GstX264EncNalHrd",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
"noise-reduction": {
|
"noise-reduction": {
|
||||||
"blurb": "Noise reduction strength",
|
"blurb": "Noise reduction strength",
|
||||||
"conditionally-available": false,
|
"conditionally-available": false,
|
||||||
|
@ -1399,6 +1411,26 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"GstX264EncNalHrd": {
|
||||||
|
"kind": "enum",
|
||||||
|
"values": [
|
||||||
|
{
|
||||||
|
"desc": "None",
|
||||||
|
"name": "none",
|
||||||
|
"value": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"desc": "Variable bitrate",
|
||||||
|
"name": "vbr",
|
||||||
|
"value": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"desc": "Constant bitrate",
|
||||||
|
"name": "cbr",
|
||||||
|
"value": "2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"GstX264EncPass": {
|
"GstX264EncPass": {
|
||||||
"kind": "enum",
|
"kind": "enum",
|
||||||
"values": [
|
"values": [
|
||||||
|
|
|
@ -114,9 +114,9 @@ gst_plugins_doc = run_command(
|
||||||
'--index', cdir / 'index.md',
|
'--index', cdir / 'index.md',
|
||||||
'--gst_index', cdir / 'index.md',
|
'--gst_index', cdir / 'index.md',
|
||||||
'--gst_c_sources',
|
'--gst_c_sources',
|
||||||
root_rel / 'sys/*/*.[ch]',
|
cdir / root_rel / 'sys/*/*.[ch]',
|
||||||
root_rel / 'ext/*/*.[ch]',
|
cdir / root_rel / 'ext/*/*.[ch]',
|
||||||
root_rel / 'gst/*/*.[ch]',
|
cdir / root_rel / 'gst/*/*.[ch]',
|
||||||
'--gst_c_source_filters', excludes,
|
'--gst_c_source_filters', excludes,
|
||||||
'--gst_cache_file', plugins_cache,
|
'--gst_cache_file', plugins_cache,
|
||||||
check: true,
|
check: true,
|
||||||
|
|
|
@ -422,6 +422,7 @@ enum
|
||||||
ARG_TUNE,
|
ARG_TUNE,
|
||||||
ARG_FRAME_PACKING,
|
ARG_FRAME_PACKING,
|
||||||
ARG_INSERT_VUI,
|
ARG_INSERT_VUI,
|
||||||
|
ARG_NAL_HRD,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ARG_THREADS_DEFAULT 0 /* 0 means 'auto' which is 1.5x number of CPU cores */
|
#define ARG_THREADS_DEFAULT 0 /* 0 means 'auto' which is 1.5x number of CPU cores */
|
||||||
|
@ -464,6 +465,7 @@ static GString *x264enc_defaults;
|
||||||
#define ARG_TUNE_DEFAULT 0 /* no tuning */
|
#define ARG_TUNE_DEFAULT 0 /* no tuning */
|
||||||
#define ARG_FRAME_PACKING_DEFAULT -1 /* automatic (none, or from input caps) */
|
#define ARG_FRAME_PACKING_DEFAULT -1 /* automatic (none, or from input caps) */
|
||||||
#define ARG_INSERT_VUI_DEFAULT TRUE
|
#define ARG_INSERT_VUI_DEFAULT TRUE
|
||||||
|
#define ARG_NAL_HRD_DEFAULT 0
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -504,6 +506,25 @@ gst_x264_enc_pass_get_type (void)
|
||||||
return pass_type;
|
return pass_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define GST_X264_ENC_NAL_HRD_TYPE (gst_x264_enc_nal_hrd_get_type())
|
||||||
|
static GType
|
||||||
|
gst_x264_enc_nal_hrd_get_type (void)
|
||||||
|
{
|
||||||
|
static GType nal_hrd_type = 0;
|
||||||
|
|
||||||
|
static const GEnumValue nal_hrd_types[] = {
|
||||||
|
{GST_X264_ENC_NAL_HRD_NONE, "None", "none"},
|
||||||
|
{GST_X264_ENC_NAL_HRD_VBR, "Variable bitrate", "vbr"},
|
||||||
|
{GST_X264_ENC_NAL_HRD_CBR, "Constant bitrate", "cbr"},
|
||||||
|
{0, NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!nal_hrd_type) {
|
||||||
|
nal_hrd_type = g_enum_register_static ("GstX264EncNalHrd", nal_hrd_types);
|
||||||
|
}
|
||||||
|
return nal_hrd_type;
|
||||||
|
}
|
||||||
|
|
||||||
#define GST_X264_ENC_ME_TYPE (gst_x264_enc_me_get_type())
|
#define GST_X264_ENC_ME_TYPE (gst_x264_enc_me_get_type())
|
||||||
static GType
|
static GType
|
||||||
gst_x264_enc_me_get_type (void)
|
gst_x264_enc_me_get_type (void)
|
||||||
|
@ -1209,6 +1230,25 @@ gst_x264_enc_class_init (GstX264EncClass * klass)
|
||||||
g_string_append_printf (x264enc_defaults, ":interlaced=%d",
|
g_string_append_printf (x264enc_defaults, ":interlaced=%d",
|
||||||
ARG_INTERLACED_DEFAULT);
|
ARG_INTERLACED_DEFAULT);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* x264enc:nal-hrd:
|
||||||
|
*
|
||||||
|
* Signal Hypothetical Reference Decoder information.
|
||||||
|
*
|
||||||
|
* Required for Blu-ray streams, television broadcast and a
|
||||||
|
* few other specialist areas.
|
||||||
|
*
|
||||||
|
* It can be used for instance to force true CBR, and will cause
|
||||||
|
* the encoder to output NULL padding packets.
|
||||||
|
*
|
||||||
|
* Since: 1.26
|
||||||
|
*/
|
||||||
|
g_object_class_install_property (gobject_class, ARG_NAL_HRD,
|
||||||
|
g_param_spec_enum ("nal-hrd", "NAL HRD",
|
||||||
|
"Signal Hypothetical Reference Decoder information",
|
||||||
|
GST_X264_ENC_NAL_HRD_TYPE, ARG_NAL_HRD_DEFAULT,
|
||||||
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
/* append deblock parameters */
|
/* append deblock parameters */
|
||||||
g_string_append_printf (x264enc_defaults, ":deblock=0,0");
|
g_string_append_printf (x264enc_defaults, ":deblock=0,0");
|
||||||
/* append weighted prediction parameter */
|
/* append weighted prediction parameter */
|
||||||
|
@ -1243,6 +1283,7 @@ gst_x264_enc_class_init (GstX264EncClass * klass)
|
||||||
gst_type_mark_as_plugin_api (GST_X264_ENC_PSY_TUNE_TYPE, 0);
|
gst_type_mark_as_plugin_api (GST_X264_ENC_PSY_TUNE_TYPE, 0);
|
||||||
gst_type_mark_as_plugin_api (GST_X264_ENC_SPEED_PRESET_TYPE, 0);
|
gst_type_mark_as_plugin_api (GST_X264_ENC_SPEED_PRESET_TYPE, 0);
|
||||||
gst_type_mark_as_plugin_api (GST_X264_ENC_TUNE_TYPE, 0);
|
gst_type_mark_as_plugin_api (GST_X264_ENC_TUNE_TYPE, 0);
|
||||||
|
gst_type_mark_as_plugin_api (GST_X264_ENC_NAL_HRD_TYPE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
|
@ -1340,6 +1381,7 @@ gst_x264_enc_init (GstX264Enc * encoder)
|
||||||
encoder->tune = ARG_TUNE_DEFAULT;
|
encoder->tune = ARG_TUNE_DEFAULT;
|
||||||
encoder->frame_packing = ARG_FRAME_PACKING_DEFAULT;
|
encoder->frame_packing = ARG_FRAME_PACKING_DEFAULT;
|
||||||
encoder->insert_vui = ARG_INSERT_VUI_DEFAULT;
|
encoder->insert_vui = ARG_INSERT_VUI_DEFAULT;
|
||||||
|
encoder->nal_hrd = ARG_NAL_HRD_DEFAULT;
|
||||||
|
|
||||||
encoder->bitrate_manager =
|
encoder->bitrate_manager =
|
||||||
gst_encoder_bitrate_profile_manager_new (ARG_BITRATE_DEFAULT);
|
gst_encoder_bitrate_profile_manager_new (ARG_BITRATE_DEFAULT);
|
||||||
|
@ -1915,6 +1957,8 @@ skip_vui_parameters:
|
||||||
|
|
||||||
GST_OBJECT_UNLOCK (encoder);
|
GST_OBJECT_UNLOCK (encoder);
|
||||||
|
|
||||||
|
encoder->x264param.i_nal_hrd = encoder->nal_hrd;
|
||||||
|
|
||||||
encoder->x264enc = encoder->vtable->x264_encoder_open (&encoder->x264param);
|
encoder->x264enc = encoder->vtable->x264_encoder_open (&encoder->x264param);
|
||||||
if (!encoder->x264enc) {
|
if (!encoder->x264enc) {
|
||||||
GST_ELEMENT_ERROR (encoder, STREAM, ENCODE,
|
GST_ELEMENT_ERROR (encoder, STREAM, ENCODE,
|
||||||
|
@ -2988,6 +3032,9 @@ gst_x264_enc_set_property (GObject * object, guint prop_id,
|
||||||
case ARG_INSERT_VUI:
|
case ARG_INSERT_VUI:
|
||||||
encoder->insert_vui = g_value_get_boolean (value);
|
encoder->insert_vui = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
|
case ARG_NAL_HRD:
|
||||||
|
encoder->nal_hrd = g_value_get_enum (value);
|
||||||
|
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;
|
||||||
|
@ -3132,6 +3179,9 @@ gst_x264_enc_get_property (GObject * object, guint prop_id,
|
||||||
case ARG_INSERT_VUI:
|
case ARG_INSERT_VUI:
|
||||||
g_value_set_boolean (value, encoder->insert_vui);
|
g_value_set_boolean (value, encoder->insert_vui);
|
||||||
break;
|
break;
|
||||||
|
case ARG_NAL_HRD:
|
||||||
|
g_value_set_enum (value, encoder->nal_hrd);
|
||||||
|
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;
|
||||||
|
|
|
@ -113,6 +113,7 @@ struct _GstX264Enc
|
||||||
GString *option_string; /* used by set prop */
|
GString *option_string; /* used by set prop */
|
||||||
gint frame_packing;
|
gint frame_packing;
|
||||||
gboolean insert_vui;
|
gboolean insert_vui;
|
||||||
|
gint nal_hrd;
|
||||||
|
|
||||||
/* input description */
|
/* input description */
|
||||||
GstVideoCodecState *input_state;
|
GstVideoCodecState *input_state;
|
||||||
|
@ -136,6 +137,24 @@ struct _GstX264EncClass
|
||||||
GstVideoEncoderClass parent_class;
|
GstVideoEncoderClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstX264EncNalHrd:
|
||||||
|
* @GST_X264_ENC_NAL_HRD_NONE: Specify no HRD information
|
||||||
|
* @GST_X264_ENC_NAL_HRD_VBR: Specify HRD information
|
||||||
|
* @GST_X264_ENC_NAL_HRD_CBR: Specify HRD information and pack the bitstream
|
||||||
|
*
|
||||||
|
* Signal HRD information. Required for Blu-ray streams,
|
||||||
|
* television broadcast and a few other specialist areas.
|
||||||
|
*
|
||||||
|
* Since: 1.26
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
GST_X264_ENC_NAL_HRD_NONE = 0,
|
||||||
|
GST_X264_ENC_NAL_HRD_VBR = 1,
|
||||||
|
GST_X264_ENC_NAL_HRD_CBR = 2,
|
||||||
|
} GstX264EncNalHrd;
|
||||||
|
|
||||||
GType gst_x264_enc_get_type (void);
|
GType gst_x264_enc_get_type (void);
|
||||||
GST_ELEMENT_REGISTER_DECLARE (x264enc);
|
GST_ELEMENT_REGISTER_DECLARE (x264enc);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue