|
|
@ -735,27 +735,26 @@ static inline void do_imdct(AC3DecodeContext *s) |
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Downmix the output to mono or stereo. |
|
|
|
* Downmix the output to mono or stereo. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static void ac3_downmix(float samples[AC3_MAX_CHANNELS][256], int fbw_channels, |
|
|
|
static void ac3_downmix(AC3DecodeContext *s) |
|
|
|
int output_mode, float coef[AC3_MAX_CHANNELS][2]) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
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=0; j<fbw_channels; j++) { |
|
|
|
for(j=0; j<s->fbw_channels; j++) { |
|
|
|
v0 += samples[j][i] * coef[j][0]; |
|
|
|
v0 += s->output[j][i] * s->downmix_coeffs[j][0]; |
|
|
|
v1 += samples[j][i] * coef[j][1]; |
|
|
|
v1 += s->output[j][i] * s->downmix_coeffs[j][1]; |
|
|
|
s0 += coef[j][0]; |
|
|
|
s0 += s->downmix_coeffs[j][0]; |
|
|
|
s1 += coef[j][1]; |
|
|
|
s1 += s->downmix_coeffs[j][1]; |
|
|
|
} |
|
|
|
} |
|
|
|
v0 /= s0; |
|
|
|
v0 /= s0; |
|
|
|
v1 /= s1; |
|
|
|
v1 /= s1; |
|
|
|
if(output_mode == AC3_CHMODE_MONO) { |
|
|
|
if(s->output_mode == AC3_CHMODE_MONO) { |
|
|
|
samples[0][i] = (v0 + v1) * LEVEL_MINUS_3DB; |
|
|
|
s->output[0][i] = (v0 + v1) * LEVEL_MINUS_3DB; |
|
|
|
} else if(output_mode == AC3_CHMODE_STEREO) { |
|
|
|
} else if(s->output_mode == AC3_CHMODE_STEREO) { |
|
|
|
samples[0][i] = v0; |
|
|
|
s->output[0][i] = v0; |
|
|
|
samples[1][i] = v1; |
|
|
|
s->output[1][i] = v1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1053,8 +1052,7 @@ static int ac3_parse_audio_block(AC3DecodeContext *s, int blk) |
|
|
|
/* downmix output if needed */ |
|
|
|
/* downmix output if needed */ |
|
|
|
if(s->channels != s->out_channels && !((s->output_mode & AC3_OUTPUT_LFEON) && |
|
|
|
if(s->channels != s->out_channels && !((s->output_mode & AC3_OUTPUT_LFEON) && |
|
|
|
s->fbw_channels == s->out_channels)) { |
|
|
|
s->fbw_channels == s->out_channels)) { |
|
|
|
ac3_downmix(s->output, s->fbw_channels, s->output_mode, |
|
|
|
ac3_downmix(s); |
|
|
|
s->downmix_coeffs); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* convert float to 16-bit integer */ |
|
|
|
/* convert float to 16-bit integer */ |
|
|
|