You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1291 lines
37KB

  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 "pixfmt.h"
  24. #include "pixdesc.h"
  25. #include "intreadwrite.h"
  26. void av_read_image_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4],
  27. const AVPixFmtDescriptor *desc, int x, int y, int c, int w,
  28. int read_pal_component)
  29. {
  30. AVComponentDescriptor comp = desc->comp[c];
  31. int plane = comp.plane;
  32. int depth = comp.depth_minus1 + 1;
  33. int mask = (1 << depth) - 1;
  34. int shift = comp.shift;
  35. int step = comp.step_minus1 + 1;
  36. int flags = desc->flags;
  37. if (flags & PIX_FMT_BITSTREAM) {
  38. int skip = x * step + comp.offset_plus1 - 1;
  39. const uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
  40. int shift = 8 - depth - (skip & 7);
  41. while (w--) {
  42. int val = (*p >> shift) & mask;
  43. if (read_pal_component)
  44. val = data[1][4*val + c];
  45. shift -= step;
  46. p -= shift >> 3;
  47. shift &= 7;
  48. *dst++ = val;
  49. }
  50. } else {
  51. const uint8_t *p = data[plane] + y * linesize[plane] + x * step + comp.offset_plus1 - 1;
  52. int is_8bit = shift + depth <= 8;
  53. if (is_8bit)
  54. p += !!(flags & PIX_FMT_BE);
  55. while (w--) {
  56. int val = is_8bit ? *p :
  57. flags & PIX_FMT_BE ? AV_RB16(p) : AV_RL16(p);
  58. val = (val >> shift) & mask;
  59. if (read_pal_component)
  60. val = data[1][4 * val + c];
  61. p += step;
  62. *dst++ = val;
  63. }
  64. }
  65. }
  66. void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesize[4],
  67. const AVPixFmtDescriptor *desc, int x, int y, int c, int w)
  68. {
  69. AVComponentDescriptor comp = desc->comp[c];
  70. int plane = comp.plane;
  71. int depth = comp.depth_minus1 + 1;
  72. int step = comp.step_minus1 + 1;
  73. int flags = desc->flags;
  74. if (flags & PIX_FMT_BITSTREAM) {
  75. int skip = x * step + comp.offset_plus1 - 1;
  76. uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
  77. int shift = 8 - depth - (skip & 7);
  78. while (w--) {
  79. *p |= *src++ << shift;
  80. shift -= step;
  81. p -= shift >> 3;
  82. shift &= 7;
  83. }
  84. } else {
  85. int shift = comp.shift;
  86. uint8_t *p = data[plane] + y * linesize[plane] + x * step + comp.offset_plus1 - 1;
  87. if (shift + depth <= 8) {
  88. p += !!(flags & PIX_FMT_BE);
  89. while (w--) {
  90. *p |= (*src++ << shift);
  91. p += step;
  92. }
  93. } else {
  94. while (w--) {
  95. if (flags & PIX_FMT_BE) {
  96. uint16_t val = AV_RB16(p) | (*src++ << shift);
  97. AV_WB16(p, val);
  98. } else {
  99. uint16_t val = AV_RL16(p) | (*src++ << shift);
  100. AV_WL16(p, val);
  101. }
  102. p += step;
  103. }
  104. }
  105. }
  106. }
  107. const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
  108. [PIX_FMT_YUV420P] = {
  109. .name = "yuv420p",
  110. .nb_components = 3,
  111. .log2_chroma_w = 1,
  112. .log2_chroma_h = 1,
  113. .comp = {
  114. { 0, 0, 1, 0, 7 }, /* Y */
  115. { 1, 0, 1, 0, 7 }, /* U */
  116. { 2, 0, 1, 0, 7 }, /* V */
  117. },
  118. .flags = PIX_FMT_PLANAR,
  119. },
  120. [PIX_FMT_YUYV422] = {
  121. .name = "yuyv422",
  122. .nb_components = 3,
  123. .log2_chroma_w = 1,
  124. .log2_chroma_h = 0,
  125. .comp = {
  126. { 0, 1, 1, 0, 7 }, /* Y */
  127. { 0, 3, 2, 0, 7 }, /* U */
  128. { 0, 3, 4, 0, 7 }, /* V */
  129. },
  130. },
  131. [PIX_FMT_RGB24] = {
  132. .name = "rgb24",
  133. .nb_components = 3,
  134. .log2_chroma_w = 0,
  135. .log2_chroma_h = 0,
  136. .comp = {
  137. { 0, 2, 1, 0, 7 }, /* R */
  138. { 0, 2, 2, 0, 7 }, /* G */
  139. { 0, 2, 3, 0, 7 }, /* B */
  140. },
  141. .flags = PIX_FMT_RGB,
  142. },
  143. [PIX_FMT_BGR24] = {
  144. .name = "bgr24",
  145. .nb_components = 3,
  146. .log2_chroma_w = 0,
  147. .log2_chroma_h = 0,
  148. .comp = {
  149. { 0, 2, 1, 0, 7 }, /* B */
  150. { 0, 2, 2, 0, 7 }, /* G */
  151. { 0, 2, 3, 0, 7 }, /* R */
  152. },
  153. .flags = PIX_FMT_RGB,
  154. },
  155. [PIX_FMT_YUV422P] = {
  156. .name = "yuv422p",
  157. .nb_components = 3,
  158. .log2_chroma_w = 1,
  159. .log2_chroma_h = 0,
  160. .comp = {
  161. { 0, 0, 1, 0, 7 }, /* Y */
  162. { 1, 0, 1, 0, 7 }, /* U */
  163. { 2, 0, 1, 0, 7 }, /* V */
  164. },
  165. .flags = PIX_FMT_PLANAR,
  166. },
  167. [PIX_FMT_YUV444P] = {
  168. .name = "yuv444p",
  169. .nb_components = 3,
  170. .log2_chroma_w = 0,
  171. .log2_chroma_h = 0,
  172. .comp = {
  173. { 0, 0, 1, 0, 7 }, /* Y */
  174. { 1, 0, 1, 0, 7 }, /* U */
  175. { 2, 0, 1, 0, 7 }, /* V */
  176. },
  177. .flags = PIX_FMT_PLANAR,
  178. },
  179. [PIX_FMT_YUV410P] = {
  180. .name = "yuv410p",
  181. .nb_components = 3,
  182. .log2_chroma_w = 2,
  183. .log2_chroma_h = 2,
  184. .comp = {
  185. { 0, 0, 1, 0, 7 }, /* Y */
  186. { 1, 0, 1, 0, 7 }, /* U */
  187. { 2, 0, 1, 0, 7 }, /* V */
  188. },
  189. .flags = PIX_FMT_PLANAR,
  190. },
  191. [PIX_FMT_YUV411P] = {
  192. .name = "yuv411p",
  193. .nb_components = 3,
  194. .log2_chroma_w = 2,
  195. .log2_chroma_h = 0,
  196. .comp = {
  197. { 0, 0, 1, 0, 7 }, /* Y */
  198. { 1, 0, 1, 0, 7 }, /* U */
  199. { 2, 0, 1, 0, 7 }, /* V */
  200. },
  201. .flags = PIX_FMT_PLANAR,
  202. },
  203. [PIX_FMT_GRAY8] = {
  204. .name = "gray",
  205. .nb_components = 1,
  206. .log2_chroma_w = 0,
  207. .log2_chroma_h = 0,
  208. .comp = {
  209. { 0, 0, 1, 0, 7 }, /* Y */
  210. },
  211. },
  212. [PIX_FMT_MONOWHITE] = {
  213. .name = "monow",
  214. .nb_components = 1,
  215. .log2_chroma_w = 0,
  216. .log2_chroma_h = 0,
  217. .comp = {
  218. { 0, 0, 1, 0, 0 }, /* Y */
  219. },
  220. .flags = PIX_FMT_BITSTREAM,
  221. },
  222. [PIX_FMT_MONOBLACK] = {
  223. .name = "monob",
  224. .nb_components = 1,
  225. .log2_chroma_w = 0,
  226. .log2_chroma_h = 0,
  227. .comp = {
  228. { 0, 0, 1, 7, 0 }, /* Y */
  229. },
  230. .flags = PIX_FMT_BITSTREAM,
  231. },
  232. [PIX_FMT_PAL8] = {
  233. .name = "pal8",
  234. .nb_components = 1,
  235. .log2_chroma_w = 0,
  236. .log2_chroma_h = 0,
  237. .comp = {
  238. { 0, 0, 1, 0, 7 },
  239. },
  240. .flags = PIX_FMT_PAL,
  241. },
  242. [PIX_FMT_YUVJ420P] = {
  243. .name = "yuvj420p",
  244. .nb_components = 3,
  245. .log2_chroma_w = 1,
  246. .log2_chroma_h = 1,
  247. .comp = {
  248. { 0, 0, 1, 0, 7 }, /* Y */
  249. { 1, 0, 1, 0, 7 }, /* U */
  250. { 2, 0, 1, 0, 7 }, /* V */
  251. },
  252. .flags = PIX_FMT_PLANAR,
  253. },
  254. [PIX_FMT_YUVJ422P] = {
  255. .name = "yuvj422p",
  256. .nb_components = 3,
  257. .log2_chroma_w = 1,
  258. .log2_chroma_h = 0,
  259. .comp = {
  260. { 0, 0, 1, 0, 7 }, /* Y */
  261. { 1, 0, 1, 0, 7 }, /* U */
  262. { 2, 0, 1, 0, 7 }, /* V */
  263. },
  264. .flags = PIX_FMT_PLANAR,
  265. },
  266. [PIX_FMT_YUVJ444P] = {
  267. .name = "yuvj444p",
  268. .nb_components = 3,
  269. .log2_chroma_w = 0,
  270. .log2_chroma_h = 0,
  271. .comp = {
  272. { 0, 0, 1, 0, 7 }, /* Y */
  273. { 1, 0, 1, 0, 7 }, /* U */
  274. { 2, 0, 1, 0, 7 }, /* V */
  275. },
  276. .flags = PIX_FMT_PLANAR,
  277. },
  278. [PIX_FMT_XVMC_MPEG2_MC] = {
  279. .name = "xvmcmc",
  280. .flags = PIX_FMT_HWACCEL,
  281. },
  282. [PIX_FMT_XVMC_MPEG2_IDCT] = {
  283. .name = "xvmcidct",
  284. .flags = PIX_FMT_HWACCEL,
  285. },
  286. [PIX_FMT_UYVY422] = {
  287. .name = "uyvy422",
  288. .nb_components = 3,
  289. .log2_chroma_w = 1,
  290. .log2_chroma_h = 0,
  291. .comp = {
  292. { 0, 1, 2, 0, 7 }, /* Y */
  293. { 0, 3, 1, 0, 7 }, /* U */
  294. { 0, 3, 3, 0, 7 }, /* V */
  295. },
  296. },
  297. [PIX_FMT_UYYVYY411] = {
  298. .name = "uyyvyy411",
  299. .nb_components = 3,
  300. .log2_chroma_w = 2,
  301. .log2_chroma_h = 0,
  302. .comp = {
  303. { 0, 3, 2, 0, 7 }, /* Y */
  304. { 0, 5, 1, 0, 7 }, /* U */
  305. { 0, 5, 4, 0, 7 }, /* V */
  306. },
  307. },
  308. [PIX_FMT_BGR8] = {
  309. .name = "bgr8",
  310. .nb_components = 3,
  311. .log2_chroma_w = 0,
  312. .log2_chroma_h = 0,
  313. .comp = {
  314. { 0, 0, 1, 6, 1 }, /* B */
  315. { 0, 0, 1, 3, 2 }, /* G */
  316. { 0, 0, 1, 0, 2 }, /* R */
  317. },
  318. .flags = PIX_FMT_PAL | PIX_FMT_RGB,
  319. },
  320. [PIX_FMT_BGR4] = {
  321. .name = "bgr4",
  322. .nb_components = 3,
  323. .log2_chroma_w = 0,
  324. .log2_chroma_h = 0,
  325. .comp = {
  326. { 0, 3, 1, 0, 0 }, /* B */
  327. { 0, 3, 2, 0, 1 }, /* G */
  328. { 0, 3, 4, 0, 0 }, /* R */
  329. },
  330. .flags = PIX_FMT_BITSTREAM | PIX_FMT_RGB,
  331. },
  332. [PIX_FMT_BGR4_BYTE] = {
  333. .name = "bgr4_byte",
  334. .nb_components = 3,
  335. .log2_chroma_w = 0,
  336. .log2_chroma_h = 0,
  337. .comp = {
  338. { 0, 0, 1, 3, 0 }, /* B */
  339. { 0, 0, 1, 1, 1 }, /* G */
  340. { 0, 0, 1, 0, 0 }, /* R */
  341. },
  342. .flags = PIX_FMT_PAL | PIX_FMT_RGB,
  343. },
  344. [PIX_FMT_RGB8] = {
  345. .name = "rgb8",
  346. .nb_components = 3,
  347. .log2_chroma_w = 0,
  348. .log2_chroma_h = 0,
  349. .comp = {
  350. { 0, 0, 1, 6, 1 }, /* R */
  351. { 0, 0, 1, 3, 2 }, /* G */
  352. { 0, 0, 1, 0, 2 }, /* B */
  353. },
  354. .flags = PIX_FMT_PAL | PIX_FMT_RGB,
  355. },
  356. [PIX_FMT_RGB4] = {
  357. .name = "rgb4",
  358. .nb_components = 3,
  359. .log2_chroma_w = 0,
  360. .log2_chroma_h = 0,
  361. .comp = {
  362. { 0, 3, 1, 0, 0 }, /* R */
  363. { 0, 3, 2, 0, 1 }, /* G */
  364. { 0, 3, 4, 0, 0 }, /* B */
  365. },
  366. .flags = PIX_FMT_BITSTREAM | PIX_FMT_RGB,
  367. },
  368. [PIX_FMT_RGB4_BYTE] = {
  369. .name = "rgb4_byte",
  370. .nb_components = 3,
  371. .log2_chroma_w = 0,
  372. .log2_chroma_h = 0,
  373. .comp = {
  374. { 0, 0, 1, 3, 0 }, /* R */
  375. { 0, 0, 1, 1, 1 }, /* G */
  376. { 0, 0, 1, 0, 0 }, /* B */
  377. },
  378. .flags = PIX_FMT_PAL | PIX_FMT_RGB,
  379. },
  380. [PIX_FMT_NV12] = {
  381. .name = "nv12",
  382. .nb_components = 3,
  383. .log2_chroma_w = 1,
  384. .log2_chroma_h = 1,
  385. .comp = {
  386. { 0, 0, 1, 0, 7 }, /* Y */
  387. { 1, 1, 1, 0, 7 }, /* U */
  388. { 1, 1, 2, 0, 7 }, /* V */
  389. },
  390. .flags = PIX_FMT_PLANAR,
  391. },
  392. [PIX_FMT_NV21] = {
  393. .name = "nv21",
  394. .nb_components = 3,
  395. .log2_chroma_w = 1,
  396. .log2_chroma_h = 1,
  397. .comp = {
  398. { 0, 0, 1, 0, 7 }, /* Y */
  399. { 1, 1, 1, 0, 7 }, /* V */
  400. { 1, 1, 2, 0, 7 }, /* U */
  401. },
  402. .flags = PIX_FMT_PLANAR,
  403. },
  404. [PIX_FMT_ARGB] = {
  405. .name = "argb",
  406. .nb_components = 4,
  407. .log2_chroma_w = 0,
  408. .log2_chroma_h = 0,
  409. .comp = {
  410. { 0, 3, 1, 0, 7 }, /* A */
  411. { 0, 3, 2, 0, 7 }, /* R */
  412. { 0, 3, 3, 0, 7 }, /* G */
  413. { 0, 3, 4, 0, 7 }, /* B */
  414. },
  415. .flags = PIX_FMT_RGB,
  416. },
  417. [PIX_FMT_RGBA] = {
  418. .name = "rgba",
  419. .nb_components = 4,
  420. .log2_chroma_w = 0,
  421. .log2_chroma_h = 0,
  422. .comp = {
  423. { 0, 3, 1, 0, 7 }, /* R */
  424. { 0, 3, 2, 0, 7 }, /* G */
  425. { 0, 3, 3, 0, 7 }, /* B */
  426. { 0, 3, 4, 0, 7 }, /* A */
  427. },
  428. .flags = PIX_FMT_RGB,
  429. },
  430. [PIX_FMT_ABGR] = {
  431. .name = "abgr",
  432. .nb_components = 4,
  433. .log2_chroma_w = 0,
  434. .log2_chroma_h = 0,
  435. .comp = {
  436. { 0, 3, 1, 0, 7 }, /* A */
  437. { 0, 3, 2, 0, 7 }, /* B */
  438. { 0, 3, 3, 0, 7 }, /* G */
  439. { 0, 3, 4, 0, 7 }, /* R */
  440. },
  441. .flags = PIX_FMT_RGB,
  442. },
  443. [PIX_FMT_BGRA] = {
  444. .name = "bgra",
  445. .nb_components = 4,
  446. .log2_chroma_w = 0,
  447. .log2_chroma_h = 0,
  448. .comp = {
  449. { 0, 3, 1, 0, 7 }, /* B */
  450. { 0, 3, 2, 0, 7 }, /* G */
  451. { 0, 3, 3, 0, 7 }, /* R */
  452. { 0, 3, 4, 0, 7 }, /* A */
  453. },
  454. .flags = PIX_FMT_RGB,
  455. },
  456. [PIX_FMT_0RGB] = {
  457. .name = "0rgb",
  458. .nb_components= 3,
  459. .log2_chroma_w= 0,
  460. .log2_chroma_h= 0,
  461. .comp = {
  462. { 0, 3, 2, 0, 7 }, /* R */
  463. { 0, 3, 3, 0, 7 }, /* G */
  464. { 0, 3, 4, 0, 7 }, /* B */
  465. },
  466. .flags = PIX_FMT_RGB,
  467. },
  468. [PIX_FMT_RGB0] = {
  469. .name = "rgb0",
  470. .nb_components= 3,
  471. .log2_chroma_w= 0,
  472. .log2_chroma_h= 0,
  473. .comp = {
  474. { 0, 3, 1, 0, 7 }, /* R */
  475. { 0, 3, 2, 0, 7 }, /* G */
  476. { 0, 3, 3, 0, 7 }, /* B */
  477. { 0, 3, 4, 0, 7 }, /* A */
  478. },
  479. .flags = PIX_FMT_RGB,
  480. },
  481. [PIX_FMT_0BGR] = {
  482. .name = "0bgr",
  483. .nb_components= 3,
  484. .log2_chroma_w= 0,
  485. .log2_chroma_h= 0,
  486. .comp = {
  487. { 0, 3, 2, 0, 7 }, /* B */
  488. { 0, 3, 3, 0, 7 }, /* G */
  489. { 0, 3, 4, 0, 7 }, /* R */
  490. },
  491. .flags = PIX_FMT_RGB,
  492. },
  493. [PIX_FMT_BGR0] = {
  494. .name = "bgr0",
  495. .nb_components= 3,
  496. .log2_chroma_w= 0,
  497. .log2_chroma_h= 0,
  498. .comp = {
  499. { 0, 3, 1, 0, 7 }, /* B */
  500. { 0, 3, 2, 0, 7 }, /* G */
  501. { 0, 3, 3, 0, 7 }, /* R */
  502. { 0, 3, 4, 0, 7 }, /* A */
  503. },
  504. .flags = PIX_FMT_RGB,
  505. },
  506. [PIX_FMT_GRAY16BE] = {
  507. .name = "gray16be",
  508. .nb_components = 1,
  509. .log2_chroma_w = 0,
  510. .log2_chroma_h = 0,
  511. .comp = {
  512. { 0, 1, 1, 0, 15 }, /* Y */
  513. },
  514. .flags = PIX_FMT_BE,
  515. },
  516. [PIX_FMT_GRAY16LE] = {
  517. .name = "gray16le",
  518. .nb_components = 1,
  519. .log2_chroma_w = 0,
  520. .log2_chroma_h = 0,
  521. .comp = {
  522. { 0, 1, 1, 0, 15 }, /* Y */
  523. },
  524. },
  525. [PIX_FMT_YUV440P] = {
  526. .name = "yuv440p",
  527. .nb_components = 3,
  528. .log2_chroma_w = 0,
  529. .log2_chroma_h = 1,
  530. .comp = {
  531. { 0, 0, 1, 0, 7 }, /* Y */
  532. { 1, 0, 1, 0, 7 }, /* U */
  533. { 2, 0, 1, 0, 7 }, /* V */
  534. },
  535. .flags = PIX_FMT_PLANAR,
  536. },
  537. [PIX_FMT_YUVJ440P] = {
  538. .name = "yuvj440p",
  539. .nb_components = 3,
  540. .log2_chroma_w = 0,
  541. .log2_chroma_h = 1,
  542. .comp = {
  543. { 0, 0, 1, 0, 7 }, /* Y */
  544. { 1, 0, 1, 0, 7 }, /* U */
  545. { 2, 0, 1, 0, 7 }, /* V */
  546. },
  547. .flags = PIX_FMT_PLANAR,
  548. },
  549. [PIX_FMT_YUVA420P] = {
  550. .name = "yuva420p",
  551. .nb_components = 4,
  552. .log2_chroma_w = 1,
  553. .log2_chroma_h = 1,
  554. .comp = {
  555. { 0, 0, 1, 0, 7 }, /* Y */
  556. { 1, 0, 1, 0, 7 }, /* U */
  557. { 2, 0, 1, 0, 7 }, /* V */
  558. { 3, 0, 1, 0, 7 }, /* A */
  559. },
  560. .flags = PIX_FMT_PLANAR,
  561. },
  562. [PIX_FMT_YUVA444P] = {
  563. .name = "yuva444p",
  564. .nb_components = 4,
  565. .log2_chroma_w = 0,
  566. .log2_chroma_h = 0,
  567. .comp = {
  568. { 0, 0, 1, 0, 7 }, /* Y */
  569. { 1, 0, 1, 0, 7 }, /* U */
  570. { 2, 0, 1, 0, 7 }, /* V */
  571. { 3, 0, 1, 0, 7 }, /* A */
  572. },
  573. .flags = PIX_FMT_PLANAR,
  574. },
  575. [PIX_FMT_VDPAU_H264] = {
  576. .name = "vdpau_h264",
  577. .log2_chroma_w = 1,
  578. .log2_chroma_h = 1,
  579. .flags = PIX_FMT_HWACCEL,
  580. },
  581. [PIX_FMT_VDPAU_MPEG1] = {
  582. .name = "vdpau_mpeg1",
  583. .log2_chroma_w = 1,
  584. .log2_chroma_h = 1,
  585. .flags = PIX_FMT_HWACCEL,
  586. },
  587. [PIX_FMT_VDPAU_MPEG2] = {
  588. .name = "vdpau_mpeg2",
  589. .log2_chroma_w = 1,
  590. .log2_chroma_h = 1,
  591. .flags = PIX_FMT_HWACCEL,
  592. },
  593. [PIX_FMT_VDPAU_WMV3] = {
  594. .name = "vdpau_wmv3",
  595. .log2_chroma_w = 1,
  596. .log2_chroma_h = 1,
  597. .flags = PIX_FMT_HWACCEL,
  598. },
  599. [PIX_FMT_VDPAU_VC1] = {
  600. .name = "vdpau_vc1",
  601. .log2_chroma_w = 1,
  602. .log2_chroma_h = 1,
  603. .flags = PIX_FMT_HWACCEL,
  604. },
  605. [PIX_FMT_VDPAU_MPEG4] = {
  606. .name = "vdpau_mpeg4",
  607. .log2_chroma_w = 1,
  608. .log2_chroma_h = 1,
  609. .flags = PIX_FMT_HWACCEL,
  610. },
  611. [PIX_FMT_RGB48BE] = {
  612. .name = "rgb48be",
  613. .nb_components = 3,
  614. .log2_chroma_w = 0,
  615. .log2_chroma_h = 0,
  616. .comp = {
  617. { 0, 5, 1, 0, 15 }, /* R */
  618. { 0, 5, 3, 0, 15 }, /* G */
  619. { 0, 5, 5, 0, 15 }, /* B */
  620. },
  621. .flags = PIX_FMT_RGB | PIX_FMT_BE,
  622. },
  623. [PIX_FMT_RGB48LE] = {
  624. .name = "rgb48le",
  625. .nb_components = 3,
  626. .log2_chroma_w = 0,
  627. .log2_chroma_h = 0,
  628. .comp = {
  629. { 0, 5, 1, 0, 15 }, /* R */
  630. { 0, 5, 3, 0, 15 }, /* G */
  631. { 0, 5, 5, 0, 15 }, /* B */
  632. },
  633. .flags = PIX_FMT_RGB,
  634. },
  635. [PIX_FMT_RGBA64BE] = {
  636. .name = "rgba64be",
  637. .nb_components= 4,
  638. .log2_chroma_w= 0,
  639. .log2_chroma_h= 0,
  640. .comp = {
  641. { 0, 7, 1, 0, 15 }, /* R */
  642. { 0, 7, 3, 0, 15 }, /* G */
  643. { 0, 7, 5, 0, 15 }, /* B */
  644. { 0, 7, 7, 0, 15 }, /* A */
  645. },
  646. .flags = PIX_FMT_RGB | PIX_FMT_BE,
  647. },
  648. [PIX_FMT_RGBA64LE] = {
  649. .name = "rgba64le",
  650. .nb_components= 4,
  651. .log2_chroma_w= 0,
  652. .log2_chroma_h= 0,
  653. .comp = {
  654. { 0, 7, 1, 0, 15 }, /* R */
  655. { 0, 7, 3, 0, 15 }, /* G */
  656. { 0, 7, 5, 0, 15 }, /* B */
  657. { 0, 7, 7, 0, 15 }, /* B */
  658. },
  659. .flags = PIX_FMT_RGB,
  660. },
  661. [PIX_FMT_RGB565BE] = {
  662. .name = "rgb565be",
  663. .nb_components = 3,
  664. .log2_chroma_w = 0,
  665. .log2_chroma_h = 0,
  666. .comp = {
  667. { 0, 1, 0, 3, 4 }, /* R */
  668. { 0, 1, 1, 5, 5 }, /* G */
  669. { 0, 1, 1, 0, 4 }, /* B */
  670. },
  671. .flags = PIX_FMT_BE | PIX_FMT_RGB,
  672. },
  673. [PIX_FMT_RGB565LE] = {
  674. .name = "rgb565le",
  675. .nb_components = 3,
  676. .log2_chroma_w = 0,
  677. .log2_chroma_h = 0,
  678. .comp = {
  679. { 0, 1, 2, 3, 4 }, /* R */
  680. { 0, 1, 1, 5, 5 }, /* G */
  681. { 0, 1, 1, 0, 4 }, /* B */
  682. },
  683. .flags = PIX_FMT_RGB,
  684. },
  685. [PIX_FMT_RGB555BE] = {
  686. .name = "rgb555be",
  687. .nb_components = 3,
  688. .log2_chroma_w = 0,
  689. .log2_chroma_h = 0,
  690. .comp = {
  691. { 0, 1, 0, 2, 4 }, /* R */
  692. { 0, 1, 1, 5, 4 }, /* G */
  693. { 0, 1, 1, 0, 4 }, /* B */
  694. },
  695. .flags = PIX_FMT_BE | PIX_FMT_RGB,
  696. },
  697. [PIX_FMT_RGB555LE] = {
  698. .name = "rgb555le",
  699. .nb_components = 3,
  700. .log2_chroma_w = 0,
  701. .log2_chroma_h = 0,
  702. .comp = {
  703. { 0, 1, 2, 2, 4 }, /* R */
  704. { 0, 1, 1, 5, 4 }, /* G */
  705. { 0, 1, 1, 0, 4 }, /* B */
  706. },
  707. .flags = PIX_FMT_RGB,
  708. },
  709. [PIX_FMT_RGB444BE] = {
  710. .name = "rgb444be",
  711. .nb_components = 3,
  712. .log2_chroma_w = 0,
  713. .log2_chroma_h = 0,
  714. .comp = {
  715. { 0, 1, 0, 0, 3 }, /* R */
  716. { 0, 1, 1, 4, 3 }, /* G */
  717. { 0, 1, 1, 0, 3 }, /* B */
  718. },
  719. .flags = PIX_FMT_BE | PIX_FMT_RGB,
  720. },
  721. [PIX_FMT_RGB444LE] = {
  722. .name = "rgb444le",
  723. .nb_components = 3,
  724. .log2_chroma_w = 0,
  725. .log2_chroma_h = 0,
  726. .comp = {
  727. { 0, 1, 2, 0, 3 }, /* R */
  728. { 0, 1, 1, 4, 3 }, /* G */
  729. { 0, 1, 1, 0, 3 }, /* B */
  730. },
  731. .flags = PIX_FMT_RGB,
  732. },
  733. [PIX_FMT_BGR48BE] = {
  734. .name = "bgr48be",
  735. .nb_components = 3,
  736. .log2_chroma_w = 0,
  737. .log2_chroma_h = 0,
  738. .comp = {
  739. { 0, 5, 1, 0, 15 }, /* B */
  740. { 0, 5, 3, 0, 15 }, /* G */
  741. { 0, 5, 5, 0, 15 }, /* R */
  742. },
  743. .flags = PIX_FMT_BE | PIX_FMT_RGB,
  744. },
  745. [PIX_FMT_BGR48LE] = {
  746. .name = "bgr48le",
  747. .nb_components = 3,
  748. .log2_chroma_w = 0,
  749. .log2_chroma_h = 0,
  750. .comp = {
  751. { 0, 5, 1, 0, 15 }, /* B */
  752. { 0, 5, 3, 0, 15 }, /* G */
  753. { 0, 5, 5, 0, 15 }, /* R */
  754. },
  755. .flags = PIX_FMT_RGB,
  756. },
  757. [PIX_FMT_BGRA64BE] = {
  758. .name = "bgra64be",
  759. .nb_components= 4,
  760. .log2_chroma_w= 0,
  761. .log2_chroma_h= 0,
  762. .comp = {
  763. { 0, 7, 1, 0, 15 }, /* B */
  764. { 0, 7, 3, 0, 15 }, /* G */
  765. { 0, 7, 5, 0, 15 }, /* R */
  766. { 0, 7, 7, 0, 15 }, /* A */
  767. },
  768. .flags = PIX_FMT_BE,
  769. },
  770. [PIX_FMT_BGRA64LE] = {
  771. .name = "bgra64le",
  772. .nb_components= 4,
  773. .log2_chroma_w= 0,
  774. .log2_chroma_h= 0,
  775. .comp = {
  776. { 0, 7, 1, 0, 15 }, /* B */
  777. { 0, 7, 3, 0, 15 }, /* G */
  778. { 0, 7, 5, 0, 15 }, /* R */
  779. { 0, 7, 7, 0, 15 }, /* A */
  780. },
  781. },
  782. [PIX_FMT_BGR565BE] = {
  783. .name = "bgr565be",
  784. .nb_components = 3,
  785. .log2_chroma_w = 0,
  786. .log2_chroma_h = 0,
  787. .comp = {
  788. { 0, 1, 0, 3, 4 }, /* B */
  789. { 0, 1, 1, 5, 5 }, /* G */
  790. { 0, 1, 1, 0, 4 }, /* R */
  791. },
  792. .flags = PIX_FMT_BE | PIX_FMT_RGB,
  793. },
  794. [PIX_FMT_BGR565LE] = {
  795. .name = "bgr565le",
  796. .nb_components = 3,
  797. .log2_chroma_w = 0,
  798. .log2_chroma_h = 0,
  799. .comp = {
  800. { 0, 1, 2, 3, 4 }, /* B */
  801. { 0, 1, 1, 5, 5 }, /* G */
  802. { 0, 1, 1, 0, 4 }, /* R */
  803. },
  804. .flags = PIX_FMT_RGB,
  805. },
  806. [PIX_FMT_BGR555BE] = {
  807. .name = "bgr555be",
  808. .nb_components = 3,
  809. .log2_chroma_w = 0,
  810. .log2_chroma_h = 0,
  811. .comp = {
  812. { 0, 1, 0, 2, 4 }, /* B */
  813. { 0, 1, 1, 5, 4 }, /* G */
  814. { 0, 1, 1, 0, 4 }, /* R */
  815. },
  816. .flags = PIX_FMT_BE | PIX_FMT_RGB,
  817. },
  818. [PIX_FMT_BGR555LE] = {
  819. .name = "bgr555le",
  820. .nb_components = 3,
  821. .log2_chroma_w = 0,
  822. .log2_chroma_h = 0,
  823. .comp = {
  824. { 0, 1, 2, 2, 4 }, /* B */
  825. { 0, 1, 1, 5, 4 }, /* G */
  826. { 0, 1, 1, 0, 4 }, /* R */
  827. },
  828. .flags = PIX_FMT_RGB,
  829. },
  830. [PIX_FMT_BGR444BE] = {
  831. .name = "bgr444be",
  832. .nb_components = 3,
  833. .log2_chroma_w = 0,
  834. .log2_chroma_h = 0,
  835. .comp = {
  836. { 0, 1, 0, 0, 3 }, /* B */
  837. { 0, 1, 1, 4, 3 }, /* G */
  838. { 0, 1, 1, 0, 3 }, /* R */
  839. },
  840. .flags = PIX_FMT_BE | PIX_FMT_RGB,
  841. },
  842. [PIX_FMT_BGR444LE] = {
  843. .name = "bgr444le",
  844. .nb_components = 3,
  845. .log2_chroma_w = 0,
  846. .log2_chroma_h = 0,
  847. .comp = {
  848. { 0, 1, 2, 0, 3 }, /* B */
  849. { 0, 1, 1, 4, 3 }, /* G */
  850. { 0, 1, 1, 0, 3 }, /* R */
  851. },
  852. .flags = PIX_FMT_RGB,
  853. },
  854. [PIX_FMT_VAAPI_MOCO] = {
  855. .name = "vaapi_moco",
  856. .log2_chroma_w = 1,
  857. .log2_chroma_h = 1,
  858. .flags = PIX_FMT_HWACCEL,
  859. },
  860. [PIX_FMT_VAAPI_IDCT] = {
  861. .name = "vaapi_idct",
  862. .log2_chroma_w = 1,
  863. .log2_chroma_h = 1,
  864. .flags = PIX_FMT_HWACCEL,
  865. },
  866. [PIX_FMT_VAAPI_VLD] = {
  867. .name = "vaapi_vld",
  868. .log2_chroma_w = 1,
  869. .log2_chroma_h = 1,
  870. .flags = PIX_FMT_HWACCEL,
  871. },
  872. [PIX_FMT_VDA_VLD] = {
  873. .name = "vda_vld",
  874. .log2_chroma_w = 1,
  875. .log2_chroma_h = 1,
  876. .flags = PIX_FMT_HWACCEL,
  877. },
  878. [PIX_FMT_YUV420P9LE] = {
  879. .name = "yuv420p9le",
  880. .nb_components = 3,
  881. .log2_chroma_w = 1,
  882. .log2_chroma_h = 1,
  883. .comp = {
  884. { 0, 1, 1, 0, 8 }, /* Y */
  885. { 1, 1, 1, 0, 8 }, /* U */
  886. { 2, 1, 1, 0, 8 }, /* V */
  887. },
  888. .flags = PIX_FMT_PLANAR,
  889. },
  890. [PIX_FMT_YUV420P9BE] = {
  891. .name = "yuv420p9be",
  892. .nb_components = 3,
  893. .log2_chroma_w = 1,
  894. .log2_chroma_h = 1,
  895. .comp = {
  896. { 0, 1, 1, 0, 8 }, /* Y */
  897. { 1, 1, 1, 0, 8 }, /* U */
  898. { 2, 1, 1, 0, 8 }, /* V */
  899. },
  900. .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
  901. },
  902. [PIX_FMT_YUV420P10LE] = {
  903. .name = "yuv420p10le",
  904. .nb_components = 3,
  905. .log2_chroma_w = 1,
  906. .log2_chroma_h = 1,
  907. .comp = {
  908. { 0, 1, 1, 0, 9 }, /* Y */
  909. { 1, 1, 1, 0, 9 }, /* U */
  910. { 2, 1, 1, 0, 9 }, /* V */
  911. },
  912. .flags = PIX_FMT_PLANAR,
  913. },
  914. [PIX_FMT_YUV420P10BE] = {
  915. .name = "yuv420p10be",
  916. .nb_components = 3,
  917. .log2_chroma_w = 1,
  918. .log2_chroma_h = 1,
  919. .comp = {
  920. { 0, 1, 1, 0, 9 }, /* Y */
  921. { 1, 1, 1, 0, 9 }, /* U */
  922. { 2, 1, 1, 0, 9 }, /* V */
  923. },
  924. .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
  925. },
  926. [PIX_FMT_YUV420P16LE] = {
  927. .name = "yuv420p16le",
  928. .nb_components = 3,
  929. .log2_chroma_w = 1,
  930. .log2_chroma_h = 1,
  931. .comp = {
  932. { 0, 1, 1, 0, 15 }, /* Y */
  933. { 1, 1, 1, 0, 15 }, /* U */
  934. { 2, 1, 1, 0, 15 }, /* V */
  935. },
  936. .flags = PIX_FMT_PLANAR,
  937. },
  938. [PIX_FMT_YUV420P16BE] = {
  939. .name = "yuv420p16be",
  940. .nb_components = 3,
  941. .log2_chroma_w = 1,
  942. .log2_chroma_h = 1,
  943. .comp = {
  944. { 0, 1, 1, 0, 15 }, /* Y */
  945. { 1, 1, 1, 0, 15 }, /* U */
  946. { 2, 1, 1, 0, 15 }, /* V */
  947. },
  948. .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
  949. },
  950. [PIX_FMT_YUV422P9LE] = {
  951. .name = "yuv422p9le",
  952. .nb_components = 3,
  953. .log2_chroma_w = 1,
  954. .log2_chroma_h = 0,
  955. .comp = {
  956. { 0, 1, 1, 0, 8 }, /* Y */
  957. { 1, 1, 1, 0, 8 }, /* U */
  958. { 2, 1, 1, 0, 8 }, /* V */
  959. },
  960. .flags = PIX_FMT_PLANAR,
  961. },
  962. [PIX_FMT_YUV422P9BE] = {
  963. .name = "yuv422p9be",
  964. .nb_components = 3,
  965. .log2_chroma_w = 1,
  966. .log2_chroma_h = 0,
  967. .comp = {
  968. { 0, 1, 1, 0, 8 }, /* Y */
  969. { 1, 1, 1, 0, 8 }, /* U */
  970. { 2, 1, 1, 0, 8 }, /* V */
  971. },
  972. .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
  973. },
  974. [PIX_FMT_YUV422P10LE] = {
  975. .name = "yuv422p10le",
  976. .nb_components = 3,
  977. .log2_chroma_w = 1,
  978. .log2_chroma_h = 0,
  979. .comp = {
  980. { 0, 1, 1, 0, 9 }, /* Y */
  981. { 1, 1, 1, 0, 9 }, /* U */
  982. { 2, 1, 1, 0, 9 }, /* V */
  983. },
  984. .flags = PIX_FMT_PLANAR,
  985. },
  986. [PIX_FMT_YUV422P10BE] = {
  987. .name = "yuv422p10be",
  988. .nb_components = 3,
  989. .log2_chroma_w = 1,
  990. .log2_chroma_h = 0,
  991. .comp = {
  992. { 0, 1, 1, 0, 9 }, /* Y */
  993. { 1, 1, 1, 0, 9 }, /* U */
  994. { 2, 1, 1, 0, 9 }, /* V */
  995. },
  996. .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
  997. },
  998. [PIX_FMT_YUV422P16LE] = {
  999. .name = "yuv422p16le",
  1000. .nb_components = 3,
  1001. .log2_chroma_w = 1,
  1002. .log2_chroma_h = 0,
  1003. .comp = {
  1004. { 0, 1, 1, 0, 15 }, /* Y */
  1005. { 1, 1, 1, 0, 15 }, /* U */
  1006. { 2, 1, 1, 0, 15 }, /* V */
  1007. },
  1008. .flags = PIX_FMT_PLANAR,
  1009. },
  1010. [PIX_FMT_YUV422P16BE] = {
  1011. .name = "yuv422p16be",
  1012. .nb_components = 3,
  1013. .log2_chroma_w = 1,
  1014. .log2_chroma_h = 0,
  1015. .comp = {
  1016. { 0, 1, 1, 0, 15 }, /* Y */
  1017. { 1, 1, 1, 0, 15 }, /* U */
  1018. { 2, 1, 1, 0, 15 }, /* V */
  1019. },
  1020. .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
  1021. },
  1022. [PIX_FMT_YUV444P16LE] = {
  1023. .name = "yuv444p16le",
  1024. .nb_components = 3,
  1025. .log2_chroma_w = 0,
  1026. .log2_chroma_h = 0,
  1027. .comp = {
  1028. { 0, 1, 1, 0, 15 }, /* Y */
  1029. { 1, 1, 1, 0, 15 }, /* U */
  1030. { 2, 1, 1, 0, 15 }, /* V */
  1031. },
  1032. .flags = PIX_FMT_PLANAR,
  1033. },
  1034. [PIX_FMT_YUV444P16BE] = {
  1035. .name = "yuv444p16be",
  1036. .nb_components = 3,
  1037. .log2_chroma_w = 0,
  1038. .log2_chroma_h = 0,
  1039. .comp = {
  1040. { 0, 1, 1, 0, 15 }, /* Y */
  1041. { 1, 1, 1, 0, 15 }, /* U */
  1042. { 2, 1, 1, 0, 15 }, /* V */
  1043. },
  1044. .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
  1045. },
  1046. [PIX_FMT_YUV444P10LE] = {
  1047. .name = "yuv444p10le",
  1048. .nb_components = 3,
  1049. .log2_chroma_w = 0,
  1050. .log2_chroma_h = 0,
  1051. .comp = {
  1052. { 0, 1, 1, 0, 9 }, /* Y */
  1053. { 1, 1, 1, 0, 9 }, /* U */
  1054. { 2, 1, 1, 0, 9 }, /* V */
  1055. },
  1056. .flags = PIX_FMT_PLANAR,
  1057. },
  1058. [PIX_FMT_YUV444P10BE] = {
  1059. .name = "yuv444p10be",
  1060. .nb_components = 3,
  1061. .log2_chroma_w = 0,
  1062. .log2_chroma_h = 0,
  1063. .comp = {
  1064. { 0, 1, 1, 0, 9 }, /* Y */
  1065. { 1, 1, 1, 0, 9 }, /* U */
  1066. { 2, 1, 1, 0, 9 }, /* V */
  1067. },
  1068. .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
  1069. },
  1070. [PIX_FMT_YUV444P9LE] = {
  1071. .name = "yuv444p9le",
  1072. .nb_components = 3,
  1073. .log2_chroma_w = 0,
  1074. .log2_chroma_h = 0,
  1075. .comp = {
  1076. { 0, 1, 1, 0, 8 }, /* Y */
  1077. { 1, 1, 1, 0, 8 }, /* U */
  1078. { 2, 1, 1, 0, 8 }, /* V */
  1079. },
  1080. .flags = PIX_FMT_PLANAR,
  1081. },
  1082. [PIX_FMT_YUV444P9BE] = {
  1083. .name = "yuv444p9be",
  1084. .nb_components = 3,
  1085. .log2_chroma_w = 0,
  1086. .log2_chroma_h = 0,
  1087. .comp = {
  1088. { 0, 1, 1, 0, 8 }, /* Y */
  1089. { 1, 1, 1, 0, 8 }, /* U */
  1090. { 2, 1, 1, 0, 8 }, /* V */
  1091. },
  1092. .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
  1093. },
  1094. [PIX_FMT_DXVA2_VLD] = {
  1095. .name = "dxva2_vld",
  1096. .log2_chroma_w = 1,
  1097. .log2_chroma_h = 1,
  1098. .flags = PIX_FMT_HWACCEL,
  1099. },
  1100. [PIX_FMT_VDA_VLD] = {
  1101. .name = "vda_vld",
  1102. .log2_chroma_w = 1,
  1103. .log2_chroma_h = 1,
  1104. .flags = PIX_FMT_HWACCEL,
  1105. },
  1106. [PIX_FMT_GRAY8A] = {
  1107. .name = "gray8a",
  1108. .nb_components = 2,
  1109. .comp = {
  1110. { 0, 1, 1, 0, 7 }, /* Y */
  1111. { 0, 1, 2, 0, 7 }, /* A */
  1112. },
  1113. },
  1114. [PIX_FMT_GBR24P] = {
  1115. .name = "gbr24p",
  1116. .nb_components= 3,
  1117. .comp = {
  1118. { 1, 0, 1, 0, 7 }, /* B */
  1119. { 0, 0, 1, 0, 7 }, /* G */
  1120. { 2, 0, 1, 0, 7 }, /* R */
  1121. },
  1122. .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
  1123. },
  1124. [PIX_FMT_GBRP] = {
  1125. .name = "gbrp",
  1126. .nb_components = 3,
  1127. .log2_chroma_w = 0,
  1128. .log2_chroma_h = 0,
  1129. .comp = {
  1130. { 0, 0, 1, 0, 7 }, /* G */
  1131. { 1, 0, 1, 0, 7 }, /* B */
  1132. { 2, 0, 1, 0, 7 }, /* R */
  1133. },
  1134. .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
  1135. },
  1136. [PIX_FMT_GBRP9LE] = {
  1137. .name = "gbrp9le",
  1138. .nb_components = 3,
  1139. .log2_chroma_w = 0,
  1140. .log2_chroma_h = 0,
  1141. .comp = {
  1142. { 0, 1, 1, 0, 8 }, /* G */
  1143. { 1, 1, 1, 0, 8 }, /* B */
  1144. { 2, 1, 1, 0, 8 }, /* R */
  1145. },
  1146. .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
  1147. },
  1148. [PIX_FMT_GBRP9BE] = {
  1149. .name = "gbrp9be",
  1150. .nb_components = 3,
  1151. .log2_chroma_w = 0,
  1152. .log2_chroma_h = 0,
  1153. .comp = {
  1154. { 0, 1, 1, 0, 8 }, /* G */
  1155. { 1, 1, 1, 0, 8 }, /* B */
  1156. { 2, 1, 1, 0, 8 }, /* R */
  1157. },
  1158. .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
  1159. },
  1160. [PIX_FMT_GBRP10LE] = {
  1161. .name = "gbrp10le",
  1162. .nb_components = 3,
  1163. .log2_chroma_w = 0,
  1164. .log2_chroma_h = 0,
  1165. .comp = {
  1166. { 0, 1, 1, 0, 9 }, /* G */
  1167. { 1, 1, 1, 0, 9 }, /* B */
  1168. { 2, 1, 1, 0, 9 }, /* R */
  1169. },
  1170. .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
  1171. },
  1172. [PIX_FMT_GBRP10BE] = {
  1173. .name = "gbrp10be",
  1174. .nb_components = 3,
  1175. .log2_chroma_w = 0,
  1176. .log2_chroma_h = 0,
  1177. .comp = {
  1178. { 0, 1, 1, 0, 9 }, /* G */
  1179. { 1, 1, 1, 0, 9 }, /* B */
  1180. { 2, 1, 1, 0, 9 }, /* R */
  1181. },
  1182. .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
  1183. },
  1184. [PIX_FMT_GBRP16LE] = {
  1185. .name = "gbrp16le",
  1186. .nb_components = 3,
  1187. .log2_chroma_w = 0,
  1188. .log2_chroma_h = 0,
  1189. .comp = {
  1190. { 0, 1, 1, 0, 15 }, /* G */
  1191. { 1, 1, 1, 0, 15 }, /* B */
  1192. { 2, 1, 1, 0, 15 }, /* R */
  1193. },
  1194. .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
  1195. },
  1196. [PIX_FMT_GBRP16BE] = {
  1197. .name = "gbrp16be",
  1198. .nb_components = 3,
  1199. .log2_chroma_w = 0,
  1200. .log2_chroma_h = 0,
  1201. .comp = {
  1202. { 0, 1, 1, 0, 15 }, /* G */
  1203. { 1, 1, 1, 0, 15 }, /* B */
  1204. { 2, 1, 1, 0, 15 }, /* R */
  1205. },
  1206. .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
  1207. },
  1208. };
  1209. static enum PixelFormat get_pix_fmt_internal(const char *name)
  1210. {
  1211. enum PixelFormat pix_fmt;
  1212. for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++)
  1213. if (av_pix_fmt_descriptors[pix_fmt].name &&
  1214. !strcmp(av_pix_fmt_descriptors[pix_fmt].name, name))
  1215. return pix_fmt;
  1216. return PIX_FMT_NONE;
  1217. }
  1218. const char *av_get_pix_fmt_name(enum PixelFormat pix_fmt)
  1219. {
  1220. return (unsigned)pix_fmt < PIX_FMT_NB ?
  1221. av_pix_fmt_descriptors[pix_fmt].name : NULL;
  1222. }
  1223. #if HAVE_BIGENDIAN
  1224. # define X_NE(be, le) be
  1225. #else
  1226. # define X_NE(be, le) le
  1227. #endif
  1228. enum PixelFormat av_get_pix_fmt(const char *name)
  1229. {
  1230. enum PixelFormat pix_fmt;
  1231. if (!strcmp(name, "rgb32"))
  1232. name = X_NE("argb", "bgra");
  1233. else if (!strcmp(name, "bgr32"))
  1234. name = X_NE("abgr", "rgba");
  1235. pix_fmt = get_pix_fmt_internal(name);
  1236. if (pix_fmt == PIX_FMT_NONE) {
  1237. char name2[32];
  1238. snprintf(name2, sizeof(name2), "%s%s", name, X_NE("be", "le"));
  1239. pix_fmt = get_pix_fmt_internal(name2);
  1240. }
  1241. return pix_fmt;
  1242. }
  1243. int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
  1244. {
  1245. int c, bits = 0;
  1246. int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h;
  1247. for (c = 0; c < pixdesc->nb_components; c++) {
  1248. int s = c == 1 || c == 2 ? 0 : log2_pixels;
  1249. bits += (pixdesc->comp[c].depth_minus1 + 1) << s;
  1250. }
  1251. return bits >> log2_pixels;
  1252. }
  1253. char *av_get_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt)
  1254. {
  1255. /* print header */
  1256. if (pix_fmt < 0) {
  1257. snprintf (buf, buf_size, "name" " nb_components" " nb_bits");
  1258. } else {
  1259. const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[pix_fmt];
  1260. snprintf(buf, buf_size, "%-11s %7d %10d", pixdesc->name,
  1261. pixdesc->nb_components, av_get_bits_per_pixel(pixdesc));
  1262. }
  1263. return buf;
  1264. }