Mercurial > mplayer.hg
comparison DOCS/tech/colorspaces.txt @ 5312:211c0f1ec065
soem explanation
author | arpi |
---|---|
date | Sun, 24 Mar 2002 18:42:05 +0000 |
parents | |
children | ba5c92e64c5d |
comparison
equal
deleted
inserted
replaced
5311:91c8ffdd4721 | 5312:211c0f1ec065 |
---|---|
1 Huh. The planar YUV modes. | |
2 ========================== | |
3 | |
4 The most missunderstood thingie... | |
5 | |
6 Let's see: (some cut'n'paste from www and maillist) | |
7 | |
8 RGB to YUV Conversion: | |
9 Y = (0.257 * R) + (0.504 * G) + (0.098 * B) + 16 | |
10 Cr = V = (0.439 * R) - (0.368 * G) - (0.071 * B) + 128 | |
11 Cb = U = -(0.148 * R) - (0.291 * G) + (0.439 * B) + 128 | |
12 YUV to RGB Conversion: | |
13 B = 1.164(Y - 16) + 2.018(U - 128) | |
14 G = 1.164(Y - 16) - 0.813(V - 128) - 0.391(U - 128) | |
15 R = 1.164(Y - 16) + 1.596(V - 128) | |
16 | |
17 In both these cases, you have to clamp the output values to keep them in | |
18 the [0-255] range. Rumour has it that the valid range is actually a subset | |
19 of [0-255] (I've seen an RGB range of [16-235] mentioned) but clamping the | |
20 values into [0-255] seems to produce acceptable results to me. | |
21 | |
22 Julien (surname unknown) suggests that there are problems with the above | |
23 formulae and suggests the following instead: | |
24 Y = 0.299R + 0.587G + 0.114B | |
25 Cb = U'= (B-Y)*0.565 | |
26 Cr = V'= (R-Y)*0.713 | |
27 with reciprocal versions: | |
28 R = Y + 1.403V' | |
29 G = Y - 0.344U' - 0.714V' | |
30 B = Y + 1.770U' | |
31 note: this formule doesn't contain the +128 offsets of U,V values! | |
32 | |
33 Conclusion: | |
34 Y = luminance, the weighted average of R G B components. (0=black 255=white) | |
35 U = Cb = blue component (0=green 128=grey 255=blue) | |
36 V = Cv = red component (0=green 128=grey 255=red) | |
37 | |
38 MPlayer side: | |
39 ============= | |
40 In MPlayer, we usually have 3 pointers to the Y, U and V planes, so it | |
41 doesn't matter what is they order in memory. | |
42 But there are some codecs (vfw, dshow) and vo drivers (xv) ignoring the 2nd | |
43 and 3rd pointer, and use only a single pointer to the planar yuv image. In | |
44 this case we must know the right order and alignment of planes in the memory! | |
45 | |
46 from the webartz fourcc list: | |
47 YV12: 12 bpp, full sized Y plane followed by 2x2 subsampled V and U planes | |
48 I420: 12 bpp, full sized Y plane followed by 2x2 subsampled U and V planes | |
49 IYUV: the same as I420 | |
50 YVU9: 9 bpp, full sized Y plane followed by 4x4 subsampled V and U planes | |
51 |