[Ffmpeg-cvslog] r8338 - in trunk: libavcodec/gifdec.c libavcodec/h263.c libavcodec/mpeg12.c libavcodec/mpegaudiodec.c libavcodec/parser.c libavcodec/shorten.c libavcodec/wma.c libavformat/mov.c libavformat/mxf.c libavutil/internal.h

mbardiaux subversion
Mon Mar 12 13:36:43 CET 2007


Author: mbardiaux
Date: Mon Mar 12 13:36:41 2007
New Revision: 8338

Modified:
   trunk/libavcodec/gifdec.c
   trunk/libavcodec/h263.c
   trunk/libavcodec/mpeg12.c
   trunk/libavcodec/mpegaudiodec.c
   trunk/libavcodec/parser.c
   trunk/libavcodec/shorten.c
   trunk/libavcodec/wma.c
   trunk/libavformat/mov.c
   trunk/libavformat/mxf.c
   trunk/libavutil/internal.h

Log:
Give context to dprintf


Modified: trunk/libavcodec/gifdec.c
==============================================================================
--- trunk/libavcodec/gifdec.c	(original)
+++ trunk/libavcodec/gifdec.c	Mon Mar 12 13:36:41 2007
@@ -53,6 +53,8 @@ typedef struct GifState {
     /* 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 @@ static int gif_read_image(GifState *s)
     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 @@ static int gif_read_extension(GifState *
     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 @@ static int gif_read_extension(GifState *
             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 @@ static int gif_read_extension(GifState *
             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 @@ static int gif_read_header1(GifState *s)
     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 @@ static int gif_parse_next_image(GifState
     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 @@ static int gif_decode_init(AVCodecContex
 {
     GifState *s = avctx->priv_data;
 
+    s->avctx = avctx;
+
     avcodec_get_frame_defaults(&s->picture);
     avctx->coded_frame= &s->picture;
     s->picture.data[0] = NULL;

Modified: trunk/libavcodec/h263.c
==============================================================================
--- trunk/libavcodec/h263.c	(original)
+++ trunk/libavcodec/h263.c	Mon Mar 12 13:36:41 2007
@@ -5141,7 +5141,7 @@ int h263_decode_picture_header(MpegEncCo
         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 @@ int h263_decode_picture_header(MpegEncCo
             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 @@ int h263_decode_picture_header(MpegEncCo
                 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);

Modified: trunk/libavcodec/mpeg12.c
==============================================================================
--- trunk/libavcodec/mpeg12.c	(original)
+++ trunk/libavcodec/mpeg12.c	Mon Mar 12 13:36:41 2007
@@ -996,7 +996,7 @@ static void mpeg1_encode_block(MpegEncCo
     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 @@ static int mpeg_decode_mb(MpegEncContext
     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 @@ static int mpeg_decode_mb(MpegEncContext
         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 @@ static int mpeg_decode_mb(MpegEncContext
             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 @@ static int mpeg_decode_mb(MpegEncContext
                                                          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 @@ static inline int mpeg1_decode_block_int
     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 @@ static inline int mpeg2_decode_block_int
     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 @@ static void mpeg_decode_sequence_extensi
     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 @@ static void mpeg_decode_quant_matrix_ext
 {
     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 @@ static void mpeg_decode_picture_coding_e
     }
 
     /* 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 @@ static int mpeg_decode_slice(Mpeg1Contex
         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 @@ static int mpeg1_decode_sequence(AVCodec
             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 @@ static int mpeg1_decode_sequence(AVCodec
             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 @@ static int mpeg_decode_frame(AVCodecCont
     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 @@ static int mpeg_mc_decode_init(AVCodecCo
     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;

Modified: trunk/libavcodec/mpegaudiodec.c
==============================================================================
--- trunk/libavcodec/mpegaudiodec.c	(original)
+++ trunk/libavcodec/mpegaudiodec.c	Mon Mar 12 13:36:41 2007
@@ -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 * 
     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 * 
             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 * 
                 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(MPADecodeContex
     }
 
 #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(MPADecodeContex
 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(MPADecodeCon
     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(MPADecodeCon
     {
         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(MPADecodeCon
         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(MPADecodeConte
 
             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(MPADecodeConte
         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(MPADecodeCon
 
     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(MPADecodeCon
                 /* 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(MPADecodeCon
                 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(MPADecodeCon
     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(MPADecodeCon
                 /* 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(MPADecodeCon
                 }
 #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(MPADecodeCon
                     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(MPADecodeCont
     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(MPADecodeCont
     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(AVCodecCon
         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;

Modified: trunk/libavcodec/parser.c
==============================================================================
--- trunk/libavcodec/parser.c	(original)
+++ trunk/libavcodec/parser.c	Mon Mar 12 13:36:41 2007
@@ -451,7 +451,7 @@ static int mpegaudio_parse(AVCodecParser
                     /* 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 @@ static int mpegaudio_parse(AVCodecParser
                             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;

Modified: trunk/libavcodec/shorten.c
==============================================================================
--- trunk/libavcodec/shorten.c	(original)
+++ trunk/libavcodec/shorten.c	Mon Mar 12 13:36:41 2007
@@ -293,7 +293,7 @@ static int shorten_decode_frame(AVCodecC
         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;
         }
     }

Modified: trunk/libavcodec/wma.c
==============================================================================
--- trunk/libavcodec/wma.c	(original)
+++ trunk/libavcodec/wma.c	Mon Mar 12 13:36:41 2007
@@ -171,13 +171,13 @@ int ff_wma_init(AVCodecContext * avctx, 
             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 */

Modified: trunk/libavformat/mov.c
==============================================================================
--- trunk/libavformat/mov.c	(original)
+++ trunk/libavformat/mov.c	Mon Mar 12 13:36:41 2007
@@ -232,7 +232,7 @@ static int mov_read_default(MOVContext *
         }
         total_size += 8;
         a.offset += 8;
-        dprintf("type: %08x  %.4s  sz: %"PRIx64"  %"PRIx64"   %"PRIx64"\n", a.type, (char*)&a.type, a.size, atom.size, total_size);
+        dprintf(c->fc, "type: %08x  %.4s  sz: %"PRIx64"  %"PRIx64"   %"PRIx64"\n", a.type, (char*)&a.type, a.size, atom.size, total_size);
         if (a.size == 1) { /* 64 bit extended size */
             a.size = get_be64(pb) - 8;
             a.offset += 8;
@@ -311,8 +311,8 @@ static int mov_read_hdlr(MOVContext *c, 
     ctype = get_le32(pb);
     type = get_le32(pb); /* component subtype */
 
-    dprintf("ctype= %c%c%c%c (0x%08lx)\n", *((char *)&ctype), ((char *)&ctype)[1], ((char *)&ctype)[2], ((char *)&ctype)[3], (long) ctype);
-    dprintf("stype= %c%c%c%c\n", *((char *)&type), ((char *)&type)[1], ((char *)&type)[2], ((char *)&type)[3]);
+    dprintf(c->fc, "ctype= %c%c%c%c (0x%08lx)\n", *((char *)&ctype), ((char *)&ctype)[1], ((char *)&ctype)[2], ((char *)&ctype)[3], (long) ctype);
+    dprintf(c->fc, "stype= %c%c%c%c\n", *((char *)&type), ((char *)&type)[1], ((char *)&type)[2], ((char *)&type)[3]);
     if(!ctype)
         c->isom = 1;
     if(type == MKTAG('v', 'i', 'd', 'e'))
@@ -349,12 +349,12 @@ static int mov_mp4_read_descr_len(ByteIO
     return len;
 }
 
-static int mov_mp4_read_descr(ByteIOContext *pb, int *tag)
+static int mov_mp4_read_descr(MOVContext *c, ByteIOContext *pb, int *tag)
 {
     int len;
     *tag = get_byte(pb);
     len = mov_mp4_read_descr_len(pb);
-    dprintf("MPEG4 description: tag=0x%02x len=%d\n", *tag, len);
+    dprintf(c->fc, "MPEG4 description: tag=0x%02x len=%d\n", *tag, len);
     return len;
 }
 
@@ -366,14 +366,14 @@ static int mov_read_esds(MOVContext *c, 
 
     /* Well, broken but suffisant for some MP4 streams */
     get_be32(pb); /* version + flags */
-    len = mov_mp4_read_descr(pb, &tag);
+    len = mov_mp4_read_descr(c, pb, &tag);
     if (tag == MP4ESDescrTag) {
         get_be16(pb); /* ID */
         get_byte(pb); /* priority */
     } else
         get_be16(pb); /* ID */
 
-    len = mov_mp4_read_descr(pb, &tag);
+    len = mov_mp4_read_descr(c, pb, &tag);
     if (tag == MP4DecConfigDescrTag) {
         sc->esds.object_type_id = get_byte(pb);
         sc->esds.stream_type = get_byte(pb);
@@ -382,10 +382,10 @@ static int mov_read_esds(MOVContext *c, 
         sc->esds.avg_bitrate = get_be32(pb);
 
         st->codec->codec_id= codec_get_id(ff_mov_obj_type, sc->esds.object_type_id);
-        dprintf("esds object type id %d\n", sc->esds.object_type_id);
-        len = mov_mp4_read_descr(pb, &tag);
+        dprintf(c->fc, "esds object type id %d\n", sc->esds.object_type_id);
+        len = mov_mp4_read_descr(c, pb, &tag);
         if (tag == MP4DecSpecificDescrTag) {
-            dprintf("Specific MPEG4 header len=%d\n", len);
+            dprintf(c->fc, "Specific MPEG4 header len=%d\n", len);
             st->codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
             if (st->codec->extradata) {
                 get_buffer(pb, st->codec->extradata, len);
@@ -527,7 +527,7 @@ static int mov_read_smi(MOVContext *c, B
     if (st->codec->extradata) {
         memcpy(st->codec->extradata, "SVQ3", 4); // fake
         get_buffer(pb, st->codec->extradata + 0x5a, atom.size);
-        dprintf("Reading SMI %"PRId64"  %s\n", atom.size, st->codec->extradata + 0x5a);
+        dprintf(c->fc, "Reading SMI %"PRId64"  %s\n", atom.size, st->codec->extradata + 0x5a);
     } else
         url_fskip(pb, atom.size);
 
@@ -702,7 +702,7 @@ static int mov_read_stsd(MOVContext *c, 
                 st->codec->codec_type = CODEC_TYPE_VIDEO;
         }
 
-        dprintf("size=%d 4CC= %c%c%c%c codec_type=%d\n",
+        dprintf(c->fc, "size=%d 4CC= %c%c%c%c codec_type=%d\n",
                 size,
                 (format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff, (format >> 24) & 0xff,
                 st->codec->codec_type);
@@ -812,7 +812,7 @@ static int mov_read_stsd(MOVContext *c, 
             get_be32(pb); /* vendor */
 
             st->codec->channels = get_be16(pb);             /* channel count */
-            dprintf("audio channels %d\n", st->codec->channels);
+            dprintf(c->fc, "audio channels %d\n", st->codec->channels);
             st->codec->bits_per_sample = get_be16(pb);      /* sample size */
             /* do we need to force to 16 for AMR ? */
 
@@ -840,7 +840,7 @@ static int mov_read_stsd(MOVContext *c, 
             }
 
             //Read QT version 1 fields. In version 0 theese dont exist
-            dprintf("version =%d, isom =%d\n",version,c->isom);
+            dprintf(c->fc, "version =%d, isom =%d\n",version,c->isom);
             if(!c->isom) {
                 if(version==1) {
                     sc->sample_size_v1.den = get_be32(pb); /* samples per packet */
@@ -1063,7 +1063,7 @@ av_log(NULL, AV_LOG_DEBUG, "track[%i].st
 
         sc->time_rate= ff_gcd(sc->time_rate, sample_duration);
 
-        dprintf("sample_count=%d, sample_duration=%d\n",sample_count,sample_duration);
+        dprintf(c->fc, "sample_count=%d, sample_duration=%d\n",sample_count,sample_duration);
 
         duration+=(int64_t)sample_duration*sample_count;
         total_sample_count+=sample_count;
@@ -1090,7 +1090,7 @@ static int mov_read_ctts(MOVContext *c, 
     sc->ctts_count = entries;
     sc->ctts_data = av_malloc(entries * sizeof(Time2Sample));
 
-    dprintf("track[%i].ctts.entries = %i\n", c->fc->nb_streams-1, entries);
+    dprintf(c->fc, "track[%i].ctts.entries = %i\n", c->fc->nb_streams-1, entries);
 
     for(i=0; i<entries; i++) {
         int count    =get_be32(pb);
@@ -1262,7 +1262,7 @@ static int mov_read_elst(MOVContext *c, 
         get_be32(pb); /* Media time */
         get_be32(pb); /* Media rate */
     }
-    dprintf("track[%i].edit_count = %i\n", c->fc->nb_streams-1, c->streams[c->fc->nb_streams-1]->edit_count);
+    dprintf(c->fc, "track[%i].edit_count = %i\n", c->fc->nb_streams-1, c->streams[c->fc->nb_streams-1]->edit_count);
     return 0;
 }
 
@@ -1389,7 +1389,7 @@ static void mov_build_index(MOVContext *
                         stss_index++;
                 }
                 sample_size = sc->sample_size > 0 ? sc->sample_size : sc->sample_sizes[current_sample];
-                dprintf("AVIndex stream %d, sample %d, offset %"PRIx64", dts %"PRId64", size %d, distance %d, keyframe %d\n",
+                dprintf(mov->fc, "AVIndex stream %d, sample %d, offset %"PRIx64", dts %"PRId64", size %d, distance %d, keyframe %d\n",
                         st->index, current_sample, current_offset, current_dts, sample_size, distance, keyframe);
                 av_add_index_entry(st, current_offset, current_dts, sample_size, distance, keyframe ? AVINDEX_KEYFRAME : 0);
                 current_offset += sample_size;
@@ -1433,7 +1433,7 @@ static void mov_build_index(MOVContext *
                 /* check for last chunk */
                 if (chunk_size == INT_MAX)
                     for (j = 0; j < mov->mdat_count; j++) {
-                        dprintf("mdat %d, offset %"PRIx64", size %"PRId64", current offset %"PRIx64"\n",
+                        dprintf(mov->fc, "mdat %d, offset %"PRIx64", size %"PRId64", current offset %"PRIx64"\n",
                                 j, mov->mdat_list[j].offset, mov->mdat_list[j].size, current_offset);
                         if (mov->mdat_list[j].offset <= current_offset && mov->mdat_list[j].offset + mov->mdat_list[j].size > current_offset)
                             chunk_size = mov->mdat_list[j].offset + mov->mdat_list[j].size - current_offset;
@@ -1459,7 +1459,7 @@ static void mov_build_index(MOVContext *
                     }
                 }
             }
-            dprintf("AVIndex stream %d, chunk %d, offset %"PRIx64", dts %"PRId64", size %d, duration %d\n",
+            dprintf(mov->fc, "AVIndex stream %d, chunk %d, offset %"PRIx64", dts %"PRId64", size %d, duration %d\n",
                     st->index, i, current_offset, current_dts, chunk_size, chunk_duration);
             assert(chunk_duration % sc->time_rate == 0);
             current_dts += chunk_duration / sc->time_rate;
@@ -1492,7 +1492,7 @@ static int mov_read_header(AVFormatConte
                 err, mov->found_moov, mov->found_mdat, url_ftell(pb));
         return -1;
     }
-    dprintf("on_parse_exit_offset=%d\n", (int) url_ftell(pb));
+    dprintf(mov->fc, "on_parse_exit_offset=%d\n", (int) url_ftell(pb));
 
     /* some cleanup : make sure we are on the mdat atom */
     if(!url_is_streamed(pb) && (url_ftell(pb) != mov->mdat_offset))
@@ -1549,7 +1549,7 @@ static int mov_read_packet(AVFormatConte
             AVIndexEntry *current_sample = &s->streams[i]->index_entries[msc->current_sample];
             int64_t dts = av_rescale(current_sample->timestamp * (int64_t)msc->time_rate, AV_TIME_BASE, msc->time_scale);
 
-            dprintf("stream %d, sample %ld, dts %"PRId64"\n", i, msc->current_sample, dts);
+            dprintf(s, "stream %d, sample %ld, dts %"PRId64"\n", i, msc->current_sample, dts);
             if (dts < best_dts) {
                 sample = current_sample;
                 best_dts = dts;
@@ -1568,7 +1568,7 @@ static int mov_read_packet(AVFormatConte
 #ifdef CONFIG_DV_DEMUXER
     if (sc->dv_audio_container) {
         dv_get_packet(mov->dv_demux, pkt);
-        dprintf("dv audio pkt size %d\n", pkt->size);
+        dprintf(s, "dv audio pkt size %d\n", pkt->size);
     } else {
 #endif
         url_fseek(&s->pb, sample->pos, SEEK_SET);
@@ -1597,7 +1597,7 @@ static int mov_read_packet(AVFormatConte
     }
     pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? PKT_FLAG_KEY : 0;
     pkt->pos = sample->pos;
-    dprintf("stream %d, pts %"PRId64", dts %"PRId64", pos 0x%"PRIx64", duration %d\n", pkt->stream_index, pkt->pts, pkt->dts, pkt->pos, pkt->duration);
+    dprintf(s, "stream %d, pts %"PRId64", dts %"PRId64", pos 0x%"PRIx64", duration %d\n", pkt->stream_index, pkt->pts, pkt->dts, pkt->pos, pkt->duration);
     return 0;
 }
 
@@ -1608,11 +1608,11 @@ static int mov_seek_stream(AVStream *st,
     int i;
 
     sample = av_index_search_timestamp(st, timestamp, flags);
-    dprintf("stream %d, timestamp %"PRId64", sample %d\n", st->index, timestamp, sample);
+    dprintf(st->codec, "stream %d, timestamp %"PRId64", sample %d\n", st->index, timestamp, sample);
     if (sample < 0) /* not sure what to do */
         return -1;
     sc->current_sample = sample;
-    dprintf("stream %d, found sample %ld\n", st->index, sc->current_sample);
+    dprintf(st->codec, "stream %d, found sample %ld\n", st->index, sc->current_sample);
     /* adjust ctts index */
     if (sc->ctts_data) {
         time_sample = 0;

Modified: trunk/libavformat/mxf.c
==============================================================================
--- trunk/libavformat/mxf.c	(original)
+++ trunk/libavformat/mxf.c	Mon Mar 12 13:36:41 2007
@@ -187,7 +187,7 @@ static const uint8_t mxf_encrypted_essen
 
 #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
 
-#define PRINT_KEY(s, x) dprintf("%s %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", s, \
+#define PRINT_KEY(pc, s, x) dprintf(pc, "%s %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", s, \
                              (x)[0], (x)[1], (x)[2], (x)[3], (x)[4], (x)[5], (x)[6], (x)[7], (x)[8], (x)[9], (x)[10], (x)[11], (x)[12], (x)[13], (x)[14], (x)[15])
 
 static int64_t klv_decode_ber_length(ByteIOContext *pb)
@@ -324,7 +324,7 @@ static int mxf_read_packet(AVFormatConte
             return -1;
         }
 #ifdef DEBUG
-        PRINT_KEY("read packet", klv.key);
+        PRINT_KEY(s, "read packet", klv.key);
 #endif
         if (IS_KLV_KEY(klv.key, mxf_encrypted_triplet_key)) {
             int res = mxf_decrypt_triplet(s, pkt, &klv);
@@ -500,7 +500,7 @@ static void mxf_read_metadata_pixel_layo
 
     do {
         code = get_byte(pb);
-        dprintf("pixel layout: code 0x%x\n", code);
+        dprintf(NULL, "pixel layout: code 0x%x\n", code);
         switch (code) {
         case 0x52: /* R */
             descriptor->bits_per_sample += get_byte(pb);
@@ -668,7 +668,7 @@ static int mxf_parse_structural_metadata
     MXFPackage *temp_package = NULL;
     int i, j, k;
 
-    dprintf("metadata sets count %d\n", mxf->metadata_sets_count);
+    dprintf(mxf->fc, "metadata sets count %d\n", mxf->metadata_sets_count);
     /* TODO: handle multiple material packages (OP3x) */
     for (i = 0; i < mxf->packages_count; i++) {
         material_package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[i], MaterialPackage);
@@ -753,7 +753,7 @@ static int mxf_parse_structural_metadata
         }
 
 #ifdef DEBUG
-        PRINT_KEY("data definition   ul", source_track->sequence->data_definition_ul);
+        PRINT_KEY(mxf->fc, "data definition   ul", source_track->sequence->data_definition_ul);
 #endif
         st->codec->codec_type = mxf_get_codec_type(mxf_data_definition_uls, &source_track->sequence->data_definition_ul);
 
@@ -780,8 +780,8 @@ static int mxf_parse_structural_metadata
             continue;
         }
 #ifdef DEBUG
-        PRINT_KEY("essence codec     ul", descriptor->essence_codec_ul);
-        PRINT_KEY("essence container ul", descriptor->essence_container_ul);
+        PRINT_KEY(mxf->fc, "essence codec     ul", descriptor->essence_codec_ul);
+        PRINT_KEY(mxf->fc, "essence container ul", descriptor->essence_container_ul);
 #endif
         essence_container_ul = &descriptor->essence_container_ul;
         /* HACK: replacing the original key with mxf_encrypted_essence_container
@@ -836,7 +836,7 @@ static int mxf_parse_structural_metadata
             }
         }
         if (container_ul && container_ul->wrapping == Clip) {
-            dprintf("stream %d: clip wrapped essence\n", st->index);
+            dprintf(mxf->fc, "stream %d: clip wrapped essence\n", st->index);
             st->need_parsing = 1;
         }
     }
@@ -921,7 +921,7 @@ static int mxf_read_header(AVFormatConte
             return -1;
         }
 #ifdef DEBUG
-        PRINT_KEY("read header", klv.key);
+        PRINT_KEY(s, "read header", klv.key);
 #endif
         if (IS_KLV_KEY(klv.key, mxf_encrypted_triplet_key) ||
             IS_KLV_KEY(klv.key, mxf_essence_element_key)) {

Modified: trunk/libavutil/internal.h
==============================================================================
--- trunk/libavutil/internal.h	(original)
+++ trunk/libavutil/internal.h	Mon Mar 12 13:36:41 2007
@@ -150,9 +150,9 @@
 
 /* dprintf macros */
 #ifdef DEBUG
-#    define dprintf(...) av_log(NULL, AV_LOG_DEBUG, __VA_ARGS__)
+#    define dprintf(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__)
 #else
-#    define dprintf(...)
+#    define dprintf(pctx, ...)
 #endif
 
 #define av_abort()      do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0)




More information about the ffmpeg-cvslog mailing list