aq_cyclicrefresh.h
/*
* Copyright (c) 2016, Alliance for Open Media. All rights reserved.
*
* This source code is subject to the terms of the BSD 2 Clause License and
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
* was not distributed with this source code in the LICENSE file, you can
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
* Media Patent License 1.0 was not distributed with this source code in the
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
#ifndef AOM_AV1_ENCODER_AQ_CYCLICREFRESH_H_
#define AOM_AV1_ENCODER_AQ_CYCLICREFRESH_H_
#include "av1/common/blockd.h"
#include "av1/encoder/block.h"
#include "av1/encoder/tokenize.h"
#ifdef __cplusplus
extern "C" {
#endif
// The segment ids used in cyclic refresh: from base (no boost) to increasing
// boost (higher delta-qp).
#define CR_SEGMENT_ID_BASE 0
#define CR_SEGMENT_ID_BOOST1 1
#define CR_SEGMENT_ID_BOOST2 2
// Maximum rate target ratio for setting segment delta-qp.
#define CR_MAX_RATE_TARGET_RATIO 4.0
struct CYCLIC_REFRESH {
int percent_refresh;
int percent_refresh_adjustment;
int max_qdelta_perc;
int sb_index;
int last_sb_index;
int time_for_refresh;
int target_num_seg_blocks;
int actual_num_seg1_blocks;
int actual_num_seg2_blocks;
int rdmult;
int8_t *map;
int64_t thresh_rate_sb;
int64_t thresh_dist_sb;
int16_t motion_thresh;
double rate_ratio_qdelta;
double rate_ratio_qdelta_adjustment;
int rate_boost_fac;
int qindex_delta[3];
int apply_cyclic_refresh;
int skip_over4x4;
int counter_encode_maxq_scene_change;
int use_block_sad_scene_det;
};
struct AV1_COMP;
typedef struct CYCLIC_REFRESH CYCLIC_REFRESH;
CYCLIC_REFRESH *av1_cyclic_refresh_alloc(int mi_rows, int mi_cols);
void av1_cyclic_refresh_free(CYCLIC_REFRESH *cr);
int av1_cyclic_refresh_estimate_bits_at_q(const struct AV1_COMP *cpi,
double correction_factor);
int av1_cyclic_refresh_rc_bits_per_mb(const struct AV1_COMP *cpi, int i,
double correction_factor);
void av1_cyclic_reset_segment_skip(const struct AV1_COMP *cpi,
MACROBLOCK *const x, int mi_row, int mi_col,
BLOCK_SIZE bsize, RUN_TYPE dry_run);
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);
void av1_init_cyclic_refresh_counters(MACROBLOCK *const x);
void av1_accumulate_cyclic_refresh_counters(
CYCLIC_REFRESH *const cyclic_refresh, const MACROBLOCK *const x);
void av1_cyclic_refresh_set_golden_update(struct AV1_COMP *const cpi);
void av1_cyclic_refresh_update_parameters(struct AV1_COMP *const cpi);
void av1_cyclic_refresh_setup(struct AV1_COMP *const cpi);
int av1_cyclic_refresh_get_rdmult(const CYCLIC_REFRESH *cr);
int av1_cyclic_refresh_disable_lf_cdef(struct AV1_COMP *const cpi);
static inline int cyclic_refresh_segment_id_boosted(int segment_id) {
return segment_id == CR_SEGMENT_ID_BOOST1 ||
segment_id == CR_SEGMENT_ID_BOOST2;
}
static inline int cyclic_refresh_segment_id(int segment_id) {
if (segment_id == CR_SEGMENT_ID_BOOST1)
return CR_SEGMENT_ID_BOOST1;
else if (segment_id == CR_SEGMENT_ID_BOOST2)
return CR_SEGMENT_ID_BOOST2;
else
return CR_SEGMENT_ID_BASE;
}
#ifdef __cplusplus
} // extern "C"
#endif
#endif // AOM_AV1_ENCODER_AQ_CYCLICREFRESH_H_
block.h
MACROBLOCK
struct macroblock MACROBLOCK
Encoder's parameters related to the current coding block.
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_cyclic_reset_segment_skip
void av1_cyclic_reset_segment_skip(const struct AV1_COMP *cpi, MACROBLOCK *const x, int mi_row, int mi_col, BLOCK_SIZE bsize, RUN_TYPE dry_run)
Update segment_id for blocks are skipped.
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:2897
CYCLIC_REFRESH
The stucture of CYCLIC_REFRESH.
Definition aq_cyclicrefresh.h:36
CYCLIC_REFRESH::motion_thresh
int16_t motion_thresh
Definition aq_cyclicrefresh.h:102
CYCLIC_REFRESH::thresh_rate_sb
int64_t thresh_rate_sb
Definition aq_cyclicrefresh.h:92
CYCLIC_REFRESH::time_for_refresh
int time_for_refresh
Definition aq_cyclicrefresh.h:65
CYCLIC_REFRESH::rdmult
int rdmult
Definition aq_cyclicrefresh.h:83
CYCLIC_REFRESH::max_qdelta_perc
int max_qdelta_perc
Definition aq_cyclicrefresh.h:51
CYCLIC_REFRESH::map
int8_t * map
Definition aq_cyclicrefresh.h:87
CYCLIC_REFRESH::thresh_dist_sb
int64_t thresh_dist_sb
Definition aq_cyclicrefresh.h:97
CYCLIC_REFRESH::actual_num_seg2_blocks
int actual_num_seg2_blocks
Definition aq_cyclicrefresh.h:79
CYCLIC_REFRESH::rate_ratio_qdelta_adjustment
double rate_ratio_qdelta_adjustment
Definition aq_cyclicrefresh.h:111
CYCLIC_REFRESH::last_sb_index
int last_sb_index
Definition aq_cyclicrefresh.h:59
CYCLIC_REFRESH::target_num_seg_blocks
int target_num_seg_blocks
Definition aq_cyclicrefresh.h:69
CYCLIC_REFRESH::sb_index
int sb_index
Definition aq_cyclicrefresh.h:55
CYCLIC_REFRESH::percent_refresh_adjustment
int percent_refresh_adjustment
Definition aq_cyclicrefresh.h:46
CYCLIC_REFRESH::rate_boost_fac
int rate_boost_fac
Definition aq_cyclicrefresh.h:116
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:74
CYCLIC_REFRESH::rate_ratio_qdelta
double rate_ratio_qdelta
Definition aq_cyclicrefresh.h:106