Skip to content
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
78ab058
Let's just commit 3k loc in a single commit
NicolasHug Sep 25, 2025
b45decc
Fixes
NicolasHug Sep 26, 2025
316f218
Merge branch 'main' of github.com:pytorch/torchcodec into aeaenjfjanef
NicolasHug Sep 30, 2025
d0192ec
GetCache -> getCache
NicolasHug Sep 30, 2025
515deb5
Make UniqueCUvideodecoder a pointer on CUvideodecoder, not void
NicolasHug Sep 30, 2025
13fad10
Make device and device_variant have a default instead of being std::o…
NicolasHug Sep 30, 2025
eb8de72
Remove old registerDeviceInterface
NicolasHug Sep 30, 2025
4f7a4fb
Call std::memset
NicolasHug Sep 30, 2025
dcf3124
remove unnecessary cuda_runtime.h include, update cmake accordingly
NicolasHug Sep 30, 2025
0ad7370
abstract frameBuffer_ into a FrameBuffer class
NicolasHug Sep 30, 2025
aad142e
Cleanup BSF logic
NicolasHug Sep 30, 2025
2592888
Return int in callback instead of unsigned char
NicolasHug Sep 30, 2025
b5fe9bc
define width and height as unsigned int
NicolasHug Sep 30, 2025
5605c90
Rework frame ordering and pts matching
NicolasHug Oct 1, 2025
7494259
Merge branch 'main' of github.com:pytorch/torchcodec into aeaenjfjanef
NicolasHug Oct 1, 2025
560b376
Fix cuda context initialization
NicolasHug Oct 1, 2025
88196c5
Merge branch 'aeaenjfjanef' into nvdec-rework-frame-ordering
NicolasHug Oct 1, 2025
2a78b84
Renaming
NicolasHug Oct 1, 2025
5d194e5
Comment
NicolasHug Oct 1, 2025
d1e51b3
Merge branch 'main' of github.com:pytorch/torchcodec into aeaenjfjanef
NicolasHug Oct 2, 2025
f9c7297
Skip equality check on ffmepg 4
NicolasHug Oct 2, 2025
b7bbfb2
Merge branch 'aeaenjfjanef' into nvdec-rework-frame-ordering
NicolasHug Oct 2, 2025
390fd7c
Refac, simplify
NicolasHug Oct 2, 2025
f55dcc0
Update comment
NicolasHug Oct 2, 2025
7e4dd10
Define constant, add TODO for AVRational
NicolasHug Oct 2, 2025
f614846
Use uint32_t types
NicolasHug Oct 2, 2025
aa6e253
Create packet.reset() and add P0 TODO
NicolasHug Oct 2, 2025
186eaa4
Add TODO
NicolasHug Oct 2, 2025
1cb4890
Merge branch 'aeaenjfjanef' into nvdec-rework-frame-ordering
NicolasHug Oct 2, 2025
c5b32a4
Merge branch 'main' of github.com:pytorch/torchcodec into nvdec-rewor…
NicolasHug Oct 2, 2025
70873bf
lint
NicolasHug Oct 2, 2025
8e73bcf
Add TODOs and more explicit initialization
NicolasHug Oct 3, 2025
9b63504
Merge branch 'main' of github.com:pytorch/torchcodec into nvdec-param…
NicolasHug 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
40 changes: 23 additions & 17 deletions src/torchcodec/_core/BetaCudaDeviceInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,27 +109,29 @@ static UniqueCUvideodecoder createDecoder(CUVIDEOFORMAT* videoFormat) {
caps.nMaxMBCount);

// Decoder creation parameters, taken from DALI
CUVIDDECODECREATEINFO decoder_info = {};
decoder_info.bitDepthMinus8 = videoFormat->bit_depth_luma_minus8;
decoder_info.ChromaFormat = videoFormat->chroma_format;
decoder_info.CodecType = videoFormat->codec;
decoder_info.ulHeight = videoFormat->coded_height;
decoder_info.ulWidth = videoFormat->coded_width;
decoder_info.ulMaxHeight = videoFormat->coded_height;
decoder_info.ulMaxWidth = videoFormat->coded_width;
decoder_info.ulTargetHeight =
CUVIDDECODECREATEINFO decoderParams = {};
decoderParams.bitDepthMinus8 = videoFormat->bit_depth_luma_minus8;
decoderParams.ChromaFormat = videoFormat->chroma_format;
decoderParams.OutputFormat = cudaVideoSurfaceFormat_NV12;
decoderParams.ulCreationFlags = cudaVideoCreate_Default;
Comment on lines +115 to +116
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not obvious from the diff because of the drive-by renaming, but these are the 2 lines that were added. They are used by default whether we explicitly set them or not (their enum value is 0 and we zero-initialize the decoderParams). But I think setting them explicitly makes sense, if only for the reader to know that they exist.

decoderParams.CodecType = videoFormat->codec;
decoderParams.ulHeight = videoFormat->coded_height;
decoderParams.ulWidth = videoFormat->coded_width;
decoderParams.ulMaxHeight = videoFormat->coded_height;
decoderParams.ulMaxWidth = videoFormat->coded_width;
decoderParams.ulTargetHeight =
videoFormat->display_area.bottom - videoFormat->display_area.top;
decoder_info.ulTargetWidth =
decoderParams.ulTargetWidth =
videoFormat->display_area.right - videoFormat->display_area.left;
decoder_info.ulNumDecodeSurfaces = videoFormat->min_num_decode_surfaces;
decoder_info.ulNumOutputSurfaces = 2;
decoder_info.display_area.left = videoFormat->display_area.left;
decoder_info.display_area.right = videoFormat->display_area.right;
decoder_info.display_area.top = videoFormat->display_area.top;
decoder_info.display_area.bottom = videoFormat->display_area.bottom;
decoderParams.ulNumDecodeSurfaces = videoFormat->min_num_decode_surfaces;
decoderParams.ulNumOutputSurfaces = 2;
decoderParams.display_area.left = videoFormat->display_area.left;
decoderParams.display_area.right = videoFormat->display_area.right;
decoderParams.display_area.top = videoFormat->display_area.top;
decoderParams.display_area.bottom = videoFormat->display_area.bottom;

CUvideodecoder* decoder = new CUvideodecoder();
result = cuvidCreateDecoder(decoder, &decoder_info);
result = cuvidCreateDecoder(decoder, &decoderParams);
TORCH_CHECK(
result == CUDA_SUCCESS, "Failed to create NVDEC decoder: ", result);
return UniqueCUvideodecoder(decoder, CUvideoDecoderDeleter{});
Expand Down Expand Up @@ -360,6 +362,10 @@ int BetaCudaDeviceInterface::receiveFrame(UniqueAVFrame& avFrame) {
CUVIDPARSERDISPINFO dispInfo = readyFrames_.front();
readyFrames_.pop();

// TODONVDEC P1 we need to set the procParams.output_stream field to the
// current CUDA stream and ensure proper synchronization. There's a related
// NVDECTODO in CudaDeviceInterface.cpp where we do the necessary
// synchronization for NPP.
CUVIDPROCPARAMS procParams = {};
procParams.progressive_frame = dispInfo.progressive_frame;
procParams.top_field_first = dispInfo.top_field_first;
Expand Down
Loading