[FFmpeg-devel] [PATCH 1/2] avcodec: add photocd decoder

Paul B Mahol onemda at gmail.com
Sat Dec 22 22:04:26 EET 2018


On 12/22/18, Steinar H. Gunderson <steinar+ffmpeg at gunderson.no> wrote:
> 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.

I can not accept internal conversion to RGB. This is subsampled format
after all.


More information about the ffmpeg-devel mailing list