Mercurial > libavcodec.hg
comparison ac3dec.c @ 5471:37c1944ca4ee libavcodec
make exponent decoding consistent (prepare for merging coupling and lfe code with normal channel code).
author | jbr |
---|---|
date | Sat, 04 Aug 2007 13:26:46 +0000 |
parents | c427d8950769 |
children | 11585a021898 |
comparison
equal
deleted
inserted
replaced
5470:fea6732bc199 | 5471:37c1944ca4ee |
---|---|
695 */ | 695 */ |
696 static int ac3_parse_audio_block(AC3DecodeContext *ctx, int blk) | 696 static int ac3_parse_audio_block(AC3DecodeContext *ctx, int blk) |
697 { | 697 { |
698 int nfchans = ctx->nfchans; | 698 int nfchans = ctx->nfchans; |
699 int acmod = ctx->acmod; | 699 int acmod = ctx->acmod; |
700 int i, bnd, seg, grpsize, ch; | 700 int i, bnd, seg, ch; |
701 GetBitContext *gb = &ctx->gb; | 701 GetBitContext *gb = &ctx->gb; |
702 int bit_alloc_flags = 0; | 702 int bit_alloc_flags = 0; |
703 int8_t *dexps; | |
704 int mstrcplco, cplcoexp, cplcomant; | 703 int mstrcplco, cplcoexp, cplcomant; |
705 int chbwcod, ngrps, cplabsexp, skipl; | 704 int chbwcod, skipl; |
706 | 705 |
707 for (i = 0; i < nfchans; i++) /*block switch flag */ | 706 for (i = 0; i < nfchans; i++) /*block switch flag */ |
708 ctx->blksw[i] = get_bits1(gb); | 707 ctx->blksw[i] = get_bits1(gb); |
709 | 708 |
710 ctx->dither_all = 1; | 709 ctx->dither_all = 1; |
825 } | 824 } |
826 } | 825 } |
827 } | 826 } |
828 | 827 |
829 if (ctx->cplexpstr != EXP_REUSE) {/* coupling exponents */ | 828 if (ctx->cplexpstr != EXP_REUSE) {/* coupling exponents */ |
829 int grpsize, ngrps, absexp; | |
830 bit_alloc_flags = 64; | 830 bit_alloc_flags = 64; |
831 cplabsexp = get_bits(gb, 4) << 1; | 831 grpsize = 3 << (ctx->cplexpstr - 1); |
832 ngrps = (ctx->cplendmant - ctx->cplstrtmant) / (3 << (ctx->cplexpstr - 1)); | 832 ngrps = (ctx->cplendmant - ctx->cplstrtmant) / grpsize; |
833 decode_exponents(gb, ctx->cplexpstr, ngrps, cplabsexp, ctx->dcplexps + ctx->cplstrtmant); | 833 absexp = get_bits(gb, 4) << 1; |
834 decode_exponents(gb, ctx->cplexpstr, ngrps, absexp, &ctx->dcplexps[ctx->cplstrtmant]); | |
834 } | 835 } |
835 | 836 |
836 for (i = 0; i < nfchans; i++) { /* fbw channel exponents */ | 837 for (i = 0; i < nfchans; i++) { /* fbw channel exponents */ |
837 if (ctx->chexpstr[i] != EXP_REUSE) { | 838 if (ctx->chexpstr[i] != EXP_REUSE) { |
839 int grpsize, ngrps, absexp; | |
838 bit_alloc_flags |= 1 << i; | 840 bit_alloc_flags |= 1 << i; |
839 grpsize = 3 << (ctx->chexpstr[i] - 1); | 841 grpsize = 3 << (ctx->chexpstr[i] - 1); |
840 ngrps = (ctx->endmant[i] + grpsize - 4) / grpsize; | 842 ngrps = (ctx->endmant[i] + grpsize - 4) / grpsize; |
841 dexps = ctx->dexps[i]; | 843 absexp = ctx->dexps[i][0] = get_bits(gb, 4); |
842 dexps[0] = get_bits(gb, 4); | 844 decode_exponents(gb, ctx->chexpstr[i], ngrps, absexp, &ctx->dexps[i][1]); |
843 decode_exponents(gb, ctx->chexpstr[i], ngrps, dexps[0], dexps + 1); | |
844 skip_bits(gb, 2); /* skip gainrng */ | 845 skip_bits(gb, 2); /* skip gainrng */ |
845 } | 846 } |
846 } | 847 } |
847 | 848 |
848 if (ctx->lfeexpstr != EXP_REUSE) { /* lfe exponents */ | 849 if (ctx->lfeexpstr != EXP_REUSE) { /* lfe exponents */ |
850 int ngrps, absexp; | |
849 bit_alloc_flags |= 32; | 851 bit_alloc_flags |= 32; |
850 ctx->dlfeexps[0] = get_bits(gb, 4); | 852 ngrps = 2; |
851 decode_exponents(gb, ctx->lfeexpstr, 2, ctx->dlfeexps[0], ctx->dlfeexps + 1); | 853 absexp = ctx->dlfeexps[0] = get_bits(gb, 4); |
854 decode_exponents(gb, ctx->lfeexpstr, ngrps, absexp, &ctx->dlfeexps[1]); | |
852 } | 855 } |
853 | 856 |
854 if (get_bits1(gb)) { /* bit allocation information */ | 857 if (get_bits1(gb)) { /* bit allocation information */ |
855 bit_alloc_flags = 127; | 858 bit_alloc_flags = 127; |
856 ctx->bit_alloc_params.sdecay = ff_sdecaytab[get_bits(gb, 2)]; | 859 ctx->bit_alloc_params.sdecay = ff_sdecaytab[get_bits(gb, 2)]; |