Add support for full-range VP9 video decoding#6367
Conversation
- Use FFmpeg color-range metadata as a fallback when NVDEC does not report full-range video. Pass full-range source details to libswscale in the CPU decoder and extend full dynamic range video coverage to the VP9 sample. Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
65316c0 to
539de9e
Compare
|
!build |
|
CI MESSAGE: [52611502]: BUILD STARTED |
|
CI MESSAGE: [52611502]: BUILD PASSED |
|
| Filename | Overview |
|---|---|
| dali/operators/video/frames_decoder_cpu.cc | Adds sws_setColorspaceDetails call after context creation to pass full-range metadata; guarded by sws_src_full_range_ so it only fires when the range changes. |
| dali/operators/video/frames_decoder_gpu.cc | Extracts full-range detection into IsFullRange, OR-ing NVDEC's video_full_range_flag with codec_params_->color_range == AVCOL_RANGE_JPEG. |
| dali/operators/video/legacy/reader/nvdecoder/nvdecoder.cc | Adds full_range_from_codecpar_ member initialized in constructor; OR-ed with video_full_range_flag in handle_sequence_ to provide FFmpeg fallback for VP9. |
| dali/test/python/decoder/test_video.py | Parameterizes existing full-range tests over H.264 and VP9 assets; adds CPU+VP9 variant; DALI_extra assets confirmed present. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Video File / Stream] --> B{Decode Path}
B -->|Legacy GPU| C[NvDecoder: full_range_from_codecpar_]
C --> D[handle_sequence_]
D --> E[full_range = video_full_range_flag OR full_range_from_codecpar_]
E --> F[Convert YUV to RGB with correct range]
B -->|New GPU| G[FramesDecoderGpu::IsFullRange]
G --> H[video_full_range_flag OR codec_params color_range == JPEG]
H --> I{Full range?}
I -->|Yes| J[YUV_TO_RGB_FULL_RANGE]
I -->|No| K[YUV_TO_RGB]
B -->|CPU| L[FramesDecoderCpu::CopyToOutput]
L --> M[src_full_range from frame or codecpar fallback]
M --> N{Range changed vs cached?}
N -->|Yes| O[sws_setColorspaceDetails + update cache]
N -->|No| P[Skip]
O --> Q[sws_scale to output]
P --> Q
Reviews (3): Last reviewed commit: "Avoid redundant sws_setColorspaceDetails..." | Re-trigger Greptile
Cache the last applied source full-range flag in FramesDecoderCpu and only call sws_setColorspaceDetails when it changes. Previously the call ran for every decoded frame even though sws_ctx_ is created once, forcing libswscale to recompute coefficient tables unnecessarily. Also bump copyright headers on the five video decoder files touched in this PR to include 2026. Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
|
@greptile review |
|
!build |
|
CI MESSAGE: [52699111]: BUILD STARTED |
|
CI MESSAGE: [52699111]: BUILD PASSED |
Category:
Bug fix (non-breaking change which fixes an issue)
Description:
This PR fixes full-range video handling for VP9 video decoding.
The GPU video decoders used NVDEC's
video_full_range_flagto choose theYUV-to-RGB conversion range. NVDEC does not always report this flag for VP9,
even when FFmpeg stream metadata marks the video as full range. The GPU and
legacy GPU paths now fall back to FFmpeg
color_rangemetadata when NVDECdoes not report full range.
The CPU decoder also now propagates full-range source information to
libswscale so VP9 CPU decoding uses the expected conversion range.
Additional information:
Affected modules and functionalities:
fn.readers.videoGPU NVDEC conversion range selectionfn.experimental.readers.videoGPU decoder range selectionfn.experimental.readers.videoCPU decoder libswscale conversion setupKey points relevant for the review:
falls back to FFmpeg
color_range == AVCOL_RANGE_JPEG.falling back to stream metadata when the frame leaves it unspecified.
full-range asset from
DALI_extra.Tests:
Checklist
Documentation
DALI team only
Requirements
REQ IDs: N/A
JIRA TASK: N/A