]> granicus.if.org Git - libx264/blob - x264cli.h
mp4: Update GPAC support to v0.8.0 or later
[libx264] / x264cli.h
1 /*****************************************************************************
2  * x264cli.h: x264cli common
3  *****************************************************************************
4  * Copyright (C) 2003-2020 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/base.h"
31
32 /* In microseconds */
33 #define UPDATE_INTERVAL 250000
34
35 #define MAX_RESOLUTION 16384
36
37 typedef void *hnd_t;
38
39 extern const char * const x264_avcintra_class_names[];
40 extern const char * const x264_cqm_names[];
41 extern const char * const x264_log_level_names[];
42 extern const char * const x264_partition_names[];
43 extern const char * const x264_pulldown_names[];
44 extern const char * const x264_range_names[];
45 extern const char * const x264_output_csp_names[];
46 extern const char * const x264_valid_profile_names[];
47 extern const char * const x264_demuxer_names[];
48 extern const char * const x264_muxer_names[];
49
50 static inline uint64_t gcd( uint64_t a, uint64_t b )
51 {
52     while( 1 )
53     {
54         int64_t c = a % b;
55         if( !c )
56             return b;
57         a = b;
58         b = c;
59     }
60 }
61
62 static inline uint64_t lcm( uint64_t a, uint64_t b )
63 {
64     return ( a / gcd( a, b ) ) * b;
65 }
66
67 static inline char *get_filename_extension( char *filename )
68 {
69     char *ext = filename + strlen( filename );
70     while( *ext != '.' && ext > filename )
71         ext--;
72     ext += *ext == '.';
73     return ext;
74 }
75
76 void x264_cli_log( const char *name, int i_level, const char *fmt, ... );
77 void x264_cli_printf( int i_level, const char *fmt, ... );
78 int x264_cli_autocomplete( const char *prev, const char *cur );
79
80 #ifdef _WIN32
81 void x264_cli_set_console_title( const char *title );
82 int x264_ansi_filename( const char *filename, char *ansi_filename, int size, int create_file );
83 #else
84 #define x264_cli_set_console_title( title )
85 #endif
86
87 #define RETURN_IF_ERR( cond, name, ret, ... )\
88 do\
89 {\
90     if( cond )\
91     {\
92         x264_cli_log( name, X264_LOG_ERROR, __VA_ARGS__ );\
93         return ret;\
94     }\
95 } while( 0 )
96
97 #define FAIL_IF_ERR( cond, name, ... ) RETURN_IF_ERR( cond, name, -1, __VA_ARGS__ )
98
99 typedef enum
100 {
101     RANGE_AUTO = -1,
102     RANGE_TV,
103     RANGE_PC
104 } range_enum;
105
106 #endif