Skip to content

{CUDA Decoding} Destroy existing NVDEC decoder before recreating on sequence re-signal - #261

Closed
YLouWashU wants to merge 2 commits into
facebookresearch:mainfrom
YLouWashU:export-D113848493
Closed

{CUDA Decoding} Destroy existing NVDEC decoder before recreating on sequence re-signal#261
YLouWashU wants to merge 2 commits into
facebookresearch:mainfrom
YLouWashU:export-D113848493

Conversation

@YLouWashU

Copy link
Copy Markdown
Contributor

Summary:
NvDecoder::HandleVideoSequence is the NVDEC parser's sequence callback and, as its own header doc notes, can fire again mid-stream on a new sequence header or format change. The body unconditionally called cuvidCreateDecoder(&_decoder, ...), so on any re-invocation it overwrote _decoder with a fresh handle without destroying the previous one — leaking the old CUvideodecoder and leaving the parser driving a stale/duplicated decoder. This is the "returning stale decoder" issue raised in review on D103253728.

Fix: guard the create call. When _decoder is already non-null, cuvidDestroyDecoder it (and null it, so a subsequent create failure can't double-free in the destructor) before creating the replacement. Destroy-before-recreate is chosen over cuvidReconfigureDecoder for correctness and simplicity: Aria streams have constant format so re-signal is rare, making the recreate cost negligible; reconfigure (an in-place perf optimization bounded by the original ulMaxWidth/Height) can be a later change if a re-signaling workload ever needs it.

Follow-up to D103253728.

Reviewed By: georges-berenger

Differential Revision: D113848493

…cs (facebookresearch#260)

Summary:

Adds a Linux build-only CI job (`build-nvcodec`) to VRS `build-and-test.yml` that installs `nv-codec-headers`, configures with `-DBUILD_WITH_XPRS=ON -DENABLE_NVCODEC=ON`, and builds. GitHub-hosted runners have no NVIDIA GPU, so this compiles the NVDEC path -- which needs only `nv-codec-headers`, not a GPU or CUDA toolkit -- to catch OSS build breakage. GPU decode is validated manually on a GPU machine. Also documents `nv-codec-headers` as an optional dependency for GPU-accelerated H.265 decoding in the README.

Part of the GPU-accelerated H.265 decoding rollout. Lands after the xprs CUDA decoder files are synced to the GitHub VRS mirror (configerator cconf change), since the NVCODEC build needs those sources.

Reviewed By: georges-berenger

Differential Revision: D110227873
…equence re-signal

Summary:
`NvDecoder::HandleVideoSequence` is the NVDEC parser's sequence callback and, as its own header doc notes, can fire again mid-stream on a new sequence header or format change. The body unconditionally called `cuvidCreateDecoder(&_decoder, ...)`, so on any re-invocation it overwrote `_decoder` with a fresh handle without destroying the previous one — leaking the old `CUvideodecoder` and leaving the parser driving a stale/duplicated decoder. This is the "returning stale decoder" issue raised in review on D103253728.

Fix: guard the create call. When `_decoder` is already non-null, `cuvidDestroyDecoder` it (and null it, so a subsequent create failure can't double-free in the destructor) before creating the replacement. Destroy-before-recreate is chosen over `cuvidReconfigureDecoder` for correctness and simplicity: Aria streams have constant format so re-signal is rare, making the recreate cost negligible; reconfigure (an in-place perf optimization bounded by the original ulMaxWidth/Height) can be a later change if a re-signaling workload ever needs it.

Follow-up to D103253728.

Reviewed By: georges-berenger

Differential Revision: D113848493
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 31, 2026
@meta-codesync

meta-codesync Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

@YLouWashU has exported this pull request. If you are a Meta employee, you can view the originating Diff in D113848493.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant