diff vmdav.c @ 1927:d7505fbe66cb libavcodec

conversion to av_log
author alex
date Wed, 07 Apr 2004 13:26:47 +0000
parents 5456ab242388
children 141a9539e270
line wrap: on
line diff
--- a/vmdav.c	Wed Apr 07 13:14:29 2004 +0000
+++ b/vmdav.c	Wed Apr 07 13:26:47 2004 +0000
@@ -47,9 +47,6 @@
 #include "avcodec.h"
 #include "dsputil.h"
 
-#define printf(...) {} //(f)printf() usage is forbidden in libavcodec, use av_log
-#define fprintf(...) {} 
-
 #define VMD_HEADER_SIZE 0x330
 #define PALETTE_COUNT 256
 
@@ -245,7 +242,7 @@
                     }
                 } while (ofs < frame_width);
                 if (ofs > frame_width) {
-                    printf (" VMD video: offset > width (%d > %d)\n",
+                    av_log(s->avctx, AV_LOG_ERROR, "VMD video: offset > width (%d > %d)\n",
                         ofs, frame_width);
                     break;
                 }
@@ -283,7 +280,7 @@
                     }
                 } while (ofs < frame_width);
                 if (ofs > frame_width) {
-                    printf (" VMD video: offset > width (%d > %d)\n",
+                    av_log(s->avctx, AV_LOG_ERROR, "VMD video: offset > width (%d > %d)\n",
                         ofs, frame_width);
                 }
                 dp += s->frame.linesize[0];
@@ -311,7 +308,7 @@
 
     /* make sure the VMD header made it */
     if (s->avctx->extradata_size != VMD_HEADER_SIZE) {
-        printf("  VMD video: expected extradata size of %d\n", 
+        av_log(s->avctx, AV_LOG_ERROR, "VMD video: expected extradata size of %d\n", 
             VMD_HEADER_SIZE);
         return -1;
     }
@@ -350,7 +347,7 @@
 
     s->frame.reference = 1;
     if (avctx->get_buffer(avctx, &s->frame)) {
-        printf ("  VMD Video: get_buffer() failed\n");
+        av_log(s->avctx, AV_LOG_ERROR, "VMD Video: get_buffer() failed\n");
         return -1;
     }
 
@@ -389,6 +386,7 @@
  */
 
 typedef struct VmdAudioContext {
+    AVCodecContext *avctx;
     int channels;
     int bits;
     int block_align;
@@ -403,12 +401,13 @@
     VmdAudioContext *s = (VmdAudioContext *)avctx->priv_data;
     int i;
 
+    s->avctx = avctx;
     s->channels = avctx->channels;
     s->bits = avctx->bits_per_sample;
     s->block_align = avctx->block_align;
 
-printf ("  %d channels, %d bits/sample, block align = %d, sample rate = %d\n",
-  s->channels, s->bits, s->block_align, avctx->sample_rate);
+    av_log(s->avctx, AV_LOG_DEBUG, "%d channels, %d bits/sample, block align = %d, sample rate = %d\n",
+	    s->channels, s->bits, s->block_align, avctx->sample_rate);
 
     /* set up the steps8 and steps16 tables */
     for (i = 0; i < 8; i++) {
@@ -465,8 +464,8 @@
     int bytes_decoded = 0;
     int i;
 
-if (silence)
-  printf (" silent block!\n");
+    if (silence)
+	av_log(s->avctx, AV_LOG_INFO, "silent block!\n");
     if (s->channels == 2) {
 
         /* stereo handling */
@@ -520,7 +519,6 @@
     unsigned char *p = buf + 16;
     unsigned char *p_end = buf + buf_size;
 
-printf ("    processing audio frame with %d bytes\n", buf_size);
     if (buf_size < 16)
         return buf_size;
 
@@ -529,7 +527,6 @@
         /* the chunk contains audio */
         *data_size = vmdaudio_loadsound(s, output_samples, p, 0);
     } else if (buf[6] == 2) {
-printf ("  hey! audio case #2\n");
         /* the chunk contains audio and silence mixed together */
         sound_flags = LE_32(p);
         p += 4;
@@ -549,13 +546,10 @@
             sound_flags >>= 1;
         }
     } else if (buf[6] == 3) {
-printf ("  hey! audio case #3\n");
         /* silent chunk */
         *data_size = vmdaudio_loadsound(s, output_samples, p, 1);
     }
 
-printf ("      final sample count = %d, byte count = %d\n", (*data_size) / 2,
-  *data_size);
     return buf_size;
 }