1 /*****************************************************************************
2 * chroma.h: libavutil <-> libvlc conversion routines
3 *****************************************************************************
4 * Copyright (C) 1999-2008 the VideoLAN team
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8 * Gildas Bazin <gbazin@videolan.org>
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.
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.
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 *****************************************************************************/
25 /*****************************************************************************
26 * Chroma fourcc -> ffmpeg_id mapping
27 *****************************************************************************/
29 #define VLC_FF( fcc, fav ) \
30 { VLC_FOURCC fcc, fav }
32 #if defined(WORDS_BIGENDIAN)
33 # define VLC_FF_RGB_DEFAULT( fcc, le, be ) VLC_FF( fcc, be )
35 # define VLC_FF_RGB_DEFAULT( fcc, le, be ) VLC_FF( fcc, le )
40 vlc_fourcc_t i_chroma;
45 /* Planar YUV formats */
46 VLC_FF( ('Y','U','V','A'), PIX_FMT_YUV444P ), /* Hack */
48 VLC_FF( ('I','4','4','4'), PIX_FMT_YUV444P ),
49 VLC_FF( ('J','4','4','4'), PIX_FMT_YUVJ444P ),
51 VLC_FF( ('I','4','2','2'), PIX_FMT_YUV422P ),
52 VLC_FF( ('J','4','2','2'), PIX_FMT_YUVJ422P ),
54 VLC_FF( ('I','4','2','0'), PIX_FMT_YUV420P ),
55 VLC_FF( ('Y','V','1','2'), PIX_FMT_YUV420P ),
56 VLC_FF( ('I','Y','U','V'), PIX_FMT_YUV420P ),
57 VLC_FF( ('J','4','2','0'), PIX_FMT_YUVJ420P ),
58 VLC_FF( ('I','4','1','1'), PIX_FMT_YUV411P ),
59 VLC_FF( ('I','4','1','0'), PIX_FMT_YUV410P ),
60 VLC_FF( ('Y','V','U','9'), PIX_FMT_YUV410P ),
62 /* Packed YUV formats */
63 VLC_FF( ('Y','U','Y','2'), PIX_FMT_YUV422 ),
64 VLC_FF( ('Y','U','Y','V'), PIX_FMT_YUV422 ),
65 VLC_FF( ('U','Y','V','Y'), PIX_FMT_UYVY422 ),
67 /* Packed RGB formats */
68 VLC_FF_RGB_DEFAULT( ('R','G','B','8'), PIX_FMT_RGB8, PIX_FMT_BGR8 ),
69 VLC_FF_RGB_DEFAULT( ('R','V','1','5'), PIX_FMT_RGB555, PIX_FMT_BGR555 ),
70 VLC_FF_RGB_DEFAULT( ('R','V','1','6'), PIX_FMT_RGB565, PIX_FMT_BGR565 ),
71 VLC_FF_RGB_DEFAULT( ('R','V','2','4'), PIX_FMT_RGB24, PIX_FMT_BGR24 ),
73 VLC_FF( ('R','V','3','2'), PIX_FMT_RGBA32 ), // FIXME is that wanted
75 #if defined(PIX_FMT_RGBA)
76 VLC_FF( ('R','G','B','A'), PIX_FMT_RGBA ),
78 VLC_FF( ('G','R','E','Y'), PIX_FMT_GRAY8 ),
83 static inline int GetFfmpegChroma( vlc_fourcc_t i_chroma )
87 for( i = 0; chroma_table[i].i_chroma != 0; i++ )
89 if( chroma_table[i].i_chroma == i_chroma )
90 return chroma_table[i].i_chroma_id;
95 static inline vlc_fourcc_t GetVlcChroma( int i_ffmpeg_chroma )
99 /* TODO FIXME for rgb format we HAVE to set rgb mask/shift */
100 for( i = 0; chroma_table[i].i_chroma != 0; i++ )
102 if( chroma_table[i].i_chroma_id == i_ffmpeg_chroma )
103 return chroma_table[i].i_chroma;