Merge tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso...
[linux-2.6-microblaze.git] / Documentation / userspace-api / media / v4l / yuv-formats.rst
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2
3 .. _yuv-formats:
4
5 ***********
6 YUV Formats
7 ***********
8
9 YUV is the format native to TV broadcast and composite video signals. It
10 separates the brightness information (Y) from the color information (U
11 and V or Cb and Cr). The color information consists of red and blue
12 *color difference* signals, this way the green component can be
13 reconstructed by subtracting from the brightness component. See
14 :ref:`colorspaces` for conversion examples. YUV was chosen because
15 early television would only transmit brightness information. To add
16 color in a way compatible with existing receivers a new signal carrier
17 was added to transmit the color difference signals.
18
19
20 Subsampling
21 ===========
22
23 YUV formats commonly encode images with a lower resolution for the chroma
24 components than for the luma component. This compression technique, taking
25 advantage of the human eye being more sensitive to luminance than color
26 differences, is called chroma subsampling.
27
28 While many combinations of subsampling factors in the horizontal and vertical
29 direction are possible, common factors are 1 (no subsampling), 2 and 4, with
30 horizontal subsampling always larger than or equal to vertical subsampling.
31 Common combinations are named as follows.
32
33 - `4:4:4`: No subsampling
34 - `4:2:2`: Horizontal subsampling by 2, no vertical subsampling
35 - `4:2:0`: Horizontal subsampling by 2, vertical subsampling by 2
36 - `4:1:1`: Horizontal subsampling by 4, no vertical subsampling
37 - `4:1:0`: Horizontal subsampling by 4, vertical subsampling by 4
38
39 Subsampling the chroma component effectively creates chroma values that can be
40 located in different spatial locations:
41
42 - .. _yuv-chroma-centered:
43
44   The subsampled chroma value may be calculated by simply averaging the chroma
45   value of two consecutive pixels. It effectively models the chroma of a pixel
46   sited between the two original pixels. This is referred to as centered or
47   interstitially sited chroma.
48
49 - .. _yuv-chroma-cosited:
50
51   The other option is to subsample chroma values in a way that place them in
52   the same spatial sites as the pixels. This may be performed by skipping every
53   other chroma sample (creating aliasing artifacts), or with filters using an
54   odd number of taps. This is referred to as co-sited chroma.
55
56 The following examples show different combination of chroma siting in a 4x4
57 image.
58
59 .. flat-table:: 4:2:2 subsampling, interstitially sited
60     :header-rows: 1
61     :stub-columns: 1
62
63     * -
64       - 0
65       -
66       - 1
67       -
68       - 2
69       -
70       - 3
71     * - 0
72       - Y
73       - C
74       - Y
75       -
76       - Y
77       - C
78       - Y
79     * - 1
80       - Y
81       - C
82       - Y
83       -
84       - Y
85       - C
86       - Y
87     * - 2
88       - Y
89       - C
90       - Y
91       -
92       - Y
93       - C
94       - Y
95     * - 3
96       - Y
97       - C
98       - Y
99       -
100       - Y
101       - C
102       - Y
103
104 .. flat-table:: 4:2:2 subsampling, co-sited
105     :header-rows: 1
106     :stub-columns: 1
107
108     * -
109       - 0
110       -
111       - 1
112       -
113       - 2
114       -
115       - 3
116     * - 0
117       - Y/C
118       -
119       - Y
120       -
121       - Y/C
122       -
123       - Y
124     * - 1
125       - Y/C
126       -
127       - Y
128       -
129       - Y/C
130       -
131       - Y
132     * - 2
133       - Y/C
134       -
135       - Y
136       -
137       - Y/C
138       -
139       - Y
140     * - 3
141       - Y/C
142       -
143       - Y
144       -
145       - Y/C
146       -
147       - Y
148
149 .. flat-table:: 4:2:0 subsampling, horizontally interstitially sited, vertically co-sited
150     :header-rows: 1
151     :stub-columns: 1
152
153     * -
154       - 0
155       -
156       - 1
157       -
158       - 2
159       -
160       - 3
161     * - 0
162       - Y
163       - C
164       - Y
165       -
166       - Y
167       - C
168       - Y
169     * - 1
170       - Y
171       -
172       - Y
173       -
174       - Y
175       -
176       - Y
177     * - 2
178       - Y
179       - C
180       - Y
181       -
182       - Y
183       - C
184       - Y
185     * - 3
186       - Y
187       -
188       - Y
189       -
190       - Y
191       -
192       - Y
193
194 .. flat-table:: 4:1:0 subsampling, horizontally and vertically interstitially sited
195     :header-rows: 1
196     :stub-columns: 1
197
198     * -
199       - 0
200       -
201       - 1
202       -
203       - 2
204       -
205       - 3
206     * - 0
207       - Y
208       -
209       - Y
210       -
211       - Y
212       -
213       - Y
214     * -
215       -
216       -
217       -
218       -
219       -
220       -
221       -
222     * - 1
223       - Y
224       -
225       - Y
226       -
227       - Y
228       -
229       - Y
230     * -
231       -
232       -
233       -
234       - C
235       -
236       -
237       -
238     * - 2
239       - Y
240       -
241       - Y
242       -
243       - Y
244       -
245       - Y
246     * -
247       -
248       -
249       -
250       -
251       -
252       -
253       -
254     * - 3
255       - Y
256       -
257       - Y
258       -
259       - Y
260       -
261       - Y
262
263
264 .. toctree::
265     :maxdepth: 1
266
267     pixfmt-packed-yuv
268     pixfmt-yuv-planar
269     pixfmt-yuv-luma
270     pixfmt-y8i
271     pixfmt-y12i
272     pixfmt-uv8
273     pixfmt-m420