]> git.sesse.net Git - vlc/blob - modules/video_filter/filter_picture.h
b39a26637c9b0e9e036aff5363016757cc8fd854
[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 /* FIXME: do all of these really have square pixels? */
25 #define CASE_PLANAR_YUV_SQUARE              \
26         case VLC_FOURCC('I','4','2','0'):   \
27         case VLC_FOURCC('I','Y','U','V'):   \
28         case VLC_FOURCC('J','4','2','0'):   \
29         case VLC_FOURCC('Y','V','1','2'):   \
30         case VLC_FOURCC('I','4','1','1'):   \
31         case VLC_FOURCC('I','4','1','0'):   \
32         case VLC_FOURCC('Y','V','U','9'):   \
33         case VLC_FOURCC('I','4','4','4'):   \
34         case VLC_FOURCC('J','4','4','4'):   \
35         case VLC_FOURCC('Y','U','V','A'):
36
37 #define CASE_PLANAR_YUV_NONSQUARE           \
38         case VLC_FOURCC('I','4','2','2'):   \
39         case VLC_FOURCC('J','4','2','2'):
40
41 #define CASE_PLANAR_YUV                     \
42         CASE_PLANAR_YUV_SQUARE              \
43         CASE_PLANAR_YUV_NONSQUARE           \
44
45 #define CASE_PACKED_YUV_422                 \
46         case VLC_FOURCC('U','Y','V','Y'):   \
47         case VLC_FOURCC('U','Y','N','V'):   \
48         case VLC_FOURCC('Y','4','2','2'):   \
49         case VLC_FOURCC('c','y','u','v'):   \
50         case VLC_FOURCC('Y','U','Y','2'):   \
51         case VLC_FOURCC('Y','U','N','V'):   \
52         case VLC_FOURCC('Y','V','Y','U'):
53
54 static inline int GetPackedYuvOffsets( vlc_fourcc_t i_chroma,
55     int *i_y_offset, int *i_u_offset, int *i_v_offset )
56 {
57     switch( i_chroma )
58     {
59         case VLC_FOURCC('U','Y','V','Y'):
60         case VLC_FOURCC('U','Y','N','V'):
61         case VLC_FOURCC('Y','4','2','2'):
62         case VLC_FOURCC('c','y','u','v'): /* <-- FIXME: reverted, whatever that means */
63             /* UYVY */
64             *i_y_offset = 1;
65             *i_u_offset = 0;
66             *i_v_offset = 2;
67             return VLC_SUCCESS;
68         case VLC_FOURCC('Y','U','Y','2'):
69         case VLC_FOURCC('Y','U','N','V'):
70             /* YUYV */
71             *i_y_offset = 0;
72             *i_u_offset = 1;
73             *i_v_offset = 3;
74             return VLC_SUCCESS;
75         case VLC_FOURCC('Y','V','Y','U'):
76             /* YVYU */
77             *i_y_offset = 0;
78             *i_u_offset = 3;
79             *i_v_offset = 1;
80             return VLC_SUCCESS;
81         default:
82             return VLC_EGENERIC;
83     }
84 }
85
86 /*****************************************************************************
87  *
88  *****************************************************************************/
89 static inline picture_t *CopyInfoAndRelease( picture_t *p_outpic, picture_t *p_inpic )
90 {
91     picture_CopyProperties( p_outpic, p_inpic );
92
93     picture_Release( p_inpic );
94
95     return p_outpic;
96 }