Browse Source

ac3enc: add num_rematrixing_bands to AC3EncodeContext and use it instead of the hardcoded value.

Currently it is always 4, but this change will allow it to be adjusted when
bandwidth-related features are added such as channel coupling, enhanced
channel coupling, and spectral extension.
tags/n0.8
Justin Ruggles 14 years ago
parent
commit
53e35fd340
1 changed files with 7 additions and 4 deletions
  1. +7
    -4
      libavcodec/ac3enc.c

+ 7
- 4
libavcodec/ac3enc.c View File

@@ -117,6 +117,7 @@ typedef struct AC3EncodeContext {
int nb_coefs[AC3_MAX_CHANNELS]; int nb_coefs[AC3_MAX_CHANNELS];


int rematrixing; ///< determines how rematrixing strategy is calculated int rematrixing; ///< determines how rematrixing strategy is calculated
int num_rematrixing_bands; ///< number of rematrixing bands


/* bitrate allocation control */ /* bitrate allocation control */
int slow_gain_code; ///< slow gain code (sgaincod) int slow_gain_code; ///< slow gain code (sgaincod)
@@ -305,6 +306,8 @@ static void compute_rematrixing_strategy(AC3EncodeContext *s)
int blk, bnd, i; int blk, bnd, i;
AC3Block *block, *block0; AC3Block *block, *block0;


s->num_rematrixing_bands = 4;

if (s->rematrixing & AC3_REMATRIXING_IS_STATIC) if (s->rematrixing & AC3_REMATRIXING_IS_STATIC)
return; return;


@@ -313,7 +316,7 @@ static void compute_rematrixing_strategy(AC3EncodeContext *s)
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
block = &s->blocks[blk]; block = &s->blocks[blk];
block->new_rematrixing_strategy = !blk; block->new_rematrixing_strategy = !blk;
for (bnd = 0; bnd < 4; bnd++) {
for (bnd = 0; bnd < s->num_rematrixing_bands; bnd++) {
/* calculate calculate sum of squared coeffs for one band in one block */ /* calculate calculate sum of squared coeffs for one band in one block */
int start = ff_ac3_rematrix_band_tab[bnd]; int start = ff_ac3_rematrix_band_tab[bnd];
int end = FFMIN(nb_coefs, ff_ac3_rematrix_band_tab[bnd+1]); int end = FFMIN(nb_coefs, ff_ac3_rematrix_band_tab[bnd+1]);
@@ -365,7 +368,7 @@ static void apply_rematrixing(AC3EncodeContext *s)
AC3Block *block = &s->blocks[blk]; AC3Block *block = &s->blocks[blk];
if (block->new_rematrixing_strategy) if (block->new_rematrixing_strategy)
flags = block->rematrixing_flags; flags = block->rematrixing_flags;
for (bnd = 0; bnd < 4; bnd++) {
for (bnd = 0; bnd < s->num_rematrixing_bands; bnd++) {
if (flags[bnd]) { if (flags[bnd]) {
start = ff_ac3_rematrix_band_tab[bnd]; start = ff_ac3_rematrix_band_tab[bnd];
end = FFMIN(nb_coefs, ff_ac3_rematrix_band_tab[bnd+1]); end = FFMIN(nb_coefs, ff_ac3_rematrix_band_tab[bnd+1]);
@@ -785,7 +788,7 @@ static void count_frame_bits(AC3EncodeContext *s)
/* stereo rematrixing */ /* stereo rematrixing */
if (s->channel_mode == AC3_CHMODE_STEREO && if (s->channel_mode == AC3_CHMODE_STEREO &&
s->blocks[blk].new_rematrixing_strategy) { s->blocks[blk].new_rematrixing_strategy) {
frame_bits += 4;
frame_bits += s->num_rematrixing_bands;
} }


for (ch = 0; ch < s->fbw_channels; ch++) { for (ch = 0; ch < s->fbw_channels; ch++) {
@@ -1304,7 +1307,7 @@ static void output_audio_block(AC3EncodeContext *s, int blk)
put_bits(&s->pb, 1, block->new_rematrixing_strategy); put_bits(&s->pb, 1, block->new_rematrixing_strategy);
if (block->new_rematrixing_strategy) { if (block->new_rematrixing_strategy) {
/* rematrixing flags */ /* rematrixing flags */
for (rbnd = 0; rbnd < 4; rbnd++)
for (rbnd = 0; rbnd < s->num_rematrixing_bands; rbnd++)
put_bits(&s->pb, 1, block->rematrixing_flags[rbnd]); put_bits(&s->pb, 1, block->rematrixing_flags[rbnd]);
} }
} }


Loading…
Cancel
Save