Summary:
When decoding H.264 via NVDEC and cuvidParseVideoData, omitting SPS/PPS NAL units or submitting them after the first slice NAL can lead to silent corruption of decoder state. This can manifest as severe macroblock artifacts, incorrect output, or in some cases apparent memory corruption without any error return from the API.
Steps to Reproduce:
Encode an H.264 stream using NVENC (baseline, main, or high profile).
Parse the stream and extract only NAL units of type 1 or 5 (slices), omitting types 7 and 8 (SPS/PPS).
Submit each slice individually via cuvidParseVideoData.
Observe decoder behavior:
Sometimes the stream decodes cleanly (likely due to decoder caching prior config)
Sometimes the decoded output is severely corrupted (macroblock errors, visual garbage)
Sometimes the corruption manifests in downstream shared memory consumers
Expected Behavior:
Decoder should return an error if required configuration data (e.g. SPS/PPS) has not been received.
At minimum, internal decoder state should fail gracefully rather than proceeding in an undefined way.
Actual Behavior:
cuvidParseVideoData returns success (CUDA_SUCCESS)
Decoder initializes with garbage state
All slices in the GOP decode incorrectly
In some cases, client applications experience downstream errors (possibly due to corrupted memory structures)
Notes:
Reproducibility is not 100% deterministic; it depends on decoder warm/cold state, and timing.
Once corrupted, the decoder stays in that state until reset.
Fixing the issue by prepending SPS/PPS NALs explicitly resolves all symptoms.
System Configuration:
GPU: Seen on 4080 and 1650
Driver Version: 572.83
CUDA Version: 12.3
Codec SDK: 12.1.14
Windows 11
Further note:
We control both encoding and parsing - this is not a malformed stream, just a malformed decode setup (our NAL parser) that the API allows without warning.