[FFmpeg-cvslog] swresample/rematrix: support mixing top front left/right channels
James Almer
git at videolan.org
Fri Nov 4 00:45:10 EET 2022
ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Sun Oct 30 20:47:36 2022 -0300| [c79b16306f6c612cb5ef970b2745564082bb8d16] | committer: James Almer
swresample/rematrix: support mixing top front left/right channels
Signed-off-by: James Almer <jamrial at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c79b16306f6c612cb5ef970b2745564082bb8d16
---
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) {
More information about the ffmpeg-cvslog
mailing list