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
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index e8a5711..1f0fca7 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -429,7 +429,7 @@
cpi->oxcf.q_cfg.deltaq_mode == NO_DELTA_Q && gf_group_index > 0 &&
cpi->gf_group.update_type[gf_group_index] == ARF_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 9a67f01..23a9cc1 100644
--- a/av1/encoder/encodeframe_utils.c
+++ b/av1/encoder/encodeframe_utils.c
@@ -643,8 +643,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,
@@ -666,7 +666,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);
@@ -684,8 +683,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++;
}
}
@@ -693,20 +690,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);
@@ -880,7 +867,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);
@@ -898,8 +884,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 5dd5f0b..55318aa 100644
--- a/av1/encoder/encodeframe_utils.h
+++ b/av1/encoder/encodeframe_utils.h
@@ -244,8 +244,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 9eb87f2..4dade09 100644
--- a/av1/encoder/encoder_utils.c
+++ b/av1/encoder/encoder_utils.c
@@ -498,8 +498,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);
@@ -513,8 +511,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;
}
}
@@ -541,10 +537,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 6227981..548fccf 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 b4d3db2..40aabae 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 {