diff options
Diffstat (limited to 'third_party/aom/av1/encoder/rd.c')
-rw-r--r-- | third_party/aom/av1/encoder/rd.c | 146 |
1 files changed, 93 insertions, 53 deletions
diff --git a/third_party/aom/av1/encoder/rd.c b/third_party/aom/av1/encoder/rd.c index f06e569e7..94c3bb96d 100644 --- a/third_party/aom/av1/encoder/rd.c +++ b/third_party/aom/av1/encoder/rd.c @@ -330,7 +330,6 @@ static void set_block_thresholds(const AV1_COMMON *cm, RD_OPT *rd) { } } -#if CONFIG_REF_MV void av1_set_mvcost(MACROBLOCK *x, MV_REFERENCE_FRAME ref_frame, int ref, int ref_mv_idx) { MB_MODE_INFO_EXT *mbmi_ext = x->mbmi_ext; @@ -340,19 +339,14 @@ void av1_set_mvcost(MACROBLOCK *x, MV_REFERENCE_FRAME ref_frame, int ref, (void)ref_frame; x->mvcost = x->mv_cost_stack[nmv_ctx]; x->nmvjointcost = x->nmv_vec_cost[nmv_ctx]; - x->mvsadcost = x->mvcost; - x->nmvjointsadcost = x->nmvjointcost; } -#endif void av1_initialize_rd_consts(AV1_COMP *cpi) { AV1_COMMON *const cm = &cpi->common; MACROBLOCK *const x = &cpi->td.mb; RD_OPT *const rd = &cpi->rd; int i; -#if CONFIG_REF_MV int nmv_ctx; -#endif aom_clear_system_state(); @@ -363,7 +357,6 @@ void av1_initialize_rd_consts(AV1_COMP *cpi) { set_block_thresholds(cm, rd); -#if CONFIG_REF_MV for (nmv_ctx = 0; nmv_ctx < NMV_CONTEXTS; ++nmv_ctx) { av1_build_nmv_cost_table( x->nmv_vec_cost[nmv_ctx], @@ -373,19 +366,11 @@ void av1_initialize_rd_consts(AV1_COMP *cpi) { } x->mvcost = x->mv_cost_stack[0]; x->nmvjointcost = x->nmv_vec_cost[0]; - x->mvsadcost = x->mvcost; - x->nmvjointsadcost = x->nmvjointcost; -#else - av1_build_nmv_cost_table( - x->nmvjointcost, cm->allow_high_precision_mv ? x->nmvcost_hp : x->nmvcost, - &cm->fc->nmvc, cm->allow_high_precision_mv); -#endif if (cpi->oxcf.pass != 1) { av1_fill_token_costs(x->token_costs, cm->fc->coef_probs); - if (cpi->sf.partition_search_type != VAR_BASED_PARTITION || - cm->frame_type == KEY_FRAME) { + if (cm->frame_type == KEY_FRAME) { #if CONFIG_EXT_PARTITION_TYPES for (i = 0; i < PARTITION_PLOFFSET; ++i) av1_cost_tokens(cpi->partition_cost[i], cm->fc->partition_prob[i], @@ -425,7 +410,6 @@ void av1_initialize_rd_consts(AV1_COMP *cpi) { fill_mode_costs(cpi); if (!frame_is_intra_only(cm)) { -#if CONFIG_REF_MV for (i = 0; i < NEWMV_MODE_CONTEXTS; ++i) { cpi->newmv_mode_cost[i][0] = av1_cost_bit(cm->fc->newmv_prob[i], 0); cpi->newmv_mode_cost[i][1] = av1_cost_bit(cm->fc->newmv_prob[i], 1); @@ -445,20 +429,17 @@ void av1_initialize_rd_consts(AV1_COMP *cpi) { cpi->drl_mode_cost0[i][0] = av1_cost_bit(cm->fc->drl_prob[i], 0); cpi->drl_mode_cost0[i][1] = av1_cost_bit(cm->fc->drl_prob[i], 1); } -#else - for (i = 0; i < INTER_MODE_CONTEXTS; ++i) - av1_cost_tokens((int *)cpi->inter_mode_cost[i], - cm->fc->inter_mode_probs[i], av1_inter_mode_tree); -#endif // CONFIG_REF_MV #if CONFIG_EXT_INTER for (i = 0; i < INTER_MODE_CONTEXTS; ++i) av1_cost_tokens((int *)cpi->inter_compound_mode_cost[i], cm->fc->inter_compound_mode_probs[i], av1_inter_compound_mode_tree); +#if CONFIG_INTERINTRA for (i = 0; i < BLOCK_SIZE_GROUPS; ++i) av1_cost_tokens((int *)cpi->interintra_mode_cost[i], cm->fc->interintra_mode_prob[i], av1_interintra_mode_tree); +#endif // CONFIG_INTERINTRA #endif // CONFIG_EXT_INTER #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION for (i = BLOCK_8X8; i < BLOCK_SIZES; i++) { @@ -575,9 +556,15 @@ static void get_entropy_contexts_plane( const ENTROPY_CONTEXT *const above = pd->above_context; const ENTROPY_CONTEXT *const left = pd->left_context; +#if CONFIG_LV_MAP + memcpy(t_above, above, sizeof(ENTROPY_CONTEXT) * num_4x4_w); + memcpy(t_left, left, sizeof(ENTROPY_CONTEXT) * num_4x4_h); + return; +#endif // CONFIG_LV_MAP + int i; -#if CONFIG_CB4X4 +#if CONFIG_CHROMA_2X2 switch (tx_size) { case TX_2X2: memcpy(t_above, above, sizeof(ENTROPY_CONTEXT) * num_4x4_w); @@ -609,6 +596,20 @@ static void get_entropy_contexts_plane( t_left[i] = !!(*(const uint64_t *)&left[i] | *(const uint64_t *)&left[i + 8]); break; +#if CONFIG_TX64X64 + case TX_64X64: + for (i = 0; i < num_4x4_w; i += 32) + t_above[i] = + !!(*(const uint64_t *)&above[i] | *(const uint64_t *)&above[i + 8] | + *(const uint64_t *)&above[i + 16] | + *(const uint64_t *)&above[i + 24]); + for (i = 0; i < num_4x4_h; i += 32) + t_left[i] = + !!(*(const uint64_t *)&left[i] | *(const uint64_t *)&left[i + 8] | + *(const uint64_t *)&left[i + 16] | + *(const uint64_t *)&left[i + 24]); + break; +#endif // CONFIG_TX64X64 case TX_4X8: for (i = 0; i < num_4x4_w; i += 2) t_above[i] = !!*(const uint16_t *)&above[i]; @@ -647,11 +648,39 @@ static void get_entropy_contexts_plane( for (i = 0; i < num_4x4_h; i += 8) t_left[i] = !!*(const uint64_t *)&left[i]; break; +#if CONFIG_EXT_TX && CONFIG_RECT_TX && CONFIG_RECT_TX_EXT + case TX_4X16: + for (i = 0; i < num_4x4_w; i += 2) + t_above[i] = !!*(const uint16_t *)&above[i]; + for (i = 0; i < num_4x4_h; i += 8) + t_left[i] = !!*(const uint64_t *)&left[i]; + break; + case TX_16X4: + for (i = 0; i < num_4x4_w; i += 8) + t_above[i] = !!*(const uint64_t *)&above[i]; + for (i = 0; i < num_4x4_h; i += 2) + t_left[i] = !!*(const uint16_t *)&left[i]; + break; + case TX_8X32: + for (i = 0; i < num_4x4_w; i += 4) + t_above[i] = !!*(const uint32_t *)&above[i]; + for (i = 0; i < num_4x4_h; i += 16) + t_left[i] = + !!(*(const uint64_t *)&left[i] | *(const uint64_t *)&left[i + 8]); + break; + case TX_32X8: + for (i = 0; i < num_4x4_w; i += 16) + t_above[i] = + !!(*(const uint64_t *)&above[i] | *(const uint64_t *)&above[i + 8]); + for (i = 0; i < num_4x4_h; i += 4) + t_left[i] = !!*(const uint32_t *)&left[i]; + break; +#endif // CONFIG_EXT_TX && CONFIG_RECT_TX && CONFIG_RECT_TX_EXT default: assert(0 && "Invalid transform size."); break; } return; -#endif +#endif // CONFIG_CHROMA_2X2 switch (tx_size) { case TX_4X4: @@ -720,6 +749,30 @@ static void get_entropy_contexts_plane( for (i = 0; i < num_4x4_h; i += 4) t_left[i] = !!*(const uint32_t *)&left[i]; break; +#if CONFIG_EXT_TX && CONFIG_RECT_TX && CONFIG_RECT_TX_EXT + case TX_4X16: + memcpy(t_above, above, sizeof(ENTROPY_CONTEXT) * num_4x4_w); + for (i = 0; i < num_4x4_h; i += 4) + t_left[i] = !!*(const uint32_t *)&left[i]; + break; + case TX_16X4: + for (i = 0; i < num_4x4_w; i += 4) + t_above[i] = !!*(const uint32_t *)&above[i]; + memcpy(t_left, left, sizeof(ENTROPY_CONTEXT) * num_4x4_h); + break; + case TX_8X32: + for (i = 0; i < num_4x4_w; i += 2) + t_above[i] = !!*(const uint16_t *)&above[i]; + for (i = 0; i < num_4x4_h; i += 8) + t_left[i] = !!*(const uint64_t *)&left[i]; + break; + case TX_32X8: + for (i = 0; i < num_4x4_w; i += 8) + t_above[i] = !!*(const uint64_t *)&above[i]; + for (i = 0; i < num_4x4_h; i += 2) + t_left[i] = !!*(const uint16_t *)&left[i]; + break; +#endif // CONFIG_EXT_TX && CONFIG_RECT_TX && CONFIG_RECT_TX_EXT default: assert(0 && "Invalid transform size."); break; } } @@ -728,7 +781,12 @@ void av1_get_entropy_contexts(BLOCK_SIZE bsize, TX_SIZE tx_size, const struct macroblockd_plane *pd, ENTROPY_CONTEXT t_above[2 * MAX_MIB_SIZE], ENTROPY_CONTEXT t_left[2 * MAX_MIB_SIZE]) { +#if CONFIG_CB4X4 && !CONFIG_CHROMA_2X2 + const BLOCK_SIZE plane_bsize = + AOMMAX(BLOCK_4X4, get_plane_block_size(bsize, pd)); +#else const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd); +#endif get_entropy_contexts_plane(plane_bsize, tx_size, pd, t_above, t_left); } @@ -740,27 +798,25 @@ void av1_mv_pred(const AV1_COMP *cpi, MACROBLOCK *x, uint8_t *ref_y_buffer, int best_sad = INT_MAX; int this_sad = INT_MAX; int max_mv = 0; - int near_same_nearest; uint8_t *src_y_ptr = x->plane[0].src.buf; uint8_t *ref_y_ptr; - const int num_mv_refs = - MAX_MV_REF_CANDIDATES + - (cpi->sf.adaptive_motion_search && block_size < x->max_partition_size); - - MV pred_mv[3]; - pred_mv[0] = x->mbmi_ext->ref_mvs[ref_frame][0].as_mv; - pred_mv[1] = x->mbmi_ext->ref_mvs[ref_frame][1].as_mv; - pred_mv[2] = x->pred_mv[ref_frame]; + MV pred_mv[MAX_MV_REF_CANDIDATES + 1]; + int num_mv_refs = 0; + + pred_mv[num_mv_refs++] = x->mbmi_ext->ref_mvs[ref_frame][0].as_mv; + if (x->mbmi_ext->ref_mvs[ref_frame][0].as_int != + x->mbmi_ext->ref_mvs[ref_frame][1].as_int) { + pred_mv[num_mv_refs++] = x->mbmi_ext->ref_mvs[ref_frame][1].as_mv; + } + if (cpi->sf.adaptive_motion_search && block_size < x->max_partition_size) + pred_mv[num_mv_refs++] = x->pred_mv[ref_frame]; + assert(num_mv_refs <= (int)(sizeof(pred_mv) / sizeof(pred_mv[0]))); - near_same_nearest = x->mbmi_ext->ref_mvs[ref_frame][0].as_int == - x->mbmi_ext->ref_mvs[ref_frame][1].as_int; // Get the sad for each candidate reference mv. for (i = 0; i < num_mv_refs; ++i) { const MV *this_mv = &pred_mv[i]; int fp_row, fp_col; - - if (i == 1 && near_same_nearest) continue; fp_row = (this_mv->row + 3 + (this_mv->row >= 0)) >> 3; fp_col = (this_mv->col + 3 + (this_mv->col >= 0)) >> 3; max_mv = AOMMAX(max_mv, AOMMAX(abs(this_mv->row), abs(this_mv->col)) >> 3); @@ -959,8 +1015,6 @@ void av1_set_rd_speed_thresholds(AV1_COMP *cpi) { #if CONFIG_EXT_INTER - rd->thresh_mult[THR_COMP_NEAREST_NEARLA] += 1200; - rd->thresh_mult[THR_COMP_NEAR_NEARESTLA] += 1200; rd->thresh_mult[THR_COMP_NEAR_NEARLA] += 1200; rd->thresh_mult[THR_COMP_NEAREST_NEWLA] += 1500; rd->thresh_mult[THR_COMP_NEW_NEARESTLA] += 1500; @@ -970,8 +1024,6 @@ void av1_set_rd_speed_thresholds(AV1_COMP *cpi) { rd->thresh_mult[THR_COMP_ZERO_ZEROLA] += 2500; #if CONFIG_EXT_REFS - rd->thresh_mult[THR_COMP_NEAREST_NEARL2A] += 1200; - rd->thresh_mult[THR_COMP_NEAR_NEARESTL2A] += 1200; rd->thresh_mult[THR_COMP_NEAR_NEARL2A] += 1200; rd->thresh_mult[THR_COMP_NEAREST_NEWL2A] += 1500; rd->thresh_mult[THR_COMP_NEW_NEARESTL2A] += 1500; @@ -980,8 +1032,6 @@ void av1_set_rd_speed_thresholds(AV1_COMP *cpi) { rd->thresh_mult[THR_COMP_NEW_NEWL2A] += 2000; rd->thresh_mult[THR_COMP_ZERO_ZEROL2A] += 2500; - rd->thresh_mult[THR_COMP_NEAREST_NEARL3A] += 1200; - rd->thresh_mult[THR_COMP_NEAR_NEARESTL3A] += 1200; rd->thresh_mult[THR_COMP_NEAR_NEARL3A] += 1200; rd->thresh_mult[THR_COMP_NEAREST_NEWL3A] += 1500; rd->thresh_mult[THR_COMP_NEW_NEARESTL3A] += 1500; @@ -991,8 +1041,6 @@ void av1_set_rd_speed_thresholds(AV1_COMP *cpi) { rd->thresh_mult[THR_COMP_ZERO_ZEROL3A] += 2500; #endif // CONFIG_EXT_REFS - rd->thresh_mult[THR_COMP_NEAREST_NEARGA] += 1200; - rd->thresh_mult[THR_COMP_NEAR_NEARESTGA] += 1200; rd->thresh_mult[THR_COMP_NEAR_NEARGA] += 1200; rd->thresh_mult[THR_COMP_NEAREST_NEWGA] += 1500; rd->thresh_mult[THR_COMP_NEW_NEARESTGA] += 1500; @@ -1002,8 +1050,6 @@ void av1_set_rd_speed_thresholds(AV1_COMP *cpi) { rd->thresh_mult[THR_COMP_ZERO_ZEROGA] += 2500; #if CONFIG_EXT_REFS - rd->thresh_mult[THR_COMP_NEAREST_NEARLB] += 1200; - rd->thresh_mult[THR_COMP_NEAR_NEARESTLB] += 1200; rd->thresh_mult[THR_COMP_NEAR_NEARLB] += 1200; rd->thresh_mult[THR_COMP_NEAREST_NEWLB] += 1500; rd->thresh_mult[THR_COMP_NEW_NEARESTLB] += 1500; @@ -1012,8 +1058,6 @@ void av1_set_rd_speed_thresholds(AV1_COMP *cpi) { rd->thresh_mult[THR_COMP_NEW_NEWLB] += 2000; rd->thresh_mult[THR_COMP_ZERO_ZEROLB] += 2500; - rd->thresh_mult[THR_COMP_NEAREST_NEARL2B] += 1200; - rd->thresh_mult[THR_COMP_NEAR_NEARESTL2B] += 1200; rd->thresh_mult[THR_COMP_NEAR_NEARL2B] += 1200; rd->thresh_mult[THR_COMP_NEAREST_NEWL2B] += 1500; rd->thresh_mult[THR_COMP_NEW_NEARESTL2B] += 1500; @@ -1022,8 +1066,6 @@ void av1_set_rd_speed_thresholds(AV1_COMP *cpi) { rd->thresh_mult[THR_COMP_NEW_NEWL2B] += 2000; rd->thresh_mult[THR_COMP_ZERO_ZEROL2B] += 2500; - rd->thresh_mult[THR_COMP_NEAREST_NEARL3B] += 1200; - rd->thresh_mult[THR_COMP_NEAR_NEARESTL3B] += 1200; rd->thresh_mult[THR_COMP_NEAR_NEARL3B] += 1200; rd->thresh_mult[THR_COMP_NEAREST_NEWL3B] += 1500; rd->thresh_mult[THR_COMP_NEW_NEARESTL3B] += 1500; @@ -1032,8 +1074,6 @@ void av1_set_rd_speed_thresholds(AV1_COMP *cpi) { rd->thresh_mult[THR_COMP_NEW_NEWL3B] += 2000; rd->thresh_mult[THR_COMP_ZERO_ZEROL3B] += 2500; - rd->thresh_mult[THR_COMP_NEAREST_NEARGB] += 1200; - rd->thresh_mult[THR_COMP_NEAR_NEARESTGB] += 1200; rd->thresh_mult[THR_COMP_NEAR_NEARGB] += 1200; rd->thresh_mult[THR_COMP_NEAREST_NEWGB] += 1500; rd->thresh_mult[THR_COMP_NEW_NEARESTGB] += 1500; |