Browse code

Bink version 'b' audio decoder

Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
(cherry picked from commit ccfcddb3f287545a20831f266c2a2f734d6a9f31)

Peter Ross authored on 2011/02/20 10:25:05
Showing 3 changed files
... ...
@@ -76,7 +76,7 @@ version <next>:
76 76
 - IVF muxer added
77 77
 - Wing Commander IV movies decoder added
78 78
 - movie source added
79
-- Bink version 'b' video decoder
79
+- Bink version 'b' audio and video decoder
80 80
 
81 81
 
82 82
 version 0.6:
... ...
@@ -33,7 +33,7 @@
33 33
 
34 34
 #define LIBAVCODEC_VERSION_MAJOR 52
35 35
 #define LIBAVCODEC_VERSION_MINOR 113
36
-#define LIBAVCODEC_VERSION_MICRO  1
36
+#define LIBAVCODEC_VERSION_MICRO  2
37 37
 
38 38
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
39 39
                                                LIBAVCODEC_VERSION_MINOR, \
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * Bink Audio decoder
3
- * Copyright (c) 2007-2010 Peter Ross (pross@xvid.org)
3
+ * Copyright (c) 2007-2011 Peter Ross (pross@xvid.org)
4 4
  * Copyright (c) 2009 Daniel Verkamp (daniel@drv.nu)
5 5
  *
6 6
  * This file is part of FFmpeg.
... ...
@@ -34,6 +34,7 @@
34 34
 #include "dsputil.h"
35 35
 #include "fft.h"
36 36
 #include "fmtconvert.h"
37
+#include "libavutil/intfloat_readwrite.h"
37 38
 
38 39
 extern const uint16_t ff_wma_critical_freqs[25];
39 40
 
... ...
@@ -44,6 +45,7 @@ typedef struct {
44 44
     GetBitContext gb;
45 45
     DSPContext dsp;
46 46
     FmtConvertContext fmt_conv;
47
+    int version_b;          ///< Bink version 'b'
47 48
     int first;
48 49
     int channels;
49 50
     int frame_len;          ///< transform size (samples)
... ...
@@ -87,11 +89,14 @@ static av_cold int decode_init(AVCodecContext *avctx)
87 87
         return -1;
88 88
     }
89 89
 
90
+    s->version_b = avctx->codec_tag == MKTAG('B','I','K','b');
91
+
90 92
     if (avctx->codec->id == CODEC_ID_BINKAUDIO_RDFT) {
91 93
         // audio is already interleaved for the RDFT format variant
92 94
         sample_rate  *= avctx->channels;
93 95
         s->channels = 1;
94
-        frame_len_bits += av_log2(avctx->channels);
96
+        if (!s->version_b)
97
+            frame_len_bits += av_log2(avctx->channels);
95 98
     } else {
96 99
         s->channels = avctx->channels;
97 100
     }
... ...
@@ -162,8 +167,13 @@ static void decode_block(BinkAudioContext *s, short *out, int use_dct)
162 162
 
163 163
     for (ch = 0; ch < s->channels; ch++) {
164 164
         FFTSample *coeffs = s->coeffs_ptr[ch];
165
-        coeffs[0] = get_float(gb) * s->root;
166
-        coeffs[1] = get_float(gb) * s->root;
165
+        if (s->version_b) {
166
+            coeffs[0] = av_int2flt(get_bits(gb, 32)) * s->root;
167
+            coeffs[1] = av_int2flt(get_bits(gb, 32)) * s->root;
168
+        } else {
169
+            coeffs[0] = get_float(gb) * s->root;
170
+            coeffs[1] = get_float(gb) * s->root;
171
+        }
167 172
 
168 173
         for (i = 0; i < s->num_bands; i++) {
169 174
             /* constant is result of 0.066399999/log10(M_E) */
... ...
@@ -177,7 +187,9 @@ static void decode_block(BinkAudioContext *s, short *out, int use_dct)
177 177
         // parse coefficients
178 178
         i = 2;
179 179
         while (i < s->frame_len) {
180
-            if (get_bits1(gb)) {
180
+            if (s->version_b) {
181
+                j = i + 16;
182
+            } else if (get_bits1(gb)) {
181 183
                 j = i + rle_length_tab[get_bits(gb, 4)] * 8;
182 184
             } else {
183 185
                 j = i + 8;