blob: fde32981ce3ebfb7463b1118d2f7d013b3df9e93 [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
Yaowu Xuf883b422016-08-30 14:01:10 -070012#ifndef AV1_ENCODER_ENCODER_H_
13#define AV1_ENCODER_ENCODER_H_
Yaowu Xuc27fc142016-08-22 16:08:15 -070014
15#include <stdio.h>
16
Yaowu Xuf883b422016-08-30 14:01:10 -070017#include "./aom_config.h"
18#include "aom/aomcx.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070019
20#include "av1/common/alloccommon.h"
21#include "av1/common/entropymode.h"
22#include "av1/common/thread_common.h"
23#include "av1/common/onyxc_int.h"
Fergus Simpsond2bcbb52017-05-22 23:15:05 -070024#include "av1/common/resize.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070025#include "av1/encoder/aq_cyclicrefresh.h"
Tom Finegan17ce8b12017-02-08 12:46:31 -080026#include "av1/encoder/av1_quantize.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070027#include "av1/encoder/context_tree.h"
28#include "av1/encoder/encodemb.h"
29#include "av1/encoder/firstpass.h"
30#include "av1/encoder/lookahead.h"
31#include "av1/encoder/mbgraph.h"
32#include "av1/encoder/mcomp.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070033#include "av1/encoder/ratectrl.h"
34#include "av1/encoder/rd.h"
35#include "av1/encoder/speed_features.h"
36#include "av1/encoder/tokenize.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070037
38#if CONFIG_INTERNAL_STATS
39#include "aom_dsp/ssim.h"
40#endif
41#include "aom_dsp/variance.h"
Yaowu Xuf883b422016-08-30 14:01:10 -070042#include "aom/internal/aom_codec_internal.h"
43#include "aom_util/aom_thread.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070044
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49typedef struct {
Jingning Hanf050fc12018-03-09 14:53:33 -080050 int nmv_vec_cost[MV_JOINTS];
51 int nmv_costs[2][MV_VALS];
52 int nmv_costs_hp[2][MV_VALS];
James Zern01a9d702017-08-25 19:09:33 +000053
Yaowu Xuc27fc142016-08-22 16:08:15 -070054 FRAME_CONTEXT fc;
55} CODING_CONTEXT;
56
57typedef enum {
58 // regular inter frame
59 REGULAR_FRAME = 0,
60 // alternate reference frame
61 ARF_FRAME = 1,
62 // overlay frame
63 OVERLAY_FRAME = 2,
64 // golden frame
65 GLD_FRAME = 3,
Yaowu Xuc27fc142016-08-22 16:08:15 -070066 // backward reference frame
67 BRF_FRAME = 4,
68 // extra alternate reference frame
Thomas Daede51020e12017-12-14 20:12:44 -080069 EXT_ARF_FRAME = 5,
70 FRAME_CONTEXT_INDEXES
Yaowu Xuc27fc142016-08-22 16:08:15 -070071} FRAME_CONTEXT_INDEX;
72
73typedef enum {
Yaowu Xuc27fc142016-08-22 16:08:15 -070074 NORMAL = 0,
75 FOURFIVE = 1,
76 THREEFIVE = 2,
77 ONETWO = 3
Yaowu Xuf883b422016-08-30 14:01:10 -070078} AOM_SCALING;
Yaowu Xuc27fc142016-08-22 16:08:15 -070079
80typedef enum {
81 // Good Quality Fast Encoding. The encoder balances quality with the amount of
82 // time it takes to encode the output. Speed setting controls how fast.
Thomas Daede80826142017-03-20 15:44:24 -070083 GOOD
Yaowu Xuc27fc142016-08-22 16:08:15 -070084} MODE;
85
86typedef enum {
87 FRAMEFLAGS_KEY = 1 << 0,
88 FRAMEFLAGS_GOLDEN = 1 << 1,
Yaowu Xuc27fc142016-08-22 16:08:15 -070089 FRAMEFLAGS_BWDREF = 1 << 2,
Zoe Liu3ac20932017-08-30 16:35:55 -070090 // TODO(zoeliu): To determine whether a frame flag is needed for ALTREF2_FRAME
Yaowu Xuc27fc142016-08-22 16:08:15 -070091 FRAMEFLAGS_ALTREF = 1 << 3,
Yaowu Xuc27fc142016-08-22 16:08:15 -070092} FRAMETYPE_FLAGS;
93
94typedef enum {
95 NO_AQ = 0,
96 VARIANCE_AQ = 1,
97 COMPLEXITY_AQ = 2,
98 CYCLIC_REFRESH_AQ = 3,
99 AQ_MODE_COUNT // This should always be the last member of the enum
100} AQ_MODE;
Fangwen Fu6160df22017-04-24 09:45:51 -0700101typedef enum {
102 NO_DELTA_Q = 0,
103 DELTA_Q_ONLY = 1,
104 DELTA_Q_LF = 2,
105 DELTAQ_MODE_COUNT // This should always be the last member of the enum
106} DELTAQ_MODE;
Debargha Mukherjee3a4959f2018-02-26 15:34:03 -0800107
Yaowu Xuc27fc142016-08-22 16:08:15 -0700108typedef enum {
109 RESIZE_NONE = 0, // No frame resizing allowed.
Debargha Mukherjee7166f222017-09-05 21:32:42 -0700110 RESIZE_FIXED = 1, // All frames are coded at the specified scale.
111 RESIZE_RANDOM = 2, // All frames are coded at a random scale.
112 RESIZE_MODES
Debargha Mukherjee29e40a62017-06-14 09:37:12 -0700113} RESIZE_MODE;
Debargha Mukherjee3a4959f2018-02-26 15:34:03 -0800114
Fergus Simpsonc4e78942017-04-10 14:59:00 -0700115typedef enum {
Debargha Mukherjee7166f222017-09-05 21:32:42 -0700116 SUPERRES_NONE = 0, // No frame superres allowed
117 SUPERRES_FIXED = 1, // All frames are coded at the specified scale,
118 // and super-resolved.
119 SUPERRES_RANDOM = 2, // All frames are coded at a random scale,
120 // and super-resolved.
121 SUPERRES_QTHRESH = 3, // Superres scale for a frame is determined based on
122 // q_index
123 SUPERRES_MODES
Fergus Simpsonc4e78942017-04-10 14:59:00 -0700124} SUPERRES_MODE;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700125
Yaowu Xuf883b422016-08-30 14:01:10 -0700126typedef struct AV1EncoderConfig {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700127 BITSTREAM_PROFILE profile;
Tom Finegan8ab2bba2018-02-28 07:36:28 -0800128 aom_bit_depth_t bit_depth; // Codec bit-depth.
129 int width; // width of data passed to the compressor
130 int height; // height of data passed to the compressor
131 int forced_max_frame_width; // forced maximum width of frame (if != 0)
132 int forced_max_frame_height; // forced maximum height of frame (if != 0)
Yaowu Xuc27fc142016-08-22 16:08:15 -0700133 unsigned int input_bit_depth; // Input bit depth.
134 double init_framerate; // set to passed in framerate
135 int64_t target_bandwidth; // bandwidth to be used in bits per second
136
137 int noise_sensitivity; // pre processing blur: recommendation 0
138 int sharpness; // sharpening output: recommendation 0:
139 int speed;
Jingning Hanb49c6ae2017-11-27 18:14:05 -0800140 int dev_sf;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700141 // maximum allowed bitrate for any intra frame in % of bitrate target.
142 unsigned int rc_max_intra_bitrate_pct;
143 // maximum allowed bitrate for any inter frame in % of bitrate target.
144 unsigned int rc_max_inter_bitrate_pct;
145 // percent of rate boost for golden frame in CBR mode.
146 unsigned int gf_cbr_boost_pct;
147
148 MODE mode;
149 int pass;
150
151 // Key Framing Operations
152 int auto_key; // autodetect cut scenes and set the keyframes
153 int key_freq; // maximum distance to key frame.
Tarek AMARAc9813852018-03-05 18:40:18 -0500154 int sframe_dist;
155 int sframe_mode;
156 int sframe_enabled;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700157 int lag_in_frames; // how many frames lag before we start encoding
158
159 // ----------------------------------------------------------------
160 // DATARATE CONTROL OPTIONS
161
162 // vbr, cbr, constrained quality or constant quality
Yaowu Xuf883b422016-08-30 14:01:10 -0700163 enum aom_rc_mode rc_mode;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700164
165 // buffer targeting aggressiveness
166 int under_shoot_pct;
167 int over_shoot_pct;
168
169 // buffering parameters
170 int64_t starting_buffer_level_ms;
171 int64_t optimal_buffer_level_ms;
172 int64_t maximum_buffer_size_ms;
173
174 // Frame drop threshold.
175 int drop_frames_water_mark;
176
177 // controlling quality
178 int fixed_q;
179 int worst_allowed_q;
180 int best_allowed_q;
181 int cq_level;
182 AQ_MODE aq_mode; // Adaptive Quantization mode
Fangwen Fu6160df22017-04-24 09:45:51 -0700183 DELTAQ_MODE deltaq_mode;
Debargha Mukherjee98a311c2018-03-25 16:33:11 -0700184 int enable_cdef;
185 int enable_restoration;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700186 int using_qm;
Yaowu Xuf7a12422018-01-31 15:29:20 -0800187 int qm_y;
188 int qm_u;
189 int qm_v;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700190 int qm_minlevel;
191 int qm_maxlevel;
Yushin Chod808bfc2017-08-10 15:54:36 -0700192#if CONFIG_DIST_8X8
193 int using_dist_8x8;
194#endif
Thomas Daviesaf6df172016-11-09 14:04:18 +0000195 unsigned int num_tile_groups;
196 unsigned int mtu;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700197
198 // Internal frame size scaling.
Debargha Mukherjee29e40a62017-06-14 09:37:12 -0700199 RESIZE_MODE resize_mode;
Urvang Joshide71d142017-10-05 12:12:15 -0700200 uint8_t resize_scale_denominator;
201 uint8_t resize_kf_scale_denominator;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700202
Fergus Simpsonc4e78942017-04-10 14:59:00 -0700203 // Frame Super-Resolution size scaling.
204 SUPERRES_MODE superres_mode;
Urvang Joshide71d142017-10-05 12:12:15 -0700205 uint8_t superres_scale_denominator;
206 uint8_t superres_kf_scale_denominator;
Debargha Mukherjee7166f222017-09-05 21:32:42 -0700207 int superres_qthresh;
208 int superres_kf_qthresh;
Fergus Simpson3502d082017-04-10 12:25:07 -0700209
Yaowu Xuc27fc142016-08-22 16:08:15 -0700210 // Enable feature to reduce the frame quantization every x frames.
211 int frame_periodic_boost;
212
213 // two pass datarate control
214 int two_pass_vbrbias; // two pass datarate control tweaks
215 int two_pass_vbrmin_section;
216 int two_pass_vbrmax_section;
217 // END DATARATE CONTROL OPTIONS
218 // ----------------------------------------------------------------
219
220 int enable_auto_arf;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700221 int enable_auto_brf; // (b)ackward (r)ef (f)rame
Yaowu Xuc27fc142016-08-22 16:08:15 -0700222
Yaowu Xuc27fc142016-08-22 16:08:15 -0700223 /* Bitfield defining the error resiliency features to enable.
224 * Can provide decodable frames after losses in previous
225 * frames and decodable partitions after losses in the same frame.
226 */
227 unsigned int error_resilient_mode;
228
229 /* Bitfield defining the parallel decoding mode where the
230 * decoding in successive frames may be conducted in parallel
231 * just by decoding the frame headers.
232 */
233 unsigned int frame_parallel_decoding_mode;
234
235 int arnr_max_frames;
236 int arnr_strength;
237
238 int min_gf_interval;
239 int max_gf_interval;
240
241 int tile_columns;
242 int tile_rows;
Dominic Symes26ad0b22017-10-01 16:35:13 +0200243 int tile_width_count;
244 int tile_height_count;
245 int tile_widths[MAX_TILE_COLS];
246 int tile_heights[MAX_TILE_ROWS];
Yaowu Xuc27fc142016-08-22 16:08:15 -0700247
248 int max_threads;
249
Yaowu Xuf883b422016-08-30 14:01:10 -0700250 aom_fixed_buf_t two_pass_stats_in;
251 struct aom_codec_pkt_list *output_pkt_list;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700252
253#if CONFIG_FP_MB_STATS
Yaowu Xuf883b422016-08-30 14:01:10 -0700254 aom_fixed_buf_t firstpass_mb_stats_in;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700255#endif
256
Yaowu Xuf883b422016-08-30 14:01:10 -0700257 aom_tune_metric tuning;
258 aom_tune_content content;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700259 int use_highbitdepth;
Andrey Norkin9e694632017-12-21 18:50:57 -0800260 aom_color_primaries_t color_primaries;
261 aom_transfer_characteristics_t transfer_characteristics;
262 aom_matrix_coefficients_t matrix_coefficients;
anorkin76fb1262017-03-22 15:12:12 -0700263 aom_chroma_sample_position_t chroma_sample_position;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700264 int color_range;
265 int render_width;
266 int render_height;
Andrey Norkin28e9ce22018-01-08 10:11:21 -0800267 aom_timing_info_t timing_info;
268 int timing_info_present;
269 uint32_t num_units_in_tick;
270 uint32_t time_scale;
271 int equal_picture_interval;
272 uint32_t num_ticks_per_picture;
Andrey Norkin6f1c2f72018-01-15 20:08:52 -0800273 int film_grain_test_vector;
Neil Birkbeckeb895ef2018-03-14 17:51:03 -0700274 const char *film_grain_table_filename;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700275
Hui Su1cb1c002018-02-05 18:21:20 -0800276 uint8_t cdf_update_mode;
Yaowu Xuf883b422016-08-30 14:01:10 -0700277 aom_superblock_size_t superblock_size;
Yunqing Wangeeb08a92017-07-07 21:25:18 -0700278 unsigned int large_scale_tile;
279 unsigned int single_tile_decoding;
Debargha Mukherjeef340fec2018-01-10 18:12:22 -0800280 int monochrome;
Jingning Hana446f552018-02-22 15:42:12 -0800281 int enable_dual_filter;
Yunqing Wangff4fa062017-04-21 10:56:08 -0700282 unsigned int motion_vector_unit_test;
Maxym Dmytrychenkocc6e0e12018-02-05 16:35:37 +0100283 const cfg_options_t *cfg;
Debargha Mukherjee0d8368a2018-03-25 12:23:02 -0700284 int enable_order_hint;
Cheng Chene0c918a2018-02-22 19:38:31 -0800285 int enable_jnt_comp;
Debargha Mukherjee0187d7c2018-03-25 11:37:56 -0700286 int enable_ref_frame_mvs;
Debargha Mukherjee0d8368a2018-03-25 12:23:02 -0700287 unsigned int allow_ref_frame_mvs;
Debargha Mukherjee37df9162018-03-25 12:48:24 -0700288 int enable_warped_motion;
289 int allow_warped_motion;
Urvang Joshi2c92b072018-03-19 17:23:31 -0700290 int enable_superres;
Soo-Chul Han29c46fb2018-03-23 16:02:00 -0400291 unsigned int save_as_annexb;
Yaowu Xuf883b422016-08-30 14:01:10 -0700292} AV1EncoderConfig;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700293
Yaowu Xuf883b422016-08-30 14:01:10 -0700294static INLINE int is_lossless_requested(const AV1EncoderConfig *cfg) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700295 return cfg->best_allowed_q == 0 && cfg->worst_allowed_q == 0;
296}
297
298// TODO(jingning) All spatially adaptive variables should go to TileDataEnc.
299typedef struct TileDataEnc {
300 TileInfo tile_info;
Rupert Swarbrick93c39e92017-07-12 11:11:02 +0100301 int thresh_freq_fact[BLOCK_SIZES_ALL][MAX_MODES];
302 int mode_map[BLOCK_SIZES_ALL][MAX_MODES];
Yunqing Wang8c1e57c2016-10-25 15:15:23 -0700303 int m_search_count;
304 int ex_search_count;
Luc Trudeauf8164152017-04-11 16:20:51 -0400305 CFL_CTX cfl;
Jingning Han9f07be12017-04-13 09:31:40 -0700306 DECLARE_ALIGNED(16, FRAME_CONTEXT, tctx);
Yunqing Wang0e141b52017-11-02 15:08:58 -0700307 uint8_t allow_update_cdf;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700308} TileDataEnc;
309
310typedef struct RD_COUNTS {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700311 int64_t comp_pred_diff[REFERENCE_MODES];
Debargha Mukherjeea575d232017-04-28 17:46:47 -0700312 // Stores number of 4x4 blocks using global motion per reference frame.
Zoe Liu27deb382018-03-27 15:13:56 -0700313 int global_motion_used[REF_FRAMES];
Arild Fuldseth (arilfuld)6c20c782017-06-15 09:45:02 +0200314 int compound_ref_used_flag;
Zoe Liu8a5d3432017-11-30 16:33:44 -0800315 int skip_mode_used_flag;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700316} RD_COUNTS;
317
318typedef struct ThreadData {
319 MACROBLOCK mb;
320 RD_COUNTS rd_counts;
321 FRAME_COUNTS *counts;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700322 PC_TREE *pc_tree;
323 PC_TREE *pc_root[MAX_MIB_SIZE_LOG2 - MIN_MIB_SIZE_LOG2 + 1];
Jingning Hand064cf02017-06-01 10:00:39 -0700324 int32_t *wsrc_buf;
325 int32_t *mask_buf;
326 uint8_t *above_pred_buf;
327 uint8_t *left_pred_buf;
hui su5d493142017-05-08 12:06:12 -0700328 PALETTE_BUFFER *palette_buffer;
Hui Su85878782017-11-07 14:56:31 -0800329 int intrabc_used_this_tile;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700330} ThreadData;
331
332struct EncWorkerData;
333
334typedef struct ActiveMap {
335 int enabled;
336 int update;
337 unsigned char *map;
338} ActiveMap;
339
Urvang Joshib5ed3502016-10-17 16:38:05 -0700340#define NUM_STAT_TYPES 4 // types of stats: Y, U, V and ALL
Yaowu Xuc27fc142016-08-22 16:08:15 -0700341
342typedef struct IMAGE_STAT {
Urvang Joshib5ed3502016-10-17 16:38:05 -0700343 double stat[NUM_STAT_TYPES];
Yaowu Xuc27fc142016-08-22 16:08:15 -0700344 double worst;
345} ImageStat;
346
Urvang Joshib5ed3502016-10-17 16:38:05 -0700347#undef NUM_STAT_TYPES
348
Yaowu Xuc27fc142016-08-22 16:08:15 -0700349typedef struct {
350 int ref_count;
351 YV12_BUFFER_CONFIG buf;
352} EncRefCntBuffer;
353
Yaowu Xuc27fc142016-08-22 16:08:15 -0700354typedef struct TileBufferEnc {
355 uint8_t *data;
356 size_t size;
357} TileBufferEnc;
358
Yaowu Xuf883b422016-08-30 14:01:10 -0700359typedef struct AV1_COMP {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700360 QUANTS quants;
361 ThreadData td;
362 MB_MODE_INFO_EXT *mbmi_ext_base;
Jingning Hanf5a4d3b2017-08-27 23:01:19 -0700363 CB_COEFF_BUFFER *coeff_buffer_base;
Yi Luoc6210232017-05-25 15:09:25 -0700364 Dequants dequants;
Yaowu Xuf883b422016-08-30 14:01:10 -0700365 AV1_COMMON common;
366 AV1EncoderConfig oxcf;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700367 struct lookahead_ctx *lookahead;
368 struct lookahead_entry *alt_ref_source;
369
Angie Chiange69a6822018-03-16 13:52:44 -0700370 int optimize_speed_feature;
371 int optimize_seg_arr[MAX_SEGMENTS];
372
Alex Conversef77fd0b2017-04-20 11:00:24 -0700373 YV12_BUFFER_CONFIG *source;
374 YV12_BUFFER_CONFIG *last_source; // NULL for first frame and alt_ref frames
Fergus Simpsond2bcbb52017-05-22 23:15:05 -0700375 YV12_BUFFER_CONFIG *unscaled_source;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700376 YV12_BUFFER_CONFIG scaled_source;
377 YV12_BUFFER_CONFIG *unscaled_last_source;
378 YV12_BUFFER_CONFIG scaled_last_source;
379
Yaowu Xuc27fc142016-08-22 16:08:15 -0700380 // For a still frame, this flag is set to 1 to skip partition search.
381 int partition_search_skippable_frame;
RogerZhou3b635242017-09-19 10:06:46 -0700382 double csm_rate_array[32];
383 double m_rate_array[32];
384 int rate_size;
385 int rate_index;
Debargha Mukherjeee41a6672018-02-27 11:56:31 -0800386 hash_table *previous_hash_table;
387 int previous_index;
RogerZhou3b635242017-09-19 10:06:46 -0700388 int cur_poc; // DebugInfo
Yaowu Xuc27fc142016-08-22 16:08:15 -0700389
Zoe Liu27deb382018-03-27 15:13:56 -0700390 int scaled_ref_idx[REF_FRAMES];
Yaowu Xuc27fc142016-08-22 16:08:15 -0700391 int lst_fb_idxes[LAST_REF_FRAMES];
Yaowu Xuc27fc142016-08-22 16:08:15 -0700392 int gld_fb_idx;
Zoe Liu3ac20932017-08-30 16:35:55 -0700393 int bwd_fb_idx; // BWDREF_FRAME
Zoe Liue9b15e22017-07-19 15:53:01 -0700394 int alt2_fb_idx; // ALTREF2_FRAME
Yaowu Xuc27fc142016-08-22 16:08:15 -0700395 int alt_fb_idx;
Zoe Liu8dd1c982017-09-11 10:14:35 -0700396 int ext_fb_idx; // extra ref frame buffer index
397 int refresh_fb_idx; // ref frame buffer index to refresh
Yaowu Xuc27fc142016-08-22 16:08:15 -0700398
399 int last_show_frame_buf_idx; // last show frame buffer index
400
401 int refresh_last_frame;
402 int refresh_golden_frame;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700403 int refresh_bwd_ref_frame;
Zoe Liue9b15e22017-07-19 15:53:01 -0700404 int refresh_alt2_ref_frame;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700405 int refresh_alt_ref_frame;
406
407 int ext_refresh_frame_flags_pending;
408 int ext_refresh_last_frame;
409 int ext_refresh_golden_frame;
Yunqing Wang9a50fec2017-11-02 17:02:00 -0700410 int ext_refresh_bwd_ref_frame;
411 int ext_refresh_alt2_ref_frame;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700412 int ext_refresh_alt_ref_frame;
413
414 int ext_refresh_frame_context_pending;
415 int ext_refresh_frame_context;
416
417 YV12_BUFFER_CONFIG last_frame_uf;
Debargha Mukherjee999d2f62016-12-15 13:23:21 -0800418 YV12_BUFFER_CONFIG trial_frame_rst;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700419
420 // Ambient reconstruction err target for force key frames
421 int64_t ambient_err;
422
423 RD_OPT rd;
424
425 CODING_CONTEXT coding_context;
426
Yue Chenb23d00a2017-07-28 17:01:21 -0700427 int gmtype_cost[TRANS_TYPES];
Zoe Liu27deb382018-03-27 15:13:56 -0700428 int gmparams_cost[REF_FRAMES];
Yue Chenb23d00a2017-07-28 17:01:21 -0700429
Jingning Hanf050fc12018-03-09 14:53:33 -0800430 int nmv_costs[2][MV_VALS];
431 int nmv_costs_hp[2][MV_VALS];
James Zern01a9d702017-08-25 19:09:33 +0000432
Yaowu Xuc27fc142016-08-22 16:08:15 -0700433 int64_t last_time_stamp_seen;
434 int64_t last_end_time_stamp_seen;
435 int64_t first_time_stamp_ever;
436
437 RATE_CONTROL rc;
438 double framerate;
439
440 // NOTE(zoeliu): Any inter frame allows maximum of REF_FRAMES inter
441 // references; Plus the currently coded frame itself, it is needed to allocate
442 // sufficient space to the size of the maximum possible number of frames.
443 int interp_filter_selected[REF_FRAMES + 1][SWITCHABLE];
444
Yaowu Xuf883b422016-08-30 14:01:10 -0700445 struct aom_codec_pkt_list *output_pkt_list;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700446
447 MBGRAPH_FRAME_STATS mbgraph_stats[MAX_LAG_BUFFERS];
448 int mbgraph_n_frames; // number of frames filled in the above
449 int static_mb_pct; // % forced skip mbs by segmentation
450 int ref_frame_flags;
Yunqing Wangf2e7a392017-11-08 00:27:21 -0800451 int ext_ref_frame_flags;
Zoe Liuf452fdf2017-11-02 23:08:12 -0700452 RATE_FACTOR_LEVEL frame_rf_level[FRAME_BUFFERS];
Yaowu Xuc27fc142016-08-22 16:08:15 -0700453
454 SPEED_FEATURES sf;
455
456 unsigned int max_mv_magnitude;
457 int mv_step_param;
458
459 int allow_comp_inter_inter;
Zoe Liu77fb5be2017-11-02 14:36:19 -0700460 int all_one_sided_refs;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700461
Yaowu Xuc27fc142016-08-22 16:08:15 -0700462 uint8_t *segmentation_map;
463
Yaowu Xuc27fc142016-08-22 16:08:15 -0700464 CYCLIC_REFRESH *cyclic_refresh;
465 ActiveMap active_map;
466
467 fractional_mv_step_fp *find_fractional_mv_step;
Yaowu Xuf883b422016-08-30 14:01:10 -0700468 av1_full_search_fn_t full_search_sad; // It is currently unused.
469 av1_diamond_search_fn_t diamond_search_sad;
Rupert Swarbrick93c39e92017-07-12 11:11:02 +0100470 aom_variance_fn_ptr_t fn_ptr[BLOCK_SIZES_ALL];
Yaowu Xuc27fc142016-08-22 16:08:15 -0700471 uint64_t time_receive_data;
472 uint64_t time_compress_data;
473 uint64_t time_pick_lpf;
474 uint64_t time_encode_sb_row;
475
476#if CONFIG_FP_MB_STATS
477 int use_fp_mb_stats;
478#endif
479
480 TWO_PASS twopass;
481
482 YV12_BUFFER_CONFIG alt_ref_buffer;
483
484#if CONFIG_INTERNAL_STATS
485 unsigned int mode_chosen_counts[MAX_MODES];
486
487 int count;
488 uint64_t total_sq_error;
489 uint64_t total_samples;
490 ImageStat psnr;
491
492 double total_blockiness;
493 double worst_blockiness;
494
495 int bytes;
496 double summed_quality;
497 double summed_weights;
498 unsigned int tot_recode_hits;
499 double worst_ssim;
500
501 ImageStat fastssim;
502 ImageStat psnrhvs;
503
504 int b_calculate_blockiness;
505 int b_calculate_consistency;
506
507 double total_inconsistency;
508 double worst_consistency;
509 Ssimv *ssim_vars;
510 Metrics metrics;
511#endif
512 int b_calculate_psnr;
513
514 int droppable;
515
516 int initial_width;
517 int initial_height;
518 int initial_mbs; // Number of MBs in the full-size frame; to be used to
519 // normalize the firstpass stats. This will differ from the
520 // number of MBs in the current frame when the frame is
521 // scaled.
522
Debargha Mukherjeeccb27262017-09-25 14:19:46 -0700523 // When resize is triggered through external control, the desired width/height
524 // are stored here until use in the next frame coded. They are effective only
525 // for
526 // one frame and are reset after use.
527 int resize_pending_width;
528 int resize_pending_height;
529
Yaowu Xuc27fc142016-08-22 16:08:15 -0700530 int frame_flags;
531
532 search_site_config ss_cfg;
533
Yaowu Xuc27fc142016-08-22 16:08:15 -0700534 int multi_arf_allowed;
535 int multi_arf_enabled;
536 int multi_arf_last_grp_enabled;
537
538 TileDataEnc *tile_data;
539 int allocated_tiles; // Keep track of memory allocated for tiles.
540
541 TOKENEXTRA *tile_tok[MAX_TILE_ROWS][MAX_TILE_COLS];
542 unsigned int tok_count[MAX_TILE_ROWS][MAX_TILE_COLS];
543
544 TileBufferEnc tile_buffers[MAX_TILE_ROWS][MAX_TILE_COLS];
545
Yaowu Xuc27fc142016-08-22 16:08:15 -0700546 int resize_state;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700547 int resize_avg_qp;
548 int resize_buffer_underflow;
549 int resize_count;
550
Debargha Mukherjeef2e5bb32018-03-26 14:35:24 -0700551 // Sequence parameters have been transmitted already and locked
552 // or not. Once locked av1_change_config cannot change the seq
553 // parameters.
554 int seq_params_locked;
555
Yaowu Xuc27fc142016-08-22 16:08:15 -0700556 // VARIANCE_AQ segment map refresh
557 int vaq_refresh;
558
559 // Multi-threading
560 int num_workers;
Yaowu Xuf883b422016-08-30 14:01:10 -0700561 AVxWorker *workers;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700562 struct EncWorkerData *tile_thr_data;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700563 int refresh_frame_mask;
564 int existing_fb_idx_to_show;
565 int is_arf_filter_off[MAX_EXT_ARFS + 1];
566 int num_extra_arfs;
567 int arf_map[MAX_EXT_ARFS + 1];
Zoe Liuf271a952017-09-05 15:03:48 -0700568 int arf_pos_in_gf[MAX_EXT_ARFS + 1];
569 int arf_pos_for_ovrly[MAX_EXT_ARFS + 1];
Debargha Mukherjeeb98a7022016-11-15 16:07:12 -0800570 int global_motion_search_done;
Angie Chiangf0fbf9d2017-03-15 15:01:22 -0700571 tran_low_t *tcoeff_buf[MAX_MB_PLANE];
Di Chen53a04f62017-06-23 13:47:56 -0700572 int extra_arf_allowed;
573 int bwd_ref_allowed;
Hui Su85878782017-11-07 14:56:31 -0800574 // A flag to indicate if intrabc is ever used in current frame.
575 int intrabc_used;
Hui Sudfcbfbd2017-11-13 12:05:30 -0800576 int dv_cost[2][MV_VALS];
577 // TODO(huisu@google.com): we can update dv_joint_cost per SB.
578 int dv_joint_cost[MV_JOINTS];
Hui Suad7551e2018-03-14 11:13:31 -0700579 int has_lossless_segment;
Yaowu Xuf883b422016-08-30 14:01:10 -0700580} AV1_COMP;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700581
Yaowu Xuf883b422016-08-30 14:01:10 -0700582void av1_initialize_enc(void);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700583
Yaowu Xuf883b422016-08-30 14:01:10 -0700584struct AV1_COMP *av1_create_compressor(AV1EncoderConfig *oxcf,
585 BufferPool *const pool);
586void av1_remove_compressor(AV1_COMP *cpi);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700587
Yaowu Xuf883b422016-08-30 14:01:10 -0700588void av1_change_config(AV1_COMP *cpi, const AV1EncoderConfig *oxcf);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700589
590// receive a frames worth of data. caller can assume that a copy of this
591// frame is made and not just a copy of the pointer..
James Zern3e2613b2017-03-30 23:14:40 -0700592int av1_receive_raw_frame(AV1_COMP *cpi, aom_enc_frame_flags_t frame_flags,
Yaowu Xuf883b422016-08-30 14:01:10 -0700593 YV12_BUFFER_CONFIG *sd, int64_t time_stamp,
594 int64_t end_time_stamp);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700595
Yaowu Xuf883b422016-08-30 14:01:10 -0700596int av1_get_compressed_data(AV1_COMP *cpi, unsigned int *frame_flags,
597 size_t *size, uint8_t *dest, int64_t *time_stamp,
598 int64_t *time_end, int flush);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700599
Yaowu Xuf883b422016-08-30 14:01:10 -0700600int av1_get_preview_raw_frame(AV1_COMP *cpi, YV12_BUFFER_CONFIG *dest);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700601
Yaowu Xuf883b422016-08-30 14:01:10 -0700602int av1_get_last_show_frame(AV1_COMP *cpi, YV12_BUFFER_CONFIG *frame);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700603
Yaowu Xuf883b422016-08-30 14:01:10 -0700604int av1_use_as_reference(AV1_COMP *cpi, int ref_frame_flags);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700605
Yaowu Xuf883b422016-08-30 14:01:10 -0700606void av1_update_reference(AV1_COMP *cpi, int ref_frame_flags);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700607
Thomas Daede497d1952017-08-08 17:33:06 -0700608int av1_copy_reference_enc(AV1_COMP *cpi, int idx, YV12_BUFFER_CONFIG *sd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700609
Thomas Daede497d1952017-08-08 17:33:06 -0700610int av1_set_reference_enc(AV1_COMP *cpi, int idx, YV12_BUFFER_CONFIG *sd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700611
Yaowu Xuf883b422016-08-30 14:01:10 -0700612int av1_update_entropy(AV1_COMP *cpi, int update);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700613
Yaowu Xuf883b422016-08-30 14:01:10 -0700614int av1_set_active_map(AV1_COMP *cpi, unsigned char *map, int rows, int cols);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700615
Yaowu Xuf883b422016-08-30 14:01:10 -0700616int av1_get_active_map(AV1_COMP *cpi, unsigned char *map, int rows, int cols);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700617
Yaowu Xuf883b422016-08-30 14:01:10 -0700618int av1_set_internal_size(AV1_COMP *cpi, AOM_SCALING horiz_mode,
619 AOM_SCALING vert_mode);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700620
Yaowu Xuf883b422016-08-30 14:01:10 -0700621int av1_get_quantizer(struct AV1_COMP *cpi);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700622
Soo-Chul Han29c46fb2018-03-23 16:02:00 -0400623int av1_convert_sect5obus_to_annexb(uint8_t *buffer, size_t *input_size);
624
Yaowu Xuf883b422016-08-30 14:01:10 -0700625static INLINE int frame_is_kf_gf_arf(const AV1_COMP *cpi) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700626 return frame_is_intra_only(&cpi->common) || cpi->refresh_alt_ref_frame ||
627 (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref);
628}
629
Yaowu Xuf883b422016-08-30 14:01:10 -0700630static INLINE int get_ref_frame_map_idx(const AV1_COMP *cpi,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700631 MV_REFERENCE_FRAME ref_frame) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700632 if (ref_frame >= LAST_FRAME && ref_frame <= LAST3_FRAME)
633 return cpi->lst_fb_idxes[ref_frame - 1];
Yaowu Xuc27fc142016-08-22 16:08:15 -0700634 else if (ref_frame == GOLDEN_FRAME)
635 return cpi->gld_fb_idx;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700636 else if (ref_frame == BWDREF_FRAME)
637 return cpi->bwd_fb_idx;
Zoe Liue9b15e22017-07-19 15:53:01 -0700638 else if (ref_frame == ALTREF2_FRAME)
639 return cpi->alt2_fb_idx;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700640 else
641 return cpi->alt_fb_idx;
642}
643
Urvang Joshi52648442016-10-13 17:27:51 -0700644static INLINE int get_ref_frame_buf_idx(const AV1_COMP *cpi,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700645 MV_REFERENCE_FRAME ref_frame) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700646 const AV1_COMMON *const cm = &cpi->common;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700647 const int map_idx = get_ref_frame_map_idx(cpi, ref_frame);
648 return (map_idx != INVALID_IDX) ? cm->ref_frame_map[map_idx] : INVALID_IDX;
649}
650
Hui Su2d5fd742018-02-21 18:10:37 -0800651// TODO(huisu@google.com, youzhou@microsoft.com): enable hash-me for HBD.
652static INLINE int av1_use_hash_me(const AV1_COMMON *const cm) {
Debargha Mukherjee8112d2f2018-03-01 09:53:11 -0800653 return cm->allow_screen_content_tools;
Hui Su2d5fd742018-02-21 18:10:37 -0800654}
655
656static INLINE hash_table *av1_get_ref_frame_hash_map(
657 const AV1_COMP *cpi, MV_REFERENCE_FRAME ref_frame) {
RogerZhoucc5d35d2017-08-07 22:20:15 -0700658 const AV1_COMMON *const cm = &cpi->common;
659 const int buf_idx = get_ref_frame_buf_idx(cpi, ref_frame);
660 return buf_idx != INVALID_IDX
661 ? &cm->buffer_pool->frame_bufs[buf_idx].hash_table
662 : NULL;
663}
RogerZhoucc5d35d2017-08-07 22:20:15 -0700664
Yaowu Xuc27fc142016-08-22 16:08:15 -0700665static INLINE YV12_BUFFER_CONFIG *get_ref_frame_buffer(
Urvang Joshi52648442016-10-13 17:27:51 -0700666 const AV1_COMP *cpi, MV_REFERENCE_FRAME ref_frame) {
667 const AV1_COMMON *const cm = &cpi->common;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700668 const int buf_idx = get_ref_frame_buf_idx(cpi, ref_frame);
669 return buf_idx != INVALID_IDX ? &cm->buffer_pool->frame_bufs[buf_idx].buf
670 : NULL;
671}
672
Yaowu Xuf883b422016-08-30 14:01:10 -0700673static INLINE int enc_is_ref_frame_buf(AV1_COMP *cpi, RefCntBuffer *frame_buf) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700674 MV_REFERENCE_FRAME ref_frame;
Yaowu Xuf883b422016-08-30 14:01:10 -0700675 AV1_COMMON *const cm = &cpi->common;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700676 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
677 const int buf_idx = get_ref_frame_buf_idx(cpi, ref_frame);
678 if (buf_idx == INVALID_IDX) continue;
679 if (frame_buf == &cm->buffer_pool->frame_bufs[buf_idx]) break;
680 }
681 return (ref_frame <= ALTREF_FRAME);
682}
Yaowu Xuc27fc142016-08-22 16:08:15 -0700683
Yaowu Xue39b3b82017-10-31 16:11:59 -0700684static INLINE unsigned int get_token_alloc(int mb_rows, int mb_cols,
Imdad Sardharwallaaf8e2642018-01-19 11:46:34 +0000685 int sb_size_log2,
686 const int num_planes) {
Rupert Swarbrickce63e832017-10-25 17:54:17 +0100687 // Calculate the maximum number of max superblocks in the image.
Yaowu Xue39b3b82017-10-31 16:11:59 -0700688 const int shift = sb_size_log2 - 4;
689 const int sb_size = 1 << sb_size_log2;
690 const int sb_size_square = sb_size * sb_size;
Rupert Swarbrickce63e832017-10-25 17:54:17 +0100691 const int sb_rows = ALIGN_POWER_OF_TWO(mb_rows, shift) >> shift;
692 const int sb_cols = ALIGN_POWER_OF_TWO(mb_cols, shift) >> shift;
693
Rupert Swarbrickdcb3cff2017-11-09 15:58:33 +0000694 // For transform coefficients, assume planes with no subsampling. We assume
Rupert Swarbrickce63e832017-10-25 17:54:17 +0100695 // up to 1 token per pixel, and then allow a head room of 1 EOSB token per
696 // 4x4 block per plane, plus EOSB_TOKEN per plane.
Rupert Swarbrickdcb3cff2017-11-09 15:58:33 +0000697 const int sb_coeff_toks =
698 num_planes * (sb_size_square + (sb_size_square / 16) + 1);
Rupert Swarbrickce63e832017-10-25 17:54:17 +0100699
700 // For palette coefficients, there can be at most one palette for each 8x8
701 // block. If w, h are the width and height of the block, the palette has at
702 // most 1 + h * w tokens (65 for an 8x8 block) without (see
703 // cost_and_tokenize_map). At most, there can be palettes on two planes.
Yaowu Xue39b3b82017-10-31 16:11:59 -0700704 const int sb_palette_toks = 2 * (1 + 64) * (sb_size_square / 64);
Rupert Swarbrickce63e832017-10-25 17:54:17 +0100705
706 return sb_rows * sb_cols * (sb_coeff_toks + sb_palette_toks);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700707}
708
709// Get the allocated token size for a tile. It does the same calculation as in
710// the frame token allocation.
Rupert Swarbrickdcb3cff2017-11-09 15:58:33 +0000711static INLINE unsigned int allocated_tokens(TileInfo tile, int sb_size_log2,
712 int num_planes) {
Jingning Haneafbd5f2017-03-07 11:18:17 -0800713 int tile_mb_rows = (tile.mi_row_end - tile.mi_row_start + 2) >> 2;
714 int tile_mb_cols = (tile.mi_col_end - tile.mi_col_start + 2) >> 2;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700715
Rupert Swarbrickdcb3cff2017-11-09 15:58:33 +0000716 return get_token_alloc(tile_mb_rows, tile_mb_cols, sb_size_log2, num_planes);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700717}
718
Yaowu Xuf883b422016-08-30 14:01:10 -0700719void av1_apply_encoding_flags(AV1_COMP *cpi, aom_enc_frame_flags_t flags);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700720
Yaowu Xu6da42302017-10-10 14:45:06 -0700721#define ALT_MIN_LAG 3
Yaowu Xuf883b422016-08-30 14:01:10 -0700722static INLINE int is_altref_enabled(const AV1_COMP *const cpi) {
Yaowu Xu6da42302017-10-10 14:45:06 -0700723 return cpi->oxcf.lag_in_frames >= ALT_MIN_LAG && cpi->oxcf.enable_auto_arf;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700724}
725
726// TODO(zoeliu): To set up cpi->oxcf.enable_auto_brf
Yaowu Xuc27fc142016-08-22 16:08:15 -0700727
Urvang Joshi52648442016-10-13 17:27:51 -0700728static INLINE void set_ref_ptrs(const AV1_COMMON *cm, MACROBLOCKD *xd,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700729 MV_REFERENCE_FRAME ref0,
730 MV_REFERENCE_FRAME ref1) {
731 xd->block_refs[0] =
732 &cm->frame_refs[ref0 >= LAST_FRAME ? ref0 - LAST_FRAME : 0];
733 xd->block_refs[1] =
734 &cm->frame_refs[ref1 >= LAST_FRAME ? ref1 - LAST_FRAME : 0];
735}
736
Yaowu Xu4ff59b52017-04-24 12:41:56 -0700737static INLINE int get_chessboard_index(int frame_index) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700738 return frame_index & 0x1;
739}
740
Yaowu Xuf883b422016-08-30 14:01:10 -0700741static INLINE int *cond_cost_list(const struct AV1_COMP *cpi, int *cost_list) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700742 return cpi->sf.mv.subpel_search_method != SUBPEL_TREE ? cost_list : NULL;
743}
744
Yaowu Xuf883b422016-08-30 14:01:10 -0700745void av1_new_framerate(AV1_COMP *cpi, double framerate);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700746
747#define LAYER_IDS_TO_IDX(sl, tl, num_tl) ((sl) * (num_tl) + (tl))
748
749// Update up-sampled reference frame index.
750static INLINE void uref_cnt_fb(EncRefCntBuffer *ubufs, int *uidx,
751 int new_uidx) {
752 const int ref_index = *uidx;
753
754 if (ref_index >= 0 && ubufs[ref_index].ref_count > 0)
755 ubufs[ref_index].ref_count--;
756
757 *uidx = new_uidx;
758 ubufs[new_uidx].ref_count++;
759}
760
Fergus Simpsonfecb2ab2017-04-30 15:49:57 -0700761// Returns 1 if a frame is unscaled and 0 otherwise.
Fergus Simpsond2bcbb52017-05-22 23:15:05 -0700762static INLINE int av1_resize_unscaled(const AV1_COMMON *cm) {
Fergus Simpsond2bcbb52017-05-22 23:15:05 -0700763 return cm->superres_upscaled_width == cm->render_width &&
764 cm->superres_upscaled_height == cm->render_height;
Fergus Simpsonfecb2ab2017-04-30 15:49:57 -0700765}
766
Fergus Simpsond2bcbb52017-05-22 23:15:05 -0700767static INLINE int av1_frame_unscaled(const AV1_COMMON *cm) {
Fergus Simpsond2bcbb52017-05-22 23:15:05 -0700768 return av1_superres_unscaled(cm) && av1_resize_unscaled(cm);
Fergus Simpsonfecb2ab2017-04-30 15:49:57 -0700769}
770
Yaowu Xuc27fc142016-08-22 16:08:15 -0700771#ifdef __cplusplus
772} // extern "C"
773#endif
774
Yaowu Xuf883b422016-08-30 14:01:10 -0700775#endif // AV1_ENCODER_ENCODER_H_