mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-01 13:08:49 +00:00
theoraenc: Add property for speed level control
Add property "speed-level" to control the amount of motion searching the encoder does. This is only available in libtheora >= 1.0 and will silently fail with earlier libraries. Fixes: #572275. Signed-off-by: David Schleef <ds@schleef.org>
This commit is contained in:
parent
a490b3f2dd
commit
d8a33f094c
2 changed files with 24 additions and 0 deletions
|
@ -104,6 +104,8 @@ struct _GstTheoraEnc
|
||||||
guint64 granulepos_offset;
|
guint64 granulepos_offset;
|
||||||
guint64 timestamp_offset;
|
guint64 timestamp_offset;
|
||||||
gint granule_shift;
|
gint granule_shift;
|
||||||
|
|
||||||
|
gint speed_level;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstTheoraEncClass
|
struct _GstTheoraEncClass
|
||||||
|
|
|
@ -119,6 +119,7 @@ _ilog (unsigned int v)
|
||||||
#define THEORA_DEF_KEYFRAME_MINDISTANCE 8
|
#define THEORA_DEF_KEYFRAME_MINDISTANCE 8
|
||||||
#define THEORA_DEF_NOISE_SENSITIVITY 1
|
#define THEORA_DEF_NOISE_SENSITIVITY 1
|
||||||
#define THEORA_DEF_SHARPNESS 0
|
#define THEORA_DEF_SHARPNESS 0
|
||||||
|
#define THEORA_DEF_SPEEDLEVEL 1
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
ARG_0,
|
ARG_0,
|
||||||
|
@ -134,6 +135,7 @@ enum
|
||||||
ARG_KEYFRAME_MINDISTANCE,
|
ARG_KEYFRAME_MINDISTANCE,
|
||||||
ARG_NOISE_SENSITIVITY,
|
ARG_NOISE_SENSITIVITY,
|
||||||
ARG_SHARPNESS,
|
ARG_SHARPNESS,
|
||||||
|
ARG_SPEEDLEVEL,
|
||||||
/* FILL ME */
|
/* FILL ME */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -265,6 +267,12 @@ gst_theora_enc_class_init (GstTheoraEncClass * klass)
|
||||||
g_param_spec_int ("sharpness", "Sharpness", "Sharpness", 0, 2,
|
g_param_spec_int ("sharpness", "Sharpness", "Sharpness", 0, 2,
|
||||||
THEORA_DEF_SHARPNESS,
|
THEORA_DEF_SHARPNESS,
|
||||||
(GParamFlags) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
(GParamFlags) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
g_object_class_install_property (gobject_class, ARG_SPEEDLEVEL,
|
||||||
|
g_param_spec_int ("speed-level", "Speed level",
|
||||||
|
"Controls the amount of motion vector searching done while "
|
||||||
|
"encoding. This property requires libtheora version >= 1.0",
|
||||||
|
0, 2, THEORA_DEF_SPEEDLEVEL,
|
||||||
|
(GParamFlags) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
gstelement_class->change_state = theora_enc_change_state;
|
gstelement_class->change_state = theora_enc_change_state;
|
||||||
GST_DEBUG_CATEGORY_INIT (theoraenc_debug, "theoraenc", 0, "Theora encoder");
|
GST_DEBUG_CATEGORY_INIT (theoraenc_debug, "theoraenc", 0, "Theora encoder");
|
||||||
|
@ -307,6 +315,8 @@ gst_theora_enc_init (GstTheoraEnc * enc, GstTheoraEncClass * g_class)
|
||||||
"keyframe_frequency_force is %d, granule shift is %d",
|
"keyframe_frequency_force is %d, granule shift is %d",
|
||||||
enc->info.keyframe_frequency_force, enc->granule_shift);
|
enc->info.keyframe_frequency_force, enc->granule_shift);
|
||||||
enc->expected_ts = GST_CLOCK_TIME_NONE;
|
enc->expected_ts = GST_CLOCK_TIME_NONE;
|
||||||
|
|
||||||
|
enc->speed_level = THEORA_DEF_SPEEDLEVEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -327,6 +337,10 @@ theora_enc_reset (GstTheoraEnc * enc)
|
||||||
{
|
{
|
||||||
theora_clear (&enc->state);
|
theora_clear (&enc->state);
|
||||||
theora_encode_init (&enc->state, &enc->info);
|
theora_encode_init (&enc->state, &enc->info);
|
||||||
|
#ifdef TH_ENCCTL_SET_SPLEVEL
|
||||||
|
theora_control (&enc->state, TH_ENCCTL_SET_SPLEVEL, &enc->speed_level,
|
||||||
|
sizeof (enc->speed_level));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1101,6 +1115,11 @@ theora_enc_set_property (GObject * object, guint prop_id,
|
||||||
case ARG_SHARPNESS:
|
case ARG_SHARPNESS:
|
||||||
enc->sharpness = g_value_get_int (value);
|
enc->sharpness = g_value_get_int (value);
|
||||||
break;
|
break;
|
||||||
|
case ARG_SPEEDLEVEL:
|
||||||
|
#ifdef TH_ENCCTL_SET_SPLEVEL
|
||||||
|
enc->speed_level = g_value_get_int (value);
|
||||||
|
#endif
|
||||||
|
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;
|
||||||
|
@ -1150,6 +1169,9 @@ theora_enc_get_property (GObject * object, guint prop_id,
|
||||||
case ARG_SHARPNESS:
|
case ARG_SHARPNESS:
|
||||||
g_value_set_int (value, enc->sharpness);
|
g_value_set_int (value, enc->sharpness);
|
||||||
break;
|
break;
|
||||||
|
case ARG_SPEEDLEVEL:
|
||||||
|
g_value_set_int (value, enc->speed_level);
|
||||||
|
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;
|
||||||
|
|
Loading…
Reference in a new issue