Commit 9452e350 authored by banan's avatar banan

save avctx in cook decoder context and use it for av_log

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@17988 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent de84ff30
...@@ -91,6 +91,7 @@ typedef struct cook { ...@@ -91,6 +91,7 @@ typedef struct cook {
void (* saturate_output) (struct cook *q, int chan, int16_t *out); void (* saturate_output) (struct cook *q, int chan, int16_t *out);
AVCodecContext* avctx;
GetBitContext gb; GetBitContext gb;
/* stream data */ /* stream data */
int nb_channels; int nb_channels;
...@@ -211,7 +212,7 @@ static av_cold int init_cook_vlc_tables(COOKContext *q) { ...@@ -211,7 +212,7 @@ static av_cold int init_cook_vlc_tables(COOKContext *q) {
envelope_quant_index_huffbits[i], 1, 1, envelope_quant_index_huffbits[i], 1, 1,
envelope_quant_index_huffcodes[i], 2, 2, 0); 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++) { for (i=0 ; i<7 ; i++) {
result |= init_vlc (&q->sqvh[i], vhvlcsize_tab[i], vhsize_tab[i], result |= init_vlc (&q->sqvh[i], vhvlcsize_tab[i], vhsize_tab[i],
cvh_huffbits[i], 1, 1, cvh_huffbits[i], 1, 1,
...@@ -222,10 +223,10 @@ static av_cold int init_cook_vlc_tables(COOKContext *q) { ...@@ -222,10 +223,10 @@ static av_cold int init_cook_vlc_tables(COOKContext *q) {
result |= init_vlc (&q->ccpl, 6, (1<<q->js_vlc_bits)-1, result |= init_vlc (&q->ccpl, 6, (1<<q->js_vlc_bits)-1,
ccpl_huffbits[q->js_vlc_bits-2], 1, 1, ccpl_huffbits[q->js_vlc_bits-2], 1, 1,
ccpl_huffcodes[q->js_vlc_bits-2], 2, 2, 0); 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; return result;
} }
...@@ -246,7 +247,7 @@ static av_cold int init_cook_mlt(COOKContext *q) { ...@@ -246,7 +247,7 @@ static av_cold int init_cook_mlt(COOKContext *q) {
av_free(q->mlt_window); av_free(q->mlt_window);
return -1; 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); av_log2(mlt_size)+1);
return 0; return 0;
...@@ -338,7 +339,7 @@ static av_cold int cook_decode_close(AVCodecContext *avctx) ...@@ -338,7 +339,7 @@ static av_cold int cook_decode_close(AVCodecContext *avctx)
free_vlc(&q->ccpl); free_vlc(&q->ccpl);
} }
av_log(NULL,AV_LOG_DEBUG,"Memory deallocated.\n"); av_log(avctx,AV_LOG_DEBUG,"Memory deallocated.\n");
return 0; return 0;
} }
...@@ -419,7 +420,7 @@ static void categorize(COOKContext *q, int* quant_index_table, ...@@ -419,7 +420,7 @@ static void categorize(COOKContext *q, int* quant_index_table,
if(bits_left > q->samples_per_channel) { if(bits_left > q->samples_per_channel) {
bits_left = q->samples_per_channel + bits_left = q->samples_per_channel +
((bits_left - q->samples_per_channel)*5)/8; ((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)); memset(&exp_index1,0,102*sizeof(int));
...@@ -935,9 +936,9 @@ static int decode_subpacket(COOKContext *q, const uint8_t *inbuffer, ...@@ -935,9 +936,9 @@ static int decode_subpacket(COOKContext *q, const uint8_t *inbuffer,
int sub_packet_size, int16_t *outbuffer) { int sub_packet_size, int16_t *outbuffer) {
/* packet dump */ /* packet dump */
// for (i=0 ; i<sub_packet_size ; i++) { // 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); decode_bytes_and_gain(q, inbuffer, &q->gains1);
...@@ -994,14 +995,14 @@ static int cook_decode_frame(AVCodecContext *avctx, ...@@ -994,14 +995,14 @@ static int cook_decode_frame(AVCodecContext *avctx,
static void dump_cook_context(COOKContext *q) static void dump_cook_context(COOKContext *q)
{ {
//int i=0; //int i=0;
#define PRINT(a,b) av_log(NULL,AV_LOG_ERROR," %s = %d\n", a, b); #define PRINT(a,b) av_log(q->avctx,AV_LOG_ERROR," %s = %d\n", a, b);
av_log(NULL,AV_LOG_ERROR,"COOKextradata\n"); av_log(q->avctx,AV_LOG_ERROR,"COOKextradata\n");
av_log(NULL,AV_LOG_ERROR,"cookversion=%x\n",q->cookversion); av_log(q->avctx,AV_LOG_ERROR,"cookversion=%x\n",q->cookversion);
if (q->cookversion > STEREO) { if (q->cookversion > STEREO) {
PRINT("js_subband_start",q->js_subband_start); PRINT("js_subband_start",q->js_subband_start);
PRINT("js_vlc_bits",q->js_vlc_bits); 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("nb_channels",q->nb_channels);
PRINT("bit_rate",q->bit_rate); PRINT("bit_rate",q->bit_rate);
PRINT("sample_rate",q->sample_rate); PRINT("sample_rate",q->sample_rate);
...@@ -1026,6 +1027,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) ...@@ -1026,6 +1027,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
{ {
COOKContext *q = avctx->priv_data; COOKContext *q = avctx->priv_data;
const uint8_t *edata_ptr = avctx->extradata; const uint8_t *edata_ptr = avctx->extradata;
q->avctx = avctx;
/* Take care of the codec specific extradata. */ /* Take care of the codec specific extradata. */
if (avctx->extradata_size <= 0) { if (avctx->extradata_size <= 0) {
...@@ -1064,7 +1066,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) ...@@ -1064,7 +1066,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
q->total_subbands = q->subbands; q->total_subbands = q->subbands;
/* Initialize version-dependent variables */ /* 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; q->joint_stereo = 0;
switch (q->cookversion) { switch (q->cookversion) {
case MONO: case MONO:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment