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>
This commit is contained in:
Michael Niedermayer 2013-02-13 12:58:24 +01:00
commit 845fa2f5c9

View File

@ -572,11 +572,22 @@ static void reduce_matrix(AudioMix *am, const double *matrix, int stride)
int skip = 1; int skip = 1;
for (o = 0; o < am->out_channels; o++) { for (o = 0; o < am->out_channels; o++) {
int i0;
if ((o != i && matrix[o * stride + i] != 0.0) || if ((o != i && matrix[o * stride + i] != 0.0) ||
(o == i && matrix[o * stride + i] != 1.0)) { (o == i && matrix[o * stride + i] != 1.0)) {
skip = 0; skip = 0;
break; 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) { if (skip) {
am->input_skip[i] = 1; am->input_skip[i] = 1;
@ -607,6 +618,7 @@ static void reduce_matrix(AudioMix *am, const double *matrix, int stride)
corresponding input channel */ corresponding input channel */
for (o = 0; o < FFMIN(am->in_channels, am->out_channels); o++) { for (o = 0; o < FFMIN(am->in_channels, am->out_channels); o++) {
int skip = 1; int skip = 1;
int o0;
for (i = 0; i < am->in_channels; i++) { for (i = 0; i < am->in_channels; i++) {
if ((o != i && matrix[o * stride + i] != 0.0) || 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; 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) { if (skip) {
am->output_skip[o] = 1; am->output_skip[o] = 1;
am->out_matrix_channels--; 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; am->matrix = (void **)am->matrix_## type;
if (am->in_matrix_channels && am->out_matrix_channels) { if (am->in_matrix_channels && am->out_matrix_channels) {
switch (am->coeff_type) { switch (am->coeff_type) {
case AV_MIX_COEFF_TYPE_Q8: case AV_MIX_COEFF_TYPE_Q8:
CONVERT_MATRIX(q8, av_clip_int16(lrint(256.0 * v))) CONVERT_MATRIX(q8, av_clip_int16(lrint(256.0 * v)))
break; break;
case AV_MIX_COEFF_TYPE_Q15: case AV_MIX_COEFF_TYPE_Q15:
CONVERT_MATRIX(q15, av_clipl_int32(llrint(32768.0 * v))) CONVERT_MATRIX(q15, av_clipl_int32(llrint(32768.0 * v)))
break; break;
case AV_MIX_COEFF_TYPE_FLT: case AV_MIX_COEFF_TYPE_FLT:
CONVERT_MATRIX(flt, v) CONVERT_MATRIX(flt, v)
break; break;
default: default:
av_log(am->avr, AV_LOG_ERROR, "Invalid mix coeff type\n"); av_log(am->avr, AV_LOG_ERROR, "Invalid mix coeff type\n");
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
} }
ret = mix_function_init(am); ret = mix_function_init(am);