Revision 77416325

View differences:

libavcodec/ac3dec.c
163 163

  
164 164
    float    downmix_coeffs[AC3_MAX_CHANNELS][2];   ///< stereo downmix coefficients
165 165
    float    dialnorm[2];                       ///< dialogue normalization
166
    float    dynrng;            //dynamic range gain
167
    float    dynrng2;           //dynamic range gain for 1+1 mode
166
    float    dynrng[2];                         ///< dynamic range
168 167
    float    cplco[AC3_MAX_CHANNELS][18];   //coupling coordinates
169 168
    int      ncplbnd;           //number of coupling bands
170 169
    int      ncplsubnd;         //number of coupling sub bands
......
782 781
            ctx->dither_all = 0;
783 782
    }
784 783

  
785
    if (get_bits1(gb)) { /* dynamic range */
786
        ctx->dynrng = dynrng_tbl[get_bits(gb, 8)];
787
    } else if(blk == 0) {
788
        ctx->dynrng = 1.0;
789
    }
790

  
791
    if(acmod == AC3_ACMOD_DUALMONO) { /* dynamic range 1+1 mode */
784
    /* dynamic range */
785
    i = !(ctx->acmod);
786
    do {
792 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 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 794
    if (get_bits1(gb)) { /* coupling strategy */
800 795
        memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS);
......
1022 1017
    /* apply scaling to coefficients (headroom, dialnorm, dynrng) */
1023 1018
    for(ch=1; ch<=ctx->nchans; ch++) {
1024 1019
        float gain = 2.0f * ctx->mul_bias;
1025
        if(ctx->acmod == AC3_ACMOD_DUALMONO && ch == 2) {
1026
            gain *= ctx->dialnorm[ch-1] * ctx->dynrng2;
1020
        if(ctx->acmod == AC3_ACMOD_DUALMONO) {
1021
            gain *= ctx->dialnorm[ch-1] * ctx->dynrng[ch-1];
1027 1022
        } else {
1028
            gain *= ctx->dialnorm[0] * ctx->dynrng;
1023
            gain *= ctx->dialnorm[0] * ctx->dynrng[0];
1029 1024
        }
1030 1025
        for(i=0; i<ctx->endmant[ch]; i++) {
1031 1026
            ctx->transform_coeffs[ch][i] *= gain;

Also available in: Unified diff