1 /*****************************************************************************
2 * filter.c : filter_t helpers.
3 *****************************************************************************
4 * Copyright (C) 2009 Laurent Aimar
7 * Author: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
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.
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.
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 *****************************************************************************/
28 #include <vlc_common.h>
30 #include <vlc_filter.h>
31 #include <vlc_modules.h>
33 filter_t
*filter_NewBlend( vlc_object_t
*p_this
,
34 const video_format_t
*p_dst_chroma
)
36 filter_t
*p_blend
= vlc_custom_create( p_this
, sizeof(*p_blend
),
37 VLC_OBJECT_GENERIC
, "blend" );
41 es_format_Init( &p_blend
->fmt_in
, VIDEO_ES
, 0 );
43 es_format_Init( &p_blend
->fmt_out
, VIDEO_ES
, 0 );
45 p_blend
->fmt_out
.i_codec
=
46 p_blend
->fmt_out
.video
.i_chroma
= p_dst_chroma
->i_chroma
;
47 p_blend
->fmt_out
.video
.i_rmask
= p_dst_chroma
->i_rmask
;
48 p_blend
->fmt_out
.video
.i_gmask
= p_dst_chroma
->i_gmask
;
49 p_blend
->fmt_out
.video
.i_bmask
= p_dst_chroma
->i_bmask
;
50 p_blend
->fmt_out
.video
.i_rrshift
= p_dst_chroma
->i_rrshift
;
51 p_blend
->fmt_out
.video
.i_rgshift
= p_dst_chroma
->i_rgshift
;
52 p_blend
->fmt_out
.video
.i_rbshift
= p_dst_chroma
->i_rbshift
;
53 p_blend
->fmt_out
.video
.i_lrshift
= p_dst_chroma
->i_lrshift
;
54 p_blend
->fmt_out
.video
.i_lgshift
= p_dst_chroma
->i_lgshift
;
55 p_blend
->fmt_out
.video
.i_lbshift
= p_dst_chroma
->i_lbshift
;
57 /* The blend module will be loaded when needed with the real
59 p_blend
->p_module
= NULL
;
62 vlc_object_attach( p_blend
, p_this
);
67 int filter_ConfigureBlend( filter_t
*p_blend
,
68 int i_dst_width
, int i_dst_height
,
69 const video_format_t
*p_src
)
72 if( p_blend
->p_module
&&
73 p_blend
->fmt_in
.video
.i_chroma
!= p_src
->i_chroma
)
75 /* The chroma is not the same, we need to reload the blend module */
76 module_unneed( p_blend
, p_blend
->p_module
);
77 p_blend
->p_module
= NULL
;
82 p_blend
->fmt_in
.i_codec
= p_src
->i_chroma
;
83 p_blend
->fmt_in
.video
= *p_src
;
86 p_blend
->fmt_out
.video
.i_width
=
87 p_blend
->fmt_out
.video
.i_visible_width
= i_dst_width
;
88 p_blend
->fmt_out
.video
.i_height
=
89 p_blend
->fmt_out
.video
.i_visible_height
= i_dst_height
;
92 if( !p_blend
->p_module
)
93 p_blend
->p_module
= module_need( p_blend
, "video blending", NULL
, false );
94 if( !p_blend
->p_module
)
99 int filter_Blend( filter_t
*p_blend
,
100 picture_t
*p_dst
, int i_dst_x
, int i_dst_y
,
101 const picture_t
*p_src
, int i_alpha
)
103 if( !p_blend
->p_module
)
106 p_blend
->pf_video_blend( p_blend
, p_dst
, p_src
, i_dst_x
, i_dst_y
, i_alpha
);
110 void filter_DeleteBlend( filter_t
*p_blend
)
112 if( p_blend
->p_module
)
113 module_unneed( p_blend
, p_blend
->p_module
);
115 vlc_object_release( p_blend
);
119 #include <vlc_video_splitter.h>
121 video_splitter_t
*video_splitter_New( vlc_object_t
*p_this
,
122 const char *psz_name
,
123 const video_format_t
*p_fmt
)
125 video_splitter_t
*p_splitter
= vlc_custom_create( p_this
, sizeof(*p_splitter
),
126 VLC_OBJECT_GENERIC
, "video splitter" );
130 video_format_Copy( &p_splitter
->fmt
, p_fmt
);
133 vlc_object_attach( p_splitter
, p_this
);
135 p_splitter
->p_module
= module_need( p_splitter
, "video splitter", psz_name
, true );
136 if( ! p_splitter
->p_module
)
138 video_splitter_Delete( p_splitter
);
145 void video_splitter_Delete( video_splitter_t
*p_splitter
)
147 if( p_splitter
->p_module
)
148 module_unneed( p_splitter
, p_splitter
->p_module
);
150 video_format_Clean( &p_splitter
->fmt
);
152 vlc_object_release( p_splitter
);