Commit 2f4fc9e
{CUDA Decoding} Destroy existing NVDEC decoder before recreating on sequence re-signal (#261)
Summary:
Pull Request resolved: #261
`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
fbshipit-source-id: 7b3bf7f32f379e2cd9dcc44f482c541a63506f4f1 parent 15d40a4 commit 2f4fc9e
1 file changed
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
213 | 225 | | |
214 | 226 | | |
215 | 227 | | |
| |||
0 commit comments