]> git.sesse.net Git - vlc/blob - include/vlc_filter.h
Chroma modules now exactly implement the "video filter2" capability.
[vlc] / include / vlc_filter.h
1 /*****************************************************************************
2  * vlc_filter.h: filter related structures
3  *****************************************************************************
4  * Copyright (C) 1999-2003 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Gildas Bazin <gbazin@videolan.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 #if !defined( __LIBVLC__ )
25   #error You are not libvlc or one of its plugins. You cannot include this file
26 #endif
27
28 #ifndef _VLC_FILTER_H
29 #define _VLC_FILTER_H 1
30
31 #include <vlc_es.h>
32
33 /**
34  * \file
35  * This file defines the structure and types used by video and audio filters
36  */
37
38 typedef struct filter_owner_sys_t filter_owner_sys_t;
39
40 /** Structure describing a filter
41  * @warning BIG FAT WARNING : the code relies in the first 4 members of
42  * filter_t and decoder_t to be the same, so if you have anything to add,
43  * do it at the end of the structure.
44  */
45 struct filter_t
46 {
47     VLC_COMMON_MEMBERS
48
49     /* Module properties */
50     module_t *          p_module;
51     filter_sys_t *      p_sys;
52
53     /* Input format */
54     es_format_t         fmt_in;
55
56     /* Output format of filter */
57     es_format_t         fmt_out;
58
59     /* Filter configuration */
60     config_chain_t *    p_cfg;
61
62     picture_t *         ( * pf_video_filter ) ( filter_t *, picture_t * );
63     block_t *           ( * pf_audio_filter ) ( filter_t *, block_t * );
64     void                ( * pf_video_blend )  ( filter_t *, picture_t *,
65                                                 picture_t *, picture_t *,
66                                                 int, int, int );
67
68     subpicture_t *      ( *pf_sub_filter ) ( filter_t *, mtime_t );
69     int                 ( *pf_render_text ) ( filter_t *, subpicture_region_t *,
70                                               subpicture_region_t * );
71     int                 ( *pf_render_html ) ( filter_t *, subpicture_region_t *,
72                                               subpicture_region_t * );
73
74     /*
75      * Buffers allocation
76      */
77
78     /* Audio output callbacks */
79     block_t *       ( * pf_audio_buffer_new) ( filter_t *, int );
80
81     /* Video output callbacks */
82     picture_t     * ( * pf_vout_buffer_new) ( filter_t * );
83     void            ( * pf_vout_buffer_del) ( filter_t *, picture_t * );
84     void            ( * pf_picture_link)    ( picture_t * );
85     void            ( * pf_picture_unlink)  ( picture_t * );
86
87     /* SPU output callbacks */
88     subpicture_t *  ( * pf_sub_buffer_new) ( filter_t * );
89     void            ( * pf_sub_buffer_del) ( filter_t *, subpicture_t * );
90
91     /* Private structure for the owner of the decoder */
92     filter_owner_sys_t *p_owner;
93 };
94
95
96 /**
97  * Create a picture_t *(*)( filter_t *, picture_t * ) compatible wrapper
98  * using a void (*)( filter_t *, picture_t *, picture_t * ) function
99  *
100  * Currently used by the chroma video filters
101  */
102 #define VIDEO_FILTER_WRAPPER( name )                                    \
103     static picture_t *name ## _Filter ( filter_t *p_filter,             \
104                                         picture_t *p_pic )              \
105     {                                                                   \
106         picture_t *p_outpic = p_filter->pf_vout_buffer_new( p_filter ); \
107         if( !p_outpic )                                                 \
108         {                                                               \
109             msg_Warn( p_filter, "can't get output picture" );           \
110             if( p_pic->pf_release )                                     \
111                 p_pic->pf_release( p_pic );                             \
112             return NULL;                                                \
113         }                                                               \
114                                                                         \
115         name( p_filter, p_pic, p_outpic );                              \
116                                                                         \
117         p_outpic->date = p_pic->date;                                   \
118         p_outpic->b_force = p_pic->b_force;                             \
119         p_outpic->i_nb_fields = p_pic->i_nb_fields;                     \
120         p_outpic->b_progressive = p_pic->b_progressive;                 \
121         p_outpic->b_top_field_first = p_pic->b_top_field_first;         \
122                                                                         \
123         if( p_pic->pf_release )                                         \
124             p_pic->pf_release( p_pic );                                 \
125         return p_outpic;                                                \
126     }
127
128 #endif /* _VLC_FILTER_H */