Revision 969c163f libavcodec/mpegaudiodec.c

View differences:

libavcodec/mpegaudiodec.c
24 24
 * MPEG Audio decoder.
25 25
 */
26 26

  
27
//#define DEBUG
28 27
#include "avcodec.h"
29 28
#include "bitstream.h"
30 29
#include "dsputil.h"
......
430 429

  
431 430
            /* normalized to FRAC_BITS */
432 431
            table_4_3_value[i] = m;
433
//            av_log(NULL, AV_LOG_DEBUG, "%d %d %f\n", i, m, pow((double)i, 4.0 / 3.0));
434 432
            table_4_3_exp[i] = -e;
435 433
        }
436 434
        for(i=0; i<512*16; i++){
......
485 483
            csa_table_float[i][1] = ca;
486 484
            csa_table_float[i][2] = ca + cs;
487 485
            csa_table_float[i][3] = ca - cs;
488
//            printf("%d %d %d %d\n", FIX(cs), FIX(cs-1), FIX(ca), FIX(cs)-FIX(ca));
489
//            av_log(NULL, AV_LOG_DEBUG,"%f %f %f %f\n", cs, ca, ca+cs, ca-cs);
490 486
        }
491 487

  
492 488
        /* compute mdct windows */
......
514 510
                    mdct_win[j][i/3] = FIXHR((d / (1<<5)));
515 511
                else
516 512
                    mdct_win[j][i  ] = FIXHR((d / (1<<5)));
517
//                av_log(NULL, AV_LOG_DEBUG, "%2d %d %f\n", i,j,d / (1<<5));
518 513
            }
519 514
        }
520 515

  
......
527 522
            }
528 523
        }
529 524

  
530
#if defined(DEBUG)
531
        for(j=0;j<8;j++) {
532
            av_log(avctx, AV_LOG_DEBUG, "win%d=\n", j);
533
            for(i=0;i<36;i++)
534
                av_log(avctx, AV_LOG_DEBUG, "%f, ", (double)mdct_win[j][i] / FRAC_ONE);
535
            av_log(avctx, AV_LOG_DEBUG, "\n");
536
        }
537
#endif
538 525
        init = 1;
539 526
    }
540 527

  
541
#ifdef DEBUG
542
    s->frame_count = 0;
543
#endif
544 528
    if (avctx->codec_id == CODEC_ID_MP3ADU)
545 529
        s->adu_mode = 1;
546 530
    return 0;
......
1251 1235
        j += 1 << bit_alloc_bits;
1252 1236
    }
1253 1237

  
1254
#ifdef DEBUG
1255
    {
1256
        for(ch=0;ch<s->nb_channels;ch++) {
1257
            for(i=0;i<sblimit;i++)
1258
                dprintf(s->avctx, " %d", bit_alloc[ch][i]);
1259
            dprintf(s->avctx, "\n");
1260
        }
1261
    }
1262
#endif
1263

  
1264 1238
    /* scale codes */
1265 1239
    for(i=0;i<sblimit;i++) {
1266 1240
        for(ch=0;ch<s->nb_channels;ch++) {
......
1301 1275
        }
1302 1276
    }
1303 1277

  
1304
#ifdef DEBUG
1305
    for(ch=0;ch<s->nb_channels;ch++) {
1306
        for(i=0;i<sblimit;i++) {
1307
            if (bit_alloc[ch][i]) {
1308
                sf = scale_factors[ch][i];
1309
                dprintf(s->avctx, " %d %d %d", sf[0], sf[1], sf[2]);
1310
            } else {
1311
                dprintf(s->avctx, " -");
1312
            }
1313
        }
1314
        dprintf(s->avctx, "\n");
1315
    }
1316
#endif
1317

  
1318 1278
    /* samples */
1319 1279
    for(k=0;k<3;k++) {
1320 1280
        for(l=0;l<12;l+=3) {
......
1990 1950
    }
1991 1951
}
1992 1952

  
1993
#if defined(DEBUG)
1994
void sample_dump(int fnum, int32_t *tab, int n)
1995
{
1996
    static FILE *files[16], *f;
1997
    char buf[512];
1998
    int i;
1999
    int32_t v;
2000

  
2001
    f = files[fnum];
2002
    if (!f) {
2003
        snprintf(buf, sizeof(buf), "/tmp/out%d.%s.pcm",
2004
                fnum,
2005
#ifdef USE_HIGHPRECISION
2006
                "hp"
2007
#else
2008
                "lp"
2009
#endif
2010
                );
2011
        f = fopen(buf, "w");
2012
        if (!f)
2013
            return;
2014
        files[fnum] = f;
2015
    }
2016

  
2017
    if (fnum == 0) {
2018
        static int pos = 0;
2019
        av_log(NULL, AV_LOG_DEBUG, "pos=%d\n", pos);
2020
        for(i=0;i<n;i++) {
2021
            av_log(NULL, AV_LOG_DEBUG, " %0.4f", (double)tab[i] / FRAC_ONE);
2022
            if ((i % 18) == 17)
2023
                av_log(NULL, AV_LOG_DEBUG, "\n");
2024
        }
2025
        pos += n;
2026
    }
2027
    for(i=0;i<n;i++) {
2028
        /* normalize to 23 frac bits */
2029
        v = tab[i] << (23 - FRAC_BITS);
2030
        fwrite(&v, 1, sizeof(int32_t), f);
2031
    }
2032
}
2033
#endif
2034

  
2035

  
2036 1953
/* main layer3 decoding function */
2037 1954
static int mp_decode_layer3(MPADecodeContext *s)
2038 1955
{
......
2201 2118
                    }
2202 2119
                    g->scale_factors[j++] = 0;
2203 2120
                }
2204
#if defined(DEBUG)
2205
                {
2206
                    dprintf(s->avctx, "scfsi=%x gr=%d ch=%d scale_factors:\n",
2207
                           g->scfsi, gr, ch);
2208
                    for(i=0;i<j;i++)
2209
                        dprintf(s->avctx, " %d", g->scale_factors[i]);
2210
                    dprintf(s->avctx, "\n");
2211
                }
2212
#endif
2213 2121
            } else {
2214 2122
                int tindex, tindex2, slen[4], sl, sf;
2215 2123

  
......
2263 2171
                /* XXX: should compute exact size */
2264 2172
                for(;j<40;j++)
2265 2173
                    g->scale_factors[j] = 0;
2266
#if defined(DEBUG)
2267
                {
2268
                    dprintf(s->avctx, "gr=%d ch=%d scale_factors:\n",
2269
                           gr, ch);
2270
                    for(i=0;i<40;i++)
2271
                        dprintf(s->avctx, " %d", g->scale_factors[i]);
2272
                    dprintf(s->avctx, "\n");
2273
                }
2274
#endif
2275 2174
            }
2276 2175

  
2277 2176
            exponents_from_scale_factors(s, g, exponents);
2278 2177

  
2279 2178
            /* read Huffman coded residue */
2280 2179
            huffman_decode(s, g, exponents, bits_pos + g->part2_3_length);
2281
#if defined(DEBUG)
2282
            sample_dump(0, g->sb_hybrid, 576);
2283
#endif
2284 2180
        } /* ch */
2285 2181

  
2286 2182
        if (s->nb_channels == 2)
......
2290 2186
            g = &granules[ch][gr];
2291 2187

  
2292 2188
            reorder_block(s, g);
2293
#if defined(DEBUG)
2294
            sample_dump(0, g->sb_hybrid, 576);
2295
#endif
2296 2189
            s->compute_antialias(s, g);
2297
#if defined(DEBUG)
2298
            sample_dump(1, g->sb_hybrid, 576);
2299
#endif
2300 2190
            compute_imdct(s, g, &s->sb_samples[ch][18 * gr][0], s->mdct_buf[ch]);
2301
#if defined(DEBUG)
2302
            sample_dump(2, &s->sb_samples[ch][18 * gr][0], 576);
2303
#endif
2304 2191
        }
2305 2192
    } /* gr */
2306 2193
    if(get_bits_count(&s->gb)<0)
......
2362 2249

  
2363 2250
        break;
2364 2251
    }
2365
#if defined(DEBUG)
2366
    for(i=0;i<nb_frames;i++) {
2367
        for(ch=0;ch<s->nb_channels;ch++) {
2368
            int j;
2369
            dprintf(s->avctx, "%d-%d:", i, ch);
2370
            for(j=0;j<SBLIMIT;j++)
2371
                dprintf(s->avctx, " %0.6f", (double)s->sb_samples[ch][i][j] / FRAC_ONE);
2372
            dprintf(s->avctx, "\n");
2373
        }
2374
    }
2375
#endif
2252

  
2376 2253
    /* apply the synthesis filter */
2377 2254
    for(ch=0;ch<s->nb_channels;ch++) {
2378 2255
        samples_ptr = samples + ch;
......
2384 2261
            samples_ptr += 32 * s->nb_channels;
2385 2262
        }
2386 2263
    }
2387
#ifdef DEBUG
2388
    s->frame_count++;
2389
#endif
2264

  
2390 2265
    return nb_frames * 32 * sizeof(OUT_INT) * s->nb_channels;
2391 2266
}
2392 2267

  

Also available in: Unified diff