| Index: source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c
|
| diff --git a/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c b/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c
|
| index b61906388b8807b286fdabfc7af951bafe8dd9c2..813c339823c3633faf8dd50c128e10568901e4aa 100644
|
| --- a/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c
|
| +++ b/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c
|
| @@ -11,6 +11,8 @@
|
| #include <limits.h>
|
| #include <math.h>
|
|
|
| +#include "vpx_ports/system_state.h"
|
| +
|
| #include "vp9/encoder/vp9_aq_cyclicrefresh.h"
|
|
|
| #include "vp9/common/vp9_seg_common.h"
|
| @@ -221,8 +223,8 @@ void vp9_cyclic_refresh_update_segment(VP9_COMP *const cpi,
|
| CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
|
| const int bw = num_8x8_blocks_wide_lookup[bsize];
|
| const int bh = num_8x8_blocks_high_lookup[bsize];
|
| - const int xmis = MIN(cm->mi_cols - mi_col, bw);
|
| - const int ymis = MIN(cm->mi_rows - mi_row, bh);
|
| + const int xmis = VPXMIN(cm->mi_cols - mi_col, bw);
|
| + const int ymis = VPXMIN(cm->mi_rows - mi_row, bh);
|
| const int block_index = mi_row * cm->mi_cols + mi_col;
|
| const int refresh_this_block = candidate_refresh_aq(cr, mbmi, rate, dist,
|
| bsize);
|
| @@ -414,10 +416,10 @@ static void cyclic_refresh_update_map(VP9_COMP *const cpi) {
|
| assert(mi_col >= 0 && mi_col < cm->mi_cols);
|
| bl_index = mi_row * cm->mi_cols + mi_col;
|
| // Loop through all 8x8 blocks in superblock and update map.
|
| - xmis = MIN(cm->mi_cols - mi_col,
|
| - num_8x8_blocks_wide_lookup[BLOCK_64X64]);
|
| - ymis = MIN(cm->mi_rows - mi_row,
|
| - num_8x8_blocks_high_lookup[BLOCK_64X64]);
|
| + xmis =
|
| + VPXMIN(cm->mi_cols - mi_col, num_8x8_blocks_wide_lookup[BLOCK_64X64]);
|
| + ymis =
|
| + VPXMIN(cm->mi_rows - mi_row, num_8x8_blocks_high_lookup[BLOCK_64X64]);
|
| for (y = 0; y < ymis; y++) {
|
| for (x = 0; x < xmis; x++) {
|
| const int bl_index2 = bl_index + y * cm->mi_cols + x;
|
| @@ -459,7 +461,10 @@ void vp9_cyclic_refresh_update_parameters(VP9_COMP *const cpi) {
|
| cr->time_for_refresh = 0;
|
| // Use larger delta-qp (increase rate_ratio_qdelta) for first few (~4)
|
| // periods of the refresh cycle, after a key frame.
|
| - if (rc->frames_since_key < 4 * cr->percent_refresh)
|
| + // Account for larger interval on base layer for temporal layers.
|
| + if (cr->percent_refresh > 0 &&
|
| + rc->frames_since_key < (4 * cpi->svc.number_temporal_layers) *
|
| + (100 / cr->percent_refresh))
|
| cr->rate_ratio_qdelta = 3.0;
|
| else
|
| cr->rate_ratio_qdelta = 2.0;
|
| @@ -503,7 +508,7 @@ void vp9_cyclic_refresh_setup(VP9_COMP *const cpi) {
|
| int qindex_delta = 0;
|
| int qindex2;
|
| const double q = vp9_convert_qindex_to_q(cm->base_qindex, cm->bit_depth);
|
| - vp9_clear_system_state();
|
| + vpx_clear_system_state();
|
| // Set rate threshold to some multiple (set to 2 for now) of the target
|
| // rate (target is given by sb64_target_rate and scaled by 256).
|
| cr->thresh_rate_sb = ((int64_t)(rc->sb64_target_rate) << 8) << 2;
|
| @@ -546,8 +551,9 @@ void vp9_cyclic_refresh_setup(VP9_COMP *const cpi) {
|
|
|
| // Set a more aggressive (higher) q delta for segment BOOST2.
|
| qindex_delta = compute_deltaq(
|
| - cpi, cm->base_qindex, MIN(CR_MAX_RATE_TARGET_RATIO,
|
| - 0.1 * cr->rate_boost_fac * cr->rate_ratio_qdelta));
|
| + cpi, cm->base_qindex,
|
| + VPXMIN(CR_MAX_RATE_TARGET_RATIO,
|
| + 0.1 * cr->rate_boost_fac * cr->rate_ratio_qdelta));
|
| cr->qindex_delta[2] = qindex_delta;
|
| vp9_set_segdata(seg, CR_SEGMENT_ID_BOOST2, SEG_LVL_ALT_Q, qindex_delta);
|
|
|
|
|