Mercurial > libavcodec.hg
changeset 4652:6679d37a3338 libavcodec
Give context to dprintf
author | mbardiaux |
---|---|
date | Mon, 12 Mar 2007 12:36:41 +0000 |
parents | ff9749708137 |
children | 1d88da25349b |
files | gifdec.c h263.c mpeg12.c mpegaudiodec.c parser.c shorten.c wma.c |
diffstat | 7 files changed, 85 insertions(+), 76 deletions(-) [+] |
line wrap: on
line diff
--- a/gifdec.c Sun Mar 11 21:01:33 2007 +0000 +++ b/gifdec.c Mon Mar 12 12:36:41 2007 +0000 @@ -53,6 +53,8 @@ /* aux buffers */ uint8_t global_palette[256 * 3]; uint8_t local_palette[256 * 3]; + + AVCodecContext* avctx; } GifState; static const uint8_t gif87a_sig[6] = "GIF87a"; @@ -73,7 +75,7 @@ has_local_palette = flags & 0x80; bits_per_pixel = (flags & 0x07) + 1; #ifdef DEBUG - dprintf("gif: image x=%d y=%d w=%d h=%d\n", left, top, width, height); + dprintf(s->avctx, "gif: image x=%d y=%d w=%d h=%d\n", left, top, width, height); #endif if (has_local_palette) { @@ -164,7 +166,7 @@ ext_code = bytestream_get_byte(&s->bytestream); ext_len = bytestream_get_byte(&s->bytestream); #ifdef DEBUG - dprintf("gif: ext_code=0x%x len=%d\n", ext_code, ext_len); + dprintf(s->avctx, "gif: ext_code=0x%x len=%d\n", ext_code, ext_len); #endif switch(ext_code) { case 0xf9: @@ -180,7 +182,7 @@ s->transparent_color_index = -1; s->gce_disposal = (gce_flags >> 2) & 0x7; #ifdef DEBUG - dprintf("gif: gce_flags=%x delay=%d tcolor=%d disposal=%d\n", + dprintf(s->avctx, "gif: gce_flags=%x delay=%d tcolor=%d disposal=%d\n", gce_flags, s->gce_delay, s->transparent_color_index, s->gce_disposal); #endif @@ -195,7 +197,7 @@ bytestream_get_byte(&s->bytestream); ext_len = bytestream_get_byte(&s->bytestream); #ifdef DEBUG - dprintf("gif: ext_len1=%d\n", ext_len); + dprintf(s->avctx, "gif: ext_len1=%d\n", ext_len); #endif } return 0; @@ -230,7 +232,7 @@ s->background_color_index = bytestream_get_byte(&s->bytestream); bytestream_get_byte(&s->bytestream); /* ignored */ #ifdef DEBUG - dprintf("gif: screen_w=%d screen_h=%d bpp=%d global_palette=%d\n", + dprintf(s->avctx, "gif: screen_w=%d screen_h=%d bpp=%d global_palette=%d\n", s->screen_width, s->screen_height, s->bits_per_pixel, has_global_palette); #endif @@ -248,7 +250,7 @@ for (;;) { code = bytestream_get_byte(&s->bytestream); #ifdef DEBUG - dprintf("gif: code=%02x '%c'\n", code, code); + dprintf(s->avctx, "gif: code=%02x '%c'\n", code, code); #endif switch (code) { case ',': @@ -279,6 +281,8 @@ { GifState *s = avctx->priv_data; + s->avctx = avctx; + avcodec_get_frame_defaults(&s->picture); avctx->coded_frame= &s->picture; s->picture.data[0] = NULL;
--- a/h263.c Sun Mar 11 21:01:33 2007 +0000 +++ b/h263.c Mon Mar 12 12:36:41 2007 +0000 @@ -5141,7 +5141,7 @@ if (ufep == 1) { /* OPPTYPE */ format = get_bits(&s->gb, 3); - dprintf("ufep=1, format: %d\n", format); + dprintf(s->avctx, "ufep=1, format: %d\n", format); s->custom_pcf= get_bits1(&s->gb); s->umvplus = get_bits(&s->gb, 1); /* Unrestricted Motion Vector */ if (get_bits1(&s->gb) != 0) { @@ -5191,7 +5191,7 @@ if (format == 6) { /* Custom Picture Format (CPFMT) */ s->aspect_ratio_info = get_bits(&s->gb, 4); - dprintf("aspect: %d\n", s->aspect_ratio_info); + dprintf(s->avctx, "aspect: %d\n", s->aspect_ratio_info); /* aspect ratios: 0 - forbidden 1 - 1:1 @@ -5204,7 +5204,7 @@ width = (get_bits(&s->gb, 9) + 1) * 4; skip_bits1(&s->gb); height = get_bits(&s->gb, 9) * 4; - dprintf("\nH.263+ Custom picture: %dx%d\n",width,height); + dprintf(s->avctx, "\nH.263+ Custom picture: %dx%d\n",width,height); if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) { /* aspected dimensions */ s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 8);
--- a/mpeg12.c Sun Mar 11 21:01:33 2007 +0000 +++ b/mpeg12.c Mon Mar 12 12:36:41 2007 +0000 @@ -996,7 +996,7 @@ next_coef: #if 0 if (level != 0) - dprintf("level[%d]=%d\n", i, level); + dprintf(s->avctx, "level[%d]=%d\n", i, level); #endif /* encode using VLC */ if (level != 0) { @@ -1115,7 +1115,7 @@ int i, j, k, cbp, val, mb_type, motion_type; const int mb_block_count = 4 + (1<< s->chroma_format); - dprintf("decode_mb: x=%d y=%d\n", s->mb_x, s->mb_y); + dprintf(s->avctx, "decode_mb: x=%d y=%d\n", s->mb_x, s->mb_y); assert(s->mb_skipped==0); @@ -1199,7 +1199,7 @@ mb_type = btype2mb_type[ mb_type ]; break; } - dprintf("mb_type=%x\n", mb_type); + dprintf(s->avctx, "mb_type=%x\n", mb_type); // motion_type = 0; /* avoid warning */ if (IS_INTRA(mb_type)) { s->dsp.clear_blocks(s->block[0]); @@ -1309,7 +1309,7 @@ for(i=0;i<2;i++) { if (USES_LIST(mb_type, i)) { s->mv_dir |= (MV_DIR_FORWARD >> i); - dprintf("motion_type=%d\n", motion_type); + dprintf(s->avctx, "motion_type=%d\n", motion_type); switch(motion_type) { case MT_FRAME: /* or MT_16X8 */ if (s->picture_structure == PICT_FRAME) { @@ -1350,12 +1350,12 @@ s->last_mv[i][j][0]); s->last_mv[i][j][0] = val; s->mv[i][j][0] = val; - dprintf("fmx=%d\n", val); + dprintf(s->avctx, "fmx=%d\n", val); val = mpeg_decode_motion(s, s->mpeg_f_code[i][1], s->last_mv[i][j][1] >> 1); s->last_mv[i][j][1] = val << 1; s->mv[i][j][1] = val; - dprintf("fmy=%d\n", val); + dprintf(s->avctx, "fmy=%d\n", val); } } else { mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED; @@ -1580,7 +1580,7 @@ dc += diff; s->last_dc[component] = dc; block[0] = dc<<3; - dprintf("dc=%d diff=%d\n", dc, diff); + dprintf(s->avctx, "dc=%d diff=%d\n", dc, diff); i = 0; { OPEN_READER(re, &s->gb); @@ -1954,7 +1954,7 @@ dc += diff; s->last_dc[component] = dc; block[0] = dc << (3 - s->intra_dc_precision); - dprintf("dc=%d\n", block[0]); + dprintf(s->avctx, "dc=%d\n", block[0]); mismatch = block[0] ^ 1; i = 0; if (s->intra_vlc_format) @@ -2305,7 +2305,7 @@ s1->frame_rate_ext.num = get_bits(&s->gb, 2)+1; s1->frame_rate_ext.den = get_bits(&s->gb, 5)+1; - dprintf("sequence extension\n"); + dprintf(s->avctx, "sequence extension\n"); s->codec_id= s->avctx->codec_id= CODEC_ID_MPEG2VIDEO; s->avctx->sub_id = 2; /* indicates mpeg2 found */ @@ -2377,7 +2377,7 @@ { int i, v, j; - dprintf("matrix extension\n"); + dprintf(s->avctx, "matrix extension\n"); if (get_bits1(&s->gb)) { for(i=0;i<64;i++) { @@ -2448,15 +2448,15 @@ } /* composite display not parsed */ - dprintf("intra_dc_precision=%d\n", s->intra_dc_precision); - dprintf("picture_structure=%d\n", s->picture_structure); - dprintf("top field first=%d\n", s->top_field_first); - dprintf("repeat first field=%d\n", s->repeat_first_field); - dprintf("conceal=%d\n", s->concealment_motion_vectors); - dprintf("intra_vlc_format=%d\n", s->intra_vlc_format); - dprintf("alternate_scan=%d\n", s->alternate_scan); - dprintf("frame_pred_frame_dct=%d\n", s->frame_pred_frame_dct); - dprintf("progressive_frame=%d\n", s->progressive_frame); + dprintf(s->avctx, "intra_dc_precision=%d\n", s->intra_dc_precision); + dprintf(s->avctx, "picture_structure=%d\n", s->picture_structure); + dprintf(s->avctx, "top field first=%d\n", s->top_field_first); + dprintf(s->avctx, "repeat first field=%d\n", s->repeat_first_field); + dprintf(s->avctx, "conceal=%d\n", s->concealment_motion_vectors); + dprintf(s->avctx, "intra_vlc_format=%d\n", s->intra_vlc_format); + dprintf(s->avctx, "alternate_scan=%d\n", s->alternate_scan); + dprintf(s->avctx, "frame_pred_frame_dct=%d\n", s->frame_pred_frame_dct); + dprintf(s->avctx, "progressive_frame=%d\n", s->progressive_frame); } static void mpeg_decode_extension(AVCodecContext *avctx, @@ -2635,7 +2635,7 @@ ret = mpeg_decode_mb(s, s->block); s->chroma_qscale= s->qscale; - dprintf("ret=%d\n", ret); + dprintf(s->avctx, "ret=%d\n", ret); if (ret < 0) return -1; @@ -2858,10 +2858,10 @@ s->chroma_intra_matrix[j] = v; } #ifdef DEBUG - dprintf("intra matrix present\n"); + dprintf(s->avctx, "intra matrix present\n"); for(i=0;i<64;i++) - dprintf(" %d", s->intra_matrix[s->dsp.idct_permutation[i]]); - dprintf("\n"); + dprintf(s->avctx, " %d", s->intra_matrix[s->dsp.idct_permutation[i]]); + dprintf(s->avctx, "\n"); #endif } else { for(i=0;i<64;i++) { @@ -2883,10 +2883,10 @@ s->chroma_inter_matrix[j] = v; } #ifdef DEBUG - dprintf("non intra matrix present\n"); + dprintf(s->avctx, "non intra matrix present\n"); for(i=0;i<64;i++) - dprintf(" %d", s->inter_matrix[s->dsp.idct_permutation[i]]); - dprintf("\n"); + dprintf(s->avctx, " %d", s->inter_matrix[s->dsp.idct_permutation[i]]); + dprintf(s->avctx, "\n"); #endif } else { for(i=0;i<64;i++) { @@ -3086,7 +3086,7 @@ int ret, input_size; AVFrame *picture = data; MpegEncContext *s2 = &s->mpeg_enc_ctx; - dprintf("fill_buffer\n"); + dprintf(avctx, "fill_buffer\n"); if (buf_size == 0) { /* special case for last picture */ @@ -3334,7 +3334,7 @@ if( !(avctx->slice_flags & SLICE_FLAG_CODED_ORDER) ) return -1; if( !(avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD) ){ - dprintf("mpeg12.c: XvMC decoder will work better if SLICE_FLAG_ALLOW_FIELD is set\n"); + dprintf(avctx, "mpeg12.c: XvMC decoder will work better if SLICE_FLAG_ALLOW_FIELD is set\n"); } mpeg_decode_init(avctx); s = avctx->priv_data;
--- a/mpegaudiodec.c Sun Mar 11 21:01:33 2007 +0000 +++ b/mpegaudiodec.c Mon Mar 12 12:36:41 2007 +0000 @@ -90,6 +90,7 @@ 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 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 @@ 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 @@ 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 @@ } #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 @@ 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 @@ 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 @@ { 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ /* 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 @@ } #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 @@ 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 @@ 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 @@ 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 @@ 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;
--- a/parser.c Sun Mar 11 21:01:33 2007 +0000 +++ b/parser.c Mon Mar 12 12:36:41 2007 +0000 @@ -451,7 +451,7 @@ /* no sync found : move by one byte (inefficient, but simple!) */ memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1); s->inbuf_ptr--; - dprintf("skip %x\n", header); + dprintf(avctx, "skip %x\n", header); /* reset free format frame size to give a chance to get a new bitrate */ s->free_format_frame_size = 0; @@ -515,7 +515,7 @@ s->free_format_frame_size -= padding * 4; else s->free_format_frame_size -= padding; - dprintf("free frame size=%d padding=%d\n", + dprintf(avctx, "free frame size=%d padding=%d\n", s->free_format_frame_size, padding); decode_header(s, header1); goto next_data;
--- a/shorten.c Sun Mar 11 21:01:33 2007 +0000 +++ b/shorten.c Mon Mar 12 12:36:41 2007 +0000 @@ -293,7 +293,7 @@ s->bitstream_size= buf_size; if(buf_size < s->max_framesize){ - //dprintf("wanna more data ... %d\n", buf_size); + //dprintf(avctx, "wanna more data ... %d\n", buf_size); return input_buf_size; } }
--- a/wma.c Sun Mar 11 21:01:33 2007 +0000 +++ b/wma.c Mon Mar 12 12:36:41 2007 +0000 @@ -171,13 +171,13 @@ high_freq = high_freq * 0.5; } } - dprintf("flags2=0x%x\n", flags2); - dprintf("version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\n", + dprintf(s->avctx, "flags2=0x%x\n", flags2); + dprintf(s->avctx, "version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\n", s->version, s->nb_channels, s->sample_rate, s->bit_rate, s->block_align); - dprintf("bps=%f bps1=%f high_freq=%f bitoffset=%d\n", + dprintf(s->avctx, "bps=%f bps1=%f high_freq=%f bitoffset=%d\n", bps, bps1, high_freq, s->byte_offset_bits); - dprintf("use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n", + dprintf(s->avctx, "use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n", s->use_noise_coding, s->use_exp_vlc, s->nb_block_sizes); /* compute the scale factor band sizes for each MDCT block size */