4242 needs_cuda ,
4343 needs_ffmpeg_cli ,
4444 psnr ,
45+ SINE_16_CHANNEL_S16 ,
4546 SINE_MONO_S16 ,
4647 SINE_MONO_S32 ,
4748 SINE_MONO_S32_44100 ,
@@ -1947,7 +1948,9 @@ def test_cpu_fallback_no_fallback_on_supported_video(self, device):
19471948
19481949
19491950class TestAudioDecoder :
1950- @pytest .mark .parametrize ("asset" , (NASA_AUDIO , NASA_AUDIO_MP3 , SINE_MONO_S32 ))
1951+ @pytest .mark .parametrize (
1952+ "asset" , (NASA_AUDIO , NASA_AUDIO_MP3 , SINE_MONO_S32 , SINE_16_CHANNEL_S16 )
1953+ )
19511954 def test_metadata (self , asset ):
19521955 decoder = AudioDecoder (asset .path )
19531956 assert isinstance (decoder .metadata , AudioStreamMetadata )
@@ -2005,7 +2008,7 @@ def test_get_all_samples_with_range(self, asset, stop_seconds):
20052008 assert samples .sample_rate == asset .sample_rate
20062009 assert samples .pts_seconds == asset .get_frame_info (idx = 0 ).pts_seconds
20072010
2008- @pytest .mark .parametrize ("asset" , (NASA_AUDIO , NASA_AUDIO_MP3 ))
2011+ @pytest .mark .parametrize ("asset" , (NASA_AUDIO , NASA_AUDIO_MP3 , SINE_16_CHANNEL_S16 ))
20092012 def test_get_all_samples (self , asset ):
20102013 decoder = AudioDecoder (asset .path )
20112014 torch .testing .assert_close (
@@ -2274,8 +2277,7 @@ def test_samples_duration(self, asset, sample_rate):
22742277 # that the extra tensor allocation that happens within
22752278 # maybeFlushSwrBuffers() is correct.
22762279 @pytest .mark .parametrize ("sample_rate" , (None , 16_000 ))
2277- # FFmpeg can handle up to AV_NUM_DATA_POINTERS=8 channels
2278- @pytest .mark .parametrize ("num_channels" , (1 , 2 , 8 , None ))
2280+ @pytest .mark .parametrize ("num_channels" , (1 , 2 , 8 , 16 , 24 , None ))
22792281 def test_num_channels (self , asset , sample_rate , num_channels ):
22802282 decoder = AudioDecoder (
22812283 asset .path , sample_rate = sample_rate , num_channels = num_channels
@@ -2289,12 +2291,12 @@ def test_num_channels(self, asset, sample_rate, num_channels):
22892291
22902292 @pytest .mark .parametrize ("asset" , (SINE_MONO_S32 , NASA_AUDIO_MP3 ))
22912293 def test_num_channels_errors (self , asset ):
2292- with pytest .raises (
2293- RuntimeError , match = "num_channels must be > 0 and <= AV_NUM_DATA_POINTERS"
2294- ):
2294+ with pytest .raises (RuntimeError , match = "num_channels must be > 0" ):
22952295 AudioDecoder (asset .path , num_channels = 0 )
2296- with pytest .raises (
2297- RuntimeError , match = "num_channels must be > 0 and <= AV_NUM_DATA_POINTERS"
2298- ):
2299- # FFmpeg can handle up to AV_NUM_DATA_POINTERS=8 channels
2300- AudioDecoder (asset .path , num_channels = 9 )
2296+ for num_channels in (15 , 23 ):
2297+ with pytest .raises (RuntimeError , match = "Couldn't initialize SwrContext:" ):
2298+ decoder = AudioDecoder (asset .path , num_channels = num_channels )
2299+ # Call get_all_samples to trigger num_channels conversion.
2300+ # FFmpeg fails to find a default layout for certain channel counts,
2301+ # which causes SwrContext to fail to initialize.
2302+ decoder .get_all_samples ()
0 commit comments