Mercurial > libavcodec.hg
comparison ac3dec.c @ 5497:377e9152aa9b libavcodec
use array for dynamic range scaling factors
author | jbr |
---|---|
date | Sun, 05 Aug 2007 21:10:09 +0000 |
parents | 15c6ea63cb62 |
children | 9971ba9c30a3 |
comparison
equal
deleted
inserted
replaced
5496:f966fc154841 | 5497:377e9152aa9b |
---|---|
161 int output_mode; ///< output channel configuration | 161 int output_mode; ///< output channel configuration |
162 int out_channels; ///< number of output channels | 162 int out_channels; ///< number of output channels |
163 | 163 |
164 float downmix_coeffs[AC3_MAX_CHANNELS][2]; ///< stereo downmix coefficients | 164 float downmix_coeffs[AC3_MAX_CHANNELS][2]; ///< stereo downmix coefficients |
165 float dialnorm[2]; ///< dialogue normalization | 165 float dialnorm[2]; ///< dialogue normalization |
166 float dynrng; //dynamic range gain | 166 float dynrng[2]; ///< dynamic range |
167 float dynrng2; //dynamic range gain for 1+1 mode | |
168 float cplco[AC3_MAX_CHANNELS][18]; //coupling coordinates | 167 float cplco[AC3_MAX_CHANNELS][18]; //coupling coordinates |
169 int ncplbnd; //number of coupling bands | 168 int ncplbnd; //number of coupling bands |
170 int ncplsubnd; //number of coupling sub bands | 169 int ncplsubnd; //number of coupling sub bands |
171 int startmant[AC3_MAX_CHANNELS]; ///< start frequency bin | 170 int startmant[AC3_MAX_CHANNELS]; ///< start frequency bin |
172 int endmant[AC3_MAX_CHANNELS]; //channel end mantissas | 171 int endmant[AC3_MAX_CHANNELS]; //channel end mantissas |
780 ctx->dithflag[ch] = get_bits1(gb); | 779 ctx->dithflag[ch] = get_bits1(gb); |
781 if(!ctx->dithflag[ch]) | 780 if(!ctx->dithflag[ch]) |
782 ctx->dither_all = 0; | 781 ctx->dither_all = 0; |
783 } | 782 } |
784 | 783 |
785 if (get_bits1(gb)) { /* dynamic range */ | 784 /* dynamic range */ |
786 ctx->dynrng = dynrng_tbl[get_bits(gb, 8)]; | 785 i = !(ctx->acmod); |
787 } else if(blk == 0) { | 786 do { |
788 ctx->dynrng = 1.0; | |
789 } | |
790 | |
791 if(acmod == AC3_ACMOD_DUALMONO) { /* dynamic range 1+1 mode */ | |
792 if(get_bits1(gb)) { | 787 if(get_bits1(gb)) { |
793 ctx->dynrng2 = dynrng_tbl[get_bits(gb, 8)]; | 788 ctx->dynrng[i] = dynrng_tbl[get_bits(gb, 8)]; |
794 } else if(blk == 0) { | 789 } else if(blk == 0) { |
795 ctx->dynrng2 = 1.0; | 790 ctx->dynrng[i] = 1.0f; |
796 } | 791 } |
797 } | 792 } while(i--); |
798 | 793 |
799 if (get_bits1(gb)) { /* coupling strategy */ | 794 if (get_bits1(gb)) { /* coupling strategy */ |
800 memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS); | 795 memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS); |
801 ctx->cplinu = get_bits1(gb); | 796 ctx->cplinu = get_bits1(gb); |
802 if (ctx->cplinu) { /* coupling in use */ | 797 if (ctx->cplinu) { /* coupling in use */ |
1020 do_rematrixing(ctx); | 1015 do_rematrixing(ctx); |
1021 | 1016 |
1022 /* apply scaling to coefficients (headroom, dialnorm, dynrng) */ | 1017 /* apply scaling to coefficients (headroom, dialnorm, dynrng) */ |
1023 for(ch=1; ch<=ctx->nchans; ch++) { | 1018 for(ch=1; ch<=ctx->nchans; ch++) { |
1024 float gain = 2.0f * ctx->mul_bias; | 1019 float gain = 2.0f * ctx->mul_bias; |
1025 if(ctx->acmod == AC3_ACMOD_DUALMONO && ch == 2) { | 1020 if(ctx->acmod == AC3_ACMOD_DUALMONO) { |
1026 gain *= ctx->dialnorm[ch-1] * ctx->dynrng2; | 1021 gain *= ctx->dialnorm[ch-1] * ctx->dynrng[ch-1]; |
1027 } else { | 1022 } else { |
1028 gain *= ctx->dialnorm[0] * ctx->dynrng; | 1023 gain *= ctx->dialnorm[0] * ctx->dynrng[0]; |
1029 } | 1024 } |
1030 for(i=0; i<ctx->endmant[ch]; i++) { | 1025 for(i=0; i<ctx->endmant[ch]; i++) { |
1031 ctx->transform_coeffs[ch][i] *= gain; | 1026 ctx->transform_coeffs[ch][i] *= gain; |
1032 } | 1027 } |
1033 } | 1028 } |