AOMedia AV1 Codec
aq_cyclicrefresh.h
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 #ifndef AOM_AV1_ENCODER_AQ_CYCLICREFRESH_H_
13 #define AOM_AV1_ENCODER_AQ_CYCLICREFRESH_H_
14 
15 #include "av1/common/blockd.h"
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 // The segment ids used in cyclic refresh: from base (no boost) to increasing
22 // boost (higher delta-qp).
23 #define CR_SEGMENT_ID_BASE 0
24 #define CR_SEGMENT_ID_BOOST1 1
25 #define CR_SEGMENT_ID_BOOST2 2
26 
27 // Maximum rate target ratio for setting segment delta-qp.
28 #define CR_MAX_RATE_TARGET_RATIO 4.0
29 
47  int sb_index;
71  int rdmult;
75  int8_t *map;
79  uint8_t *last_coded_q_map;
84  int64_t thresh_rate_sb;
89  int64_t thresh_dist_sb;
94  int16_t motion_thresh;
103 
105  int qindex_delta[3];
106  double weight_segment;
107  int apply_cyclic_refresh;
109 };
110 
111 struct AV1_COMP;
112 
113 typedef struct CYCLIC_REFRESH CYCLIC_REFRESH;
114 
115 CYCLIC_REFRESH *av1_cyclic_refresh_alloc(int mi_rows, int mi_cols);
116 
117 void av1_cyclic_refresh_free(CYCLIC_REFRESH *cr);
118 
135  double correction_factor);
136 
155 int av1_cyclic_refresh_rc_bits_per_mb(const struct AV1_COMP *cpi, int i,
156  double correction_factor);
157 
181  MB_MODE_INFO *const mbmi, int mi_row,
182  int mi_col, BLOCK_SIZE bsize,
183  int64_t rate, int64_t dist, int skip);
184 
198 void av1_cyclic_refresh_postencode(struct AV1_COMP *const cpi);
199 
211 
228 
242 void av1_cyclic_refresh_setup(struct AV1_COMP *const cpi);
243 
244 int av1_cyclic_refresh_get_rdmult(const CYCLIC_REFRESH *cr);
245 
246 void av1_cyclic_refresh_reset_resize(struct AV1_COMP *const cpi);
247 
248 static INLINE int cyclic_refresh_segment_id_boosted(int segment_id) {
249  return segment_id == CR_SEGMENT_ID_BOOST1 ||
250  segment_id == CR_SEGMENT_ID_BOOST2;
251 }
252 
253 static INLINE int cyclic_refresh_segment_id(int segment_id) {
254  if (segment_id == CR_SEGMENT_ID_BOOST1)
255  return CR_SEGMENT_ID_BOOST1;
256  else if (segment_id == CR_SEGMENT_ID_BOOST2)
257  return CR_SEGMENT_ID_BOOST2;
258  else
259  return CR_SEGMENT_ID_BASE;
260 }
261 
262 #ifdef __cplusplus
263 } // extern "C"
264 #endif
265 
266 #endif // AOM_AV1_ENCODER_AQ_CYCLICREFRESH_H_
void av1_cyclic_refresh_postencode(struct AV1_COMP *const cpi)
Update stats after encoding frame.
int av1_cyclic_refresh_rc_bits_per_mb(const struct AV1_COMP *cpi, int i, double correction_factor)
Estimate the bits per mb, for given q = i and delta-q.
void av1_cyclic_refresh_update_parameters(struct AV1_COMP *const cpi)
Set the global/frame level parameters for cyclic refresh.
int av1_cyclic_refresh_estimate_bits_at_q(const struct AV1_COMP *cpi, double correction_factor)
Estimate the bits, incorporating the delta-q from the segments.
void av1_cyclic_refresh_set_golden_update(struct AV1_COMP *const cpi)
Set golden frame update interval nased on cyclic refresh.
void av1_cyclic_refresh_update_segment(const struct AV1_COMP *cpi, MB_MODE_INFO *const mbmi, int mi_row, int mi_col, BLOCK_SIZE bsize, int64_t rate, int64_t dist, int skip)
Update segment_id for block based on mode selected.
void av1_cyclic_refresh_setup(struct AV1_COMP *const cpi)
Setup the cyclic background refresh.
Top level encoder structure.
Definition: encoder.h:2042
The stucture of CYCLIC_REFRESH.
Definition: aq_cyclicrefresh.h:34
int16_t motion_thresh
Definition: aq_cyclicrefresh.h:94
int64_t thresh_rate_sb
Definition: aq_cyclicrefresh.h:84
int time_for_refresh
Definition: aq_cyclicrefresh.h:53
int rdmult
Definition: aq_cyclicrefresh.h:71
int max_qdelta_perc
Definition: aq_cyclicrefresh.h:43
int8_t * map
Definition: aq_cyclicrefresh.h:75
int64_t thresh_dist_sb
Definition: aq_cyclicrefresh.h:89
int actual_num_seg2_blocks
Definition: aq_cyclicrefresh.h:67
int target_num_seg_blocks
Definition: aq_cyclicrefresh.h:57
int sb_index
Definition: aq_cyclicrefresh.h:47
uint8_t * last_coded_q_map
Definition: aq_cyclicrefresh.h:79
int rate_boost_fac
Definition: aq_cyclicrefresh.h:102
int percent_refresh
Definition: aq_cyclicrefresh.h:39
int actual_num_seg1_blocks
Definition: aq_cyclicrefresh.h:62
double rate_ratio_qdelta
Definition: aq_cyclicrefresh.h:98
Stores the prediction/txfm mode of the current coding block.
Definition: blockd.h:221