Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement support for proper HDR to SDR conversion #1305

Open
k4yt3x opened this issue Jan 24, 2025 · 0 comments
Open

Implement support for proper HDR to SDR conversion #1305

k4yt3x opened this issue Jan 24, 2025 · 0 comments
Labels
state:Planned This issue is already scheduled to be worked on type:Enhancement New feature or request

Comments

@k4yt3x
Copy link
Owner

k4yt3x commented Jan 24, 2025

This ticket tracks the proper support for processing HDR videos.

When processing HDR videos, the decoded frames could have properties looking like this:

  • Pixel Format: yuv420p10le
  • Color Primaries: BT.2020
  • Color Transfer: SMPTE2084 (PQ)
  • Color Range: TV (limited range)

Before the frame can be passed to, say, Real-ESRGAN, it must be converted into an ncnn::Mat, which will require converting the 10-bit HDR image into an 8-bit SDR (RGB24) image. Right now, AVFrame conversions are done through libswscale, which can convert the frame formats, but does not support proper tone-mapping from HDR to SDR. As a result, processing HDR videos will result in color inaccuracies in the output video.

Currently, the idea is to use libavformat's zscale and tonemap filters to perform the tone-mapping and format conversion:

zscale=transferin=smpte2084:primariesin=bt2020:transfer=bt709:primaries=bt709:rangein=tv:range=tv,tonemap=hable,format=rgb24

Please feel free to suggest better ways to implement this feature and discuss about this in this thread if you're familiar with HDR content processing best practices.

@k4yt3x k4yt3x added the type:Enhancement New feature or request label Jan 24, 2025
@github-actions github-actions bot added the state:Backlog This issue will be worked on in the future label Jan 24, 2025
@k4yt3x k4yt3x added state:Planned This issue is already scheduled to be worked on and removed state:Backlog This issue will be worked on in the future labels Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:Planned This issue is already scheduled to be worked on type:Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant