Skip to content

Commit a0ceebe

Browse files
committed
remove comments
1 parent 1646609 commit a0ceebe

3 files changed

Lines changed: 5 additions & 19 deletions

File tree

src/torchcodec/_core/AudioConverter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ torch::stable::Tensor AudioConverter::convert(
9999
src_planes[channel] = base + channel * bytes_per_channel;
100100
}
101101

102+
// TODO_API_BREAKDOWN CC P2: the CPUDeviceInterface relies on
103+
// swr_convert_to_tensor but only for flushing. We effectively have two
104+
// code-paths doing libswresample conversion. Worth aligning.
102105
return swr_convert_to_tensor(
103106
swr_context_,
104107
src_planes.data(),

src/torchcodec/_core/AudioConverter.h

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,20 @@ namespace facebook::torchcodec {
1616
// Audio conversion building block: turns a decoded frame's samples, in the
1717
// codec's own sample type, into normalized float32 ones - optionally at another
1818
// sample rate, and with another channel count.
19-
//
20-
// Unlike ColorConverter this is a stream processor, not a function of its
21-
// input, because resampling is an interpolation filter: the sample it emits at
22-
// a given instant is a weighted sum of input samples on both sides of it. So
23-
// swresample holds the tail of each frame back until the next one arrives,
24-
// which means convert() emits fewer samples than it was given (sometimes none),
25-
// drain() is needed to get the last ones out, and frames must be fed in order.
26-
// reset() drops that state, and is what a caller must do after seeking.
27-
//
19+
2820
// Not thread-safe.
2921
class FORCE_PUBLIC_VISIBILITY AudioConverter {
3022
public:
31-
// Both default to the source's own value, i.e. to no conversion. Note that
32-
// the sample *type* is always converted, to float32.
3323
explicit AudioConverter(
3424
std::optional<int> sample_rate = std::nullopt,
3525
std::optional<int> num_channels = std::nullopt);
3626

37-
// `samples` is a contiguous [num_channels, num_samples] tensor in the
38-
// source's own sample type, i.e. exactly what audio_samples() produces.
39-
// Returns the samples that are now computable, as float32
40-
// [out_num_channels, N] - and N may well be 0.
4127
torch::stable::Tensor convert(
4228
const torch::stable::Tensor& samples,
4329
int sample_rate);
4430

45-
// The samples swresample was still holding on to. Callers who skip this lose
46-
// the tail of the stream.
4731
torch::stable::Tensor drain();
4832

49-
// Drop the resampler's buffered state and start over, so that the next
50-
// convert() call reconfigures from the samples it is given.
5133
void reset();
5234

5335
bool has_converted_samples() const {

src/torchcodec/_core/FFMPEGCommon.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ SwrContext* create_swr_context(
557557
out_layout);
558558
}
559559

560+
// TODO Other places use the built-in swr_get_out_samples. We should align.
560561
int64_t get_swr_output_num_samples_bound(
561562
const UniqueSwrContext& swr_context,
562563
int num_src_samples,

0 commit comments

Comments
 (0)