summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorMukul Majmudar <mukul.majmudar@gmail.com>2011-07-09 16:05:07 -0400
committerDavid Schleef <ds@schleef.org>2011-08-03 13:39:33 -0700
commit5293f30f3ff0c4db6104d7e2697214629ced4c5b (patch)
tree8cba72a2160159cdeb4e4009c14c7a4d8356097b /ext
parent2b5e8db968a210160e39d67a424801c4af5c4588 (diff)
faac: Add properties for VBR encoding
Property "quality" to specify VBR quantizer quality and property "brtype" to choose between ABR and VBR encoding. The default is now VBR with quality=100. Fixes bug #654310. Signed-off-by: David Schleef <ds@schleef.org>
Diffstat (limited to 'ext')
-rw-r--r--ext/faac/gstfaac.c66
-rw-r--r--ext/faac/gstfaac.h2
2 files changed, 64 insertions, 4 deletions
diff --git a/ext/faac/gstfaac.c b/ext/faac/gstfaac.c
index 978e6ccd2..c0db878d5 100644
--- a/ext/faac/gstfaac.c
+++ b/ext/faac/gstfaac.c
@@ -91,6 +91,12 @@
"rate = (int) {" SAMPLE_RATES "}, " \
"stream-format = (string) { adts, raw }, " \
"profile = (string) { main, lc }"
+ enum
+{
+ VBR = 1,
+ ABR
+};
+
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
@@ -104,7 +110,9 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
enum
{
PROP_0,
+ PROP_QUALITY,
PROP_BITRATE,
+ PROP_RATE_CONTROL,
PROP_PROFILE,
PROP_TNS,
PROP_MIDSIDE,
@@ -137,7 +145,9 @@ GST_DEBUG_CATEGORY_STATIC (faac_debug);
#define GST_CAT_DEFAULT faac_debug
#define FAAC_DEFAULT_OUTPUTFORMAT 0 /* RAW */
+#define FAAC_DEFAULT_QUALITY 100
#define FAAC_DEFAULT_BITRATE 128 * 1000
+#define FAAC_DEFAULT_RATE_CONTROL VBR
#define FAAC_DEFAULT_TNS FALSE
#define FAAC_DEFAULT_MIDSIDE TRUE
#define FAAC_DEFAULT_SHORTCTL SHORTCTL_NORMAL
@@ -193,6 +203,26 @@ gst_faac_base_init (GstFaacClass * klass)
GST_DEBUG_CATEGORY_INIT (faac_debug, "faac", 0, "AAC encoding");
}
+#define GST_TYPE_FAAC_RATE_CONTROL (gst_faac_brtype_get_type ())
+static GType
+gst_faac_brtype_get_type (void)
+{
+ static GType gst_faac_brtype_type = 0;
+
+ if (!gst_faac_brtype_type) {
+ static GEnumValue gst_faac_brtype[] = {
+ {VBR, "VBR", "VBR encoding"},
+ {ABR, "ABR", "ABR encoding"},
+ {0, NULL, NULL},
+ };
+
+ gst_faac_brtype_type = g_enum_register_static ("GstFaacBrtype",
+ gst_faac_brtype);
+ }
+
+ return gst_faac_brtype_type;
+}
+
#define GST_TYPE_FAAC_SHORTCTL (gst_faac_shortctl_get_type ())
static GType
gst_faac_shortctl_get_type (void)
@@ -227,10 +257,18 @@ gst_faac_class_init (GstFaacClass * klass)
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_faac_finalize);
/* properties */
+ g_object_class_install_property (gobject_class, PROP_QUALITY,
+ g_param_spec_int ("quality", "Quality (%)",
+ "Variable bitrate (VBR) quantizer quality in %", 1, 1000,
+ FAAC_DEFAULT_QUALITY, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_BITRATE,
- g_param_spec_int ("bitrate", "Bitrate (bps)", "Bitrate in bits/sec",
- 8 * 1000, 320 * 1000, FAAC_DEFAULT_BITRATE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_param_spec_int ("bitrate", "Bitrate (bps)",
+ "Average bitrate (ABR) in bits/sec", 8 * 1000, 320 * 1000,
+ FAAC_DEFAULT_BITRATE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_RATE_CONTROL,
+ g_param_spec_enum ("rate-control", "Rate Control (ABR/VBR)",
+ "Encoding bitrate type (VBR/ABR)", GST_TYPE_FAAC_RATE_CONTROL,
+ FAAC_DEFAULT_RATE_CONTROL, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_TNS,
g_param_spec_boolean ("tns", "TNS", "Use temporal noise shaping",
FAAC_DEFAULT_TNS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
@@ -271,7 +309,9 @@ gst_faac_init (GstFaac * faac)
faac->mpegversion = 4;
/* default properties */
+ faac->quality = FAAC_DEFAULT_QUALITY;
faac->bitrate = FAAC_DEFAULT_BITRATE;
+ faac->brtype = FAAC_DEFAULT_RATE_CONTROL;
faac->shortctl = FAAC_DEFAULT_SHORTCTL;
faac->outputformat = FAAC_DEFAULT_OUTPUTFORMAT;
faac->tns = FAAC_DEFAULT_TNS;
@@ -557,7 +597,13 @@ gst_faac_configure_source_pad (GstFaac * faac)
conf->allowMidside = faac->midside;
conf->useLfe = 0;
conf->useTns = faac->tns;
- conf->bitRate = faac->bitrate / faac->channels;
+
+ if (faac->brtype == VBR) {
+ conf->quantqual = faac->quality;
+ } else if (faac->brtype == ABR) {
+ conf->bitRate = faac->bitrate / faac->channels;
+ }
+
conf->inputFormat = faac->format;
conf->outputFormat = faac->outputformat;
conf->shortctl = faac->shortctl;
@@ -879,9 +925,15 @@ gst_faac_set_property (GObject * object,
GST_OBJECT_LOCK (faac);
switch (prop_id) {
+ case PROP_QUALITY:
+ faac->quality = g_value_get_int (value);
+ break;
case PROP_BITRATE:
faac->bitrate = g_value_get_int (value);
break;
+ case PROP_RATE_CONTROL:
+ faac->brtype = g_value_get_enum (value);
+ break;
case PROP_TNS:
faac->tns = g_value_get_boolean (value);
break;
@@ -908,9 +960,15 @@ gst_faac_get_property (GObject * object,
GST_OBJECT_LOCK (faac);
switch (prop_id) {
+ case PROP_QUALITY:
+ g_value_set_int (value, faac->quality);
+ break;
case PROP_BITRATE:
g_value_set_int (value, faac->bitrate);
break;
+ case PROP_RATE_CONTROL:
+ g_value_set_enum (value, faac->brtype);
+ break;
case PROP_TNS:
g_value_set_boolean (value, faac->tns);
break;
diff --git a/ext/faac/gstfaac.h b/ext/faac/gstfaac.h
index 49e2b85e8..f5ab5ab4f 100644
--- a/ext/faac/gstfaac.h
+++ b/ext/faac/gstfaac.h
@@ -52,7 +52,9 @@ struct _GstFaac {
channels,
format,
bps,
+ quality,
bitrate,
+ brtype,
profile,
mpegversion,
shortctl,