Add Colorspace.BT2020 for BT.2020 YUV matrix conversion#2325
Merged
Conversation
f27dca8 to
98bb44d
Compare
98bb44d to
da771e0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Colorspace.BT2020 for BT.2020 YUV matrix conversion
Summary
Expose libswscale's
SWS_CS_BT2020in PyAV'sColorspaceenum so HDR content taggedbt2020nccan use the correct YUV→RGB matrix coefficients throughVideoFrame.reformat()andVideoFrame.to_ndarray().libswscale already supports BT.2020 matrix conversion; PyAV's Cython declarations and Python enum were missing the constant, so users could not pass
BT2020assrc_colorspace/dst_colorspace.Changes
SWS_CS_BT2020inav/video/reformatter.pxdColorspace.BT2020and backward-compat aliasColorspace.bt2020inav/video/reformatter.pySWS_CS_BT2020→AVCOL_SPC_BT2020_NCLin_set_frame_colorspace(non-constant-luminance, the standard for consumer HDR /bt2020nc)av/video/reformatter.pyitest_reformat_dst_colorspace_metadatacovering all distinct colorspace matrix mappings, including BT.2020v18.0.0 (next)Usage
Notes
AVCOL_SPC_BT2020_NCLwas already declared ininclude/avutil.pxd; no FFmpeg binding changes were required.SWS_CS_BT2020is the only libswscale colorspace constant not previously exposed in PyAV'sColorspaceenum.Test plan
make— Cython build succeedspython -m pytest tests/test_colorspace.py -v— all tests pass, including parametrized metadata testpython -m pytest tests/test_videoframe.py -k reformat -v— reformat regression tests passmake test— full suite passes locally (471 passed, 17 skipped)