x264cli.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*****************************************************************************
  2. * x264cli.h: x264cli common
  3. *****************************************************************************
  4. * Copyright (C) 2003-2018 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. #ifndef X264_CLI_H
  27. #define X264_CLI_H
  28. #include "common/base.h"
  29. /* In microseconds */
  30. #define UPDATE_INTERVAL 250000
  31. typedef void *hnd_t;
  32. static inline uint64_t gcd( uint64_t a, uint64_t b )
  33. {
  34. while( 1 )
  35. {
  36. int64_t c = a % b;
  37. if( !c )
  38. return b;
  39. a = b;
  40. b = c;
  41. }
  42. }
  43. static inline uint64_t lcm( uint64_t a, uint64_t b )
  44. {
  45. return ( a / gcd( a, b ) ) * b;
  46. }
  47. static inline char *get_filename_extension( char *filename )
  48. {
  49. char *ext = filename + strlen( filename );
  50. while( *ext != '.' && ext > filename )
  51. ext--;
  52. ext += *ext == '.';
  53. return ext;
  54. }
  55. void x264_cli_log( const char *name, int i_level, const char *fmt, ... );
  56. void x264_cli_printf( int i_level, const char *fmt, ... );
  57. #ifdef _WIN32
  58. void x264_cli_set_console_title( const char *title );
  59. int x264_ansi_filename( const char *filename, char *ansi_filename, int size, int create_file );
  60. #else
  61. #define x264_cli_set_console_title( title )
  62. #endif
  63. #define RETURN_IF_ERR( cond, name, ret, ... )\
  64. do\
  65. {\
  66. if( cond )\
  67. {\
  68. x264_cli_log( name, X264_LOG_ERROR, __VA_ARGS__ );\
  69. return ret;\
  70. }\
  71. } while( 0 )
  72. #define FAIL_IF_ERR( cond, name, ... ) RETURN_IF_ERR( cond, name, -1, __VA_ARGS__ )
  73. typedef enum
  74. {
  75. RANGE_AUTO = -1,
  76. RANGE_TV,
  77. RANGE_PC
  78. } range_enum;
  79. #endif