Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 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. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 12 | #ifndef AOM_AV1_ENCODER_AQ_CYCLICREFRESH_H_ |
| 13 | #define AOM_AV1_ENCODER_AQ_CYCLICREFRESH_H_ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 14 | |
| 15 | #include "av1/common/blockd.h" |
Cherma Rajan A | d27a147 | 2021-02-19 11:35:40 +0530 | [diff] [blame] | 16 | #include "av1/encoder/block.h" |
| 17 | #include "av1/encoder/tokenize.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 18 | |
| 19 | #ifdef __cplusplus |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | |
| 23 | // The segment ids used in cyclic refresh: from base (no boost) to increasing |
| 24 | // boost (higher delta-qp). |
| 25 | #define CR_SEGMENT_ID_BASE 0 |
| 26 | #define CR_SEGMENT_ID_BOOST1 1 |
| 27 | #define CR_SEGMENT_ID_BOOST2 2 |
| 28 | |
| 29 | // Maximum rate target ratio for setting segment delta-qp. |
| 30 | #define CR_MAX_RATE_TARGET_RATIO 4.0 |
| 31 | |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 32 | /*! |
| 33 | * \brief The stucture of CYCLIC_REFRESH. |
| 34 | * \ingroup cyclic_refresh |
| 35 | */ |
Marco Paniconi | 5b1e473 | 2019-08-08 18:57:53 -0700 | [diff] [blame] | 36 | struct CYCLIC_REFRESH { |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 37 | /*! |
| 38 | * Percentage of blocks per frame that are targeted as candidates |
| 39 | * for cyclic refresh. |
| 40 | */ |
Marco Paniconi | 5b1e473 | 2019-08-08 18:57:53 -0700 | [diff] [blame] | 41 | int percent_refresh; |
Paul Wilkins | ff3923f | 2022-08-22 17:16:03 +0100 | [diff] [blame] | 42 | |
| 43 | /*! |
| 44 | * Active adjustment delta for cyclic refresh for rate control. |
| 45 | */ |
| 46 | int percent_refresh_adjustment; |
| 47 | |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 48 | /*! |
| 49 | * Maximum q-delta as percentage of base q. |
| 50 | */ |
Marco Paniconi | 5b1e473 | 2019-08-08 18:57:53 -0700 | [diff] [blame] | 51 | int max_qdelta_perc; |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 52 | /*! |
| 53 | *Superblock starting index for cycling through the frame. |
| 54 | */ |
Marco Paniconi | 5b1e473 | 2019-08-08 18:57:53 -0700 | [diff] [blame] | 55 | int sb_index; |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 56 | /*! |
Paul Wilkins | ece2c48 | 2023-01-10 16:18:32 +0000 | [diff] [blame] | 57 | *Superblock index cyclic refresh index last frame |
| 58 | */ |
| 59 | int last_sb_index; |
| 60 | /*! |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 61 | * Controls how long block will need to wait to be refreshed again, in |
| 62 | * excess of the cycle time, i.e., in the case of all zero motion, block |
| 63 | * will be refreshed every (100/percent_refresh + time_for_refresh) frames. |
| 64 | */ |
Marco Paniconi | 5b1e473 | 2019-08-08 18:57:53 -0700 | [diff] [blame] | 65 | int time_for_refresh; |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 66 | /*! |
| 67 | * Target number of (4x4) blocks that are set for delta-q. |
| 68 | */ |
Marco Paniconi | 5b1e473 | 2019-08-08 18:57:53 -0700 | [diff] [blame] | 69 | int target_num_seg_blocks; |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 70 | /*! |
| 71 | * Actual number of (4x4) blocks that were applied delta-q, |
| 72 | * for segment 1. |
| 73 | */ |
Marco Paniconi | 5b1e473 | 2019-08-08 18:57:53 -0700 | [diff] [blame] | 74 | int actual_num_seg1_blocks; |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 75 | /*! |
| 76 | * Actual number of (4x4) blocks that were applied delta-q, |
| 77 | * for segment 2. |
| 78 | */ |
Marco Paniconi | 5b1e473 | 2019-08-08 18:57:53 -0700 | [diff] [blame] | 79 | int actual_num_seg2_blocks; |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 80 | /*! |
| 81 | * RD mult. parameters for segment 1. |
| 82 | */ |
Marco Paniconi | 5b1e473 | 2019-08-08 18:57:53 -0700 | [diff] [blame] | 83 | int rdmult; |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 84 | /*! |
| 85 | * Cyclic refresh map. |
| 86 | */ |
Marco Paniconi | 5b1e473 | 2019-08-08 18:57:53 -0700 | [diff] [blame] | 87 | int8_t *map; |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 88 | /*! |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 89 | * Threshold applied to the projected rate of the coding block, |
| 90 | * when deciding whether block should be refreshed. |
| 91 | */ |
Marco Paniconi | 5b1e473 | 2019-08-08 18:57:53 -0700 | [diff] [blame] | 92 | int64_t thresh_rate_sb; |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 93 | /*! |
| 94 | * Threshold applied to the projected distortion of the coding block, |
| 95 | * when deciding whether block should be refreshed. |
| 96 | */ |
Marco Paniconi | 5b1e473 | 2019-08-08 18:57:53 -0700 | [diff] [blame] | 97 | int64_t thresh_dist_sb; |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 98 | /*! |
| 99 | * Threshold applied to the motion vector (in units of 1/8 pel) of the |
| 100 | * coding block, when deciding whether block should be refreshed. |
| 101 | */ |
Marco Paniconi | 5b1e473 | 2019-08-08 18:57:53 -0700 | [diff] [blame] | 102 | int16_t motion_thresh; |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 103 | /*! |
| 104 | * Rate target ratio to set q delta. |
| 105 | */ |
Marco Paniconi | 5b1e473 | 2019-08-08 18:57:53 -0700 | [diff] [blame] | 106 | double rate_ratio_qdelta; |
Paul Wilkins | ff3923f | 2022-08-22 17:16:03 +0100 | [diff] [blame] | 107 | |
| 108 | /*! |
| 109 | * Active adjustment of qdelta rate ratio for enhanced rate control |
| 110 | */ |
| 111 | double rate_ratio_qdelta_adjustment; |
| 112 | |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 113 | /*! |
| 114 | * Boost factor for rate target ratio, for segment CR_SEGMENT_ID_BOOST2. |
| 115 | */ |
Marco Paniconi | 5b1e473 | 2019-08-08 18:57:53 -0700 | [diff] [blame] | 116 | int rate_boost_fac; |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 117 | |
| 118 | /*!\cond */ |
Marco Paniconi | 5b1e473 | 2019-08-08 18:57:53 -0700 | [diff] [blame] | 119 | int qindex_delta[3]; |
Marco Paniconi | 5b1e473 | 2019-08-08 18:57:53 -0700 | [diff] [blame] | 120 | int apply_cyclic_refresh; |
Marco Paniconi | 03b6f69 | 2021-09-30 10:22:36 -0700 | [diff] [blame] | 121 | int skip_over4x4; |
Marco Paniconi | 033ae47 | 2022-01-13 00:48:35 -0800 | [diff] [blame] | 122 | int counter_encode_maxq_scene_change; |
Marco Paniconi | ec42d4d | 2022-05-22 22:18:15 -0700 | [diff] [blame] | 123 | int use_block_sad_scene_det; |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 124 | /*!\endcond */ |
Marco Paniconi | 5b1e473 | 2019-08-08 18:57:53 -0700 | [diff] [blame] | 125 | }; |
| 126 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 127 | struct AV1_COMP; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 128 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 129 | typedef struct CYCLIC_REFRESH CYCLIC_REFRESH; |
| 130 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 131 | CYCLIC_REFRESH *av1_cyclic_refresh_alloc(int mi_rows, int mi_cols); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 132 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 133 | void av1_cyclic_refresh_free(CYCLIC_REFRESH *cr); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 134 | |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 135 | /*!\brief Estimate the bits, incorporating the delta-q from the segments. |
| 136 | * |
| 137 | * For the just encoded frame, estimate the bits, incorporating the delta-q |
| 138 | * from non-base segment(s). Note this function is called in the postencode |
| 139 | * (called from rc_update_rate_correction_factors()). |
| 140 | * |
| 141 | * \ingroup cyclic_refresh |
| 142 | * \callgraph |
| 143 | * \callergraph |
| 144 | * |
| 145 | * \param[in] cpi Top level encoder structure |
| 146 | * \param[in] correction_factor rate correction factor |
| 147 | * |
| 148 | * \return Return the estimated bits at given q. |
| 149 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 150 | int av1_cyclic_refresh_estimate_bits_at_q(const struct AV1_COMP *cpi, |
| 151 | double correction_factor); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 152 | |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 153 | /*!\brief Estimate the bits per mb, for given q = i and delta-q. |
| 154 | * |
| 155 | * Prior to encoding the frame, estimate the bits per mb, for a given q = i and |
| 156 | * a corresponding delta-q (for segment 1). This function is called in the |
| 157 | * rc_regulate_q() to set the base qp index. Note: the segment map is set to |
| 158 | * either 0/CR_SEGMENT_ID_BASE (no refresh) or to 1/CR_SEGMENT_ID_BOOST1 |
| 159 | * (refresh) for each superblock, prior to encoding. |
| 160 | * |
| 161 | * \ingroup cyclic_refresh |
| 162 | * \callgraph |
| 163 | * \callergraph |
| 164 | * |
| 165 | * \param[in] cpi Top level encoder structure |
| 166 | * \param[in] i q index |
| 167 | * \param[in] correction_factor rate correction factor |
| 168 | * |
| 169 | * \return Return the estimated bits for q = i and delta-q (segment 1). |
| 170 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 171 | int av1_cyclic_refresh_rc_bits_per_mb(const struct AV1_COMP *cpi, int i, |
| 172 | double correction_factor); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 173 | |
Marco Paniconi | 14f0c64 | 2021-04-27 16:08:11 -0700 | [diff] [blame] | 174 | /*!\brief Update segment_id for blocks are skipped. |
| 175 | * |
| 176 | * After encoding a given prediction block, of size bsize at (mi_row, mi_col), |
| 177 | * check if we should reset the segment_id based on skip_txfm, |
| 178 | * and update the cyclic_refresh map and segmentation counters. |
| 179 | * |
| 180 | * \ingroup cyclic_refresh |
| 181 | * \callgraph |
| 182 | * \callergraph |
| 183 | * |
| 184 | * \param[in] cpi Top level encoder structure |
| 185 | * \param[in] x Pointer to MACROBLOCK structure |
| 186 | * \param[in] mi_row Row coordinate of the block in a step size of MI_SIZE |
| 187 | * \param[in] mi_col Col coordinate of the block in a step size of MI_SIZE |
| 188 | * \param[in] bsize Block size |
Ranjit Kumar Tulabandu | 0066e7a | 2022-10-10 11:57:06 +0530 | [diff] [blame] | 189 | * \param[in] dry_run A code indicating whether it is part of the final |
| 190 | * pass for reconstructing the superblock |
Marco Paniconi | 14f0c64 | 2021-04-27 16:08:11 -0700 | [diff] [blame] | 191 | * |
Wan-Teh Chang | 0defff8 | 2022-08-23 14:17:01 -0700 | [diff] [blame] | 192 | * \remark Update the \c mbmi->segment_id, the \c cpi->cyclic_refresh and |
Marco Paniconi | 14f0c64 | 2021-04-27 16:08:11 -0700 | [diff] [blame] | 193 | * the \c cm->cpi->enc_seg.map. |
| 194 | */ |
| 195 | |
| 196 | void av1_cyclic_reset_segment_skip(const struct AV1_COMP *cpi, |
| 197 | MACROBLOCK *const x, int mi_row, int mi_col, |
Ranjit Kumar Tulabandu | 0066e7a | 2022-10-10 11:57:06 +0530 | [diff] [blame] | 198 | BLOCK_SIZE bsize, RUN_TYPE dry_run); |
Marco Paniconi | 14f0c64 | 2021-04-27 16:08:11 -0700 | [diff] [blame] | 199 | |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 200 | /*!\brief Update segment_id for block based on mode selected. |
| 201 | * |
| 202 | * Prior to coding a given prediction block, of size bsize at (mi_row, mi_col), |
| 203 | * check if we should reset the segment_id (based on mode/motion/skip selected |
| 204 | * for that block) and update the cyclic_refresh map and segmentation map. |
| 205 | * |
| 206 | * \ingroup cyclic_refresh |
| 207 | * \callgraph |
| 208 | * \callergraph |
| 209 | * |
| 210 | * \param[in] cpi Top level encoder structure |
Cherma Rajan A | d27a147 | 2021-02-19 11:35:40 +0530 | [diff] [blame] | 211 | * \param[in] x Pointer to MACROBLOCK structure |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 212 | * \param[in] mi_row Row coordinate of the block in a step size of MI_SIZE |
| 213 | * \param[in] mi_col Col coordinate of the block in a step size of MI_SIZE |
| 214 | * \param[in] bsize Block size |
| 215 | * \param[in] rate Projected block rate from pickmode |
| 216 | * \param[in] dist Projected block dist from pickmode |
Cherma Rajan A | d27a147 | 2021-02-19 11:35:40 +0530 | [diff] [blame] | 217 | * \param[in] skip Skip flag set from picmode |
| 218 | * \param[in] dry_run A code indicating whether it is part of the final |
| 219 | * pass for reconstructing the superblock |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 220 | * |
Wan-Teh Chang | 0defff8 | 2022-08-23 14:17:01 -0700 | [diff] [blame] | 221 | * \remark Update the \c mbmi->segment_id, the \c cpi->cyclic_refresh and |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 222 | * the \c cm->cpi->enc_seg.map. |
| 223 | */ |
Urvang Joshi | 5264844 | 2016-10-13 17:27:51 -0700 | [diff] [blame] | 224 | void av1_cyclic_refresh_update_segment(const struct AV1_COMP *cpi, |
Cherma Rajan A | d27a147 | 2021-02-19 11:35:40 +0530 | [diff] [blame] | 225 | MACROBLOCK *const x, int mi_row, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 226 | int mi_col, BLOCK_SIZE bsize, |
Cherma Rajan A | d27a147 | 2021-02-19 11:35:40 +0530 | [diff] [blame] | 227 | int64_t rate, int64_t dist, int skip, |
| 228 | RUN_TYPE dry_run); |
| 229 | |
| 230 | /*!\brief Initialize counters used for cyclic refresh. |
| 231 | * |
Marco Paniconi | 92a24f9 | 2023-04-18 14:42:26 -0700 | [diff] [blame] | 232 | * Initializes cyclic refresh counters actual_num_seg1_blocks and |
Cherma Rajan A | d27a147 | 2021-02-19 11:35:40 +0530 | [diff] [blame] | 233 | * actual_num_seg2_blocks. |
| 234 | * |
| 235 | * \ingroup cyclic_refresh |
| 236 | * \callgraph |
| 237 | * \callergraph |
| 238 | * |
| 239 | * \param[in] x Pointer to MACROBLOCK structure |
| 240 | * |
Marco Paniconi | 92a24f9 | 2023-04-18 14:42:26 -0700 | [diff] [blame] | 241 | * \remark Update the \c x->actual_num_seg1_blocks and the |
| 242 | * \c x->actual_num_seg2_blocks. |
Cherma Rajan A | d27a147 | 2021-02-19 11:35:40 +0530 | [diff] [blame] | 243 | */ |
| 244 | void av1_init_cyclic_refresh_counters(MACROBLOCK *const x); |
| 245 | |
| 246 | /*!\brief Accumulate cyclic refresh counters. |
| 247 | * |
Marco Paniconi | 92a24f9 | 2023-04-18 14:42:26 -0700 | [diff] [blame] | 248 | * Accumulates cyclic refresh counters actual_num_seg1_blocks and |
Cherma Rajan A | d27a147 | 2021-02-19 11:35:40 +0530 | [diff] [blame] | 249 | * actual_num_seg2_blocks from MACROBLOCK strcture to CYCLIC_REFRESH strcture. |
| 250 | * |
| 251 | * \ingroup cyclic_refresh |
| 252 | * \callgraph |
| 253 | * \callergraph |
| 254 | * |
| 255 | * \param[in] cyclic_refresh Pointer to CYCLIC_REFRESH structure |
| 256 | * \param[in] x Pointer to MACROBLOCK structure |
| 257 | * |
Marco Paniconi | 92a24f9 | 2023-04-18 14:42:26 -0700 | [diff] [blame] | 258 | * \remark Update the \c cyclic_refresh->actual_num_seg1_blocks and the |
| 259 | * \c cyclic_refresh->actual_num_seg2_blocks. |
Cherma Rajan A | d27a147 | 2021-02-19 11:35:40 +0530 | [diff] [blame] | 260 | */ |
| 261 | void av1_accumulate_cyclic_refresh_counters( |
| 262 | CYCLIC_REFRESH *const cyclic_refresh, const MACROBLOCK *const x); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 263 | |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 264 | /*!\brief Set golden frame update interval nased on cyclic refresh. |
| 265 | * |
| 266 | * \ingroup cyclic_refresh |
| 267 | * \callgraph |
| 268 | * \callergraph |
| 269 | * |
| 270 | * \param[in] cpi Top level encoder structure |
| 271 | * |
Wan-Teh Chang | 0defff8 | 2022-08-23 14:17:01 -0700 | [diff] [blame] | 272 | * \remark Returns the interval in \c cpi->rc.baseline_gf_interval. |
Marco Paniconi | 9cd0881 | 2020-07-13 11:01:24 -0700 | [diff] [blame] | 273 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 274 | void av1_cyclic_refresh_set_golden_update(struct AV1_COMP *const cpi); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 275 | |
Marco Paniconi | 5b2faba | 2020-07-09 11:39:22 -0700 | [diff] [blame] | 276 | /*!\brief Set the global/frame level parameters for cyclic refresh. |
| 277 | * |
| 278 | * First call to the cyclic refresh, before encoding the frame. |
| 279 | * Sets the flag on whether cyclic refresh should be applied, sets |
| 280 | * the amount/percent of refresh, and the amount of boost applied to |
| 281 | * the two segments (set by rate_ratio_qdelta and rate_boost_fac). |
| 282 | * |
| 283 | * \ingroup cyclic_refresh |
| 284 | * \callgraph |
| 285 | * \callergraph |
| 286 | * |
| 287 | * \param[in] cpi Top level encoder structure |
| 288 | * |
Wan-Teh Chang | 0defff8 | 2022-08-23 14:17:01 -0700 | [diff] [blame] | 289 | * \remark Updates the \c cpi->cyclic_refresh with the settings. |
Marco Paniconi | 5b2faba | 2020-07-09 11:39:22 -0700 | [diff] [blame] | 290 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 291 | void av1_cyclic_refresh_update_parameters(struct AV1_COMP *const cpi); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 292 | |
Marco Paniconi | 5b2faba | 2020-07-09 11:39:22 -0700 | [diff] [blame] | 293 | /*!\brief Setup the cyclic background refresh. |
| 294 | * |
| 295 | * Set the delta q for the segment(s), and set the segmentation map. |
| 296 | * |
| 297 | * \ingroup cyclic_refresh |
| 298 | * \callgraph |
| 299 | * \callergraph |
| 300 | * |
| 301 | * \param[in] cpi Top level encoder structure |
| 302 | * |
Wan-Teh Chang | 0defff8 | 2022-08-23 14:17:01 -0700 | [diff] [blame] | 303 | * \remark Updates the \c cpi->cyclic_refresh with the cyclic refresh |
Marco Paniconi | 5b2faba | 2020-07-09 11:39:22 -0700 | [diff] [blame] | 304 | * parameters and the \c cm->seg with the segmentation data. |
| 305 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 306 | void av1_cyclic_refresh_setup(struct AV1_COMP *const cpi); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 307 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 308 | int av1_cyclic_refresh_get_rdmult(const CYCLIC_REFRESH *cr); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 309 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 310 | void av1_cyclic_refresh_reset_resize(struct AV1_COMP *const cpi); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 311 | |
Marco Paniconi | 85b9ecb | 2022-02-27 23:04:58 -0800 | [diff] [blame] | 312 | int av1_cyclic_refresh_disable_lf_cdef(struct AV1_COMP *const cpi); |
| 313 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 314 | static INLINE int cyclic_refresh_segment_id_boosted(int segment_id) { |
| 315 | return segment_id == CR_SEGMENT_ID_BOOST1 || |
| 316 | segment_id == CR_SEGMENT_ID_BOOST2; |
| 317 | } |
| 318 | |
| 319 | static INLINE int cyclic_refresh_segment_id(int segment_id) { |
| 320 | if (segment_id == CR_SEGMENT_ID_BOOST1) |
| 321 | return CR_SEGMENT_ID_BOOST1; |
| 322 | else if (segment_id == CR_SEGMENT_ID_BOOST2) |
| 323 | return CR_SEGMENT_ID_BOOST2; |
| 324 | else |
| 325 | return CR_SEGMENT_ID_BASE; |
| 326 | } |
| 327 | |
| 328 | #ifdef __cplusplus |
| 329 | } // extern "C" |
| 330 | #endif |
| 331 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 332 | #endif // AOM_AV1_ENCODER_AQ_CYCLICREFRESH_H_ |