summaryrefslogtreecommitdiffstats
path: root/ext/faac/gstfaac.c
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2008-10-03 17:11:12 +0000
committerWim Taymans <wim.taymans@gmail.com>2008-10-03 17:11:12 +0000
commitdb433443c99cbd851fbb27ae5dee7fbd533f767e (patch)
treeea176155155c0950931ea5010e59e18d39acfd6b /ext/faac/gstfaac.c
parent67030c152bdaae04c9cb92cd5ef323454047b835 (diff)
downloadgst-plugins-bad-db433443c99cbd851fbb27ae5dee7fbd533f767e.tar.gz
gst-plugins-bad-db433443c99cbd851fbb27ae5dee7fbd533f767e.tar.bz2
gst-plugins-bad-db433443c99cbd851fbb27ae5dee7fbd533f767e.zip
ext/faac/gstfaac.c: Warn and clamp to max bitrate for samplerate.
Original commit message from CVS: * ext/faac/gstfaac.c: (gst_faac_configure_source_pad): Warn and clamp to max bitrate for samplerate. Fixes #550486.
Diffstat (limited to 'ext/faac/gstfaac.c')
-rw-r--r--ext/faac/gstfaac.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/ext/faac/gstfaac.c b/ext/faac/gstfaac.c
index fb62b336..487777a0 100644
--- a/ext/faac/gstfaac.c
+++ b/ext/faac/gstfaac.c
@@ -356,6 +356,7 @@ gst_faac_configure_source_pad (GstFaac * faac)
gboolean ret = FALSE;
gint n, ver, mpegversion;
faacEncConfiguration *conf;
+ guint maxbitrate;
mpegversion = FAAC_DEFAULT_MPEGVERSION;
@@ -392,6 +393,20 @@ gst_faac_configure_source_pad (GstFaac * faac)
conf->inputFormat = faac->format;
conf->outputFormat = faac->outputformat;
conf->shortctl = faac->shortctl;
+
+ /* check, warn and correct if the max bitrate for the given samplerate is
+ * exceeded. Maximum of 6144 bit for a channel */
+ maxbitrate =
+ (unsigned int) (6144.0 * (double) faac->samplerate / (double) 1024.0 +
+ .5);
+ if (conf->bitRate > maxbitrate) {
+ GST_ELEMENT_WARNING (faac, RESOURCE, SETTINGS, (NULL),
+ ("bitrate %u exceeds maximum allowed bitrate of %u for samplerate %d. "
+ "Setting bitrate to %u", conf->bitRate, maxbitrate,
+ faac->samplerate, maxbitrate));
+ conf->bitRate = maxbitrate;
+ }
+
if (!faacEncSetConfiguration (faac->handle, conf))
goto set_failed;