celtenc: Add support for setting the prediction mode and the start band

This commit is contained in:
Sebastian Dröge 2010-07-05 10:08:30 +02:00
parent 2d80fd6c22
commit 042419baa1
2 changed files with 59 additions and 3 deletions

View file

@ -54,6 +54,29 @@
GST_DEBUG_CATEGORY_STATIC (celtenc_debug);
#define GST_CAT_DEFAULT celtenc_debug
#define GST_CELT_ENC_TYPE_PREDICTION (gst_celt_enc_prediction_get_type())
static GType
gst_celt_enc_prediction_get_type (void)
{
static const GEnumValue values[] = {
{0, "Independent frames", "idependent"},
{1, "Short term interframe prediction", "short-term"},
{2, "Long term interframe prediction", "long-term"},
{0, NULL, NULL}
};
static volatile GType id = 0;
if (g_once_init_enter ((gsize *) & id)) {
GType _id;
_id = g_enum_register_static ("GstCeltEncPrediction", values);
g_once_init_leave ((gsize *) & id, _id);
}
return id;
}
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
@ -77,6 +100,8 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
#define DEFAULT_CBR TRUE
#define DEFAULT_COMPLEXITY 9
#define DEFAULT_MAX_BITRATE 64
#define DEFAULT_PREDICTION 0
#define DEFAULT_START_BAND 0
enum
{
@ -85,7 +110,9 @@ enum
PROP_FRAMESIZE,
PROP_CBR,
PROP_COMPLEXITY,
PROP_MAX_BITRATE
PROP_MAX_BITRATE,
PROP_PREDICTION,
PROP_START_BAND
};
static void gst_celt_enc_finalize (GObject * object);
@ -173,6 +200,16 @@ gst_celt_enc_class_init (GstCeltEncClass * klass)
"Specify a maximum encoding bit rate (in Kbps) for variable bit rate encoding.",
10, 320, DEFAULT_MAX_BITRATE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_PREDICTION,
g_param_spec_enum ("prediction", "Interframe Prediction",
"Controls the use of interframe prediction.",
GST_CELT_ENC_TYPE_PREDICTION, DEFAULT_PREDICTION,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_START_BAND,
g_param_spec_int ("start-band", "Start Band",
"Controls the start band that should be used",
0, G_MAXINT, DEFAULT_START_BAND,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_celt_enc_finalize);
@ -542,6 +579,7 @@ gst_celt_enc_init (GstCeltEnc * enc, GstCeltEncClass * klass)
enc->cbr = DEFAULT_CBR;
enc->complexity = DEFAULT_COMPLEXITY;
enc->max_bitrate = DEFAULT_MAX_BITRATE;
enc->prediction = DEFAULT_PREDICTION;
enc->setup = FALSE;
enc->header_sent = FALSE;
@ -624,6 +662,12 @@ gst_celt_enc_setup (GstCeltEnc * enc)
#ifdef CELT_SET_COMPLEXITY
celt_encoder_ctl (enc->state, CELT_SET_COMPLEXITY (enc->complexity), 0);
#endif
#ifdef CELT_SET_PREDICTION
celt_encoder_ctl (enc->state, CELT_SET_PREDICTION (enc->prediction), 0);
#endif
#ifdef CELT_SET_START_BAND
celt_encoder_ctl (enc->state, CELT_SET_START_BAND (enc->start_band), 0);
#endif
GST_LOG_OBJECT (enc, "we have frame size %d", enc->frame_size);
@ -1011,9 +1055,7 @@ gst_celt_enc_get_property (GObject * object, guint prop_id, GValue * value,
g_value_set_int (value, enc->frame_size);
break;
case PROP_CBR:
#ifdef CELT_SET_VBR_RATE
g_value_set_boolean (value, enc->cbr);
#endif
break;
case PROP_COMPLEXITY:
g_value_set_int (value, enc->complexity);
@ -1021,6 +1063,12 @@ gst_celt_enc_get_property (GObject * object, guint prop_id, GValue * value,
case PROP_MAX_BITRATE:
g_value_set_int (value, enc->max_bitrate);
break;
case PROP_PREDICTION:
g_value_set_enum (value, enc->prediction);
break;
case PROP_START_BAND:
g_value_set_int (value, enc->start_band);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -1051,6 +1099,12 @@ gst_celt_enc_set_property (GObject * object, guint prop_id,
case PROP_MAX_BITRATE:
enc->max_bitrate = g_value_get_int (value);
break;
case PROP_PREDICTION:
enc->prediction = g_value_get_enum (value);
break;
case PROP_START_BAND:
enc->start_band = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;

View file

@ -65,6 +65,8 @@ struct _GstCeltEnc {
gboolean cbr;
gint complexity;
gint max_bitrate;
gint prediction;
gint start_band;
gint channels;
gint rate;