Mercurial > libavcodec.hg
comparison ac3dec.c @ 5461:c427d8950769 libavcodec
cosmetics: use braces when it makes the code easier to read.
author | jbr |
---|---|
date | Sat, 04 Aug 2007 12:04:41 +0000 |
parents | 669395a6bca8 |
children | 37c1944ca4ee |
comparison
equal
deleted
inserted
replaced
5460:669395a6bca8 | 5461:c427d8950769 |
---|---|
570 } | 570 } |
571 uncouple_channels(ctx); | 571 uncouple_channels(ctx); |
572 got_cplchan = 1; | 572 got_cplchan = 1; |
573 } | 573 } |
574 end = ctx->cplendmant; | 574 end = ctx->cplendmant; |
575 } else | 575 } else { |
576 end = ctx->endmant[i]; | 576 end = ctx->endmant[i]; |
577 } | |
577 do | 578 do |
578 ctx->transform_coeffs[i + 1][end] = 0; | 579 ctx->transform_coeffs[i + 1][end] = 0; |
579 while(++end < 256); | 580 while(++end < 256); |
580 } | 581 } |
581 if (ctx->lfeon) { | 582 if (ctx->lfeon) { |
671 ctx->window, ctx->delay[0], 384, 256, 1); | 672 ctx->window, ctx->delay[0], 384, 256, 1); |
672 ctx->dsp.vector_fmul_reverse(ctx->delay[0], ctx->tmp_output+256, | 673 ctx->dsp.vector_fmul_reverse(ctx->delay[0], ctx->tmp_output+256, |
673 ctx->window, 256); | 674 ctx->window, 256); |
674 } | 675 } |
675 for (ch=1; ch<=ctx->nfchans; ch++) { | 676 for (ch=1; ch<=ctx->nfchans; ch++) { |
676 if (ctx->blksw[ch-1]) | 677 if (ctx->blksw[ch-1]) { |
677 do_imdct_256(ctx, ch); | 678 do_imdct_256(ctx, ch); |
678 else | 679 } else { |
679 ctx->imdct_512.fft.imdct_calc(&ctx->imdct_512, ctx->tmp_output, | 680 ctx->imdct_512.fft.imdct_calc(&ctx->imdct_512, ctx->tmp_output, |
680 ctx->transform_coeffs[ch], | 681 ctx->transform_coeffs[ch], |
681 ctx->tmp_imdct); | 682 ctx->tmp_imdct); |
682 | 683 } |
683 ctx->dsp.vector_fmul_add_add(ctx->output[ch], ctx->tmp_output, | 684 ctx->dsp.vector_fmul_add_add(ctx->output[ch], ctx->tmp_output, |
684 ctx->window, ctx->delay[ch], 384, 256, 1); | 685 ctx->window, ctx->delay[ch], 384, 256, 1); |
685 ctx->dsp.vector_fmul_reverse(ctx->delay[ch], ctx->tmp_output+256, | 686 ctx->dsp.vector_fmul_reverse(ctx->delay[ch], ctx->tmp_output+256, |
686 ctx->window, 256); | 687 ctx->window, 256); |
687 } | 688 } |
747 } | 748 } |
748 | 749 |
749 ctx->ncplbnd = ctx->ncplsubnd = 3 + cplendf - cplbegf; | 750 ctx->ncplbnd = ctx->ncplsubnd = 3 + cplendf - cplbegf; |
750 ctx->cplstrtmant = cplbegf * 12 + 37; | 751 ctx->cplstrtmant = cplbegf * 12 + 37; |
751 ctx->cplendmant = cplendf * 12 + 73; | 752 ctx->cplendmant = cplendf * 12 + 73; |
752 for (i = 0; i < ctx->ncplsubnd - 1; i++) /* coupling band structure */ | 753 for (i = 0; i < ctx->ncplsubnd - 1; i++) { /* coupling band structure */ |
753 if (get_bits1(gb)) { | 754 if (get_bits1(gb)) { |
754 ctx->cplbndstrc[i] = 1; | 755 ctx->cplbndstrc[i] = 1; |
755 ctx->ncplbnd--; | 756 ctx->ncplbnd--; |
756 } | 757 } |
758 } | |
757 } else { | 759 } else { |
758 for (i = 0; i < nfchans; i++) | 760 for (i = 0; i < nfchans; i++) |
759 ctx->chincpl[i] = 0; | 761 ctx->chincpl[i] = 0; |
760 } | 762 } |
761 } | 763 } |
762 | 764 |
763 if (ctx->cplinu) { | 765 if (ctx->cplinu) { |
764 int cplcoe = 0; | 766 int cplcoe = 0; |
765 | 767 |
766 for (i = 0; i < nfchans; i++) | 768 for (i = 0; i < nfchans; i++) { |
767 if (ctx->chincpl[i]) | 769 if (ctx->chincpl[i]) { |
768 if (get_bits1(gb)) { /* coupling co-ordinates */ | 770 if (get_bits1(gb)) { /* coupling co-ordinates */ |
769 cplcoe = 1; | 771 cplcoe = 1; |
770 mstrcplco = 3 * get_bits(gb, 2); | 772 mstrcplco = 3 * get_bits(gb, 2); |
771 for (bnd = 0; bnd < ctx->ncplbnd; bnd++) { | 773 for (bnd = 0; bnd < ctx->ncplbnd; bnd++) { |
772 cplcoexp = get_bits(gb, 4); | 774 cplcoexp = get_bits(gb, 4); |
776 else | 778 else |
777 ctx->cplco[i][bnd] = (cplcomant + 16.0f) / 32.0f; | 779 ctx->cplco[i][bnd] = (cplcomant + 16.0f) / 32.0f; |
778 ctx->cplco[i][bnd] *= scale_factors[cplcoexp + mstrcplco]; | 780 ctx->cplco[i][bnd] *= scale_factors[cplcoexp + mstrcplco]; |
779 } | 781 } |
780 } | 782 } |
781 | 783 } |
782 if (acmod == AC3_ACMOD_STEREO && ctx->phsflginu && cplcoe) | 784 } |
783 for (bnd = 0; bnd < ctx->ncplbnd; bnd++) | 785 |
786 if (acmod == AC3_ACMOD_STEREO && ctx->phsflginu && cplcoe) { | |
787 for (bnd = 0; bnd < ctx->ncplbnd; bnd++) { | |
784 if (get_bits1(gb)) | 788 if (get_bits1(gb)) |
785 ctx->cplco[1][bnd] = -ctx->cplco[1][bnd]; | 789 ctx->cplco[1][bnd] = -ctx->cplco[1][bnd]; |
790 } | |
791 } | |
786 } | 792 } |
787 | 793 |
788 if (acmod == AC3_ACMOD_STEREO) {/* rematrixing */ | 794 if (acmod == AC3_ACMOD_STEREO) {/* rematrixing */ |
789 ctx->rematstr = get_bits1(gb); | 795 ctx->rematstr = get_bits1(gb); |
790 if (ctx->rematstr) { | 796 if (ctx->rematstr) { |
803 for (i = 0; i < nfchans; i++) /* channel exponent strategy */ | 809 for (i = 0; i < nfchans; i++) /* channel exponent strategy */ |
804 ctx->chexpstr[i] = get_bits(gb, 2); | 810 ctx->chexpstr[i] = get_bits(gb, 2); |
805 if (ctx->lfeon) /* lfe exponent strategy */ | 811 if (ctx->lfeon) /* lfe exponent strategy */ |
806 ctx->lfeexpstr = get_bits1(gb); | 812 ctx->lfeexpstr = get_bits1(gb); |
807 | 813 |
808 for (i = 0; i < nfchans; i++) /* channel bandwidth code */ | 814 for (i = 0; i < nfchans; i++) { /* channel bandwidth code */ |
809 if (ctx->chexpstr[i] != EXP_REUSE) { | 815 if (ctx->chexpstr[i] != EXP_REUSE) { |
810 if (ctx->chincpl[i]) | 816 if (ctx->chincpl[i]) |
811 ctx->endmant[i] = ctx->cplstrtmant; | 817 ctx->endmant[i] = ctx->cplstrtmant; |
812 else { | 818 else { |
813 chbwcod = get_bits(gb, 6); | 819 chbwcod = get_bits(gb, 6); |
816 return -1; | 822 return -1; |
817 } | 823 } |
818 ctx->endmant[i] = chbwcod * 3 + 73; | 824 ctx->endmant[i] = chbwcod * 3 + 73; |
819 } | 825 } |
820 } | 826 } |
827 } | |
821 | 828 |
822 if (ctx->cplexpstr != EXP_REUSE) {/* coupling exponents */ | 829 if (ctx->cplexpstr != EXP_REUSE) {/* coupling exponents */ |
823 bit_alloc_flags = 64; | 830 bit_alloc_flags = 64; |
824 cplabsexp = get_bits(gb, 4) << 1; | 831 cplabsexp = get_bits(gb, 4) << 1; |
825 ngrps = (ctx->cplendmant - ctx->cplstrtmant) / (3 << (ctx->cplexpstr - 1)); | 832 ngrps = (ctx->cplendmant - ctx->cplstrtmant) / (3 << (ctx->cplexpstr - 1)); |
826 decode_exponents(gb, ctx->cplexpstr, ngrps, cplabsexp, ctx->dcplexps + ctx->cplstrtmant); | 833 decode_exponents(gb, ctx->cplexpstr, ngrps, cplabsexp, ctx->dcplexps + ctx->cplstrtmant); |
827 } | 834 } |
828 | 835 |
829 for (i = 0; i < nfchans; i++) /* fbw channel exponents */ | 836 for (i = 0; i < nfchans; i++) { /* fbw channel exponents */ |
830 if (ctx->chexpstr[i] != EXP_REUSE) { | 837 if (ctx->chexpstr[i] != EXP_REUSE) { |
831 bit_alloc_flags |= 1 << i; | 838 bit_alloc_flags |= 1 << i; |
832 grpsize = 3 << (ctx->chexpstr[i] - 1); | 839 grpsize = 3 << (ctx->chexpstr[i] - 1); |
833 ngrps = (ctx->endmant[i] + grpsize - 4) / grpsize; | 840 ngrps = (ctx->endmant[i] + grpsize - 4) / grpsize; |
834 dexps = ctx->dexps[i]; | 841 dexps = ctx->dexps[i]; |
835 dexps[0] = get_bits(gb, 4); | 842 dexps[0] = get_bits(gb, 4); |
836 decode_exponents(gb, ctx->chexpstr[i], ngrps, dexps[0], dexps + 1); | 843 decode_exponents(gb, ctx->chexpstr[i], ngrps, dexps[0], dexps + 1); |
837 skip_bits(gb, 2); /* skip gainrng */ | 844 skip_bits(gb, 2); /* skip gainrng */ |
838 } | 845 } |
846 } | |
839 | 847 |
840 if (ctx->lfeexpstr != EXP_REUSE) { /* lfe exponents */ | 848 if (ctx->lfeexpstr != EXP_REUSE) { /* lfe exponents */ |
841 bit_alloc_flags |= 32; | 849 bit_alloc_flags |= 32; |
842 ctx->dlfeexps[0] = get_bits(gb, 4); | 850 ctx->dlfeexps[0] = get_bits(gb, 4); |
843 decode_exponents(gb, ctx->lfeexpstr, 2, ctx->dlfeexps[0], ctx->dlfeexps + 1); | 851 decode_exponents(gb, ctx->lfeexpstr, 2, ctx->dlfeexps[0], ctx->dlfeexps + 1); |
893 av_log(NULL, AV_LOG_ERROR, "delta bit allocation strategy reserved\n"); | 901 av_log(NULL, AV_LOG_ERROR, "delta bit allocation strategy reserved\n"); |
894 return -1; | 902 return -1; |
895 } | 903 } |
896 } | 904 } |
897 | 905 |
898 if (ctx->cplinu) | 906 if (ctx->cplinu) { |
899 if (ctx->cpldeltbae == DBA_NEW) { /*coupling delta offset, len and bit allocation */ | 907 if (ctx->cpldeltbae == DBA_NEW) { /*coupling delta offset, len and bit allocation */ |
900 ctx->cpldeltnseg = get_bits(gb, 3); | 908 ctx->cpldeltnseg = get_bits(gb, 3); |
901 for (seg = 0; seg <= ctx->cpldeltnseg; seg++) { | 909 for (seg = 0; seg <= ctx->cpldeltnseg; seg++) { |
902 ctx->cpldeltoffst[seg] = get_bits(gb, 5); | 910 ctx->cpldeltoffst[seg] = get_bits(gb, 5); |
903 ctx->cpldeltlen[seg] = get_bits(gb, 4); | 911 ctx->cpldeltlen[seg] = get_bits(gb, 4); |
904 ctx->cpldeltba[seg] = get_bits(gb, 3); | 912 ctx->cpldeltba[seg] = get_bits(gb, 3); |
905 } | 913 } |
906 } | 914 } |
907 | 915 } |
908 for (i = 0; i < nfchans; i++) | 916 |
917 for (i = 0; i < nfchans; i++) { | |
909 if (ctx->deltbae[i] == DBA_NEW) {/*channel delta offset, len and bit allocation */ | 918 if (ctx->deltbae[i] == DBA_NEW) {/*channel delta offset, len and bit allocation */ |
910 ctx->deltnseg[i] = get_bits(gb, 3); | 919 ctx->deltnseg[i] = get_bits(gb, 3); |
911 for (seg = 0; seg <= ctx->deltnseg[i]; seg++) { | 920 for (seg = 0; seg <= ctx->deltnseg[i]; seg++) { |
912 ctx->deltoffst[i][seg] = get_bits(gb, 5); | 921 ctx->deltoffst[i][seg] = get_bits(gb, 5); |
913 ctx->deltlen[i][seg] = get_bits(gb, 4); | 922 ctx->deltlen[i][seg] = get_bits(gb, 4); |
914 ctx->deltba[i][seg] = get_bits(gb, 3); | 923 ctx->deltba[i][seg] = get_bits(gb, 3); |
915 } | 924 } |
916 } | 925 } |
926 } | |
917 } else if(blk == 0) { | 927 } else if(blk == 0) { |
918 if(ctx->cplinu) | 928 if(ctx->cplinu) |
919 ctx->cpldeltbae = DBA_NONE; | 929 ctx->cpldeltbae = DBA_NONE; |
920 for(i=0; i<nfchans; i++) { | 930 for(i=0; i<nfchans; i++) { |
921 ctx->deltbae[i] = DBA_NONE; | 931 ctx->deltbae[i] = DBA_NONE; |
922 } | 932 } |
923 } | 933 } |
924 | 934 |
925 if (bit_alloc_flags) { | 935 if (bit_alloc_flags) { |
926 if (ctx->cplinu && (bit_alloc_flags & 64)) | 936 if (ctx->cplinu && (bit_alloc_flags & 64)) { |
927 ac3_parametric_bit_allocation(&ctx->bit_alloc_params, ctx->cplbap, | 937 ac3_parametric_bit_allocation(&ctx->bit_alloc_params, ctx->cplbap, |
928 ctx->dcplexps, ctx->cplstrtmant, | 938 ctx->dcplexps, ctx->cplstrtmant, |
929 ctx->cplendmant, ctx->cplsnroffst, | 939 ctx->cplendmant, ctx->cplsnroffst, |
930 ctx->cplfgain, 0, | 940 ctx->cplfgain, 0, |
931 ctx->cpldeltbae, ctx->cpldeltnseg, | 941 ctx->cpldeltbae, ctx->cpldeltnseg, |
932 ctx->cpldeltoffst, ctx->cpldeltlen, | 942 ctx->cpldeltoffst, ctx->cpldeltlen, |
933 ctx->cpldeltba); | 943 ctx->cpldeltba); |
934 for (i = 0; i < nfchans; i++) | 944 } |
935 if ((bit_alloc_flags >> i) & 1) | 945 for (i = 0; i < nfchans; i++) { |
946 if ((bit_alloc_flags >> i) & 1) { | |
936 ac3_parametric_bit_allocation(&ctx->bit_alloc_params, | 947 ac3_parametric_bit_allocation(&ctx->bit_alloc_params, |
937 ctx->bap[i], ctx->dexps[i], 0, | 948 ctx->bap[i], ctx->dexps[i], 0, |
938 ctx->endmant[i], ctx->snroffst[i], | 949 ctx->endmant[i], ctx->snroffst[i], |
939 ctx->fgain[i], 0, ctx->deltbae[i], | 950 ctx->fgain[i], 0, ctx->deltbae[i], |
940 ctx->deltnseg[i], ctx->deltoffst[i], | 951 ctx->deltnseg[i], ctx->deltoffst[i], |
941 ctx->deltlen[i], ctx->deltba[i]); | 952 ctx->deltlen[i], ctx->deltba[i]); |
942 if (ctx->lfeon && (bit_alloc_flags & 32)) | 953 } |
954 } | |
955 if (ctx->lfeon && (bit_alloc_flags & 32)) { | |
943 ac3_parametric_bit_allocation(&ctx->bit_alloc_params, ctx->lfebap, | 956 ac3_parametric_bit_allocation(&ctx->bit_alloc_params, ctx->lfebap, |
944 ctx->dlfeexps, 0, 7, ctx->lfesnroffst, | 957 ctx->dlfeexps, 0, 7, ctx->lfesnroffst, |
945 ctx->lfefgain, 1, | 958 ctx->lfefgain, 1, |
946 DBA_NONE, 0, NULL, NULL, NULL); | 959 DBA_NONE, 0, NULL, NULL, NULL); |
960 } | |
947 } | 961 } |
948 | 962 |
949 if (get_bits1(gb)) { /* unused dummy data */ | 963 if (get_bits1(gb)) { /* unused dummy data */ |
950 skipl = get_bits(gb, 9); | 964 skipl = get_bits(gb, 9); |
951 while(skipl--) | 965 while(skipl--) |