Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0620470
First pass on transforms. Committing to switch branches
scotts Sep 12, 2025
ad1631d
Merge branch 'main' of github.com:pytorch/torchcodec into transform_core
scotts Sep 12, 2025
c59de36
Initial C++ implementaiton of transforms
scotts Sep 19, 2025
890e2b4
Ha, "maybe unsued".
scotts Sep 19, 2025
d07f7d8
Update C++ tests
scotts Sep 19, 2025
cc4e2ec
Remove C++ test that we no longer need
scotts Sep 19, 2025
f471776
Virtual classes need virtual destructors
scotts Sep 19, 2025
c06aa94
Cuda device convert frames function
scotts Sep 19, 2025
781f956
Fix cuda
scotts Sep 19, 2025
8e7072f
Handle swscale correctly
scotts Sep 19, 2025
1d0c275
Variable names matter
scotts Sep 19, 2025
30622a7
Timebase
scotts Sep 19, 2025
7a41bfd
Removes width and height from StreamOptions
scotts Sep 19, 2025
8e55bd4
More cuda error checking
scotts Sep 22, 2025
a032cb7
Don't pass pre-allocated GPU tensor to CPU decoding
scotts Sep 23, 2025
9aa85c2
Lint
scotts Sep 23, 2025
4e6c6f8
Remove prints from test
scotts Sep 23, 2025
aa54a02
Merge branch 'main' of github.com:pytorch/torchcodec into transform_core
scotts Sep 24, 2025
3737099
Lint
scotts Sep 24, 2025
139e4ff
Refactor NV12 stuff; test if we need format for FFmpeg 4
scotts Sep 24, 2025
6668f4b
Specify hwdownload format as rgb24
scotts Sep 24, 2025
9f357c7
Do all nv12 conversions on GPU
scotts Sep 24, 2025
3dc20b8
Wrong output format
scotts Sep 24, 2025
7f88e60
Back to RGB24
scotts Sep 24, 2025
dda2649
CUDA and CPU refactoring regarding NV12.
scotts Sep 25, 2025
fc5468e
Test to ensure transforms are not used with non-CPU
scotts Sep 25, 2025
48e3ea3
Better comments; refactor toTensor
scotts Sep 26, 2025
7813005
Deal with variable resolution and lying metadata - again
scotts Sep 26, 2025
23ec35f
Better comment
scotts Sep 26, 2025
fb06f87
Proper frame dims handling in CUDA
scotts Sep 27, 2025
3626854
Make swscale and filtergraph look more similar
scotts Sep 29, 2025
1a07828
Better comment formatting
scotts Sep 29, 2025
ee3b9b7
Apply reviewer suggestions
scotts Oct 1, 2025
d2e9bde
Refactor device interface, again.
scotts Oct 1, 2025
343ed3e
Merge branch 'main' of github.com:pytorch/torchcodec into transform_core
scotts Oct 1, 2025
db2ea07
Clean up comment
scotts Oct 1, 2025
1753f9c
Name change
scotts Oct 2, 2025
4b9f4c9
Merge branch 'main' of github.com:pytorch/torchcodec into transform_core
scotts Oct 3, 2025
9efb767
Stragglers
scotts Oct 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions src/torchcodec/_core/BetaCudaDeviceInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,20 @@ BetaCudaDeviceInterface::~BetaCudaDeviceInterface() {
}
}

void BetaCudaDeviceInterface::initializeInterface(AVStream* avStream) {
void BetaCudaDeviceInterface::initialize(const AVStream* avStream) {
torch::Tensor dummyTensorForCudaInitialization = torch::empty(
{1}, torch::TensorOptions().dtype(torch::kUInt8).device(device_));

TORCH_CHECK(avStream != nullptr, "AVStream cannot be null");
timeBase_ = avStream->time_base;

auto cudaDevice = torch::Device(torch::kCUDA);
defaultCudaInterface_ =
std::unique_ptr<DeviceInterface>(createDeviceInterface(cudaDevice));
AVCodecContext dummyCodecContext = {};
defaultCudaInterface_->initialize(avStream);
defaultCudaInterface_->registerHardwareDeviceWithCodec(&dummyCodecContext);

const AVCodecParameters* codecpar = avStream->codecpar;
TORCH_CHECK(codecpar != nullptr, "CodecParameters cannot be null");

Expand Down Expand Up @@ -523,8 +530,6 @@ void BetaCudaDeviceInterface::flush() {
}

void BetaCudaDeviceInterface::convertAVFrameToFrameOutput(
const VideoStreamOptions& videoStreamOptions,
const AVRational& timeBase,
UniqueAVFrame& avFrame,
FrameOutput& frameOutput,
std::optional<torch::Tensor> preAllocatedOutputTensor) {
Expand All @@ -535,20 +540,8 @@ void BetaCudaDeviceInterface::convertAVFrameToFrameOutput(
// TODONVDEC P1: we use the 'default' cuda device interface for color
// conversion. That's a temporary hack to make things work. we should abstract
// the color conversion stuff separately.
if (!defaultCudaInterface_) {
auto cudaDevice = torch::Device(torch::kCUDA);
defaultCudaInterface_ =
std::unique_ptr<DeviceInterface>(createDeviceInterface(cudaDevice));
AVCodecContext dummyCodecContext = {};
defaultCudaInterface_->initializeContext(&dummyCodecContext);
}

defaultCudaInterface_->convertAVFrameToFrameOutput(
videoStreamOptions,
timeBase,
avFrame,
frameOutput,
preAllocatedOutputTensor);
avFrame, frameOutput, preAllocatedOutputTensor);
}

BetaCudaDeviceInterface::FrameBuffer::Slot*
Expand Down
4 changes: 1 addition & 3 deletions src/torchcodec/_core/BetaCudaDeviceInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ class BetaCudaDeviceInterface : public DeviceInterface {
explicit BetaCudaDeviceInterface(const torch::Device& device);
virtual ~BetaCudaDeviceInterface();

void initializeInterface(AVStream* stream) override;
void initialize(const AVStream* avStream) override;

void convertAVFrameToFrameOutput(
const VideoStreamOptions& videoStreamOptions,
const AVRational& timeBase,
UniqueAVFrame& avFrame,
FrameOutput& frameOutput,
std::optional<torch::Tensor> preAllocatedOutputTensor =
Expand Down
1 change: 1 addition & 0 deletions src/torchcodec/_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ function(make_torchcodec_libraries
SingleStreamDecoder.cpp
Encoder.cpp
ValidationUtils.cpp
Transform.cpp
)

if(ENABLE_CUDA)
Expand Down
Loading
Loading