summaryrefslogtreecommitdiff
path: root/libswresample
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2022-10-30 20:47:36 -0300
committerJames Almer <jamrial@gmail.com>2022-11-03 19:39:52 -0300
commitc79b16306f6c612cb5ef970b2745564082bb8d16 (patch)
tree4b3694dbefcd4c33eb0c1ef503f464f8a1b40cb5 /libswresample
parent6228ba141df5e00cdc46e70d082c8399179476bf (diff)
downloadffmpeg-c79b16306f6c612cb5ef970b2745564082bb8d16.tar.gz
swresample/rematrix: support mixing top front left/right channels
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libswresample')
-rw-r--r--libswresample/rematrix.c24
1 files changed, 24 insertions, 0 deletions
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) {