[MPlayer-dev-eng] [PATCH] vobsub custom colors rgb->yuv fix.
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Sat Dec 8 14:25:10 CET 2007
Hello,
On Sat, Dec 08, 2007 at 08:37:51PM +0800, Ulion wrote:
[...]
> +unsigned int vobsub_rgb_to_yuv(unsigned int rgb)
> +{
> + int r, g, b, y, u, v;
> + r = rgb >> 16 & 0xff;
> + g = rgb >> 8 & 0xff;
> + b = rgb & 0xff;
> + y = round(( 0.299 * r + 0.587 * g + 0.114 * b) * 219 / 255 + 16);
> + u = round((-0.16874 * r - 0.33126 * g + 0.5 * b) * 224 / 255 + 128);
> + v = round(( 0.5 * r - 0.41869 * g - 0.08131 * b) * 224 / 255 + 128);
> + return y << 16 | u << 8 | v;
> +}
The *219/255 etc. is a really bad idea IMO, since it means the subtitles
can at best become a muddy gray and never truly white.
This may be acceptable or even good for videos, but not for subtitles.
Also my man pages say round is C99 only, if you really think it is worth
the bother just add + 0.5 as the last step (though I admit it is not
equivalent for u and v).
Greetings,
Reimar Döffinger
More information about the MPlayer-dev-eng
mailing list