Skip to content

Commit ab90612

Browse files
committed
rename 16ch file, remove <8 channels check
1 parent f042228 commit ab90612

File tree

5 files changed

+12
-19
lines changed

5 files changed

+12
-19
lines changed

src/torchcodec/_core/SingleStreamDecoder.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,8 @@ void SingleStreamDecoder::addAudioStream(
571571
"seek_mode must be 'approximate' for audio streams.");
572572
if (audioStreamOptions.numChannels.has_value()) {
573573
TORCH_CHECK(
574-
*audioStreamOptions.numChannels > 0 &&
575-
*audioStreamOptions.numChannels <= AV_NUM_DATA_POINTERS,
576-
"num_channels must be > 0 and <= AV_NUM_DATA_POINTERS (usually 8). Got: ",
574+
*audioStreamOptions.numChannels > 0,
575+
"num_channels must be > 0. Got: ",
577576
*audioStreamOptions.numChannels);
578577
}
579578

test/resources/16ch.wav.stream0.all_frames_info.json renamed to test/resources/sine_16ch_s16.wav.stream0.all_frames_info.json

File renamed without changes.

test/test_decoders.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
needs_cuda,
4444
needs_ffmpeg_cli,
4545
psnr,
46-
SINE_16_CHANNELS,
46+
SINE_16_CHANNEL_S16,
4747
SINE_MONO_S16,
4848
SINE_MONO_S32,
4949
SINE_MONO_S32_44100,
@@ -1791,7 +1791,9 @@ def test_cpu_fallback_no_fallback_on_supported_video(self, device):
17911791

17921792

17931793
class TestAudioDecoder:
1794-
@pytest.mark.parametrize("asset", (NASA_AUDIO, NASA_AUDIO_MP3, SINE_MONO_S32))
1794+
@pytest.mark.parametrize(
1795+
"asset", (NASA_AUDIO, NASA_AUDIO_MP3, SINE_MONO_S32, SINE_16_CHANNEL_S16)
1796+
)
17951797
def test_metadata(self, asset):
17961798
decoder = AudioDecoder(asset.path)
17971799
assert isinstance(decoder.metadata, AudioStreamMetadata)
@@ -1849,7 +1851,7 @@ def test_get_all_samples_with_range(self, asset, stop_seconds):
18491851
assert samples.sample_rate == asset.sample_rate
18501852
assert samples.pts_seconds == asset.get_frame_info(idx=0).pts_seconds
18511853

1852-
@pytest.mark.parametrize("asset", (NASA_AUDIO, NASA_AUDIO_MP3, SINE_16_CHANNELS))
1854+
@pytest.mark.parametrize("asset", (NASA_AUDIO, NASA_AUDIO_MP3, SINE_16_CHANNEL_S16))
18531855
def test_get_all_samples(self, asset):
18541856
decoder = AudioDecoder(asset.path)
18551857
torch.testing.assert_close(
@@ -2118,8 +2120,7 @@ def test_samples_duration(self, asset, sample_rate):
21182120
# that the extra tensor allocation that happens within
21192121
# maybeFlushSwrBuffers() is correct.
21202122
@pytest.mark.parametrize("sample_rate", (None, 16_000))
2121-
# FFmpeg can handle up to AV_NUM_DATA_POINTERS=8 channels
2122-
@pytest.mark.parametrize("num_channels", (1, 2, 8, None))
2123+
@pytest.mark.parametrize("num_channels", (1, 2, 8, 16, None))
21232124
def test_num_channels(self, asset, sample_rate, num_channels):
21242125
decoder = AudioDecoder(
21252126
asset.path, sample_rate=sample_rate, num_channels=num_channels
@@ -2133,12 +2134,5 @@ def test_num_channels(self, asset, sample_rate, num_channels):
21332134

21342135
@pytest.mark.parametrize("asset", (SINE_MONO_S32, NASA_AUDIO_MP3))
21352136
def test_num_channels_errors(self, asset):
2136-
with pytest.raises(
2137-
RuntimeError, match="num_channels must be > 0 and <= AV_NUM_DATA_POINTERS"
2138-
):
2137+
with pytest.raises(RuntimeError, match="num_channels must be > 0"):
21392138
AudioDecoder(asset.path, num_channels=0)
2140-
with pytest.raises(
2141-
RuntimeError, match="num_channels must be > 0 and <= AV_NUM_DATA_POINTERS"
2142-
):
2143-
# FFmpeg can handle up to AV_NUM_DATA_POINTERS=8 channels
2144-
AudioDecoder(asset.path, num_channels=9)

test/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -836,9 +836,9 @@ def sample_format(self) -> str:
836836
)
837837

838838
# 16-channel audio for testing support for >8 channels. Generated with:
839-
# ffmpeg -i test/resources/sine_mono_s32.wav -t 1 -filter_complex "[0]asplit=16[s0][s1][s2][s3][s4][s5][s6][s7][s8][s9][s10][s11][s12][s13][s14][s15];[s0][s1][s2][s3][s4][s5][s6][s7][s8][s9][s10][s11][s12][s13][s14][s15]amerge=inputs=16" -c:a pcm_s16le test/resources/16ch.wav
840-
SINE_16_CHANNELS = TestAudio(
841-
filename="16ch.wav",
839+
# ffmpeg -i test/resources/sine_mono_s32.wav -t 1 -filter_complex "[0]asplit=16[s0][s1][s2][s3][s4][s5][s6][s7][s8][s9][s10][s11][s12][s13][s14][s15];[s0][s1][s2][s3][s4][s5][s6][s7][s8][s9][s10][s11][s12][s13][s14][s15]amerge=inputs=16" -c:a pcm_s16le test/resources/sine_16ch_s16.wav
840+
SINE_16_CHANNEL_S16 = TestAudio(
841+
filename="sine_16ch_s16.wav",
842842
default_stream_index=0,
843843
frames={}, # Automatically loaded from json file
844844
stream_infos={

0 commit comments

Comments
 (0)