]> git.sesse.net Git - x264/blob - filters/video/video.c
2ee239f4f69381d4afa745e34d807bc77d0dc8b0
[x264] / filters / video / video.c
1 /*****************************************************************************
2  * video.c: video filters
3  *****************************************************************************
4  * Copyright (C) 2010 x264 project
5  *
6  * Authors: Steven Walters <kemuri9@gmail.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
21  *
22  * This program is also available under a commercial proprietary license.
23  * For more information, contact us at licensing@x264.com.
24  *****************************************************************************/
25
26 #include "video.h"
27
28 static cli_vid_filter_t *first_filter = NULL;
29
30 static void register_vid_filter( cli_vid_filter_t *new_filter )
31 {
32     cli_vid_filter_t *filter_i = first_filter;
33     while( filter_i->next )
34         filter_i = filter_i->next;
35     filter_i->next = new_filter;
36     new_filter->next = NULL;
37 }
38
39 #define REGISTER_VFILTER(name)\
40 {\
41     extern cli_vid_filter_t name##_filter;\
42     register_vid_filter( &name##_filter );\
43 }
44
45 void x264_register_vid_filters()
46 {
47     extern cli_vid_filter_t source_filter;
48     first_filter = &source_filter;
49     REGISTER_VFILTER( cache );
50     REGISTER_VFILTER( crop );
51     REGISTER_VFILTER( fix_vfr_pts );
52     REGISTER_VFILTER( resize );
53     REGISTER_VFILTER( select_every );
54 }
55
56 int x264_init_vid_filter( const char *name, hnd_t *handle, cli_vid_filter_t *filter,
57                           video_info_t *info, x264_param_t *param, char *opt_string )
58 {
59     cli_vid_filter_t *filter_i = first_filter;
60     while( filter_i && strcasecmp( name, filter_i->name ) )
61         filter_i = filter_i->next;
62     FAIL_IF_ERR( !filter_i, "x264", "invalid filter `%s'\n", name );
63     if( filter_i->init( handle, filter, info, param, opt_string ) )
64         return -1;
65
66     return 0;
67 }
68
69 void x264_vid_filter_help( int longhelp )
70 {
71     for( cli_vid_filter_t *filter_i = first_filter; filter_i; filter_i = filter_i->next )
72         if( filter_i->help )
73             filter_i->help( longhelp );
74 }