lavr: mix front center channel as indicated in the ATSC A/52 specification.
authorTim Walker <tdskywalker@gmail.com>
Wed, 15 Jan 2014 00:18:19 +0000 (00:18 +0000)
committerTim Walker <tdskywalker@gmail.com>
Sat, 8 Feb 2014 12:42:55 +0000 (13:42 +0100)
When mixing 3 front channels into 2, the center channel is mixed into left and right with the center mix level, not -3dB.

libavresample/audio_mix_matrix.c

index 8da1b48..487869b 100644 (file)
@@ -126,8 +126,13 @@ int avresample_build_matrix(uint64_t in_layout, uint64_t out_layout,
     /* mix front center to front left/right */
     if (unaccounted & AV_CH_FRONT_CENTER) {
         if ((out_layout & AV_CH_LAYOUT_STEREO) == AV_CH_LAYOUT_STEREO) {
     /* mix front center to front left/right */
     if (unaccounted & AV_CH_FRONT_CENTER) {
         if ((out_layout & AV_CH_LAYOUT_STEREO) == AV_CH_LAYOUT_STEREO) {
-            matrix[FRONT_LEFT ][FRONT_CENTER] += M_SQRT1_2;
-            matrix[FRONT_RIGHT][FRONT_CENTER] += M_SQRT1_2;
+            if ((in_layout & AV_CH_LAYOUT_STEREO) == AV_CH_LAYOUT_STEREO) {
+                matrix[FRONT_LEFT ][FRONT_CENTER] += center_mix_level;
+                matrix[FRONT_RIGHT][FRONT_CENTER] += center_mix_level;
+            } else {
+                matrix[FRONT_LEFT ][FRONT_CENTER] += M_SQRT1_2;
+                matrix[FRONT_RIGHT][FRONT_CENTER] += M_SQRT1_2;
+            }
         } else
             return AVERROR_PATCHWELCOME;
     }
         } else
             return AVERROR_PATCHWELCOME;
     }