changeset 1598:932d306bf1dc libavcodec

av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
author michael
date Mon, 03 Nov 2003 13:26:22 +0000
parents 4c9165372ab3
children 079239998a38
files 4xm.c ac3enc.c adpcm.c adx.c asv1.c avcodec.h cinepak.c cljr.c common.c common.h cyuv.c dsputil.c dv.c error_resilience.c eval.c ffv1.c h263.c h263dec.c h264.c huffyuv.c idcinvideo.c indeo3.c interplayvideo.c mdec.c mjpeg.c motion_est.c mpeg12.c mpegaudio.c mpegvideo.c msmpeg4.c msrle.c msvideo1.c oggvorbis.c opts.c ra288.c ratecontrol.c resample.c roqvideo.c rpza.c rv10.c svq1.c svq3.c utils.c vcr1.c vp3.c vqavideo.c wmv2.c xan.c
diffstat 48 files changed, 527 insertions(+), 453 deletions(-) [+]
line wrap: on
line diff
--- a/4xm.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/4xm.c	Mon Nov 03 13:26:22 2003 +0000
@@ -333,7 +333,7 @@
     const int wordstream_size= get32(buf+12);
     
     if(bitstream_size+ bytestream_size+ wordstream_size + 20 != length)
-        printf("lengths %d %d %d %d\n", bitstream_size, bytestream_size, wordstream_size, 
+        av_log(f->avctx, AV_LOG_ERROR, "lengths %d %d %d %d\n", bitstream_size, bytestream_size, wordstream_size, 
         bitstream_size+ bytestream_size+ wordstream_size - length);
     
     f->bitstream_buffer= av_fast_realloc(f->bitstream_buffer, &f->bitstream_buffer_size, bitstream_size + FF_INPUT_BUFFER_PADDING_SIZE);
@@ -354,7 +354,7 @@
     }
     
     if(bitstream_size != (get_bits_count(&f->gb)+31)/32*4)
-        printf(" %d %d %d bytes left\n", 
+        av_log(f->avctx, AV_LOG_ERROR, " %d %d %d bytes left\n", 
             bitstream_size - (get_bits_count(&f->gb)+31)/32*4, 
             bytestream_size - (f->bytestream - (buf + 20 + bitstream_size + wordstream_size)),
             wordstream_size - (((uint8_t*)f->wordstream) - (buf + 20 + bitstream_size))
@@ -373,7 +373,7 @@
     /* DC coef */
     val = get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3);
     if (val>>4){
-        printf("error dc run != 0\n");
+        av_log(f->avctx, AV_LOG_ERROR, "error dc run != 0\n");
     }
 
     if(val)
@@ -396,7 +396,7 @@
             level = get_xbits(&f->gb, code & 0xf);
             i += code >> 4;
             if (i >= 64) {
-                printf("run %d oveflow\n", i);
+                av_log(f->avctx, AV_LOG_ERROR, "run %d oveflow\n", i);
                 return 0;
             }
 
@@ -535,7 +535,7 @@
         for(node= j; up[node] != -1; node= up[node]){
             bits += flag[node]<<len;
             len++;
-            if(len > 31) printf("vlc length overflow\n"); //can this happen at all ?
+            if(len > 31) av_log(f->avctx, AV_LOG_ERROR, "vlc length overflow\n"); //can this happen at all ?
         }
         
         bits_tab[j]= bits;
@@ -561,7 +561,7 @@
     uint8_t *prestream= buf + bitstream_size + 12;
     
     if(prestream_size + bitstream_size + 12 != length)
-        fprintf(stderr, "size missmatch %d %d %d\n", prestream_size, bitstream_size, length);
+        av_log(f->avctx, AV_LOG_ERROR, "size missmatch %d %d %d\n", prestream_size, bitstream_size, length);
    
     prestream= read_huffman_tables(f, prestream);
 
@@ -586,7 +586,7 @@
     }
 
     if(get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3) != 256)
-        printf("end missmatch\n");
+        av_log(f->avctx, AV_LOG_ERROR, "end missmatch\n");
     
     return 0;
 }
@@ -609,7 +609,7 @@
 
     frame_4cc= get32(buf);
     if(buf_size != get32(buf+4)+8){
-        fprintf(stderr, "size missmatch %d %d\n", buf_size, get32(buf+4));
+        av_log(f->avctx, AV_LOG_ERROR, "size missmatch %d %d\n", buf_size, get32(buf+4));
     }
 
     if(frame_4cc == ff_get_fourcc("cfrm")){
@@ -621,7 +621,7 @@
 
         for(i=0; i<CFRAME_BUFFER_COUNT; i++){
             if(f->cfrm[i].id && f->cfrm[i].id < avctx->frame_number)
-                printf("lost c frame %d\n", f->cfrm[i].id);
+                av_log(f->avctx, AV_LOG_ERROR, "lost c frame %d\n", f->cfrm[i].id);
         }
         
         for(i=0; i<CFRAME_BUFFER_COUNT; i++){
@@ -645,7 +645,7 @@
             frame_size= cfrm->size;
             
             if(id != avctx->frame_number){
-                printf("cframe id missmatch %d %d\n", id, avctx->frame_number);
+                av_log(f->avctx, AV_LOG_ERROR, "cframe id missmatch %d %d\n", id, avctx->frame_number);
             }
             
             cfrm->size= cfrm->id= 0;
@@ -671,7 +671,7 @@
 
     p->reference= 1;
     if(avctx->get_buffer(avctx, p) < 0){
-        fprintf(stderr, "get_buffer() failed\n");
+        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
         return -1;
     }
 
@@ -684,9 +684,9 @@
         if(decode_p_frame(f, buf, frame_size) < 0)
             return -1;
     }else if(frame_4cc == ff_get_fourcc("snd_")){
-        printf("ignoring snd_ chunk length:%d\n", buf_size);
+        av_log(avctx, AV_LOG_ERROR, "ignoring snd_ chunk length:%d\n", buf_size);
     }else{
-        printf("ignoring unknown chunk length:%d\n", buf_size);
+        av_log(avctx, AV_LOG_ERROR, "ignoring unknown chunk length:%d\n", buf_size);
     }
 
 #if 0
--- a/ac3enc.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/ac3enc.c	Mon Nov 03 13:26:22 2003 +0000
@@ -464,7 +464,7 @@
     for(i=1;i<NB_BLOCKS;i++) {
         exp_diff = calc_exp_diff(exp[i][ch], exp[i-1][ch], N/2);
 #ifdef DEBUG            
-        printf("exp_diff=%d\n", exp_diff);
+        av_log(AV_LOG_DEBUG, "exp_diff=%d\n", exp_diff);
 #endif
         if (exp_diff > EXP_DIFF_THRESHOLD)
             exp_strategy[i][ch] = EXP_NEW;
@@ -580,11 +580,11 @@
     }
     
 #if defined(DEBUG)
-    printf("exponents: strategy=%d\n", exp_strategy);
+    av_log(AV_LOG_DEBUG, "exponents: strategy=%d\n", exp_strategy);
     for(i=0;i<=nb_groups * group_size;i++) {
-        printf("%d ", encoded_exp[i]);
+        av_log(AV_LOG_DEBUG, "%d ", encoded_exp[i]);
     }
-    printf("\n");
+    av_log(AV_LOG_DEBUG, "\n");
 #endif
 
     return 4 + (nb_groups / 3) * 7;
@@ -746,7 +746,7 @@
 	   bit_alloc(s, bap, encoded_exp, exp_strategy, frame_bits, csnroffst, 0) < 0)
 	csnroffst -= SNR_INC1;
     if (csnroffst < 0) {
-	fprintf(stderr, "Yack, Error !!!\n");
+	av_log(NULL, AV_LOG_ERROR, "Yack, Error !!!\n");
 	return -1;
     }
     while ((csnroffst + SNR_INC1) <= 63 && 
@@ -1021,7 +1021,7 @@
 #if defined(DEBUG) 
     {
       static int count = 0;
-      printf("Block #%d (%d)\n", block_num, count++);
+      av_log(AV_LOG_DEBUG, "Block #%d (%d)\n", block_num, count++);
     }
 #endif
     /* exponent strategy */
--- a/adpcm.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/adpcm.c	Mon Nov 03 13:26:22 2003 +0000
@@ -129,7 +129,7 @@
         return -1; /* only stereo or mono =) */
     switch(avctx->codec->id) {
     case CODEC_ID_ADPCM_IMA_QT:
-        fprintf(stderr, "ADPCM: codec admcp_ima_qt unsupported for encoding !\n");
+        av_log(avctx, AV_LOG_ERROR, "ADPCM: codec admcp_ima_qt unsupported for encoding !\n");
         avctx->frame_size = 64; /* XXX: can multiple of avctx->channels * 64 (left and right blocks are interleaved) */
         return -1;
         break;
@@ -140,7 +140,7 @@
         /* seems frame_size isn't taken into account... have to buffer the samples :-( */
         break;
     case CODEC_ID_ADPCM_MS:
-        fprintf(stderr, "ADPCM: codec admcp_ms unsupported for encoding !\n");
+        av_log(avctx, AV_LOG_ERROR, "ADPCM: codec admcp_ms unsupported for encoding !\n");
         return -1;
         break;
     default:
@@ -496,7 +496,7 @@
 
         cs->step_index = (*src++) & 0x7F;
 
-        if (cs->step_index > 88) fprintf(stderr, "ERROR: step_index = %i\n", cs->step_index);
+        if (cs->step_index > 88) av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index);
         if (cs->step_index > 88) cs->step_index = 88;
 
         cs->step = step_table[cs->step_index];
@@ -540,7 +540,7 @@
 	cs->step_index = *src++;
         if (cs->step_index < 0) cs->step_index = 0;
         if (cs->step_index > 88) cs->step_index = 88;
-        if (*src++) fprintf(stderr, "unused byte should be null !!\n"); /* unused */
+        if (*src++) av_log(avctx, AV_LOG_ERROR, "unused byte should be null !!\n"); /* unused */
 
         if (st) {
             cs = &(c->status[1]);
--- a/adx.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/adx.c	Mon Nov 03 13:26:22 2003 +0000
@@ -199,7 +199,7 @@
 
 //    avctx->bit_rate = avctx->sample_rate*avctx->channels*18*8/32;
 
-    printf("adx encode init\n"); fflush(stdout);
+    av_log(avctx, AV_LOG_DEBUG, "adx encode init\n");
     adx_decode_init(avctx);
 
     return 0;
@@ -318,11 +318,11 @@
 {
     int i;
     for(i=0;i<len;i++) {
-        if ((i&15)==0) printf("%04x  ",i);
-        printf("%02x ",buf[i]);
-        if ((i&15)==15) printf("\n");
+        if ((i&15)==0) av_log(NULL, AV_LOG_DEBUG, "%04x  ",i);
+        av_log(NULL, AV_LOG_DEBUG, "%02x ",buf[i]);
+        if ((i&15)==15) av_log(NULL, AV_LOG_DEBUG, "\n");
     }
-    printf("\n");
+    av_log(NULL, AV_LOG_ERROR, "\n");
 }
 static int adx_decode_frame(AVCodecContext *avctx,
                 void *data, int *data_size,
--- a/asv1.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/asv1.c	Mon Nov 03 13:26:22 2003 +0000
@@ -207,7 +207,7 @@
         if(ccp){
             if(ccp == 16) break;
             if(ccp < 0 || i>=10){
-                printf("coded coeff pattern damaged\n");
+                av_log(a->avctx, AV_LOG_ERROR, "coded coeff pattern damaged\n");
                 return -1;
             }
 
@@ -415,7 +415,7 @@
 
     p->reference= 0;
     if(avctx->get_buffer(avctx, p) < 0){
-        fprintf(stderr, "get_buffer() failed\n");
+        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
         return -1;
     }
     p->pict_type= I_TYPE;
@@ -561,7 +561,7 @@
 
     a->inv_qscale= ((uint8_t*)avctx->extradata)[0];
     if(a->inv_qscale == 0){
-        printf("illegal qscale 0\n");
+        av_log(avctx, AV_LOG_ERROR, "illegal qscale 0\n");
         if(avctx->codec_id == CODEC_ID_ASV1)
             a->inv_qscale= 6;
         else
--- a/avcodec.h	Sun Nov 02 23:19:47 2003 +0000
+++ b/avcodec.h	Mon Nov 03 13:26:22 2003 +0000
@@ -1830,6 +1830,28 @@
 /* add by bero : in adx.c */
 int is_adx(const unsigned char *buf,size_t bufsize);
 
+/* av_log API */
+
+#include <stdarg.h>
+
+#define AV_LOG_ERROR 0
+#define AV_LOG_INFO 1
+#define AV_LOG_DEBUG 2
+
+extern void av_log(AVCodecContext*, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4)));
+extern void av_vlog(AVCodecContext*, int level, const char *fmt, va_list);
+extern int av_log_get_level(void);
+extern void av_log_set_level(int);
+extern void av_log_set_callback(void (*)(AVCodecContext*, int, const char*, va_list));
+
+#undef  AV_LOG_TRAP_PRINTF
+#ifdef AV_LOG_TRAP_PRINTF
+#define printf DO NOT USE
+#define fprintf DO NOT USE
+#undef stderr
+#define stderr DO NOT USE
+#endif
+
 #ifdef __cplusplus
 }
 #endif
--- a/cinepak.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/cinepak.c	Mon Nov 03 13:26:22 2003 +0000
@@ -418,7 +418,7 @@
     s->size = buf_size;
 
     if (avctx->get_buffer(avctx, &s->frame)) {
-        printf ("  Cinepak: get_buffer() failed\n");
+        av_log(avctx, AV_LOG_ERROR, "  Cinepak: get_buffer() failed\n");
         return -1;
     }
 
--- a/cljr.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/cljr.c	Mon Nov 03 13:26:22 2003 +0000
@@ -55,7 +55,7 @@
 
     p->reference= 0;
     if(avctx->get_buffer(avctx, p) < 0){
-        fprintf(stderr, "get_buffer() failed\n");
+        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
         return -1;
     }
     p->pict_type= I_TYPE;
--- a/common.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/common.c	Mon Nov 03 13:26:22 2003 +0000
@@ -196,7 +196,8 @@
 int check_marker(GetBitContext *s, const char *msg)
 {
     int bit= get_bits1(s);
-    if(!bit) printf("Marker bit missing %s\n", msg);
+    if(!bit)
+	    av_log(NULL, AV_LOG_INFO, "Marker bit missing %s\n", msg);
 
     return bit;
 }
@@ -281,11 +282,11 @@
                 nb = 1 << (table_nb_bits - n);
                 for(k=0;k<nb;k++) {
 #ifdef DEBUG_VLC
-                    printf("%4x: code=%d n=%d\n",
+                    av_log(AV_LOG_DEBUG, "%4x: code=%d n=%d\n",
                            j, i, n);
 #endif
                     if (table[j][1] /*bits*/ != 0) {
-                        fprintf(stderr, "incorrect codes\n");
+                        av_log(NULL, AV_LOG_ERROR, "incorrect codes\n");
                         av_abort();
                     }
                     table[j][1] = n; //bits
--- a/common.h	Sun Nov 02 23:19:47 2003 +0000
+++ b/common.h	Mon Nov 03 13:26:22 2003 +0000
@@ -192,7 +192,7 @@
 
 #    endif /* !CONFIG_WIN32 */
 
-#    define av_abort()      do { fprintf(stderr, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0)
+#    define av_abort()      do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0)
 
 //rounded divison & shift
 #define RSHIFT(a,b) ((a) > 0 ? ((a) + (1<<((b)-1)))>>(b) : ((a) + (1<<((b)-1))-1)>>(b))
--- a/cyuv.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/cyuv.c	Mon Nov 03 13:26:22 2003 +0000
@@ -88,7 +88,7 @@
      * of 4 pixels. Thus, the total size of the buffer ought to be:
      *    (3 * 16) + height * (width * 3 / 4) */
     if (buf_size != 48 + s->height * (s->width * 3 / 4)) {
-      printf ("ffmpeg: cyuv: got a buffer with %d bytes when %d were expected\n",
+      av_log(avctx, AV_LOG_ERROR, "ffmpeg: cyuv: got a buffer with %d bytes when %d were expected\n",
         buf_size,
         48 + s->height * (s->width * 3 / 4));
       return -1;
@@ -102,7 +102,7 @@
 
     s->frame.reference = 0;
     if(avctx->get_buffer(avctx, &s->frame) < 0) {
-        fprintf(stderr, "get_buffer() failed\n");
+        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
         return -1;
     }
 
--- a/dsputil.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/dsputil.c	Mon Nov 03 13:26:22 2003 +0000
@@ -3089,7 +3089,7 @@
             c->idct_permutation[i]= ((i&7)<<3) | (i>>3);
         break;
     default:
-        fprintf(stderr, "Internal error, IDCT permutation not set\n");
+        av_log(avctx, AV_LOG_ERROR, "Internal error, IDCT permutation not set\n");
     }
 }
 
--- a/dv.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/dv.c	Mon Nov 03 13:26:22 2003 +0000
@@ -297,7 +297,7 @@
             if (pos >= 64) {
             read_error:
 #if defined(VLC_DEBUG) || 1
-                fprintf(stderr, "error pos=%d\n", pos);
+                av_log(NULL, AV_LOG_ERROR, "error pos=%d\n", pos);
 #endif
                 /* for errors, we consider the eob is reached */
                 mb->eob_reached = 1;
@@ -868,7 +868,7 @@
     avctx->width = s->sys->width;
     avctx->height = s->sys->height;
     if(avctx->get_buffer(avctx, &s->picture) < 0) {
-        fprintf(stderr, "get_buffer() failed\n");
+        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
         return -1;
     }
     s->picture.interlaced_frame = 1;
--- a/error_resilience.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/error_resilience.c	Mon Nov 03 13:26:22 2003 +0000
@@ -669,12 +669,12 @@
     
     if(!s->error_resilience || s->error_count==0) return;
 
-    fprintf(stderr, "concealing errors\n");
+    av_log(s->avctx, AV_LOG_INFO, "concealing errors\n");
     
     if(s->motion_val == NULL){
         int size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2);
         
-        fprintf(stderr, "Warning MVs not available\n");
+        av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n");
         
         s->motion_val= av_mallocz(size * 2 * sizeof(int16_t));
     }
@@ -684,9 +684,9 @@
             for(mb_x=0; mb_x<s->mb_width; mb_x++){
                 int status= s->error_status_table[mb_x + mb_y*s->mb_stride];
             
-                printf("%2X ", status); 
+                av_log(s->avctx, AV_LOG_DEBUG, "%2X ", status); 
             }
-            printf("\n");
+            av_log(s->avctx, AV_LOG_DEBUG, "\n");
         }
     }
     
--- a/eval.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/eval.c	Mon Nov 03 13:26:22 2003 +0000
@@ -61,7 +61,7 @@
 
 static void push(Parser *p, double d){
     if(p->stack_index+1>= STACK_SIZE){
-        fprintf(stderr, "stack overflow in the parser\n");
+        av_log(NULL, AV_LOG_ERROR, "stack overflow in the parser\n");
         return;
     }
     p->stack[ p->stack_index++ ]= d;
@@ -70,7 +70,7 @@
 
 static double pop(Parser *p){
     if(p->stack_index<=0){
-        fprintf(stderr, "stack underflow in the parser\n");
+        av_log(NULL, AV_LOG_ERROR, "stack underflow in the parser\n");
         return NAN;
     }
 //printf("pop\n"); fflush(stdout);
@@ -109,7 +109,7 @@
     
     p->s= strchr(p->s, '(');
     if(p->s==NULL){
-        fprintf(stderr, "Parser: missing ( in \"%s\"\n", next);
+        av_log(NULL, AV_LOG_ERROR, "Parser: missing ( in \"%s\"\n", next);
         return;
     }
     p->s++; // "("
@@ -159,13 +159,13 @@
         }
 
         if(error){
-            fprintf(stderr, "Parser: unknown function in \"%s\"\n", next);
+            av_log(NULL, AV_LOG_ERROR, "Parser: unknown function in \"%s\"\n", next);
             return;
         }
     }
     
     if(p->s[-1]!= ')'){
-        fprintf(stderr, "Parser: missing ) in \"%s\"\n", next);
+        av_log(NULL, AV_LOG_ERROR, "Parser: missing ) in \"%s\"\n", next);
         return;
     }
     push(p, d);
@@ -185,7 +185,7 @@
         evalExpression(p);
 
         if(p->s[0]!=')')
-            fprintf(stderr, "Parser: missing )\n");
+            av_log(NULL, AV_LOG_ERROR, "Parser: missing )\n");
         p->s++;
     }else{
         evalPrimary(p);
--- a/ffv1.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/ffv1.c	Mon Nov 03 13:26:22 2003 +0000
@@ -598,7 +598,7 @@
         s->colorspace= 1;
         break;
     default:
-        fprintf(stderr, "format not supported\n");
+        av_log(avctx, AV_LOG_ERROR, "format not supported\n");
         return -1;
     }
     avcodec_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_h_shift, &s->chroma_v_shift);
@@ -642,7 +642,7 @@
     int used_count= 0;
 
     if(avctx->strict_std_compliance >= 0){
-        printf("this codec is under development, files encoded with it wont be decodeable with future versions!!!\n"
+        av_log(avctx, AV_LOG_ERROR, "this codec is under development, files encoded with it wont be decodeable with future versions!!!\n"
                "use vstrict=-1 to use it anyway\n");
         return -1;
     }
@@ -885,17 +885,17 @@
         case 0x20: f->avctx->pix_fmt= PIX_FMT_YUV411P; break;
         case 0x33: f->avctx->pix_fmt= PIX_FMT_YUV410P; break;
         default:
-            fprintf(stderr, "format not supported\n");
+            av_log(f->avctx, AV_LOG_ERROR, "format not supported\n");
             return -1;
         }
     }else if(f->colorspace==1){
         if(f->chroma_h_shift || f->chroma_v_shift){
-            fprintf(stderr, "chroma subsampling not supported in this colorspace\n");
+            av_log(f->avctx, AV_LOG_ERROR, "chroma subsampling not supported in this colorspace\n");
             return -1;
         }
         f->avctx->pix_fmt= PIX_FMT_RGBA32;
     }else{
-        fprintf(stderr, "colorspace not supported\n");
+        av_log(f->avctx, AV_LOG_ERROR, "colorspace not supported\n");
         return -1;
     }
 
@@ -905,7 +905,7 @@
     for(i=0; i<5; i++){
         context_count*= read_quant_table(c, f->quant_table[i], context_count);
         if(context_count < 0){
-            printf("read_quant_table error\n");
+            av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n");
             return -1;
         }
     }
@@ -965,16 +965,16 @@
 
     p->reference= 0;
     if(avctx->get_buffer(avctx, p) < 0){
-        fprintf(stderr, "get_buffer() failed\n");
+        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
         return -1;
     }
 
     if(avctx->debug&FF_DEBUG_PICT_INFO)
-        printf("keyframe:%d coder:%d\n", p->key_frame, f->ac);
+        av_log(avctx, AV_LOG_ERROR, "keyframe:%d coder:%d\n", p->key_frame, f->ac);
     
     if(!f->ac){
         bytes_read = get_cabac_terminate(c);
-        if(bytes_read ==0) printf("error at end of AC stream\n");
+        if(bytes_read ==0) av_log(avctx, AV_LOG_ERROR, "error at end of AC stream\n");
 //printf("pos=%d\n", bytes_read);
         init_get_bits(&f->gb, buf + bytes_read, buf_size - bytes_read);
     } else {
@@ -1004,7 +1004,7 @@
     
     if(f->ac){
         bytes_read= get_cabac_terminate(c);
-        if(bytes_read ==0) printf("error at end of frame\n");
+        if(bytes_read ==0) av_log(f->avctx, AV_LOG_ERROR, "error at end of frame\n");
     }else{
         bytes_read+= (get_bits_count(&f->gb)+7)/8;
     }
--- a/h263.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/h263.c	Mon Nov 03 13:26:22 2003 +0000
@@ -617,7 +617,7 @@
     if(s->flags & CODEC_FLAG_CBP_RD){
         int best_cbpy_score= INT_MAX;
         int best_cbpc_score= INT_MAX;
-        int cbpc, cbpy;
+        int cbpc = (-1), cbpy= (-1);
         const int offset= (s->mv_type==MV_TYPE_16X16 ? 0 : 16) + (s->dquant ? 8 : 0);
         const int lambda= s->lambda2 >> (FF_LAMBDA_SHIFT - 6);
 
@@ -828,7 +828,7 @@
                 s->f_count++;
                 break;
             default:
-                printf("unknown mb type\n");
+                av_log(s->avctx, AV_LOG_ERROR, "unknown mb type\n");
                 return;
             }
 
@@ -2721,7 +2721,7 @@
     }
 
     if(len!=ff_mpeg4_get_video_packet_prefix_length(s)){
-        printf("marker does not match f_code\n");
+        av_log(s->avctx, AV_LOG_ERROR, "marker does not match f_code\n");
         return -1;
     }
     
@@ -2732,7 +2732,7 @@
 
     mb_num= get_bits(&s->gb, mb_num_bits);
     if(mb_num>=s->mb_num){
-        fprintf(stderr, "illegal mb_num in video packet (%d %d) \n", mb_num, s->mb_num);
+        av_log(s->avctx, AV_LOG_ERROR, "illegal mb_num in video packet (%d %d) \n", mb_num, s->mb_num);
         return -1;
     }
     if(s->pict_type == B_TYPE){
@@ -2771,7 +2771,7 @@
 //FIXME dont just ignore everything
             if(s->pict_type == S_TYPE && s->vol_sprite_usage==GMC_SPRITE){
                 mpeg4_decode_sprite_trajectory(s);
-                fprintf(stderr, "untested\n");
+                av_log(s->avctx, AV_LOG_ERROR, "untested\n");
             }
 
             //FIXME reduced res stuff here
@@ -2779,13 +2779,13 @@
             if (s->pict_type != I_TYPE) {
                 int f_code = get_bits(&s->gb, 3);	/* fcode_for */
                 if(f_code==0){
-                    printf("Error, video packet header damaged (f_code=0)\n");
+                    av_log(s->avctx, AV_LOG_ERROR, "Error, video packet header damaged (f_code=0)\n");
                 }
             }
             if (s->pict_type == B_TYPE) {
                 int b_code = get_bits(&s->gb, 3);
                 if(b_code==0){
-                    printf("Error, video packet header damaged (b_code=0)\n");
+                    av_log(s->avctx, AV_LOG_ERROR, "Error, video packet header damaged (b_code=0)\n");
                 }
             }       
         }
@@ -2948,7 +2948,7 @@
                 do{
                     cbpc = get_vlc2(&s->gb, intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2);
                     if (cbpc < 0){
-                        fprintf(stderr, "cbpc corrupted at %d %d\n", s->mb_x, s->mb_y);
+                        av_log(s->avctx, AV_LOG_ERROR, "cbpc corrupted at %d %d\n", s->mb_x, s->mb_y);
                         return -1;
                     }
                 }while(cbpc == 8);
@@ -2967,7 +2967,7 @@
                     int dc_pred_dir;
                     int dc= mpeg4_decode_dc(s, i, &dc_pred_dir); 
                     if(dc < 0){
-                        fprintf(stderr, "DC corrupted at %d %d\n", s->mb_x, s->mb_y);
+                        av_log(s->avctx, AV_LOG_ERROR, "DC corrupted at %d %d\n", s->mb_x, s->mb_y);
                         return -1;
                     }
                     dir<<=1;
@@ -3007,7 +3007,7 @@
 
                 cbpc = get_vlc2(&s->gb, inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
                 if (cbpc < 0){
-                    fprintf(stderr, "cbpc corrupted at %d %d\n", s->mb_x, s->mb_y);
+                    av_log(s->avctx, AV_LOG_ERROR, "cbpc corrupted at %d %d\n", s->mb_x, s->mb_y);
                     return -1;
                 }
 //              }while(cbpc == 20);
@@ -3103,7 +3103,7 @@
                 int ac_pred= get_bits1(&s->gb);
                 int cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);
                 if(cbpy<0){
-                    fprintf(stderr, "cbpy corrupted at %d %d\n", s->mb_x, s->mb_y);
+                    av_log(s->avctx, AV_LOG_ERROR, "cbpy corrupted at %d %d\n", s->mb_x, s->mb_y);
                     return -1;
                 }
                 
@@ -3116,7 +3116,7 @@
                     int cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);
 
                     if(cbpy<0){
-                        fprintf(stderr, "I cbpy corrupted at %d %d\n", s->mb_x, s->mb_y);
+                        av_log(s->avctx, AV_LOG_ERROR, "I cbpy corrupted at %d %d\n", s->mb_x, s->mb_y);
                         return -1;
                     }
                     
@@ -3129,7 +3129,7 @@
                         int dc_pred_dir;
                         int dc= mpeg4_decode_dc(s, i, &dc_pred_dir); 
                         if(dc < 0){
-                            fprintf(stderr, "DC corrupted at %d %d\n", s->mb_x, s->mb_y);
+                            av_log(s->avctx, AV_LOG_ERROR, "DC corrupted at %d %d\n", s->mb_x, s->mb_y);
                             return -1;
                         }
                         dir<<=1;
@@ -3146,7 +3146,7 @@
                     int cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);
 
                     if(cbpy<0){
-                        fprintf(stderr, "P cbpy corrupted at %d %d\n", s->mb_x, s->mb_y);
+                        av_log(s->avctx, AV_LOG_ERROR, "P cbpy corrupted at %d %d\n", s->mb_x, s->mb_y);
                         return -1;
                     }
                     
@@ -3183,7 +3183,7 @@
     }
     
     if(s->resync_mb_x + s->resync_mb_y*s->mb_width + mb_num > s->mb_num){
-        fprintf(stderr, "slice below monitor ...\n");
+        av_log(s->avctx, AV_LOG_ERROR, "slice below monitor ...\n");
         ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, part_a_error);
         return -1;
     }
@@ -3192,12 +3192,12 @@
         
     if(s->pict_type==I_TYPE){
         if(get_bits_long(&s->gb, 19)!=DC_MARKER){
-            fprintf(stderr, "marker missing after first I partition at %d %d\n", s->mb_x, s->mb_y);
+            av_log(s->avctx, AV_LOG_ERROR, "marker missing after first I partition at %d %d\n", s->mb_x, s->mb_y);
             return -1;
         }
     }else{
         if(get_bits(&s->gb, 17)!=MOTION_MARKER){
-            fprintf(stderr, "marker missing after first P partition at %d %d\n", s->mb_x, s->mb_y);
+            av_log(s->avctx, AV_LOG_ERROR, "marker missing after first P partition at %d %d\n", s->mb_x, s->mb_y);
             return -1;
         }
     }
@@ -3276,7 +3276,7 @@
         /* decode each block */
         for (i = 0; i < 6; i++) {
             if(mpeg4_decode_block(s, block[i], i, cbp&32, s->mb_intra, s->rvlc) < 0){
-                fprintf(stderr, "texture corrupted at %d %d %d\n", s->mb_x, s->mb_y, s->mb_intra);
+                av_log(s->avctx, AV_LOG_ERROR, "texture corrupted at %d %d %d\n", s->mb_x, s->mb_y, s->mb_intra);
                 return -1;
             }
             cbp+=cbp;
@@ -3337,7 +3337,7 @@
         cbpc = get_vlc2(&s->gb, inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
         //fprintf(stderr, "\tCBPC: %d", cbpc);
         if (cbpc < 0){
-            fprintf(stderr, "cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
+            av_log(s->avctx, AV_LOG_ERROR, "cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
             return -1;
         }
       }while(cbpc == 20);
@@ -3484,7 +3484,7 @@
             modb2= get_bits1(&s->gb);
             mb_type= get_vlc2(&s->gb, mb_type_b_vlc.table, MB_TYPE_B_VLC_BITS, 1);
             if(mb_type<0){
-                printf("illegal MB_type\n");
+                av_log(s->avctx, AV_LOG_ERROR, "illegal MB_type\n");
                 return -1;
             }
             mb_type= mb_type_b_map[ mb_type ];
@@ -3580,7 +3580,7 @@
         do{
             cbpc = get_vlc2(&s->gb, intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2);
             if (cbpc < 0){
-                fprintf(stderr, "I cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
+                av_log(s->avctx, AV_LOG_ERROR, "I cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
                 return -1;
             }
         }while(cbpc == 8);
@@ -3602,7 +3602,7 @@
         
         cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);
         if(cbpy<0){
-            fprintf(stderr, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
+            av_log(s->avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
             return -1;
         }
         cbp = (cbpc & 3) | (cbpy << 2);
@@ -3771,7 +3771,7 @@
         }else{
             level = get_bits(&s->gb, 8);
             if((level&0x7F) == 0){
-                fprintf(stderr, "illegal dc %d at %d %d\n", level, s->mb_x, s->mb_y);
+                av_log(s->avctx, AV_LOG_ERROR, "illegal dc %d at %d %d\n", level, s->mb_x, s->mb_y);
                 return -1;
             }
             if (level == 255)
@@ -3792,7 +3792,7 @@
     for(;;) {
         code = get_vlc2(&s->gb, rl->vlc.table, TEX_VLC_BITS, 2);
         if (code < 0){
-            fprintf(stderr, "illegal ac vlc code at %dx%d\n", s->mb_x, s->mb_y);
+            av_log(s->avctx, AV_LOG_ERROR, "illegal ac vlc code at %dx%d\n", s->mb_x, s->mb_y);
             return -1;
         }
         if (code == rl->n) {
@@ -3829,7 +3829,7 @@
         }
         i += run;
         if (i >= 64){
-            fprintf(stderr, "run overflow at %dx%d\n", s->mb_x, s->mb_y);
+            av_log(s->avctx, AV_LOG_ERROR, "run overflow at %dx%d\n", s->mb_x, s->mb_y);
             return -1;
         }
         j = scan_table[i];
@@ -3863,7 +3863,7 @@
     else 
         code = get_vlc2(&s->gb, dc_chrom.table, DC_VLC_BITS, 1);
     if (code < 0 || code > 9 /* && s->nbit<9 */){
-        fprintf(stderr, "illegal dc vlc\n");
+        av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
         return -1;
     }
     if (code == 0) {
@@ -3885,7 +3885,7 @@
         if (code > 8){
             if(get_bits1(&s->gb)==0){ /* marker */
                 if(s->error_resilience>=2){
-                    fprintf(stderr, "dc marker bit missing\n");
+                    av_log(s->avctx, AV_LOG_ERROR, "dc marker bit missing\n");
                     return -1;
                 }
             }
@@ -3895,7 +3895,7 @@
     level += pred;
     if (level < 0){
         if(s->error_resilience>=3){
-            fprintf(stderr, "dc<0 at %dx%d\n", s->mb_x, s->mb_y);
+            av_log(s->avctx, AV_LOG_ERROR, "dc<0 at %dx%d\n", s->mb_x, s->mb_y);
             return -1;
         }
         level = 0;
@@ -3910,7 +3910,7 @@
     
     if(s->error_resilience>=3){
         if(*dc_val > 2048 + s->y_dc_scale + s->c_dc_scale){
-            fprintf(stderr, "dc overflow at %dx%d\n", s->mb_x, s->mb_y);
+            av_log(s->avctx, AV_LOG_ERROR, "dc overflow at %dx%d\n", s->mb_x, s->mb_y);
             return -1;
         }
     }
@@ -4009,7 +4009,7 @@
           /* escape */                
           if(rvlc){
                 if(SHOW_UBITS(re, &s->gb, 1)==0){
-                    fprintf(stderr, "1. marker bit missing in rvlc esc\n");
+                    av_log(s->avctx, AV_LOG_ERROR, "1. marker bit missing in rvlc esc\n");
                     return -1;
                 }; SKIP_CACHE(re, &s->gb, 1);
  
@@ -4019,14 +4019,14 @@
                 UPDATE_CACHE(re, &s->gb);
               
                 if(SHOW_UBITS(re, &s->gb, 1)==0){
-                    fprintf(stderr, "2. marker bit missing in rvlc esc\n");
+                    av_log(s->avctx, AV_LOG_ERROR, "2. marker bit missing in rvlc esc\n");
                     return -1;
                 }; SKIP_CACHE(re, &s->gb, 1);
  
                 level= SHOW_UBITS(re, &s->gb, 11); SKIP_CACHE(re, &s->gb, 11);
  
                 if(SHOW_UBITS(re, &s->gb, 5)!=0x10){
-                    fprintf(stderr, "reverse esc missing\n");
+                    av_log(s->avctx, AV_LOG_ERROR, "reverse esc missing\n");
                     return -1;
                 }; SKIP_CACHE(re, &s->gb, 5);
 
@@ -4056,14 +4056,14 @@
                         level= SHOW_SBITS(re, &s->gb, 12); LAST_SKIP_BITS(re, &s->gb, 12);
                     }else{
                         if(SHOW_UBITS(re, &s->gb, 1)==0){
-                            fprintf(stderr, "1. marker bit missing in 3. esc\n");
+                            av_log(s->avctx, AV_LOG_ERROR, "1. marker bit missing in 3. esc\n");
                             return -1;
                         }; SKIP_CACHE(re, &s->gb, 1);
 
                         level= SHOW_SBITS(re, &s->gb, 12); SKIP_CACHE(re, &s->gb, 12);
 
                         if(SHOW_UBITS(re, &s->gb, 1)==0){
-                            fprintf(stderr, "2. marker bit missing in 3. esc\n");
+                            av_log(s->avctx, AV_LOG_ERROR, "2. marker bit missing in 3. esc\n");
                             return -1;
                         }; LAST_SKIP_CACHE(re, &s->gb, 1);
 
@@ -4071,7 +4071,7 @@
                     }
  
                     if(level*s->qscale>1024 || level*s->qscale<-1024){
-                        fprintf(stderr, "|level| overflow in 3. esc, qp=%d\n", s->qscale);
+                        av_log(s->avctx, AV_LOG_ERROR, "|level| overflow in 3. esc, qp=%d\n", s->qscale);
                         return -1;
                     }
 #if 0
@@ -4080,7 +4080,7 @@
                         if(abs_level<=MAX_LEVEL && run<=MAX_RUN){
                             const int run1= run - rl->max_run[last][abs_level] - 1;
                             if(abs_level <= rl->max_level[last][run]){
-                                fprintf(stderr, "illegal 3. esc, vlc encoding possible\n");
+                                av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, vlc encoding possible\n");
                                 return -1;
                             }
                             if(s->error_resilience > FF_ER_COMPLIANT){
@@ -4137,7 +4137,7 @@
         if (i > 62){
             i-= 192;
             if(i&(~63)){
-                fprintf(stderr, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
+                av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
                 return -1;
             }
 
@@ -4190,7 +4190,7 @@
     }
         
     if (startcode != 0x20) {
-        fprintf(stderr, "Bad picture start code\n");
+        av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
         return -1;
     }
     /* temporal reference */
@@ -4199,11 +4199,11 @@
     /* PTYPE starts here */    
     if (get_bits1(&s->gb) != 1) {
         /* marker */
-        fprintf(stderr, "Bad marker\n");
+        av_log(s->avctx, AV_LOG_ERROR, "Bad marker\n");
         return -1;
     }
     if (get_bits1(&s->gb) != 0) {
-        fprintf(stderr, "Bad H263 id\n");
+        av_log(s->avctx, AV_LOG_ERROR, "Bad H263 id\n");
         return -1;	/* h263 id */
     }
     skip_bits1(&s->gb);	/* split screen off */
@@ -4235,7 +4235,7 @@
         s->h263_long_vectors = s->unrestricted_mv;
 
         if (get_bits1(&s->gb) != 0) {
-            fprintf(stderr, "H263 SAC not supported\n");
+            av_log(s->avctx, AV_LOG_ERROR, "H263 SAC not supported\n");
             return -1;	/* SAC: off */
         }
         if (get_bits1(&s->gb) != 0) {
@@ -4243,7 +4243,7 @@
         }   
         
         if (get_bits1(&s->gb) != 0) {
-            fprintf(stderr, "H263 PB frame not supported\n");
+            av_log(s->avctx, AV_LOG_ERROR, "H263 PB frame not supported\n");
             return -1;	/* not PB frame */
         }
         s->qscale = get_bits(&s->gb, 5);
@@ -4275,29 +4275,29 @@
             }
 	    
             if (get_bits1(&s->gb) != 0) {
-                fprintf(stderr, "Deblocking Filter not supported\n");
+                av_log(s->avctx, AV_LOG_ERROR, "Deblocking Filter not supported\n");
             }
             if (get_bits1(&s->gb) != 0) {
-                fprintf(stderr, "Slice Structured not supported\n");
+                av_log(s->avctx, AV_LOG_ERROR, "Slice Structured not supported\n");
             }
             if (get_bits1(&s->gb) != 0) {
-                fprintf(stderr, "Reference Picture Selection not supported\n");
+                av_log(s->avctx, AV_LOG_ERROR, "Reference Picture Selection not supported\n");
             }
             if (get_bits1(&s->gb) != 0) {
-                fprintf(stderr, "Independent Segment Decoding not supported\n");
+                av_log(s->avctx, AV_LOG_ERROR, "Independent Segment Decoding not supported\n");
             }
             if (get_bits1(&s->gb) != 0) {
-                fprintf(stderr, "Alternative Inter VLC not supported\n");
+                av_log(s->avctx, AV_LOG_ERROR, "Alternative Inter VLC not supported\n");
             }
             if (get_bits1(&s->gb) != 0) {
-                fprintf(stderr, "Modified Quantization not supported\n");
+                av_log(s->avctx, AV_LOG_ERROR, "Modified Quantization not supported\n");
             }
             
             skip_bits(&s->gb, 1); /* Prevent start code emulation */
 
             skip_bits(&s->gb, 3); /* Reserved */
         } else if (ufep != 0) {
-            fprintf(stderr, "Bad UFEP type (%d)\n", ufep);
+            av_log(s->avctx, AV_LOG_ERROR, "Bad UFEP type (%d)\n", ufep);
             return -1;
         }
             
@@ -4371,7 +4371,7 @@
     }
 
      if(s->avctx->debug&FF_DEBUG_PICT_INFO){
-         printf("qp:%d %c size:%d rnd:%d %s %s %s %s\n", 
+         av_log(s->avctx, AV_LOG_DEBUG, "qp:%d %c size:%d rnd:%d %s %s %s %s\n", 
          s->qscale, av_get_pict_type_char(s->pict_type),
          s->gb.size_in_bits, 1-s->no_rounding,
          s->mv_type == MV_TYPE_8X8 ? "ADV" : "",
@@ -4383,17 +4383,17 @@
 #if 1
     if (s->pict_type == I_TYPE && s->avctx->codec_tag == ff_get_fourcc("ZYGO")){
         int i,j;
-        for(i=0; i<85; i++) printf("%d", get_bits1(&s->gb));
-        printf("\n");
+        for(i=0; i<85; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb));
+        av_log(s->avctx, AV_LOG_DEBUG, "\n");
         for(i=0; i<13; i++){
             for(j=0; j<3; j++){
                 int v= get_bits(&s->gb, 8);
                 v |= get_sbits(&s->gb, 8)<<8;
-                printf(" %5d", v);
+                av_log(s->avctx, AV_LOG_DEBUG, " %5d", v);
             }
-            printf("\n");
+            av_log(s->avctx, AV_LOG_DEBUG, "\n");
         }
-        for(i=0; i<50; i++) printf("%d", get_bits1(&s->gb));
+        for(i=0; i<50; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb));
     }
 #endif
 
@@ -4649,7 +4649,7 @@
     if ((s->vol_control_parameters=get_bits1(gb))) { /* vol control parameter */
         int chroma_format= get_bits(gb, 2);
         if(chroma_format!=1){
-            printf("illegal chroma format\n");
+            av_log(s->avctx, AV_LOG_ERROR, "illegal chroma format\n");
         }
         s->low_delay= get_bits1(gb);
         if(get_bits1(gb)){ /* vbv parameters */
@@ -4672,9 +4672,9 @@
     }
 
     s->shape = get_bits(gb, 2); /* vol shape */
-    if(s->shape != RECT_SHAPE) printf("only rectangular vol supported\n");
+    if(s->shape != RECT_SHAPE) av_log(s->avctx, AV_LOG_ERROR, "only rectangular vol supported\n");
     if(s->shape == GRAY_SHAPE && vo_ver_id != 1){
-        printf("Gray shape not supported\n");
+        av_log(s->avctx, AV_LOG_ERROR, "Gray shape not supported\n");
         skip_bits(gb, 4);  //video_object_layer_shape_extension
     }
 
@@ -4708,13 +4708,13 @@
         
         s->progressive_sequence= get_bits1(gb)^1;
         if(!get_bits1(gb) && (s->avctx->debug & FF_DEBUG_PICT_INFO)) 
-            printf("OBMC not supported (very likely buggy encoder)\n");   /* OBMC Disable */
+            av_log(s->avctx, AV_LOG_ERROR, "OBMC not supported (very likely buggy encoder)\n");   /* OBMC Disable */
         if (vo_ver_id == 1) {
             s->vol_sprite_usage = get_bits1(gb); /* vol_sprite_usage */
         } else {
             s->vol_sprite_usage = get_bits(gb, 2); /* vol_sprite_usage */
         }
-        if(s->vol_sprite_usage==STATIC_SPRITE) printf("Static Sprites not supported\n");
+        if(s->vol_sprite_usage==STATIC_SPRITE) av_log(s->avctx, AV_LOG_ERROR, "Static Sprites not supported\n");
         if(s->vol_sprite_usage==STATIC_SPRITE || s->vol_sprite_usage==GMC_SPRITE){
             if(s->vol_sprite_usage==STATIC_SPRITE){
                 s->sprite_width = get_bits(gb, 13);
@@ -4736,8 +4736,8 @@
         
         if (get_bits1(gb) == 1) {   /* not_8_bit */
             s->quant_precision = get_bits(gb, 4); /* quant_precision */
-            if(get_bits(gb, 4)!=8) printf("N-bit not supported\n"); /* bits_per_pixel */
-            if(s->quant_precision!=5) printf("quant precission %d\n", s->quant_precision);
+            if(get_bits(gb, 4)!=8) av_log(s->avctx, AV_LOG_ERROR, "N-bit not supported\n"); /* bits_per_pixel */
+            if(s->quant_precision!=5) av_log(s->avctx, AV_LOG_ERROR, "quant precission %d\n", s->quant_precision);
         } else {
             s->quant_precision = 5;
         }
@@ -4810,7 +4810,7 @@
              s->quarter_sample= get_bits1(gb);
         else s->quarter_sample=0;
 
-        if(!get_bits1(gb)) printf("Complexity estimation not supported\n");
+        if(!get_bits1(gb)) av_log(s->avctx, AV_LOG_ERROR, "Complexity estimation not supported\n");
 
         s->resync_marker= !get_bits1(gb); /* resync_marker_disabled */
 
@@ -4822,12 +4822,12 @@
         if(vo_ver_id != 1) {
             s->new_pred= get_bits1(gb);
             if(s->new_pred){
-                printf("new pred not supported\n");
+                av_log(s->avctx, AV_LOG_ERROR, "new pred not supported\n");
                 skip_bits(gb, 2); /* requested upstream message type */
                 skip_bits1(gb); /* newpred segment type */
             }
             s->reduced_res_vop= get_bits1(gb);
-            if(s->reduced_res_vop) printf("reduced resolution VOP not supported\n");
+            if(s->reduced_res_vop) av_log(s->avctx, AV_LOG_ERROR, "reduced resolution VOP not supported\n");
         }
         else{
             s->new_pred=0;
@@ -4862,7 +4862,7 @@
                
                 *gb= bak;
             }else
-                printf("scalability not supported\n");
+                av_log(s->avctx, AV_LOG_ERROR, "scalability not supported\n");
             
             // bin shape stuff FIXME
         }
@@ -4929,7 +4929,7 @@
 
     s->pict_type = get_bits(gb, 2) + I_TYPE;	/* pict type: I = 0 , P = 1 */
     if(s->pict_type==B_TYPE && s->low_delay && s->vol_control_parameters==0 && !(s->flags & CODEC_FLAG_LOW_DELAY)){
-        printf("low_delay flag set, but shouldnt, clearing it\n");
+        av_log(s->avctx, AV_LOG_ERROR, "low_delay flag set, but shouldnt, clearing it\n");
         s->low_delay=0;
     }
  
@@ -4950,13 +4950,13 @@
     check_marker(gb, "before time_increment");
     
     if(s->time_increment_bits==0){
-        printf("hmm, seems the headers arnt complete, trying to guess time_increment_bits\n");
+        av_log(s->avctx, AV_LOG_ERROR, "hmm, seems the headers arnt complete, trying to guess time_increment_bits\n");
 
         for(s->time_increment_bits=1 ;s->time_increment_bits<16; s->time_increment_bits++){
             if(show_bits(gb, s->time_increment_bits+1)&1) break;
         }
 
-        printf("my guess is %d bits ;)\n",s->time_increment_bits);
+        av_log(s->avctx, AV_LOG_ERROR, "my guess is %d bits ;)\n",s->time_increment_bits);
     }
     
     if(IS_3IV1) time_increment= get_bits1(gb); //FIXME investigate further
@@ -4996,13 +4996,13 @@
     
     s->current_picture_ptr->pts= s->time*1000LL*1000LL / s->time_increment_resolution;
     if(s->avctx->debug&FF_DEBUG_PTS)
-        printf("MPEG4 PTS: %f\n", s->current_picture_ptr->pts/(1000.0*1000.0));
+        av_log(s->avctx, AV_LOG_DEBUG, "MPEG4 PTS: %f\n", s->current_picture_ptr->pts/(1000.0*1000.0));
     
     check_marker(gb, "before vop_coded");
     
     /* vop coded */
     if (get_bits1(gb) != 1){
-        printf("vop not coded\n");
+        av_log(s->avctx, AV_LOG_ERROR, "vop not coded\n");
         return FRAME_SKIPED;
     }
 //printf("time %d %d %d || %Ld %Ld %Ld\n", s->time_increment_bits, s->time_increment_resolution, s->time_base,
@@ -5059,21 +5059,21 @@
  
      if(s->pict_type == S_TYPE && (s->vol_sprite_usage==STATIC_SPRITE || s->vol_sprite_usage==GMC_SPRITE)){
          mpeg4_decode_sprite_trajectory(s);
-         if(s->sprite_brightness_change) printf("sprite_brightness_change not supported\n");
-         if(s->vol_sprite_usage==STATIC_SPRITE) printf("static sprite not supported\n");
+         if(s->sprite_brightness_change) av_log(s->avctx, AV_LOG_ERROR, "sprite_brightness_change not supported\n");
+         if(s->vol_sprite_usage==STATIC_SPRITE) av_log(s->avctx, AV_LOG_ERROR, "static sprite not supported\n");
      }
 
      if (s->shape != BIN_ONLY_SHAPE) {
          s->qscale = get_bits(gb, s->quant_precision);
          if(s->qscale==0){
-             printf("Error, header damaged or not MPEG4 header (qscale=0)\n");
+             av_log(s->avctx, AV_LOG_ERROR, "Error, header damaged or not MPEG4 header (qscale=0)\n");
              return -1; // makes no sense to continue, as there is nothing left from the image then
          }
   
          if (s->pict_type != I_TYPE) {
              s->f_code = get_bits(gb, 3);	/* fcode_for */
              if(s->f_code==0){
-                 printf("Error, header damaged or not MPEG4 header (f_code=0)\n");
+                 av_log(s->avctx, AV_LOG_ERROR, "Error, header damaged or not MPEG4 header (f_code=0)\n");
                  return -1; // makes no sense to continue, as the MV decoding will break very quickly
              }
          }else
@@ -5085,7 +5085,7 @@
              s->b_code=1;
 
          if(s->avctx->debug&FF_DEBUG_PICT_INFO){
-             printf("qp:%d fc:%d,%d %s size:%d pro:%d alt:%d top:%d %spel part:%d resync:%d w:%d a:%d rnd:%d vot:%d%s dc:%d\n", 
+             av_log(s->avctx, AV_LOG_DEBUG, "qp:%d fc:%d,%d %s size:%d pro:%d alt:%d top:%d %spel part:%d resync:%d w:%d a:%d rnd:%d vot:%d%s dc:%d\n", 
                  s->qscale, s->f_code, s->b_code, 
                  s->pict_type == I_TYPE ? "I" : (s->pict_type == P_TYPE ? "P" : (s->pict_type == B_TYPE ? "B" : "S")), 
                  gb->size_in_bits,s->progressive_sequence, s->alternate_scan, s->top_field_first, 
@@ -5101,7 +5101,7 @@
              if(s->enhancement_type){
                  int load_backward_shape= get_bits1(gb);
                  if(load_backward_shape){
-                     printf("load backward shape isnt supported\n");
+                     av_log(s->avctx, AV_LOG_ERROR, "load backward shape isnt supported\n");
                  }
              }
              skip_bits(gb, 2); //ref_select_code
@@ -5110,7 +5110,7 @@
      /* detect buggy encoders which dont set the low_delay flag (divx4/xvid/opendivx)*/
      // note we cannot detect divx5 without b-frames easyly (allthough its buggy too)
      if(s->vo_type==0 && s->vol_control_parameters==0 && s->divx_version==0 && s->picture_number==0){
-         printf("looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n");
+         av_log(s->avctx, AV_LOG_ERROR, "looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n");
          s->low_delay=1;
      }
 
@@ -5145,7 +5145,7 @@
         
         if(get_bits_count(gb) >= gb->size_in_bits){
             if(gb->size_in_bits==8 && s->divx_version){
-                printf("frame skip %d\n", gb->size_in_bits);
+                av_log(s->avctx, AV_LOG_ERROR, "frame skip %d\n", gb->size_in_bits);
                 return FRAME_SKIPED; //divx bug
             }else
                 return -1; //end of stream
@@ -5155,35 +5155,35 @@
             continue; //no startcode
         
         if(s->avctx->debug&FF_DEBUG_STARTCODE){
-            printf("startcode: %3X ", startcode);
-            if     (startcode<=0x11F) printf("Video Object Start");
-            else if(startcode<=0x12F) printf("Video Object Layer Start");
-            else if(startcode<=0x13F) printf("Reserved");
-            else if(startcode<=0x15F) printf("FGS bp start");
-            else if(startcode<=0x1AF) printf("Reserved");
-            else if(startcode==0x1B0) printf("Visual Object Seq Start");
-            else if(startcode==0x1B1) printf("Visual Object Seq End");
-            else if(startcode==0x1B2) printf("User Data");
-            else if(startcode==0x1B3) printf("Group of VOP start");
-            else if(startcode==0x1B4) printf("Video Session Error");
-            else if(startcode==0x1B5) printf("Visual Object Start");
-            else if(startcode==0x1B6) printf("Video Object Plane start");
-            else if(startcode==0x1B7) printf("slice start");
-            else if(startcode==0x1B8) printf("extension start");
-            else if(startcode==0x1B9) printf("fgs start");
-            else if(startcode==0x1BA) printf("FBA Object start");
-            else if(startcode==0x1BB) printf("FBA Object Plane start");
-            else if(startcode==0x1BC) printf("Mesh Object start");
-            else if(startcode==0x1BD) printf("Mesh Object Plane start");
-            else if(startcode==0x1BE) printf("Still Textutre Object start");
-            else if(startcode==0x1BF) printf("Textutre Spatial Layer start");
-            else if(startcode==0x1C0) printf("Textutre SNR Layer start");
-            else if(startcode==0x1C1) printf("Textutre Tile start");
-            else if(startcode==0x1C2) printf("Textutre Shape Layer start");
-            else if(startcode==0x1C3) printf("stuffing start");
-            else if(startcode<=0x1C5) printf("reserved");
-            else if(startcode<=0x1FF) printf("System start");
-            printf(" at %d\n", get_bits_count(gb));
+            av_log(s->avctx, AV_LOG_DEBUG, "startcode: %3X ", startcode);
+            if     (startcode<=0x11F) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Start");
+            else if(startcode<=0x12F) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Layer Start");
+            else if(startcode<=0x13F) av_log(s->avctx, AV_LOG_DEBUG, "Reserved");
+            else if(startcode<=0x15F) av_log(s->avctx, AV_LOG_DEBUG, "FGS bp start");
+            else if(startcode<=0x1AF) av_log(s->avctx, AV_LOG_DEBUG, "Reserved");
+            else if(startcode==0x1B0) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Seq Start");
+            else if(startcode==0x1B1) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Seq End");
+            else if(startcode==0x1B2) av_log(s->avctx, AV_LOG_DEBUG, "User Data");
+            else if(startcode==0x1B3) av_log(s->avctx, AV_LOG_DEBUG, "Group of VOP start");
+            else if(startcode==0x1B4) av_log(s->avctx, AV_LOG_DEBUG, "Video Session Error");
+            else if(startcode==0x1B5) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Start");
+            else if(startcode==0x1B6) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Plane start");
+            else if(startcode==0x1B7) av_log(s->avctx, AV_LOG_DEBUG, "slice start");
+            else if(startcode==0x1B8) av_log(s->avctx, AV_LOG_DEBUG, "extension start");
+            else if(startcode==0x1B9) av_log(s->avctx, AV_LOG_DEBUG, "fgs start");
+            else if(startcode==0x1BA) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object start");
+            else if(startcode==0x1BB) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object Plane start");
+            else if(startcode==0x1BC) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object start");
+            else if(startcode==0x1BD) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object Plane start");
+            else if(startcode==0x1BE) av_log(s->avctx, AV_LOG_DEBUG, "Still Textutre Object start");
+            else if(startcode==0x1BF) av_log(s->avctx, AV_LOG_DEBUG, "Textutre Spatial Layer start");
+            else if(startcode==0x1C0) av_log(s->avctx, AV_LOG_DEBUG, "Textutre SNR Layer start");
+            else if(startcode==0x1C1) av_log(s->avctx, AV_LOG_DEBUG, "Textutre Tile start");
+            else if(startcode==0x1C2) av_log(s->avctx, AV_LOG_DEBUG, "Textutre Shape Layer start");
+            else if(startcode==0x1C3) av_log(s->avctx, AV_LOG_DEBUG, "stuffing start");
+            else if(startcode<=0x1C5) av_log(s->avctx, AV_LOG_DEBUG, "reserved");
+            else if(startcode<=0x1FF) av_log(s->avctx, AV_LOG_DEBUG, "System start");
+            av_log(s->avctx, AV_LOG_DEBUG, " at %d\n", get_bits_count(gb));
         }
 
         if(startcode >= 0x120 && startcode <= 0x12F){
@@ -5212,17 +5212,17 @@
 
     /* picture header */
     if (get_bits_long(&s->gb, 22) != 0x20) {
-        fprintf(stderr, "Bad picture start code\n");
+        av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
         return -1;
     }
     s->picture_number = get_bits(&s->gb, 8); /* picture timestamp */
 
     if (get_bits1(&s->gb) != 1) {
-        fprintf(stderr, "Bad marker\n");
+        av_log(s->avctx, AV_LOG_ERROR, "Bad marker\n");
         return -1;	/* marker */
     }
     if (get_bits1(&s->gb) != 0) {
-        fprintf(stderr, "Bad H263 id\n");
+        av_log(s->avctx, AV_LOG_ERROR, "Bad H263 id\n");
         return -1;	/* h263 id */
     }
     skip_bits1(&s->gb);	/* split screen off */
@@ -5231,7 +5231,7 @@
 
     format = get_bits(&s->gb, 3);
     if (format != 7) {
-        fprintf(stderr, "Intel H263 free format not supported\n");
+        av_log(s->avctx, AV_LOG_ERROR, "Intel H263 free format not supported\n");
         return -1;
     }
     s->h263_plus = 0;
@@ -5242,15 +5242,15 @@
     s->h263_long_vectors = s->unrestricted_mv;
 
     if (get_bits1(&s->gb) != 0) {
-        fprintf(stderr, "SAC not supported\n");
+        av_log(s->avctx, AV_LOG_ERROR, "SAC not supported\n");
         return -1;	/* SAC: off */
     }
     if (get_bits1(&s->gb) != 0) {
-        fprintf(stderr, "Advanced Prediction Mode not supported\n");
+        av_log(s->avctx, AV_LOG_ERROR, "Advanced Prediction Mode not supported\n");
         return -1;	/* advanced prediction mode: off */
     }
     if (get_bits1(&s->gb) != 0) {
-        fprintf(stderr, "PB frame mode no supported\n");
+        av_log(s->avctx, AV_LOG_ERROR, "PB frame mode no supported\n");
         return -1;	/* PB frame mode */
     }
 
@@ -5278,12 +5278,12 @@
 
     /* picture header */
     if (get_bits_long(&s->gb, 17) != 1) {
-        fprintf(stderr, "Bad picture start code\n");
+        av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
         return -1;
     }
     format = get_bits(&s->gb, 5);
     if (format != 0 && format != 1) {
-        fprintf(stderr, "Bad picture format\n");
+        av_log(s->avctx, AV_LOG_ERROR, "Bad picture format\n");
         return -1;
     }
     s->h263_flv = format+1;
@@ -5345,7 +5345,7 @@
     s->f_code = 1;
 
     if(s->avctx->debug & FF_DEBUG_PICT_INFO){
-        printf("%c esc_type:%d, qp:%d num:%d\n",
+        av_log(s->avctx, AV_LOG_DEBUG, "%c esc_type:%d, qp:%d num:%d\n",
                av_get_pict_type_char(s->pict_type), s->h263_flv-1, s->qscale, s->picture_number);
     }
     
--- a/h263dec.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/h263dec.c	Mon Nov 03 13:26:22 2003 +0000
@@ -219,11 +219,11 @@
                     }
                     return 0; 
                 }else if(ret==SLICE_NOEND){
-                    fprintf(stderr,"Slice mismatch at MB: %d\n", xy);
+                    av_log(s->avctx, AV_LOG_ERROR, "Slice mismatch at MB: %d\n", xy);
                     ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x+1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
                     return -1;
                 }
-                fprintf(stderr,"Error at MB: %d\n", xy);
+                av_log(s->avctx, AV_LOG_ERROR, "Error at MB: %d\n", xy);
                 ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask);
     
                 return -1;
@@ -281,17 +281,17 @@
             max_extra+= 256*256*256*64;
         
         if(left>max_extra){
-            fprintf(stderr, "discarding %d junk bits at end, next would be %X\n", left, show_bits(&s->gb, 24));
+            av_log(s->avctx, AV_LOG_ERROR, "discarding %d junk bits at end, next would be %X\n", left, show_bits(&s->gb, 24));
         }
         else if(left<0){
-            fprintf(stderr, "overreading %d bits\n", -left);
+            av_log(s->avctx, AV_LOG_ERROR, "overreading %d bits\n", -left);
         }else
             ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END);
         
         return 0;
     }
 
-    fprintf(stderr, "slice end not reached but screenspace end (%d left %06X, score= %d)\n", 
+    av_log(s->avctx, AV_LOG_ERROR, "slice end not reached but screenspace end (%d left %06X, score= %d)\n", 
             s->gb.size_in_bits - get_bits_count(&s->gb),
             show_bits(&s->gb, 24), s->padding_bug_score);
             
@@ -415,7 +415,7 @@
         }else if(s->codec_id==CODEC_ID_H263){
             next= h263_find_frame_end(s, buf, buf_size);
         }else{
-            fprintf(stderr, "this codec doesnt support truncated bitstreams\n");
+            av_log(s->avctx, AV_LOG_ERROR, "this codec doesnt support truncated bitstreams\n");
             return -1;
         }
         
@@ -470,7 +470,7 @@
 
     /* skip if the header was thrashed */
     if (ret < 0){
-        fprintf(stderr, "header damaged\n");
+        av_log(s->avctx, AV_LOG_ERROR, "header damaged\n");
         return -1;
     }
     
@@ -580,7 +580,7 @@
     }
 
     if(avctx->debug & FF_DEBUG_BUGS)
-        printf("bugs: %X lavc_build:%d xvid_build:%d divx_version:%d divx_build:%d %s\n", 
+        av_log(s->avctx, AV_LOG_DEBUG, "bugs: %X lavc_build:%d xvid_build:%d divx_version:%d divx_build:%d %s\n", 
                s->workaround_bugs, s->lavc_build, s->xvid_build, s->divx_version, s->divx_build,
                s->divx_packed ? "p" : "");
     
--- a/h264.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/h264.c	Mon Nov 03 13:26:22 2003 +0000
@@ -643,7 +643,7 @@
         for(i=0; i<4; i++){
             int status= top[ h->intra4x4_pred_mode_cache[scan8[0] + i] ];
             if(status<0){
-                fprintf(stderr, "top block unavailable for requested intra4x4 mode %d at %d %d\n", status, s->mb_x, s->mb_y);
+                av_log(h->s.avctx, AV_LOG_ERROR, "top block unavailable for requested intra4x4 mode %d at %d %d\n", status, s->mb_x, s->mb_y);
                 return -1;
             } else if(status){
                 h->intra4x4_pred_mode_cache[scan8[0] + i]= status;
@@ -655,7 +655,7 @@
         for(i=0; i<4; i++){
             int status= left[ h->intra4x4_pred_mode_cache[scan8[0] + 8*i] ];
             if(status<0){
-                fprintf(stderr, "left block unavailable for requested intra4x4 mode %d at %d %d\n", status, s->mb_x, s->mb_y);
+                av_log(h->s.avctx, AV_LOG_ERROR, "left block unavailable for requested intra4x4 mode %d at %d %d\n", status, s->mb_x, s->mb_y);
                 return -1;
             } else if(status){
                 h->intra4x4_pred_mode_cache[scan8[0] + 8*i]= status;
@@ -677,7 +677,7 @@
     if(!(h->top_samples_available&0x8000)){
         mode= top[ mode ];
         if(mode<0){
-            fprintf(stderr, "top block unavailable for requested intra mode at %d %d\n", s->mb_x, s->mb_y);
+            av_log(h->s.avctx, AV_LOG_ERROR, "top block unavailable for requested intra mode at %d %d\n", s->mb_x, s->mb_y);
             return -1;
         }
     }
@@ -685,7 +685,7 @@
     if(!(h->left_samples_available&0x8000)){
         mode= left[ mode ];
         if(mode<0){
-            fprintf(stderr, "left block unavailable for requested intra mode at %d %d\n", s->mb_x, s->mb_y);
+            av_log(h->s.avctx, AV_LOG_ERROR, "left block unavailable for requested intra mode at %d %d\n", s->mb_x, s->mb_y);
             return -1;
         } 
     }
@@ -2447,7 +2447,7 @@
                 
                 
                 if(index >= h->ref_count[list]){
-                    fprintf(stderr, "reference count overflow\n");
+                    av_log(h->s.avctx, AV_LOG_ERROR, "reference count overflow\n");
                     return -1;
                 }
                 
@@ -2456,7 +2456,7 @@
                         const int abs_diff_pic_num= get_ue_golomb(&s->gb) + 1;
 
                         if(abs_diff_pic_num >= h->max_pic_num){
-                            fprintf(stderr, "abs_diff_pic_num overflow\n");
+                            av_log(h->s.avctx, AV_LOG_ERROR, "abs_diff_pic_num overflow\n");
                             return -1;
                         }
 
@@ -2478,7 +2478,7 @@
                     }
 
                     if(i < index){
-                        fprintf(stderr, "reference picture missing during reorder\n");
+                        av_log(h->s.avctx, AV_LOG_ERROR, "reference picture missing during reorder\n");
                         memset(&h->ref_list[list][index], 0, sizeof(Picture)); //FIXME
                     }else if(i > index){
                         Picture tmp= h->ref_list[list][i];
@@ -2490,7 +2490,7 @@
                 }else if(reordering_of_pic_nums_idc==3) 
                     break;
                 else{
-                    fprintf(stderr, "illegal reordering_of_pic_nums_idc\n");
+                    av_log(h->s.avctx, AV_LOG_ERROR, "illegal reordering_of_pic_nums_idc\n");
                     return -1;
                 }
             }
@@ -2560,12 +2560,12 @@
     int i;
     
     if(s->avctx->debug&FF_DEBUG_MMCO)
-        printf("remove short %d count %d\n", frame_num, h->short_ref_count);
+        av_log(h->s.avctx, AV_LOG_DEBUG, "remove short %d count %d\n", frame_num, h->short_ref_count);
     
     for(i=0; i<h->short_ref_count; i++){
         Picture *pic= h->short_ref[i];
         if(s->avctx->debug&FF_DEBUG_MMCO)
-            printf("%d %d %p\n", i, pic->frame_num, pic);
+            av_log(h->s.avctx, AV_LOG_DEBUG, "%d %d %p\n", i, pic->frame_num, pic);
         if(pic->frame_num == frame_num){
             h->short_ref[i]= NULL;
             memmove(&h->short_ref[i], &h->short_ref[i+1], (h->short_ref_count - i - 1)*sizeof(Picture*));
@@ -2604,11 +2604,11 @@
     Picture *pic;
     
     if((s->avctx->debug&FF_DEBUG_MMCO) && mmco_count==0)
-        printf("no mmco here\n");
+        av_log(h->s.avctx, AV_LOG_DEBUG, "no mmco here\n");
         
     for(i=0; i<mmco_count; i++){
         if(s->avctx->debug&FF_DEBUG_MMCO)
-            printf("mmco:%d %d %d\n", h->mmco[i].opcode, h->mmco[i].short_frame_num, h->mmco[i].long_index);
+            av_log(h->s.avctx, AV_LOG_DEBUG, "mmco:%d %d %d\n", h->mmco[i].opcode, h->mmco[i].short_frame_num, h->mmco[i].long_index);
 
         switch(mmco[i].opcode){
         case MMCO_SHORT2UNUSED:
@@ -2666,7 +2666,7 @@
         pic= remove_short(h, s->current_picture_ptr->frame_num);
         if(pic){
             pic->reference=0;
-            fprintf(stderr, "illegal short term buffer state detected\n");
+            av_log(h->s.avctx, AV_LOG_ERROR, "illegal short term buffer state detected\n");
         }
         
         if(h->short_ref_count)
@@ -2709,13 +2709,13 @@
                 if(opcode==MMCO_SHORT2LONG || opcode==MMCO_LONG2UNUSED || opcode==MMCO_LONG || opcode==MMCO_SET_MAX_LONG){
                     h->mmco[i].long_index= get_ue_golomb(&s->gb);
                     if(/*h->mmco[i].long_index >= h->long_ref_count || h->long_ref[ h->mmco[i].long_index ] == NULL*/ h->mmco[i].long_index >= 16){
-                        fprintf(stderr, "illegal long ref in memory management control operation %d\n", opcode);
+                        av_log(h->s.avctx, AV_LOG_ERROR, "illegal long ref in memory management control operation %d\n", opcode);
                         return -1;
                     }
                 }
                     
                 if(opcode > MMCO_LONG){
-                    fprintf(stderr, "illegal memory management control operation %d\n", opcode);
+                    av_log(h->s.avctx, AV_LOG_ERROR, "illegal memory management control operation %d\n", opcode);
                     return -1;
                 }
             }
@@ -2835,7 +2835,7 @@
 
     h->slice_type= get_ue_golomb(&s->gb);
     if(h->slice_type > 9){
-        fprintf(stderr, "slice type too large (%d) at %d %d\n", h->slice_type, s->mb_x, s->mb_y);
+        av_log(h->s.avctx, AV_LOG_ERROR, "slice type too large (%d) at %d %d\n", h->slice_type, s->mb_x, s->mb_y);
     }
     if(h->slice_type > 4){
         h->slice_type -= 5;
@@ -2849,18 +2849,18 @@
         
     pps_id= get_ue_golomb(&s->gb);
     if(pps_id>255){
-        fprintf(stderr, "pps_id out of range\n");
+        av_log(h->s.avctx, AV_LOG_ERROR, "pps_id out of range\n");
         return -1;
     }
     h->pps= h->pps_buffer[pps_id];
     if(h->pps.slice_group_count == 0){
-        fprintf(stderr, "non existing PPS referenced\n");
+        av_log(h->s.avctx, AV_LOG_ERROR, "non existing PPS referenced\n");
         return -1;
     }
 
     h->sps= h->sps_buffer[ h->pps.sps_id ];
     if(h->sps.log2_max_frame_num == 0){
-        fprintf(stderr, "non existing SPS referenced\n");
+        av_log(h->s.avctx, AV_LOG_ERROR, "non existing SPS referenced\n");
         return -1;
     }
     
@@ -2960,7 +2960,7 @@
                 h->ref_count[1]= get_ue_golomb(&s->gb) + 1;
 
             if(h->ref_count[0] > 32 || h->ref_count[1] > 32){
-                fprintf(stderr, "reference overflow\n");
+                av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow\n");
                 return -1;
             }
         }
@@ -3004,7 +3004,7 @@
 #endif
 
     if(s->avctx->debug&FF_DEBUG_PICT_INFO){
-        printf("mb:%d %c pps:%d frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d\n", 
+        av_log(h->s.avctx, AV_LOG_DEBUG, "mb:%d %c pps:%d frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d\n", 
                first_mb_in_slice, 
                av_get_pict_type_char(h->slice_type),
                pps_id, h->frame_num,
@@ -3106,7 +3106,7 @@
             level_code= (prefix<<suffix_length) + get_bits(gb, 12); //part
             if(suffix_length==0) level_code+=15; //FIXME doesnt make (much)sense
         }else{
-            fprintf(stderr, "prefix too large at %d %d\n", s->mb_x, s->mb_y);
+            av_log(h->s.avctx, AV_LOG_ERROR, "prefix too large at %d %d\n", s->mb_x, s->mb_y);
             return -1;
         }
 
@@ -3147,7 +3147,7 @@
     }
 
     if(zeros_left<0){
-        fprintf(stderr, "negative number of zero coeffs at %d %d\n", s->mb_x, s->mb_y);
+        av_log(h->s.avctx, AV_LOG_ERROR, "negative number of zero coeffs at %d %d\n", s->mb_x, s->mb_y);
         return -1;
     }
     
@@ -3257,7 +3257,7 @@
        assert(h->slice_type == I_TYPE);
 decode_intra_mb:
         if(mb_type > 25){
-            fprintf(stderr, "mb_type %d in %c slice to large at %d %d\n", mb_type, av_get_pict_type_char(h->slice_type), s->mb_x, s->mb_y);
+            av_log(h->s.avctx, AV_LOG_ERROR, "mb_type %d in %c slice to large at %d %d\n", mb_type, av_get_pict_type_char(h->slice_type), s->mb_x, s->mb_y);
             return -1;
         }
         partition_count=0;
@@ -3353,7 +3353,7 @@
             for(i=0; i<4; i++){
                 h->sub_mb_type[i]= get_ue_golomb(&s->gb);
                 if(h->sub_mb_type[i] >=13){
-                    fprintf(stderr, "B sub_mb_type %d out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y);
+                    av_log(h->s.avctx, AV_LOG_ERROR, "B sub_mb_type %d out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y);
                     return -1;
                 }
                 sub_partition_count[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
@@ -3364,7 +3364,7 @@
             for(i=0; i<4; i++){
                 h->sub_mb_type[i]= get_ue_golomb(&s->gb);
                 if(h->sub_mb_type[i] >=4){
-                    fprintf(stderr, "P sub_mb_type %d out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y);
+                    av_log(h->s.avctx, AV_LOG_ERROR, "P sub_mb_type %d out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y);
                     return -1;
                 }
                 sub_partition_count[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
@@ -3508,7 +3508,7 @@
     if(!IS_INTRA16x16(mb_type)){
         cbp= get_ue_golomb(&s->gb);
         if(cbp > 47){
-            fprintf(stderr, "cbp too large (%d) at %d %d\n", cbp, s->mb_x, s->mb_y);
+            av_log(h->s.avctx, AV_LOG_ERROR, "cbp too large (%d) at %d %d\n", cbp, s->mb_x, s->mb_y);
             return -1;
         }
         
@@ -3537,7 +3537,7 @@
         dquant= get_se_golomb(&s->gb);
 
         if( dquant > 25 || dquant < -26 ){
-            fprintf(stderr, "dquant out of range (%d) at %d %d\n", dquant, s->mb_x, s->mb_y);
+            av_log(h->s.avctx, AV_LOG_ERROR, "dquant out of range (%d) at %d %d\n", dquant, s->mb_x, s->mb_y);
             return -1;
         }
         
@@ -3634,7 +3634,7 @@
         }
 
         if(ret<0){
-            fprintf(stderr, "error while decoding MB %d %d\n", s->mb_x, s->mb_y);
+            av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d\n", s->mb_x, s->mb_y);
             ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask);
 
             return -1;
@@ -3733,7 +3733,7 @@
         }else if(aspect_ratio_idc < 16){
             sps->sar=  pixel_aspect[aspect_ratio_idc];
         }else{
-            fprintf(stderr, "illegal aspect ratio\n");
+            av_log(h->s.avctx, AV_LOG_ERROR, "illegal aspect ratio\n");
             return -1;
         }
     }else{
@@ -3825,7 +3825,7 @@
             sps->offset_for_ref_frame[i]= get_se_golomb(&s->gb);
     }
     if(sps->poc_type > 2){
-        fprintf(stderr, "illegal POC type %d\n", sps->poc_type);
+        av_log(h->s.avctx, AV_LOG_ERROR, "illegal POC type %d\n", sps->poc_type);
         return -1;
     }
 
@@ -3848,7 +3848,7 @@
         sps->crop_top   = get_ue_golomb(&s->gb);
         sps->crop_bottom= get_ue_golomb(&s->gb);
         if(sps->crop_left || sps->crop_top){
-            fprintf(stderr, "insane croping not completly supported, this could look slightly wrong ...\n");
+            av_log(h->s.avctx, AV_LOG_ERROR, "insane cropping not completly supported, this could look slightly wrong ...\n");
         }
     }else{
         sps->crop_left  = 
@@ -3862,7 +3862,7 @@
         decode_vui_parameters(h, sps);
     
     if(s->avctx->debug&FF_DEBUG_PICT_INFO){
-        printf("sps:%d profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s\n", 
+        av_log(h->s.avctx, AV_LOG_DEBUG, "sps:%d profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s\n", 
                sps_id, sps->profile_idc, sps->level_idc,
                sps->poc_type,
                sps->ref_frame_count,
@@ -3888,7 +3888,7 @@
     pps->slice_group_count= get_ue_golomb(&s->gb) + 1;
     if(pps->slice_group_count > 1 ){
         pps->mb_slice_group_map_type= get_ue_golomb(&s->gb);
-fprintf(stderr, "FMO not supported\n");
+        av_log(h->s.avctx, AV_LOG_ERROR, "FMO not supported\n");
         switch(pps->mb_slice_group_map_type){
         case 0:
 #if 0
@@ -3926,7 +3926,7 @@
     pps->ref_count[0]= get_ue_golomb(&s->gb) + 1;
     pps->ref_count[1]= get_ue_golomb(&s->gb) + 1;
     if(pps->ref_count[0] > 32 || pps->ref_count[1] > 32){
-        fprintf(stderr, "reference overflow (pps)\n");
+        av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow (pps)\n");
         return -1;
     }
     
@@ -3940,7 +3940,7 @@
     pps->redundant_pic_cnt_present = get_bits1(&s->gb);
     
     if(s->avctx->debug&FF_DEBUG_PICT_INFO){
-        printf("pps:%d sps:%d %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d %s %s %s\n", 
+        av_log(h->s.avctx, AV_LOG_DEBUG, "pps:%d sps:%d %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d %s %s %s\n", 
                pps_id, pps->sps_id,
                pps->cabac ? "CABAC" : "CAVLC",
                pps->slice_group_count,
@@ -4016,7 +4016,7 @@
         bit_length= 8*dst_length - decode_rbsp_trailing(ptr + dst_length - 1);
 
         if(s->avctx->debug&FF_DEBUG_STARTCODE){
-            printf("NAL %d at %d length %d\n", h->nal_unit_type, buf_index, dst_length);
+            av_log(h->s.avctx, AV_LOG_DEBUG, "NAL %d at %d length %d\n", h->nal_unit_type, buf_index, dst_length);
         }
         
         buf_index += consumed;
@@ -4166,7 +4166,7 @@
     }
 #endif
     if(!s->current_picture_ptr){
-        fprintf(stderr, "error, NO frame\n");
+        av_log(h->s.avctx, AV_LOG_DEBUG, "error, NO frame\n");
         return -1;
     }
 
--- a/huffyuv.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/huffyuv.c	Mon Nov 03 13:26:22 2003 +0000
@@ -219,7 +219,7 @@
                 dst[index]= bits++;
         }
         if(bits & 1){
-            fprintf(stderr, "Error generating huffman table\n");
+            av_log(NULL, AV_LOG_ERROR, "Error generating huffman table\n");
             return -1;
         }
         bits >>= 1;
@@ -480,7 +480,7 @@
     switch(avctx->pix_fmt){
     case PIX_FMT_YUV420P:
         if(avctx->strict_std_compliance>=0){
-            fprintf(stderr, "YV12-huffyuv is experimental, there WILL be no compatbility! (use (v)strict=-1)\n");
+            av_log(avctx, AV_LOG_ERROR, "YV12-huffyuv is experimental, there WILL be no compatbility! (use (v)strict=-1)\n");
             return -1;
         }
         s->bitstream_bpp= 12;
@@ -489,7 +489,7 @@
         s->bitstream_bpp= 16;
         break;
     default:
-        fprintf(stderr, "format not supported\n");
+        av_log(avctx, AV_LOG_ERROR, "format not supported\n");
         return -1;
     }
     avctx->bits_per_sample= s->bitstream_bpp;
@@ -703,7 +703,7 @@
 
     p->reference= 0;
     if(avctx->get_buffer(avctx, p) < 0){
-        fprintf(stderr, "get_buffer() failed\n");
+        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
         return -1;
     }
 
@@ -724,7 +724,7 @@
             p->data[0][1]= get_bits(&s->gb, 8);
             p->data[0][0]= get_bits(&s->gb, 8);
             
-            fprintf(stderr, "YUY2 output isnt implemenetd yet\n");
+            av_log(avctx, AV_LOG_ERROR, "YUY2 output isnt implemenetd yet\n");
             return -1;
         }else{
         
@@ -896,11 +896,11 @@
                 draw_slice(s, height); // just 1 large slice as this isnt possible in reverse order
                 break;
             default:
-                fprintf(stderr, "prediction type not supported!\n");
+                av_log(avctx, AV_LOG_ERROR, "prediction type not supported!\n");
             }
         }else{
 
-            fprintf(stderr, "BGR24 output isnt implemenetd yet\n");
+            av_log(avctx, AV_LOG_ERROR, "BGR24 output isnt implemenetd yet\n");
             return -1;
         }
     }
@@ -1049,7 +1049,7 @@
             }
         }        
     }else{
-        fprintf(stderr, "Format not supported!\n");
+        av_log(avctx, AV_LOG_ERROR, "Format not supported!\n");
     }
     emms_c();
     
--- a/idcinvideo.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/idcinvideo.c	Mon Nov 03 13:26:22 2003 +0000
@@ -158,7 +158,7 @@
 
     /* make sure the Huffman tables make it */
     if (s->avctx->extradata_size != HUFFMAN_TABLE_SIZE) {
-        printf("  Id CIN video: expected extradata size of %d\n", HUFFMAN_TABLE_SIZE);
+        av_log(s->avctx, AV_LOG_ERROR, "  Id CIN video: expected extradata size of %d\n", HUFFMAN_TABLE_SIZE);
         return -1;
     }
 
@@ -193,7 +193,7 @@
             while(node_num >= HUF_TOKENS) {
                 if(!bit_pos) {
                     if(dat_pos > s->size) {
-                        printf("Huffman decode error.\n");
+                        av_log(s->avctx, AV_LOG_ERROR, "Huffman decode error.\n");
                         return;
                     }
                     bit_pos = 8;
@@ -225,7 +225,7 @@
         avctx->release_buffer(avctx, &s->frame);
 
     if (avctx->get_buffer(avctx, &s->frame)) {
-        printf ("  Id CIN Video: get_buffer() failed\n");
+        av_log(avctx, AV_LOG_ERROR, "  Id CIN Video: get_buffer() failed\n");
         return -1;
     }
 
--- a/indeo3.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/indeo3.c	Mon Nov 03 13:26:22 2003 +0000
@@ -622,7 +622,7 @@
                     break;
 
                   case 9:
-                    fprintf(stderr, "UNTESTED.\n");
+                    av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n");
                     lv1 = *buf1++;
                     lv = (lv1 & 0x7F) << 1;
                     lv += (lv << 8);
@@ -791,7 +791,7 @@
                       break;
 
                     case 9:
-                      fprintf(stderr, "UNTESTED.\n");
+                      av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n");
                       lv1 = *buf1;
                       lv = (lv1 & 0x7F) << 1;
                       lv += (lv << 8);
@@ -887,7 +887,7 @@
                       break;
 
                     case 9:
-                      fprintf(stderr, "UNTESTED.\n");
+                      av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n");
                       lv1 = *buf1;
                       lv = (lv1 & 0x7F) << 1;
                       lv += (lv << 8);
@@ -980,7 +980,7 @@
                     break;
 
                 case 9:
-                  fprintf(stderr, "UNTESTED.\n");
+                  av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n");
                   lv1 = *buf1++;
                   lv = (lv1 & 0x7F) << 1;
                   lv += (lv << 8);
@@ -1063,7 +1063,7 @@
 
     s->frame.reference = 0;
     if(avctx->get_buffer(avctx, &s->frame) < 0) {
-        fprintf(stderr, "get_buffer() failed\n");
+        av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
         return -1;
     }
 
--- a/interplayvideo.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/interplayvideo.c	Mon Nov 03 13:26:22 2003 +0000
@@ -76,7 +76,7 @@
 
 #define CHECK_STREAM_PTR(n) \
   if ((s->stream_ptr + n) > s->stream_end) { \
-    printf ("Interplay video warning: stream_ptr out of bounds (%p >= %p)\n", \
+    av_log(s->avctx, AV_LOG_ERROR, "Interplay video warning: stream_ptr out of bounds (%p >= %p)\n", \
       s->stream_ptr + n, s->stream_end); \
     return -1; \
   }
@@ -86,10 +86,10 @@
     motion_offset += y * s->stride; \
     motion_offset += x; \
     if (motion_offset < 0) { \
-        printf (" Interplay video: motion offset < 0 (%d)\n", motion_offset); \
+        av_log(s->avctx, AV_LOG_ERROR, " Interplay video: motion offset < 0 (%d)\n", motion_offset); \
         return -1; \
     } else if (motion_offset > s->upper_motion_limit_offset) { \
-        printf (" Interplay video: motion offset above limit (%d >= %d)\n", \
+        av_log(s->avctx, AV_LOG_ERROR, " Interplay video: motion offset above limit (%d >= %d)\n", \
             motion_offset, s->upper_motion_limit_offset); \
         return -1; \
     } \
@@ -101,10 +101,10 @@
     motion_offset += y * s->stride; \
     motion_offset += x; \
     if (motion_offset < 0) { \
-        printf (" Interplay video: motion offset < 0 (%d)\n", motion_offset); \
+        av_log(s->avctx, AV_LOG_ERROR, " Interplay video: motion offset < 0 (%d)\n", motion_offset); \
         return -1; \
     } else if (motion_offset > s->upper_motion_limit_offset) { \
-        printf (" Interplay video: motion offset above limit (%d >= %d)\n", \
+        av_log(s->avctx, AV_LOG_ERROR, " Interplay video: motion offset above limit (%d >= %d)\n", \
             motion_offset, s->upper_motion_limit_offset); \
         return -1; \
     } \
@@ -116,10 +116,10 @@
     motion_offset += y * s->stride; \
     motion_offset += x; \
     if (motion_offset < 0) { \
-        printf (" Interplay video: motion offset < 0 (%d)\n", motion_offset); \
+        av_log(s->avctx, AV_LOG_ERROR, " Interplay video: motion offset < 0 (%d)\n", motion_offset); \
         return -1; \
     } else if (motion_offset > s->upper_motion_limit_offset) { \
-        printf (" Interplay video: motion offset above limit (%d >= %d)\n", \
+        av_log(s->avctx, AV_LOG_ERROR, " Interplay video: motion offset above limit (%d >= %d)\n", \
             motion_offset, s->upper_motion_limit_offset); \
         return -1; \
     } \
@@ -254,7 +254,7 @@
 static int ipvideo_decode_block_opcode_0x6(IpvideoContext *s)
 {
     /* mystery opcode? skip multiple blocks? */
-    printf ("  Interplay video: Help! Mystery opcode 0x6 seen\n");
+    av_log(s->avctx, AV_LOG_ERROR, "  Interplay video: Help! Mystery opcode 0x6 seen\n");
 
     /* report success */
     return 0;
@@ -838,7 +838,7 @@
             s->pixel_ptr = s->current_frame.data[0] + x;
             ret = ipvideo_decode_block[opcode](s);
             if (ret != 0) {
-                printf(" Interplay video: decode problem on frame %d, @ block (%d, %d)\n",
+                av_log(s->avctx, AV_LOG_ERROR, " Interplay video: decode problem on frame %d, @ block (%d, %d)\n",
                     frame, x - y, y / s->stride);
                 return;
             }
@@ -846,7 +846,7 @@
     }
     if ((s->stream_ptr != s->stream_end) &&
         (s->stream_ptr + 1 != s->stream_end)) {
-        printf (" Interplay video: decode finished with %d bytes left over\n",
+        av_log(s->avctx, AV_LOG_ERROR, " Interplay video: decode finished with %d bytes left over\n",
             s->stream_end - s->stream_ptr);
     }
 }
@@ -858,7 +858,7 @@
     s->avctx = avctx;
 
     if (s->avctx->palctrl == NULL) {
-        printf (" Interplay video: palette expected.\n");
+        av_log(avctx, AV_LOG_ERROR, " Interplay video: palette expected.\n");
         return -1;
     }
 
@@ -906,7 +906,7 @@
 
     s->current_frame.reference = 3;
     if (avctx->get_buffer(avctx, &s->current_frame)) {
-        printf ("  Interplay Video: get_buffer() failed\n");
+        av_log(avctx, AV_LOG_ERROR, "  Interplay Video: get_buffer() failed\n");
         return -1;
     }
 
--- a/mdec.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/mdec.c	Mon Nov 03 13:26:22 2003 +0000
@@ -110,7 +110,7 @@
                 }
             }
             if (i > 63){
-                fprintf(stderr, "ac-tex damaged at %d %d\n", a->mb_x, a->mb_y);
+                av_log(a->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", a->mb_x, a->mb_y);
                 return -1;
             }
 
@@ -175,7 +175,7 @@
 
     p->reference= 0;
     if(avctx->get_buffer(avctx, p) < 0){
-        fprintf(stderr, "get_buffer() failed\n");
+        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
         return -1;
     }
     p->pict_type= I_TYPE;
--- a/mjpeg.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/mjpeg.c	Mon Nov 03 13:26:22 2003 +0000
@@ -884,7 +884,7 @@
 
     if (avctx->flags & CODEC_FLAG_EXTERN_HUFF)
     {
-	printf("mjpeg: using external huffman table\n");
+	av_log(avctx, AV_LOG_INFO, "mjpeg: using external huffman table\n");
 	init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size*8);
 	mjpeg_decode_dht(s);
 	/* should check for error - but dunno */
@@ -987,7 +987,7 @@
     if(s->bits==9 && !s->pegasus_rct) s->rct=1;    //FIXME ugly
 
     if (s->bits != 8 && !s->lossless){
-        printf("only 8 bits/component accepted\n");
+        av_log(s->avctx, AV_LOG_ERROR, "only 8 bits/component accepted\n");
         return -1;
     }
     height = get_bits(&s->gb, 16);
@@ -1066,7 +1066,7 @@
 
     s->picture.reference= 0;
     if(s->avctx->get_buffer(s->avctx, &s->picture) < 0){
-        fprintf(stderr, "get_buffer() failed\n");
+        av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
         return -1;
     }
     s->picture.pict_type= I_TYPE;
@@ -1444,7 +1444,7 @@
     }
 
     if(s->avctx->debug & FF_DEBUG_PICT_INFO)
-        printf("%s %s p:%d >>:%d\n", s->lossless ? "lossless" : "sequencial DCT", s->rgb ? "RGB" : "", predictor, point_transform);
+        av_log(s->avctx, AV_LOG_DEBUG, "%s %s p:%d >>:%d\n", s->lossless ? "lossless" : "sequencial DCT", s->rgb ? "RGB" : "", predictor, point_transform);
     
     if(s->lossless){
             if(s->rgb){
@@ -1489,7 +1489,7 @@
     len -= 6;
 
     if(s->avctx->debug & FF_DEBUG_STARTCODE){
-        printf("APPx %8X\n", id); 
+        av_log(s->avctx, AV_LOG_DEBUG, "APPx %8X\n", id); 
     }
     
     /* buggy AVID, it puts EOI only at every 10th frame */
@@ -1525,7 +1525,7 @@
     {
 	int t_w, t_h;
 	skip_bits(&s->gb, 8); /* the trailing zero-byte */
-	printf("mjpeg: JFIF header found (version: %x.%x)\n",
+	av_log(s->avctx, AV_LOG_INFO, "mjpeg: JFIF header found (version: %x.%x)\n",
 	    get_bits(&s->gb, 8), get_bits(&s->gb, 8));
         skip_bits(&s->gb, 8);
 
@@ -1546,7 +1546,7 @@
     
     if (id == ff_get_fourcc("Adob") && (get_bits(&s->gb, 8) == 'e'))
     {
-	printf("mjpeg: Adobe header found\n");
+	av_log(s->avctx, AV_LOG_INFO, "mjpeg: Adobe header found\n");
 	skip_bits(&s->gb, 16); /* version */
 	skip_bits(&s->gb, 16); /* flags0 */
 	skip_bits(&s->gb, 16); /* flags1 */
@@ -1556,7 +1556,7 @@
     }
 
     if (id == ff_get_fourcc("LJIF")){
-        printf("Pegasus lossless jpeg header found\n");
+        av_log(s->avctx, AV_LOG_INFO, "Pegasus lossless jpeg header found\n");
 	skip_bits(&s->gb, 16); /* version ? */
 	skip_bits(&s->gb, 16); /* unknwon always 0? */
 	skip_bits(&s->gb, 16); /* unknwon always 0? */
@@ -1571,7 +1571,7 @@
             s->pegasus_rct=1;
             break;
         default:
-            printf("unknown colorspace\n");
+            av_log(s->avctx, AV_LOG_ERROR, "unknown colorspace\n");
         }
         len -= 9;
         goto out;
@@ -1596,14 +1596,14 @@
 	    skip_bits(&s->gb, 32); /* data off */
 #endif
 	    if (s->first_picture)
-		printf("mjpeg: Apple MJPEG-A header found\n");
+		av_log(s->avctx, AV_LOG_INFO, "mjpeg: Apple MJPEG-A header found\n");
 	}
     }
 
 out:
     /* slow but needed for extreme adobe jpegs */
     if (len < 0)
-	printf("mjpeg: error, decode_app parser read over the end\n");
+	av_log(s->avctx, AV_LOG_ERROR, "mjpeg: error, decode_app parser read over the end\n");
     while(--len > 0)
 	skip_bits(&s->gb, 8);
 
@@ -1626,7 +1626,7 @@
 	    else
 		cbuf[i] = 0;
 
-	    printf("mjpeg comment: '%s'\n", cbuf);
+	    av_log(s->avctx, AV_LOG_INFO, "mjpeg comment: '%s'\n", cbuf);
 
 	    /* buggy avid, it puts EOI only at every 10th frame */
 	    if (!strcmp(cbuf, "AVID"))
@@ -1766,7 +1766,7 @@
 		
 		s->start_code = start_code;
                 if(s->avctx->debug & FF_DEBUG_STARTCODE){
-                    printf("startcode: %X\n", start_code);
+                    av_log(s->avctx, AV_LOG_DEBUG, "startcode: %X\n", start_code);
                 }
 
 		/* process markers */
@@ -1791,7 +1791,7 @@
                     break;
                 case DHT:
                     if(mjpeg_decode_dht(s) < 0){
-                        fprintf(stderr, "huffman table decode error\n");
+                        av_log(s->avctx, AV_LOG_ERROR, "huffman table decode error\n");
                         return -1;
                     }
                     break;
@@ -1829,7 +1829,7 @@
                             picture->qscale_table= s->qscale_table;
                             memset(picture->qscale_table, picture->quality, (s->width+15)/16);
                             if(avctx->debug & FF_DEBUG_QP)
-                                printf("QP: %d\n", picture->quality);
+                                av_log(s->avctx, AV_LOG_DEBUG, "QP: %d\n", picture->quality);
                             picture->quality*= FF_QP2LAMBDA;
                         }
                         
@@ -1858,7 +1858,7 @@
 		case SOF14:
 		case SOF15:
 		case JPG:
-		    printf("mjpeg: unsupported coding type (%x)\n", start_code);
+		    av_log(s->avctx, AV_LOG_ERROR, "mjpeg: unsupported coding type (%x)\n", start_code);
 		    break;
 //		default:
 //		    printf("mjpeg: unsupported marker (%x)\n", start_code);
@@ -1987,7 +1987,7 @@
         picture->qscale_table= s->qscale_table;
         memset(picture->qscale_table, picture->quality, (s->width+15)/16);
         if(avctx->debug & FF_DEBUG_QP)
-            printf("QP: %d\n", picture->quality);
+            av_log(avctx, AV_LOG_DEBUG, "QP: %d\n", picture->quality);
         picture->quality*= FF_QP2LAMBDA;
     }
 
--- a/motion_est.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/motion_est.c	Mon Nov 03 13:26:22 2003 +0000
@@ -322,7 +322,7 @@
         }
         break;
     default:
-        fprintf(stderr,"internal error in cmp function selection\n");
+        av_log(s->avctx, AV_LOG_ERROR,"internal error in cmp function selection\n");
     }
 }
 
--- a/mpeg12.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/mpeg12.c	Mon Nov 03 13:26:22 2003 +0000
@@ -994,7 +994,7 @@
 
     if (s->mb_skip_run-- != 0) {
         if(s->pict_type == I_TYPE){
-            fprintf(stderr, "skiped MB in I frame at %d %d\n", s->mb_x, s->mb_y);
+            av_log(s->avctx, AV_LOG_ERROR, "skiped MB in I frame at %d %d\n", s->mb_x, s->mb_y);
             return -1;
         }
     
@@ -1034,7 +1034,7 @@
     case I_TYPE:
         if (get_bits1(&s->gb) == 0) {
             if (get_bits1(&s->gb) == 0){
-                fprintf(stderr, "invalid mb type in I Frame at %d %d\n", s->mb_x, s->mb_y);
+                av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in I Frame at %d %d\n", s->mb_x, s->mb_y);
                 return -1;
             }
             mb_type = MB_TYPE_QUANT | MB_TYPE_INTRA;
@@ -1045,7 +1045,7 @@
     case P_TYPE:
         mb_type = get_vlc2(&s->gb, mb_ptype_vlc.table, MB_PTYPE_VLC_BITS, 1);
         if (mb_type < 0){
-            fprintf(stderr, "invalid mb type in P Frame at %d %d\n", s->mb_x, s->mb_y);
+            av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in P Frame at %d %d\n", s->mb_x, s->mb_y);
             return -1;
         }
         mb_type = ptype2mb_type[ mb_type ];
@@ -1053,7 +1053,7 @@
     case B_TYPE:
         mb_type = get_vlc2(&s->gb, mb_btype_vlc.table, MB_BTYPE_VLC_BITS, 1);
         if (mb_type < 0){
-            fprintf(stderr, "invalid mb type in B Frame at %d %d\n", s->mb_x, s->mb_y);
+            av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in B Frame at %d %d\n", s->mb_x, s->mb_y);
             return -1;
         }
         mb_type = btype2mb_type[ mb_type ];
@@ -1268,7 +1268,7 @@
         if (IS_PAT(mb_type)) {
             cbp = get_vlc2(&s->gb, mb_pat_vlc.table, MB_PAT_VLC_BITS, 1);
             if (cbp < 0){
-                fprintf(stderr, "invalid cbp at %d %d\n", s->mb_x, s->mb_y);
+                av_log(s->avctx, AV_LOG_ERROR, "invalid cbp at %d %d\n", s->mb_x, s->mb_y);
                 return -1;
             }
             cbp++;
@@ -1356,7 +1356,7 @@
         code = get_vlc2(gb, dc_chroma_vlc.table, DC_VLC_BITS, 2);
     }
     if (code < 0){
-        fprintf(stderr, "invalid dc code at\n");
+        av_log(NULL, AV_LOG_ERROR, "invalid dc code at\n");
         return 0xffff;
     }
     if (code == 0) {
@@ -1428,7 +1428,7 @@
                 }
             }
             if (i > 63){
-                fprintf(stderr, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
+                av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
                 return -1;
             }
 
@@ -1504,7 +1504,7 @@
                 }
             }
             if (i > 63){
-                fprintf(stderr, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
+                av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
                 return -1;
             }
 
@@ -1582,7 +1582,7 @@
                 }
             }
             if (i > 63){
-                fprintf(stderr, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
+                av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
                 return -1;
             }
             
@@ -1662,7 +1662,7 @@
                 }
             }
             if (i > 63){
-                fprintf(stderr, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
+                av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
                 return -1;
             }
             
@@ -1810,7 +1810,7 @@
     }
     
     if(s->avctx->debug & FF_DEBUG_PICT_INFO)
-        printf("profile: %d, level: %d \n", profile, level);
+        av_log(s->avctx, AV_LOG_DEBUG, "profile: %d, level: %d \n", profile, level);
 }
 
 static void mpeg_decode_sequence_display_extension(Mpeg1Context *s1)
@@ -1841,7 +1841,7 @@
             );
     
     if(s->avctx->debug & FF_DEBUG_PICT_INFO)
-        printf("sde w:%d, h:%d\n", w, h);
+        av_log(s->avctx, AV_LOG_DEBUG, "sde w:%d, h:%d\n", w, h);
 }
 
 static void mpeg_decode_picture_display_extension(Mpeg1Context *s1)
@@ -1857,7 +1857,7 @@
     }
    
     if(s->avctx->debug & FF_DEBUG_PICT_INFO)
-        printf("pde (%d,%d) (%d,%d) (%d,%d)\n", 
+        av_log(s->avctx, AV_LOG_DEBUG, "pde (%d,%d) (%d,%d) (%d,%d)\n", 
             s1->pan_scan.position[0][0], s1->pan_scan.position[0][1], 
             s1->pan_scan.position[1][0], s1->pan_scan.position[1][1], 
             s1->pan_scan.position[2][0], s1->pan_scan.position[2][1]
@@ -2014,7 +2014,7 @@
     
     start_code = (start_code - 1) & 0xff;
     if (start_code >= s->mb_height){
-        fprintf(stderr, "slice below image (%d >= %d)\n", start_code, s->mb_height);
+        av_log(s->avctx, AV_LOG_ERROR, "slice below image (%d >= %d)\n", start_code, s->mb_height);
         return -1;
     }
     
@@ -2047,7 +2047,7 @@
         //printf("%d\n", s->current_picture_ptr->repeat_pict);
 
         if(s->avctx->debug&FF_DEBUG_PICT_INFO){
-             printf("qp:%d fc:%2d%2d%2d%2d %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n", 
+             av_log(s->avctx, AV_LOG_DEBUG, "qp:%d fc:%2d%2d%2d%2d %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n", 
                  s->qscale, s->mpeg_f_code[0][0],s->mpeg_f_code[0][1],s->mpeg_f_code[1][0],s->mpeg_f_code[1][1],
                  s->pict_type == I_TYPE ? "I" : (s->pict_type == P_TYPE ? "P" : (s->pict_type == B_TYPE ? "B" : "S")), 
                  s->progressive_sequence ? "pro" :"", s->alternate_scan ? "alt" :"", s->top_field_first ? "top" :"", 
@@ -2058,7 +2058,7 @@
             int i;
             
             if(!s->current_picture_ptr){
-                fprintf(stderr, "first field missing\n");
+                av_log(s->avctx, AV_LOG_ERROR, "first field missing\n");
                 return -1;
             }
             
@@ -2082,7 +2082,7 @@
 
     s->qscale = get_qscale(s);
     if(s->qscale == 0){
-        fprintf(stderr, "qscale == 0\n");
+        av_log(s->avctx, AV_LOG_ERROR, "qscale == 0\n");
         return -1;
     }
     
@@ -2096,7 +2096,7 @@
     for(;;) {
         int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2);
         if (code < 0){
-            fprintf(stderr, "first mb_incr damaged\n");
+            av_log(s->avctx, AV_LOG_ERROR, "first mb_incr damaged\n");
             return -1;
         }
         if (code >= 33) {
@@ -2173,7 +2173,7 @@
 
                 if(left < 0 || (left && show_bits(&s->gb, FFMIN(left, 23)))
                    || (avctx->error_resilience >= FF_ER_AGGRESSIVE && left>8)){
-                    fprintf(stderr, "end missmatch left=%d\n", left);
+                    av_log(avctx, AV_LOG_ERROR, "end mismatch left=%d\n", left);
                     return -1;
                 }else
                     goto eos;
@@ -2189,7 +2189,7 @@
             for(;;) {
                 int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2);
                 if (code < 0){
-                    fprintf(stderr, "mb incr damaged\n");
+                    av_log(s->avctx, AV_LOG_ERROR, "mb incr damaged\n");
                     return -1;
                 }
                 if (code >= 33) {
@@ -2197,7 +2197,7 @@
                         s->mb_skip_run += 33;
                     }else if(code == 35){
                         if(s->mb_skip_run != 0 || show_bits(&s->gb, 15) != 0){
-                            fprintf(stderr, "slice missmatch\n");
+                            av_log(s->avctx, AV_LOG_ERROR, "slice mismatch\n");
                             return -1;
                         }
                         goto eos; /* end of slice */
@@ -2564,7 +2564,7 @@
         input_size = buf_end - buf_ptr;
 
         if(avctx->debug & FF_DEBUG_STARTCODE){
-            printf("%3X at %d left %d\n", start_code, buf_ptr-buf, input_size);
+            av_log(avctx, AV_LOG_DEBUG, "%3X at %d left %d\n", start_code, buf_ptr-buf, input_size);
         }
 
                 /* prepare data for next start code */
--- a/mpegaudio.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/mpegaudio.c	Mon Nov 03 13:26:22 2003 +0000
@@ -117,7 +117,7 @@
     s->alloc_table = alloc_tables[table];
 
 #ifdef DEBUG
-    printf("%d kb/s, %d Hz, frame_size=%d bits, table=%d, padincr=%x\n", 
+    av_log(AV_LOG_DEBUG, "%d kb/s, %d Hz, frame_size=%d bits, table=%d, padincr=%x\n", 
            bitrate, freq, s->frame_size, table, s->frame_frac_incr);
 #endif
 
--- a/mpegvideo.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/mpegvideo.c	Mon Nov 03 13:26:22 2003 +0000
@@ -274,17 +274,17 @@
         r= s->avctx->get_buffer(s->avctx, (AVFrame*)pic);
         
         if(r<0 || !pic->age || !pic->type || !pic->data[0]){
-            fprintf(stderr, "get_buffer() failed (%d %d %d %p)\n", r, pic->age, pic->type, pic->data[0]);
+	    av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %d %p)\n", r, pic->age, pic->type, pic->data[0]);
             return -1;
         }
 
         if(s->linesize && (s->linesize != pic->linesize[0] || s->uvlinesize != pic->linesize[1])){
-            fprintf(stderr, "get_buffer() failed (stride changed)\n");
+            av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (stride changed)\n");
             return -1;
         }
 
         if(pic->linesize[1] != pic->linesize[2]){
-            fprintf(stderr, "get_buffer() failed (uv stride missmatch)\n");
+            av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (uv stride missmatch)\n");
             return -1;
         }
 
@@ -625,7 +625,7 @@
     s->width = avctx->width;
     s->height = avctx->height;
     if(avctx->gop_size > 600){
-        fprintf(stderr, "Warning keyframe interval too large! reducing it ...\n");
+	av_log(avctx, AV_LOG_ERROR, "Warning keyframe interval too large! reducing it ...\n");
         avctx->gop_size=600;
     }
     s->gop_size = avctx->gop_size;
@@ -670,32 +670,32 @@
     s->progressive_sequence= !(avctx->flags & CODEC_FLAG_INTERLACED_DCT);
 
     if((s->flags & CODEC_FLAG_4MV) && s->codec_id != CODEC_ID_MPEG4){
-        fprintf(stderr, "4MV not supporetd by codec\n");
+        av_log(avctx, AV_LOG_ERROR, "4MV not supported by codec\n");
         return -1;
     }
     
     if(s->quarter_sample && s->codec_id != CODEC_ID_MPEG4){
-        fprintf(stderr, "qpel not supporetd by codec\n");
+        av_log(avctx, AV_LOG_ERROR, "qpel not supported by codec\n");
         return -1;
     }
 
     if(s->data_partitioning && s->codec_id != CODEC_ID_MPEG4){
-        fprintf(stderr, "data partitioning not supporetd by codec\n");
+        av_log(avctx, AV_LOG_ERROR, "data partitioning not supported by codec\n");
         return -1;
     }
     
     if(s->max_b_frames && s->codec_id != CODEC_ID_MPEG4 && s->codec_id != CODEC_ID_MPEG1VIDEO && s->codec_id != CODEC_ID_MPEG2VIDEO){
-        fprintf(stderr, "b frames not supporetd by codec\n");
+        av_log(avctx, AV_LOG_ERROR, "b frames not supported by codec\n");
         return -1;
     }
     
     if(s->mpeg_quant && s->codec_id != CODEC_ID_MPEG4){ //FIXME mpeg2 uses that too
-        fprintf(stderr, "mpeg2 style quantization not supporetd by codec\n");
+        av_log(avctx, AV_LOG_ERROR, "mpeg2 style quantization not supporetd by codec\n");
         return -1;
     }
         
     if((s->flags & CODEC_FLAG_CBP_RD) && !(s->flags & CODEC_FLAG_TRELLIS_QUANT)){
-        fprintf(stderr, "CBP RD needs trellis quant\n");
+        av_log(avctx, AV_LOG_ERROR, "CBP RD needs trellis quant\n");
         return -1;
     }
 
@@ -753,7 +753,7 @@
 #ifdef CONFIG_RISKY
     case CODEC_ID_H263:
         if (h263_get_picture_format(s->width, s->height) == 7) {
-            printf("Input picture size isn't suitable for h263 codec! try h263+\n");
+            av_log(avctx, AV_LOG_INFO, "Input picture size isn't suitable for h263 codec! try h263+\n");
             return -1;
         }
         s->out_format = FMT_H263;
@@ -1078,7 +1078,7 @@
         if(!s->encoding){
             for(i=0; i<MAX_PICTURE_COUNT; i++){
                 if(s->picture[i].data[0] && &s->picture[i] != s->next_picture_ptr && s->picture[i].reference){
-                    fprintf(stderr, "releasing zombie picture\n");
+                    av_log(avctx, AV_LOG_ERROR, "releasing zombie picture\n");
                     avctx->release_buffer(avctx, (AVFrame*)&s->picture[i]);                
                 }
             }
@@ -1128,7 +1128,7 @@
     if(s->next_picture_ptr) copy_picture(&s->next_picture, s->next_picture_ptr);
     
     if(s->pict_type != I_TYPE && (s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL)){
-        fprintf(stderr, "warning: first frame is no keyframe\n");
+        av_log(avctx, AV_LOG_ERROR, "warning: first frame is no keyframe\n");
         assert(s->pict_type != B_TYPE); //these should have been dropped if we dont have a reference
         goto alloc;
     }
@@ -1315,63 +1315,63 @@
                 if(s->avctx->debug&FF_DEBUG_SKIP){
                     int count= s->mbskip_table[x + y*s->mb_stride];
                     if(count>9) count=9;
-                    printf("%1d", count);
+                    av_log(s->avctx, AV_LOG_DEBUG, "%1d", count);
                 }
                 if(s->avctx->debug&FF_DEBUG_QP){
-                    printf("%2d", pict->qscale_table[x + y*s->mb_stride]);
+                    av_log(s->avctx, AV_LOG_DEBUG, "%2d", pict->qscale_table[x + y*s->mb_stride]);
                 }
                 if(s->avctx->debug&FF_DEBUG_MB_TYPE){
                     int mb_type= pict->mb_type[x + y*s->mb_stride];
                     
                     //Type & MV direction
                     if(IS_PCM(mb_type))
-                        printf("P");
+                        av_log(s->avctx, AV_LOG_DEBUG, "P");
                     else if(IS_INTRA(mb_type) && IS_ACPRED(mb_type))
-                        printf("A");
+                        av_log(s->avctx, AV_LOG_DEBUG, "A");
                     else if(IS_INTRA4x4(mb_type))
-                        printf("i");
+                        av_log(s->avctx, AV_LOG_DEBUG, "i");
                     else if(IS_INTRA16x16(mb_type))
-                        printf("I");
+                        av_log(s->avctx, AV_LOG_DEBUG, "I");
                     else if(IS_DIRECT(mb_type) && IS_SKIP(mb_type))
-                        printf("d");
+                        av_log(s->avctx, AV_LOG_DEBUG, "d");
                     else if(IS_DIRECT(mb_type))
-                        printf("D");
+                        av_log(s->avctx, AV_LOG_DEBUG, "D");
                     else if(IS_GMC(mb_type) && IS_SKIP(mb_type))
-                        printf("g");
+                        av_log(s->avctx, AV_LOG_DEBUG, "g");
                     else if(IS_GMC(mb_type))
-                        printf("G");
+                        av_log(s->avctx, AV_LOG_DEBUG, "G");
                     else if(IS_SKIP(mb_type))
-                        printf("S");
+                        av_log(s->avctx, AV_LOG_DEBUG, "S");
                     else if(!USES_LIST(mb_type, 1))
-                        printf(">");
+                        av_log(s->avctx, AV_LOG_DEBUG, ">");
                     else if(!USES_LIST(mb_type, 0))
-                        printf("<");
+                        av_log(s->avctx, AV_LOG_DEBUG, "<");
                     else{
                         assert(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1));
-                        printf("X");
+                        av_log(s->avctx, AV_LOG_DEBUG, "X");
                     }
                     
                     //segmentation
                     if(IS_8X8(mb_type))
-                        printf("+");
+                        av_log(s->avctx, AV_LOG_DEBUG, "+");
                     else if(IS_16X8(mb_type))
-                        printf("-");
+                        av_log(s->avctx, AV_LOG_DEBUG, "-");
                     else if(IS_8X16(mb_type))
-                        printf("¦");
+                        av_log(s->avctx, AV_LOG_DEBUG, "¦");
                     else if(IS_INTRA(mb_type) || IS_16X16(mb_type))
-                        printf(" ");
+                        av_log(s->avctx, AV_LOG_DEBUG, " ");
                     else
-                        printf("?");
+                        av_log(s->avctx, AV_LOG_DEBUG, "?");
                     
                         
                     if(IS_INTERLACED(mb_type) && s->codec_id == CODEC_ID_H264)
-                        printf("=");
+                        av_log(s->avctx, AV_LOG_DEBUG, "=");
                     else
-                        printf(" ");
+                        av_log(s->avctx, AV_LOG_DEBUG, " ");
                 }
-//                printf(" ");
+//                av_log(s->avctx, AV_LOG_DEBUG, " ");
             }
-            printf("\n");
+            av_log(s->avctx, AV_LOG_DEBUG, "\n");
         }
     }
     
@@ -1457,7 +1457,7 @@
     if(pic_arg->linesize[1] != s->uvlinesize) direct=0;
     if(pic_arg->linesize[2] != s->uvlinesize) direct=0;
   
-//    printf("%d %d %d %d\n",pic_arg->linesize[0], pic_arg->linesize[1], s->linesize, s->uvlinesize);
+//    av_log(AV_LOG_DEBUG, "%d %d %d %d\n",pic_arg->linesize[0], pic_arg->linesize[1], s->linesize, s->uvlinesize);
     
     if(direct){
         i= ff_find_unused_picture(s, 1);
@@ -1564,7 +1564,7 @@
                 }
             
                 if(b_frames > s->max_b_frames){
-                    fprintf(stderr, "warning, too many bframes in a row\n");
+                    av_log(s->avctx, AV_LOG_ERROR, "warning, too many bframes in a row\n");
                     b_frames = s->max_b_frames;
                 }
             }else if(s->b_frame_strategy==0){
@@ -1589,14 +1589,14 @@
                     s->input_picture[i]->b_frame_score=0;
                 }
             }else{
-                fprintf(stderr, "illegal b frame strategy\n");
+                av_log(s->avctx, AV_LOG_ERROR, "illegal b frame strategy\n");
                 b_frames=0;
             }
 
             emms_c();
 //static int b_count=0;
 //b_count+= b_frames;
-//printf("b_frames: %d\n", b_count);
+//av_log(s->avctx, AV_LOG_DEBUG, "b_frames: %d\n", b_count);
                         
             s->reordered_input_picture[0]= s->input_picture[b_frames];
             if(   s->picture_in_gop_number + b_frames >= s->gop_size 
@@ -1668,7 +1668,7 @@
     int i;
 
     if(avctx->pix_fmt != PIX_FMT_YUV420P){
-        fprintf(stderr, "this codec supports only YUV420P\n");
+        av_log(avctx, AV_LOG_ERROR, "this codec supports only YUV420P\n");
         return -1;
     }
     
@@ -4002,7 +4002,7 @@
                     break;
                 default:
                     motion_x=motion_y=0; //gcc warning fix
-                    printf("illegal MB type\n");
+                    av_log(s->avctx, AV_LOG_ERROR, "illegal MB type\n");
                 }
 
                 encode_mb(s, motion_x, motion_y);
--- a/msmpeg4.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/msmpeg4.c	Mon Nov 03 13:26:22 2003 +0000
@@ -1238,7 +1238,7 @@
         int start_code, num;
         start_code = (get_bits(&s->gb, 16)<<16) | get_bits(&s->gb, 16);
         if(start_code!=0x00000100){
-            fprintf(stderr, "invalid startcode\n");
+            av_log(s->avctx, AV_LOG_ERROR, "invalid startcode\n");
             return -1;
         }
 
@@ -1248,7 +1248,7 @@
     s->pict_type = get_bits(&s->gb, 2) + 1;
     if (s->pict_type != I_TYPE &&
         s->pict_type != P_TYPE){
-        fprintf(stderr, "invalid picture type\n");
+        av_log(s->avctx, AV_LOG_ERROR, "invalid picture type\n");
         return -1;
     }
 #if 0
@@ -1260,7 +1260,7 @@
 #endif
     s->qscale = get_bits(&s->gb, 5);
     if(s->qscale==0){
-        fprintf(stderr, "invalid qscale\n");
+        av_log(s->avctx, AV_LOG_ERROR, "invalid qscale\n");
         return -1;
     }
 
@@ -1268,7 +1268,7 @@
         code = get_bits(&s->gb, 5); 
         if(s->msmpeg4_version==1){
             if(code==0 || code>s->mb_height){
-                fprintf(stderr, "invalid slice height %d\n", code);
+                av_log(s->avctx, AV_LOG_ERROR, "invalid slice height %d\n", code);
                 return -1;
             }
 
@@ -1276,7 +1276,7 @@
         }else{
             /* 0x17: one slice, 0x18: two slices, ... */
             if (code < 0x17){
-                fprintf(stderr, "error, slice code was %X\n", code);
+                av_log(s->avctx, AV_LOG_ERROR, "error, slice code was %X\n", code);
                 return -1;
             }
 
@@ -1314,7 +1314,7 @@
         }
         s->no_rounding = 1;
         if(s->avctx->debug&FF_DEBUG_PICT_INFO)
-	    printf("qscale:%d rlc:%d rl:%d dc:%d mbrl:%d slice:%d   \n", 
+	    av_log(s->avctx, AV_LOG_DEBUG, "qscale:%d rlc:%d rl:%d dc:%d mbrl:%d slice:%d   \n", 
 		s->qscale,
 		s->rl_chroma_table_index,
 		s->rl_table_index, 
@@ -1362,7 +1362,7 @@
         }
         
         if(s->avctx->debug&FF_DEBUG_PICT_INFO)
-	    printf("skip:%d rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d   \n", 
+	    av_log(s->avctx, AV_LOG_DEBUG, "skip:%d rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d   \n", 
 		s->use_skip_mb_code, 
 		s->rl_table_index, 
 		s->rl_chroma_table_index, 
@@ -1410,11 +1410,11 @@
     {
         s->flipflop_rounding= 0;
         if(s->msmpeg4_version != 2)
-            printf("ext header missing, %d left\n", left);
+            av_log(s->avctx, AV_LOG_ERROR, "ext header missing, %d left\n", left);
     }
     else
     {
-        fprintf(stderr, "I frame too long, ignoring ext header\n");
+        av_log(s->avctx, AV_LOG_ERROR, "I frame too long, ignoring ext header\n");
     }
 
     return 0;
@@ -1517,7 +1517,7 @@
         else
             code = get_vlc2(&s->gb, v1_inter_cbpc_vlc.table, V1_INTER_CBPC_VLC_BITS, 3);
         if(code<0 || code>7){
-            fprintf(stderr, "cbpc %d invalid at %d %d\n", code, s->mb_x, s->mb_y);
+            av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", code, s->mb_x, s->mb_y);
             return -1;
         }
 
@@ -1531,7 +1531,7 @@
         else
             cbp= get_vlc2(&s->gb, v1_intra_cbpc_vlc.table, V1_INTRA_CBPC_VLC_BITS, 1);
         if(cbp<0 || cbp>3){
-            fprintf(stderr, "cbpc %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);
+            av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);
             return -1;
         }
     }
@@ -1541,7 +1541,7 @@
         
         cbpy= get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);
         if(cbpy<0){
-            fprintf(stderr, "cbpy %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);
+            av_log(s->avctx, AV_LOG_ERROR, "cbpy %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);
             return -1;
         }
 
@@ -1570,7 +1570,7 @@
     for (i = 0; i < 6; i++) {
         if (msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
 	{
-             fprintf(stderr,"\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
+             av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
              return -1;
 	}
     }
@@ -1662,7 +1662,7 @@
     for (i = 0; i < 6; i++) {
         if (msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
 	{
-	    fprintf(stderr,"\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
+	    av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
 	    return -1;
 	}
     }
@@ -1688,20 +1688,20 @@
         level = msmpeg4_decode_dc(s, n, &dc_pred_dir);
         
         if (level < 0){
-            fprintf(stderr, "dc overflow- block: %d qscale: %d//\n", n, s->qscale);
+            av_log(s->avctx, AV_LOG_ERROR, "dc overflow- block: %d qscale: %d//\n", n, s->qscale);
             if(s->inter_intra_pred) level=0;
             else                    return -1;
         }
         if (n < 4) {
             rl = &rl_table[s->rl_table_index];
             if(level > 256*s->y_dc_scale){
-                fprintf(stderr, "dc overflow+ L qscale: %d//\n", s->qscale);
+                av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ L qscale: %d//\n", s->qscale);
                 if(!s->inter_intra_pred) return -1;
             }
         } else {
             rl = &rl_table[3 + s->rl_chroma_table_index];
             if(level > 256*s->c_dc_scale){
-                fprintf(stderr, "dc overflow+ C qscale: %d//\n", s->qscale);
+                av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ C qscale: %d//\n", s->qscale);
                 if(!s->inter_intra_pred) return -1;
             }
         }
@@ -1770,7 +1770,7 @@
                             if(s->qscale<8){
                                 ll= SHOW_UBITS(re, &s->gb, 3); SKIP_BITS(re, &s->gb, 3);
                                 if(ll==0){
-                                    if(SHOW_UBITS(re, &s->gb, 1)) printf("cool a new vlc code ,contact the ffmpeg developers and upload the file\n");
+                                    if(SHOW_UBITS(re, &s->gb, 1)) av_log(s->avctx, AV_LOG_ERROR, "cool a new vlc code ,contact the ffmpeg developers and upload the file\n");
                                     SKIP_BITS(re, &s->gb, 1);
                                     ll=8;
                                 }
@@ -1891,10 +1891,10 @@
             if(i&(~63)){
                 const int left= s->gb.size_in_bits - get_bits_count(&s->gb);
                 if(((i+192 == 64 && level/qmul==-1) || s->error_resilience<=1) && left>=0){
-                    fprintf(stderr, "ignoring overflow at %d %d\n", s->mb_x, s->mb_y);
+                    av_log(s->avctx, AV_LOG_ERROR, "ignoring overflow at %d %d\n", s->mb_x, s->mb_y);
                     break;
                 }else{
-                    fprintf(stderr, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
+                    av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
                     return -1;
                 }
             }
@@ -1940,7 +1940,7 @@
             level = get_vlc2(&s->gb, dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
         }
         if (level < 0){
-            fprintf(stderr, "illegal dc vlc\n");
+            av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
             return -1;
         }
 
@@ -1987,7 +1987,7 @@
 
     code = get_vlc2(&s->gb, mv->vlc.table, MV_VLC_BITS, 2);
     if (code < 0){
-        fprintf(stderr, "illegal MV code at %d %d\n", s->mb_x, s->mb_y);
+        av_log(s->avctx, AV_LOG_ERROR, "illegal MV code at %d %d\n", s->mb_x, s->mb_y);
         return -1;
     }
     if (code == mv->n) {
--- a/msrle.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/msrle.c	Mon Nov 03 13:26:22 2003 +0000
@@ -51,7 +51,7 @@
 #define FETCH_NEXT_STREAM_BYTE() \
     if (stream_ptr >= s->size) \
     { \
-      printf(" MS RLE: stream ptr just went out of bounds (1)\n"); \
+      av_log(s->avctx, AV_LOG_ERROR, " MS RLE: stream ptr just went out of bounds (1)\n"); \
       return; \
     } \
     stream_byte = s->buf[stream_ptr++];
@@ -90,14 +90,14 @@
                 /* copy pixels from encoded stream */
                 if ((row_ptr + pixel_ptr + stream_byte > frame_size) ||
                     (row_ptr < 0)) {
-                    printf(" MS RLE: frame ptr just went out of bounds (1)\n");
+                    av_log(s->avctx, AV_LOG_ERROR, " MS RLE: frame ptr just went out of bounds (1)\n");
                     return;
                 }
 
                 rle_code = stream_byte;
                 extra_byte = stream_byte & 0x01;
                 if (stream_ptr + rle_code + extra_byte > s->size) {
-                    printf(" MS RLE: stream ptr just went out of bounds (2)\n");
+                    av_log(s->avctx, AV_LOG_ERROR, " MS RLE: stream ptr just went out of bounds (2)\n");
                     return;
                 }
 
@@ -115,7 +115,7 @@
             /* decode a run of data */
             if ((row_ptr + pixel_ptr + stream_byte > frame_size) ||
                 (row_ptr < 0)) {
-                printf(" MS RLE: frame ptr just went out of bounds (2)\n");
+                av_log(s->avctx, AV_LOG_ERROR, " MS RLE: frame ptr just went out of bounds (2)\n");
                 return;
             }
 
@@ -137,7 +137,7 @@
 
     /* one last sanity check on the way out */
     if (stream_ptr < s->size)
-        printf(" MS RLE: ended frame decode with bytes left over (%d < %d)\n",
+        av_log(s->avctx, AV_LOG_ERROR, " MS RLE: ended frame decode with bytes left over (%d < %d)\n",
             stream_ptr, s->size);
 }
 
@@ -165,12 +165,12 @@
 
     s->frame.reference = 1;
     if (avctx->get_buffer(avctx, &s->frame)) {
-        printf ("  MS RLE: get_buffer() failed\n");
+        av_log(avctx, AV_LOG_ERROR, "  MS RLE: get_buffer() failed\n");
         return -1;
     }
 
     if (s->prev_frame.data[0] && (s->frame.linesize[0] != s->prev_frame.linesize[0]))
-        printf ("  MS RLE: Buffer linesize changed: current %u, previous %u.\n"
+        av_log(avctx, AV_LOG_ERROR, "  MS RLE: Buffer linesize changed: current %u, previous %u.\n"
                 "          Expect wrong image and/or crash!\n",
                 s->frame.linesize[0], s->prev_frame.linesize[0]);
 
--- a/msvideo1.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/msvideo1.c	Mon Nov 03 13:26:22 2003 +0000
@@ -42,7 +42,7 @@
 #define LE_16(x)  ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0])
 #define CHECK_STREAM_PTR(n) \
   if ((stream_ptr + n) > s->size ) { \
-    printf (" MS Video-1 warning: stream_ptr out of bounds (%d >= %d)\n", \
+    av_log(s->avctx, AV_LOG_ERROR, " MS Video-1 warning: stream_ptr out of bounds (%d >= %d)\n", \
       stream_ptr + n, s->size); \
     return; \
   }
@@ -322,12 +322,12 @@
     s->size = buf_size;
 
     if (avctx->get_buffer(avctx, &s->frame)) {
-        printf ("  MS Video-1 Video: get_buffer() failed\n");
+        av_log(s->avctx, AV_LOG_ERROR, "  MS Video-1 Video: get_buffer() failed\n");
         return -1;
     }
 
     if (s->prev_frame.data[0] &&(s->frame.linesize[0] != s->prev_frame.linesize[0]))
-        printf ("  MS Video-1: Buffer linesize changed: current %u, previous %u.\n"
+        av_log(avctx, AV_LOG_ERROR, "  MS Video-1: Buffer linesize changed: current %u, previous %u.\n"
                 "              Expect wrong image and/or crash!\n",
                 s->frame.linesize[0], s->prev_frame.linesize[0]);
 
--- a/oggvorbis.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/oggvorbis.c	Mon Nov 03 13:26:22 2003 +0000
@@ -47,7 +47,7 @@
 
     vorbis_info_init(&context->vi) ;
     if(oggvorbis_init_encoder(&context->vi, avccontext) < 0) {
-	fprintf(stderr, "oggvorbis_encode_init: init_encoder failed") ;
+	av_log(avccontext, AV_LOG_ERROR, "oggvorbis_encode_init: init_encoder failed") ;
 	return -1 ;
     }
     vorbis_analysis_init(&context->vd, &context->vi) ;
@@ -112,7 +112,7 @@
     /* We need to write all the remaining packets into the stream
      * on closing */
     
-    fprintf(stderr, "fixme: not all packets written on oggvorbis_encode_close()\n") ;
+    av_log(avccontext, AV_LOG_ERROR, "fixme: not all packets written on oggvorbis_encode_close()\n") ;
 
 /*
     while(vorbis_bitrate_flushpacket(&context->vd, &op)) {
@@ -195,7 +195,7 @@
     }
 
     if(op->packetno == 3) {
-	fprintf(stderr, "vorbis_decode: %d channel, %ldHz, encoder `%s'\n",
+	av_log(avccontext, AV_LOG_ERROR, "vorbis_decode: %d channel, %ldHz, encoder `%s'\n",
 		context->vi.channels, context->vi.rate, context->vc.vendor);
 
 	avccontext->channels = context->vi.channels ;
--- a/opts.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/opts.c	Mon Nov 03 13:26:22 2003 +0000
@@ -89,7 +89,7 @@
     d = atof(s);
     if (c->min != c->max) {
 	if (d < c->min || d > c->max) {
-	    fprintf(stderr, "Option: %s double value: %f out of range <%f, %f>\n",
+	    av_log(NULL, AV_LOG_ERROR, "Option: %s double value: %f out of range <%f, %f>\n",
 		    c->name, d, c->min, c->max);
 	    return -1;
 	}
@@ -106,7 +106,7 @@
     i = atoi(s);
     if (c->min != c->max) {
 	if (i < (int)c->min || i > (int)c->max) {
-	    fprintf(stderr, "Option: %s integer value: %d out of range <%d, %d>\n",
+	    av_log(NULL, AV_LOG_ERROR, "Option: %s integer value: %d out of range <%d, %d>\n",
 		    c->name, i, (int)c->min, (int)c->max);
 	    return -1;
 	}
@@ -136,7 +136,7 @@
 
 	    //printf("parsed Rc:  %d,%d,%d,%f  (%d)\n", sf,ef,qs,qf, avctx->rc_override_count);
 	} else {
-	    printf("incorrect/unparsable Rc: \"%s\"\n", s);
+	    av_log(NULL, AV_LOG_ERROR, "incorrect/unparsable Rc: \"%s\"\n", s);
 	}
     } else
 	*var = av_strdup(s);
--- a/ra288.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/ra288.c	Mon Nov 03 13:26:22 2003 +0000
@@ -244,7 +244,7 @@
     int i,j;
     if(buf_size<w*h)
     {
-	fprintf(stderr,"ffra288: Error! Input buffer is too small [%d<%d]\n",buf_size,w*h);
+	av_log(avctx, AV_LOG_ERROR, "ffra288: Error! Input buffer is too small [%d<%d]\n",buf_size,w*h);
 	return 0;
     }
     datao = data;
@@ -260,7 +260,7 @@
   }
   else
   {
-    fprintf(stderr,"ffra288: Error: need extra data!!!\n");
+    av_log(avctx, AV_LOG_ERROR, "ffra288: Error: need extra data!!!\n");
     return 0;
   }
 }
--- a/ratecontrol.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/ratecontrol.c	Mon Nov 03 13:26:22 2003 +0000
@@ -109,7 +109,7 @@
                    &rce->pict_type, &rce->qscale, &rce->i_tex_bits, &rce->p_tex_bits, &rce->mv_bits, &rce->misc_bits, 
                    &rce->f_code, &rce->b_code, &rce->mc_mb_var_sum, &rce->mb_var_sum, &rce->i_count);
             if(e!=12){
-                fprintf(stderr, "statistics are damaged at line %d, parser out=%d\n", i, e);
+                av_log(s->avctx, AV_LOG_ERROR, "statistics are damaged at line %d, parser out=%d\n", i, e);
                 return -1;
             }
             p= next;
@@ -183,14 +183,14 @@
 
 static inline double qp2bits(RateControlEntry *rce, double qp){
     if(qp<=0.0){
-        fprintf(stderr, "qp<=0.0\n");
+        av_log(NULL, AV_LOG_ERROR, "qp<=0.0\n");
     }
     return rce->qscale * (double)(rce->i_tex_bits + rce->p_tex_bits+1)/ qp;
 }
 
 static inline double bits2qp(RateControlEntry *rce, double bits){
     if(bits<0.9){
-        fprintf(stderr, "bits<0.9\n");
+        av_log(NULL, AV_LOG_ERROR, "bits<0.9\n");
     }
     return rce->qscale * (double)(rce->i_tex_bits + rce->p_tex_bits+1)/ bits;
 }
@@ -213,9 +213,9 @@
         }
         
         if(rcc->buffer_index < 0)
-            fprintf(stderr, "rc buffer underflow\n");
+            av_log(s->avctx, AV_LOG_ERROR, "rc buffer underflow\n");
         if(rcc->buffer_index >= s->avctx->rc_buffer_size)
-            fprintf(stderr, "rc buffer overflow\n");
+            av_log(s->avctx, AV_LOG_ERROR, "rc buffer overflow\n");
     }
 }
 
@@ -667,7 +667,7 @@
     }
 
     if(s->avctx->debug&FF_DEBUG_RC){
-        printf("%c qp:%d<%2.1f<%d %d want:%d total:%d comp:%f st_q:%2.2f size:%d var:%d/%d br:%d fps:%d\n",
+        av_log(s->avctx, AV_LOG_DEBUG, "%c qp:%d<%2.1f<%d %d want:%d total:%d comp:%f st_q:%2.2f size:%d var:%d/%d br:%d fps:%d\n",
         av_get_pict_type_char(pict_type), qmin, q, qmax, picture_number, (int)wanted_bits/1000, (int)s->total_bits/1000,
         br_compensation, short_term_q, s->frame_bits, pic->mb_var_sum, pic->mc_mb_var_sum, s->bit_rate/1000, (int)fps
         );
@@ -732,7 +732,7 @@
     all_const_bits= const_bits[I_TYPE] + const_bits[P_TYPE] + const_bits[B_TYPE];
     
     if(all_available_bits < all_const_bits){
-        fprintf(stderr, "requested bitrate is to low\n");
+        av_log(s->avctx, AV_LOG_ERROR, "requested bitrate is to low\n");
         return -1;
     }
     
@@ -823,7 +823,7 @@
     av_free(blured_qscale);
 
     if(abs(expected_bits/all_available_bits - 1.0) > 0.01 ){
-        fprintf(stderr, "Error: 2pass curve failed to converge\n");
+        av_log(s->avctx, AV_LOG_ERROR, "Error: 2pass curve failed to converge\n");
         return -1;
     }
 
--- a/resample.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/resample.c	Mon Nov 03 13:26:22 2003 +0000
@@ -243,14 +243,14 @@
     
     if ( input_channels > 2)
       {
-	printf("Resampling with input channels greater than 2 unsupported.");
+	av_log(NULL, AV_LOG_ERROR, "Resampling with input channels greater than 2 unsupported.");
 	return NULL;
       }
 
     s = av_mallocz(sizeof(ReSampleContext));
     if (!s)
       {
-	printf("Can't allocate memory for resample context.");
+	av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for resample context.");
 	return NULL;
       }
 
--- a/roqvideo.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/roqvideo.c	Mon Nov 03 13:26:22 2003 +0000
@@ -411,7 +411,7 @@
                     }
                     break;
                 default:
-                    printf("Unknown vq code: %d\n", vqid);
+                    av_log(ri->avctx, AV_LOG_ERROR, "Unknown vq code: %d\n", vqid);
             }
         }
 
@@ -453,7 +453,7 @@
     *data_size = 0;
 
     if (avctx->get_buffer(avctx, &s->current_frame)) {
-        printf ("  RoQ: get_buffer() failed\n");
+        av_log(avctx, AV_LOG_ERROR, "  RoQ: get_buffer() failed\n");
         return -1;
     }
     s->y_stride = s->current_frame.linesize[0];
--- a/rpza.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/rpza.c	Mon Nov 03 13:26:22 2003 +0000
@@ -71,7 +71,7 @@
     total_blocks--; \
     if (total_blocks < 0) \
     { \
-        printf("warning: block counter just went negative (this should not happen)\n"); \
+        av_log(s->avctx, AV_LOG_ERROR, "warning: block counter just went negative (this should not happen)\n"); \
         return; \
     } \
 }
@@ -100,7 +100,7 @@
 
     /* First byte is always 0xe1. Warn if it's different */
     if (s->buf[stream_ptr] != 0xe1)
-        printf("First chunk byte is 0x%02x instead of 0x1e\n",
+        av_log(s->avctx, AV_LOG_ERROR, "First chunk byte is 0x%02x instead of 0x1e\n",
             s->buf[stream_ptr]);
 
     /* Get chunk size, ingnoring first byte */
@@ -109,7 +109,7 @@
 
     /* If length mismatch use size from MOV file and try to decode anyway */
     if (chunk_size != s->size)
-        printf("MOV chunk size != encoded chunk size; using MOV chunk size\n");
+        av_log(s->avctx, AV_LOG_ERROR, "MOV chunk size != encoded chunk size; using MOV chunk size\n");
 
     chunk_size = s->size;
 
@@ -236,7 +236,7 @@
 
         /* Unknown opcode */
         default:
-            printf("Unknown opcode %d in rpza chunk."
+            av_log(s->avctx, AV_LOG_ERROR, "Unknown opcode %d in rpza chunk."
                  " Skip remaining %d bytes of chunk data.\n", opcode,
                  chunk_size - stream_ptr);
             return;
@@ -269,7 +269,7 @@
 
     s->frame.reference = 1;
     if (avctx->get_buffer(avctx, &s->frame)) {
-        printf ("  RPZA Video: get_buffer() failed\n");
+        av_log(avctx, AV_LOG_ERROR, "  RPZA Video: get_buffer() failed\n");
         return -1;
     }
 
--- a/rv10.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/rv10.c	Mon Nov 03 13:26:22 2003 +0000
@@ -216,7 +216,7 @@
                 get_bits(&s->gb, 9);
                 code = 1;
             } else {
-                fprintf(stderr, "chroma dc error\n");
+                av_log(s->avctx, AV_LOG_ERROR, "chroma dc error\n");
                 return 0xffff;
             }
         } else {
@@ -286,7 +286,7 @@
     else
         s->pict_type = I_TYPE;
 //printf("h:%X ver:%d\n",h,s->rv10_version);
-    if(!marker) printf("marker missing\n");
+    if(!marker) av_log(s->avctx, AV_LOG_ERROR, "marker missing\n");
     pb_frame = get_bits(&s->gb, 1);
 
 #ifdef DEBUG
@@ -294,13 +294,13 @@
 #endif
     
     if (pb_frame){
-        fprintf(stderr, "pb frame not supported\n");
+        av_log(s->avctx, AV_LOG_ERROR, "pb frame not supported\n");
         return -1;
     }
 
     s->qscale = get_bits(&s->gb, 5);
     if(s->qscale==0){
-        fprintf(stderr, "error, qscale:0\n");
+        av_log(s->avctx, AV_LOG_ERROR, "error, qscale:0\n");
         return -1;
     }
 
@@ -363,7 +363,7 @@
         s->h263_long_vectors=0;
         break;
     default:
-        fprintf(stderr, "unknown header %X\n", avctx->sub_id);
+        av_log(s->avctx, AV_LOG_ERROR, "unknown header %X\n", avctx->sub_id);
     }
 //printf("ver:%X\n", avctx->sub_id);
     s->flags= avctx->flags;
@@ -411,19 +411,19 @@
     
     mb_count = rv10_decode_picture_header(s);
     if (mb_count < 0) {
-        fprintf(stderr, "HEADER ERROR\n");
+        av_log(s->avctx, AV_LOG_ERROR, "HEADER ERROR\n");
         return -1;
     }
     
     if (s->mb_x >= s->mb_width ||
         s->mb_y >= s->mb_height) {
-        fprintf(stderr, "POS ERROR %d %d\n", s->mb_x, s->mb_y);
+        av_log(s->avctx, AV_LOG_ERROR, "POS ERROR %d %d\n", s->mb_x, s->mb_y);
         return -1;
     }
     mb_pos = s->mb_y * s->mb_width + s->mb_x;
     left = s->mb_width * s->mb_height - mb_pos;
     if (mb_count > left) {
-        fprintf(stderr, "COUNT ERROR\n");
+        av_log(s->avctx, AV_LOG_ERROR, "COUNT ERROR\n");
         return -1;
     }
 
@@ -463,7 +463,7 @@
         s->mv_dir = MV_DIR_FORWARD;
         s->mv_type = MV_TYPE_16X16; 
         if (ff_h263_decode_mb(s, s->block) == SLICE_ERROR) {
-            fprintf(stderr, "ERROR at MB %d %d\n", s->mb_x, s->mb_y);
+            av_log(s->avctx, AV_LOG_ERROR, "ERROR at MB %d %d\n", s->mb_x, s->mb_y);
             return -1;
         }
         ff_h263_update_motion_val(s);
--- a/svq1.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/svq1.c	Mon Nov 03 13:26:22 2003 +0000
@@ -613,7 +613,7 @@
 
       svq1_parse_string (bitbuf, (char *) msg);
 
-      printf ("embedded message: \"%s\"\n", (char *) msg);
+      av_log(s->avctx, AV_LOG_INFO, "embedded message: \"%s\"\n", (char *) msg);
     }
 
     skip_bits (bitbuf, 2);
--- a/svq3.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/svq3.c	Mon Nov 03 13:26:22 2003 +0000
@@ -690,7 +690,7 @@
 
   if (((header & 0x9F) != 1 && (header & 0x9F) != 2) || (header & 0x60) == 0) {
     /* TODO: what? */
-    fprintf (stderr, "unsupported slice header (%02X)\n", header);
+    av_log(h->s.avctx, AV_LOG_ERROR, "unsupported slice header (%02X)\n", header);
     return -1;
   } else {
     int length = (header >> 5) & 3;
@@ -841,7 +841,7 @@
   s->picture_number = h->slice_num;
 
   if(avctx->debug&FF_DEBUG_PICT_INFO){
-      printf("%c hpel:%d, tpel:%d aqp:%d qp:%d\n", 
+      av_log(h->s.avctx, AV_LOG_DEBUG, "%c hpel:%d, tpel:%d aqp:%d qp:%d\n", 
       av_get_pict_type_char(s->pict_type), h->halfpel_flag, h->thirdpel_flag,
       s->adaptive_quant, s->qscale
       );
@@ -874,7 +874,7 @@
       h->frame_num_offset += 256;
     }
     if (h->frame_num_offset == 0 || h->frame_num_offset >= h->prev_frame_num_offset) {
-      printf ("error in B-frame picture id\n");
+      av_log(h->s.avctx, AV_LOG_ERROR, "error in B-frame picture id\n");
       return -1;
     }
   } else {
@@ -920,7 +920,7 @@
 	mb_type += 4;
       }
       if (mb_type > 33 || svq3_decode_mb (h, mb_type)) {
-	fprintf (stderr, "error while decoding MB %d %d\n", s->mb_x, s->mb_y);
+	av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d\n", s->mb_x, s->mb_y);
 	return -1;
       }
 
--- a/utils.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/utils.c	Mon Nov 03 13:26:22 2003 +0000
@@ -1,6 +1,7 @@
 /*
  * utils for libavcodec
  * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2003 Michel Bardiaux for the av_log API
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -25,6 +26,7 @@
 #include "avcodec.h"
 #include "dsputil.h"
 #include "mpegvideo.h"
+#include <stdarg.h>
 
 void *av_mallocz(unsigned int size)
 {
@@ -766,3 +768,52 @@
 
     return ((h/c)<<32) + l/c;
 }
+
+/* av_log API */
+
+#ifdef AV_LOG_TRAP_PRINTF
+#undef stderr
+#undef fprintf
+#endif
+
+static int av_log_level = AV_LOG_DEBUG;
+
+static void av_log_default_callback(AVCodecContext* avctx, int level, const char* fmt, va_list vl)
+{
+    if(level>av_log_level)
+	    return;
+    if(avctx)
+        fprintf(stderr, "[%s @ %p]", avctx->codec->name, avctx);
+    vfprintf(stderr, fmt, vl);
+}
+
+static void (*av_log_callback)(AVCodecContext*, int, const char*, va_list) = av_log_default_callback;
+
+void av_log(AVCodecContext* avctx, int level, const char *fmt, ...)
+{
+    va_list vl;
+    va_start(vl, fmt);
+    av_vlog(avctx, level, fmt, vl);
+    va_end(vl);
+}
+
+void av_vlog(AVCodecContext* avctx, int level, const char *fmt, va_list vl)
+{
+    av_log_callback(avctx, level, fmt, vl);
+}
+
+int av_log_get_level(void)
+{
+    return av_log_level;
+}
+
+void av_log_set_level(int level)
+{
+    av_log_level = level;
+}
+
+void av_log_set_callback(void (*callback)(AVCodecContext*, int, const char*, va_list))
+{
+    av_log_callback = callback;
+}
+
--- a/vcr1.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/vcr1.c	Mon Nov 03 13:26:22 2003 +0000
@@ -57,7 +57,7 @@
 
     p->reference= 0;
     if(avctx->get_buffer(avctx, p) < 0){
-        fprintf(stderr, "get_buffer() failed\n");
+        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
         return -1;
     }
     p->pict_type= I_TYPE;
--- a/vp3.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/vp3.c	Mon Nov 03 13:26:22 2003 +0000
@@ -1109,7 +1109,7 @@
         break;
 
     default:
-        printf ("  vp3: help! Got a bad token: %d > 31\n", token);
+        av_log(NULL, AV_LOG_ERROR, "  vp3: help! Got a bad token: %d > 31\n", token);
         break;
 
   }
@@ -1549,7 +1549,7 @@
             /* if the fragment is in bounds, check its coding status */
             current_fragment = s->superblock_fragments[i * 16 + j];
             if (current_fragment >= s->fragment_count) {
-                printf ("  vp3:unpack_superblocks(): bad fragment number (%d >= %d)\n",
+                av_log(s->avctx, AV_LOG_ERROR, "  vp3:unpack_superblocks(): bad fragment number (%d >= %d)\n",
                     current_fragment, s->fragment_count);
                 return 1;
             }
@@ -1685,7 +1685,7 @@
                     (s->macroblock_coding[current_macroblock] == MODE_COPY))
                     continue;
                 if (current_macroblock >= s->macroblock_count) {
-                    printf ("  vp3:unpack_modes(): bad macroblock number (%d >= %d)\n",
+                    av_log(s->avctx, AV_LOG_ERROR, "  vp3:unpack_modes(): bad macroblock number (%d >= %d)\n",
                         current_macroblock, s->macroblock_count);
                     return 1;
                 }
@@ -1703,7 +1703,7 @@
                     if (current_fragment == -1)
                         continue;
                     if (current_fragment >= s->fragment_count) {
-                        printf ("  vp3:unpack_modes(): bad fragment number (%d >= %d)\n",
+                        av_log(s->avctx, AV_LOG_ERROR, "  vp3:unpack_modes(): bad fragment number (%d >= %d)\n",
                             current_fragment, s->fragment_count);
                         return 1;
                     }
@@ -1764,14 +1764,14 @@
                     (s->macroblock_coding[current_macroblock] == MODE_COPY))
                     continue;
                 if (current_macroblock >= s->macroblock_count) {
-                    printf ("  vp3:unpack_vectors(): bad macroblock number (%d >= %d)\n",
+                    av_log(s->avctx, AV_LOG_ERROR, "  vp3:unpack_vectors(): bad macroblock number (%d >= %d)\n",
                         current_macroblock, s->macroblock_count);
                     return 1;
                 }
 
                 current_fragment = s->macroblock_fragments[current_macroblock * 6];
                 if (current_fragment >= s->fragment_count) {
-                    printf ("  vp3:unpack_vectors(): bad fragment number (%d >= %d\n",
+                    av_log(s->avctx, AV_LOG_ERROR, "  vp3:unpack_vectors(): bad fragment number (%d >= %d\n",
                         current_fragment, s->fragment_count);
                     return 1;
                 }
@@ -1887,7 +1887,7 @@
                     if (current_fragment == -1)
                         continue;
                     if (current_fragment >= s->fragment_count) {
-                        printf ("  vp3:unpack_vectors(): bad fragment number (%d >= %d)\n",
+                        av_log(s->avctx, AV_LOG_ERROR, "  vp3:unpack_vectors(): bad fragment number (%d >= %d)\n",
                             current_fragment, s->fragment_count);
                         return 1;
                     }
@@ -1929,7 +1929,7 @@
     if ((first_fragment >= s->fragment_count) ||
         (last_fragment >= s->fragment_count)) {
 
-        printf ("  vp3:unpack_vlcs(): bad fragment number (%d -> %d ?)\n",
+        av_log(s->avctx, AV_LOG_ERROR, "  vp3:unpack_vlcs(): bad fragment number (%d -> %d ?)\n",
             first_fragment, last_fragment);
         return 0;
     }
@@ -2393,7 +2393,7 @@
         for (x = 0; x < width; x += 8, i++) {
 
             if ((i < 0) || (i >= s->fragment_count)) {
-                printf ("  vp3:render_fragments(): bad fragment number (%d)\n", i);
+                av_log(s->avctx, AV_LOG_ERROR, "  vp3:render_fragments(): bad fragment number (%d)\n", i);
                 return;
             }
 
@@ -2424,7 +2424,7 @@
                     src_x= (motion_x>>1) + x;
                     src_y= (motion_y>>1) + y;
 if ((motion_x == 0xbeef) || (motion_y == 0xbeef))
-printf (" help! got beefy vector! (%X, %X)\n", motion_x, motion_y);
+av_log(s->avctx, AV_LOG_ERROR, " help! got beefy vector! (%X, %X)\n", motion_x, motion_y);
 
                     motion_halfpel_index = motion_x & 0x01;
                     motion_source += (motion_x >> 1);
@@ -2704,7 +2704,7 @@
     
     if (s->theora && get_bits1(&gb))
     {
-	printf("Theora: bad frame indicator\n");
+	av_log(s->avctx, AV_LOG_ERROR, "Theora: bad frame indicator\n");
 	return -1;
     }
 
@@ -2712,7 +2712,7 @@
     if (s->theora && s->keyframe)
     {
 	if (get_bits1(&gb))
-	    printf("Theora: warning, unsupported keyframe coding type?!\n");
+	    av_log(s->avctx, AV_LOG_ERROR, "Theora: warning, unsupported keyframe coding type?!\n");
 	skip_bits(&gb, 2); /* reserved? */
     }
     else
@@ -2743,7 +2743,7 @@
 
         s->golden_frame.reference = 3;
         if(avctx->get_buffer(avctx, &s->golden_frame) < 0) {
-            printf("vp3: get_buffer() failed\n");
+            av_log(s->avctx, AV_LOG_ERROR, "vp3: get_buffer() failed\n");
             return -1;
         }
 
@@ -2758,7 +2758,7 @@
         /* allocate a new current frame */
         s->current_frame.reference = 3;
         if(avctx->get_buffer(avctx, &s->current_frame) < 0) {
-            printf("vp3: get_buffer() failed\n");
+            av_log(s->avctx, AV_LOG_ERROR, "vp3: get_buffer() failed\n");
             return -1;
         }
     }
@@ -2786,7 +2786,7 @@
         unpack_vectors(s, &gb) ||
         unpack_dct_coeffs(s, &gb)) {
 
-        printf("  vp3: could not decode frame\n");
+        av_log(s->avctx, AV_LOG_ERROR, "  vp3: could not decode frame\n");
         return -1;
     }
 
--- a/vqavideo.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/vqavideo.c	Mon Nov 03 13:26:22 2003 +0000
@@ -155,7 +155,7 @@
 
     /* make sure the extradata made it */
     if (s->avctx->extradata_size != VQA_HEADER_SIZE) {
-        printf("  VQA video: expected extradata size of %d\n", VQA_HEADER_SIZE);
+        av_log(s->avctx, AV_LOG_ERROR, "  VQA video: expected extradata size of %d\n", VQA_HEADER_SIZE);
         return -1;
     }
 
@@ -206,8 +206,8 @@
 
 #define CHECK_COUNT() \
     if (dest_index + count > dest_size) { \
-        printf ("  VQA video: decode_format80 problem: next op would overflow dest_index\n"); \
-        printf ("  VQA video: current dest_index = %d, count = %d, dest_size = %d\n", \
+        av_log(NULL, AV_LOG_ERROR, "  VQA video: decode_format80 problem: next op would overflow dest_index\n"); \
+        av_log(NULL, AV_LOG_ERROR, "  VQA video: current dest_index = %d, count = %d, dest_size = %d\n", \
             dest_index, count, dest_size); \
         return; \
     }
@@ -231,7 +231,7 @@
             return;
 
         if (dest_index >= dest_size) {
-            printf ("  VQA video: decode_format80 problem: dest_index (%d) exceeded dest_size (%d)\n",
+            av_log(NULL, AV_LOG_ERROR, "  VQA video: decode_format80 problem: dest_index (%d) exceeded dest_size (%d)\n",
                 dest_index, dest_size);
             return;
         }
@@ -299,7 +299,7 @@
      * not every entry needs to be filled */
     if (check_size)
         if (dest_index < dest_size)
-            printf ("  VQA video: decode_format80 problem: decode finished with dest_index (%d) < dest_size (%d)\n",
+            av_log(NULL, AV_LOG_ERROR, "  VQA video: decode_format80 problem: decode finished with dest_index (%d) < dest_size (%d)\n",
                 dest_index, dest_size);
 }
 
@@ -367,7 +367,7 @@
             break;
 
         default:
-            printf ("  VQA video: Found unknown chunk type: %c%c%c%c (%08X)\n",
+            av_log(s->avctx, AV_LOG_ERROR, "  VQA video: Found unknown chunk type: %c%c%c%c (%08X)\n",
             (chunk_type >> 24) & 0xFF,
             (chunk_type >> 16) & 0xFF,
             (chunk_type >>  8) & 0xFF,
@@ -384,7 +384,7 @@
     if ((cpl0_chunk != -1) && (cplz_chunk != -1)) {
 
         /* a chunk should not have both chunk types */
-        printf ("  VQA video: problem: found both CPL0 and CPLZ chunks\n");
+        av_log(s->avctx, AV_LOG_ERROR, "  VQA video: problem: found both CPL0 and CPLZ chunks\n");
         return;
     }
 
@@ -401,7 +401,7 @@
         chunk_size = BE_32(&s->buf[cpl0_chunk + 4]);
         /* sanity check the palette size */
         if (chunk_size / 3 > 256) {
-            printf ("  VQA video: problem: found a palette chunk with %d colors\n",
+            av_log(s->avctx, AV_LOG_ERROR, "  VQA video: problem: found a palette chunk with %d colors\n",
                 chunk_size / 3);
             return;
         }
@@ -419,7 +419,7 @@
     if ((cbf0_chunk != -1) && (cbfz_chunk != -1)) {
 
         /* a chunk should not have both chunk types */
-        printf ("  VQA video: problem: found both CBF0 and CBFZ chunks\n");
+        av_log(s->avctx, AV_LOG_ERROR, "  VQA video: problem: found both CBF0 and CBFZ chunks\n");
         return;
     }
 
@@ -438,7 +438,7 @@
         chunk_size = BE_32(&s->buf[cbf0_chunk + 4]);
         /* sanity check the full codebook size */
         if (chunk_size > MAX_CODEBOOK_SIZE) {
-            printf ("  VQA video: problem: CBF0 chunk too large (0x%X bytes)\n",
+            av_log(s->avctx, AV_LOG_ERROR, "  VQA video: problem: CBF0 chunk too large (0x%X bytes)\n",
                 chunk_size);
             return;
         }
@@ -451,7 +451,7 @@
     if (vptz_chunk == -1) {
 
         /* something is wrong if there is no VPTZ chunk */
-        printf ("  VQA video: problem: no VPTZ chunk found\n");
+        av_log(s->avctx, AV_LOG_ERROR, "  VQA video: problem: no VPTZ chunk found\n");
         return;
     }
 
@@ -508,7 +508,7 @@
     /* handle partial codebook */
     if ((cbp0_chunk != -1) && (cbpz_chunk != -1)) {
         /* a chunk should not have both chunk types */
-        printf ("  VQA video: problem: found both CBP0 and CBPZ chunks\n");
+        av_log(s->avctx, AV_LOG_ERROR, "  VQA video: problem: found both CBP0 and CBPZ chunks\n");
         return;
     }
 
@@ -573,7 +573,7 @@
         avctx->release_buffer(avctx, &s->frame);
 
     if (avctx->get_buffer(avctx, &s->frame)) {
-        printf ("  VQA Video: get_buffer() failed\n");
+        av_log(s->avctx, AV_LOG_ERROR, "  VQA Video: get_buffer() failed\n");
         return -1;
     }
 
--- a/wmv2.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/wmv2.c	Mon Nov 03 13:26:22 2003 +0000
@@ -338,7 +338,7 @@
     s->slice_height = s->mb_height / code;
 
     if(s->avctx->debug&FF_DEBUG_PICT_INFO){
-        printf("fps:%d, br:%d, qpbit:%d, abt_flag:%d, j_type_bit:%d, tl_mv_flag:%d, mbrl_bit:%d, code:%d, flag3:%d, slices:%d\n", 
+        av_log(s->avctx, AV_LOG_DEBUG, "fps:%d, br:%d, qpbit:%d, abt_flag:%d, j_type_bit:%d, tl_mv_flag:%d, mbrl_bit:%d, code:%d, flag3:%d, slices:%d\n", 
         fps, s->bit_rate, w->mspel_bit, w->abt_flag, w->j_type_bit, w->top_left_mv_flag, w->per_mb_rl_bit, code, w->flag3, 
         code);
     }
@@ -366,7 +366,7 @@
     s->pict_type = get_bits(&s->gb, 1) + 1;
     if(s->pict_type == I_TYPE){
         code = get_bits(&s->gb, 7);
-        printf("I7:%X/\n", code);
+        av_log(s->avctx, AV_LOG_ERROR, "I7:%X/\n", code);
     }
     s->qscale = get_bits(&s->gb, 5);
     if(s->qscale < 0)
@@ -397,7 +397,7 @@
         s->inter_intra_pred= 0;
         s->no_rounding = 1;
         if(s->avctx->debug&FF_DEBUG_PICT_INFO){
-	    printf("qscale:%d rlc:%d rl:%d dc:%d mbrl:%d j_type:%d \n", 
+	    av_log(s->avctx, AV_LOG_DEBUG, "qscale:%d rlc:%d rl:%d dc:%d mbrl:%d j_type:%d \n", 
 		s->qscale,
 		s->rl_chroma_table_index,
 		s->rl_table_index, 
@@ -447,7 +447,7 @@
         s->no_rounding ^= 1;
         
         if(s->avctx->debug&FF_DEBUG_PICT_INFO){
-            printf("rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d mspel:%d per_mb_abt:%d abt_type:%d cbp:%d ii:%d\n", 
+            av_log(s->avctx, AV_LOG_DEBUG, "rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d mspel:%d per_mb_abt:%d abt_type:%d cbp:%d ii:%d\n", 
 		s->rl_table_index, 
 		s->rl_chroma_table_index, 
 		s->dc_table_index,
@@ -471,7 +471,7 @@
 //        return wmv2_decode_j_picture(w); //FIXME
 
     if(w->j_type){
-        printf("J-type picture isnt supported\n");
+        av_log(s->avctx, AV_LOG_ERROR, "J-type picture isnt supported\n");
         return -1;
     }
 
@@ -604,7 +604,7 @@
         memset(w->abt_block2[n], 0, 64*sizeof(DCTELEM));
         break;
     default:
-        fprintf(stderr, "internal error in WMV2 abt\n");
+        av_log(s->avctx, AV_LOG_ERROR, "internal error in WMV2 abt\n");
     }
 }
 
@@ -738,7 +738,7 @@
         s->mb_intra = 1;
         code = get_vlc2(&s->gb, mb_intra_vlc.table, MB_INTRA_VLC_BITS, 2);
         if (code < 0){
-            fprintf(stderr, "II-cbp illegal at %d %d\n", s->mb_x, s->mb_y);
+            av_log(s->avctx, AV_LOG_ERROR, "II-cbp illegal at %d %d\n", s->mb_x, s->mb_y);
             return -1;
         }
         /* predict coded block pattern */
@@ -784,7 +784,7 @@
         for (i = 0; i < 6; i++) {
             if (wmv2_decode_inter_block(w, block[i], i, (cbp >> (5 - i)) & 1) < 0)
 	    {
-	        fprintf(stderr,"\nerror while decoding inter block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
+	        av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding inter block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
 	        return -1;
 	    }
         }    
@@ -805,7 +805,7 @@
         for (i = 0; i < 6; i++) {
             if (msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
 	    {
-	        fprintf(stderr,"\nerror while decoding intra block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
+	        av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding intra block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
 	        return -1;
 	    }
         }    
--- a/xan.c	Sun Nov 02 23:19:47 2003 +0000
+++ b/xan.c	Mon Nov 03 13:26:22 2003 +0000
@@ -116,7 +116,7 @@
 
     if ((avctx->codec->id == CODEC_ID_XAN_WC3) && 
         (s->avctx->palctrl == NULL)) {
-        printf (" WC3 Xan video: palette expected.\n");
+        av_log(avctx, AV_LOG_ERROR, " WC3 Xan video: palette expected.\n");
         return -1;
     }
 
@@ -336,7 +336,7 @@
         break;
 
     default:
-        printf (" Xan WC3: Unhandled colorspace\n");
+        av_log(s->avctx, AV_LOG_ERROR, " Xan WC3: Unhandled colorspace\n");
         break;
     }
 }
@@ -457,7 +457,7 @@
         break;
 
     default:
-        printf (" Xan WC3: Unhandled colorspace\n");
+        av_log(s->avctx, AV_LOG_ERROR, " Xan WC3: Unhandled colorspace\n");
         break;
     }
 }
@@ -600,7 +600,7 @@
         break;
 
     default:
-        printf (" Xan WC3: Unhandled colorspace\n");
+        av_log(s->avctx, AV_LOG_ERROR, " Xan WC3: Unhandled colorspace\n");
         break;
     }
 }
@@ -761,7 +761,7 @@
     }
 
     if (avctx->get_buffer(avctx, &s->current_frame)) {
-        printf ("  Xan Video: get_buffer() failed\n");
+        av_log(s->avctx, AV_LOG_ERROR, "  Xan Video: get_buffer() failed\n");
         return -1;
     }
     s->current_frame.reference = 3;