blob: 72925258de331a423664dfcf27dbae40b9fb5175 [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
Urvang Joshi8a02d762016-07-28 15:51:12 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Yaowu Xuc27fc142016-08-22 16:08:15 -07003 *
Urvang Joshi8a02d762016-07-28 15:51:12 -07004 * 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.
Yaowu Xuc27fc142016-08-22 16:08:15 -070010 */
11
James Zerne1cbb132018-08-22 14:10:36 -070012#ifndef AOM_AV1_ENCODER_ENCODER_H_
13#define AOM_AV1_ENCODER_ENCODER_H_
Yaowu Xuc27fc142016-08-22 16:08:15 -070014
15#include <stdio.h>
16
Tom Finegan60e653d2018-05-22 11:34:58 -070017#include "config/aom_config.h"
18
Yaowu Xuf883b422016-08-30 14:01:10 -070019#include "aom/aomcx.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070020
21#include "av1/common/alloccommon.h"
22#include "av1/common/entropymode.h"
23#include "av1/common/thread_common.h"
24#include "av1/common/onyxc_int.h"
Fergus Simpsond2bcbb52017-05-22 23:15:05 -070025#include "av1/common/resize.h"
Andrey Norkin795ba872018-03-06 13:24:14 -080026#include "av1/common/timing.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070027#include "av1/encoder/aq_cyclicrefresh.h"
Tom Finegan17ce8b12017-02-08 12:46:31 -080028#include "av1/encoder/av1_quantize.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070029#include "av1/encoder/context_tree.h"
30#include "av1/encoder/encodemb.h"
31#include "av1/encoder/firstpass.h"
32#include "av1/encoder/lookahead.h"
33#include "av1/encoder/mbgraph.h"
34#include "av1/encoder/mcomp.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070035#include "av1/encoder/ratectrl.h"
36#include "av1/encoder/rd.h"
37#include "av1/encoder/speed_features.h"
38#include "av1/encoder/tokenize.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070039
40#if CONFIG_INTERNAL_STATS
41#include "aom_dsp/ssim.h"
42#endif
43#include "aom_dsp/variance.h"
Neil Birkbecka2893ab2018-06-08 14:45:13 -070044#if CONFIG_DENOISE
45#include "aom_dsp/noise_model.h"
46#endif
Yaowu Xuf883b422016-08-30 14:01:10 -070047#include "aom/internal/aom_codec_internal.h"
48#include "aom_util/aom_thread.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070049
50#ifdef __cplusplus
51extern "C" {
52#endif
53
54typedef struct {
Jingning Hanf050fc12018-03-09 14:53:33 -080055 int nmv_vec_cost[MV_JOINTS];
56 int nmv_costs[2][MV_VALS];
57 int nmv_costs_hp[2][MV_VALS];
James Zern01a9d702017-08-25 19:09:33 +000058
Yaowu Xuc27fc142016-08-22 16:08:15 -070059 FRAME_CONTEXT fc;
60} CODING_CONTEXT;
61
Satish Kumar Suman4667aa12018-12-14 18:28:19 +053062enum {
Yaowu Xuc27fc142016-08-22 16:08:15 -070063 // regular inter frame
64 REGULAR_FRAME = 0,
65 // alternate reference frame
66 ARF_FRAME = 1,
67 // overlay frame
68 OVERLAY_FRAME = 2,
69 // golden frame
70 GLD_FRAME = 3,
Yaowu Xuc27fc142016-08-22 16:08:15 -070071 // backward reference frame
72 BRF_FRAME = 4,
73 // extra alternate reference frame
Thomas Daede51020e12017-12-14 20:12:44 -080074 EXT_ARF_FRAME = 5,
75 FRAME_CONTEXT_INDEXES
Satish Kumar Suman4667aa12018-12-14 18:28:19 +053076} UENUM1BYTE(FRAME_CONTEXT_INDEX);
Yaowu Xuc27fc142016-08-22 16:08:15 -070077
Satish Kumar Suman4667aa12018-12-14 18:28:19 +053078enum {
Yaowu Xuc27fc142016-08-22 16:08:15 -070079 NORMAL = 0,
80 FOURFIVE = 1,
81 THREEFIVE = 2,
82 ONETWO = 3
Satish Kumar Suman4667aa12018-12-14 18:28:19 +053083} UENUM1BYTE(AOM_SCALING);
Yaowu Xuc27fc142016-08-22 16:08:15 -070084
Satish Kumar Suman4667aa12018-12-14 18:28:19 +053085enum {
Yaowu Xuc27fc142016-08-22 16:08:15 -070086 // Good Quality Fast Encoding. The encoder balances quality with the amount of
87 // time it takes to encode the output. Speed setting controls how fast.
Thomas Daede80826142017-03-20 15:44:24 -070088 GOOD
Satish Kumar Suman4667aa12018-12-14 18:28:19 +053089} UENUM1BYTE(MODE);
Yaowu Xuc27fc142016-08-22 16:08:15 -070090
Satish Kumar Suman4667aa12018-12-14 18:28:19 +053091enum {
Yaowu Xuc27fc142016-08-22 16:08:15 -070092 FRAMEFLAGS_KEY = 1 << 0,
93 FRAMEFLAGS_GOLDEN = 1 << 1,
Yaowu Xuc27fc142016-08-22 16:08:15 -070094 FRAMEFLAGS_BWDREF = 1 << 2,
Zoe Liu3ac20932017-08-30 16:35:55 -070095 // TODO(zoeliu): To determine whether a frame flag is needed for ALTREF2_FRAME
Yaowu Xuc27fc142016-08-22 16:08:15 -070096 FRAMEFLAGS_ALTREF = 1 << 3,
Debargha Mukherjee57378252018-09-21 18:29:37 -070097 FRAMEFLAGS_INTRAONLY = 1 << 4,
98 FRAMEFLAGS_SWITCH = 1 << 5,
99 FRAMEFLAGS_ERROR_RESILIENT = 1 << 6,
Satish Kumar Suman4667aa12018-12-14 18:28:19 +0530100} UENUM1BYTE(FRAMETYPE_FLAGS);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700101
Satish Kumar Suman4667aa12018-12-14 18:28:19 +0530102enum {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700103 NO_AQ = 0,
104 VARIANCE_AQ = 1,
105 COMPLEXITY_AQ = 2,
106 CYCLIC_REFRESH_AQ = 3,
107 AQ_MODE_COUNT // This should always be the last member of the enum
Satish Kumar Suman4667aa12018-12-14 18:28:19 +0530108} UENUM1BYTE(AQ_MODE);
109enum {
Fangwen Fu6160df22017-04-24 09:45:51 -0700110 NO_DELTA_Q = 0,
111 DELTA_Q_ONLY = 1,
112 DELTA_Q_LF = 2,
113 DELTAQ_MODE_COUNT // This should always be the last member of the enum
Satish Kumar Suman4667aa12018-12-14 18:28:19 +0530114} UENUM1BYTE(DELTAQ_MODE);
Debargha Mukherjee3a4959f2018-02-26 15:34:03 -0800115
Satish Kumar Suman4667aa12018-12-14 18:28:19 +0530116enum {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700117 RESIZE_NONE = 0, // No frame resizing allowed.
Debargha Mukherjee7166f222017-09-05 21:32:42 -0700118 RESIZE_FIXED = 1, // All frames are coded at the specified scale.
119 RESIZE_RANDOM = 2, // All frames are coded at a random scale.
120 RESIZE_MODES
Satish Kumar Suman4667aa12018-12-14 18:28:19 +0530121} UENUM1BYTE(RESIZE_MODE);
Debargha Mukherjee3a4959f2018-02-26 15:34:03 -0800122
Satish Kumar Suman4667aa12018-12-14 18:28:19 +0530123enum {
Debargha Mukherjee7166f222017-09-05 21:32:42 -0700124 SUPERRES_NONE = 0, // No frame superres allowed
125 SUPERRES_FIXED = 1, // All frames are coded at the specified scale,
126 // and super-resolved.
127 SUPERRES_RANDOM = 2, // All frames are coded at a random scale,
128 // and super-resolved.
129 SUPERRES_QTHRESH = 3, // Superres scale for a frame is determined based on
130 // q_index
131 SUPERRES_MODES
Satish Kumar Suman4667aa12018-12-14 18:28:19 +0530132} UENUM1BYTE(SUPERRES_MODE);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700133
Yue Chen7cae98f2018-08-24 10:43:16 -0700134typedef struct TplDepStats {
135 int64_t intra_cost;
136 int64_t inter_cost;
137 int64_t mc_flow;
138 int64_t mc_dep_cost;
139 int64_t mc_ref_cost;
140
141 int ref_frame_index;
142 int_mv mv;
143} TplDepStats;
144
145typedef struct TplDepFrame {
146 uint8_t is_valid;
147 TplDepStats *tpl_stats_ptr;
148 int stride;
149 int width;
150 int height;
151 int mi_rows;
152 int mi_cols;
153 int base_qindex;
154} TplDepFrame;
155
156#define TPL_DEP_COST_SCALE_LOG2 4
157
Yaowu Xuf883b422016-08-30 14:01:10 -0700158typedef struct AV1EncoderConfig {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700159 BITSTREAM_PROFILE profile;
Tom Finegan8ab2bba2018-02-28 07:36:28 -0800160 aom_bit_depth_t bit_depth; // Codec bit-depth.
161 int width; // width of data passed to the compressor
162 int height; // height of data passed to the compressor
163 int forced_max_frame_width; // forced maximum width of frame (if != 0)
164 int forced_max_frame_height; // forced maximum height of frame (if != 0)
Yaowu Xuc27fc142016-08-22 16:08:15 -0700165 unsigned int input_bit_depth; // Input bit depth.
166 double init_framerate; // set to passed in framerate
167 int64_t target_bandwidth; // bandwidth to be used in bits per second
168
169 int noise_sensitivity; // pre processing blur: recommendation 0
170 int sharpness; // sharpening output: recommendation 0:
171 int speed;
172 // maximum allowed bitrate for any intra frame in % of bitrate target.
173 unsigned int rc_max_intra_bitrate_pct;
174 // maximum allowed bitrate for any inter frame in % of bitrate target.
175 unsigned int rc_max_inter_bitrate_pct;
176 // percent of rate boost for golden frame in CBR mode.
177 unsigned int gf_cbr_boost_pct;
178
179 MODE mode;
180 int pass;
181
182 // Key Framing Operations
183 int auto_key; // autodetect cut scenes and set the keyframes
184 int key_freq; // maximum distance to key frame.
Tarek AMARAc9813852018-03-05 18:40:18 -0500185 int sframe_dist;
186 int sframe_mode;
187 int sframe_enabled;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700188 int lag_in_frames; // how many frames lag before we start encoding
Sarah Parker93c03142018-05-22 13:35:45 -0700189 int fwd_kf_enabled;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700190
191 // ----------------------------------------------------------------
192 // DATARATE CONTROL OPTIONS
193
194 // vbr, cbr, constrained quality or constant quality
Yaowu Xuf883b422016-08-30 14:01:10 -0700195 enum aom_rc_mode rc_mode;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700196
197 // buffer targeting aggressiveness
198 int under_shoot_pct;
199 int over_shoot_pct;
200
201 // buffering parameters
202 int64_t starting_buffer_level_ms;
203 int64_t optimal_buffer_level_ms;
204 int64_t maximum_buffer_size_ms;
205
206 // Frame drop threshold.
207 int drop_frames_water_mark;
208
209 // controlling quality
210 int fixed_q;
211 int worst_allowed_q;
212 int best_allowed_q;
213 int cq_level;
214 AQ_MODE aq_mode; // Adaptive Quantization mode
Fangwen Fu6160df22017-04-24 09:45:51 -0700215 DELTAQ_MODE deltaq_mode;
Debargha Mukherjee98a311c2018-03-25 16:33:11 -0700216 int enable_cdef;
217 int enable_restoration;
Yue Chen5e129512018-12-10 10:48:54 -0800218 int enable_obmc;
Yue Chen4835dc02018-05-11 15:57:43 -0700219 int disable_trellis_quant;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700220 int using_qm;
Yaowu Xuf7a12422018-01-31 15:29:20 -0800221 int qm_y;
222 int qm_u;
223 int qm_v;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700224 int qm_minlevel;
225 int qm_maxlevel;
Yushin Chod808bfc2017-08-10 15:54:36 -0700226#if CONFIG_DIST_8X8
227 int using_dist_8x8;
228#endif
Thomas Daviesaf6df172016-11-09 14:04:18 +0000229 unsigned int num_tile_groups;
230 unsigned int mtu;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700231
232 // Internal frame size scaling.
Debargha Mukherjee29e40a62017-06-14 09:37:12 -0700233 RESIZE_MODE resize_mode;
Urvang Joshide71d142017-10-05 12:12:15 -0700234 uint8_t resize_scale_denominator;
235 uint8_t resize_kf_scale_denominator;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700236
Fergus Simpsonc4e78942017-04-10 14:59:00 -0700237 // Frame Super-Resolution size scaling.
238 SUPERRES_MODE superres_mode;
Urvang Joshide71d142017-10-05 12:12:15 -0700239 uint8_t superres_scale_denominator;
240 uint8_t superres_kf_scale_denominator;
Debargha Mukherjee7166f222017-09-05 21:32:42 -0700241 int superres_qthresh;
242 int superres_kf_qthresh;
Fergus Simpson3502d082017-04-10 12:25:07 -0700243
Yaowu Xuc27fc142016-08-22 16:08:15 -0700244 // Enable feature to reduce the frame quantization every x frames.
245 int frame_periodic_boost;
246
247 // two pass datarate control
248 int two_pass_vbrbias; // two pass datarate control tweaks
249 int two_pass_vbrmin_section;
250 int two_pass_vbrmax_section;
251 // END DATARATE CONTROL OPTIONS
252 // ----------------------------------------------------------------
253
254 int enable_auto_arf;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700255 int enable_auto_brf; // (b)ackward (r)ef (f)rame
Yaowu Xuc27fc142016-08-22 16:08:15 -0700256
Yaowu Xuc27fc142016-08-22 16:08:15 -0700257 /* Bitfield defining the error resiliency features to enable.
258 * Can provide decodable frames after losses in previous
259 * frames and decodable partitions after losses in the same frame.
260 */
261 unsigned int error_resilient_mode;
262
Debargha Mukherjee52fb0472018-03-29 15:48:11 -0700263 unsigned int s_frame_mode;
264
Yaowu Xuc27fc142016-08-22 16:08:15 -0700265 /* Bitfield defining the parallel decoding mode where the
266 * decoding in successive frames may be conducted in parallel
267 * just by decoding the frame headers.
268 */
269 unsigned int frame_parallel_decoding_mode;
270
Debargha Mukherjeec6f24c22018-04-07 08:43:08 -0700271 unsigned int limit;
272
Yaowu Xuc27fc142016-08-22 16:08:15 -0700273 int arnr_max_frames;
274 int arnr_strength;
275
276 int min_gf_interval;
277 int max_gf_interval;
Urvang Joshif4e775c2018-12-14 11:33:17 -0800278 int gf_max_pyr_height;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700279
Ravi Chaudhary0ec03a42018-08-17 18:53:28 +0530280 int row_mt;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700281 int tile_columns;
282 int tile_rows;
Dominic Symes26ad0b22017-10-01 16:35:13 +0200283 int tile_width_count;
284 int tile_height_count;
285 int tile_widths[MAX_TILE_COLS];
286 int tile_heights[MAX_TILE_ROWS];
Yaowu Xuc27fc142016-08-22 16:08:15 -0700287
Yue Chen7cae98f2018-08-24 10:43:16 -0700288 int enable_tpl_model;
289
Yaowu Xuc27fc142016-08-22 16:08:15 -0700290 int max_threads;
291
Yaowu Xuf883b422016-08-30 14:01:10 -0700292 aom_fixed_buf_t two_pass_stats_in;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700293
294#if CONFIG_FP_MB_STATS
Yaowu Xuf883b422016-08-30 14:01:10 -0700295 aom_fixed_buf_t firstpass_mb_stats_in;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700296#endif
297
Yaowu Xuf883b422016-08-30 14:01:10 -0700298 aom_tune_metric tuning;
299 aom_tune_content content;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700300 int use_highbitdepth;
Andrey Norkin9e694632017-12-21 18:50:57 -0800301 aom_color_primaries_t color_primaries;
302 aom_transfer_characteristics_t transfer_characteristics;
303 aom_matrix_coefficients_t matrix_coefficients;
anorkin76fb1262017-03-22 15:12:12 -0700304 aom_chroma_sample_position_t chroma_sample_position;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700305 int color_range;
306 int render_width;
307 int render_height;
Andrey Norkin28e9ce22018-01-08 10:11:21 -0800308 int timing_info_present;
Andrey Norkin795ba872018-03-06 13:24:14 -0800309 aom_timing_info_t timing_info;
310 int decoder_model_info_present_flag;
Andrey Norkin26495512018-06-20 17:13:11 -0700311 int display_model_info_present_flag;
Wan-Teh Changf64b3bc2018-07-02 09:42:39 -0700312 int buffer_removal_time_present;
Andrey Norkin795ba872018-03-06 13:24:14 -0800313 aom_dec_model_info_t buffer_model;
Andrey Norkin6f1c2f72018-01-15 20:08:52 -0800314 int film_grain_test_vector;
Neil Birkbeckeb895ef2018-03-14 17:51:03 -0700315 const char *film_grain_table_filename;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700316
Hui Su1cb1c002018-02-05 18:21:20 -0800317 uint8_t cdf_update_mode;
Yaowu Xuf883b422016-08-30 14:01:10 -0700318 aom_superblock_size_t superblock_size;
Yunqing Wangeeb08a92017-07-07 21:25:18 -0700319 unsigned int large_scale_tile;
320 unsigned int single_tile_decoding;
Yaowu Xu76537ca2019-01-03 12:41:32 -0800321 uint8_t monochrome;
Debargha Mukherjee9713ccb2018-04-08 19:09:17 -0700322 unsigned int full_still_picture_hdr;
Jingning Hana446f552018-02-22 15:42:12 -0800323 int enable_dual_filter;
Yunqing Wangff4fa062017-04-21 10:56:08 -0700324 unsigned int motion_vector_unit_test;
Maxym Dmytrychenkocc6e0e12018-02-05 16:35:37 +0100325 const cfg_options_t *cfg;
Debargha Mukherjee9d9cf192018-12-17 11:24:21 -0800326 int enable_rect_partitions;
Debargha Mukherjee03c43ba2018-12-14 13:08:08 -0800327 int enable_intra_edge_filter;
Debargha Mukherjee8c917b02018-12-17 13:45:50 -0800328 int enable_tx64;
Debargha Mukherjee0d8368a2018-03-25 12:23:02 -0700329 int enable_order_hint;
Debargha Mukherjee7ac3eb12018-12-12 10:26:50 -0800330 int enable_dist_wtd_comp;
Debargha Mukherjee0187d7c2018-03-25 11:37:56 -0700331 int enable_ref_frame_mvs;
Debargha Mukherjee0d8368a2018-03-25 12:23:02 -0700332 unsigned int allow_ref_frame_mvs;
Debargha Mukherjee16ea6ba2018-12-10 12:01:38 -0800333 int enable_masked_comp;
334 int enable_interintra_comp;
Yue Chen8cbee6c2018-12-14 11:54:39 -0800335 int enable_smooth_interintra;
Debargha Mukherjee78e6b2c2018-12-11 07:50:57 -0800336 int enable_diff_wtd_comp;
337 int enable_interinter_wedge;
338 int enable_interintra_wedge;
Debargha Mukherjeed2e53ca2018-12-10 11:34:59 -0800339 int enable_global_motion;
Debargha Mukherjee37df9162018-03-25 12:48:24 -0700340 int enable_warped_motion;
341 int allow_warped_motion;
Yue Chen8f9ca582018-12-12 15:11:47 -0800342 int enable_filter_intra;
Debargha Mukherjee078ae862018-12-18 11:05:43 -0800343 int enable_smooth_intra;
344 int enable_paeth_intra;
Debargha Mukherjee8e256782018-12-18 13:44:13 -0800345 int enable_cfl_intra;
Urvang Joshi2c92b072018-03-19 17:23:31 -0700346 int enable_superres;
Hui Sua9e3d142018-12-14 15:21:21 -0800347 int enable_palette;
Hui Su440e6d42018-12-17 11:47:07 -0800348 int enable_intrabc;
Hui Su94b38172018-12-19 10:40:29 -0800349 int enable_angle_delta;
Soo-Chul Han29c46fb2018-03-23 16:02:00 -0400350 unsigned int save_as_annexb;
Neil Birkbecka2893ab2018-06-08 14:45:13 -0700351
352#if CONFIG_DENOISE
353 float noise_level;
354 int noise_block_size;
355#endif
Tom Finegan02b2a842018-08-24 13:50:00 -0700356
357 unsigned int chroma_subsampling_x;
358 unsigned int chroma_subsampling_y;
Sarah Parker0b7e5902018-12-10 13:35:25 -0800359 int reduced_tx_type_set;
Sarah Parker740e8392019-01-23 15:47:53 -0800360 int quant_b_adapt;
Satish Kumar Suman29909962019-01-09 10:31:21 +0530361 int border_in_pixels;
Yaowu Xuf883b422016-08-30 14:01:10 -0700362} AV1EncoderConfig;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700363
Yaowu Xuf883b422016-08-30 14:01:10 -0700364static INLINE int is_lossless_requested(const AV1EncoderConfig *cfg) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700365 return cfg->best_allowed_q == 0 && cfg->worst_allowed_q == 0;
366}
367
Yue Chencc6a6ef2018-05-21 16:21:05 -0700368typedef struct FRAME_COUNTS {
369// Note: This structure should only contain 'unsigned int' fields, or
370// aggregates built solely from 'unsigned int' fields/elements
371#if CONFIG_ENTROPY_STATS
372 unsigned int kf_y_mode[KF_MODE_CONTEXTS][KF_MODE_CONTEXTS][INTRA_MODES];
373 unsigned int angle_delta[DIRECTIONAL_MODES][2 * MAX_ANGLE_DELTA + 1];
374 unsigned int y_mode[BLOCK_SIZE_GROUPS][INTRA_MODES];
375 unsigned int uv_mode[CFL_ALLOWED_TYPES][INTRA_MODES][UV_INTRA_MODES];
376 unsigned int cfl_sign[CFL_JOINT_SIGNS];
377 unsigned int cfl_alpha[CFL_ALPHA_CONTEXTS][CFL_ALPHABET_SIZE];
378 unsigned int palette_y_mode[PALATTE_BSIZE_CTXS][PALETTE_Y_MODE_CONTEXTS][2];
379 unsigned int palette_uv_mode[PALETTE_UV_MODE_CONTEXTS][2];
380 unsigned int palette_y_size[PALATTE_BSIZE_CTXS][PALETTE_SIZES];
381 unsigned int palette_uv_size[PALATTE_BSIZE_CTXS][PALETTE_SIZES];
382 unsigned int palette_y_color_index[PALETTE_SIZES]
383 [PALETTE_COLOR_INDEX_CONTEXTS]
384 [PALETTE_COLORS];
385 unsigned int palette_uv_color_index[PALETTE_SIZES]
386 [PALETTE_COLOR_INDEX_CONTEXTS]
387 [PALETTE_COLORS];
388 unsigned int partition[PARTITION_CONTEXTS][EXT_PARTITION_TYPES];
389 unsigned int txb_skip[TOKEN_CDF_Q_CTXS][TX_SIZES][TXB_SKIP_CONTEXTS][2];
390 unsigned int eob_extra[TOKEN_CDF_Q_CTXS][TX_SIZES][PLANE_TYPES]
391 [EOB_COEF_CONTEXTS][2];
392 unsigned int dc_sign[PLANE_TYPES][DC_SIGN_CONTEXTS][2];
393 unsigned int coeff_lps[TX_SIZES][PLANE_TYPES][BR_CDF_SIZE - 1][LEVEL_CONTEXTS]
394 [2];
395 unsigned int eob_flag[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS][2];
396 unsigned int eob_multi16[TOKEN_CDF_Q_CTXS][PLANE_TYPES][2][5];
397 unsigned int eob_multi32[TOKEN_CDF_Q_CTXS][PLANE_TYPES][2][6];
398 unsigned int eob_multi64[TOKEN_CDF_Q_CTXS][PLANE_TYPES][2][7];
399 unsigned int eob_multi128[TOKEN_CDF_Q_CTXS][PLANE_TYPES][2][8];
400 unsigned int eob_multi256[TOKEN_CDF_Q_CTXS][PLANE_TYPES][2][9];
401 unsigned int eob_multi512[TOKEN_CDF_Q_CTXS][PLANE_TYPES][2][10];
402 unsigned int eob_multi1024[TOKEN_CDF_Q_CTXS][PLANE_TYPES][2][11];
403 unsigned int coeff_lps_multi[TOKEN_CDF_Q_CTXS][TX_SIZES][PLANE_TYPES]
404 [LEVEL_CONTEXTS][BR_CDF_SIZE];
405 unsigned int coeff_base_multi[TOKEN_CDF_Q_CTXS][TX_SIZES][PLANE_TYPES]
406 [SIG_COEF_CONTEXTS][NUM_BASE_LEVELS + 2];
407 unsigned int coeff_base_eob_multi[TOKEN_CDF_Q_CTXS][TX_SIZES][PLANE_TYPES]
408 [SIG_COEF_CONTEXTS_EOB][NUM_BASE_LEVELS + 1];
409 unsigned int newmv_mode[NEWMV_MODE_CONTEXTS][2];
410 unsigned int zeromv_mode[GLOBALMV_MODE_CONTEXTS][2];
411 unsigned int refmv_mode[REFMV_MODE_CONTEXTS][2];
412 unsigned int drl_mode[DRL_MODE_CONTEXTS][2];
413 unsigned int inter_compound_mode[INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES];
414 unsigned int wedge_idx[BLOCK_SIZES_ALL][16];
415 unsigned int interintra[BLOCK_SIZE_GROUPS][2];
416 unsigned int interintra_mode[BLOCK_SIZE_GROUPS][INTERINTRA_MODES];
417 unsigned int wedge_interintra[BLOCK_SIZES_ALL][2];
418 unsigned int compound_type[BLOCK_SIZES_ALL][COMPOUND_TYPES - 1];
419 unsigned int motion_mode[BLOCK_SIZES_ALL][MOTION_MODES];
420 unsigned int obmc[BLOCK_SIZES_ALL][2];
421 unsigned int intra_inter[INTRA_INTER_CONTEXTS][2];
422 unsigned int comp_inter[COMP_INTER_CONTEXTS][2];
423 unsigned int comp_ref_type[COMP_REF_TYPE_CONTEXTS][2];
424 unsigned int uni_comp_ref[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1][2];
425 unsigned int single_ref[REF_CONTEXTS][SINGLE_REFS - 1][2];
426 unsigned int comp_ref[REF_CONTEXTS][FWD_REFS - 1][2];
427 unsigned int comp_bwdref[REF_CONTEXTS][BWD_REFS - 1][2];
428 unsigned int intrabc[2];
429
430 unsigned int txfm_partition[TXFM_PARTITION_CONTEXTS][2];
431 unsigned int intra_tx_size[MAX_TX_CATS][TX_SIZE_CONTEXTS][MAX_TX_DEPTH + 1];
432 unsigned int skip_mode[SKIP_MODE_CONTEXTS][2];
433 unsigned int skip[SKIP_CONTEXTS][2];
434 unsigned int compound_index[COMP_INDEX_CONTEXTS][2];
435 unsigned int comp_group_idx[COMP_GROUP_IDX_CONTEXTS][2];
436 unsigned int delta_q[DELTA_Q_PROBS][2];
437 unsigned int delta_lf_multi[FRAME_LF_COUNT][DELTA_LF_PROBS][2];
438 unsigned int delta_lf[DELTA_LF_PROBS][2];
439
440 unsigned int inter_ext_tx[EXT_TX_SETS_INTER][EXT_TX_SIZES][TX_TYPES];
441 unsigned int intra_ext_tx[EXT_TX_SETS_INTRA][EXT_TX_SIZES][INTRA_MODES]
442 [TX_TYPES];
443 unsigned int filter_intra_mode[FILTER_INTRA_MODES];
444 unsigned int filter_intra[BLOCK_SIZES_ALL][2];
445 unsigned int switchable_restore[RESTORE_SWITCHABLE_TYPES];
446 unsigned int wiener_restore[2];
447 unsigned int sgrproj_restore[2];
448#endif // CONFIG_ENTROPY_STATS
449
450 unsigned int switchable_interp[SWITCHABLE_FILTER_CONTEXTS]
451 [SWITCHABLE_FILTERS];
452} FRAME_COUNTS;
453
Angie Chiang71572162018-08-06 16:20:36 -0700454#if CONFIG_COLLECT_INTER_MODE_RD_STATS
455#define INTER_MODE_RD_DATA_OVERALL_SIZE 6400
456
457typedef struct {
458 int ready;
459 double a;
460 double b;
461 double dist_mean;
Angie Chiang199f3d42018-08-14 18:07:02 -0700462 double ld_mean;
463 double sse_mean;
464 double sse_sse_mean;
465 double sse_ld_mean;
Angie Chiang106fa482018-08-07 18:28:40 -0700466 int num;
467 double dist_sum;
468 double ld_sum;
469 double sse_sum;
470 double sse_sse_sum;
471 double sse_ld_sum;
Angie Chiang71572162018-08-06 16:20:36 -0700472} InterModeRdModel;
473
474typedef struct {
475 int idx;
476 int64_t rd;
477} RdIdxPair;
478// TODO(angiebird): This is an estimated size. We still need to figure what is
479// the maximum number of modes.
480#define MAX_INTER_MODES 1024
481typedef struct inter_modes_info {
482 int num;
483 MB_MODE_INFO mbmi_arr[MAX_INTER_MODES];
484 int mode_rate_arr[MAX_INTER_MODES];
485 int64_t sse_arr[MAX_INTER_MODES];
486 int64_t est_rd_arr[MAX_INTER_MODES];
487 RdIdxPair rd_idx_pair_arr[MAX_INTER_MODES];
488} InterModesInfo;
489#endif
490
Ravi Chaudhary40cdf132018-10-08 11:04:16 +0530491// Encoder row synchronization
492typedef struct AV1RowMTSyncData {
493#if CONFIG_MULTITHREAD
494 pthread_mutex_t *mutex_;
495 pthread_cond_t *cond_;
496#endif
497 // Allocate memory to store the sb/mb block index in each row.
498 int *cur_col;
499 int sync_range;
500 int rows;
501} AV1RowMTSync;
502
Ravi Chaudhary90a15f42018-10-11 18:56:35 +0530503typedef struct AV1RowMTInfo {
504 int current_mi_row;
505 int num_threads_working;
506} AV1RowMTInfo;
507
Yaowu Xuc27fc142016-08-22 16:08:15 -0700508// TODO(jingning) All spatially adaptive variables should go to TileDataEnc.
509typedef struct TileDataEnc {
510 TileInfo tile_info;
Rupert Swarbrick93c39e92017-07-12 11:11:02 +0100511 int thresh_freq_fact[BLOCK_SIZES_ALL][MAX_MODES];
Yunqing Wang8c1e57c2016-10-25 15:15:23 -0700512 int m_search_count;
513 int ex_search_count;
Luc Trudeauf8164152017-04-11 16:20:51 -0400514 CFL_CTX cfl;
Jingning Han9f07be12017-04-13 09:31:40 -0700515 DECLARE_ALIGNED(16, FRAME_CONTEXT, tctx);
Ravi Chaudharye5215172018-12-21 18:47:25 +0530516 FRAME_CONTEXT *row_ctx;
Yunqing Wang0e141b52017-11-02 15:08:58 -0700517 uint8_t allow_update_cdf;
Angie Chiang71572162018-08-06 16:20:36 -0700518#if CONFIG_COLLECT_INTER_MODE_RD_STATS
519 InterModeRdModel inter_mode_rd_models[BLOCK_SIZES_ALL];
Angie Chiang71572162018-08-06 16:20:36 -0700520#endif
Ravi Chaudhary40cdf132018-10-08 11:04:16 +0530521 AV1RowMTSync row_mt_sync;
Ravi Chaudhary90a15f42018-10-11 18:56:35 +0530522 AV1RowMTInfo row_mt_info;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700523} TileDataEnc;
524
Ravi Chaudhary73cf15b2018-08-30 10:52:51 +0530525typedef struct {
526 TOKENEXTRA *start;
527 TOKENEXTRA *stop;
528 unsigned int count;
529} TOKENLIST;
530
Ravi Chaudharyc5e74692018-10-08 16:05:38 +0530531typedef struct MultiThreadHandle {
532 int allocated_tile_rows;
533 int allocated_tile_cols;
534 int allocated_sb_rows;
Ravi Chaudhary90a15f42018-10-11 18:56:35 +0530535 int thread_id_to_tile_id[MAX_NUM_THREADS]; // Mapping of threads to tiles
Ravi Chaudharyc5e74692018-10-08 16:05:38 +0530536} MultiThreadHandle;
537
Yaowu Xuc27fc142016-08-22 16:08:15 -0700538typedef struct RD_COUNTS {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700539 int64_t comp_pred_diff[REFERENCE_MODES];
Debargha Mukherjeea575d232017-04-28 17:46:47 -0700540 // Stores number of 4x4 blocks using global motion per reference frame.
Zoe Liu27deb382018-03-27 15:13:56 -0700541 int global_motion_used[REF_FRAMES];
Arild Fuldseth (arilfuld)6c20c782017-06-15 09:45:02 +0200542 int compound_ref_used_flag;
Zoe Liu8a5d3432017-11-30 16:33:44 -0800543 int skip_mode_used_flag;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700544} RD_COUNTS;
545
546typedef struct ThreadData {
547 MACROBLOCK mb;
548 RD_COUNTS rd_counts;
549 FRAME_COUNTS *counts;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700550 PC_TREE *pc_tree;
551 PC_TREE *pc_root[MAX_MIB_SIZE_LOG2 - MIN_MIB_SIZE_LOG2 + 1];
wenyao.liu0c6f5fd2018-10-23 18:41:16 +0800552 tran_low_t *tree_coeff_buf[MAX_MB_PLANE];
553 tran_low_t *tree_qcoeff_buf[MAX_MB_PLANE];
554 tran_low_t *tree_dqcoeff_buf[MAX_MB_PLANE];
Ravi Chaudhary5d970f42018-09-25 11:25:32 +0530555#if CONFIG_COLLECT_INTER_MODE_RD_STATS
556 InterModesInfo *inter_modes_info;
557#endif
Ravi Chaudhary783d6a32018-08-28 18:21:02 +0530558 uint32_t *hash_value_buffer[2][2];
Jingning Hand064cf02017-06-01 10:00:39 -0700559 int32_t *wsrc_buf;
560 int32_t *mask_buf;
561 uint8_t *above_pred_buf;
562 uint8_t *left_pred_buf;
hui su5d493142017-05-08 12:06:12 -0700563 PALETTE_BUFFER *palette_buffer;
Urvang Joshi0a4cfad2018-09-07 11:10:39 -0700564 CONV_BUF_TYPE *tmp_conv_dst;
565 uint8_t *tmp_obmc_bufs[2];
Ravi Chaudhary00525ef2018-10-31 19:52:42 +0530566 int intrabc_used;
Ravi Chaudhary84a280a2018-09-24 16:09:48 +0530567 FRAME_CONTEXT *tctx;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700568} ThreadData;
569
570struct EncWorkerData;
571
572typedef struct ActiveMap {
573 int enabled;
574 int update;
575 unsigned char *map;
576} ActiveMap;
577
Wan-Teh Changc25c92a2018-04-23 15:04:14 -0700578#if CONFIG_INTERNAL_STATS
579// types of stats
Satish Kumar Suman4667aa12018-12-14 18:28:19 +0530580enum {
Wan-Teh Changc25c92a2018-04-23 15:04:14 -0700581 STAT_Y,
582 STAT_U,
583 STAT_V,
584 STAT_ALL,
585 NUM_STAT_TYPES // This should always be the last member of the enum
Satish Kumar Suman4667aa12018-12-14 18:28:19 +0530586} UENUM1BYTE(StatType);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700587
588typedef struct IMAGE_STAT {
Urvang Joshib5ed3502016-10-17 16:38:05 -0700589 double stat[NUM_STAT_TYPES];
Yaowu Xuc27fc142016-08-22 16:08:15 -0700590 double worst;
591} ImageStat;
Wan-Teh Changc25c92a2018-04-23 15:04:14 -0700592#endif // CONFIG_INTERNAL_STATS
Urvang Joshib5ed3502016-10-17 16:38:05 -0700593
Yaowu Xuc27fc142016-08-22 16:08:15 -0700594typedef struct {
595 int ref_count;
596 YV12_BUFFER_CONFIG buf;
597} EncRefCntBuffer;
598
Yaowu Xuf883b422016-08-30 14:01:10 -0700599typedef struct AV1_COMP {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700600 QUANTS quants;
601 ThreadData td;
Yue Chencc6a6ef2018-05-21 16:21:05 -0700602 FRAME_COUNTS counts;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700603 MB_MODE_INFO_EXT *mbmi_ext_base;
Jingning Hanf5a4d3b2017-08-27 23:01:19 -0700604 CB_COEFF_BUFFER *coeff_buffer_base;
Yi Luoc6210232017-05-25 15:09:25 -0700605 Dequants dequants;
Yaowu Xuf883b422016-08-30 14:01:10 -0700606 AV1_COMMON common;
607 AV1EncoderConfig oxcf;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700608 struct lookahead_ctx *lookahead;
609 struct lookahead_entry *alt_ref_source;
Sarah Parkeraf32a7b2018-06-29 14:59:05 -0700610 int no_show_kf;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700611
Angie Chiange69a6822018-03-16 13:52:44 -0700612 int optimize_speed_feature;
613 int optimize_seg_arr[MAX_SEGMENTS];
614
Alex Conversef77fd0b2017-04-20 11:00:24 -0700615 YV12_BUFFER_CONFIG *source;
616 YV12_BUFFER_CONFIG *last_source; // NULL for first frame and alt_ref frames
Fergus Simpsond2bcbb52017-05-22 23:15:05 -0700617 YV12_BUFFER_CONFIG *unscaled_source;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700618 YV12_BUFFER_CONFIG scaled_source;
619 YV12_BUFFER_CONFIG *unscaled_last_source;
620 YV12_BUFFER_CONFIG scaled_last_source;
621
Yue Chen7cae98f2018-08-24 10:43:16 -0700622 TplDepFrame tpl_stats[MAX_LAG_BUFFERS];
623 YV12_BUFFER_CONFIG *tpl_recon_frames[INTER_REFS_PER_FRAME + 1];
624
Yaowu Xuc27fc142016-08-22 16:08:15 -0700625 // For a still frame, this flag is set to 1 to skip partition search.
626 int partition_search_skippable_frame;
RogerZhou3b635242017-09-19 10:06:46 -0700627 double csm_rate_array[32];
628 double m_rate_array[32];
629 int rate_size;
630 int rate_index;
Debargha Mukherjeee41a6672018-02-27 11:56:31 -0800631 hash_table *previous_hash_table;
632 int previous_index;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700633
Ravi Chaudhary0ec03a42018-08-17 18:53:28 +0530634 unsigned int row_mt;
David Turnere7ebf902018-12-04 14:04:55 +0000635 RefCntBuffer *scaled_ref_buf[INTER_REFS_PER_FRAME];
Urvang Joshi4d9f15f2018-11-05 15:26:22 -0800636
David Turnere7ebf902018-12-04 14:04:55 +0000637 RefCntBuffer *last_show_frame_buf; // last show frame buffer
Yaowu Xuc27fc142016-08-22 16:08:15 -0700638
Urvang Joshi06b37652018-11-06 11:17:56 -0800639 // refresh_*_frame are boolean flags. If 'refresh_xyz_frame' is true, then
640 // after the current frame is encoded, the XYZ reference frame gets refreshed
641 // (updated) to be the current frame.
642 //
643 // Special case: 'refresh_last_frame' specifies that:
644 // - LAST_FRAME reference should be updated to be the current frame (as usual)
645 // - Also, LAST2_FRAME and LAST3_FRAME references are implicitly updated to be
646 // the two past reference frames just before LAST_FRAME that are available.
647 //
648 // Note: Usually at most one of these refresh flags is true at a time.
649 // But a key-frame is special, for which all the flags are true at once.
Yaowu Xuc27fc142016-08-22 16:08:15 -0700650 int refresh_last_frame;
651 int refresh_golden_frame;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700652 int refresh_bwd_ref_frame;
Zoe Liue9b15e22017-07-19 15:53:01 -0700653 int refresh_alt2_ref_frame;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700654 int refresh_alt_ref_frame;
Urvang Joshi06b37652018-11-06 11:17:56 -0800655
David Turner99e990e2018-12-10 12:54:26 +0000656 // For each type of reference frame, this contains the index of a reference
657 // frame buffer for a reference frame of the same type. We use this to
658 // choose our primary reference frame (which is the most recent reference
659 // frame of the same type as the current frame).
660 int fb_of_context_type[REF_FRAMES];
661
Wei-Ting Linbafa11c2018-07-10 13:20:59 -0700662#if USE_SYMM_MULTI_LAYER
Urvang Joshi06b37652018-11-06 11:17:56 -0800663 // When true, a new rule for backward (future) reference frames is in effect:
664 // - BWDREF_FRAME is always the closest future frame available
665 // - ALTREF2_FRAME is always the 2nd closest future frame available
666 // - 'refresh_bwd_ref_frame' flag is used for updating both the BWDREF_FRAME
667 // and ALTREF2_FRAME. ('refresh_alt2_ref_frame' flag is irrelevant).
Wei-Ting Linbafa11c2018-07-10 13:20:59 -0700668 int new_bwdref_update_rule;
669#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -0700670
671 int ext_refresh_frame_flags_pending;
672 int ext_refresh_last_frame;
673 int ext_refresh_golden_frame;
Yunqing Wang9a50fec2017-11-02 17:02:00 -0700674 int ext_refresh_bwd_ref_frame;
675 int ext_refresh_alt2_ref_frame;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700676 int ext_refresh_alt_ref_frame;
677
678 int ext_refresh_frame_context_pending;
679 int ext_refresh_frame_context;
sarahparker21dbca42018-03-30 17:43:44 -0700680 int ext_use_ref_frame_mvs;
sarahparker27d686a2018-03-30 17:43:44 -0700681 int ext_use_error_resilient;
sarahparker9806fed2018-03-30 17:43:44 -0700682 int ext_use_s_frame;
Sarah Parker50b6d6e2018-04-11 19:21:54 -0700683 int ext_use_primary_ref_none;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700684
685 YV12_BUFFER_CONFIG last_frame_uf;
Debargha Mukherjee999d2f62016-12-15 13:23:21 -0800686 YV12_BUFFER_CONFIG trial_frame_rst;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700687
688 // Ambient reconstruction err target for force key frames
689 int64_t ambient_err;
690
691 RD_OPT rd;
692
693 CODING_CONTEXT coding_context;
694
Yue Chenb23d00a2017-07-28 17:01:21 -0700695 int gmtype_cost[TRANS_TYPES];
Zoe Liu27deb382018-03-27 15:13:56 -0700696 int gmparams_cost[REF_FRAMES];
Yue Chenb23d00a2017-07-28 17:01:21 -0700697
Jingning Hanf050fc12018-03-09 14:53:33 -0800698 int nmv_costs[2][MV_VALS];
699 int nmv_costs_hp[2][MV_VALS];
James Zern01a9d702017-08-25 19:09:33 +0000700
Yaowu Xuc27fc142016-08-22 16:08:15 -0700701 int64_t last_time_stamp_seen;
702 int64_t last_end_time_stamp_seen;
703 int64_t first_time_stamp_ever;
704
705 RATE_CONTROL rc;
706 double framerate;
707
Yunqing Wang9538e4d2019-01-07 18:28:08 +0000708 // Relevant for an inter frame.
709 // - Index '0' corresponds to the values for the currently coded frame.
710 // - Indices LAST_FRAME ... EXTREF_FRAMES are used to store values for all the
711 // possible inter reference frames.
712 int interp_filter_selected[REF_FRAMES + 1][SWITCHABLE];
713
Yaowu Xuf883b422016-08-30 14:01:10 -0700714 struct aom_codec_pkt_list *output_pkt_list;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700715
716 MBGRAPH_FRAME_STATS mbgraph_stats[MAX_LAG_BUFFERS];
717 int mbgraph_n_frames; // number of frames filled in the above
718 int static_mb_pct; // % forced skip mbs by segmentation
719 int ref_frame_flags;
Yunqing Wangf2e7a392017-11-08 00:27:21 -0800720 int ext_ref_frame_flags;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700721
David Turner04b70d82019-01-24 15:39:19 +0000722 // speed is passed as a per-frame parameter into the encoder
723 int speed;
724 // sf contains fine-grained config set internally based on speed
Yaowu Xuc27fc142016-08-22 16:08:15 -0700725 SPEED_FEATURES sf;
726
727 unsigned int max_mv_magnitude;
728 int mv_step_param;
729
Zoe Liu77fb5be2017-11-02 14:36:19 -0700730 int all_one_sided_refs;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700731
Yaowu Xuc27fc142016-08-22 16:08:15 -0700732 uint8_t *segmentation_map;
733
Yaowu Xuc27fc142016-08-22 16:08:15 -0700734 CYCLIC_REFRESH *cyclic_refresh;
735 ActiveMap active_map;
736
737 fractional_mv_step_fp *find_fractional_mv_step;
Yaowu Xuf883b422016-08-30 14:01:10 -0700738 av1_diamond_search_fn_t diamond_search_sad;
Rupert Swarbrick93c39e92017-07-12 11:11:02 +0100739 aom_variance_fn_ptr_t fn_ptr[BLOCK_SIZES_ALL];
Yaowu Xuc27fc142016-08-22 16:08:15 -0700740 uint64_t time_receive_data;
741 uint64_t time_compress_data;
742 uint64_t time_pick_lpf;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700743
744#if CONFIG_FP_MB_STATS
745 int use_fp_mb_stats;
746#endif
747
748 TWO_PASS twopass;
749
750 YV12_BUFFER_CONFIG alt_ref_buffer;
751
752#if CONFIG_INTERNAL_STATS
753 unsigned int mode_chosen_counts[MAX_MODES];
754
755 int count;
756 uint64_t total_sq_error;
757 uint64_t total_samples;
758 ImageStat psnr;
759
760 double total_blockiness;
761 double worst_blockiness;
762
763 int bytes;
764 double summed_quality;
765 double summed_weights;
766 unsigned int tot_recode_hits;
767 double worst_ssim;
768
769 ImageStat fastssim;
770 ImageStat psnrhvs;
771
772 int b_calculate_blockiness;
773 int b_calculate_consistency;
774
775 double total_inconsistency;
776 double worst_consistency;
777 Ssimv *ssim_vars;
778 Metrics metrics;
779#endif
780 int b_calculate_psnr;
Debargha Mukherjee0857e662019-01-04 16:22:09 -0800781#if CONFIG_SPEED_STATS
782 unsigned int tx_search_count;
783#endif // CONFIG_SPEED_STATS
Yaowu Xuc27fc142016-08-22 16:08:15 -0700784
785 int droppable;
786
787 int initial_width;
788 int initial_height;
789 int initial_mbs; // Number of MBs in the full-size frame; to be used to
790 // normalize the firstpass stats. This will differ from the
791 // number of MBs in the current frame when the frame is
792 // scaled.
793
Debargha Mukherjeeccb27262017-09-25 14:19:46 -0700794 // When resize is triggered through external control, the desired width/height
795 // are stored here until use in the next frame coded. They are effective only
796 // for
797 // one frame and are reset after use.
798 int resize_pending_width;
799 int resize_pending_height;
800
Yaowu Xuc27fc142016-08-22 16:08:15 -0700801 int frame_flags;
802
803 search_site_config ss_cfg;
804
Yaowu Xuc27fc142016-08-22 16:08:15 -0700805 TileDataEnc *tile_data;
806 int allocated_tiles; // Keep track of memory allocated for tiles.
807
808 TOKENEXTRA *tile_tok[MAX_TILE_ROWS][MAX_TILE_COLS];
Ravi Chaudhary73cf15b2018-08-30 10:52:51 +0530809 TOKENLIST *tplist[MAX_TILE_ROWS][MAX_TILE_COLS];
Yaowu Xuc27fc142016-08-22 16:08:15 -0700810
Yaowu Xuc27fc142016-08-22 16:08:15 -0700811 int resize_state;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700812 int resize_avg_qp;
813 int resize_buffer_underflow;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700814
Debargha Mukherjeef2e5bb32018-03-26 14:35:24 -0700815 // Sequence parameters have been transmitted already and locked
816 // or not. Once locked av1_change_config cannot change the seq
817 // parameters.
818 int seq_params_locked;
819
Yaowu Xuc27fc142016-08-22 16:08:15 -0700820 // VARIANCE_AQ segment map refresh
821 int vaq_refresh;
822
823 // Multi-threading
824 int num_workers;
Yaowu Xuf883b422016-08-30 14:01:10 -0700825 AVxWorker *workers;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700826 struct EncWorkerData *tile_thr_data;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700827 int existing_fb_idx_to_show;
828 int is_arf_filter_off[MAX_EXT_ARFS + 1];
829 int num_extra_arfs;
Zoe Liuf271a952017-09-05 15:03:48 -0700830 int arf_pos_in_gf[MAX_EXT_ARFS + 1];
831 int arf_pos_for_ovrly[MAX_EXT_ARFS + 1];
Debargha Mukherjeeb98a7022016-11-15 16:07:12 -0800832 int global_motion_search_done;
Di Chen53a04f62017-06-23 13:47:56 -0700833 int extra_arf_allowed;
Hui Su85878782017-11-07 14:56:31 -0800834 // A flag to indicate if intrabc is ever used in current frame.
835 int intrabc_used;
Hui Sudfcbfbd2017-11-13 12:05:30 -0800836 int dv_cost[2][MV_VALS];
837 // TODO(huisu@google.com): we can update dv_joint_cost per SB.
838 int dv_joint_cost[MV_JOINTS];
Hui Suad7551e2018-03-14 11:13:31 -0700839 int has_lossless_segment;
Zoe Liu1d90ceb2018-04-16 16:53:37 -0700840
Remya6924f4a2018-11-26 12:27:32 +0530841 // Factors to control gating of compound type selection based on best
842 // approximate rd so far
843 int max_comp_type_rd_threshold_mul;
844 int max_comp_type_rd_threshold_div;
845
Venkatb62a64b2019-01-03 17:50:40 +0530846 unsigned int tx_domain_dist_threshold;
847
Venkat48067652019-01-09 17:59:53 +0530848 // Factor to control R-D optimization of coeffs based on block
849 // mse.
850 unsigned int coeff_opt_dist_threshold;
851
Deepa K G964e72e2018-05-16 16:56:01 +0530852 AV1LfSync lf_row_sync;
Ravi Chaudharye2aa4012018-06-04 14:20:00 +0530853 AV1LrSync lr_row_sync;
Ravi Chaudharyce0f5fc2018-05-30 16:19:32 +0530854 AV1LrStruct lr_ctxt;
Neil Birkbecka2893ab2018-06-08 14:45:13 -0700855
856 aom_film_grain_table_t *film_grain_table;
857#if CONFIG_DENOISE
858 struct aom_denoise_and_model_t *denoise_and_model;
859#endif
Ranjit Kumar Tulabandu8105bf42018-07-27 14:16:55 +0530860 // Stores the default value of skip flag depending on chroma format
861 // Set as 1 for monochrome and 3 for other color formats
862 int default_interp_skip_flags;
Wei-Ting Lina8c02452018-08-13 11:04:06 -0700863 int preserve_arf_as_gld;
Ravi Chaudharyc5e74692018-10-08 16:05:38 +0530864 MultiThreadHandle multi_thread_ctxt;
Ravi Chaudhary40cdf132018-10-08 11:04:16 +0530865 void (*row_mt_sync_read_ptr)(AV1RowMTSync *const, int, int);
866 void (*row_mt_sync_write_ptr)(AV1RowMTSync *const, int, int, const int);
Ravi Chaudhary90a15f42018-10-11 18:56:35 +0530867#if CONFIG_MULTITHREAD
868 pthread_mutex_t *row_mt_mutex_;
869#endif
Aniket Dhokf6d7ed82019-01-04 14:05:57 +0530870 // Set if screen content is set or relevant tools are enabled
871 int is_screen_content_type;
Yaowu Xuf883b422016-08-30 14:01:10 -0700872} AV1_COMP;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700873
David Turner056f7cd2019-01-07 17:48:13 +0000874// EncodeFrameParams contains per-frame encoding parameters decided upon by
875// av1_encode_strategy() and passed down to av1_encode()
876typedef struct {
David Turner07dbd8e2019-01-08 17:16:25 +0000877 int error_resilient_mode;
878
879 // This is a bitmask of which reference slots can be used in this frame
880 int ref_frame_flags;
881
David Turner04b70d82019-01-24 15:39:19 +0000882 // Speed level to use for this frame: Bigger number means faster.
883 int speed;
884
David Turner056f7cd2019-01-07 17:48:13 +0000885 unsigned int *frame_flags;
886} EncodeFrameParams;
887
888// EncodeFrameResults contains information about the result of encoding a
889// single frame
890typedef struct {
891 size_t size; // Size of resulting bitstream
892} EncodeFrameResults;
893
Wan-Teh Chang3cac4542018-06-29 10:21:39 -0700894// Must not be called more than once.
Yaowu Xuf883b422016-08-30 14:01:10 -0700895void av1_initialize_enc(void);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700896
Yaowu Xuf883b422016-08-30 14:01:10 -0700897struct AV1_COMP *av1_create_compressor(AV1EncoderConfig *oxcf,
898 BufferPool *const pool);
899void av1_remove_compressor(AV1_COMP *cpi);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700900
Yaowu Xuf883b422016-08-30 14:01:10 -0700901void av1_change_config(AV1_COMP *cpi, const AV1EncoderConfig *oxcf);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700902
903// receive a frames worth of data. caller can assume that a copy of this
904// frame is made and not just a copy of the pointer..
James Zern3e2613b2017-03-30 23:14:40 -0700905int av1_receive_raw_frame(AV1_COMP *cpi, aom_enc_frame_flags_t frame_flags,
Yaowu Xuf883b422016-08-30 14:01:10 -0700906 YV12_BUFFER_CONFIG *sd, int64_t time_stamp,
907 int64_t end_time_stamp);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700908
Andrey Norkin795ba872018-03-06 13:24:14 -0800909int av1_get_compressed_data(AV1_COMP *cpi, unsigned int *frame_flags,
910 size_t *size, uint8_t *dest, int64_t *time_stamp,
911 int64_t *time_end, int flush,
912 const aom_rational_t *timebase);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700913
David Turner056f7cd2019-01-07 17:48:13 +0000914int av1_encode(AV1_COMP *const cpi, uint8_t *const dest,
915 const EncodeFrameParams *const frame_params,
916 EncodeFrameResults *const frame_results);
917
Yaowu Xuf883b422016-08-30 14:01:10 -0700918int av1_get_preview_raw_frame(AV1_COMP *cpi, YV12_BUFFER_CONFIG *dest);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700919
Yaowu Xuf883b422016-08-30 14:01:10 -0700920int av1_get_last_show_frame(AV1_COMP *cpi, YV12_BUFFER_CONFIG *frame);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700921
Yunqing Wang93b18f32018-06-08 21:08:29 -0700922aom_codec_err_t av1_copy_new_frame_enc(AV1_COMMON *cm,
923 YV12_BUFFER_CONFIG *new_frame,
924 YV12_BUFFER_CONFIG *sd);
Yunqing Wangff9bfca2018-06-06 11:46:08 -0700925
Yaowu Xuf883b422016-08-30 14:01:10 -0700926int av1_use_as_reference(AV1_COMP *cpi, int ref_frame_flags);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700927
Yaowu Xuf883b422016-08-30 14:01:10 -0700928void av1_update_reference(AV1_COMP *cpi, int ref_frame_flags);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700929
Thomas Daede497d1952017-08-08 17:33:06 -0700930int av1_copy_reference_enc(AV1_COMP *cpi, int idx, YV12_BUFFER_CONFIG *sd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700931
Thomas Daede497d1952017-08-08 17:33:06 -0700932int av1_set_reference_enc(AV1_COMP *cpi, int idx, YV12_BUFFER_CONFIG *sd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700933
Yaowu Xuf883b422016-08-30 14:01:10 -0700934int av1_update_entropy(AV1_COMP *cpi, int update);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700935
Yaowu Xuf883b422016-08-30 14:01:10 -0700936int av1_set_active_map(AV1_COMP *cpi, unsigned char *map, int rows, int cols);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700937
Yaowu Xuf883b422016-08-30 14:01:10 -0700938int av1_get_active_map(AV1_COMP *cpi, unsigned char *map, int rows, int cols);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700939
Yaowu Xuf883b422016-08-30 14:01:10 -0700940int av1_set_internal_size(AV1_COMP *cpi, AOM_SCALING horiz_mode,
941 AOM_SCALING vert_mode);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700942
Yaowu Xuf883b422016-08-30 14:01:10 -0700943int av1_get_quantizer(struct AV1_COMP *cpi);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700944
Soo-Chul Han29c46fb2018-03-23 16:02:00 -0400945int av1_convert_sect5obus_to_annexb(uint8_t *buffer, size_t *input_size);
946
Andrey Norkin795ba872018-03-06 13:24:14 -0800947int64_t timebase_units_to_ticks(const aom_rational_t *timebase, int64_t n);
948int64_t ticks_to_timebase_units(const aom_rational_t *timebase, int64_t n);
Andrey Norkin795ba872018-03-06 13:24:14 -0800949
Yaowu Xuf883b422016-08-30 14:01:10 -0700950static INLINE int frame_is_kf_gf_arf(const AV1_COMP *cpi) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700951 return frame_is_intra_only(&cpi->common) || cpi->refresh_alt_ref_frame ||
952 (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref);
953}
954
Hui Su2d5fd742018-02-21 18:10:37 -0800955// TODO(huisu@google.com, youzhou@microsoft.com): enable hash-me for HBD.
956static INLINE int av1_use_hash_me(const AV1_COMMON *const cm) {
Debargha Mukherjee8112d2f2018-03-01 09:53:11 -0800957 return cm->allow_screen_content_tools;
Hui Su2d5fd742018-02-21 18:10:37 -0800958}
959
960static INLINE hash_table *av1_get_ref_frame_hash_map(
David Turnera21966b2018-12-05 14:48:49 +0000961 const AV1_COMMON *cm, MV_REFERENCE_FRAME ref_frame) {
962 const int map_idx = get_ref_frame_map_idx(cm, ref_frame);
963 RefCntBuffer *buf =
964 (map_idx != INVALID_IDX) ? cm->ref_frame_map[map_idx] : NULL;
965 return buf ? &buf->hash_table : NULL;
RogerZhoucc5d35d2017-08-07 22:20:15 -0700966}
RogerZhoucc5d35d2017-08-07 22:20:15 -0700967
David Turnera21966b2018-12-05 14:48:49 +0000968static INLINE const YV12_BUFFER_CONFIG *get_ref_frame_yv12_buf(
969 const AV1_COMMON *const cm, MV_REFERENCE_FRAME ref_frame) {
970 const RefCntBuffer *const buf = get_ref_frame_buf(cm, ref_frame);
David Turnere7ebf902018-12-04 14:04:55 +0000971 return buf != NULL ? &buf->buf : NULL;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700972}
973
David Turnera21966b2018-12-05 14:48:49 +0000974static INLINE int enc_is_ref_frame_buf(const AV1_COMMON *const cm,
975 const RefCntBuffer *const frame_buf) {
Urvang Joshi40582172018-11-07 11:53:03 -0800976 MV_REFERENCE_FRAME ref_frame;
977 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
David Turnera21966b2018-12-05 14:48:49 +0000978 const RefCntBuffer *const buf = get_ref_frame_buf(cm, ref_frame);
David Turnere7ebf902018-12-04 14:04:55 +0000979 if (buf == NULL) continue;
980 if (frame_buf == buf) break;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700981 }
Urvang Joshi40582172018-11-07 11:53:03 -0800982 return (ref_frame <= ALTREF_FRAME);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700983}
Yaowu Xuc27fc142016-08-22 16:08:15 -0700984
Hui Su8ac0c982018-04-03 12:17:36 -0700985// Token buffer is only used for palette tokens.
Yaowu Xue39b3b82017-10-31 16:11:59 -0700986static INLINE unsigned int get_token_alloc(int mb_rows, int mb_cols,
Imdad Sardharwallaaf8e2642018-01-19 11:46:34 +0000987 int sb_size_log2,
988 const int num_planes) {
Rupert Swarbrickce63e832017-10-25 17:54:17 +0100989 // Calculate the maximum number of max superblocks in the image.
Yaowu Xue39b3b82017-10-31 16:11:59 -0700990 const int shift = sb_size_log2 - 4;
991 const int sb_size = 1 << sb_size_log2;
992 const int sb_size_square = sb_size * sb_size;
Rupert Swarbrickce63e832017-10-25 17:54:17 +0100993 const int sb_rows = ALIGN_POWER_OF_TWO(mb_rows, shift) >> shift;
994 const int sb_cols = ALIGN_POWER_OF_TWO(mb_cols, shift) >> shift;
995
Hui Su8ac0c982018-04-03 12:17:36 -0700996 // One palette token for each pixel. There can be palettes on two planes.
997 const int sb_palette_toks = AOMMIN(2, num_planes) * sb_size_square;
Rupert Swarbrickce63e832017-10-25 17:54:17 +0100998
Hui Su8ac0c982018-04-03 12:17:36 -0700999 return sb_rows * sb_cols * sb_palette_toks;
Yaowu Xuc27fc142016-08-22 16:08:15 -07001000}
1001
1002// Get the allocated token size for a tile. It does the same calculation as in
1003// the frame token allocation.
Rupert Swarbrickdcb3cff2017-11-09 15:58:33 +00001004static INLINE unsigned int allocated_tokens(TileInfo tile, int sb_size_log2,
1005 int num_planes) {
Jingning Haneafbd5f2017-03-07 11:18:17 -08001006 int tile_mb_rows = (tile.mi_row_end - tile.mi_row_start + 2) >> 2;
1007 int tile_mb_cols = (tile.mi_col_end - tile.mi_col_start + 2) >> 2;
Yaowu Xuc27fc142016-08-22 16:08:15 -07001008
Rupert Swarbrickdcb3cff2017-11-09 15:58:33 +00001009 return get_token_alloc(tile_mb_rows, tile_mb_cols, sb_size_log2, num_planes);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001010}
1011
Ravi Chaudhary73cf15b2018-08-30 10:52:51 +05301012static INLINE void get_start_tok(AV1_COMP *cpi, int tile_row, int tile_col,
1013 int mi_row, TOKENEXTRA **tok, int sb_size_log2,
1014 int num_planes) {
1015 AV1_COMMON *const cm = &cpi->common;
1016 const int tile_cols = cm->tile_cols;
1017 TileDataEnc *this_tile = &cpi->tile_data[tile_row * tile_cols + tile_col];
1018 const TileInfo *const tile_info = &this_tile->tile_info;
1019
1020 const int tile_mb_cols =
1021 (tile_info->mi_col_end - tile_info->mi_col_start + 2) >> 2;
1022 const int tile_mb_row = (mi_row - tile_info->mi_row_start + 2) >> 2;
1023
1024 *tok = cpi->tile_tok[tile_row][tile_col] +
1025 get_token_alloc(tile_mb_row, tile_mb_cols, sb_size_log2, num_planes);
1026}
1027
Yaowu Xuf883b422016-08-30 14:01:10 -07001028void av1_apply_encoding_flags(AV1_COMP *cpi, aom_enc_frame_flags_t flags);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001029
Yaowu Xu6da42302017-10-10 14:45:06 -07001030#define ALT_MIN_LAG 3
Yaowu Xuf883b422016-08-30 14:01:10 -07001031static INLINE int is_altref_enabled(const AV1_COMP *const cpi) {
Yaowu Xu6da42302017-10-10 14:45:06 -07001032 return cpi->oxcf.lag_in_frames >= ALT_MIN_LAG && cpi->oxcf.enable_auto_arf;
Yaowu Xuc27fc142016-08-22 16:08:15 -07001033}
1034
1035// TODO(zoeliu): To set up cpi->oxcf.enable_auto_brf
Yaowu Xuc27fc142016-08-22 16:08:15 -07001036
Urvang Joshi52648442016-10-13 17:27:51 -07001037static INLINE void set_ref_ptrs(const AV1_COMMON *cm, MACROBLOCKD *xd,
Yaowu Xuc27fc142016-08-22 16:08:15 -07001038 MV_REFERENCE_FRAME ref0,
1039 MV_REFERENCE_FRAME ref1) {
David Turnera21966b2018-12-05 14:48:49 +00001040 xd->block_ref_scale_factors[0] =
1041 get_ref_scale_factors_const(cm, ref0 >= LAST_FRAME ? ref0 : 1);
1042 xd->block_ref_scale_factors[1] =
1043 get_ref_scale_factors_const(cm, ref1 >= LAST_FRAME ? ref1 : 1);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001044}
1045
Yaowu Xu4ff59b52017-04-24 12:41:56 -07001046static INLINE int get_chessboard_index(int frame_index) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001047 return frame_index & 0x1;
1048}
1049
Yaowu Xuf883b422016-08-30 14:01:10 -07001050static INLINE int *cond_cost_list(const struct AV1_COMP *cpi, int *cost_list) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001051 return cpi->sf.mv.subpel_search_method != SUBPEL_TREE ? cost_list : NULL;
1052}
1053
Yaowu Xuf883b422016-08-30 14:01:10 -07001054void av1_new_framerate(AV1_COMP *cpi, double framerate);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001055
1056#define LAYER_IDS_TO_IDX(sl, tl, num_tl) ((sl) * (num_tl) + (tl))
1057
Cheng Chen09c83a52018-06-05 12:27:36 -07001058// Returns 1 if a frame is scaled and 0 otherwise.
1059static INLINE int av1_resize_scaled(const AV1_COMMON *cm) {
1060 return !(cm->superres_upscaled_width == cm->render_width &&
1061 cm->superres_upscaled_height == cm->render_height);
Fergus Simpsonfecb2ab2017-04-30 15:49:57 -07001062}
1063
Cheng Chen09c83a52018-06-05 12:27:36 -07001064static INLINE int av1_frame_scaled(const AV1_COMMON *cm) {
1065 return !av1_superres_scaled(cm) && av1_resize_scaled(cm);
Fergus Simpsonfecb2ab2017-04-30 15:49:57 -07001066}
1067
Sarah Parker33005522018-07-27 14:46:25 -07001068// Don't allow a show_existing_frame to coincide with an error resilient
1069// frame. An exception can be made for a forward keyframe since it has no
1070// previous dependencies.
1071static INLINE int encode_show_existing_frame(const AV1_COMMON *cm) {
David Turnerd2a592e2018-11-16 14:59:31 +00001072 return cm->show_existing_frame && (!cm->error_resilient_mode ||
1073 cm->current_frame.frame_type == KEY_FRAME);
Sarah Parker33005522018-07-27 14:46:25 -07001074}
1075
Tom Fineganf8d6a162018-08-21 10:47:55 -07001076// Returns a Sequence Header OBU stored in an aom_fixed_buf_t, or NULL upon
1077// failure. When a non-NULL aom_fixed_buf_t pointer is returned by this
1078// function, the memory must be freed by the caller. Both the buf member of the
Tom Fineganca1e28f2018-08-28 16:55:35 -07001079// aom_fixed_buf_t, and the aom_fixed_buf_t pointer itself must be freed. Memory
1080// returned must be freed via call to free().
1081//
1082// Note: The OBU returned is in Low Overhead Bitstream Format. Specifically,
1083// the obu_has_size_field bit is set, and the buffer contains the obu_size
1084// field.
Tom Fineganf8d6a162018-08-21 10:47:55 -07001085aom_fixed_buf_t *av1_get_global_headers(AV1_COMP *cpi);
1086
Yaowu Xuc27fc142016-08-22 16:08:15 -07001087#ifdef __cplusplus
1088} // extern "C"
1089#endif
1090
James Zerne1cbb132018-08-22 14:10:36 -07001091#endif // AOM_AV1_ENCODER_ENCODER_H_