changeset 370:845f9de2c883 libavformat

av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
author michael
date Wed, 03 Mar 2004 15:41:21 +0000
parents b2a0f47067ed
children b0e50e10472c
files asf.c audio.c avformat.h dv.c dv1394.c flvdec.c grab.c idroq.c mov.c mpeg.c nut.c psxstr.c rm.c rtp.c rtsp.c swf.c utils.c wc3movie.c westwood.c yuv4mpeg.c
diffstat 20 files changed, 89 insertions(+), 66 deletions(-) [+]
line wrap: on
line diff
--- a/asf.c	Wed Feb 25 17:35:52 2004 +0000
+++ b/asf.c	Wed Mar 03 15:41:21 2004 +0000
@@ -1070,12 +1070,12 @@
     c = get_byte(pb);
     if (c != 0x82) {
         if (!url_feof(pb))
-	    printf("ff asf bad header %x  at:%lld\n", c, url_ftell(pb));
+	    av_log(s, AV_LOG_ERROR, "ff asf bad header %x  at:%lld\n", c, url_ftell(pb));
     }
     if ((c & 0x0f) == 2) { // always true for now
 	if (get_le16(pb) != 0) {
             if (!url_feof(pb))
-		printf("ff asf bad non zero\n");
+		av_log(s, AV_LOG_ERROR, "ff asf bad non zero\n");
 	    return -EIO;
 	}
         rsize+=2;
@@ -1190,7 +1190,7 @@
 		/* unhandled packet (should not happen) */
 		url_fskip(pb, asf->packet_frag_size);
 		asf->packet_size_left -= asf->packet_frag_size;
-		printf("ff asf skip %d  %d\n", asf->packet_frag_size, num & 0x7f);
+		av_log(s, AV_LOG_ERROR, "ff asf skip %d  %d\n", asf->packet_frag_size, num & 0x7f);
                 continue;
 	    }
 	    asf->asf_st = s->streams[asf->stream_index]->priv_data;
@@ -1203,7 +1203,7 @@
 	   ) {
 	    /* cannot continue current packet: free it */
 	    // FIXME better check if packet was already allocated
-	    printf("ff asf parser skips: %d - %d     o:%d - %d    %d %d   fl:%d\n",
+	    av_log(s, AV_LOG_INFO, "ff asf parser skips: %d - %d     o:%d - %d    %d %d   fl:%d\n",
 		   asf_st->pkt.size,
 		   asf->packet_obj_size,
 		   asf->packet_frag_offset, asf_st->frag_offset,
@@ -1213,7 +1213,7 @@
 	    asf_st->frag_offset = 0;
 	    if (asf->packet_frag_offset != 0) {
 		url_fskip(pb, asf->packet_frag_size);
-		printf("ff asf parser skiping %db\n", asf->packet_frag_size);
+		av_log(s, AV_LOG_INFO, "ff asf parser skiping %db\n", asf->packet_frag_size);
 		asf->packet_size_left -= asf->packet_frag_size;
 		continue;
 	    }
@@ -1367,7 +1367,7 @@
     asf_reset_header(s);
     for(;;){
         if (av_read_frame(s, pkt) < 0){
-            printf("seek failed\n");
+            av_log(s, AV_LOG_INFO, "seek failed\n");
     	    return AV_NOPTS_VALUE;
         }
         pts= pkt->pts;
--- a/audio.c	Wed Feb 25 17:35:52 2004 +0000
+++ b/audio.c	Wed Mar 03 15:41:21 2004 +0000
@@ -106,7 +106,7 @@
         s->codec_id = CODEC_ID_PCM_S16BE;
         break;
     default:
-        fprintf(stderr, "Soundcard does not support 16 bit sample format\n");
+        av_log(NULL, AV_LOG_ERROR, "Soundcard does not support 16 bit sample format\n");
         close(audio_fd);
         return -EIO;
     }
--- a/avformat.h	Wed Feb 25 17:35:52 2004 +0000
+++ b/avformat.h	Wed Mar 03 15:41:21 2004 +0000
@@ -241,6 +241,7 @@
 
 /* format I/O context */
 typedef struct AVFormatContext {
+    AVClass class; /* set by av_alloc_format_context */
     /* can only be iformat or oformat, not both at the same time */
     struct AVInputFormat *iformat;
     struct AVOutputFormat *oformat;
@@ -523,6 +524,8 @@
                        AVInputFormat *fmt,
                        int buf_size,
                        AVFormatParameters *ap);
+/* no av_open for output, so applications will need this: */
+AVFormatContext *av_alloc_format_context(void);
 
 #define AVERROR_UNKNOWN     (-1)  /* unknown error */
 #define AVERROR_IO          (-2)  /* i/o error */
--- a/dv.c	Wed Feb 25 17:35:52 2004 +0000
+++ b/dv.c	Wed Mar 03 15:41:21 2004 +0000
@@ -610,7 +610,7 @@
     if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
         /* FIXME: we have to have more sensible approach than this one */
 	if (c->has_video)
-	    fprintf(stderr, "Can't process DV frame #%d. Insufficient audio data or severe sync problem.\n", c->frames);
+	    av_log(&st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient audio data or severe sync problem.\n", c->frames);
 	    
         dv_inject_video(c, data, *frame);
 	c->has_video = 1;
@@ -635,7 +635,7 @@
     
         /* FIXME: we have to have more sensible approach than this one */
         if (fifo_size(&c->audio_data, c->audio_data.rptr) + data_size >= 100*AVCODEC_MAX_AUDIO_FRAME_SIZE)
-	    fprintf(stderr, "Can't process DV frame #%d. Insufficient video data or severe sync problem.\n", c->frames);
+	    av_log(&st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient video data or severe sync problem.\n", c->frames);
 	fifo_write(&c->audio_data, (uint8_t *)data, data_size, &c->audio_data.wptr);
     }
 
@@ -848,7 +848,7 @@
 {
     s->priv_data = dv_init_mux(s);
     if (!s->priv_data) {
-        fprintf(stderr, "Can't initialize DV format!\n"
+        av_log(s, AV_LOG_ERROR, "Can't initialize DV format!\n"
 		    "Make sure that you supply exactly two streams:\n"
 		    "     video: 25fps or 29.97fps, audio: 2ch/48Khz/PCM\n");
 	return -1;
--- a/dv1394.c	Wed Feb 25 17:35:52 2004 +0000
+++ b/dv1394.c	Wed Mar 03 15:41:21 2004 +0000
@@ -153,7 +153,7 @@
                  * We have to reset :(.
                  */
   
-                fprintf(stderr, "DV1394: Ring buffer overflow. Reseting ..\n");
+                av_log(context, AV_LOG_ERROR, "DV1394: Ring buffer overflow. Reseting ..\n");
  
                 dv1394_reset(dv);
                 dv1394_start(dv);
@@ -191,7 +191,7 @@
         dv->done  = 0;
 
         if (s.dropped_frames) {
-            fprintf(stderr, "DV1394: Frame drop detected (%d). Reseting ..\n",
+            av_log(context, AV_LOG_ERROR, "DV1394: Frame drop detected (%d). Reseting ..\n",
                     s.dropped_frames);
 
             dv1394_reset(dv);
--- a/flvdec.c	Wed Feb 25 17:35:52 2004 +0000
+++ b/flvdec.c	Wed Mar 03 15:41:21 2004 +0000
@@ -102,7 +102,7 @@
     } else {
     skip:
         /* skip packet */
-        printf("skipping flv packet: type %d, size %d, flags %d\n", type, size, flags);
+        av_log(s, AV_LOG_ERROR, "skipping flv packet: type %d, size %d, flags %d\n", type, size, flags);
         url_fskip(&s->pb, size);
         goto redo;
     }
--- a/grab.c	Wed Feb 25 17:35:52 2004 +0000
+++ b/grab.c	Wed Mar 03 15:41:21 2004 +0000
@@ -99,7 +99,7 @@
     }
 
     if (!(s->video_cap.type & VID_TYPE_CAPTURE)) {
-        fprintf(stderr, "Fatal: grab device does not handle capture\n");
+	av_log(s1, AV_LOG_ERROR, "Fatal: grab device does not handle capture\n");
         goto fail;
     }
 
@@ -223,9 +223,9 @@
         if (ret < 0) {
             if (errno != EAGAIN) {
             fail1:
-                fprintf(stderr, "Fatal: grab device does not support suitable format\n");
+                av_log(s1, AV_LOG_ERROR, "Fatal: grab device does not support suitable format\n");
             } else {
-                fprintf(stderr,"Fatal: grab device does not receive any video signal\n");
+                av_log(s1, AV_LOG_ERROR,"Fatal: grab device does not receive any video signal\n");
             }
             goto fail;
         }
@@ -277,7 +277,7 @@
     s->gb_buf.frame = (s->gb_frame + 1) % s->gb_buffers.frames;
     if (ioctl(s->fd, VIDIOCMCAPTURE, &s->gb_buf) < 0) {
         if (errno == EAGAIN)
-            fprintf(stderr,"Cannot Sync\n");
+            av_log(NULL, AV_LOG_ERROR, "Cannot Sync\n");
         else
             perror("VIDIOCMCAPTURE");
         return -EIO;
@@ -387,8 +387,8 @@
         if (height == s->video_cap.maxheight*2) s->deint=1;
         if (width == s->video_cap.maxwidth/2) s->halfw=1;
     } else {
-        fprintf(stderr,"\nIncorrect Grab Size Supplied - Supported Sizes Are:\n");
-        fprintf(stderr," %dx%d  %dx%d %dx%d\n\n",
+        av_log(NULL, AV_LOG_ERROR, "\nIncorrect Grab Size Supplied - Supported Sizes Are:\n");
+        av_log(NULL, AV_LOG_ERROR, " %dx%d  %dx%d %dx%d\n\n",
                 s->video_cap.maxwidth,s->video_cap.maxheight,
                 s->video_cap.maxwidth,s->video_cap.maxheight*2,
                 s->video_cap.maxwidth/2,s->video_cap.maxheight);
--- a/idroq.c	Wed Feb 25 17:35:52 2004 +0000
+++ b/idroq.c	Wed Mar 03 15:41:21 2004 +0000
@@ -135,7 +135,7 @@
             break;
 
         default:
-            printf (" unknown RoQ chunk type (%04X)\n", LE_16(&preamble[0]));
+            av_log(s, AV_LOG_ERROR, " unknown RoQ chunk type (%04X)\n", LE_16(&preamble[0]));
             return AVERROR_INVALIDDATA;
             break;
         }
@@ -268,7 +268,7 @@
             break;
 
         default:
-            printf ("  unknown RoQ chunk (%04X)\n", chunk_type);
+            av_log(s, AV_LOG_ERROR, "  unknown RoQ chunk (%04X)\n", chunk_type);
             return AVERROR_INVALIDDATA;
             break;
         }
--- a/mov.c	Wed Feb 25 17:35:52 2004 +0000
+++ b/mov.c	Wed Mar 03 15:41:21 2004 +0000
@@ -1531,7 +1531,7 @@
     /* check MOV header */
     err = mov_read_default(mov, pb, atom);
     if (err<0 || (!mov->found_moov && !mov->found_mdat)) {
-	fprintf(stderr, "mov: header not found !!! (err:%d, moov:%d, mdat:%d) pos:%lld\n",
+	av_log(s, AV_LOG_ERROR, "mov: header not found !!! (err:%d, moov:%d, mdat:%d) pos:%lld\n",
 		err, mov->found_moov, mov->found_mdat, url_ftell(pb));
 	return -1;
     }
--- a/mpeg.c	Wed Feb 25 17:35:52 2004 +0000
+++ b/mpeg.c	Wed Mar 03 15:41:21 2004 +0000
@@ -773,7 +773,7 @@
             }
         }
 #if 1
-        printf("pts=%0.3f dts=%0.3f pict_type=%c\n", 
+        av_log(&st->codec, AV_LOG_DEBUG, "pts=%0.3f dts=%0.3f pict_type=%c\n", 
                pts / 90000.0, dts / 90000.0, 
                av_get_pict_type_char(st->codec.coded_frame->pict_type));
 #endif
--- a/nut.c	Wed Feb 25 17:35:52 2004 +0000
+++ b/nut.c	Wed Mar 03 15:41:21 2004 +0000
@@ -456,12 +456,12 @@
     /* main header */
     tmp = get_be64(bc);
     if (tmp != MAIN_STARTCODE)
-	fprintf(stderr, "damaged? startcode!=1 (%Ld)\n", tmp);
+	av_log(s, AV_LOG_ERROR, "damaged? startcode!=1 (%Ld)\n", tmp);
     get_packetheader(nut, bc);
     
     tmp = get_v(bc);
     if (tmp != 0)
-	fprintf(stderr, "bad version (%Ld)\n", tmp);
+	av_log(s, AV_LOG_ERROR, "bad version (%Ld)\n", tmp);
     
     nb_streams = get_v(bc);
     get_be32(bc); /* checkusm */
@@ -481,7 +481,7 @@
 	
 	tmp = get_be64(bc);
 	if (tmp != STREAM_STARTCODE)
-	    fprintf(stderr, "damaged? startcode!=1 (%Ld)\n", tmp);
+	    av_log(s, AV_LOG_ERROR, "damaged? startcode!=1 (%Ld)\n", tmp);
 	get_packetheader(nut, bc);
 	st = av_new_stream(s, get_v(bc));
 	if (!st)
@@ -494,16 +494,16 @@
 		st->codec.codec_type = CODEC_TYPE_VIDEO;
 		st->codec.codec_id = codec_get_bmp_id(tmp);
 		if (st->codec.codec_id == CODEC_ID_NONE)
-		    fprintf(stderr, "Unknown codec?!\n");
+		    av_log(s, AV_LOG_ERROR, "Unknown codec?!\n");
 		break;
 	    case 32:
 		st->codec.codec_type = CODEC_TYPE_AUDIO;
 		st->codec.codec_id = codec_get_wav_id(tmp);
 		if (st->codec.codec_id == CODEC_ID_NONE)
-		    fprintf(stderr, "Unknown codec?!\n");
+		    av_log(s, AV_LOG_ERROR, "Unknown codec?!\n");
 		break;
 	    default:
-		fprintf(stderr, "Unknown stream class (%d)\n", class);
+		av_log(s, AV_LOG_ERROR, "Unknown stream class (%d)\n", class);
 		return -1;
 	}
 	s->bit_rate += get_v(bc);
@@ -565,12 +565,12 @@
 	    tmp = get_byte(bc); /* flags */
 	}
 	else
-	    fprintf(stderr, "error in zero bit / startcode %LX\n", tmp);
+	    av_log(s, AV_LOG_ERROR, "error in zero bit / startcode %LX\n", tmp);
     }
     get_packetheader(nut, bc);
 #if 0
     if (((tmp & 0x60)>>5) > 3) /* priority <= 3 */
-	fprintf(stderr, "sanity check failed!\n");
+	av_log(s, AV_LOG_ERROR, "sanity check failed!\n");
 #endif
     id = get_v(bc);
     if ((tmp & 0x8) >> 3)
--- a/psxstr.c	Wed Feb 25 17:35:52 2004 +0000
+++ b/psxstr.c	Wed Mar 03 15:41:21 2004 +0000
@@ -123,11 +123,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_DEBUG, "\n");
 }
 
 static int str_read_header(AVFormatContext *s,
@@ -239,11 +239,11 @@
     }
 
 if (str->video_channel != -1)
-  printf (" video channel = %d, %d x %d %d\n", str->video_channel,
+  av_log (s, AV_LOG_DEBUG, " video channel = %d, %d x %d %d\n", str->video_channel,
     str->channels[str->video_channel].width,
     str->channels[str->video_channel].height,str->channels[str->video_channel].video_stream_index);
 if (str->audio_channel != -1)
-  printf (" audio channel = %d, %d Hz, %d channels, %d bits/sample %d\n", 
+   av_log (s, AV_LOG_DEBUG, " audio channel = %d, %d Hz, %d channels, %d bits/sample %d\n", 
     str->audio_channel,
     str->channels[str->audio_channel].sample_rate,
     str->channels[str->audio_channel].channels,
--- a/rm.c	Wed Feb 25 17:35:52 2004 +0000
+++ b/rm.c	Wed Mar 03 15:41:21 2004 +0000
@@ -636,7 +636,7 @@
             } else {
                 if (get_le32(pb) != MKTAG('V', 'I', 'D', 'O')) {
                 fail1:
-                    fprintf(stderr, "Unsupported video codec\n");
+                    av_log(&st->codec, AV_LOG_ERROR, "Unsupported video codec\n");
                     goto fail;
                 }
                 st->codec.codec_tag = get_le32(pb);
--- a/rtp.c	Wed Feb 25 17:35:52 2004 +0000
+++ b/rtp.c	Wed Mar 03 15:41:21 2004 +0000
@@ -301,7 +301,7 @@
         return -1;
 #if defined(DEBUG) || 1
     if (seq != ((s->seq + 1) & 0xffff)) {
-        printf("RTP: PT=%02x: bad cseq %04x expected=%04x\n", 
+        av_log(&s->st->codec, AV_LOG_ERROR, "RTP: PT=%02x: bad cseq %04x expected=%04x\n", 
                payload_type, seq, ((s->seq + 1) & 0xffff));
     }
     s->seq = seq;
--- a/rtsp.c	Wed Feb 25 17:35:52 2004 +0000
+++ b/rtsp.c	Wed Mar 03 15:41:21 2004 +0000
@@ -1050,7 +1050,7 @@
     RTSPHeader reply1, *reply = &reply1;
     char cmd[1024];
 
-    printf("hello state=%d\n", rt->state);
+    av_log(s, AV_LOG_DEBUG, "hello state=%d\n", rt->state);
 
     if (rt->state == RTSP_STATE_PAUSED) {
         snprintf(cmd, sizeof(cmd), 
--- a/swf.c	Wed Feb 25 17:35:52 2004 +0000
+++ b/swf.c	Wed Mar 03 15:41:21 2004 +0000
@@ -341,7 +341,7 @@
             if ( enc->codec_id == CODEC_ID_FLV1 || enc->codec_id == CODEC_ID_MJPEG ) {
                 video_enc = enc;
             } else {
-                fprintf(stderr, "SWF only supports FLV1 and MJPEG\n");
+                av_log(enc, AV_LOG_ERROR, "SWF only supports FLV1 and MJPEG\n");
                 return -1;
             }
         }
@@ -479,7 +479,7 @@
     
     /* Flash Player limit */
     if ( swf->swf_frame_number == 16000 ) {
-        fprintf(stderr, "warning: Flash Player limit of 16000 frames reached\n");
+        av_log(enc, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
     }
 
     /* Store video data in queue */
@@ -680,7 +680,7 @@
 
     /* Flash Player limit */
     if ( swf->swf_frame_number == 16000 ) {
-        fprintf(stderr, "warning: Flash Player limit of 16000 frames reached\n");
+        av_log(enc, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
     }
 
     if (enc->codec_id == CODEC_ID_MP3 ) {
@@ -825,7 +825,7 @@
                 }
                 break;
             }
-            fprintf(stderr, "No media found in SWF\n");
+            av_log(s, AV_LOG_ERROR, "No media found in SWF\n");
             return -EIO;
         }
         if ( tag == TAG_VIDEOSTREAM && !vst) {
--- a/utils.c	Wed Feb 25 17:35:52 2004 +0000
+++ b/utils.c	Wed Mar 03 15:41:21 2004 +0000
@@ -300,6 +300,26 @@
 /**
  * open a media file from an IO stream. 'fmt' must be specified.
  */
+
+static const char* format_to_name(void* class_ptr)
+{
+    AVFormatContext* fc = (AVFormatContext*) class_ptr;
+    if(fc->iformat) return fc->iformat->name;
+    else if(fc->oformat) return fc->oformat->name;
+    else return "NULL";
+}
+
+static const AVClass av_format_context_class = { "AVFormatContext", format_to_name };
+
+AVFormatContext *av_alloc_format_context(void)
+{
+    AVFormatContext *ic;
+    ic = av_mallocz(sizeof(AVFormatContext));
+    if (!ic) return ic;
+    ic->class = av_format_context_class;
+    return ic;
+}
+
 int av_open_input_stream(AVFormatContext **ic_ptr, 
                          ByteIOContext *pb, const char *filename, 
                          AVInputFormat *fmt, AVFormatParameters *ap)
@@ -307,7 +327,7 @@
     int err;
     AVFormatContext *ic;
 
-    ic = av_mallocz(sizeof(AVFormatContext));
+    ic = av_alloc_format_context();
     if (!ic) {
         err = AVERROR_NOMEM;
         goto fail;
@@ -1725,13 +1745,13 @@
     int i, flags;
     char buf[256];
 
-    fprintf(stderr, "%s #%d, %s, %s '%s':\n", 
+    av_log(ic, AV_LOG_DEBUG, "%s #%d, %s, %s '%s':\n", 
             is_output ? "Output" : "Input",
             index, 
             is_output ? ic->oformat->name : ic->iformat->name, 
             is_output ? "to" : "from", url);
     if (!is_output) {
-        fprintf(stderr, "  Duration: ");
+        av_log(ic, AV_LOG_DEBUG, "  Duration: ");
         if (ic->duration != AV_NOPTS_VALUE) {
             int hours, mins, secs, us;
             secs = ic->duration / AV_TIME_BASE;
@@ -1740,23 +1760,23 @@
             secs %= 60;
             hours = mins / 60;
             mins %= 60;
-            fprintf(stderr, "%02d:%02d:%02d.%01d", hours, mins, secs, 
+            av_log(ic, AV_LOG_DEBUG, "%02d:%02d:%02d.%01d", hours, mins, secs, 
                    (10 * us) / AV_TIME_BASE);
         } else {
-            fprintf(stderr, "N/A");
+            av_log(ic, AV_LOG_DEBUG, "N/A");
         }
-        fprintf(stderr, ", bitrate: ");
+        av_log(ic, AV_LOG_DEBUG, ", bitrate: ");
         if (ic->bit_rate) {
-            fprintf(stderr,"%d kb/s", ic->bit_rate / 1000);
+            av_log(ic, AV_LOG_DEBUG,"%d kb/s", ic->bit_rate / 1000);
         } else {
-            fprintf(stderr, "N/A");
+            av_log(ic, AV_LOG_DEBUG, "N/A");
         }
-        fprintf(stderr, "\n");
+        av_log(ic, AV_LOG_DEBUG, "\n");
     }
     for(i=0;i<ic->nb_streams;i++) {
         AVStream *st = ic->streams[i];
         avcodec_string(buf, sizeof(buf), &st->codec, is_output);
-        fprintf(stderr, "  Stream #%d.%d", index, i);
+        av_log(ic, AV_LOG_DEBUG, "  Stream #%d.%d", index, i);
         /* the pid is an important information, so we display it */
         /* XXX: add a generic system */
         if (is_output)
@@ -1764,9 +1784,9 @@
         else
             flags = ic->iformat->flags;
         if (flags & AVFMT_SHOW_IDS) {
-            fprintf(stderr, "[0x%x]", st->id);
+            av_log(ic, AV_LOG_DEBUG, "[0x%x]", st->id);
         }
-        fprintf(stderr, ": %s\n", buf);
+        av_log(ic, AV_LOG_DEBUG, ": %s\n", buf);
     }
 }
 
--- a/wc3movie.c	Wed Feb 25 17:35:52 2004 +0000
+++ b/wc3movie.c	Wed Mar 03 15:41:21 2004 +0000
@@ -230,7 +230,7 @@
             break;
 
         default:
-            printf ("  unrecognized WC3 chunk: %c%c%c%c (0x%02X%02X%02X%02X)\n",
+            av_log(s, AV_LOG_ERROR, "  unrecognized WC3 chunk: %c%c%c%c (0x%02X%02X%02X%02X)\n",
                 preamble[0], preamble[1], preamble[2], preamble[3],
                 preamble[0], preamble[1], preamble[2], preamble[3]);
             return AVERROR_INVALIDDATA;
@@ -352,12 +352,12 @@
                 ret = -EIO;
             else {
                 int i = 0;
-                printf ("Subtitle time!\n");
-                printf ("  inglish: %s\n", &text[i + 1]);
+                av_log (s, AV_LOG_DEBUG, "Subtitle time!\n");
+                av_log (s, AV_LOG_DEBUG, "  inglish: %s\n", &text[i + 1]);
                 i += text[i] + 1;
-                printf ("  doytsch: %s\n", &text[i + 1]);
+                av_log (s, AV_LOG_DEBUG, "  doytsch: %s\n", &text[i + 1]);
                 i += text[i] + 1;
-                printf ("  fronsay: %s\n", &text[i + 1]);
+                av_log (s, AV_LOG_DEBUG, "  fronsay: %s\n", &text[i + 1]);
             }
 #endif
             break;
@@ -379,7 +379,7 @@
             break;
 
         default:
-            printf ("  unrecognized WC3 chunk: %c%c%c%c (0x%02X%02X%02X%02X)\n",
+	    av_log (s, AV_LOG_ERROR, "  unrecognized WC3 chunk: %c%c%c%c (0x%02X%02X%02X%02X)\n",
                 preamble[0], preamble[1], preamble[2], preamble[3],
                 preamble[0], preamble[1], preamble[2], preamble[3]);
             ret = AVERROR_INVALIDDATA;
--- a/westwood.c	Wed Feb 25 17:35:52 2004 +0000
+++ b/westwood.c	Wed Mar 03 15:41:21 2004 +0000
@@ -309,7 +309,7 @@
             break;
 
         default:
-            printf (" note: unknown chunk seen (%c%c%c%c)\n",
+            av_log (s, AV_LOG_ERROR, " note: unknown chunk seen (%c%c%c%c)\n",
                 scratch[0], scratch[1],
                 scratch[2], scratch[3]);
             break;
--- a/yuv4mpeg.c	Wed Feb 25 17:35:52 2004 +0000
+++ b/yuv4mpeg.c	Wed Mar 03 15:41:21 2004 +0000
@@ -77,7 +77,7 @@
     if (*first_pkt) {
         *first_pkt = 0;
 	if (yuv4_generate_header(s, buf2) < 0) {
-	    fprintf(stderr, "Error. YUV4MPEG stream header write failed.\n");
+	    av_log(s, AV_LOG_ERROR, "Error. YUV4MPEG stream header write failed.\n");
 	    return -EIO;
 	} else {
 	    put_buffer(pb, buf2, strlen(buf2)); 
@@ -122,10 +122,10 @@
         return -EIO;
     
     if (s->streams[0]->codec.pix_fmt == PIX_FMT_YUV411P) {
-        fprintf(stderr, "Warning: generating non-standard 4:1:1 YUV stream, some mjpegtools might not work.\n");
+        av_log(s, AV_LOG_ERROR, "Warning: generating non-standard 4:1:1 YUV stream, some mjpegtools might not work.\n");
     } 
     else if (s->streams[0]->codec.pix_fmt != PIX_FMT_YUV420P) {
-        fprintf(stderr, "ERROR: yuv4mpeg only handles 4:2:0, 4:1:1 YUV data. Use -pix_fmt to select one.\n");
+        av_log(s, AV_LOG_ERROR, "ERROR: yuv4mpeg only handles 4:2:0, 4:1:1 YUV data. Use -pix_fmt to select one.\n");
 	return -EIO;
     }