summaryrefslogtreecommitdiff
path: root/ext/x265
diff options
context:
space:
mode:
authorJames Stevenson <james@stev.org>2018-03-23 14:14:12 +0000
committerTim-Philipp Müller <tim@centricular.com>2018-03-26 19:53:24 +0100
commit0670befbaf466dd45ef0d78382b0fdcc4b05b1aa (patch)
tree25e4062b8c2c40320cec1b23191a706f806e7e19 /ext/x265
parent3b5c2049bba360c36c6021bd93784e3b3fac3b68 (diff)
x265enc: Add "key-int-max" property
https://bugzilla.gnome.org/show_bug.cgi?id=794623
Diffstat (limited to 'ext/x265')
-rw-r--r--ext/x265/gstx265enc.c26
-rw-r--r--ext/x265/gstx265enc.h1
2 files changed, 26 insertions, 1 deletions
diff --git a/ext/x265/gstx265enc.c b/ext/x265/gstx265enc.c
index 670d02f8d..3d268c2d2 100644
--- a/ext/x265/gstx265enc.c
+++ b/ext/x265/gstx265enc.c
@@ -53,7 +53,8 @@ enum
PROP_OPTION_STRING,
PROP_X265_LOG_LEVEL,
PROP_SPEED_PRESET,
- PROP_TUNE
+ PROP_TUNE,
+ PROP_KEY_INT_MAX
};
#define PROP_BITRATE_DEFAULT (2 * 1024)
@@ -62,6 +63,7 @@ enum
#define PROP_LOG_LEVEL_DEFAULT -1 // None
#define PROP_SPEED_PRESET_DEFAULT 6 // Medium
#define PROP_TUNE_DEFAULT 2 // SSIM
+#define PROP_KEY_INT_MAX_DEFAULT 0 // x265 lib default
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define FORMATS "I420, Y444, I420_10LE, Y444_10LE"
@@ -396,6 +398,17 @@ gst_x265_enc_class_init (GstX265EncClass * klass)
g_param_spec_enum ("tune", "Tune options",
"Preset name for tuning options", GST_X265_ENC_TUNE_TYPE,
PROP_TUNE_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ /**
+ * GstX265Enc::key-int-max:
+ *
+ * Controls maximum number of frames since the last keyframe
+ *
+ * Since: 1.16
+ */
+ g_object_class_install_property (gobject_class, PROP_KEY_INT_MAX,
+ g_param_spec_int ("key-int-max", "Max key frame",
+ "Maximal distance between two key-frames (0 = x265 default / 250)",
+ 0, G_MAXINT32, PROP_KEY_INT_MAX_DEFAULT, G_PARAM_READWRITE));
gst_element_class_set_static_metadata (element_class,
"x265enc", "Codec/Encoder/Video", "H265 Encoder",
@@ -423,6 +436,7 @@ gst_x265_enc_init (GstX265Enc * encoder)
encoder->log_level = PROP_LOG_LEVEL_DEFAULT;
encoder->speed_preset = PROP_SPEED_PRESET_DEFAULT;
encoder->tune = PROP_TUNE_DEFAULT;
+ encoder->keyintmax = PROP_KEY_INT_MAX_DEFAULT;
}
typedef struct
@@ -674,6 +688,10 @@ gst_x265_enc_init_encoder (GstX265Enc * encoder)
encoder->x265param.rc.rateControlMode = X265_RC_ABR;
}
+ if (encoder->keyintmax > 0) {
+ encoder->x265param.keyframeMax = encoder->keyintmax;
+ }
+
/* apply option-string property */
if (encoder->option_string_prop && encoder->option_string_prop->len) {
GST_DEBUG_OBJECT (encoder, "Applying option-string: %s",
@@ -1202,6 +1220,9 @@ gst_x265_enc_set_property (GObject * object, guint prop_id,
case PROP_TUNE:
encoder->tune = g_value_get_enum (value);
break;
+ case PROP_KEY_INT_MAX:
+ encoder->keyintmax = g_value_get_int (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1246,6 +1267,9 @@ gst_x265_enc_get_property (GObject * object, guint prop_id,
case PROP_TUNE:
g_value_set_enum (value, encoder->tune);
break;
+ case PROP_KEY_INT_MAX:
+ g_value_set_int (value, encoder->keyintmax);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
diff --git a/ext/x265/gstx265enc.h b/ext/x265/gstx265enc.h
index 66a8135c0..c9ce4712e 100644
--- a/ext/x265/gstx265enc.h
+++ b/ext/x265/gstx265enc.h
@@ -61,6 +61,7 @@ struct _GstX265Enc
gint log_level;
gint tune;
gint speed_preset;
+ gint keyintmax;
GString *option_string_prop; /* option-string property */
/*GString *option_string; *//* used by set prop */