pixfmt.xml 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992
  1. <title>Image Formats</title>
  2. <para>The V4L2 API was primarily designed for devices exchanging
  3. image data with applications. The
  4. <structname>v4l2_pix_format</structname> and <structname>v4l2_pix_format_mplane
  5. </structname> structures define the format and layout of an image in memory.
  6. The former is used with the single-planar API, while the latter is used with the
  7. multi-planar version (see <xref linkend="planar-apis"/>). Image formats are
  8. negotiated with the &VIDIOC-S-FMT; ioctl. (The explanations here focus on video
  9. capturing and output, for overlay frame buffer formats see also
  10. &VIDIOC-G-FBUF;.)</para>
  11. <section>
  12. <title>Single-planar format structure</title>
  13. <table pgwide="1" frame="none" id="v4l2-pix-format">
  14. <title>struct <structname>v4l2_pix_format</structname></title>
  15. <tgroup cols="3">
  16. &cs-str;
  17. <tbody valign="top">
  18. <row>
  19. <entry>__u32</entry>
  20. <entry><structfield>width</structfield></entry>
  21. <entry>Image width in pixels.</entry>
  22. </row>
  23. <row>
  24. <entry>__u32</entry>
  25. <entry><structfield>height</structfield></entry>
  26. <entry>Image height in pixels. If <structfield>field</structfield> is
  27. one of <constant>V4L2_FIELD_TOP</constant>, <constant>V4L2_FIELD_BOTTOM</constant>
  28. or <constant>V4L2_FIELD_ALTERNATE</constant> then height refers to the
  29. number of lines in the field, otherwise it refers to the number of
  30. lines in the frame (which is twice the field height for interlaced
  31. formats).</entry>
  32. </row>
  33. <row>
  34. <entry spanname="hspan">Applications set these fields to
  35. request an image size, drivers return the closest possible values. In
  36. case of planar formats the <structfield>width</structfield> and
  37. <structfield>height</structfield> applies to the largest plane. To
  38. avoid ambiguities drivers must return values rounded up to a multiple
  39. of the scale factor of any smaller planes. For example when the image
  40. format is YUV 4:2:0, <structfield>width</structfield> and
  41. <structfield>height</structfield> must be multiples of two.</entry>
  42. </row>
  43. <row>
  44. <entry>__u32</entry>
  45. <entry><structfield>pixelformat</structfield></entry>
  46. <entry>The pixel format or type of compression, set by the
  47. application. This is a little endian <link
  48. linkend="v4l2-fourcc">four character code</link>. V4L2 defines
  49. standard RGB formats in <xref linkend="rgb-formats" />, YUV formats in <xref
  50. linkend="yuv-formats" />, and reserved codes in <xref
  51. linkend="reserved-formats" /></entry>
  52. </row>
  53. <row>
  54. <entry>&v4l2-field;</entry>
  55. <entry><structfield>field</structfield></entry>
  56. <entry>Video images are typically interlaced. Applications
  57. can request to capture or output only the top or bottom field, or both
  58. fields interlaced or sequentially stored in one buffer or alternating
  59. in separate buffers. Drivers return the actual field order selected.
  60. For more details on fields see <xref linkend="field-order" />.</entry>
  61. </row>
  62. <row>
  63. <entry>__u32</entry>
  64. <entry><structfield>bytesperline</structfield></entry>
  65. <entry>Distance in bytes between the leftmost pixels in two
  66. adjacent lines.</entry>
  67. </row>
  68. <row>
  69. <entry spanname="hspan"><para>Both applications and drivers
  70. can set this field to request padding bytes at the end of each line.
  71. Drivers however may ignore the value requested by the application,
  72. returning <structfield>width</structfield> times bytes per pixel or a
  73. larger value required by the hardware. That implies applications can
  74. just set this field to zero to get a reasonable
  75. default.</para><para>Video hardware may access padding bytes,
  76. therefore they must reside in accessible memory. Consider cases where
  77. padding bytes after the last line of an image cross a system page
  78. boundary. Input devices may write padding bytes, the value is
  79. undefined. Output devices ignore the contents of padding
  80. bytes.</para><para>When the image format is planar the
  81. <structfield>bytesperline</structfield> value applies to the first
  82. plane and is divided by the same factor as the
  83. <structfield>width</structfield> field for the other planes. For
  84. example the Cb and Cr planes of a YUV 4:2:0 image have half as many
  85. padding bytes following each line as the Y plane. To avoid ambiguities
  86. drivers must return a <structfield>bytesperline</structfield> value
  87. rounded up to a multiple of the scale factor.</para>
  88. <para>For compressed formats the <structfield>bytesperline</structfield>
  89. value makes no sense. Applications and drivers must set this to 0 in
  90. that case.</para></entry>
  91. </row>
  92. <row>
  93. <entry>__u32</entry>
  94. <entry><structfield>sizeimage</structfield></entry>
  95. <entry>Size in bytes of the buffer to hold a complete image,
  96. set by the driver. Usually this is
  97. <structfield>bytesperline</structfield> times
  98. <structfield>height</structfield>. When the image consists of variable
  99. length compressed data this is the maximum number of bytes required to
  100. hold an image.</entry>
  101. </row>
  102. <row>
  103. <entry>&v4l2-colorspace;</entry>
  104. <entry><structfield>colorspace</structfield></entry>
  105. <entry>This information supplements the
  106. <structfield>pixelformat</structfield> and must be set by the driver for
  107. capture streams and by the application for output streams,
  108. see <xref linkend="colorspaces" />.</entry>
  109. </row>
  110. <row>
  111. <entry>__u32</entry>
  112. <entry><structfield>priv</structfield></entry>
  113. <entry><para>This field indicates whether the remaining fields of the
  114. <structname>v4l2_pix_format</structname> structure, also called the extended
  115. fields, are valid. When set to <constant>V4L2_PIX_FMT_PRIV_MAGIC</constant>, it
  116. indicates that the extended fields have been correctly initialized. When set to
  117. any other value it indicates that the extended fields contain undefined values.
  118. </para>
  119. <para>Applications that wish to use the pixel format extended fields must first
  120. ensure that the feature is supported by querying the device for the
  121. <link linkend="querycap"><constant>V4L2_CAP_EXT_PIX_FORMAT</constant></link>
  122. capability. If the capability isn't set the pixel format extended fields are not
  123. supported and using the extended fields will lead to undefined results.</para>
  124. <para>To use the extended fields, applications must set the
  125. <structfield>priv</structfield> field to
  126. <constant>V4L2_PIX_FMT_PRIV_MAGIC</constant>, initialize all the extended fields
  127. and zero the unused bytes of the <structname>v4l2_format</structname>
  128. <structfield>raw_data</structfield> field.</para>
  129. <para>When the <structfield>priv</structfield> field isn't set to
  130. <constant>V4L2_PIX_FMT_PRIV_MAGIC</constant> drivers must act as if all the
  131. extended fields were set to zero. On return drivers must set the
  132. <structfield>priv</structfield> field to
  133. <constant>V4L2_PIX_FMT_PRIV_MAGIC</constant> and all the extended fields to
  134. applicable values.</para></entry>
  135. </row>
  136. <row>
  137. <entry>__u32</entry>
  138. <entry><structfield>flags</structfield></entry>
  139. <entry>Flags set by the application or driver, see <xref
  140. linkend="format-flags" />.</entry>
  141. </row>
  142. <row>
  143. <entry>&v4l2-ycbcr-encoding;</entry>
  144. <entry><structfield>ycbcr_enc</structfield></entry>
  145. <entry>This information supplements the
  146. <structfield>colorspace</structfield> and must be set by the driver for
  147. capture streams and by the application for output streams,
  148. see <xref linkend="colorspaces" />.</entry>
  149. </row>
  150. <row>
  151. <entry>&v4l2-quantization;</entry>
  152. <entry><structfield>quantization</structfield></entry>
  153. <entry>This information supplements the
  154. <structfield>colorspace</structfield> and must be set by the driver for
  155. capture streams and by the application for output streams,
  156. see <xref linkend="colorspaces" />.</entry>
  157. </row>
  158. <row>
  159. <entry>&v4l2-xfer-func;</entry>
  160. <entry><structfield>xfer_func</structfield></entry>
  161. <entry>This information supplements the
  162. <structfield>colorspace</structfield> and must be set by the driver for
  163. capture streams and by the application for output streams,
  164. see <xref linkend="colorspaces" />.</entry>
  165. </row>
  166. </tbody>
  167. </tgroup>
  168. </table>
  169. </section>
  170. <section>
  171. <title>Multi-planar format structures</title>
  172. <para>The <structname>v4l2_plane_pix_format</structname> structures define
  173. size and layout for each of the planes in a multi-planar format.
  174. The <structname>v4l2_pix_format_mplane</structname> structure contains
  175. information common to all planes (such as image width and height) and
  176. an array of <structname>v4l2_plane_pix_format</structname> structures,
  177. describing all planes of that format.</para>
  178. <table pgwide="1" frame="none" id="v4l2-plane-pix-format">
  179. <title>struct <structname>v4l2_plane_pix_format</structname></title>
  180. <tgroup cols="3">
  181. &cs-str;
  182. <tbody valign="top">
  183. <row>
  184. <entry>__u32</entry>
  185. <entry><structfield>sizeimage</structfield></entry>
  186. <entry>Maximum size in bytes required for image data in this plane.
  187. </entry>
  188. </row>
  189. <row>
  190. <entry>__u32</entry>
  191. <entry><structfield>bytesperline</structfield></entry>
  192. <entry>Distance in bytes between the leftmost pixels in two adjacent
  193. lines. See &v4l2-pix-format;.</entry>
  194. </row>
  195. <row>
  196. <entry>__u16</entry>
  197. <entry><structfield>reserved[6]</structfield></entry>
  198. <entry>Reserved for future extensions. Should be zeroed by drivers and
  199. applications.</entry>
  200. </row>
  201. </tbody>
  202. </tgroup>
  203. </table>
  204. <table pgwide="1" frame="none" id="v4l2-pix-format-mplane">
  205. <title>struct <structname>v4l2_pix_format_mplane</structname></title>
  206. <tgroup cols="3">
  207. &cs-str;
  208. <tbody valign="top">
  209. <row>
  210. <entry>__u32</entry>
  211. <entry><structfield>width</structfield></entry>
  212. <entry>Image width in pixels. See &v4l2-pix-format;.</entry>
  213. </row>
  214. <row>
  215. <entry>__u32</entry>
  216. <entry><structfield>height</structfield></entry>
  217. <entry>Image height in pixels. See &v4l2-pix-format;.</entry>
  218. </row>
  219. <row>
  220. <entry>__u32</entry>
  221. <entry><structfield>pixelformat</structfield></entry>
  222. <entry>The pixel format. Both single- and multi-planar four character
  223. codes can be used.</entry>
  224. </row>
  225. <row>
  226. <entry>&v4l2-field;</entry>
  227. <entry><structfield>field</structfield></entry>
  228. <entry>See &v4l2-pix-format;.</entry>
  229. </row>
  230. <row>
  231. <entry>&v4l2-colorspace;</entry>
  232. <entry><structfield>colorspace</structfield></entry>
  233. <entry>See &v4l2-pix-format;.</entry>
  234. </row>
  235. <row>
  236. <entry>&v4l2-plane-pix-format;</entry>
  237. <entry><structfield>plane_fmt[VIDEO_MAX_PLANES]</structfield></entry>
  238. <entry>An array of structures describing format of each plane this
  239. pixel format consists of. The number of valid entries in this array
  240. has to be put in the <structfield>num_planes</structfield>
  241. field.</entry>
  242. </row>
  243. <row>
  244. <entry>__u8</entry>
  245. <entry><structfield>num_planes</structfield></entry>
  246. <entry>Number of planes (i.e. separate memory buffers) for this format
  247. and the number of valid entries in the
  248. <structfield>plane_fmt</structfield> array.</entry>
  249. </row>
  250. <row>
  251. <entry>__u8</entry>
  252. <entry><structfield>flags</structfield></entry>
  253. <entry>Flags set by the application or driver, see <xref
  254. linkend="format-flags" />.</entry>
  255. </row>
  256. <row>
  257. <entry>&v4l2-ycbcr-encoding;</entry>
  258. <entry><structfield>ycbcr_enc</structfield></entry>
  259. <entry>This information supplements the
  260. <structfield>colorspace</structfield> and must be set by the driver for
  261. capture streams and by the application for output streams,
  262. see <xref linkend="colorspaces" />.</entry>
  263. </row>
  264. <row>
  265. <entry>&v4l2-quantization;</entry>
  266. <entry><structfield>quantization</structfield></entry>
  267. <entry>This information supplements the
  268. <structfield>colorspace</structfield> and must be set by the driver for
  269. capture streams and by the application for output streams,
  270. see <xref linkend="colorspaces" />.</entry>
  271. </row>
  272. <row>
  273. <entry>&v4l2-xfer-func;</entry>
  274. <entry><structfield>xfer_func</structfield></entry>
  275. <entry>This information supplements the
  276. <structfield>colorspace</structfield> and must be set by the driver for
  277. capture streams and by the application for output streams,
  278. see <xref linkend="colorspaces" />.</entry>
  279. </row>
  280. <row>
  281. <entry>__u8</entry>
  282. <entry><structfield>reserved[7]</structfield></entry>
  283. <entry>Reserved for future extensions. Should be zeroed by drivers
  284. and applications.</entry>
  285. </row>
  286. </tbody>
  287. </tgroup>
  288. </table>
  289. </section>
  290. <section>
  291. <title>Standard Image Formats</title>
  292. <para>In order to exchange images between drivers and
  293. applications, it is necessary to have standard image data formats
  294. which both sides will interpret the same way. V4L2 includes several
  295. such formats, and this section is intended to be an unambiguous
  296. specification of the standard image data formats in V4L2.</para>
  297. <para>V4L2 drivers are not limited to these formats, however.
  298. Driver-specific formats are possible. In that case the application may
  299. depend on a codec to convert images to one of the standard formats
  300. when needed. But the data can still be stored and retrieved in the
  301. proprietary format. For example, a device may support a proprietary
  302. compressed format. Applications can still capture and save the data in
  303. the compressed format, saving much disk space, and later use a codec
  304. to convert the images to the X Windows screen format when the video is
  305. to be displayed.</para>
  306. <para>Even so, ultimately, some standard formats are needed, so
  307. the V4L2 specification would not be complete without well-defined
  308. standard formats.</para>
  309. <para>The V4L2 standard formats are mainly uncompressed formats. The
  310. pixels are always arranged in memory from left to right, and from top
  311. to bottom. The first byte of data in the image buffer is always for
  312. the leftmost pixel of the topmost row. Following that is the pixel
  313. immediately to its right, and so on until the end of the top row of
  314. pixels. Following the rightmost pixel of the row there may be zero or
  315. more bytes of padding to guarantee that each row of pixel data has a
  316. certain alignment. Following the pad bytes, if any, is data for the
  317. leftmost pixel of the second row from the top, and so on. The last row
  318. has just as many pad bytes after it as the other rows.</para>
  319. <para>In V4L2 each format has an identifier which looks like
  320. <constant>PIX_FMT_XXX</constant>, defined in the <link
  321. linkend="videodev">videodev2.h</link> header file. These identifiers
  322. represent <link linkend="v4l2-fourcc">four character (FourCC) codes</link>
  323. which are also listed below, however they are not the same as those
  324. used in the Windows world.</para>
  325. <para>For some formats, data is stored in separate, discontiguous
  326. memory buffers. Those formats are identified by a separate set of FourCC codes
  327. and are referred to as "multi-planar formats". For example, a YUV422 frame is
  328. normally stored in one memory buffer, but it can also be placed in two or three
  329. separate buffers, with Y component in one buffer and CbCr components in another
  330. in the 2-planar version or with each component in its own buffer in the
  331. 3-planar case. Those sub-buffers are referred to as "planes".</para>
  332. </section>
  333. <section id="colorspaces">
  334. <title>Colorspaces</title>
  335. <para>'Color' is a very complex concept and depends on physics, chemistry and
  336. biology. Just because you have three numbers that describe the 'red', 'green'
  337. and 'blue' components of the color of a pixel does not mean that you can accurately
  338. display that color. A colorspace defines what it actually <emphasis>means</emphasis>
  339. to have an RGB value of e.g. (255,&nbsp;0,&nbsp;0). That is, which color should be
  340. reproduced on the screen in a perfectly calibrated environment.</para>
  341. <para>In order to do that we first need to have a good definition of
  342. color, i.e. some way to uniquely and unambiguously define a color so that someone
  343. else can reproduce it. Human color vision is trichromatic since the human eye has
  344. color receptors that are sensitive to three different wavelengths of light. Hence
  345. the need to use three numbers to describe color. Be glad you are not a mantis shrimp
  346. as those are sensitive to 12 different wavelengths, so instead of RGB we would be
  347. using the ABCDEFGHIJKL colorspace...</para>
  348. <para>Color exists only in the eye and brain and is the result of how strongly
  349. color receptors are stimulated. This is based on the Spectral
  350. Power Distribution (SPD) which is a graph showing the intensity (radiant power)
  351. of the light at wavelengths covering the visible spectrum as it enters the eye.
  352. The science of colorimetry is about the relationship between the SPD and color as
  353. perceived by the human brain.</para>
  354. <para>Since the human eye has only three color receptors it is perfectly
  355. possible that different SPDs will result in the same stimulation of those receptors
  356. and are perceived as the same color, even though the SPD of the light is
  357. different.</para>
  358. <para>In the 1920s experiments were devised to determine the relationship
  359. between SPDs and the perceived color and that resulted in the CIE 1931 standard
  360. that defines spectral weighting functions that model the perception of color.
  361. Specifically that standard defines functions that can take an SPD and calculate
  362. the stimulus for each color receptor. After some further mathematical transforms
  363. these stimuli are known as the <emphasis>CIE XYZ tristimulus</emphasis> values
  364. and these X, Y and Z values describe a color as perceived by a human unambiguously.
  365. These X, Y and Z values are all in the range [0&hellip;1].</para>
  366. <para>The Y value in the CIE XYZ colorspace corresponds to luminance. Often
  367. the CIE XYZ colorspace is transformed to the normalized CIE xyY colorspace:</para>
  368. <para>x = X / (X + Y + Z)</para>
  369. <para>y = Y / (X + Y + Z)</para>
  370. <para>The x and y values are the chromaticity coordinates and can be used to
  371. define a color without the luminance component Y. It is very confusing to
  372. have such similar names for these colorspaces. Just be aware that if colors
  373. are specified with lower case 'x' and 'y', then the CIE xyY colorspace is
  374. used. Upper case 'X' and 'Y' refer to the CIE XYZ colorspace. Also, y has nothing
  375. to do with luminance. Together x and y specify a color, and Y the luminance.
  376. That is really all you need to remember from a practical point of view. At
  377. the end of this section you will find reading resources that go into much more
  378. detail if you are interested.
  379. </para>
  380. <para>A monitor or TV will reproduce colors by emitting light at three
  381. different wavelengths, the combination of which will stimulate the color receptors
  382. in the eye and thus cause the perception of color. Historically these wavelengths
  383. were defined by the red, green and blue phosphors used in the displays. These
  384. <emphasis>color primaries</emphasis> are part of what defines a colorspace.</para>
  385. <para>Different display devices will have different primaries and some
  386. primaries are more suitable for some display technologies than others. This has
  387. resulted in a variety of colorspaces that are used for different display
  388. technologies or uses. To define a colorspace you need to define the three
  389. color primaries (these are typically defined as x,&nbsp;y chromaticity coordinates
  390. from the CIE xyY colorspace) but also the white reference: that is the color obtained
  391. when all three primaries are at maximum power. This determines the relative power
  392. or energy of the primaries. This is usually chosen to be close to daylight which has
  393. been defined as the CIE D65 Illuminant.</para>
  394. <para>To recapitulate: the CIE XYZ colorspace uniquely identifies colors.
  395. Other colorspaces are defined by three chromaticity coordinates defined in the
  396. CIE xyY colorspace. Based on those a 3x3 matrix can be constructed that
  397. transforms CIE XYZ colors to colors in the new colorspace.
  398. </para>
  399. <para>Both the CIE XYZ and the RGB colorspace that are derived from the
  400. specific chromaticity primaries are linear colorspaces. But neither the eye,
  401. nor display technology is linear. Doubling the values of all components in
  402. the linear colorspace will not be perceived as twice the intensity of the color.
  403. So each colorspace also defines a transfer function that takes a linear color
  404. component value and transforms it to the non-linear component value, which is a
  405. closer match to the non-linear performance of both the eye and displays. Linear
  406. component values are denoted RGB, non-linear are denoted as R'G'B'. In general
  407. colors used in graphics are all R'G'B', except in openGL which uses linear RGB.
  408. Special care should be taken when dealing with openGL to provide linear RGB colors
  409. or to use the built-in openGL support to apply the inverse transfer function.</para>
  410. <para>The final piece that defines a colorspace is a function that
  411. transforms non-linear R'G'B' to non-linear Y'CbCr. This function is determined
  412. by the so-called luma coefficients. There may be multiple possible Y'CbCr
  413. encodings allowed for the same colorspace. Many encodings of color
  414. prefer to use luma (Y') and chroma (CbCr) instead of R'G'B'. Since the human
  415. eye is more sensitive to differences in luminance than in color this encoding
  416. allows one to reduce the amount of color information compared to the luma
  417. data. Note that the luma (Y') is unrelated to the Y in the CIE XYZ colorspace.
  418. Also note that Y'CbCr is often called YCbCr or YUV even though these are
  419. strictly speaking wrong.</para>
  420. <para>Sometimes people confuse Y'CbCr as being a colorspace. This is not
  421. correct, it is just an encoding of an R'G'B' color into luma and chroma
  422. values. The underlying colorspace that is associated with the R'G'B' color
  423. is also associated with the Y'CbCr color.</para>
  424. <para>The final step is how the RGB, R'G'B' or Y'CbCr values are
  425. quantized. The CIE XYZ colorspace where X, Y and Z are in the range
  426. [0&hellip;1] describes all colors that humans can perceive, but the transform to
  427. another colorspace will produce colors that are outside the [0&hellip;1] range.
  428. Once clamped to the [0&hellip;1] range those colors can no longer be reproduced
  429. in that colorspace. This clamping is what reduces the extent or gamut of the
  430. colorspace. How the range of [0&hellip;1] is translated to integer values in the
  431. range of [0&hellip;255] (or higher, depending on the color depth) is called the
  432. quantization. This is <emphasis>not</emphasis> part of the colorspace
  433. definition. In practice RGB or R'G'B' values are full range, i.e. they
  434. use the full [0&hellip;255] range. Y'CbCr values on the other hand are limited
  435. range with Y' using [16&hellip;235] and Cb and Cr using [16&hellip;240].</para>
  436. <para>Unfortunately, in some cases limited range RGB is also used
  437. where the components use the range [16&hellip;235]. And full range Y'CbCr also exists
  438. using the [0&hellip;255] range.</para>
  439. <para>In order to correctly interpret a color you need to know the
  440. quantization range, whether it is R'G'B' or Y'CbCr, the used Y'CbCr encoding
  441. and the colorspace.
  442. From that information you can calculate the corresponding CIE XYZ color
  443. and map that again to whatever colorspace your display device uses.</para>
  444. <para>The colorspace definition itself consists of the three
  445. chromaticity primaries, the white reference chromaticity, a transfer
  446. function and the luma coefficients needed to transform R'G'B' to Y'CbCr. While
  447. some colorspace standards correctly define all four, quite often the colorspace
  448. standard only defines some, and you have to rely on other standards for
  449. the missing pieces. The fact that colorspaces are often a mix of different
  450. standards also led to very confusing naming conventions where the name of
  451. a standard was used to name a colorspace when in fact that standard was
  452. part of various other colorspaces as well.</para>
  453. <para>If you want to read more about colors and colorspaces, then the
  454. following resources are useful: <xref linkend="poynton" /> is a good practical
  455. book for video engineers, <xref linkend="colimg" /> has a much broader scope and
  456. describes many more aspects of color (physics, chemistry, biology, etc.).
  457. The <ulink url="http://www.brucelindbloom.com">http://www.brucelindbloom.com</ulink>
  458. website is an excellent resource, especially with respect to the mathematics behind
  459. colorspace conversions. The wikipedia <ulink url="http://en.wikipedia.org/wiki/CIE_1931_color_space#CIE_xy_chromaticity_diagram_and_the_CIE_xyY_color_space">CIE 1931 colorspace</ulink> article
  460. is also very useful.</para>
  461. </section>
  462. <section>
  463. <title>Defining Colorspaces in V4L2</title>
  464. <para>In V4L2 colorspaces are defined by four values. The first is the colorspace
  465. identifier (&v4l2-colorspace;) which defines the chromaticities, the default transfer
  466. function, the default Y'CbCr encoding and the default quantization method. The second
  467. is the transfer function identifier (&v4l2-xfer-func;) to specify non-standard
  468. transfer functions. The third is the Y'CbCr encoding identifier (&v4l2-ycbcr-encoding;)
  469. to specify non-standard Y'CbCr encodings and the fourth is the quantization identifier
  470. (&v4l2-quantization;) to specify non-standard quantization methods. Most of the time
  471. only the colorspace field of &v4l2-pix-format; or &v4l2-pix-format-mplane; needs to
  472. be filled in. Note that the default R'G'B' quantization is full range for all
  473. colorspaces except for BT.2020 which uses limited range R'G'B' quantization.</para>
  474. <table pgwide="1" frame="none" id="v4l2-colorspace">
  475. <title>V4L2 Colorspaces</title>
  476. <tgroup cols="2" align="left">
  477. &cs-def;
  478. <thead>
  479. <row>
  480. <entry>Identifier</entry>
  481. <entry>Details</entry>
  482. </row>
  483. </thead>
  484. <tbody valign="top">
  485. <row>
  486. <entry><constant>V4L2_COLORSPACE_DEFAULT</constant></entry>
  487. <entry>The default colorspace. This can be used by applications to let the
  488. driver fill in the colorspace.</entry>
  489. </row>
  490. <row>
  491. <entry><constant>V4L2_COLORSPACE_SMPTE170M</constant></entry>
  492. <entry>See <xref linkend="col-smpte-170m" />.</entry>
  493. </row>
  494. <row>
  495. <entry><constant>V4L2_COLORSPACE_REC709</constant></entry>
  496. <entry>See <xref linkend="col-rec709" />.</entry>
  497. </row>
  498. <row>
  499. <entry><constant>V4L2_COLORSPACE_SRGB</constant></entry>
  500. <entry>See <xref linkend="col-srgb" />.</entry>
  501. </row>
  502. <row>
  503. <entry><constant>V4L2_COLORSPACE_ADOBERGB</constant></entry>
  504. <entry>See <xref linkend="col-adobergb" />.</entry>
  505. </row>
  506. <row>
  507. <entry><constant>V4L2_COLORSPACE_BT2020</constant></entry>
  508. <entry>See <xref linkend="col-bt2020" />.</entry>
  509. </row>
  510. <row>
  511. <entry><constant>V4L2_COLORSPACE_DCI_P3</constant></entry>
  512. <entry>See <xref linkend="col-dcip3" />.</entry>
  513. </row>
  514. <row>
  515. <entry><constant>V4L2_COLORSPACE_SMPTE240M</constant></entry>
  516. <entry>See <xref linkend="col-smpte-240m" />.</entry>
  517. </row>
  518. <row>
  519. <entry><constant>V4L2_COLORSPACE_470_SYSTEM_M</constant></entry>
  520. <entry>See <xref linkend="col-sysm" />.</entry>
  521. </row>
  522. <row>
  523. <entry><constant>V4L2_COLORSPACE_470_SYSTEM_BG</constant></entry>
  524. <entry>See <xref linkend="col-sysbg" />.</entry>
  525. </row>
  526. <row>
  527. <entry><constant>V4L2_COLORSPACE_JPEG</constant></entry>
  528. <entry>See <xref linkend="col-jpeg" />.</entry>
  529. </row>
  530. <row>
  531. <entry><constant>V4L2_COLORSPACE_RAW</constant></entry>
  532. <entry>The raw colorspace. This is used for raw image capture where
  533. the image is minimally processed and is using the internal colorspace
  534. of the device. The software that processes an image using this
  535. 'colorspace' will have to know the internals of the capture device.</entry>
  536. </row>
  537. </tbody>
  538. </tgroup>
  539. </table>
  540. <table pgwide="1" frame="none" id="v4l2-xfer-func">
  541. <title>V4L2 Transfer Function</title>
  542. <tgroup cols="2" align="left">
  543. &cs-def;
  544. <thead>
  545. <row>
  546. <entry>Identifier</entry>
  547. <entry>Details</entry>
  548. </row>
  549. </thead>
  550. <tbody valign="top">
  551. <row>
  552. <entry><constant>V4L2_XFER_FUNC_DEFAULT</constant></entry>
  553. <entry>Use the default transfer function as defined by the colorspace.</entry>
  554. </row>
  555. <row>
  556. <entry><constant>V4L2_XFER_FUNC_709</constant></entry>
  557. <entry>Use the Rec. 709 transfer function.</entry>
  558. </row>
  559. <row>
  560. <entry><constant>V4L2_XFER_FUNC_SRGB</constant></entry>
  561. <entry>Use the sRGB transfer function.</entry>
  562. </row>
  563. <row>
  564. <entry><constant>V4L2_XFER_FUNC_ADOBERGB</constant></entry>
  565. <entry>Use the AdobeRGB transfer function.</entry>
  566. </row>
  567. <row>
  568. <entry><constant>V4L2_XFER_FUNC_SMPTE240M</constant></entry>
  569. <entry>Use the SMPTE 240M transfer function.</entry>
  570. </row>
  571. <row>
  572. <entry><constant>V4L2_XFER_FUNC_NONE</constant></entry>
  573. <entry>Do not use a transfer function (i.e. use linear RGB values).</entry>
  574. </row>
  575. <row>
  576. <entry><constant>V4L2_XFER_FUNC_DCI_P3</constant></entry>
  577. <entry>Use the DCI-P3 transfer function.</entry>
  578. </row>
  579. <row>
  580. <entry><constant>V4L2_XFER_FUNC_SMPTE2084</constant></entry>
  581. <entry>Use the SMPTE 2084 transfer function.</entry>
  582. </row>
  583. </tbody>
  584. </tgroup>
  585. </table>
  586. <table pgwide="1" frame="none" id="v4l2-ycbcr-encoding">
  587. <title>V4L2 Y'CbCr Encodings</title>
  588. <tgroup cols="2" align="left">
  589. &cs-def;
  590. <thead>
  591. <row>
  592. <entry>Identifier</entry>
  593. <entry>Details</entry>
  594. </row>
  595. </thead>
  596. <tbody valign="top">
  597. <row>
  598. <entry><constant>V4L2_YCBCR_ENC_DEFAULT</constant></entry>
  599. <entry>Use the default Y'CbCr encoding as defined by the colorspace.</entry>
  600. </row>
  601. <row>
  602. <entry><constant>V4L2_YCBCR_ENC_601</constant></entry>
  603. <entry>Use the BT.601 Y'CbCr encoding.</entry>
  604. </row>
  605. <row>
  606. <entry><constant>V4L2_YCBCR_ENC_709</constant></entry>
  607. <entry>Use the Rec. 709 Y'CbCr encoding.</entry>
  608. </row>
  609. <row>
  610. <entry><constant>V4L2_YCBCR_ENC_XV601</constant></entry>
  611. <entry>Use the extended gamut xvYCC BT.601 encoding.</entry>
  612. </row>
  613. <row>
  614. <entry><constant>V4L2_YCBCR_ENC_XV709</constant></entry>
  615. <entry>Use the extended gamut xvYCC Rec. 709 encoding.</entry>
  616. </row>
  617. <row>
  618. <entry><constant>V4L2_YCBCR_ENC_SYCC</constant></entry>
  619. <entry>Use the extended gamut sYCC encoding.</entry>
  620. </row>
  621. <row>
  622. <entry><constant>V4L2_YCBCR_ENC_BT2020</constant></entry>
  623. <entry>Use the default non-constant luminance BT.2020 Y'CbCr encoding.</entry>
  624. </row>
  625. <row>
  626. <entry><constant>V4L2_YCBCR_ENC_BT2020_CONST_LUM</constant></entry>
  627. <entry>Use the constant luminance BT.2020 Yc'CbcCrc encoding.</entry>
  628. </row>
  629. </tbody>
  630. </tgroup>
  631. </table>
  632. <table pgwide="1" frame="none" id="v4l2-quantization">
  633. <title>V4L2 Quantization Methods</title>
  634. <tgroup cols="2" align="left">
  635. &cs-def;
  636. <thead>
  637. <row>
  638. <entry>Identifier</entry>
  639. <entry>Details</entry>
  640. </row>
  641. </thead>
  642. <tbody valign="top">
  643. <row>
  644. <entry><constant>V4L2_QUANTIZATION_DEFAULT</constant></entry>
  645. <entry>Use the default quantization encoding as defined by the colorspace.
  646. This is always full range for R'G'B' (except for the BT.2020 colorspace) and usually
  647. limited range for Y'CbCr.</entry>
  648. </row>
  649. <row>
  650. <entry><constant>V4L2_QUANTIZATION_FULL_RANGE</constant></entry>
  651. <entry>Use the full range quantization encoding. I.e. the range [0&hellip;1]
  652. is mapped to [0&hellip;255] (with possible clipping to [1&hellip;254] to avoid the
  653. 0x00 and 0xff values). Cb and Cr are mapped from [-0.5&hellip;0.5] to [0&hellip;255]
  654. (with possible clipping to [1&hellip;254] to avoid the 0x00 and 0xff values).</entry>
  655. </row>
  656. <row>
  657. <entry><constant>V4L2_QUANTIZATION_LIM_RANGE</constant></entry>
  658. <entry>Use the limited range quantization encoding. I.e. the range [0&hellip;1]
  659. is mapped to [16&hellip;235]. Cb and Cr are mapped from [-0.5&hellip;0.5] to [16&hellip;240].
  660. </entry>
  661. </row>
  662. </tbody>
  663. </tgroup>
  664. </table>
  665. </section>
  666. <section>
  667. <title>Detailed Colorspace Descriptions</title>
  668. <section id="col-smpte-170m">
  669. <title>Colorspace SMPTE 170M (<constant>V4L2_COLORSPACE_SMPTE170M</constant>)</title>
  670. <para>The <xref linkend="smpte170m" /> standard defines the colorspace used by NTSC and PAL and by SDTV
  671. in general. The default transfer function is <constant>V4L2_XFER_FUNC_709</constant>.
  672. The default Y'CbCr encoding is <constant>V4L2_YCBCR_ENC_601</constant>.
  673. The default Y'CbCr quantization is limited range. The chromaticities of the primary colors and
  674. the white reference are:</para>
  675. <table frame="none">
  676. <title>SMPTE 170M Chromaticities</title>
  677. <tgroup cols="3" align="left">
  678. &cs-str;
  679. <thead>
  680. <row>
  681. <entry>Color</entry>
  682. <entry>x</entry>
  683. <entry>y</entry>
  684. </row>
  685. </thead>
  686. <tbody valign="top">
  687. <row>
  688. <entry>Red</entry>
  689. <entry>0.630</entry>
  690. <entry>0.340</entry>
  691. </row>
  692. <row>
  693. <entry>Green</entry>
  694. <entry>0.310</entry>
  695. <entry>0.595</entry>
  696. </row>
  697. <row>
  698. <entry>Blue</entry>
  699. <entry>0.155</entry>
  700. <entry>0.070</entry>
  701. </row>
  702. <row>
  703. <entry>White Reference (D65)</entry>
  704. <entry>0.3127</entry>
  705. <entry>0.3290</entry>
  706. </row>
  707. </tbody>
  708. </tgroup>
  709. </table>
  710. <para>The red, green and blue chromaticities are also often referred to
  711. as the SMPTE C set, so this colorspace is sometimes called SMPTE C as well.</para>
  712. <variablelist>
  713. <varlistentry>
  714. <term>The transfer function defined for SMPTE 170M is the same as the
  715. one defined in Rec. 709.</term>
  716. <listitem>
  717. <para>L' = -1.099(-L)<superscript>0.45</superscript>&nbsp;+&nbsp;0.099&nbsp;for&nbsp;L&nbsp;&le;&nbsp;-0.018</para>
  718. <para>L' = 4.5L&nbsp;for&nbsp;-0.018&nbsp;&lt;&nbsp;L&nbsp;&lt;&nbsp;0.018</para>
  719. <para>L' = 1.099L<superscript>0.45</superscript>&nbsp;-&nbsp;0.099&nbsp;for&nbsp;L&nbsp;&ge;&nbsp;0.018</para>
  720. </listitem>
  721. </varlistentry>
  722. </variablelist>
  723. <variablelist>
  724. <varlistentry>
  725. <term>Inverse Transfer function:</term>
  726. <listitem>
  727. <para>L = -((L'&nbsp;-&nbsp;0.099)&nbsp;/&nbsp;-1.099)<superscript>1/0.45</superscript>&nbsp;for&nbsp;L'&nbsp;&le;&nbsp;-0.081</para>
  728. <para>L = L'&nbsp;/&nbsp;4.5&nbsp;for&nbsp;-0.081&nbsp;&lt;&nbsp;L'&nbsp;&lt;&nbsp;0.081</para>
  729. <para>L = ((L'&nbsp;+&nbsp;0.099)&nbsp;/&nbsp;1.099)<superscript>1/0.45</superscript>&nbsp;for&nbsp;L'&nbsp;&ge;&nbsp;0.081</para>
  730. </listitem>
  731. </varlistentry>
  732. </variablelist>
  733. <variablelist>
  734. <varlistentry>
  735. <term>The luminance (Y') and color difference (Cb and Cr) are obtained with
  736. the following <constant>V4L2_YCBCR_ENC_601</constant> encoding:</term>
  737. <listitem>
  738. <para>Y'&nbsp;=&nbsp;0.299R'&nbsp;+&nbsp;0.587G'&nbsp;+&nbsp;0.114B'</para>
  739. <para>Cb&nbsp;=&nbsp;-0.169R'&nbsp;-&nbsp;0.331G'&nbsp;+&nbsp;0.5B'</para>
  740. <para>Cr&nbsp;=&nbsp;0.5R'&nbsp;-&nbsp;0.419G'&nbsp;-&nbsp;0.081B'</para>
  741. </listitem>
  742. </varlistentry>
  743. </variablelist>
  744. <para>Y' is clamped to the range [0&hellip;1] and Cb and Cr are
  745. clamped to the range [-0.5&hellip;0.5]. This conversion to Y'CbCr is identical to the one
  746. defined in the <xref linkend="itu601" /> standard and this colorspace is sometimes called BT.601 as well, even
  747. though BT.601 does not mention any color primaries.</para>
  748. <para>The default quantization is limited range, but full range is possible although
  749. rarely seen.</para>
  750. </section>
  751. <section id="col-rec709">
  752. <title>Colorspace Rec. 709 (<constant>V4L2_COLORSPACE_REC709</constant>)</title>
  753. <para>The <xref linkend="itu709" /> standard defines the colorspace used by HDTV in general.
  754. The default transfer function is <constant>V4L2_XFER_FUNC_709</constant>. The default
  755. Y'CbCr encoding is <constant>V4L2_YCBCR_ENC_709</constant>. The default Y'CbCr quantization is
  756. limited range. The chromaticities of the primary colors and the white reference are:</para>
  757. <table frame="none">
  758. <title>Rec. 709 Chromaticities</title>
  759. <tgroup cols="3" align="left">
  760. &cs-str;
  761. <thead>
  762. <row>
  763. <entry>Color</entry>
  764. <entry>x</entry>
  765. <entry>y</entry>
  766. </row>
  767. </thead>
  768. <tbody valign="top">
  769. <row>
  770. <entry>Red</entry>
  771. <entry>0.640</entry>
  772. <entry>0.330</entry>
  773. </row>
  774. <row>
  775. <entry>Green</entry>
  776. <entry>0.300</entry>
  777. <entry>0.600</entry>
  778. </row>
  779. <row>
  780. <entry>Blue</entry>
  781. <entry>0.150</entry>
  782. <entry>0.060</entry>
  783. </row>
  784. <row>
  785. <entry>White Reference (D65)</entry>
  786. <entry>0.3127</entry>
  787. <entry>0.3290</entry>
  788. </row>
  789. </tbody>
  790. </tgroup>
  791. </table>
  792. <para>The full name of this standard is Rec. ITU-R BT.709-5.</para>
  793. <variablelist>
  794. <varlistentry>
  795. <term>Transfer function. Normally L is in the range [0&hellip;1], but for the extended
  796. gamut xvYCC encoding values outside that range are allowed.</term>
  797. <listitem>
  798. <para>L' = -1.099(-L)<superscript>0.45</superscript>&nbsp;+&nbsp;0.099&nbsp;for&nbsp;L&nbsp;&le;&nbsp;-0.018</para>
  799. <para>L' = 4.5L&nbsp;for&nbsp;-0.018&nbsp;&lt;&nbsp;L&nbsp;&lt;&nbsp;0.018</para>
  800. <para>L' = 1.099L<superscript>0.45</superscript>&nbsp;-&nbsp;0.099&nbsp;for&nbsp;L&nbsp;&ge;&nbsp;0.018</para>
  801. </listitem>
  802. </varlistentry>
  803. </variablelist>
  804. <variablelist>
  805. <varlistentry>
  806. <term>Inverse Transfer function:</term>
  807. <listitem>
  808. <para>L = -((L'&nbsp;-&nbsp;0.099)&nbsp;/&nbsp;-1.099)<superscript>1/0.45</superscript>&nbsp;for&nbsp;L'&nbsp;&le;&nbsp;-0.081</para>
  809. <para>L = L'&nbsp;/&nbsp;4.5&nbsp;for&nbsp;-0.081&nbsp;&lt;&nbsp;L'&nbsp;&lt;&nbsp;0.081</para>
  810. <para>L = ((L'&nbsp;+&nbsp;0.099)&nbsp;/&nbsp;1.099)<superscript>1/0.45</superscript>&nbsp;for&nbsp;L'&nbsp;&ge;&nbsp;0.081</para>
  811. </listitem>
  812. </varlistentry>
  813. </variablelist>
  814. <variablelist>
  815. <varlistentry>
  816. <term>The luminance (Y') and color difference (Cb and Cr) are obtained with the following
  817. <constant>V4L2_YCBCR_ENC_709</constant> encoding:</term>
  818. <listitem>
  819. <para>Y'&nbsp;=&nbsp;0.2126R'&nbsp;+&nbsp;0.7152G'&nbsp;+&nbsp;0.0722B'</para>
  820. <para>Cb&nbsp;=&nbsp;-0.1146R'&nbsp;-&nbsp;0.3854G'&nbsp;+&nbsp;0.5B'</para>
  821. <para>Cr&nbsp;=&nbsp;0.5R'&nbsp;-&nbsp;0.4542G'&nbsp;-&nbsp;0.0458B'</para>
  822. </listitem>
  823. </varlistentry>
  824. </variablelist>
  825. <para>Y' is clamped to the range [0&hellip;1] and Cb and Cr are
  826. clamped to the range [-0.5&hellip;0.5].</para>
  827. <para>The default quantization is limited range, but full range is possible although
  828. rarely seen.</para>
  829. <para>The <constant>V4L2_YCBCR_ENC_709</constant> encoding described above is the default
  830. for this colorspace, but it can be overridden with <constant>V4L2_YCBCR_ENC_601</constant>, in which
  831. case the BT.601 Y'CbCr encoding is used.</para>
  832. <para>Two additional extended gamut Y'CbCr encodings are also possible with this colorspace:</para>
  833. <variablelist>
  834. <varlistentry>
  835. <term>The xvYCC 709 encoding (<constant>V4L2_YCBCR_ENC_XV709</constant>, <xref linkend="xvycc" />)
  836. is similar to the Rec. 709 encoding, but it allows for R', G' and B' values that are outside the range
  837. [0&hellip;1]. The resulting Y', Cb and Cr values are scaled and offset:</term>
  838. <listitem>
  839. <para>Y'&nbsp;=&nbsp;(219&nbsp;/&nbsp;256)&nbsp;*&nbsp;(0.2126R'&nbsp;+&nbsp;0.7152G'&nbsp;+&nbsp;0.0722B')&nbsp;+&nbsp;(16&nbsp;/&nbsp;256)</para>
  840. <para>Cb&nbsp;=&nbsp;(224&nbsp;/&nbsp;256)&nbsp;*&nbsp;(-0.1146R'&nbsp;-&nbsp;0.3854G'&nbsp;+&nbsp;0.5B')</para>
  841. <para>Cr&nbsp;=&nbsp;(224&nbsp;/&nbsp;256)&nbsp;*&nbsp;(0.5R'&nbsp;-&nbsp;0.4542G'&nbsp;-&nbsp;0.0458B')</para>
  842. </listitem>
  843. </varlistentry>
  844. </variablelist>
  845. <variablelist>
  846. <varlistentry>
  847. <term>The xvYCC 601 encoding (<constant>V4L2_YCBCR_ENC_XV601</constant>, <xref linkend="xvycc" />) is similar
  848. to the BT.601 encoding, but it allows for R', G' and B' values that are outside the range
  849. [0&hellip;1]. The resulting Y', Cb and Cr values are scaled and offset:</term>
  850. <listitem>
  851. <para>Y'&nbsp;=&nbsp;(219&nbsp;/&nbsp;256)&nbsp;*&nbsp;(0.299R'&nbsp;+&nbsp;0.587G'&nbsp;+&nbsp;0.114B')&nbsp;+&nbsp;(16&nbsp;/&nbsp;256)</para>
  852. <para>Cb&nbsp;=&nbsp;(224&nbsp;/&nbsp;256)&nbsp;*&nbsp;(-0.169R'&nbsp;-&nbsp;0.331G'&nbsp;+&nbsp;0.5B')</para>
  853. <para>Cr&nbsp;=&nbsp;(224&nbsp;/&nbsp;256)&nbsp;*&nbsp;(0.5R'&nbsp;-&nbsp;0.419G'&nbsp;-&nbsp;0.081B')</para>
  854. </listitem>
  855. </varlistentry>
  856. </variablelist>
  857. <para>Y' is clamped to the range [0&hellip;1] and Cb and Cr are clamped
  858. to the range [-0.5&hellip;0.5]. The non-standard xvYCC 709 or xvYCC 601 encodings can be used by
  859. selecting <constant>V4L2_YCBCR_ENC_XV709</constant> or <constant>V4L2_YCBCR_ENC_XV601</constant>.
  860. The xvYCC encodings always use full range quantization.</para>
  861. </section>
  862. <section id="col-srgb">
  863. <title>Colorspace sRGB (<constant>V4L2_COLORSPACE_SRGB</constant>)</title>
  864. <para>The <xref linkend="srgb" /> standard defines the colorspace used by most webcams
  865. and computer graphics. The default transfer function is <constant>V4L2_XFER_FUNC_SRGB</constant>.
  866. The default Y'CbCr encoding is <constant>V4L2_YCBCR_ENC_SYCC</constant>. The default Y'CbCr
  867. quantization is full range. The chromaticities of the primary colors and the white
  868. reference are:</para>
  869. <table frame="none">
  870. <title>sRGB Chromaticities</title>
  871. <tgroup cols="3" align="left">
  872. &cs-str;
  873. <thead>
  874. <row>
  875. <entry>Color</entry>
  876. <entry>x</entry>
  877. <entry>y</entry>
  878. </row>
  879. </thead>
  880. <tbody valign="top">
  881. <row>
  882. <entry>Red</entry>
  883. <entry>0.640</entry>
  884. <entry>0.330</entry>
  885. </row>
  886. <row>
  887. <entry>Green</entry>
  888. <entry>0.300</entry>
  889. <entry>0.600</entry>
  890. </row>
  891. <row>
  892. <entry>Blue</entry>
  893. <entry>0.150</entry>
  894. <entry>0.060</entry>
  895. </row>
  896. <row>
  897. <entry>White Reference (D65)</entry>
  898. <entry>0.3127</entry>
  899. <entry>0.3290</entry>
  900. </row>
  901. </tbody>
  902. </tgroup>
  903. </table>
  904. <para>These chromaticities are identical to the Rec. 709 colorspace.</para>
  905. <variablelist>
  906. <varlistentry>
  907. <term>Transfer function. Note that negative values for L are only used by the Y'CbCr conversion.</term>
  908. <listitem>
  909. <para>L' = -1.055(-L)<superscript>1/2.4</superscript>&nbsp;+&nbsp;0.055&nbsp;for&nbsp;L&nbsp;&lt;&nbsp;-0.0031308</para>
  910. <para>L' = 12.92L&nbsp;for&nbsp;-0.0031308&nbsp;&le;&nbsp;L&nbsp;&le;&nbsp;0.0031308</para>
  911. <para>L' = 1.055L<superscript>1/2.4</superscript>&nbsp;-&nbsp;0.055&nbsp;for&nbsp;0.0031308&nbsp;&lt;&nbsp;L&nbsp;&le;&nbsp;1</para>
  912. </listitem>
  913. </varlistentry>
  914. <varlistentry>
  915. <term>Inverse Transfer function:</term>
  916. <listitem>
  917. <para>L = -((-L'&nbsp;+&nbsp;0.055)&nbsp;/&nbsp;1.055)<superscript>2.4</superscript>&nbsp;for&nbsp;L'&nbsp;&lt;&nbsp;-0.04045</para>
  918. <para>L = L'&nbsp;/&nbsp;12.92&nbsp;for&nbsp;-0.04045&nbsp;&le;&nbsp;L'&nbsp;&le;&nbsp;0.04045</para>
  919. <para>L = ((L'&nbsp;+&nbsp;0.055)&nbsp;/&nbsp;1.055)<superscript>2.4</superscript>&nbsp;for&nbsp;L'&nbsp;&gt;&nbsp;0.04045</para>
  920. </listitem>
  921. </varlistentry>
  922. </variablelist>
  923. <variablelist>
  924. <varlistentry>
  925. <term>The luminance (Y') and color difference (Cb and Cr) are obtained with the following
  926. <constant>V4L2_YCBCR_ENC_SYCC</constant> encoding as defined by <xref linkend="sycc" />:</term>
  927. <listitem>
  928. <para>Y'&nbsp;=&nbsp;0.2990R'&nbsp;+&nbsp;0.5870G'&nbsp;+&nbsp;0.1140B'</para>
  929. <para>Cb&nbsp;=&nbsp;-0.1687R'&nbsp;-&nbsp;0.3313G'&nbsp;+&nbsp;0.5B'</para>
  930. <para>Cr&nbsp;=&nbsp;0.5R'&nbsp;-&nbsp;0.4187G'&nbsp;-&nbsp;0.0813B'</para>
  931. </listitem>
  932. </varlistentry>
  933. </variablelist>
  934. <para>Y' is clamped to the range [0&hellip;1] and Cb and Cr are clamped
  935. to the range [-0.5&hellip;0.5]. The <constant>V4L2_YCBCR_ENC_SYCC</constant> quantization is always
  936. full range. Although this Y'CbCr encoding looks very similar to the <constant>V4L2_YCBCR_ENC_XV601</constant>
  937. encoding, it is not. The <constant>V4L2_YCBCR_ENC_XV601</constant> scales and offsets the Y'CbCr
  938. values before quantization, but this encoding does not do that.</para>
  939. </section>
  940. <section id="col-adobergb">
  941. <title>Colorspace Adobe RGB (<constant>V4L2_COLORSPACE_ADOBERGB</constant>)</title>
  942. <para>The <xref linkend="adobergb" /> standard defines the colorspace used by computer graphics
  943. that use the AdobeRGB colorspace. This is also known as the <xref linkend="oprgb" /> standard.
  944. The default transfer function is <constant>V4L2_XFER_FUNC_ADOBERGB</constant>.
  945. The default Y'CbCr encoding is <constant>V4L2_YCBCR_ENC_601</constant>. The default Y'CbCr
  946. quantization is limited range. The chromaticities of the primary colors and the white reference
  947. are:</para>
  948. <table frame="none">
  949. <title>Adobe RGB Chromaticities</title>
  950. <tgroup cols="3" align="left">
  951. &cs-str;
  952. <thead>
  953. <row>
  954. <entry>Color</entry>
  955. <entry>x</entry>
  956. <entry>y</entry>
  957. </row>
  958. </thead>
  959. <tbody valign="top">
  960. <row>
  961. <entry>Red</entry>
  962. <entry>0.6400</entry>
  963. <entry>0.3300</entry>
  964. </row>
  965. <row>
  966. <entry>Green</entry>
  967. <entry>0.2100</entry>
  968. <entry>0.7100</entry>
  969. </row>
  970. <row>
  971. <entry>Blue</entry>
  972. <entry>0.1500</entry>
  973. <entry>0.0600</entry>
  974. </row>
  975. <row>
  976. <entry>White Reference (D65)</entry>
  977. <entry>0.3127</entry>
  978. <entry>0.3290</entry>
  979. </row>
  980. </tbody>
  981. </tgroup>
  982. </table>
  983. <variablelist>
  984. <varlistentry>
  985. <term>Transfer function:</term>
  986. <listitem>
  987. <para>L' = L<superscript>1/2.19921875</superscript></para>
  988. </listitem>
  989. </varlistentry>
  990. <varlistentry>
  991. <term>Inverse Transfer function:</term>
  992. <listitem>
  993. <para>L = L'<superscript>2.19921875</superscript></para>
  994. </listitem>
  995. </varlistentry>
  996. </variablelist>
  997. <variablelist>
  998. <varlistentry>
  999. <term>The luminance (Y') and color difference (Cb and Cr) are obtained with the
  1000. following <constant>V4L2_YCBCR_ENC_601</constant> encoding:</term>
  1001. <listitem>
  1002. <para>Y'&nbsp;=&nbsp;0.299R'&nbsp;+&nbsp;0.587G'&nbsp;+&nbsp;0.114B'</para>
  1003. <para>Cb&nbsp;=&nbsp;-0.169R'&nbsp;-&nbsp;0.331G'&nbsp;+&nbsp;0.5B'</para>
  1004. <para>Cr&nbsp;=&nbsp;0.5R'&nbsp;-&nbsp;0.419G'&nbsp;-&nbsp;0.081B'</para>
  1005. </listitem>
  1006. </varlistentry>
  1007. </variablelist>
  1008. <para>Y' is clamped to the range [0&hellip;1] and Cb and Cr are
  1009. clamped to the range [-0.5&hellip;0.5]. This transform is identical to one defined in
  1010. SMPTE 170M/BT.601. The Y'CbCr quantization is limited range.</para>
  1011. </section>
  1012. <section id="col-bt2020">
  1013. <title>Colorspace BT.2020 (<constant>V4L2_COLORSPACE_BT2020</constant>)</title>
  1014. <para>The <xref linkend="itu2020" /> standard defines the colorspace used by Ultra-high definition
  1015. television (UHDTV). The default transfer function is <constant>V4L2_XFER_FUNC_709</constant>.
  1016. The default Y'CbCr encoding is <constant>V4L2_YCBCR_ENC_BT2020</constant>.
  1017. The default R'G'B' quantization is limited range (!), and so is the default Y'CbCr quantization.
  1018. The chromaticities of the primary colors and the white reference are:</para>
  1019. <table frame="none">
  1020. <title>BT.2020 Chromaticities</title>
  1021. <tgroup cols="3" align="left">
  1022. &cs-str;
  1023. <thead>
  1024. <row>
  1025. <entry>Color</entry>
  1026. <entry>x</entry>
  1027. <entry>y</entry>
  1028. </row>
  1029. </thead>
  1030. <tbody valign="top">
  1031. <row>
  1032. <entry>Red</entry>
  1033. <entry>0.708</entry>
  1034. <entry>0.292</entry>
  1035. </row>
  1036. <row>
  1037. <entry>Green</entry>
  1038. <entry>0.170</entry>
  1039. <entry>0.797</entry>
  1040. </row>
  1041. <row>
  1042. <entry>Blue</entry>
  1043. <entry>0.131</entry>
  1044. <entry>0.046</entry>
  1045. </row>
  1046. <row>
  1047. <entry>White Reference (D65)</entry>
  1048. <entry>0.3127</entry>
  1049. <entry>0.3290</entry>
  1050. </row>
  1051. </tbody>
  1052. </tgroup>
  1053. </table>
  1054. <variablelist>
  1055. <varlistentry>
  1056. <term>Transfer function (same as Rec. 709):</term>
  1057. <listitem>
  1058. <para>L' = 4.5L&nbsp;for&nbsp;0&nbsp;&le;&nbsp;L&nbsp;&lt;&nbsp;0.018</para>
  1059. <para>L' = 1.099L<superscript>0.45</superscript>&nbsp;-&nbsp;0.099&nbsp;for&nbsp;0.018&nbsp;&le;&nbsp;L&nbsp;&le;&nbsp;1</para>
  1060. </listitem>
  1061. </varlistentry>
  1062. <varlistentry>
  1063. <term>Inverse Transfer function:</term>
  1064. <listitem>
  1065. <para>L = L'&nbsp;/&nbsp;4.5&nbsp;for&nbsp;L'&nbsp;&lt;&nbsp;0.081</para>
  1066. <para>L = ((L'&nbsp;+&nbsp;0.099)&nbsp;/&nbsp;1.099)<superscript>1/0.45</superscript>&nbsp;for&nbsp;L'&nbsp;&ge;&nbsp;0.081</para>
  1067. </listitem>
  1068. </varlistentry>
  1069. </variablelist>
  1070. <variablelist>
  1071. <varlistentry>
  1072. <term>The luminance (Y') and color difference (Cb and Cr) are obtained with the
  1073. following <constant>V4L2_YCBCR_ENC_BT2020</constant> encoding:</term>
  1074. <listitem>
  1075. <para>Y'&nbsp;=&nbsp;0.2627R'&nbsp;+&nbsp;0.6780G'&nbsp;+&nbsp;0.0593B'</para>
  1076. <para>Cb&nbsp;=&nbsp;-0.1396R'&nbsp;-&nbsp;0.3604G'&nbsp;+&nbsp;0.5B'</para>
  1077. <para>Cr&nbsp;=&nbsp;0.5R'&nbsp;-&nbsp;0.4598G'&nbsp;-&nbsp;0.0402B'</para>
  1078. </listitem>
  1079. </varlistentry>
  1080. </variablelist>
  1081. <para>Y' is clamped to the range [0&hellip;1] and Cb and Cr are
  1082. clamped to the range [-0.5&hellip;0.5]. The Y'CbCr quantization is limited range.</para>
  1083. <para>There is also an alternate constant luminance R'G'B' to Yc'CbcCrc
  1084. (<constant>V4L2_YCBCR_ENC_BT2020_CONST_LUM</constant>) encoding:</para>
  1085. <variablelist>
  1086. <varlistentry>
  1087. <term>Luma:</term>
  1088. <listitem>
  1089. <para>Yc'&nbsp;=&nbsp;(0.2627R&nbsp;+&nbsp;0.6780G&nbsp;+&nbsp;0.0593B)'</para>
  1090. </listitem>
  1091. </varlistentry>
  1092. </variablelist>
  1093. <variablelist>
  1094. <varlistentry>
  1095. <term>B'&nbsp;-&nbsp;Yc'&nbsp;&le;&nbsp;0:</term>
  1096. <listitem>
  1097. <para>Cbc&nbsp;=&nbsp;(B'&nbsp;-&nbsp;Yc')&nbsp;/&nbsp;1.9404</para>
  1098. </listitem>
  1099. </varlistentry>
  1100. </variablelist>
  1101. <variablelist>
  1102. <varlistentry>
  1103. <term>B'&nbsp;-&nbsp;Yc'&nbsp;&gt;&nbsp;0:</term>
  1104. <listitem>
  1105. <para>Cbc&nbsp;=&nbsp;(B'&nbsp;-&nbsp;Yc')&nbsp;/&nbsp;1.5816</para>
  1106. </listitem>
  1107. </varlistentry>
  1108. </variablelist>
  1109. <variablelist>
  1110. <varlistentry>
  1111. <term>R'&nbsp;-&nbsp;Yc'&nbsp;&le;&nbsp;0:</term>
  1112. <listitem>
  1113. <para>Crc&nbsp;=&nbsp;(R'&nbsp;-&nbsp;Y')&nbsp;/&nbsp;1.7184</para>
  1114. </listitem>
  1115. </varlistentry>
  1116. </variablelist>
  1117. <variablelist>
  1118. <varlistentry>
  1119. <term>R'&nbsp;-&nbsp;Yc'&nbsp;&gt;&nbsp;0:</term>
  1120. <listitem>
  1121. <para>Crc&nbsp;=&nbsp;(R'&nbsp;-&nbsp;Y')&nbsp;/&nbsp;0.9936</para>
  1122. </listitem>
  1123. </varlistentry>
  1124. </variablelist>
  1125. <para>Yc' is clamped to the range [0&hellip;1] and Cbc and Crc are
  1126. clamped to the range [-0.5&hellip;0.5]. The Yc'CbcCrc quantization is limited range.</para>
  1127. </section>
  1128. <section id="col-dcip3">
  1129. <title>Colorspace DCI-P3 (<constant>V4L2_COLORSPACE_DCI_P3</constant>)</title>
  1130. <para>The <xref linkend="smpte431" /> standard defines the colorspace used by cinema
  1131. projectors that use the DCI-P3 colorspace.
  1132. The default transfer function is <constant>V4L2_XFER_FUNC_DCI_P3</constant>.
  1133. The default Y'CbCr encoding is <constant>V4L2_YCBCR_ENC_709</constant>. Note that this
  1134. colorspace does not specify a Y'CbCr encoding since it is not meant to be encoded
  1135. to Y'CbCr. So this default Y'CbCr encoding was picked because it is the HDTV
  1136. encoding. The default Y'CbCr quantization is limited range. The chromaticities of
  1137. the primary colors and the white reference are:</para>
  1138. <table frame="none">
  1139. <title>DCI-P3 Chromaticities</title>
  1140. <tgroup cols="3" align="left">
  1141. &cs-str;
  1142. <thead>
  1143. <row>
  1144. <entry>Color</entry>
  1145. <entry>x</entry>
  1146. <entry>y</entry>
  1147. </row>
  1148. </thead>
  1149. <tbody valign="top">
  1150. <row>
  1151. <entry>Red</entry>
  1152. <entry>0.6800</entry>
  1153. <entry>0.3200</entry>
  1154. </row>
  1155. <row>
  1156. <entry>Green</entry>
  1157. <entry>0.2650</entry>
  1158. <entry>0.6900</entry>
  1159. </row>
  1160. <row>
  1161. <entry>Blue</entry>
  1162. <entry>0.1500</entry>
  1163. <entry>0.0600</entry>
  1164. </row>
  1165. <row>
  1166. <entry>White Reference</entry>
  1167. <entry>0.3140</entry>
  1168. <entry>0.3510</entry>
  1169. </row>
  1170. </tbody>
  1171. </tgroup>
  1172. </table>
  1173. <variablelist>
  1174. <varlistentry>
  1175. <term>Transfer function:</term>
  1176. <listitem>
  1177. <para>L' = L<superscript>1/2.6</superscript></para>
  1178. </listitem>
  1179. </varlistentry>
  1180. <varlistentry>
  1181. <term>Inverse Transfer function:</term>
  1182. <listitem>
  1183. <para>L = L'<superscript>2.6</superscript></para>
  1184. </listitem>
  1185. </varlistentry>
  1186. </variablelist>
  1187. <para>Y'CbCr encoding is not specified. V4L2 defaults to Rec. 709.</para>
  1188. </section>
  1189. <section id="col-smpte-240m">
  1190. <title>Colorspace SMPTE 240M (<constant>V4L2_COLORSPACE_SMPTE240M</constant>)</title>
  1191. <para>The <xref linkend="smpte240m" /> standard was an interim standard used during
  1192. the early days of HDTV (1988-1998). It has been superseded by Rec. 709.
  1193. The default transfer function is <constant>V4L2_XFER_FUNC_SMPTE240M</constant>.
  1194. The default Y'CbCr encoding is <constant>V4L2_YCBCR_ENC_SMPTE240M</constant>.
  1195. The default Y'CbCr quantization is limited range. The chromaticities of the primary colors and the
  1196. white reference are:</para>
  1197. <table frame="none">
  1198. <title>SMPTE 240M Chromaticities</title>
  1199. <tgroup cols="3" align="left">
  1200. &cs-str;
  1201. <thead>
  1202. <row>
  1203. <entry>Color</entry>
  1204. <entry>x</entry>
  1205. <entry>y</entry>
  1206. </row>
  1207. </thead>
  1208. <tbody valign="top">
  1209. <row>
  1210. <entry>Red</entry>
  1211. <entry>0.630</entry>
  1212. <entry>0.340</entry>
  1213. </row>
  1214. <row>
  1215. <entry>Green</entry>
  1216. <entry>0.310</entry>
  1217. <entry>0.595</entry>
  1218. </row>
  1219. <row>
  1220. <entry>Blue</entry>
  1221. <entry>0.155</entry>
  1222. <entry>0.070</entry>
  1223. </row>
  1224. <row>
  1225. <entry>White Reference (D65)</entry>
  1226. <entry>0.3127</entry>
  1227. <entry>0.3290</entry>
  1228. </row>
  1229. </tbody>
  1230. </tgroup>
  1231. </table>
  1232. <para>These chromaticities are identical to the SMPTE 170M colorspace.</para>
  1233. <variablelist>
  1234. <varlistentry>
  1235. <term>Transfer function:</term>
  1236. <listitem>
  1237. <para>L' = 4L&nbsp;for&nbsp;0&nbsp;&le;&nbsp;L&nbsp;&lt;&nbsp;0.0228</para>
  1238. <para>L' = 1.1115L<superscript>0.45</superscript>&nbsp;-&nbsp;0.1115&nbsp;for&nbsp;0.0228&nbsp;&le;&nbsp;L&nbsp;&le;&nbsp;1</para>
  1239. </listitem>
  1240. </varlistentry>
  1241. <varlistentry>
  1242. <term>Inverse Transfer function:</term>
  1243. <listitem>
  1244. <para>L = L'&nbsp;/&nbsp;4&nbsp;for&nbsp;0&nbsp;&le;&nbsp;L'&nbsp;&lt;&nbsp;0.0913</para>
  1245. <para>L = ((L'&nbsp;+&nbsp;0.1115)&nbsp;/&nbsp;1.1115)<superscript>1/0.45</superscript>&nbsp;for&nbsp;L'&nbsp;&ge;&nbsp;0.0913</para>
  1246. </listitem>
  1247. </varlistentry>
  1248. </variablelist>
  1249. <variablelist>
  1250. <varlistentry>
  1251. <term>The luminance (Y') and color difference (Cb and Cr) are obtained with the
  1252. following <constant>V4L2_YCBCR_ENC_SMPTE240M</constant> encoding:</term>
  1253. <listitem>
  1254. <para>Y'&nbsp;=&nbsp;0.2122R'&nbsp;+&nbsp;0.7013G'&nbsp;+&nbsp;0.0865B'</para>
  1255. <para>Cb&nbsp;=&nbsp;-0.1161R'&nbsp;-&nbsp;0.3839G'&nbsp;+&nbsp;0.5B'</para>
  1256. <para>Cr&nbsp;=&nbsp;0.5R'&nbsp;-&nbsp;0.4451G'&nbsp;-&nbsp;0.0549B'</para>
  1257. </listitem>
  1258. </varlistentry>
  1259. </variablelist>
  1260. <para>Yc' is clamped to the range [0&hellip;1] and Cbc and Crc are
  1261. clamped to the range [-0.5&hellip;0.5]. The Y'CbCr quantization is limited range.</para>
  1262. </section>
  1263. <section id="col-sysm">
  1264. <title>Colorspace NTSC 1953 (<constant>V4L2_COLORSPACE_470_SYSTEM_M</constant>)</title>
  1265. <para>This standard defines the colorspace used by NTSC in 1953. In practice this
  1266. colorspace is obsolete and SMPTE 170M should be used instead.
  1267. The default transfer function is <constant>V4L2_XFER_FUNC_709</constant>.
  1268. The default Y'CbCr encoding is <constant>V4L2_YCBCR_ENC_601</constant>.
  1269. The default Y'CbCr quantization is limited range.
  1270. The chromaticities of the primary colors and the white reference are:</para>
  1271. <table frame="none">
  1272. <title>NTSC 1953 Chromaticities</title>
  1273. <tgroup cols="3" align="left">
  1274. &cs-str;
  1275. <thead>
  1276. <row>
  1277. <entry>Color</entry>
  1278. <entry>x</entry>
  1279. <entry>y</entry>
  1280. </row>
  1281. </thead>
  1282. <tbody valign="top">
  1283. <row>
  1284. <entry>Red</entry>
  1285. <entry>0.67</entry>
  1286. <entry>0.33</entry>
  1287. </row>
  1288. <row>
  1289. <entry>Green</entry>
  1290. <entry>0.21</entry>
  1291. <entry>0.71</entry>
  1292. </row>
  1293. <row>
  1294. <entry>Blue</entry>
  1295. <entry>0.14</entry>
  1296. <entry>0.08</entry>
  1297. </row>
  1298. <row>
  1299. <entry>White Reference (C)</entry>
  1300. <entry>0.310</entry>
  1301. <entry>0.316</entry>
  1302. </row>
  1303. </tbody>
  1304. </tgroup>
  1305. </table>
  1306. <para>Note that this colorspace uses Illuminant C instead of D65 as the
  1307. white reference. To correctly convert an image in this colorspace to another
  1308. that uses D65 you need to apply a chromatic adaptation algorithm such as the
  1309. Bradford method.</para>
  1310. <variablelist>
  1311. <varlistentry>
  1312. <term>The transfer function was never properly defined for NTSC 1953. The
  1313. Rec. 709 transfer function is recommended in the literature:</term>
  1314. <listitem>
  1315. <para>L' = 4.5L&nbsp;for&nbsp;0&nbsp;&le;&nbsp;L&nbsp;&lt;&nbsp;0.018</para>
  1316. <para>L' = 1.099L<superscript>0.45</superscript>&nbsp;-&nbsp;0.099&nbsp;for&nbsp;0.018&nbsp;&le;&nbsp;L&nbsp;&le;&nbsp;1</para>
  1317. </listitem>
  1318. </varlistentry>
  1319. <varlistentry>
  1320. <term>Inverse Transfer function:</term>
  1321. <listitem>
  1322. <para>L = L'&nbsp;/&nbsp;4.5&nbsp;for&nbsp;L'&nbsp;&lt;&nbsp;0.081</para>
  1323. <para>L = ((L'&nbsp;+&nbsp;0.099)&nbsp;/&nbsp;1.099)<superscript>1/0.45</superscript>&nbsp;for&nbsp;L'&nbsp;&ge;&nbsp;0.081</para>
  1324. </listitem>
  1325. </varlistentry>
  1326. </variablelist>
  1327. <variablelist>
  1328. <varlistentry>
  1329. <term>The luminance (Y') and color difference (Cb and Cr) are obtained with the
  1330. following <constant>V4L2_YCBCR_ENC_601</constant> encoding:</term>
  1331. <listitem>
  1332. <para>Y'&nbsp;=&nbsp;0.299R'&nbsp;+&nbsp;0.587G'&nbsp;+&nbsp;0.114B'</para>
  1333. <para>Cb&nbsp;=&nbsp;-0.169R'&nbsp;-&nbsp;0.331G'&nbsp;+&nbsp;0.5B'</para>
  1334. <para>Cr&nbsp;=&nbsp;0.5R'&nbsp;-&nbsp;0.419G'&nbsp;-&nbsp;0.081B'</para>
  1335. </listitem>
  1336. </varlistentry>
  1337. </variablelist>
  1338. <para>Y' is clamped to the range [0&hellip;1] and Cb and Cr are
  1339. clamped to the range [-0.5&hellip;0.5]. The Y'CbCr quantization is limited range.
  1340. This transform is identical to one defined in SMPTE 170M/BT.601.</para>
  1341. </section>
  1342. <section id="col-sysbg">
  1343. <title>Colorspace EBU Tech. 3213 (<constant>V4L2_COLORSPACE_470_SYSTEM_BG</constant>)</title>
  1344. <para>The <xref linkend="tech3213" /> standard defines the colorspace used by PAL/SECAM in 1975. In practice this
  1345. colorspace is obsolete and SMPTE 170M should be used instead.
  1346. The default transfer function is <constant>V4L2_XFER_FUNC_709</constant>.
  1347. The default Y'CbCr encoding is <constant>V4L2_YCBCR_ENC_601</constant>.
  1348. The default Y'CbCr quantization is limited range.
  1349. The chromaticities of the primary colors and the white reference are:</para>
  1350. <table frame="none">
  1351. <title>EBU Tech. 3213 Chromaticities</title>
  1352. <tgroup cols="3" align="left">
  1353. &cs-str;
  1354. <thead>
  1355. <row>
  1356. <entry>Color</entry>
  1357. <entry>x</entry>
  1358. <entry>y</entry>
  1359. </row>
  1360. </thead>
  1361. <tbody valign="top">
  1362. <row>
  1363. <entry>Red</entry>
  1364. <entry>0.64</entry>
  1365. <entry>0.33</entry>
  1366. </row>
  1367. <row>
  1368. <entry>Green</entry>
  1369. <entry>0.29</entry>
  1370. <entry>0.60</entry>
  1371. </row>
  1372. <row>
  1373. <entry>Blue</entry>
  1374. <entry>0.15</entry>
  1375. <entry>0.06</entry>
  1376. </row>
  1377. <row>
  1378. <entry>White Reference (D65)</entry>
  1379. <entry>0.3127</entry>
  1380. <entry>0.3290</entry>
  1381. </row>
  1382. </tbody>
  1383. </tgroup>
  1384. </table>
  1385. <variablelist>
  1386. <varlistentry>
  1387. <term>The transfer function was never properly defined for this colorspace.
  1388. The Rec. 709 transfer function is recommended in the literature:</term>
  1389. <listitem>
  1390. <para>L' = 4.5L&nbsp;for&nbsp;0&nbsp;&le;&nbsp;L&nbsp;&lt;&nbsp;0.018</para>
  1391. <para>L' = 1.099L<superscript>0.45</superscript>&nbsp;-&nbsp;0.099&nbsp;for&nbsp;0.018&nbsp;&le;&nbsp;L&nbsp;&le;&nbsp;1</para>
  1392. </listitem>
  1393. </varlistentry>
  1394. <varlistentry>
  1395. <term>Inverse Transfer function:</term>
  1396. <listitem>
  1397. <para>L = L'&nbsp;/&nbsp;4.5&nbsp;for&nbsp;L'&nbsp;&lt;&nbsp;0.081</para>
  1398. <para>L = ((L'&nbsp;+&nbsp;0.099)&nbsp;/&nbsp;1.099)<superscript>1/0.45</superscript>&nbsp;for&nbsp;L'&nbsp;&ge;&nbsp;0.081</para>
  1399. </listitem>
  1400. </varlistentry>
  1401. </variablelist>
  1402. <variablelist>
  1403. <varlistentry>
  1404. <term>The luminance (Y') and color difference (Cb and Cr) are obtained with the
  1405. following <constant>V4L2_YCBCR_ENC_601</constant> encoding:</term>
  1406. <listitem>
  1407. <para>Y'&nbsp;=&nbsp;0.299R'&nbsp;+&nbsp;0.587G'&nbsp;+&nbsp;0.114B'</para>
  1408. <para>Cb&nbsp;=&nbsp;-0.169R'&nbsp;-&nbsp;0.331G'&nbsp;+&nbsp;0.5B'</para>
  1409. <para>Cr&nbsp;=&nbsp;0.5R'&nbsp;-&nbsp;0.419G'&nbsp;-&nbsp;0.081B'</para>
  1410. </listitem>
  1411. </varlistentry>
  1412. </variablelist>
  1413. <para>Y' is clamped to the range [0&hellip;1] and Cb and Cr are
  1414. clamped to the range [-0.5&hellip;0.5]. The Y'CbCr quantization is limited range.
  1415. This transform is identical to one defined in SMPTE 170M/BT.601.</para>
  1416. </section>
  1417. <section id="col-jpeg">
  1418. <title>Colorspace JPEG (<constant>V4L2_COLORSPACE_JPEG</constant>)</title>
  1419. <para>This colorspace defines the colorspace used by most (Motion-)JPEG formats. The chromaticities
  1420. of the primary colors and the white reference are identical to sRGB. The transfer
  1421. function use is <constant>V4L2_XFER_FUNC_SRGB</constant>. The Y'CbCr encoding is
  1422. <constant>V4L2_YCBCR_ENC_601</constant> with full range quantization where
  1423. Y' is scaled to [0&hellip;255] and Cb/Cr are scaled to [-128&hellip;128] and
  1424. then clipped to [-128&hellip;127].</para>
  1425. <para>Note that the JPEG standard does not actually store colorspace information.
  1426. So if something other than sRGB is used, then the driver will have to set that information
  1427. explicitly. Effectively <constant>V4L2_COLORSPACE_JPEG</constant> can be considered to be
  1428. an abbreviation for <constant>V4L2_COLORSPACE_SRGB</constant>, <constant>V4L2_YCBCR_ENC_601</constant>
  1429. and <constant>V4L2_QUANTIZATION_FULL_RANGE</constant>.</para>
  1430. </section>
  1431. </section>
  1432. <section>
  1433. <title>Detailed Transfer Function Descriptions</title>
  1434. <section id="xf-smpte-2084">
  1435. <title>Transfer Function SMPTE 2084 (<constant>V4L2_XFER_FUNC_SMPTE2084</constant>)</title>
  1436. <para>The <xref linkend="smpte2084" /> standard defines the transfer function used by
  1437. High Dynamic Range content.</para>
  1438. <variablelist>
  1439. <varlistentry>
  1440. <term>Constants:</term>
  1441. <listitem>
  1442. <para>m1 = (2610 / 4096) / 4</para>
  1443. <para>m2 = (2523 / 4096) * 128</para>
  1444. <para>c1 = 3424 / 4096</para>
  1445. <para>c2 = (2413 / 4096) * 32</para>
  1446. <para>c3 = (2392 / 4096) * 32</para>
  1447. </listitem>
  1448. </varlistentry>
  1449. <varlistentry>
  1450. <term>Transfer function:</term>
  1451. <listitem>
  1452. <para>L' = ((c1 + c2 * L<superscript>m1</superscript>) / (1 + c3 * L<superscript>m1</superscript>))<superscript>m2</superscript></para>
  1453. </listitem>
  1454. </varlistentry>
  1455. </variablelist>
  1456. <variablelist>
  1457. <varlistentry>
  1458. <term>Inverse Transfer function:</term>
  1459. <listitem>
  1460. <para>L = (max(L'<superscript>1/m2</superscript> - c1, 0) / (c2 - c3 * L'<superscript>1/m2</superscript>))<superscript>1/m1</superscript></para>
  1461. </listitem>
  1462. </varlistentry>
  1463. </variablelist>
  1464. </section>
  1465. </section>
  1466. <section id="pixfmt-indexed">
  1467. <title>Indexed Format</title>
  1468. <para>In this format each pixel is represented by an 8 bit index
  1469. into a 256 entry ARGB palette. It is intended for <link
  1470. linkend="osd">Video Output Overlays</link> only. There are no ioctls to
  1471. access the palette, this must be done with ioctls of the Linux framebuffer API.</para>
  1472. <table pgwide="0" frame="none">
  1473. <title>Indexed Image Format</title>
  1474. <tgroup cols="37" align="center">
  1475. <colspec colname="id" align="left" />
  1476. <colspec colname="fourcc" />
  1477. <colspec colname="bit" />
  1478. <colspec colnum="4" colname="b07" align="center" />
  1479. <colspec colnum="5" colname="b06" align="center" />
  1480. <colspec colnum="6" colname="b05" align="center" />
  1481. <colspec colnum="7" colname="b04" align="center" />
  1482. <colspec colnum="8" colname="b03" align="center" />
  1483. <colspec colnum="9" colname="b02" align="center" />
  1484. <colspec colnum="10" colname="b01" align="center" />
  1485. <colspec colnum="11" colname="b00" align="center" />
  1486. <spanspec namest="b07" nameend="b00" spanname="b0" />
  1487. <spanspec namest="b17" nameend="b10" spanname="b1" />
  1488. <spanspec namest="b27" nameend="b20" spanname="b2" />
  1489. <spanspec namest="b37" nameend="b30" spanname="b3" />
  1490. <thead>
  1491. <row>
  1492. <entry>Identifier</entry>
  1493. <entry>Code</entry>
  1494. <entry>&nbsp;</entry>
  1495. <entry spanname="b0">Byte&nbsp;0</entry>
  1496. </row>
  1497. <row>
  1498. <entry>&nbsp;</entry>
  1499. <entry>&nbsp;</entry>
  1500. <entry>Bit</entry>
  1501. <entry>7</entry>
  1502. <entry>6</entry>
  1503. <entry>5</entry>
  1504. <entry>4</entry>
  1505. <entry>3</entry>
  1506. <entry>2</entry>
  1507. <entry>1</entry>
  1508. <entry>0</entry>
  1509. </row>
  1510. </thead>
  1511. <tbody valign="top">
  1512. <row id="V4L2-PIX-FMT-PAL8">
  1513. <entry><constant>V4L2_PIX_FMT_PAL8</constant></entry>
  1514. <entry>'PAL8'</entry>
  1515. <entry></entry>
  1516. <entry>i<subscript>7</subscript></entry>
  1517. <entry>i<subscript>6</subscript></entry>
  1518. <entry>i<subscript>5</subscript></entry>
  1519. <entry>i<subscript>4</subscript></entry>
  1520. <entry>i<subscript>3</subscript></entry>
  1521. <entry>i<subscript>2</subscript></entry>
  1522. <entry>i<subscript>1</subscript></entry>
  1523. <entry>i<subscript>0</subscript></entry>
  1524. </row>
  1525. </tbody>
  1526. </tgroup>
  1527. </table>
  1528. </section>
  1529. <section id="pixfmt-rgb">
  1530. <title>RGB Formats</title>
  1531. &sub-packed-rgb;
  1532. &sub-sbggr8;
  1533. &sub-sgbrg8;
  1534. &sub-sgrbg8;
  1535. &sub-srggb8;
  1536. &sub-sbggr16;
  1537. &sub-srggb10;
  1538. &sub-srggb10p;
  1539. &sub-srggb10alaw8;
  1540. &sub-srggb10dpcm8;
  1541. &sub-srggb12;
  1542. </section>
  1543. <section id="yuv-formats">
  1544. <title>YUV Formats</title>
  1545. <para>YUV is the format native to TV broadcast and composite video
  1546. signals. It separates the brightness information (Y) from the color
  1547. information (U and V or Cb and Cr). The color information consists of
  1548. red and blue <emphasis>color difference</emphasis> signals, this way
  1549. the green component can be reconstructed by subtracting from the
  1550. brightness component. See <xref linkend="colorspaces" /> for conversion
  1551. examples. YUV was chosen because early television would only transmit
  1552. brightness information. To add color in a way compatible with existing
  1553. receivers a new signal carrier was added to transmit the color
  1554. difference signals. Secondary in the YUV format the U and V components
  1555. usually have lower resolution than the Y component. This is an analog
  1556. video compression technique taking advantage of a property of the
  1557. human visual system, being more sensitive to brightness
  1558. information.</para>
  1559. &sub-packed-yuv;
  1560. &sub-grey;
  1561. &sub-y10;
  1562. &sub-y12;
  1563. &sub-y10b;
  1564. &sub-y16;
  1565. &sub-y16-be;
  1566. &sub-uv8;
  1567. &sub-yuyv;
  1568. &sub-uyvy;
  1569. &sub-yvyu;
  1570. &sub-vyuy;
  1571. &sub-y41p;
  1572. &sub-yuv420;
  1573. &sub-yuv420m;
  1574. &sub-yvu420m;
  1575. &sub-yuv410;
  1576. &sub-yuv422p;
  1577. &sub-yuv411p;
  1578. &sub-nv12;
  1579. &sub-nv12m;
  1580. &sub-nv12mt;
  1581. &sub-nv16;
  1582. &sub-nv16m;
  1583. &sub-nv24;
  1584. &sub-m420;
  1585. </section>
  1586. <section>
  1587. <title>Compressed Formats</title>
  1588. <table pgwide="1" frame="none" id="compressed-formats">
  1589. <title>Compressed Image Formats</title>
  1590. <tgroup cols="3" align="left">
  1591. &cs-def;
  1592. <thead>
  1593. <row>
  1594. <entry>Identifier</entry>
  1595. <entry>Code</entry>
  1596. <entry>Details</entry>
  1597. </row>
  1598. </thead>
  1599. <tbody valign="top">
  1600. <row id="V4L2-PIX-FMT-JPEG">
  1601. <entry><constant>V4L2_PIX_FMT_JPEG</constant></entry>
  1602. <entry>'JPEG'</entry>
  1603. <entry>TBD. See also &VIDIOC-G-JPEGCOMP;,
  1604. &VIDIOC-S-JPEGCOMP;.</entry>
  1605. </row>
  1606. <row id="V4L2-PIX-FMT-MPEG">
  1607. <entry><constant>V4L2_PIX_FMT_MPEG</constant></entry>
  1608. <entry>'MPEG'</entry>
  1609. <entry>MPEG multiplexed stream. The actual format is determined by
  1610. extended control <constant>V4L2_CID_MPEG_STREAM_TYPE</constant>, see
  1611. <xref linkend="mpeg-control-id" />.</entry>
  1612. </row>
  1613. <row id="V4L2-PIX-FMT-H264">
  1614. <entry><constant>V4L2_PIX_FMT_H264</constant></entry>
  1615. <entry>'H264'</entry>
  1616. <entry>H264 video elementary stream with start codes.</entry>
  1617. </row>
  1618. <row id="V4L2-PIX-FMT-H264-NO-SC">
  1619. <entry><constant>V4L2_PIX_FMT_H264_NO_SC</constant></entry>
  1620. <entry>'AVC1'</entry>
  1621. <entry>H264 video elementary stream without start codes.</entry>
  1622. </row>
  1623. <row id="V4L2-PIX-FMT-H264-MVC">
  1624. <entry><constant>V4L2_PIX_FMT_H264_MVC</constant></entry>
  1625. <entry>'M264'</entry>
  1626. <entry>H264 MVC video elementary stream.</entry>
  1627. </row>
  1628. <row id="V4L2-PIX-FMT-H263">
  1629. <entry><constant>V4L2_PIX_FMT_H263</constant></entry>
  1630. <entry>'H263'</entry>
  1631. <entry>H263 video elementary stream.</entry>
  1632. </row>
  1633. <row id="V4L2-PIX-FMT-MPEG1">
  1634. <entry><constant>V4L2_PIX_FMT_MPEG1</constant></entry>
  1635. <entry>'MPG1'</entry>
  1636. <entry>MPEG1 video elementary stream.</entry>
  1637. </row>
  1638. <row id="V4L2-PIX-FMT-MPEG2">
  1639. <entry><constant>V4L2_PIX_FMT_MPEG2</constant></entry>
  1640. <entry>'MPG2'</entry>
  1641. <entry>MPEG2 video elementary stream.</entry>
  1642. </row>
  1643. <row id="V4L2-PIX-FMT-MPEG4">
  1644. <entry><constant>V4L2_PIX_FMT_MPEG4</constant></entry>
  1645. <entry>'MPG4'</entry>
  1646. <entry>MPEG4 video elementary stream.</entry>
  1647. </row>
  1648. <row id="V4L2-PIX-FMT-XVID">
  1649. <entry><constant>V4L2_PIX_FMT_XVID</constant></entry>
  1650. <entry>'XVID'</entry>
  1651. <entry>Xvid video elementary stream.</entry>
  1652. </row>
  1653. <row id="V4L2-PIX-FMT-VC1-ANNEX-G">
  1654. <entry><constant>V4L2_PIX_FMT_VC1_ANNEX_G</constant></entry>
  1655. <entry>'VC1G'</entry>
  1656. <entry>VC1, SMPTE 421M Annex G compliant stream.</entry>
  1657. </row>
  1658. <row id="V4L2-PIX-FMT-VC1-ANNEX-L">
  1659. <entry><constant>V4L2_PIX_FMT_VC1_ANNEX_L</constant></entry>
  1660. <entry>'VC1L'</entry>
  1661. <entry>VC1, SMPTE 421M Annex L compliant stream.</entry>
  1662. </row>
  1663. <row id="V4L2-PIX-FMT-VP8">
  1664. <entry><constant>V4L2_PIX_FMT_VP8</constant></entry>
  1665. <entry>'VP80'</entry>
  1666. <entry>VP8 video elementary stream.</entry>
  1667. </row>
  1668. </tbody>
  1669. </tgroup>
  1670. </table>
  1671. </section>
  1672. <section id="sdr-formats">
  1673. <title>SDR Formats</title>
  1674. <para>These formats are used for <link linkend="sdr">SDR</link>
  1675. interface only.</para>
  1676. &sub-sdr-cu08;
  1677. &sub-sdr-cu16le;
  1678. &sub-sdr-cs08;
  1679. &sub-sdr-cs14le;
  1680. &sub-sdr-ru12le;
  1681. </section>
  1682. <section id="pixfmt-reserved">
  1683. <title>Reserved Format Identifiers</title>
  1684. <para>These formats are not defined by this specification, they
  1685. are just listed for reference and to avoid naming conflicts. If you
  1686. want to register your own format, send an e-mail to the linux-media mailing
  1687. list &v4l-ml; for inclusion in the <filename>videodev2.h</filename>
  1688. file. If you want to share your format with other developers add a
  1689. link to your documentation and send a copy to the linux-media mailing list
  1690. for inclusion in this section. If you think your format should be listed
  1691. in a standard format section please make a proposal on the linux-media mailing
  1692. list.</para>
  1693. <table pgwide="1" frame="none" id="reserved-formats">
  1694. <title>Reserved Image Formats</title>
  1695. <tgroup cols="3" align="left">
  1696. &cs-def;
  1697. <thead>
  1698. <row>
  1699. <entry>Identifier</entry>
  1700. <entry>Code</entry>
  1701. <entry>Details</entry>
  1702. </row>
  1703. </thead>
  1704. <tbody valign="top">
  1705. <row id="V4L2-PIX-FMT-DV">
  1706. <entry><constant>V4L2_PIX_FMT_DV</constant></entry>
  1707. <entry>'dvsd'</entry>
  1708. <entry>unknown</entry>
  1709. </row>
  1710. <row id="V4L2-PIX-FMT-ET61X251">
  1711. <entry><constant>V4L2_PIX_FMT_ET61X251</constant></entry>
  1712. <entry>'E625'</entry>
  1713. <entry>Compressed format of the ET61X251 driver.</entry>
  1714. </row>
  1715. <row id="V4L2-PIX-FMT-HI240">
  1716. <entry><constant>V4L2_PIX_FMT_HI240</constant></entry>
  1717. <entry>'HI24'</entry>
  1718. <entry><para>8 bit RGB format used by the BTTV driver.</para></entry>
  1719. </row>
  1720. <row id="V4L2-PIX-FMT-HM12">
  1721. <entry><constant>V4L2_PIX_FMT_HM12</constant></entry>
  1722. <entry>'HM12'</entry>
  1723. <entry><para>YUV 4:2:0 format used by the
  1724. IVTV driver, <ulink url="http://www.ivtvdriver.org/">
  1725. http://www.ivtvdriver.org/</ulink></para><para>The format is documented in the
  1726. kernel sources in the file <filename>Documentation/video4linux/cx2341x/README.hm12</filename>
  1727. </para></entry>
  1728. </row>
  1729. <row id="V4L2-PIX-FMT-CPIA1">
  1730. <entry><constant>V4L2_PIX_FMT_CPIA1</constant></entry>
  1731. <entry>'CPIA'</entry>
  1732. <entry>YUV format used by the gspca cpia1 driver.</entry>
  1733. </row>
  1734. <row id="V4L2-PIX-FMT-JPGL">
  1735. <entry><constant>V4L2_PIX_FMT_JPGL</constant></entry>
  1736. <entry>'JPGL'</entry>
  1737. <entry>JPEG-Light format (Pegasus Lossless JPEG)
  1738. used in Divio webcams NW 80x.</entry>
  1739. </row>
  1740. <row id="V4L2-PIX-FMT-SPCA501">
  1741. <entry><constant>V4L2_PIX_FMT_SPCA501</constant></entry>
  1742. <entry>'S501'</entry>
  1743. <entry>YUYV per line used by the gspca driver.</entry>
  1744. </row>
  1745. <row id="V4L2-PIX-FMT-SPCA505">
  1746. <entry><constant>V4L2_PIX_FMT_SPCA505</constant></entry>
  1747. <entry>'S505'</entry>
  1748. <entry>YYUV per line used by the gspca driver.</entry>
  1749. </row>
  1750. <row id="V4L2-PIX-FMT-SPCA508">
  1751. <entry><constant>V4L2_PIX_FMT_SPCA508</constant></entry>
  1752. <entry>'S508'</entry>
  1753. <entry>YUVY per line used by the gspca driver.</entry>
  1754. </row>
  1755. <row id="V4L2-PIX-FMT-SPCA561">
  1756. <entry><constant>V4L2_PIX_FMT_SPCA561</constant></entry>
  1757. <entry>'S561'</entry>
  1758. <entry>Compressed GBRG Bayer format used by the gspca driver.</entry>
  1759. </row>
  1760. <row id="V4L2-PIX-FMT-PAC207">
  1761. <entry><constant>V4L2_PIX_FMT_PAC207</constant></entry>
  1762. <entry>'P207'</entry>
  1763. <entry>Compressed BGGR Bayer format used by the gspca driver.</entry>
  1764. </row>
  1765. <row id="V4L2-PIX-FMT-MR97310A">
  1766. <entry><constant>V4L2_PIX_FMT_MR97310A</constant></entry>
  1767. <entry>'M310'</entry>
  1768. <entry>Compressed BGGR Bayer format used by the gspca driver.</entry>
  1769. </row>
  1770. <row id="V4L2-PIX-FMT-JL2005BCD">
  1771. <entry><constant>V4L2_PIX_FMT_JL2005BCD</constant></entry>
  1772. <entry>'JL20'</entry>
  1773. <entry>JPEG compressed RGGB Bayer format used by the gspca driver.</entry>
  1774. </row>
  1775. <row id="V4L2-PIX-FMT-OV511">
  1776. <entry><constant>V4L2_PIX_FMT_OV511</constant></entry>
  1777. <entry>'O511'</entry>
  1778. <entry>OV511 JPEG format used by the gspca driver.</entry>
  1779. </row>
  1780. <row id="V4L2-PIX-FMT-OV518">
  1781. <entry><constant>V4L2_PIX_FMT_OV518</constant></entry>
  1782. <entry>'O518'</entry>
  1783. <entry>OV518 JPEG format used by the gspca driver.</entry>
  1784. </row>
  1785. <row id="V4L2-PIX-FMT-PJPG">
  1786. <entry><constant>V4L2_PIX_FMT_PJPG</constant></entry>
  1787. <entry>'PJPG'</entry>
  1788. <entry>Pixart 73xx JPEG format used by the gspca driver.</entry>
  1789. </row>
  1790. <row id="V4L2-PIX-FMT-SE401">
  1791. <entry><constant>V4L2_PIX_FMT_SE401</constant></entry>
  1792. <entry>'S401'</entry>
  1793. <entry>Compressed RGB format used by the gspca se401 driver</entry>
  1794. </row>
  1795. <row id="V4L2-PIX-FMT-SQ905C">
  1796. <entry><constant>V4L2_PIX_FMT_SQ905C</constant></entry>
  1797. <entry>'905C'</entry>
  1798. <entry>Compressed RGGB bayer format used by the gspca driver.</entry>
  1799. </row>
  1800. <row id="V4L2-PIX-FMT-MJPEG">
  1801. <entry><constant>V4L2_PIX_FMT_MJPEG</constant></entry>
  1802. <entry>'MJPG'</entry>
  1803. <entry>Compressed format used by the Zoran driver</entry>
  1804. </row>
  1805. <row id="V4L2-PIX-FMT-PWC1">
  1806. <entry><constant>V4L2_PIX_FMT_PWC1</constant></entry>
  1807. <entry>'PWC1'</entry>
  1808. <entry>Compressed format of the PWC driver.</entry>
  1809. </row>
  1810. <row id="V4L2-PIX-FMT-PWC2">
  1811. <entry><constant>V4L2_PIX_FMT_PWC2</constant></entry>
  1812. <entry>'PWC2'</entry>
  1813. <entry>Compressed format of the PWC driver.</entry>
  1814. </row>
  1815. <row id="V4L2-PIX-FMT-SN9C10X">
  1816. <entry><constant>V4L2_PIX_FMT_SN9C10X</constant></entry>
  1817. <entry>'S910'</entry>
  1818. <entry>Compressed format of the SN9C102 driver.</entry>
  1819. </row>
  1820. <row id="V4L2-PIX-FMT-SN9C20X-I420">
  1821. <entry><constant>V4L2_PIX_FMT_SN9C20X_I420</constant></entry>
  1822. <entry>'S920'</entry>
  1823. <entry>YUV 4:2:0 format of the gspca sn9c20x driver.</entry>
  1824. </row>
  1825. <row id="V4L2-PIX-FMT-SN9C2028">
  1826. <entry><constant>V4L2_PIX_FMT_SN9C2028</constant></entry>
  1827. <entry>'SONX'</entry>
  1828. <entry>Compressed GBRG bayer format of the gspca sn9c2028 driver.</entry>
  1829. </row>
  1830. <row id="V4L2-PIX-FMT-STV0680">
  1831. <entry><constant>V4L2_PIX_FMT_STV0680</constant></entry>
  1832. <entry>'S680'</entry>
  1833. <entry>Bayer format of the gspca stv0680 driver.</entry>
  1834. </row>
  1835. <row id="V4L2-PIX-FMT-WNVA">
  1836. <entry><constant>V4L2_PIX_FMT_WNVA</constant></entry>
  1837. <entry>'WNVA'</entry>
  1838. <entry><para>Used by the Winnov Videum driver, <ulink
  1839. url="http://www.thedirks.org/winnov/">
  1840. http://www.thedirks.org/winnov/</ulink></para></entry>
  1841. </row>
  1842. <row id="V4L2-PIX-FMT-TM6000">
  1843. <entry><constant>V4L2_PIX_FMT_TM6000</constant></entry>
  1844. <entry>'TM60'</entry>
  1845. <entry><para>Used by Trident tm6000</para></entry>
  1846. </row>
  1847. <row id="V4L2-PIX-FMT-CIT-YYVYUY">
  1848. <entry><constant>V4L2_PIX_FMT_CIT_YYVYUY</constant></entry>
  1849. <entry>'CITV'</entry>
  1850. <entry><para>Used by xirlink CIT, found at IBM webcams.</para>
  1851. <para>Uses one line of Y then 1 line of VYUY</para>
  1852. </entry>
  1853. </row>
  1854. <row id="V4L2-PIX-FMT-KONICA420">
  1855. <entry><constant>V4L2_PIX_FMT_KONICA420</constant></entry>
  1856. <entry>'KONI'</entry>
  1857. <entry><para>Used by Konica webcams.</para>
  1858. <para>YUV420 planar in blocks of 256 pixels.</para>
  1859. </entry>
  1860. </row>
  1861. <row id="V4L2-PIX-FMT-YYUV">
  1862. <entry><constant>V4L2_PIX_FMT_YYUV</constant></entry>
  1863. <entry>'YYUV'</entry>
  1864. <entry>unknown</entry>
  1865. </row>
  1866. <row id="V4L2-PIX-FMT-Y4">
  1867. <entry><constant>V4L2_PIX_FMT_Y4</constant></entry>
  1868. <entry>'Y04 '</entry>
  1869. <entry>Old 4-bit greyscale format. Only the most significant 4 bits of each byte are used,
  1870. the other bits are set to 0.</entry>
  1871. </row>
  1872. <row id="V4L2-PIX-FMT-Y6">
  1873. <entry><constant>V4L2_PIX_FMT_Y6</constant></entry>
  1874. <entry>'Y06 '</entry>
  1875. <entry>Old 6-bit greyscale format. Only the most significant 6 bits of each byte are used,
  1876. the other bits are set to 0.</entry>
  1877. </row>
  1878. <row id="V4L2-PIX-FMT-S5C-UYVY-JPG">
  1879. <entry><constant>V4L2_PIX_FMT_S5C_UYVY_JPG</constant></entry>
  1880. <entry>'S5CI'</entry>
  1881. <entry>Two-planar format used by Samsung S5C73MX cameras. The
  1882. first plane contains interleaved JPEG and UYVY image data, followed by meta data
  1883. in form of an array of offsets to the UYVY data blocks. The actual pointer array
  1884. follows immediately the interleaved JPEG/UYVY data, the number of entries in
  1885. this array equals the height of the UYVY image. Each entry is a 4-byte unsigned
  1886. integer in big endian order and it's an offset to a single pixel line of the
  1887. UYVY image. The first plane can start either with JPEG or UYVY data chunk. The
  1888. size of a single UYVY block equals the UYVY image's width multiplied by 2. The
  1889. size of a JPEG chunk depends on the image and can vary with each line.
  1890. <para>The second plane, at an offset of 4084 bytes, contains a 4-byte offset to
  1891. the pointer array in the first plane. This offset is followed by a 4-byte value
  1892. indicating size of the pointer array. All numbers in the second plane are also
  1893. in big endian order. Remaining data in the second plane is undefined. The
  1894. information in the second plane allows to easily find location of the pointer
  1895. array, which can be different for each frame. The size of the pointer array is
  1896. constant for given UYVY image height.</para>
  1897. <para>In order to extract UYVY and JPEG frames an application can initially set
  1898. a data pointer to the start of first plane and then add an offset from the first
  1899. entry of the pointers table. Such a pointer indicates start of an UYVY image
  1900. pixel line. Whole UYVY line can be copied to a separate buffer. These steps
  1901. should be repeated for each line, i.e. the number of entries in the pointer
  1902. array. Anything what's in between the UYVY lines is JPEG data and should be
  1903. concatenated to form the JPEG stream. </para>
  1904. </entry>
  1905. </row>
  1906. </tbody>
  1907. </tgroup>
  1908. </table>
  1909. <table frame="none" pgwide="1" id="format-flags">
  1910. <title>Format Flags</title>
  1911. <tgroup cols="3">
  1912. &cs-def;
  1913. <tbody valign="top">
  1914. <row>
  1915. <entry><constant>V4L2_PIX_FMT_FLAG_PREMUL_ALPHA</constant></entry>
  1916. <entry>0x00000001</entry>
  1917. <entry>The color values are premultiplied by the alpha channel
  1918. value. For example, if a light blue pixel with 50% transparency was described by
  1919. RGBA values (128, 192, 255, 128), the same pixel described with premultiplied
  1920. colors would be described by RGBA values (64, 96, 128, 128) </entry>
  1921. </row>
  1922. </tbody>
  1923. </tgroup>
  1924. </table>
  1925. </section>