]> git.sesse.net Git - x264/blob - x264cli.h
Update source file headers
[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  * This program is also available under a commercial proprietary license.
24  * For more information, contact us at licensing@x264.com.
25  *****************************************************************************/
26
27 #ifndef X264_CLI_H
28 #define X264_CLI_H
29
30 #include "common/common.h"
31
32 typedef void *hnd_t;
33
34 static inline int64_t gcd( int64_t a, int64_t b )
35 {
36     while( 1 )
37     {
38         int64_t c = a % b;
39         if( !c )
40             return b;
41         a = b;
42         b = c;
43     }
44 }
45
46 static inline int64_t lcm( int64_t a, int64_t b )
47 {
48     return ( a / gcd( a, b ) ) * b;
49 }
50
51 static inline char *get_filename_extension( char *filename )
52 {
53     char *ext = filename + strlen( filename );
54     while( *ext != '.' && ext > filename )
55         ext--;
56     ext += *ext == '.';
57     return ext;
58 }
59
60 void x264_cli_log( const char *name, int i_level, const char *fmt, ... );
61 void x264_cli_printf( int i_level, const char *fmt, ... );
62
63 #define RETURN_IF_ERR( cond, name, ret, ... )\
64 if( cond )\
65 {\
66     x264_cli_log( name, X264_LOG_ERROR, __VA_ARGS__ );\
67     return ret;\
68 }
69
70 #define FAIL_IF_ERR( cond, name, ... ) RETURN_IF_ERR( cond, name, -1, __VA_ARGS__ )
71
72 #endif