]> git.sesse.net Git - x264/blob - input/input.h
Fix regression in rev1549
[x264] / input / input.h
1 /*****************************************************************************
2  * input.h: file input
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  *          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 *resolution;
38     char *colorspace;
39     int bit_depth;
40     char *timebase;
41     int seek;
42 } cli_input_opt_t;
43
44 /* properties of the source given by the demuxer */
45 typedef struct
46 {
47     int csp;         /* colorspace of the input */
48     uint32_t fps_num;
49     uint32_t fps_den;
50     int height;
51     int interlaced;
52     int num_frames;
53     uint32_t sar_width;
54     uint32_t sar_height;
55     int tff;
56     int thread_safe; /* demuxer is thread_input safe */
57     uint32_t timebase_num;
58     uint32_t timebase_den;
59     int vfr;
60     int width;
61 } video_info_t;
62
63 /* image data type used by x264cli */
64 typedef struct
65 {
66     int     csp;       /* colorspace */
67     int     width;     /* width of the picture */
68     int     height;    /* height of the picture */
69     int     planes;    /* number of planes */
70     uint8_t *plane[4]; /* pointers for each plane */
71     int     stride[4]; /* strides for each plane */
72 } cli_image_t;
73
74 typedef struct
75 {
76     cli_image_t img;
77     int64_t pts;       /* input pts */
78     int64_t duration;  /* frame duration - used for vfr */
79     void    *opaque;   /* opaque handle */
80 } cli_pic_t;
81
82 typedef struct
83 {
84     int (*open_file)( char *psz_filename, hnd_t *p_handle, video_info_t *info, cli_input_opt_t *opt );
85     int (*picture_alloc)( cli_pic_t *pic, int csp, int width, int height );
86     int (*read_frame)( cli_pic_t *pic, hnd_t handle, int i_frame );
87     int (*release_frame)( cli_pic_t *pic, hnd_t handle );
88     void (*picture_clean)( cli_pic_t *pic );
89     int (*close_file)( hnd_t handle );
90 } cli_input_t;
91
92 extern const cli_input_t raw_input;
93 extern const cli_input_t y4m_input;
94 extern const cli_input_t avs_input;
95 extern cli_input_t thread_input;
96 extern const cli_input_t lavf_input;
97 extern const cli_input_t ffms_input;
98 extern cli_input_t timecode_input;
99
100 extern cli_input_t input;
101
102 /* extended colorspace list that isn't supported by libx264 but by the cli */
103 #define X264_CSP_I422           X264_CSP_MAX     /* yuv 4:2:2 planar    */
104 #define X264_CSP_I444          (X264_CSP_MAX+1)  /* yuv 4:4:4 planar    */
105 #define X264_CSP_BGR           (X264_CSP_MAX+2)  /* packed bgr 24bits   */
106 #define X264_CSP_BGRA          (X264_CSP_MAX+3)  /* packed bgr 32bits   */
107 #define X264_CSP_RGB           (X264_CSP_MAX+4)  /* packed rgb 24bits   */
108 #define X264_CSP_CLI_MAX       (X264_CSP_MAX+5)  /* end of list         */
109 #define X264_CSP_OTHER          0x4000           /* non x264 colorspace */
110
111 typedef struct
112 {
113     const char *name;
114     int planes;
115     float width[4];
116     float height[4];
117     int mod_width;
118     int mod_height;
119 } x264_cli_csp_t;
120
121 extern const x264_cli_csp_t x264_cli_csps[];
122
123 int      x264_cli_csp_is_invalid( int csp );
124 int      x264_cli_csp_depth_factor( int csp );
125 int      x264_cli_pic_alloc( cli_pic_t *pic, int csp, int width, int height );
126 void     x264_cli_pic_clean( cli_pic_t *pic );
127 uint64_t x264_cli_pic_plane_size( int csp, int width, int height, int plane );
128 uint64_t x264_cli_pic_size( int csp, int width, int height );
129 const x264_cli_csp_t *x264_cli_get_csp( int csp );
130
131 #endif