Skip to content

tonemap_cuda: native 4:2:2 in and out - #35

Merged
jpietek merged 1 commit into
ffmpeg8from
tonemap-422
Sep 17, 2026
Merged

jpietek merged 1 commit into
ffmpeg8from
tonemap-422

Conversation

@jpietek

@jpietek jpietek commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #33.

tonemap_cuda handled 4:2:0 only, so every colour conversion touching a P210 canvas was wrapped in scale_cuda=format=p010le before and scale_cuda=format=p210le after. The kernel now takes NV12/P010/NV16/P210 and writes any of them, resampling 4:2:2/4:2:0 in the same pass.

  • Converted sources on a P210 canvas keep 4:2:2 (previously only sources with a matching contract did).
  • A rendition off a P210 canvas subsamples once, inside the tone mapper: one 156 µs pass fewer per converted source and per rendition (the profiler's top lever).
  • conversion_graph loses its P010 round trip; unit tests updated; series re-pinned on n8.0 and n8.1.

Verified on the T4: transfers, mixer, interop, v210 and output-qualification smokes.

🤖 Generated with Claude Code

…n the same pass

The kernel handled one 2x2 luma block with a single shared chroma sample,
i.e. 4:2:0 only, so every conversion touching a P210 canvas needed a
scale_cuda pass to P010 before and one back to P210 after. It now takes
NV12/P010/NV16/P210 and writes any of them: 4:2:2 input keeps one chroma
sample per luma row, 4:2:0 output averages the block, 4:2:2 output keeps
the rows. The default output keeps the input subsampling (8 bits for
SDR, 10 for HDR); `format=` selects it explicitly. Passthrough requires
matching subsampling as well.

conversion_graph drops the P010 sandwich: converted sources on a P210
canvas stay 4:2:2, and a rendition off a P210 canvas subsamples once,
inside the tone mapper, instead of scale, tonemap, scale. That is one
fewer 156 us pass per converted source and per rendition on the T4.
Planar CUDA storage is still re-laid out by scale_cuda first.

Series re-pinned on n8.0 and n8.1.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@jpietek
jpietek merged commit 2e6223b into ffmpeg8 Sep 17, 2026
@jpietek

jpietek commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

Folded into #33 as commit 2e6223b.

@jpietek
jpietek deleted the tonemap-422 branch September 17, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant