xyz2rgb Video Filter
The xyz2rgb filter is an ffmpeg Video filter that converts from XYZ to RGB Rec 709 color space. It can be used to transform the colors of JPEG2000 image files in a DCP.
Download
You may want to right-click and select download
Documentation
The zip file contains 3 files
- vf_xyz2rgb.c source code of the filter
- allfilters.c modified to include xyz2rgb
- Makefile modified to include xyz2rgb
See Install ffmpeg with xyz2rgb Video Filter
The xyz2rgb filter has no parameters and converts pixel by pixel from XYZ to sRGB. It does this by 4 steps
- convert from XYZ to XYZlinear (gamma 2.6)
- convert from XYZlinear to RGBlinear (colormatrix)
- limit values
- convert from RGBlinear to RGB Rec 709 (gamma 2.2222)
The color matrix used is
r = 3.2404542 * x - 1.5371385 * y - 0.4985314 * z
g = - 0.9692660 * x + 1.8760108 * y + 0.0415560 * z
b = 0.0556434 * x - 0.2040259 * y + 1.0572252 * z
The calculation is done in 12bit integer precision. The filter accepts 8bit and 16bit input.
The gamma values are precalculated to speed up the transformation
See also Open Source DCP Player Proof of Concept
You can find theoretical documentation on the transformation here
- http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
- http://en.wikipedia.org/wiki/Rec._709
- http://en.wikipedia.org/wiki/SRGB
License
The xyz2rgb Video Filter is released as LGPL. ffmpeg is a great tool so I am proud to add my little contribution on it. It took about 30 hours to code and check xyz2rgb.