ref: d011c78e03d017c10e8b9931bbcd63b57d78ea88
parent: 920472844ccea7792dfc58e0ad2d15b2b41785c3
author: menno <menno>
date: Sat Feb 10 07:28:54 EST 2001
- Fixed scalefactor bandwidths (Thanks again to Ivan) - Better checking of configuration
--- a/libfaac/frame.c
+++ b/libfaac/frame.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: frame.c,v 1.7 2001/02/09 09:07:35 menno Exp $
+ * $Id: frame.c,v 1.8 2001/02/10 12:28:54 menno Exp $
*/
/*
@@ -53,8 +53,17 @@
{
hEncoder->config.allowMidside = config->allowMidside;
hEncoder->config.useLfe = config->useLfe;
+
+ /* Check for correct bitrate */
+ if (config->bitRate > MaxBitrate(hEncoder->sampleRate))
+ return 0;
+ if (config->bitRate < MinBitrate(hEncoder->sampleRate))
+ return 0;
+
+ /* Bitrate check passed */
hEncoder->config.bitRate = config->bitRate;
+ /* OK */
return 1;
}
--- a/libfaac/util.c
+++ b/libfaac/util.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: util.c,v 1.2 2001/02/04 17:50:47 oxygene2000 Exp $
+ * $Id: util.c,v 1.3 2001/02/10 12:28:54 menno Exp $
*/
/* Returns the sample rate index */
@@ -37,10 +37,27 @@
return 11;
}
-int max(a, b){
- return (((a) > (b)) ? (a) : (b));
+/* Returns the maximum bitrate per channel for that sampling frequency */
+unsigned int MaxBitrate(unsigned long sampleRate)
+{
+ /*
+ * Maximum of 6144 bit for a channel
+ */
+ return (int)(6144.0 * (double)sampleRate/1024.0 + .5);
}
-int min(a, b){
- return (((a) < (b)) ? (a) : (b));
+/* Returns the minimum bitrate per channel for that sampling frequency */
+unsigned int MinBitrate(unsigned long sampleRate)
+{
+ return 8000;
+}
+
+int max(a, b)
+{
+ return (((a) > (b)) ? (a) : (b));
+}
+
+int min(a, b)
+{
+ return (((a) < (b)) ? (a) : (b));
}
--- a/libfaac/util.h
+++ b/libfaac/util.h
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: util.h,v 1.1 2001/01/17 11:21:40 menno Exp $
+ * $Id: util.h,v 1.2 2001/02/10 12:28:54 menno Exp $
*/
#ifndef UTIL_H
@@ -29,6 +29,8 @@
int GetSRIndex(unsigned int sampleRate);
+unsigned int MaxBitrate(unsigned long sampleRate);
+unsigned int MinBitrate(unsigned long sampleRate);
#ifdef __cplusplus