pixdesc.c 84 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607
  1. /*
  2. * pixel format descriptor
  3. * Copyright (c) 2009 Michael Niedermayer <michaelni@gmx.at>
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include <stdio.h>
  22. #include <string.h>
  23. #include "avassert.h"
  24. #include "avstring.h"
  25. #include "common.h"
  26. #include "pixfmt.h"
  27. #include "pixdesc.h"
  28. #include "internal.h"
  29. #include "intreadwrite.h"
  30. #include "version.h"
  31. void av_read_image_line(uint16_t *dst,
  32. const uint8_t *data[4], const int linesize[4],
  33. const AVPixFmtDescriptor *desc,
  34. int x, int y, int c, int w,
  35. int read_pal_component)
  36. {
  37. AVComponentDescriptor comp = desc->comp[c];
  38. int plane = comp.plane;
  39. int depth = comp.depth;
  40. int mask = (1 << depth) - 1;
  41. int shift = comp.shift;
  42. int step = comp.step;
  43. int flags = desc->flags;
  44. if (flags & AV_PIX_FMT_FLAG_BITSTREAM) {
  45. int skip = x * step + comp.offset;
  46. const uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
  47. int shift = 8 - depth - (skip & 7);
  48. while (w--) {
  49. int val = (*p >> shift) & mask;
  50. if (read_pal_component)
  51. val = data[1][4*val + c];
  52. shift -= step;
  53. p -= shift >> 3;
  54. shift &= 7;
  55. *dst++ = val;
  56. }
  57. } else {
  58. const uint8_t *p = data[plane] + y * linesize[plane] +
  59. x * step + comp.offset;
  60. int is_8bit = shift + depth <= 8;
  61. if (is_8bit)
  62. p += !!(flags & AV_PIX_FMT_FLAG_BE);
  63. while (w--) {
  64. int val = is_8bit ? *p :
  65. flags & AV_PIX_FMT_FLAG_BE ? AV_RB16(p) : AV_RL16(p);
  66. val = (val >> shift) & mask;
  67. if (read_pal_component)
  68. val = data[1][4 * val + c];
  69. p += step;
  70. *dst++ = val;
  71. }
  72. }
  73. }
  74. void av_write_image_line(const uint16_t *src,
  75. uint8_t *data[4], const int linesize[4],
  76. const AVPixFmtDescriptor *desc,
  77. int x, int y, int c, int w)
  78. {
  79. AVComponentDescriptor comp = desc->comp[c];
  80. int plane = comp.plane;
  81. int depth = comp.depth;
  82. int step = comp.step;
  83. int flags = desc->flags;
  84. if (flags & AV_PIX_FMT_FLAG_BITSTREAM) {
  85. int skip = x * step + comp.offset;
  86. uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
  87. int shift = 8 - depth - (skip & 7);
  88. while (w--) {
  89. *p |= *src++ << shift;
  90. shift -= step;
  91. p -= shift >> 3;
  92. shift &= 7;
  93. }
  94. } else {
  95. int shift = comp.shift;
  96. uint8_t *p = data[plane] + y * linesize[plane] +
  97. x * step + comp.offset;
  98. if (shift + depth <= 8) {
  99. p += !!(flags & AV_PIX_FMT_FLAG_BE);
  100. while (w--) {
  101. *p |= (*src++ << shift);
  102. p += step;
  103. }
  104. } else {
  105. while (w--) {
  106. if (flags & AV_PIX_FMT_FLAG_BE) {
  107. uint16_t val = AV_RB16(p) | (*src++ << shift);
  108. AV_WB16(p, val);
  109. } else {
  110. uint16_t val = AV_RL16(p) | (*src++ << shift);
  111. AV_WL16(p, val);
  112. }
  113. p += step;
  114. }
  115. }
  116. }
  117. }
  118. #if FF_API_PLUS1_MINUS1
  119. FF_DISABLE_DEPRECATION_WARNINGS
  120. #endif
  121. static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
  122. [AV_PIX_FMT_YUV420P] = {
  123. .name = "yuv420p",
  124. .nb_components = 3,
  125. .log2_chroma_w = 1,
  126. .log2_chroma_h = 1,
  127. .comp = {
  128. { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */
  129. { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */
  130. { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */
  131. },
  132. .flags = AV_PIX_FMT_FLAG_PLANAR,
  133. },
  134. [AV_PIX_FMT_YUYV422] = {
  135. .name = "yuyv422",
  136. .nb_components = 3,
  137. .log2_chroma_w = 1,
  138. .log2_chroma_h = 0,
  139. .comp = {
  140. { 0, 2, 0, 0, 8, 1, 7, 1 }, /* Y */
  141. { 0, 4, 1, 0, 8, 3, 7, 2 }, /* U */
  142. { 0, 4, 3, 0, 8, 3, 7, 4 }, /* V */
  143. },
  144. },
  145. [AV_PIX_FMT_YVYU422] = {
  146. .name = "yvyu422",
  147. .nb_components = 3,
  148. .log2_chroma_w = 1,
  149. .log2_chroma_h = 0,
  150. .comp = {
  151. { 0, 2, 0, 0, 8, 1, 7, 1 }, /* Y */
  152. { 0, 4, 3, 0, 8, 3, 7, 4 }, /* U */
  153. { 0, 4, 1, 0, 8, 3, 7, 2 }, /* V */
  154. },
  155. },
  156. [AV_PIX_FMT_RGB24] = {
  157. .name = "rgb24",
  158. .nb_components = 3,
  159. .log2_chroma_w = 0,
  160. .log2_chroma_h = 0,
  161. .comp = {
  162. { 0, 3, 0, 0, 8, 2, 7, 1 }, /* R */
  163. { 0, 3, 1, 0, 8, 2, 7, 2 }, /* G */
  164. { 0, 3, 2, 0, 8, 2, 7, 3 }, /* B */
  165. },
  166. .flags = AV_PIX_FMT_FLAG_RGB,
  167. },
  168. [AV_PIX_FMT_BGR24] = {
  169. .name = "bgr24",
  170. .nb_components = 3,
  171. .log2_chroma_w = 0,
  172. .log2_chroma_h = 0,
  173. .comp = {
  174. { 0, 3, 2, 0, 8, 2, 7, 3 }, /* R */
  175. { 0, 3, 1, 0, 8, 2, 7, 2 }, /* G */
  176. { 0, 3, 0, 0, 8, 2, 7, 1 }, /* B */
  177. },
  178. .flags = AV_PIX_FMT_FLAG_RGB,
  179. },
  180. [AV_PIX_FMT_YUV422P] = {
  181. .name = "yuv422p",
  182. .nb_components = 3,
  183. .log2_chroma_w = 1,
  184. .log2_chroma_h = 0,
  185. .comp = {
  186. { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */
  187. { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */
  188. { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */
  189. },
  190. .flags = AV_PIX_FMT_FLAG_PLANAR,
  191. },
  192. [AV_PIX_FMT_YUV444P] = {
  193. .name = "yuv444p",
  194. .nb_components = 3,
  195. .log2_chroma_w = 0,
  196. .log2_chroma_h = 0,
  197. .comp = {
  198. { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */
  199. { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */
  200. { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */
  201. },
  202. .flags = AV_PIX_FMT_FLAG_PLANAR,
  203. },
  204. [AV_PIX_FMT_YUV410P] = {
  205. .name = "yuv410p",
  206. .nb_components = 3,
  207. .log2_chroma_w = 2,
  208. .log2_chroma_h = 2,
  209. .comp = {
  210. { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */
  211. { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */
  212. { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */
  213. },
  214. .flags = AV_PIX_FMT_FLAG_PLANAR,
  215. },
  216. [AV_PIX_FMT_YUV411P] = {
  217. .name = "yuv411p",
  218. .nb_components = 3,
  219. .log2_chroma_w = 2,
  220. .log2_chroma_h = 0,
  221. .comp = {
  222. { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */
  223. { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */
  224. { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */
  225. },
  226. .flags = AV_PIX_FMT_FLAG_PLANAR,
  227. },
  228. [AV_PIX_FMT_YUVJ411P] = {
  229. .name = "yuvj411p",
  230. .nb_components = 3,
  231. .log2_chroma_w = 2,
  232. .log2_chroma_h = 0,
  233. .comp = {
  234. { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */
  235. { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */
  236. { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */
  237. },
  238. .flags = AV_PIX_FMT_FLAG_PLANAR,
  239. },
  240. [AV_PIX_FMT_GRAY8] = {
  241. .name = "gray",
  242. .nb_components = 1,
  243. .log2_chroma_w = 0,
  244. .log2_chroma_h = 0,
  245. .comp = {
  246. { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */
  247. },
  248. .flags = AV_PIX_FMT_FLAG_PSEUDOPAL,
  249. .alias = "gray8,y8",
  250. },
  251. [AV_PIX_FMT_MONOWHITE] = {
  252. .name = "monow",
  253. .nb_components = 1,
  254. .log2_chroma_w = 0,
  255. .log2_chroma_h = 0,
  256. .comp = {
  257. { 0, 1, 0, 0, 1, 0, 0, 1 }, /* Y */
  258. },
  259. .flags = AV_PIX_FMT_FLAG_BITSTREAM,
  260. },
  261. [AV_PIX_FMT_MONOBLACK] = {
  262. .name = "monob",
  263. .nb_components = 1,
  264. .log2_chroma_w = 0,
  265. .log2_chroma_h = 0,
  266. .comp = {
  267. { 0, 1, 0, 7, 1, 0, 0, 1 }, /* Y */
  268. },
  269. .flags = AV_PIX_FMT_FLAG_BITSTREAM,
  270. },
  271. [AV_PIX_FMT_PAL8] = {
  272. .name = "pal8",
  273. .nb_components = 1,
  274. .log2_chroma_w = 0,
  275. .log2_chroma_h = 0,
  276. .comp = {
  277. { 0, 1, 0, 0, 8, 0, 7, 1 },
  278. },
  279. .flags = AV_PIX_FMT_FLAG_PAL,
  280. },
  281. [AV_PIX_FMT_YUVJ420P] = {
  282. .name = "yuvj420p",
  283. .nb_components = 3,
  284. .log2_chroma_w = 1,
  285. .log2_chroma_h = 1,
  286. .comp = {
  287. { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */
  288. { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */
  289. { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */
  290. },
  291. .flags = AV_PIX_FMT_FLAG_PLANAR,
  292. },
  293. [AV_PIX_FMT_YUVJ422P] = {
  294. .name = "yuvj422p",
  295. .nb_components = 3,
  296. .log2_chroma_w = 1,
  297. .log2_chroma_h = 0,
  298. .comp = {
  299. { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */
  300. { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */
  301. { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */
  302. },
  303. .flags = AV_PIX_FMT_FLAG_PLANAR,
  304. },
  305. [AV_PIX_FMT_YUVJ444P] = {
  306. .name = "yuvj444p",
  307. .nb_components = 3,
  308. .log2_chroma_w = 0,
  309. .log2_chroma_h = 0,
  310. .comp = {
  311. { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */
  312. { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */
  313. { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */
  314. },
  315. .flags = AV_PIX_FMT_FLAG_PLANAR,
  316. },
  317. #if FF_API_XVMC
  318. [AV_PIX_FMT_XVMC_MPEG2_MC] = {
  319. .name = "xvmcmc",
  320. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  321. },
  322. [AV_PIX_FMT_XVMC_MPEG2_IDCT] = {
  323. .name = "xvmcidct",
  324. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  325. },
  326. #endif /* FF_API_XVMC */
  327. #if !FF_API_XVMC
  328. [AV_PIX_FMT_XVMC] = {
  329. .name = "xvmc",
  330. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  331. },
  332. #endif /* !FF_API_XVMC */
  333. [AV_PIX_FMT_UYVY422] = {
  334. .name = "uyvy422",
  335. .nb_components = 3,
  336. .log2_chroma_w = 1,
  337. .log2_chroma_h = 0,
  338. .comp = {
  339. { 0, 2, 1, 0, 8, 1, 7, 2 }, /* Y */
  340. { 0, 4, 0, 0, 8, 3, 7, 1 }, /* U */
  341. { 0, 4, 2, 0, 8, 3, 7, 3 }, /* V */
  342. },
  343. },
  344. [AV_PIX_FMT_UYYVYY411] = {
  345. .name = "uyyvyy411",
  346. .nb_components = 3,
  347. .log2_chroma_w = 2,
  348. .log2_chroma_h = 0,
  349. .comp = {
  350. { 0, 4, 1, 0, 8, 3, 7, 2 }, /* Y */
  351. { 0, 6, 0, 0, 8, 5, 7, 1 }, /* U */
  352. { 0, 6, 3, 0, 8, 5, 7, 4 }, /* V */
  353. },
  354. },
  355. [AV_PIX_FMT_BGR8] = {
  356. .name = "bgr8",
  357. .nb_components = 3,
  358. .log2_chroma_w = 0,
  359. .log2_chroma_h = 0,
  360. .comp = {
  361. { 0, 1, 0, 0, 3, 0, 2, 1 }, /* R */
  362. { 0, 1, 0, 3, 3, 0, 2, 1 }, /* G */
  363. { 0, 1, 0, 6, 2, 0, 1, 1 }, /* B */
  364. },
  365. .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_PSEUDOPAL,
  366. },
  367. [AV_PIX_FMT_BGR4] = {
  368. .name = "bgr4",
  369. .nb_components = 3,
  370. .log2_chroma_w = 0,
  371. .log2_chroma_h = 0,
  372. .comp = {
  373. { 0, 4, 3, 0, 1, 3, 0, 4 }, /* R */
  374. { 0, 4, 1, 0, 2, 3, 1, 2 }, /* G */
  375. { 0, 4, 0, 0, 1, 3, 0, 1 }, /* B */
  376. },
  377. .flags = AV_PIX_FMT_FLAG_BITSTREAM | AV_PIX_FMT_FLAG_RGB,
  378. },
  379. [AV_PIX_FMT_BGR4_BYTE] = {
  380. .name = "bgr4_byte",
  381. .nb_components = 3,
  382. .log2_chroma_w = 0,
  383. .log2_chroma_h = 0,
  384. .comp = {
  385. { 0, 1, 0, 0, 1, 0, 0, 1 }, /* R */
  386. { 0, 1, 0, 1, 2, 0, 1, 1 }, /* G */
  387. { 0, 1, 0, 3, 1, 0, 0, 1 }, /* B */
  388. },
  389. .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_PSEUDOPAL,
  390. },
  391. [AV_PIX_FMT_RGB8] = {
  392. .name = "rgb8",
  393. .nb_components = 3,
  394. .log2_chroma_w = 0,
  395. .log2_chroma_h = 0,
  396. .comp = {
  397. { 0, 1, 0, 6, 2, 0, 1, 1 }, /* R */
  398. { 0, 1, 0, 3, 3, 0, 2, 1 }, /* G */
  399. { 0, 1, 0, 0, 3, 0, 2, 1 }, /* B */
  400. },
  401. .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_PSEUDOPAL,
  402. },
  403. [AV_PIX_FMT_RGB4] = {
  404. .name = "rgb4",
  405. .nb_components = 3,
  406. .log2_chroma_w = 0,
  407. .log2_chroma_h = 0,
  408. .comp = {
  409. { 0, 4, 0, 0, 1, 3, 0, 1 }, /* R */
  410. { 0, 4, 1, 0, 2, 3, 1, 2 }, /* G */
  411. { 0, 4, 3, 0, 1, 3, 0, 4 }, /* B */
  412. },
  413. .flags = AV_PIX_FMT_FLAG_BITSTREAM | AV_PIX_FMT_FLAG_RGB,
  414. },
  415. [AV_PIX_FMT_RGB4_BYTE] = {
  416. .name = "rgb4_byte",
  417. .nb_components = 3,
  418. .log2_chroma_w = 0,
  419. .log2_chroma_h = 0,
  420. .comp = {
  421. { 0, 1, 0, 3, 1, 0, 0, 1 }, /* R */
  422. { 0, 1, 0, 1, 2, 0, 1, 1 }, /* G */
  423. { 0, 1, 0, 0, 1, 0, 0, 1 }, /* B */
  424. },
  425. .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_PSEUDOPAL,
  426. },
  427. [AV_PIX_FMT_NV12] = {
  428. .name = "nv12",
  429. .nb_components = 3,
  430. .log2_chroma_w = 1,
  431. .log2_chroma_h = 1,
  432. .comp = {
  433. { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */
  434. { 1, 2, 0, 0, 8, 1, 7, 1 }, /* U */
  435. { 1, 2, 1, 0, 8, 1, 7, 2 }, /* V */
  436. },
  437. .flags = AV_PIX_FMT_FLAG_PLANAR,
  438. },
  439. [AV_PIX_FMT_NV21] = {
  440. .name = "nv21",
  441. .nb_components = 3,
  442. .log2_chroma_w = 1,
  443. .log2_chroma_h = 1,
  444. .comp = {
  445. { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */
  446. { 1, 2, 1, 0, 8, 1, 7, 2 }, /* U */
  447. { 1, 2, 0, 0, 8, 1, 7, 1 }, /* V */
  448. },
  449. .flags = AV_PIX_FMT_FLAG_PLANAR,
  450. },
  451. [AV_PIX_FMT_ARGB] = {
  452. .name = "argb",
  453. .nb_components = 4,
  454. .log2_chroma_w = 0,
  455. .log2_chroma_h = 0,
  456. .comp = {
  457. { 0, 4, 1, 0, 8, 3, 7, 2 }, /* R */
  458. { 0, 4, 2, 0, 8, 3, 7, 3 }, /* G */
  459. { 0, 4, 3, 0, 8, 3, 7, 4 }, /* B */
  460. { 0, 4, 0, 0, 8, 3, 7, 1 }, /* A */
  461. },
  462. .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
  463. },
  464. [AV_PIX_FMT_RGBA] = {
  465. .name = "rgba",
  466. .nb_components = 4,
  467. .log2_chroma_w = 0,
  468. .log2_chroma_h = 0,
  469. .comp = {
  470. { 0, 4, 0, 0, 8, 3, 7, 1 }, /* R */
  471. { 0, 4, 1, 0, 8, 3, 7, 2 }, /* G */
  472. { 0, 4, 2, 0, 8, 3, 7, 3 }, /* B */
  473. { 0, 4, 3, 0, 8, 3, 7, 4 }, /* A */
  474. },
  475. .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
  476. },
  477. [AV_PIX_FMT_ABGR] = {
  478. .name = "abgr",
  479. .nb_components = 4,
  480. .log2_chroma_w = 0,
  481. .log2_chroma_h = 0,
  482. .comp = {
  483. { 0, 4, 3, 0, 8, 3, 7, 4 }, /* R */
  484. { 0, 4, 2, 0, 8, 3, 7, 3 }, /* G */
  485. { 0, 4, 1, 0, 8, 3, 7, 2 }, /* B */
  486. { 0, 4, 0, 0, 8, 3, 7, 1 }, /* A */
  487. },
  488. .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
  489. },
  490. [AV_PIX_FMT_BGRA] = {
  491. .name = "bgra",
  492. .nb_components = 4,
  493. .log2_chroma_w = 0,
  494. .log2_chroma_h = 0,
  495. .comp = {
  496. { 0, 4, 2, 0, 8, 3, 7, 3 }, /* R */
  497. { 0, 4, 1, 0, 8, 3, 7, 2 }, /* G */
  498. { 0, 4, 0, 0, 8, 3, 7, 1 }, /* B */
  499. { 0, 4, 3, 0, 8, 3, 7, 4 }, /* A */
  500. },
  501. .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
  502. },
  503. [AV_PIX_FMT_0RGB] = {
  504. .name = "0rgb",
  505. .nb_components= 3,
  506. .log2_chroma_w= 0,
  507. .log2_chroma_h= 0,
  508. .comp = {
  509. { 0, 4, 1, 0, 8, 3, 7, 2 }, /* R */
  510. { 0, 4, 2, 0, 8, 3, 7, 3 }, /* G */
  511. { 0, 4, 3, 0, 8, 3, 7, 4 }, /* B */
  512. },
  513. .flags = AV_PIX_FMT_FLAG_RGB,
  514. },
  515. [AV_PIX_FMT_RGB0] = {
  516. .name = "rgb0",
  517. .nb_components= 3,
  518. .log2_chroma_w= 0,
  519. .log2_chroma_h= 0,
  520. .comp = {
  521. { 0, 4, 0, 0, 8, 3, 7, 1 }, /* R */
  522. { 0, 4, 1, 0, 8, 3, 7, 2 }, /* G */
  523. { 0, 4, 2, 0, 8, 3, 7, 3 }, /* B */
  524. },
  525. .flags = AV_PIX_FMT_FLAG_RGB,
  526. },
  527. [AV_PIX_FMT_0BGR] = {
  528. .name = "0bgr",
  529. .nb_components= 3,
  530. .log2_chroma_w= 0,
  531. .log2_chroma_h= 0,
  532. .comp = {
  533. { 0, 4, 3, 0, 8, 3, 7, 4 }, /* R */
  534. { 0, 4, 2, 0, 8, 3, 7, 3 }, /* G */
  535. { 0, 4, 1, 0, 8, 3, 7, 2 }, /* B */
  536. },
  537. .flags = AV_PIX_FMT_FLAG_RGB,
  538. },
  539. [AV_PIX_FMT_BGR0] = {
  540. .name = "bgr0",
  541. .nb_components= 3,
  542. .log2_chroma_w= 0,
  543. .log2_chroma_h= 0,
  544. .comp = {
  545. { 0, 4, 2, 0, 8, 3, 7, 3 }, /* R */
  546. { 0, 4, 1, 0, 8, 3, 7, 2 }, /* G */
  547. { 0, 4, 0, 0, 8, 3, 7, 1 }, /* B */
  548. },
  549. .flags = AV_PIX_FMT_FLAG_RGB,
  550. },
  551. [AV_PIX_FMT_GRAY16BE] = {
  552. .name = "gray16be",
  553. .nb_components = 1,
  554. .log2_chroma_w = 0,
  555. .log2_chroma_h = 0,
  556. .comp = {
  557. { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */
  558. },
  559. .flags = AV_PIX_FMT_FLAG_BE,
  560. .alias = "y16be",
  561. },
  562. [AV_PIX_FMT_GRAY16LE] = {
  563. .name = "gray16le",
  564. .nb_components = 1,
  565. .log2_chroma_w = 0,
  566. .log2_chroma_h = 0,
  567. .comp = {
  568. { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */
  569. },
  570. .alias = "y16le",
  571. },
  572. [AV_PIX_FMT_YUV440P] = {
  573. .name = "yuv440p",
  574. .nb_components = 3,
  575. .log2_chroma_w = 0,
  576. .log2_chroma_h = 1,
  577. .comp = {
  578. { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */
  579. { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */
  580. { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */
  581. },
  582. .flags = AV_PIX_FMT_FLAG_PLANAR,
  583. },
  584. [AV_PIX_FMT_YUVJ440P] = {
  585. .name = "yuvj440p",
  586. .nb_components = 3,
  587. .log2_chroma_w = 0,
  588. .log2_chroma_h = 1,
  589. .comp = {
  590. { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */
  591. { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */
  592. { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */
  593. },
  594. .flags = AV_PIX_FMT_FLAG_PLANAR,
  595. },
  596. [AV_PIX_FMT_YUV440P10LE] = {
  597. .name = "yuv440p10le",
  598. .nb_components = 3,
  599. .log2_chroma_w = 0,
  600. .log2_chroma_h = 1,
  601. .comp = {
  602. { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */
  603. { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */
  604. { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */
  605. },
  606. .flags = AV_PIX_FMT_FLAG_PLANAR,
  607. },
  608. [AV_PIX_FMT_YUV440P10BE] = {
  609. .name = "yuv440p10be",
  610. .nb_components = 3,
  611. .log2_chroma_w = 0,
  612. .log2_chroma_h = 1,
  613. .comp = {
  614. { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */
  615. { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */
  616. { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */
  617. },
  618. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
  619. },
  620. [AV_PIX_FMT_YUV440P12LE] = {
  621. .name = "yuv440p12le",
  622. .nb_components = 3,
  623. .log2_chroma_w = 0,
  624. .log2_chroma_h = 1,
  625. .comp = {
  626. { 0, 2, 0, 0, 12, 1, 11, 1 }, /* Y */
  627. { 1, 2, 0, 0, 12, 1, 11, 1 }, /* U */
  628. { 2, 2, 0, 0, 12, 1, 11, 1 }, /* V */
  629. },
  630. .flags = AV_PIX_FMT_FLAG_PLANAR,
  631. },
  632. [AV_PIX_FMT_YUV440P12BE] = {
  633. .name = "yuv440p12be",
  634. .nb_components = 3,
  635. .log2_chroma_w = 0,
  636. .log2_chroma_h = 1,
  637. .comp = {
  638. { 0, 2, 0, 0, 12, 1, 11, 1 }, /* Y */
  639. { 1, 2, 0, 0, 12, 1, 11, 1 }, /* U */
  640. { 2, 2, 0, 0, 12, 1, 11, 1 }, /* V */
  641. },
  642. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
  643. },
  644. [AV_PIX_FMT_YUVA420P] = {
  645. .name = "yuva420p",
  646. .nb_components = 4,
  647. .log2_chroma_w = 1,
  648. .log2_chroma_h = 1,
  649. .comp = {
  650. { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */
  651. { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */
  652. { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */
  653. { 3, 1, 0, 0, 8, 0, 7, 1 }, /* A */
  654. },
  655. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
  656. },
  657. [AV_PIX_FMT_YUVA422P] = {
  658. .name = "yuva422p",
  659. .nb_components = 4,
  660. .log2_chroma_w = 1,
  661. .log2_chroma_h = 0,
  662. .comp = {
  663. { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */
  664. { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */
  665. { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */
  666. { 3, 1, 0, 0, 8, 0, 7, 1 }, /* A */
  667. },
  668. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
  669. },
  670. [AV_PIX_FMT_YUVA444P] = {
  671. .name = "yuva444p",
  672. .nb_components = 4,
  673. .log2_chroma_w = 0,
  674. .log2_chroma_h = 0,
  675. .comp = {
  676. { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */
  677. { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */
  678. { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */
  679. { 3, 1, 0, 0, 8, 0, 7, 1 }, /* A */
  680. },
  681. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
  682. },
  683. [AV_PIX_FMT_YUVA420P9BE] = {
  684. .name = "yuva420p9be",
  685. .nb_components = 4,
  686. .log2_chroma_w = 1,
  687. .log2_chroma_h = 1,
  688. .comp = {
  689. { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */
  690. { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */
  691. { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */
  692. { 3, 2, 0, 0, 9, 1, 8, 1 }, /* A */
  693. },
  694. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
  695. },
  696. [AV_PIX_FMT_YUVA420P9LE] = {
  697. .name = "yuva420p9le",
  698. .nb_components = 4,
  699. .log2_chroma_w = 1,
  700. .log2_chroma_h = 1,
  701. .comp = {
  702. { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */
  703. { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */
  704. { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */
  705. { 3, 2, 0, 0, 9, 1, 8, 1 }, /* A */
  706. },
  707. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
  708. },
  709. [AV_PIX_FMT_YUVA422P9BE] = {
  710. .name = "yuva422p9be",
  711. .nb_components = 4,
  712. .log2_chroma_w = 1,
  713. .log2_chroma_h = 0,
  714. .comp = {
  715. { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */
  716. { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */
  717. { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */
  718. { 3, 2, 0, 0, 9, 1, 8, 1 }, /* A */
  719. },
  720. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
  721. },
  722. [AV_PIX_FMT_YUVA422P9LE] = {
  723. .name = "yuva422p9le",
  724. .nb_components = 4,
  725. .log2_chroma_w = 1,
  726. .log2_chroma_h = 0,
  727. .comp = {
  728. { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */
  729. { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */
  730. { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */
  731. { 3, 2, 0, 0, 9, 1, 8, 1 }, /* A */
  732. },
  733. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
  734. },
  735. [AV_PIX_FMT_YUVA444P9BE] = {
  736. .name = "yuva444p9be",
  737. .nb_components = 4,
  738. .log2_chroma_w = 0,
  739. .log2_chroma_h = 0,
  740. .comp = {
  741. { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */
  742. { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */
  743. { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */
  744. { 3, 2, 0, 0, 9, 1, 8, 1 }, /* A */
  745. },
  746. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
  747. },
  748. [AV_PIX_FMT_YUVA444P9LE] = {
  749. .name = "yuva444p9le",
  750. .nb_components = 4,
  751. .log2_chroma_w = 0,
  752. .log2_chroma_h = 0,
  753. .comp = {
  754. { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */
  755. { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */
  756. { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */
  757. { 3, 2, 0, 0, 9, 1, 8, 1 }, /* A */
  758. },
  759. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
  760. },
  761. [AV_PIX_FMT_YUVA420P10BE] = {
  762. .name = "yuva420p10be",
  763. .nb_components = 4,
  764. .log2_chroma_w = 1,
  765. .log2_chroma_h = 1,
  766. .comp = {
  767. { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */
  768. { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */
  769. { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */
  770. { 3, 2, 0, 0, 10, 1, 9, 1 }, /* A */
  771. },
  772. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
  773. },
  774. [AV_PIX_FMT_YUVA420P10LE] = {
  775. .name = "yuva420p10le",
  776. .nb_components = 4,
  777. .log2_chroma_w = 1,
  778. .log2_chroma_h = 1,
  779. .comp = {
  780. { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */
  781. { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */
  782. { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */
  783. { 3, 2, 0, 0, 10, 1, 9, 1 }, /* A */
  784. },
  785. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
  786. },
  787. [AV_PIX_FMT_YUVA422P10BE] = {
  788. .name = "yuva422p10be",
  789. .nb_components = 4,
  790. .log2_chroma_w = 1,
  791. .log2_chroma_h = 0,
  792. .comp = {
  793. { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */
  794. { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */
  795. { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */
  796. { 3, 2, 0, 0, 10, 1, 9, 1 }, /* A */
  797. },
  798. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
  799. },
  800. [AV_PIX_FMT_YUVA422P10LE] = {
  801. .name = "yuva422p10le",
  802. .nb_components = 4,
  803. .log2_chroma_w = 1,
  804. .log2_chroma_h = 0,
  805. .comp = {
  806. { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */
  807. { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */
  808. { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */
  809. { 3, 2, 0, 0, 10, 1, 9, 1 }, /* A */
  810. },
  811. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
  812. },
  813. [AV_PIX_FMT_YUVA444P10BE] = {
  814. .name = "yuva444p10be",
  815. .nb_components = 4,
  816. .log2_chroma_w = 0,
  817. .log2_chroma_h = 0,
  818. .comp = {
  819. { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */
  820. { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */
  821. { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */
  822. { 3, 2, 0, 0, 10, 1, 9, 1 }, /* A */
  823. },
  824. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
  825. },
  826. [AV_PIX_FMT_YUVA444P10LE] = {
  827. .name = "yuva444p10le",
  828. .nb_components = 4,
  829. .log2_chroma_w = 0,
  830. .log2_chroma_h = 0,
  831. .comp = {
  832. { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */
  833. { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */
  834. { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */
  835. { 3, 2, 0, 0, 10, 1, 9, 1 }, /* A */
  836. },
  837. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
  838. },
  839. [AV_PIX_FMT_YUVA420P16BE] = {
  840. .name = "yuva420p16be",
  841. .nb_components = 4,
  842. .log2_chroma_w = 1,
  843. .log2_chroma_h = 1,
  844. .comp = {
  845. { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */
  846. { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */
  847. { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */
  848. { 3, 2, 0, 0, 16, 1, 15, 1 }, /* A */
  849. },
  850. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
  851. },
  852. [AV_PIX_FMT_YUVA420P16LE] = {
  853. .name = "yuva420p16le",
  854. .nb_components = 4,
  855. .log2_chroma_w = 1,
  856. .log2_chroma_h = 1,
  857. .comp = {
  858. { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */
  859. { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */
  860. { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */
  861. { 3, 2, 0, 0, 16, 1, 15, 1 }, /* A */
  862. },
  863. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
  864. },
  865. [AV_PIX_FMT_YUVA422P16BE] = {
  866. .name = "yuva422p16be",
  867. .nb_components = 4,
  868. .log2_chroma_w = 1,
  869. .log2_chroma_h = 0,
  870. .comp = {
  871. { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */
  872. { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */
  873. { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */
  874. { 3, 2, 0, 0, 16, 1, 15, 1 }, /* A */
  875. },
  876. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
  877. },
  878. [AV_PIX_FMT_YUVA422P16LE] = {
  879. .name = "yuva422p16le",
  880. .nb_components = 4,
  881. .log2_chroma_w = 1,
  882. .log2_chroma_h = 0,
  883. .comp = {
  884. { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */
  885. { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */
  886. { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */
  887. { 3, 2, 0, 0, 16, 1, 15, 1 }, /* A */
  888. },
  889. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
  890. },
  891. [AV_PIX_FMT_YUVA444P16BE] = {
  892. .name = "yuva444p16be",
  893. .nb_components = 4,
  894. .log2_chroma_w = 0,
  895. .log2_chroma_h = 0,
  896. .comp = {
  897. { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */
  898. { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */
  899. { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */
  900. { 3, 2, 0, 0, 16, 1, 15, 1 }, /* A */
  901. },
  902. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
  903. },
  904. [AV_PIX_FMT_YUVA444P16LE] = {
  905. .name = "yuva444p16le",
  906. .nb_components = 4,
  907. .log2_chroma_w = 0,
  908. .log2_chroma_h = 0,
  909. .comp = {
  910. { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */
  911. { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */
  912. { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */
  913. { 3, 2, 0, 0, 16, 1, 15, 1 }, /* A */
  914. },
  915. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
  916. },
  917. #if FF_API_VDPAU
  918. [AV_PIX_FMT_VDPAU_H264] = {
  919. .name = "vdpau_h264",
  920. .log2_chroma_w = 1,
  921. .log2_chroma_h = 1,
  922. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  923. },
  924. [AV_PIX_FMT_VDPAU_MPEG1] = {
  925. .name = "vdpau_mpeg1",
  926. .log2_chroma_w = 1,
  927. .log2_chroma_h = 1,
  928. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  929. },
  930. [AV_PIX_FMT_VDPAU_MPEG2] = {
  931. .name = "vdpau_mpeg2",
  932. .log2_chroma_w = 1,
  933. .log2_chroma_h = 1,
  934. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  935. },
  936. [AV_PIX_FMT_VDPAU_WMV3] = {
  937. .name = "vdpau_wmv3",
  938. .log2_chroma_w = 1,
  939. .log2_chroma_h = 1,
  940. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  941. },
  942. [AV_PIX_FMT_VDPAU_VC1] = {
  943. .name = "vdpau_vc1",
  944. .log2_chroma_w = 1,
  945. .log2_chroma_h = 1,
  946. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  947. },
  948. [AV_PIX_FMT_VDPAU_MPEG4] = {
  949. .name = "vdpau_mpeg4",
  950. .log2_chroma_w = 1,
  951. .log2_chroma_h = 1,
  952. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  953. },
  954. #endif
  955. [AV_PIX_FMT_RGB48BE] = {
  956. .name = "rgb48be",
  957. .nb_components = 3,
  958. .log2_chroma_w = 0,
  959. .log2_chroma_h = 0,
  960. .comp = {
  961. { 0, 6, 0, 0, 16, 5, 15, 1 }, /* R */
  962. { 0, 6, 2, 0, 16, 5, 15, 3 }, /* G */
  963. { 0, 6, 4, 0, 16, 5, 15, 5 }, /* B */
  964. },
  965. .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BE,
  966. },
  967. [AV_PIX_FMT_RGB48LE] = {
  968. .name = "rgb48le",
  969. .nb_components = 3,
  970. .log2_chroma_w = 0,
  971. .log2_chroma_h = 0,
  972. .comp = {
  973. { 0, 6, 0, 0, 16, 5, 15, 1 }, /* R */
  974. { 0, 6, 2, 0, 16, 5, 15, 3 }, /* G */
  975. { 0, 6, 4, 0, 16, 5, 15, 5 }, /* B */
  976. },
  977. .flags = AV_PIX_FMT_FLAG_RGB,
  978. },
  979. [AV_PIX_FMT_RGBA64BE] = {
  980. .name = "rgba64be",
  981. .nb_components = 4,
  982. .log2_chroma_w = 0,
  983. .log2_chroma_h = 0,
  984. .comp = {
  985. { 0, 8, 0, 0, 16, 7, 15, 1 }, /* R */
  986. { 0, 8, 2, 0, 16, 7, 15, 3 }, /* G */
  987. { 0, 8, 4, 0, 16, 7, 15, 5 }, /* B */
  988. { 0, 8, 6, 0, 16, 7, 15, 7 }, /* A */
  989. },
  990. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
  991. },
  992. [AV_PIX_FMT_RGBA64LE] = {
  993. .name = "rgba64le",
  994. .nb_components = 4,
  995. .log2_chroma_w = 0,
  996. .log2_chroma_h = 0,
  997. .comp = {
  998. { 0, 8, 0, 0, 16, 7, 15, 1 }, /* R */
  999. { 0, 8, 2, 0, 16, 7, 15, 3 }, /* G */
  1000. { 0, 8, 4, 0, 16, 7, 15, 5 }, /* B */
  1001. { 0, 8, 6, 0, 16, 7, 15, 7 }, /* A */
  1002. },
  1003. .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
  1004. },
  1005. [AV_PIX_FMT_RGB565BE] = {
  1006. .name = "rgb565be",
  1007. .nb_components = 3,
  1008. .log2_chroma_w = 0,
  1009. .log2_chroma_h = 0,
  1010. .comp = {
  1011. { 0, 2, -1, 3, 5, 1, 4, 0 }, /* R */
  1012. { 0, 2, 0, 5, 6, 1, 5, 1 }, /* G */
  1013. { 0, 2, 0, 0, 5, 1, 4, 1 }, /* B */
  1014. },
  1015. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB,
  1016. },
  1017. [AV_PIX_FMT_RGB565LE] = {
  1018. .name = "rgb565le",
  1019. .nb_components = 3,
  1020. .log2_chroma_w = 0,
  1021. .log2_chroma_h = 0,
  1022. .comp = {
  1023. { 0, 2, 1, 3, 5, 1, 4, 2 }, /* R */
  1024. { 0, 2, 0, 5, 6, 1, 5, 1 }, /* G */
  1025. { 0, 2, 0, 0, 5, 1, 4, 1 }, /* B */
  1026. },
  1027. .flags = AV_PIX_FMT_FLAG_RGB,
  1028. },
  1029. [AV_PIX_FMT_RGB555BE] = {
  1030. .name = "rgb555be",
  1031. .nb_components = 3,
  1032. .log2_chroma_w = 0,
  1033. .log2_chroma_h = 0,
  1034. .comp = {
  1035. { 0, 2, -1, 2, 5, 1, 4, 0 }, /* R */
  1036. { 0, 2, 0, 5, 5, 1, 4, 1 }, /* G */
  1037. { 0, 2, 0, 0, 5, 1, 4, 1 }, /* B */
  1038. },
  1039. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB,
  1040. },
  1041. [AV_PIX_FMT_RGB555LE] = {
  1042. .name = "rgb555le",
  1043. .nb_components = 3,
  1044. .log2_chroma_w = 0,
  1045. .log2_chroma_h = 0,
  1046. .comp = {
  1047. { 0, 2, 1, 2, 5, 1, 4, 2 }, /* R */
  1048. { 0, 2, 0, 5, 5, 1, 4, 1 }, /* G */
  1049. { 0, 2, 0, 0, 5, 1, 4, 1 }, /* B */
  1050. },
  1051. .flags = AV_PIX_FMT_FLAG_RGB,
  1052. },
  1053. [AV_PIX_FMT_RGB444BE] = {
  1054. .name = "rgb444be",
  1055. .nb_components = 3,
  1056. .log2_chroma_w = 0,
  1057. .log2_chroma_h = 0,
  1058. .comp = {
  1059. { 0, 2, -1, 0, 4, 1, 3, 0 }, /* R */
  1060. { 0, 2, 0, 4, 4, 1, 3, 1 }, /* G */
  1061. { 0, 2, 0, 0, 4, 1, 3, 1 }, /* B */
  1062. },
  1063. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB,
  1064. },
  1065. [AV_PIX_FMT_RGB444LE] = {
  1066. .name = "rgb444le",
  1067. .nb_components = 3,
  1068. .log2_chroma_w = 0,
  1069. .log2_chroma_h = 0,
  1070. .comp = {
  1071. { 0, 2, 1, 0, 4, 1, 3, 2 }, /* R */
  1072. { 0, 2, 0, 4, 4, 1, 3, 1 }, /* G */
  1073. { 0, 2, 0, 0, 4, 1, 3, 1 }, /* B */
  1074. },
  1075. .flags = AV_PIX_FMT_FLAG_RGB,
  1076. },
  1077. [AV_PIX_FMT_BGR48BE] = {
  1078. .name = "bgr48be",
  1079. .nb_components = 3,
  1080. .log2_chroma_w = 0,
  1081. .log2_chroma_h = 0,
  1082. .comp = {
  1083. { 0, 6, 4, 0, 16, 5, 15, 5 }, /* R */
  1084. { 0, 6, 2, 0, 16, 5, 15, 3 }, /* G */
  1085. { 0, 6, 0, 0, 16, 5, 15, 1 }, /* B */
  1086. },
  1087. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB,
  1088. },
  1089. [AV_PIX_FMT_BGR48LE] = {
  1090. .name = "bgr48le",
  1091. .nb_components = 3,
  1092. .log2_chroma_w = 0,
  1093. .log2_chroma_h = 0,
  1094. .comp = {
  1095. { 0, 6, 4, 0, 16, 5, 15, 5 }, /* R */
  1096. { 0, 6, 2, 0, 16, 5, 15, 3 }, /* G */
  1097. { 0, 6, 0, 0, 16, 5, 15, 1 }, /* B */
  1098. },
  1099. .flags = AV_PIX_FMT_FLAG_RGB,
  1100. },
  1101. [AV_PIX_FMT_BGRA64BE] = {
  1102. .name = "bgra64be",
  1103. .nb_components = 4,
  1104. .log2_chroma_w = 0,
  1105. .log2_chroma_h = 0,
  1106. .comp = {
  1107. { 0, 8, 4, 0, 16, 7, 15, 5 }, /* R */
  1108. { 0, 8, 2, 0, 16, 7, 15, 3 }, /* G */
  1109. { 0, 8, 0, 0, 16, 7, 15, 1 }, /* B */
  1110. { 0, 8, 6, 0, 16, 7, 15, 7 }, /* A */
  1111. },
  1112. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
  1113. },
  1114. [AV_PIX_FMT_BGRA64LE] = {
  1115. .name = "bgra64le",
  1116. .nb_components = 4,
  1117. .log2_chroma_w = 0,
  1118. .log2_chroma_h = 0,
  1119. .comp = {
  1120. { 0, 8, 4, 0, 16, 7, 15, 5 }, /* R */
  1121. { 0, 8, 2, 0, 16, 7, 15, 3 }, /* G */
  1122. { 0, 8, 0, 0, 16, 7, 15, 1 }, /* B */
  1123. { 0, 8, 6, 0, 16, 7, 15, 7 }, /* A */
  1124. },
  1125. .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
  1126. },
  1127. [AV_PIX_FMT_BGR565BE] = {
  1128. .name = "bgr565be",
  1129. .nb_components = 3,
  1130. .log2_chroma_w = 0,
  1131. .log2_chroma_h = 0,
  1132. .comp = {
  1133. { 0, 2, 0, 0, 5, 1, 4, 1 }, /* R */
  1134. { 0, 2, 0, 5, 6, 1, 5, 1 }, /* G */
  1135. { 0, 2, -1, 3, 5, 1, 4, 0 }, /* B */
  1136. },
  1137. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB,
  1138. },
  1139. [AV_PIX_FMT_BGR565LE] = {
  1140. .name = "bgr565le",
  1141. .nb_components = 3,
  1142. .log2_chroma_w = 0,
  1143. .log2_chroma_h = 0,
  1144. .comp = {
  1145. { 0, 2, 0, 0, 5, 1, 4, 1 }, /* R */
  1146. { 0, 2, 0, 5, 6, 1, 5, 1 }, /* G */
  1147. { 0, 2, 1, 3, 5, 1, 4, 2 }, /* B */
  1148. },
  1149. .flags = AV_PIX_FMT_FLAG_RGB,
  1150. },
  1151. [AV_PIX_FMT_BGR555BE] = {
  1152. .name = "bgr555be",
  1153. .nb_components = 3,
  1154. .log2_chroma_w = 0,
  1155. .log2_chroma_h = 0,
  1156. .comp = {
  1157. { 0, 2, 0, 0, 5, 1, 4, 1 }, /* R */
  1158. { 0, 2, 0, 5, 5, 1, 4, 1 }, /* G */
  1159. { 0, 2, -1, 2, 5, 1, 4, 0 }, /* B */
  1160. },
  1161. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB,
  1162. },
  1163. [AV_PIX_FMT_BGR555LE] = {
  1164. .name = "bgr555le",
  1165. .nb_components = 3,
  1166. .log2_chroma_w = 0,
  1167. .log2_chroma_h = 0,
  1168. .comp = {
  1169. { 0, 2, 0, 0, 5, 1, 4, 1 }, /* R */
  1170. { 0, 2, 0, 5, 5, 1, 4, 1 }, /* G */
  1171. { 0, 2, 1, 2, 5, 1, 4, 2 }, /* B */
  1172. },
  1173. .flags = AV_PIX_FMT_FLAG_RGB,
  1174. },
  1175. [AV_PIX_FMT_BGR444BE] = {
  1176. .name = "bgr444be",
  1177. .nb_components = 3,
  1178. .log2_chroma_w = 0,
  1179. .log2_chroma_h = 0,
  1180. .comp = {
  1181. { 0, 2, 0, 0, 4, 1, 3, 1 }, /* R */
  1182. { 0, 2, 0, 4, 4, 1, 3, 1 }, /* G */
  1183. { 0, 2, -1, 0, 4, 1, 3, 0 }, /* B */
  1184. },
  1185. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB,
  1186. },
  1187. [AV_PIX_FMT_BGR444LE] = {
  1188. .name = "bgr444le",
  1189. .nb_components = 3,
  1190. .log2_chroma_w = 0,
  1191. .log2_chroma_h = 0,
  1192. .comp = {
  1193. { 0, 2, 0, 0, 4, 1, 3, 1 }, /* R */
  1194. { 0, 2, 0, 4, 4, 1, 3, 1 }, /* G */
  1195. { 0, 2, 1, 0, 4, 1, 3, 2 }, /* B */
  1196. },
  1197. .flags = AV_PIX_FMT_FLAG_RGB,
  1198. },
  1199. #if FF_API_VAAPI
  1200. [AV_PIX_FMT_VAAPI_MOCO] = {
  1201. .name = "vaapi_moco",
  1202. .log2_chroma_w = 1,
  1203. .log2_chroma_h = 1,
  1204. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  1205. },
  1206. [AV_PIX_FMT_VAAPI_IDCT] = {
  1207. .name = "vaapi_idct",
  1208. .log2_chroma_w = 1,
  1209. .log2_chroma_h = 1,
  1210. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  1211. },
  1212. [AV_PIX_FMT_VAAPI_VLD] = {
  1213. .name = "vaapi_vld",
  1214. .log2_chroma_w = 1,
  1215. .log2_chroma_h = 1,
  1216. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  1217. },
  1218. #else
  1219. [AV_PIX_FMT_VAAPI] = {
  1220. .name = "vaapi",
  1221. .log2_chroma_w = 1,
  1222. .log2_chroma_h = 1,
  1223. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  1224. },
  1225. #endif
  1226. [AV_PIX_FMT_YUV420P9LE] = {
  1227. .name = "yuv420p9le",
  1228. .nb_components = 3,
  1229. .log2_chroma_w = 1,
  1230. .log2_chroma_h = 1,
  1231. .comp = {
  1232. { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */
  1233. { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */
  1234. { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */
  1235. },
  1236. .flags = AV_PIX_FMT_FLAG_PLANAR,
  1237. },
  1238. [AV_PIX_FMT_YUV420P9BE] = {
  1239. .name = "yuv420p9be",
  1240. .nb_components = 3,
  1241. .log2_chroma_w = 1,
  1242. .log2_chroma_h = 1,
  1243. .comp = {
  1244. { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */
  1245. { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */
  1246. { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */
  1247. },
  1248. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
  1249. },
  1250. [AV_PIX_FMT_YUV420P10LE] = {
  1251. .name = "yuv420p10le",
  1252. .nb_components = 3,
  1253. .log2_chroma_w = 1,
  1254. .log2_chroma_h = 1,
  1255. .comp = {
  1256. { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */
  1257. { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */
  1258. { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */
  1259. },
  1260. .flags = AV_PIX_FMT_FLAG_PLANAR,
  1261. },
  1262. [AV_PIX_FMT_YUV420P10BE] = {
  1263. .name = "yuv420p10be",
  1264. .nb_components = 3,
  1265. .log2_chroma_w = 1,
  1266. .log2_chroma_h = 1,
  1267. .comp = {
  1268. { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */
  1269. { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */
  1270. { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */
  1271. },
  1272. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
  1273. },
  1274. [AV_PIX_FMT_YUV420P12LE] = {
  1275. .name = "yuv420p12le",
  1276. .nb_components = 3,
  1277. .log2_chroma_w = 1,
  1278. .log2_chroma_h = 1,
  1279. .comp = {
  1280. { 0, 2, 0, 0, 12, 1, 11, 1 }, /* Y */
  1281. { 1, 2, 0, 0, 12, 1, 11, 1 }, /* U */
  1282. { 2, 2, 0, 0, 12, 1, 11, 1 }, /* V */
  1283. },
  1284. .flags = AV_PIX_FMT_FLAG_PLANAR,
  1285. },
  1286. [AV_PIX_FMT_YUV420P12BE] = {
  1287. .name = "yuv420p12be",
  1288. .nb_components = 3,
  1289. .log2_chroma_w = 1,
  1290. .log2_chroma_h = 1,
  1291. .comp = {
  1292. { 0, 2, 0, 0, 12, 1, 11, 1 }, /* Y */
  1293. { 1, 2, 0, 0, 12, 1, 11, 1 }, /* U */
  1294. { 2, 2, 0, 0, 12, 1, 11, 1 }, /* V */
  1295. },
  1296. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
  1297. },
  1298. [AV_PIX_FMT_YUV420P14LE] = {
  1299. .name = "yuv420p14le",
  1300. .nb_components = 3,
  1301. .log2_chroma_w = 1,
  1302. .log2_chroma_h = 1,
  1303. .comp = {
  1304. { 0, 2, 0, 0, 14, 1, 13, 1 }, /* Y */
  1305. { 1, 2, 0, 0, 14, 1, 13, 1 }, /* U */
  1306. { 2, 2, 0, 0, 14, 1, 13, 1 }, /* V */
  1307. },
  1308. .flags = AV_PIX_FMT_FLAG_PLANAR,
  1309. },
  1310. [AV_PIX_FMT_YUV420P14BE] = {
  1311. .name = "yuv420p14be",
  1312. .nb_components = 3,
  1313. .log2_chroma_w = 1,
  1314. .log2_chroma_h = 1,
  1315. .comp = {
  1316. { 0, 2, 0, 0, 14, 1, 13, 1 }, /* Y */
  1317. { 1, 2, 0, 0, 14, 1, 13, 1 }, /* U */
  1318. { 2, 2, 0, 0, 14, 1, 13, 1 }, /* V */
  1319. },
  1320. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
  1321. },
  1322. [AV_PIX_FMT_YUV420P16LE] = {
  1323. .name = "yuv420p16le",
  1324. .nb_components = 3,
  1325. .log2_chroma_w = 1,
  1326. .log2_chroma_h = 1,
  1327. .comp = {
  1328. { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */
  1329. { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */
  1330. { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */
  1331. },
  1332. .flags = AV_PIX_FMT_FLAG_PLANAR,
  1333. },
  1334. [AV_PIX_FMT_YUV420P16BE] = {
  1335. .name = "yuv420p16be",
  1336. .nb_components = 3,
  1337. .log2_chroma_w = 1,
  1338. .log2_chroma_h = 1,
  1339. .comp = {
  1340. { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */
  1341. { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */
  1342. { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */
  1343. },
  1344. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
  1345. },
  1346. [AV_PIX_FMT_YUV422P9LE] = {
  1347. .name = "yuv422p9le",
  1348. .nb_components = 3,
  1349. .log2_chroma_w = 1,
  1350. .log2_chroma_h = 0,
  1351. .comp = {
  1352. { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */
  1353. { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */
  1354. { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */
  1355. },
  1356. .flags = AV_PIX_FMT_FLAG_PLANAR,
  1357. },
  1358. [AV_PIX_FMT_YUV422P9BE] = {
  1359. .name = "yuv422p9be",
  1360. .nb_components = 3,
  1361. .log2_chroma_w = 1,
  1362. .log2_chroma_h = 0,
  1363. .comp = {
  1364. { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */
  1365. { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */
  1366. { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */
  1367. },
  1368. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
  1369. },
  1370. [AV_PIX_FMT_YUV422P10LE] = {
  1371. .name = "yuv422p10le",
  1372. .nb_components = 3,
  1373. .log2_chroma_w = 1,
  1374. .log2_chroma_h = 0,
  1375. .comp = {
  1376. { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */
  1377. { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */
  1378. { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */
  1379. },
  1380. .flags = AV_PIX_FMT_FLAG_PLANAR,
  1381. },
  1382. [AV_PIX_FMT_YUV422P10BE] = {
  1383. .name = "yuv422p10be",
  1384. .nb_components = 3,
  1385. .log2_chroma_w = 1,
  1386. .log2_chroma_h = 0,
  1387. .comp = {
  1388. { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */
  1389. { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */
  1390. { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */
  1391. },
  1392. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
  1393. },
  1394. [AV_PIX_FMT_YUV422P12LE] = {
  1395. .name = "yuv422p12le",
  1396. .nb_components = 3,
  1397. .log2_chroma_w = 1,
  1398. .log2_chroma_h = 0,
  1399. .comp = {
  1400. { 0, 2, 0, 0, 12, 1, 11, 1 }, /* Y */
  1401. { 1, 2, 0, 0, 12, 1, 11, 1 }, /* U */
  1402. { 2, 2, 0, 0, 12, 1, 11, 1 }, /* V */
  1403. },
  1404. .flags = AV_PIX_FMT_FLAG_PLANAR,
  1405. },
  1406. [AV_PIX_FMT_YUV422P12BE] = {
  1407. .name = "yuv422p12be",
  1408. .nb_components = 3,
  1409. .log2_chroma_w = 1,
  1410. .log2_chroma_h = 0,
  1411. .comp = {
  1412. { 0, 2, 0, 0, 12, 1, 11, 1 }, /* Y */
  1413. { 1, 2, 0, 0, 12, 1, 11, 1 }, /* U */
  1414. { 2, 2, 0, 0, 12, 1, 11, 1 }, /* V */
  1415. },
  1416. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
  1417. },
  1418. [AV_PIX_FMT_YUV422P14LE] = {
  1419. .name = "yuv422p14le",
  1420. .nb_components = 3,
  1421. .log2_chroma_w = 1,
  1422. .log2_chroma_h = 0,
  1423. .comp = {
  1424. { 0, 2, 0, 0, 14, 1, 13, 1 }, /* Y */
  1425. { 1, 2, 0, 0, 14, 1, 13, 1 }, /* U */
  1426. { 2, 2, 0, 0, 14, 1, 13, 1 }, /* V */
  1427. },
  1428. .flags = AV_PIX_FMT_FLAG_PLANAR,
  1429. },
  1430. [AV_PIX_FMT_YUV422P14BE] = {
  1431. .name = "yuv422p14be",
  1432. .nb_components = 3,
  1433. .log2_chroma_w = 1,
  1434. .log2_chroma_h = 0,
  1435. .comp = {
  1436. { 0, 2, 0, 0, 14, 1, 13, 1 }, /* Y */
  1437. { 1, 2, 0, 0, 14, 1, 13, 1 }, /* U */
  1438. { 2, 2, 0, 0, 14, 1, 13, 1 }, /* V */
  1439. },
  1440. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
  1441. },
  1442. [AV_PIX_FMT_YUV422P16LE] = {
  1443. .name = "yuv422p16le",
  1444. .nb_components = 3,
  1445. .log2_chroma_w = 1,
  1446. .log2_chroma_h = 0,
  1447. .comp = {
  1448. { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */
  1449. { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */
  1450. { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */
  1451. },
  1452. .flags = AV_PIX_FMT_FLAG_PLANAR,
  1453. },
  1454. [AV_PIX_FMT_YUV422P16BE] = {
  1455. .name = "yuv422p16be",
  1456. .nb_components = 3,
  1457. .log2_chroma_w = 1,
  1458. .log2_chroma_h = 0,
  1459. .comp = {
  1460. { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */
  1461. { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */
  1462. { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */
  1463. },
  1464. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
  1465. },
  1466. [AV_PIX_FMT_YUV444P16LE] = {
  1467. .name = "yuv444p16le",
  1468. .nb_components = 3,
  1469. .log2_chroma_w = 0,
  1470. .log2_chroma_h = 0,
  1471. .comp = {
  1472. { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */
  1473. { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */
  1474. { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */
  1475. },
  1476. .flags = AV_PIX_FMT_FLAG_PLANAR,
  1477. },
  1478. [AV_PIX_FMT_YUV444P16BE] = {
  1479. .name = "yuv444p16be",
  1480. .nb_components = 3,
  1481. .log2_chroma_w = 0,
  1482. .log2_chroma_h = 0,
  1483. .comp = {
  1484. { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */
  1485. { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */
  1486. { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */
  1487. },
  1488. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
  1489. },
  1490. [AV_PIX_FMT_YUV444P10LE] = {
  1491. .name = "yuv444p10le",
  1492. .nb_components = 3,
  1493. .log2_chroma_w = 0,
  1494. .log2_chroma_h = 0,
  1495. .comp = {
  1496. { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */
  1497. { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */
  1498. { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */
  1499. },
  1500. .flags = AV_PIX_FMT_FLAG_PLANAR,
  1501. },
  1502. [AV_PIX_FMT_YUV444P10BE] = {
  1503. .name = "yuv444p10be",
  1504. .nb_components = 3,
  1505. .log2_chroma_w = 0,
  1506. .log2_chroma_h = 0,
  1507. .comp = {
  1508. { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */
  1509. { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */
  1510. { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */
  1511. },
  1512. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
  1513. },
  1514. [AV_PIX_FMT_YUV444P9LE] = {
  1515. .name = "yuv444p9le",
  1516. .nb_components = 3,
  1517. .log2_chroma_w = 0,
  1518. .log2_chroma_h = 0,
  1519. .comp = {
  1520. { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */
  1521. { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */
  1522. { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */
  1523. },
  1524. .flags = AV_PIX_FMT_FLAG_PLANAR,
  1525. },
  1526. [AV_PIX_FMT_YUV444P9BE] = {
  1527. .name = "yuv444p9be",
  1528. .nb_components = 3,
  1529. .log2_chroma_w = 0,
  1530. .log2_chroma_h = 0,
  1531. .comp = {
  1532. { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */
  1533. { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */
  1534. { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */
  1535. },
  1536. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
  1537. },
  1538. [AV_PIX_FMT_YUV444P12LE] = {
  1539. .name = "yuv444p12le",
  1540. .nb_components = 3,
  1541. .log2_chroma_w = 0,
  1542. .log2_chroma_h = 0,
  1543. .comp = {
  1544. { 0, 2, 0, 0, 12, 1, 11, 1 }, /* Y */
  1545. { 1, 2, 0, 0, 12, 1, 11, 1 }, /* U */
  1546. { 2, 2, 0, 0, 12, 1, 11, 1 }, /* V */
  1547. },
  1548. .flags = AV_PIX_FMT_FLAG_PLANAR,
  1549. },
  1550. [AV_PIX_FMT_YUV444P12BE] = {
  1551. .name = "yuv444p12be",
  1552. .nb_components = 3,
  1553. .log2_chroma_w = 0,
  1554. .log2_chroma_h = 0,
  1555. .comp = {
  1556. { 0, 2, 0, 0, 12, 1, 11, 1 }, /* Y */
  1557. { 1, 2, 0, 0, 12, 1, 11, 1 }, /* U */
  1558. { 2, 2, 0, 0, 12, 1, 11, 1 }, /* V */
  1559. },
  1560. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
  1561. },
  1562. [AV_PIX_FMT_YUV444P14LE] = {
  1563. .name = "yuv444p14le",
  1564. .nb_components = 3,
  1565. .log2_chroma_w = 0,
  1566. .log2_chroma_h = 0,
  1567. .comp = {
  1568. { 0, 2, 0, 0, 14, 1, 13, 1 }, /* Y */
  1569. { 1, 2, 0, 0, 14, 1, 13, 1 }, /* U */
  1570. { 2, 2, 0, 0, 14, 1, 13, 1 }, /* V */
  1571. },
  1572. .flags = AV_PIX_FMT_FLAG_PLANAR,
  1573. },
  1574. [AV_PIX_FMT_YUV444P14BE] = {
  1575. .name = "yuv444p14be",
  1576. .nb_components = 3,
  1577. .log2_chroma_w = 0,
  1578. .log2_chroma_h = 0,
  1579. .comp = {
  1580. { 0, 2, 0, 0, 14, 1, 13, 1 }, /* Y */
  1581. { 1, 2, 0, 0, 14, 1, 13, 1 }, /* U */
  1582. { 2, 2, 0, 0, 14, 1, 13, 1 }, /* V */
  1583. },
  1584. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
  1585. },
  1586. [AV_PIX_FMT_D3D11VA_VLD] = {
  1587. .name = "d3d11va_vld",
  1588. .log2_chroma_w = 1,
  1589. .log2_chroma_h = 1,
  1590. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  1591. },
  1592. [AV_PIX_FMT_DXVA2_VLD] = {
  1593. .name = "dxva2_vld",
  1594. .log2_chroma_w = 1,
  1595. .log2_chroma_h = 1,
  1596. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  1597. },
  1598. [AV_PIX_FMT_VDA_VLD] = {
  1599. .name = "vda_vld",
  1600. .log2_chroma_w = 1,
  1601. .log2_chroma_h = 1,
  1602. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  1603. },
  1604. [AV_PIX_FMT_YA8] = {
  1605. .name = "ya8",
  1606. .nb_components = 2,
  1607. .comp = {
  1608. { 0, 2, 0, 0, 8, 1, 7, 1 }, /* Y */
  1609. { 0, 2, 1, 0, 8, 1, 7, 2 }, /* A */
  1610. },
  1611. .flags = AV_PIX_FMT_FLAG_ALPHA,
  1612. .alias = "gray8a",
  1613. },
  1614. [AV_PIX_FMT_YA16LE] = {
  1615. .name = "ya16le",
  1616. .nb_components = 2,
  1617. .comp = {
  1618. { 0, 4, 0, 0, 16, 3, 15, 1 }, /* Y */
  1619. { 0, 4, 2, 0, 16, 3, 15, 3 }, /* A */
  1620. },
  1621. .flags = AV_PIX_FMT_FLAG_ALPHA,
  1622. },
  1623. [AV_PIX_FMT_YA16BE] = {
  1624. .name = "ya16be",
  1625. .nb_components = 2,
  1626. .comp = {
  1627. { 0, 4, 0, 0, 16, 3, 15, 1 }, /* Y */
  1628. { 0, 4, 2, 0, 16, 3, 15, 3 }, /* A */
  1629. },
  1630. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_ALPHA,
  1631. },
  1632. [AV_PIX_FMT_VIDEOTOOLBOX] = {
  1633. .name = "videotoolbox_vld",
  1634. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  1635. },
  1636. [AV_PIX_FMT_GBRP] = {
  1637. .name = "gbrp",
  1638. .nb_components = 3,
  1639. .log2_chroma_w = 0,
  1640. .log2_chroma_h = 0,
  1641. .comp = {
  1642. { 2, 1, 0, 0, 8, 0, 7, 1 }, /* R */
  1643. { 0, 1, 0, 0, 8, 0, 7, 1 }, /* G */
  1644. { 1, 1, 0, 0, 8, 0, 7, 1 }, /* B */
  1645. },
  1646. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB,
  1647. },
  1648. [AV_PIX_FMT_GBRP9LE] = {
  1649. .name = "gbrp9le",
  1650. .nb_components = 3,
  1651. .log2_chroma_w = 0,
  1652. .log2_chroma_h = 0,
  1653. .comp = {
  1654. { 2, 2, 0, 0, 9, 1, 8, 1 }, /* R */
  1655. { 0, 2, 0, 0, 9, 1, 8, 1 }, /* G */
  1656. { 1, 2, 0, 0, 9, 1, 8, 1 }, /* B */
  1657. },
  1658. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB,
  1659. },
  1660. [AV_PIX_FMT_GBRP9BE] = {
  1661. .name = "gbrp9be",
  1662. .nb_components = 3,
  1663. .log2_chroma_w = 0,
  1664. .log2_chroma_h = 0,
  1665. .comp = {
  1666. { 2, 2, 0, 0, 9, 1, 8, 1 }, /* R */
  1667. { 0, 2, 0, 0, 9, 1, 8, 1 }, /* G */
  1668. { 1, 2, 0, 0, 9, 1, 8, 1 }, /* B */
  1669. },
  1670. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB,
  1671. },
  1672. [AV_PIX_FMT_GBRP10LE] = {
  1673. .name = "gbrp10le",
  1674. .nb_components = 3,
  1675. .log2_chroma_w = 0,
  1676. .log2_chroma_h = 0,
  1677. .comp = {
  1678. { 2, 2, 0, 0, 10, 1, 9, 1 }, /* R */
  1679. { 0, 2, 0, 0, 10, 1, 9, 1 }, /* G */
  1680. { 1, 2, 0, 0, 10, 1, 9, 1 }, /* B */
  1681. },
  1682. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB,
  1683. },
  1684. [AV_PIX_FMT_GBRP10BE] = {
  1685. .name = "gbrp10be",
  1686. .nb_components = 3,
  1687. .log2_chroma_w = 0,
  1688. .log2_chroma_h = 0,
  1689. .comp = {
  1690. { 2, 2, 0, 0, 10, 1, 9, 1 }, /* R */
  1691. { 0, 2, 0, 0, 10, 1, 9, 1 }, /* G */
  1692. { 1, 2, 0, 0, 10, 1, 9, 1 }, /* B */
  1693. },
  1694. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB,
  1695. },
  1696. [AV_PIX_FMT_GBRP12LE] = {
  1697. .name = "gbrp12le",
  1698. .nb_components = 3,
  1699. .log2_chroma_w = 0,
  1700. .log2_chroma_h = 0,
  1701. .comp = {
  1702. { 2, 2, 0, 0, 12, 1, 11, 1 }, /* R */
  1703. { 0, 2, 0, 0, 12, 1, 11, 1 }, /* G */
  1704. { 1, 2, 0, 0, 12, 1, 11, 1 }, /* B */
  1705. },
  1706. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB,
  1707. },
  1708. [AV_PIX_FMT_GBRP12BE] = {
  1709. .name = "gbrp12be",
  1710. .nb_components = 3,
  1711. .log2_chroma_w = 0,
  1712. .log2_chroma_h = 0,
  1713. .comp = {
  1714. { 2, 2, 0, 0, 12, 1, 11, 1 }, /* R */
  1715. { 0, 2, 0, 0, 12, 1, 11, 1 }, /* G */
  1716. { 1, 2, 0, 0, 12, 1, 11, 1 }, /* B */
  1717. },
  1718. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB,
  1719. },
  1720. [AV_PIX_FMT_GBRP14LE] = {
  1721. .name = "gbrp14le",
  1722. .nb_components = 3,
  1723. .log2_chroma_w = 0,
  1724. .log2_chroma_h = 0,
  1725. .comp = {
  1726. { 2, 2, 0, 0, 14, 1, 13, 1 }, /* R */
  1727. { 0, 2, 0, 0, 14, 1, 13, 1 }, /* G */
  1728. { 1, 2, 0, 0, 14, 1, 13, 1 }, /* B */
  1729. },
  1730. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB,
  1731. },
  1732. [AV_PIX_FMT_GBRP14BE] = {
  1733. .name = "gbrp14be",
  1734. .nb_components = 3,
  1735. .log2_chroma_w = 0,
  1736. .log2_chroma_h = 0,
  1737. .comp = {
  1738. { 2, 2, 0, 0, 14, 1, 13, 1 }, /* R */
  1739. { 0, 2, 0, 0, 14, 1, 13, 1 }, /* G */
  1740. { 1, 2, 0, 0, 14, 1, 13, 1 }, /* B */
  1741. },
  1742. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB,
  1743. },
  1744. [AV_PIX_FMT_GBRP16LE] = {
  1745. .name = "gbrp16le",
  1746. .nb_components = 3,
  1747. .log2_chroma_w = 0,
  1748. .log2_chroma_h = 0,
  1749. .comp = {
  1750. { 2, 2, 0, 0, 16, 1, 15, 1 }, /* R */
  1751. { 0, 2, 0, 0, 16, 1, 15, 1 }, /* G */
  1752. { 1, 2, 0, 0, 16, 1, 15, 1 }, /* B */
  1753. },
  1754. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB,
  1755. },
  1756. [AV_PIX_FMT_GBRP16BE] = {
  1757. .name = "gbrp16be",
  1758. .nb_components = 3,
  1759. .log2_chroma_w = 0,
  1760. .log2_chroma_h = 0,
  1761. .comp = {
  1762. { 2, 2, 0, 0, 16, 1, 15, 1 }, /* R */
  1763. { 0, 2, 0, 0, 16, 1, 15, 1 }, /* G */
  1764. { 1, 2, 0, 0, 16, 1, 15, 1 }, /* B */
  1765. },
  1766. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB,
  1767. },
  1768. [AV_PIX_FMT_GBRAP] = {
  1769. .name = "gbrap",
  1770. .nb_components = 4,
  1771. .log2_chroma_w = 0,
  1772. .log2_chroma_h = 0,
  1773. .comp = {
  1774. { 2, 1, 0, 0, 8, 0, 7, 1 }, /* R */
  1775. { 0, 1, 0, 0, 8, 0, 7, 1 }, /* G */
  1776. { 1, 1, 0, 0, 8, 0, 7, 1 }, /* B */
  1777. { 3, 1, 0, 0, 8, 0, 7, 1 }, /* A */
  1778. },
  1779. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB |
  1780. AV_PIX_FMT_FLAG_ALPHA,
  1781. },
  1782. [AV_PIX_FMT_GBRAP16LE] = {
  1783. .name = "gbrap16le",
  1784. .nb_components = 4,
  1785. .log2_chroma_w = 0,
  1786. .log2_chroma_h = 0,
  1787. .comp = {
  1788. { 2, 2, 0, 0, 16, 1, 15, 1 }, /* R */
  1789. { 0, 2, 0, 0, 16, 1, 15, 1 }, /* G */
  1790. { 1, 2, 0, 0, 16, 1, 15, 1 }, /* B */
  1791. { 3, 2, 0, 0, 16, 1, 15, 1 }, /* A */
  1792. },
  1793. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB |
  1794. AV_PIX_FMT_FLAG_ALPHA,
  1795. },
  1796. [AV_PIX_FMT_GBRAP16BE] = {
  1797. .name = "gbrap16be",
  1798. .nb_components = 4,
  1799. .log2_chroma_w = 0,
  1800. .log2_chroma_h = 0,
  1801. .comp = {
  1802. { 2, 2, 0, 0, 16, 1, 15, 1 }, /* R */
  1803. { 0, 2, 0, 0, 16, 1, 15, 1 }, /* G */
  1804. { 1, 2, 0, 0, 16, 1, 15, 1 }, /* B */
  1805. { 3, 2, 0, 0, 16, 1, 15, 1 }, /* A */
  1806. },
  1807. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR |
  1808. AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
  1809. },
  1810. [AV_PIX_FMT_VDPAU] = {
  1811. .name = "vdpau",
  1812. .log2_chroma_w = 1,
  1813. .log2_chroma_h = 1,
  1814. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  1815. },
  1816. [AV_PIX_FMT_XYZ12LE] = {
  1817. .name = "xyz12le",
  1818. .nb_components = 3,
  1819. .log2_chroma_w = 0,
  1820. .log2_chroma_h = 0,
  1821. .comp = {
  1822. { 0, 6, 0, 4, 12, 5, 11, 1 }, /* X */
  1823. { 0, 6, 2, 4, 12, 5, 11, 3 }, /* Y */
  1824. { 0, 6, 4, 4, 12, 5, 11, 5 }, /* Z */
  1825. },
  1826. /*.flags = -- not used*/
  1827. },
  1828. [AV_PIX_FMT_XYZ12BE] = {
  1829. .name = "xyz12be",
  1830. .nb_components = 3,
  1831. .log2_chroma_w = 0,
  1832. .log2_chroma_h = 0,
  1833. .comp = {
  1834. { 0, 6, 0, 4, 12, 5, 11, 1 }, /* X */
  1835. { 0, 6, 2, 4, 12, 5, 11, 3 }, /* Y */
  1836. { 0, 6, 4, 4, 12, 5, 11, 5 }, /* Z */
  1837. },
  1838. .flags = AV_PIX_FMT_FLAG_BE,
  1839. },
  1840. #define BAYER8_DESC_COMMON \
  1841. .nb_components= 3, \
  1842. .log2_chroma_w= 0, \
  1843. .log2_chroma_h= 0, \
  1844. .comp = { \
  1845. {0,1,0,0,2,0,1,1},\
  1846. {0,1,0,0,4,0,3,1},\
  1847. {0,1,0,0,2,0,1,1},\
  1848. }, \
  1849. #define BAYER16_DESC_COMMON \
  1850. .nb_components= 3, \
  1851. .log2_chroma_w= 0, \
  1852. .log2_chroma_h= 0, \
  1853. .comp = { \
  1854. {0,2,0,0,4,1,3,1},\
  1855. {0,2,0,0,8,1,7,1},\
  1856. {0,2,0,0,4,1,3,1},\
  1857. }, \
  1858. [AV_PIX_FMT_BAYER_BGGR8] = {
  1859. .name = "bayer_bggr8",
  1860. BAYER8_DESC_COMMON
  1861. .flags = AV_PIX_FMT_FLAG_RGB,
  1862. },
  1863. [AV_PIX_FMT_BAYER_BGGR16LE] = {
  1864. .name = "bayer_bggr16le",
  1865. BAYER16_DESC_COMMON
  1866. .flags = AV_PIX_FMT_FLAG_RGB,
  1867. },
  1868. [AV_PIX_FMT_BAYER_BGGR16BE] = {
  1869. .name = "bayer_bggr16be",
  1870. BAYER16_DESC_COMMON
  1871. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB,
  1872. },
  1873. [AV_PIX_FMT_BAYER_RGGB8] = {
  1874. .name = "bayer_rggb8",
  1875. BAYER8_DESC_COMMON
  1876. .flags = AV_PIX_FMT_FLAG_RGB,
  1877. },
  1878. [AV_PIX_FMT_BAYER_RGGB16LE] = {
  1879. .name = "bayer_rggb16le",
  1880. BAYER16_DESC_COMMON
  1881. .flags = AV_PIX_FMT_FLAG_RGB,
  1882. },
  1883. [AV_PIX_FMT_BAYER_RGGB16BE] = {
  1884. .name = "bayer_rggb16be",
  1885. BAYER16_DESC_COMMON
  1886. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB,
  1887. },
  1888. [AV_PIX_FMT_BAYER_GBRG8] = {
  1889. .name = "bayer_gbrg8",
  1890. BAYER8_DESC_COMMON
  1891. .flags = AV_PIX_FMT_FLAG_RGB,
  1892. },
  1893. [AV_PIX_FMT_BAYER_GBRG16LE] = {
  1894. .name = "bayer_gbrg16le",
  1895. BAYER16_DESC_COMMON
  1896. .flags = AV_PIX_FMT_FLAG_RGB,
  1897. },
  1898. [AV_PIX_FMT_BAYER_GBRG16BE] = {
  1899. .name = "bayer_gbrg16be",
  1900. BAYER16_DESC_COMMON
  1901. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB,
  1902. },
  1903. [AV_PIX_FMT_BAYER_GRBG8] = {
  1904. .name = "bayer_grbg8",
  1905. BAYER8_DESC_COMMON
  1906. .flags = AV_PIX_FMT_FLAG_RGB,
  1907. },
  1908. [AV_PIX_FMT_BAYER_GRBG16LE] = {
  1909. .name = "bayer_grbg16le",
  1910. BAYER16_DESC_COMMON
  1911. .flags = AV_PIX_FMT_FLAG_RGB,
  1912. },
  1913. [AV_PIX_FMT_BAYER_GRBG16BE] = {
  1914. .name = "bayer_grbg16be",
  1915. BAYER16_DESC_COMMON
  1916. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB,
  1917. },
  1918. [AV_PIX_FMT_NV16] = {
  1919. .name = "nv16",
  1920. .nb_components = 3,
  1921. .log2_chroma_w = 1,
  1922. .log2_chroma_h = 0,
  1923. .comp = {
  1924. { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */
  1925. { 1, 2, 0, 0, 8, 1, 7, 1 }, /* U */
  1926. { 1, 2, 1, 0, 8, 1, 7, 2 }, /* V */
  1927. },
  1928. .flags = AV_PIX_FMT_FLAG_PLANAR,
  1929. },
  1930. [AV_PIX_FMT_NV20LE] = {
  1931. .name = "nv20le",
  1932. .nb_components = 3,
  1933. .log2_chroma_w = 1,
  1934. .log2_chroma_h = 0,
  1935. .comp = {
  1936. { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */
  1937. { 1, 4, 0, 0, 10, 3, 9, 1 }, /* U */
  1938. { 1, 4, 2, 0, 10, 3, 9, 3 }, /* V */
  1939. },
  1940. .flags = AV_PIX_FMT_FLAG_PLANAR,
  1941. },
  1942. [AV_PIX_FMT_NV20BE] = {
  1943. .name = "nv20be",
  1944. .nb_components = 3,
  1945. .log2_chroma_w = 1,
  1946. .log2_chroma_h = 0,
  1947. .comp = {
  1948. { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */
  1949. { 1, 4, 0, 0, 10, 3, 9, 1 }, /* U */
  1950. { 1, 4, 2, 0, 10, 3, 9, 3 }, /* V */
  1951. },
  1952. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE,
  1953. },
  1954. [AV_PIX_FMT_VDA] = {
  1955. .name = "vda",
  1956. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  1957. },
  1958. [AV_PIX_FMT_QSV] = {
  1959. .name = "qsv",
  1960. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  1961. },
  1962. [AV_PIX_FMT_MEDIACODEC] = {
  1963. .name = "mediacodec",
  1964. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  1965. },
  1966. [AV_PIX_FMT_MMAL] = {
  1967. .name = "mmal",
  1968. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  1969. },
  1970. [AV_PIX_FMT_CUDA] = {
  1971. .name = "cuda",
  1972. .flags = AV_PIX_FMT_FLAG_HWACCEL,
  1973. },
  1974. [AV_PIX_FMT_AYUV64LE] = {
  1975. .name = "ayuv64le",
  1976. .nb_components = 4,
  1977. .log2_chroma_w = 0,
  1978. .log2_chroma_h = 0,
  1979. .comp = {
  1980. { 0, 8, 2, 0, 16, 7, 15, 3 }, /* Y */
  1981. { 0, 8, 4, 0, 16, 7, 15, 5 }, /* U */
  1982. { 0, 8, 6, 0, 16, 7, 15, 7 }, /* V */
  1983. { 0, 8, 0, 0, 16, 7, 15, 1 }, /* A */
  1984. },
  1985. .flags = AV_PIX_FMT_FLAG_ALPHA,
  1986. },
  1987. [AV_PIX_FMT_AYUV64BE] = {
  1988. .name = "ayuv64be",
  1989. .nb_components = 4,
  1990. .log2_chroma_w = 0,
  1991. .log2_chroma_h = 0,
  1992. .comp = {
  1993. { 0, 8, 2, 0, 16, 7, 15, 3 }, /* Y */
  1994. { 0, 8, 4, 0, 16, 7, 15, 5 }, /* U */
  1995. { 0, 8, 6, 0, 16, 7, 15, 7 }, /* V */
  1996. { 0, 8, 0, 0, 16, 7, 15, 1 }, /* A */
  1997. },
  1998. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_ALPHA,
  1999. },
  2000. [AV_PIX_FMT_P010LE] = {
  2001. .name = "p010le",
  2002. .nb_components = 3,
  2003. .log2_chroma_w = 1,
  2004. .log2_chroma_h = 1,
  2005. .comp = {
  2006. { 0, 2, 0, 6, 10, 1, 9, 1 }, /* Y */
  2007. { 1, 4, 0, 6, 10, 3, 9, 1 }, /* U */
  2008. { 1, 4, 2, 6, 10, 3, 9, 3 }, /* V */
  2009. },
  2010. .flags = AV_PIX_FMT_FLAG_PLANAR,
  2011. },
  2012. [AV_PIX_FMT_P010BE] = {
  2013. .name = "p010be",
  2014. .nb_components = 3,
  2015. .log2_chroma_w = 1,
  2016. .log2_chroma_h = 1,
  2017. .comp = {
  2018. { 0, 2, 0, 6, 10, 1, 9, 1 }, /* Y */
  2019. { 1, 4, 0, 6, 10, 3, 9, 1 }, /* U */
  2020. { 1, 4, 2, 6, 10, 3, 9, 3 }, /* V */
  2021. },
  2022. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE,
  2023. },
  2024. [AV_PIX_FMT_GBRAP12LE] = {
  2025. .name = "gbrap12le",
  2026. .nb_components = 4,
  2027. .log2_chroma_w = 0,
  2028. .log2_chroma_h = 0,
  2029. .comp = {
  2030. { 2, 2, 0, 0, 12, 1, 11, 1 }, /* R */
  2031. { 0, 2, 0, 0, 12, 1, 11, 1 }, /* G */
  2032. { 1, 2, 0, 0, 12, 1, 11, 1 }, /* B */
  2033. { 3, 2, 0, 0, 12, 1, 11, 1 }, /* A */
  2034. },
  2035. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB |
  2036. AV_PIX_FMT_FLAG_ALPHA,
  2037. },
  2038. [AV_PIX_FMT_GBRAP12BE] = {
  2039. .name = "gbrap12be",
  2040. .nb_components = 4,
  2041. .log2_chroma_w = 0,
  2042. .log2_chroma_h = 0,
  2043. .comp = {
  2044. { 2, 2, 0, 0, 12, 1, 11, 1 }, /* R */
  2045. { 0, 2, 0, 0, 12, 1, 11, 1 }, /* G */
  2046. { 1, 2, 0, 0, 12, 1, 11, 1 }, /* B */
  2047. { 3, 2, 0, 0, 12, 1, 11, 1 }, /* A */
  2048. },
  2049. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR |
  2050. AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
  2051. },
  2052. [AV_PIX_FMT_GBRAP10LE] = {
  2053. .name = "gbrap10le",
  2054. .nb_components = 4,
  2055. .log2_chroma_w = 0,
  2056. .log2_chroma_h = 0,
  2057. .comp = {
  2058. { 2, 2, 0, 0, 10, 1, 9, 1 }, /* R */
  2059. { 0, 2, 0, 0, 10, 1, 9, 1 }, /* G */
  2060. { 1, 2, 0, 0, 10, 1, 9, 1 }, /* B */
  2061. { 3, 2, 0, 0, 10, 1, 9, 1 }, /* A */
  2062. },
  2063. .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB |
  2064. AV_PIX_FMT_FLAG_ALPHA,
  2065. },
  2066. [AV_PIX_FMT_GBRAP10BE] = {
  2067. .name = "gbrap10be",
  2068. .nb_components = 4,
  2069. .log2_chroma_w = 0,
  2070. .log2_chroma_h = 0,
  2071. .comp = {
  2072. { 2, 2, 0, 0, 10, 1, 9, 1 }, /* R */
  2073. { 0, 2, 0, 0, 10, 1, 9, 1 }, /* G */
  2074. { 1, 2, 0, 0, 10, 1, 9, 1 }, /* B */
  2075. { 3, 2, 0, 0, 10, 1, 9, 1 }, /* A */
  2076. },
  2077. .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR |
  2078. AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
  2079. },
  2080. };
  2081. #if FF_API_PLUS1_MINUS1
  2082. FF_ENABLE_DEPRECATION_WARNINGS
  2083. #endif
  2084. static const char *color_range_names[] = {
  2085. [AVCOL_RANGE_UNSPECIFIED] = "unknown",
  2086. [AVCOL_RANGE_MPEG] = "tv",
  2087. [AVCOL_RANGE_JPEG] = "pc",
  2088. };
  2089. static const char *color_primaries_names[AVCOL_PRI_NB] = {
  2090. [AVCOL_PRI_RESERVED0] = "reserved",
  2091. [AVCOL_PRI_BT709] = "bt709",
  2092. [AVCOL_PRI_UNSPECIFIED] = "unknown",
  2093. [AVCOL_PRI_RESERVED] = "reserved",
  2094. [AVCOL_PRI_BT470M] = "bt470m",
  2095. [AVCOL_PRI_BT470BG] = "bt470bg",
  2096. [AVCOL_PRI_SMPTE170M] = "smpte170m",
  2097. [AVCOL_PRI_SMPTE240M] = "smpte240m",
  2098. [AVCOL_PRI_FILM] = "film",
  2099. [AVCOL_PRI_BT2020] = "bt2020",
  2100. [AVCOL_PRI_SMPTEST428_1] = "smpte428-1",
  2101. [AVCOL_PRI_SMPTE431] = "smpte431",
  2102. [AVCOL_PRI_SMPTE432] = "smpte432",
  2103. };
  2104. static const char *color_transfer_names[] = {
  2105. [AVCOL_TRC_RESERVED0] = "reserved",
  2106. [AVCOL_TRC_BT709] = "bt709",
  2107. [AVCOL_TRC_UNSPECIFIED] = "unknown",
  2108. [AVCOL_TRC_RESERVED] = "reserved",
  2109. [AVCOL_TRC_GAMMA22] = "bt470m",
  2110. [AVCOL_TRC_GAMMA28] = "bt470bg",
  2111. [AVCOL_TRC_SMPTE170M] = "smpte170m",
  2112. [AVCOL_TRC_SMPTE240M] = "smpte240m",
  2113. [AVCOL_TRC_LINEAR] = "linear",
  2114. [AVCOL_TRC_LOG] = "log100",
  2115. [AVCOL_TRC_LOG_SQRT] = "log316",
  2116. [AVCOL_TRC_IEC61966_2_4] = "iec61966-2-4",
  2117. [AVCOL_TRC_BT1361_ECG] = "bt1361e",
  2118. [AVCOL_TRC_IEC61966_2_1] = "iec61966-2-1",
  2119. [AVCOL_TRC_BT2020_10] = "bt2020-10",
  2120. [AVCOL_TRC_BT2020_12] = "bt2020-20",
  2121. [AVCOL_TRC_SMPTEST2084] = "smpte2084",
  2122. [AVCOL_TRC_SMPTEST428_1] = "smpte428-1",
  2123. [AVCOL_TRC_ARIB_STD_B67] = "arib-std-b67",
  2124. };
  2125. static const char *color_space_names[] = {
  2126. [AVCOL_SPC_RGB] = "gbr",
  2127. [AVCOL_SPC_BT709] = "bt709",
  2128. [AVCOL_SPC_UNSPECIFIED] = "unknown",
  2129. [AVCOL_SPC_RESERVED] = "reserved",
  2130. [AVCOL_SPC_FCC] = "fcc",
  2131. [AVCOL_SPC_BT470BG] = "bt470bg",
  2132. [AVCOL_SPC_SMPTE170M] = "smpte170m",
  2133. [AVCOL_SPC_SMPTE240M] = "smpte240m",
  2134. [AVCOL_SPC_YCOCG] = "ycgco",
  2135. [AVCOL_SPC_BT2020_NCL] = "bt2020nc",
  2136. [AVCOL_SPC_BT2020_CL] = "bt2020c",
  2137. [AVCOL_SPC_SMPTE2085] = "smpte2085",
  2138. };
  2139. static const char *chroma_location_names[] = {
  2140. [AVCHROMA_LOC_UNSPECIFIED] = "unspecified",
  2141. [AVCHROMA_LOC_LEFT] = "left",
  2142. [AVCHROMA_LOC_CENTER] = "center",
  2143. [AVCHROMA_LOC_TOPLEFT] = "topleft",
  2144. [AVCHROMA_LOC_TOP] = "top",
  2145. [AVCHROMA_LOC_BOTTOMLEFT] = "bottomleft",
  2146. [AVCHROMA_LOC_BOTTOM] = "bottom",
  2147. };
  2148. static enum AVPixelFormat get_pix_fmt_internal(const char *name)
  2149. {
  2150. enum AVPixelFormat pix_fmt;
  2151. for (pix_fmt = 0; pix_fmt < AV_PIX_FMT_NB; pix_fmt++)
  2152. if (av_pix_fmt_descriptors[pix_fmt].name &&
  2153. (!strcmp(av_pix_fmt_descriptors[pix_fmt].name, name) ||
  2154. av_match_name(name, av_pix_fmt_descriptors[pix_fmt].alias)))
  2155. return pix_fmt;
  2156. return AV_PIX_FMT_NONE;
  2157. }
  2158. const char *av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
  2159. {
  2160. return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
  2161. av_pix_fmt_descriptors[pix_fmt].name : NULL;
  2162. }
  2163. #if HAVE_BIGENDIAN
  2164. # define X_NE(be, le) be
  2165. #else
  2166. # define X_NE(be, le) le
  2167. #endif
  2168. enum AVPixelFormat av_get_pix_fmt(const char *name)
  2169. {
  2170. enum AVPixelFormat pix_fmt;
  2171. if (!strcmp(name, "rgb32"))
  2172. name = X_NE("argb", "bgra");
  2173. else if (!strcmp(name, "bgr32"))
  2174. name = X_NE("abgr", "rgba");
  2175. pix_fmt = get_pix_fmt_internal(name);
  2176. if (pix_fmt == AV_PIX_FMT_NONE) {
  2177. char name2[32];
  2178. snprintf(name2, sizeof(name2), "%s%s", name, X_NE("be", "le"));
  2179. pix_fmt = get_pix_fmt_internal(name2);
  2180. }
  2181. #if FF_API_VAAPI
  2182. if (pix_fmt == AV_PIX_FMT_NONE && !strcmp(name, "vaapi"))
  2183. pix_fmt = AV_PIX_FMT_VAAPI;
  2184. #endif
  2185. return pix_fmt;
  2186. }
  2187. int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
  2188. {
  2189. int c, bits = 0;
  2190. int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h;
  2191. for (c = 0; c < pixdesc->nb_components; c++) {
  2192. int s = c == 1 || c == 2 ? 0 : log2_pixels;
  2193. bits += pixdesc->comp[c].depth << s;
  2194. }
  2195. return bits >> log2_pixels;
  2196. }
  2197. int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
  2198. {
  2199. int c, bits = 0;
  2200. int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h;
  2201. int steps[4] = {0};
  2202. for (c = 0; c < pixdesc->nb_components; c++) {
  2203. const AVComponentDescriptor *comp = &pixdesc->comp[c];
  2204. int s = c == 1 || c == 2 ? 0 : log2_pixels;
  2205. steps[comp->plane] = comp->step << s;
  2206. }
  2207. for (c = 0; c < 4; c++)
  2208. bits += steps[c];
  2209. if(!(pixdesc->flags & AV_PIX_FMT_FLAG_BITSTREAM))
  2210. bits *= 8;
  2211. return bits >> log2_pixels;
  2212. }
  2213. char *av_get_pix_fmt_string(char *buf, int buf_size,
  2214. enum AVPixelFormat pix_fmt)
  2215. {
  2216. /* print header */
  2217. if (pix_fmt < 0) {
  2218. snprintf (buf, buf_size, "name" " nb_components" " nb_bits");
  2219. } else {
  2220. const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[pix_fmt];
  2221. snprintf(buf, buf_size, "%-11s %7d %10d", pixdesc->name,
  2222. pixdesc->nb_components, av_get_bits_per_pixel(pixdesc));
  2223. }
  2224. return buf;
  2225. }
  2226. const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
  2227. {
  2228. if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
  2229. return NULL;
  2230. return &av_pix_fmt_descriptors[pix_fmt];
  2231. }
  2232. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
  2233. {
  2234. if (!prev)
  2235. return &av_pix_fmt_descriptors[0];
  2236. while (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1) {
  2237. prev++;
  2238. if (prev->name)
  2239. return prev;
  2240. }
  2241. return NULL;
  2242. }
  2243. enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
  2244. {
  2245. if (desc < av_pix_fmt_descriptors ||
  2246. desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors))
  2247. return AV_PIX_FMT_NONE;
  2248. return desc - av_pix_fmt_descriptors;
  2249. }
  2250. int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt,
  2251. int *h_shift, int *v_shift)
  2252. {
  2253. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  2254. if (!desc)
  2255. return AVERROR(ENOSYS);
  2256. *h_shift = desc->log2_chroma_w;
  2257. *v_shift = desc->log2_chroma_h;
  2258. return 0;
  2259. }
  2260. int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
  2261. {
  2262. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  2263. int i, planes[4] = { 0 }, ret = 0;
  2264. if (!desc)
  2265. return AVERROR(EINVAL);
  2266. for (i = 0; i < desc->nb_components; i++)
  2267. planes[desc->comp[i].plane] = 1;
  2268. for (i = 0; i < FF_ARRAY_ELEMS(planes); i++)
  2269. ret += planes[i];
  2270. return ret;
  2271. }
  2272. void ff_check_pixfmt_descriptors(void){
  2273. int i, j;
  2274. for (i=0; i<FF_ARRAY_ELEMS(av_pix_fmt_descriptors); i++) {
  2275. const AVPixFmtDescriptor *d = &av_pix_fmt_descriptors[i];
  2276. uint8_t fill[4][8+6+3] = {{0}};
  2277. uint8_t *data[4] = {fill[0], fill[1], fill[2], fill[3]};
  2278. int linesize[4] = {0,0,0,0};
  2279. uint16_t tmp[2];
  2280. if (!d->name && !d->nb_components && !d->log2_chroma_w && !d->log2_chroma_h && !d->flags)
  2281. continue;
  2282. // av_log(NULL, AV_LOG_DEBUG, "Checking: %s\n", d->name);
  2283. av_assert0(d->log2_chroma_w <= 3);
  2284. av_assert0(d->log2_chroma_h <= 3);
  2285. av_assert0(d->nb_components <= 4);
  2286. av_assert0(d->name && d->name[0]);
  2287. av_assert0((d->nb_components==4 || d->nb_components==2) == !!(d->flags & AV_PIX_FMT_FLAG_ALPHA));
  2288. av_assert2(av_get_pix_fmt(d->name) == i);
  2289. for (j=0; j<FF_ARRAY_ELEMS(d->comp); j++) {
  2290. const AVComponentDescriptor *c = &d->comp[j];
  2291. if(j>=d->nb_components) {
  2292. av_assert0(!c->plane && !c->step && !c->offset && !c->shift && !c->depth);
  2293. continue;
  2294. }
  2295. if (d->flags & AV_PIX_FMT_FLAG_BITSTREAM) {
  2296. av_assert0(c->step >= c->depth);
  2297. } else {
  2298. av_assert0(8*c->step >= c->depth);
  2299. }
  2300. if (!strncmp(d->name, "bayer_", 6))
  2301. continue;
  2302. av_read_image_line(tmp, (void*)data, linesize, d, 0, 0, j, 2, 0);
  2303. av_assert0(tmp[0] == 0 && tmp[1] == 0);
  2304. tmp[0] = tmp[1] = (1<<c->depth) - 1;
  2305. av_write_image_line(tmp, data, linesize, d, 0, 0, j, 2);
  2306. }
  2307. }
  2308. }
  2309. enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt)
  2310. {
  2311. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  2312. char name[16];
  2313. int i;
  2314. if (!desc || strlen(desc->name) < 2)
  2315. return AV_PIX_FMT_NONE;
  2316. av_strlcpy(name, desc->name, sizeof(name));
  2317. i = strlen(name) - 2;
  2318. if (strcmp(name + i, "be") && strcmp(name + i, "le"))
  2319. return AV_PIX_FMT_NONE;
  2320. name[i] ^= 'b' ^ 'l';
  2321. return get_pix_fmt_internal(name);
  2322. }
  2323. #define FF_COLOR_NA -1
  2324. #define FF_COLOR_RGB 0 /**< RGB color space */
  2325. #define FF_COLOR_GRAY 1 /**< gray color space */
  2326. #define FF_COLOR_YUV 2 /**< YUV color space. 16 <= Y <= 235, 16 <= U, V <= 240 */
  2327. #define FF_COLOR_YUV_JPEG 3 /**< YUV color space. 0 <= Y <= 255, 0 <= U, V <= 255 */
  2328. #define FF_COLOR_XYZ 4
  2329. #define pixdesc_has_alpha(pixdesc) \
  2330. ((pixdesc)->nb_components == 2 || (pixdesc)->nb_components == 4 || (pixdesc)->flags & AV_PIX_FMT_FLAG_PAL)
  2331. static int get_color_type(const AVPixFmtDescriptor *desc) {
  2332. if (desc->flags & AV_PIX_FMT_FLAG_PAL)
  2333. return FF_COLOR_RGB;
  2334. if(desc->nb_components == 1 || desc->nb_components == 2)
  2335. return FF_COLOR_GRAY;
  2336. if(desc->name && !strncmp(desc->name, "yuvj", 4))
  2337. return FF_COLOR_YUV_JPEG;
  2338. if(desc->name && !strncmp(desc->name, "xyz", 3))
  2339. return FF_COLOR_XYZ;
  2340. if(desc->flags & AV_PIX_FMT_FLAG_RGB)
  2341. return FF_COLOR_RGB;
  2342. if(desc->nb_components == 0)
  2343. return FF_COLOR_NA;
  2344. return FF_COLOR_YUV;
  2345. }
  2346. static int get_pix_fmt_depth(int *min, int *max, enum AVPixelFormat pix_fmt)
  2347. {
  2348. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  2349. int i;
  2350. if (!desc || !desc->nb_components) {
  2351. *min = *max = 0;
  2352. return AVERROR(EINVAL);
  2353. }
  2354. *min = INT_MAX, *max = -INT_MAX;
  2355. for (i = 0; i < desc->nb_components; i++) {
  2356. *min = FFMIN(desc->comp[i].depth, *min);
  2357. *max = FFMAX(desc->comp[i].depth, *max);
  2358. }
  2359. return 0;
  2360. }
  2361. static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt,
  2362. enum AVPixelFormat src_pix_fmt,
  2363. unsigned *lossp, unsigned consider)
  2364. {
  2365. const AVPixFmtDescriptor *src_desc = av_pix_fmt_desc_get(src_pix_fmt);
  2366. const AVPixFmtDescriptor *dst_desc = av_pix_fmt_desc_get(dst_pix_fmt);
  2367. int src_color, dst_color;
  2368. int src_min_depth, src_max_depth, dst_min_depth, dst_max_depth;
  2369. int ret, loss, i, nb_components;
  2370. int score = INT_MAX - 1;
  2371. if (dst_pix_fmt >= AV_PIX_FMT_NB || dst_pix_fmt <= AV_PIX_FMT_NONE)
  2372. return ~0;
  2373. /* compute loss */
  2374. *lossp = loss = 0;
  2375. if (dst_pix_fmt == src_pix_fmt)
  2376. return INT_MAX;
  2377. if ((ret = get_pix_fmt_depth(&src_min_depth, &src_max_depth, src_pix_fmt)) < 0)
  2378. return ret;
  2379. if ((ret = get_pix_fmt_depth(&dst_min_depth, &dst_max_depth, dst_pix_fmt)) < 0)
  2380. return ret;
  2381. src_color = get_color_type(src_desc);
  2382. dst_color = get_color_type(dst_desc);
  2383. if (dst_pix_fmt == AV_PIX_FMT_PAL8)
  2384. nb_components = FFMIN(src_desc->nb_components, 4);
  2385. else
  2386. nb_components = FFMIN(src_desc->nb_components, dst_desc->nb_components);
  2387. for (i = 0; i < nb_components; i++) {
  2388. int depth_minus1 = (dst_pix_fmt == AV_PIX_FMT_PAL8) ? 7/nb_components : (dst_desc->comp[i].depth - 1);
  2389. if (src_desc->comp[i].depth - 1 > depth_minus1 && (consider & FF_LOSS_DEPTH)) {
  2390. loss |= FF_LOSS_DEPTH;
  2391. score -= 65536 >> depth_minus1;
  2392. }
  2393. }
  2394. if (consider & FF_LOSS_RESOLUTION) {
  2395. if (dst_desc->log2_chroma_w > src_desc->log2_chroma_w) {
  2396. loss |= FF_LOSS_RESOLUTION;
  2397. score -= 256 << dst_desc->log2_chroma_w;
  2398. }
  2399. if (dst_desc->log2_chroma_h > src_desc->log2_chroma_h) {
  2400. loss |= FF_LOSS_RESOLUTION;
  2401. score -= 256 << dst_desc->log2_chroma_h;
  2402. }
  2403. // don't favor 422 over 420 if downsampling is needed, because 420 has much better support on the decoder side
  2404. if (dst_desc->log2_chroma_w == 1 && src_desc->log2_chroma_w == 0 &&
  2405. dst_desc->log2_chroma_h == 1 && src_desc->log2_chroma_h == 0 ) {
  2406. score += 512;
  2407. }
  2408. }
  2409. if(consider & FF_LOSS_COLORSPACE)
  2410. switch(dst_color) {
  2411. case FF_COLOR_RGB:
  2412. if (src_color != FF_COLOR_RGB &&
  2413. src_color != FF_COLOR_GRAY)
  2414. loss |= FF_LOSS_COLORSPACE;
  2415. break;
  2416. case FF_COLOR_GRAY:
  2417. if (src_color != FF_COLOR_GRAY)
  2418. loss |= FF_LOSS_COLORSPACE;
  2419. break;
  2420. case FF_COLOR_YUV:
  2421. if (src_color != FF_COLOR_YUV)
  2422. loss |= FF_LOSS_COLORSPACE;
  2423. break;
  2424. case FF_COLOR_YUV_JPEG:
  2425. if (src_color != FF_COLOR_YUV_JPEG &&
  2426. src_color != FF_COLOR_YUV &&
  2427. src_color != FF_COLOR_GRAY)
  2428. loss |= FF_LOSS_COLORSPACE;
  2429. break;
  2430. default:
  2431. /* fail safe test */
  2432. if (src_color != dst_color)
  2433. loss |= FF_LOSS_COLORSPACE;
  2434. break;
  2435. }
  2436. if(loss & FF_LOSS_COLORSPACE)
  2437. score -= (nb_components * 65536) >> FFMIN(dst_desc->comp[0].depth - 1, src_desc->comp[0].depth - 1);
  2438. if (dst_color == FF_COLOR_GRAY &&
  2439. src_color != FF_COLOR_GRAY && (consider & FF_LOSS_CHROMA)) {
  2440. loss |= FF_LOSS_CHROMA;
  2441. score -= 2 * 65536;
  2442. }
  2443. if (!pixdesc_has_alpha(dst_desc) && (pixdesc_has_alpha(src_desc) && (consider & FF_LOSS_ALPHA))) {
  2444. loss |= FF_LOSS_ALPHA;
  2445. score -= 65536;
  2446. }
  2447. if (dst_pix_fmt == AV_PIX_FMT_PAL8 && (consider & FF_LOSS_COLORQUANT) &&
  2448. (src_pix_fmt != AV_PIX_FMT_PAL8 && (src_color != FF_COLOR_GRAY || (pixdesc_has_alpha(src_desc) && (consider & FF_LOSS_ALPHA))))) {
  2449. loss |= FF_LOSS_COLORQUANT;
  2450. score -= 65536;
  2451. }
  2452. *lossp = loss;
  2453. return score;
  2454. }
  2455. int av_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt,
  2456. enum AVPixelFormat src_pix_fmt,
  2457. int has_alpha)
  2458. {
  2459. int loss;
  2460. int ret = get_pix_fmt_score(dst_pix_fmt, src_pix_fmt, &loss, has_alpha ? ~0 : ~FF_LOSS_ALPHA);
  2461. if (ret < 0)
  2462. return ret;
  2463. return loss;
  2464. }
  2465. enum AVPixelFormat av_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
  2466. enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr)
  2467. {
  2468. enum AVPixelFormat dst_pix_fmt;
  2469. int loss1, loss2, loss_mask;
  2470. const AVPixFmtDescriptor *desc1 = av_pix_fmt_desc_get(dst_pix_fmt1);
  2471. const AVPixFmtDescriptor *desc2 = av_pix_fmt_desc_get(dst_pix_fmt2);
  2472. int score1, score2;
  2473. loss_mask= loss_ptr?~*loss_ptr:~0; /* use loss mask if provided */
  2474. if(!has_alpha)
  2475. loss_mask &= ~FF_LOSS_ALPHA;
  2476. score1 = get_pix_fmt_score(dst_pix_fmt1, src_pix_fmt, &loss1, loss_mask);
  2477. score2 = get_pix_fmt_score(dst_pix_fmt2, src_pix_fmt, &loss2, loss_mask);
  2478. if (score1 == score2) {
  2479. if(av_get_padded_bits_per_pixel(desc2) != av_get_padded_bits_per_pixel(desc1)) {
  2480. dst_pix_fmt = av_get_padded_bits_per_pixel(desc2) < av_get_padded_bits_per_pixel(desc1) ? dst_pix_fmt2 : dst_pix_fmt1;
  2481. } else {
  2482. dst_pix_fmt = desc2->nb_components < desc1->nb_components ? dst_pix_fmt2 : dst_pix_fmt1;
  2483. }
  2484. } else {
  2485. dst_pix_fmt = score1 < score2 ? dst_pix_fmt2 : dst_pix_fmt1;
  2486. }
  2487. if (loss_ptr)
  2488. *loss_ptr = av_get_pix_fmt_loss(dst_pix_fmt, src_pix_fmt, has_alpha);
  2489. return dst_pix_fmt;
  2490. }
  2491. const char *av_color_range_name(enum AVColorRange range)
  2492. {
  2493. return (unsigned) range < AVCOL_RANGE_NB ?
  2494. color_range_names[range] : NULL;
  2495. }
  2496. const char *av_color_primaries_name(enum AVColorPrimaries primaries)
  2497. {
  2498. return (unsigned) primaries < AVCOL_PRI_NB ?
  2499. color_primaries_names[primaries] : NULL;
  2500. }
  2501. const char *av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
  2502. {
  2503. return (unsigned) transfer < AVCOL_TRC_NB ?
  2504. color_transfer_names[transfer] : NULL;
  2505. }
  2506. const char *av_color_space_name(enum AVColorSpace space)
  2507. {
  2508. return (unsigned) space < AVCOL_SPC_NB ?
  2509. color_space_names[space] : NULL;
  2510. }
  2511. const char *av_chroma_location_name(enum AVChromaLocation location)
  2512. {
  2513. return (unsigned) location < AVCHROMA_LOC_NB ?
  2514. chroma_location_names[location] : NULL;
  2515. }