summaryrefslogtreecommitdiffstats
path: root/libavresample
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-02-13 12:58:24 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-02-13 12:58:29 +0100
commit845fa2f5c9643a2f80b29614351609f1f1d3994d (patch)
tree7a3b1136b62cfaeb8889e1709a225c52ab207edb /libavresample
parent91043de8256fa87a0a20cc3a139f668110257dbe (diff)
parent157542ebc15dd175e5b4d14ffa92afd74ab4a991 (diff)
downloadffmpeg-streaming-845fa2f5c9643a2f80b29614351609f1f1d3994d.zip
ffmpeg-streaming-845fa2f5c9643a2f80b29614351609f1f1d3994d.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: lavr: fix mixing matrix reduction when normalization is disabled lavr: fix matrix reduction for upmixing in certain cases lavr: cosmetics: reindent Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavresample')
-rw-r--r--libavresample/audio_mix.c49
1 files changed, 35 insertions, 14 deletions
diff --git a/libavresample/audio_mix.c b/libavresample/audio_mix.c
index fc37eac..b69bfbc 100644
--- a/libavresample/audio_mix.c
+++ b/libavresample/audio_mix.c
@@ -572,11 +572,22 @@ static void reduce_matrix(AudioMix *am, const double *matrix, int stride)
int skip = 1;
for (o = 0; o < am->out_channels; o++) {
+ int i0;
if ((o != i && matrix[o * stride + i] != 0.0) ||
(o == i && matrix[o * stride + i] != 1.0)) {
skip = 0;
break;
}
+ /* if the input contributes fully to the output, also check that no
+ other inputs contribute to this output */
+ if (o == i) {
+ for (i0 = 0; i0 < am->in_channels; i0++) {
+ if (i0 != i && matrix[o * stride + i0] != 0.0) {
+ skip = 0;
+ break;
+ }
+ }
+ }
}
if (skip) {
am->input_skip[i] = 1;
@@ -607,6 +618,7 @@ static void reduce_matrix(AudioMix *am, const double *matrix, int stride)
corresponding input channel */
for (o = 0; o < FFMIN(am->in_channels, am->out_channels); o++) {
int skip = 1;
+ int o0;
for (i = 0; i < am->in_channels; i++) {
if ((o != i && matrix[o * stride + i] != 0.0) ||
@@ -615,6 +627,15 @@ static void reduce_matrix(AudioMix *am, const double *matrix, int stride)
break;
}
}
+ /* check if the corresponding input channel makes a contribution to
+ any other output channel */
+ i = o;
+ for (o0 = 0; o0 < am->out_channels; o0++) {
+ if (o0 != i && matrix[o0 * stride + i] != 0.0) {
+ skip = 0;
+ break;
+ }
+ }
if (skip) {
am->output_skip[o] = 1;
am->out_matrix_channels--;
@@ -673,20 +694,20 @@ int ff_audio_mix_set_matrix(AudioMix *am, const double *matrix, int stride)
am->matrix = (void **)am->matrix_## type;
if (am->in_matrix_channels && am->out_matrix_channels) {
- switch (am->coeff_type) {
- case AV_MIX_COEFF_TYPE_Q8:
- CONVERT_MATRIX(q8, av_clip_int16(lrint(256.0 * v)))
- break;
- case AV_MIX_COEFF_TYPE_Q15:
- CONVERT_MATRIX(q15, av_clipl_int32(llrint(32768.0 * v)))
- break;
- case AV_MIX_COEFF_TYPE_FLT:
- CONVERT_MATRIX(flt, v)
- break;
- default:
- av_log(am->avr, AV_LOG_ERROR, "Invalid mix coeff type\n");
- return AVERROR(EINVAL);
- }
+ switch (am->coeff_type) {
+ case AV_MIX_COEFF_TYPE_Q8:
+ CONVERT_MATRIX(q8, av_clip_int16(lrint(256.0 * v)))
+ break;
+ case AV_MIX_COEFF_TYPE_Q15:
+ CONVERT_MATRIX(q15, av_clipl_int32(llrint(32768.0 * v)))
+ break;
+ case AV_MIX_COEFF_TYPE_FLT:
+ CONVERT_MATRIX(flt, v)
+ break;
+ default:
+ av_log(am->avr, AV_LOG_ERROR, "Invalid mix coeff type\n");
+ return AVERROR(EINVAL);
+ }
}
ret = mix_function_init(am);
OpenPOWER on IntegriCloud