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

Michael Niedermayer michaelni
Thu Jan 24 14:30:55 CET 2008

On Thu, Jan 24, 2008 at 01:33:55PM +0100, christophelorenz wrote:
> (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 
> symmetric.

> As people will often do YUV->RGB->custom pixel op->RGB->YUV, it will 
> endup with videos that are low contrast and gray blacks.

no, people will not do this commonly
filters should always be implemented in the colorspace you are most likely
to encounter

> 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...

RGB->YUV uses hardcoded coeffs currently, a patch changing that is weclcome
YUV->RGB should honor whatever you set with sws_setColorspaceDetails()
if it does not, well find out why and send a patch

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080124/3fae93fe/attachment.pgp>

More information about the ffmpeg-devel mailing list