1.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 2.. c:namespace:: V4L 3 4.. _packed-yuv: 5 6****************** 7Packed YUV formats 8****************** 9 10Similarly to the packed RGB formats, the packed YUV formats store the Y, Cb and 11Cr components consecutively in memory. They may apply subsampling to the chroma 12components and thus differ in how they interlave the three components. 13 14.. note:: 15 16 - In all the tables that follow, bit 7 is the most significant bit in a byte. 17 - 'Y', 'Cb' and 'Cr' denote bits of the luma, blue chroma (also known as 18 'U') and red chroma (also known as 'V') components respectively. 'A' 19 denotes bits of the alpha component (if supported by the format), and 'X' 20 denotes padding bits. 21 22 234:4:4 Subsampling 24================= 25 26These formats do not subsample the chroma components and store each pixels as a 27full triplet of Y, Cb and Cr values. 28 29The next table lists the packed YUV 4:4:4 formats with less than 8 bits per 30component. They are named based on the order of the Y, Cb and Cr components as 31seen in a 16-bit word, which is then stored in memory in little endian byte 32order, and on the number of bits for each component. For instance the YUV565 33format stores a pixel in a 16-bit word [15:0] laid out at as [Y'\ :sub:`4-0` 34Cb\ :sub:`5-0` Cr\ :sub:`4-0`], and stored in memory in two bytes, 35[Cb\ :sub:`2-0` Cr\ :sub:`4-0`] followed by [Y'\ :sub:`4-0` Cb\ :sub:`5-3`]. 36 37.. raw:: latex 38 39 \begingroup 40 \scriptsize 41 \setlength{\tabcolsep}{2pt} 42 43.. tabularcolumns:: |p{3.5cm}|p{0.96cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}| 44 45.. flat-table:: Packed YUV 4:4:4 Image Formats (less than 8bpc) 46 :header-rows: 2 47 :stub-columns: 0 48 49 * - Identifier 50 - Code 51 52 - :cspan:`7` Byte 0 in memory 53 54 - :cspan:`7` Byte 1 55 56 * - 57 - 58 - 7 59 - 6 60 - 5 61 - 4 62 - 3 63 - 2 64 - 1 65 - 0 66 67 - 7 68 - 6 69 - 5 70 - 4 71 - 3 72 - 2 73 - 1 74 - 0 75 76 * .. _V4L2-PIX-FMT-YUV444: 77 78 - ``V4L2_PIX_FMT_YUV444`` 79 - 'Y444' 80 81 - Cb\ :sub:`3` 82 - Cb\ :sub:`2` 83 - Cb\ :sub:`1` 84 - Cb\ :sub:`0` 85 - Cr\ :sub:`3` 86 - Cr\ :sub:`2` 87 - Cr\ :sub:`1` 88 - Cr\ :sub:`0` 89 90 - a\ :sub:`3` 91 - a\ :sub:`2` 92 - a\ :sub:`1` 93 - a\ :sub:`0` 94 - Y'\ :sub:`3` 95 - Y'\ :sub:`2` 96 - Y'\ :sub:`1` 97 - Y'\ :sub:`0` 98 99 * .. _V4L2-PIX-FMT-YUV555: 100 101 - ``V4L2_PIX_FMT_YUV555`` 102 - 'YUVO' 103 104 - Cb\ :sub:`2` 105 - Cb\ :sub:`1` 106 - Cb\ :sub:`0` 107 - Cr\ :sub:`4` 108 - Cr\ :sub:`3` 109 - Cr\ :sub:`2` 110 - Cr\ :sub:`1` 111 - Cr\ :sub:`0` 112 113 - a 114 - Y'\ :sub:`4` 115 - Y'\ :sub:`3` 116 - Y'\ :sub:`2` 117 - Y'\ :sub:`1` 118 - Y'\ :sub:`0` 119 - Cb\ :sub:`4` 120 - Cb\ :sub:`3` 121 122 * .. _V4L2-PIX-FMT-YUV565: 123 124 - ``V4L2_PIX_FMT_YUV565`` 125 - 'YUVP' 126 127 - Cb\ :sub:`2` 128 - Cb\ :sub:`1` 129 - Cb\ :sub:`0` 130 - Cr\ :sub:`4` 131 - Cr\ :sub:`3` 132 - Cr\ :sub:`2` 133 - Cr\ :sub:`1` 134 - Cr\ :sub:`0` 135 136 - Y'\ :sub:`4` 137 - Y'\ :sub:`3` 138 - Y'\ :sub:`2` 139 - Y'\ :sub:`1` 140 - Y'\ :sub:`0` 141 - Cb\ :sub:`5` 142 - Cb\ :sub:`4` 143 - Cb\ :sub:`3` 144 145.. raw:: latex 146 147 \endgroup 148 149.. note:: 150 151 For the YUV444 and YUV555 formats, the value of alpha bits is undefined 152 when reading from the driver, ignored when writing to the driver, except 153 when alpha blending has been negotiated for a :ref:`Video Overlay 154 <overlay>` or :ref:`Video Output Overlay <osd>`. 155 156 157The next table lists the packed YUV 4:4:4 formats with 8 bits per component. 158They are named based on the order of the Y, Cb and Cr components as stored in 159memory, and on the total number of bits per pixel. For instance, the VUYX32 160format stores a pixel with Cr\ :sub:`7-0` in the first byte, Cb\ :sub:`7-0` in 161the second byte and Y'\ :sub:`7-0` in the third byte. 162 163.. flat-table:: Packed YUV Image Formats (8bpc) 164 :header-rows: 1 165 :stub-columns: 0 166 167 * - Identifier 168 - Code 169 - Byte 0 170 - Byte 1 171 - Byte 2 172 - Byte 3 173 174 * .. _V4L2-PIX-FMT-YUV32: 175 176 - ``V4L2_PIX_FMT_YUV32`` 177 - 'YUV4' 178 179 - A\ :sub:`7-0` 180 - Y'\ :sub:`7-0` 181 - Cb\ :sub:`7-0` 182 - Cr\ :sub:`7-0` 183 184 * .. _V4L2-PIX-FMT-AYUV32: 185 186 - ``V4L2_PIX_FMT_AYUV32`` 187 - 'AYUV' 188 189 - A\ :sub:`7-0` 190 - Y'\ :sub:`7-0` 191 - Cb\ :sub:`7-0` 192 - Cr\ :sub:`7-0` 193 194 * .. _V4L2-PIX-FMT-XYUV32: 195 196 - ``V4L2_PIX_FMT_XYUV32`` 197 - 'XYUV' 198 199 - X\ :sub:`7-0` 200 - Y'\ :sub:`7-0` 201 - Cb\ :sub:`7-0` 202 - Cr\ :sub:`7-0` 203 204 * .. _V4L2-PIX-FMT-VUYA32: 205 206 - ``V4L2_PIX_FMT_VUYA32`` 207 - 'VUYA' 208 209 - Cr\ :sub:`7-0` 210 - Cb\ :sub:`7-0` 211 - Y'\ :sub:`7-0` 212 - A\ :sub:`7-0` 213 214 * .. _V4L2-PIX-FMT-VUYX32: 215 216 - ``V4L2_PIX_FMT_VUYX32`` 217 - 'VUYX' 218 219 - Cr\ :sub:`7-0` 220 - Cb\ :sub:`7-0` 221 - Y'\ :sub:`7-0` 222 - X\ :sub:`7-0` 223 224 * .. _V4L2-PIX-FMT-YUVA32: 225 226 - ``V4L2_PIX_FMT_YUVA32`` 227 - 'YUVA' 228 229 - Y'\ :sub:`7-0` 230 - Cb\ :sub:`7-0` 231 - Cr\ :sub:`7-0` 232 - A\ :sub:`7-0` 233 234 * .. _V4L2-PIX-FMT-YUVX32: 235 236 - ``V4L2_PIX_FMT_YUVX32`` 237 - 'YUVX' 238 239 - Y'\ :sub:`7-0` 240 - Cb\ :sub:`7-0` 241 - Cr\ :sub:`7-0` 242 - X\ :sub:`7-0` 243 244 * .. _V4L2-PIX-FMT-YUV24: 245 246 - ``V4L2_PIX_FMT_YUV24`` 247 - 'YUV3' 248 249 - Y'\ :sub:`7-0` 250 - Cb\ :sub:`7-0` 251 - Cr\ :sub:`7-0` 252 - -\ 253 254.. note:: 255 256 - The alpha component is expected to contain a meaningful value that can be 257 used by drivers and applications. 258 - The padding bits contain undefined values that must be ignored by all 259 applications and drivers. 260 261The next table lists the packed YUV 4:4:4 formats with 12 bits per component. 262Expand the bits per component to 16 bits, data in the high bits, zeros in the low bits, 263arranged in little endian order, storing 1 pixel in 6 bytes. 264 265.. flat-table:: Packed YUV 4:4:4 Image Formats (12bpc) 266 :header-rows: 1 267 :stub-columns: 0 268 269 * - Identifier 270 - Code 271 - Byte 1-0 272 - Byte 3-2 273 - Byte 5-4 274 - Byte 7-6 275 - Byte 9-8 276 - Byte 11-10 277 278 * .. _V4L2-PIX-FMT-YUV48-12: 279 280 - ``V4L2_PIX_FMT_YUV48_12`` 281 - 'Y312' 282 283 - Y'\ :sub:`0` 284 - Cb\ :sub:`0` 285 - Cr\ :sub:`0` 286 - Y'\ :sub:`1` 287 - Cb\ :sub:`1` 288 - Cr\ :sub:`1` 289 2904:2:2 Subsampling 291================= 292 293These formats, commonly referred to as YUYV or YUY2, subsample the chroma 294components horizontally by 2, storing 2 pixels in a container. The container 295is 32-bits for 8-bit formats, and 64-bits for 10+-bit formats. 296 297The packed YUYV formats with more than 8 bits per component are stored as four 29816-bit little-endian words. Each word's most significant bits contain one 299component, and the least significant bits are zero padding. 300 301.. raw:: latex 302 303 \footnotesize 304 305.. tabularcolumns:: |p{3.4cm}|p{1.2cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}| 306 307.. flat-table:: Packed YUV 4:2:2 Formats in 32-bit container 308 :header-rows: 1 309 :stub-columns: 0 310 311 * - Identifier 312 - Code 313 - Byte 0 314 - Byte 1 315 - Byte 2 316 - Byte 3 317 - Byte 4 318 - Byte 5 319 - Byte 6 320 - Byte 7 321 * .. _V4L2-PIX-FMT-UYVY: 322 323 - ``V4L2_PIX_FMT_UYVY`` 324 - 'UYVY' 325 326 - Cb\ :sub:`0` 327 - Y'\ :sub:`0` 328 - Cr\ :sub:`0` 329 - Y'\ :sub:`1` 330 - Cb\ :sub:`2` 331 - Y'\ :sub:`2` 332 - Cr\ :sub:`2` 333 - Y'\ :sub:`3` 334 * .. _V4L2-PIX-FMT-VYUY: 335 336 - ``V4L2_PIX_FMT_VYUY`` 337 - 'VYUY' 338 339 - Cr\ :sub:`0` 340 - Y'\ :sub:`0` 341 - Cb\ :sub:`0` 342 - Y'\ :sub:`1` 343 - Cr\ :sub:`2` 344 - Y'\ :sub:`2` 345 - Cb\ :sub:`2` 346 - Y'\ :sub:`3` 347 * .. _V4L2-PIX-FMT-YUYV: 348 349 - ``V4L2_PIX_FMT_YUYV`` 350 - 'YUYV' 351 352 - Y'\ :sub:`0` 353 - Cb\ :sub:`0` 354 - Y'\ :sub:`1` 355 - Cr\ :sub:`0` 356 - Y'\ :sub:`2` 357 - Cb\ :sub:`2` 358 - Y'\ :sub:`3` 359 - Cr\ :sub:`2` 360 * .. _V4L2-PIX-FMT-YVYU: 361 362 - ``V4L2_PIX_FMT_YVYU`` 363 - 'YVYU' 364 365 - Y'\ :sub:`0` 366 - Cr\ :sub:`0` 367 - Y'\ :sub:`1` 368 - Cb\ :sub:`0` 369 - Y'\ :sub:`2` 370 - Cr\ :sub:`2` 371 - Y'\ :sub:`3` 372 - Cb\ :sub:`2` 373 374.. tabularcolumns:: |p{3.4cm}|p{1.2cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}| 375 376.. flat-table:: Packed YUV 4:2:2 Formats in 64-bit container 377 :header-rows: 1 378 :stub-columns: 0 379 380 * - Identifier 381 - Code 382 - Word 0 383 - Word 1 384 - Word 2 385 - Word 3 386 * .. _V4L2-PIX-FMT-Y210: 387 388 - ``V4L2_PIX_FMT_Y210`` 389 - 'Y210' 390 391 - Y'\ :sub:`0` (bits 15-6) 392 - Cb\ :sub:`0` (bits 15-6) 393 - Y'\ :sub:`1` (bits 15-6) 394 - Cr\ :sub:`0` (bits 15-6) 395 * .. _V4L2-PIX-FMT-Y212: 396 397 - ``V4L2_PIX_FMT_Y212`` 398 - 'Y212' 399 400 - Y'\ :sub:`0` (bits 15-4) 401 - Cb\ :sub:`0` (bits 15-4) 402 - Y'\ :sub:`1` (bits 15-4) 403 - Cr\ :sub:`0` (bits 15-4) 404 * .. _V4L2-PIX-FMT-Y216: 405 406 - ``V4L2_PIX_FMT_Y216`` 407 - 'Y216' 408 409 - Y'\ :sub:`0` (bits 15-0) 410 - Cb\ :sub:`0` (bits 15-0) 411 - Y'\ :sub:`1` (bits 15-0) 412 - Cr\ :sub:`0` (bits 15-0) 413 414.. raw:: latex 415 416 \normalsize 417 418**Color Sample Location:** 419Chroma samples are :ref:`interstitially sited<yuv-chroma-centered>` 420horizontally. 421 422 4234:1:1 Subsampling 424================= 425 426This format subsamples the chroma components horizontally by 4, storing 8 427pixels in 12 bytes. 428 429.. raw:: latex 430 431 \scriptsize 432 433.. tabularcolumns:: |p{2.9cm}|p{0.8cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}| 434 435.. flat-table:: Packed YUV 4:1:1 Formats 436 :header-rows: 1 437 :stub-columns: 0 438 439 * - Identifier 440 - Code 441 - Byte 0 442 - Byte 1 443 - Byte 2 444 - Byte 3 445 - Byte 4 446 - Byte 5 447 - Byte 6 448 - Byte 7 449 - Byte 8 450 - Byte 9 451 - Byte 10 452 - Byte 11 453 * .. _V4L2-PIX-FMT-Y41P: 454 455 - ``V4L2_PIX_FMT_Y41P`` 456 - 'Y41P' 457 458 - Cb\ :sub:`0` 459 - Y'\ :sub:`0` 460 - Cr\ :sub:`0` 461 - Y'\ :sub:`1` 462 - Cb\ :sub:`4` 463 - Y'\ :sub:`2` 464 - Cr\ :sub:`4` 465 - Y'\ :sub:`3` 466 - Y'\ :sub:`4` 467 - Y'\ :sub:`5` 468 - Y'\ :sub:`6` 469 - Y'\ :sub:`7` 470 471.. raw:: latex 472 473 \normalsize 474 475.. note:: 476 477 Do not confuse ``V4L2_PIX_FMT_Y41P`` with 478 :ref:`V4L2_PIX_FMT_YUV411P <V4L2-PIX-FMT-YUV411P>`. Y41P is derived from 479 "YUV 4:1:1 **packed**", while YUV411P stands for "YUV 4:1:1 **planar**". 480 481**Color Sample Location:** 482Chroma samples are :ref:`interstitially sited<yuv-chroma-centered>` 483horizontally. 484