Skip to content

Commit ee1c7b7

Browse files
committed
Nit
1 parent 7cb2271 commit ee1c7b7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/torchcodec/decoders/_core/VideoDecoder.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,6 +1468,9 @@ UniqueAVFrame VideoDecoder::convertAudioAVFrameSampleFormatAndSampleRate(
14681468
// samples if sample rate conversion is needed. It will buffer the last few
14691469
// ones because those require future samples. That's also why we reset
14701470
// nb_samples after the call to `swr_convert()`.
1471+
// We could also use `swr_get_out_samples()` to determine the number of
1472+
// output samples, but empirically `av_rescale_rnd()` seems to provide a
1473+
// tighter bound.
14711474
convertedAVFrame->nb_samples = av_rescale_rnd(
14721475
swr_get_delay(streamInfo.swrContext.get(), sourceSampleRate) +
14731476
srcAVFrame->nb_samples,

0 commit comments

Comments
 (0)