mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
x265enc: add qp property
QP property enables CQP mode and sets the QP for P slices.
This commit is contained in:
parent
6215b5dd14
commit
c89844ec1e
2 changed files with 25 additions and 2 deletions
|
@ -48,6 +48,7 @@ enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_BITRATE,
|
PROP_BITRATE,
|
||||||
|
PROP_QP,
|
||||||
PROP_OPTION_STRING,
|
PROP_OPTION_STRING,
|
||||||
PROP_X265_LOG_LEVEL,
|
PROP_X265_LOG_LEVEL,
|
||||||
PROP_SPEED_PRESET,
|
PROP_SPEED_PRESET,
|
||||||
|
@ -57,6 +58,7 @@ enum
|
||||||
static GString *x265enc_defaults;
|
static GString *x265enc_defaults;
|
||||||
|
|
||||||
#define PROP_BITRATE_DEFAULT (2 * 1024)
|
#define PROP_BITRATE_DEFAULT (2 * 1024)
|
||||||
|
#define PROP_QP_DEFAULT -1
|
||||||
#define PROP_OPTION_STRING_DEFAULT ""
|
#define PROP_OPTION_STRING_DEFAULT ""
|
||||||
#define PROP_LOG_LEVEL_DEFAULT -1 // None
|
#define PROP_LOG_LEVEL_DEFAULT -1 // None
|
||||||
#define PROP_SPEED_PRESET_DEFAULT 6 // Medium
|
#define PROP_SPEED_PRESET_DEFAULT 6 // Medium
|
||||||
|
@ -371,6 +373,11 @@ gst_x265_enc_class_init (GstX265EncClass * klass)
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||||
GST_PARAM_MUTABLE_PLAYING));
|
GST_PARAM_MUTABLE_PLAYING));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class, PROP_QP,
|
||||||
|
g_param_spec_int ("qp", "Quantization parameter",
|
||||||
|
"QP for P slices in (implied) CQP mode (-1 = disabled)", -1,
|
||||||
|
51, PROP_QP_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, PROP_OPTION_STRING,
|
g_object_class_install_property (gobject_class, PROP_OPTION_STRING,
|
||||||
g_param_spec_string ("option-string", "Option string",
|
g_param_spec_string ("option-string", "Option string",
|
||||||
"String of x264 options (overridden by element properties)",
|
"String of x264 options (overridden by element properties)",
|
||||||
|
@ -416,6 +423,7 @@ gst_x265_enc_init (GstX265Enc * encoder)
|
||||||
encoder->push_header = TRUE;
|
encoder->push_header = TRUE;
|
||||||
|
|
||||||
encoder->bitrate = PROP_BITRATE_DEFAULT;
|
encoder->bitrate = PROP_BITRATE_DEFAULT;
|
||||||
|
encoder->qp = PROP_QP_DEFAULT;
|
||||||
encoder->option_string_prop = g_string_new (PROP_OPTION_STRING_DEFAULT);
|
encoder->option_string_prop = g_string_new (PROP_OPTION_STRING_DEFAULT);
|
||||||
encoder->log_level = PROP_LOG_LEVEL_DEFAULT;
|
encoder->log_level = PROP_LOG_LEVEL_DEFAULT;
|
||||||
encoder->speed_preset = PROP_SPEED_PRESET_DEFAULT;
|
encoder->speed_preset = PROP_SPEED_PRESET_DEFAULT;
|
||||||
|
@ -653,8 +661,16 @@ gst_x265_enc_init_encoder (GstX265Enc * encoder)
|
||||||
encoder->x265param.vui.sarWidth = info->par_n;
|
encoder->x265param.vui.sarWidth = info->par_n;
|
||||||
encoder->x265param.vui.sarHeight = info->par_d;
|
encoder->x265param.vui.sarHeight = info->par_d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (encoder->qp != -1) {
|
||||||
|
/* CQP */
|
||||||
|
encoder->x265param.rc.qp = encoder->qp;
|
||||||
|
encoder->x265param.rc.rateControlMode = X265_RC_CQP;
|
||||||
|
} else {
|
||||||
|
/* ABR */
|
||||||
encoder->x265param.rc.bitrate = encoder->bitrate;
|
encoder->x265param.rc.bitrate = encoder->bitrate;
|
||||||
encoder->x265param.rc.rateControlMode = X265_RC_ABR;
|
encoder->x265param.rc.rateControlMode = X265_RC_ABR;
|
||||||
|
}
|
||||||
|
|
||||||
/* apply option-string property */
|
/* apply option-string property */
|
||||||
if (encoder->option_string_prop && encoder->option_string_prop->len) {
|
if (encoder->option_string_prop && encoder->option_string_prop->len) {
|
||||||
|
@ -1157,6 +1173,9 @@ gst_x265_enc_set_property (GObject * object, guint prop_id,
|
||||||
case PROP_BITRATE:
|
case PROP_BITRATE:
|
||||||
encoder->bitrate = g_value_get_uint (value);
|
encoder->bitrate = g_value_get_uint (value);
|
||||||
break;
|
break;
|
||||||
|
case PROP_QP:
|
||||||
|
encoder->qp = g_value_get_int (value);
|
||||||
|
break;
|
||||||
case PROP_OPTION_STRING:
|
case PROP_OPTION_STRING:
|
||||||
g_string_assign (encoder->option_string_prop, g_value_get_string (value));
|
g_string_assign (encoder->option_string_prop, g_value_get_string (value));
|
||||||
break;
|
break;
|
||||||
|
@ -1198,6 +1217,9 @@ gst_x265_enc_get_property (GObject * object, guint prop_id,
|
||||||
case PROP_BITRATE:
|
case PROP_BITRATE:
|
||||||
g_value_set_uint (value, encoder->bitrate);
|
g_value_set_uint (value, encoder->bitrate);
|
||||||
break;
|
break;
|
||||||
|
case PROP_QP:
|
||||||
|
g_value_set_int (value, encoder->qp);
|
||||||
|
break;
|
||||||
case PROP_OPTION_STRING:
|
case PROP_OPTION_STRING:
|
||||||
g_value_set_string (value, encoder->option_string_prop->str);
|
g_value_set_string (value, encoder->option_string_prop->str);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -58,6 +58,7 @@ struct _GstX265Enc
|
||||||
|
|
||||||
/* properties */
|
/* properties */
|
||||||
guint bitrate;
|
guint bitrate;
|
||||||
|
gint qp;
|
||||||
gint log_level;
|
gint log_level;
|
||||||
gint tune;
|
gint tune;
|
||||||
gint speed_preset;
|
gint speed_preset;
|
||||||
|
|
Loading…
Reference in a new issue