ref: 9488dfced05f2b75b4b33382ad69eb5a1e25b746
parent: 623471efa30fa97657abc02ebcc251ae03d4a563
parent: 92733261a804d18af8fe24ccc7c822f28ad69198
author: Jingning Han <[email protected]>
date: Mon Jul 23 22:36:27 EDT 2018
Merge "Make the tpl model update operated in 8x8 block unit"
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -5666,8 +5666,34 @@
return round;
}
-void tpl_model_update(TplDepFrame *tpl_frame, TplDepStats *tpl_stats,
- int mi_row, int mi_col, const BLOCK_SIZE bsize) {
+void tpl_model_store(TplDepStats *tpl_stats, int mi_row, int mi_col,
+ BLOCK_SIZE bsize, int stride, int64_t intra_cost,
+ int64_t inter_cost, int ref_frame_idx, int_mv mv) {
+ const int mi_height = num_8x8_blocks_high_lookup[bsize];
+ const int mi_width = num_8x8_blocks_wide_lookup[bsize];
+ int idx, idy;
+
+ intra_cost = intra_cost / (mi_height * mi_width);
+ inter_cost = inter_cost / (mi_height * mi_width);
+
+ intra_cost = VPXMAX(1, intra_cost);
+ inter_cost = VPXMAX(1, inter_cost);
+
+ for (idy = 0; idy < mi_height; ++idy) {
+ for (idx = 0; idx < mi_width; ++idx) {
+ TplDepStats *tpl_ptr =
+ &tpl_stats[(mi_row + idy) * stride + (mi_col + idx)];
+ tpl_ptr->intra_cost = intra_cost;
+ tpl_ptr->inter_cost = inter_cost;
+ tpl_ptr->mc_dep_cost = tpl_ptr->intra_cost + tpl_ptr->mc_flow;
+ tpl_ptr->ref_frame_index = ref_frame_idx;
+ tpl_ptr->mv.as_int = mv.as_int;
+ }
+ }
+}
+
+void tpl_model_update_b(TplDepFrame *tpl_frame, TplDepStats *tpl_stats,
+ int mi_row, int mi_col, const BLOCK_SIZE bsize) {
TplDepFrame *ref_tpl_frame = &tpl_frame[tpl_stats->ref_frame_index];
TplDepStats *ref_stats = ref_tpl_frame->tpl_stats_ptr;
MV mv = tpl_stats->mv.as_mv;
@@ -5722,6 +5748,22 @@
}
}
+void tpl_model_update(TplDepFrame *tpl_frame, TplDepStats *tpl_stats,
+ int mi_row, int mi_col, const BLOCK_SIZE bsize) {
+ int idx, idy;
+ const int mi_height = num_8x8_blocks_high_lookup[bsize];
+ const int mi_width = num_8x8_blocks_wide_lookup[bsize];
+
+ for (idy = 0; idy < mi_height; ++idy) {
+ for (idx = 0; idx < mi_width; ++idx) {
+ TplDepStats *tpl_ptr =
+ &tpl_stats[(mi_row + idy) * tpl_frame->stride + (mi_col + idx)];
+ tpl_model_update_b(tpl_frame, tpl_ptr, mi_row + idy, mi_col + idx,
+ BLOCK_8X8);
+ }
+ }
+}
+
void get_quantize_error(MACROBLOCK *x, int plane, tran_low_t *coeff,
tran_low_t *qcoeff, tran_low_t *dqcoeff,
TX_SIZE tx_size, int64_t *recon_error, int64_t *sse) {
@@ -5848,9 +5890,6 @@
int64_t intra_cost;
PREDICTION_MODE mode;
- TplDepStats *tpl_stats =
- &tpl_frame->tpl_stats_ptr[mi_row * tpl_frame->stride + mi_col];
-
// Intra prediction search
for (mode = DC_PRED; mode <= TM_PRED; ++mode) {
uint8_t *src, *dst;
@@ -5952,13 +5991,16 @@
// Motion flow dependency dispenser.
best_intra_cost = VPXMAX(best_intra_cost, 1);
best_inter_cost = VPXMIN(best_inter_cost, best_intra_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->ref_frame_index = gf_picture[frame_idx].ref_frame[best_rf_idx];
- tpl_stats->mv.as_int = best_mv.as_int;
- tpl_model_update(cpi->tpl_stats, tpl_stats, mi_row, mi_col, bsize);
+ best_intra_cost <<= TPL_DEP_COST_SCALE_LOG2;
+ best_inter_cost <<= TPL_DEP_COST_SCALE_LOG2;
+
+ tpl_model_store(tpl_frame->tpl_stats_ptr, mi_row, mi_col, bsize,
+ tpl_frame->stride, best_intra_cost, best_inter_cost,
+ gf_picture[frame_idx].ref_frame[best_rf_idx], best_mv);
+
+ tpl_model_update(cpi->tpl_stats, tpl_frame->tpl_stats_ptr, mi_row, mi_col,
+ bsize);
}
}
}