summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorAngie Chiang <angiebird@google.com>2018-10-11 01:18:45 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-10-11 01:18:45 +0000
commit6f56d8b86981b40fc36222f7e754b96fd07ce0d9 (patch)
treef2678a962d690ea2dfbe4ffbc52c6242d9d55755 /vp9
parent4a2ea54a672bffc331746e1eac0d008ceed0b5a9 (diff)
parent1072267dc1d03df3415894dd2db86db605eaf05c (diff)
downloadlibvpx-6f56d8b86981b40fc36222f7e754b96fd07ce0d9.tar
libvpx-6f56d8b86981b40fc36222f7e754b96fd07ce0d9.tar.gz
libvpx-6f56d8b86981b40fc36222f7e754b96fd07ce0d9.tar.bz2
libvpx-6f56d8b86981b40fc36222f7e754b96fd07ce0d9.zip
Merge changes Ia5978d91,I3e3754f3
* changes: Simplify mode_estimation / tpl_model_store Move [inter/intra]_cost change to mode_estimation
Diffstat (limited to 'vp9')
-rw-r--r--vp9/encoder/vp9_encoder.c74
1 files changed, 24 insertions, 50 deletions
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index 4a55e08a4..c10d010a4 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -5608,42 +5608,21 @@ int round_floor(int ref_pos, int bsize_pix) {
}
void tpl_model_store(TplDepStats *tpl_stats, int mi_row, int mi_col,
- BLOCK_SIZE bsize, int stride,
- const TplDepStats *src_stats) {
+ BLOCK_SIZE bsize, int stride) {
const int mi_height = num_8x8_blocks_high_lookup[bsize];
const int mi_width = num_8x8_blocks_wide_lookup[bsize];
+ const TplDepStats *src_stats = &tpl_stats[mi_row * stride + mi_col];
int idx, idy;
- int64_t intra_cost = src_stats->intra_cost / (mi_height * mi_width);
- int64_t inter_cost = src_stats->inter_cost / (mi_height * mi_width);
-
- TplDepStats *tpl_ptr;
-
- intra_cost = VPXMAX(1, intra_cost);
- inter_cost = VPXMAX(1, inter_cost);
-
for (idy = 0; idy < mi_height; ++idy) {
- tpl_ptr = &tpl_stats[(mi_row + idy) * stride + mi_col];
for (idx = 0; idx < mi_width; ++idx) {
-#if CONFIG_NON_GREEDY_MV
- int rf_idx;
- for (rf_idx = 0; rf_idx < 3; ++rf_idx) {
- tpl_ptr->ready[rf_idx] = src_stats->ready[rf_idx];
- tpl_ptr->mv_dist[rf_idx] = src_stats->mv_dist[rf_idx];
- tpl_ptr->mv_cost[rf_idx] = src_stats->mv_cost[rf_idx];
- tpl_ptr->inter_cost_arr[rf_idx] = src_stats->inter_cost;
- tpl_ptr->recon_error_arr[rf_idx] = src_stats->recon_error_arr[rf_idx];
- tpl_ptr->sse_arr[rf_idx] = src_stats->sse_arr[rf_idx];
- tpl_ptr->mv_arr[rf_idx].as_int = src_stats->mv_arr[rf_idx].as_int;
- }
- tpl_ptr->feature_score = src_stats->feature_score;
-#endif
- tpl_ptr->intra_cost = intra_cost;
- tpl_ptr->inter_cost = inter_cost;
+ TplDepStats *tpl_ptr = &tpl_stats[(mi_row + idy) * stride + mi_col + idx];
+ const int64_t mc_flow = tpl_ptr->mc_flow;
+ const int64_t mc_ref_cost = tpl_ptr->mc_ref_cost;
+ *tpl_ptr = *src_stats;
+ tpl_ptr->mc_flow = mc_flow;
+ tpl_ptr->mc_ref_cost = mc_ref_cost;
tpl_ptr->mc_dep_cost = tpl_ptr->intra_cost + tpl_ptr->mc_flow;
- tpl_ptr->ref_frame_index = src_stats->ref_frame_index;
- tpl_ptr->mv.as_int = src_stats->mv.as_int;
- ++tpl_ptr;
}
}
}
@@ -5789,12 +5768,11 @@ static void set_mv_limits(const VP9_COMMON *cm, MACROBLOCK *x, int mi_row,
void mode_estimation(VP9_COMP *cpi, MACROBLOCK *x, MACROBLOCKD *xd,
struct scale_factors *sf, GF_PICTURE *gf_picture,
- int frame_idx, int16_t *src_diff, tran_low_t *coeff,
- tran_low_t *qcoeff, tran_low_t *dqcoeff, int mi_row,
- int mi_col, BLOCK_SIZE bsize, TX_SIZE tx_size,
+ int frame_idx, TplDepFrame *tpl_frame, int16_t *src_diff,
+ tran_low_t *coeff, tran_low_t *qcoeff, tran_low_t *dqcoeff,
+ int mi_row, int mi_col, BLOCK_SIZE bsize, TX_SIZE tx_size,
YV12_BUFFER_CONFIG *ref_frame[], uint8_t *predictor,
- int64_t *recon_error, int64_t *sse,
- TplDepStats *tpl_stats) {
+ int64_t *recon_error, int64_t *sse) {
VP9_COMMON *cm = &cpi->common;
ThreadData *td = &cpi->td;
@@ -5813,8 +5791,10 @@ void mode_estimation(VP9_COMP *cpi, MACROBLOCK *x, MACROBLOCKD *xd,
PREDICTION_MODE mode;
int mb_y_offset = mi_row * MI_SIZE * xd->cur_buf->y_stride + mi_col * MI_SIZE;
MODE_INFO mi_above, mi_left;
-
- memset(tpl_stats, 0, sizeof(*tpl_stats));
+ const int mi_height = num_8x8_blocks_high_lookup[bsize];
+ const int mi_width = num_8x8_blocks_wide_lookup[bsize];
+ TplDepStats *tpl_stats =
+ &tpl_frame->tpl_stats_ptr[mi_row * tpl_frame->stride + mi_col];
xd->mb_to_top_edge = -((mi_row * MI_SIZE) * 8);
xd->mb_to_bottom_edge = ((cm->mi_rows - 1 - mi_row) * MI_SIZE) * 8;
@@ -5936,9 +5916,10 @@ void mode_estimation(VP9_COMP *cpi, MACROBLOCK *x, MACROBLOCKD *xd,
}
best_intra_cost = VPXMAX(best_intra_cost, 1);
best_inter_cost = VPXMIN(best_intra_cost, best_inter_cost);
- tpl_stats->inter_cost = best_inter_cost << TPL_DEP_COST_SCALE_LOG2;
- tpl_stats->intra_cost = best_intra_cost << TPL_DEP_COST_SCALE_LOG2;
- tpl_stats->mc_dep_cost = tpl_stats->intra_cost + tpl_stats->mc_flow;
+ tpl_stats->inter_cost = VPXMAX(
+ 1, (best_inter_cost << TPL_DEP_COST_SCALE_LOG2) / (mi_height * mi_width));
+ tpl_stats->intra_cost = VPXMAX(
+ 1, (best_intra_cost << TPL_DEP_COST_SCALE_LOG2) / (mi_height * mi_width));
tpl_stats->ref_frame_index = gf_picture[frame_idx].ref_frame[best_rf_idx];
tpl_stats->mv.as_int = best_mv.as_int;
}
@@ -6040,19 +6021,12 @@ void mc_flow_dispenser(VP9_COMP *cpi, GF_PICTURE *gf_picture, int frame_idx,
#endif
for (mi_row = 0; mi_row < cm->mi_rows; mi_row += mi_height) {
for (mi_col = 0; mi_col < cm->mi_cols; mi_col += mi_width) {
- TplDepStats tpl_stats;
- mode_estimation(cpi, x, xd, &sf, gf_picture, frame_idx, src_diff, coeff,
- qcoeff, dqcoeff, mi_row, mi_col, bsize, tx_size,
- ref_frame, predictor, &recon_error, &sse, &tpl_stats);
-#if CONFIG_NON_GREEDY_MV
- tpl_stats.feature_score =
- tpl_frame->tpl_stats_ptr[mi_row * tpl_frame->stride + mi_col]
- .feature_score;
-#endif
-
+ mode_estimation(cpi, x, xd, &sf, gf_picture, frame_idx, tpl_frame,
+ src_diff, coeff, qcoeff, dqcoeff, mi_row, mi_col, bsize,
+ tx_size, ref_frame, predictor, &recon_error, &sse);
// Motion flow dependency dispenser.
tpl_model_store(tpl_frame->tpl_stats_ptr, mi_row, mi_col, bsize,
- tpl_frame->stride, &tpl_stats);
+ tpl_frame->stride);
tpl_model_update(cpi->tpl_stats, tpl_frame->tpl_stats_ptr, mi_row, mi_col,
bsize);