220b1bd245b6bc19aee42b3e0dfab40555e35e22
[libav.git] / libavcodec / libaom.c
1 /*
2 * Copyright (c) 2013 Guillaume Martres <smarter@ubuntu.com>
3 *
4 * This file is part of Libav.
5 *
6 * Libav is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * Libav is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Libav; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include <aom/aom_image.h>
22
23 #include "libaom.h"
24
25 #define HIGH_DEPTH(fmt) \
26 case AOM_IMG_FMT_I ## fmt ## 16: \
27 switch (depth) { \
28 case 8: \
29 return AV_PIX_FMT_YUV ## fmt ## P; \
30 case 10: \
31 return AV_PIX_FMT_YUV ## fmt ## P10; \
32 case 12: \
33 return AV_PIX_FMT_YUV ## fmt ## P12; \
34 default: \
35 return AV_PIX_FMT_NONE; \
36 }
37
38 enum AVPixelFormat ff_aom_imgfmt_to_pixfmt(aom_img_fmt_t img, int depth)
39 {
40 switch (img) {
41 case AOM_IMG_FMT_RGB24:
42 return AV_PIX_FMT_RGB24;
43 case AOM_IMG_FMT_RGB565:
44 return AV_PIX_FMT_RGB565BE;
45 case AOM_IMG_FMT_RGB555:
46 return AV_PIX_FMT_RGB555BE;
47 case AOM_IMG_FMT_UYVY:
48 return AV_PIX_FMT_UYVY422;
49 case AOM_IMG_FMT_YUY2:
50 return AV_PIX_FMT_YUYV422;
51 case AOM_IMG_FMT_YVYU:
52 return AV_PIX_FMT_YVYU422;
53 case AOM_IMG_FMT_BGR24:
54 return AV_PIX_FMT_BGR24;
55 case AOM_IMG_FMT_ARGB:
56 return AV_PIX_FMT_ARGB;
57 case AOM_IMG_FMT_ARGB_LE:
58 return AV_PIX_FMT_BGRA;
59 case AOM_IMG_FMT_RGB565_LE:
60 return AV_PIX_FMT_RGB565LE;
61 case AOM_IMG_FMT_RGB555_LE:
62 return AV_PIX_FMT_RGB555LE;
63 case AOM_IMG_FMT_I420:
64 return AV_PIX_FMT_YUV420P;
65 case AOM_IMG_FMT_I422:
66 return AV_PIX_FMT_YUV422P;
67 case AOM_IMG_FMT_I444:
68 return AV_PIX_FMT_YUV444P;
69 case AOM_IMG_FMT_444A:
70 return AV_PIX_FMT_YUVA444P;
71 case AOM_IMG_FMT_I440:
72 return AV_PIX_FMT_YUV440P;
73 HIGH_DEPTH(420)
74 HIGH_DEPTH(422)
75 HIGH_DEPTH(444)
76 default:
77 return AV_PIX_FMT_NONE;
78 }
79 }
80
81 #undef HIGH_DEPTH
82
83 aom_img_fmt_t ff_aom_pixfmt_to_imgfmt(enum AVPixelFormat pix)
84 {
85 switch (pix) {
86 case AV_PIX_FMT_RGB24:
87 return AOM_IMG_FMT_RGB24;
88 case AV_PIX_FMT_RGB565BE:
89 return AOM_IMG_FMT_RGB565;
90 case AV_PIX_FMT_RGB555BE:
91 return AOM_IMG_FMT_RGB555;
92 case AV_PIX_FMT_UYVY422:
93 return AOM_IMG_FMT_UYVY;
94 case AV_PIX_FMT_YUYV422:
95 return AOM_IMG_FMT_YUY2;
96 case AV_PIX_FMT_YVYU422:
97 return AOM_IMG_FMT_YVYU;
98 case AV_PIX_FMT_BGR24:
99 return AOM_IMG_FMT_BGR24;
100 case AV_PIX_FMT_ARGB:
101 return AOM_IMG_FMT_ARGB;
102 case AV_PIX_FMT_BGRA:
103 return AOM_IMG_FMT_ARGB_LE;
104 case AV_PIX_FMT_RGB565LE:
105 return AOM_IMG_FMT_RGB565_LE;
106 case AV_PIX_FMT_RGB555LE:
107 return AOM_IMG_FMT_RGB555_LE;
108 case AV_PIX_FMT_YUV420P:
109 return AOM_IMG_FMT_I420;
110 case AV_PIX_FMT_YUV422P:
111 return AOM_IMG_FMT_I422;
112 case AV_PIX_FMT_YUV444P:
113 return AOM_IMG_FMT_I444;
114 case AV_PIX_FMT_YUVA444P:
115 return AOM_IMG_FMT_444A;
116 case AV_PIX_FMT_YUV440P:
117 return AOM_IMG_FMT_I440;
118 case AV_PIX_FMT_YUV420P10:
119 return AOM_IMG_FMT_I42016;
120 case AV_PIX_FMT_YUV422P10:
121 return AOM_IMG_FMT_I42216;
122 case AV_PIX_FMT_YUV444P10:
123 return AOM_IMG_FMT_I44416;
124 case AV_PIX_FMT_YUV420P12:
125 return AOM_IMG_FMT_I42016;
126 case AV_PIX_FMT_YUV422P12:
127 return AOM_IMG_FMT_I42216;
128 case AV_PIX_FMT_YUV444P12:
129 return AOM_IMG_FMT_I44416;
130 default:
131 return AOM_IMG_FMT_NONE;
132 }
133 }