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