[FFmpeg-devel] [PATCH]lavc/pgssubdec: Fix palette colourspace

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Apr 17 20:55:47 CEST 2016

On Sun, Apr 17, 2016 at 09:41:32PM +0300, Jan Ekstrom wrote:
> On Sun, Apr 17, 2016 at 9:21 PM, Reimar Döffinger
> <Reimar.Doeffinger at gmx.de> wrote:
> > In particular, I have an uncomfortable suspicion that
> > PGS might be designed to match the movie's colour space,
> > in which case neither variant would give correct results
> > but instead it would have to depend on what format the
> > corresponding video track uses (and it probably would
> > be more than just the 255/224 factor that would differ).
> Yes, the YCbCr values in palettes are matched accordingly against the
> video stream. As per the specification:
> "Y, Cr and Cb shall have the same color matrix as the associated HDMV
> Video stream: 525-60/625-50 (Rec.601); 1080i, 720p (ITU-709)"
> Otherwise the specification notes that valid values in palettes are:
> -Y: 16-235
> -Cr: 16-240
> -Cb: 16-240

These two kind of contradict each other, at least if the HDMV video
stream uses a full range color matrix (or is that not allowed?).
However with that additional information about the valid ranges
I believe Carl's patch is correct, though we are not handling the
exact coefficients correctly.
As I don't really expect PGS to be used much with PAL/NTSC resolution,
using ITU-709 would probably be a safe assumption in practice.
I think the PGS stream does however contain the movie resolution,
so switching between Rec.601 and ITU-709 based on that should
probably be possible.
In which case the dependency on the video stream does not really exist
in practice.

More information about the ffmpeg-devel mailing list