Mercurial > libavcodec.hg
comparison ac3dec.c @ 5498:9971ba9c30a3 libavcodec
add pointer to the parent context for use with av_log()
author | jbr |
---|---|
date | Sun, 05 Aug 2007 21:34:33 +0000 |
parents | 377e9152aa9b |
children | 838ba4dafaae |
comparison
equal
deleted
inserted
replaced
5497:377e9152aa9b | 5498:9971ba9c30a3 |
---|---|
194 DECLARE_ALIGNED_16(float, window[256]); //window coefficients | 194 DECLARE_ALIGNED_16(float, window[256]); //window coefficients |
195 | 195 |
196 /* Miscellaneous. */ | 196 /* Miscellaneous. */ |
197 GetBitContext gb; | 197 GetBitContext gb; |
198 AVRandomState dith_state; //for dither generation | 198 AVRandomState dith_state; //for dither generation |
199 AVCodecContext *avctx; ///< parent context | |
199 } AC3DecodeContext; | 200 } AC3DecodeContext; |
200 | 201 |
201 /*********** BEGIN INIT HELPER FUNCTIONS ***********/ | 202 /*********** BEGIN INIT HELPER FUNCTIONS ***********/ |
202 /** | 203 /** |
203 * Generate a Kaiser-Bessel Derived Window. | 204 * Generate a Kaiser-Bessel Derived Window. |
295 | 296 |
296 | 297 |
297 static int ac3_decode_init(AVCodecContext *avctx) | 298 static int ac3_decode_init(AVCodecContext *avctx) |
298 { | 299 { |
299 AC3DecodeContext *ctx = avctx->priv_data; | 300 AC3DecodeContext *ctx = avctx->priv_data; |
301 ctx->avctx = avctx; | |
300 | 302 |
301 ac3_common_init(); | 303 ac3_common_init(); |
302 ac3_tables_init(); | 304 ac3_tables_init(); |
303 ff_mdct_init(&ctx->imdct_256, 8, 1); | 305 ff_mdct_init(&ctx->imdct_256, 8, 1); |
304 ff_mdct_init(&ctx->imdct_512, 9, 1); | 306 ff_mdct_init(&ctx->imdct_512, 9, 1); |
613 return -1; | 615 return -1; |
614 /* tranform coefficients for coupling channels */ | 616 /* tranform coefficients for coupling channels */ |
615 if (ctx->chincpl[ch]) { | 617 if (ctx->chincpl[ch]) { |
616 if (!got_cplchan) { | 618 if (!got_cplchan) { |
617 if (get_transform_coeffs_ch(ctx, CPL_CH, &m)) { | 619 if (get_transform_coeffs_ch(ctx, CPL_CH, &m)) { |
618 av_log(NULL, AV_LOG_ERROR, "error in decoupling channels\n"); | 620 av_log(ctx->avctx, AV_LOG_ERROR, "error in decoupling channels\n"); |
619 return -1; | 621 return -1; |
620 } | 622 } |
621 uncouple_channels(ctx); | 623 uncouple_channels(ctx); |
622 got_cplchan = 1; | 624 got_cplchan = 1; |
623 } | 625 } |
805 | 807 |
806 cplbegf = get_bits(gb, 4); | 808 cplbegf = get_bits(gb, 4); |
807 cplendf = get_bits(gb, 4); | 809 cplendf = get_bits(gb, 4); |
808 | 810 |
809 if (3 + cplendf - cplbegf < 0) { | 811 if (3 + cplendf - cplbegf < 0) { |
810 av_log(NULL, AV_LOG_ERROR, "cplendf = %d < cplbegf = %d\n", cplendf, cplbegf); | 812 av_log(ctx->avctx, AV_LOG_ERROR, "cplendf = %d < cplbegf = %d\n", cplendf, cplbegf); |
811 return -1; | 813 return -1; |
812 } | 814 } |
813 | 815 |
814 ctx->ncplbnd = ctx->ncplsubnd = 3 + cplendf - cplbegf; | 816 ctx->ncplbnd = ctx->ncplsubnd = 3 + cplendf - cplbegf; |
815 ctx->startmant[CPL_CH] = cplbegf * 12 + 37; | 817 ctx->startmant[CPL_CH] = cplbegf * 12 + 37; |
885 if (ctx->chincpl[ch]) | 887 if (ctx->chincpl[ch]) |
886 ctx->endmant[ch] = ctx->startmant[CPL_CH]; | 888 ctx->endmant[ch] = ctx->startmant[CPL_CH]; |
887 else { | 889 else { |
888 int chbwcod = get_bits(gb, 6); | 890 int chbwcod = get_bits(gb, 6); |
889 if (chbwcod > 60) { | 891 if (chbwcod > 60) { |
890 av_log(NULL, AV_LOG_ERROR, "chbwcod = %d > 60", chbwcod); | 892 av_log(ctx->avctx, AV_LOG_ERROR, "chbwcod = %d > 60", chbwcod); |
891 return -1; | 893 return -1; |
892 } | 894 } |
893 ctx->endmant[ch] = chbwcod * 3 + 73; | 895 ctx->endmant[ch] = chbwcod * 3 + 73; |
894 } | 896 } |
895 if(blk > 0 && ctx->endmant[ch] != prev) | 897 if(blk > 0 && ctx->endmant[ch] != prev) |
946 | 948 |
947 if (get_bits1(gb)) { /* delta bit allocation information */ | 949 if (get_bits1(gb)) { /* delta bit allocation information */ |
948 for (ch = !ctx->cplinu; ch <= nfchans; ch++) { | 950 for (ch = !ctx->cplinu; ch <= nfchans; ch++) { |
949 ctx->deltbae[ch] = get_bits(gb, 2); | 951 ctx->deltbae[ch] = get_bits(gb, 2); |
950 if (ctx->deltbae[ch] == DBA_RESERVED) { | 952 if (ctx->deltbae[ch] == DBA_RESERVED) { |
951 av_log(NULL, AV_LOG_ERROR, "delta bit allocation strategy reserved\n"); | 953 av_log(ctx->avctx, AV_LOG_ERROR, "delta bit allocation strategy reserved\n"); |
952 return -1; | 954 return -1; |
953 } | 955 } |
954 bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2); | 956 bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2); |
955 } | 957 } |
956 | 958 |
1004 } | 1006 } |
1005 /* unpack the transform coefficients | 1007 /* unpack the transform coefficients |
1006 * * this also uncouples channels if coupling is in use. | 1008 * * this also uncouples channels if coupling is in use. |
1007 */ | 1009 */ |
1008 if (get_transform_coeffs(ctx)) { | 1010 if (get_transform_coeffs(ctx)) { |
1009 av_log(NULL, AV_LOG_ERROR, "Error in routine get_transform_coeffs\n"); | 1011 av_log(ctx->avctx, AV_LOG_ERROR, "Error in routine get_transform_coeffs\n"); |
1010 return -1; | 1012 return -1; |
1011 } | 1013 } |
1012 | 1014 |
1013 /* recover coefficients if rematrixing is in use */ | 1015 /* recover coefficients if rematrixing is in use */ |
1014 if(ctx->acmod == AC3_ACMOD_STEREO) | 1016 if(ctx->acmod == AC3_ACMOD_STEREO) |