ref: ab1f9054389dc14736d73c43101a0f882c120a33
parent: 924dc81e7426852d6c447fa10515e59f4f3c19bf
author: Dmitry Kovalev <dkovalev@google.com>
date: Mon Mar 10 06:58:32 EDT 2014
Cleaning up rd_pick_sb_modes() function. Changing aq_mode type from int to AQ_MODE enum. Change-Id: Ib7b5f0b70d02ded58a31dfade9c05a347f73beca
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -662,10 +662,11 @@
VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
+ MB_MODE_INFO *mbmi;
struct macroblock_plane *const p = x->plane;
struct macroblockd_plane *const pd = xd->plane;
- int i;
- int orig_rdmult = x->rdmult;
+ const AQ_MODE aq_mode = cpi->oxcf.aq_mode;
+ int i, orig_rdmult = x->rdmult;
double rdmult_ratio;
vp9_clear_system_state();
@@ -685,7 +686,8 @@
}
set_offsets(cpi, tile, mi_row, mi_col, bsize);
- xd->mi_8x8[0]->mbmi.sb_type = bsize;
+ mbmi = &xd->mi_8x8[0]->mbmi;
+ mbmi->sb_type = bsize;
for (i = 0; i < MAX_MB_PLANE; ++i) {
p[i].coeff = ctx->coeff_pbuf[i][0];
@@ -697,11 +699,11 @@
x->skip_recode = 0;
// Set to zero to make sure we do not use the previous encoded frame stats
- xd->mi_8x8[0]->mbmi.skip = 0;
+ mbmi->skip = 0;
x->source_variance = get_sby_perpixel_variance(cpi, x, bsize);
- if (cpi->oxcf.aq_mode == VARIANCE_AQ) {
+ if (aq_mode == VARIANCE_AQ) {
const int energy = bsize <= BLOCK_16X16 ? x->mb_energy
: vp9_block_energy(cpi, x, bsize);
@@ -708,12 +710,11 @@
if (cm->frame_type == KEY_FRAME ||
cpi->refresh_alt_ref_frame ||
(cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref)) {
- xd->mi_8x8[0]->mbmi.segment_id = vp9_vaq_segment_id(energy);
+ mbmi->segment_id = vp9_vaq_segment_id(energy);
} else {
const uint8_t *const map = cm->seg.update_map ? cpi->segmentation_map
: cm->last_frame_seg_map;
- xd->mi_8x8[0]->mbmi.segment_id =
- vp9_get_segment_id(cm, map, bsize, mi_row, mi_col);
+ mbmi->segment_id = vp9_get_segment_id(cm, map, bsize, mi_row, mi_col);
}
rdmult_ratio = vp9_vaq_rdmult_ratio(energy);
@@ -723,18 +724,17 @@
if (cpi->oxcf.tuning == VP8_TUNE_SSIM)
activity_masking(cpi, x);
- if (cpi->oxcf.aq_mode == VARIANCE_AQ) {
+ if (aq_mode == VARIANCE_AQ) {
vp9_clear_system_state();
x->rdmult = (int)round(x->rdmult * rdmult_ratio);
- } else if (cpi->oxcf.aq_mode == COMPLEXITY_AQ) {
+ } else if (aq_mode == COMPLEXITY_AQ) {
const int mi_offset = mi_row * cm->mi_cols + mi_col;
unsigned char complexity = cpi->complexity_map[mi_offset];
const int is_edge = (mi_row <= 1) || (mi_row >= (cm->mi_rows - 2)) ||
(mi_col <= 1) || (mi_col >= (cm->mi_cols - 2));
- if (!is_edge && (complexity > 128)) {
- x->rdmult = x->rdmult + ((x->rdmult * (complexity - 128)) / 256);
- }
+ if (!is_edge && (complexity > 128))
+ x->rdmult += ((x->rdmult * (complexity - 128)) / 256);
}
// Find best coding mode & reconstruct the MB so it is available
@@ -751,14 +751,13 @@
totaldist, bsize, ctx, best_rd);
}
- if (cpi->oxcf.aq_mode == VARIANCE_AQ) {
+ if (aq_mode == VARIANCE_AQ) {
x->rdmult = orig_rdmult;
if (*totalrate != INT_MAX) {
vp9_clear_system_state();
*totalrate = (int)round(*totalrate * rdmult_ratio);
}
- }
- else if (cpi->oxcf.aq_mode == COMPLEXITY_AQ) {
+ } else if (aq_mode == COMPLEXITY_AQ) {
x->rdmult = orig_rdmult;
}
}
--- a/vp9/encoder/vp9_onyx_int.h
+++ b/vp9/encoder/vp9_onyx_int.h
@@ -484,8 +484,8 @@
NO_AQ = 0,
VARIANCE_AQ = 1,
COMPLEXITY_AQ = 2,
- AQ_MODES_COUNT // This should always be the last member of the enum
-} AQ_MODES;
+ AQ_MODE_COUNT // This should always be the last member of the enum
+} AQ_MODE;
typedef struct {
int version; // 4 versions of bitstream defined:
@@ -553,7 +553,7 @@
int best_allowed_q;
int cq_level;
int lossless;
- int aq_mode; // Adaptive Quantization mode
+ AQ_MODE aq_mode; // Adaptive Quantization mode
// two pass datarate control
int two_pass_vbrbias; // two pass datarate control tweaks
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -156,7 +156,7 @@
RANGE_CHECK_HI(cfg, rc_max_quantizer, 0);
RANGE_CHECK_HI(cfg, rc_min_quantizer, 0);
}
- RANGE_CHECK(vp8_cfg, aq_mode, 0, AQ_MODES_COUNT - 1);
+ RANGE_CHECK(vp8_cfg, aq_mode, 0, AQ_MODE_COUNT - 1);
RANGE_CHECK_HI(cfg, g_threads, 64);
RANGE_CHECK_HI(cfg, g_lag_in_frames, MAX_LAG_BUFFERS);
--
⑨