/src/aom/av1/av1_cx_iface.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
3 | | * |
4 | | * This source code is subject to the terms of the BSD 2 Clause License and |
5 | | * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License |
6 | | * was not distributed with this source code in the LICENSE file, you can |
7 | | * obtain it at www.aomedia.org/license/software. If the Alliance for Open |
8 | | * Media Patent License 1.0 was not distributed with this source code in the |
9 | | * PATENTS file, you can obtain it at www.aomedia.org/license/patent. |
10 | | */ |
11 | | #include <stdlib.h> |
12 | | #include <string.h> |
13 | | |
14 | | #include "aom_mem/aom_mem.h" |
15 | | #include "config/aom_config.h" |
16 | | #include "config/aom_version.h" |
17 | | |
18 | | #include "aom_ports/mem_ops.h" |
19 | | |
20 | | #include "aom/aom_encoder.h" |
21 | | #include "aom/internal/aom_codec_internal.h" |
22 | | |
23 | | #include "av1/av1_iface_common.h" |
24 | | #include "av1/encoder/bitstream.h" |
25 | | #include "av1/encoder/encoder.h" |
26 | | #include "av1/encoder/ethread.h" |
27 | | #include "av1/encoder/external_partition.h" |
28 | | #include "av1/encoder/firstpass.h" |
29 | | #include "av1/arg_defs.h" |
30 | | |
31 | | #include "common/args_helper.h" |
32 | | |
33 | | struct av1_extracfg { |
34 | | int cpu_used; |
35 | | unsigned int enable_auto_alt_ref; |
36 | | unsigned int enable_auto_bwd_ref; |
37 | | unsigned int noise_sensitivity; |
38 | | unsigned int sharpness; |
39 | | unsigned int static_thresh; |
40 | | unsigned int row_mt; |
41 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
42 | | unsigned int fp_mt; |
43 | | #endif |
44 | | unsigned int tile_columns; // log2 number of tile columns |
45 | | unsigned int tile_rows; // log2 number of tile rows |
46 | | unsigned int enable_tpl_model; |
47 | | unsigned int enable_keyframe_filtering; |
48 | | unsigned int arnr_max_frames; |
49 | | unsigned int arnr_strength; |
50 | | unsigned int min_gf_interval; |
51 | | unsigned int max_gf_interval; |
52 | | unsigned int gf_min_pyr_height; |
53 | | unsigned int gf_max_pyr_height; |
54 | | aom_tune_metric tuning; |
55 | | const char *vmaf_model_path; |
56 | | const char *partition_info_path; |
57 | | unsigned int cq_level; // constrained quality level |
58 | | unsigned int rc_max_intra_bitrate_pct; |
59 | | unsigned int rc_max_inter_bitrate_pct; |
60 | | unsigned int gf_cbr_boost_pct; |
61 | | unsigned int lossless; |
62 | | unsigned int enable_cdef; |
63 | | unsigned int enable_restoration; |
64 | | unsigned int force_video_mode; |
65 | | unsigned int enable_obmc; |
66 | | unsigned int disable_trellis_quant; |
67 | | unsigned int enable_qm; |
68 | | unsigned int qm_y; |
69 | | unsigned int qm_u; |
70 | | unsigned int qm_v; |
71 | | unsigned int qm_min; |
72 | | unsigned int qm_max; |
73 | | unsigned int num_tg; |
74 | | unsigned int mtu_size; |
75 | | |
76 | | aom_timing_info_type_t timing_info_type; |
77 | | unsigned int frame_parallel_decoding_mode; |
78 | | int enable_dual_filter; |
79 | | unsigned int enable_chroma_deltaq; |
80 | | AQ_MODE aq_mode; |
81 | | DELTAQ_MODE deltaq_mode; |
82 | | int deltaq_strength; |
83 | | int deltalf_mode; |
84 | | unsigned int frame_periodic_boost; |
85 | | aom_bit_depth_t bit_depth; |
86 | | aom_tune_content content; |
87 | | aom_color_primaries_t color_primaries; |
88 | | aom_transfer_characteristics_t transfer_characteristics; |
89 | | aom_matrix_coefficients_t matrix_coefficients; |
90 | | aom_chroma_sample_position_t chroma_sample_position; |
91 | | int color_range; |
92 | | int render_width; |
93 | | int render_height; |
94 | | aom_superblock_size_t superblock_size; |
95 | | unsigned int single_tile_decoding; |
96 | | int error_resilient_mode; |
97 | | int s_frame_mode; |
98 | | |
99 | | int film_grain_test_vector; |
100 | | const char *film_grain_table_filename; |
101 | | unsigned int motion_vector_unit_test; |
102 | | #if CONFIG_FRAME_PARALLEL_ENCODE && CONFIG_FPMT_TEST |
103 | | unsigned int fpmt_unit_test; |
104 | | #endif |
105 | | unsigned int cdf_update_mode; |
106 | | int enable_rect_partitions; // enable rectangular partitions for sequence |
107 | | int enable_ab_partitions; // enable AB partitions for sequence |
108 | | int enable_1to4_partitions; // enable 1:4 and 4:1 partitions for sequence |
109 | | int min_partition_size; // min partition size [4,8,16,32,64,128] |
110 | | int max_partition_size; // max partition size [4,8,16,32,64,128] |
111 | | int enable_intra_edge_filter; // enable intra-edge filter for sequence |
112 | | int enable_order_hint; // enable order hint for sequence |
113 | | int enable_tx64; // enable 64-pt transform usage for sequence |
114 | | int enable_flip_idtx; // enable flip and identity transform types |
115 | | int enable_rect_tx; // enable rectangular transform usage for sequence |
116 | | int enable_dist_wtd_comp; // enable dist wtd compound for sequence |
117 | | int max_reference_frames; // maximum number of references per frame |
118 | | int enable_reduced_reference_set; // enable reduced set of references |
119 | | int enable_ref_frame_mvs; // sequence level |
120 | | int allow_ref_frame_mvs; // frame level |
121 | | int enable_masked_comp; // enable masked compound for sequence |
122 | | int enable_onesided_comp; // enable one sided compound for sequence |
123 | | int enable_interintra_comp; // enable interintra compound for sequence |
124 | | int enable_smooth_interintra; // enable smooth interintra mode usage |
125 | | int enable_diff_wtd_comp; // enable diff-wtd compound usage |
126 | | int enable_interinter_wedge; // enable interinter-wedge compound usage |
127 | | int enable_interintra_wedge; // enable interintra-wedge compound usage |
128 | | int enable_global_motion; // enable global motion usage for sequence |
129 | | int enable_warped_motion; // sequence level |
130 | | int allow_warped_motion; // frame level |
131 | | int enable_filter_intra; // enable filter intra for sequence |
132 | | int enable_smooth_intra; // enable smooth intra modes for sequence |
133 | | int enable_paeth_intra; // enable Paeth intra mode for sequence |
134 | | int enable_cfl_intra; // enable CFL uv intra mode for sequence |
135 | | int enable_directional_intra; // enable directional modes for sequence |
136 | | int enable_diagonal_intra; // enable D45 to D203 intra modes for sequence |
137 | | int enable_superres; |
138 | | int enable_overlay; // enable overlay for filtered arf frames |
139 | | int enable_palette; |
140 | | int enable_intrabc; |
141 | | int enable_angle_delta; |
142 | | #if CONFIG_DENOISE |
143 | | float noise_level; |
144 | | int noise_block_size; |
145 | | int enable_dnl_denoising; |
146 | | #endif |
147 | | |
148 | | unsigned int chroma_subsampling_x; |
149 | | unsigned int chroma_subsampling_y; |
150 | | int reduced_tx_type_set; |
151 | | int use_intra_dct_only; |
152 | | int use_inter_dct_only; |
153 | | int use_intra_default_tx_only; |
154 | | int enable_tx_size_search; |
155 | | int quant_b_adapt; |
156 | | unsigned int vbr_corpus_complexity_lap; |
157 | | AV1_LEVEL target_seq_level_idx[MAX_NUM_OPERATING_POINTS]; |
158 | | // Bit mask to specify which tier each of the 32 possible operating points |
159 | | // conforms to. |
160 | | unsigned int tier_mask; |
161 | | // min_cr / 100 is the target minimum compression ratio for each frame. |
162 | | unsigned int min_cr; |
163 | | COST_UPDATE_TYPE coeff_cost_upd_freq; |
164 | | COST_UPDATE_TYPE mode_cost_upd_freq; |
165 | | COST_UPDATE_TYPE mv_cost_upd_freq; |
166 | | COST_UPDATE_TYPE dv_cost_upd_freq; |
167 | | unsigned int ext_tile_debug; |
168 | | unsigned int sb_multipass_unit_test; |
169 | | // Total number of passes. If this number is -1, then we assume passes = 1 or |
170 | | // 2 (passes = 1 if pass == AOM_RC_ONE_PASS and passes = 2 otherwise). |
171 | | int passes; |
172 | | int fwd_kf_dist; |
173 | | |
174 | | LOOPFILTER_CONTROL loopfilter_control; |
175 | | // the name of the second pass output file when passes > 2 |
176 | | const char *two_pass_output; |
177 | | const char *second_pass_log; |
178 | | // Automatically determine whether to disable several intra tools |
179 | | // when "--deltaq-mode=3" is true. |
180 | | // Default as 0. |
181 | | // When set to 1, the encoder will analyze the reconstruction quality |
182 | | // as compared to the source image in the preprocessing pass. |
183 | | // If the recontruction quality is considered high enough, we disable |
184 | | // the following intra coding tools, for better encoding speed: |
185 | | // "--enable_smooth_intra", |
186 | | // "--enable_paeth_intra", |
187 | | // "--enable_cfl_intra", |
188 | | // "--enable_diagonal_intra". |
189 | | int auto_intra_tools_off; |
190 | | }; |
191 | | |
192 | | #if CONFIG_REALTIME_ONLY |
193 | | // Settings changed for realtime only build: |
194 | | // cpu_used: 7 |
195 | | // enable_tpl_model: 0 |
196 | | // enable_restoration: 0 |
197 | | // enable_obmc: 0 |
198 | | // deltaq_mode: NO_DELTA_Q |
199 | | // enable_global_motion usage: 0 |
200 | | // enable_warped_motion at sequence level: 0 |
201 | | // allow_warped_motion at frame level: 0 |
202 | | // coeff_cost_upd_freq: COST_UPD_OFF |
203 | | // mode_cost_upd_freq: COST_UPD_OFF |
204 | | // mv_cost_upd_freq: COST_UPD_OFF |
205 | | static const struct av1_extracfg default_extra_cfg = { |
206 | | 7, // cpu_used |
207 | | 1, // enable_auto_alt_ref |
208 | | 0, // enable_auto_bwd_ref |
209 | | 0, // noise_sensitivity |
210 | | 0, // sharpness |
211 | | 0, // static_thresh |
212 | | 1, // row_mt |
213 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
214 | | 0, // fp_mt |
215 | | #endif |
216 | | 0, // tile_columns |
217 | | 0, // tile_rows |
218 | | 0, // enable_tpl_model |
219 | | 1, // enable_keyframe_filtering |
220 | | 7, // arnr_max_frames |
221 | | 5, // arnr_strength |
222 | | 0, // min_gf_interval; 0 -> default decision |
223 | | 0, // max_gf_interval; 0 -> default decision |
224 | | 0, // gf_min_pyr_height |
225 | | 5, // gf_max_pyr_height |
226 | | AOM_TUNE_PSNR, // tuning |
227 | | "/usr/local/share/model/vmaf_v0.6.1.json", // VMAF model path |
228 | | ".", // partition info path |
229 | | 10, // cq_level |
230 | | 0, // rc_max_intra_bitrate_pct |
231 | | 0, // rc_max_inter_bitrate_pct |
232 | | 0, // gf_cbr_boost_pct |
233 | | 0, // lossless |
234 | | 1, // enable_cdef |
235 | | 0, // enable_restoration |
236 | | 0, // force_video_mode |
237 | | 0, // enable_obmc |
238 | | 3, // disable_trellis_quant |
239 | | 0, // enable_qm |
240 | | DEFAULT_QM_Y, // qm_y |
241 | | DEFAULT_QM_U, // qm_u |
242 | | DEFAULT_QM_V, // qm_v |
243 | | DEFAULT_QM_FIRST, // qm_min |
244 | | DEFAULT_QM_LAST, // qm_max |
245 | | 1, // max number of tile groups |
246 | | 0, // mtu_size |
247 | | AOM_TIMING_UNSPECIFIED, // No picture timing signaling in bitstream |
248 | | 0, // frame_parallel_decoding_mode |
249 | | 1, // enable dual filter |
250 | | 0, // enable delta quant in chroma planes |
251 | | NO_AQ, // aq_mode |
252 | | NO_DELTA_Q, // deltaq_mode |
253 | | 100, // deltaq_strength |
254 | | 0, // delta lf mode |
255 | | 0, // frame_periodic_boost |
256 | | AOM_BITS_8, // Bit depth |
257 | | AOM_CONTENT_DEFAULT, // content |
258 | | AOM_CICP_CP_UNSPECIFIED, // CICP color primaries |
259 | | AOM_CICP_TC_UNSPECIFIED, // CICP transfer characteristics |
260 | | AOM_CICP_MC_UNSPECIFIED, // CICP matrix coefficients |
261 | | AOM_CSP_UNKNOWN, // chroma sample position |
262 | | 0, // color range |
263 | | 0, // render width |
264 | | 0, // render height |
265 | | AOM_SUPERBLOCK_SIZE_DYNAMIC, // superblock_size |
266 | | 1, // this depends on large_scale_tile. |
267 | | 0, // error_resilient_mode off by default. |
268 | | 0, // s_frame_mode off by default. |
269 | | 0, // film_grain_test_vector |
270 | | NULL, // film_grain_table_filename |
271 | | 0, // motion_vector_unit_test |
272 | | 1, // CDF update mode |
273 | | 1, // enable rectangular partitions |
274 | | 1, // enable ab shape partitions |
275 | | 1, // enable 1:4 and 4:1 partitions |
276 | | 4, // min_partition_size |
277 | | 128, // max_partition_size |
278 | | 1, // enable intra edge filter |
279 | | 1, // frame order hint |
280 | | 1, // enable 64-pt transform usage |
281 | | 1, // enable flip and identity transform |
282 | | 1, // enable rectangular transform usage |
283 | | 1, // dist-wtd compound |
284 | | 7, // max_reference_frames |
285 | | 0, // enable_reduced_reference_set |
286 | | 1, // enable_ref_frame_mvs sequence level |
287 | | 1, // allow ref_frame_mvs frame level |
288 | | 1, // enable masked compound at sequence level |
289 | | 1, // enable one sided compound at sequence level |
290 | | 1, // enable interintra compound at sequence level |
291 | | 1, // enable smooth interintra mode |
292 | | 1, // enable difference-weighted compound |
293 | | 1, // enable interinter wedge compound |
294 | | 1, // enable interintra wedge compound |
295 | | 0, // enable_global_motion usage |
296 | | 0, // enable_warped_motion at sequence level |
297 | | 0, // allow_warped_motion at frame level |
298 | | 1, // enable filter intra at sequence level |
299 | | 1, // enable smooth intra modes usage for sequence |
300 | | 1, // enable Paeth intra mode usage for sequence |
301 | | 1, // enable CFL uv intra mode usage for sequence |
302 | | 1, // enable directional intra mode usage for sequence |
303 | | 1, // enable D45 to D203 intra mode usage for sequence |
304 | | 1, // superres |
305 | | 1, // enable overlay |
306 | | 1, // enable palette |
307 | | !CONFIG_SHARP_SETTINGS, // enable intrabc |
308 | | 1, // enable angle delta |
309 | | #if CONFIG_DENOISE |
310 | | 0, // noise_level |
311 | | 32, // noise_block_size |
312 | | 1, // enable_dnl_denoising |
313 | | #endif |
314 | | 0, // chroma_subsampling_x |
315 | | 0, // chroma_subsampling_y |
316 | | 0, // reduced_tx_type_set |
317 | | 0, // use_intra_dct_only |
318 | | 0, // use_inter_dct_only |
319 | | 0, // use_intra_default_tx_only |
320 | | 1, // enable_tx_size_search |
321 | | 0, // quant_b_adapt |
322 | | 0, // vbr_corpus_complexity_lap |
323 | | { |
324 | | SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, |
325 | | SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, |
326 | | SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, |
327 | | SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, |
328 | | SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, |
329 | | SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, |
330 | | SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, |
331 | | }, // target_seq_level_idx |
332 | | 0, // tier_mask |
333 | | 0, // min_cr |
334 | | COST_UPD_OFF, // coeff_cost_upd_freq |
335 | | COST_UPD_OFF, // mode_cost_upd_freq |
336 | | COST_UPD_OFF, // mv_cost_upd_freq |
337 | | COST_UPD_OFF, // dv_cost_upd_freq |
338 | | 0, // ext_tile_debug |
339 | | 0, // sb_multipass_unit_test |
340 | | -1, // passes |
341 | | -1, // fwd_kf_dist |
342 | | LOOPFILTER_ALL, // loopfilter_control |
343 | | NULL, // two_pass_output |
344 | | NULL, // second_pass_log |
345 | | 0, // auto_intra_tools_off |
346 | | }; |
347 | | #else |
348 | | static const struct av1_extracfg default_extra_cfg = { |
349 | | 0, // cpu_used |
350 | | 1, // enable_auto_alt_ref |
351 | | 0, // enable_auto_bwd_ref |
352 | | 0, // noise_sensitivity |
353 | | 0, // sharpness |
354 | | 0, // static_thresh |
355 | | 1, // row_mt |
356 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
357 | | 0, // fp_mt |
358 | | #endif |
359 | | 0, // tile_columns |
360 | | 0, // tile_rows |
361 | | 1, // enable_tpl_model |
362 | | 1, // enable_keyframe_filtering |
363 | | 7, // arnr_max_frames |
364 | | 5, // arnr_strength |
365 | | 0, // min_gf_interval; 0 -> default decision |
366 | | 0, // max_gf_interval; 0 -> default decision |
367 | | 0, // gf_min_pyr_height |
368 | | 5, // gf_max_pyr_height |
369 | | AOM_TUNE_PSNR, // tuning |
370 | | "/usr/local/share/model/vmaf_v0.6.1.json", // VMAF model path |
371 | | ".", // partition info path |
372 | | 10, // cq_level |
373 | | 0, // rc_max_intra_bitrate_pct |
374 | | 0, // rc_max_inter_bitrate_pct |
375 | | 0, // gf_cbr_boost_pct |
376 | | 0, // lossless |
377 | | 1, // enable_cdef |
378 | | 1, // enable_restoration |
379 | | 0, // force_video_mode |
380 | | 1, // enable_obmc |
381 | | 3, // disable_trellis_quant |
382 | | 0, // enable_qm |
383 | | DEFAULT_QM_Y, // qm_y |
384 | | DEFAULT_QM_U, // qm_u |
385 | | DEFAULT_QM_V, // qm_v |
386 | | DEFAULT_QM_FIRST, // qm_min |
387 | | DEFAULT_QM_LAST, // qm_max |
388 | | 1, // max number of tile groups |
389 | | 0, // mtu_size |
390 | | AOM_TIMING_UNSPECIFIED, // No picture timing signaling in bitstream |
391 | | 0, // frame_parallel_decoding_mode |
392 | | 1, // enable dual filter |
393 | | 0, // enable delta quant in chroma planes |
394 | | NO_AQ, // aq_mode |
395 | | DELTA_Q_OBJECTIVE, // deltaq_mode |
396 | | 100, // deltaq_strength |
397 | | 0, // delta lf mode |
398 | | 0, // frame_periodic_boost |
399 | | AOM_BITS_8, // Bit depth |
400 | | AOM_CONTENT_DEFAULT, // content |
401 | | AOM_CICP_CP_UNSPECIFIED, // CICP color primaries |
402 | | AOM_CICP_TC_UNSPECIFIED, // CICP transfer characteristics |
403 | | AOM_CICP_MC_UNSPECIFIED, // CICP matrix coefficients |
404 | | AOM_CSP_UNKNOWN, // chroma sample position |
405 | | 0, // color range |
406 | | 0, // render width |
407 | | 0, // render height |
408 | | AOM_SUPERBLOCK_SIZE_DYNAMIC, // superblock_size |
409 | | 1, // this depends on large_scale_tile. |
410 | | 0, // error_resilient_mode off by default. |
411 | | 0, // s_frame_mode off by default. |
412 | | 0, // film_grain_test_vector |
413 | | NULL, // film_grain_table_filename |
414 | | 0, // motion_vector_unit_test |
415 | | #if CONFIG_FRAME_PARALLEL_ENCODE && CONFIG_FPMT_TEST |
416 | | 0, // fpmt_unit_test |
417 | | #endif |
418 | | 1, // CDF update mode |
419 | | 1, // enable rectangular partitions |
420 | | 1, // enable ab shape partitions |
421 | | 1, // enable 1:4 and 4:1 partitions |
422 | | 4, // min_partition_size |
423 | | 128, // max_partition_size |
424 | | 1, // enable intra edge filter |
425 | | 1, // frame order hint |
426 | | 1, // enable 64-pt transform usage |
427 | | 1, // enable flip and identity transform |
428 | | 1, // enable rectangular transform usage |
429 | | 1, // dist-wtd compound |
430 | | 7, // max_reference_frames |
431 | | 0, // enable_reduced_reference_set |
432 | | 1, // enable_ref_frame_mvs sequence level |
433 | | 1, // allow ref_frame_mvs frame level |
434 | | 1, // enable masked compound at sequence level |
435 | | 1, // enable one sided compound at sequence level |
436 | | 1, // enable interintra compound at sequence level |
437 | | 1, // enable smooth interintra mode |
438 | | 1, // enable difference-weighted compound |
439 | | 1, // enable interinter wedge compound |
440 | | 1, // enable interintra wedge compound |
441 | | 1, // enable_global_motion usage |
442 | | 1, // enable_warped_motion at sequence level |
443 | | 1, // allow_warped_motion at frame level |
444 | | 1, // enable filter intra at sequence level |
445 | | 1, // enable smooth intra modes usage for sequence |
446 | | 1, // enable Paeth intra mode usage for sequence |
447 | | 1, // enable CFL uv intra mode usage for sequence |
448 | | 1, // enable directional intra mode usage for sequence |
449 | | 1, // enable D45 to D203 intra mode usage for sequence |
450 | | 1, // superres |
451 | | 1, // enable overlay |
452 | | 1, // enable palette |
453 | | !CONFIG_SHARP_SETTINGS, // enable intrabc |
454 | | 1, // enable angle delta |
455 | | #if CONFIG_DENOISE |
456 | | 0, // noise_level |
457 | | 32, // noise_block_size |
458 | | 1, // enable_dnl_denoising |
459 | | #endif |
460 | | 0, // chroma_subsampling_x |
461 | | 0, // chroma_subsampling_y |
462 | | 0, // reduced_tx_type_set |
463 | | 0, // use_intra_dct_only |
464 | | 0, // use_inter_dct_only |
465 | | 0, // use_intra_default_tx_only |
466 | | 1, // enable_tx_size_search |
467 | | 0, // quant_b_adapt |
468 | | 0, // vbr_corpus_complexity_lap |
469 | | { |
470 | | SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, |
471 | | SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, |
472 | | SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, |
473 | | SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, |
474 | | SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, |
475 | | SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, |
476 | | SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, |
477 | | }, // target_seq_level_idx |
478 | | 0, // tier_mask |
479 | | 0, // min_cr |
480 | | COST_UPD_SB, // coeff_cost_upd_freq |
481 | | COST_UPD_SB, // mode_cost_upd_freq |
482 | | COST_UPD_SB, // mv_cost_upd_freq |
483 | | COST_UPD_SB, // dv_cost_upd_freq |
484 | | 0, // ext_tile_debug |
485 | | 0, // sb_multipass_unit_test |
486 | | -1, // passes |
487 | | -1, // fwd_kf_dist |
488 | | LOOPFILTER_ALL, // loopfilter_control |
489 | | NULL, // two_pass_output |
490 | | NULL, // second_pass_log |
491 | | 0, // auto_intra_tools_off |
492 | | }; |
493 | | #endif |
494 | | |
495 | | struct aom_codec_alg_priv { |
496 | | aom_codec_priv_t base; |
497 | | aom_codec_enc_cfg_t cfg; |
498 | | struct av1_extracfg extra_cfg; |
499 | | aom_rational64_t timestamp_ratio; |
500 | | aom_codec_pts_t pts_offset; |
501 | | unsigned char pts_offset_initialized; |
502 | | AV1EncoderConfig oxcf; |
503 | | AV1_PRIMARY *ppi; |
504 | | unsigned char *cx_data; |
505 | | size_t cx_data_sz; |
506 | | size_t pending_cx_data_sz; |
507 | | aom_image_t preview_img; |
508 | | aom_enc_frame_flags_t next_frame_flags; |
509 | | aom_codec_pkt_list_decl(256) pkt_list; |
510 | | unsigned int fixed_kf_cntr; |
511 | | // BufferPool that holds all reference frames. |
512 | | BufferPool *buffer_pool; |
513 | | |
514 | | // lookahead instance variables |
515 | | BufferPool *buffer_pool_lap; |
516 | | FIRSTPASS_STATS *frame_stats_buffer; |
517 | | // Number of stats buffers required for look ahead |
518 | | int num_lap_buffers; |
519 | | STATS_BUFFER_CTX stats_buf_context; |
520 | | }; |
521 | | |
522 | 1.26k | static INLINE int gcd(int64_t a, int b) { |
523 | 1.26k | int remainder; |
524 | 3.78k | while (b > 0) { |
525 | 2.52k | remainder = (int)(a % b); |
526 | 2.52k | a = b; |
527 | 2.52k | b = remainder; |
528 | 2.52k | } |
529 | | |
530 | 1.26k | return (int)a; |
531 | 1.26k | } |
532 | | |
533 | 1.26k | static INLINE void reduce_ratio(aom_rational64_t *ratio) { |
534 | 1.26k | const int denom = gcd(ratio->num, ratio->den); |
535 | 1.26k | ratio->num /= denom; |
536 | 1.26k | ratio->den /= denom; |
537 | 1.26k | } |
538 | | |
539 | | static aom_codec_err_t update_error_state( |
540 | 0 | aom_codec_alg_priv_t *ctx, const struct aom_internal_error_info *error) { |
541 | 0 | const aom_codec_err_t res = error->error_code; |
542 | |
|
543 | 0 | if (res != AOM_CODEC_OK) |
544 | 0 | ctx->base.err_detail = error->has_detail ? error->detail : NULL; |
545 | |
|
546 | 0 | return res; |
547 | 0 | } |
548 | | |
549 | | // This function deep copies a string src to *dst. For default string we will |
550 | | // use a string literal, and otherwise we will allocate memory for the string. |
551 | | static aom_codec_err_t allocate_and_set_string(const char *src, |
552 | | const char *default_src, |
553 | | const char **dst, |
554 | 0 | char *err_detail) { |
555 | 0 | if (!src) { |
556 | 0 | snprintf(err_detail, ARG_ERR_MSG_MAX_LEN, |
557 | 0 | "Null pointer given to a string parameter."); |
558 | 0 | return AOM_CODEC_INVALID_PARAM; |
559 | 0 | } |
560 | 0 | if (*dst && strcmp(src, *dst) == 0) return AOM_CODEC_OK; |
561 | | // If the input is exactly the same as default, we will use the string |
562 | | // literal, so do not free here. |
563 | 0 | if (*dst != default_src) { |
564 | 0 | aom_free((void *)*dst); |
565 | 0 | } |
566 | |
|
567 | 0 | if (default_src && strcmp(src, default_src) == 0) { |
568 | | // default_src should be a string literal |
569 | 0 | *dst = default_src; |
570 | 0 | } else { |
571 | 0 | size_t len = strlen(src) + 1; |
572 | 0 | char *tmp = aom_malloc(len * sizeof(*tmp)); |
573 | 0 | if (!tmp) { |
574 | 0 | snprintf(err_detail, ARG_ERR_MSG_MAX_LEN, |
575 | 0 | "Failed to allocate memory for copying parameters."); |
576 | 0 | return AOM_CODEC_MEM_ERROR; |
577 | 0 | } |
578 | 0 | memcpy(tmp, src, len); |
579 | 0 | *dst = tmp; |
580 | 0 | } |
581 | 0 | return 0; |
582 | 0 | } |
583 | | |
584 | | #undef ERROR |
585 | | #define ERROR(str) \ |
586 | 0 | do { \ |
587 | 0 | ctx->base.err_detail = str; \ |
588 | 0 | return AOM_CODEC_INVALID_PARAM; \ |
589 | 0 | } while (0) |
590 | | |
591 | | #define RANGE_CHECK(p, memb, lo, hi) \ |
592 | 265k | do { \ |
593 | 265k | if (!((p)->memb >= (lo) && (p)->memb <= (hi))) \ |
594 | 265k | ERROR(#memb " out of range [" #lo ".." #hi "]"); \ |
595 | 265k | } while (0) |
596 | | |
597 | | #define RANGE_CHECK_HI(p, memb, hi) \ |
598 | 397k | do { \ |
599 | 397k | if (!((p)->memb <= (hi))) ERROR(#memb " out of range [.." #hi "]"); \ |
600 | 397k | } while (0) |
601 | | |
602 | | #define RANGE_CHECK_BOOL(p, memb) \ |
603 | 7.79k | do { \ |
604 | 7.79k | if (!!((p)->memb) != (p)->memb) ERROR(#memb " expected boolean"); \ |
605 | 7.79k | } while (0) |
606 | | |
607 | | static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx, |
608 | | const aom_codec_enc_cfg_t *cfg, |
609 | 7.79k | const struct av1_extracfg *extra_cfg) { |
610 | 7.79k | RANGE_CHECK(cfg, g_w, 1, 65535); // 16 bits available |
611 | 7.79k | RANGE_CHECK(cfg, g_h, 1, 65535); // 16 bits available |
612 | 7.79k | RANGE_CHECK(cfg, g_timebase.den, 1, 1000000000); |
613 | 7.79k | RANGE_CHECK(cfg, g_timebase.num, 1, cfg->g_timebase.den); |
614 | 7.79k | RANGE_CHECK_HI(cfg, g_profile, MAX_PROFILES - 1); |
615 | | |
616 | 7.79k | RANGE_CHECK_HI(cfg, rc_max_quantizer, 63); |
617 | 7.79k | RANGE_CHECK_HI(cfg, rc_min_quantizer, cfg->rc_max_quantizer); |
618 | 7.79k | RANGE_CHECK_BOOL(extra_cfg, lossless); |
619 | 7.79k | RANGE_CHECK_HI(extra_cfg, aq_mode, AQ_MODE_COUNT - 1); |
620 | 7.79k | RANGE_CHECK_HI(extra_cfg, deltaq_mode, DELTA_Q_MODE_COUNT - 1); |
621 | 7.79k | RANGE_CHECK_HI(extra_cfg, deltalf_mode, 1); |
622 | 7.79k | RANGE_CHECK_HI(extra_cfg, frame_periodic_boost, 1); |
623 | | #if CONFIG_REALTIME_ONLY |
624 | | RANGE_CHECK(cfg, g_usage, AOM_USAGE_REALTIME, AOM_USAGE_REALTIME); |
625 | | #else |
626 | 7.79k | RANGE_CHECK_HI(cfg, g_usage, AOM_USAGE_ALL_INTRA); |
627 | 7.79k | #endif |
628 | 7.79k | RANGE_CHECK_HI(cfg, g_threads, MAX_NUM_THREADS); |
629 | 7.79k | RANGE_CHECK(cfg, rc_end_usage, AOM_VBR, AOM_Q); |
630 | 7.79k | RANGE_CHECK_HI(cfg, rc_undershoot_pct, 100); |
631 | 7.79k | RANGE_CHECK_HI(cfg, rc_overshoot_pct, 100); |
632 | 7.79k | RANGE_CHECK_HI(cfg, rc_2pass_vbr_bias_pct, 100); |
633 | 7.79k | RANGE_CHECK(cfg, kf_mode, AOM_KF_DISABLED, AOM_KF_AUTO); |
634 | 7.79k | RANGE_CHECK_HI(cfg, rc_dropframe_thresh, 100); |
635 | 7.79k | RANGE_CHECK(cfg, g_pass, AOM_RC_ONE_PASS, AOM_RC_THIRD_PASS); |
636 | 7.79k | if (cfg->g_pass == AOM_RC_ONE_PASS) { |
637 | 7.79k | RANGE_CHECK_HI(cfg, g_lag_in_frames, MAX_TOTAL_BUFFERS); |
638 | 7.79k | } else { |
639 | 0 | RANGE_CHECK_HI(cfg, g_lag_in_frames, MAX_LAG_BUFFERS); |
640 | 0 | } |
641 | 7.79k | if (cfg->g_usage == AOM_USAGE_ALL_INTRA) { |
642 | 7.79k | RANGE_CHECK_HI(cfg, g_lag_in_frames, 0); |
643 | 7.79k | RANGE_CHECK_HI(cfg, kf_max_dist, 0); |
644 | 7.79k | } |
645 | 7.79k | RANGE_CHECK_HI(extra_cfg, min_gf_interval, MAX_LAG_BUFFERS - 1); |
646 | 7.79k | RANGE_CHECK_HI(extra_cfg, max_gf_interval, MAX_LAG_BUFFERS - 1); |
647 | 7.79k | if (extra_cfg->max_gf_interval > 0) { |
648 | 0 | RANGE_CHECK(extra_cfg, max_gf_interval, |
649 | 0 | AOMMAX(2, extra_cfg->min_gf_interval), (MAX_LAG_BUFFERS - 1)); |
650 | 0 | } |
651 | 7.79k | RANGE_CHECK_HI(extra_cfg, gf_min_pyr_height, 5); |
652 | 7.79k | RANGE_CHECK_HI(extra_cfg, gf_max_pyr_height, 5); |
653 | 7.79k | if (extra_cfg->gf_min_pyr_height > extra_cfg->gf_max_pyr_height) { |
654 | 0 | ERROR( |
655 | 0 | "gf_min_pyr_height must be less than or equal to " |
656 | 0 | "gf_max_pyramid_height"); |
657 | 0 | } |
658 | | |
659 | 7.79k | RANGE_CHECK_HI(cfg, rc_resize_mode, RESIZE_MODES - 1); |
660 | 7.79k | RANGE_CHECK(cfg, rc_resize_denominator, SCALE_NUMERATOR, |
661 | 7.79k | SCALE_NUMERATOR << 1); |
662 | 7.79k | RANGE_CHECK(cfg, rc_resize_kf_denominator, SCALE_NUMERATOR, |
663 | 7.79k | SCALE_NUMERATOR << 1); |
664 | 7.79k | RANGE_CHECK_HI(cfg, rc_superres_mode, AOM_SUPERRES_AUTO); |
665 | 7.79k | RANGE_CHECK(cfg, rc_superres_denominator, SCALE_NUMERATOR, |
666 | 7.79k | SCALE_NUMERATOR << 1); |
667 | 7.79k | RANGE_CHECK(cfg, rc_superres_kf_denominator, SCALE_NUMERATOR, |
668 | 7.79k | SCALE_NUMERATOR << 1); |
669 | 7.79k | RANGE_CHECK(cfg, rc_superres_qthresh, 1, 63); |
670 | 7.79k | RANGE_CHECK(cfg, rc_superres_kf_qthresh, 1, 63); |
671 | 7.79k | RANGE_CHECK_HI(extra_cfg, cdf_update_mode, 2); |
672 | | |
673 | 7.79k | RANGE_CHECK_HI(extra_cfg, motion_vector_unit_test, 2); |
674 | | #if CONFIG_FRAME_PARALLEL_ENCODE && CONFIG_FPMT_TEST |
675 | | RANGE_CHECK_HI(extra_cfg, fpmt_unit_test, 1); |
676 | | #endif |
677 | 7.79k | RANGE_CHECK_HI(extra_cfg, sb_multipass_unit_test, 1); |
678 | 7.79k | RANGE_CHECK_HI(extra_cfg, ext_tile_debug, 1); |
679 | 7.79k | RANGE_CHECK_HI(extra_cfg, enable_auto_alt_ref, 1); |
680 | 7.79k | RANGE_CHECK_HI(extra_cfg, enable_auto_bwd_ref, 2); |
681 | 7.79k | RANGE_CHECK(extra_cfg, cpu_used, 0, |
682 | 7.79k | (cfg->g_usage == AOM_USAGE_REALTIME) ? 10 : 9); |
683 | 7.79k | RANGE_CHECK_HI(extra_cfg, noise_sensitivity, 6); |
684 | 7.79k | RANGE_CHECK(extra_cfg, superblock_size, AOM_SUPERBLOCK_SIZE_64X64, |
685 | 7.79k | AOM_SUPERBLOCK_SIZE_DYNAMIC); |
686 | 7.79k | RANGE_CHECK_HI(cfg, large_scale_tile, 1); |
687 | 7.79k | RANGE_CHECK_HI(extra_cfg, single_tile_decoding, 1); |
688 | | |
689 | 7.79k | RANGE_CHECK_HI(extra_cfg, row_mt, 1); |
690 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
691 | | RANGE_CHECK_HI(extra_cfg, fp_mt, 1); |
692 | | #endif |
693 | | |
694 | 7.79k | RANGE_CHECK_HI(extra_cfg, tile_columns, 6); |
695 | 7.79k | RANGE_CHECK_HI(extra_cfg, tile_rows, 6); |
696 | | |
697 | 7.79k | RANGE_CHECK_HI(cfg, monochrome, 1); |
698 | | |
699 | 7.79k | if (cfg->large_scale_tile && extra_cfg->aq_mode) |
700 | 0 | ERROR( |
701 | 7.79k | "Adaptive quantization are not supported in large scale tile " |
702 | 7.79k | "coding."); |
703 | | |
704 | 7.79k | RANGE_CHECK_HI(extra_cfg, sharpness, 7); |
705 | 7.79k | RANGE_CHECK_HI(extra_cfg, arnr_max_frames, 15); |
706 | 7.79k | RANGE_CHECK_HI(extra_cfg, arnr_strength, 6); |
707 | 7.79k | RANGE_CHECK_HI(extra_cfg, cq_level, 63); |
708 | 7.79k | RANGE_CHECK(cfg, g_bit_depth, AOM_BITS_8, AOM_BITS_12); |
709 | 7.79k | RANGE_CHECK(cfg, g_input_bit_depth, 8, 12); |
710 | 7.79k | RANGE_CHECK(extra_cfg, content, AOM_CONTENT_DEFAULT, AOM_CONTENT_INVALID - 1); |
711 | | |
712 | 7.79k | if (cfg->g_pass >= AOM_RC_SECOND_PASS) { |
713 | 0 | const size_t packet_sz = sizeof(FIRSTPASS_STATS); |
714 | 0 | const int n_packets = (int)(cfg->rc_twopass_stats_in.sz / packet_sz); |
715 | 0 | const FIRSTPASS_STATS *stats; |
716 | |
|
717 | 0 | if (cfg->rc_twopass_stats_in.buf == NULL) |
718 | 0 | ERROR("rc_twopass_stats_in.buf not set."); |
719 | | |
720 | 0 | if (cfg->rc_twopass_stats_in.sz % packet_sz) |
721 | 0 | ERROR("rc_twopass_stats_in.sz indicates truncated packet."); |
722 | | |
723 | 0 | if (cfg->rc_twopass_stats_in.sz < 2 * packet_sz) |
724 | 0 | ERROR("rc_twopass_stats_in requires at least two packets."); |
725 | | |
726 | 0 | stats = |
727 | 0 | (const FIRSTPASS_STATS *)cfg->rc_twopass_stats_in.buf + n_packets - 1; |
728 | |
|
729 | 0 | if ((int)(stats->count + 0.5) != n_packets - 1) |
730 | 0 | ERROR("rc_twopass_stats_in missing EOS stats packet"); |
731 | 0 | } |
732 | | |
733 | 7.79k | if (extra_cfg->passes != -1 && cfg->g_pass == AOM_RC_ONE_PASS && |
734 | 7.79k | extra_cfg->passes != 1) { |
735 | 0 | ERROR("One pass encoding but passes != 1."); |
736 | 0 | } |
737 | | |
738 | 7.79k | if (extra_cfg->passes != -1 && (int)cfg->g_pass > extra_cfg->passes) { |
739 | 0 | ERROR("Current pass is larger than total number of passes."); |
740 | 0 | } |
741 | | |
742 | 7.79k | if (cfg->g_profile <= (unsigned int)PROFILE_1 && |
743 | 7.79k | cfg->g_bit_depth > AOM_BITS_10) { |
744 | 0 | ERROR("Codec bit-depth 12 not supported in profile < 2"); |
745 | 0 | } |
746 | 7.79k | if (cfg->g_profile <= (unsigned int)PROFILE_1 && |
747 | 7.79k | cfg->g_input_bit_depth > 10) { |
748 | 0 | ERROR("Source bit-depth 12 not supported in profile < 2"); |
749 | 0 | } |
750 | | |
751 | 7.79k | if (cfg->rc_end_usage == AOM_Q) { |
752 | 7.79k | RANGE_CHECK_HI(cfg, use_fixed_qp_offsets, 1); |
753 | 46.7k | for (int i = 0; i < FIXED_QP_OFFSET_COUNT; ++i) { |
754 | 38.9k | RANGE_CHECK_HI(cfg, fixed_qp_offsets[i], 63); |
755 | 38.9k | } |
756 | 7.79k | } else { |
757 | 0 | if (cfg->use_fixed_qp_offsets > 0) { |
758 | 0 | ERROR("--use_fixed_qp_offsets can only be used with --end-usage=q"); |
759 | 0 | } |
760 | 0 | for (int i = 0; i < FIXED_QP_OFFSET_COUNT; ++i) { |
761 | 0 | if (cfg->fixed_qp_offsets[i] >= 0) { |
762 | 0 | ERROR("--fixed_qp_offsets can only be used with --end-usage=q"); |
763 | 0 | } |
764 | 0 | } |
765 | 0 | } |
766 | | |
767 | 7.79k | RANGE_CHECK(extra_cfg, color_primaries, AOM_CICP_CP_BT_709, |
768 | 7.79k | AOM_CICP_CP_EBU_3213); // Need to check range more precisely to |
769 | | // check for reserved values? |
770 | 7.79k | RANGE_CHECK(extra_cfg, transfer_characteristics, AOM_CICP_TC_BT_709, |
771 | 7.79k | AOM_CICP_TC_HLG); |
772 | 7.79k | RANGE_CHECK(extra_cfg, matrix_coefficients, AOM_CICP_MC_IDENTITY, |
773 | 7.79k | AOM_CICP_MC_ICTCP); |
774 | 7.79k | RANGE_CHECK(extra_cfg, color_range, 0, 1); |
775 | | |
776 | | /* Average corpus complexity is supported only in the case of single pass |
777 | | * VBR*/ |
778 | 7.79k | if (cfg->g_pass == AOM_RC_ONE_PASS && cfg->rc_end_usage == AOM_VBR) |
779 | 0 | RANGE_CHECK_HI(extra_cfg, vbr_corpus_complexity_lap, |
780 | 7.79k | MAX_VBR_CORPUS_COMPLEXITY); |
781 | 7.79k | else if (extra_cfg->vbr_corpus_complexity_lap != 0) |
782 | 0 | ERROR( |
783 | 7.79k | "VBR corpus complexity is supported only in the case of single pass " |
784 | 7.79k | "VBR mode."); |
785 | | |
786 | 7.79k | #if !CONFIG_TUNE_BUTTERAUGLI |
787 | 7.79k | if (extra_cfg->tuning == AOM_TUNE_BUTTERAUGLI) { |
788 | 0 | ERROR( |
789 | 0 | "This error may be related to the wrong configuration options: try to " |
790 | 0 | "set -DCONFIG_TUNE_BUTTERAUGLI=1 at the time CMake is run."); |
791 | 0 | } |
792 | 7.79k | #endif |
793 | | |
794 | 7.79k | #if !CONFIG_TUNE_VMAF |
795 | 7.79k | if (extra_cfg->tuning >= AOM_TUNE_VMAF_WITH_PREPROCESSING && |
796 | 7.79k | extra_cfg->tuning <= AOM_TUNE_VMAF_NEG_MAX_GAIN) { |
797 | 0 | ERROR( |
798 | 0 | "This error may be related to the wrong configuration options: try to " |
799 | 0 | "set -DCONFIG_TUNE_VMAF=1 at the time CMake is run."); |
800 | 0 | } |
801 | 7.79k | #endif |
802 | | |
803 | 7.79k | RANGE_CHECK(extra_cfg, tuning, AOM_TUNE_PSNR, AOM_TUNE_BUTTERAUGLI); |
804 | | |
805 | 7.79k | RANGE_CHECK(extra_cfg, timing_info_type, AOM_TIMING_UNSPECIFIED, |
806 | 7.79k | AOM_TIMING_DEC_MODEL); |
807 | | |
808 | 7.79k | RANGE_CHECK(extra_cfg, film_grain_test_vector, 0, 16); |
809 | | |
810 | 7.79k | if (extra_cfg->lossless) { |
811 | 225 | if (extra_cfg->aq_mode != 0) |
812 | 0 | ERROR("Only --aq_mode=0 can be used with --lossless=1."); |
813 | 225 | if (extra_cfg->enable_chroma_deltaq) |
814 | 0 | ERROR("Only --enable_chroma_deltaq=0 can be used with --lossless=1."); |
815 | 225 | } |
816 | | |
817 | 7.79k | RANGE_CHECK(extra_cfg, max_reference_frames, 3, 7); |
818 | 7.79k | RANGE_CHECK(extra_cfg, enable_reduced_reference_set, 0, 1); |
819 | 7.79k | RANGE_CHECK_HI(extra_cfg, chroma_subsampling_x, 1); |
820 | 7.79k | RANGE_CHECK_HI(extra_cfg, chroma_subsampling_y, 1); |
821 | | |
822 | 7.79k | RANGE_CHECK_HI(extra_cfg, disable_trellis_quant, 3); |
823 | 7.79k | RANGE_CHECK(extra_cfg, coeff_cost_upd_freq, 0, 3); |
824 | 7.79k | RANGE_CHECK(extra_cfg, mode_cost_upd_freq, 0, 3); |
825 | 7.79k | RANGE_CHECK(extra_cfg, mv_cost_upd_freq, 0, 3); |
826 | 7.79k | RANGE_CHECK(extra_cfg, dv_cost_upd_freq, 0, 3); |
827 | | |
828 | 7.79k | RANGE_CHECK(extra_cfg, min_partition_size, 4, 128); |
829 | 7.79k | RANGE_CHECK(extra_cfg, max_partition_size, 4, 128); |
830 | 7.79k | RANGE_CHECK_HI(extra_cfg, min_partition_size, extra_cfg->max_partition_size); |
831 | | |
832 | 257k | for (int i = 0; i < MAX_NUM_OPERATING_POINTS; ++i) { |
833 | 249k | const int level_idx = extra_cfg->target_seq_level_idx[i]; |
834 | 249k | if (!is_valid_seq_level_idx(level_idx) && level_idx != SEQ_LEVELS) { |
835 | 0 | ERROR("Target sequence level index is invalid"); |
836 | 0 | } |
837 | 249k | } |
838 | | |
839 | 7.79k | RANGE_CHECK(extra_cfg, deltaq_strength, 0, 1000); |
840 | 7.79k | RANGE_CHECK_HI(extra_cfg, loopfilter_control, 3); |
841 | 7.79k | RANGE_CHECK_HI(extra_cfg, enable_cdef, 2); |
842 | | |
843 | 7.79k | return AOM_CODEC_OK; |
844 | 7.79k | } |
845 | | |
846 | | static aom_codec_err_t validate_img(aom_codec_alg_priv_t *ctx, |
847 | 1.26k | const aom_image_t *img) { |
848 | 1.26k | switch (img->fmt) { |
849 | 0 | case AOM_IMG_FMT_YV12: |
850 | 1.26k | case AOM_IMG_FMT_I420: |
851 | 1.26k | case AOM_IMG_FMT_YV1216: |
852 | 1.26k | case AOM_IMG_FMT_I42016: break; |
853 | 0 | case AOM_IMG_FMT_I444: |
854 | 0 | case AOM_IMG_FMT_I44416: |
855 | 0 | if (ctx->cfg.g_profile == (unsigned int)PROFILE_0 && |
856 | 0 | !ctx->cfg.monochrome) { |
857 | 0 | ERROR("Invalid image format. I444 images not supported in profile."); |
858 | 0 | } |
859 | 0 | break; |
860 | 0 | case AOM_IMG_FMT_I422: |
861 | 0 | case AOM_IMG_FMT_I42216: |
862 | 0 | if (ctx->cfg.g_profile != (unsigned int)PROFILE_2) { |
863 | 0 | ERROR("Invalid image format. I422 images not supported in profile."); |
864 | 0 | } |
865 | 0 | break; |
866 | 0 | default: |
867 | 0 | ERROR( |
868 | 0 | "Invalid image format. Only YV12, I420, I422, I444 images are " |
869 | 0 | "supported."); |
870 | 0 | break; |
871 | 1.26k | } |
872 | | |
873 | 1.26k | if (img->d_w != ctx->cfg.g_w || img->d_h != ctx->cfg.g_h) |
874 | 0 | ERROR("Image size must match encoder init configuration size"); |
875 | | |
876 | | #if CONFIG_TUNE_BUTTERAUGLI |
877 | | if (ctx->extra_cfg.tuning == AOM_TUNE_BUTTERAUGLI) { |
878 | | if (img->bit_depth > 8) { |
879 | | ERROR("Only 8 bit depth images supported in tune=butteraugli mode."); |
880 | | } |
881 | | if (img->mc != 0 && img->mc != AOM_CICP_MC_BT_709 && |
882 | | img->mc != AOM_CICP_MC_BT_601 && img->mc != AOM_CICP_MC_BT_470_B_G) { |
883 | | ERROR( |
884 | | "Only BT.709 and BT.601 matrix coefficients supported in " |
885 | | "tune=butteraugli mode. Identity matrix is treated as BT.601."); |
886 | | } |
887 | | } |
888 | | #endif |
889 | | |
890 | 1.26k | return AOM_CODEC_OK; |
891 | 1.26k | } |
892 | | |
893 | 1.26k | static int get_image_bps(const aom_image_t *img) { |
894 | 1.26k | switch (img->fmt) { |
895 | 0 | case AOM_IMG_FMT_YV12: |
896 | 1.26k | case AOM_IMG_FMT_I420: return 12; |
897 | 0 | case AOM_IMG_FMT_I422: return 16; |
898 | 0 | case AOM_IMG_FMT_I444: return 24; |
899 | 0 | case AOM_IMG_FMT_YV1216: |
900 | 0 | case AOM_IMG_FMT_I42016: return 24; |
901 | 0 | case AOM_IMG_FMT_I42216: return 32; |
902 | 0 | case AOM_IMG_FMT_I44416: return 48; |
903 | 0 | default: assert(0 && "Invalid image format"); break; |
904 | 1.26k | } |
905 | 0 | return 0; |
906 | 1.26k | } |
907 | | |
908 | | // Set appropriate options to disable frame super-resolution. |
909 | 8.02k | static void disable_superres(SuperResCfg *const superres_cfg) { |
910 | 8.02k | superres_cfg->superres_mode = AOM_SUPERRES_NONE; |
911 | 8.02k | superres_cfg->superres_scale_denominator = SCALE_NUMERATOR; |
912 | 8.02k | superres_cfg->superres_kf_scale_denominator = SCALE_NUMERATOR; |
913 | 8.02k | superres_cfg->superres_qthresh = 255; |
914 | 8.02k | superres_cfg->superres_kf_qthresh = 255; |
915 | 8.02k | } |
916 | | |
917 | | static void update_default_encoder_config(const cfg_options_t *cfg, |
918 | 0 | struct av1_extracfg *extra_cfg) { |
919 | 0 | extra_cfg->enable_cdef = (cfg->disable_cdef == 0) ? 1 : 0; |
920 | 0 | extra_cfg->enable_restoration = (cfg->disable_lr == 0); |
921 | 0 | extra_cfg->superblock_size = (cfg->super_block_size == 64) |
922 | 0 | ? AOM_SUPERBLOCK_SIZE_64X64 |
923 | 0 | : (cfg->super_block_size == 128) |
924 | 0 | ? AOM_SUPERBLOCK_SIZE_128X128 |
925 | 0 | : AOM_SUPERBLOCK_SIZE_DYNAMIC; |
926 | 0 | extra_cfg->enable_warped_motion = (cfg->disable_warp_motion == 0); |
927 | 0 | extra_cfg->enable_dist_wtd_comp = (cfg->disable_dist_wtd_comp == 0); |
928 | 0 | extra_cfg->enable_diff_wtd_comp = (cfg->disable_diff_wtd_comp == 0); |
929 | 0 | extra_cfg->enable_dual_filter = (cfg->disable_dual_filter == 0); |
930 | 0 | extra_cfg->enable_angle_delta = (cfg->disable_intra_angle_delta == 0); |
931 | 0 | extra_cfg->enable_rect_partitions = (cfg->disable_rect_partition_type == 0); |
932 | 0 | extra_cfg->enable_ab_partitions = (cfg->disable_ab_partition_type == 0); |
933 | 0 | extra_cfg->enable_1to4_partitions = (cfg->disable_1to4_partition_type == 0); |
934 | 0 | extra_cfg->max_partition_size = cfg->max_partition_size; |
935 | 0 | extra_cfg->min_partition_size = cfg->min_partition_size; |
936 | 0 | extra_cfg->enable_intra_edge_filter = (cfg->disable_intra_edge_filter == 0); |
937 | 0 | extra_cfg->enable_tx64 = (cfg->disable_tx_64x64 == 0); |
938 | 0 | extra_cfg->enable_flip_idtx = (cfg->disable_flip_idtx == 0); |
939 | 0 | extra_cfg->enable_masked_comp = (cfg->disable_masked_comp == 0); |
940 | 0 | extra_cfg->enable_interintra_comp = (cfg->disable_inter_intra_comp == 0); |
941 | 0 | extra_cfg->enable_smooth_interintra = (cfg->disable_smooth_inter_intra == 0); |
942 | 0 | extra_cfg->enable_interinter_wedge = (cfg->disable_inter_inter_wedge == 0); |
943 | 0 | extra_cfg->enable_interintra_wedge = (cfg->disable_inter_intra_wedge == 0); |
944 | 0 | extra_cfg->enable_global_motion = (cfg->disable_global_motion == 0); |
945 | 0 | extra_cfg->enable_filter_intra = (cfg->disable_filter_intra == 0); |
946 | 0 | extra_cfg->enable_smooth_intra = (cfg->disable_smooth_intra == 0); |
947 | 0 | extra_cfg->enable_paeth_intra = (cfg->disable_paeth_intra == 0); |
948 | 0 | extra_cfg->enable_cfl_intra = (cfg->disable_cfl == 0); |
949 | 0 | extra_cfg->enable_obmc = (cfg->disable_obmc == 0); |
950 | 0 | extra_cfg->enable_palette = (cfg->disable_palette == 0); |
951 | 0 | extra_cfg->enable_intrabc = (cfg->disable_intrabc == 0); |
952 | 0 | extra_cfg->disable_trellis_quant = cfg->disable_trellis_quant; |
953 | 0 | extra_cfg->allow_ref_frame_mvs = (cfg->disable_ref_frame_mv == 0); |
954 | 0 | extra_cfg->enable_ref_frame_mvs = (cfg->disable_ref_frame_mv == 0); |
955 | 0 | extra_cfg->enable_onesided_comp = (cfg->disable_one_sided_comp == 0); |
956 | 0 | extra_cfg->enable_reduced_reference_set = cfg->reduced_reference_set; |
957 | 0 | extra_cfg->reduced_tx_type_set = cfg->reduced_tx_type_set; |
958 | 0 | } |
959 | | |
960 | 0 | static double convert_qp_offset(int cq_level, int q_offset, int bit_depth) { |
961 | 0 | const double base_q_val = av1_convert_qindex_to_q(cq_level, bit_depth); |
962 | 0 | const int new_q_index_offset = av1_quantizer_to_qindex(q_offset); |
963 | 0 | const int new_q_index = AOMMAX(cq_level - new_q_index_offset, 0); |
964 | 0 | const double new_q_val = av1_convert_qindex_to_q(new_q_index, bit_depth); |
965 | 0 | return (base_q_val - new_q_val); |
966 | 0 | } |
967 | | |
968 | 0 | static double get_modeled_qp_offset(int cq_level, int level, int bit_depth) { |
969 | | // 80% for keyframe was derived empirically. |
970 | | // 40% similar to rc_pick_q_and_bounds_one_pass_vbr() for Q mode ARF. |
971 | | // Rest derived similar to rc_pick_q_and_bounds_two_pass() |
972 | 0 | static const int percents[FIXED_QP_OFFSET_COUNT] = { 76, 60, 30, 15, 8 }; |
973 | 0 | const double q_val = av1_convert_qindex_to_q(cq_level, bit_depth); |
974 | 0 | return q_val * percents[level] / 100; |
975 | 0 | } |
976 | | |
977 | | static aom_codec_err_t set_encoder_config(AV1EncoderConfig *oxcf, |
978 | | const aom_codec_enc_cfg_t *cfg, |
979 | 7.79k | struct av1_extracfg *extra_cfg) { |
980 | 7.79k | if (cfg->encoder_cfg.init_by_cfg_file) { |
981 | 0 | update_default_encoder_config(&cfg->encoder_cfg, extra_cfg); |
982 | 0 | } |
983 | | |
984 | 7.79k | TuneCfg *const tune_cfg = &oxcf->tune_cfg; |
985 | | |
986 | 7.79k | FrameDimensionCfg *const frm_dim_cfg = &oxcf->frm_dim_cfg; |
987 | | |
988 | 7.79k | TileConfig *const tile_cfg = &oxcf->tile_cfg; |
989 | | |
990 | 7.79k | ResizeCfg *const resize_cfg = &oxcf->resize_cfg; |
991 | | |
992 | 7.79k | GFConfig *const gf_cfg = &oxcf->gf_cfg; |
993 | | |
994 | 7.79k | PartitionCfg *const part_cfg = &oxcf->part_cfg; |
995 | | |
996 | 7.79k | IntraModeCfg *const intra_mode_cfg = &oxcf->intra_mode_cfg; |
997 | | |
998 | 7.79k | TxfmSizeTypeCfg *const txfm_cfg = &oxcf->txfm_cfg; |
999 | | |
1000 | 7.79k | CompoundTypeCfg *const comp_type_cfg = &oxcf->comp_type_cfg; |
1001 | | |
1002 | 7.79k | SuperResCfg *const superres_cfg = &oxcf->superres_cfg; |
1003 | | |
1004 | 7.79k | KeyFrameCfg *const kf_cfg = &oxcf->kf_cfg; |
1005 | | |
1006 | 7.79k | DecoderModelCfg *const dec_model_cfg = &oxcf->dec_model_cfg; |
1007 | | |
1008 | 7.79k | RateControlCfg *const rc_cfg = &oxcf->rc_cfg; |
1009 | | |
1010 | 7.79k | QuantizationCfg *const q_cfg = &oxcf->q_cfg; |
1011 | | |
1012 | 7.79k | ColorCfg *const color_cfg = &oxcf->color_cfg; |
1013 | | |
1014 | 7.79k | InputCfg *const input_cfg = &oxcf->input_cfg; |
1015 | | |
1016 | 7.79k | AlgoCfg *const algo_cfg = &oxcf->algo_cfg; |
1017 | | |
1018 | 7.79k | ToolCfg *const tool_cfg = &oxcf->tool_cfg; |
1019 | | |
1020 | 7.79k | const int is_vbr = cfg->rc_end_usage == AOM_VBR; |
1021 | 7.79k | oxcf->profile = cfg->g_profile; |
1022 | 7.79k | oxcf->max_threads = (int)cfg->g_threads; |
1023 | | |
1024 | 7.79k | switch (cfg->g_usage) { |
1025 | 0 | case AOM_USAGE_REALTIME: oxcf->mode = REALTIME; break; |
1026 | 7.79k | case AOM_USAGE_ALL_INTRA: oxcf->mode = ALLINTRA; break; |
1027 | 0 | default: oxcf->mode = GOOD; break; |
1028 | 7.79k | } |
1029 | | |
1030 | | // Set frame-dimension related configuration. |
1031 | 7.79k | frm_dim_cfg->width = cfg->g_w; |
1032 | 7.79k | frm_dim_cfg->height = cfg->g_h; |
1033 | 7.79k | frm_dim_cfg->forced_max_frame_width = cfg->g_forced_max_frame_width; |
1034 | 7.79k | frm_dim_cfg->forced_max_frame_height = cfg->g_forced_max_frame_height; |
1035 | 7.79k | frm_dim_cfg->render_width = extra_cfg->render_width; |
1036 | 7.79k | frm_dim_cfg->render_height = extra_cfg->render_height; |
1037 | | |
1038 | | // Set input video related configuration. |
1039 | 7.79k | input_cfg->input_bit_depth = cfg->g_input_bit_depth; |
1040 | | // guess a frame rate if out of whack, use 30 |
1041 | 7.79k | input_cfg->init_framerate = (double)cfg->g_timebase.den / cfg->g_timebase.num; |
1042 | 7.79k | if (cfg->g_pass >= AOM_RC_SECOND_PASS) { |
1043 | 0 | const size_t packet_sz = sizeof(FIRSTPASS_STATS); |
1044 | 0 | const int n_packets = (int)(cfg->rc_twopass_stats_in.sz / packet_sz); |
1045 | 0 | input_cfg->limit = n_packets - 1; |
1046 | 7.79k | } else { |
1047 | 7.79k | input_cfg->limit = cfg->g_limit; |
1048 | 7.79k | } |
1049 | 7.79k | input_cfg->chroma_subsampling_x = extra_cfg->chroma_subsampling_x; |
1050 | 7.79k | input_cfg->chroma_subsampling_y = extra_cfg->chroma_subsampling_y; |
1051 | 7.79k | if (input_cfg->init_framerate > 180) { |
1052 | 0 | input_cfg->init_framerate = 30; |
1053 | 0 | dec_model_cfg->timing_info_present = 0; |
1054 | 0 | } |
1055 | | |
1056 | | // Set Decoder model configuration. |
1057 | 7.79k | if (extra_cfg->timing_info_type == AOM_TIMING_EQUAL || |
1058 | 7.79k | extra_cfg->timing_info_type == AOM_TIMING_DEC_MODEL) { |
1059 | 0 | dec_model_cfg->timing_info_present = 1; |
1060 | 0 | dec_model_cfg->timing_info.num_units_in_display_tick = cfg->g_timebase.num; |
1061 | 0 | dec_model_cfg->timing_info.time_scale = cfg->g_timebase.den; |
1062 | 0 | dec_model_cfg->timing_info.num_ticks_per_picture = 1; |
1063 | 7.79k | } else { |
1064 | 7.79k | dec_model_cfg->timing_info_present = 0; |
1065 | 7.79k | } |
1066 | 7.79k | if (extra_cfg->timing_info_type == AOM_TIMING_EQUAL) { |
1067 | 0 | dec_model_cfg->timing_info.equal_picture_interval = 1; |
1068 | 0 | dec_model_cfg->decoder_model_info_present_flag = 0; |
1069 | 0 | dec_model_cfg->display_model_info_present_flag = 1; |
1070 | 7.79k | } else if (extra_cfg->timing_info_type == AOM_TIMING_DEC_MODEL) { |
1071 | | // if( extra_cfg->arnr_strength > 0 ) |
1072 | | // { |
1073 | | // printf("Only --arnr-strength=0 can currently be used with |
1074 | | // --timing-info=model."); return AOM_CODEC_INVALID_PARAM; |
1075 | | // } |
1076 | | // if( extra_cfg->enable_superres) |
1077 | | // { |
1078 | | // printf("Only --superres-mode=0 can currently be used with |
1079 | | // --timing-info=model."); return AOM_CODEC_INVALID_PARAM; |
1080 | | // } |
1081 | 0 | dec_model_cfg->num_units_in_decoding_tick = cfg->g_timebase.num; |
1082 | 0 | dec_model_cfg->timing_info.equal_picture_interval = 0; |
1083 | 0 | dec_model_cfg->decoder_model_info_present_flag = 1; |
1084 | 0 | dec_model_cfg->display_model_info_present_flag = 1; |
1085 | 0 | } |
1086 | | |
1087 | 7.79k | oxcf->pass = cfg->g_pass; |
1088 | | // For backward compatibility, assume that if extra_cfg->passes==-1, then |
1089 | | // passes = 1 or 2. |
1090 | 7.79k | if (extra_cfg->passes == -1) { |
1091 | 7.79k | if (cfg->g_pass == AOM_RC_ONE_PASS) { |
1092 | 7.79k | oxcf->passes = 1; |
1093 | 7.79k | } else { |
1094 | 0 | oxcf->passes = 2; |
1095 | 0 | } |
1096 | 7.79k | } else { |
1097 | 0 | oxcf->passes = extra_cfg->passes; |
1098 | 0 | } |
1099 | | |
1100 | | // Set Rate Control configuration. |
1101 | 7.79k | rc_cfg->max_intra_bitrate_pct = extra_cfg->rc_max_intra_bitrate_pct; |
1102 | 7.79k | rc_cfg->max_inter_bitrate_pct = extra_cfg->rc_max_inter_bitrate_pct; |
1103 | 7.79k | rc_cfg->gf_cbr_boost_pct = extra_cfg->gf_cbr_boost_pct; |
1104 | 7.79k | rc_cfg->mode = cfg->rc_end_usage; |
1105 | 7.79k | rc_cfg->min_cr = extra_cfg->min_cr; |
1106 | 7.79k | rc_cfg->best_allowed_q = |
1107 | 7.79k | extra_cfg->lossless ? 0 : av1_quantizer_to_qindex(cfg->rc_min_quantizer); |
1108 | 7.79k | rc_cfg->worst_allowed_q = |
1109 | 7.79k | extra_cfg->lossless ? 0 : av1_quantizer_to_qindex(cfg->rc_max_quantizer); |
1110 | 7.79k | rc_cfg->cq_level = av1_quantizer_to_qindex(extra_cfg->cq_level); |
1111 | 7.79k | rc_cfg->under_shoot_pct = cfg->rc_undershoot_pct; |
1112 | 7.79k | rc_cfg->over_shoot_pct = cfg->rc_overshoot_pct; |
1113 | 7.79k | rc_cfg->maximum_buffer_size_ms = is_vbr ? 240000 : cfg->rc_buf_sz; |
1114 | 7.79k | rc_cfg->starting_buffer_level_ms = is_vbr ? 60000 : cfg->rc_buf_initial_sz; |
1115 | 7.79k | rc_cfg->optimal_buffer_level_ms = is_vbr ? 60000 : cfg->rc_buf_optimal_sz; |
1116 | | // Convert target bandwidth from Kbit/s to Bit/s |
1117 | 7.79k | rc_cfg->target_bandwidth = 1000 * cfg->rc_target_bitrate; |
1118 | 7.79k | rc_cfg->drop_frames_water_mark = cfg->rc_dropframe_thresh; |
1119 | 7.79k | rc_cfg->vbr_corpus_complexity_lap = extra_cfg->vbr_corpus_complexity_lap; |
1120 | 7.79k | rc_cfg->vbrbias = cfg->rc_2pass_vbr_bias_pct; |
1121 | 7.79k | rc_cfg->vbrmin_section = cfg->rc_2pass_vbr_minsection_pct; |
1122 | 7.79k | rc_cfg->vbrmax_section = cfg->rc_2pass_vbr_maxsection_pct; |
1123 | | |
1124 | | // Set Toolset related configuration. |
1125 | 7.79k | tool_cfg->bit_depth = cfg->g_bit_depth; |
1126 | 7.79k | tool_cfg->cdef_control = (CDEF_CONTROL)extra_cfg->enable_cdef; |
1127 | 7.79k | tool_cfg->enable_restoration = |
1128 | 7.79k | (cfg->g_usage == AOM_USAGE_REALTIME) ? 0 : extra_cfg->enable_restoration; |
1129 | 7.79k | tool_cfg->force_video_mode = extra_cfg->force_video_mode; |
1130 | 7.79k | tool_cfg->enable_palette = extra_cfg->enable_palette; |
1131 | | // FIXME(debargha): Should this be: |
1132 | | // tool_cfg->enable_ref_frame_mvs = extra_cfg->allow_ref_frame_mvs & |
1133 | | // extra_cfg->enable_order_hint ? |
1134 | | // Disallow using temporal MVs while large_scale_tile = 1. |
1135 | 7.79k | tool_cfg->enable_ref_frame_mvs = |
1136 | 7.79k | extra_cfg->allow_ref_frame_mvs && !cfg->large_scale_tile; |
1137 | 7.79k | tool_cfg->superblock_size = extra_cfg->superblock_size; |
1138 | 7.79k | tool_cfg->enable_monochrome = cfg->monochrome; |
1139 | 7.79k | tool_cfg->full_still_picture_hdr = cfg->full_still_picture_hdr; |
1140 | 7.79k | tool_cfg->enable_dual_filter = extra_cfg->enable_dual_filter; |
1141 | 7.79k | tool_cfg->enable_order_hint = extra_cfg->enable_order_hint; |
1142 | 7.79k | tool_cfg->enable_interintra_comp = extra_cfg->enable_interintra_comp; |
1143 | 7.79k | tool_cfg->ref_frame_mvs_present = |
1144 | 7.79k | extra_cfg->enable_ref_frame_mvs & extra_cfg->enable_order_hint; |
1145 | 7.79k | tool_cfg->enable_global_motion = extra_cfg->enable_global_motion; |
1146 | 7.79k | tool_cfg->error_resilient_mode = |
1147 | 7.79k | cfg->g_error_resilient | extra_cfg->error_resilient_mode; |
1148 | 7.79k | tool_cfg->frame_parallel_decoding_mode = |
1149 | 7.79k | extra_cfg->frame_parallel_decoding_mode; |
1150 | | |
1151 | | // Set Quantization related configuration. |
1152 | 7.79k | q_cfg->using_qm = extra_cfg->enable_qm; |
1153 | 7.79k | q_cfg->qm_minlevel = extra_cfg->qm_min; |
1154 | 7.79k | q_cfg->qm_maxlevel = extra_cfg->qm_max; |
1155 | 7.79k | q_cfg->quant_b_adapt = extra_cfg->quant_b_adapt; |
1156 | 7.79k | q_cfg->enable_chroma_deltaq = extra_cfg->enable_chroma_deltaq; |
1157 | 7.79k | q_cfg->aq_mode = extra_cfg->aq_mode; |
1158 | 7.79k | q_cfg->deltaq_mode = extra_cfg->deltaq_mode; |
1159 | 7.79k | q_cfg->deltaq_strength = extra_cfg->deltaq_strength; |
1160 | 7.79k | q_cfg->use_fixed_qp_offsets = |
1161 | 7.79k | cfg->use_fixed_qp_offsets && (rc_cfg->mode == AOM_Q); |
1162 | 7.79k | q_cfg->enable_hdr_deltaq = |
1163 | 7.79k | (q_cfg->deltaq_mode == DELTA_Q_HDR) && |
1164 | 7.79k | (cfg->g_bit_depth == AOM_BITS_10) && |
1165 | 7.79k | (extra_cfg->color_primaries == AOM_CICP_CP_BT_2020); |
1166 | 46.7k | for (int i = 0; i < FIXED_QP_OFFSET_COUNT; ++i) { |
1167 | 38.9k | if (q_cfg->use_fixed_qp_offsets) { |
1168 | 0 | if (cfg->fixed_qp_offsets[i] >= 0) { // user-provided qp offset |
1169 | 0 | q_cfg->fixed_qp_offsets[i] = convert_qp_offset( |
1170 | 0 | rc_cfg->cq_level, cfg->fixed_qp_offsets[i], tool_cfg->bit_depth); |
1171 | 0 | } else { // auto-selected qp offset |
1172 | 0 | q_cfg->fixed_qp_offsets[i] = |
1173 | 0 | get_modeled_qp_offset(rc_cfg->cq_level, i, tool_cfg->bit_depth); |
1174 | 0 | } |
1175 | 38.9k | } else { |
1176 | 38.9k | q_cfg->fixed_qp_offsets[i] = -1.0; |
1177 | 38.9k | } |
1178 | 38.9k | } |
1179 | | |
1180 | 7.79k | tool_cfg->enable_deltalf_mode = |
1181 | 7.79k | (q_cfg->deltaq_mode != NO_DELTA_Q) && extra_cfg->deltalf_mode; |
1182 | | |
1183 | | // Set cost update frequency configuration. |
1184 | 7.79k | oxcf->cost_upd_freq.coeff = (COST_UPDATE_TYPE)extra_cfg->coeff_cost_upd_freq; |
1185 | 7.79k | oxcf->cost_upd_freq.mode = (COST_UPDATE_TYPE)extra_cfg->mode_cost_upd_freq; |
1186 | | // Avoid MV cost update for allintra encoding mode. |
1187 | 7.79k | oxcf->cost_upd_freq.mv = (cfg->kf_max_dist != 0) |
1188 | 7.79k | ? (COST_UPDATE_TYPE)extra_cfg->mv_cost_upd_freq |
1189 | 7.79k | : COST_UPD_OFF; |
1190 | 7.79k | oxcf->cost_upd_freq.dv = (COST_UPDATE_TYPE)extra_cfg->dv_cost_upd_freq; |
1191 | | |
1192 | | // Set frame resize mode configuration. |
1193 | 7.79k | resize_cfg->resize_mode = (RESIZE_MODE)cfg->rc_resize_mode; |
1194 | 7.79k | resize_cfg->resize_scale_denominator = (uint8_t)cfg->rc_resize_denominator; |
1195 | 7.79k | resize_cfg->resize_kf_scale_denominator = |
1196 | 7.79k | (uint8_t)cfg->rc_resize_kf_denominator; |
1197 | 7.79k | if (resize_cfg->resize_mode == RESIZE_FIXED && |
1198 | 7.79k | resize_cfg->resize_scale_denominator == SCALE_NUMERATOR && |
1199 | 7.79k | resize_cfg->resize_kf_scale_denominator == SCALE_NUMERATOR) |
1200 | 0 | resize_cfg->resize_mode = RESIZE_NONE; |
1201 | | |
1202 | | // Set encoder algorithm related configuration. |
1203 | 7.79k | algo_cfg->enable_overlay = extra_cfg->enable_overlay; |
1204 | 7.79k | algo_cfg->disable_trellis_quant = extra_cfg->disable_trellis_quant; |
1205 | 7.79k | algo_cfg->sharpness = extra_cfg->sharpness; |
1206 | 7.79k | algo_cfg->arnr_max_frames = extra_cfg->arnr_max_frames; |
1207 | 7.79k | algo_cfg->arnr_strength = extra_cfg->arnr_strength; |
1208 | 7.79k | algo_cfg->cdf_update_mode = (uint8_t)extra_cfg->cdf_update_mode; |
1209 | | // TODO(any): Fix and Enable TPL for resize-mode > 0 |
1210 | 7.79k | algo_cfg->enable_tpl_model = |
1211 | 7.79k | resize_cfg->resize_mode ? 0 : extra_cfg->enable_tpl_model; |
1212 | 7.79k | algo_cfg->loopfilter_control = extra_cfg->loopfilter_control; |
1213 | | |
1214 | | // Set two-pass stats configuration. |
1215 | 7.79k | oxcf->twopass_stats_in = cfg->rc_twopass_stats_in; |
1216 | | |
1217 | 7.79k | if (extra_cfg->two_pass_output) |
1218 | 0 | oxcf->two_pass_output = extra_cfg->two_pass_output; |
1219 | | |
1220 | 7.79k | oxcf->second_pass_log = extra_cfg->second_pass_log; |
1221 | | |
1222 | | // Set Key frame configuration. |
1223 | 7.79k | kf_cfg->fwd_kf_enabled = cfg->fwd_kf_enabled; |
1224 | 7.79k | kf_cfg->auto_key = |
1225 | 7.79k | cfg->kf_mode == AOM_KF_AUTO && cfg->kf_min_dist != cfg->kf_max_dist; |
1226 | 7.79k | kf_cfg->key_freq_min = cfg->kf_min_dist; |
1227 | 7.79k | kf_cfg->key_freq_max = cfg->kf_max_dist; |
1228 | 7.79k | kf_cfg->sframe_dist = cfg->sframe_dist; |
1229 | 7.79k | kf_cfg->sframe_mode = cfg->sframe_mode; |
1230 | 7.79k | kf_cfg->enable_sframe = extra_cfg->s_frame_mode; |
1231 | 7.79k | kf_cfg->enable_keyframe_filtering = extra_cfg->enable_keyframe_filtering; |
1232 | 7.79k | kf_cfg->fwd_kf_dist = extra_cfg->fwd_kf_dist; |
1233 | | // Disable key frame filtering in all intra mode. |
1234 | 7.79k | if (cfg->kf_max_dist == 0) { |
1235 | 7.79k | kf_cfg->enable_keyframe_filtering = 0; |
1236 | 7.79k | } |
1237 | 7.79k | kf_cfg->enable_intrabc = extra_cfg->enable_intrabc; |
1238 | | |
1239 | 7.79k | oxcf->speed = extra_cfg->cpu_used; |
1240 | | |
1241 | | // Set Color related configuration. |
1242 | 7.79k | color_cfg->color_primaries = extra_cfg->color_primaries; |
1243 | 7.79k | color_cfg->transfer_characteristics = extra_cfg->transfer_characteristics; |
1244 | 7.79k | color_cfg->matrix_coefficients = extra_cfg->matrix_coefficients; |
1245 | 7.79k | color_cfg->color_range = extra_cfg->color_range; |
1246 | 7.79k | color_cfg->chroma_sample_position = extra_cfg->chroma_sample_position; |
1247 | | |
1248 | | // Set Group of frames configuration. |
1249 | | // Force lag_in_frames to 0 for REALTIME mode |
1250 | 7.79k | gf_cfg->lag_in_frames = (oxcf->mode == REALTIME) |
1251 | 7.79k | ? 0 |
1252 | 7.79k | : clamp(cfg->g_lag_in_frames, 0, MAX_LAG_BUFFERS); |
1253 | 7.79k | gf_cfg->enable_auto_arf = extra_cfg->enable_auto_alt_ref; |
1254 | 7.79k | gf_cfg->enable_auto_brf = extra_cfg->enable_auto_bwd_ref; |
1255 | 7.79k | gf_cfg->min_gf_interval = extra_cfg->min_gf_interval; |
1256 | 7.79k | gf_cfg->max_gf_interval = extra_cfg->max_gf_interval; |
1257 | 7.79k | gf_cfg->gf_min_pyr_height = extra_cfg->gf_min_pyr_height; |
1258 | 7.79k | gf_cfg->gf_max_pyr_height = extra_cfg->gf_max_pyr_height; |
1259 | | |
1260 | | // Set tune related configuration. |
1261 | 7.79k | tune_cfg->tuning = extra_cfg->tuning; |
1262 | 7.79k | tune_cfg->vmaf_model_path = extra_cfg->vmaf_model_path; |
1263 | 7.79k | tune_cfg->content = extra_cfg->content; |
1264 | 7.79k | if (cfg->large_scale_tile) { |
1265 | 0 | tune_cfg->film_grain_test_vector = 0; |
1266 | 0 | tune_cfg->film_grain_table_filename = NULL; |
1267 | 7.79k | } else { |
1268 | 7.79k | tune_cfg->film_grain_test_vector = extra_cfg->film_grain_test_vector; |
1269 | 7.79k | tune_cfg->film_grain_table_filename = extra_cfg->film_grain_table_filename; |
1270 | 7.79k | } |
1271 | 7.79k | #if CONFIG_DENOISE |
1272 | 7.79k | oxcf->noise_level = extra_cfg->noise_level; |
1273 | 7.79k | oxcf->noise_block_size = extra_cfg->noise_block_size; |
1274 | 7.79k | oxcf->enable_dnl_denoising = extra_cfg->enable_dnl_denoising; |
1275 | 7.79k | #endif |
1276 | | |
1277 | | #if CONFIG_AV1_TEMPORAL_DENOISING |
1278 | | // Temporal denoiser is for nonrd pickmode so disable it for speed < 7. |
1279 | | // Also disable it for speed 7 for now since it needs to be modified for |
1280 | | // the check_partition_merge_mode feature. |
1281 | | if (cfg->g_bit_depth == AOM_BITS_8 && oxcf->speed > 7) { |
1282 | | oxcf->noise_sensitivity = extra_cfg->noise_sensitivity; |
1283 | | } else { |
1284 | | oxcf->noise_sensitivity = 0; |
1285 | | } |
1286 | | #endif |
1287 | | // Set Tile related configuration. |
1288 | 7.79k | tile_cfg->num_tile_groups = extra_cfg->num_tg; |
1289 | | // In large-scale tile encoding mode, num_tile_groups is always 1. |
1290 | 7.79k | if (cfg->large_scale_tile) tile_cfg->num_tile_groups = 1; |
1291 | 7.79k | tile_cfg->mtu = extra_cfg->mtu_size; |
1292 | 7.79k | tile_cfg->enable_large_scale_tile = cfg->large_scale_tile; |
1293 | 7.79k | tile_cfg->enable_single_tile_decoding = |
1294 | 7.79k | (tile_cfg->enable_large_scale_tile) ? extra_cfg->single_tile_decoding : 0; |
1295 | 7.79k | tile_cfg->tile_columns = extra_cfg->tile_columns; |
1296 | 7.79k | tile_cfg->tile_rows = extra_cfg->tile_rows; |
1297 | 7.79k | tile_cfg->tile_width_count = AOMMIN(cfg->tile_width_count, MAX_TILE_COLS); |
1298 | 7.79k | tile_cfg->tile_height_count = AOMMIN(cfg->tile_height_count, MAX_TILE_ROWS); |
1299 | 7.79k | for (int i = 0; i < tile_cfg->tile_width_count; i++) { |
1300 | 0 | tile_cfg->tile_widths[i] = AOMMAX(cfg->tile_widths[i], 1); |
1301 | 0 | } |
1302 | 7.79k | for (int i = 0; i < tile_cfg->tile_height_count; i++) { |
1303 | 0 | tile_cfg->tile_heights[i] = AOMMAX(cfg->tile_heights[i], 1); |
1304 | 0 | } |
1305 | 7.79k | tile_cfg->enable_ext_tile_debug = extra_cfg->ext_tile_debug; |
1306 | | |
1307 | 7.79k | if (tile_cfg->enable_large_scale_tile) { |
1308 | | // The superblock_size can only be AOM_SUPERBLOCK_SIZE_64X64 or |
1309 | | // AOM_SUPERBLOCK_SIZE_128X128 while tile_cfg->enable_large_scale_tile = 1. |
1310 | | // If superblock_size = AOM_SUPERBLOCK_SIZE_DYNAMIC, hard set it to |
1311 | | // AOM_SUPERBLOCK_SIZE_64X64(default value in large_scale_tile). |
1312 | 0 | if (extra_cfg->superblock_size != AOM_SUPERBLOCK_SIZE_64X64 && |
1313 | 0 | extra_cfg->superblock_size != AOM_SUPERBLOCK_SIZE_128X128) |
1314 | 0 | tool_cfg->superblock_size = AOM_SUPERBLOCK_SIZE_64X64; |
1315 | 0 | } |
1316 | | |
1317 | | // Set reference frame related configuration. |
1318 | 7.79k | oxcf->ref_frm_cfg.max_reference_frames = extra_cfg->max_reference_frames; |
1319 | 7.79k | oxcf->ref_frm_cfg.enable_reduced_reference_set = |
1320 | 7.79k | extra_cfg->enable_reduced_reference_set; |
1321 | 7.79k | oxcf->ref_frm_cfg.enable_onesided_comp = extra_cfg->enable_onesided_comp; |
1322 | | |
1323 | 7.79k | oxcf->row_mt = extra_cfg->row_mt; |
1324 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
1325 | | oxcf->fp_mt = extra_cfg->fp_mt; |
1326 | | #endif |
1327 | | |
1328 | | // Set motion mode related configuration. |
1329 | 7.79k | oxcf->motion_mode_cfg.enable_obmc = extra_cfg->enable_obmc; |
1330 | 7.79k | oxcf->motion_mode_cfg.enable_warped_motion = extra_cfg->enable_warped_motion; |
1331 | 7.79k | #if !CONFIG_REALTIME_ONLY |
1332 | 7.79k | oxcf->motion_mode_cfg.allow_warped_motion = |
1333 | 7.79k | (extra_cfg->allow_warped_motion & extra_cfg->enable_warped_motion); |
1334 | | #else |
1335 | | oxcf->motion_mode_cfg.allow_warped_motion = |
1336 | | (cfg->g_usage == AOM_USAGE_REALTIME && oxcf->speed >= 7) |
1337 | | ? false |
1338 | | : (extra_cfg->allow_warped_motion & extra_cfg->enable_warped_motion); |
1339 | | #endif |
1340 | | |
1341 | | // Set partition related configuration. |
1342 | 7.79k | part_cfg->enable_rect_partitions = extra_cfg->enable_rect_partitions; |
1343 | 7.79k | part_cfg->enable_ab_partitions = extra_cfg->enable_ab_partitions; |
1344 | 7.79k | part_cfg->enable_1to4_partitions = extra_cfg->enable_1to4_partitions; |
1345 | 7.79k | part_cfg->min_partition_size = extra_cfg->min_partition_size; |
1346 | 7.79k | part_cfg->max_partition_size = extra_cfg->max_partition_size; |
1347 | | |
1348 | | // Set intra mode configuration. |
1349 | 7.79k | intra_mode_cfg->enable_angle_delta = extra_cfg->enable_angle_delta; |
1350 | 7.79k | intra_mode_cfg->enable_intra_edge_filter = |
1351 | 7.79k | extra_cfg->enable_intra_edge_filter; |
1352 | 7.79k | intra_mode_cfg->enable_filter_intra = extra_cfg->enable_filter_intra; |
1353 | 7.79k | intra_mode_cfg->enable_smooth_intra = extra_cfg->enable_smooth_intra; |
1354 | 7.79k | intra_mode_cfg->enable_paeth_intra = extra_cfg->enable_paeth_intra; |
1355 | 7.79k | intra_mode_cfg->enable_cfl_intra = extra_cfg->enable_cfl_intra; |
1356 | 7.79k | intra_mode_cfg->enable_directional_intra = |
1357 | 7.79k | extra_cfg->enable_directional_intra; |
1358 | 7.79k | intra_mode_cfg->enable_diagonal_intra = extra_cfg->enable_diagonal_intra; |
1359 | 7.79k | intra_mode_cfg->auto_intra_tools_off = extra_cfg->auto_intra_tools_off; |
1360 | | |
1361 | | // Set transform size/type configuration. |
1362 | 7.79k | txfm_cfg->enable_tx64 = extra_cfg->enable_tx64; |
1363 | 7.79k | txfm_cfg->enable_flip_idtx = extra_cfg->enable_flip_idtx; |
1364 | 7.79k | txfm_cfg->enable_rect_tx = extra_cfg->enable_rect_tx; |
1365 | 7.79k | txfm_cfg->reduced_tx_type_set = extra_cfg->reduced_tx_type_set; |
1366 | 7.79k | txfm_cfg->use_intra_dct_only = extra_cfg->use_intra_dct_only; |
1367 | 7.79k | txfm_cfg->use_inter_dct_only = extra_cfg->use_inter_dct_only; |
1368 | 7.79k | txfm_cfg->use_intra_default_tx_only = extra_cfg->use_intra_default_tx_only; |
1369 | 7.79k | txfm_cfg->enable_tx_size_search = extra_cfg->enable_tx_size_search; |
1370 | | |
1371 | | // Set compound type configuration. |
1372 | 7.79k | comp_type_cfg->enable_dist_wtd_comp = |
1373 | 7.79k | extra_cfg->enable_dist_wtd_comp & extra_cfg->enable_order_hint; |
1374 | 7.79k | comp_type_cfg->enable_masked_comp = extra_cfg->enable_masked_comp; |
1375 | 7.79k | comp_type_cfg->enable_diff_wtd_comp = |
1376 | 7.79k | extra_cfg->enable_masked_comp & extra_cfg->enable_diff_wtd_comp; |
1377 | 7.79k | comp_type_cfg->enable_interinter_wedge = |
1378 | 7.79k | extra_cfg->enable_masked_comp & extra_cfg->enable_interinter_wedge; |
1379 | 7.79k | comp_type_cfg->enable_smooth_interintra = |
1380 | 7.79k | extra_cfg->enable_interintra_comp && extra_cfg->enable_smooth_interintra; |
1381 | 7.79k | comp_type_cfg->enable_interintra_wedge = |
1382 | 7.79k | extra_cfg->enable_interintra_comp & extra_cfg->enable_interintra_wedge; |
1383 | | |
1384 | | // Set Super-resolution mode configuration. |
1385 | 7.79k | if (extra_cfg->lossless || cfg->large_scale_tile) { |
1386 | 225 | disable_superres(superres_cfg); |
1387 | 7.57k | } else { |
1388 | 7.57k | superres_cfg->superres_mode = cfg->rc_superres_mode; |
1389 | 7.57k | superres_cfg->superres_scale_denominator = |
1390 | 7.57k | (uint8_t)cfg->rc_superres_denominator; |
1391 | 7.57k | superres_cfg->superres_kf_scale_denominator = |
1392 | 7.57k | (uint8_t)cfg->rc_superres_kf_denominator; |
1393 | 7.57k | superres_cfg->superres_qthresh = |
1394 | 7.57k | av1_quantizer_to_qindex(cfg->rc_superres_qthresh); |
1395 | 7.57k | superres_cfg->superres_kf_qthresh = |
1396 | 7.57k | av1_quantizer_to_qindex(cfg->rc_superres_kf_qthresh); |
1397 | 7.57k | if (superres_cfg->superres_mode == AOM_SUPERRES_FIXED && |
1398 | 7.57k | superres_cfg->superres_scale_denominator == SCALE_NUMERATOR && |
1399 | 7.57k | superres_cfg->superres_kf_scale_denominator == SCALE_NUMERATOR) { |
1400 | 0 | disable_superres(superres_cfg); |
1401 | 0 | } |
1402 | 7.57k | if (superres_cfg->superres_mode == AOM_SUPERRES_QTHRESH && |
1403 | 7.57k | superres_cfg->superres_qthresh == 255 && |
1404 | 7.57k | superres_cfg->superres_kf_qthresh == 255) { |
1405 | 0 | disable_superres(superres_cfg); |
1406 | 0 | } |
1407 | 7.57k | } |
1408 | | |
1409 | 7.79k | superres_cfg->enable_superres = |
1410 | 7.79k | (superres_cfg->superres_mode != AOM_SUPERRES_NONE) && |
1411 | 7.79k | extra_cfg->enable_superres; |
1412 | 7.79k | if (!superres_cfg->enable_superres) { |
1413 | 7.79k | disable_superres(superres_cfg); |
1414 | 7.79k | } |
1415 | | |
1416 | 7.79k | if (input_cfg->limit == 1) { |
1417 | | // still picture mode, display model and timing is meaningless |
1418 | 7.79k | dec_model_cfg->display_model_info_present_flag = 0; |
1419 | 7.79k | dec_model_cfg->timing_info_present = 0; |
1420 | 7.79k | } |
1421 | | |
1422 | 7.79k | oxcf->save_as_annexb = cfg->save_as_annexb; |
1423 | | |
1424 | | // Set unit test related configuration. |
1425 | 7.79k | oxcf->unit_test_cfg.motion_vector_unit_test = |
1426 | 7.79k | extra_cfg->motion_vector_unit_test; |
1427 | 7.79k | oxcf->unit_test_cfg.sb_multipass_unit_test = |
1428 | 7.79k | extra_cfg->sb_multipass_unit_test; |
1429 | | |
1430 | | // For allintra encoding mode, inter-frame motion search is not applicable and |
1431 | | // the intraBC motion vectors are restricted within the tile boundaries. Hence |
1432 | | // a smaller frame border size (AOM_ENC_ALLINTRA_BORDER) is used in this case. |
1433 | 7.79k | oxcf->border_in_pixels = |
1434 | 7.79k | (resize_cfg->resize_mode || superres_cfg->superres_mode) |
1435 | 7.79k | ? AOM_BORDER_IN_PIXELS |
1436 | 7.79k | : (oxcf->kf_cfg.key_freq_max == 0) ? AOM_ENC_ALLINTRA_BORDER |
1437 | 7.79k | : AOM_ENC_NO_SCALE_BORDER; |
1438 | 7.79k | memcpy(oxcf->target_seq_level_idx, extra_cfg->target_seq_level_idx, |
1439 | 7.79k | sizeof(oxcf->target_seq_level_idx)); |
1440 | 7.79k | oxcf->tier_mask = extra_cfg->tier_mask; |
1441 | | |
1442 | 7.79k | oxcf->partition_info_path = extra_cfg->partition_info_path; |
1443 | | |
1444 | 7.79k | return AOM_CODEC_OK; |
1445 | 7.79k | } |
1446 | | |
1447 | | static aom_codec_err_t encoder_set_config(aom_codec_alg_priv_t *ctx, |
1448 | 0 | const aom_codec_enc_cfg_t *cfg) { |
1449 | 0 | InitialDimensions *const initial_dimensions = |
1450 | 0 | &ctx->ppi->cpi->initial_dimensions; |
1451 | 0 | aom_codec_err_t res; |
1452 | 0 | int force_key = 0; |
1453 | |
|
1454 | 0 | if (cfg->g_w != ctx->cfg.g_w || cfg->g_h != ctx->cfg.g_h) { |
1455 | 0 | if (cfg->g_lag_in_frames > 1 || cfg->g_pass != AOM_RC_ONE_PASS) |
1456 | 0 | ERROR("Cannot change width or height after initialization"); |
1457 | 0 | if (!valid_ref_frame_size(ctx->cfg.g_w, ctx->cfg.g_h, cfg->g_w, cfg->g_h) || |
1458 | 0 | (initial_dimensions->width && |
1459 | 0 | (int)cfg->g_w > initial_dimensions->width) || |
1460 | 0 | (initial_dimensions->height && |
1461 | 0 | (int)cfg->g_h > initial_dimensions->height)) |
1462 | 0 | force_key = 1; |
1463 | 0 | } |
1464 | | |
1465 | | // Prevent increasing lag_in_frames. This check is stricter than it needs |
1466 | | // to be -- the limit is not increasing past the first lag_in_frames |
1467 | | // value, but we don't track the initial config, only the last successful |
1468 | | // config. |
1469 | 0 | if (cfg->g_lag_in_frames > ctx->cfg.g_lag_in_frames) |
1470 | 0 | ERROR("Cannot increase lag_in_frames"); |
1471 | | // Prevent changing lag_in_frames if Lookahead Processing is enabled |
1472 | 0 | if (cfg->g_lag_in_frames != ctx->cfg.g_lag_in_frames && |
1473 | 0 | ctx->num_lap_buffers > 0) |
1474 | 0 | ERROR("Cannot change lag_in_frames if LAP is enabled"); |
1475 | | |
1476 | 0 | res = validate_config(ctx, cfg, &ctx->extra_cfg); |
1477 | |
|
1478 | 0 | if (res == AOM_CODEC_OK) { |
1479 | 0 | ctx->cfg = *cfg; |
1480 | 0 | set_encoder_config(&ctx->oxcf, &ctx->cfg, &ctx->extra_cfg); |
1481 | | // On profile change, request a key frame |
1482 | 0 | force_key |= ctx->ppi->seq_params.profile != ctx->oxcf.profile; |
1483 | 0 | bool is_sb_size_changed = false; |
1484 | 0 | av1_change_config_seq(ctx->ppi, &ctx->oxcf, &is_sb_size_changed); |
1485 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
1486 | | int i; |
1487 | | for (i = 0; i < ctx->ppi->num_fp_contexts; i++) { |
1488 | | av1_change_config(ctx->ppi->parallel_cpi[i], &ctx->oxcf, |
1489 | | is_sb_size_changed); |
1490 | | } |
1491 | | #else |
1492 | 0 | av1_change_config(ctx->ppi->cpi, &ctx->oxcf, is_sb_size_changed); |
1493 | 0 | #endif // CONFIG_FRAME_PARALLEL_ENCODE |
1494 | 0 | if (ctx->ppi->cpi_lap != NULL) { |
1495 | 0 | av1_change_config(ctx->ppi->cpi_lap, &ctx->oxcf, is_sb_size_changed); |
1496 | 0 | } |
1497 | 0 | } |
1498 | |
|
1499 | 0 | if (force_key) ctx->next_frame_flags |= AOM_EFLAG_FORCE_KF; |
1500 | |
|
1501 | 0 | return res; |
1502 | 0 | } |
1503 | | |
1504 | 0 | static aom_fixed_buf_t *encoder_get_global_headers(aom_codec_alg_priv_t *ctx) { |
1505 | 0 | return av1_get_global_headers(ctx->ppi); |
1506 | 0 | } |
1507 | | |
1508 | | static aom_codec_err_t ctrl_get_quantizer(aom_codec_alg_priv_t *ctx, |
1509 | 0 | va_list args) { |
1510 | 0 | int *const arg = va_arg(args, int *); |
1511 | 0 | if (arg == NULL) return AOM_CODEC_INVALID_PARAM; |
1512 | 0 | *arg = av1_get_quantizer(ctx->ppi->cpi); |
1513 | 0 | return AOM_CODEC_OK; |
1514 | 0 | } |
1515 | | |
1516 | | static aom_codec_err_t ctrl_get_quantizer64(aom_codec_alg_priv_t *ctx, |
1517 | 0 | va_list args) { |
1518 | 0 | int *const arg = va_arg(args, int *); |
1519 | 0 | if (arg == NULL) return AOM_CODEC_INVALID_PARAM; |
1520 | 0 | *arg = av1_qindex_to_quantizer(av1_get_quantizer(ctx->ppi->cpi)); |
1521 | 0 | return AOM_CODEC_OK; |
1522 | 0 | } |
1523 | | |
1524 | | static aom_codec_err_t ctrl_get_loopfilter_level(aom_codec_alg_priv_t *ctx, |
1525 | 0 | va_list args) { |
1526 | 0 | int *const arg = va_arg(args, int *); |
1527 | 0 | if (arg == NULL) return AOM_CODEC_INVALID_PARAM; |
1528 | 0 | *arg = ctx->ppi->cpi->common.lf.filter_level[0]; |
1529 | 0 | return AOM_CODEC_OK; |
1530 | 0 | } |
1531 | | |
1532 | | static aom_codec_err_t ctrl_get_baseline_gf_interval(aom_codec_alg_priv_t *ctx, |
1533 | 0 | va_list args) { |
1534 | 0 | int *const arg = va_arg(args, int *); |
1535 | 0 | if (arg == NULL) return AOM_CODEC_INVALID_PARAM; |
1536 | 0 | *arg = ctx->ppi->p_rc.baseline_gf_interval; |
1537 | 0 | return AOM_CODEC_OK; |
1538 | 0 | } |
1539 | | |
1540 | | static aom_codec_err_t update_extra_cfg(aom_codec_alg_priv_t *ctx, |
1541 | 6.53k | struct av1_extracfg *extra_cfg) { |
1542 | 6.53k | const aom_codec_err_t res = validate_config(ctx, &ctx->cfg, extra_cfg); |
1543 | 6.53k | if (res == AOM_CODEC_OK) { |
1544 | 6.53k | ctx->extra_cfg = *extra_cfg; |
1545 | 6.53k | set_encoder_config(&ctx->oxcf, &ctx->cfg, &ctx->extra_cfg); |
1546 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
1547 | | av1_check_fpmt_config(ctx->ppi, &ctx->oxcf); |
1548 | | #endif |
1549 | 6.53k | bool is_sb_size_changed = false; |
1550 | 6.53k | av1_change_config_seq(ctx->ppi, &ctx->oxcf, &is_sb_size_changed); |
1551 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
1552 | | int i; |
1553 | | for (i = 0; i < ctx->ppi->num_fp_contexts; i++) { |
1554 | | av1_change_config(ctx->ppi->parallel_cpi[i], &ctx->oxcf, |
1555 | | is_sb_size_changed); |
1556 | | } |
1557 | | #else |
1558 | 6.53k | av1_change_config(ctx->ppi->cpi, &ctx->oxcf, is_sb_size_changed); |
1559 | 6.53k | #endif // CONFIG_FRAME_PARALLEL_ENCODE |
1560 | 6.53k | if (ctx->ppi->cpi_lap != NULL) { |
1561 | 0 | av1_change_config(ctx->ppi->cpi_lap, &ctx->oxcf, is_sb_size_changed); |
1562 | 0 | } |
1563 | 6.53k | } |
1564 | 6.53k | return res; |
1565 | 6.53k | } |
1566 | | |
1567 | | static aom_codec_err_t ctrl_set_cpuused(aom_codec_alg_priv_t *ctx, |
1568 | 1.26k | va_list args) { |
1569 | 1.26k | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1570 | 1.26k | extra_cfg.cpu_used = CAST(AOME_SET_CPUUSED, args); |
1571 | 1.26k | return update_extra_cfg(ctx, &extra_cfg); |
1572 | 1.26k | } |
1573 | | |
1574 | | static aom_codec_err_t ctrl_set_enable_auto_alt_ref(aom_codec_alg_priv_t *ctx, |
1575 | 0 | va_list args) { |
1576 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1577 | 0 | extra_cfg.enable_auto_alt_ref = CAST(AOME_SET_ENABLEAUTOALTREF, args); |
1578 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1579 | 0 | } |
1580 | | |
1581 | | static aom_codec_err_t ctrl_set_enable_auto_bwd_ref(aom_codec_alg_priv_t *ctx, |
1582 | 0 | va_list args) { |
1583 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1584 | 0 | extra_cfg.enable_auto_bwd_ref = CAST(AOME_SET_ENABLEAUTOBWDREF, args); |
1585 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1586 | 0 | } |
1587 | | |
1588 | | static aom_codec_err_t ctrl_set_noise_sensitivity(aom_codec_alg_priv_t *ctx, |
1589 | 0 | va_list args) { |
1590 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1591 | 0 | extra_cfg.noise_sensitivity = CAST(AV1E_SET_NOISE_SENSITIVITY, args); |
1592 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1593 | 0 | } |
1594 | | |
1595 | | static aom_codec_err_t ctrl_set_sharpness(aom_codec_alg_priv_t *ctx, |
1596 | 0 | va_list args) { |
1597 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1598 | 0 | extra_cfg.sharpness = CAST(AOME_SET_SHARPNESS, args); |
1599 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1600 | 0 | } |
1601 | | |
1602 | | static aom_codec_err_t ctrl_set_static_thresh(aom_codec_alg_priv_t *ctx, |
1603 | 0 | va_list args) { |
1604 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1605 | 0 | extra_cfg.static_thresh = CAST(AOME_SET_STATIC_THRESHOLD, args); |
1606 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1607 | 0 | } |
1608 | | |
1609 | | static aom_codec_err_t ctrl_set_row_mt(aom_codec_alg_priv_t *ctx, |
1610 | 0 | va_list args) { |
1611 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1612 | 0 | extra_cfg.row_mt = CAST(AV1E_SET_ROW_MT, args); |
1613 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1614 | 0 | } |
1615 | | |
1616 | | static aom_codec_err_t ctrl_set_tile_columns(aom_codec_alg_priv_t *ctx, |
1617 | 0 | va_list args) { |
1618 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1619 | 0 | extra_cfg.tile_columns = CAST(AV1E_SET_TILE_COLUMNS, args); |
1620 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1621 | 0 | } |
1622 | | |
1623 | | static aom_codec_err_t ctrl_set_tile_rows(aom_codec_alg_priv_t *ctx, |
1624 | 0 | va_list args) { |
1625 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1626 | 0 | extra_cfg.tile_rows = CAST(AV1E_SET_TILE_ROWS, args); |
1627 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1628 | 0 | } |
1629 | | |
1630 | | static aom_codec_err_t ctrl_set_enable_tpl_model(aom_codec_alg_priv_t *ctx, |
1631 | 0 | va_list args) { |
1632 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1633 | 0 | const unsigned int tpl_model_arg = CAST(AV1E_SET_ENABLE_TPL_MODEL, args); |
1634 | | #if CONFIG_REALTIME_ONLY |
1635 | | if (tpl_model_arg) { |
1636 | | ERROR("TPL model can't be turned on in realtime only build."); |
1637 | | } |
1638 | | #endif |
1639 | 0 | extra_cfg.enable_tpl_model = tpl_model_arg; |
1640 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1641 | 0 | } |
1642 | | |
1643 | | static aom_codec_err_t ctrl_set_enable_keyframe_filtering( |
1644 | 0 | aom_codec_alg_priv_t *ctx, va_list args) { |
1645 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1646 | 0 | extra_cfg.enable_keyframe_filtering = |
1647 | 0 | CAST(AV1E_SET_ENABLE_KEYFRAME_FILTERING, args); |
1648 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1649 | 0 | } |
1650 | | |
1651 | | static aom_codec_err_t ctrl_set_arnr_max_frames(aom_codec_alg_priv_t *ctx, |
1652 | 0 | va_list args) { |
1653 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1654 | 0 | extra_cfg.arnr_max_frames = CAST(AOME_SET_ARNR_MAXFRAMES, args); |
1655 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1656 | 0 | } |
1657 | | |
1658 | | static aom_codec_err_t ctrl_set_arnr_strength(aom_codec_alg_priv_t *ctx, |
1659 | 0 | va_list args) { |
1660 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1661 | 0 | extra_cfg.arnr_strength = CAST(AOME_SET_ARNR_STRENGTH, args); |
1662 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1663 | 0 | } |
1664 | | |
1665 | | static aom_codec_err_t ctrl_set_tuning(aom_codec_alg_priv_t *ctx, |
1666 | 1.26k | va_list args) { |
1667 | 1.26k | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1668 | 1.26k | extra_cfg.tuning = CAST(AOME_SET_TUNING, args); |
1669 | 1.26k | return update_extra_cfg(ctx, &extra_cfg); |
1670 | 1.26k | } |
1671 | | |
1672 | | static aom_codec_err_t ctrl_set_cq_level(aom_codec_alg_priv_t *ctx, |
1673 | 1.26k | va_list args) { |
1674 | 1.26k | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1675 | 1.26k | extra_cfg.cq_level = CAST(AOME_SET_CQ_LEVEL, args); |
1676 | 1.26k | return update_extra_cfg(ctx, &extra_cfg); |
1677 | 1.26k | } |
1678 | | |
1679 | | static aom_codec_err_t ctrl_set_rc_max_intra_bitrate_pct( |
1680 | 0 | aom_codec_alg_priv_t *ctx, va_list args) { |
1681 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1682 | 0 | extra_cfg.rc_max_intra_bitrate_pct = |
1683 | 0 | CAST(AOME_SET_MAX_INTRA_BITRATE_PCT, args); |
1684 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1685 | 0 | } |
1686 | | |
1687 | | static aom_codec_err_t ctrl_set_rc_max_inter_bitrate_pct( |
1688 | 0 | aom_codec_alg_priv_t *ctx, va_list args) { |
1689 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1690 | 0 | extra_cfg.rc_max_inter_bitrate_pct = |
1691 | 0 | CAST(AOME_SET_MAX_INTER_BITRATE_PCT, args); |
1692 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1693 | 0 | } |
1694 | | |
1695 | | static aom_codec_err_t ctrl_set_rc_gf_cbr_boost_pct(aom_codec_alg_priv_t *ctx, |
1696 | 0 | va_list args) { |
1697 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1698 | 0 | extra_cfg.gf_cbr_boost_pct = CAST(AV1E_SET_GF_CBR_BOOST_PCT, args); |
1699 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1700 | 0 | } |
1701 | | |
1702 | | static aom_codec_err_t ctrl_set_lossless(aom_codec_alg_priv_t *ctx, |
1703 | 225 | va_list args) { |
1704 | 225 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1705 | 225 | extra_cfg.lossless = CAST(AV1E_SET_LOSSLESS, args); |
1706 | 225 | return update_extra_cfg(ctx, &extra_cfg); |
1707 | 225 | } |
1708 | | |
1709 | | static aom_codec_err_t ctrl_set_enable_cdef(aom_codec_alg_priv_t *ctx, |
1710 | 0 | va_list args) { |
1711 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1712 | 0 | extra_cfg.enable_cdef = CAST(AV1E_SET_ENABLE_CDEF, args); |
1713 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1714 | 0 | } |
1715 | | |
1716 | | static aom_codec_err_t ctrl_set_enable_restoration(aom_codec_alg_priv_t *ctx, |
1717 | 0 | va_list args) { |
1718 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1719 | 0 | const unsigned int restoration_arg = CAST(AV1E_SET_ENABLE_RESTORATION, args); |
1720 | | #if CONFIG_REALTIME_ONLY |
1721 | | if (restoration_arg) { |
1722 | | ERROR("Restoration can't be turned on in realtime only build."); |
1723 | | } |
1724 | | #endif |
1725 | 0 | extra_cfg.enable_restoration = restoration_arg; |
1726 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1727 | 0 | } |
1728 | | |
1729 | | static aom_codec_err_t ctrl_set_force_video_mode(aom_codec_alg_priv_t *ctx, |
1730 | 0 | va_list args) { |
1731 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1732 | 0 | extra_cfg.force_video_mode = CAST(AV1E_SET_FORCE_VIDEO_MODE, args); |
1733 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1734 | 0 | } |
1735 | | |
1736 | | static aom_codec_err_t ctrl_set_enable_obmc(aom_codec_alg_priv_t *ctx, |
1737 | 0 | va_list args) { |
1738 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1739 | 0 | const unsigned int obmc_arg = CAST(AV1E_SET_ENABLE_OBMC, args); |
1740 | | #if CONFIG_REALTIME_ONLY |
1741 | | if (obmc_arg) { |
1742 | | ERROR("OBMC can't be enabled in realtime only build."); |
1743 | | } |
1744 | | #endif |
1745 | 0 | extra_cfg.enable_obmc = obmc_arg; |
1746 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1747 | 0 | } |
1748 | | |
1749 | | static aom_codec_err_t ctrl_set_disable_trellis_quant(aom_codec_alg_priv_t *ctx, |
1750 | 0 | va_list args) { |
1751 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1752 | 0 | extra_cfg.disable_trellis_quant = CAST(AV1E_SET_DISABLE_TRELLIS_QUANT, args); |
1753 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1754 | 0 | } |
1755 | | |
1756 | | static aom_codec_err_t ctrl_set_enable_qm(aom_codec_alg_priv_t *ctx, |
1757 | 0 | va_list args) { |
1758 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1759 | 0 | extra_cfg.enable_qm = CAST(AV1E_SET_ENABLE_QM, args); |
1760 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1761 | 0 | } |
1762 | 0 | static aom_codec_err_t ctrl_set_qm_y(aom_codec_alg_priv_t *ctx, va_list args) { |
1763 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1764 | 0 | extra_cfg.qm_y = CAST(AV1E_SET_QM_Y, args); |
1765 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1766 | 0 | } |
1767 | 0 | static aom_codec_err_t ctrl_set_qm_u(aom_codec_alg_priv_t *ctx, va_list args) { |
1768 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1769 | 0 | extra_cfg.qm_u = CAST(AV1E_SET_QM_U, args); |
1770 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1771 | 0 | } |
1772 | 0 | static aom_codec_err_t ctrl_set_qm_v(aom_codec_alg_priv_t *ctx, va_list args) { |
1773 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1774 | 0 | extra_cfg.qm_v = CAST(AV1E_SET_QM_V, args); |
1775 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1776 | 0 | } |
1777 | | static aom_codec_err_t ctrl_set_qm_min(aom_codec_alg_priv_t *ctx, |
1778 | 0 | va_list args) { |
1779 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1780 | 0 | extra_cfg.qm_min = CAST(AV1E_SET_QM_MIN, args); |
1781 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1782 | 0 | } |
1783 | | |
1784 | | static aom_codec_err_t ctrl_set_qm_max(aom_codec_alg_priv_t *ctx, |
1785 | 0 | va_list args) { |
1786 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1787 | 0 | extra_cfg.qm_max = CAST(AV1E_SET_QM_MAX, args); |
1788 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1789 | 0 | } |
1790 | | |
1791 | | static aom_codec_err_t ctrl_set_num_tg(aom_codec_alg_priv_t *ctx, |
1792 | 0 | va_list args) { |
1793 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1794 | 0 | extra_cfg.num_tg = CAST(AV1E_SET_NUM_TG, args); |
1795 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1796 | 0 | } |
1797 | | |
1798 | 0 | static aom_codec_err_t ctrl_set_mtu(aom_codec_alg_priv_t *ctx, va_list args) { |
1799 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1800 | 0 | extra_cfg.mtu_size = CAST(AV1E_SET_MTU, args); |
1801 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1802 | 0 | } |
1803 | | static aom_codec_err_t ctrl_set_timing_info_type(aom_codec_alg_priv_t *ctx, |
1804 | 0 | va_list args) { |
1805 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1806 | 0 | extra_cfg.timing_info_type = CAST(AV1E_SET_TIMING_INFO_TYPE, args); |
1807 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1808 | 0 | } |
1809 | | |
1810 | | static aom_codec_err_t ctrl_set_enable_dual_filter(aom_codec_alg_priv_t *ctx, |
1811 | 0 | va_list args) { |
1812 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1813 | 0 | extra_cfg.enable_dual_filter = CAST(AV1E_SET_ENABLE_DUAL_FILTER, args); |
1814 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1815 | 0 | } |
1816 | | |
1817 | | static aom_codec_err_t ctrl_set_enable_chroma_deltaq(aom_codec_alg_priv_t *ctx, |
1818 | 0 | va_list args) { |
1819 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1820 | 0 | extra_cfg.enable_chroma_deltaq = CAST(AV1E_SET_ENABLE_CHROMA_DELTAQ, args); |
1821 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1822 | 0 | } |
1823 | | |
1824 | | static aom_codec_err_t ctrl_set_enable_rect_partitions( |
1825 | 0 | aom_codec_alg_priv_t *ctx, va_list args) { |
1826 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1827 | 0 | extra_cfg.enable_rect_partitions = |
1828 | 0 | CAST(AV1E_SET_ENABLE_RECT_PARTITIONS, args); |
1829 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1830 | 0 | } |
1831 | | |
1832 | | static aom_codec_err_t ctrl_set_enable_ab_partitions(aom_codec_alg_priv_t *ctx, |
1833 | 0 | va_list args) { |
1834 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1835 | 0 | extra_cfg.enable_ab_partitions = CAST(AV1E_SET_ENABLE_AB_PARTITIONS, args); |
1836 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1837 | 0 | } |
1838 | | |
1839 | | static aom_codec_err_t ctrl_set_enable_1to4_partitions( |
1840 | 0 | aom_codec_alg_priv_t *ctx, va_list args) { |
1841 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1842 | 0 | extra_cfg.enable_1to4_partitions = |
1843 | 0 | CAST(AV1E_SET_ENABLE_1TO4_PARTITIONS, args); |
1844 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1845 | 0 | } |
1846 | | |
1847 | | static aom_codec_err_t ctrl_set_min_partition_size(aom_codec_alg_priv_t *ctx, |
1848 | 0 | va_list args) { |
1849 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1850 | 0 | extra_cfg.min_partition_size = CAST(AV1E_SET_MIN_PARTITION_SIZE, args); |
1851 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1852 | 0 | } |
1853 | | |
1854 | | static aom_codec_err_t ctrl_set_max_partition_size(aom_codec_alg_priv_t *ctx, |
1855 | 0 | va_list args) { |
1856 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1857 | 0 | extra_cfg.max_partition_size = CAST(AV1E_SET_MAX_PARTITION_SIZE, args); |
1858 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1859 | 0 | } |
1860 | | |
1861 | | static aom_codec_err_t ctrl_set_enable_intra_edge_filter( |
1862 | 0 | aom_codec_alg_priv_t *ctx, va_list args) { |
1863 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1864 | 0 | extra_cfg.enable_intra_edge_filter = |
1865 | 0 | CAST(AV1E_SET_ENABLE_INTRA_EDGE_FILTER, args); |
1866 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1867 | 0 | } |
1868 | | |
1869 | | static aom_codec_err_t ctrl_set_enable_order_hint(aom_codec_alg_priv_t *ctx, |
1870 | 0 | va_list args) { |
1871 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1872 | 0 | extra_cfg.enable_order_hint = CAST(AV1E_SET_ENABLE_ORDER_HINT, args); |
1873 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1874 | 0 | } |
1875 | | |
1876 | | static aom_codec_err_t ctrl_set_enable_tx64(aom_codec_alg_priv_t *ctx, |
1877 | 0 | va_list args) { |
1878 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1879 | 0 | extra_cfg.enable_tx64 = CAST(AV1E_SET_ENABLE_TX64, args); |
1880 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1881 | 0 | } |
1882 | | |
1883 | | static aom_codec_err_t ctrl_set_enable_flip_idtx(aom_codec_alg_priv_t *ctx, |
1884 | 0 | va_list args) { |
1885 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1886 | 0 | extra_cfg.enable_flip_idtx = CAST(AV1E_SET_ENABLE_FLIP_IDTX, args); |
1887 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1888 | 0 | } |
1889 | | |
1890 | | static aom_codec_err_t ctrl_set_enable_rect_tx(aom_codec_alg_priv_t *ctx, |
1891 | 0 | va_list args) { |
1892 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1893 | 0 | extra_cfg.enable_rect_tx = CAST(AV1E_SET_ENABLE_RECT_TX, args); |
1894 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1895 | 0 | } |
1896 | | |
1897 | | static aom_codec_err_t ctrl_set_enable_dist_wtd_comp(aom_codec_alg_priv_t *ctx, |
1898 | 0 | va_list args) { |
1899 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1900 | 0 | extra_cfg.enable_dist_wtd_comp = CAST(AV1E_SET_ENABLE_DIST_WTD_COMP, args); |
1901 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1902 | 0 | } |
1903 | | |
1904 | | static aom_codec_err_t ctrl_set_max_reference_frames(aom_codec_alg_priv_t *ctx, |
1905 | 0 | va_list args) { |
1906 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1907 | 0 | extra_cfg.max_reference_frames = CAST(AV1E_SET_MAX_REFERENCE_FRAMES, args); |
1908 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1909 | 0 | } |
1910 | | |
1911 | | static aom_codec_err_t ctrl_set_enable_reduced_reference_set( |
1912 | 0 | aom_codec_alg_priv_t *ctx, va_list args) { |
1913 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1914 | 0 | extra_cfg.enable_reduced_reference_set = |
1915 | 0 | CAST(AV1E_SET_REDUCED_REFERENCE_SET, args); |
1916 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1917 | 0 | } |
1918 | | |
1919 | | static aom_codec_err_t ctrl_set_enable_ref_frame_mvs(aom_codec_alg_priv_t *ctx, |
1920 | 0 | va_list args) { |
1921 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1922 | 0 | extra_cfg.enable_ref_frame_mvs = CAST(AV1E_SET_ENABLE_REF_FRAME_MVS, args); |
1923 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1924 | 0 | } |
1925 | | |
1926 | | static aom_codec_err_t ctrl_set_allow_ref_frame_mvs(aom_codec_alg_priv_t *ctx, |
1927 | 0 | va_list args) { |
1928 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1929 | 0 | extra_cfg.allow_ref_frame_mvs = CAST(AV1E_SET_ALLOW_REF_FRAME_MVS, args); |
1930 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1931 | 0 | } |
1932 | | |
1933 | | static aom_codec_err_t ctrl_set_enable_masked_comp(aom_codec_alg_priv_t *ctx, |
1934 | 0 | va_list args) { |
1935 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1936 | 0 | extra_cfg.enable_masked_comp = CAST(AV1E_SET_ENABLE_MASKED_COMP, args); |
1937 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1938 | 0 | } |
1939 | | |
1940 | | static aom_codec_err_t ctrl_set_enable_onesided_comp(aom_codec_alg_priv_t *ctx, |
1941 | 0 | va_list args) { |
1942 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1943 | 0 | extra_cfg.enable_onesided_comp = CAST(AV1E_SET_ENABLE_ONESIDED_COMP, args); |
1944 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1945 | 0 | } |
1946 | | |
1947 | | static aom_codec_err_t ctrl_set_enable_interintra_comp( |
1948 | 0 | aom_codec_alg_priv_t *ctx, va_list args) { |
1949 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1950 | 0 | extra_cfg.enable_interintra_comp = |
1951 | 0 | CAST(AV1E_SET_ENABLE_INTERINTRA_COMP, args); |
1952 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1953 | 0 | } |
1954 | | |
1955 | | static aom_codec_err_t ctrl_set_enable_smooth_interintra( |
1956 | 0 | aom_codec_alg_priv_t *ctx, va_list args) { |
1957 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1958 | 0 | extra_cfg.enable_smooth_interintra = |
1959 | 0 | CAST(AV1E_SET_ENABLE_SMOOTH_INTERINTRA, args); |
1960 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1961 | 0 | } |
1962 | | |
1963 | | static aom_codec_err_t ctrl_set_enable_diff_wtd_comp(aom_codec_alg_priv_t *ctx, |
1964 | 0 | va_list args) { |
1965 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1966 | 0 | extra_cfg.enable_diff_wtd_comp = CAST(AV1E_SET_ENABLE_DIFF_WTD_COMP, args); |
1967 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1968 | 0 | } |
1969 | | |
1970 | | static aom_codec_err_t ctrl_set_enable_interinter_wedge( |
1971 | 0 | aom_codec_alg_priv_t *ctx, va_list args) { |
1972 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1973 | 0 | extra_cfg.enable_interinter_wedge = |
1974 | 0 | CAST(AV1E_SET_ENABLE_INTERINTER_WEDGE, args); |
1975 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1976 | 0 | } |
1977 | | |
1978 | | static aom_codec_err_t ctrl_set_enable_interintra_wedge( |
1979 | 0 | aom_codec_alg_priv_t *ctx, va_list args) { |
1980 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1981 | 0 | extra_cfg.enable_interintra_wedge = |
1982 | 0 | CAST(AV1E_SET_ENABLE_INTERINTRA_WEDGE, args); |
1983 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1984 | 0 | } |
1985 | | |
1986 | | static aom_codec_err_t ctrl_set_enable_global_motion(aom_codec_alg_priv_t *ctx, |
1987 | 0 | va_list args) { |
1988 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
1989 | 0 | const int global_motion_arg = CAST(AV1E_SET_ENABLE_GLOBAL_MOTION, args); |
1990 | | #if CONFIG_REALTIME_ONLY |
1991 | | if (global_motion_arg) { |
1992 | | ERROR("Global motion can't be enabled in realtime only build."); |
1993 | | } |
1994 | | #endif |
1995 | 0 | extra_cfg.enable_global_motion = global_motion_arg; |
1996 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
1997 | 0 | } |
1998 | | |
1999 | | static aom_codec_err_t ctrl_set_enable_warped_motion(aom_codec_alg_priv_t *ctx, |
2000 | 0 | va_list args) { |
2001 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2002 | 0 | const int warped_motion_arg = CAST(AV1E_SET_ENABLE_WARPED_MOTION, args); |
2003 | | #if CONFIG_REALTIME_ONLY |
2004 | | if (warped_motion_arg) { |
2005 | | ERROR("Warped motion can't be enabled in realtime only build."); |
2006 | | } |
2007 | | #endif |
2008 | 0 | extra_cfg.enable_warped_motion = warped_motion_arg; |
2009 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2010 | 0 | } |
2011 | | |
2012 | | static aom_codec_err_t ctrl_set_allow_warped_motion(aom_codec_alg_priv_t *ctx, |
2013 | 0 | va_list args) { |
2014 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2015 | 0 | extra_cfg.allow_warped_motion = CAST(AV1E_SET_ALLOW_WARPED_MOTION, args); |
2016 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2017 | 0 | } |
2018 | | |
2019 | | static aom_codec_err_t ctrl_set_enable_filter_intra(aom_codec_alg_priv_t *ctx, |
2020 | 0 | va_list args) { |
2021 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2022 | 0 | extra_cfg.enable_filter_intra = CAST(AV1E_SET_ENABLE_FILTER_INTRA, args); |
2023 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2024 | 0 | } |
2025 | | |
2026 | | static aom_codec_err_t ctrl_set_enable_smooth_intra(aom_codec_alg_priv_t *ctx, |
2027 | 0 | va_list args) { |
2028 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2029 | 0 | extra_cfg.enable_smooth_intra = CAST(AV1E_SET_ENABLE_SMOOTH_INTRA, args); |
2030 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2031 | 0 | } |
2032 | | |
2033 | | static aom_codec_err_t ctrl_set_enable_directional_intra( |
2034 | 0 | aom_codec_alg_priv_t *ctx, va_list args) { |
2035 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2036 | 0 | extra_cfg.enable_directional_intra = |
2037 | 0 | CAST(AV1E_SET_ENABLE_DIRECTIONAL_INTRA, args); |
2038 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2039 | 0 | } |
2040 | | |
2041 | | static aom_codec_err_t ctrl_set_enable_diagonal_intra(aom_codec_alg_priv_t *ctx, |
2042 | 0 | va_list args) { |
2043 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2044 | 0 | extra_cfg.enable_diagonal_intra = CAST(AV1E_SET_ENABLE_DIAGONAL_INTRA, args); |
2045 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2046 | 0 | } |
2047 | | |
2048 | | static aom_codec_err_t ctrl_set_enable_paeth_intra(aom_codec_alg_priv_t *ctx, |
2049 | 0 | va_list args) { |
2050 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2051 | 0 | extra_cfg.enable_paeth_intra = CAST(AV1E_SET_ENABLE_PAETH_INTRA, args); |
2052 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2053 | 0 | } |
2054 | | |
2055 | | static aom_codec_err_t ctrl_set_enable_cfl_intra(aom_codec_alg_priv_t *ctx, |
2056 | 0 | va_list args) { |
2057 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2058 | 0 | extra_cfg.enable_cfl_intra = CAST(AV1E_SET_ENABLE_CFL_INTRA, args); |
2059 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2060 | 0 | } |
2061 | | |
2062 | | static aom_codec_err_t ctrl_set_enable_superres(aom_codec_alg_priv_t *ctx, |
2063 | 0 | va_list args) { |
2064 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2065 | 0 | extra_cfg.enable_superres = CAST(AV1E_SET_ENABLE_SUPERRES, args); |
2066 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2067 | 0 | } |
2068 | | |
2069 | | static aom_codec_err_t ctrl_set_enable_overlay(aom_codec_alg_priv_t *ctx, |
2070 | 0 | va_list args) { |
2071 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2072 | 0 | extra_cfg.enable_overlay = CAST(AV1E_SET_ENABLE_OVERLAY, args); |
2073 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2074 | 0 | } |
2075 | | |
2076 | | static aom_codec_err_t ctrl_set_enable_palette(aom_codec_alg_priv_t *ctx, |
2077 | 0 | va_list args) { |
2078 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2079 | 0 | extra_cfg.enable_palette = CAST(AV1E_SET_ENABLE_PALETTE, args); |
2080 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2081 | 0 | } |
2082 | | |
2083 | | static aom_codec_err_t ctrl_set_enable_intrabc(aom_codec_alg_priv_t *ctx, |
2084 | 0 | va_list args) { |
2085 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2086 | 0 | extra_cfg.enable_intrabc = CAST(AV1E_SET_ENABLE_INTRABC, args); |
2087 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2088 | 0 | } |
2089 | | |
2090 | | static aom_codec_err_t ctrl_set_enable_angle_delta(aom_codec_alg_priv_t *ctx, |
2091 | 0 | va_list args) { |
2092 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2093 | 0 | extra_cfg.enable_angle_delta = CAST(AV1E_SET_ENABLE_ANGLE_DELTA, args); |
2094 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2095 | 0 | } |
2096 | | |
2097 | | static aom_codec_err_t ctrl_set_error_resilient_mode(aom_codec_alg_priv_t *ctx, |
2098 | 0 | va_list args) { |
2099 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2100 | 0 | extra_cfg.error_resilient_mode = CAST(AV1E_SET_ERROR_RESILIENT_MODE, args); |
2101 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2102 | 0 | } |
2103 | | |
2104 | | static aom_codec_err_t ctrl_set_s_frame_mode(aom_codec_alg_priv_t *ctx, |
2105 | 0 | va_list args) { |
2106 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2107 | 0 | extra_cfg.s_frame_mode = CAST(AV1E_SET_S_FRAME_MODE, args); |
2108 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2109 | 0 | } |
2110 | | |
2111 | | static aom_codec_err_t ctrl_set_frame_parallel_decoding_mode( |
2112 | 0 | aom_codec_alg_priv_t *ctx, va_list args) { |
2113 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2114 | 0 | extra_cfg.frame_parallel_decoding_mode = |
2115 | 0 | CAST(AV1E_SET_FRAME_PARALLEL_DECODING, args); |
2116 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2117 | 0 | } |
2118 | | |
2119 | | static aom_codec_err_t ctrl_set_single_tile_decoding(aom_codec_alg_priv_t *ctx, |
2120 | 0 | va_list args) { |
2121 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2122 | 0 | extra_cfg.single_tile_decoding = CAST(AV1E_SET_SINGLE_TILE_DECODING, args); |
2123 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2124 | 0 | } |
2125 | | |
2126 | | static aom_codec_err_t ctrl_set_aq_mode(aom_codec_alg_priv_t *ctx, |
2127 | 0 | va_list args) { |
2128 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2129 | 0 | extra_cfg.aq_mode = CAST(AV1E_SET_AQ_MODE, args); |
2130 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2131 | 0 | } |
2132 | | |
2133 | | static aom_codec_err_t ctrl_set_reduced_tx_type_set(aom_codec_alg_priv_t *ctx, |
2134 | 0 | va_list args) { |
2135 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2136 | 0 | extra_cfg.reduced_tx_type_set = CAST(AV1E_SET_REDUCED_TX_TYPE_SET, args); |
2137 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2138 | 0 | } |
2139 | | |
2140 | | static aom_codec_err_t ctrl_set_intra_dct_only(aom_codec_alg_priv_t *ctx, |
2141 | 0 | va_list args) { |
2142 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2143 | 0 | extra_cfg.use_intra_dct_only = CAST(AV1E_SET_INTRA_DCT_ONLY, args); |
2144 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2145 | 0 | } |
2146 | | |
2147 | | static aom_codec_err_t ctrl_set_inter_dct_only(aom_codec_alg_priv_t *ctx, |
2148 | 0 | va_list args) { |
2149 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2150 | 0 | extra_cfg.use_inter_dct_only = CAST(AV1E_SET_INTER_DCT_ONLY, args); |
2151 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2152 | 0 | } |
2153 | | |
2154 | | static aom_codec_err_t ctrl_set_intra_default_tx_only(aom_codec_alg_priv_t *ctx, |
2155 | 0 | va_list args) { |
2156 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2157 | 0 | extra_cfg.use_intra_default_tx_only = |
2158 | 0 | CAST(AV1E_SET_INTRA_DEFAULT_TX_ONLY, args); |
2159 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2160 | 0 | } |
2161 | | |
2162 | | static aom_codec_err_t ctrl_set_enable_tx_size_search(aom_codec_alg_priv_t *ctx, |
2163 | 0 | va_list args) { |
2164 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2165 | 0 | extra_cfg.enable_tx_size_search = CAST(AV1E_SET_ENABLE_TX_SIZE_SEARCH, args); |
2166 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2167 | 0 | } |
2168 | | |
2169 | | static aom_codec_err_t ctrl_set_quant_b_adapt(aom_codec_alg_priv_t *ctx, |
2170 | 0 | va_list args) { |
2171 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2172 | 0 | extra_cfg.quant_b_adapt = CAST(AV1E_SET_QUANT_B_ADAPT, args); |
2173 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2174 | 0 | } |
2175 | | |
2176 | | static aom_codec_err_t ctrl_set_vbr_corpus_complexity_lap( |
2177 | 0 | aom_codec_alg_priv_t *ctx, va_list args) { |
2178 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2179 | 0 | extra_cfg.vbr_corpus_complexity_lap = |
2180 | 0 | CAST(AV1E_SET_VBR_CORPUS_COMPLEXITY_LAP, args); |
2181 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2182 | 0 | } |
2183 | | static aom_codec_err_t ctrl_set_coeff_cost_upd_freq(aom_codec_alg_priv_t *ctx, |
2184 | 0 | va_list args) { |
2185 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2186 | 0 | extra_cfg.coeff_cost_upd_freq = CAST(AV1E_SET_COEFF_COST_UPD_FREQ, args); |
2187 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2188 | 0 | } |
2189 | | |
2190 | | static aom_codec_err_t ctrl_set_mode_cost_upd_freq(aom_codec_alg_priv_t *ctx, |
2191 | 0 | va_list args) { |
2192 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2193 | 0 | extra_cfg.mode_cost_upd_freq = CAST(AV1E_SET_MODE_COST_UPD_FREQ, args); |
2194 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2195 | 0 | } |
2196 | | |
2197 | | static aom_codec_err_t ctrl_set_mv_cost_upd_freq(aom_codec_alg_priv_t *ctx, |
2198 | 0 | va_list args) { |
2199 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2200 | 0 | extra_cfg.mv_cost_upd_freq = CAST(AV1E_SET_MV_COST_UPD_FREQ, args); |
2201 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2202 | 0 | } |
2203 | | |
2204 | | static aom_codec_err_t ctrl_set_dv_cost_upd_freq(aom_codec_alg_priv_t *ctx, |
2205 | 0 | va_list args) { |
2206 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2207 | 0 | extra_cfg.dv_cost_upd_freq = CAST(AV1E_SET_DV_COST_UPD_FREQ, args); |
2208 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2209 | 0 | } |
2210 | | |
2211 | | static aom_codec_err_t ctrl_set_vmaf_model_path(aom_codec_alg_priv_t *ctx, |
2212 | 0 | va_list args) { |
2213 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2214 | 0 | const char *str = CAST(AV1E_SET_VMAF_MODEL_PATH, args); |
2215 | 0 | const aom_codec_err_t ret = allocate_and_set_string( |
2216 | 0 | str, default_extra_cfg.vmaf_model_path, &extra_cfg.vmaf_model_path, |
2217 | 0 | ctx->ppi->error.detail); |
2218 | 0 | if (ret != AOM_CODEC_OK) return ret; |
2219 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2220 | 0 | } |
2221 | | |
2222 | | static aom_codec_err_t ctrl_set_partition_info_path(aom_codec_alg_priv_t *ctx, |
2223 | 0 | va_list args) { |
2224 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2225 | 0 | const char *str = CAST(AV1E_SET_PARTITION_INFO_PATH, args); |
2226 | 0 | const aom_codec_err_t ret = allocate_and_set_string( |
2227 | 0 | str, default_extra_cfg.partition_info_path, |
2228 | 0 | &extra_cfg.partition_info_path, ctx->ppi->error.detail); |
2229 | 0 | if (ret != AOM_CODEC_OK) return ret; |
2230 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2231 | 0 | } |
2232 | | |
2233 | | static aom_codec_err_t ctrl_set_film_grain_test_vector( |
2234 | 0 | aom_codec_alg_priv_t *ctx, va_list args) { |
2235 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2236 | 0 | extra_cfg.film_grain_test_vector = |
2237 | 0 | CAST(AV1E_SET_FILM_GRAIN_TEST_VECTOR, args); |
2238 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2239 | 0 | } |
2240 | | |
2241 | | static aom_codec_err_t ctrl_set_film_grain_table(aom_codec_alg_priv_t *ctx, |
2242 | 0 | va_list args) { |
2243 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2244 | 0 | const char *str = CAST(AV1E_SET_FILM_GRAIN_TABLE, args); |
2245 | 0 | if (str == NULL) { |
2246 | | // this parameter allows NULL as its value |
2247 | 0 | extra_cfg.film_grain_table_filename = str; |
2248 | 0 | } else { |
2249 | 0 | const aom_codec_err_t ret = allocate_and_set_string( |
2250 | 0 | str, default_extra_cfg.film_grain_table_filename, |
2251 | 0 | &extra_cfg.film_grain_table_filename, ctx->ppi->error.detail); |
2252 | 0 | if (ret != AOM_CODEC_OK) return ret; |
2253 | 0 | } |
2254 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2255 | 0 | } |
2256 | | |
2257 | | static aom_codec_err_t ctrl_set_denoise_noise_level(aom_codec_alg_priv_t *ctx, |
2258 | 0 | va_list args) { |
2259 | | #if !CONFIG_DENOISE |
2260 | | (void)ctx; |
2261 | | (void)args; |
2262 | | return AOM_CODEC_INCAPABLE; |
2263 | | #else |
2264 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2265 | 0 | extra_cfg.noise_level = |
2266 | 0 | ((float)CAST(AV1E_SET_DENOISE_NOISE_LEVEL, args)) / 10.0f; |
2267 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2268 | 0 | #endif |
2269 | 0 | } |
2270 | | |
2271 | | static aom_codec_err_t ctrl_set_denoise_block_size(aom_codec_alg_priv_t *ctx, |
2272 | 0 | va_list args) { |
2273 | | #if !CONFIG_DENOISE |
2274 | | (void)ctx; |
2275 | | (void)args; |
2276 | | return AOM_CODEC_INCAPABLE; |
2277 | | #else |
2278 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2279 | 0 | extra_cfg.noise_block_size = CAST(AV1E_SET_DENOISE_BLOCK_SIZE, args); |
2280 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2281 | 0 | #endif |
2282 | 0 | } |
2283 | | |
2284 | | static aom_codec_err_t ctrl_set_enable_dnl_denoising(aom_codec_alg_priv_t *ctx, |
2285 | 0 | va_list args) { |
2286 | | #if !CONFIG_DENOISE |
2287 | | (void)ctx; |
2288 | | (void)args; |
2289 | | return AOM_CODEC_INCAPABLE; |
2290 | | #else |
2291 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2292 | 0 | extra_cfg.enable_dnl_denoising = CAST(AV1E_SET_ENABLE_DNL_DENOISING, args); |
2293 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2294 | 0 | #endif |
2295 | 0 | } |
2296 | | |
2297 | | static aom_codec_err_t ctrl_set_deltaq_mode(aom_codec_alg_priv_t *ctx, |
2298 | 0 | va_list args) { |
2299 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2300 | 0 | const DELTAQ_MODE deltaq_arg = CAST(AV1E_SET_DELTAQ_MODE, args); |
2301 | | #if CONFIG_REALTIME_ONLY |
2302 | | if (deltaq_arg > NO_DELTA_Q) { |
2303 | | ERROR("Delta Q mode can't be enabled in realtime only build."); |
2304 | | } |
2305 | | #endif |
2306 | 0 | extra_cfg.deltaq_mode = deltaq_arg; |
2307 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2308 | 0 | } |
2309 | | |
2310 | | static aom_codec_err_t ctrl_set_deltaq_strength(aom_codec_alg_priv_t *ctx, |
2311 | 0 | va_list args) { |
2312 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2313 | 0 | extra_cfg.deltaq_strength = CAST(AV1E_SET_DELTAQ_STRENGTH, args); |
2314 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2315 | 0 | } |
2316 | | |
2317 | | static aom_codec_err_t ctrl_set_deltalf_mode(aom_codec_alg_priv_t *ctx, |
2318 | 0 | va_list args) { |
2319 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2320 | 0 | extra_cfg.deltalf_mode = CAST(AV1E_SET_DELTALF_MODE, args); |
2321 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2322 | 0 | } |
2323 | | |
2324 | | static aom_codec_err_t ctrl_set_min_gf_interval(aom_codec_alg_priv_t *ctx, |
2325 | 0 | va_list args) { |
2326 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2327 | 0 | extra_cfg.min_gf_interval = CAST(AV1E_SET_MIN_GF_INTERVAL, args); |
2328 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2329 | 0 | } |
2330 | | |
2331 | | static aom_codec_err_t ctrl_set_max_gf_interval(aom_codec_alg_priv_t *ctx, |
2332 | 0 | va_list args) { |
2333 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2334 | 0 | extra_cfg.max_gf_interval = CAST(AV1E_SET_MAX_GF_INTERVAL, args); |
2335 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2336 | 0 | } |
2337 | | |
2338 | | static aom_codec_err_t ctrl_set_gf_min_pyr_height(aom_codec_alg_priv_t *ctx, |
2339 | 0 | va_list args) { |
2340 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2341 | 0 | extra_cfg.gf_min_pyr_height = CAST(AV1E_SET_GF_MIN_PYRAMID_HEIGHT, args); |
2342 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2343 | 0 | } |
2344 | | |
2345 | | static aom_codec_err_t ctrl_set_gf_max_pyr_height(aom_codec_alg_priv_t *ctx, |
2346 | 0 | va_list args) { |
2347 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2348 | 0 | extra_cfg.gf_max_pyr_height = CAST(AV1E_SET_GF_MAX_PYRAMID_HEIGHT, args); |
2349 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2350 | 0 | } |
2351 | | |
2352 | | static aom_codec_err_t ctrl_set_frame_periodic_boost(aom_codec_alg_priv_t *ctx, |
2353 | 0 | va_list args) { |
2354 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2355 | 0 | extra_cfg.frame_periodic_boost = CAST(AV1E_SET_FRAME_PERIODIC_BOOST, args); |
2356 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2357 | 0 | } |
2358 | | |
2359 | | static aom_codec_err_t ctrl_enable_motion_vector_unit_test( |
2360 | 0 | aom_codec_alg_priv_t *ctx, va_list args) { |
2361 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2362 | 0 | extra_cfg.motion_vector_unit_test = |
2363 | 0 | CAST(AV1E_ENABLE_MOTION_VECTOR_UNIT_TEST, args); |
2364 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2365 | 0 | } |
2366 | | |
2367 | | static aom_codec_err_t ctrl_enable_fpmt_unit_test(aom_codec_alg_priv_t *ctx, |
2368 | 0 | va_list args) { |
2369 | 0 | #if !(CONFIG_FRAME_PARALLEL_ENCODE && CONFIG_FPMT_TEST) |
2370 | 0 | (void)args; |
2371 | 0 | (void)ctx; |
2372 | 0 | return AOM_CODEC_INCAPABLE; |
2373 | | #else |
2374 | | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2375 | | extra_cfg.fpmt_unit_test = CAST(AV1E_SET_FP_MT_UNIT_TEST, args); |
2376 | | ctx->ppi->fpmt_unit_test_cfg = (extra_cfg.fpmt_unit_test == 1) |
2377 | | ? PARALLEL_ENCODE |
2378 | | : PARALLEL_SIMULATION_ENCODE; |
2379 | | return update_extra_cfg(ctx, &extra_cfg); |
2380 | | #endif |
2381 | 0 | } |
2382 | | |
2383 | | static aom_codec_err_t ctrl_enable_ext_tile_debug(aom_codec_alg_priv_t *ctx, |
2384 | 0 | va_list args) { |
2385 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2386 | 0 | extra_cfg.ext_tile_debug = CAST(AV1E_ENABLE_EXT_TILE_DEBUG, args); |
2387 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2388 | 0 | } |
2389 | | |
2390 | | static aom_codec_err_t ctrl_set_target_seq_level_idx(aom_codec_alg_priv_t *ctx, |
2391 | 0 | va_list args) { |
2392 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2393 | 0 | const int val = CAST(AV1E_SET_TARGET_SEQ_LEVEL_IDX, args); |
2394 | 0 | const int level = val % 100; |
2395 | 0 | const int operating_point_idx = val / 100; |
2396 | 0 | if (operating_point_idx >= 0 && |
2397 | 0 | operating_point_idx < MAX_NUM_OPERATING_POINTS) { |
2398 | 0 | extra_cfg.target_seq_level_idx[operating_point_idx] = (AV1_LEVEL)level; |
2399 | 0 | } |
2400 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2401 | 0 | } |
2402 | | |
2403 | | static aom_codec_err_t ctrl_set_tier_mask(aom_codec_alg_priv_t *ctx, |
2404 | 0 | va_list args) { |
2405 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2406 | 0 | extra_cfg.tier_mask = CAST(AV1E_SET_TIER_MASK, args); |
2407 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2408 | 0 | } |
2409 | | |
2410 | | static aom_codec_err_t ctrl_set_min_cr(aom_codec_alg_priv_t *ctx, |
2411 | 0 | va_list args) { |
2412 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2413 | 0 | extra_cfg.min_cr = CAST(AV1E_SET_MIN_CR, args); |
2414 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2415 | 0 | } |
2416 | | |
2417 | | static aom_codec_err_t ctrl_enable_sb_multipass_unit_test( |
2418 | 0 | aom_codec_alg_priv_t *ctx, va_list args) { |
2419 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2420 | 0 | extra_cfg.sb_multipass_unit_test = |
2421 | 0 | CAST(AV1E_ENABLE_SB_MULTIPASS_UNIT_TEST, args); |
2422 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2423 | 0 | } |
2424 | | |
2425 | | static aom_codec_err_t ctrl_set_external_partition(aom_codec_alg_priv_t *ctx, |
2426 | 0 | va_list args) { |
2427 | 0 | AV1_COMP *const cpi = ctx->ppi->cpi; |
2428 | 0 | aom_ext_part_funcs_t funcs = *CAST(AV1E_SET_EXTERNAL_PARTITION, args); |
2429 | 0 | aom_ext_part_config_t config; |
2430 | | // TODO(chengchen): verify the sb_size has been set at this point. |
2431 | 0 | config.superblock_size = cpi->common.seq_params->sb_size; |
2432 | 0 | const aom_codec_err_t status = |
2433 | 0 | av1_ext_part_create(funcs, config, &cpi->ext_part_controller); |
2434 | 0 | return status; |
2435 | 0 | } |
2436 | | |
2437 | | static aom_codec_err_t ctrl_set_loopfilter_control(aom_codec_alg_priv_t *ctx, |
2438 | 0 | va_list args) { |
2439 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2440 | 0 | extra_cfg.loopfilter_control = CAST(AV1E_SET_LOOPFILTER_CONTROL, args); |
2441 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2442 | 0 | } |
2443 | | |
2444 | | static aom_codec_err_t ctrl_set_rtc_external_rc(aom_codec_alg_priv_t *ctx, |
2445 | 0 | va_list args) { |
2446 | 0 | ctx->ppi->cpi->rc.rtc_external_ratectrl = |
2447 | 0 | CAST(AV1E_SET_RTC_EXTERNAL_RC, args); |
2448 | 0 | return AOM_CODEC_OK; |
2449 | 0 | } |
2450 | | |
2451 | | #if !CONFIG_REALTIME_ONLY |
2452 | | static aom_codec_err_t create_stats_buffer(FIRSTPASS_STATS **frame_stats_buffer, |
2453 | | STATS_BUFFER_CTX *stats_buf_context, |
2454 | 1.26k | int num_lap_buffers) { |
2455 | 1.26k | aom_codec_err_t res = AOM_CODEC_OK; |
2456 | | |
2457 | 1.26k | int size = get_stats_buf_size(num_lap_buffers, MAX_LAG_BUFFERS); |
2458 | 1.26k | *frame_stats_buffer = |
2459 | 1.26k | (FIRSTPASS_STATS *)aom_calloc(size, sizeof(FIRSTPASS_STATS)); |
2460 | 1.26k | if (*frame_stats_buffer == NULL) return AOM_CODEC_MEM_ERROR; |
2461 | | |
2462 | 1.26k | stats_buf_context->stats_in_start = *frame_stats_buffer; |
2463 | 1.26k | stats_buf_context->stats_in_end = stats_buf_context->stats_in_start; |
2464 | 1.26k | stats_buf_context->stats_in_buf_end = |
2465 | 1.26k | stats_buf_context->stats_in_start + size; |
2466 | | |
2467 | 1.26k | stats_buf_context->total_left_stats = aom_calloc(1, sizeof(FIRSTPASS_STATS)); |
2468 | 1.26k | if (stats_buf_context->total_left_stats == NULL) return AOM_CODEC_MEM_ERROR; |
2469 | 1.26k | av1_twopass_zero_stats(stats_buf_context->total_left_stats); |
2470 | 1.26k | stats_buf_context->total_stats = aom_calloc(1, sizeof(FIRSTPASS_STATS)); |
2471 | 1.26k | if (stats_buf_context->total_stats == NULL) return AOM_CODEC_MEM_ERROR; |
2472 | 1.26k | av1_twopass_zero_stats(stats_buf_context->total_stats); |
2473 | 1.26k | return res; |
2474 | 1.26k | } |
2475 | | #endif |
2476 | | |
2477 | | static aom_codec_err_t create_context_and_bufferpool( |
2478 | | AV1_PRIMARY *ppi, AV1_COMP **p_cpi, BufferPool **p_buffer_pool, |
2479 | 1.26k | AV1EncoderConfig *oxcf, COMPRESSOR_STAGE stage, int lap_lag_in_frames) { |
2480 | 1.26k | aom_codec_err_t res = AOM_CODEC_OK; |
2481 | | |
2482 | 1.26k | if (*p_buffer_pool == NULL) { |
2483 | 1.26k | *p_buffer_pool = (BufferPool *)aom_calloc(1, sizeof(BufferPool)); |
2484 | 1.26k | if (*p_buffer_pool == NULL) return AOM_CODEC_MEM_ERROR; |
2485 | | |
2486 | 1.26k | #if CONFIG_MULTITHREAD |
2487 | 1.26k | if (pthread_mutex_init(&((*p_buffer_pool)->pool_mutex), NULL)) { |
2488 | 0 | return AOM_CODEC_MEM_ERROR; |
2489 | 0 | } |
2490 | 1.26k | #endif |
2491 | 1.26k | } |
2492 | 1.26k | *p_cpi = av1_create_compressor(ppi, oxcf, *p_buffer_pool, stage, |
2493 | 1.26k | lap_lag_in_frames); |
2494 | 1.26k | if (*p_cpi == NULL) res = AOM_CODEC_MEM_ERROR; |
2495 | | |
2496 | 1.26k | return res; |
2497 | 1.26k | } |
2498 | | |
2499 | 0 | static aom_codec_err_t ctrl_set_fp_mt(aom_codec_alg_priv_t *ctx, va_list args) { |
2500 | 0 | #if !CONFIG_FRAME_PARALLEL_ENCODE |
2501 | 0 | (void)args; |
2502 | 0 | (void)ctx; |
2503 | 0 | return AOM_CODEC_INCAPABLE; |
2504 | | #else |
2505 | | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2506 | | extra_cfg.fp_mt = CAST(AV1E_SET_FP_MT, args); |
2507 | | const aom_codec_err_t result = update_extra_cfg(ctx, &extra_cfg); |
2508 | | int num_fp_contexts = 1; |
2509 | | if (ctx->ppi->num_fp_contexts == 1) { |
2510 | | num_fp_contexts = |
2511 | | av1_compute_num_fp_contexts(ctx->ppi, &ctx->ppi->parallel_cpi[0]->oxcf); |
2512 | | if (num_fp_contexts > 1) { |
2513 | | int i; |
2514 | | for (i = 1; i < num_fp_contexts; i++) { |
2515 | | int res = create_context_and_bufferpool( |
2516 | | ctx->ppi, &ctx->ppi->parallel_cpi[i], &ctx->buffer_pool, &ctx->oxcf, |
2517 | | ENCODE_STAGE, -1); |
2518 | | if (res != AOM_CODEC_OK) { |
2519 | | return res; |
2520 | | } |
2521 | | #if !CONFIG_REALTIME_ONLY |
2522 | | ctx->ppi->parallel_cpi[i]->twopass_frame.stats_in = |
2523 | | ctx->ppi->twopass.stats_buf_ctx->stats_in_start; |
2524 | | #endif |
2525 | | } |
2526 | | } |
2527 | | } |
2528 | | ctx->ppi->num_fp_contexts = num_fp_contexts; |
2529 | | return result; |
2530 | | #endif |
2531 | 0 | } |
2532 | | |
2533 | | static aom_codec_err_t ctrl_set_auto_intra_tools_off(aom_codec_alg_priv_t *ctx, |
2534 | 0 | va_list args) { |
2535 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
2536 | 0 | extra_cfg.auto_intra_tools_off = CAST(AV1E_SET_AUTO_INTRA_TOOLS_OFF, args); |
2537 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
2538 | 0 | } |
2539 | | |
2540 | 1.26k | static aom_codec_err_t encoder_init(aom_codec_ctx_t *ctx) { |
2541 | 1.26k | aom_codec_err_t res = AOM_CODEC_OK; |
2542 | | |
2543 | 1.26k | if (ctx->priv == NULL) { |
2544 | 1.26k | aom_codec_alg_priv_t *const priv = aom_calloc(1, sizeof(*priv)); |
2545 | 1.26k | if (priv == NULL) return AOM_CODEC_MEM_ERROR; |
2546 | | |
2547 | 1.26k | ctx->priv = (aom_codec_priv_t *)priv; |
2548 | 1.26k | ctx->priv->init_flags = ctx->init_flags; |
2549 | | |
2550 | | // Update the reference to the config structure to an internal copy. |
2551 | 1.26k | assert(ctx->config.enc); |
2552 | 1.26k | priv->cfg = *ctx->config.enc; |
2553 | 1.26k | ctx->config.enc = &priv->cfg; |
2554 | | |
2555 | 1.26k | priv->extra_cfg = default_extra_cfg; |
2556 | | // Special handling: |
2557 | | // By default, if omitted, --enable-cdef = 1. |
2558 | | // Here we set its default value to 0 when --allintra is turned on. |
2559 | | // However, if users set --enable-cdef = 1 from command line, |
2560 | | // The encoder still respects it. |
2561 | 1.26k | if (priv->cfg.g_usage == ALLINTRA) { |
2562 | 1.26k | priv->extra_cfg.enable_cdef = 0; |
2563 | 1.26k | } |
2564 | 1.26k | av1_initialize_enc(); |
2565 | | |
2566 | 1.26k | res = validate_config(priv, &priv->cfg, &priv->extra_cfg); |
2567 | | |
2568 | 1.26k | if (res == AOM_CODEC_OK) { |
2569 | 1.26k | int *num_lap_buffers = &priv->num_lap_buffers; |
2570 | 1.26k | int lap_lag_in_frames = 0; |
2571 | 1.26k | *num_lap_buffers = 0; |
2572 | 1.26k | priv->timestamp_ratio.den = priv->cfg.g_timebase.den; |
2573 | 1.26k | priv->timestamp_ratio.num = |
2574 | 1.26k | (int64_t)priv->cfg.g_timebase.num * TICKS_PER_SEC; |
2575 | 1.26k | reduce_ratio(&priv->timestamp_ratio); |
2576 | | |
2577 | 1.26k | set_encoder_config(&priv->oxcf, &priv->cfg, &priv->extra_cfg); |
2578 | 1.26k | if (priv->oxcf.rc_cfg.mode != AOM_CBR && |
2579 | 1.26k | priv->oxcf.pass == AOM_RC_ONE_PASS && priv->oxcf.mode == GOOD) { |
2580 | | // Enable look ahead - enabled for AOM_Q, AOM_CQ, AOM_VBR |
2581 | 0 | *num_lap_buffers = |
2582 | 0 | AOMMIN((int)priv->cfg.g_lag_in_frames, |
2583 | 0 | AOMMIN(MAX_LAP_BUFFERS, priv->oxcf.kf_cfg.key_freq_max + |
2584 | 0 | SCENE_CUT_KEY_TEST_INTERVAL)); |
2585 | 0 | if ((int)priv->cfg.g_lag_in_frames - (*num_lap_buffers) >= |
2586 | 0 | LAP_LAG_IN_FRAMES) { |
2587 | 0 | lap_lag_in_frames = LAP_LAG_IN_FRAMES; |
2588 | 0 | } |
2589 | 0 | } |
2590 | 1.26k | priv->oxcf.use_highbitdepth = |
2591 | 1.26k | (ctx->init_flags & AOM_CODEC_USE_HIGHBITDEPTH) ? 1 : 0; |
2592 | | |
2593 | 1.26k | priv->ppi = av1_create_primary_compressor(&priv->pkt_list.head, |
2594 | 1.26k | *num_lap_buffers, &priv->oxcf); |
2595 | 1.26k | if (!priv->ppi) return AOM_CODEC_MEM_ERROR; |
2596 | | |
2597 | 1.26k | #if !CONFIG_REALTIME_ONLY |
2598 | 1.26k | res = create_stats_buffer(&priv->frame_stats_buffer, |
2599 | 1.26k | &priv->stats_buf_context, *num_lap_buffers); |
2600 | 1.26k | if (res != AOM_CODEC_OK) return AOM_CODEC_MEM_ERROR; |
2601 | | |
2602 | 1.26k | assert(MAX_LAP_BUFFERS >= MAX_LAG_BUFFERS); |
2603 | 1.26k | int size = get_stats_buf_size(*num_lap_buffers, MAX_LAG_BUFFERS); |
2604 | 61.8k | for (int i = 0; i < size; i++) |
2605 | 60.5k | priv->ppi->twopass.frame_stats_arr[i] = &priv->frame_stats_buffer[i]; |
2606 | | |
2607 | 1.26k | priv->ppi->twopass.stats_buf_ctx = &priv->stats_buf_context; |
2608 | 1.26k | #endif |
2609 | | |
2610 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
2611 | | assert(priv->ppi->num_fp_contexts >= 1); |
2612 | | res = create_context_and_bufferpool( |
2613 | | priv->ppi, &priv->ppi->parallel_cpi[0], &priv->buffer_pool, |
2614 | | &priv->oxcf, ENCODE_STAGE, -1); |
2615 | | if (res != AOM_CODEC_OK) { |
2616 | | return res; |
2617 | | } |
2618 | | #if !CONFIG_REALTIME_ONLY |
2619 | | priv->ppi->parallel_cpi[0]->twopass_frame.stats_in = |
2620 | | priv->ppi->twopass.stats_buf_ctx->stats_in_start; |
2621 | | #endif |
2622 | | priv->ppi->cpi = priv->ppi->parallel_cpi[0]; |
2623 | | #else |
2624 | 1.26k | res = create_context_and_bufferpool(priv->ppi, &priv->ppi->cpi, |
2625 | 1.26k | &priv->buffer_pool, &priv->oxcf, |
2626 | 1.26k | ENCODE_STAGE, -1); |
2627 | 1.26k | #if !CONFIG_REALTIME_ONLY |
2628 | 1.26k | priv->ppi->cpi->twopass_frame.stats_in = |
2629 | 1.26k | priv->ppi->twopass.stats_buf_ctx->stats_in_start; |
2630 | 1.26k | #endif |
2631 | 1.26k | #endif // CONFIG_FRAME_PARALLEL_ENCODE |
2632 | | |
2633 | | // Create another compressor if look ahead is enabled |
2634 | 1.26k | if (res == AOM_CODEC_OK && *num_lap_buffers) { |
2635 | 0 | res = create_context_and_bufferpool( |
2636 | 0 | priv->ppi, &priv->ppi->cpi_lap, &priv->buffer_pool_lap, &priv->oxcf, |
2637 | 0 | LAP_STAGE, clamp(lap_lag_in_frames, 0, MAX_LAG_BUFFERS)); |
2638 | 0 | } |
2639 | 1.26k | } |
2640 | 1.26k | } |
2641 | | |
2642 | 1.26k | return res; |
2643 | 1.26k | } |
2644 | | |
2645 | | static void destroy_context_and_bufferpool(AV1_COMP *cpi, |
2646 | 1.26k | BufferPool **p_buffer_pool) { |
2647 | 1.26k | av1_remove_compressor(cpi); |
2648 | 1.26k | if (*p_buffer_pool) { |
2649 | 1.26k | av1_free_ref_frame_buffers(*p_buffer_pool); |
2650 | 1.26k | #if CONFIG_MULTITHREAD |
2651 | 1.26k | pthread_mutex_destroy(&(*p_buffer_pool)->pool_mutex); |
2652 | 1.26k | #endif |
2653 | 1.26k | aom_free(*p_buffer_pool); |
2654 | 1.26k | *p_buffer_pool = NULL; |
2655 | 1.26k | } |
2656 | 1.26k | } |
2657 | | |
2658 | | static void destroy_stats_buffer(STATS_BUFFER_CTX *stats_buf_context, |
2659 | 1.26k | FIRSTPASS_STATS *frame_stats_buffer) { |
2660 | 1.26k | aom_free(stats_buf_context->total_left_stats); |
2661 | 1.26k | aom_free(stats_buf_context->total_stats); |
2662 | 1.26k | aom_free(frame_stats_buffer); |
2663 | 1.26k | } |
2664 | | |
2665 | 5.04k | static void check_and_free_string(const char *default_str, const char **ptr) { |
2666 | 5.04k | if (*ptr == default_str) { |
2667 | | // Default should be a literal. Do not free. |
2668 | 5.04k | return; |
2669 | 5.04k | } |
2670 | 0 | aom_free((void *)*ptr); |
2671 | 0 | *ptr = NULL; |
2672 | 0 | } |
2673 | | |
2674 | 1.26k | static void destroy_extra_config(struct av1_extracfg *extra_cfg) { |
2675 | | #if CONFIG_TUNE_VMAF |
2676 | | check_and_free_string(default_extra_cfg.vmaf_model_path, |
2677 | | &extra_cfg->vmaf_model_path); |
2678 | | #endif |
2679 | 1.26k | check_and_free_string(default_extra_cfg.two_pass_output, |
2680 | 1.26k | &extra_cfg->two_pass_output); |
2681 | 1.26k | check_and_free_string(default_extra_cfg.two_pass_output, |
2682 | 1.26k | &extra_cfg->second_pass_log); |
2683 | 1.26k | check_and_free_string(default_extra_cfg.partition_info_path, |
2684 | 1.26k | &extra_cfg->partition_info_path); |
2685 | 1.26k | check_and_free_string(default_extra_cfg.film_grain_table_filename, |
2686 | 1.26k | &extra_cfg->film_grain_table_filename); |
2687 | 1.26k | } |
2688 | | |
2689 | 1.26k | static aom_codec_err_t encoder_destroy(aom_codec_alg_priv_t *ctx) { |
2690 | 1.26k | free(ctx->cx_data); |
2691 | 1.26k | destroy_extra_config(&ctx->extra_cfg); |
2692 | | |
2693 | 1.26k | if (ctx->ppi) { |
2694 | 1.26k | AV1_PRIMARY *ppi = ctx->ppi; |
2695 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
2696 | | for (int i = 0; i < MAX_PARALLEL_FRAMES - 1; i++) { |
2697 | | if (ppi->parallel_frames_data[i].cx_data) { |
2698 | | free(ppi->parallel_frames_data[i].cx_data); |
2699 | | } |
2700 | | } |
2701 | | #endif |
2702 | | #if CONFIG_ENTROPY_STATS |
2703 | | print_entropy_stats(ppi); |
2704 | | #endif |
2705 | | #if CONFIG_INTERNAL_STATS |
2706 | | print_internal_stats(ppi); |
2707 | | #endif |
2708 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
2709 | | int i; |
2710 | | for (i = 0; i < MAX_PARALLEL_FRAMES; i++) { |
2711 | | destroy_context_and_bufferpool(ppi->parallel_cpi[i], &ctx->buffer_pool); |
2712 | | } |
2713 | | ppi->cpi = NULL; |
2714 | | #else |
2715 | 1.26k | destroy_context_and_bufferpool(ppi->cpi, &ctx->buffer_pool); |
2716 | 1.26k | #endif // CONFIG_FRAME_PARALLEL_ENCODE |
2717 | 1.26k | if (ppi->cpi_lap) { |
2718 | 0 | destroy_context_and_bufferpool(ppi->cpi_lap, &ctx->buffer_pool_lap); |
2719 | 0 | } |
2720 | 1.26k | av1_remove_primary_compressor(ppi); |
2721 | 1.26k | } |
2722 | 1.26k | destroy_stats_buffer(&ctx->stats_buf_context, ctx->frame_stats_buffer); |
2723 | 1.26k | aom_free(ctx); |
2724 | 1.26k | return AOM_CODEC_OK; |
2725 | 1.26k | } |
2726 | | |
2727 | | static aom_codec_frame_flags_t get_frame_pkt_flags(const AV1_COMP *cpi, |
2728 | 1.26k | unsigned int lib_flags) { |
2729 | 1.26k | aom_codec_frame_flags_t flags = lib_flags << 16; |
2730 | 1.26k | if (lib_flags & FRAMEFLAGS_KEY) flags |= AOM_FRAME_IS_KEY; |
2731 | 1.26k | if (lib_flags & FRAMEFLAGS_INTRAONLY) flags |= AOM_FRAME_IS_INTRAONLY; |
2732 | 1.26k | if (lib_flags & FRAMEFLAGS_SWITCH) flags |= AOM_FRAME_IS_SWITCH; |
2733 | 1.26k | if (lib_flags & FRAMEFLAGS_ERROR_RESILIENT) |
2734 | 0 | flags |= AOM_FRAME_IS_ERROR_RESILIENT; |
2735 | 1.26k | if (cpi->droppable) flags |= AOM_FRAME_IS_DROPPABLE; |
2736 | | |
2737 | 1.26k | return flags; |
2738 | 1.26k | } |
2739 | | |
2740 | | // TODO(Mufaddal): Check feasibility of abstracting functions related to LAP |
2741 | | // into a separate function. |
2742 | | static aom_codec_err_t encoder_encode(aom_codec_alg_priv_t *ctx, |
2743 | | const aom_image_t *img, |
2744 | | aom_codec_pts_t pts, |
2745 | | unsigned long duration, |
2746 | 2.52k | aom_enc_frame_flags_t enc_flags) { |
2747 | 2.52k | const size_t kMinCompressedSize = 8192; |
2748 | 2.52k | volatile aom_codec_err_t res = AOM_CODEC_OK; |
2749 | 2.52k | AV1_PRIMARY *const ppi = ctx->ppi; |
2750 | 2.52k | volatile aom_codec_pts_t ptsvol = pts; |
2751 | 2.52k | AV1_COMP_DATA cpi_data = { 0 }; |
2752 | | |
2753 | 2.52k | cpi_data.timestamp_ratio = &ctx->timestamp_ratio; |
2754 | 2.52k | cpi_data.flush = !img; |
2755 | | // LAP context |
2756 | 2.52k | AV1_COMP *cpi_lap = ppi->cpi_lap; |
2757 | 2.52k | if (ppi->cpi == NULL) return AOM_CODEC_INVALID_PARAM; |
2758 | | |
2759 | 2.52k | if (ppi->lap_enabled && cpi_lap == NULL && |
2760 | 2.52k | ppi->cpi->oxcf.pass == AOM_RC_ONE_PASS) |
2761 | 0 | return AOM_CODEC_INVALID_PARAM; |
2762 | | |
2763 | 2.52k | if (img != NULL) { |
2764 | 1.26k | res = validate_img(ctx, img); |
2765 | 1.26k | if (res == AOM_CODEC_OK) { |
2766 | 1.26k | const size_t uncompressed_frame_sz = ALIGN_POWER_OF_TWO(ctx->cfg.g_w, 5) * |
2767 | 1.26k | ALIGN_POWER_OF_TWO(ctx->cfg.g_h, 5) * |
2768 | 1.26k | get_image_bps(img) / 8; |
2769 | | |
2770 | | // Due to the presence of no-show frames, the ctx->cx_data buffer holds |
2771 | | // compressed data corresponding to multiple frames. As no-show frames are |
2772 | | // not possible for all intra frame encoding with no forward key frames, |
2773 | | // the buffer is allocated with a smaller size in this case. |
2774 | | // |
2775 | | // For pseudo random input, the compressed frame size is seen to exceed |
2776 | | // the uncompressed frame size, but is less than 2 times the uncompressed |
2777 | | // frame size. Hence the size of the buffer is chosen as 2 times the |
2778 | | // uncompressed frame size. |
2779 | 1.26k | int multiplier = 8; |
2780 | 1.26k | if (ppi->cpi->oxcf.kf_cfg.key_freq_max == 0 && |
2781 | 1.26k | !ppi->cpi->oxcf.kf_cfg.fwd_kf_enabled) |
2782 | 1.26k | multiplier = 2; |
2783 | 1.26k | size_t data_sz = uncompressed_frame_sz * multiplier; |
2784 | 1.26k | if (data_sz < kMinCompressedSize) data_sz = kMinCompressedSize; |
2785 | 1.26k | if (ctx->cx_data == NULL || ctx->cx_data_sz < data_sz) { |
2786 | 1.26k | ctx->cx_data_sz = data_sz; |
2787 | 1.26k | free(ctx->cx_data); |
2788 | 1.26k | ctx->cx_data = (unsigned char *)malloc(ctx->cx_data_sz); |
2789 | 1.26k | if (ctx->cx_data == NULL) { |
2790 | 0 | ctx->cx_data_sz = 0; |
2791 | 0 | return AOM_CODEC_MEM_ERROR; |
2792 | 0 | } |
2793 | 1.26k | } |
2794 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
2795 | | for (int i = 0; i < ppi->num_fp_contexts - 1; i++) { |
2796 | | if (ppi->parallel_frames_data[i].cx_data == NULL) { |
2797 | | ppi->parallel_frames_data[i].cx_data_sz = uncompressed_frame_sz; |
2798 | | ppi->parallel_frames_data[i].frame_display_order_hint = -1; |
2799 | | ppi->parallel_frames_data[i].frame_size = 0; |
2800 | | ppi->parallel_frames_data[i].cx_data = |
2801 | | (unsigned char *)malloc(ppi->parallel_frames_data[i].cx_data_sz); |
2802 | | if (ppi->parallel_frames_data[i].cx_data == NULL) { |
2803 | | ppi->parallel_frames_data[i].cx_data_sz = 0; |
2804 | | return AOM_CODEC_MEM_ERROR; |
2805 | | } |
2806 | | } |
2807 | | } |
2808 | | #endif |
2809 | 1.26k | } |
2810 | 1.26k | } |
2811 | | |
2812 | 2.52k | aom_codec_pkt_list_init(&ctx->pkt_list); |
2813 | | |
2814 | 2.52k | volatile aom_enc_frame_flags_t flags = enc_flags; |
2815 | | |
2816 | | // The jmp_buf is valid only for the duration of the function that calls |
2817 | | // setjmp(). Therefore, this function must reset the 'setjmp' field to 0 |
2818 | | // before it returns. |
2819 | 2.52k | if (setjmp(ppi->error.jmp)) { |
2820 | 0 | ppi->error.setjmp = 0; |
2821 | 0 | res = update_error_state(ctx, &ppi->error); |
2822 | 0 | return res; |
2823 | 0 | } |
2824 | 2.52k | ppi->error.setjmp = 1; |
2825 | | |
2826 | 2.52k | if (ppi->use_svc && ppi->cpi->svc.use_flexible_mode == 0 && flags == 0) |
2827 | 0 | av1_set_svc_fixed_mode(ppi->cpi); |
2828 | | |
2829 | | // Note(yunqing): While applying encoding flags, always start from enabling |
2830 | | // all, and then modifying according to the flags. Previous frame's flags are |
2831 | | // overwritten. |
2832 | 2.52k | av1_apply_encoding_flags(ppi->cpi, flags); |
2833 | 2.52k | if (cpi_lap != NULL) { |
2834 | 0 | av1_apply_encoding_flags(cpi_lap, flags); |
2835 | 0 | } |
2836 | | |
2837 | | #if CONFIG_TUNE_VMAF |
2838 | | if (ctx->extra_cfg.tuning >= AOM_TUNE_VMAF_WITH_PREPROCESSING && |
2839 | | ctx->extra_cfg.tuning <= AOM_TUNE_VMAF_NEG_MAX_GAIN) { |
2840 | | aom_init_vmaf_model(&ppi->cpi->vmaf_info.vmaf_model, |
2841 | | ppi->cpi->oxcf.tune_cfg.vmaf_model_path); |
2842 | | } |
2843 | | #endif |
2844 | | |
2845 | | // Handle fixed keyframe intervals |
2846 | 2.52k | if (is_stat_generation_stage(ppi->cpi) || is_one_pass_rt_params(ppi->cpi)) { |
2847 | 0 | if (ctx->cfg.kf_mode == AOM_KF_AUTO && |
2848 | 0 | ctx->cfg.kf_min_dist == ctx->cfg.kf_max_dist) { |
2849 | 0 | if (ppi->cpi->common.spatial_layer_id == 0 && |
2850 | 0 | ++ctx->fixed_kf_cntr > ctx->cfg.kf_min_dist) { |
2851 | 0 | flags |= AOM_EFLAG_FORCE_KF; |
2852 | 0 | ctx->fixed_kf_cntr = 1; |
2853 | 0 | } |
2854 | 0 | } |
2855 | 0 | } |
2856 | | |
2857 | 2.52k | if (res == AOM_CODEC_OK) { |
2858 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
2859 | | AV1_COMP *cpi = ppi->cpi; |
2860 | | #else |
2861 | 2.52k | AV1_COMP *const cpi = ppi->cpi; |
2862 | 2.52k | #endif |
2863 | | |
2864 | | // Set up internal flags |
2865 | 2.52k | if (ctx->base.init_flags & AOM_CODEC_USE_PSNR) ppi->b_calculate_psnr = 1; |
2866 | | |
2867 | 2.52k | if (img != NULL) { |
2868 | 1.26k | if (!ctx->pts_offset_initialized) { |
2869 | 1.26k | ctx->pts_offset = ptsvol; |
2870 | 1.26k | ctx->pts_offset_initialized = 1; |
2871 | 1.26k | } |
2872 | 1.26k | ptsvol -= ctx->pts_offset; |
2873 | 1.26k | int64_t src_time_stamp = |
2874 | 1.26k | timebase_units_to_ticks(cpi_data.timestamp_ratio, ptsvol); |
2875 | 1.26k | int64_t src_end_time_stamp = |
2876 | 1.26k | timebase_units_to_ticks(cpi_data.timestamp_ratio, ptsvol + duration); |
2877 | | |
2878 | 1.26k | YV12_BUFFER_CONFIG sd; |
2879 | 1.26k | res = image2yuvconfig(img, &sd); |
2880 | | // When generating a monochrome stream, make |sd| a monochrome image. |
2881 | 1.26k | if (ctx->cfg.monochrome) { |
2882 | 0 | sd.u_buffer = sd.v_buffer = NULL; |
2883 | 0 | sd.uv_stride = 0; |
2884 | 0 | sd.monochrome = 1; |
2885 | 0 | } |
2886 | 1.26k | int use_highbitdepth = (sd.flags & YV12_FLAG_HIGHBITDEPTH) != 0; |
2887 | 1.26k | int subsampling_x = sd.subsampling_x; |
2888 | 1.26k | int subsampling_y = sd.subsampling_y; |
2889 | | |
2890 | 1.26k | if (!ppi->lookahead) { |
2891 | 1.26k | int lag_in_frames = cpi_lap != NULL ? cpi_lap->oxcf.gf_cfg.lag_in_frames |
2892 | 1.26k | : cpi->oxcf.gf_cfg.lag_in_frames; |
2893 | | |
2894 | 1.26k | ppi->lookahead = av1_lookahead_init( |
2895 | 1.26k | cpi->oxcf.frm_dim_cfg.width, cpi->oxcf.frm_dim_cfg.height, |
2896 | 1.26k | subsampling_x, subsampling_y, use_highbitdepth, lag_in_frames, |
2897 | 1.26k | cpi->oxcf.border_in_pixels, cpi->common.features.byte_alignment, |
2898 | 1.26k | ctx->num_lap_buffers, (cpi->oxcf.kf_cfg.key_freq_max == 0), |
2899 | 1.26k | cpi->oxcf.tool_cfg.enable_global_motion); |
2900 | 1.26k | } |
2901 | 1.26k | if (!ppi->lookahead) |
2902 | 0 | aom_internal_error(&ppi->error, AOM_CODEC_MEM_ERROR, |
2903 | 0 | "Failed to allocate lag buffers"); |
2904 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
2905 | | int i; |
2906 | | for (i = 0; i < ppi->num_fp_contexts; i++) { |
2907 | | av1_check_initial_width(ppi->parallel_cpi[i], use_highbitdepth, |
2908 | | subsampling_x, subsampling_y); |
2909 | | } |
2910 | | #else |
2911 | 1.26k | av1_check_initial_width(cpi, use_highbitdepth, subsampling_x, |
2912 | 1.26k | subsampling_y); |
2913 | 1.26k | #endif |
2914 | 1.26k | if (cpi_lap != NULL) { |
2915 | 0 | av1_check_initial_width(cpi_lap, use_highbitdepth, subsampling_x, |
2916 | 0 | subsampling_y); |
2917 | 0 | } |
2918 | | |
2919 | | // Store the original flags in to the frame buffer. Will extract the |
2920 | | // key frame flag when we actually encode this frame. |
2921 | 1.26k | if (av1_receive_raw_frame(cpi, flags | ctx->next_frame_flags, &sd, |
2922 | 1.26k | src_time_stamp, src_end_time_stamp)) { |
2923 | 0 | res = update_error_state(ctx, &ppi->error); |
2924 | 0 | } |
2925 | 1.26k | ctx->next_frame_flags = 0; |
2926 | 1.26k | } |
2927 | | |
2928 | 2.52k | cpi_data.cx_data = ctx->cx_data; |
2929 | 2.52k | cpi_data.cx_data_sz = ctx->cx_data_sz; |
2930 | | |
2931 | | /* Any pending invisible frames? */ |
2932 | 2.52k | if (ctx->pending_cx_data_sz) { |
2933 | 0 | cpi_data.cx_data += ctx->pending_cx_data_sz; |
2934 | 0 | cpi_data.cx_data_sz -= ctx->pending_cx_data_sz; |
2935 | | |
2936 | | /* TODO: this is a minimal check, the underlying codec doesn't respect |
2937 | | * the buffer size anyway. |
2938 | | */ |
2939 | 0 | if (cpi_data.cx_data_sz < ctx->cx_data_sz / 2) { |
2940 | 0 | aom_internal_error(&ppi->error, AOM_CODEC_ERROR, |
2941 | 0 | "Compressed data buffer too small"); |
2942 | 0 | } |
2943 | 0 | } |
2944 | | |
2945 | 2.52k | int is_frame_visible = 0; |
2946 | 2.52k | int has_no_show_keyframe = 0; |
2947 | 2.52k | int num_workers = 0; |
2948 | | |
2949 | 2.52k | if (cpi->oxcf.pass == AOM_RC_FIRST_PASS) { |
2950 | 0 | #if !CONFIG_REALTIME_ONLY |
2951 | 0 | num_workers = ppi->p_mt_info.num_mod_workers[MOD_FP] = |
2952 | 0 | av1_fp_compute_num_enc_workers(cpi); |
2953 | 0 | #endif |
2954 | 2.52k | } else { |
2955 | 2.52k | av1_compute_num_workers_for_mt(cpi); |
2956 | 2.52k | num_workers = av1_get_max_num_workers(cpi); |
2957 | 2.52k | } |
2958 | 2.52k | if ((num_workers > 1) && (ppi->p_mt_info.num_workers == 0)) { |
2959 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
2960 | | // Obtain the maximum no. of frames that can be supported in a parallel |
2961 | | // encode set. |
2962 | | if (is_stat_consumption_stage(cpi)) { |
2963 | | ppi->num_fp_contexts = av1_compute_num_fp_contexts(ppi, &cpi->oxcf); |
2964 | | } |
2965 | | #endif // CONFIG_FRAME_PARALLEL_ENCODE |
2966 | 628 | av1_create_workers(ppi, num_workers); |
2967 | 628 | av1_init_tile_thread_data(ppi, cpi->oxcf.pass == AOM_RC_FIRST_PASS); |
2968 | 628 | #if CONFIG_MULTITHREAD |
2969 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
2970 | | for (int i = 0; i < ppi->num_fp_contexts; i++) { |
2971 | | av1_init_mt_sync(ppi->parallel_cpi[i], |
2972 | | ppi->parallel_cpi[i]->oxcf.pass == AOM_RC_FIRST_PASS); |
2973 | | } |
2974 | | #else |
2975 | 628 | av1_init_mt_sync(cpi, cpi->oxcf.pass == 1); |
2976 | 628 | #endif // CONFIG_FRAME_PARALLEL_ENCODE |
2977 | 628 | if (cpi_lap != NULL) { |
2978 | 0 | av1_init_mt_sync(cpi_lap, 1); |
2979 | 0 | } |
2980 | 628 | #endif // CONFIG_MULTITHREAD |
2981 | 628 | } |
2982 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
2983 | | for (int i = 0; i < ppi->num_fp_contexts; i++) { |
2984 | | av1_init_frame_mt(ppi, ppi->parallel_cpi[i]); |
2985 | | } |
2986 | | #else |
2987 | 2.52k | av1_init_frame_mt(ppi, cpi); |
2988 | 2.52k | #endif // CONFIG_FRAME_PARALLEL_ENCODE |
2989 | 2.52k | if (cpi_lap != NULL) { |
2990 | 0 | av1_init_frame_mt(ppi, cpi_lap); |
2991 | 0 | } |
2992 | | |
2993 | | // Call for LAP stage |
2994 | 2.52k | if (cpi_lap != NULL) { |
2995 | 0 | AV1_COMP_DATA cpi_lap_data = { 0 }; |
2996 | 0 | cpi_lap_data.flush = !img; |
2997 | 0 | cpi_lap_data.timestamp_ratio = &ctx->timestamp_ratio; |
2998 | 0 | const int status = av1_get_compressed_data(cpi_lap, &cpi_lap_data); |
2999 | 0 | if (status != -1) { |
3000 | 0 | if (status != AOM_CODEC_OK) { |
3001 | 0 | aom_internal_error(&ppi->error, AOM_CODEC_ERROR, NULL); |
3002 | 0 | } |
3003 | 0 | } |
3004 | 0 | av1_post_encode_updates(cpi_lap, &cpi_lap_data); |
3005 | 0 | } |
3006 | | |
3007 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
3008 | | // Recalculate the maximum number of frames that can be encoded in |
3009 | | // parallel at the beginning of sub gop. |
3010 | | if (is_stat_consumption_stage(cpi) && ppi->gf_group.size > 0 && |
3011 | | cpi->gf_frame_index == ppi->gf_group.size) { |
3012 | | ppi->num_fp_contexts = av1_compute_num_fp_contexts(ppi, &cpi->oxcf); |
3013 | | } |
3014 | | #endif // CONFIG_FRAME_PARALLEL_ENCODE |
3015 | | |
3016 | | // Get the next visible frame. Invisible frames get packed with the next |
3017 | | // visible frame. |
3018 | 3.78k | while (cpi_data.cx_data_sz >= ctx->cx_data_sz / 2 && !is_frame_visible) { |
3019 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
3020 | | int simulate_parallel_frame = 0; |
3021 | | int status = -1; |
3022 | | cpi->do_frame_data_update = true; |
3023 | | #if CONFIG_FRAME_PARALLEL_ENCODE_2 |
3024 | | cpi->ref_idx_to_skip = INVALID_IDX; |
3025 | | cpi->ref_refresh_index = INVALID_IDX; |
3026 | | cpi->refresh_idx_available = false; |
3027 | | #endif // CONFIG_FRAME_PARALLEL_ENCODE_2 |
3028 | | |
3029 | | #if CONFIG_FPMT_TEST |
3030 | | simulate_parallel_frame = |
3031 | | cpi->ppi->fpmt_unit_test_cfg == PARALLEL_SIMULATION_ENCODE ? 1 : 0; |
3032 | | if (simulate_parallel_frame) { |
3033 | | if (ppi->num_fp_contexts > 1 && ppi->gf_group.size > 1) { |
3034 | | if (cpi->gf_frame_index < ppi->gf_group.size) { |
3035 | | calc_frame_data_update_flag(&ppi->gf_group, cpi->gf_frame_index, |
3036 | | &cpi->do_frame_data_update); |
3037 | | } |
3038 | | } |
3039 | | status = av1_get_compressed_data(cpi, &cpi_data); |
3040 | | } |
3041 | | |
3042 | | #endif |
3043 | | if (!simulate_parallel_frame) { |
3044 | | if (ppi->gf_group.frame_parallel_level[cpi->gf_frame_index] == 0) { |
3045 | | status = av1_get_compressed_data(cpi, &cpi_data); |
3046 | | } else if (ppi->gf_group.frame_parallel_level[cpi->gf_frame_index] == |
3047 | | 1) { |
3048 | | status = av1_compress_parallel_frames(ppi, &cpi_data); |
3049 | | } else { |
3050 | | cpi = av1_get_parallel_frame_enc_data(ppi, &cpi_data); |
3051 | | status = AOM_CODEC_OK; |
3052 | | } |
3053 | | } |
3054 | | #else |
3055 | 2.52k | const int status = av1_get_compressed_data(cpi, &cpi_data); |
3056 | 2.52k | #endif // CONFIG_FRAME_PARALLEL_ENCODE |
3057 | 2.52k | if (status == -1) break; |
3058 | 1.26k | if (status != AOM_CODEC_OK) { |
3059 | 0 | aom_internal_error(&ppi->error, AOM_CODEC_ERROR, NULL); |
3060 | 0 | } |
3061 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
3062 | | if (ppi->num_fp_contexts > 0 && frame_is_intra_only(&cpi->common)) { |
3063 | | av1_init_sc_decisions(ppi); |
3064 | | } |
3065 | | #endif |
3066 | | |
3067 | 1.26k | ppi->seq_params_locked = 1; |
3068 | 1.26k | av1_post_encode_updates(cpi, &cpi_data); |
3069 | | |
3070 | | #if CONFIG_ENTROPY_STATS |
3071 | | if (ppi->cpi->oxcf.pass != 1 && !cpi->common.show_existing_frame) |
3072 | | av1_accumulate_frame_counts(&ppi->aggregate_fc, &cpi->counts); |
3073 | | #endif |
3074 | | #if CONFIG_INTERNAL_STATS |
3075 | | if (ppi->cpi->oxcf.pass != 1) { |
3076 | | ppi->total_time_compress_data += cpi->time_compress_data; |
3077 | | ppi->total_recode_hits += cpi->frame_recode_hits; |
3078 | | ppi->total_bytes += cpi->bytes; |
3079 | | for (int i = 0; i < MAX_MODES; i++) { |
3080 | | ppi->total_mode_chosen_counts[i] += cpi->mode_chosen_counts[i]; |
3081 | | } |
3082 | | } |
3083 | | #endif // CONFIG_INTERNAL_STATS |
3084 | | |
3085 | 1.26k | if (!cpi_data.frame_size) continue; |
3086 | 1.26k | assert(cpi_data.cx_data != NULL && cpi_data.cx_data_sz != 0); |
3087 | 1.26k | const int write_temporal_delimiter = |
3088 | 1.26k | !cpi->common.spatial_layer_id && !ctx->pending_cx_data_sz; |
3089 | | |
3090 | 1.26k | if (write_temporal_delimiter) { |
3091 | 1.26k | uint32_t obu_header_size = 1; |
3092 | 1.26k | const uint32_t obu_payload_size = 0; |
3093 | 1.26k | const size_t length_field_size = |
3094 | 1.26k | aom_uleb_size_in_bytes(obu_payload_size); |
3095 | | |
3096 | 1.26k | const size_t move_offset = obu_header_size + length_field_size; |
3097 | 1.26k | memmove(ctx->cx_data + move_offset, ctx->cx_data, cpi_data.frame_size); |
3098 | 1.26k | obu_header_size = |
3099 | 1.26k | av1_write_obu_header(&ppi->level_params, &cpi->frame_header_count, |
3100 | 1.26k | OBU_TEMPORAL_DELIMITER, 0, ctx->cx_data); |
3101 | | |
3102 | | // OBUs are preceded/succeeded by an unsigned leb128 coded integer. |
3103 | 1.26k | if (av1_write_uleb_obu_size(obu_header_size, obu_payload_size, |
3104 | 1.26k | ctx->cx_data) != AOM_CODEC_OK) { |
3105 | 0 | aom_internal_error(&ppi->error, AOM_CODEC_ERROR, NULL); |
3106 | 0 | } |
3107 | | |
3108 | 1.26k | cpi_data.frame_size += |
3109 | 1.26k | obu_header_size + obu_payload_size + length_field_size; |
3110 | 1.26k | } |
3111 | | |
3112 | 1.26k | if (ctx->oxcf.save_as_annexb) { |
3113 | 0 | size_t curr_frame_size = cpi_data.frame_size; |
3114 | 0 | if (av1_convert_sect5obus_to_annexb(cpi_data.cx_data, |
3115 | 0 | &curr_frame_size) != AOM_CODEC_OK) { |
3116 | 0 | aom_internal_error(&ppi->error, AOM_CODEC_ERROR, NULL); |
3117 | 0 | } |
3118 | 0 | cpi_data.frame_size = curr_frame_size; |
3119 | | |
3120 | | // B_PRIME (add frame size) |
3121 | 0 | const size_t length_field_size = |
3122 | 0 | aom_uleb_size_in_bytes(cpi_data.frame_size); |
3123 | 0 | memmove(cpi_data.cx_data + length_field_size, cpi_data.cx_data, |
3124 | 0 | cpi_data.frame_size); |
3125 | 0 | if (av1_write_uleb_obu_size(0, (uint32_t)cpi_data.frame_size, |
3126 | 0 | cpi_data.cx_data) != AOM_CODEC_OK) { |
3127 | 0 | aom_internal_error(&ppi->error, AOM_CODEC_ERROR, NULL); |
3128 | 0 | } |
3129 | 0 | cpi_data.frame_size += length_field_size; |
3130 | 0 | } |
3131 | | |
3132 | 1.26k | ctx->pending_cx_data_sz += cpi_data.frame_size; |
3133 | | |
3134 | 1.26k | cpi_data.cx_data += cpi_data.frame_size; |
3135 | 1.26k | cpi_data.cx_data_sz -= cpi_data.frame_size; |
3136 | | |
3137 | 1.26k | is_frame_visible = cpi->common.show_frame; |
3138 | | |
3139 | 1.26k | has_no_show_keyframe |= |
3140 | 1.26k | (!is_frame_visible && |
3141 | 1.26k | cpi->common.current_frame.frame_type == KEY_FRAME); |
3142 | 1.26k | } |
3143 | 2.52k | if (is_frame_visible) { |
3144 | | // Add the frame packet to the list of returned packets. |
3145 | 1.26k | aom_codec_cx_pkt_t pkt; |
3146 | | |
3147 | | // decrement frames_left counter |
3148 | 1.26k | ppi->frames_left = AOMMAX(0, ppi->frames_left - 1); |
3149 | 1.26k | if (ctx->oxcf.save_as_annexb) { |
3150 | | // B_PRIME (add TU size) |
3151 | 0 | size_t tu_size = ctx->pending_cx_data_sz; |
3152 | 0 | const size_t length_field_size = aom_uleb_size_in_bytes(tu_size); |
3153 | 0 | memmove(ctx->cx_data + length_field_size, ctx->cx_data, tu_size); |
3154 | 0 | if (av1_write_uleb_obu_size(0, (uint32_t)tu_size, ctx->cx_data) != |
3155 | 0 | AOM_CODEC_OK) { |
3156 | 0 | aom_internal_error(&ppi->error, AOM_CODEC_ERROR, NULL); |
3157 | 0 | } |
3158 | 0 | ctx->pending_cx_data_sz += length_field_size; |
3159 | 0 | } |
3160 | | |
3161 | 1.26k | pkt.kind = AOM_CODEC_CX_FRAME_PKT; |
3162 | | |
3163 | 1.26k | pkt.data.frame.buf = ctx->cx_data; |
3164 | 1.26k | pkt.data.frame.sz = ctx->pending_cx_data_sz; |
3165 | 1.26k | pkt.data.frame.partition_id = -1; |
3166 | 1.26k | pkt.data.frame.vis_frame_size = cpi_data.frame_size; |
3167 | | |
3168 | 1.26k | pkt.data.frame.pts = ticks_to_timebase_units(cpi_data.timestamp_ratio, |
3169 | 1.26k | cpi_data.ts_frame_start) + |
3170 | 1.26k | ctx->pts_offset; |
3171 | 1.26k | pkt.data.frame.flags = get_frame_pkt_flags(cpi, cpi_data.lib_flags); |
3172 | 1.26k | if (has_no_show_keyframe) { |
3173 | | // If one of the invisible frames in the packet is a keyframe, set |
3174 | | // the delayed random access point flag. |
3175 | 0 | pkt.data.frame.flags |= AOM_FRAME_IS_DELAYED_RANDOM_ACCESS_POINT; |
3176 | 0 | } |
3177 | 1.26k | pkt.data.frame.duration = (uint32_t)ticks_to_timebase_units( |
3178 | 1.26k | cpi_data.timestamp_ratio, |
3179 | 1.26k | cpi_data.ts_frame_end - cpi_data.ts_frame_start); |
3180 | | |
3181 | 1.26k | aom_codec_pkt_list_add(&ctx->pkt_list.head, &pkt); |
3182 | | |
3183 | 1.26k | ctx->pending_cx_data_sz = 0; |
3184 | 1.26k | } |
3185 | 2.52k | } |
3186 | | |
3187 | 2.52k | ppi->error.setjmp = 0; |
3188 | 2.52k | return res; |
3189 | 2.52k | } |
3190 | | |
3191 | | static const aom_codec_cx_pkt_t *encoder_get_cxdata(aom_codec_alg_priv_t *ctx, |
3192 | 3.78k | aom_codec_iter_t *iter) { |
3193 | 3.78k | return aom_codec_pkt_list_get(&ctx->pkt_list.head, iter); |
3194 | 3.78k | } |
3195 | | |
3196 | | static aom_codec_err_t ctrl_set_reference(aom_codec_alg_priv_t *ctx, |
3197 | 0 | va_list args) { |
3198 | 0 | av1_ref_frame_t *const frame = va_arg(args, av1_ref_frame_t *); |
3199 | |
|
3200 | 0 | if (frame != NULL) { |
3201 | 0 | YV12_BUFFER_CONFIG sd; |
3202 | |
|
3203 | 0 | image2yuvconfig(&frame->img, &sd); |
3204 | 0 | av1_set_reference_enc(ctx->ppi->cpi, frame->idx, &sd); |
3205 | 0 | return AOM_CODEC_OK; |
3206 | 0 | } else { |
3207 | 0 | return AOM_CODEC_INVALID_PARAM; |
3208 | 0 | } |
3209 | 0 | } |
3210 | | |
3211 | | static aom_codec_err_t ctrl_copy_reference(aom_codec_alg_priv_t *ctx, |
3212 | 0 | va_list args) { |
3213 | 0 | av1_ref_frame_t *const frame = va_arg(args, av1_ref_frame_t *); |
3214 | |
|
3215 | 0 | if (frame != NULL) { |
3216 | 0 | YV12_BUFFER_CONFIG sd; |
3217 | |
|
3218 | 0 | image2yuvconfig(&frame->img, &sd); |
3219 | 0 | av1_copy_reference_enc(ctx->ppi->cpi, frame->idx, &sd); |
3220 | 0 | return AOM_CODEC_OK; |
3221 | 0 | } else { |
3222 | 0 | return AOM_CODEC_INVALID_PARAM; |
3223 | 0 | } |
3224 | 0 | } |
3225 | | |
3226 | | static aom_codec_err_t ctrl_get_reference(aom_codec_alg_priv_t *ctx, |
3227 | 0 | va_list args) { |
3228 | 0 | av1_ref_frame_t *const frame = va_arg(args, av1_ref_frame_t *); |
3229 | |
|
3230 | 0 | if (frame != NULL) { |
3231 | 0 | YV12_BUFFER_CONFIG *fb = get_ref_frame(&ctx->ppi->cpi->common, frame->idx); |
3232 | 0 | if (fb == NULL) return AOM_CODEC_ERROR; |
3233 | | |
3234 | 0 | yuvconfig2image(&frame->img, fb, NULL); |
3235 | 0 | return AOM_CODEC_OK; |
3236 | 0 | } else { |
3237 | 0 | return AOM_CODEC_INVALID_PARAM; |
3238 | 0 | } |
3239 | 0 | } |
3240 | | |
3241 | | static aom_codec_err_t ctrl_get_new_frame_image(aom_codec_alg_priv_t *ctx, |
3242 | 0 | va_list args) { |
3243 | 0 | aom_image_t *const new_img = va_arg(args, aom_image_t *); |
3244 | |
|
3245 | 0 | if (new_img != NULL) { |
3246 | 0 | YV12_BUFFER_CONFIG new_frame; |
3247 | |
|
3248 | 0 | if (av1_get_last_show_frame(ctx->ppi->cpi, &new_frame) == 0) { |
3249 | 0 | yuvconfig2image(new_img, &new_frame, NULL); |
3250 | 0 | return AOM_CODEC_OK; |
3251 | 0 | } else { |
3252 | 0 | return AOM_CODEC_ERROR; |
3253 | 0 | } |
3254 | 0 | } else { |
3255 | 0 | return AOM_CODEC_INVALID_PARAM; |
3256 | 0 | } |
3257 | 0 | } |
3258 | | |
3259 | | static aom_codec_err_t ctrl_copy_new_frame_image(aom_codec_alg_priv_t *ctx, |
3260 | 0 | va_list args) { |
3261 | 0 | aom_image_t *const new_img = va_arg(args, aom_image_t *); |
3262 | |
|
3263 | 0 | if (new_img != NULL) { |
3264 | 0 | YV12_BUFFER_CONFIG new_frame; |
3265 | |
|
3266 | 0 | if (av1_get_last_show_frame(ctx->ppi->cpi, &new_frame) == 0) { |
3267 | 0 | YV12_BUFFER_CONFIG sd; |
3268 | 0 | image2yuvconfig(new_img, &sd); |
3269 | 0 | return av1_copy_new_frame_enc(&ctx->ppi->cpi->common, &new_frame, &sd); |
3270 | 0 | } else { |
3271 | 0 | return AOM_CODEC_ERROR; |
3272 | 0 | } |
3273 | 0 | } else { |
3274 | 0 | return AOM_CODEC_INVALID_PARAM; |
3275 | 0 | } |
3276 | 0 | } |
3277 | | |
3278 | 0 | static aom_image_t *encoder_get_preview(aom_codec_alg_priv_t *ctx) { |
3279 | 0 | YV12_BUFFER_CONFIG sd; |
3280 | |
|
3281 | 0 | if (av1_get_preview_raw_frame(ctx->ppi->cpi, &sd) == 0) { |
3282 | 0 | yuvconfig2image(&ctx->preview_img, &sd, NULL); |
3283 | 0 | return &ctx->preview_img; |
3284 | 0 | } else { |
3285 | 0 | return NULL; |
3286 | 0 | } |
3287 | 0 | } |
3288 | | |
3289 | | static aom_codec_err_t ctrl_use_reference(aom_codec_alg_priv_t *ctx, |
3290 | 0 | va_list args) { |
3291 | 0 | const int reference_flag = va_arg(args, int); |
3292 | |
|
3293 | 0 | av1_use_as_reference(&ctx->ppi->cpi->ext_flags.ref_frame_flags, |
3294 | 0 | reference_flag); |
3295 | 0 | return AOM_CODEC_OK; |
3296 | 0 | } |
3297 | | |
3298 | | static aom_codec_err_t ctrl_set_roi_map(aom_codec_alg_priv_t *ctx, |
3299 | 0 | va_list args) { |
3300 | 0 | (void)ctx; |
3301 | 0 | (void)args; |
3302 | | |
3303 | | // TODO(yaowu): Need to re-implement and test for AV1. |
3304 | 0 | return AOM_CODEC_INVALID_PARAM; |
3305 | 0 | } |
3306 | | |
3307 | | static aom_codec_err_t ctrl_set_active_map(aom_codec_alg_priv_t *ctx, |
3308 | 0 | va_list args) { |
3309 | 0 | aom_active_map_t *const map = va_arg(args, aom_active_map_t *); |
3310 | |
|
3311 | 0 | if (map) { |
3312 | 0 | if (!av1_set_active_map(ctx->ppi->cpi, map->active_map, (int)map->rows, |
3313 | 0 | (int)map->cols)) |
3314 | 0 | return AOM_CODEC_OK; |
3315 | 0 | else |
3316 | 0 | return AOM_CODEC_INVALID_PARAM; |
3317 | 0 | } else { |
3318 | 0 | return AOM_CODEC_INVALID_PARAM; |
3319 | 0 | } |
3320 | 0 | } |
3321 | | |
3322 | | static aom_codec_err_t ctrl_get_active_map(aom_codec_alg_priv_t *ctx, |
3323 | 0 | va_list args) { |
3324 | 0 | aom_active_map_t *const map = va_arg(args, aom_active_map_t *); |
3325 | |
|
3326 | 0 | if (map) { |
3327 | 0 | if (!av1_get_active_map(ctx->ppi->cpi, map->active_map, (int)map->rows, |
3328 | 0 | (int)map->cols)) |
3329 | 0 | return AOM_CODEC_OK; |
3330 | 0 | else |
3331 | 0 | return AOM_CODEC_INVALID_PARAM; |
3332 | 0 | } else { |
3333 | 0 | return AOM_CODEC_INVALID_PARAM; |
3334 | 0 | } |
3335 | 0 | } |
3336 | | |
3337 | | static aom_codec_err_t ctrl_set_scale_mode(aom_codec_alg_priv_t *ctx, |
3338 | 0 | va_list args) { |
3339 | 0 | aom_scaling_mode_t *const mode = va_arg(args, aom_scaling_mode_t *); |
3340 | |
|
3341 | 0 | if (mode) { |
3342 | 0 | const int res = av1_set_internal_size( |
3343 | 0 | &ctx->ppi->cpi->oxcf, &ctx->ppi->cpi->resize_pending_params, |
3344 | 0 | (AOM_SCALING)mode->h_scaling_mode, (AOM_SCALING)mode->v_scaling_mode); |
3345 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
3346 | | av1_check_fpmt_config(ctx->ppi, &ctx->ppi->cpi->oxcf); |
3347 | | #endif |
3348 | 0 | return (res == 0) ? AOM_CODEC_OK : AOM_CODEC_INVALID_PARAM; |
3349 | 0 | } else { |
3350 | 0 | return AOM_CODEC_INVALID_PARAM; |
3351 | 0 | } |
3352 | 0 | } |
3353 | | |
3354 | | static aom_codec_err_t ctrl_set_spatial_layer_id(aom_codec_alg_priv_t *ctx, |
3355 | 0 | va_list args) { |
3356 | 0 | const int spatial_layer_id = va_arg(args, int); |
3357 | 0 | if (spatial_layer_id >= MAX_NUM_SPATIAL_LAYERS) |
3358 | 0 | return AOM_CODEC_INVALID_PARAM; |
3359 | 0 | ctx->ppi->cpi->common.spatial_layer_id = spatial_layer_id; |
3360 | 0 | return AOM_CODEC_OK; |
3361 | 0 | } |
3362 | | |
3363 | | static aom_codec_err_t ctrl_set_number_spatial_layers(aom_codec_alg_priv_t *ctx, |
3364 | 0 | va_list args) { |
3365 | 0 | const int number_spatial_layers = va_arg(args, int); |
3366 | 0 | if (number_spatial_layers > MAX_NUM_SPATIAL_LAYERS) |
3367 | 0 | return AOM_CODEC_INVALID_PARAM; |
3368 | 0 | ctx->ppi->number_spatial_layers = number_spatial_layers; |
3369 | 0 | return AOM_CODEC_OK; |
3370 | 0 | } |
3371 | | |
3372 | | static aom_codec_err_t ctrl_set_layer_id(aom_codec_alg_priv_t *ctx, |
3373 | 0 | va_list args) { |
3374 | 0 | aom_svc_layer_id_t *const data = va_arg(args, aom_svc_layer_id_t *); |
3375 | 0 | ctx->ppi->cpi->common.spatial_layer_id = data->spatial_layer_id; |
3376 | 0 | ctx->ppi->cpi->common.temporal_layer_id = data->temporal_layer_id; |
3377 | 0 | ctx->ppi->cpi->svc.spatial_layer_id = data->spatial_layer_id; |
3378 | 0 | ctx->ppi->cpi->svc.temporal_layer_id = data->temporal_layer_id; |
3379 | 0 | return AOM_CODEC_OK; |
3380 | 0 | } |
3381 | | |
3382 | | static aom_codec_err_t ctrl_set_svc_params(aom_codec_alg_priv_t *ctx, |
3383 | 0 | va_list args) { |
3384 | 0 | AV1_PRIMARY *const ppi = ctx->ppi; |
3385 | 0 | AV1_COMP *const cpi = ppi->cpi; |
3386 | 0 | AV1_COMMON *const cm = &cpi->common; |
3387 | 0 | aom_svc_params_t *const params = va_arg(args, aom_svc_params_t *); |
3388 | 0 | int64_t target_bandwidth = 0; |
3389 | 0 | ppi->number_spatial_layers = params->number_spatial_layers; |
3390 | 0 | ppi->number_temporal_layers = params->number_temporal_layers; |
3391 | 0 | cpi->svc.number_spatial_layers = params->number_spatial_layers; |
3392 | 0 | cpi->svc.number_temporal_layers = params->number_temporal_layers; |
3393 | 0 | if (ppi->number_spatial_layers > 1 || ppi->number_temporal_layers > 1) { |
3394 | 0 | unsigned int sl, tl; |
3395 | 0 | ctx->ppi->use_svc = 1; |
3396 | 0 | for (sl = 0; sl < ppi->number_spatial_layers; ++sl) { |
3397 | 0 | for (tl = 0; tl < ppi->number_temporal_layers; ++tl) { |
3398 | 0 | const int layer = LAYER_IDS_TO_IDX(sl, tl, ppi->number_temporal_layers); |
3399 | 0 | LAYER_CONTEXT *lc = &cpi->svc.layer_context[layer]; |
3400 | 0 | lc->max_q = params->max_quantizers[layer]; |
3401 | 0 | lc->min_q = params->min_quantizers[layer]; |
3402 | 0 | lc->scaling_factor_num = params->scaling_factor_num[sl]; |
3403 | 0 | lc->scaling_factor_den = params->scaling_factor_den[sl]; |
3404 | 0 | lc->layer_target_bitrate = 1000 * params->layer_target_bitrate[layer]; |
3405 | 0 | lc->framerate_factor = params->framerate_factor[tl]; |
3406 | 0 | if (tl == ppi->number_temporal_layers - 1) |
3407 | 0 | target_bandwidth += lc->layer_target_bitrate; |
3408 | 0 | } |
3409 | 0 | } |
3410 | 0 | if (cm->current_frame.frame_number == 0) { |
3411 | 0 | if (!cpi->ppi->seq_params_locked) { |
3412 | 0 | SequenceHeader *const seq_params = &ppi->seq_params; |
3413 | 0 | seq_params->operating_points_cnt_minus_1 = |
3414 | 0 | ppi->number_spatial_layers * ppi->number_temporal_layers - 1; |
3415 | 0 | av1_init_seq_coding_tools(ppi, &cpi->oxcf, 1); |
3416 | 0 | } |
3417 | 0 | av1_init_layer_context(cpi); |
3418 | 0 | } |
3419 | 0 | av1_update_layer_context_change_config(cpi, target_bandwidth); |
3420 | 0 | } |
3421 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
3422 | | av1_check_fpmt_config(ctx->ppi, &ctx->ppi->cpi->oxcf); |
3423 | | #endif // CONFIG_FRAME_PARALLEL_ENCODE |
3424 | 0 | return AOM_CODEC_OK; |
3425 | 0 | } |
3426 | | |
3427 | | static aom_codec_err_t ctrl_set_svc_ref_frame_config(aom_codec_alg_priv_t *ctx, |
3428 | 0 | va_list args) { |
3429 | 0 | AV1_COMP *const cpi = ctx->ppi->cpi; |
3430 | 0 | aom_svc_ref_frame_config_t *const data = |
3431 | 0 | va_arg(args, aom_svc_ref_frame_config_t *); |
3432 | 0 | cpi->svc.set_ref_frame_config = 1; |
3433 | 0 | for (unsigned int i = 0; i < INTER_REFS_PER_FRAME; ++i) { |
3434 | 0 | cpi->svc.reference[i] = data->reference[i]; |
3435 | 0 | cpi->svc.ref_idx[i] = data->ref_idx[i]; |
3436 | 0 | } |
3437 | 0 | for (unsigned int i = 0; i < REF_FRAMES; ++i) |
3438 | 0 | cpi->svc.refresh[i] = data->refresh[i]; |
3439 | 0 | cpi->svc.use_flexible_mode = 1; |
3440 | 0 | cpi->svc.ksvc_fixed_mode = 0; |
3441 | 0 | return AOM_CODEC_OK; |
3442 | 0 | } |
3443 | | |
3444 | | static aom_codec_err_t ctrl_set_svc_ref_frame_comp_pred( |
3445 | 0 | aom_codec_alg_priv_t *ctx, va_list args) { |
3446 | 0 | AV1_COMP *const cpi = ctx->ppi->cpi; |
3447 | 0 | aom_svc_ref_frame_comp_pred_t *const data = |
3448 | 0 | va_arg(args, aom_svc_ref_frame_comp_pred_t *); |
3449 | 0 | cpi->svc.ref_frame_comp[0] = data->use_comp_pred[0]; |
3450 | 0 | cpi->svc.ref_frame_comp[1] = data->use_comp_pred[1]; |
3451 | 0 | cpi->svc.ref_frame_comp[2] = data->use_comp_pred[2]; |
3452 | 0 | return AOM_CODEC_OK; |
3453 | 0 | } |
3454 | | |
3455 | | static aom_codec_err_t ctrl_set_tune_content(aom_codec_alg_priv_t *ctx, |
3456 | 0 | va_list args) { |
3457 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
3458 | 0 | extra_cfg.content = CAST(AV1E_SET_TUNE_CONTENT, args); |
3459 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
3460 | 0 | } |
3461 | | |
3462 | | static aom_codec_err_t ctrl_set_cdf_update_mode(aom_codec_alg_priv_t *ctx, |
3463 | 0 | va_list args) { |
3464 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
3465 | 0 | extra_cfg.cdf_update_mode = CAST(AV1E_SET_CDF_UPDATE_MODE, args); |
3466 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
3467 | 0 | } |
3468 | | |
3469 | | static aom_codec_err_t ctrl_set_color_primaries(aom_codec_alg_priv_t *ctx, |
3470 | 0 | va_list args) { |
3471 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
3472 | 0 | extra_cfg.color_primaries = CAST(AV1E_SET_COLOR_PRIMARIES, args); |
3473 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
3474 | 0 | } |
3475 | | |
3476 | | static aom_codec_err_t ctrl_set_transfer_characteristics( |
3477 | 0 | aom_codec_alg_priv_t *ctx, va_list args) { |
3478 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
3479 | 0 | extra_cfg.transfer_characteristics = |
3480 | 0 | CAST(AV1E_SET_TRANSFER_CHARACTERISTICS, args); |
3481 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
3482 | 0 | } |
3483 | | |
3484 | | static aom_codec_err_t ctrl_set_matrix_coefficients(aom_codec_alg_priv_t *ctx, |
3485 | 0 | va_list args) { |
3486 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
3487 | 0 | extra_cfg.matrix_coefficients = CAST(AV1E_SET_MATRIX_COEFFICIENTS, args); |
3488 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
3489 | 0 | } |
3490 | | |
3491 | | static aom_codec_err_t ctrl_set_chroma_sample_position( |
3492 | 1.26k | aom_codec_alg_priv_t *ctx, va_list args) { |
3493 | 1.26k | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
3494 | 1.26k | extra_cfg.chroma_sample_position = |
3495 | 1.26k | CAST(AV1E_SET_CHROMA_SAMPLE_POSITION, args); |
3496 | 1.26k | return update_extra_cfg(ctx, &extra_cfg); |
3497 | 1.26k | } |
3498 | | |
3499 | | static aom_codec_err_t ctrl_set_color_range(aom_codec_alg_priv_t *ctx, |
3500 | 1.26k | va_list args) { |
3501 | 1.26k | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
3502 | 1.26k | extra_cfg.color_range = CAST(AV1E_SET_COLOR_RANGE, args); |
3503 | 1.26k | return update_extra_cfg(ctx, &extra_cfg); |
3504 | 1.26k | } |
3505 | | |
3506 | | static aom_codec_err_t ctrl_set_render_size(aom_codec_alg_priv_t *ctx, |
3507 | 0 | va_list args) { |
3508 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
3509 | 0 | int *const render_size = va_arg(args, int *); |
3510 | 0 | extra_cfg.render_width = render_size[0]; |
3511 | 0 | extra_cfg.render_height = render_size[1]; |
3512 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
3513 | 0 | } |
3514 | | |
3515 | | static aom_codec_err_t ctrl_set_superblock_size(aom_codec_alg_priv_t *ctx, |
3516 | 0 | va_list args) { |
3517 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
3518 | 0 | extra_cfg.superblock_size = CAST(AV1E_SET_SUPERBLOCK_SIZE, args); |
3519 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
3520 | 0 | } |
3521 | | |
3522 | | static aom_codec_err_t ctrl_set_chroma_subsampling_x(aom_codec_alg_priv_t *ctx, |
3523 | 0 | va_list args) { |
3524 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
3525 | 0 | extra_cfg.chroma_subsampling_x = CAST(AV1E_SET_CHROMA_SUBSAMPLING_X, args); |
3526 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
3527 | 0 | } |
3528 | | |
3529 | | static aom_codec_err_t ctrl_set_chroma_subsampling_y(aom_codec_alg_priv_t *ctx, |
3530 | 0 | va_list args) { |
3531 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
3532 | 0 | extra_cfg.chroma_subsampling_y = CAST(AV1E_SET_CHROMA_SUBSAMPLING_Y, args); |
3533 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
3534 | 0 | } |
3535 | | |
3536 | | static aom_codec_err_t encoder_set_option(aom_codec_alg_priv_t *ctx, |
3537 | 0 | const char *name, const char *value) { |
3538 | 0 | if (ctx == NULL || name == NULL || value == NULL) |
3539 | 0 | return AOM_CODEC_INVALID_PARAM; |
3540 | 0 | struct av1_extracfg extra_cfg = ctx->extra_cfg; |
3541 | | // Used to mock the argv with just one string "--{name}={value}" |
3542 | 0 | char *argv[2] = { NULL, "" }; |
3543 | 0 | size_t len = strlen(name) + strlen(value) + 4; |
3544 | 0 | char *const err_string = ctx->ppi->error.detail; |
3545 | |
|
3546 | | #if __STDC_VERSION__ >= 201112L |
3547 | | // We use the keyword _Static_assert because clang-cl does not allow the |
3548 | | // convenience macro static_assert to be used in function scope. See |
3549 | | // https://bugs.llvm.org/show_bug.cgi?id=48904. |
3550 | | _Static_assert(sizeof(ctx->ppi->error.detail) >= ARG_ERR_MSG_MAX_LEN, |
3551 | | "The size of the err_msg buffer for arg_match_helper must be " |
3552 | | "at least ARG_ERR_MSG_MAX_LEN"); |
3553 | | #else |
3554 | 0 | assert(sizeof(ctx->ppi->error.detail) >= ARG_ERR_MSG_MAX_LEN); |
3555 | 0 | #endif |
3556 | |
|
3557 | 0 | argv[0] = aom_malloc(len * sizeof(argv[1][0])); |
3558 | 0 | snprintf(argv[0], len, "--%s=%s", name, value); |
3559 | 0 | struct arg arg; |
3560 | 0 | aom_codec_err_t err = AOM_CODEC_OK; |
3561 | |
|
3562 | 0 | int match = 1; |
3563 | 0 | if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_keyframe_filtering, |
3564 | 0 | argv, err_string)) { |
3565 | 0 | extra_cfg.enable_keyframe_filtering = |
3566 | 0 | arg_parse_uint_helper(&arg, err_string); |
3567 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.min_gf_interval, argv, |
3568 | 0 | err_string)) { |
3569 | 0 | extra_cfg.min_gf_interval = arg_parse_uint_helper(&arg, err_string); |
3570 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.max_gf_interval, argv, |
3571 | 0 | err_string)) { |
3572 | 0 | extra_cfg.max_gf_interval = arg_parse_uint_helper(&arg, err_string); |
3573 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.gf_min_pyr_height, |
3574 | 0 | argv, err_string)) { |
3575 | 0 | extra_cfg.gf_min_pyr_height = arg_parse_uint_helper(&arg, err_string); |
3576 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.gf_max_pyr_height, |
3577 | 0 | argv, err_string)) { |
3578 | 0 | extra_cfg.gf_max_pyr_height = arg_parse_uint_helper(&arg, err_string); |
3579 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.cpu_used_av1, argv, |
3580 | 0 | err_string)) { |
3581 | 0 | extra_cfg.cpu_used = arg_parse_uint_helper(&arg, err_string); |
3582 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.auto_altref, argv, |
3583 | 0 | err_string)) { |
3584 | 0 | extra_cfg.enable_auto_alt_ref = arg_parse_uint_helper(&arg, err_string); |
3585 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.noise_sens, argv, |
3586 | 0 | err_string)) { |
3587 | 0 | extra_cfg.noise_sensitivity = arg_parse_uint_helper(&arg, err_string); |
3588 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.sharpness, argv, |
3589 | 0 | err_string)) { |
3590 | 0 | extra_cfg.sharpness = arg_parse_uint_helper(&arg, err_string); |
3591 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.static_thresh, argv, |
3592 | 0 | err_string)) { |
3593 | 0 | extra_cfg.static_thresh = arg_parse_uint_helper(&arg, err_string); |
3594 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.rowmtarg, argv, |
3595 | 0 | err_string)) { |
3596 | 0 | extra_cfg.row_mt = arg_parse_uint_helper(&arg, err_string); |
3597 | 0 | } |
3598 | | #if CONFIG_FRAME_PARALLEL_ENCODE |
3599 | | else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.fpmtarg, argv, |
3600 | | err_string)) { |
3601 | | extra_cfg.fp_mt = arg_parse_uint_helper(&arg, err_string); |
3602 | | } |
3603 | | #endif |
3604 | 0 | else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.tile_cols, argv, |
3605 | 0 | err_string)) { |
3606 | 0 | extra_cfg.tile_columns = arg_parse_uint_helper(&arg, err_string); |
3607 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.tile_rows, argv, |
3608 | 0 | err_string)) { |
3609 | 0 | extra_cfg.tile_rows = arg_parse_uint_helper(&arg, err_string); |
3610 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_tpl_model, |
3611 | 0 | argv, err_string)) { |
3612 | 0 | extra_cfg.enable_tpl_model = arg_parse_uint_helper(&arg, err_string); |
3613 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.arnr_maxframes, argv, |
3614 | 0 | err_string)) { |
3615 | 0 | extra_cfg.arnr_max_frames = arg_parse_uint_helper(&arg, err_string); |
3616 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.arnr_strength, argv, |
3617 | 0 | err_string)) { |
3618 | 0 | extra_cfg.arnr_strength = arg_parse_uint_helper(&arg, err_string); |
3619 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.tune_metric, argv, |
3620 | 0 | err_string)) { |
3621 | 0 | extra_cfg.tuning = arg_parse_enum_helper(&arg, err_string); |
3622 | 0 | } |
3623 | | #if CONFIG_TUNE_VMAF |
3624 | | else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.vmaf_model_path, argv, |
3625 | | err_string)) { |
3626 | | err = allocate_and_set_string(value, default_extra_cfg.vmaf_model_path, |
3627 | | &extra_cfg.vmaf_model_path, err_string); |
3628 | | } |
3629 | | #endif |
3630 | 0 | else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.partition_info_path, |
3631 | 0 | argv, err_string)) { |
3632 | 0 | err = allocate_and_set_string(value, default_extra_cfg.partition_info_path, |
3633 | 0 | &extra_cfg.partition_info_path, err_string); |
3634 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.cq_level, argv, |
3635 | 0 | err_string)) { |
3636 | 0 | extra_cfg.cq_level = arg_parse_uint_helper(&arg, err_string); |
3637 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.max_intra_rate_pct, |
3638 | 0 | argv, err_string)) { |
3639 | 0 | extra_cfg.rc_max_intra_bitrate_pct = |
3640 | 0 | arg_parse_uint_helper(&arg, err_string); |
3641 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.max_inter_rate_pct, |
3642 | 0 | argv, err_string)) { |
3643 | 0 | extra_cfg.rc_max_inter_bitrate_pct = |
3644 | 0 | arg_parse_uint_helper(&arg, err_string); |
3645 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.gf_cbr_boost_pct, |
3646 | 0 | argv, err_string)) { |
3647 | 0 | extra_cfg.gf_cbr_boost_pct = arg_parse_uint_helper(&arg, err_string); |
3648 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.lossless, argv, |
3649 | 0 | err_string)) { |
3650 | 0 | extra_cfg.lossless = arg_parse_uint_helper(&arg, err_string); |
3651 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_cdef, argv, |
3652 | 0 | err_string)) { |
3653 | 0 | extra_cfg.enable_cdef = arg_parse_uint_helper(&arg, err_string); |
3654 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_restoration, |
3655 | 0 | argv, err_string)) { |
3656 | 0 | extra_cfg.enable_restoration = arg_parse_uint_helper(&arg, err_string); |
3657 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.force_video_mode, |
3658 | 0 | argv, err_string)) { |
3659 | 0 | extra_cfg.force_video_mode = arg_parse_uint_helper(&arg, err_string); |
3660 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_obmc, argv, |
3661 | 0 | err_string)) { |
3662 | 0 | extra_cfg.enable_obmc = arg_parse_uint_helper(&arg, err_string); |
3663 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.disable_trellis_quant, |
3664 | 0 | argv, err_string)) { |
3665 | 0 | extra_cfg.disable_trellis_quant = arg_parse_uint_helper(&arg, err_string); |
3666 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_qm, argv, |
3667 | 0 | err_string)) { |
3668 | 0 | extra_cfg.enable_qm = arg_parse_uint_helper(&arg, err_string); |
3669 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.qm_max, argv, |
3670 | 0 | err_string)) { |
3671 | 0 | extra_cfg.qm_max = arg_parse_uint_helper(&arg, err_string); |
3672 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.qm_min, argv, |
3673 | 0 | err_string)) { |
3674 | 0 | extra_cfg.qm_min = arg_parse_uint_helper(&arg, err_string); |
3675 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.num_tg, argv, |
3676 | 0 | err_string)) { |
3677 | 0 | extra_cfg.num_tg = arg_parse_uint_helper(&arg, err_string); |
3678 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.mtu_size, argv, |
3679 | 0 | err_string)) { |
3680 | 0 | extra_cfg.mtu_size = arg_parse_uint_helper(&arg, err_string); |
3681 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.timing_info, argv, |
3682 | 0 | err_string)) { |
3683 | 0 | extra_cfg.timing_info_type = arg_parse_enum_helper(&arg, err_string); |
3684 | 0 | } else if (arg_match_helper(&arg, |
3685 | 0 | &g_av1_codec_arg_defs.frame_parallel_decoding, |
3686 | 0 | argv, err_string)) { |
3687 | 0 | extra_cfg.frame_parallel_decoding_mode = |
3688 | 0 | arg_parse_uint_helper(&arg, err_string); |
3689 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_dual_filter, |
3690 | 0 | argv, err_string)) { |
3691 | 0 | extra_cfg.enable_dual_filter = arg_parse_uint_helper(&arg, err_string); |
3692 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_chroma_deltaq, |
3693 | 0 | argv, err_string)) { |
3694 | 0 | extra_cfg.enable_chroma_deltaq = arg_parse_uint_helper(&arg, err_string); |
3695 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.aq_mode, argv, |
3696 | 0 | err_string)) { |
3697 | 0 | extra_cfg.aq_mode = arg_parse_uint_helper(&arg, err_string); |
3698 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.deltaq_mode, argv, |
3699 | 0 | err_string)) { |
3700 | 0 | extra_cfg.deltaq_mode = arg_parse_uint_helper(&arg, err_string); |
3701 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.deltaq_strength, argv, |
3702 | 0 | err_string)) { |
3703 | 0 | extra_cfg.deltaq_strength = arg_parse_uint_helper(&arg, err_string); |
3704 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.deltalf_mode, argv, |
3705 | 0 | err_string)) { |
3706 | 0 | extra_cfg.deltalf_mode = arg_parse_uint_helper(&arg, err_string); |
3707 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.frame_periodic_boost, |
3708 | 0 | argv, err_string)) { |
3709 | 0 | extra_cfg.frame_periodic_boost = arg_parse_uint_helper(&arg, err_string); |
3710 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.tune_content, argv, |
3711 | 0 | err_string)) { |
3712 | 0 | extra_cfg.content = arg_parse_enum_helper(&arg, err_string); |
3713 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.input_color_primaries, |
3714 | 0 | argv, err_string)) { |
3715 | 0 | extra_cfg.color_primaries = arg_parse_enum_helper(&arg, err_string); |
3716 | 0 | } else if (arg_match_helper( |
3717 | 0 | &arg, &g_av1_codec_arg_defs.input_transfer_characteristics, |
3718 | 0 | argv, err_string)) { |
3719 | 0 | extra_cfg.transfer_characteristics = |
3720 | 0 | arg_parse_enum_helper(&arg, err_string); |
3721 | 0 | } else if (arg_match_helper(&arg, |
3722 | 0 | &g_av1_codec_arg_defs.input_matrix_coefficients, |
3723 | 0 | argv, err_string)) { |
3724 | 0 | extra_cfg.matrix_coefficients = arg_parse_enum_helper(&arg, err_string); |
3725 | 0 | } else if (arg_match_helper( |
3726 | 0 | &arg, &g_av1_codec_arg_defs.input_chroma_sample_position, argv, |
3727 | 0 | err_string)) { |
3728 | 0 | extra_cfg.chroma_sample_position = arg_parse_enum_helper(&arg, err_string); |
3729 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.superblock_size, argv, |
3730 | 0 | err_string)) { |
3731 | 0 | extra_cfg.superblock_size = arg_parse_enum_helper(&arg, err_string); |
3732 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.error_resilient_mode, |
3733 | 0 | argv, err_string)) { |
3734 | 0 | extra_cfg.error_resilient_mode = arg_parse_int_helper(&arg, err_string); |
3735 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.sframe_mode, argv, |
3736 | 0 | err_string)) { |
3737 | 0 | extra_cfg.s_frame_mode = arg_parse_int_helper(&arg, err_string); |
3738 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.film_grain_test, argv, |
3739 | 0 | err_string)) { |
3740 | 0 | extra_cfg.film_grain_test_vector = arg_parse_int_helper(&arg, err_string); |
3741 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.film_grain_table, |
3742 | 0 | argv, err_string)) { |
3743 | 0 | if (value == NULL) { |
3744 | | // this parameter allows NULL as its value |
3745 | 0 | extra_cfg.film_grain_table_filename = value; |
3746 | 0 | } else { |
3747 | 0 | err = allocate_and_set_string( |
3748 | 0 | value, default_extra_cfg.film_grain_table_filename, |
3749 | 0 | &extra_cfg.film_grain_table_filename, err_string); |
3750 | 0 | } |
3751 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.cdf_update_mode, argv, |
3752 | 0 | err_string)) { |
3753 | 0 | extra_cfg.cdf_update_mode = arg_parse_int_helper(&arg, err_string); |
3754 | 0 | } else if (arg_match_helper(&arg, |
3755 | 0 | &g_av1_codec_arg_defs.enable_rect_partitions, |
3756 | 0 | argv, err_string)) { |
3757 | 0 | extra_cfg.enable_rect_partitions = arg_parse_int_helper(&arg, err_string); |
3758 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_ab_partitions, |
3759 | 0 | argv, err_string)) { |
3760 | 0 | extra_cfg.enable_ab_partitions = arg_parse_int_helper(&arg, err_string); |
3761 | 0 | } else if (arg_match_helper(&arg, |
3762 | 0 | &g_av1_codec_arg_defs.enable_1to4_partitions, |
3763 | 0 | argv, err_string)) { |
3764 | 0 | extra_cfg.enable_1to4_partitions = arg_parse_int_helper(&arg, err_string); |
3765 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.min_partition_size, |
3766 | 0 | argv, err_string)) { |
3767 | 0 | extra_cfg.min_partition_size = arg_parse_int_helper(&arg, err_string); |
3768 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.max_partition_size, |
3769 | 0 | argv, err_string)) { |
3770 | 0 | extra_cfg.max_partition_size = arg_parse_int_helper(&arg, err_string); |
3771 | 0 | } else if (arg_match_helper(&arg, |
3772 | 0 | &g_av1_codec_arg_defs.enable_intra_edge_filter, |
3773 | 0 | argv, err_string)) { |
3774 | 0 | extra_cfg.enable_intra_edge_filter = |
3775 | 0 | arg_parse_uint_helper(&arg, err_string); |
3776 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_order_hint, |
3777 | 0 | argv, err_string)) { |
3778 | 0 | extra_cfg.enable_order_hint = arg_parse_int_helper(&arg, err_string); |
3779 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_tx64, argv, |
3780 | 0 | err_string)) { |
3781 | 0 | extra_cfg.enable_tx64 = arg_parse_int_helper(&arg, err_string); |
3782 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_flip_idtx, |
3783 | 0 | argv, err_string)) { |
3784 | 0 | extra_cfg.enable_flip_idtx = arg_parse_int_helper(&arg, err_string); |
3785 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_rect_tx, argv, |
3786 | 0 | err_string)) { |
3787 | 0 | extra_cfg.enable_rect_tx = arg_parse_int_helper(&arg, err_string); |
3788 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_dist_wtd_comp, |
3789 | 0 | argv, err_string)) { |
3790 | 0 | extra_cfg.enable_dist_wtd_comp = arg_parse_int_helper(&arg, err_string); |
3791 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.max_reference_frames, |
3792 | 0 | argv, err_string)) { |
3793 | 0 | extra_cfg.max_reference_frames = arg_parse_int_helper(&arg, err_string); |
3794 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.reduced_reference_set, |
3795 | 0 | argv, err_string)) { |
3796 | 0 | extra_cfg.enable_reduced_reference_set = |
3797 | 0 | arg_parse_int_helper(&arg, err_string); |
3798 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_ref_frame_mvs, |
3799 | 0 | argv, err_string)) { |
3800 | 0 | extra_cfg.enable_ref_frame_mvs = arg_parse_int_helper(&arg, err_string); |
3801 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_masked_comp, |
3802 | 0 | argv, err_string)) { |
3803 | 0 | extra_cfg.enable_masked_comp = arg_parse_int_helper(&arg, err_string); |
3804 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_onesided_comp, |
3805 | 0 | argv, err_string)) { |
3806 | 0 | extra_cfg.enable_onesided_comp = arg_parse_int_helper(&arg, err_string); |
3807 | 0 | } else if (arg_match_helper(&arg, |
3808 | 0 | &g_av1_codec_arg_defs.enable_interintra_comp, |
3809 | 0 | argv, err_string)) { |
3810 | 0 | extra_cfg.enable_interintra_comp = arg_parse_int_helper(&arg, err_string); |
3811 | 0 | } else if (arg_match_helper(&arg, |
3812 | 0 | &g_av1_codec_arg_defs.enable_smooth_interintra, |
3813 | 0 | argv, err_string)) { |
3814 | 0 | extra_cfg.enable_smooth_interintra = arg_parse_int_helper(&arg, err_string); |
3815 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_diff_wtd_comp, |
3816 | 0 | argv, err_string)) { |
3817 | 0 | extra_cfg.enable_diff_wtd_comp = arg_parse_int_helper(&arg, err_string); |
3818 | 0 | } else if (arg_match_helper(&arg, |
3819 | 0 | &g_av1_codec_arg_defs.enable_interinter_wedge, |
3820 | 0 | argv, err_string)) { |
3821 | 0 | extra_cfg.enable_interinter_wedge = arg_parse_int_helper(&arg, err_string); |
3822 | 0 | } else if (arg_match_helper(&arg, |
3823 | 0 | &g_av1_codec_arg_defs.enable_interintra_wedge, |
3824 | 0 | argv, err_string)) { |
3825 | 0 | extra_cfg.enable_interintra_wedge = arg_parse_int_helper(&arg, err_string); |
3826 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_global_motion, |
3827 | 0 | argv, err_string)) { |
3828 | 0 | extra_cfg.enable_global_motion = arg_parse_int_helper(&arg, err_string); |
3829 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_warped_motion, |
3830 | 0 | argv, err_string)) { |
3831 | 0 | extra_cfg.enable_warped_motion = arg_parse_int_helper(&arg, err_string); |
3832 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_filter_intra, |
3833 | 0 | argv, err_string)) { |
3834 | 0 | extra_cfg.enable_filter_intra = arg_parse_int_helper(&arg, err_string); |
3835 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_smooth_intra, |
3836 | 0 | argv, err_string)) { |
3837 | 0 | extra_cfg.enable_smooth_intra = arg_parse_int_helper(&arg, err_string); |
3838 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_paeth_intra, |
3839 | 0 | argv, err_string)) { |
3840 | 0 | extra_cfg.enable_paeth_intra = arg_parse_int_helper(&arg, err_string); |
3841 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_cfl_intra, |
3842 | 0 | argv, err_string)) { |
3843 | 0 | extra_cfg.enable_cfl_intra = arg_parse_int_helper(&arg, err_string); |
3844 | 0 | } else if (arg_match_helper(&arg, |
3845 | 0 | &g_av1_codec_arg_defs.enable_directional_intra, |
3846 | 0 | argv, err_string)) { |
3847 | 0 | extra_cfg.enable_directional_intra = arg_parse_int_helper(&arg, err_string); |
3848 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_diagonal_intra, |
3849 | 0 | argv, err_string)) { |
3850 | 0 | extra_cfg.enable_diagonal_intra = arg_parse_int_helper(&arg, err_string); |
3851 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_overlay, argv, |
3852 | 0 | err_string)) { |
3853 | 0 | extra_cfg.enable_overlay = arg_parse_int_helper(&arg, err_string); |
3854 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_palette, argv, |
3855 | 0 | err_string)) { |
3856 | 0 | extra_cfg.enable_palette = arg_parse_int_helper(&arg, err_string); |
3857 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_intrabc, argv, |
3858 | 0 | err_string)) { |
3859 | 0 | extra_cfg.enable_intrabc = arg_parse_int_helper(&arg, err_string); |
3860 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_angle_delta, |
3861 | 0 | argv, err_string)) { |
3862 | 0 | extra_cfg.enable_angle_delta = arg_parse_int_helper(&arg, err_string); |
3863 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.reduced_tx_type_set, |
3864 | 0 | argv, err_string)) { |
3865 | 0 | extra_cfg.reduced_tx_type_set = arg_parse_int_helper(&arg, err_string); |
3866 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.use_intra_dct_only, |
3867 | 0 | argv, err_string)) { |
3868 | 0 | extra_cfg.use_intra_dct_only = arg_parse_int_helper(&arg, err_string); |
3869 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.use_inter_dct_only, |
3870 | 0 | argv, err_string)) { |
3871 | 0 | extra_cfg.use_inter_dct_only = arg_parse_int_helper(&arg, err_string); |
3872 | 0 | } else if (arg_match_helper(&arg, |
3873 | 0 | &g_av1_codec_arg_defs.use_intra_default_tx_only, |
3874 | 0 | argv, err_string)) { |
3875 | 0 | extra_cfg.use_intra_default_tx_only = |
3876 | 0 | arg_parse_int_helper(&arg, err_string); |
3877 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.quant_b_adapt, argv, |
3878 | 0 | err_string)) { |
3879 | 0 | extra_cfg.quant_b_adapt = arg_parse_int_helper(&arg, err_string); |
3880 | 0 | } else if (arg_match_helper(&arg, |
3881 | 0 | &g_av1_codec_arg_defs.vbr_corpus_complexity_lap, |
3882 | 0 | argv, err_string)) { |
3883 | 0 | extra_cfg.vbr_corpus_complexity_lap = |
3884 | 0 | arg_parse_uint_helper(&arg, err_string); |
3885 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.set_tier_mask, argv, |
3886 | 0 | err_string)) { |
3887 | 0 | extra_cfg.tier_mask = arg_parse_uint_helper(&arg, err_string); |
3888 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.set_min_cr, argv, |
3889 | 0 | err_string)) { |
3890 | 0 | extra_cfg.min_cr = arg_parse_uint_helper(&arg, err_string); |
3891 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.coeff_cost_upd_freq, |
3892 | 0 | argv, err_string)) { |
3893 | 0 | extra_cfg.coeff_cost_upd_freq = arg_parse_uint_helper(&arg, err_string); |
3894 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.mode_cost_upd_freq, |
3895 | 0 | argv, err_string)) { |
3896 | 0 | extra_cfg.mode_cost_upd_freq = arg_parse_uint_helper(&arg, err_string); |
3897 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.mv_cost_upd_freq, |
3898 | 0 | argv, err_string)) { |
3899 | 0 | extra_cfg.mv_cost_upd_freq = arg_parse_uint_helper(&arg, err_string); |
3900 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.dv_cost_upd_freq, |
3901 | 0 | argv, err_string)) { |
3902 | 0 | extra_cfg.dv_cost_upd_freq = arg_parse_uint_helper(&arg, err_string); |
3903 | 0 | } |
3904 | 0 | #if CONFIG_DENOISE |
3905 | 0 | else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.denoise_noise_level, |
3906 | 0 | argv, err_string)) { |
3907 | 0 | extra_cfg.noise_level = |
3908 | 0 | (float)arg_parse_int_helper(&arg, err_string) / 10.0f; |
3909 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.denoise_block_size, |
3910 | 0 | argv, err_string)) { |
3911 | 0 | extra_cfg.noise_block_size = arg_parse_uint_helper(&arg, err_string); |
3912 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_dnl_denoising, |
3913 | 0 | argv, err_string)) { |
3914 | 0 | extra_cfg.enable_dnl_denoising = arg_parse_uint_helper(&arg, err_string); |
3915 | 0 | } |
3916 | 0 | #endif |
3917 | 0 | else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.target_seq_level_idx, |
3918 | 0 | argv, err_string)) { |
3919 | 0 | const int val = arg_parse_int_helper(&arg, err_string); |
3920 | 0 | const int level = val % 100; |
3921 | 0 | const int operating_point_idx = val / 100; |
3922 | 0 | if (operating_point_idx >= 0 && |
3923 | 0 | operating_point_idx < MAX_NUM_OPERATING_POINTS) { |
3924 | 0 | extra_cfg.target_seq_level_idx[operating_point_idx] = (AV1_LEVEL)level; |
3925 | 0 | } |
3926 | 0 | } else if (arg_match_helper(&arg, |
3927 | 0 | &g_av1_codec_arg_defs.input_chroma_subsampling_x, |
3928 | 0 | argv, err_string)) { |
3929 | 0 | extra_cfg.chroma_subsampling_x = arg_parse_uint_helper(&arg, err_string); |
3930 | 0 | } else if (arg_match_helper(&arg, |
3931 | 0 | &g_av1_codec_arg_defs.input_chroma_subsampling_y, |
3932 | 0 | argv, err_string)) { |
3933 | 0 | extra_cfg.chroma_subsampling_y = arg_parse_uint_helper(&arg, err_string); |
3934 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.passes, argv, |
3935 | 0 | err_string)) { |
3936 | 0 | extra_cfg.passes = arg_parse_int_helper(&arg, err_string); |
3937 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.fwd_kf_dist, argv, |
3938 | 0 | err_string)) { |
3939 | 0 | extra_cfg.fwd_kf_dist = arg_parse_int_helper(&arg, err_string); |
3940 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.two_pass_output, argv, |
3941 | 0 | err_string)) { |
3942 | 0 | err = allocate_and_set_string(value, default_extra_cfg.two_pass_output, |
3943 | 0 | &extra_cfg.two_pass_output, err_string); |
3944 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.second_pass_log, argv, |
3945 | 0 | err_string)) { |
3946 | 0 | err = allocate_and_set_string(value, default_extra_cfg.second_pass_log, |
3947 | 0 | &extra_cfg.second_pass_log, err_string); |
3948 | 0 | } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.loopfilter_control, |
3949 | 0 | argv, err_string)) { |
3950 | 0 | extra_cfg.loopfilter_control = arg_parse_int_helper(&arg, err_string); |
3951 | 0 | } else { |
3952 | 0 | match = 0; |
3953 | 0 | snprintf(err_string, ARG_ERR_MSG_MAX_LEN, "Cannot find aom option %s", |
3954 | 0 | name); |
3955 | 0 | } |
3956 | 0 | aom_free(argv[0]); |
3957 | |
|
3958 | 0 | if (err != AOM_CODEC_OK) { |
3959 | 0 | ctx->base.err_detail = err_string; |
3960 | 0 | return err; |
3961 | 0 | } |
3962 | | |
3963 | 0 | if (strlen(err_string) != 0) { |
3964 | 0 | ctx->base.err_detail = err_string; |
3965 | 0 | return AOM_CODEC_INVALID_PARAM; |
3966 | 0 | } |
3967 | | |
3968 | 0 | ctx->base.err_detail = NULL; |
3969 | |
|
3970 | 0 | if (!match) { |
3971 | 0 | return AOM_CODEC_INVALID_PARAM; |
3972 | 0 | } |
3973 | 0 | return update_extra_cfg(ctx, &extra_cfg); |
3974 | 0 | } |
3975 | | |
3976 | | static aom_codec_err_t ctrl_get_seq_level_idx(aom_codec_alg_priv_t *ctx, |
3977 | 0 | va_list args) { |
3978 | 0 | int *const arg = va_arg(args, int *); |
3979 | 0 | if (arg == NULL) return AOM_CODEC_INVALID_PARAM; |
3980 | 0 | return av1_get_seq_level_idx(&ctx->ppi->seq_params, &ctx->ppi->level_params, |
3981 | 0 | arg); |
3982 | 0 | } |
3983 | | |
3984 | | static aom_codec_ctrl_fn_map_t encoder_ctrl_maps[] = { |
3985 | | { AV1_COPY_REFERENCE, ctrl_copy_reference }, |
3986 | | { AOME_USE_REFERENCE, ctrl_use_reference }, |
3987 | | |
3988 | | // Setters |
3989 | | { AV1_SET_REFERENCE, ctrl_set_reference }, |
3990 | | { AOME_SET_ROI_MAP, ctrl_set_roi_map }, |
3991 | | { AOME_SET_ACTIVEMAP, ctrl_set_active_map }, |
3992 | | { AOME_SET_SCALEMODE, ctrl_set_scale_mode }, |
3993 | | { AOME_SET_SPATIAL_LAYER_ID, ctrl_set_spatial_layer_id }, |
3994 | | { AOME_SET_CPUUSED, ctrl_set_cpuused }, |
3995 | | { AOME_SET_ENABLEAUTOALTREF, ctrl_set_enable_auto_alt_ref }, |
3996 | | { AOME_SET_ENABLEAUTOBWDREF, ctrl_set_enable_auto_bwd_ref }, |
3997 | | { AOME_SET_SHARPNESS, ctrl_set_sharpness }, |
3998 | | { AOME_SET_STATIC_THRESHOLD, ctrl_set_static_thresh }, |
3999 | | { AV1E_SET_ROW_MT, ctrl_set_row_mt }, |
4000 | | { AV1E_SET_FP_MT, ctrl_set_fp_mt }, |
4001 | | { AV1E_SET_TILE_COLUMNS, ctrl_set_tile_columns }, |
4002 | | { AV1E_SET_TILE_ROWS, ctrl_set_tile_rows }, |
4003 | | { AV1E_SET_ENABLE_TPL_MODEL, ctrl_set_enable_tpl_model }, |
4004 | | { AV1E_SET_ENABLE_KEYFRAME_FILTERING, ctrl_set_enable_keyframe_filtering }, |
4005 | | { AOME_SET_ARNR_MAXFRAMES, ctrl_set_arnr_max_frames }, |
4006 | | { AOME_SET_ARNR_STRENGTH, ctrl_set_arnr_strength }, |
4007 | | { AOME_SET_TUNING, ctrl_set_tuning }, |
4008 | | { AOME_SET_CQ_LEVEL, ctrl_set_cq_level }, |
4009 | | { AOME_SET_MAX_INTRA_BITRATE_PCT, ctrl_set_rc_max_intra_bitrate_pct }, |
4010 | | { AOME_SET_NUMBER_SPATIAL_LAYERS, ctrl_set_number_spatial_layers }, |
4011 | | { AV1E_SET_MAX_INTER_BITRATE_PCT, ctrl_set_rc_max_inter_bitrate_pct }, |
4012 | | { AV1E_SET_GF_CBR_BOOST_PCT, ctrl_set_rc_gf_cbr_boost_pct }, |
4013 | | { AV1E_SET_LOSSLESS, ctrl_set_lossless }, |
4014 | | { AV1E_SET_ENABLE_CDEF, ctrl_set_enable_cdef }, |
4015 | | { AV1E_SET_ENABLE_RESTORATION, ctrl_set_enable_restoration }, |
4016 | | { AV1E_SET_FORCE_VIDEO_MODE, ctrl_set_force_video_mode }, |
4017 | | { AV1E_SET_ENABLE_OBMC, ctrl_set_enable_obmc }, |
4018 | | { AV1E_SET_DISABLE_TRELLIS_QUANT, ctrl_set_disable_trellis_quant }, |
4019 | | { AV1E_SET_ENABLE_QM, ctrl_set_enable_qm }, |
4020 | | { AV1E_SET_QM_Y, ctrl_set_qm_y }, |
4021 | | { AV1E_SET_QM_U, ctrl_set_qm_u }, |
4022 | | { AV1E_SET_QM_V, ctrl_set_qm_v }, |
4023 | | { AV1E_SET_QM_MIN, ctrl_set_qm_min }, |
4024 | | { AV1E_SET_QM_MAX, ctrl_set_qm_max }, |
4025 | | { AV1E_SET_NUM_TG, ctrl_set_num_tg }, |
4026 | | { AV1E_SET_MTU, ctrl_set_mtu }, |
4027 | | { AV1E_SET_TIMING_INFO_TYPE, ctrl_set_timing_info_type }, |
4028 | | { AV1E_SET_FRAME_PARALLEL_DECODING, ctrl_set_frame_parallel_decoding_mode }, |
4029 | | { AV1E_SET_ERROR_RESILIENT_MODE, ctrl_set_error_resilient_mode }, |
4030 | | { AV1E_SET_S_FRAME_MODE, ctrl_set_s_frame_mode }, |
4031 | | { AV1E_SET_ENABLE_RECT_PARTITIONS, ctrl_set_enable_rect_partitions }, |
4032 | | { AV1E_SET_ENABLE_AB_PARTITIONS, ctrl_set_enable_ab_partitions }, |
4033 | | { AV1E_SET_ENABLE_1TO4_PARTITIONS, ctrl_set_enable_1to4_partitions }, |
4034 | | { AV1E_SET_MIN_PARTITION_SIZE, ctrl_set_min_partition_size }, |
4035 | | { AV1E_SET_MAX_PARTITION_SIZE, ctrl_set_max_partition_size }, |
4036 | | { AV1E_SET_ENABLE_DUAL_FILTER, ctrl_set_enable_dual_filter }, |
4037 | | { AV1E_SET_ENABLE_CHROMA_DELTAQ, ctrl_set_enable_chroma_deltaq }, |
4038 | | { AV1E_SET_ENABLE_INTRA_EDGE_FILTER, ctrl_set_enable_intra_edge_filter }, |
4039 | | { AV1E_SET_ENABLE_ORDER_HINT, ctrl_set_enable_order_hint }, |
4040 | | { AV1E_SET_ENABLE_TX64, ctrl_set_enable_tx64 }, |
4041 | | { AV1E_SET_ENABLE_FLIP_IDTX, ctrl_set_enable_flip_idtx }, |
4042 | | { AV1E_SET_ENABLE_RECT_TX, ctrl_set_enable_rect_tx }, |
4043 | | { AV1E_SET_ENABLE_DIST_WTD_COMP, ctrl_set_enable_dist_wtd_comp }, |
4044 | | { AV1E_SET_MAX_REFERENCE_FRAMES, ctrl_set_max_reference_frames }, |
4045 | | { AV1E_SET_REDUCED_REFERENCE_SET, ctrl_set_enable_reduced_reference_set }, |
4046 | | { AV1E_SET_ENABLE_REF_FRAME_MVS, ctrl_set_enable_ref_frame_mvs }, |
4047 | | { AV1E_SET_ALLOW_REF_FRAME_MVS, ctrl_set_allow_ref_frame_mvs }, |
4048 | | { AV1E_SET_ENABLE_MASKED_COMP, ctrl_set_enable_masked_comp }, |
4049 | | { AV1E_SET_ENABLE_ONESIDED_COMP, ctrl_set_enable_onesided_comp }, |
4050 | | { AV1E_SET_ENABLE_INTERINTRA_COMP, ctrl_set_enable_interintra_comp }, |
4051 | | { AV1E_SET_ENABLE_SMOOTH_INTERINTRA, ctrl_set_enable_smooth_interintra }, |
4052 | | { AV1E_SET_ENABLE_DIFF_WTD_COMP, ctrl_set_enable_diff_wtd_comp }, |
4053 | | { AV1E_SET_ENABLE_INTERINTER_WEDGE, ctrl_set_enable_interinter_wedge }, |
4054 | | { AV1E_SET_ENABLE_INTERINTRA_WEDGE, ctrl_set_enable_interintra_wedge }, |
4055 | | { AV1E_SET_ENABLE_GLOBAL_MOTION, ctrl_set_enable_global_motion }, |
4056 | | { AV1E_SET_ENABLE_WARPED_MOTION, ctrl_set_enable_warped_motion }, |
4057 | | { AV1E_SET_ALLOW_WARPED_MOTION, ctrl_set_allow_warped_motion }, |
4058 | | { AV1E_SET_ENABLE_FILTER_INTRA, ctrl_set_enable_filter_intra }, |
4059 | | { AV1E_SET_ENABLE_SMOOTH_INTRA, ctrl_set_enable_smooth_intra }, |
4060 | | { AV1E_SET_ENABLE_PAETH_INTRA, ctrl_set_enable_paeth_intra }, |
4061 | | { AV1E_SET_ENABLE_CFL_INTRA, ctrl_set_enable_cfl_intra }, |
4062 | | { AV1E_SET_ENABLE_DIRECTIONAL_INTRA, ctrl_set_enable_directional_intra }, |
4063 | | { AV1E_SET_ENABLE_DIAGONAL_INTRA, ctrl_set_enable_diagonal_intra }, |
4064 | | { AV1E_SET_ENABLE_SUPERRES, ctrl_set_enable_superres }, |
4065 | | { AV1E_SET_ENABLE_OVERLAY, ctrl_set_enable_overlay }, |
4066 | | { AV1E_SET_ENABLE_PALETTE, ctrl_set_enable_palette }, |
4067 | | { AV1E_SET_ENABLE_INTRABC, ctrl_set_enable_intrabc }, |
4068 | | { AV1E_SET_ENABLE_ANGLE_DELTA, ctrl_set_enable_angle_delta }, |
4069 | | { AV1E_SET_AQ_MODE, ctrl_set_aq_mode }, |
4070 | | { AV1E_SET_REDUCED_TX_TYPE_SET, ctrl_set_reduced_tx_type_set }, |
4071 | | { AV1E_SET_INTRA_DCT_ONLY, ctrl_set_intra_dct_only }, |
4072 | | { AV1E_SET_INTER_DCT_ONLY, ctrl_set_inter_dct_only }, |
4073 | | { AV1E_SET_INTRA_DEFAULT_TX_ONLY, ctrl_set_intra_default_tx_only }, |
4074 | | { AV1E_SET_QUANT_B_ADAPT, ctrl_set_quant_b_adapt }, |
4075 | | { AV1E_SET_COEFF_COST_UPD_FREQ, ctrl_set_coeff_cost_upd_freq }, |
4076 | | { AV1E_SET_MODE_COST_UPD_FREQ, ctrl_set_mode_cost_upd_freq }, |
4077 | | { AV1E_SET_MV_COST_UPD_FREQ, ctrl_set_mv_cost_upd_freq }, |
4078 | | { AV1E_SET_DELTAQ_MODE, ctrl_set_deltaq_mode }, |
4079 | | { AV1E_SET_DELTAQ_STRENGTH, ctrl_set_deltaq_strength }, |
4080 | | { AV1E_SET_DELTALF_MODE, ctrl_set_deltalf_mode }, |
4081 | | { AV1E_SET_FRAME_PERIODIC_BOOST, ctrl_set_frame_periodic_boost }, |
4082 | | { AV1E_SET_TUNE_CONTENT, ctrl_set_tune_content }, |
4083 | | { AV1E_SET_CDF_UPDATE_MODE, ctrl_set_cdf_update_mode }, |
4084 | | { AV1E_SET_COLOR_PRIMARIES, ctrl_set_color_primaries }, |
4085 | | { AV1E_SET_TRANSFER_CHARACTERISTICS, ctrl_set_transfer_characteristics }, |
4086 | | { AV1E_SET_MATRIX_COEFFICIENTS, ctrl_set_matrix_coefficients }, |
4087 | | { AV1E_SET_CHROMA_SAMPLE_POSITION, ctrl_set_chroma_sample_position }, |
4088 | | { AV1E_SET_COLOR_RANGE, ctrl_set_color_range }, |
4089 | | { AV1E_SET_NOISE_SENSITIVITY, ctrl_set_noise_sensitivity }, |
4090 | | { AV1E_SET_MIN_GF_INTERVAL, ctrl_set_min_gf_interval }, |
4091 | | { AV1E_SET_MAX_GF_INTERVAL, ctrl_set_max_gf_interval }, |
4092 | | { AV1E_SET_GF_MIN_PYRAMID_HEIGHT, ctrl_set_gf_min_pyr_height }, |
4093 | | { AV1E_SET_GF_MAX_PYRAMID_HEIGHT, ctrl_set_gf_max_pyr_height }, |
4094 | | { AV1E_SET_RENDER_SIZE, ctrl_set_render_size }, |
4095 | | { AV1E_SET_SUPERBLOCK_SIZE, ctrl_set_superblock_size }, |
4096 | | { AV1E_SET_SINGLE_TILE_DECODING, ctrl_set_single_tile_decoding }, |
4097 | | { AV1E_SET_VMAF_MODEL_PATH, ctrl_set_vmaf_model_path }, |
4098 | | { AV1E_SET_PARTITION_INFO_PATH, ctrl_set_partition_info_path }, |
4099 | | { AV1E_SET_FILM_GRAIN_TEST_VECTOR, ctrl_set_film_grain_test_vector }, |
4100 | | { AV1E_SET_FILM_GRAIN_TABLE, ctrl_set_film_grain_table }, |
4101 | | { AV1E_SET_DENOISE_NOISE_LEVEL, ctrl_set_denoise_noise_level }, |
4102 | | { AV1E_SET_DENOISE_BLOCK_SIZE, ctrl_set_denoise_block_size }, |
4103 | | { AV1E_SET_ENABLE_DNL_DENOISING, ctrl_set_enable_dnl_denoising }, |
4104 | | { AV1E_ENABLE_MOTION_VECTOR_UNIT_TEST, ctrl_enable_motion_vector_unit_test }, |
4105 | | { AV1E_SET_FP_MT_UNIT_TEST, ctrl_enable_fpmt_unit_test }, |
4106 | | { AV1E_ENABLE_EXT_TILE_DEBUG, ctrl_enable_ext_tile_debug }, |
4107 | | { AV1E_SET_TARGET_SEQ_LEVEL_IDX, ctrl_set_target_seq_level_idx }, |
4108 | | { AV1E_SET_TIER_MASK, ctrl_set_tier_mask }, |
4109 | | { AV1E_SET_MIN_CR, ctrl_set_min_cr }, |
4110 | | { AV1E_SET_SVC_LAYER_ID, ctrl_set_layer_id }, |
4111 | | { AV1E_SET_SVC_PARAMS, ctrl_set_svc_params }, |
4112 | | { AV1E_SET_SVC_REF_FRAME_CONFIG, ctrl_set_svc_ref_frame_config }, |
4113 | | { AV1E_SET_SVC_REF_FRAME_COMP_PRED, ctrl_set_svc_ref_frame_comp_pred }, |
4114 | | { AV1E_SET_VBR_CORPUS_COMPLEXITY_LAP, ctrl_set_vbr_corpus_complexity_lap }, |
4115 | | { AV1E_ENABLE_SB_MULTIPASS_UNIT_TEST, ctrl_enable_sb_multipass_unit_test }, |
4116 | | { AV1E_SET_DV_COST_UPD_FREQ, ctrl_set_dv_cost_upd_freq }, |
4117 | | { AV1E_SET_EXTERNAL_PARTITION, ctrl_set_external_partition }, |
4118 | | { AV1E_SET_ENABLE_TX_SIZE_SEARCH, ctrl_set_enable_tx_size_search }, |
4119 | | { AV1E_SET_LOOPFILTER_CONTROL, ctrl_set_loopfilter_control }, |
4120 | | { AV1E_SET_AUTO_INTRA_TOOLS_OFF, ctrl_set_auto_intra_tools_off }, |
4121 | | { AV1E_SET_RTC_EXTERNAL_RC, ctrl_set_rtc_external_rc }, |
4122 | | |
4123 | | // Getters |
4124 | | { AOME_GET_LAST_QUANTIZER, ctrl_get_quantizer }, |
4125 | | { AOME_GET_LAST_QUANTIZER_64, ctrl_get_quantizer64 }, |
4126 | | { AOME_GET_LOOPFILTER_LEVEL, ctrl_get_loopfilter_level }, |
4127 | | { AV1_GET_REFERENCE, ctrl_get_reference }, |
4128 | | { AV1E_GET_ACTIVEMAP, ctrl_get_active_map }, |
4129 | | { AV1_GET_NEW_FRAME_IMAGE, ctrl_get_new_frame_image }, |
4130 | | { AV1_COPY_NEW_FRAME_IMAGE, ctrl_copy_new_frame_image }, |
4131 | | { AV1E_SET_CHROMA_SUBSAMPLING_X, ctrl_set_chroma_subsampling_x }, |
4132 | | { AV1E_SET_CHROMA_SUBSAMPLING_Y, ctrl_set_chroma_subsampling_y }, |
4133 | | { AV1E_GET_SEQ_LEVEL_IDX, ctrl_get_seq_level_idx }, |
4134 | | { AV1E_GET_BASELINE_GF_INTERVAL, ctrl_get_baseline_gf_interval }, |
4135 | | |
4136 | | CTRL_MAP_END, |
4137 | | }; |
4138 | | |
4139 | | static const aom_codec_enc_cfg_t encoder_usage_cfg[] = { |
4140 | | #if !CONFIG_REALTIME_ONLY |
4141 | | { |
4142 | | // NOLINT |
4143 | | AOM_USAGE_GOOD_QUALITY, // g_usage - non-realtime usage |
4144 | | 0, // g_threads |
4145 | | 0, // g_profile |
4146 | | |
4147 | | 320, // g_w |
4148 | | 240, // g_h |
4149 | | 0, // g_limit |
4150 | | 0, // g_forced_max_frame_width |
4151 | | 0, // g_forced_max_frame_height |
4152 | | AOM_BITS_8, // g_bit_depth |
4153 | | 8, // g_input_bit_depth |
4154 | | |
4155 | | { 1, 30 }, // g_timebase |
4156 | | |
4157 | | 0, // g_error_resilient |
4158 | | |
4159 | | AOM_RC_ONE_PASS, // g_pass |
4160 | | |
4161 | | 35, // g_lag_in_frames |
4162 | | |
4163 | | 0, // rc_dropframe_thresh |
4164 | | RESIZE_NONE, // rc_resize_mode |
4165 | | SCALE_NUMERATOR, // rc_resize_denominator |
4166 | | SCALE_NUMERATOR, // rc_resize_kf_denominator |
4167 | | |
4168 | | AOM_SUPERRES_NONE, // rc_superres_mode |
4169 | | SCALE_NUMERATOR, // rc_superres_denominator |
4170 | | SCALE_NUMERATOR, // rc_superres_kf_denominator |
4171 | | 63, // rc_superres_qthresh |
4172 | | 32, // rc_superres_kf_qthresh |
4173 | | |
4174 | | AOM_VBR, // rc_end_usage |
4175 | | { NULL, 0 }, // rc_twopass_stats_in |
4176 | | { NULL, 0 }, // rc_firstpass_mb_stats_in |
4177 | | 256, // rc_target_bitrate |
4178 | | 0, // rc_min_quantizer |
4179 | | 63, // rc_max_quantizer |
4180 | | 25, // rc_undershoot_pct |
4181 | | 25, // rc_overshoot_pct |
4182 | | |
4183 | | 6000, // rc_max_buffer_size |
4184 | | 4000, // rc_buffer_initial_size |
4185 | | 5000, // rc_buffer_optimal_size |
4186 | | |
4187 | | 50, // rc_two_pass_vbrbias |
4188 | | 0, // rc_two_pass_vbrmin_section |
4189 | | 2000, // rc_two_pass_vbrmax_section |
4190 | | |
4191 | | // keyframing settings (kf) |
4192 | | 0, // fwd_kf_enabled |
4193 | | AOM_KF_AUTO, // kf_mode |
4194 | | 0, // kf_min_dist |
4195 | | 9999, // kf_max_dist |
4196 | | 0, // sframe_dist |
4197 | | 1, // sframe_mode |
4198 | | 0, // large_scale_tile |
4199 | | 0, // monochrome |
4200 | | 0, // full_still_picture_hdr |
4201 | | 0, // save_as_annexb |
4202 | | 0, // tile_width_count |
4203 | | 0, // tile_height_count |
4204 | | { 0 }, // tile_widths |
4205 | | { 0 }, // tile_heights |
4206 | | 0, // use_fixed_qp_offsets |
4207 | | { -1, -1, -1, -1, -1 }, // fixed_qp_offsets |
4208 | | { 0, 128, 128, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
4209 | | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // cfg |
4210 | | }, |
4211 | | #endif // !CONFIG_REALTIME_ONLY |
4212 | | { |
4213 | | // NOLINT |
4214 | | AOM_USAGE_REALTIME, // g_usage - real-time usage |
4215 | | 0, // g_threads |
4216 | | 0, // g_profile |
4217 | | |
4218 | | 320, // g_w |
4219 | | 240, // g_h |
4220 | | 0, // g_limit |
4221 | | 0, // g_forced_max_frame_width |
4222 | | 0, // g_forced_max_frame_height |
4223 | | AOM_BITS_8, // g_bit_depth |
4224 | | 8, // g_input_bit_depth |
4225 | | |
4226 | | { 1, 30 }, // g_timebase |
4227 | | |
4228 | | 0, // g_error_resilient |
4229 | | |
4230 | | AOM_RC_ONE_PASS, // g_pass |
4231 | | |
4232 | | 0, // g_lag_in_frames |
4233 | | |
4234 | | 0, // rc_dropframe_thresh |
4235 | | RESIZE_NONE, // rc_resize_mode |
4236 | | SCALE_NUMERATOR, // rc_resize_denominator |
4237 | | SCALE_NUMERATOR, // rc_resize_kf_denominator |
4238 | | |
4239 | | AOM_SUPERRES_NONE, // rc_superres_mode |
4240 | | SCALE_NUMERATOR, // rc_superres_denominator |
4241 | | SCALE_NUMERATOR, // rc_superres_kf_denominator |
4242 | | 63, // rc_superres_qthresh |
4243 | | 32, // rc_superres_kf_qthresh |
4244 | | |
4245 | | AOM_CBR, // rc_end_usage |
4246 | | { NULL, 0 }, // rc_twopass_stats_in |
4247 | | { NULL, 0 }, // rc_firstpass_mb_stats_in |
4248 | | 256, // rc_target_bitrate |
4249 | | 0, // rc_min_quantizer |
4250 | | 63, // rc_max_quantizer |
4251 | | 25, // rc_undershoot_pct |
4252 | | 25, // rc_overshoot_pct |
4253 | | |
4254 | | 6000, // rc_max_buffer_size |
4255 | | 4000, // rc_buffer_initial_size |
4256 | | 5000, // rc_buffer_optimal_size |
4257 | | |
4258 | | 50, // rc_two_pass_vbrbias |
4259 | | 0, // rc_two_pass_vbrmin_section |
4260 | | 2000, // rc_two_pass_vbrmax_section |
4261 | | |
4262 | | // keyframing settings (kf) |
4263 | | 0, // fwd_kf_enabled |
4264 | | AOM_KF_AUTO, // kf_mode |
4265 | | 0, // kf_min_dist |
4266 | | 9999, // kf_max_dist |
4267 | | 0, // sframe_dist |
4268 | | 1, // sframe_mode |
4269 | | 0, // large_scale_tile |
4270 | | 0, // monochrome |
4271 | | 0, // full_still_picture_hdr |
4272 | | 0, // save_as_annexb |
4273 | | 0, // tile_width_count |
4274 | | 0, // tile_height_count |
4275 | | { 0 }, // tile_widths |
4276 | | { 0 }, // tile_heights |
4277 | | 0, // use_fixed_qp_offsets |
4278 | | { -1, -1, -1, -1, -1 }, // fixed_qp_offsets |
4279 | | { 0, 128, 128, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
4280 | | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // cfg |
4281 | | }, |
4282 | | #if !CONFIG_REALTIME_ONLY |
4283 | | { |
4284 | | // NOLINT |
4285 | | AOM_USAGE_ALL_INTRA, // g_usage - all intra usage |
4286 | | 0, // g_threads |
4287 | | 0, // g_profile |
4288 | | |
4289 | | 320, // g_w |
4290 | | 240, // g_h |
4291 | | 0, // g_limit |
4292 | | 0, // g_forced_max_frame_width |
4293 | | 0, // g_forced_max_frame_height |
4294 | | AOM_BITS_8, // g_bit_depth |
4295 | | 8, // g_input_bit_depth |
4296 | | |
4297 | | { 1, 30 }, // g_timebase |
4298 | | |
4299 | | 0, // g_error_resilient |
4300 | | |
4301 | | AOM_RC_ONE_PASS, // g_pass |
4302 | | |
4303 | | 0, // g_lag_in_frames |
4304 | | |
4305 | | 0, // rc_dropframe_thresh |
4306 | | RESIZE_NONE, // rc_resize_mode |
4307 | | SCALE_NUMERATOR, // rc_resize_denominator |
4308 | | SCALE_NUMERATOR, // rc_resize_kf_denominator |
4309 | | |
4310 | | AOM_SUPERRES_NONE, // rc_superres_mode |
4311 | | SCALE_NUMERATOR, // rc_superres_denominator |
4312 | | SCALE_NUMERATOR, // rc_superres_kf_denominator |
4313 | | 63, // rc_superres_qthresh |
4314 | | 32, // rc_superres_kf_qthresh |
4315 | | |
4316 | | AOM_Q, // rc_end_usage |
4317 | | { NULL, 0 }, // rc_twopass_stats_in |
4318 | | { NULL, 0 }, // rc_firstpass_mb_stats_in |
4319 | | 256, // rc_target_bitrate |
4320 | | 0, // rc_min_quantizer |
4321 | | 63, // rc_max_quantizer |
4322 | | 25, // rc_undershoot_pct |
4323 | | 25, // rc_overshoot_pct |
4324 | | |
4325 | | 6000, // rc_max_buffer_size |
4326 | | 4000, // rc_buffer_initial_size |
4327 | | 5000, // rc_buffer_optimal_size |
4328 | | |
4329 | | 50, // rc_two_pass_vbrbias |
4330 | | 0, // rc_two_pass_vbrmin_section |
4331 | | 2000, // rc_two_pass_vbrmax_section |
4332 | | |
4333 | | // keyframing settings (kf) |
4334 | | 0, // fwd_kf_enabled |
4335 | | AOM_KF_DISABLED, // kf_mode |
4336 | | 0, // kf_min_dist |
4337 | | 0, // kf_max_dist |
4338 | | 0, // sframe_dist |
4339 | | 1, // sframe_mode |
4340 | | 0, // large_scale_tile |
4341 | | 0, // monochrome |
4342 | | 0, // full_still_picture_hdr |
4343 | | 0, // save_as_annexb |
4344 | | 0, // tile_width_count |
4345 | | 0, // tile_height_count |
4346 | | { 0 }, // tile_widths |
4347 | | { 0 }, // tile_heights |
4348 | | 0, // use_fixed_qp_offsets |
4349 | | { -1, -1, -1, -1, -1 }, // fixed_qp_offsets |
4350 | | { 0, 128, 128, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
4351 | | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // cfg |
4352 | | }, |
4353 | | #endif // !CONFIG_REALTIME_ONLY |
4354 | | }; |
4355 | | |
4356 | | // This data structure and function are exported in aom/aomcx.h |
4357 | | #ifndef VERSION_STRING |
4358 | | #define VERSION_STRING |
4359 | | #endif |
4360 | | aom_codec_iface_t aom_codec_av1_cx_algo = { |
4361 | | "AOMedia Project AV1 Encoder" VERSION_STRING, |
4362 | | AOM_CODEC_INTERNAL_ABI_VERSION, |
4363 | | AOM_CODEC_CAP_HIGHBITDEPTH | AOM_CODEC_CAP_ENCODER | |
4364 | | AOM_CODEC_CAP_PSNR, // aom_codec_caps_t |
4365 | | encoder_init, // aom_codec_init_fn_t |
4366 | | encoder_destroy, // aom_codec_destroy_fn_t |
4367 | | encoder_ctrl_maps, // aom_codec_ctrl_fn_map_t |
4368 | | { |
4369 | | // NOLINT |
4370 | | NULL, // aom_codec_peek_si_fn_t |
4371 | | NULL, // aom_codec_get_si_fn_t |
4372 | | NULL, // aom_codec_decode_fn_t |
4373 | | NULL, // aom_codec_get_frame_fn_t |
4374 | | NULL // aom_codec_set_fb_fn_t |
4375 | | }, |
4376 | | { |
4377 | | // NOLINT |
4378 | | NELEMENTS(encoder_usage_cfg), // cfg_count |
4379 | | encoder_usage_cfg, // aom_codec_enc_cfg_t |
4380 | | encoder_encode, // aom_codec_encode_fn_t |
4381 | | encoder_get_cxdata, // aom_codec_get_cx_data_fn_t |
4382 | | encoder_set_config, // aom_codec_enc_config_set_fn_t |
4383 | | encoder_get_global_headers, // aom_codec_get_global_headers_fn_t |
4384 | | encoder_get_preview // aom_codec_get_preview_frame_fn_t |
4385 | | }, |
4386 | | encoder_set_option // aom_codec_set_option_fn_t |
4387 | | }; |
4388 | | |
4389 | 1.26k | aom_codec_iface_t *aom_codec_av1_cx(void) { return &aom_codec_av1_cx_algo; } |