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

Keiji Costantini lists
Sun Aug 31 17:17:47 CEST 2008

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 

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

Brightness adds or subtract value*bri/255 to the Y channel.
Saturation does the same for 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}

I don't know what are the ranges, is there anyone who knows this?

Is there any error in this theory? And is this theory applicable to 
->swscale<- ?

Thanks to everyone who is willing to answer.
Keiji Costantini

More information about the ffmpeg-devel mailing list