Browse code

Merge commit '56d061ce9da954560892e3551513d5ecc0439846'

* commit '56d061ce9da954560892e3551513d5ecc0439846':
metasound: add last missing modes (8kHz @ 6kbps per channel)

Conflicts:
Changelog
doc/general.texi

Merged-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2013/11/26 20:28:31
Showing 7 changed files
... ...
@@ -9,6 +9,7 @@ version <next>
9 9
 - elbg filter
10 10
 - string validation in ffprobe
11 11
 - support for decoding through VDPAU in ffmpeg (the -hwaccel option)
12
+- complete Voxware MetaSound decoder
12 13
 
13 14
 
14 15
 version 2.1:
... ...
@@ -943,7 +943,6 @@ following image formats are supported:
943 943
 @item Vorbis                 @tab  E  @tab  X
944 944
     @tab A native but very primitive encoder exists.
945 945
 @item Voxware MetaSound      @tab     @tab  X
946
-    @tab imperfect and incomplete support
947 946
 @item WavPack                @tab  X  @tab  X
948 947
 @item Westwood Audio (SND1)  @tab     @tab  X
949 948
 @item Windows Media Audio 1  @tab  X  @tab  X
... ...
@@ -187,7 +187,7 @@ static int metasound_read_bitstream(AVCodecContext *avctx, TwinVQContext *tctx,
187 187
 
188 188
         sub = mtab->fmode[bits->ftype].sub;
189 189
 
190
-        if (bits->ftype != TWINVQ_FT_SHORT)
190
+        if (bits->ftype != TWINVQ_FT_SHORT && !tctx->is_6kbps)
191 191
             get_bits(&gb, 2);
192 192
 
193 193
         read_cb_data(tctx, &gb, bits->main_coeffs, bits->ftype);
... ...
@@ -307,6 +307,12 @@ static av_cold int metasound_decode_init(AVCodecContext *avctx)
307 307
     ibps = avctx->bit_rate / (1000 * avctx->channels);
308 308
 
309 309
     switch ((avctx->channels << 16) + (isampf << 8) + ibps) {
310
+    case (1 << 16) + ( 8 << 8) +  6:
311
+        tctx->mtab = &ff_metasound_mode0806;
312
+        break;
313
+    case (2 << 16) + ( 8 << 8) +  6:
314
+        tctx->mtab = &ff_metasound_mode0806s;
315
+        break;
310 316
     case (1 << 16) + ( 8 << 8) +  8:
311 317
         tctx->mtab = &ff_metasound_mode0808;
312 318
         break;
... ...
@@ -362,6 +368,7 @@ static av_cold int metasound_decode_init(AVCodecContext *avctx)
362 362
     tctx->decode_ppc     = decode_ppc;
363 363
     tctx->frame_size     = avctx->bit_rate * tctx->mtab->size
364 364
                                            / avctx->sample_rate;
365
+    tctx->is_6kbps       = ibps == 6;
365 366
 
366 367
     return ff_twinvq_decode_init(avctx);
367 368
 }
... ...
@@ -15198,6 +15198,24 @@ static const uint16_t bark_tab_s44_128[] = {
15198 15198
     1, 2, 1, 2, 3, 4, 6, 10, 23, 76
15199 15199
 };
15200 15200
 
15201
+const TwinVQModeTab ff_metasound_mode0806 = {
15202
+    {
15203
+        {  8, bark_tab_s8_64,  10, fcb8s, 1, 5, cb0806ss0, cb0806ss1, 27 },
15204
+        {  2, bark_tab_m8_256, 20, fcb8m, 2, 5, cb0806sm0, cb0806sm1, 22 },
15205
+        {  1, bark_tab_l8_512, 30, fcb8l, 3, 6, cb0806sl0, cb0806sl1, 24 }
15206
+    },
15207
+    512, 12, lsp8, 1, 5, 3, 3, shape8, 8, 28, 20, 6, 200
15208
+};
15209
+
15210
+const TwinVQModeTab ff_metasound_mode0806s = {
15211
+    {
15212
+        {  8, bark_tab_s8s_64,  10, fcb8ss, 1, 5, cb0806ss0, cb0806ss1, 27 },
15213
+        {  2, bark_tab_m8s_256, 20, fcb8sm, 2, 5, cb0806sm0, cb0806sm1, 22 },
15214
+        {  1, bark_tab_l8s_512, 30, fcb8sl, 3, 6, cb0806sl0, cb0806sl1, 24 }
15215
+    },
15216
+    512, 12, lsp8s, 1, 5, 3, 3, shape8s, 8, 28, 20, 6, 200
15217
+};
15218
+
15201 15219
 const TwinVQModeTab ff_metasound_mode0808 = {
15202 15220
     {
15203 15221
         { 8, bark_tab_s8_64,  10, fcb8s, 1, 5, cb0808s0, cb0808s1, 18 },
... ...
@@ -704,7 +704,7 @@ static av_cold void init_bitstream_params(TwinVQContext *tctx)
704 704
             TWINVQ_WINDOW_TYPE_BITS +
705 705
             mtab->fmode[i].sub * (bse_bits[i] + n_ch * TWINVQ_SUB_GAIN_BITS);
706 706
 
707
-    if (tctx->codec == TWINVQ_CODEC_METASOUND) {
707
+    if (tctx->codec == TWINVQ_CODEC_METASOUND && !tctx->is_6kbps) {
708 708
         bsize_no_main_cb[1] += 2;
709 709
         bsize_no_main_cb[2] += 2;
710 710
     }
... ...
@@ -141,6 +141,8 @@ typedef struct TwinVQContext {
141 141
 
142 142
     const TwinVQModeTab *mtab;
143 143
 
144
+    int is_6kbps;
145
+
144 146
     // history
145 147
     float lsp_hist[2][20];           ///< LSP coefficients of the last frame
146 148
     float bark_hist[3][2][40];       ///< BSE coefficients of last frame
... ...
@@ -402,6 +402,7 @@ static av_cold int twinvq_decode_init(AVCodecContext *avctx)
402 402
     tctx->decode_ppc     = decode_ppc;
403 403
     tctx->frame_size     = avctx->bit_rate * tctx->mtab->size
404 404
                                            / avctx->sample_rate + 8;
405
+    tctx->is_6kbps       = 0;
405 406
     if (avctx->block_align && avctx->block_align * 8 / tctx->frame_size > 1) {
406 407
         av_log(avctx, AV_LOG_ERROR,
407 408
                "VQF TwinVQ should have only one frame per packet\n");