]> git.sesse.net Git - x264/blob - common/set.h
Add support for level 1b
[x264] / common / set.h
1 /*****************************************************************************
2  * set.h: h264 encoder
3  *****************************************************************************
4  * Copyright (C) 2003-2008 x264 project
5  *
6  * Authors: Loren Merritt <lorenm@u.washington.edu>
7  *          Laurent Aimar <fenrir@via.ecp.fr>
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
24 #ifndef X264_SET_H
25 #define X264_SET_H
26
27 enum profile_e
28 {
29     PROFILE_BASELINE = 66,
30     PROFILE_MAIN     = 77,
31     PROFILE_EXTENDED = 88,
32     PROFILE_HIGH    = 100,
33     PROFILE_HIGH10  = 110,
34     PROFILE_HIGH422 = 122,
35     PROFILE_HIGH444 = 144,
36     PROFILE_HIGH444_PREDICTIVE = 244,
37 };
38
39 enum cqm4_e
40 {
41     CQM_4IY = 0,
42     CQM_4PY = 1,
43     CQM_4IC = 2,
44     CQM_4PC = 3
45 };
46 enum cqm8_e
47 {
48     CQM_8IY = 0,
49     CQM_8PY = 1
50 };
51
52 typedef struct
53 {
54     int i_id;
55
56     int i_profile_idc;
57     int i_level_idc;
58
59     int b_constraint_set0;
60     int b_constraint_set1;
61     int b_constraint_set2;
62     int b_constraint_set3;
63
64     int i_log2_max_frame_num;
65
66     int i_poc_type;
67     /* poc 0 */
68     int i_log2_max_poc_lsb;
69     /* poc 1 */
70     int b_delta_pic_order_always_zero;
71     int i_offset_for_non_ref_pic;
72     int i_offset_for_top_to_bottom_field;
73     int i_num_ref_frames_in_poc_cycle;
74     int i_offset_for_ref_frame[256];
75
76     int i_num_ref_frames;
77     int b_gaps_in_frame_num_value_allowed;
78     int i_mb_width;
79     int i_mb_height;
80     int b_frame_mbs_only;
81     int b_mb_adaptive_frame_field;
82     int b_direct8x8_inference;
83
84     int b_crop;
85     struct
86     {
87         int i_left;
88         int i_right;
89         int i_top;
90         int i_bottom;
91     } crop;
92
93     int b_vui;
94     struct
95     {
96         int b_aspect_ratio_info_present;
97         int i_sar_width;
98         int i_sar_height;
99
100         int b_overscan_info_present;
101         int b_overscan_info;
102
103         int b_signal_type_present;
104         int i_vidformat;
105         int b_fullrange;
106         int b_color_description_present;
107         int i_colorprim;
108         int i_transfer;
109         int i_colmatrix;
110
111         int b_chroma_loc_info_present;
112         int i_chroma_loc_top;
113         int i_chroma_loc_bottom;
114
115         int b_timing_info_present;
116         uint32_t i_num_units_in_tick;
117         uint32_t i_time_scale;
118         int b_fixed_frame_rate;
119
120         int b_nal_hrd_parameters_present;
121         int b_vcl_hrd_parameters_present;
122
123         struct
124         {
125             int i_cpb_cnt;
126             int i_bit_rate_scale;
127             int i_cpb_size_scale;
128             int i_bit_rate_value;
129             int i_cpb_size_value;
130             int i_bit_rate_unscaled;
131             int i_cpb_size_unscaled;
132             int b_cbr_hrd;
133
134             int i_initial_cpb_removal_delay_length;
135             int i_cpb_removal_delay_length;
136             int i_dpb_output_delay_length;
137             int i_time_offset_length;
138         } hrd;
139
140         int b_pic_struct_present;
141         int b_bitstream_restriction;
142         int b_motion_vectors_over_pic_boundaries;
143         int i_max_bytes_per_pic_denom;
144         int i_max_bits_per_mb_denom;
145         int i_log2_max_mv_length_horizontal;
146         int i_log2_max_mv_length_vertical;
147         int i_num_reorder_frames;
148         int i_max_dec_frame_buffering;
149
150         /* FIXME to complete */
151     } vui;
152
153     int b_qpprime_y_zero_transform_bypass;
154
155 } x264_sps_t;
156
157 typedef struct
158 {
159     int i_id;
160     int i_sps_id;
161
162     int b_cabac;
163
164     int b_pic_order;
165     int i_num_slice_groups;
166
167     int i_num_ref_idx_l0_default_active;
168     int i_num_ref_idx_l1_default_active;
169
170     int b_weighted_pred;
171     int b_weighted_bipred;
172
173     int i_pic_init_qp;
174     int i_pic_init_qs;
175
176     int i_chroma_qp_index_offset;
177
178     int b_deblocking_filter_control;
179     int b_constrained_intra_pred;
180     int b_redundant_pic_cnt;
181
182     int b_transform_8x8_mode;
183
184     int i_cqm_preset;
185     const uint8_t *scaling_list[6]; /* could be 8, but we don't allow separate Cb/Cr lists */
186
187 } x264_pps_t;
188
189 /* default quant matrices */
190 static const uint8_t x264_cqm_jvt4i[16] =
191 {
192       6,13,20,28,
193      13,20,28,32,
194      20,28,32,37,
195      28,32,37,42
196 };
197 static const uint8_t x264_cqm_jvt4p[16] =
198 {
199     10,14,20,24,
200     14,20,24,27,
201     20,24,27,30,
202     24,27,30,34
203 };
204 static const uint8_t x264_cqm_jvt8i[64] =
205 {
206      6,10,13,16,18,23,25,27,
207     10,11,16,18,23,25,27,29,
208     13,16,18,23,25,27,29,31,
209     16,18,23,25,27,29,31,33,
210     18,23,25,27,29,31,33,36,
211     23,25,27,29,31,33,36,38,
212     25,27,29,31,33,36,38,40,
213     27,29,31,33,36,38,40,42
214 };
215 static const uint8_t x264_cqm_jvt8p[64] =
216 {
217      9,13,15,17,19,21,22,24,
218     13,13,17,19,21,22,24,25,
219     15,17,19,21,22,24,25,27,
220     17,19,21,22,24,25,27,28,
221     19,21,22,24,25,27,28,30,
222     21,22,24,25,27,28,30,32,
223     22,24,25,27,28,30,32,33,
224     24,25,27,28,30,32,33,35
225 };
226 static const uint8_t x264_cqm_flat16[64] =
227 {
228     16,16,16,16,16,16,16,16,
229     16,16,16,16,16,16,16,16,
230     16,16,16,16,16,16,16,16,
231     16,16,16,16,16,16,16,16,
232     16,16,16,16,16,16,16,16,
233     16,16,16,16,16,16,16,16,
234     16,16,16,16,16,16,16,16,
235     16,16,16,16,16,16,16,16
236 };
237 static const uint8_t * const x264_cqm_jvt[6] =
238 {
239     x264_cqm_jvt4i, x264_cqm_jvt4p,
240     x264_cqm_jvt4i, x264_cqm_jvt4p,
241     x264_cqm_jvt8i, x264_cqm_jvt8p
242 };
243
244 int  x264_cqm_init( x264_t *h );
245 void x264_cqm_delete( x264_t *h );
246 int  x264_cqm_parse_file( x264_t *h, const char *filename );
247
248 #endif