Clean-up variables in TplDepStats and RD_OPT
This CL removes the variables 'mc_count' and 'mc_saved' from
TplDepStats structure and 'mc_count_base' and 'mc_saved_base' from
RD_OPT structure.
This CL is verified to be bit-exact with no impact on encode time.
Resolution Tile Memory reduction
Single Multi
thread thread
640x360 2x1 0.42% 0.47% (2 threads)
832x480 2x1 0.65% 0.58% (2 threads)
1280x720 2x2 0.77% 0.67% (4 threads)
1920x1080 4x2 0.90% 0.77% (8 threads)
Memory measuring command:
$ command time -v ./aomenc ...
Change-Id: I1ff9df45aa3be44c343b30dfe006833951092fc9
(cherry picked from commit e01597462e2f8d0a22bc6753346203aa5434ebb8)
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 2f42908..0c3cf6d 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -432,7 +432,7 @@
(cpi->gf_group.update_type[gf_group_index] == ARF_UPDATE ||
cpi->gf_group.update_type[gf_group_index] == KFFLT_UPDATE)) {
const int dr =
- av1_get_rdmult_delta(cpi, sb_size, 0, mi_row, mi_col, orig_rdmult);
+ av1_get_rdmult_delta(cpi, sb_size, mi_row, mi_col, orig_rdmult);
x->rdmult = dr;
}
}
diff --git a/av1/encoder/encodeframe_utils.c b/av1/encoder/encodeframe_utils.c
index 5c9ac9d..7cc3bb7 100644
--- a/av1/encoder/encodeframe_utils.c
+++ b/av1/encoder/encodeframe_utils.c
@@ -647,8 +647,8 @@
}
#if !CONFIG_REALTIME_ONLY
-int av1_get_rdmult_delta(AV1_COMP *cpi, BLOCK_SIZE bsize, int analysis_type,
- int mi_row, int mi_col, int orig_rdmult) {
+int av1_get_rdmult_delta(AV1_COMP *cpi, BLOCK_SIZE bsize, int mi_row,
+ int mi_col, int orig_rdmult) {
AV1_COMMON *const cm = &cpi->common;
const GF_GROUP *const gf_group = &cpi->gf_group;
assert(IMPLIES(cpi->gf_group.size > 0,
@@ -670,7 +670,6 @@
if (cpi->gf_group.index >= MAX_TPL_FRAME_IDX) return orig_rdmult;
- int64_t mc_count = 0, mc_saved = 0;
int mi_count = 0;
const int mi_col_sr =
coded_to_superres_mi(mi_col, cm->superres_scale_denominator);
@@ -688,8 +687,6 @@
this_stats->mc_dep_dist);
intra_cost += this_stats->recrf_dist << RDDIV_BITS;
mc_dep_cost += (this_stats->recrf_dist << RDDIV_BITS) + mc_dep_delta;
- mc_count += this_stats->mc_count;
- mc_saved += this_stats->mc_saved;
mi_count++;
}
}
@@ -697,20 +694,10 @@
aom_clear_system_state();
double beta = 1.0;
- if (analysis_type == 0) {
- if (mc_dep_cost > 0 && intra_cost > 0) {
- const double r0 = cpi->rd.r0;
- const double rk = (double)intra_cost / mc_dep_cost;
- beta = (r0 / rk);
- }
- } else if (analysis_type == 1) {
- const double mc_count_base = (mi_count * cpi->rd.mc_count_base);
- beta = (mc_count + 1.0) / (mc_count_base + 1.0);
- beta = pow(beta, 0.5);
- } else if (analysis_type == 2) {
- const double mc_saved_base = (mi_count * cpi->rd.mc_saved_base);
- beta = (mc_saved + 1.0) / (mc_saved_base + 1.0);
- beta = pow(beta, 0.5);
+ if (mc_dep_cost > 0 && intra_cost > 0) {
+ const double r0 = cpi->rd.r0;
+ const double rk = (double)intra_cost / mc_dep_cost;
+ beta = (r0 / rk);
}
int rdmult = av1_get_adaptive_rdmult(cpi, beta);
@@ -855,7 +842,6 @@
if (cpi->gf_group.index >= MAX_TPL_FRAME_IDX) return base_qindex;
- int64_t mc_count = 0, mc_saved = 0;
int mi_count = 0;
const int mi_col_sr =
coded_to_superres_mi(mi_col, cm->superres_scale_denominator);
@@ -873,8 +859,6 @@
this_stats->mc_dep_dist);
intra_cost += this_stats->recrf_dist << RDDIV_BITS;
mc_dep_cost += (this_stats->recrf_dist << RDDIV_BITS) + mc_dep_delta;
- mc_count += this_stats->mc_count;
- mc_saved += this_stats->mc_saved;
mi_count++;
}
}
diff --git a/av1/encoder/encodeframe_utils.h b/av1/encoder/encodeframe_utils.h
index 91ea1ef..e8ff43b 100644
--- a/av1/encoder/encodeframe_utils.h
+++ b/av1/encoder/encodeframe_utils.h
@@ -249,8 +249,8 @@
}
}
-int av1_get_rdmult_delta(AV1_COMP *cpi, BLOCK_SIZE bsize, int analysis_type,
- int mi_row, int mi_col, int orig_rdmult);
+int av1_get_rdmult_delta(AV1_COMP *cpi, BLOCK_SIZE bsize, int mi_row,
+ int mi_col, int orig_rdmult);
int av1_active_h_edge(const AV1_COMP *cpi, int mi_row, int mi_step);
diff --git a/av1/encoder/encoder_utils.c b/av1/encoder/encoder_utils.c
index eab3442..754b4a6 100644
--- a/av1/encoder/encoder_utils.c
+++ b/av1/encoder/encoder_utils.c
@@ -369,8 +369,6 @@
int tpl_stride = tpl_frame->stride;
int64_t intra_cost_base = 0;
int64_t mc_dep_cost_base = 0;
- int64_t mc_saved_base = 0;
- int64_t mc_count_base = 0;
const int step = 1 << tpl_data->tpl_stats_block_mis_log2;
const int mi_cols_sr = av1_pixels_to_mi(cm->superres_upscaled_width);
@@ -384,8 +382,6 @@
intra_cost_base += (this_stats->recrf_dist << RDDIV_BITS);
mc_dep_cost_base +=
(this_stats->recrf_dist << RDDIV_BITS) + mc_dep_delta;
- mc_count_base += this_stats->mc_count;
- mc_saved_base += this_stats->mc_saved;
}
}
@@ -412,10 +408,6 @@
cpi->rc.gfu_boost, gfu_boost, cpi->rc.frames_to_key);
}
}
- cpi->rd.mc_count_base = (double)mc_count_base /
- (cm->mi_params.mi_rows * cm->mi_params.mi_cols);
- cpi->rd.mc_saved_base = (double)mc_saved_base /
- (cm->mi_params.mi_rows * cm->mi_params.mi_cols);
aom_clear_system_state();
}
}
diff --git a/av1/encoder/rd.h b/av1/encoder/rd.h
index ff6010a..0f0062b 100644
--- a/av1/encoder/rd.h
+++ b/av1/encoder/rd.h
@@ -79,7 +79,6 @@
int RDMULT;
double r0;
- double mc_saved_base, mc_count_base;
} RD_OPT;
typedef struct {
diff --git a/av1/encoder/tpl_model.h b/av1/encoder/tpl_model.h
index 85b3b9f..a63d1a4 100644
--- a/av1/encoder/tpl_model.h
+++ b/av1/encoder/tpl_model.h
@@ -94,8 +94,6 @@
int_mv mv[INTER_REFS_PER_FRAME];
int ref_frame_index;
int64_t pred_error[INTER_REFS_PER_FRAME];
- int64_t mc_count;
- int64_t mc_saved;
} TplDepStats;
typedef struct TplDepFrame {