comparison ac3dec.c @ 7027:1edec36c02c5 libavcodec

store exp_strategy for all blocks in decode context
author jbr
date Sat, 07 Jun 2008 22:30:47 +0000
parents 4bd2ccb0619e
children 4ef389a71e03
comparison
equal deleted inserted replaced
7026:4bd2ccb0619e 7027:1edec36c02c5
841 return -1; 841 return -1;
842 } 842 }
843 } 843 }
844 844
845 /* exponent strategies for each channel */ 845 /* exponent strategies for each channel */
846 s->exp_strategy[CPL_CH] = EXP_REUSE; 846 s->exp_strategy[blk][CPL_CH] = EXP_REUSE;
847 s->exp_strategy[s->lfe_ch] = EXP_REUSE; 847 s->exp_strategy[blk][s->lfe_ch] = EXP_REUSE;
848 for (ch = !cpl_in_use; ch <= s->channels; ch++) { 848 for (ch = !cpl_in_use; ch <= s->channels; ch++) {
849 s->exp_strategy[ch] = get_bits(gbc, 2 - (ch == s->lfe_ch)); 849 s->exp_strategy[blk][ch] = get_bits(gbc, 2 - (ch == s->lfe_ch));
850 if(s->exp_strategy[ch] != EXP_REUSE) 850 if(s->exp_strategy[blk][ch] != EXP_REUSE)
851 bit_alloc_stages[ch] = 3; 851 bit_alloc_stages[ch] = 3;
852 } 852 }
853 853
854 /* channel bandwidth */ 854 /* channel bandwidth */
855 for (ch = 1; ch <= fbw_channels; ch++) { 855 for (ch = 1; ch <= fbw_channels; ch++) {
856 s->start_freq[ch] = 0; 856 s->start_freq[ch] = 0;
857 if (s->exp_strategy[ch] != EXP_REUSE) { 857 if (s->exp_strategy[blk][ch] != EXP_REUSE) {
858 int group_size; 858 int group_size;
859 int prev = s->end_freq[ch]; 859 int prev = s->end_freq[ch];
860 if (s->channel_in_cpl[ch]) 860 if (s->channel_in_cpl[ch])
861 s->end_freq[ch] = s->start_freq[CPL_CH]; 861 s->end_freq[ch] = s->start_freq[CPL_CH];
862 else { 862 else {
865 av_log(s->avctx, AV_LOG_ERROR, "bandwidth code = %d > 60", bandwidth_code); 865 av_log(s->avctx, AV_LOG_ERROR, "bandwidth code = %d > 60", bandwidth_code);
866 return -1; 866 return -1;
867 } 867 }
868 s->end_freq[ch] = bandwidth_code * 3 + 73; 868 s->end_freq[ch] = bandwidth_code * 3 + 73;
869 } 869 }
870 group_size = 3 << (s->exp_strategy[ch] - 1); 870 group_size = 3 << (s->exp_strategy[blk][ch] - 1);
871 s->num_exp_groups[ch] = (s->end_freq[ch]+group_size-4) / group_size; 871 s->num_exp_groups[ch] = (s->end_freq[ch]+group_size-4) / group_size;
872 if(blk > 0 && s->end_freq[ch] != prev) 872 if(blk > 0 && s->end_freq[ch] != prev)
873 memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS); 873 memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS);
874 } 874 }
875 } 875 }
876 if (cpl_in_use && s->exp_strategy[CPL_CH] != EXP_REUSE) { 876 if (cpl_in_use && s->exp_strategy[blk][CPL_CH] != EXP_REUSE) {
877 s->num_exp_groups[CPL_CH] = (s->end_freq[CPL_CH] - s->start_freq[CPL_CH]) / 877 s->num_exp_groups[CPL_CH] = (s->end_freq[CPL_CH] - s->start_freq[CPL_CH]) /
878 (3 << (s->exp_strategy[CPL_CH] - 1)); 878 (3 << (s->exp_strategy[blk][CPL_CH] - 1));
879 } 879 }
880 880
881 /* decode exponents for each channel */ 881 /* decode exponents for each channel */
882 for (ch = !cpl_in_use; ch <= s->channels; ch++) { 882 for (ch = !cpl_in_use; ch <= s->channels; ch++) {
883 if (s->exp_strategy[ch] != EXP_REUSE) { 883 if (s->exp_strategy[blk][ch] != EXP_REUSE) {
884 s->dexps[ch][0] = get_bits(gbc, 4) << !ch; 884 s->dexps[ch][0] = get_bits(gbc, 4) << !ch;
885 decode_exponents(gbc, s->exp_strategy[ch], 885 decode_exponents(gbc, s->exp_strategy[blk][ch],
886 s->num_exp_groups[ch], s->dexps[ch][0], 886 s->num_exp_groups[ch], s->dexps[ch][0],
887 &s->dexps[ch][s->start_freq[ch]+!!ch]); 887 &s->dexps[ch][s->start_freq[ch]+!!ch]);
888 if(ch != CPL_CH && ch != s->lfe_ch) 888 if(ch != CPL_CH && ch != s->lfe_ch)
889 skip_bits(gbc, 2); /* skip gainrng */ 889 skip_bits(gbc, 2); /* skip gainrng */
890 } 890 }