From a3735bb92a6b65eeed0f646336dba9776a9479dc Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Fri, 18 Jan 2013 13:34:26 -0500 Subject: lavr: cosmetics: reindent --- libavresample/audio_mix.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'libavresample') diff --git a/libavresample/audio_mix.c b/libavresample/audio_mix.c index fc37eac6a3..096bcf3d66 100644 --- a/libavresample/audio_mix.c +++ b/libavresample/audio_mix.c @@ -673,20 +673,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); -- cgit v1.2.3 From 600b4c973fb98f07ec3c5837112865048fb8a607 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Fri, 18 Jan 2013 13:44:10 -0500 Subject: lavr: fix matrix reduction for upmixing in certain cases Do not skip an output if the corresponding input contributes to other output channels. --- libavresample/audio_mix.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libavresample') diff --git a/libavresample/audio_mix.c b/libavresample/audio_mix.c index 096bcf3d66..487bddf746 100644 --- a/libavresample/audio_mix.c +++ b/libavresample/audio_mix.c @@ -607,6 +607,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 +616,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--; -- cgit v1.2.3 From 157542ebc15dd175e5b4d14ffa92afd74ab4a991 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sun, 27 Jan 2013 14:47:54 -0500 Subject: lavr: fix mixing matrix reduction when normalization is disabled In some cases when an input contributes fully to the corresponding output, other inputs may also contribute to the same output. This is the case, for example, for the default 5.1 to stereo downmix matrix without normalization. --- libavresample/audio_mix.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libavresample') diff --git a/libavresample/audio_mix.c b/libavresample/audio_mix.c index 487bddf746..b69bfbcf3e 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; -- cgit v1.2.3