Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
52866 views
1
/*****************************************************************************
2
* set.h: quantization init
3
*****************************************************************************
4
* Copyright (C) 2003-2016 x264 project
5
*
6
* Authors: Loren Merritt <[email protected]>
7
* Laurent Aimar <[email protected]>
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 [email protected].
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_HIGH = 100,
35
PROFILE_HIGH10 = 110,
36
PROFILE_HIGH422 = 122,
37
PROFILE_HIGH444_PREDICTIVE = 244,
38
};
39
40
enum chroma_format_e
41
{
42
CHROMA_400 = 0,
43
CHROMA_420 = 1,
44
CHROMA_422 = 2,
45
CHROMA_444 = 3,
46
};
47
48
enum cqm4_e
49
{
50
CQM_4IY = 0,
51
CQM_4PY = 1,
52
CQM_4IC = 2,
53
CQM_4PC = 3
54
};
55
enum cqm8_e
56
{
57
CQM_8IY = 0,
58
CQM_8PY = 1,
59
CQM_8IC = 2,
60
CQM_8PC = 3,
61
};
62
63
typedef struct
64
{
65
int i_id;
66
67
int i_profile_idc;
68
int i_level_idc;
69
70
int b_constraint_set0;
71
int b_constraint_set1;
72
int b_constraint_set2;
73
int b_constraint_set3;
74
75
int i_log2_max_frame_num;
76
77
int i_poc_type;
78
/* poc 0 */
79
int i_log2_max_poc_lsb;
80
81
int i_num_ref_frames;
82
int b_gaps_in_frame_num_value_allowed;
83
int i_mb_width;
84
int i_mb_height;
85
int b_frame_mbs_only;
86
int b_mb_adaptive_frame_field;
87
int b_direct8x8_inference;
88
89
int b_crop;
90
struct
91
{
92
int i_left;
93
int i_right;
94
int i_top;
95
int i_bottom;
96
} crop;
97
98
int b_vui;
99
struct
100
{
101
int b_aspect_ratio_info_present;
102
int i_sar_width;
103
int i_sar_height;
104
105
int b_overscan_info_present;
106
int b_overscan_info;
107
108
int b_signal_type_present;
109
int i_vidformat;
110
int b_fullrange;
111
int b_color_description_present;
112
int i_colorprim;
113
int i_transfer;
114
int i_colmatrix;
115
116
int b_chroma_loc_info_present;
117
int i_chroma_loc_top;
118
int i_chroma_loc_bottom;
119
120
int b_timing_info_present;
121
uint32_t i_num_units_in_tick;
122
uint32_t i_time_scale;
123
int b_fixed_frame_rate;
124
125
int b_nal_hrd_parameters_present;
126
int b_vcl_hrd_parameters_present;
127
128
struct
129
{
130
int i_cpb_cnt;
131
int i_bit_rate_scale;
132
int i_cpb_size_scale;
133
int i_bit_rate_value;
134
int i_cpb_size_value;
135
int i_bit_rate_unscaled;
136
int i_cpb_size_unscaled;
137
int b_cbr_hrd;
138
139
int i_initial_cpb_removal_delay_length;
140
int i_cpb_removal_delay_length;
141
int i_dpb_output_delay_length;
142
int i_time_offset_length;
143
} hrd;
144
145
int b_pic_struct_present;
146
int b_bitstream_restriction;
147
int b_motion_vectors_over_pic_boundaries;
148
int i_max_bytes_per_pic_denom;
149
int i_max_bits_per_mb_denom;
150
int i_log2_max_mv_length_horizontal;
151
int i_log2_max_mv_length_vertical;
152
int i_num_reorder_frames;
153
int i_max_dec_frame_buffering;
154
155
/* FIXME to complete */
156
} vui;
157
158
int b_qpprime_y_zero_transform_bypass;
159
int i_chroma_format_idc;
160
161
} x264_sps_t;
162
163
typedef struct
164
{
165
int i_id;
166
int i_sps_id;
167
168
int b_cabac;
169
170
int b_pic_order;
171
int i_num_slice_groups;
172
173
int i_num_ref_idx_l0_default_active;
174
int i_num_ref_idx_l1_default_active;
175
176
int b_weighted_pred;
177
int b_weighted_bipred;
178
179
int i_pic_init_qp;
180
int i_pic_init_qs;
181
182
int i_chroma_qp_index_offset;
183
184
int b_deblocking_filter_control;
185
int b_constrained_intra_pred;
186
int b_redundant_pic_cnt;
187
188
int b_transform_8x8_mode;
189
190
int i_cqm_preset;
191
const uint8_t *scaling_list[8]; /* could be 12, but we don't allow separate Cb/Cr lists */
192
193
} x264_pps_t;
194
195
/* default quant matrices */
196
static const uint8_t x264_cqm_jvt4i[16] =
197
{
198
6,13,20,28,
199
13,20,28,32,
200
20,28,32,37,
201
28,32,37,42
202
};
203
static const uint8_t x264_cqm_jvt4p[16] =
204
{
205
10,14,20,24,
206
14,20,24,27,
207
20,24,27,30,
208
24,27,30,34
209
};
210
static const uint8_t x264_cqm_jvt8i[64] =
211
{
212
6,10,13,16,18,23,25,27,
213
10,11,16,18,23,25,27,29,
214
13,16,18,23,25,27,29,31,
215
16,18,23,25,27,29,31,33,
216
18,23,25,27,29,31,33,36,
217
23,25,27,29,31,33,36,38,
218
25,27,29,31,33,36,38,40,
219
27,29,31,33,36,38,40,42
220
};
221
static const uint8_t x264_cqm_jvt8p[64] =
222
{
223
9,13,15,17,19,21,22,24,
224
13,13,17,19,21,22,24,25,
225
15,17,19,21,22,24,25,27,
226
17,19,21,22,24,25,27,28,
227
19,21,22,24,25,27,28,30,
228
21,22,24,25,27,28,30,32,
229
22,24,25,27,28,30,32,33,
230
24,25,27,28,30,32,33,35
231
};
232
static const uint8_t x264_cqm_flat16[64] =
233
{
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
16,16,16,16,16,16,16,16,
240
16,16,16,16,16,16,16,16,
241
16,16,16,16,16,16,16,16
242
};
243
static const uint8_t * const x264_cqm_jvt[8] =
244
{
245
x264_cqm_jvt4i, x264_cqm_jvt4p,
246
x264_cqm_jvt4i, x264_cqm_jvt4p,
247
x264_cqm_jvt8i, x264_cqm_jvt8p,
248
x264_cqm_jvt8i, x264_cqm_jvt8p
249
};
250
251
// 1080i25_avci50, 1080p25_avci50
252
static const uint8_t x264_cqm_avci50_4ic[16] =
253
{
254
16,22,28,40,
255
22,28,40,44,
256
28,40,44,48,
257
40,44,48,60
258
};
259
260
// 1080i25_avci50,
261
static const uint8_t x264_cqm_avci50_1080i_8iy[64] =
262
{
263
16,18,19,21,27,33,81,87,
264
18,19,21,24,30,33,81,87,
265
19,21,24,27,30,78,84,90,
266
21,24,27,30,33,78,84,90,
267
24,27,30,33,78,81,84,90,
268
24,27,30,33,78,81,84,93,
269
27,30,33,78,78,81,87,93,
270
30,33,33,78,81,84,87,96
271
};
272
273
// 1080p25_avci50, 720p25_avci50, 720p50_avci50
274
static const uint8_t x264_cqm_avci50_p_8iy[64] =
275
{
276
16,18,19,21,24,27,30,33,
277
18,19,21,24,27,30,33,78,
278
19,21,24,27,30,33,78,81,
279
21,24,27,30,33,78,81,84,
280
24,27,30,33,78,81,84,87,
281
27,30,33,78,81,84,87,90,
282
30,33,78,81,84,87,90,93,
283
33,78,81,84,87,90,93,96
284
};
285
286
// 1080i25_avci100, 1080p25_avci100
287
static const uint8_t x264_cqm_avci100_1080_4ic[16] =
288
{
289
16,20,26,32,
290
20,26,32,38,
291
26,32,38,44,
292
32,38,44,50
293
};
294
295
// 720p25_avci100, 720p50_avci100
296
static const uint8_t x264_cqm_avci100_720p_4ic[16] =
297
{
298
16,21,27,34,
299
21,27,34,41,
300
27,34,41,46,
301
34,41,46,54
302
};
303
304
// 1080i25_avci100,
305
static const uint8_t x264_cqm_avci100_1080i_8iy[64] =
306
{
307
16,19,20,23,24,26,32,42,
308
18,19,22,24,26,32,36,42,
309
18,20,23,24,26,32,36,63,
310
19,20,23,26,32,36,42,63,
311
20,22,24,26,32,36,59,63,
312
22,23,24,26,32,36,59,68,
313
22,23,24,26,32,42,59,68,
314
22,23,24,26,36,42,59,72
315
};
316
317
// 1080p25_avci100,
318
static const uint8_t x264_cqm_avci100_1080p_8iy[64] =
319
{
320
16,18,19,20,22,23,24,26,
321
18,19,20,22,23,24,26,32,
322
19,20,22,23,24,26,32,36,
323
20,22,23,24,26,32,36,42,
324
22,23,24,26,32,36,42,59,
325
23,24,26,32,36,42,59,63,
326
24,26,32,36,42,59,63,68,
327
26,32,36,42,59,63,68,72
328
};
329
330
// 720p25_avci100, 720p50_avci100
331
static const uint8_t x264_cqm_avci100_720p_8iy[64] =
332
{
333
16,18,19,21,22,24,26,32,
334
18,19,19,21,22,24,26,32,
335
19,19,21,22,22,24,26,32,
336
21,21,22,22,23,24,26,34,
337
22,22,22,23,24,25,26,34,
338
24,24,24,24,25,26,34,36,
339
26,26,26,26,26,34,36,38,
340
32,32,32,34,34,36,38,42
341
};
342
343
int x264_cqm_init( x264_t *h );
344
void x264_cqm_delete( x264_t *h );
345
int x264_cqm_parse_file( x264_t *h, const char *filename );
346
347
#endif
348
349