[FFmpeg-devel] sws_scale RGB<->YUV luminance scaling

christophelorenz christophelorenz
Thu Jan 24 13:33:55 CET 2008

(rev 11213, using libAvC/F libs)
While playing with sws_scale, I noticed that the output range for 
YUV->RGB conversion are not done in graphic level.

Source pixel values in RGB : 255,255,255
Converted to YUV420  :235,128,128
Converted back to RGB 235,235,235
(tried RGBA32, RGB24, GBR...)

I clearly understand the 16-235 range reasons and can also understand 
cases where  RGB in the 16-235 range can be needed...
However I'm surprised to see that the default implementation is not 
As people will often do YUV->RGB->custom pixel op->RGB->YUV, it will 
endup with videos that are low contrast and gray blacks.

Note that I tried using ffmpeg for RGB24->YUV420->RGB24 video 
conversions, and the problem is not apparent in that case.

Changing the YUV format from to PIX_FMT_YUVJ420P didn't changed anything.
I also tried to change the contrast/brightness to graphic levels by 
using sws_getColorspaceDetails and sws_setColorspaceDetails.
But it didn't do anything on the output...

Why is it not symmetric, and how can you output full range RGB ?


More information about the ffmpeg-devel mailing list