On Sat, Dec 22, 2018 at 09:53:16AM +0100, Paul B Mahol wrote: >> FFmpeg doesn't have a good understanding of gamma (it rarely actually >> converts between different gamma ramps), but that's not a problem with >> PhotoCD per se. I can't find a good reason why FFmpeg could not be >> extended with conversions from the PhotoCD color space to sRGB, at least >> not if clipping out-of-gamut colors is acceptable. > I'm all ears.
I happen to have a library that does all of this stuff... :-) (https://movit.sesse.net/) I don't think FFmpeg really wants to link in Movit for a variety of reasons, and in this case, PhotoCD is nominally Rec. 709, so you don't actually need a colorspace transform. This means that the only steps you really need would be: 1. Decode the YCC to RGB. Allow for out-of-0..255 (ideally float, but FFmpeg probably wants to use int16 or something similar instead). 2. Convert to linear gamma (either float, or 16-bit fixed point) using the inverse of the function mentioned in Wikipedia. 3. Convert back from linear gamma to sRGB or Rec. 709 gamma. 4. Clip to 0..1, then scale to 0..255. Step 2, 3, 4 can probably be collapsed into a LUT that can be applied three times (the channels are independent, since the RGB color space is the same). If you're not happy with blown highlights (colors that clip), it's a much harder problem. /* Steinar */ -- Homepage: https://www.sesse.net/ _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel