i18n: missing . at the end of a sentence
[vlc.git] / src / misc / filter.c
blob505b0eddc7905cf713bc52ba86a412d8c1bae482
1 /*****************************************************************************
2 * filter.c : filter_t helpers.
3 *****************************************************************************
4 * Copyright (C) 2009 Laurent Aimar
5 * $Id$
7 * Author: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
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 Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #ifdef HAVE_CONFIG_H
25 # include "config.h"
26 #endif
28 #include <assert.h>
30 #include <vlc_common.h>
31 #include <libvlc.h>
32 #include <vlc_filter.h>
33 #include <vlc_modules.h>
34 #include "../misc/variables.h"
36 /* */
38 static int TriggerFilterCallback(vlc_object_t *p_this, char const *psz_var,
39 vlc_value_t oldval, vlc_value_t newval,
40 void *p_data)
42 (void) p_this; (void) oldval;
43 var_Set((filter_t *)p_data, psz_var, newval);
44 return 0;
47 #undef filter_AddProxyCallbacks
48 void filter_AddProxyCallbacks( vlc_object_t *obj, filter_t *filter,
49 vlc_callback_t restart_cb )
51 char **names = var_GetAllNames(VLC_OBJECT(filter));
52 if (names == NULL)
53 return;
55 for (char **pname = names; *pname != NULL; pname++)
57 char *name = *pname;
58 int var_type = var_Type(filter, name);
59 if (var_Type(obj, name))
61 free(name);
62 continue;
64 var_Create(obj, name,
65 var_type | VLC_VAR_DOINHERIT | VLC_VAR_ISCOMMAND);
66 if ((var_type & VLC_VAR_ISCOMMAND))
67 var_AddCallback(obj, name, TriggerFilterCallback, filter);
68 else
69 var_AddCallback(obj, name, restart_cb, obj);
70 free(name);
72 free(names);
75 #undef filter_DelProxyCallbacks
76 void filter_DelProxyCallbacks( vlc_object_t *obj, filter_t *filter,
77 vlc_callback_t restart_cb )
79 char **names = var_GetAllNames(VLC_OBJECT(filter));
80 if (names == NULL)
81 return;
83 for (char **pname = names; *pname != NULL; pname++)
85 char *name = *pname;
86 if (!(var_Type(obj, name) & VLC_VAR_ISCOMMAND))
88 free(name);
89 continue;
91 int filter_var_type = var_Type(filter, name);
93 if (filter_var_type & VLC_VAR_ISCOMMAND)
94 var_DelCallback(obj, name, TriggerFilterCallback, filter);
95 else if (filter_var_type)
96 var_DelCallback(obj, name, restart_cb, obj);
97 var_Destroy(obj, name);
98 free(name);
100 free(names);
103 /* */
105 filter_t *filter_NewBlend( vlc_object_t *p_this,
106 const video_format_t *p_dst_chroma )
108 filter_t *p_blend = vlc_custom_create( p_this, sizeof(*p_blend), "blend" );
109 if( !p_blend )
110 return NULL;
112 es_format_Init( &p_blend->fmt_in, VIDEO_ES, 0 );
114 es_format_Init( &p_blend->fmt_out, VIDEO_ES, 0 );
116 p_blend->fmt_out.i_codec =
117 p_blend->fmt_out.video.i_chroma = p_dst_chroma->i_chroma;
118 p_blend->fmt_out.video.i_rmask = p_dst_chroma->i_rmask;
119 p_blend->fmt_out.video.i_gmask = p_dst_chroma->i_gmask;
120 p_blend->fmt_out.video.i_bmask = p_dst_chroma->i_bmask;
121 p_blend->fmt_out.video.i_rrshift= p_dst_chroma->i_rrshift;
122 p_blend->fmt_out.video.i_rgshift= p_dst_chroma->i_rgshift;
123 p_blend->fmt_out.video.i_rbshift= p_dst_chroma->i_rbshift;
124 p_blend->fmt_out.video.i_lrshift= p_dst_chroma->i_lrshift;
125 p_blend->fmt_out.video.i_lgshift= p_dst_chroma->i_lgshift;
126 p_blend->fmt_out.video.i_lbshift= p_dst_chroma->i_lbshift;
128 /* The blend module will be loaded when needed with the real
129 * input format */
130 p_blend->p_module = NULL;
132 return p_blend;
135 int filter_ConfigureBlend( filter_t *p_blend,
136 int i_dst_width, int i_dst_height,
137 const video_format_t *p_src )
139 /* */
140 if( p_blend->p_module &&
141 p_blend->fmt_in.video.i_chroma != p_src->i_chroma )
143 /* The chroma is not the same, we need to reload the blend module */
144 module_unneed( p_blend, p_blend->p_module );
145 p_blend->p_module = NULL;
148 /* */
150 p_blend->fmt_in.i_codec = p_src->i_chroma;
151 p_blend->fmt_in.video = *p_src;
153 /* */
154 p_blend->fmt_out.video.i_width =
155 p_blend->fmt_out.video.i_visible_width = i_dst_width;
156 p_blend->fmt_out.video.i_height =
157 p_blend->fmt_out.video.i_visible_height = i_dst_height;
159 /* */
160 if( !p_blend->p_module )
161 p_blend->p_module = module_need( p_blend, "video blending", NULL, false );
162 if( !p_blend->p_module )
163 return VLC_EGENERIC;
164 return VLC_SUCCESS;
167 int filter_Blend( filter_t *p_blend,
168 picture_t *p_dst, int i_dst_x, int i_dst_y,
169 const picture_t *p_src, int i_alpha )
171 if( !p_blend->p_module )
172 return VLC_EGENERIC;
174 p_blend->pf_video_blend( p_blend, p_dst, p_src, i_dst_x, i_dst_y, i_alpha );
175 return VLC_SUCCESS;
178 void filter_DeleteBlend( filter_t *p_blend )
180 if( p_blend->p_module )
181 module_unneed( p_blend, p_blend->p_module );
183 vlc_object_release( p_blend );
186 /* */
187 #include <vlc_video_splitter.h>
189 video_splitter_t *video_splitter_New( vlc_object_t *p_this,
190 const char *psz_name,
191 const video_format_t *p_fmt )
193 video_splitter_t *p_splitter = vlc_custom_create( p_this,
194 sizeof(*p_splitter), "video splitter" );
195 if( !p_splitter )
196 return NULL;
198 video_format_Copy( &p_splitter->fmt, p_fmt );
200 /* */
201 p_splitter->p_module = module_need( p_splitter, "video splitter", psz_name, true );
202 if( ! p_splitter->p_module )
204 video_splitter_Delete( p_splitter );
205 return NULL;
208 return p_splitter;
211 void video_splitter_Delete( video_splitter_t *p_splitter )
213 if( p_splitter->p_module )
214 module_unneed( p_splitter, p_splitter->p_module );
216 video_format_Clean( &p_splitter->fmt );
218 vlc_object_release( p_splitter );