Skip to content

Commit cb9998f

Browse files
authored
Renaming of C++ variables: source* -> src* (#680)
1 parent 66c78c2 commit cb9998f

File tree

3 files changed

+24
-25
lines changed

3 files changed

+24
-25
lines changed

src/torchcodec/_core/FFMPEGCommon.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ void setChannelLayout(
161161
}
162162

163163
SwrContext* createSwrContext(
164-
AVSampleFormat sourceSampleFormat,
164+
AVSampleFormat srcSampleFormat,
165165
AVSampleFormat desiredSampleFormat,
166-
int sourceSampleRate,
166+
int srcSampleRate,
167167
int desiredSampleRate,
168168
const UniqueAVFrame& srcAVFrame,
169169
int desiredNumChannels) {
@@ -178,8 +178,8 @@ SwrContext* createSwrContext(
178178
desiredSampleFormat,
179179
desiredSampleRate,
180180
&srcAVFrame->ch_layout,
181-
sourceSampleFormat,
182-
sourceSampleRate,
181+
srcSampleFormat,
182+
srcSampleRate,
183183
0,
184184
nullptr);
185185

@@ -196,8 +196,8 @@ SwrContext* createSwrContext(
196196
desiredSampleFormat,
197197
desiredSampleRate,
198198
srcAVFrame->channel_layout,
199-
sourceSampleFormat,
200-
sourceSampleRate,
199+
srcSampleFormat,
200+
srcSampleRate,
201201
0,
202202
nullptr);
203203
#endif
@@ -228,8 +228,8 @@ UniqueAVFrame convertAudioAVFrameSamples(
228228
convertedAVFrame->format = static_cast<int>(desiredSampleFormat);
229229

230230
convertedAVFrame->sample_rate = desiredSampleRate;
231-
int sourceSampleRate = srcAVFrame->sample_rate;
232-
if (sourceSampleRate != desiredSampleRate) {
231+
int srcSampleRate = srcAVFrame->sample_rate;
232+
if (srcSampleRate != desiredSampleRate) {
233233
// Note that this is an upper bound on the number of output samples.
234234
// `swr_convert()` will likely not fill convertedAVFrame with that many
235235
// samples if sample rate conversion is needed. It will buffer the last few
@@ -239,10 +239,9 @@ UniqueAVFrame convertAudioAVFrameSamples(
239239
// output samples, but empirically `av_rescale_rnd()` seems to provide a
240240
// tighter bound.
241241
convertedAVFrame->nb_samples = av_rescale_rnd(
242-
swr_get_delay(swrContext.get(), sourceSampleRate) +
243-
srcAVFrame->nb_samples,
242+
swr_get_delay(swrContext.get(), srcSampleRate) + srcAVFrame->nb_samples,
244243
desiredSampleRate,
245-
sourceSampleRate,
244+
srcSampleRate,
246245
AV_ROUND_UP);
247246
} else {
248247
convertedAVFrame->nb_samples = srcAVFrame->nb_samples;

src/torchcodec/_core/FFMPEGCommon.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ void setChannelLayout(
161161
int desiredNumChannels);
162162

163163
SwrContext* createSwrContext(
164-
AVSampleFormat sourceSampleFormat,
164+
AVSampleFormat srcSampleFormat,
165165
AVSampleFormat desiredSampleFormat,
166-
int sourceSampleRate,
166+
int srcSampleRate,
167167
int desiredSampleRate,
168168
const UniqueAVFrame& srcAVFrame,
169169
int desiredNumChannels);

src/torchcodec/_core/SingleStreamDecoder.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,40 +1184,40 @@ FrameOutput SingleStreamDecoder::convertAVFrameToFrameOutput(
11841184
void SingleStreamDecoder::convertAudioAVFrameToFrameOutputOnCPU(
11851185
UniqueAVFrame& srcAVFrame,
11861186
FrameOutput& frameOutput) {
1187-
AVSampleFormat sourceSampleFormat =
1187+
AVSampleFormat srcSampleFormat =
11881188
static_cast<AVSampleFormat>(srcAVFrame->format);
11891189
AVSampleFormat desiredSampleFormat = AV_SAMPLE_FMT_FLTP;
11901190

11911191
StreamInfo& streamInfo = streamInfos_[activeStreamIndex_];
1192-
int sourceSampleRate = srcAVFrame->sample_rate;
1192+
int srcSampleRate = srcAVFrame->sample_rate;
11931193
int desiredSampleRate =
1194-
streamInfo.audioStreamOptions.sampleRate.value_or(sourceSampleRate);
1194+
streamInfo.audioStreamOptions.sampleRate.value_or(srcSampleRate);
11951195

1196-
int sourceNumChannels = getNumChannels(streamInfo.codecContext);
1196+
int srcNumChannels = getNumChannels(streamInfo.codecContext);
11971197
TORCH_CHECK(
1198-
sourceNumChannels == getNumChannels(srcAVFrame),
1198+
srcNumChannels == getNumChannels(srcAVFrame),
11991199
"The frame has ",
12001200
getNumChannels(srcAVFrame),
12011201
" channels, expected ",
1202-
sourceNumChannels,
1202+
srcNumChannels,
12031203
". If you are hitting this, it may be because you are using "
12041204
"a buggy FFmpeg version. FFmpeg4 is known to fail here in some "
12051205
"valid scenarios. Try to upgrade FFmpeg?");
12061206
int desiredNumChannels =
1207-
streamInfo.audioStreamOptions.numChannels.value_or(sourceNumChannels);
1207+
streamInfo.audioStreamOptions.numChannels.value_or(srcNumChannels);
12081208

12091209
bool mustConvert =
1210-
(sourceSampleFormat != desiredSampleFormat ||
1211-
sourceSampleRate != desiredSampleRate ||
1212-
sourceNumChannels != desiredNumChannels);
1210+
(srcSampleFormat != desiredSampleFormat ||
1211+
srcSampleRate != desiredSampleRate ||
1212+
srcNumChannels != desiredNumChannels);
12131213

12141214
UniqueAVFrame convertedAVFrame;
12151215
if (mustConvert) {
12161216
if (!streamInfo.swrContext) {
12171217
streamInfo.swrContext.reset(createSwrContext(
1218-
sourceSampleFormat,
1218+
srcSampleFormat,
12191219
desiredSampleFormat,
1220-
sourceSampleRate,
1220+
srcSampleRate,
12211221
desiredSampleRate,
12221222
srcAVFrame,
12231223
desiredNumChannels));

0 commit comments

Comments
 (0)