00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef VLC_FILTER_H
00026 #define VLC_FILTER_H 1
00027
00028 #include <vlc_es.h>
00029 #include <vlc_picture.h>
00030 #include <vlc_subpicture.h>
00031 #include <vlc_mouse.h>
00032
00033
00034
00035
00036
00037
00038 typedef struct filter_owner_sys_t filter_owner_sys_t;
00039
00040
00041
00042
00043
00044
00045 struct filter_t
00046 {
00047 VLC_COMMON_MEMBERS
00048
00049
00050 module_t * p_module;
00051 filter_sys_t * p_sys;
00052
00053
00054 es_format_t fmt_in;
00055
00056
00057 es_format_t fmt_out;
00058 bool b_allow_fmt_out_change;
00059
00060
00061 config_chain_t * p_cfg;
00062
00063 union
00064 {
00065 struct
00066 {
00067 picture_t * (*pf_filter) ( filter_t *, picture_t * );
00068 void (*pf_flush)( filter_t * );
00069 picture_t * (*pf_buffer_new) ( filter_t * );
00070 void (*pf_buffer_del) ( filter_t *, picture_t * );
00071
00072
00073
00074
00075
00076
00077
00078
00079 int (*pf_mouse)( filter_t *, vlc_mouse_t *,
00080 const vlc_mouse_t *p_old,
00081 const vlc_mouse_t *p_new );
00082 } video;
00083 #define pf_video_filter u.video.pf_filter
00084 #define pf_video_flush u.video.pf_flush
00085 #define pf_video_mouse u.video.pf_mouse
00086 #define pf_video_buffer_new u.video.pf_buffer_new
00087 #define pf_video_buffer_del u.video.pf_buffer_del
00088
00089 struct
00090 {
00091 block_t * (*pf_filter) ( filter_t *, block_t * );
00092 block_t * (*pf_buffer_new) ( filter_t *, int );
00093 } audio;
00094 #define pf_audio_filter u.audio.pf_filter
00095 #define pf_audio_buffer_new u.audio.pf_buffer_new
00096
00097 struct
00098 {
00099 void (*pf_blend) ( filter_t *, picture_t *,
00100 const picture_t *, int, int, int );
00101 } blend;
00102 #define pf_video_blend u.blend.pf_blend
00103
00104 struct
00105 {
00106 subpicture_t * (*pf_filter) ( filter_t *, mtime_t );
00107 subpicture_t * (*pf_buffer_new)( filter_t * );
00108 void (*pf_buffer_del)( filter_t *, subpicture_t * );
00109 int (*pf_mouse) ( filter_t *,
00110 const vlc_mouse_t *p_old,
00111 const vlc_mouse_t *p_new,
00112 const video_format_t * );
00113 } sub;
00114 #define pf_sub_filter u.sub.pf_filter
00115 #define pf_sub_buffer_new u.sub.pf_buffer_new
00116 #define pf_sub_buffer_del u.sub.pf_buffer_del
00117 #define pf_sub_mouse u.sub.pf_mouse
00118
00119 struct
00120 {
00121 int (*pf_text) ( filter_t *, subpicture_region_t *,
00122 subpicture_region_t * );
00123 int (*pf_html) ( filter_t *, subpicture_region_t *,
00124 subpicture_region_t * );
00125 } render;
00126 #define pf_render_text u.render.pf_text
00127 #define pf_render_html u.render.pf_html
00128
00129 } u;
00130
00131
00132
00133 int (*pf_get_attachments)( filter_t *, input_attachment_t ***, int * );
00134
00135
00136 filter_owner_sys_t *p_owner;
00137 };
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 static inline picture_t *filter_NewPicture( filter_t *p_filter )
00149 {
00150 picture_t *p_picture = p_filter->pf_video_buffer_new( p_filter );
00151 if( !p_picture )
00152 msg_Warn( p_filter, "can't get output picture" );
00153 return p_picture;
00154 }
00155
00156
00157
00158
00159
00160
00161
00162
00163 static inline void filter_DeletePicture( filter_t *p_filter, picture_t *p_picture )
00164 {
00165 p_filter->pf_video_buffer_del( p_filter, p_picture );
00166 }
00167
00168
00169
00170
00171 static inline void filter_FlushPictures( filter_t *p_filter )
00172 {
00173 if( p_filter->pf_video_flush )
00174 p_filter->pf_video_flush( p_filter );
00175 }
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186 static inline subpicture_t *filter_NewSubpicture( filter_t *p_filter )
00187 {
00188 subpicture_t *p_subpicture = p_filter->pf_sub_buffer_new( p_filter );
00189 if( !p_subpicture )
00190 msg_Warn( p_filter, "can't get output subpicture" );
00191 return p_subpicture;
00192 }
00193
00194
00195
00196
00197
00198
00199
00200
00201 static inline void filter_DeleteSubpicture( filter_t *p_filter, subpicture_t *p_subpicture )
00202 {
00203 p_filter->pf_sub_buffer_del( p_filter, p_subpicture );
00204 }
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216 static inline block_t *filter_NewAudioBuffer( filter_t *p_filter, int i_size )
00217 {
00218 block_t *p_block = p_filter->pf_audio_buffer_new( p_filter, i_size );
00219 if( !p_block )
00220 msg_Warn( p_filter, "can't get output block" );
00221 return p_block;
00222 }
00223
00224
00225
00226
00227
00228
00229 static inline int filter_GetInputAttachments( filter_t *p_filter,
00230 input_attachment_t ***ppp_attachment,
00231 int *pi_attachment )
00232 {
00233 if( !p_filter->pf_get_attachments )
00234 return VLC_EGENERIC;
00235 return p_filter->pf_get_attachments( p_filter,
00236 ppp_attachment, pi_attachment );
00237 }
00238
00239
00240
00241
00242
00243
00244
00245 VLC_EXPORT( filter_t *, filter_NewBlend, ( vlc_object_t *, const video_format_t *p_dst_chroma ) LIBVLC_USED );
00246
00247
00248
00249
00250
00251 VLC_EXPORT( int, filter_ConfigureBlend, ( filter_t *, int i_dst_width, int i_dst_height, const video_format_t *p_src ) );
00252
00253
00254
00255
00256
00257
00258 VLC_EXPORT( int, filter_Blend, ( filter_t *, picture_t *p_dst, int i_dst_x, int i_dst_y, const picture_t *p_src, int i_alpha ) );
00259
00260
00261
00262
00263 VLC_EXPORT( void, filter_DeleteBlend, ( filter_t * ) );
00264
00265
00266
00267
00268
00269
00270
00271 #define VIDEO_FILTER_WRAPPER( name ) \
00272 static picture_t *name ## _Filter ( filter_t *p_filter, \
00273 picture_t *p_pic ) \
00274 { \
00275 picture_t *p_outpic = filter_NewPicture( p_filter ); \
00276 if( p_outpic ) \
00277 { \
00278 name( p_filter, p_pic, p_outpic ); \
00279 picture_CopyProperties( p_outpic, p_pic ); \
00280 } \
00281 picture_Release( p_pic ); \
00282 return p_outpic; \
00283 }
00284
00285
00286
00287
00288
00289
00290
00291 typedef struct filter_chain_t filter_chain_t;
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304 VLC_EXPORT( filter_chain_t *, filter_chain_New, ( vlc_object_t *, const char *, bool, int (*)( filter_t *, void * ), void (*)( filter_t * ), void * ) LIBVLC_USED );
00305 #define filter_chain_New( a, b, c, d, e, f ) filter_chain_New( VLC_OBJECT( a ), b, c, d, e, f )
00306
00307
00308
00309
00310
00311
00312
00313 VLC_EXPORT( void, filter_chain_Delete, ( filter_chain_t * ) );
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323 VLC_EXPORT( void, filter_chain_Reset, ( filter_chain_t *, const es_format_t *, const es_format_t * ) );
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335 VLC_EXPORT( filter_t *, filter_chain_AppendFilter, ( filter_chain_t *, const char *, config_chain_t *, const es_format_t *, const es_format_t * ) );
00336
00337
00338
00339
00340
00341
00342
00343
00344 VLC_EXPORT( int, filter_chain_AppendFromString, ( filter_chain_t *, const char * ) );
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355 VLC_EXPORT( int, filter_chain_DeleteFilter, ( filter_chain_t *, filter_t * ) );
00356
00357
00358
00359
00360
00361
00362
00363 VLC_EXPORT( int, filter_chain_GetLength, ( filter_chain_t * ) );
00364
00365
00366
00367
00368
00369
00370
00371 VLC_EXPORT( const es_format_t *, filter_chain_GetFmtOut, ( filter_chain_t * ) );
00372
00373
00374
00375
00376
00377
00378
00379
00380 VLC_EXPORT( picture_t *, filter_chain_VideoFilter, ( filter_chain_t *, picture_t * ) );
00381
00382
00383
00384
00385 VLC_EXPORT( void, filter_chain_VideoFlush, ( filter_chain_t * ) );
00386
00387
00388
00389
00390
00391
00392
00393
00394 VLC_EXPORT( block_t *, filter_chain_AudioFilter, ( filter_chain_t *, block_t * ) );
00395
00396
00397
00398
00399
00400
00401
00402 VLC_EXPORT( void, filter_chain_SubFilter, ( filter_chain_t *, mtime_t ) );
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412 VLC_EXPORT( int, filter_chain_MouseFilter, ( filter_chain_t *, vlc_mouse_t *, const vlc_mouse_t * ) );
00413
00414
00415
00416
00417
00418
00419 VLC_EXPORT( int, filter_chain_MouseEvent, ( filter_chain_t *, const vlc_mouse_t *, const video_format_t * ) );
00420
00421 #endif
00422