Originally committed as revision 25967 to svn://svn.ffmpeg.org/ffmpeg/trunktags/n0.8
| @@ -33,7 +33,7 @@ | |||||
| /** | /** | ||||
| * Starting frequency coefficient bin for each critical band. | * Starting frequency coefficient bin for each critical band. | ||||
| */ | */ | ||||
| static const uint8_t band_start_tab[51] = { | |||||
| static const uint8_t band_start_tab[AC3_CRITICAL_BANDS+1] = { | |||||
| 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, | ||||
| 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ||||
| 20, 21, 22, 23, 24, 25, 26, 27, 28, 31, | 20, 21, 22, 23, 24, 25, 26, 27, 28, 31, | ||||
| @@ -127,7 +127,7 @@ int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd, | |||||
| uint8_t *dba_lengths, uint8_t *dba_values, | uint8_t *dba_lengths, uint8_t *dba_values, | ||||
| int16_t *mask) | int16_t *mask) | ||||
| { | { | ||||
| int16_t excite[50]; /* excitation */ | |||||
| int16_t excite[AC3_CRITICAL_BANDS]; /* excitation */ | |||||
| int band; | int band; | ||||
| int band_start, band_end, begin, end1; | int band_start, band_end, begin, end1; | ||||
| int lowcomp, fastleak, slowleak; | int lowcomp, fastleak, slowleak; | ||||
| @@ -198,7 +198,7 @@ int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd, | |||||
| band = 0; | band = 0; | ||||
| for (seg = 0; seg < dba_nsegs; seg++) { | for (seg = 0; seg < dba_nsegs; seg++) { | ||||
| band += dba_offsets[seg]; | band += dba_offsets[seg]; | ||||
| if (band >= 50 || dba_lengths[seg] > 50-band) | |||||
| if (band >= AC3_CRITICAL_BANDS || dba_lengths[seg] > AC3_CRITICAL_BANDS-band) | |||||
| return -1; | return -1; | ||||
| if (dba_values[seg] >= 4) { | if (dba_values[seg] >= 4) { | ||||
| delta = (dba_values[seg] - 3) << 7; | delta = (dba_values[seg] - 3) << 7; | ||||
| @@ -247,8 +247,8 @@ void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap, | |||||
| uint8_t *dba_values) | uint8_t *dba_values) | ||||
| { | { | ||||
| int16_t psd[256]; /* scaled exponents */ | int16_t psd[256]; /* scaled exponents */ | ||||
| int16_t band_psd[50]; /* interpolated exponents */ | |||||
| int16_t mask[50]; /* masking value */ | |||||
| int16_t band_psd[AC3_CRITICAL_BANDS]; /* interpolated exponents */ | |||||
| int16_t mask[AC3_CRITICAL_BANDS]; /* masking value */ | |||||
| ff_ac3_bit_alloc_calc_psd(exp, start, end, psd, band_psd); | ff_ac3_bit_alloc_calc_psd(exp, start, end, psd, band_psd); | ||||
| @@ -270,12 +270,12 @@ av_cold void ac3_common_init(void) | |||||
| #if !CONFIG_HARDCODED_TABLES | #if !CONFIG_HARDCODED_TABLES | ||||
| /* compute bndtab and masktab from bandsz */ | /* compute bndtab and masktab from bandsz */ | ||||
| int bin = 0, band; | int bin = 0, band; | ||||
| for (band = 0; band < 50; band++) { | |||||
| for (band = 0; band < AC3_CRITICAL_BANDS; band++) { | |||||
| int band_end = bin + ff_ac3_critical_band_size_tab[band]; | int band_end = bin + ff_ac3_critical_band_size_tab[band]; | ||||
| band_start_tab[band] = bin; | band_start_tab[band] = bin; | ||||
| while (bin < band_end) | while (bin < band_end) | ||||
| bin_to_band_tab[bin++] = band; | bin_to_band_tab[bin++] = band; | ||||
| } | } | ||||
| band_start_tab[50] = bin; | |||||
| band_start_tab[AC3_CRITICAL_BANDS] = bin; | |||||
| #endif /* !CONFIG_HARDCODED_TABLES */ | #endif /* !CONFIG_HARDCODED_TABLES */ | ||||
| } | } | ||||
| @@ -37,6 +37,7 @@ | |||||
| #define AC3_MAX_BLOCKS 6 | #define AC3_MAX_BLOCKS 6 | ||||
| #define AC3_FRAME_SIZE (AC3_MAX_BLOCKS * 256) | #define AC3_FRAME_SIZE (AC3_MAX_BLOCKS * 256) | ||||
| #define AC3_WINDOW_SIZE (AC3_BLOCK_SIZE * 2) | #define AC3_WINDOW_SIZE (AC3_BLOCK_SIZE * 2) | ||||
| #define AC3_CRITICAL_BANDS 50 | |||||
| /* exponent encoding strategy */ | /* exponent encoding strategy */ | ||||
| #define EXP_REUSE 0 | #define EXP_REUSE 0 | ||||
| @@ -168,8 +168,8 @@ typedef struct { | |||||
| int fast_gain[AC3_MAX_CHANNELS]; ///< fast gain values/SMR's (fgain) | int fast_gain[AC3_MAX_CHANNELS]; ///< fast gain values/SMR's (fgain) | ||||
| uint8_t bap[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< bit allocation pointers | uint8_t bap[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< bit allocation pointers | ||||
| int16_t psd[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< scaled exponents | int16_t psd[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< scaled exponents | ||||
| int16_t band_psd[AC3_MAX_CHANNELS][50]; ///< interpolated exponents | |||||
| int16_t mask[AC3_MAX_CHANNELS][50]; ///< masking curve values | |||||
| int16_t band_psd[AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS]; ///< interpolated exponents | |||||
| int16_t mask[AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS]; ///< masking curve values | |||||
| int dba_mode[AC3_MAX_CHANNELS]; ///< delta bit allocation mode | int dba_mode[AC3_MAX_CHANNELS]; ///< delta bit allocation mode | ||||
| int dba_nsegs[AC3_MAX_CHANNELS]; ///< number of delta segments | int dba_nsegs[AC3_MAX_CHANNELS]; ///< number of delta segments | ||||
| uint8_t dba_offsets[AC3_MAX_CHANNELS][8]; ///< delta segment offsets | uint8_t dba_offsets[AC3_MAX_CHANNELS][8]; ///< delta segment offsets | ||||
| @@ -506,16 +506,16 @@ static void bit_alloc_masking(AC3EncodeContext *s, | |||||
| uint8_t encoded_exp[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS], | uint8_t encoded_exp[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS], | ||||
| uint8_t exp_strategy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS], | uint8_t exp_strategy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS], | ||||
| int16_t psd[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS], | int16_t psd[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS], | ||||
| int16_t mask[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][50]) | |||||
| int16_t mask[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS]) | |||||
| { | { | ||||
| int blk, ch; | int blk, ch; | ||||
| int16_t band_psd[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][50]; | |||||
| int16_t band_psd[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS]; | |||||
| for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { | for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { | ||||
| for (ch = 0; ch < s->channels; ch++) { | for (ch = 0; ch < s->channels; ch++) { | ||||
| if(exp_strategy[blk][ch] == EXP_REUSE) { | if(exp_strategy[blk][ch] == EXP_REUSE) { | ||||
| memcpy(psd[blk][ch], psd[blk-1][ch], AC3_MAX_COEFS*sizeof(psd[0][0][0])); | memcpy(psd[blk][ch], psd[blk-1][ch], AC3_MAX_COEFS*sizeof(psd[0][0][0])); | ||||
| memcpy(mask[blk][ch], mask[blk-1][ch], 50*sizeof(mask[0][0][0])); | |||||
| memcpy(mask[blk][ch], mask[blk-1][ch], AC3_CRITICAL_BANDS*sizeof(mask[0][0][0])); | |||||
| } else { | } else { | ||||
| ff_ac3_bit_alloc_calc_psd(encoded_exp[blk][ch], 0, | ff_ac3_bit_alloc_calc_psd(encoded_exp[blk][ch], 0, | ||||
| s->nb_coefs[ch], | s->nb_coefs[ch], | ||||
| @@ -540,7 +540,7 @@ static void bit_alloc_masking(AC3EncodeContext *s, | |||||
| * SNR offset is used to quantize the mantissas. | * SNR offset is used to quantize the mantissas. | ||||
| */ | */ | ||||
| static int bit_alloc(AC3EncodeContext *s, | static int bit_alloc(AC3EncodeContext *s, | ||||
| int16_t mask[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][50], | |||||
| int16_t mask[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS], | |||||
| int16_t psd[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS], | int16_t psd[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS], | ||||
| uint8_t bap[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS], | uint8_t bap[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS], | ||||
| int frame_bits, int coarse_snr_offset, int fine_snr_offset) | int frame_bits, int coarse_snr_offset, int fine_snr_offset) | ||||
| @@ -584,7 +584,7 @@ static int compute_bit_allocation(AC3EncodeContext *s, | |||||
| int coarse_snr_offset, fine_snr_offset; | int coarse_snr_offset, fine_snr_offset; | ||||
| uint8_t bap1[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS]; | uint8_t bap1[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS]; | ||||
| int16_t psd[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS]; | int16_t psd[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS]; | ||||
| int16_t mask[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][50]; | |||||
| int16_t mask[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS]; | |||||
| static const int frame_bits_inc[8] = { 0, 0, 2, 2, 2, 4, 2, 4 }; | static const int frame_bits_inc[8] = { 0, 0, 2, 2, 2, 4, 2, 4 }; | ||||
| /* init default parameters */ | /* init default parameters */ | ||||