input.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*****************************************************************************
  2. * input.h: file input
  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. * Steven Walters <kemuri9@gmail.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
  23. *
  24. * This program is also available under a commercial proprietary license.
  25. * For more information, contact us at licensing@x264.com.
  26. *****************************************************************************/
  27. #ifndef X264_INPUT_H
  28. #define X264_INPUT_H
  29. #include "x264cli.h"
  30. #ifdef _WIN32
  31. #include <windows.h>
  32. #endif
  33. /* options that are used by only some demuxers */
  34. typedef struct
  35. {
  36. char *index_file;
  37. char *format;
  38. char *resolution;
  39. char *colorspace;
  40. int bit_depth;
  41. char *timebase;
  42. int seek;
  43. int progress;
  44. int output_csp; /* convert to this csp, if applicable */
  45. int output_range; /* user desired output range */
  46. int input_range; /* user override input range */
  47. } cli_input_opt_t;
  48. /* properties of the source given by the demuxer */
  49. typedef struct
  50. {
  51. int csp; /* colorspace of the input */
  52. uint32_t fps_num;
  53. uint32_t fps_den;
  54. int fullrange; /* has 2^bit_depth-1 instead of 219*2^(bit_depth-8) ranges (YUV only) */
  55. int width;
  56. int height;
  57. int interlaced;
  58. int num_frames;
  59. uint32_t sar_width;
  60. uint32_t sar_height;
  61. int tff;
  62. int thread_safe; /* demuxer is thread_input safe */
  63. uint32_t timebase_num;
  64. uint32_t timebase_den;
  65. int vfr;
  66. } video_info_t;
  67. /* image data type used by x264cli */
  68. typedef struct
  69. {
  70. int csp; /* colorspace */
  71. int width; /* width of the picture */
  72. int height; /* height of the picture */
  73. int planes; /* number of planes */
  74. uint8_t *plane[4]; /* pointers for each plane */
  75. int stride[4]; /* strides for each plane */
  76. } cli_image_t;
  77. typedef struct
  78. {
  79. cli_image_t img;
  80. int64_t pts; /* input pts */
  81. int64_t duration; /* frame duration - used for vfr */
  82. void *opaque; /* opaque handle */
  83. } cli_pic_t;
  84. typedef struct
  85. {
  86. int (*open_file)( char *psz_filename, hnd_t *p_handle, video_info_t *info, cli_input_opt_t *opt );
  87. int (*picture_alloc)( cli_pic_t *pic, hnd_t handle, int csp, int width, int height );
  88. int (*read_frame)( cli_pic_t *pic, hnd_t handle, int i_frame );
  89. int (*release_frame)( cli_pic_t *pic, hnd_t handle );
  90. void (*picture_clean)( cli_pic_t *pic, hnd_t handle );
  91. int (*close_file)( hnd_t handle );
  92. } cli_input_t;
  93. extern const cli_input_t raw_input;
  94. extern const cli_input_t y4m_input;
  95. extern const cli_input_t avs_input;
  96. extern const cli_input_t thread_8_input;
  97. extern const cli_input_t thread_10_input;
  98. extern const cli_input_t lavf_input;
  99. extern const cli_input_t ffms_input;
  100. extern const cli_input_t timecode_input;
  101. extern cli_input_t cli_input;
  102. /* extended colorspace list that isn't supported by libx264 but by the cli */
  103. #define X264_CSP_CLI_MAX X264_CSP_MAX /* end of list */
  104. #define X264_CSP_OTHER 0x4000 /* non x264 colorspace */
  105. typedef struct
  106. {
  107. const char *name;
  108. int planes;
  109. float width[4];
  110. float height[4];
  111. int mod_width;
  112. int mod_height;
  113. } x264_cli_csp_t;
  114. extern const x264_cli_csp_t x264_cli_csps[];
  115. int x264_cli_csp_is_invalid( int csp );
  116. int x264_cli_csp_depth_factor( int csp );
  117. int x264_cli_pic_alloc( cli_pic_t *pic, int csp, int width, int height );
  118. int x264_cli_pic_alloc_aligned( cli_pic_t *pic, int csp, int width, int height );
  119. int x264_cli_pic_init_noalloc( cli_pic_t *pic, int csp, int width, int height );
  120. void x264_cli_pic_clean( cli_pic_t *pic );
  121. uint64_t x264_cli_pic_plane_size( int csp, int width, int height, int plane );
  122. uint64_t x264_cli_pic_size( int csp, int width, int height );
  123. const x264_cli_csp_t *x264_cli_get_csp( int csp );
  124. typedef struct
  125. {
  126. int64_t file_size;
  127. int align_mask;
  128. #ifdef _WIN32
  129. int page_mask;
  130. BOOL (WINAPI *prefetch_virtual_memory)( HANDLE, ULONG_PTR, PVOID, ULONG );
  131. HANDLE process_handle;
  132. HANDLE map_handle;
  133. #elif HAVE_MMAP
  134. int fd;
  135. #endif
  136. } cli_mmap_t;
  137. int x264_cli_mmap_init( cli_mmap_t *h, FILE *fh );
  138. void *x264_cli_mmap( cli_mmap_t *h, int64_t offset, size_t size );
  139. int x264_cli_munmap( cli_mmap_t *h, void *addr, size_t size );
  140. void x264_cli_mmap_close( cli_mmap_t *h );
  141. #endif