comparison DOCS/tech/colorspaces.txt @ 5735:cebe55b15cd4

some typos
author alex
date Sat, 20 Apr 2002 21:01:41 +0000
parents 441c98167877
children 0aebf17f33ed
comparison
equal deleted inserted replaced
5734:c96c7633dfa8 5735:cebe55b15cd4
1 In general 1 In general
2 ========== 2 ==========
3 3
4 There are planar and packed modes. 4 There are planar and packed modes.
5 - Planar mode means: you have 3 separated image, one for each component, 5 - Planar mode means: you have 3 separated image, one for each component,
6 each image 8 bites/pixel. To get the real colored pixel, you have to 6 each image 8 bits/pixel. To get the real colored pixel, you have to
7 mix the components from all planes. The resolution of planes may differ! 7 mix the components from all planes. The resolution of planes may differ!
8 - Packed mode means: you have all components mixed/interleaved together, 8 - Packed mode means: you have all components mixed/interleaved together,
9 so you have small "packs" of components in a single, big image. 9 so you have small "packs" of components in a single, big image.
10 10
11 There are RGB and YUV colorspaces. 11 There are RGB and YUV colorspaces.
35 In both these cases, you have to clamp the output values to keep them in 35 In both these cases, you have to clamp the output values to keep them in
36 the [0-255] range. Rumour has it that the valid range is actually a subset 36 the [0-255] range. Rumour has it that the valid range is actually a subset
37 of [0-255] (I've seen an RGB range of [16-235] mentioned) but clamping the 37 of [0-255] (I've seen an RGB range of [16-235] mentioned) but clamping the
38 values into [0-255] seems to produce acceptable results to me. 38 values into [0-255] seems to produce acceptable results to me.
39 39
40 Julien (surname unknown) suggests that there are problems with the above 40 Julien (sorry, I can't call back his surname) suggests that there are
41 formulae and suggests the following instead: 41 problems with the above formula and suggests the following instead:
42 Y = 0.299R + 0.587G + 0.114B 42 Y = 0.299R + 0.587G + 0.114B
43 Cb = U'= (B-Y)*0.565 43 Cb = U'= (B-Y)*0.565
44 Cr = V'= (R-Y)*0.713 44 Cr = V'= (R-Y)*0.713
45 with reciprocal versions: 45 with reciprocal versions:
46 R = Y + 1.403V' 46 R = Y + 1.403V'
47 G = Y - 0.344U' - 0.714V' 47 G = Y - 0.344U' - 0.714V'
48 B = Y + 1.770U' 48 B = Y + 1.770U'
49 note: this formule doesn't contain the +128 offsets of U,V values! 49 note: this formula doesn't contain the +128 offsets of U,V values!
50 50
51 Conclusion: 51 Conclusion:
52 Y = luminance, the weighted average of R G B components. (0=black 255=white) 52 Y = luminance, the weighted average of R G B components. (0=black 255=white)
53 U = Cb = blue component (0=green 128=grey 255=blue) 53 U = Cb = blue component (0=green 128=grey 255=blue)
54 V = Cr = red component (0=green 128=grey 255=red) 54 V = Cr = red component (0=green 128=grey 255=red)
55 55
56 56
57 Huh. The planar YUV modes. 57 Huh. The planar YUV modes.
58 ========================== 58 ==========================
59 59
60 The most missunderstood thingie... 60 The most misunderstood thingie...
61 61
62 In MPlayer, we usually have 3 pointers to the Y, U and V planes, so it 62 In MPlayer, we usually have 3 pointers to the Y, U and V planes, so it
63 doesn't matter what is the order of the planes in the memory: 63 doesn't matter what is the order of the planes in the memory:
64 for mp_image_t and libvo's draw_slice(): 64 for mp_image_t and libvo's draw_slice():
65 planes[0] = Y = luminance 65 planes[0] = Y = luminance
80 YVU9: 9 bpp, full sized Y plane followed by 4x4 subsampled V and U planes 80 YVU9: 9 bpp, full sized Y plane followed by 4x4 subsampled V and U planes
81 81
82 Huh 2. RGB vs. BGR ? 82 Huh 2. RGB vs. BGR ?
83 ==================== 83 ====================
84 84
85 The 2nd most missunderstood thingie... 85 The 2nd most misunderstood thingie...
86 86
87 You know, there are Intel and Motorola, and they use different byteorder. 87 You know, there are Intel and Motorola, and they use different byteorder.
88 There are also others, like MIPS or Alpha, they all follow either Intel 88 There are also others, like MIPS or Alpha, they all follow either Intel
89 or Motorola byteorder. 89 or Motorola byteorder.
90 Unfortunatelly, the packed colorspaces depend on CPU byteorder. So, RGB 90 Unfortunately, the packed colorspaces depend on CPU byteorder. So, RGB
91 on Intel and Motorola means different order of bytes. 91 on Intel and Motorola means different order of bytes.
92 92
93 In MPlayer, we have constants IMGFMT_RGBxx and IMGFMT_BGRxx. 93 In MPlayer, we have constants IMGFMT_RGBxx and IMGFMT_BGRxx.
94 Unfortunatelly, some codecs and vo drivers follow Intel, some follow Motorola 94 Unfortunately, some codecs and vo drivers follow Intel, some follow Motorola
95 byteorder, so they are incompatible. We had to find a stable base, so long 95 byteorder, so they are incompatible. We had to find a stable base, so long
96 time ago I've choose OpenGL, as it's a wide-spreaded standard, and it well 96 time ago I've chosen OpenGL, as it's a wide-spreaded standard, and it well
97 defines what is RGB and what is BGR. So, MPlayer's RGB is compatible with 97 defines what RGB is and what BGR is. So, MPlayer's RGB is compatible with
98 OpenGL's GL_RGB on all platforms, and the same stay for BGR - GL_BGR. 98 OpenGL's GL_RGB on all platforms, and the same goes for BGR - GL_BGR.
99 Unfortunatelly, most of the x86 codecs call our BGR to RGB, so it sometimes 99 Unfortunately, most of the x86 codecs call our BGR to RGB, so it sometimes
100 confuse developers. 100 confuse developers.
101 101
102 If you are unsure, try the OpenGL driver (-vo gl). There is at least software 102 If you are unsure, try the OpenGL driver (-vo gl). There is at least software
103 OpenGL implementation for all major platforms and OSes. 103 OpenGL implementation for all major platforms and OS's.
104