]> git.sesse.net Git - vlc/blob - modules/codec/avcodec/chroma.h
Removed old hack (for YUVA)
[vlc] / modules / codec / avcodec / chroma.h
1 /*****************************************************************************
2  * chroma.h: libavutil <-> libvlc conversion routines
3  *****************************************************************************
4  * Copyright (C) 1999-2008 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8  *          Gildas Bazin <gbazin@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Chroma fourcc -> ffmpeg_id mapping
27  *****************************************************************************/
28
29 #define VLC_FF( fcc, fav ) \
30     { VLC_FOURCC fcc, fav }
31
32 #if defined(WORDS_BIGENDIAN)
33 #   define VLC_FF_RGB_DEFAULT( fcc, le, be ) VLC_FF( fcc, be )
34 #else
35 #   define VLC_FF_RGB_DEFAULT( fcc, le, be ) VLC_FF( fcc, le )
36 #endif
37
38 static const struct
39 {
40     vlc_fourcc_t  i_chroma;
41     int  i_chroma_id;
42
43 } chroma_table[] =
44 {
45     /* Planar YUV formats */
46     VLC_FF( ('I','4','4','4'), PIX_FMT_YUV444P ),
47     VLC_FF( ('J','4','4','4'), PIX_FMT_YUVJ444P ),
48
49     VLC_FF( ('I','4','2','2'), PIX_FMT_YUV422P ),
50     VLC_FF( ('J','4','2','2'), PIX_FMT_YUVJ422P ),
51
52     VLC_FF( ('I','4','2','0'), PIX_FMT_YUV420P ),
53     VLC_FF( ('Y','V','1','2'), PIX_FMT_YUV420P ),
54     VLC_FF( ('I','Y','U','V'), PIX_FMT_YUV420P ),
55     VLC_FF( ('J','4','2','0'), PIX_FMT_YUVJ420P ),
56     VLC_FF( ('I','4','1','1'), PIX_FMT_YUV411P ),
57     VLC_FF( ('I','4','1','0'), PIX_FMT_YUV410P ),
58     VLC_FF( ('Y','V','U','9'), PIX_FMT_YUV410P ),
59
60     /* Packed YUV formats */
61     VLC_FF( ('Y','U','Y','2'), PIX_FMT_YUV422 ),
62     VLC_FF( ('Y','U','Y','V'), PIX_FMT_YUV422 ),
63     VLC_FF( ('U','Y','V','Y'), PIX_FMT_UYVY422 ),
64
65     /* Packed RGB formats */
66     VLC_FF_RGB_DEFAULT( ('R','G','B','8'), PIX_FMT_RGB8,    PIX_FMT_BGR8 ),
67     VLC_FF_RGB_DEFAULT( ('R','V','1','5'), PIX_FMT_RGB555,  PIX_FMT_BGR555 ),
68     VLC_FF_RGB_DEFAULT( ('R','V','1','6'), PIX_FMT_RGB565,  PIX_FMT_BGR565 ),
69     VLC_FF_RGB_DEFAULT( ('R','V','2','4'), PIX_FMT_RGB24,   PIX_FMT_BGR24 ),
70
71     VLC_FF( ('R','V','3','2'), PIX_FMT_RGBA32 ),    // FIXME is that wanted
72
73 #if defined(PIX_FMT_RGBA)
74     VLC_FF( ('R','G','B','A'), PIX_FMT_RGBA ),
75 #endif
76     VLC_FF( ('G','R','E','Y'), PIX_FMT_GRAY8 ),
77
78     { 0, 0 }
79 };
80
81 static inline int GetFfmpegChroma( vlc_fourcc_t i_chroma )
82 {
83     int i;
84
85     for( i = 0; chroma_table[i].i_chroma != 0; i++ )
86     {
87         if( chroma_table[i].i_chroma == i_chroma )
88             return chroma_table[i].i_chroma_id;
89     }
90     return -1;
91 }
92
93 static inline vlc_fourcc_t GetVlcChroma( int i_ffmpeg_chroma )
94 {
95     int i;
96
97     /* TODO FIXME for rgb format we HAVE to set rgb mask/shift */
98     for( i = 0; chroma_table[i].i_chroma != 0; i++ )
99     {
100         if( chroma_table[i].i_chroma_id == i_ffmpeg_chroma )
101             return chroma_table[i].i_chroma;
102     }
103     return 0;
104 }