AOMedia AV1 Codec: av1/encoder/aq_cyclicrefresh.h Source File

| 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 #include "av1/encoder/block.h"
17 #include "av1/encoder/tokenize.h"
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
36 struct CYCLIC_REFRESH {
41 int percent_refresh;
45 int max_qdelta_perc;
49 int sb_index;
55 int time_for_refresh;
59 int target_num_seg_blocks;
64 int actual_num_seg1_blocks;
69 int actual_num_seg2_blocks;
73 int rdmult;
77 int cnt_zeromv;
81 int8_t *map;
85 uint8_t *last_coded_q_map;
90 int64_t thresh_rate_sb;
95 int64_t thresh_dist_sb;
100 int16_t motion_thresh;
104 double rate_ratio_qdelta;
108 int rate_boost_fac;
109
111 int qindex_delta[3];
112 double weight_segment;
113 int apply_cyclic_refresh;
115 };
116
117 struct AV1_COMP;
118
119 typedef struct CYCLIC_REFRESH CYCLIC_REFRESH;
120
121 CYCLIC_REFRESH *av1_cyclic_refresh_alloc(int mi_rows, int mi_cols);
122
123 void av1_cyclic_refresh_free(CYCLIC_REFRESH *cr);
124
140 int av1_cyclic_refresh_estimate_bits_at_q(const struct AV1_COMP *cpi,
141 double correction_factor);
142
161 int av1_cyclic_refresh_rc_bits_per_mb(const struct AV1_COMP *cpi, int i,
162 double correction_factor);
163
188 void av1_cyclic_refresh_update_segment(const struct AV1_COMP *cpi,
189 MACROBLOCK *const x, int mi_row,
190 int mi_col, BLOCK_SIZE bsize,
191 int64_t rate, int64_t dist, int skip,
192 RUN_TYPE dry_run);
193
208 void av1_init_cyclic_refresh_counters(MACROBLOCK *const x);
209
226 void av1_accumulate_cyclic_refresh_counters(
227 CYCLIC_REFRESH *const cyclic_refresh, const MACROBLOCK *const x);
228
242 void av1_cyclic_refresh_postencode(struct AV1_COMP *const cpi);
243
254 void av1_cyclic_refresh_set_golden_update(struct AV1_COMP *const cpi);
255
271 void av1_cyclic_refresh_update_parameters(struct AV1_COMP *const cpi);
272
286 void av1_cyclic_refresh_setup(struct AV1_COMP *const cpi);
287
288 int av1_cyclic_refresh_get_rdmult(const CYCLIC_REFRESH *cr);
289
290 void av1_cyclic_refresh_reset_resize(struct AV1_COMP *const cpi);
291
292 static INLINE int cyclic_refresh_segment_id_boosted(int segment_id) {
293 return segment_id == CR_SEGMENT_ID_BOOST1 ||
294 segment_id == CR_SEGMENT_ID_BOOST2;
295 }
296
297 static INLINE int cyclic_refresh_segment_id(int segment_id) {
298 if (segment_id == CR_SEGMENT_ID_BOOST1)
299 return CR_SEGMENT_ID_BOOST1;
300 else if (segment_id == CR_SEGMENT_ID_BOOST2)
301 return CR_SEGMENT_ID_BOOST2;
302 else
303 return CR_SEGMENT_ID_BASE;
304 }
305
306 #ifdef __cplusplus
307 } // extern "C"
308 #endif
309
310 #endif // AOM_AV1_ENCODER_AQ_CYCLICREFRESH_H_
block.h
av1_cyclic_refresh_postencode
void av1_cyclic_refresh_postencode(struct AV1_COMP *const cpi)
Update stats after encoding frame.
av1_cyclic_refresh_rc_bits_per_mb
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.
av1_cyclic_refresh_update_parameters
void av1_cyclic_refresh_update_parameters(struct AV1_COMP *const cpi)
Set the global/frame level parameters for cyclic refresh.
av1_cyclic_refresh_update_segment
void av1_cyclic_refresh_update_segment(const struct AV1_COMP *cpi, MACROBLOCK *const x, int mi_row, int mi_col, BLOCK_SIZE bsize, int64_t rate, int64_t dist, int skip, RUN_TYPE dry_run)
Update segment_id for block based on mode selected.
av1_cyclic_refresh_estimate_bits_at_q
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.
av1_accumulate_cyclic_refresh_counters
void av1_accumulate_cyclic_refresh_counters(CYCLIC_REFRESH *const cyclic_refresh, const MACROBLOCK *const x)
Accumulate cyclic refresh counters.
av1_cyclic_refresh_set_golden_update
void av1_cyclic_refresh_set_golden_update(struct AV1_COMP *const cpi)
Set golden frame update interval nased on cyclic refresh.
av1_init_cyclic_refresh_counters
void av1_init_cyclic_refresh_counters(MACROBLOCK *const x)
Initialize counters used for cyclic refresh.
av1_cyclic_refresh_setup
void av1_cyclic_refresh_setup(struct AV1_COMP *const cpi)
Setup the cyclic background refresh.
AV1_COMP
Top level encoder structure.
Definition: encoder.h:2095
CYCLIC_REFRESH
The stucture of CYCLIC_REFRESH.
Definition: aq_cyclicrefresh.h:36
CYCLIC_REFRESH::motion_thresh
int16_t motion_thresh
Definition: aq_cyclicrefresh.h:100
CYCLIC_REFRESH::thresh_rate_sb
int64_t thresh_rate_sb
Definition: aq_cyclicrefresh.h:90
CYCLIC_REFRESH::time_for_refresh
int time_for_refresh
Definition: aq_cyclicrefresh.h:55
CYCLIC_REFRESH::rdmult
int rdmult
Definition: aq_cyclicrefresh.h:73
CYCLIC_REFRESH::max_qdelta_perc
int max_qdelta_perc
Definition: aq_cyclicrefresh.h:45
CYCLIC_REFRESH::map
int8_t * map
Definition: aq_cyclicrefresh.h:81
CYCLIC_REFRESH::cnt_zeromv
int cnt_zeromv
Definition: aq_cyclicrefresh.h:77
CYCLIC_REFRESH::thresh_dist_sb
int64_t thresh_dist_sb
Definition: aq_cyclicrefresh.h:95
CYCLIC_REFRESH::actual_num_seg2_blocks
int actual_num_seg2_blocks
Definition: aq_cyclicrefresh.h:69
CYCLIC_REFRESH::target_num_seg_blocks
int target_num_seg_blocks
Definition: aq_cyclicrefresh.h:59
CYCLIC_REFRESH::sb_index
int sb_index
Definition: aq_cyclicrefresh.h:49
CYCLIC_REFRESH::last_coded_q_map
uint8_t * last_coded_q_map
Definition: aq_cyclicrefresh.h:85
CYCLIC_REFRESH::rate_boost_fac
int rate_boost_fac
Definition: aq_cyclicrefresh.h:108
CYCLIC_REFRESH::percent_refresh
int percent_refresh
Definition: aq_cyclicrefresh.h:41
CYCLIC_REFRESH::actual_num_seg1_blocks
int actual_num_seg1_blocks
Definition: aq_cyclicrefresh.h:64
CYCLIC_REFRESH::rate_ratio_qdelta
double rate_ratio_qdelta
Definition: aq_cyclicrefresh.h:104
macroblock
Encoder's parameters related to the current coding block.
Definition: block.h:846