Signed-off-by: James Almer <jamr...@gmail.com>
---
 libswresample/rematrix.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c
index fe823dc575..0c3fff6c42 100644
--- a/libswresample/rematrix.c
+++ b/libswresample/rematrix.c
@@ -138,6 +138,8 @@ static int sane_layout(AVChannelLayout *ch_layout) {
         return 0;
     if(!even(av_channel_layout_subset(ch_layout, (AV_CH_FRONT_LEFT_OF_CENTER | 
AV_CH_FRONT_RIGHT_OF_CENTER))))
         return 0;
+    if(!even(av_channel_layout_subset(ch_layout, (AV_CH_TOP_FRONT_LEFT | 
AV_CH_TOP_FRONT_RIGHT))))
+        return 0;
     if(ch_layout->nb_channels >= SWR_CH_MAX)
         return 0;
 
@@ -369,6 +371,28 @@ av_cold int swr_build_matrix2(const AVChannelLayout 
*in_layout, const AVChannelL
         }else
             av_assert0(0);
     }
+
+    if (unaccounted & AV_CH_TOP_FRONT_LEFT) {
+        if (av_channel_layout_index_from_channel(&out_ch_layout, 
AV_CHAN_TOP_FRONT_CENTER) >= 0) {
+            matrix[TOP_FRONT_CENTER][TOP_FRONT_LEFT ] += M_SQRT1_2;
+            matrix[TOP_FRONT_CENTER][TOP_FRONT_RIGHT] += M_SQRT1_2;
+            if (av_channel_layout_index_from_channel(&in_ch_layout, 
AV_CHAN_TOP_FRONT_CENTER) >= 0)
+                matrix[TOP_FRONT_CENTER][TOP_FRONT_CENTER] = center_mix_level 
* sqrt(2);
+        } else if (av_channel_layout_index_from_channel(&out_ch_layout, 
AV_CHAN_FRONT_LEFT) >= 0) {
+            if (av_channel_layout_index_from_channel(&in_ch_layout, 
AV_CHAN_FRONT_LEFT) >= 0) {
+                matrix[FRONT_LEFT ][TOP_FRONT_LEFT ] += M_SQRT1_2;
+                matrix[FRONT_RIGHT][TOP_FRONT_RIGHT] += M_SQRT1_2;
+            } else {
+                matrix[FRONT_LEFT ][TOP_FRONT_LEFT ] += 1.0;
+                matrix[FRONT_RIGHT][TOP_FRONT_RIGHT] += 1.0;
+            }
+        } else if (av_channel_layout_index_from_channel(&out_ch_layout, 
AV_CHAN_FRONT_CENTER) >= 0) {
+            matrix[FRONT_CENTER][TOP_FRONT_LEFT ] += M_SQRT1_2;
+            matrix[FRONT_CENTER][TOP_FRONT_RIGHT] += M_SQRT1_2;
+        } else
+            av_assert0(0);
+    }
+
     /* mix LFE into front left/right or center */
     if (unaccounted & AV_CH_LOW_FREQUENCY) {
         if (av_channel_layout_index_from_channel(&out_ch_layout, 
AV_CHAN_FRONT_CENTER) >= 0) {
-- 
2.38.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to