Add 8088flex TMV video decoder.
[ffmpeg.git] / libavcodec / pixdesc.c
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
22 #include "libavutil/pixfmt.h"
23 #include "pixdesc.h"
24
25 const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
26     [PIX_FMT_YUV420P] = {
27         .name = "yuv420p",
28         .nb_channels  = 3,
29         .log2_chroma_w= 1,
30         .log2_chroma_h= 1,
31         .comp = {
32             {0,0,1,0,7},        /* Y */
33             {1,0,1,0,7},        /* U */
34             {2,0,1,0,7},        /* V */
35         },
36     },
37     [PIX_FMT_YUYV422] = {
38         .name = "yuyv422",
39         .nb_channels  = 3,
40         .log2_chroma_w= 1,
41         .log2_chroma_h= 0,
42         .comp = {
43             {0,1,1,0,7},        /* Y */
44             {0,3,2,0,7},        /* U */
45             {0,3,4,0,7},        /* V */
46         },
47     },
48     [PIX_FMT_RGB24] = {
49         .name = "rgb24",
50         .nb_channels  = 3,
51         .log2_chroma_w= 0,
52         .log2_chroma_h= 0,
53         .comp = {
54             {0,2,1,0,7},        /* R */
55             {0,2,2,0,7},        /* G */
56             {0,2,3,0,7},        /* B */
57         },
58     },
59     [PIX_FMT_BGR24] = {
60         .name = "bgr24",
61         .nb_channels  = 3,
62         .log2_chroma_w= 0,
63         .log2_chroma_h= 0,
64         .comp = {
65             {0,2,1,0,7},        /* B */
66             {0,2,2,0,7},        /* G */
67             {0,2,3,0,7},        /* R */
68         },
69     },
70     [PIX_FMT_YUV422P] = {
71         .name = "yuv422p",
72         .nb_channels  = 3,
73         .log2_chroma_w= 1,
74         .log2_chroma_h= 0,
75         .comp = {
76             {0,0,1,0,7},        /* Y */
77             {1,0,1,0,7},        /* U */
78             {2,0,1,0,7},        /* V */
79         },
80     },
81     [PIX_FMT_YUV444P] = {
82         .name = "yuv444p",
83         .nb_channels  = 3,
84         .log2_chroma_w= 0,
85         .log2_chroma_h= 0,
86         .comp = {
87             {0,0,1,0,7},        /* Y */
88             {1,0,1,0,7},        /* U */
89             {2,0,1,0,7},        /* V */
90         },
91     },
92     [PIX_FMT_YUV410P] = {
93         .name = "yuv410p",
94         .nb_channels  = 3,
95         .log2_chroma_w= 2,
96         .log2_chroma_h= 2,
97         .comp = {
98             {0,0,1,0,7},        /* Y */
99             {1,0,1,0,7},        /* U */
100             {2,0,1,0,7},        /* V */
101         },
102     },
103     [PIX_FMT_YUV411P] = {
104         .name = "yuv411p",
105         .nb_channels  = 3,
106         .log2_chroma_w= 2,
107         .log2_chroma_h= 0,
108         .comp = {
109             {0,0,1,0,7},        /* Y */
110             {1,0,1,0,7},        /* U */
111             {2,0,1,0,7},        /* V */
112         },
113     },
114     [PIX_FMT_GRAY8] = {
115         .name = "gray8",
116         .nb_channels  = 1,
117         .log2_chroma_w= 0,
118         .log2_chroma_h= 0,
119         .comp = {
120             {0,0,1,0,7},        /* Y */
121         },
122     },
123     [PIX_FMT_MONOWHITE] = {
124         .name = "monowhite",
125         .nb_channels  = 1,
126         .log2_chroma_w= 0,
127         .log2_chroma_h= 0,
128         .comp = {
129             {0,0,1,0,0},        /* Y */
130         },
131         .flags = PIX_FMT_BITSTREAM,
132     },
133     [PIX_FMT_MONOBLACK] = {
134         .name = "monoblack",
135         .nb_channels  = 1,
136         .log2_chroma_w= 0,
137         .log2_chroma_h= 0,
138         .comp = {
139             {0,0,1,7,0},        /* Y */
140         },
141         .flags = PIX_FMT_BITSTREAM,
142     },
143     [PIX_FMT_PAL8] = {
144         .name = "pal8",
145         .nb_channels  = 1,
146         .log2_chroma_w= 0,
147         .log2_chroma_h= 0,
148         .comp = {
149             {0,0,1,0,7},
150         },
151         .flags = PIX_FMT_PAL,
152     },
153     [PIX_FMT_YUVJ420P] = {
154         .name = "yuvj420p",
155         .nb_channels  = 3,
156         .log2_chroma_w= 1,
157         .log2_chroma_h= 1,
158         .comp = {
159             {0,0,1,0,7},        /* Y */
160             {1,0,1,0,7},        /* U */
161             {2,0,1,0,7},        /* V */
162         },
163     },
164     [PIX_FMT_YUVJ422P] = {
165         .name = "yuvj422p",
166         .nb_channels  = 3,
167         .log2_chroma_w= 1,
168         .log2_chroma_h= 0,
169         .comp = {
170             {0,0,1,0,7},        /* Y */
171             {1,0,1,0,7},        /* U */
172             {2,0,1,0,7},        /* V */
173         },
174     },
175     [PIX_FMT_YUVJ444P] = {
176         .name = "yuvj444p",
177         .nb_channels  = 3,
178         .log2_chroma_w= 0,
179         .log2_chroma_h= 0,
180         .comp = {
181             {0,0,1,0,7},        /* Y */
182             {1,0,1,0,7},        /* U */
183             {2,0,1,0,7},        /* V */
184         },
185     },
186     [PIX_FMT_UYVY422] = {
187         .name = "uyvy422",
188         .nb_channels  = 3,
189         .log2_chroma_w= 1,
190         .log2_chroma_h= 0,
191         .comp = {
192             {0,1,2,0,7},        /* Y */
193             {0,3,1,0,7},        /* U */
194             {0,3,3,0,7},        /* V */
195         },
196     },
197     [PIX_FMT_UYYVYY411] = {
198         .name = "uyyvyy411",
199         .nb_channels  = 3,
200         .log2_chroma_w= 2,
201         .log2_chroma_h= 0,
202         .comp = {
203             {0,3,2,0,7},        /* Y */
204             {0,5,1,0,7},        /* U */
205             {0,5,4,0,7},        /* V */
206         },
207     },
208     [PIX_FMT_BGR8] = {
209         .name = "bgr8",
210         .nb_channels  = 3,
211         .log2_chroma_w= 0,
212         .log2_chroma_h= 0,
213         .comp = {
214             {0,0,1,6,1},        /* B */
215             {0,0,1,3,2},        /* G */
216             {0,0,1,0,2},        /* R */
217         },
218     },
219     [PIX_FMT_BGR4] = {
220         .name = "bgr4",
221         .nb_channels  = 3,
222         .log2_chroma_w= 0,
223         .log2_chroma_h= 0,
224         .comp = {
225             {0,3,1,0,0},        /* B */
226             {0,3,2,0,1},        /* G */
227             {0,3,4,0,0},        /* R */
228         },
229         .flags = PIX_FMT_BITSTREAM,
230     },
231     [PIX_FMT_BGR4_BYTE] = {
232         .name = "bgr4_byte",
233         .nb_channels  = 3,
234         .log2_chroma_w= 0,
235         .log2_chroma_h= 0,
236         .comp = {
237             {0,0,1,3,0},        /* B */
238             {0,0,1,1,1},        /* G */
239             {0,0,1,0,0},        /* R */
240         },
241     },
242     [PIX_FMT_RGB8] = {
243         .name = "rgb8",
244         .nb_channels  = 3,
245         .log2_chroma_w= 0,
246         .log2_chroma_h= 0,
247         .comp = {
248             {0,0,1,6,1},        /* R */
249             {0,0,1,3,2},        /* G */
250             {0,0,1,0,2},        /* B */
251         },
252     },
253     [PIX_FMT_RGB4] = {
254         .name = "rgb4",
255         .nb_channels  = 3,
256         .log2_chroma_w= 0,
257         .log2_chroma_h= 0,
258         .comp = {
259             {0,3,1,0,0},       /* R */
260             {0,3,2,0,1},       /* G */
261             {0,3,4,0,0},       /* B */
262         },
263         .flags = PIX_FMT_BITSTREAM,
264     },
265     [PIX_FMT_RGB4_BYTE] = {
266         .name = "rgb4_byte",
267         .nb_channels  = 3,
268         .log2_chroma_w= 0,
269         .log2_chroma_h= 0,
270         .comp = {
271             {0,0,1,3,0},        /* R */
272             {0,0,1,1,1},        /* G */
273             {0,0,1,0,0},        /* B */
274         },
275     },
276     [PIX_FMT_NV12] = {
277         .name = "nv12",
278         .nb_channels  = 3,
279         .log2_chroma_w= 1,
280         .log2_chroma_h= 1,
281         .comp = {
282             {0,0,1,0,7},        /* Y */
283             {1,1,1,0,7},        /* U */
284             {1,1,2,0,7},        /* V */
285         },
286     },
287     [PIX_FMT_NV21] = {
288         .name = "nv21",
289         .nb_channels  = 3,
290         .log2_chroma_w= 1,
291         .log2_chroma_h= 1,
292         .comp = {
293             {0,0,1,0,7},        /* Y */
294             {1,1,1,0,7},        /* V */
295             {1,1,2,0,7},        /* U */
296         },
297     },
298     [PIX_FMT_ARGB] = {
299         .name = "argb",
300         .nb_channels  = 4,
301         .log2_chroma_w= 0,
302         .log2_chroma_h= 0,
303         .comp = {
304             {0,3,1,0,7},        /* A */
305             {0,3,2,0,7},        /* R */
306             {0,3,3,0,7},        /* G */
307             {0,3,4,0,7},        /* B */
308         },
309     },
310     [PIX_FMT_RGBA] = {
311         .name = "rgba",
312         .nb_channels  = 4,
313         .log2_chroma_w= 0,
314         .log2_chroma_h= 0,
315         .comp = {
316             {0,3,1,0,7},        /* R */
317             {0,3,2,0,7},        /* G */
318             {0,3,3,0,7},        /* B */
319             {0,3,4,0,7},        /* A */
320         },
321     },
322     [PIX_FMT_ABGR] = {
323         .name = "abgr",
324         .nb_channels  = 4,
325         .log2_chroma_w= 0,
326         .log2_chroma_h= 0,
327         .comp = {
328             {0,3,1,0,7},        /* A */
329             {0,3,2,0,7},        /* B */
330             {0,3,3,0,7},        /* G */
331             {0,3,4,0,7},        /* R */
332         },
333     },
334     [PIX_FMT_BGRA] = {
335         .name = "bgra",
336         .nb_channels  = 4,
337         .log2_chroma_w= 0,
338         .log2_chroma_h= 0,
339         .comp = {
340             {0,3,1,0,7},        /* B */
341             {0,3,2,0,7},        /* G */
342             {0,3,3,0,7},        /* R */
343             {0,3,4,0,7},        /* A */
344         },
345     },
346     [PIX_FMT_GRAY16BE] = {
347         .name = "gray16be",
348         .nb_channels  = 1,
349         .log2_chroma_w= 0,
350         .log2_chroma_h= 0,
351         .comp = {
352             {0,1,1,0,15},       /* Y */
353         },
354         .flags = PIX_FMT_BE,
355     },
356     [PIX_FMT_GRAY16LE] = {
357         .name = "gray16le",
358         .nb_channels  = 1,
359         .log2_chroma_w= 0,
360         .log2_chroma_h= 0,
361         .comp = {
362             {0,1,1,0,15},       /* Y */
363         },
364     },
365     [PIX_FMT_YUV440P] = {
366         .name = "yuv440p",
367         .nb_channels  = 3,
368         .log2_chroma_w= 0,
369         .log2_chroma_h= 1,
370         .comp = {
371             {0,0,1,0,7},        /* Y */
372             {1,0,1,0,7},        /* U */
373             {2,0,1,0,7},        /* V */
374         },
375     },
376     [PIX_FMT_YUVJ440P] = {
377         .name = "yuvj440p",
378         .nb_channels  = 3,
379         .log2_chroma_w= 0,
380         .log2_chroma_h= 1,
381         .comp = {
382             {0,0,1,0,7},        /* Y */
383             {1,0,1,0,7},        /* U */
384             {2,0,1,0,7},        /* V */
385         },
386     },
387     [PIX_FMT_YUVA420P] = {
388         .name = "yuva420p",
389         .nb_channels  = 4,
390         .log2_chroma_w= 1,
391         .log2_chroma_h= 1,
392         .comp = {
393             {0,0,1,0,7},        /* Y */
394             {1,0,1,0,7},        /* U */
395             {2,0,1,0,7},        /* V */
396             {3,0,1,0,7},        /* A */
397         },
398     },
399     [PIX_FMT_RGB48BE] = {
400         .name = "rgb48be",
401         .nb_channels  = 3,
402         .log2_chroma_w= 0,
403         .log2_chroma_h= 0,
404         .comp = {
405             {0,5,1,0,15},       /* R */
406             {0,5,3,0,15},       /* G */
407             {0,5,5,0,15},       /* B */
408         },
409         .flags = PIX_FMT_BE,
410     },
411     [PIX_FMT_RGB48LE] = {
412         .name = "rgb48le",
413         .nb_channels  = 3,
414         .log2_chroma_w= 0,
415         .log2_chroma_h= 0,
416         .comp = {
417             {0,5,1,0,15},       /* R */
418             {0,5,3,0,15},       /* G */
419             {0,5,5,0,15},       /* B */
420         },
421     },
422     [PIX_FMT_RGB565BE] = {
423         .name = "rgb565be",
424         .nb_channels  = 3,
425         .log2_chroma_w= 0,
426         .log2_chroma_h= 0,
427         .comp = {
428             {0,1,0,3,4},        /* R */
429             {0,1,1,5,5},        /* G */
430             {0,1,1,0,4},        /* B */
431         },
432         .flags = PIX_FMT_BE,
433     },
434     [PIX_FMT_RGB565LE] = {
435         .name = "rgb565le",
436         .nb_channels  = 3,
437         .log2_chroma_w= 0,
438         .log2_chroma_h= 0,
439         .comp = {
440             {0,1,2,3,4},        /* R */
441             {0,1,1,5,5},        /* G */
442             {0,1,1,0,4},        /* B */
443         },
444     },
445     [PIX_FMT_RGB555BE] = {
446         .name = "rgb555be",
447         .nb_channels  = 3,
448         .log2_chroma_w= 0,
449         .log2_chroma_h= 0,
450         .comp = {
451             {0,1,0,2,4},        /* R */
452             {0,1,1,5,4},        /* G */
453             {0,1,1,0,4},        /* B */
454         },
455         .flags = PIX_FMT_BE,
456     },
457     [PIX_FMT_RGB555LE] = {
458         .name = "rgb555le",
459         .nb_channels  = 3,
460         .log2_chroma_w= 0,
461         .log2_chroma_h= 0,
462         .comp = {
463             {0,1,2,2,4},        /* R */
464             {0,1,1,5,4},        /* G */
465             {0,1,1,0,4},        /* B */
466         },
467     },
468     [PIX_FMT_BGR565BE] = {
469         .name = "bgr565be",
470         .nb_channels  = 3,
471         .log2_chroma_w= 0,
472         .log2_chroma_h= 0,
473         .comp = {
474             {0,1,0,3,4},        /* B */
475             {0,1,1,5,5},        /* G */
476             {0,1,1,0,4},        /* R */
477         },
478         .flags = PIX_FMT_BE,
479     },
480     [PIX_FMT_BGR565LE] = {
481         .name = "bgr565le",
482         .nb_channels  = 3,
483         .log2_chroma_w= 0,
484         .log2_chroma_h= 0,
485         .comp = {
486             {0,1,2,3,4},        /* B */
487             {0,1,1,5,5},        /* G */
488             {0,1,1,0,4},        /* R */
489         },
490     },
491     [PIX_FMT_BGR555BE] = {
492         .name = "bgr555be",
493         .nb_channels  = 3,
494         .log2_chroma_w= 0,
495         .log2_chroma_h= 0,
496         .comp = {
497             {0,1,0,2,4},       /* B */
498             {0,1,1,5,4},       /* G */
499             {0,1,1,0,4},       /* R */
500         },
501         .flags = PIX_FMT_BE,
502      },
503     [PIX_FMT_BGR555LE] = {
504         .name = "bgr555le",
505         .nb_channels  = 3,
506         .log2_chroma_w= 0,
507         .log2_chroma_h= 0,
508         .comp = {
509             {0,1,2,2,4},        /* B */
510             {0,1,1,5,4},        /* G */
511             {0,1,1,0,4},        /* R */
512         },
513     },
514     [PIX_FMT_YUV420PLE] = {
515         .name = "yuv420ple",
516         .nb_channels  = 3,
517         .log2_chroma_w= 1,
518         .log2_chroma_h= 1,
519         .comp = {
520             {0,1,1,0,15},        /* Y */
521             {1,1,1,0,15},        /* U */
522             {2,1,1,0,15},        /* V */
523         },
524     },
525     [PIX_FMT_YUV420PBE] = {
526         .name = "yuv420pbe",
527         .nb_channels  = 3,
528         .log2_chroma_w= 1,
529         .log2_chroma_h= 1,
530         .comp = {
531             {0,1,1,0,15},        /* Y */
532             {1,1,1,0,15},        /* U */
533             {2,1,1,0,15},        /* V */
534         },
535         .flags = PIX_FMT_BE,
536     },
537     [PIX_FMT_YUV422PLE] = {
538         .name = "yuv422ple",
539         .nb_channels  = 3,
540         .log2_chroma_w= 1,
541         .log2_chroma_h= 0,
542         .comp = {
543             {0,1,1,0,15},        /* Y */
544             {1,1,1,0,15},        /* U */
545             {2,1,1,0,15},        /* V */
546         },
547     },
548     [PIX_FMT_YUV422PBE] = {
549         .name = "yuv422pbe",
550         .nb_channels  = 3,
551         .log2_chroma_w= 1,
552         .log2_chroma_h= 0,
553         .comp = {
554             {0,1,1,0,15},        /* Y */
555             {1,1,1,0,15},        /* U */
556             {2,1,1,0,15},        /* V */
557         },
558         .flags = PIX_FMT_BE,
559     },
560     [PIX_FMT_YUV444PLE] = {
561         .name = "yuv444ple",
562         .nb_channels  = 3,
563         .log2_chroma_w= 0,
564         .log2_chroma_h= 0,
565         .comp = {
566             {0,1,1,0,15},        /* Y */
567             {1,1,1,0,15},        /* U */
568             {2,1,1,0,15},        /* V */
569         },
570     },
571     [PIX_FMT_YUV444PBE] = {
572         .name = "yuv444pbe",
573         .nb_channels  = 3,
574         .log2_chroma_w= 0,
575         .log2_chroma_h= 0,
576         .comp = {
577             {0,1,1,0,15},        /* Y */
578             {1,1,1,0,15},        /* U */
579             {2,1,1,0,15},        /* V */
580         },
581         .flags = PIX_FMT_BE,
582     },
583 };
584
585 int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
586 {
587     int c, bits = 0;
588     int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h;
589
590     for (c = 0; c < pixdesc->nb_channels; c++) {
591         int s = c==1 || c==2 ? 0 : log2_pixels;
592         bits += (pixdesc->comp[c].depth_minus1+1) << s;
593     }
594
595     return bits >> log2_pixels;
596 }