Coverage Report

Created: 2026-04-01 07:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/aom/av1/encoder/block.h
Line
Count
Source
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
12
/*! \file
13
 * Declares various structs used to encode the current partition block.
14
 */
15
#ifndef AOM_AV1_ENCODER_BLOCK_H_
16
#define AOM_AV1_ENCODER_BLOCK_H_
17
18
#include "av1/common/blockd.h"
19
#include "av1/common/entropymv.h"
20
#include "av1/common/entropy.h"
21
#include "av1/common/enums.h"
22
#include "av1/common/mvref_common.h"
23
24
#include "av1/encoder/enc_enums.h"
25
#include "av1/encoder/mcomp_structs.h"
26
#if !CONFIG_REALTIME_ONLY
27
#include "av1/encoder/partition_cnn_weights.h"
28
#endif
29
30
#include "av1/encoder/hash_motion.h"
31
32
#ifdef __cplusplus
33
extern "C" {
34
#endif
35
36
//! Minimum linear dimension of a tpl block
37
#define MIN_TPL_BSIZE_1D 16
38
//! Maximum number of tpl block in a super block
39
#define MAX_TPL_BLK_IN_SB (MAX_SB_SIZE / MIN_TPL_BSIZE_1D)
40
//! Number of txfm hash records kept for the partition block.
41
0
#define RD_RECORD_BUFFER_LEN 8
42
43
/*! Maximum value taken by transform type probabilities */
44
0
#define MAX_TX_TYPE_PROB 1024
45
46
//! Compute color sensitivity index for given plane
47
0
#define COLOR_SENS_IDX(plane) ((plane) - 1)
48
49
//! Enable timer statistics of mode search in non-rd
50
#define COLLECT_NONRD_PICK_MODE_STAT 0
51
52
/*!\cond */
53
#if COLLECT_NONRD_PICK_MODE_STAT
54
#include "aom_ports/aom_timer.h"
55
56
typedef struct _mode_search_stat_nonrd {
57
  int32_t num_blocks[BLOCK_SIZES];
58
  int64_t total_block_times[BLOCK_SIZES];
59
  int32_t num_searches[BLOCK_SIZES][MB_MODE_COUNT];
60
  int32_t num_nonskipped_searches[BLOCK_SIZES][MB_MODE_COUNT];
61
  int64_t search_times[BLOCK_SIZES][MB_MODE_COUNT];
62
  int64_t nonskipped_search_times[BLOCK_SIZES][MB_MODE_COUNT];
63
  int64_t ms_time[BLOCK_SIZES][MB_MODE_COUNT];
64
  int64_t ifs_time[BLOCK_SIZES][MB_MODE_COUNT];
65
  int64_t model_rd_time[BLOCK_SIZES][MB_MODE_COUNT];
66
  int64_t txfm_time[BLOCK_SIZES][MB_MODE_COUNT];
67
  struct aom_usec_timer timer1;
68
  struct aom_usec_timer timer2;
69
  struct aom_usec_timer bsize_timer;
70
} mode_search_stat_nonrd;
71
#endif  // COLLECT_NONRD_PICK_MODE_STAT
72
/*!\endcond */
73
74
/*! \brief Superblock level encoder info
75
 *
76
 * SuperblockEnc stores superblock level information used by the encoder for
77
 * more efficient encoding. Currently this is mostly used to store TPL data
78
 * for the current superblock.
79
 */
80
typedef struct {
81
  //! Maximum partition size for the sb.
82
  BLOCK_SIZE min_partition_size;
83
  //! Minimum partition size for the sb.
84
  BLOCK_SIZE max_partition_size;
85
86
  /*****************************************************************************
87
   * \name TPL Info
88
   *
89
   * Information gathered from tpl_model at tpl block precision for the
90
   * superblock to speed up the encoding process..
91
   ****************************************************************************/
92
  /**@{*/
93
  //! Number of TPL blocks in this superblock.
94
  int tpl_data_count;
95
  //! TPL's estimate of inter cost for each tpl block.
96
  int64_t tpl_inter_cost[MAX_TPL_BLK_IN_SB * MAX_TPL_BLK_IN_SB];
97
  //! TPL's estimate of tpl cost for each tpl block.
98
  int64_t tpl_intra_cost[MAX_TPL_BLK_IN_SB * MAX_TPL_BLK_IN_SB];
99
  //! Motion vectors found by TPL model for each tpl block.
100
  int_mv tpl_mv[MAX_TPL_BLK_IN_SB * MAX_TPL_BLK_IN_SB][INTER_REFS_PER_FRAME];
101
  //! TPL's stride for the arrays in this struct.
102
  int tpl_stride;
103
  /**@}*/
104
} SuperBlockEnc;
105
106
/*! \brief Stores the best performing modes.
107
 */
108
typedef struct {
109
  //! The mbmi used to reconstruct the winner mode.
110
  MB_MODE_INFO mbmi;
111
  //! Rdstats of the winner mode.
112
  RD_STATS rd_cost;
113
  //! Rdcost of the winner mode
114
  int64_t rd;
115
  //! Luma rate of the winner mode.
116
  int rate_y;
117
  //! Chroma rate of the winner mode.
118
  int rate_uv;
119
  //! The color map needed to reconstruct palette mode.
120
  uint8_t color_index_map[MAX_SB_SQUARE];
121
  //! The current winner mode.
122
  THR_MODES mode_index;
123
} WinnerModeStats;
124
125
/*! \brief Each source plane of the current macroblock
126
 *
127
 * This struct also stores the txfm buffers and quantizer settings.
128
 */
129
typedef struct macroblock_plane {
130
  //! Stores source - pred so the txfm can be computed later
131
  int16_t *src_diff;
132
  //! Dequantized coefficients
133
  tran_low_t *dqcoeff;
134
  //! Quantized coefficients
135
  tran_low_t *qcoeff;
136
  //! Transformed coefficients
137
  tran_low_t *coeff;
138
  //! Location of the end of qcoeff (end of block).
139
  uint16_t *eobs;
140
  //! Contexts used to code the transform coefficients.
141
  uint8_t *txb_entropy_ctx;
142
  //! A buffer containing the source frame.
143
  struct buf_2d src;
144
145
  /*! \name Quantizer Settings
146
   *
147
   * \attention These are used/accessed only in the quantization process.
148
   * RDO does not and *must not* depend on any of these values.
149
   * All values below share the coefficient scale/shift used in TX.
150
   */
151
  /**@{*/
152
  //! Quantization step size used by AV1_XFORM_QUANT_FP.
153
  const int16_t *quant_fp_QTX;
154
  //! Offset used for rounding in the quantizer process by AV1_XFORM_QUANT_FP.
155
  const int16_t *round_fp_QTX;
156
  //! Quantization step size used by AV1_XFORM_QUANT_B.
157
  const int16_t *quant_QTX;
158
  //! Offset used for rounding in the quantizer process by AV1_XFORM_QUANT_B.
159
  const int16_t *round_QTX;
160
  //! Scale factor to shift coefficients toward zero. Only used by QUANT_B.
161
  const int16_t *quant_shift_QTX;
162
  //! Size of the quantization bin around 0. Only Used by QUANT_B
163
  const int16_t *zbin_QTX;
164
  //! Dequantizer
165
  const int16_t *dequant_QTX;
166
  /**@}*/
167
} MACROBLOCK_PLANE;
168
169
/*! \brief Costs for encoding the coefficients within a level.
170
 *
171
 * Covers everything including txb_skip, eob, dc_sign,
172
 */
173
typedef struct {
174
  //! Cost to skip txfm for the current txfm block.
175
  int txb_skip_cost[TXB_SKIP_CONTEXTS][2];
176
  /*! \brief Cost for encoding the base_eob of a level.
177
   *
178
   * Decoder uses base_eob to derive the base_level as base_eob := base_eob+1.
179
   */
180
  int base_eob_cost[SIG_COEF_CONTEXTS_EOB][3];
181
  /*! \brief Cost for encoding the base level of a coefficient.
182
   *
183
   * Decoder derives coeff_base as coeff_base := base_eob + 1.
184
   */
185
  int base_cost[SIG_COEF_CONTEXTS][8];
186
  /*! \brief Cost for encoding the last non-zero coefficient.
187
   *
188
   * Eob is derived from eob_extra at the decoder as eob := eob_extra + 1
189
   */
190
  int eob_extra_cost[EOB_COEF_CONTEXTS][2];
191
  //! Cost for encoding the dc_sign
192
  int dc_sign_cost[DC_SIGN_CONTEXTS][2];
193
  //! Cost for encoding an increment to the coefficient
194
  int lps_cost[LEVEL_CONTEXTS][COEFF_BASE_RANGE + 1 + COEFF_BASE_RANGE + 1];
195
} LV_MAP_COEFF_COST;
196
197
/*! \brief Costs for encoding the eob.
198
 */
199
typedef struct {
200
  //! eob_cost.
201
  int eob_cost[2][11];
202
} LV_MAP_EOB_COST;
203
204
/*! \brief Stores the transforms coefficients for the whole superblock.
205
 */
206
typedef struct {
207
  //! The transformed coefficients.
208
  tran_low_t *tcoeff[MAX_MB_PLANE];
209
  //! Where the transformed coefficients end.
210
  uint16_t *eobs[MAX_MB_PLANE];
211
  /*! \brief Transform block entropy contexts.
212
   *
213
   * Each element is used as a bit field.
214
   * - Bits 0~3: txb_skip_ctx
215
   * - Bits 4~5: dc_sign_ctx.
216
   */
217
  uint8_t *entropy_ctx[MAX_MB_PLANE];
218
} CB_COEFF_BUFFER;
219
220
/*! \brief Extended mode info derived from mbmi.
221
 */
222
typedef struct {
223
  // TODO(angiebird): Reduce the buffer size according to sb_type
224
  //! The reference mv list for the current block.
225
  CANDIDATE_MV ref_mv_stack[MODE_CTX_REF_FRAMES][USABLE_REF_MV_STACK_SIZE];
226
  //! The weights used to compute the ref mvs.
227
  uint16_t weight[MODE_CTX_REF_FRAMES][USABLE_REF_MV_STACK_SIZE];
228
  //! Number of ref mvs in the drl.
229
  uint8_t ref_mv_count[MODE_CTX_REF_FRAMES];
230
  //! Global mvs
231
  int_mv global_mvs[REF_FRAMES];
232
  //! Context used to encode the current mode.
233
  int16_t mode_context[MODE_CTX_REF_FRAMES];
234
} MB_MODE_INFO_EXT;
235
236
/*! \brief Stores best extended mode information at frame level.
237
 *
238
 * The frame level in here is used in bitstream preparation stage. The
239
 * information in \ref MB_MODE_INFO_EXT are copied to this struct to save
240
 * memory.
241
 */
242
typedef struct {
243
  //! \copydoc MB_MODE_INFO_EXT::ref_mv_stack
244
  CANDIDATE_MV ref_mv_stack[USABLE_REF_MV_STACK_SIZE];
245
  //! \copydoc MB_MODE_INFO_EXT::weight
246
  uint16_t weight[USABLE_REF_MV_STACK_SIZE];
247
  //! \copydoc MB_MODE_INFO_EXT::ref_mv_count
248
  uint8_t ref_mv_count;
249
  // TODO(Ravi/Remya): Reduce the buffer size of global_mvs
250
  //! \copydoc MB_MODE_INFO_EXT::global_mvs
251
  int_mv global_mvs[REF_FRAMES];
252
  //! \copydoc MB_MODE_INFO_EXT::mode_context
253
  int16_t mode_context;
254
  //! Offset of current coding block's coeff buffer relative to the sb.
255
  uint16_t cb_offset[PLANE_TYPES];
256
} MB_MODE_INFO_EXT_FRAME;
257
258
/*! \brief Inter-mode txfm results for a partition block.
259
 */
260
typedef struct {
261
  //! Txfm size used if the current mode is intra mode.
262
  TX_SIZE tx_size;
263
  //! Txfm sizes used if the current mode is inter mode.
264
  TX_SIZE inter_tx_size[INTER_TX_SIZE_BUF_LEN];
265
  //! Map showing which txfm block skips the txfm process.
266
  uint8_t blk_skip[MAX_MIB_SIZE * MAX_MIB_SIZE];
267
  //! Map showing the txfm types for each block.
268
  uint8_t tx_type_map[MAX_MIB_SIZE * MAX_MIB_SIZE];
269
  //! Rd_stats for the whole partition block.
270
  RD_STATS rd_stats;
271
  //! Hash value of the current record.
272
  uint32_t hash_value;
273
} MB_RD_INFO;
274
275
/*! \brief Hash records of the inter-mode transform results
276
 *
277
 * Hash records of the inter-mode transform results for a whole partition block
278
 * based on the residue. Since this operates on the partition block level, this
279
 * can give us a whole txfm partition tree.
280
 */
281
typedef struct {
282
  /*! Circular buffer that stores the inter-mode txfm results of a partition
283
   *  block.
284
   */
285
  MB_RD_INFO mb_rd_info[RD_RECORD_BUFFER_LEN];
286
  //! Index to insert the newest rd record.
287
  int index_start;
288
  //! Number of info stored in this record.
289
  int num;
290
  //! Hash function
291
  CRC32C crc_calculator;
292
} MB_RD_RECORD;
293
294
//! Number of compound rd stats
295
0
#define MAX_COMP_RD_STATS 64
296
/*! \brief Rdcost stats in compound mode.
297
 */
298
typedef struct {
299
  //! Rate of the compound modes.
300
  int32_t rate[COMPOUND_TYPES];
301
  //! Distortion of the compound modes.
302
  int64_t dist[COMPOUND_TYPES];
303
  //! Estimated rate of the compound modes.
304
  int32_t model_rate[COMPOUND_TYPES];
305
  //! Estimated distortion of the compound modes.
306
  int64_t model_dist[COMPOUND_TYPES];
307
  //! Rate need to send the mask type.
308
  int comp_rs2[COMPOUND_TYPES];
309
  //! Motion vector for each predictor.
310
  int_mv mv[2];
311
  //! Ref frame for each predictor.
312
  MV_REFERENCE_FRAME ref_frames[2];
313
  //! Current prediction mode.
314
  PREDICTION_MODE mode;
315
  //! Current interpolation filter.
316
  int_interpfilters filter;
317
  //! Refmv index in the drl.
318
  int ref_mv_idx;
319
  //! Whether the predictors are GLOBALMV.
320
  int is_global[2];
321
  //! Current parameters for interinter mode.
322
  INTERINTER_COMPOUND_DATA interinter_comp;
323
} COMP_RD_STATS;
324
325
/*! \brief Contains buffers used to speed up rdopt for obmc.
326
 *
327
 * See the comments for calc_target_weighted_pred for details.
328
 */
329
typedef struct {
330
  /*! \brief A new source weighted with the above and left predictors.
331
   *
332
   * Used to efficiently construct multiple obmc predictors during rdopt.
333
   */
334
  int32_t *wsrc;
335
  /*! \brief A new mask constructed from the original horz/vert mask.
336
   *
337
   * \copydetails wsrc
338
   */
339
  int32_t *mask;
340
  /*! \brief Prediction from the up predictor.
341
   *
342
   * Used to build the obmc predictor.
343
   */
344
  uint8_t *above_pred;
345
  /*! \brief Prediction from the up predictor.
346
   *
347
   * \copydetails above_pred
348
   */
349
  uint8_t *left_pred;
350
} OBMCBuffer;
351
352
/*! \brief Contains color maps used in palette mode.
353
 */
354
typedef struct {
355
  //! The best color map found.
356
  uint8_t best_palette_color_map[MAX_PALETTE_SQUARE];
357
  //! A temporary buffer used for k-means clustering.
358
  int16_t kmeans_data_buf[2 * MAX_PALETTE_SQUARE];
359
} PALETTE_BUFFER;
360
361
/*! \brief Contains buffers used by av1_compound_type_rd()
362
 *
363
 * For sizes and alignment of these arrays, refer to
364
 * alloc_compound_type_rd_buffers() function.
365
 */
366
typedef struct {
367
  //! First prediction.
368
  uint8_t *pred0;
369
  //! Second prediction.
370
  uint8_t *pred1;
371
  //! Source - first prediction.
372
  int16_t *residual1;
373
  //! Second prediction - first prediction.
374
  int16_t *diff10;
375
  //! Backup of the best segmentation mask.
376
  uint8_t *tmp_best_mask_buf;
377
} CompoundTypeRdBuffers;
378
379
/*! \brief Holds some parameters related to partitioning schemes in AV1.
380
 */
381
// TODO(chiyotsai@google.com): Consolidate this with SIMPLE_MOTION_DATA_TREE
382
typedef struct {
383
#if !CONFIG_REALTIME_ONLY
384
  // The following 4 parameters are used for cnn-based partitioning on intra
385
  // frame.
386
  /*! \brief Current index on the partition block quad tree.
387
   *
388
   * Used to index into the cnn buffer for partition decision.
389
   */
390
  int quad_tree_idx;
391
  //! Whether the CNN buffer contains valid output.
392
  int cnn_output_valid;
393
  //! A buffer used by our segmentation CNN for intra-frame partitioning.
394
  float cnn_buffer[CNN_OUT_BUF_SIZE];
395
  //! log of the quantization parameter of the ancestor BLOCK_64X64.
396
  float log_q;
397
#endif
398
399
  /*! \brief Variance of the subblocks in the superblock.
400
   *
401
   * This is used by rt mode for variance based partitioning.
402
   * The indices corresponds to the following block sizes:
403
   * -   0    - 128x128
404
   * -  1-2   - 128x64
405
   * -  3-4   -  64x128
406
   * -  5-8   -  64x64
407
   * -  9-16  -  64x32
408
   * - 17-24  -  32x64
409
   * - 25-40  -  32x32
410
   * - 41-104 -  16x16
411
   */
412
  uint8_t variance_low[105];
413
} PartitionSearchInfo;
414
415
/*!\cond */
416
enum {
417
  /**
418
   * Do not prune transform depths.
419
   */
420
  TX_PRUNE_NONE = 0,
421
  /**
422
   * Prune largest transform (depth 0) based on NN model.
423
   */
424
  TX_PRUNE_LARGEST = 1,
425
  /**
426
   * Prune split transforms (depth>=1) based on NN model.
427
   */
428
  TX_PRUNE_SPLIT = 2,
429
} UENUM1BYTE(TX_PRUNE_TYPE);
430
/*!\endcond */
431
432
/*! \brief Defines the parameters used to perform txfm search.
433
 *
434
 * For the most part, this determines how various speed features are used.
435
 */
436
typedef struct {
437
  /*! \brief Whether to limit the intra txfm search type to the default txfm.
438
   *
439
   * This could either be a result of either sequence parameter or speed
440
   * features.
441
   */
442
  int use_default_intra_tx_type;
443
444
  /*! Whether to limit the intra transform search type to the ones in the table
445
   * av1_derived_intra_tx_used_flag[INTRA_MODES].
446
   */
447
  int use_derived_intra_tx_type_set;
448
449
  /*! Probability threshold used for conditionally forcing tx type*/
450
  int default_inter_tx_type_prob_thresh;
451
452
  //! Whether to prune 2d transforms based on 1d transform results.
453
  int prune_2d_txfm_mode;
454
455
  /*! \brief Variable from \ref WinnerModeParams based on current eval mode.
456
   *
457
   * See the documentation for \ref WinnerModeParams for more detail.
458
   */
459
  unsigned int coeff_opt_thresholds[2];
460
  /*! \copydoc coeff_opt_thresholds */
461
  unsigned int tx_domain_dist_threshold;
462
  /*! \copydoc coeff_opt_thresholds */
463
  TX_SIZE_SEARCH_METHOD tx_size_search_method;
464
  /*! \copydoc coeff_opt_thresholds */
465
  unsigned int use_transform_domain_distortion;
466
  /*! \copydoc coeff_opt_thresholds */
467
  unsigned int skip_txfm_level;
468
469
  /*! \brief How to search for the optimal tx_size
470
   *
471
   * If ONLY_4X4, use TX_4X4; if TX_MODE_LARGEST, use the largest tx_size for
472
   * the current partition block; if TX_MODE_SELECT, search through the whole
473
   * tree.
474
   *
475
   * \attention
476
   * Although this looks suspicious similar to a bitstream element, this
477
   * tx_mode_search_type is only used internally by the encoder, and is *not*
478
   * written to the bitstream. It determines what kind of tx_mode would be
479
   * searched. For example, we might set it to TX_MODE_LARGEST to find a good
480
   * candidate, then code it as TX_MODE_SELECT.
481
   */
482
  TX_MODE tx_mode_search_type;
483
484
  /*!
485
   * Determines whether a block can be predicted as transform skip or DC only
486
   * based on residual mean and variance.
487
   * Type 0 : No skip block or DC only block prediction
488
   * Type 1 : Prediction of skip block based on residual mean and variance
489
   * Type 2 : Prediction of skip block or DC only block based on residual mean
490
   * and variance
491
   */
492
  unsigned int predict_dc_level;
493
494
  /*!
495
   * Whether or not we should use the quantization matrix as weights for PSNR
496
   * during RD search.
497
   */
498
  int use_qm_dist_metric;
499
500
  /*!
501
   * Keep track of previous mode evaluation stage type. This will be used to
502
   * reset mb rd hash record when mode evaluation type changes.
503
   */
504
  int mode_eval_type;
505
506
#if !CONFIG_REALTIME_ONLY
507
  //! Indicates the transform depths for which RD evaluation is skipped.
508
  TX_PRUNE_TYPE nn_prune_depths_for_intra_tx;
509
510
  /*! \brief Indicates if NN model should be invoked to prune transform depths.
511
   *
512
   * Used to signal whether NN model should be evaluated to prune the R-D
513
   * evaluation of specific transform depths.
514
   */
515
  bool enable_nn_prune_intra_tx_depths;
516
#endif
517
} TxfmSearchParams;
518
519
/*!\cond */
520
#define MAX_NUM_8X8_TXBS ((MAX_MIB_SIZE >> 1) * (MAX_MIB_SIZE >> 1))
521
#define MAX_NUM_16X16_TXBS ((MAX_MIB_SIZE >> 2) * (MAX_MIB_SIZE >> 2))
522
#define MAX_NUM_32X32_TXBS ((MAX_MIB_SIZE >> 3) * (MAX_MIB_SIZE >> 3))
523
#define MAX_NUM_64X64_TXBS ((MAX_MIB_SIZE >> 4) * (MAX_MIB_SIZE >> 4))
524
/*!\endcond */
525
526
/*! \brief Stores various encoding/search decisions related to txfm search.
527
 *
528
 * This struct contains a cache of previous txfm results, and some buffers for
529
 * the current txfm decision.
530
 */
531
typedef struct {
532
  //! Whether to skip transform and quantization on a partition block level.
533
  uint8_t skip_txfm;
534
535
  /*! \brief Whether to skip transform and quantization on a txfm block level.
536
   *
537
   * Skips transform and quantization on a transform block level inside the
538
   * current partition block. Each element of this array is used as a bit-field.
539
   * So for example, the we are skipping on the luma plane, then the last bit
540
   * would be set to 1.
541
   */
542
  uint8_t blk_skip[MAX_MIB_SIZE * MAX_MIB_SIZE];
543
544
  /*! \brief Transform types inside the partition block
545
   *
546
   * Keeps a record of what kind of transform to use for each of the transform
547
   * block inside the partition block.
548
   * \attention The buffer here is *never* directly used. Instead, this just
549
   * allocates the memory for MACROBLOCKD::tx_type_map during rdopt on the
550
   * partition block. So if we need to save memory, we could move the allocation
551
   * to pick_sb_mode instead.
552
   */
553
  uint8_t tx_type_map_[MAX_MIB_SIZE * MAX_MIB_SIZE];
554
555
  //! Txfm hash records of inter-modes.
556
  MB_RD_RECORD *mb_rd_record;
557
558
  /*! \brief Number of txb splits.
559
   *
560
   * Keep track of how many times we've used split tx partition for transform
561
   * blocks. Somewhat misleadingly, this parameter doesn't actually keep track
562
   * of the count of the current block. Instead, it's a cumulative count across
563
   * of the whole frame. The main usage is that if txb_split_count is zero, then
564
   * we can signal TX_MODE_LARGEST at frame level.
565
   */
566
  // TODO(chiyotsai@google.com): Move this to a more appropriate location such
567
  // as ThreadData.
568
  unsigned int txb_split_count;
569
#if CONFIG_SPEED_STATS
570
  //! For debugging. Used to check how many txfm searches we are doing.
571
  unsigned int tx_search_count;
572
#endif  // CONFIG_SPEED_STATS
573
} TxfmSearchInfo;
574
#undef MAX_NUM_8X8_TXBS
575
#undef MAX_NUM_16X16_TXBS
576
#undef MAX_NUM_32X32_TXBS
577
#undef MAX_NUM_64X64_TXBS
578
579
/*! \brief Holds the entropy costs for various modes sent to the bitstream.
580
 *
581
 * \attention This does not include the costs for mv and transformed
582
 * coefficients.
583
 */
584
typedef struct {
585
  /*****************************************************************************
586
   * \name Partition Costs
587
   ****************************************************************************/
588
  /**@{*/
589
  //! Cost for coding the partition.
590
  int partition_cost[PARTITION_CONTEXTS][EXT_PARTITION_TYPES];
591
  /**@}*/
592
593
  /*****************************************************************************
594
   * \name Intra Costs: General
595
   ****************************************************************************/
596
  /**@{*/
597
  //! Luma mode cost for inter frame.
598
  int mbmode_cost[BLOCK_SIZE_GROUPS][INTRA_MODES];
599
  //! Luma mode cost for intra frame.
600
  int y_mode_costs[INTRA_MODES][INTRA_MODES][INTRA_MODES];
601
  //! Chroma mode cost
602
  int intra_uv_mode_cost[CFL_ALLOWED_TYPES][INTRA_MODES][UV_INTRA_MODES];
603
  //! filter_intra_cost
604
  int filter_intra_cost[BLOCK_SIZES_ALL][2];
605
  //! filter_intra_mode_cost
606
  int filter_intra_mode_cost[FILTER_INTRA_MODES];
607
  //! angle_delta_cost
608
  int angle_delta_cost[DIRECTIONAL_MODES][2 * MAX_ANGLE_DELTA + 1];
609
610
  //! Rate rate associated with each alpha codeword
611
  int cfl_cost[CFL_JOINT_SIGNS][CFL_PRED_PLANES][CFL_ALPHABET_SIZE];
612
  /**@}*/
613
614
  /*****************************************************************************
615
   * \name Intra Costs: Screen Contents
616
   ****************************************************************************/
617
  /**@{*/
618
  //! intrabc_cost
619
  int intrabc_cost[2];
620
621
  //! palette_y_size_cost
622
  int palette_y_size_cost[PALATTE_BSIZE_CTXS][PALETTE_SIZES];
623
  //! palette_uv_size_cost
624
  int palette_uv_size_cost[PALATTE_BSIZE_CTXS][PALETTE_SIZES];
625
  //! palette_y_color_cost
626
  int palette_y_color_cost[PALETTE_SIZES][PALETTE_COLOR_INDEX_CONTEXTS]
627
                          [PALETTE_COLORS];
628
  //! palette_uv_color_cost
629
  int palette_uv_color_cost[PALETTE_SIZES][PALETTE_COLOR_INDEX_CONTEXTS]
630
                           [PALETTE_COLORS];
631
  //! palette_y_mode_cost
632
  int palette_y_mode_cost[PALATTE_BSIZE_CTXS][PALETTE_Y_MODE_CONTEXTS][2];
633
  //! palette_uv_mode_cost
634
  int palette_uv_mode_cost[PALETTE_UV_MODE_CONTEXTS][2];
635
  /**@}*/
636
637
  /*****************************************************************************
638
   * \name Inter Costs: MV Modes
639
   ****************************************************************************/
640
  /**@{*/
641
  //! skip_mode_cost
642
  int skip_mode_cost[SKIP_MODE_CONTEXTS][2];
643
  //! newmv_mode_cost
644
  int newmv_mode_cost[NEWMV_MODE_CONTEXTS][2];
645
  //! zeromv_mode_cost
646
  int zeromv_mode_cost[GLOBALMV_MODE_CONTEXTS][2];
647
  //! refmv_mode_cost
648
  int refmv_mode_cost[REFMV_MODE_CONTEXTS][2];
649
  //! drl_mode_cost0
650
  int drl_mode_cost0[DRL_MODE_CONTEXTS][2];
651
  /**@}*/
652
653
  /*****************************************************************************
654
   * \name Inter Costs: Ref Frame Types
655
   ****************************************************************************/
656
  /**@{*/
657
  //! single_ref_cost
658
  int single_ref_cost[REF_CONTEXTS][SINGLE_REFS - 1][2];
659
  //! comp_inter_cost
660
  int comp_inter_cost[COMP_INTER_CONTEXTS][2];
661
  //! comp_ref_type_cost
662
  int comp_ref_type_cost[COMP_REF_TYPE_CONTEXTS]
663
                        [CDF_SIZE(COMP_REFERENCE_TYPES)];
664
  //! uni_comp_ref_cost
665
  int uni_comp_ref_cost[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1]
666
                       [CDF_SIZE(2)];
667
  /*! \brief Cost for signaling ref_frame[0] in bidir-comp mode
668
   *
669
   * Includes LAST_FRAME, LAST2_FRAME, LAST3_FRAME, and GOLDEN_FRAME.
670
   */
671
  int comp_ref_cost[REF_CONTEXTS][FWD_REFS - 1][2];
672
  /*! \brief Cost for signaling ref_frame[1] in bidir-comp mode
673
   *
674
   * Includes ALTREF_FRAME, ALTREF2_FRAME, and BWDREF_FRAME.
675
   */
676
  int comp_bwdref_cost[REF_CONTEXTS][BWD_REFS - 1][2];
677
  /**@}*/
678
679
  /*****************************************************************************
680
   * \name Inter Costs: Compound Types
681
   ****************************************************************************/
682
  /**@{*/
683
  //! intra_inter_cost
684
  int intra_inter_cost[INTRA_INTER_CONTEXTS][2];
685
  //! inter_compound_mode_cost
686
  int inter_compound_mode_cost[INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES];
687
  //! compound_type_cost
688
  int compound_type_cost[BLOCK_SIZES_ALL][MASKED_COMPOUND_TYPES];
689
  //! wedge_idx_cost
690
  int wedge_idx_cost[BLOCK_SIZES_ALL][16];
691
  //! interintra_cost
692
  int interintra_cost[BLOCK_SIZE_GROUPS][2];
693
  //! wedge_interintra_cost
694
  int wedge_interintra_cost[BLOCK_SIZES_ALL][2];
695
  //! interintra_mode_cost
696
  int interintra_mode_cost[BLOCK_SIZE_GROUPS][INTERINTRA_MODES];
697
  /**@}*/
698
699
  /*****************************************************************************
700
   * \name Inter Costs: Compound Masks
701
   ****************************************************************************/
702
  /**@{*/
703
  //! comp_idx_cost
704
  int comp_idx_cost[COMP_INDEX_CONTEXTS][2];
705
  //! comp_group_idx_cost
706
  int comp_group_idx_cost[COMP_GROUP_IDX_CONTEXTS][2];
707
  /**@}*/
708
709
  /*****************************************************************************
710
   * \name Inter Costs: Motion Modes/Filters
711
   ****************************************************************************/
712
  /**@{*/
713
  //! motion_mode_cost
714
  int motion_mode_cost[BLOCK_SIZES_ALL][MOTION_MODES];
715
  //! motion_mode_cost1
716
  int motion_mode_cost1[BLOCK_SIZES_ALL][2];
717
  //! switchable_interp_costs
718
  int switchable_interp_costs[SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS];
719
  /**@}*/
720
721
  /*****************************************************************************
722
   * \name Txfm Mode Costs
723
   ****************************************************************************/
724
  /**@{*/
725
  //! skip_txfm_cost
726
  int skip_txfm_cost[SKIP_CONTEXTS][2];
727
  //! tx_size_cost
728
  int tx_size_cost[TX_SIZES - 1][TX_SIZE_CONTEXTS][TX_SIZES];
729
  //! txfm_partition_cost
730
  int txfm_partition_cost[TXFM_PARTITION_CONTEXTS][2];
731
  //! inter_tx_type_costs
732
  int inter_tx_type_costs[EXT_TX_SETS_INTER][EXT_TX_SIZES][TX_TYPES];
733
  //! intra_tx_type_costs
734
  int intra_tx_type_costs[EXT_TX_SETS_INTRA][EXT_TX_SIZES][INTRA_MODES]
735
                         [TX_TYPES];
736
  /**@}*/
737
738
  /*****************************************************************************
739
   * \name Restoration Mode Costs
740
   ****************************************************************************/
741
  /**@{*/
742
  //! switchable_restore_cost
743
  int switchable_restore_cost[RESTORE_SWITCHABLE_TYPES];
744
  //! wiener_restore_cost
745
  int wiener_restore_cost[2];
746
  //! sgrproj_restore_cost
747
  int sgrproj_restore_cost[2];
748
  /**@}*/
749
750
  /*****************************************************************************
751
   * \name Segmentation Mode Costs
752
   ****************************************************************************/
753
  /**@{*/
754
  //! tmp_pred_cost
755
  int tmp_pred_cost[SEG_TEMPORAL_PRED_CTXS][2];
756
  //! spatial_pred_cost
757
  int spatial_pred_cost[SPATIAL_PREDICTION_PROBS][MAX_SEGMENTS];
758
  /**@}*/
759
} ModeCosts;
760
761
/*! \brief Holds mv costs for encoding and motion search.
762
 */
763
typedef struct {
764
  /*****************************************************************************
765
   * \name Encoding Costs
766
   * Here are the entropy costs needed to encode a given mv.
767
   * \ref nmv_cost_alloc and \ref nmv_cost_hp_alloc are two arrays that holds
768
   * the memory for holding the mv cost. But since the motion vectors can be
769
   * negative, we shift them to the middle and store the resulting pointer in
770
   * \ref nmv_cost and \ref nmv_cost_hp for easier referencing. Finally, \ref
771
   * mv_cost_stack points to the \ref nmv_cost with the mv precision we are
772
   * currently working with. In essence, only \ref mv_cost_stack is needed for
773
   * motion search, the other can be considered private.
774
   ****************************************************************************/
775
  /**@{*/
776
  //! Costs for coding the zero components.
777
  int nmv_joint_cost[MV_JOINTS];
778
779
  //! Allocates memory for 1/4-pel motion vector costs.
780
  int nmv_cost_alloc[2][MV_VALS];
781
  //! Allocates memory for 1/8-pel motion vector costs.
782
  int nmv_cost_hp_alloc[2][MV_VALS];
783
  //! Points to the middle of \ref nmv_cost_alloc
784
  int *nmv_cost[2];
785
  //! Points to the middle of \ref nmv_cost_hp_alloc
786
  int *nmv_cost_hp[2];
787
  //! Points to the nmv_cost_hp in use.
788
  int **mv_cost_stack;
789
  /**@}*/
790
} MvCosts;
791
792
/*! \brief Holds mv costs for intrabc.
793
 */
794
typedef struct {
795
  /*! Costs for coding the joint mv. */
796
  int joint_mv[MV_JOINTS];
797
798
  /*! \brief Cost of transmitting the actual motion vector.
799
   *  dv_costs_alloc[0][i] is the cost of motion vector with horizontal
800
   * component (mv_row) equal to i - MV_MAX. dv_costs_alloc[1][i] is the cost of
801
   * motion vector with vertical component (mv_col) equal to i - MV_MAX.
802
   */
803
  int dv_costs_alloc[2][MV_VALS];
804
805
  /*! Points to the middle of \ref dv_costs_alloc. */
806
  int *dv_costs[2];
807
} IntraBCMVCosts;
808
809
/*! \brief Holds the costs needed to encode the coefficients
810
 */
811
typedef struct {
812
  //! Costs for coding the coefficients.
813
  LV_MAP_COEFF_COST coeff_costs[TX_SIZES][PLANE_TYPES];
814
  //! Costs for coding the eobs.
815
  LV_MAP_EOB_COST eob_costs[7][2];
816
} CoeffCosts;
817
818
/*!\cond */
819
// 4: NEAREST, NEW, NEAR, GLOBAL
820
#define SINGLE_REF_MODES ((REF_FRAMES - 1) * 4)
821
/*!\endcond */
822
struct inter_modes_info;
823
824
/*! \brief Holds the motion samples for warp motion model estimation
825
 */
826
typedef struct {
827
  //! Number of samples.
828
  int num;
829
  //! Sample locations in current frame.
830
  int pts[16];
831
  //! Sample location in the reference frame.
832
  int pts_inref[16];
833
} WARP_SAMPLE_INFO;
834
835
/*!\cond */
836
typedef enum {
837
  kZeroSad = 0,
838
  kVeryLowSad = 1,
839
  kLowSad = 2,
840
  kMedSad = 3,
841
  kHighSad = 4
842
} SOURCE_SAD;
843
844
typedef struct {
845
  //! SAD levels in non-rd path
846
  SOURCE_SAD source_sad_nonrd;
847
  //! SAD levels in rd-path for var-based part qindex thresholds
848
  SOURCE_SAD source_sad_rd;
849
  int lighting_change;
850
  int low_sumdiff;
851
} CONTENT_STATE_SB;
852
853
// Structure to hold pixel level gradient info.
854
typedef struct {
855
  uint16_t abs_dx_abs_dy_sum;
856
  int8_t hist_bin_idx;
857
  bool is_dx_zero;
858
} PixelLevelGradientInfo;
859
860
// Structure to hold the variance and log(1 + variance) for 4x4 sub-blocks.
861
typedef struct {
862
  double log_var;
863
  int var;
864
} Block4x4VarInfo;
865
866
#ifndef NDEBUG
867
typedef struct SetOffsetsLoc {
868
  int mi_row;
869
  int mi_col;
870
  BLOCK_SIZE bsize;
871
} SetOffsetsLoc;
872
#endif  // NDEBUG
873
874
/*!\endcond */
875
876
//! Maximum number of estimated RD Cost records for compound average.
877
0
#define TOP_COMP_AVG_EST_RD_COUNT 2
878
879
/*! \brief Encoder's parameters related to the current coding block.
880
 *
881
 * This struct contains most of the information the encoder needs to encode the
882
 * current coding block. This includes the src and pred buffer, a copy of the
883
 * decoder's view of the current block, the txfm coefficients. This struct also
884
 * contains various buffers and data used to speed up the encoding process.
885
 */
886
typedef struct macroblock {
887
  /*****************************************************************************
888
   * \name Source, Buffers and Decoder
889
   ****************************************************************************/
890
  /**@{*/
891
  /*! \brief Each of the encoding plane.
892
   *
893
   * An array holding the src buffer for each of plane of the current block. It
894
   * also contains the txfm and quantized txfm coefficients.
895
   */
896
  struct macroblock_plane plane[MAX_MB_PLANE];
897
898
  /*! \brief Decoder's view of current coding block.
899
   *
900
   * Contains the encoder's copy of what the decoder sees in the current block.
901
   * Most importantly, this struct contains pointers to mbmi that is used in
902
   * final bitstream packing.
903
   */
904
  MACROBLOCKD e_mbd;
905
906
  /*! \brief Derived coding information.
907
   *
908
   * Contains extra information not transmitted in the bitstream but are
909
   * derived. For example, this contains the stack of ref_mvs.
910
   */
911
  MB_MODE_INFO_EXT mbmi_ext;
912
913
  /*! \brief Finalized mbmi_ext for the whole frame.
914
   *
915
   * Contains the finalized info in mbmi_ext that gets used at the frame level
916
   * for bitstream packing.
917
   */
918
  MB_MODE_INFO_EXT_FRAME *mbmi_ext_frame;
919
920
  //! Entropy context for the current row.
921
  FRAME_CONTEXT *row_ctx;
922
  /*! \brief Entropy context for the current tile.
923
   *
924
   * This context will be used to update color_map_cdf pointer which would be
925
   * used during pack bitstream. For single thread and tile-multithreading case
926
   * this pointer will be same as xd->tile_ctx, but for the case of row-mt:
927
   * xd->tile_ctx will point to a temporary context while tile_pb_ctx will point
928
   * to the accurate tile context.
929
   */
930
  FRAME_CONTEXT *tile_pb_ctx;
931
932
  /*! \brief Buffer of transformed coefficients
933
   *
934
   * Points to cb_coef_buff in the AV1_COMP struct, which contains the finalized
935
   * coefficients. This is here to conveniently copy the best coefficients to
936
   * frame level for bitstream packing. Since CB_COEFF_BUFFER is allocated on a
937
   * superblock level, we need to combine it with cb_offset to get the proper
938
   * position for the current coding block.
939
   */
940
  CB_COEFF_BUFFER *cb_coef_buff;
941
  //! Offset of current coding block's coeff buffer relative to the sb.
942
  uint16_t cb_offset[PLANE_TYPES];
943
944
  //! Modified source and masks used for fast OBMC search.
945
  OBMCBuffer obmc_buffer;
946
  //! Buffer to store the best palette map.
947
  PALETTE_BUFFER *palette_buffer;
948
  //! Buffer used for compound_type_rd().
949
  CompoundTypeRdBuffers comp_rd_buffer;
950
  //! Buffer to store convolution during averaging process in compound mode.
951
  CONV_BUF_TYPE *tmp_conv_dst;
952
953
  /*! \brief Temporary buffer to hold prediction.
954
   *
955
   * Points to a buffer that is used to hold temporary prediction results. This
956
   * is used in two ways:
957
   * - This is a temporary buffer used to ping-pong the prediction in
958
   *   handle_inter_mode.
959
   * - xd->tmp_obmc_bufs also points to this buffer, and is used in ombc
960
   *   prediction.
961
   */
962
  uint8_t *tmp_pred_bufs[2];
963
964
  /*!
965
   *  Buffer used for upsampled prediction.
966
   */
967
  uint8_t *upsample_pred;
968
  /**@}*/
969
970
  /*****************************************************************************
971
   * \name Rdopt Costs
972
   ****************************************************************************/
973
  /**@{*/
974
  /*! \brief Quantization index for the current partition block.
975
   *
976
   * This is used to as the index to find quantization parameter for luma and
977
   * chroma transformed coefficients.
978
   */
979
  int qindex;
980
981
  /*! \brief Difference between frame-level qindex and current qindex.
982
   *
983
   *  This is used to track whether a non-zero delta for qindex is used at least
984
   *  once in the current frame.
985
   */
986
  int delta_qindex;
987
988
  /*! \brief Difference between frame-level qindex and qindex used to
989
   * compute rdmult (lambda).
990
   *
991
   * rdmult_delta_qindex is assigned the same as delta_qindex before qp sweep.
992
   * During qp sweep, delta_qindex is changed and used to calculate the actual
993
   * quant params, while rdmult_delta_qindex remains the same, and is used to
994
   * calculate the rdmult in "set_deltaq_rdmult".
995
   */
996
  int rdmult_delta_qindex;
997
998
  /*! \brief Current qindex (before being adjusted by delta_q_res) used to
999
   * derive rdmult_delta_qindex.
1000
   */
1001
  int rdmult_cur_qindex;
1002
1003
  /*! \brief Rate-distortion multiplier.
1004
   *
1005
   * The rd multiplier used to determine the rate-distortion trade-off. This is
1006
   * roughly proportional to the inverse of q-index for a given frame, but this
1007
   * can be manipulated for better rate-control. For example, in tune_ssim
1008
   * mode, this is scaled by a factor related to the variance of the current
1009
   * block.
1010
   */
1011
  int rdmult;
1012
1013
  //! Intra only, per sb rd adjustment.
1014
  int intra_sb_rdmult_modifier;
1015
1016
  //! Superblock level distortion propagation factor.
1017
  double rb;
1018
1019
  //! Energy in the current source coding block. Used to calculate \ref rdmult
1020
  int mb_energy;
1021
  //! Energy in the current source superblock. Used to calculate \ref rdmult
1022
  int sb_energy_level;
1023
1024
  //! The rate needed to signal a mode to the bitstream.
1025
  ModeCosts mode_costs;
1026
1027
  //! The rate needed to encode a new motion vector to the bitstream and some
1028
  //! multipliers for motion search.
1029
  MvCosts *mv_costs;
1030
1031
  /*! The rate needed to encode a new motion vector to the bitstream in intrabc
1032
   *  mode.
1033
   */
1034
  IntraBCMVCosts *dv_costs;
1035
1036
  //! The rate needed to signal the txfm coefficients to the bitstream.
1037
  CoeffCosts coeff_costs;
1038
  /**@}*/
1039
1040
  /*****************************************************************************
1041
   * \name Rate to Distortion Multipliers
1042
   ****************************************************************************/
1043
  /**@{*/
1044
  //! A multiplier that converts mv cost to l2 error.
1045
  int errorperbit;
1046
  //! A multiplier that converts mv cost to l1 error.
1047
  int sadperbit;
1048
  /**@}*/
1049
1050
  /******************************************************************************
1051
   * \name Segmentation
1052
   *****************************************************************************/
1053
  /**@{*/
1054
  /*! \brief Skip mode for the segment
1055
   *
1056
   * A syntax element of the segmentation mode. In skip_block mode, all mvs are
1057
   * set 0 and all txfms are skipped.
1058
   */
1059
  int seg_skip_block;
1060
1061
  /*! \brief Number of segment 1 blocks
1062
   * Actual number of (4x4) blocks that were applied delta-q,
1063
   * for segment 1.
1064
   */
1065
  int actual_num_seg1_blocks;
1066
1067
  /*!\brief Number of segment 2 blocks
1068
   * Actual number of (4x4) blocks that were applied delta-q,
1069
   * for segment 2.
1070
   */
1071
  int actual_num_seg2_blocks;
1072
1073
  /*!\brief Number of zero motion vectors
1074
   */
1075
  int cnt_zeromv;
1076
1077
  /*!\brief Flag to force zeromv-skip at superblock level, for nonrd path.
1078
   *
1079
   * 0/1 imply zeromv-skip is disabled/enabled. 2 implies that the blocks
1080
   * in the superblock may be marked as zeromv-skip at block level.
1081
   */
1082
  int force_zeromv_skip_for_sb;
1083
1084
  /*!\brief Flag to force zeromv-skip at block level, for nonrd path.
1085
   */
1086
  int force_zeromv_skip_for_blk;
1087
1088
  /*! \brief Previous segment id for which qmatrices were updated.
1089
   * This is used to bypass setting of qmatrices if no change in qindex.
1090
   */
1091
  int prev_segment_id;
1092
  /**@}*/
1093
1094
  /*****************************************************************************
1095
   * \name Superblock
1096
   ****************************************************************************/
1097
  /**@{*/
1098
  //! Information on a whole superblock level.
1099
  // TODO(chiyotsai@google.com): Refactor this out of macroblock
1100
  SuperBlockEnc sb_enc;
1101
1102
  /*! \brief Characteristics of the current superblock.
1103
   *
1104
   *  Characteristics like whether the block has high sad, low sad, etc. This is
1105
   *  only used by av1 realtime mode.
1106
   */
1107
  CONTENT_STATE_SB content_state_sb;
1108
  /**@}*/
1109
1110
  /*****************************************************************************
1111
   * \name Reference Frame Search
1112
   ****************************************************************************/
1113
  /**@{*/
1114
  /*! \brief Sum absolute distortion of the predicted mv for each ref frame.
1115
   *
1116
   * This is used to measure how viable a reference frame is.
1117
   */
1118
  int pred_mv_sad[REF_FRAMES];
1119
  /*! \brief The minimum of \ref pred_mv_sad.
1120
   *
1121
   * Index 0 stores the minimum \ref pred_mv_sad across past reference frames.
1122
   * Index 1 stores the minimum \ref pred_mv_sad across future reference frames.
1123
   */
1124
  int best_pred_mv_sad[2];
1125
  //! The sad of the 1st mv ref (nearest).
1126
  int pred_mv0_sad[REF_FRAMES];
1127
  //! The sad of the 2nd mv ref (near).
1128
  int pred_mv1_sad[REF_FRAMES];
1129
1130
  /*! \brief Disables certain ref frame pruning based on tpl.
1131
   *
1132
   * Determines whether a given ref frame is "good" based on data from the TPL
1133
   * model. If so, this stops selective_ref frame from pruning the given ref
1134
   * frame at block level.
1135
   */
1136
  uint8_t tpl_keep_ref_frame[REF_FRAMES];
1137
1138
  /*! \brief Warp motion samples buffer.
1139
   *
1140
   * Store the motion samples used for warp motion.
1141
   */
1142
  WARP_SAMPLE_INFO warp_sample_info[REF_FRAMES];
1143
1144
  /*! \brief Reference frames picked by the square subblocks in a superblock.
1145
   *
1146
   * Keeps track of ref frames that are selected by square partition blocks
1147
   * within a superblock, in MI resolution. They can be used to prune ref frames
1148
   * for rectangular blocks.
1149
   */
1150
  int picked_ref_frames_mask[MAX_MIB_SIZE * MAX_MIB_SIZE];
1151
1152
  /*! \brief Prune ref frames in real-time mode.
1153
   *
1154
   * Determines whether to prune reference frames in real-time mode. For the
1155
   * most part, this is the same as nonrd_prune_ref_frame_search in
1156
   * cpi->sf.rt_sf.nonrd_prune_ref_frame_search, but this can be selectively
1157
   * turned off if the only frame available is GOLDEN_FRAME.
1158
   */
1159
  int nonrd_prune_ref_frame_search;
1160
  /**@}*/
1161
1162
  /*****************************************************************************
1163
   * \name Partition Search
1164
   ****************************************************************************/
1165
  /**@{*/
1166
  //! Stores some partition-search related buffers.
1167
  PartitionSearchInfo part_search_info;
1168
1169
  /*! \brief Whether to disable some features to force a mode in current block.
1170
   *
1171
   * In some cases, our speed features can be overly aggressive and remove all
1172
   * modes search in the superblock. When this happens, we set
1173
   * must_find_valid_partition to 1 to reduce the number of speed features, and
1174
   * recode the superblock again.
1175
   */
1176
  int must_find_valid_partition;
1177
  /**@}*/
1178
1179
  /*****************************************************************************
1180
   * \name Prediction Mode Search
1181
   ****************************************************************************/
1182
  /**@{*/
1183
  /*! \brief Inter skip mode.
1184
   *
1185
   * Skip mode tries to use the closest forward and backward references for
1186
   * inter prediction. Skip here means to skip transmitting the reference
1187
   * frames, not to be confused with skip_txfm.
1188
   */
1189
  int skip_mode;
1190
1191
  /*! \brief Factors used for rd-thresholding.
1192
   *
1193
   * Determines a rd threshold to determine whether to continue searching the
1194
   * current mode. If the current best rd is already <= threshold, then we skip
1195
   * the current mode.
1196
   */
1197
  int thresh_freq_fact[BLOCK_SIZES_ALL][MAX_MODES];
1198
1199
  /*! \brief Tracks the winner modes in the current coding block.
1200
   *
1201
   * Winner mode is a two-pass strategy to find the best prediction mode. In the
1202
   * first pass, we search the prediction modes with a limited set of txfm
1203
   * options, and keep the top modes. These modes are called the winner modes.
1204
   * In the second pass, we retry the winner modes with more thorough txfm
1205
   * options.
1206
   */
1207
  WinnerModeStats *winner_mode_stats;
1208
  //! Tracks how many winner modes there are.
1209
  int winner_mode_count;
1210
1211
  /*! \brief The model used for rd-estimation to avoid txfm
1212
   *
1213
   * These are for inter_mode_rd_model_estimation, which is another two pass
1214
   * approach. In this speed feature, we collect data in the first couple frames
1215
   * to build an rd model to estimate the rdcost of a prediction model based on
1216
   * the residue error. Once enough data is collected, this speed feature uses
1217
   * the estimated rdcost to find the most performant prediction mode. Then we
1218
   * follow up with a second pass find the best transform for the mode.
1219
   * Determines if one would go with reduced complexity transform block
1220
   * search model to select prediction modes, or full complexity model
1221
   * to select transform kernel.
1222
   */
1223
  TXFM_RD_MODEL rd_model;
1224
1225
  /*! \brief Stores the inter mode information needed to build an rd model.
1226
   *
1227
   * These are for inter_mode_rd_model_estimation, which is another two pass
1228
   * approach. In this speed feature, we collect data in the first couple frames
1229
   * to build an rd model to estimate the rdcost of a prediction model based on
1230
   * the residue error. Once enough data is collected, this speed feature uses
1231
   * the estimated rdcost to find the most performant prediction mode. Then we
1232
   * follow up with a second pass find the best transform for the mode.
1233
   */
1234
  // TODO(any): try to consolidate this speed feature with winner mode
1235
  // processing.
1236
  struct inter_modes_info *inter_modes_info;
1237
1238
  //! How to blend the compound predictions.
1239
  uint8_t compound_idx;
1240
1241
  //! A caches of results of compound type search so they can be reused later.
1242
  COMP_RD_STATS comp_rd_stats[MAX_COMP_RD_STATS];
1243
  //! The idx for the latest compound mode in the cache \ref comp_rd_stats.
1244
  int comp_rd_stats_idx;
1245
1246
  /*! \brief Whether to recompute the luma prediction.
1247
   *
1248
   * In interpolation search, we can usually skip recalculating the luma
1249
   * prediction because it is already calculated by a previous predictor. This
1250
   * flag signifies that some modes might have been skipped, so we need to
1251
   * rebuild the prediction.
1252
   */
1253
  int recalc_luma_mc_data;
1254
1255
  /*! \brief Data structure to speed up intrabc search.
1256
   *
1257
   * Contains the hash table, hash function, and buffer used for intrabc.
1258
   */
1259
  IntraBCHashInfo intrabc_hash_info;
1260
1261
  /*! \brief Whether to reuse the mode stored in mb_mode_cache. */
1262
  int use_mb_mode_cache;
1263
  /*! \brief The mode to reuse during \ref av1_rd_pick_intra_mode_sb and
1264
   *  \ref av1_rd_pick_inter_mode. */
1265
  const MB_MODE_INFO *mb_mode_cache;
1266
  /*! \brief Pointer to the buffer which caches gradient information.
1267
   *
1268
   * Pointer to the array of structures to store gradient information of each
1269
   * pixel in a superblock. The buffer constitutes of MAX_SB_SQUARE pixel level
1270
   * structures for each of the plane types (PLANE_TYPE_Y and PLANE_TYPE_UV).
1271
   */
1272
  PixelLevelGradientInfo *pixel_gradient_info;
1273
  /*! \brief Flags indicating the availability of cached gradient info. */
1274
  bool is_sb_gradient_cached[PLANE_TYPES];
1275
1276
  /*! \brief Flag to reuse predicted samples of inter block. */
1277
  bool reuse_inter_pred;
1278
  /**@}*/
1279
1280
  /*****************************************************************************
1281
   * \name MV Search
1282
   ****************************************************************************/
1283
  /**@{*/
1284
  /*! \brief Context used to determine the initial step size in motion search.
1285
   *
1286
   * This context is defined as the \f$l_\inf\f$ norm of the best ref_mvs for
1287
   * each frame.
1288
   */
1289
  unsigned int max_mv_context[REF_FRAMES];
1290
1291
  /*! \brief Limit for the range of motion vectors.
1292
   *
1293
   * These define limits to motion vector components to prevent them from
1294
   * extending outside the UMV borders
1295
   */
1296
  FullMvLimits mv_limits;
1297
1298
  /*! \brief Buffer for storing the search site config.
1299
   *
1300
   * When resize mode or super resolution mode is on, the stride of the
1301
   * reference frame does not always match what's specified in \ref
1302
   * MotionVectorSearchParams::search_site_cfg. When his happens, we update the
1303
   * search_sine_config buffer here and use it for motion search.
1304
   */
1305
  search_site_config search_site_cfg_buf[NUM_DISTINCT_SEARCH_METHODS];
1306
  /**@}*/
1307
1308
  /*****************************************************************************
1309
   * \name Txfm Search
1310
   ****************************************************************************/
1311
  /**@{*/
1312
  /*! \brief Parameters that control how motion search is done.
1313
   *
1314
   * Stores various txfm search related parameters such as txfm_type, txfm_size,
1315
   * trellis eob search, etc.
1316
   */
1317
  TxfmSearchParams txfm_search_params;
1318
1319
  /*! \brief Results of the txfm searches that have been done.
1320
   *
1321
   * Caches old txfm search results and keeps the current txfm decisions to
1322
   * facilitate rdopt.
1323
   */
1324
  TxfmSearchInfo txfm_search_info;
1325
1326
  /*! \brief Whether there is a strong color activity.
1327
   *
1328
   * Used in REALTIME coding mode to enhance the visual quality at the boundary
1329
   * of moving color objects.
1330
   */
1331
  uint8_t color_sensitivity_sb[MAX_MB_PLANE - 1];
1332
  //! Color sensitivity flag for the superblock for golden reference.
1333
  uint8_t color_sensitivity_sb_g[MAX_MB_PLANE - 1];
1334
  //! Color sensitivity flag for the superblock for altref reference.
1335
  uint8_t color_sensitivity_sb_alt[MAX_MB_PLANE - 1];
1336
  //! Color sensitivity flag for the coding block.
1337
  uint8_t color_sensitivity[MAX_MB_PLANE - 1];
1338
  //! Coding block distortion value for uv/color, minimum over the inter modes.
1339
  int64_t min_dist_inter_uv;
1340
1341
  //! Threshold on the number of colors for testing palette mode.
1342
  int color_palette_thresh;
1343
1344
  //! Used in REALTIME coding mode: flag to indicate if the color_sensitivity
1345
  // should be checked at the coding block level.
1346
  int force_color_check_block_level;
1347
1348
  //! The buffer used by search_tx_type() to swap dqcoeff in macroblockd_plane
1349
  // so we can keep dqcoeff of the best tx_type.
1350
  tran_low_t *dqcoeff_buf;
1351
  /**@}*/
1352
1353
  /*****************************************************************************
1354
   * \name Misc
1355
   ****************************************************************************/
1356
  /**@{*/
1357
  //! Variance of the source frame.
1358
  unsigned int source_variance;
1359
  //! Flag to indicate coding block is zero sad.
1360
  int block_is_zero_sad;
1361
  //! Flag to indicate superblock ME in variance partition is determined to be
1362
  // good/reliable, and so the superblock MV will be tested in the
1363
  // nonrd_pickmode. This is only used for LAST_FRAME.
1364
  int sb_me_partition;
1365
  //! Flag to indicate to test the superblock MV for the coding block in the
1366
  // nonrd_pickmode.
1367
  int sb_me_block;
1368
  //! Counter for superblock selected column scroll.
1369
  int sb_col_scroll;
1370
  //! Counter for superblock selected row scroll.
1371
  int sb_row_scroll;
1372
  //! Motion vector from superblock MV derived from int_pro_motion() in
1373
  // the variance_partitioning.
1374
  int_mv sb_me_mv;
1375
  //! Flag to indicate if a fixed partition should be used, only if the
1376
  // speed feature rt_sf->use_fast_fixed_part is enabled.
1377
  int sb_force_fixed_part;
1378
  //! SSE of the current predictor.
1379
  unsigned int pred_sse[REF_FRAMES];
1380
  //! Prediction for ML based partition.
1381
#if CONFIG_RT_ML_PARTITIONING
1382
  DECLARE_ALIGNED(16, uint8_t, est_pred[128 * 128]);
1383
#endif
1384
  /**@}*/
1385
1386
  /*! \brief NONE partition evaluated for merge.
1387
   *
1388
   * In variance based partitioning scheme, NONE & SPLIT partitions are
1389
   * evaluated to check the SPLIT can be merged as NONE. This flag signifies the
1390
   * partition is evaluated in the scheme.
1391
   */
1392
  int try_merge_partition;
1393
1394
  /*! \brief Pointer to buffer which caches sub-block variances in a superblock.
1395
   *
1396
   *  Pointer to the array of structures to store source variance information of
1397
   *  each 4x4 sub-block in a superblock. Block4x4VarInfo structure is used to
1398
   *  store source variance and log of source variance of each 4x4 sub-block.
1399
   */
1400
  Block4x4VarInfo *src_var_info_of_4x4_sub_blocks;
1401
#ifndef NDEBUG
1402
  /*! \brief A hash to make sure av1_set_offsets is called */
1403
  SetOffsetsLoc last_set_offsets_loc;
1404
#endif  // NDEBUG
1405
1406
#if COLLECT_NONRD_PICK_MODE_STAT
1407
  mode_search_stat_nonrd ms_stat_nonrd;
1408
#endif  // COLLECT_NONRD_PICK_MODE_STAT
1409
1410
  /*!\brief Number of pixels in current thread that choose palette mode in the
1411
   * fast encoding stage for screen content tool detemination.
1412
   */
1413
  int palette_pixels;
1414
1415
  /*!\brief Pointer to the structure which stores the statistics used by
1416
   * sb-level multi-pass encoding.
1417
   */
1418
  struct SB_FIRST_PASS_STATS *sb_stats_cache;
1419
1420
  /*!\brief Pointer to the structure which stores the statistics used by
1421
   * first-pass when superblock is searched twice consecutively.
1422
   */
1423
  struct SB_FIRST_PASS_STATS *sb_fp_stats;
1424
1425
  /*!\brief Array of best estimated RD Costs of compound average. */
1426
  int64_t top_comp_avg_est_rd[TOP_COMP_AVG_EST_RD_COUNT];
1427
1428
#if CONFIG_PARTITION_SEARCH_ORDER
1429
  /*!\brief Pointer to RD_STATS structure to be used in
1430
   * av1_rd_partition_search().
1431
   */
1432
  RD_STATS *rdcost;
1433
#endif  // CONFIG_PARTITION_SEARCH_ORDER
1434
} MACROBLOCK;
1435
#undef SINGLE_REF_MODES
1436
1437
/*!\cond */
1438
// Zeroes out 'n_stats' elements in the array x->winner_mode_stats.
1439
// It only zeroes out what is necessary in 'color_index_map' (just the block
1440
// size, not the whole array).
1441
static inline void zero_winner_mode_stats(BLOCK_SIZE bsize, int n_stats,
1442
0
                                          WinnerModeStats *stats) {
1443
  // When winner mode stats are not required, the memory allocation is avoided
1444
  // for x->winner_mode_stats. The stats pointer will be NULL in such cases.
1445
0
  if (stats == NULL) return;
1446
1447
0
  const int block_height = block_size_high[bsize];
1448
0
  const int block_width = block_size_wide[bsize];
1449
0
  for (int i = 0; i < n_stats; ++i) {
1450
0
    WinnerModeStats *const stat = &stats[i];
1451
0
    memset(&stat->mbmi, 0, sizeof(stat->mbmi));
1452
0
    memset(&stat->rd_cost, 0, sizeof(stat->rd_cost));
1453
0
    memset(&stat->rd, 0, sizeof(stat->rd));
1454
0
    memset(&stat->rate_y, 0, sizeof(stat->rate_y));
1455
0
    memset(&stat->rate_uv, 0, sizeof(stat->rate_uv));
1456
    // Do not reset the whole array as it is CPU intensive.
1457
0
    memset(&stat->color_index_map, 0,
1458
0
           block_width * block_height * sizeof(stat->color_index_map[0]));
1459
0
    memset(&stat->mode_index, 0, sizeof(stat->mode_index));
1460
0
  }
1461
0
}
Unexecuted instantiation: av1_cx_iface.c:zero_winner_mode_stats
Unexecuted instantiation: allintra_vis.c:zero_winner_mode_stats
Unexecuted instantiation: av1_quantize.c:zero_winner_mode_stats
Unexecuted instantiation: bitstream.c:zero_winner_mode_stats
Unexecuted instantiation: context_tree.c:zero_winner_mode_stats
Unexecuted instantiation: encodeframe.c:zero_winner_mode_stats
Unexecuted instantiation: encodeframe_utils.c:zero_winner_mode_stats
Unexecuted instantiation: encodemb.c:zero_winner_mode_stats
Unexecuted instantiation: encodemv.c:zero_winner_mode_stats
Unexecuted instantiation: encoder.c:zero_winner_mode_stats
Unexecuted instantiation: encoder_utils.c:zero_winner_mode_stats
Unexecuted instantiation: encodetxb.c:zero_winner_mode_stats
Unexecuted instantiation: ethread.c:zero_winner_mode_stats
Unexecuted instantiation: firstpass.c:zero_winner_mode_stats
Unexecuted instantiation: global_motion_facade.c:zero_winner_mode_stats
Unexecuted instantiation: hash_motion.c:zero_winner_mode_stats
Unexecuted instantiation: level.c:zero_winner_mode_stats
Unexecuted instantiation: lookahead.c:zero_winner_mode_stats
Unexecuted instantiation: mcomp.c:zero_winner_mode_stats
Unexecuted instantiation: mv_prec.c:zero_winner_mode_stats
Unexecuted instantiation: palette.c:zero_winner_mode_stats
Unexecuted instantiation: partition_search.c:zero_winner_mode_stats
Unexecuted instantiation: partition_strategy.c:zero_winner_mode_stats
Unexecuted instantiation: pass2_strategy.c:zero_winner_mode_stats
Unexecuted instantiation: pickcdef.c:zero_winner_mode_stats
Unexecuted instantiation: picklpf.c:zero_winner_mode_stats
Unexecuted instantiation: pickrst.c:zero_winner_mode_stats
Unexecuted instantiation: ratectrl.c:zero_winner_mode_stats
Unexecuted instantiation: rd.c:zero_winner_mode_stats
Unexecuted instantiation: rdopt.c:zero_winner_mode_stats
Unexecuted instantiation: nonrd_pickmode.c:zero_winner_mode_stats
Unexecuted instantiation: nonrd_opt.c:zero_winner_mode_stats
Unexecuted instantiation: segmentation.c:zero_winner_mode_stats
Unexecuted instantiation: speed_features.c:zero_winner_mode_stats
Unexecuted instantiation: superres_scale.c:zero_winner_mode_stats
Unexecuted instantiation: svc_layercontext.c:zero_winner_mode_stats
Unexecuted instantiation: temporal_filter.c:zero_winner_mode_stats
Unexecuted instantiation: tokenize.c:zero_winner_mode_stats
Unexecuted instantiation: tpl_model.c:zero_winner_mode_stats
Unexecuted instantiation: tx_search.c:zero_winner_mode_stats
Unexecuted instantiation: txb_rdopt.c:zero_winner_mode_stats
Unexecuted instantiation: intra_mode_search.c:zero_winner_mode_stats
Unexecuted instantiation: var_based_part.c:zero_winner_mode_stats
Unexecuted instantiation: av1_noise_estimate.c:zero_winner_mode_stats
Unexecuted instantiation: aq_complexity.c:zero_winner_mode_stats
Unexecuted instantiation: aq_cyclicrefresh.c:zero_winner_mode_stats
Unexecuted instantiation: aq_variance.c:zero_winner_mode_stats
Unexecuted instantiation: compound_type.c:zero_winner_mode_stats
Unexecuted instantiation: encode_strategy.c:zero_winner_mode_stats
Unexecuted instantiation: global_motion.c:zero_winner_mode_stats
Unexecuted instantiation: gop_structure.c:zero_winner_mode_stats
Unexecuted instantiation: interp_search.c:zero_winner_mode_stats
Unexecuted instantiation: motion_search_facade.c:zero_winner_mode_stats
1462
1463
0
static inline int is_rect_tx_allowed_bsize(BLOCK_SIZE bsize) {
1464
0
  static const char LUT[BLOCK_SIZES_ALL] = {
1465
0
    0,  // BLOCK_4X4
1466
0
    1,  // BLOCK_4X8
1467
0
    1,  // BLOCK_8X4
1468
0
    0,  // BLOCK_8X8
1469
0
    1,  // BLOCK_8X16
1470
0
    1,  // BLOCK_16X8
1471
0
    0,  // BLOCK_16X16
1472
0
    1,  // BLOCK_16X32
1473
0
    1,  // BLOCK_32X16
1474
0
    0,  // BLOCK_32X32
1475
0
    1,  // BLOCK_32X64
1476
0
    1,  // BLOCK_64X32
1477
0
    0,  // BLOCK_64X64
1478
0
    0,  // BLOCK_64X128
1479
0
    0,  // BLOCK_128X64
1480
0
    0,  // BLOCK_128X128
1481
0
    1,  // BLOCK_4X16
1482
0
    1,  // BLOCK_16X4
1483
0
    1,  // BLOCK_8X32
1484
0
    1,  // BLOCK_32X8
1485
0
    1,  // BLOCK_16X64
1486
0
    1,  // BLOCK_64X16
1487
0
  };
1488
1489
0
  return LUT[bsize];
1490
0
}
Unexecuted instantiation: av1_cx_iface.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: allintra_vis.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: av1_quantize.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: bitstream.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: context_tree.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: encodeframe.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: encodeframe_utils.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: encodemb.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: encodemv.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: encoder.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: encoder_utils.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: encodetxb.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: ethread.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: firstpass.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: global_motion_facade.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: hash_motion.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: level.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: lookahead.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: mcomp.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: mv_prec.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: palette.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: partition_search.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: partition_strategy.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: pass2_strategy.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: pickcdef.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: picklpf.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: pickrst.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: ratectrl.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: rd.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: rdopt.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: nonrd_pickmode.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: nonrd_opt.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: segmentation.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: speed_features.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: superres_scale.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: svc_layercontext.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: temporal_filter.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: tokenize.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: tpl_model.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: tx_search.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: txb_rdopt.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: intra_mode_search.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: var_based_part.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: av1_noise_estimate.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: aq_complexity.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: aq_cyclicrefresh.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: aq_variance.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: compound_type.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: encode_strategy.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: global_motion.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: gop_structure.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: interp_search.c:is_rect_tx_allowed_bsize
Unexecuted instantiation: motion_search_facade.c:is_rect_tx_allowed_bsize
1491
1492
static inline int is_rect_tx_allowed(const MACROBLOCKD *xd,
1493
0
                                     const MB_MODE_INFO *mbmi) {
1494
0
  return is_rect_tx_allowed_bsize(mbmi->bsize) &&
1495
0
         !xd->lossless[mbmi->segment_id];
1496
0
}
Unexecuted instantiation: av1_cx_iface.c:is_rect_tx_allowed
Unexecuted instantiation: allintra_vis.c:is_rect_tx_allowed
Unexecuted instantiation: av1_quantize.c:is_rect_tx_allowed
Unexecuted instantiation: bitstream.c:is_rect_tx_allowed
Unexecuted instantiation: context_tree.c:is_rect_tx_allowed
Unexecuted instantiation: encodeframe.c:is_rect_tx_allowed
Unexecuted instantiation: encodeframe_utils.c:is_rect_tx_allowed
Unexecuted instantiation: encodemb.c:is_rect_tx_allowed
Unexecuted instantiation: encodemv.c:is_rect_tx_allowed
Unexecuted instantiation: encoder.c:is_rect_tx_allowed
Unexecuted instantiation: encoder_utils.c:is_rect_tx_allowed
Unexecuted instantiation: encodetxb.c:is_rect_tx_allowed
Unexecuted instantiation: ethread.c:is_rect_tx_allowed
Unexecuted instantiation: firstpass.c:is_rect_tx_allowed
Unexecuted instantiation: global_motion_facade.c:is_rect_tx_allowed
Unexecuted instantiation: hash_motion.c:is_rect_tx_allowed
Unexecuted instantiation: level.c:is_rect_tx_allowed
Unexecuted instantiation: lookahead.c:is_rect_tx_allowed
Unexecuted instantiation: mcomp.c:is_rect_tx_allowed
Unexecuted instantiation: mv_prec.c:is_rect_tx_allowed
Unexecuted instantiation: palette.c:is_rect_tx_allowed
Unexecuted instantiation: partition_search.c:is_rect_tx_allowed
Unexecuted instantiation: partition_strategy.c:is_rect_tx_allowed
Unexecuted instantiation: pass2_strategy.c:is_rect_tx_allowed
Unexecuted instantiation: pickcdef.c:is_rect_tx_allowed
Unexecuted instantiation: picklpf.c:is_rect_tx_allowed
Unexecuted instantiation: pickrst.c:is_rect_tx_allowed
Unexecuted instantiation: ratectrl.c:is_rect_tx_allowed
Unexecuted instantiation: rd.c:is_rect_tx_allowed
Unexecuted instantiation: rdopt.c:is_rect_tx_allowed
Unexecuted instantiation: nonrd_pickmode.c:is_rect_tx_allowed
Unexecuted instantiation: nonrd_opt.c:is_rect_tx_allowed
Unexecuted instantiation: segmentation.c:is_rect_tx_allowed
Unexecuted instantiation: speed_features.c:is_rect_tx_allowed
Unexecuted instantiation: superres_scale.c:is_rect_tx_allowed
Unexecuted instantiation: svc_layercontext.c:is_rect_tx_allowed
Unexecuted instantiation: temporal_filter.c:is_rect_tx_allowed
Unexecuted instantiation: tokenize.c:is_rect_tx_allowed
Unexecuted instantiation: tpl_model.c:is_rect_tx_allowed
Unexecuted instantiation: tx_search.c:is_rect_tx_allowed
Unexecuted instantiation: txb_rdopt.c:is_rect_tx_allowed
Unexecuted instantiation: intra_mode_search.c:is_rect_tx_allowed
Unexecuted instantiation: var_based_part.c:is_rect_tx_allowed
Unexecuted instantiation: av1_noise_estimate.c:is_rect_tx_allowed
Unexecuted instantiation: aq_complexity.c:is_rect_tx_allowed
Unexecuted instantiation: aq_cyclicrefresh.c:is_rect_tx_allowed
Unexecuted instantiation: aq_variance.c:is_rect_tx_allowed
Unexecuted instantiation: compound_type.c:is_rect_tx_allowed
Unexecuted instantiation: encode_strategy.c:is_rect_tx_allowed
Unexecuted instantiation: global_motion.c:is_rect_tx_allowed
Unexecuted instantiation: gop_structure.c:is_rect_tx_allowed
Unexecuted instantiation: interp_search.c:is_rect_tx_allowed
Unexecuted instantiation: motion_search_facade.c:is_rect_tx_allowed
1497
1498
0
static inline int tx_size_to_depth(TX_SIZE tx_size, BLOCK_SIZE bsize) {
1499
0
  TX_SIZE ctx_size = max_txsize_rect_lookup[bsize];
1500
0
  int depth = 0;
1501
0
  while (tx_size != ctx_size) {
1502
0
    depth++;
1503
0
    ctx_size = sub_tx_size_map[ctx_size];
1504
0
    assert(depth <= MAX_TX_DEPTH);
1505
0
  }
1506
0
  return depth;
1507
0
}
Unexecuted instantiation: av1_cx_iface.c:tx_size_to_depth
Unexecuted instantiation: allintra_vis.c:tx_size_to_depth
Unexecuted instantiation: av1_quantize.c:tx_size_to_depth
Unexecuted instantiation: bitstream.c:tx_size_to_depth
Unexecuted instantiation: context_tree.c:tx_size_to_depth
Unexecuted instantiation: encodeframe.c:tx_size_to_depth
Unexecuted instantiation: encodeframe_utils.c:tx_size_to_depth
Unexecuted instantiation: encodemb.c:tx_size_to_depth
Unexecuted instantiation: encodemv.c:tx_size_to_depth
Unexecuted instantiation: encoder.c:tx_size_to_depth
Unexecuted instantiation: encoder_utils.c:tx_size_to_depth
Unexecuted instantiation: encodetxb.c:tx_size_to_depth
Unexecuted instantiation: ethread.c:tx_size_to_depth
Unexecuted instantiation: firstpass.c:tx_size_to_depth
Unexecuted instantiation: global_motion_facade.c:tx_size_to_depth
Unexecuted instantiation: hash_motion.c:tx_size_to_depth
Unexecuted instantiation: level.c:tx_size_to_depth
Unexecuted instantiation: lookahead.c:tx_size_to_depth
Unexecuted instantiation: mcomp.c:tx_size_to_depth
Unexecuted instantiation: mv_prec.c:tx_size_to_depth
Unexecuted instantiation: palette.c:tx_size_to_depth
Unexecuted instantiation: partition_search.c:tx_size_to_depth
Unexecuted instantiation: partition_strategy.c:tx_size_to_depth
Unexecuted instantiation: pass2_strategy.c:tx_size_to_depth
Unexecuted instantiation: pickcdef.c:tx_size_to_depth
Unexecuted instantiation: picklpf.c:tx_size_to_depth
Unexecuted instantiation: pickrst.c:tx_size_to_depth
Unexecuted instantiation: ratectrl.c:tx_size_to_depth
Unexecuted instantiation: rd.c:tx_size_to_depth
Unexecuted instantiation: rdopt.c:tx_size_to_depth
Unexecuted instantiation: nonrd_pickmode.c:tx_size_to_depth
Unexecuted instantiation: nonrd_opt.c:tx_size_to_depth
Unexecuted instantiation: segmentation.c:tx_size_to_depth
Unexecuted instantiation: speed_features.c:tx_size_to_depth
Unexecuted instantiation: superres_scale.c:tx_size_to_depth
Unexecuted instantiation: svc_layercontext.c:tx_size_to_depth
Unexecuted instantiation: temporal_filter.c:tx_size_to_depth
Unexecuted instantiation: tokenize.c:tx_size_to_depth
Unexecuted instantiation: tpl_model.c:tx_size_to_depth
Unexecuted instantiation: tx_search.c:tx_size_to_depth
Unexecuted instantiation: txb_rdopt.c:tx_size_to_depth
Unexecuted instantiation: intra_mode_search.c:tx_size_to_depth
Unexecuted instantiation: var_based_part.c:tx_size_to_depth
Unexecuted instantiation: av1_noise_estimate.c:tx_size_to_depth
Unexecuted instantiation: aq_complexity.c:tx_size_to_depth
Unexecuted instantiation: aq_cyclicrefresh.c:tx_size_to_depth
Unexecuted instantiation: aq_variance.c:tx_size_to_depth
Unexecuted instantiation: compound_type.c:tx_size_to_depth
Unexecuted instantiation: encode_strategy.c:tx_size_to_depth
Unexecuted instantiation: global_motion.c:tx_size_to_depth
Unexecuted instantiation: gop_structure.c:tx_size_to_depth
Unexecuted instantiation: interp_search.c:tx_size_to_depth
Unexecuted instantiation: motion_search_facade.c:tx_size_to_depth
1508
1509
static inline void set_blk_skip(uint8_t txb_skip[], int plane, int blk_idx,
1510
0
                                int skip) {
1511
0
  if (skip)
1512
0
    txb_skip[blk_idx] |= 1UL << plane;
1513
0
  else
1514
0
    txb_skip[blk_idx] &= ~(1UL << plane);
1515
0
#ifndef NDEBUG
1516
0
  // Set chroma planes to uninitialized states when luma is set to check if
1517
0
  // it will be set later
1518
0
  if (plane == 0) {
1519
0
    txb_skip[blk_idx] |= 1UL << (1 + 4);
1520
0
    txb_skip[blk_idx] |= 1UL << (2 + 4);
1521
0
  }
1522
0
1523
0
  // Clear the initialization checking bit
1524
0
  txb_skip[blk_idx] &= ~(1UL << (plane + 4));
1525
0
#endif
1526
0
}
Unexecuted instantiation: av1_cx_iface.c:set_blk_skip
Unexecuted instantiation: allintra_vis.c:set_blk_skip
Unexecuted instantiation: av1_quantize.c:set_blk_skip
Unexecuted instantiation: bitstream.c:set_blk_skip
Unexecuted instantiation: context_tree.c:set_blk_skip
Unexecuted instantiation: encodeframe.c:set_blk_skip
Unexecuted instantiation: encodeframe_utils.c:set_blk_skip
Unexecuted instantiation: encodemb.c:set_blk_skip
Unexecuted instantiation: encodemv.c:set_blk_skip
Unexecuted instantiation: encoder.c:set_blk_skip
Unexecuted instantiation: encoder_utils.c:set_blk_skip
Unexecuted instantiation: encodetxb.c:set_blk_skip
Unexecuted instantiation: ethread.c:set_blk_skip
Unexecuted instantiation: firstpass.c:set_blk_skip
Unexecuted instantiation: global_motion_facade.c:set_blk_skip
Unexecuted instantiation: hash_motion.c:set_blk_skip
Unexecuted instantiation: level.c:set_blk_skip
Unexecuted instantiation: lookahead.c:set_blk_skip
Unexecuted instantiation: mcomp.c:set_blk_skip
Unexecuted instantiation: mv_prec.c:set_blk_skip
Unexecuted instantiation: palette.c:set_blk_skip
Unexecuted instantiation: partition_search.c:set_blk_skip
Unexecuted instantiation: partition_strategy.c:set_blk_skip
Unexecuted instantiation: pass2_strategy.c:set_blk_skip
Unexecuted instantiation: pickcdef.c:set_blk_skip
Unexecuted instantiation: picklpf.c:set_blk_skip
Unexecuted instantiation: pickrst.c:set_blk_skip
Unexecuted instantiation: ratectrl.c:set_blk_skip
Unexecuted instantiation: rd.c:set_blk_skip
Unexecuted instantiation: rdopt.c:set_blk_skip
Unexecuted instantiation: nonrd_pickmode.c:set_blk_skip
Unexecuted instantiation: nonrd_opt.c:set_blk_skip
Unexecuted instantiation: segmentation.c:set_blk_skip
Unexecuted instantiation: speed_features.c:set_blk_skip
Unexecuted instantiation: superres_scale.c:set_blk_skip
Unexecuted instantiation: svc_layercontext.c:set_blk_skip
Unexecuted instantiation: temporal_filter.c:set_blk_skip
Unexecuted instantiation: tokenize.c:set_blk_skip
Unexecuted instantiation: tpl_model.c:set_blk_skip
Unexecuted instantiation: tx_search.c:set_blk_skip
Unexecuted instantiation: txb_rdopt.c:set_blk_skip
Unexecuted instantiation: intra_mode_search.c:set_blk_skip
Unexecuted instantiation: var_based_part.c:set_blk_skip
Unexecuted instantiation: av1_noise_estimate.c:set_blk_skip
Unexecuted instantiation: aq_complexity.c:set_blk_skip
Unexecuted instantiation: aq_cyclicrefresh.c:set_blk_skip
Unexecuted instantiation: aq_variance.c:set_blk_skip
Unexecuted instantiation: compound_type.c:set_blk_skip
Unexecuted instantiation: encode_strategy.c:set_blk_skip
Unexecuted instantiation: global_motion.c:set_blk_skip
Unexecuted instantiation: gop_structure.c:set_blk_skip
Unexecuted instantiation: interp_search.c:set_blk_skip
Unexecuted instantiation: motion_search_facade.c:set_blk_skip
1527
1528
0
static inline int is_blk_skip(uint8_t *txb_skip, int plane, int blk_idx) {
1529
0
#ifndef NDEBUG
1530
0
  // Check if this is initialized
1531
0
  assert(!(txb_skip[blk_idx] & (1UL << (plane + 4))));
1532
0
1533
0
  // The magic number is 0x77, this is to test if there is garbage data
1534
0
  assert((txb_skip[blk_idx] & 0x88) == 0);
1535
0
#endif
1536
0
  return (txb_skip[blk_idx] >> plane) & 1;
1537
0
}
Unexecuted instantiation: av1_cx_iface.c:is_blk_skip
Unexecuted instantiation: allintra_vis.c:is_blk_skip
Unexecuted instantiation: av1_quantize.c:is_blk_skip
Unexecuted instantiation: bitstream.c:is_blk_skip
Unexecuted instantiation: context_tree.c:is_blk_skip
Unexecuted instantiation: encodeframe.c:is_blk_skip
Unexecuted instantiation: encodeframe_utils.c:is_blk_skip
Unexecuted instantiation: encodemb.c:is_blk_skip
Unexecuted instantiation: encodemv.c:is_blk_skip
Unexecuted instantiation: encoder.c:is_blk_skip
Unexecuted instantiation: encoder_utils.c:is_blk_skip
Unexecuted instantiation: encodetxb.c:is_blk_skip
Unexecuted instantiation: ethread.c:is_blk_skip
Unexecuted instantiation: firstpass.c:is_blk_skip
Unexecuted instantiation: global_motion_facade.c:is_blk_skip
Unexecuted instantiation: hash_motion.c:is_blk_skip
Unexecuted instantiation: level.c:is_blk_skip
Unexecuted instantiation: lookahead.c:is_blk_skip
Unexecuted instantiation: mcomp.c:is_blk_skip
Unexecuted instantiation: mv_prec.c:is_blk_skip
Unexecuted instantiation: palette.c:is_blk_skip
Unexecuted instantiation: partition_search.c:is_blk_skip
Unexecuted instantiation: partition_strategy.c:is_blk_skip
Unexecuted instantiation: pass2_strategy.c:is_blk_skip
Unexecuted instantiation: pickcdef.c:is_blk_skip
Unexecuted instantiation: picklpf.c:is_blk_skip
Unexecuted instantiation: pickrst.c:is_blk_skip
Unexecuted instantiation: ratectrl.c:is_blk_skip
Unexecuted instantiation: rd.c:is_blk_skip
Unexecuted instantiation: rdopt.c:is_blk_skip
Unexecuted instantiation: nonrd_pickmode.c:is_blk_skip
Unexecuted instantiation: nonrd_opt.c:is_blk_skip
Unexecuted instantiation: segmentation.c:is_blk_skip
Unexecuted instantiation: speed_features.c:is_blk_skip
Unexecuted instantiation: superres_scale.c:is_blk_skip
Unexecuted instantiation: svc_layercontext.c:is_blk_skip
Unexecuted instantiation: temporal_filter.c:is_blk_skip
Unexecuted instantiation: tokenize.c:is_blk_skip
Unexecuted instantiation: tpl_model.c:is_blk_skip
Unexecuted instantiation: tx_search.c:is_blk_skip
Unexecuted instantiation: txb_rdopt.c:is_blk_skip
Unexecuted instantiation: intra_mode_search.c:is_blk_skip
Unexecuted instantiation: var_based_part.c:is_blk_skip
Unexecuted instantiation: av1_noise_estimate.c:is_blk_skip
Unexecuted instantiation: aq_complexity.c:is_blk_skip
Unexecuted instantiation: aq_cyclicrefresh.c:is_blk_skip
Unexecuted instantiation: aq_variance.c:is_blk_skip
Unexecuted instantiation: compound_type.c:is_blk_skip
Unexecuted instantiation: encode_strategy.c:is_blk_skip
Unexecuted instantiation: global_motion.c:is_blk_skip
Unexecuted instantiation: gop_structure.c:is_blk_skip
Unexecuted instantiation: interp_search.c:is_blk_skip
Unexecuted instantiation: motion_search_facade.c:is_blk_skip
1538
1539
/*!\endcond */
1540
1541
#ifdef __cplusplus
1542
}  // extern "C"
1543
#endif
1544
1545
#endif  // AOM_AV1_ENCODER_BLOCK_H_