[FFmpeg-soc] [soc]: r1858 - in aac: aac.c aactab.h

andoma subversion at mplayerhq.hu
Thu Jan 31 15:57:47 CET 2008


Author: andoma
Date: Thu Jan 31 15:57:47 2008
New Revision: 1858

Log:
Add support for explicit sample rate in GetSampleRate()



Modified:
   aac/aac.c
   aac/aactab.h

Modified: aac/aac.c
==============================================================================
--- aac/aac.c	(original)
+++ aac/aac.c	Thu Jan 31 15:57:47 2008
@@ -659,15 +659,25 @@ static int GetAudioObjectType(GetBitCont
     return result == 31 ? 32 + get_bits(gb, 6) : result;
 }
 
-static inline int GetSampleRate(GetBitContext * gb, int *index, int *rate) {
+/**
+ * Parse sample rate
+ * reference: Table 1.16 and 4.68
+ */
+static int GetSampleRate(GetBitContext * gb, int *index, int *rate) {
+    int i;
     *index = get_bits(gb, 4);
-    if (*index == 0xf) {
-        *index = -1;
+    if(*index == 0xf) {
+        /* Explicit rate */
         *rate = get_bits(gb, 24);
-    } else {
-        assert(*index <= 12);
-        *rate = sampling_table[*index];
+        for(i = 10; i >= 0; i--)
+            if(*rate < inv_sampling_table[i])
+                break;
+        *index = i + 1;
+        return 0;
     }
+    if(*index > 12)
+        return -1;
+    *rate = sampling_table[*index];
     return 0;
 }
 

Modified: aac/aactab.h
==============================================================================
--- aac/aactab.h	(original)
+++ aac/aactab.h	Thu Jan 31 15:57:47 2008
@@ -33,6 +33,7 @@
 #define TNS_MAX_ORDER 20
 
 static const int sampling_table[] = { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350 };
+static const int inv_sampling_table[] = { 92017, 75132, 55426, 46009, 37655, 27713, 23004, 18783, 13856, 11502, 9391 };
 
 // scalefactor bands
 static const uint16_t swb_offset_1024_96[] = {



More information about the FFmpeg-soc mailing list