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