[MPlayer-dev-eng] rgb<->yuv convertion question
D Richard Felker III
dalias at aerifal.cx
Wed Jan 14 04:11:21 CET 2004
On Wed, Jan 14, 2004 at 10:23:02AM +0800, mayaray wrote:
> i saw the following matrix in docs/tech/colorspaces.txt:
>
> Y = (0.257 * R) + (0.504 * G) + (0.098 * B) + 16
> Cr = V = (0.439 * R) - (0.368 * G) - (0.071 * B) + 128
> Cb = U = -(0.148 * R) - (0.291 * G) + (0.439 * B) + 128
>
> B = 1.164(Y - 16) + 2.018(U - 128)
> G = 1.164(Y - 16) - 0.813(V - 128) - 0.391(U - 128)
> R = 1.164(Y - 16) + 1.596(V - 128)
>
> then i used it in my program, but the result of a RGB2YUV followed by a YUV2RGB has some red dots or dashes in places
> where the lumination is high.
> the pRGB is a BYTE * and Y, U, V are all BYTE.
> does my accuracy not high enough?
No, but you have to clamp the results so they fit in a byte. Otherwise
they'll overflow/wrap.
BTW you should probably use fixed point rather than float. Float will
be _very_ slow.
Rich
More information about the MPlayer-dev-eng
mailing list