Skip to content

Commit 4fa95eb

Browse files
committed
Rebase fixups: drop helpers that moved to the parent PR, fix renames
- get_swr_output_num_samples_bound is now declared and defined by the parent commit, so remove this branch's copy. - swr_convert_to_tensor keeps the parent's `const uint8_t**` parameter, which is what compiles against FFmpeg 4-6 as well as 7+. - PacketDecoder became AudioPacketDecoder in #1666; update the converter tests.
1 parent 0ca9345 commit 4fa95eb

3 files changed

Lines changed: 3 additions & 32 deletions

File tree

src/torchcodec/_core/FFMPEGCommon.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -640,26 +640,6 @@ AVFilterContext* create_av_filter_context_with_options(
640640
return av_filter_context;
641641
}
642642

643-
int64_t get_swr_output_num_samples_bound(
644-
const UniqueSwrContext& swr_context,
645-
int num_src_samples,
646-
int src_sample_rate,
647-
int out_sample_rate) {
648-
if (src_sample_rate == out_sample_rate) {
649-
return num_src_samples;
650-
}
651-
// `swr_convert()` will likely not produce this many samples: it buffers the
652-
// last few, because those require future input. That's why callers must
653-
// narrow to what it actually returned. We could also use
654-
// `swr_get_out_samples()`, but empirically `av_rescale_rnd()` gives a
655-
// tighter bound.
656-
return av_rescale_rnd(
657-
swr_get_delay(swr_context.get(), src_sample_rate) + num_src_samples,
658-
out_sample_rate,
659-
src_sample_rate,
660-
AV_ROUND_UP);
661-
}
662-
663643
UniqueAVFrame convert_audio_av_frame_samples(
664644
const UniqueSwrContext& swr_context,
665645
const AVFrame& src_av_frame,

src/torchcodec/_core/FFMPEGCommon.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -349,15 +349,6 @@ UniqueAVFrame convert_audio_av_frame_samples(
349349
int desired_num_channels,
350350
int num_samples_to_skip = 0);
351351

352-
// Upper bound on the number of samples swr_convert() can emit for
353-
// num_src_samples of input, including whatever it still holds buffered. It is
354-
// only a bound: narrow the output down to what swr_convert() returned.
355-
int64_t get_swr_output_num_samples_bound(
356-
const UniqueSwrContext& swr_context,
357-
int num_src_samples,
358-
int src_sample_rate,
359-
int out_sample_rate);
360-
361352
// Returns true if sws_scale can handle unaligned data.
362353
bool can_sws_scale_handle_unaligned_data();
363354

test/test_decoders.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5231,7 +5231,7 @@ def test_audio_decoder_mpeg_ps_resync_after_seek(self):
52315231
@staticmethod
52325232
def _convert_audio(asset, drain=True, **converter_kwargs):
52335233
demuxer = AudioDemuxer(asset.path)
5234-
decoder = PacketDecoder(demuxer)
5234+
decoder = AudioPacketDecoder(demuxer)
52355235
converter = AudioConverter(**converter_kwargs)
52365236

52375237
chunks = []
@@ -5345,7 +5345,7 @@ def test_audio_converter_reset_allows_another_stream(self):
53455345

53465346
def convert_all(asset):
53475347
demuxer = AudioDemuxer(asset.path)
5348-
decoder = PacketDecoder(demuxer)
5348+
decoder = AudioPacketDecoder(demuxer)
53495349
chunks = []
53505350
for packet in demuxer:
53515351
chunks += [converter.convert(raw) for raw in decoder.decode(packet)]
@@ -5402,7 +5402,7 @@ def test_audio_pipeline_after_seek(self):
54025402
).shape[1]
54035403

54045404
demuxer = AudioDemuxer(NASA_AUDIO_MP3.path)
5405-
decoder = PacketDecoder(demuxer)
5405+
decoder = AudioPacketDecoder(demuxer)
54065406
converter = AudioConverter(sample_rate=16_000)
54075407
demuxer.seek(seek_seconds)
54085408
decoder.reset()

0 commit comments

Comments
 (0)