diff options
author | Michel Bardiaux <mbardiaux@mediaxim.be> | 2007-03-12 12:36:41 +0000 |
---|---|---|
committer | Michel Bardiaux <mbardiaux@mediaxim.be> | 2007-03-12 12:36:41 +0000 |
commit | 318c5e052415aada4036c382cb0ef243113f667a (patch) | |
tree | 1badf5b9254d9b8807759f59bd6121f9ce180b3b /libavcodec/mpegaudiodec.c | |
parent | ea486ab3bede4fc68b8cccb70791cdfa589a0fcb (diff) | |
download | ffmpeg-318c5e052415aada4036c382cb0ef243113f667a.tar.gz |
Give context to dprintf
Originally committed as revision 8338 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mpegaudiodec.c')
-rw-r--r-- | libavcodec/mpegaudiodec.c | 69 |
1 files changed, 37 insertions, 32 deletions
diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c index ef3384b630..5cd251e292 100644 --- a/libavcodec/mpegaudiodec.c +++ b/libavcodec/mpegaudiodec.c @@ -90,6 +90,7 @@ typedef struct MPADecodeContext { int adu_mode; ///< 0 for standard mp3, 1 for adu formatted mp3 int dither_state; int error_resilience; + AVCodecContext* avctx; } MPADecodeContext; /** @@ -301,6 +302,8 @@ static int decode_init(AVCodecContext * avctx) static int init=0; int i, j, k; + s->avctx = avctx; + #if defined(USE_HIGHPRECISION) && defined(CONFIG_AUDIO_NONSHORT) avctx->sample_fmt= SAMPLE_FMT_S32; #else @@ -331,7 +334,7 @@ static int decode_init(AVCodecContext * avctx) scale_factor_mult[i][0] = MULL(FIXR(1.0 * 2.0), norm); scale_factor_mult[i][1] = MULL(FIXR(0.7937005259 * 2.0), norm); scale_factor_mult[i][2] = MULL(FIXR(0.6299605249 * 2.0), norm); - dprintf("%d: norm=%x s=%x %x %x\n", + dprintf(avctx, "%d: norm=%x s=%x %x %x\n", i, norm, scale_factor_mult[i][0], scale_factor_mult[i][1], @@ -436,7 +439,7 @@ static int decode_init(AVCodecContext * avctx) k = i & 1; is_table_lsf[j][k ^ 1][i] = FIXR(f); is_table_lsf[j][k][i] = FIXR(1.0); - dprintf("is_table_lsf %d %d: %x %x\n", + dprintf(avctx, "is_table_lsf %d %d: %x %x\n", i, j, is_table_lsf[j][0][i], is_table_lsf[j][1][i]); } } @@ -1172,20 +1175,20 @@ static int decode_header(MPADecodeContext *s, uint32_t header) } #if defined(DEBUG) - dprintf("layer%d, %d Hz, %d kbits/s, ", + dprintf(s->avctx, "layer%d, %d Hz, %d kbits/s, ", s->layer, s->sample_rate, s->bit_rate); if (s->nb_channels == 2) { if (s->layer == 3) { if (s->mode_ext & MODE_EXT_MS_STEREO) - dprintf("ms-"); + dprintf(s->avctx, "ms-"); if (s->mode_ext & MODE_EXT_I_STEREO) - dprintf("i-"); + dprintf(s->avctx, "i-"); } - dprintf("stereo"); + dprintf(s->avctx, "stereo"); } else { - dprintf("mono"); + dprintf(s->avctx, "mono"); } - dprintf("\n"); + dprintf(s->avctx, "\n"); #endif return 0; } @@ -1195,6 +1198,7 @@ static int decode_header(MPADecodeContext *s, uint32_t header) int mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate) { MPADecodeContext s1, *s = &s1; + s1.avctx = avctx; if (ff_mpa_check_header(head) != 0) return -1; @@ -1336,7 +1340,7 @@ static int mp_decode_layer2(MPADecodeContext *s) else bound = sblimit; - dprintf("bound=%d sblimit=%d\n", bound, sblimit); + dprintf(s->avctx, "bound=%d sblimit=%d\n", bound, sblimit); /* sanity check */ if( bound > sblimit ) bound = sblimit; @@ -1362,8 +1366,8 @@ static int mp_decode_layer2(MPADecodeContext *s) { for(ch=0;ch<s->nb_channels;ch++) { for(i=0;i<sblimit;i++) - dprintf(" %d", bit_alloc[ch][i]); - dprintf("\n"); + dprintf(s->avctx, " %d", bit_alloc[ch][i]); + dprintf(s->avctx, "\n"); } } #endif @@ -1413,12 +1417,12 @@ static int mp_decode_layer2(MPADecodeContext *s) for(i=0;i<sblimit;i++) { if (bit_alloc[ch][i]) { sf = scale_factors[ch][i]; - dprintf(" %d %d %d", sf[0], sf[1], sf[2]); + dprintf(s->avctx, " %d %d %d", sf[0], sf[1], sf[2]); } else { - dprintf(" -"); + dprintf(s->avctx, " -"); } } - dprintf("\n"); + dprintf(s->avctx, "\n"); } #endif @@ -1656,7 +1660,7 @@ static int huffman_decode(MPADecodeContext *s, GranuleDef *g, exponent= exponents[s_index]; - dprintf("region=%d n=%d x=%d y=%d exp=%d\n", + dprintf(s->avctx, "region=%d n=%d x=%d y=%d exp=%d\n", i, g->region_size[i] - j, x, y, exponent); if(y&16){ x = y >> 5; @@ -1725,7 +1729,7 @@ static int huffman_decode(MPADecodeContext *s, GranuleDef *g, last_pos= pos; code = get_vlc2(&s->gb, vlc->table, vlc->bits, 1); - dprintf("t=%d code=%d\n", g->count1table_select, code); + dprintf(s->avctx, "t=%d code=%d\n", g->count1table_select, code); g->sb_hybrid[s_index+0]= g->sb_hybrid[s_index+1]= g->sb_hybrid[s_index+2]= @@ -2168,12 +2172,12 @@ static int mp_decode_layer3(MPADecodeContext *s) for(gr=0;gr<nb_granules;gr++) { for(ch=0;ch<s->nb_channels;ch++) { - dprintf("gr=%d ch=%d: side_info\n", gr, ch); + dprintf(s->avctx, "gr=%d ch=%d: side_info\n", gr, ch); g = &granules[ch][gr]; g->part2_3_length = get_bits(&s->gb, 12); g->big_values = get_bits(&s->gb, 9); if(g->big_values > 288){ - av_log(NULL, AV_LOG_ERROR, "big_values too big\n"); + av_log(s->avctx, AV_LOG_ERROR, "big_values too big\n"); return -1; } @@ -2220,7 +2224,7 @@ static int mp_decode_layer3(MPADecodeContext *s) /* compute huffman coded region sizes */ region_address1 = get_bits(&s->gb, 4); region_address2 = get_bits(&s->gb, 3); - dprintf("region1=%d region2=%d\n", + dprintf(s->avctx, "region1=%d region2=%d\n", region_address1, region_address2); g->region_size[0] = band_index_long[s->sample_rate_index][region_address1 + 1] >> 1; @@ -2269,7 +2273,7 @@ static int mp_decode_layer3(MPADecodeContext *s) g->preflag = get_bits(&s->gb, 1); g->scalefac_scale = get_bits(&s->gb, 1); g->count1table_select = get_bits(&s->gb, 1); - dprintf("block_type=%d switch_point=%d\n", + dprintf(s->avctx, "block_type=%d switch_point=%d\n", g->block_type, g->switch_point); } } @@ -2278,7 +2282,7 @@ static int mp_decode_layer3(MPADecodeContext *s) const uint8_t *ptr = s->gb.buffer + (get_bits_count(&s->gb)>>3); assert((get_bits_count(&s->gb) & 7) == 0); /* now we get bits from the main_data_begin offset */ - dprintf("seekback: %d\n", main_data_begin); + dprintf(s->avctx, "seekback: %d\n", main_data_begin); //av_log(NULL, AV_LOG_ERROR, "backstep:%d, lastbuf:%d\n", main_data_begin, s->last_buf_size); memcpy(s->last_buf + s->last_buf_size, ptr, EXTRABYTES); @@ -2312,7 +2316,7 @@ static int mp_decode_layer3(MPADecodeContext *s) /* MPEG1 scale factors */ slen1 = slen_table[0][g->scalefac_compress]; slen2 = slen_table[1][g->scalefac_compress]; - dprintf("slen1=%d slen2=%d\n", slen1, slen2); + dprintf(s->avctx, "slen1=%d slen2=%d\n", slen1, slen2); if (g->block_type == 2) { n = g->switch_point ? 17 : 18; j = 0; @@ -2358,11 +2362,11 @@ static int mp_decode_layer3(MPADecodeContext *s) } #if defined(DEBUG) { - dprintf("scfsi=%x gr=%d ch=%d scale_factors:\n", + dprintf(s->avctx, "scfsi=%x gr=%d ch=%d scale_factors:\n", g->scfsi, gr, ch); for(i=0;i<j;i++) - dprintf(" %d", g->scale_factors[i]); - dprintf("\n"); + dprintf(s->avctx, " %d", g->scale_factors[i]); + dprintf(s->avctx, "\n"); } #endif } else { @@ -2420,11 +2424,11 @@ static int mp_decode_layer3(MPADecodeContext *s) g->scale_factors[j] = 0; #if defined(DEBUG) { - dprintf("gr=%d ch=%d scale_factors:\n", + dprintf(s->avctx, "gr=%d ch=%d scale_factors:\n", gr, ch); for(i=0;i<40;i++) - dprintf(" %d", g->scale_factors[i]); - dprintf("\n"); + dprintf(s->avctx, " %d", g->scale_factors[i]); + dprintf(s->avctx, "\n"); } #endif } @@ -2475,7 +2479,7 @@ static int mp_decode_frame(MPADecodeContext *s, if (s->error_protection) get_bits(&s->gb, 16); - dprintf("frame %d:\n", s->frame_count); + dprintf(s->avctx, "frame %d:\n", s->frame_count); switch(s->layer) { case 1: nb_frames = mp_decode_layer1(s); @@ -2518,10 +2522,10 @@ static int mp_decode_frame(MPADecodeContext *s, for(i=0;i<nb_frames;i++) { for(ch=0;ch<s->nb_channels;ch++) { int j; - dprintf("%d-%d:", i, ch); + dprintf(s->avctx, "%d-%d:", i, ch); for(j=0;j<SBLIMIT;j++) - dprintf(" %0.6f", (double)s->sb_samples[ch][i][j] / FRAC_ONE); - dprintf("\n"); + dprintf(s->avctx, " %0.6f", (double)s->sb_samples[ch][i][j] / FRAC_ONE); + dprintf(s->avctx, "\n"); } } #endif @@ -2717,6 +2721,7 @@ static int decode_init_mp3on4(AVCodecContext * avctx) s->mp3decctx[i] = av_mallocz(sizeof(MPADecodeContext)); s->mp3decctx[i]->compute_antialias = s->mp3decctx[0]->compute_antialias; s->mp3decctx[i]->adu_mode = 1; + s->mp3decctx[i]->avctx = avctx; } return 0; |