Mercurial > libavcodec.hg
comparison ac3dec.c @ 6957:6eb895971766 libavcodec
only calculate number of exponent groups when exponents are not reused.
author | jbr |
---|---|
date | Sat, 31 May 2008 21:53:31 +0000 |
parents | 9984c30bf233 |
children | 1c523b5212cd |
comparison
equal
deleted
inserted
replaced
6956:9984c30bf233 | 6957:6eb895971766 |
---|---|
152 int num_cpl_subbands; ///< number of coupling sub bands | 152 int num_cpl_subbands; ///< number of coupling sub bands |
153 int start_freq[AC3_MAX_CHANNELS]; ///< start frequency bin | 153 int start_freq[AC3_MAX_CHANNELS]; ///< start frequency bin |
154 int end_freq[AC3_MAX_CHANNELS]; ///< end frequency bin | 154 int end_freq[AC3_MAX_CHANNELS]; ///< end frequency bin |
155 AC3BitAllocParameters bit_alloc_params; ///< bit allocation parameters | 155 AC3BitAllocParameters bit_alloc_params; ///< bit allocation parameters |
156 | 156 |
157 int num_exp_groups[AC3_MAX_CHANNELS]; ///< Number of exponent groups | |
157 int8_t dexps[AC3_MAX_CHANNELS][256]; ///< decoded exponents | 158 int8_t dexps[AC3_MAX_CHANNELS][256]; ///< decoded exponents |
158 uint8_t bap[AC3_MAX_CHANNELS][256]; ///< bit allocation pointers | 159 uint8_t bap[AC3_MAX_CHANNELS][256]; ///< bit allocation pointers |
159 int16_t psd[AC3_MAX_CHANNELS][256]; ///< scaled exponents | 160 int16_t psd[AC3_MAX_CHANNELS][256]; ///< scaled exponents |
160 int16_t band_psd[AC3_MAX_CHANNELS][50]; ///< interpolated exponents | 161 int16_t band_psd[AC3_MAX_CHANNELS][50]; ///< interpolated exponents |
161 int16_t mask[AC3_MAX_CHANNELS][50]; ///< masking curve values | 162 int16_t mask[AC3_MAX_CHANNELS][50]; ///< masking curve values |
905 | 906 |
906 /* channel bandwidth */ | 907 /* channel bandwidth */ |
907 for (ch = 1; ch <= fbw_channels; ch++) { | 908 for (ch = 1; ch <= fbw_channels; ch++) { |
908 s->start_freq[ch] = 0; | 909 s->start_freq[ch] = 0; |
909 if (s->exp_strategy[ch] != EXP_REUSE) { | 910 if (s->exp_strategy[ch] != EXP_REUSE) { |
911 int group_size; | |
910 int prev = s->end_freq[ch]; | 912 int prev = s->end_freq[ch]; |
911 if (s->channel_in_cpl[ch]) | 913 if (s->channel_in_cpl[ch]) |
912 s->end_freq[ch] = s->start_freq[CPL_CH]; | 914 s->end_freq[ch] = s->start_freq[CPL_CH]; |
913 else { | 915 else { |
914 int bandwidth_code = get_bits(gbc, 6); | 916 int bandwidth_code = get_bits(gbc, 6); |
916 av_log(s->avctx, AV_LOG_ERROR, "bandwidth code = %d > 60", bandwidth_code); | 918 av_log(s->avctx, AV_LOG_ERROR, "bandwidth code = %d > 60", bandwidth_code); |
917 return -1; | 919 return -1; |
918 } | 920 } |
919 s->end_freq[ch] = bandwidth_code * 3 + 73; | 921 s->end_freq[ch] = bandwidth_code * 3 + 73; |
920 } | 922 } |
923 group_size = 3 << (s->exp_strategy[ch] - 1); | |
924 s->num_exp_groups[ch] = (s->end_freq[ch]+group_size-4) / group_size; | |
921 if(blk > 0 && s->end_freq[ch] != prev) | 925 if(blk > 0 && s->end_freq[ch] != prev) |
922 memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS); | 926 memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS); |
923 } | 927 } |
924 } | 928 } |
925 s->start_freq[s->lfe_ch] = 0; | 929 s->start_freq[s->lfe_ch] = 0; |
926 s->end_freq[s->lfe_ch] = 7; | 930 s->end_freq[s->lfe_ch] = 7; |
931 s->num_exp_groups[s->lfe_ch] = 2; | |
932 if (s->cpl_in_use && s->exp_strategy[CPL_CH] != EXP_REUSE) { | |
933 s->num_exp_groups[CPL_CH] = (s->end_freq[CPL_CH] - s->start_freq[CPL_CH]) / | |
934 (3 << (s->exp_strategy[CPL_CH] - 1)); | |
935 } | |
927 | 936 |
928 /* decode exponents for each channel */ | 937 /* decode exponents for each channel */ |
929 for (ch = !s->cpl_in_use; ch <= s->channels; ch++) { | 938 for (ch = !s->cpl_in_use; ch <= s->channels; ch++) { |
930 if (s->exp_strategy[ch] != EXP_REUSE) { | 939 if (s->exp_strategy[ch] != EXP_REUSE) { |
931 int group_size, num_groups; | |
932 group_size = 3 << (s->exp_strategy[ch] - 1); | |
933 if(ch == CPL_CH) | |
934 num_groups = (s->end_freq[ch] - s->start_freq[ch]) / group_size; | |
935 else if(ch == s->lfe_ch) | |
936 num_groups = 2; | |
937 else | |
938 num_groups = (s->end_freq[ch] + group_size - 4) / group_size; | |
939 s->dexps[ch][0] = get_bits(gbc, 4) << !ch; | 940 s->dexps[ch][0] = get_bits(gbc, 4) << !ch; |
940 decode_exponents(gbc, s->exp_strategy[ch], num_groups, s->dexps[ch][0], | 941 decode_exponents(gbc, s->exp_strategy[ch], |
942 s->num_exp_groups[ch], s->dexps[ch][0], | |
941 &s->dexps[ch][s->start_freq[ch]+!!ch]); | 943 &s->dexps[ch][s->start_freq[ch]+!!ch]); |
942 if(ch != CPL_CH && ch != s->lfe_ch) | 944 if(ch != CPL_CH && ch != s->lfe_ch) |
943 skip_bits(gbc, 2); /* skip gainrng */ | 945 skip_bits(gbc, 2); /* skip gainrng */ |
944 } | 946 } |
945 } | 947 } |