[FFmpeg-devel] [rfc][swscale] brightness, contrast and saturation

Michael Niedermayer michaelni
Mon Sep 1 00:04:51 CEST 2008


s On Sun, Aug 31, 2008 at 05:17:47PM +0200, Keiji Costantini wrote:
> I was charged to make a replacement for the table generator of yuv to 
> rgb converting tables for swscale.
> 
> I made this into a file (the source is at 
> http://strites.altervista.org/wiki3/doku.php?id=generator - for everyone 
> willing to take a watch).
> 
> This function (new_yuv2rgb_c_init_tables - replacement of 
> yuv2rgb_c_init_tables) takes some arguments. In those, there are 
> brightness, contrast and saturation (seems to manipulate image during 
> conversion).
> 
> I can't see the original source (license issue) so I don't know how 
> those work inside the original converter.
> 
> I have a theory about those. Please correct me.
> 
> Brightness affects Y
> Saturation affects U and V

> Contrast affects Y, or YUV

YUV

also there is code in swscale.c (sws_setColorspaceDetails) that adjust the
various coefficients for these except brightness that isnt supported ...


> 
> Brightness adds or subtract value*bri/255 to the Y channel.

> Saturation does the same for U and V.

saturation does not add, it does scale  U and V


> 
> Contrast finds the medium point in range (0-255 so it's 128) and 
> subtracts or adds depending the values are above or below that medium 
> number, by (con*value/255) .
> 
> Those assumptions are made thinking range of bri/con/sat are {-255;255}

contrast and saturation probably have a range of 0 ... 1<<17 at least possible
larger on both sides

I dont remember it about brightness, why dont you just test it and see
which values have what effect on the picture?


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Thouse who are best at talking, realize last or never when they are wrong.
-------------- 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/20080901/585be4c6/attachment.pgp>



More information about the ffmpeg-devel mailing list