]> git.sesse.net Git - x264/blob - x264cli.h
Add video filtering system to x264cli
[x264] / x264cli.h
1 /*****************************************************************************
2  * x264cli.h: x264cli common
3  *****************************************************************************
4  * Copyright (C) 2003-2010 x264 project
5  *
6  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
7  *          Loren Merritt <lorenm@u.washington.edu>
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  02111, USA.
22  *****************************************************************************/
23
24 #ifndef X264_CLI_H
25 #define X264_CLI_H
26
27 #include "common/common.h"
28
29 typedef void *hnd_t;
30
31 static inline int64_t gcd( int64_t a, int64_t b )
32 {
33     while( 1 )
34     {
35         int64_t c = a % b;
36         if( !c )
37             return b;
38         a = b;
39         b = c;
40     }
41 }
42
43 static inline int64_t lcm( int64_t a, int64_t b )
44 {
45     return ( a / gcd( a, b ) ) * b;
46 }
47
48 static inline char *get_filename_extension( char *filename )
49 {
50     char *ext = filename + strlen( filename );
51     while( *ext != '.' && ext > filename )
52         ext--;
53     ext += *ext == '.';
54     return ext;
55 }
56
57 void x264_cli_log( const char *name, int i_level, const char *fmt, ... );
58 void x264_cli_printf( int i_level, const char *fmt, ... );
59
60 #define RETURN_IF_ERR( cond, name, ret, ... )\
61 if( cond )\
62 {\
63     x264_cli_log( name, X264_LOG_ERROR, __VA_ARGS__ );\
64     return ret;\
65 }
66
67 #define FAIL_IF_ERR( cond, name, ... ) RETURN_IF_ERR( cond, name, -1, __VA_ARGS__ )
68
69 #endif