[vlc-commits] [Git][videolan/vlc][3.0.x] demux: mkv: improve wav multichannel support
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sun Aug 9 15:46:17 UTC 2026
Steve Lhomme pushed to branch 3.0.x at VideoLAN / VLC
Commits:
1010bf3e by Steve Lhomme at 2026-08-09T15:29:00+00:00
demux: mkv: improve wav multichannel support
Similar to the wav.c ChunkParseFmt() code from 93387674915f623381cd08aedb0638b238c19104.
Fixes #29969
(cherry picked from commit cd41b6e0d4125c0caef5dcbde1bcae9d676c3bd1)
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
1 changed file:
- modules/demux/mkv/matroska_segment_parse.cpp
Changes:
=====================================
modules/demux/mkv/matroska_segment_parse.cpp
=====================================
@@ -1757,6 +1757,41 @@ bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
unsigned i_channel_mask = getChannelMask( &wfextcm,
p_tk->fmt.audio.i_channels,
&match );
+
+ if( match < p_fmt->audio.i_channels )
+ {
+ int i_missing = p_fmt->audio.i_channels - match;
+ msg_Warn( vars.p_demuxer, "Trying to fill up unspecified position for %d channels", p_fmt->audio.i_channels - match );
+
+ static const uint32_t pi_pair[] = { AOUT_CHAN_REARLEFT|AOUT_CHAN_REARRIGHT,
+ AOUT_CHAN_MIDDLELEFT|AOUT_CHAN_MIDDLERIGHT,
+ AOUT_CHAN_LEFT|AOUT_CHAN_RIGHT };
+
+ /* Try to complete with pair */
+ for( unsigned i = 0; i < ARRAY_SIZE(pi_pair); i++ )
+ {
+ if( i_missing >= 2 && !(i_channel_mask & pi_pair[i] ) )
+ {
+ i_missing -= 2;
+ i_channel_mask |= pi_pair[i];
+ }
+ }
+ /* Well fill up with what we can */
+ for( unsigned i = 0; i < ARRAY_SIZE(pi_channels_aout) && i_missing > 0; i++ )
+ {
+ if( !( i_channel_mask & pi_channels_aout[i] ) )
+ {
+ i_channel_mask |= pi_channels_aout[i];
+ i_missing--;
+
+ if( i_missing <= 0 )
+ break;
+ }
+ }
+
+ match = p_fmt->audio.i_channels - i_missing;
+ }
+
p_tk->fmt.i_codec = vlc_fourcc_GetCodecAudio( p_tk->fmt.i_codec,
p_tk->fmt.audio.i_bitspersample );
if( i_channel_mask )
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/1010bf3e447af606feb71d7f46d28f9df33b74f8
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/1010bf3e447af606feb71d7f46d28f9df33b74f8
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list