]> git.sesse.net Git - vlc/blob - modules/video_filter/filter_picture.h
Validate input chroma in transform filter, make it work with Packed YUV (tested with...
[vlc] / modules / video_filter / filter_picture.h
1 /*****************************************************************************
2  * filter_picture.h: Common picture functions for filters
3  *****************************************************************************
4  * Copyright (C) 2007 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Antoine Cellerier <dionoea at videolan dot org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #define CASE_PLANAR_YUV                     \
25         case VLC_FOURCC('I','4','2','0'):   \
26         case VLC_FOURCC('I','Y','U','V'):   \
27         case VLC_FOURCC('J','4','2','0'):   \
28         case VLC_FOURCC('Y','V','1','2'):   \
29         case VLC_FOURCC('I','4','1','1'):   \
30         case VLC_FOURCC('I','4','1','0'):   \
31         case VLC_FOURCC('Y','V','U','9'):   \
32         case VLC_FOURCC('I','4','2','2'):   \
33         case VLC_FOURCC('J','4','2','2'):   \
34         case VLC_FOURCC('I','4','4','4'):   \
35         case VLC_FOURCC('J','4','4','4'):   \
36         case VLC_FOURCC('Y','U','V','A'):
37
38 #define CASE_PACKED_YUV_422                 \
39         case VLC_FOURCC('U','Y','V','Y'):   \
40         case VLC_FOURCC('U','Y','N','V'):   \
41         case VLC_FOURCC('Y','4','2','2'):   \
42         case VLC_FOURCC('c','y','u','v'):   \
43         case VLC_FOURCC('Y','U','Y','2'):   \
44         case VLC_FOURCC('Y','U','N','V'):   \
45         case VLC_FOURCC('Y','V','Y','U'):
46
47 static inline int GetPackedYuvOffsets( vlc_fourcc_t i_chroma,
48     int *i_y_offset, int *i_u_offset, int *i_v_offset )
49 {
50     switch( i_chroma )
51     {
52         case VLC_FOURCC('U','Y','V','Y'):
53         case VLC_FOURCC('U','Y','N','V'):
54         case VLC_FOURCC('Y','4','2','2'):
55         case VLC_FOURCC('c','y','u','v'): /* <-- FIXME: reverted, whatever that means */
56             /* UYVY */
57             *i_y_offset = 1;
58             *i_u_offset = 0;
59             *i_v_offset = 2;
60             return VLC_SUCCESS;
61         case VLC_FOURCC('Y','U','Y','2'):
62         case VLC_FOURCC('Y','U','N','V'):
63             /* YUYV */
64             *i_y_offset = 0;
65             *i_u_offset = 1;
66             *i_v_offset = 3;
67             return VLC_SUCCESS;
68         case VLC_FOURCC('Y','V','Y','U'):
69             /* YVYU */
70             *i_y_offset = 0;
71             *i_u_offset = 3;
72             *i_v_offset = 1;
73             return VLC_SUCCESS;
74         default:
75             return VLC_EGENERIC;
76     }
77 }