Skip to content

Commit 8f20a8f

Browse files
author
Daniel Flores
committed
add torch check when avcodec_get_supported_config fails
1 parent a7faca0 commit 8f20a8f

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/torchcodec/_core/Encoder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void validateSampleRate(const AVCodec& avCodec, int sampleRate) {
4444
(const void**)&supportedSampleRates,
4545
&numSampleRates);
4646
if (ret < 0 || supportedSampleRates == nullptr) {
47-
// If we can't validate, assume it'll be fine??
47+
TORCH_CHECK(false, "Couldn't get supported sample rates from encoder.");
4848
return;
4949
}
5050
#else

src/torchcodec/_core/FFMPEGCommon.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,10 @@ void validateNumChannels(const AVCodec& avCodec, int numChannels) {
118118
&avCodec,
119119
AV_CODEC_CONFIG_CHANNEL_LAYOUT,
120120
0,
121-
(const void**)&supported_layouts, // use this instead of building
122-
// supportedNumChannels?
121+
(const void**)&supported_layouts,
123122
&num_layouts);
124123
if (ret < 0 || supported_layouts == nullptr) {
125-
// If we can't validate, assume it'll be fine??
124+
TORCH_CHECK(false, "Couldn't get supported channel layouts from encoder.");
126125
return;
127126
}
128127
for (int i = 0; supported_layouts[i].nb_channels != 0; ++i) {

0 commit comments

Comments
 (0)