changeset 9174:4d8d8fe29d4d libavcodec

save avctx in cook decoder context and use it for av_log
author banan
date Sun, 15 Mar 2009 14:11:11 +0000
parents fb675a9727f0
children da3196ebcf99
files cook.c
diffstat 1 files changed, 15 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/cook.c	Sun Mar 15 14:04:25 2009 +0000
+++ b/cook.c	Sun Mar 15 14:11:11 2009 +0000
@@ -91,6 +91,7 @@
 
     void (* saturate_output) (struct cook *q, int chan, int16_t *out);
 
+    AVCodecContext*     avctx;
     GetBitContext       gb;
     /* stream data */
     int                 nb_channels;
@@ -211,7 +212,7 @@
             envelope_quant_index_huffbits[i], 1, 1,
             envelope_quant_index_huffcodes[i], 2, 2, 0);
     }
-    av_log(NULL,AV_LOG_DEBUG,"sqvh VLC init\n");
+    av_log(q->avctx,AV_LOG_DEBUG,"sqvh VLC init\n");
     for (i=0 ; i<7 ; i++) {
         result |= init_vlc (&q->sqvh[i], vhvlcsize_tab[i], vhsize_tab[i],
             cvh_huffbits[i], 1, 1,
@@ -222,10 +223,10 @@
         result |= init_vlc (&q->ccpl, 6, (1<<q->js_vlc_bits)-1,
             ccpl_huffbits[q->js_vlc_bits-2], 1, 1,
             ccpl_huffcodes[q->js_vlc_bits-2], 2, 2, 0);
-        av_log(NULL,AV_LOG_DEBUG,"Joint-stereo VLC used.\n");
+        av_log(q->avctx,AV_LOG_DEBUG,"Joint-stereo VLC used.\n");
     }
 
-    av_log(NULL,AV_LOG_DEBUG,"VLC tables initialized.\n");
+    av_log(q->avctx,AV_LOG_DEBUG,"VLC tables initialized.\n");
     return result;
 }
 
@@ -246,7 +247,7 @@
       av_free(q->mlt_window);
       return -1;
     }
-    av_log(NULL,AV_LOG_DEBUG,"MDCT initialized, order = %d.\n",
+    av_log(q->avctx,AV_LOG_DEBUG,"MDCT initialized, order = %d.\n",
            av_log2(mlt_size)+1);
 
     return 0;
@@ -338,7 +339,7 @@
         free_vlc(&q->ccpl);
     }
 
-    av_log(NULL,AV_LOG_DEBUG,"Memory deallocated.\n");
+    av_log(avctx,AV_LOG_DEBUG,"Memory deallocated.\n");
 
     return 0;
 }
@@ -419,7 +420,7 @@
     if(bits_left > q->samples_per_channel) {
         bits_left = q->samples_per_channel +
                     ((bits_left - q->samples_per_channel)*5)/8;
-        //av_log(NULL, AV_LOG_ERROR, "bits_left = %d\n",bits_left);
+        //av_log(q->avctx, AV_LOG_ERROR, "bits_left = %d\n",bits_left);
     }
 
     memset(&exp_index1,0,102*sizeof(int));
@@ -935,9 +936,9 @@
                             int sub_packet_size, int16_t *outbuffer) {
     /* packet dump */
 //    for (i=0 ; i<sub_packet_size ; i++) {
-//        av_log(NULL, AV_LOG_ERROR, "%02x", inbuffer[i]);
+//        av_log(q->avctx, AV_LOG_ERROR, "%02x", inbuffer[i]);
 //    }
-//    av_log(NULL, AV_LOG_ERROR, "\n");
+//    av_log(q->avctx, AV_LOG_ERROR, "\n");
 
     decode_bytes_and_gain(q, inbuffer, &q->gains1);
 
@@ -994,14 +995,14 @@
 static void dump_cook_context(COOKContext *q)
 {
     //int i=0;
-#define PRINT(a,b) av_log(NULL,AV_LOG_ERROR," %s = %d\n", a, b);
-    av_log(NULL,AV_LOG_ERROR,"COOKextradata\n");
-    av_log(NULL,AV_LOG_ERROR,"cookversion=%x\n",q->cookversion);
+#define PRINT(a,b) av_log(q->avctx,AV_LOG_ERROR," %s = %d\n", a, b);
+    av_log(q->avctx,AV_LOG_ERROR,"COOKextradata\n");
+    av_log(q->avctx,AV_LOG_ERROR,"cookversion=%x\n",q->cookversion);
     if (q->cookversion > STEREO) {
         PRINT("js_subband_start",q->js_subband_start);
         PRINT("js_vlc_bits",q->js_vlc_bits);
     }
-    av_log(NULL,AV_LOG_ERROR,"COOKContext\n");
+    av_log(q->avctx,AV_LOG_ERROR,"COOKContext\n");
     PRINT("nb_channels",q->nb_channels);
     PRINT("bit_rate",q->bit_rate);
     PRINT("sample_rate",q->sample_rate);
@@ -1026,6 +1027,7 @@
 {
     COOKContext *q = avctx->priv_data;
     const uint8_t *edata_ptr = avctx->extradata;
+    q->avctx = avctx;
 
     /* Take care of the codec specific extradata. */
     if (avctx->extradata_size <= 0) {
@@ -1064,7 +1066,7 @@
     q->total_subbands = q->subbands;
 
     /* Initialize version-dependent variables */
-    av_log(NULL,AV_LOG_DEBUG,"q->cookversion=%x\n",q->cookversion);
+    av_log(avctx,AV_LOG_DEBUG,"q->cookversion=%x\n",q->cookversion);
     q->joint_stereo = 0;
     switch (q->cookversion) {
         case MONO: