mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
Revert commit made in revision 11228. I'm getting some strange results in the
downmixed output that I can't quite figure out. Originally committed as revision 11245 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
407c50a024
commit
224bc440b2
@ -750,28 +750,27 @@ static inline void do_imdct(AC3DecodeContext *ctx)
|
|||||||
/**
|
/**
|
||||||
* Downmix the output to mono or stereo.
|
* Downmix the output to mono or stereo.
|
||||||
*/
|
*/
|
||||||
static void ac3_downmix(float samples[][256], int fbw_channels,
|
static void ac3_downmix(float samples[AC3_MAX_CHANNELS][256], int fbw_channels,
|
||||||
int output_mode, float coef[AC3_MAX_CHANNELS][2],
|
int output_mode, float coef[AC3_MAX_CHANNELS][2])
|
||||||
int ch_offset)
|
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
float v0, v1, s0, s1;
|
float v0, v1, s0, s1;
|
||||||
|
|
||||||
for(i=0; i<256; i++) {
|
for(i=0; i<256; i++) {
|
||||||
v0 = v1 = s0 = s1 = 0.0f;
|
v0 = v1 = s0 = s1 = 0.0f;
|
||||||
for(j=ch_offset; j<fbw_channels+ch_offset; j++) {
|
for(j=0; j<fbw_channels; j++) {
|
||||||
v0 += samples[j][i] * coef[j-ch_offset][0];
|
v0 += samples[j][i] * coef[j][0];
|
||||||
v1 += samples[j][i] * coef[j-ch_offset][1];
|
v1 += samples[j][i] * coef[j][1];
|
||||||
s0 += coef[j-ch_offset][0];
|
s0 += coef[j][0];
|
||||||
s1 += coef[j-ch_offset][1];
|
s1 += coef[j][1];
|
||||||
}
|
}
|
||||||
v0 /= s0;
|
v0 /= s0;
|
||||||
v1 /= s1;
|
v1 /= s1;
|
||||||
if(output_mode == AC3_CHMODE_MONO) {
|
if(output_mode == AC3_CHMODE_MONO) {
|
||||||
samples[ch_offset][i] = (v0 + v1) * LEVEL_MINUS_3DB;
|
samples[0][i] = (v0 + v1) * LEVEL_MINUS_3DB;
|
||||||
} else if(output_mode == AC3_CHMODE_STEREO) {
|
} else if(output_mode == AC3_CHMODE_STEREO) {
|
||||||
samples[ch_offset][i] = v0;
|
samples[0][i] = v0;
|
||||||
samples[ch_offset+1][i] = v1;
|
samples[1][i] = v1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -786,16 +785,12 @@ static int ac3_parse_audio_block(AC3DecodeContext *ctx, int blk)
|
|||||||
int i, bnd, seg, ch;
|
int i, bnd, seg, ch;
|
||||||
GetBitContext *gb = &ctx->gb;
|
GetBitContext *gb = &ctx->gb;
|
||||||
uint8_t bit_alloc_stages[AC3_MAX_CHANNELS];
|
uint8_t bit_alloc_stages[AC3_MAX_CHANNELS];
|
||||||
int any_block_switching = 0;
|
|
||||||
int num_channels_bak, fbw_channels_bak;
|
|
||||||
|
|
||||||
memset(bit_alloc_stages, 0, AC3_MAX_CHANNELS);
|
memset(bit_alloc_stages, 0, AC3_MAX_CHANNELS);
|
||||||
|
|
||||||
/* block switch flags */
|
/* block switch flags */
|
||||||
for (ch = 1; ch <= fbw_channels; ch++) {
|
for (ch = 1; ch <= fbw_channels; ch++)
|
||||||
ctx->block_switch[ch] = get_bits1(gb);
|
ctx->block_switch[ch] = get_bits1(gb);
|
||||||
any_block_switching |= ctx->block_switch[ch];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* dithering flags */
|
/* dithering flags */
|
||||||
ctx->dither_all = 1;
|
ctx->dither_all = 1;
|
||||||
@ -1067,26 +1062,13 @@ static int ac3_parse_audio_block(AC3DecodeContext *ctx, int blk)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if no block switching is used, downmixing can be done before IMDCT */
|
|
||||||
num_channels_bak = ctx->channels;
|
|
||||||
fbw_channels_bak = ctx->fbw_channels;
|
|
||||||
if(!any_block_switching) {
|
|
||||||
if(ctx->channels != ctx->out_channels && !((ctx->output_mode & AC3_OUTPUT_LFEON) &&
|
|
||||||
ctx->fbw_channels == ctx->out_channels)) {
|
|
||||||
ac3_downmix(ctx->transform_coeffs, ctx->fbw_channels,
|
|
||||||
ctx->output_mode, ctx->downmix_coeffs, 1);
|
|
||||||
ctx->channels = ctx->out_channels;
|
|
||||||
ctx->fbw_channels = ctx->channels - (ctx->output_mode & AC3_OUTPUT_LFEON);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
do_imdct(ctx);
|
do_imdct(ctx);
|
||||||
|
|
||||||
/* downmix output now if it wasn't done before IMDCT */
|
/* downmix output if needed */
|
||||||
if(ctx->channels != ctx->out_channels && !((ctx->output_mode & AC3_OUTPUT_LFEON) &&
|
if(ctx->channels != ctx->out_channels && !((ctx->output_mode & AC3_OUTPUT_LFEON) &&
|
||||||
ctx->fbw_channels == ctx->out_channels)) {
|
ctx->fbw_channels == ctx->out_channels)) {
|
||||||
ac3_downmix(ctx->output, ctx->fbw_channels, ctx->output_mode,
|
ac3_downmix(ctx->output, ctx->fbw_channels, ctx->output_mode,
|
||||||
ctx->downmix_coeffs, 0);
|
ctx->downmix_coeffs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* convert float to 16-bit integer */
|
/* convert float to 16-bit integer */
|
||||||
@ -1097,9 +1079,6 @@ static int ac3_parse_audio_block(AC3DecodeContext *ctx, int blk)
|
|||||||
ctx->dsp.float_to_int16(ctx->int_output[ch], ctx->output[ch], 256);
|
ctx->dsp.float_to_int16(ctx->int_output[ch], ctx->output[ch], 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->channels = num_channels_bak;
|
|
||||||
ctx->fbw_channels = fbw_channels_bak;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user