]> git.sesse.net Git - x264/blob - input/input.h
Various cosmetics
[x264] / input / input.h
1 /*****************************************************************************
2  * input.h: file input
3  *****************************************************************************
4  * Copyright (C) 2003-2011 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
28 #ifndef X264_INPUT_H
29 #define X264_INPUT_H
30
31 #include "x264cli.h"
32
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 } cli_input_opt_t;
46
47 /* properties of the source given by the demuxer */
48 typedef struct
49 {
50     int csp;         /* colorspace of the input */
51     uint32_t fps_num;
52     uint32_t fps_den;
53     int height;
54     int interlaced;
55     int num_frames;
56     uint32_t sar_width;
57     uint32_t sar_height;
58     int tff;
59     int thread_safe; /* demuxer is thread_input safe */
60     uint32_t timebase_num;
61     uint32_t timebase_den;
62     int vfr;
63     int width;
64 } video_info_t;
65
66 /* image data type used by x264cli */
67 typedef struct
68 {
69     int     csp;       /* colorspace */
70     int     width;     /* width of the picture */
71     int     height;    /* height of the picture */
72     int     planes;    /* number of planes */
73     uint8_t *plane[4]; /* pointers for each plane */
74     int     stride[4]; /* strides for each plane */
75 } cli_image_t;
76
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
85 typedef struct
86 {
87     int (*open_file)( char *psz_filename, hnd_t *p_handle, video_info_t *info, cli_input_opt_t *opt );
88     int (*picture_alloc)( cli_pic_t *pic, int csp, int width, int height );
89     int (*read_frame)( cli_pic_t *pic, hnd_t handle, int i_frame );
90     int (*release_frame)( cli_pic_t *pic, hnd_t handle );
91     void (*picture_clean)( cli_pic_t *pic );
92     int (*close_file)( hnd_t handle );
93 } cli_input_t;
94
95 extern const cli_input_t raw_input;
96 extern const cli_input_t y4m_input;
97 extern const cli_input_t avs_input;
98 extern cli_input_t thread_input;
99 extern const cli_input_t lavf_input;
100 extern const cli_input_t ffms_input;
101 extern cli_input_t timecode_input;
102
103 extern cli_input_t cli_input;
104
105 /* extended colorspace list that isn't supported by libx264 but by the cli */
106 #define X264_CSP_I422           X264_CSP_MAX     /* yuv 4:2:2 planar    */
107 #define X264_CSP_CLI_MAX       (X264_CSP_MAX+1)  /* end of list         */
108 #define X264_CSP_OTHER          0x4000           /* non x264 colorspace */
109
110 typedef struct
111 {
112     const char *name;
113     int planes;
114     float width[4];
115     float height[4];
116     int mod_width;
117     int mod_height;
118 } x264_cli_csp_t;
119
120 extern const x264_cli_csp_t x264_cli_csps[];
121
122 int      x264_cli_csp_is_invalid( int csp );
123 int      x264_cli_csp_depth_factor( int csp );
124 int      x264_cli_pic_alloc( cli_pic_t *pic, int csp, int width, int height );
125 void     x264_cli_pic_clean( cli_pic_t *pic );
126 uint64_t x264_cli_pic_plane_size( int csp, int width, int height, int plane );
127 uint64_t x264_cli_pic_size( int csp, int width, int height );
128 const x264_cli_csp_t *x264_cli_get_csp( int csp );
129
130 #endif