Browse code

Last hunk of the AAC decoder code to be OKed and build system and documentation alterations as appropriate

Originally committed as revision 14873 to svn://svn.ffmpeg.org/ffmpeg/trunk

Robert Swain authored on 2008/08/21 16:21:26
Showing 6 changed files
... ...
@@ -130,6 +130,7 @@ version <next>
130 130
 - D-Cinema audio muxer
131 131
 - Electronic Arts TGV decoder
132 132
 - Apple Lossless Audio Codec (ALAC) encoder
133
+- AAC decoder
133 134
 
134 135
 version 0.4.9-pre1:
135 136
 
... ...
@@ -337,7 +337,7 @@ following image formats are supported:
337 337
 @item 4X IMA ADPCM           @tab     @tab  X
338 338
 @item 8SVX audio             @tab     @tab  X
339 339
 @item AAC                    @tab  X  @tab  X
340
-    @tab Supported through the external library libfaac/libfaad.
340
+    @tab Encoding is supported through the external library libfaac.
341 341
 @item AC-3                   @tab IX  @tab IX
342 342
     @tab liba52 can be used alternatively for decoding.
343 343
 @item AMR-NB                 @tab  X  @tab  X
... ...
@@ -25,6 +25,7 @@ HEADERS = avcodec.h opt.h
25 25
 
26 26
 OBJS-$(CONFIG_ENCODERS)                += faandct.o jfdctfst.o jfdctint.o
27 27
 
28
+OBJS-$(CONFIG_AAC_DECODER)             += aac.o aactab.o mdct.o fft.o
28 29
 OBJS-$(CONFIG_AASC_DECODER)            += aasc.o
29 30
 OBJS-$(CONFIG_AC3_DECODER)             += ac3dec.o ac3tab.o ac3dec_data.o ac3.o mdct.o fft.o
30 31
 OBJS-$(CONFIG_AC3_ENCODER)             += ac3enc.o ac3tab.o ac3.o
... ...
@@ -1104,6 +1104,42 @@ static int decode_extension_payload(AACContext * ac, GetBitContext * gb, int cnt
1104 1104
     return res;
1105 1105
 }
1106 1106
 
1107
+/**
1108
+ * Decode Temporal Noise Shaping filter coefficients and apply all-pole filters; reference: 4.6.9.3.
1109
+ *
1110
+ * @param   decode  1 if tool is used normally, 0 if tool is used in LTP.
1111
+ * @param   coef    spectral coefficients
1112
+ */
1113
+static void apply_tns(float coef[1024], TemporalNoiseShaping * tns, IndividualChannelStream * ics, int decode) {
1114
+    const int mmm = FFMIN(ics->tns_max_bands,  ics->max_sfb);
1115
+    int w, filt, m, i, ib;
1116
+    int bottom, top, order, start, end, size, inc;
1117
+    float lpc[TNS_MAX_ORDER];
1118
+
1119
+    for (w = 0; w < ics->num_windows; w++) {
1120
+        bottom = ics->num_swb;
1121
+        for (filt = 0; filt < tns->n_filt[w]; filt++) {
1122
+            top    = bottom;
1123
+            bottom = FFMAX(0, top - tns->length[w][filt]);
1124
+            order  = tns->order[w][filt];
1125
+            if (order == 0)
1126
+                continue;
1127
+
1128
+            /* tns_decode_coef
1129
+             * FIXME: This duplicates the functionality of some double code in lpc.c.
1130
+             */
1131
+            for (m = 0; m < order; m++) {
1132
+               float tmp;
1133
+               lpc[m] = tns->coef[w][filt][m];
1134
+               for (i = 0; i < m/2; i++) {
1135
+                   tmp = lpc[i];
1136
+                   lpc[i]     += lpc[m] * lpc[m-1-i];
1137
+                   lpc[m-1-i] += lpc[m] * tmp;
1138
+               }
1139
+               if(m & 1)
1140
+                   lpc[i]     += lpc[m] * lpc[i];
1141
+            }
1142
+
1107 1143
             start = ics->swb_offset[FFMIN(bottom, mmm)];
1108 1144
             end   = ics->swb_offset[FFMIN(   top, mmm)];
1109 1145
             if ((size = end - start) <= 0)
... ...
@@ -1118,7 +1154,7 @@ static int decode_extension_payload(AACContext * ac, GetBitContext * gb, int cnt
1118 1118
             // ar filter
1119 1119
             for (m = 0; m < size; m++, start += inc)
1120 1120
                 for (i = 1; i <= FFMIN(m, order); i++)
1121
-                    coef[start] -= coef[start - i*inc] * lpc[i];
1121
+                    coef[start] -= coef[start - i*inc] * lpc[i-1];
1122 1122
         }
1123 1123
     }
1124 1124
 }
... ...
@@ -181,6 +181,7 @@ void avcodec_register_all(void)
181 181
     REGISTER_ENCDEC  (ZMBV, zmbv);
182 182
 
183 183
     /* audio codecs */
184
+    REGISTER_DECODER (AAC, aac);
184 185
     REGISTER_ENCDEC  (AC3, ac3);
185 186
     REGISTER_ENCDEC  (ALAC, alac);
186 187
     REGISTER_DECODER (APE, ape);
... ...
@@ -30,7 +30,7 @@
30 30
 #include "libavutil/avutil.h"
31 31
 
32 32
 #define LIBAVCODEC_VERSION_MAJOR 51
33
-#define LIBAVCODEC_VERSION_MINOR 68
33
+#define LIBAVCODEC_VERSION_MINOR 69
34 34
 #define LIBAVCODEC_VERSION_MICRO  0
35 35
 
36 36
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \