Skip to content

Commit f565e86

Browse files
NicolasHugscotts
andauthored
Align variable and type names across the codebase (#462)
Co-authored-by: Scott Schneider <[email protected]>
1 parent 9a9d17c commit f565e86

File tree

7 files changed

+263
-237
lines changed

7 files changed

+263
-237
lines changed

src/torchcodec/decoders/_core/CPUOnlyDevice.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace facebook::torchcodec {
1616

1717
void convertAVFrameToDecodedOutputOnCuda(
1818
const torch::Device& device,
19-
[[maybe_unused]] const VideoDecoder::VideoStreamDecoderOptions& options,
19+
[[maybe_unused]] const VideoDecoder::VideoStreamOptions& videoStreamOptions,
2020
[[maybe_unused]] VideoDecoder::RawDecodedOutput& rawOutput,
2121
[[maybe_unused]] VideoDecoder::DecodedOutput& output,
2222
[[maybe_unused]] std::optional<torch::Tensor> preAllocatedOutputTensor) {

src/torchcodec/decoders/_core/CudaDevice.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,18 @@ void initializeContextOnCuda(
185185

186186
void convertAVFrameToDecodedOutputOnCuda(
187187
const torch::Device& device,
188-
const VideoDecoder::VideoStreamDecoderOptions& options,
188+
const VideoDecoder::VideoStreamOptions& videoStreamOptions,
189189
VideoDecoder::RawDecodedOutput& rawOutput,
190190
VideoDecoder::DecodedOutput& output,
191191
std::optional<torch::Tensor> preAllocatedOutputTensor) {
192-
AVFrame* src = rawOutput.frame.get();
192+
AVFrame* avFrame = rawOutput.avFrame.get();
193193

194194
TORCH_CHECK(
195-
src->format == AV_PIX_FMT_CUDA,
195+
avFrame->format == AV_PIX_FMT_CUDA,
196196
"Expected format to be AV_PIX_FMT_CUDA, got " +
197-
std::string(av_get_pix_fmt_name((AVPixelFormat)src->format)));
198-
auto frameDims = getHeightAndWidthFromOptionsOrAVFrame(options, *src);
197+
std::string(av_get_pix_fmt_name((AVPixelFormat)avFrame->format)));
198+
auto frameDims =
199+
getHeightAndWidthFromOptionsOrAVFrame(videoStreamOptions, *avFrame);
199200
int height = frameDims.height;
200201
int width = frameDims.width;
201202
torch::Tensor& dst = output.frame;
@@ -212,28 +213,28 @@ void convertAVFrameToDecodedOutputOnCuda(
212213
"x3, got ",
213214
shape);
214215
} else {
215-
dst = allocateEmptyHWCTensor(height, width, options.device);
216+
dst = allocateEmptyHWCTensor(height, width, videoStreamOptions.device);
216217
}
217218

218219
// Use the user-requested GPU for running the NPP kernel.
219220
c10::cuda::CUDAGuard deviceGuard(device);
220221

221222
NppiSize oSizeROI = {width, height};
222-
Npp8u* input[2] = {src->data[0], src->data[1]};
223+
Npp8u* input[2] = {avFrame->data[0], avFrame->data[1]};
223224

224225
auto start = std::chrono::high_resolution_clock::now();
225226
NppStatus status;
226-
if (src->colorspace == AVColorSpace::AVCOL_SPC_BT709) {
227+
if (avFrame->colorspace == AVColorSpace::AVCOL_SPC_BT709) {
227228
status = nppiNV12ToRGB_709CSC_8u_P2C3R(
228229
input,
229-
src->linesize[0],
230+
avFrame->linesize[0],
230231
static_cast<Npp8u*>(dst.data_ptr()),
231232
dst.stride(0),
232233
oSizeROI);
233234
} else {
234235
status = nppiNV12ToRGB_8u_P2C3R(
235236
input,
236-
src->linesize[0],
237+
avFrame->linesize[0],
237238
static_cast<Npp8u*>(dst.data_ptr()),
238239
dst.stride(0),
239240
oSizeROI);

src/torchcodec/decoders/_core/DeviceInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void initializeContextOnCuda(
3131

3232
void convertAVFrameToDecodedOutputOnCuda(
3333
const torch::Device& device,
34-
const VideoDecoder::VideoStreamDecoderOptions& options,
34+
const VideoDecoder::VideoStreamOptions& videoStreamOptions,
3535
VideoDecoder::RawDecodedOutput& rawOutput,
3636
VideoDecoder::DecodedOutput& output,
3737
std::optional<torch::Tensor> preAllocatedOutputTensor = std::nullopt);

0 commit comments

Comments
 (0)