diff options
-rw-r--r-- | vp9/common/vp9_onyxc_int.h | 6 | ||||
-rw-r--r-- | vp9/decoder/vp9_decodemv.c | 3 | ||||
-rw-r--r-- | vp9/decoder/vp9_decodframe.c | 9 | ||||
-rw-r--r-- | vp9/encoder/vp9_bitstream.c | 27 | ||||
-rw-r--r-- | vp9/encoder/vp9_onyx_if.c | 8 | ||||
-rw-r--r-- | vp9/encoder/vp9_onyx_int.h | 10 | ||||
-rw-r--r-- | vp9/encoder/vp9_rdopt.c | 119 | ||||
-rw-r--r-- | vp9/vp9_cx_iface.c | 114 |
8 files changed, 174 insertions, 122 deletions
diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h index 946c33dd5..12bcabd6e 100644 --- a/vp9/common/vp9_onyxc_int.h +++ b/vp9/common/vp9_onyxc_int.h @@ -148,6 +148,12 @@ typedef struct VP9Common { int show_frame; int last_show_frame; + // Flag signaling that the frame is encoded using only INTRA modes. + int intra_only; + + // Flag signaling that the frame context should be reset to default values. + int reset_frame_context; + int frame_flags; // MBs, mb_rows/cols is in 16-pixel units; mi_rows/cols is in // MODE_INFO (8-pixel) units. diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c index 2449a7bec..91a8769a0 100644 --- a/vp9/decoder/vp9_decodemv.c +++ b/vp9/decoder/vp9_decodemv.c @@ -815,9 +815,6 @@ void vp9_decode_mb_mode_mv(VP9D_COMP* const pbi, kfread_modes(pbi, mi, mi_row, mi_col, r); } else { read_mb_modes_mv(pbi, mi, &mi->mbmi, mi_row, mi_col, r); - set_scale_factors(xd, - mi->mbmi.ref_frame - 1, mi->mbmi.second_ref_frame - 1, - cm->active_ref_scale); } if (1) { diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c index b58204df6..5271411e4 100644 --- a/vp9/decoder/vp9_decodframe.c +++ b/vp9/decoder/vp9_decodframe.c @@ -953,16 +953,25 @@ size_t read_uncompressed_header(VP9D_COMP *pbi, "Invalid frame sync code"); } } + setup_frame_size(pbi, scaling_active, rb); + if (!cm->show_frame) { + cm->intra_only = vp9_rb_read_bit(rb); + } else { + cm->intra_only = 0; + } + cm->frame_context_idx = vp9_rb_read_literal(rb, NUM_FRAME_CONTEXTS_LG2); cm->clr_type = (YUV_TYPE)vp9_rb_read_bit(rb); cm->error_resilient_mode = vp9_rb_read_bit(rb); if (!cm->error_resilient_mode) { + cm->reset_frame_context = vp9_rb_read_bit(rb); cm->refresh_frame_context = vp9_rb_read_bit(rb); cm->frame_parallel_decoding_mode = vp9_rb_read_bit(rb); } else { + cm->reset_frame_context = 0; cm->refresh_frame_context = 0; cm->frame_parallel_decoding_mode = 1; } diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c index 102ec6f8a..718130e56 100644 --- a/vp9/encoder/vp9_bitstream.c +++ b/vp9/encoder/vp9_bitstream.c @@ -1023,13 +1023,13 @@ static void build_tree_distribution(vp9_coeff_probs_model *coef_probs, VP9_COMP *cpi, vp9_coeff_accum *context_counters, #endif - vp9_coeff_stats_model *coef_branch_ct, + vp9_coeff_stats *coef_branch_ct, int block_types) { int i, j, k, l; #ifdef ENTROPY_STATS int t = 0; #endif - unsigned int model_counts[UNCONSTRAINED_NODES + 1]; + vp9_prob full_probs[ENTROPY_NODES]; for (i = 0; i < block_types; ++i) { for (j = 0; j < REF_TYPES; ++j) { @@ -1037,11 +1037,12 @@ static void build_tree_distribution(vp9_coeff_probs_model *coef_probs, for (l = 0; l < PREV_COEF_CONTEXTS; ++l) { if (l >= 3 && k == 0) continue; - vp9_full_to_model_count(model_counts, coef_counts[i][j][k][l]); - vp9_tree_probs_from_distribution(vp9_coefmodel_tree, - coef_probs[i][j][k][l], + vp9_tree_probs_from_distribution(vp9_coef_tree, + full_probs, coef_branch_ct[i][j][k][l], - model_counts, 0); + coef_counts[i][j][k][l], 0); + vpx_memcpy(coef_probs[i][j][k][l], full_probs, + sizeof(vp9_prob) * UNCONSTRAINED_NODES); #if CONFIG_BALANCED_COEFTREE coef_branch_ct[i][j][k][l][1][1] = eob_branch_ct[i][j][k][l] - coef_branch_ct[i][j][k][l][1][0]; @@ -1108,14 +1109,13 @@ static void update_coef_probs_common( #endif vp9_coeff_probs_model *new_frame_coef_probs, vp9_coeff_probs_model *old_frame_coef_probs, - vp9_coeff_stats_model *frame_branch_ct, + vp9_coeff_stats *frame_branch_ct, TX_SIZE tx_size) { int i, j, k, l, t; int update[2] = {0, 0}; int savings; const int entropy_nodes_update = UNCONSTRAINED_NODES; - // vp9_prob bestupd = find_coef_update_prob(cpi); const int tstart = 0; /* dry run to see if there is any udpate at all needed */ @@ -1129,7 +1129,7 @@ static void update_coef_probs_common( vp9_prob newp = new_frame_coef_probs[i][j][k][l][t]; const vp9_prob oldp = old_frame_coef_probs[i][j][k][l][t]; const vp9_prob upd = vp9_coef_update_prob[t]; - int s; // = prev_coef_savings[t]; + int s; int u = 0; if (l >= 3 && k == 0) @@ -1171,11 +1171,10 @@ static void update_coef_probs_common( vp9_prob newp = new_frame_coef_probs[i][j][k][l][t]; vp9_prob *oldp = old_frame_coef_probs[i][j][k][l] + t; const vp9_prob upd = vp9_coef_update_prob[t]; - int s; // = prev_coef_savings[t]; + int s; int u = 0; if (l >= 3 && k == 0) continue; - if (t == PIVOT_NODE) s = prob_diff_update_savings_search_model( frame_branch_ct[i][j][k][l][0], @@ -1430,7 +1429,6 @@ static void encode_segmentation(VP9_COMP *cpi, vp9_writer *w) { } } - void write_uncompressed_header(VP9_COMMON *cm, struct vp9_write_bit_buffer *wb) { const int scaling_active = cm->width != cm->display_width || @@ -1457,11 +1455,16 @@ void write_uncompressed_header(VP9_COMMON *cm, vp9_wb_write_literal(wb, cm->width, 16); vp9_wb_write_literal(wb, cm->height, 16); + if (!cm->show_frame) { + vp9_wb_write_bit(wb, cm->intra_only); + } + vp9_wb_write_literal(wb, cm->frame_context_idx, NUM_FRAME_CONTEXTS_LG2); vp9_wb_write_bit(wb, cm->clr_type); vp9_wb_write_bit(wb, cm->error_resilient_mode); if (!cm->error_resilient_mode) { + vp9_wb_write_bit(wb, cm->reset_frame_context); vp9_wb_write_bit(wb, cm->refresh_frame_context); vp9_wb_write_bit(wb, cm->frame_parallel_decoding_mode); } diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index a38adaade..4b4a479dd 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -774,7 +774,7 @@ void vp9_set_speed_features(VP9_COMP *cpi) { sf->optimize_coefficients = !cpi->oxcf.lossless; sf->first_step = 0; sf->max_step_search_steps = MAX_MVSEARCH_STEPS; - sf->comp_inter_joint_serach = 1; + sf->comp_inter_joint_search = 1; #if CONFIG_MULTIPLE_ARF // Switch segmentation off. sf->static_segmentation = 0; @@ -809,7 +809,7 @@ void vp9_set_speed_features(VP9_COMP *cpi) { /* Disable coefficient optimization above speed 0 */ sf->optimize_coefficients = 0; sf->no_skip_block4x4_search = 0; - sf->comp_inter_joint_serach = 0; + sf->comp_inter_joint_search = 0; sf->first_step = 1; @@ -1190,6 +1190,7 @@ void vp9_change_config(VP9_PTR ptr, VP9_CONFIG *oxcf) { cpi->refresh_golden_frame = 0; cpi->refresh_last_frame = 1; cm->refresh_frame_context = 1; + cm->reset_frame_context = 0; setup_features(cpi); cpi->mb.e_mbd.allow_high_precision_mv = 0; // Default mv precision adaptation @@ -2617,6 +2618,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, (cpi->oxcf.frame_parallel_decoding_mode != 0); if (cm->error_resilient_mode) { cm->frame_parallel_decoding_mode = 1; + cm->reset_frame_context = 0; cm->refresh_frame_context = 0; } } @@ -3669,6 +3671,7 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags, } cm->show_frame = 0; + cm->intra_only = 0; cpi->refresh_alt_ref_frame = 1; cpi->refresh_golden_frame = 0; cpi->refresh_last_frame = 0; @@ -3873,6 +3876,7 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags, cpi->droppable = !frame_is_reference(cpi); // return to normal state + cm->reset_frame_context = 0; cm->refresh_frame_context = 1; cpi->refresh_alt_ref_frame = 0; cpi->refresh_golden_frame = 0; diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h index da3179aa2..754e872f4 100644 --- a/vp9/encoder/vp9_onyx_int.h +++ b/vp9/encoder/vp9_onyx_int.h @@ -223,7 +223,7 @@ typedef struct { int search_best_filter; int mb16_breakout; int static_segmentation; - int comp_inter_joint_serach; + int comp_inter_joint_search; } SPEED_FEATURES; enum BlockSize { @@ -419,19 +419,19 @@ typedef struct VP9_COMP { vp9_coeff_count coef_counts_4x4[BLOCK_TYPES]; vp9_coeff_probs_model frame_coef_probs_4x4[BLOCK_TYPES]; - vp9_coeff_stats_model frame_branch_ct_4x4[BLOCK_TYPES]; + vp9_coeff_stats frame_branch_ct_4x4[BLOCK_TYPES]; vp9_coeff_count coef_counts_8x8[BLOCK_TYPES]; vp9_coeff_probs_model frame_coef_probs_8x8[BLOCK_TYPES]; - vp9_coeff_stats_model frame_branch_ct_8x8[BLOCK_TYPES]; + vp9_coeff_stats frame_branch_ct_8x8[BLOCK_TYPES]; vp9_coeff_count coef_counts_16x16[BLOCK_TYPES]; vp9_coeff_probs_model frame_coef_probs_16x16[BLOCK_TYPES]; - vp9_coeff_stats_model frame_branch_ct_16x16[BLOCK_TYPES]; + vp9_coeff_stats frame_branch_ct_16x16[BLOCK_TYPES]; vp9_coeff_count coef_counts_32x32[BLOCK_TYPES]; vp9_coeff_probs_model frame_coef_probs_32x32[BLOCK_TYPES]; - vp9_coeff_stats_model frame_branch_ct_32x32[BLOCK_TYPES]; + vp9_coeff_stats frame_branch_ct_32x32[BLOCK_TYPES]; int gfu_boost; int last_boost; diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index dc4913c5c..9c4dee351 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -1006,7 +1006,7 @@ static int labels2mode(MACROBLOCK *x, int i, MB_PREDICTION_MODE this_mode, int_mv *this_mv, int_mv *this_second_mv, int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES], - int_mv seg_mvs[MAX_REF_FRAMES - 1], + int_mv seg_mvs[MAX_REF_FRAMES], int_mv *best_ref_mv, int_mv *second_best_ref_mv, int *mvjcost, int *mvcost[2], VP9_COMP *cpi) { @@ -1027,14 +1027,11 @@ static int labels2mode(MACROBLOCK *x, int i, // is when we are on a new label (jbb May 08, 2007) switch (m = this_mode) { case NEWMV: - if (mbmi->second_ref_frame > 0) { - this_mv->as_int = seg_mvs[mbmi->ref_frame - 1].as_int; - this_second_mv->as_int = seg_mvs[mbmi->second_ref_frame - 1].as_int; - } - + this_mv->as_int = seg_mvs[mbmi->ref_frame].as_int; thismvcost = vp9_mv_bit_cost(this_mv, best_ref_mv, mvjcost, mvcost, 102, xd->allow_high_precision_mv); if (mbmi->second_ref_frame > 0) { + this_second_mv->as_int = seg_mvs[mbmi->second_ref_frame].as_int; thismvcost += vp9_mv_bit_cost(this_second_mv, second_best_ref_mv, mvjcost, mvcost, 102, xd->allow_high_precision_mv); @@ -1239,9 +1236,44 @@ static enum BlockSize get_block_size(int bw, int bh) { return -1; } +static INLINE void mi_buf_shift(MACROBLOCK *x, int i) { + MB_MODE_INFO *mbmi = &x->e_mbd.mode_info_context->mbmi; + x->plane[0].src.buf = + raster_block_offset_uint8(&x->e_mbd, BLOCK_SIZE_SB8X8, 0, i, + x->plane[0].src.buf, + x->plane[0].src.stride); + assert(((intptr_t)x->e_mbd.plane[0].pre[0].buf & 0x7) == 0); + x->e_mbd.plane[0].pre[0].buf = + raster_block_offset_uint8(&x->e_mbd, BLOCK_SIZE_SB8X8, 0, i, + x->e_mbd.plane[0].pre[0].buf, + x->e_mbd.plane[0].pre[0].stride); + if (mbmi->second_ref_frame) + x->e_mbd.plane[0].pre[1].buf = + raster_block_offset_uint8(&x->e_mbd, BLOCK_SIZE_SB8X8, 0, i, + x->e_mbd.plane[0].pre[1].buf, + x->e_mbd.plane[0].pre[1].stride); +} + +static INLINE void mi_buf_restore(MACROBLOCK *x, struct buf_2d orig_src, + struct buf_2d orig_pre[2]) { + MB_MODE_INFO *mbmi = &x->e_mbd.mode_info_context->mbmi; + x->plane[0].src = orig_src; + x->e_mbd.plane[0].pre[0] = orig_pre[0]; + if (mbmi->second_ref_frame) + x->e_mbd.plane[0].pre[1] = orig_pre[1]; +} + +static void iterative_motion_search(VP9_COMP *cpi, MACROBLOCK *x, + BLOCK_SIZE_TYPE bsize, + int_mv *frame_mv, + YV12_BUFFER_CONFIG **scaled_ref_frame, + int mi_row, int mi_col, + int_mv single_newmv[MAX_REF_FRAMES]); + static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x, BEST_SEG_INFO *bsi, - int_mv seg_mvs[4][MAX_REF_FRAMES - 1]) { + int_mv seg_mvs[4][MAX_REF_FRAMES], + int mi_row, int mi_col) { int i, j; int br = 0, bd = 0; MB_PREDICTION_MODE this_mode; @@ -1258,7 +1290,7 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x, int bhl = b_height_log2(bsize), bh = 1 << bhl; int idx, idy; vp9_variance_fn_ptr_t *v_fn_ptr; - + YV12_BUFFER_CONFIG *scaled_ref_frame[2] = {NULL, NULL}; ENTROPY_CONTEXT t_above[4], t_left[4]; ENTROPY_CONTEXT t_above_b[4], t_left_b[4]; @@ -1305,6 +1337,10 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x, int distortion; int labelyrate; ENTROPY_CONTEXT t_above_s[4], t_left_s[4]; + const struct buf_2d orig_src = x->plane[0].src; + struct buf_2d orig_pre[2]; + + vpx_memcpy(orig_pre, x->e_mbd.plane[0].pre, sizeof(orig_pre)); vpx_memcpy(t_above_s, t_above, sizeof(t_above_s)); vpx_memcpy(t_left_s, t_left, sizeof(t_left_s)); @@ -1314,8 +1350,6 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x, int step_param = 0; int further_steps; int thissme, bestsme = INT_MAX; - const struct buf_2d orig_src = x->plane[0].src; - const struct buf_2d orig_pre = x->e_mbd.plane[0].pre[0]; int sadpb = x->sadperbit4; int_mv mvp_full; @@ -1341,17 +1375,8 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x, mvp_full.as_mv.row = bsi->mvp.as_mv.row >> 3; mvp_full.as_mv.col = bsi->mvp.as_mv.col >> 3; - // adjust src pointer for this segment - x->plane[0].src.buf = - raster_block_offset_uint8(&x->e_mbd, BLOCK_SIZE_SB8X8, 0, i, - x->plane[0].src.buf, - x->plane[0].src.stride); - assert(((intptr_t)x->e_mbd.plane[0].pre[0].buf & 0x7) == 0); - x->e_mbd.plane[0].pre[0].buf = - raster_block_offset_uint8(&x->e_mbd, BLOCK_SIZE_SB8X8, 0, i, - x->e_mbd.plane[0].pre[0].buf, - x->e_mbd.plane[0].pre[0].stride); - + // adjust src pointer for this block + mi_buf_shift(x, i); bestsme = vp9_full_pixel_diamond(cpi, x, &mvp_full, step_param, sadpb, further_steps, 0, v_fn_ptr, bsi->ref_mv, &mode_mv[NEWMV]); @@ -1388,16 +1413,29 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x, &distortion, &sse); // safe motion search result for use in compound prediction - seg_mvs[i][mbmi->ref_frame - 1].as_int = mode_mv[NEWMV].as_int; + seg_mvs[i][mbmi->ref_frame].as_int = mode_mv[NEWMV].as_int; } // restore src pointers - x->plane[0].src = orig_src; - x->e_mbd.plane[0].pre[0] = orig_pre; + mi_buf_restore(x, orig_src, orig_pre); } else if (mbmi->second_ref_frame > 0 && this_mode == NEWMV) { - if (seg_mvs[i][mbmi->second_ref_frame - 1].as_int == INVALID_MV || - seg_mvs[i][mbmi->ref_frame - 1].as_int == INVALID_MV) + if (seg_mvs[i][mbmi->second_ref_frame].as_int == INVALID_MV || + seg_mvs[i][mbmi->ref_frame ].as_int == INVALID_MV) continue; + + // adjust src pointers + mi_buf_shift(x, i); + if (cpi->sf.comp_inter_joint_search) { + iterative_motion_search(cpi, x, bsize, frame_mv[this_mode], + scaled_ref_frame, + mi_row, mi_col, seg_mvs[i]); + seg_mvs[i][mbmi->ref_frame].as_int = + frame_mv[this_mode][mbmi->ref_frame].as_int; + seg_mvs[i][mbmi->second_ref_frame].as_int = + frame_mv[this_mode][mbmi->second_ref_frame].as_int; + } + // restore src pointers + mi_buf_restore(x, orig_src, orig_pre); } rate = labels2mode(x, i, this_mode, &mode_mv[this_mode], @@ -1476,12 +1514,6 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x, } } -static void rd_check_segment(VP9_COMP *cpi, MACROBLOCK *x, - BEST_SEG_INFO *bsi, - int_mv seg_mvs[4][MAX_REF_FRAMES - 1]) { - rd_check_segment_txsize(cpi, x, bsi, seg_mvs); -} - static int rd_pick_best_mbsegmentation(VP9_COMP *cpi, MACROBLOCK *x, int_mv *best_ref_mv, int_mv *second_best_ref_mv, @@ -1490,7 +1522,8 @@ static int rd_pick_best_mbsegmentation(VP9_COMP *cpi, MACROBLOCK *x, int *returnyrate, int *returndistortion, int *skippable, int mvthresh, - int_mv seg_mvs[4][MAX_REF_FRAMES - 1]) { + int_mv seg_mvs[4][MAX_REF_FRAMES], + int mi_row, int mi_col) { int i; BEST_SEG_INFO bsi; MB_MODE_INFO * mbmi = &x->e_mbd.mode_info_context->mbmi; @@ -1506,7 +1539,7 @@ static int rd_pick_best_mbsegmentation(VP9_COMP *cpi, MACROBLOCK *x, for (i = 0; i < 4; i++) bsi.modes[i] = ZEROMV; - rd_check_segment(cpi, x, &bsi, seg_mvs); + rd_check_segment_txsize(cpi, x, &bsi, seg_mvs, mi_row, mi_col); /* set it to the best */ for (i = 0; i < 4; i++) { @@ -2110,7 +2143,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, frame_mv[refs[0]].as_int = single_newmv[refs[0]].as_int; frame_mv[refs[1]].as_int = single_newmv[refs[1]].as_int; - if (cpi->sf.comp_inter_joint_serach) + if (cpi->sf.comp_inter_joint_search) iterative_motion_search(cpi, x, bsize, frame_mv, scaled_ref_frame, mi_row, mi_col, single_newmv); @@ -2446,16 +2479,14 @@ void vp9_rd_pick_intra_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, *returnrate = rate4x4_y + rate_uv + vp9_cost_bit(vp9_get_pred_prob(cm, xd, PRED_MBSKIP), 0); *returndist = dist4x4_y + (dist_uv >> 2); - for (i = 0; i < NB_TXFM_MODES; i++) { - ctx->txfm_rd_diff[i] = MIN(err4x4, err - txfm_cache[i]); - } + vpx_memset(ctx->txfm_rd_diff, 0, sizeof(ctx->txfm_rd_diff)); xd->mode_info_context->mbmi.txfm_size = TX_4X4; } else { *returnrate = rate_y + rate_uv + vp9_cost_bit(vp9_get_pred_prob(cm, xd, PRED_MBSKIP), 0); *returndist = dist_y + (dist_uv >> 2); for (i = 0; i < NB_TXFM_MODES; i++) { - ctx->txfm_rd_diff[i] = MIN(err4x4, err - txfm_cache[i]); + ctx->txfm_rd_diff[i] = txfm_cache[i] - txfm_cache[cm->txfm_mode]; } xd->mode_info_context->mbmi.txfm_size = txfm_size; xd->mode_info_context->mbmi.mode = mode; @@ -2510,14 +2541,14 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, int64_t frame_distortions[MAX_REF_FRAMES] = {-1}; int intra_cost_penalty = 20 * vp9_dc_quant(cpi->common.base_qindex, cpi->common.y_dc_delta_q); - int_mv seg_mvs[4][MAX_REF_FRAMES - 1]; + int_mv seg_mvs[4][MAX_REF_FRAMES]; union b_mode_info best_bmodes[4]; PARTITION_INFO best_partition; for (i = 0; i < 4; i++) { int j; - for (j = 0; j < MAX_REF_FRAMES - 1; j++) + for (j = 0; j < MAX_REF_FRAMES; j++) seg_mvs[i][j].as_int = INVALID_MV; } // Everywhere the flag is set the error is much higher than its neighbors. @@ -2810,7 +2841,8 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, second_ref, INT64_MAX, &rate, &rate_y, &distortion, &skippable, - (int)this_rd_thresh, seg_mvs); + (int)this_rd_thresh, seg_mvs, + mi_row, mi_col); if (cpi->common.mcomp_filter_type == SWITCHABLE) { const int rs = get_switchable_rate(cm, x); tmp_rd += RDCOST(x->rdmult, x->rddiv, rs, 0); @@ -2849,7 +2881,8 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, second_ref, INT64_MAX, &rate, &rate_y, &distortion, &skippable, - (int)this_rd_thresh, seg_mvs); + (int)this_rd_thresh, seg_mvs, + mi_row, mi_col); } else { if (cpi->common.mcomp_filter_type == SWITCHABLE) { int rs = get_switchable_rate(cm, x); diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c index 9326165ed..e5b50894c 100644 --- a/vp9/vp9_cx_iface.c +++ b/vp9/vp9_cx_iface.c @@ -20,7 +20,7 @@ #include <stdlib.h> #include <string.h> -struct vp8_extracfg { +struct vp9_extracfg { struct vpx_codec_pkt_list *pkt_list; int cpu_used; /** available cpu percentage in 1/16*/ unsigned int enable_auto_alt_ref; /** if encoder decides to uses alternate reference frame */ @@ -42,7 +42,7 @@ struct vp8_extracfg { struct extraconfig_map { int usage; - struct vp8_extracfg cfg; + struct vp9_extracfg cfg; }; static const struct extraconfig_map extracfg_map[] = { @@ -73,7 +73,7 @@ static const struct extraconfig_map extracfg_map[] = { struct vpx_codec_alg_priv { vpx_codec_priv_t base; vpx_codec_enc_cfg_t cfg; - struct vp8_extracfg vp8_cfg; + struct vp9_extracfg vp8_cfg; VP9_CONFIG oxcf; VP9_PTR cpi; unsigned char *cx_data; @@ -131,7 +131,7 @@ update_error_state(vpx_codec_alg_priv_t *ctx, static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, const vpx_codec_enc_cfg_t *cfg, - const struct vp8_extracfg *vp8_cfg) { + const struct vp9_extracfg *vp8_cfg) { RANGE_CHECK(cfg, g_w, 1, 65535); /* 16 bits available */ RANGE_CHECK(cfg, g_h, 1, 65535); /* 16 bits available */ RANGE_CHECK(cfg, g_timebase.den, 1, 1000000000); @@ -226,9 +226,9 @@ static vpx_codec_err_t validate_img(vpx_codec_alg_priv_t *ctx, } -static vpx_codec_err_t set_vp8e_config(VP9_CONFIG *oxcf, +static vpx_codec_err_t set_vp9e_config(VP9_CONFIG *oxcf, vpx_codec_enc_cfg_t cfg, - struct vp8_extracfg vp8_cfg) { + struct vp9_extracfg vp8_cfg) { oxcf->version = cfg.g_profile | (vp8_cfg.experimental ? 0x4 : 0); oxcf->width = cfg.g_w; oxcf->height = cfg.g_h; @@ -351,7 +351,7 @@ static vpx_codec_err_t set_vp8e_config(VP9_CONFIG *oxcf, return VPX_CODEC_OK; } -static vpx_codec_err_t vp8e_set_config(vpx_codec_alg_priv_t *ctx, +static vpx_codec_err_t vp9e_set_config(vpx_codec_alg_priv_t *ctx, const vpx_codec_enc_cfg_t *cfg) { vpx_codec_err_t res; @@ -370,7 +370,7 @@ static vpx_codec_err_t vp8e_set_config(vpx_codec_alg_priv_t *ctx, if (!res) { ctx->cfg = *cfg; - set_vp8e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg); + set_vp9e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg); vp9_change_config(ctx->cpi, &ctx->oxcf); } @@ -406,7 +406,7 @@ static vpx_codec_err_t set_param(vpx_codec_alg_priv_t *ctx, int ctrl_id, va_list args) { vpx_codec_err_t res = VPX_CODEC_OK; - struct vp8_extracfg xcfg = ctx->vp8_cfg; + struct vp9_extracfg xcfg = ctx->vp8_cfg; #define MAP(id, var) case id: var = CAST(id, args); break; @@ -433,7 +433,7 @@ static vpx_codec_err_t set_param(vpx_codec_alg_priv_t *ctx, if (!res) { ctx->vp8_cfg = xcfg; - set_vp8e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg); + set_vp9e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg); vp9_change_config(ctx->cpi, &ctx->oxcf); } @@ -442,7 +442,7 @@ static vpx_codec_err_t set_param(vpx_codec_alg_priv_t *ctx, } -static vpx_codec_err_t vp8e_common_init(vpx_codec_ctx_t *ctx, +static vpx_codec_err_t vp9e_common_init(vpx_codec_ctx_t *ctx, int experimental) { vpx_codec_err_t res = VPX_CODEC_OK; struct vpx_codec_alg_priv *priv; @@ -488,7 +488,7 @@ static vpx_codec_err_t vp8e_common_init(vpx_codec_ctx_t *ctx, priv->vp8_cfg.experimental = experimental; // TODO(agrange) Check the limits set on this buffer, or the check that is - // applied in vp8e_encode. + // applied in vp9e_encode. priv->cx_data_sz = priv->cfg.g_w * priv->cfg.g_h * 3 / 2 * 8; // priv->cx_data_sz = priv->cfg.g_w * priv->cfg.g_h * 3 / 2 * 2; @@ -505,7 +505,7 @@ static vpx_codec_err_t vp8e_common_init(vpx_codec_ctx_t *ctx, res = validate_config(priv, &priv->cfg, &priv->vp8_cfg); if (!res) { - set_vp8e_config(&ctx->priv->alg_priv->oxcf, + set_vp9e_config(&ctx->priv->alg_priv->oxcf, ctx->priv->alg_priv->cfg, ctx->priv->alg_priv->vp8_cfg); optr = vp9_create_compressor(&ctx->priv->alg_priv->oxcf); @@ -521,21 +521,21 @@ static vpx_codec_err_t vp8e_common_init(vpx_codec_ctx_t *ctx, } -static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx, +static vpx_codec_err_t vp9e_init(vpx_codec_ctx_t *ctx, vpx_codec_priv_enc_mr_cfg_t *data) { - return vp8e_common_init(ctx, 0); + return vp9e_common_init(ctx, 0); } #if CONFIG_EXPERIMENTAL -static vpx_codec_err_t vp8e_exp_init(vpx_codec_ctx_t *ctx, +static vpx_codec_err_t vp9e_exp_init(vpx_codec_ctx_t *ctx, vpx_codec_priv_enc_mr_cfg_t *data) { - return vp8e_common_init(ctx, 1); + return vp9e_common_init(ctx, 1); } #endif -static vpx_codec_err_t vp8e_destroy(vpx_codec_alg_priv_t *ctx) { +static vpx_codec_err_t vp9e_destroy(vpx_codec_alg_priv_t *ctx) { free(ctx->cx_data); vp9_remove_compressor(&ctx->cpi); @@ -608,7 +608,7 @@ static int write_superframe_index(vpx_codec_alg_priv_t *ctx) { return index_sz; } -static vpx_codec_err_t vp8e_encode(vpx_codec_alg_priv_t *ctx, +static vpx_codec_err_t vp9e_encode(vpx_codec_alg_priv_t *ctx, const vpx_image_t *img, vpx_codec_pts_t pts, unsigned long duration, @@ -831,12 +831,12 @@ static vpx_codec_err_t vp8e_encode(vpx_codec_alg_priv_t *ctx, } -static const vpx_codec_cx_pkt_t *vp8e_get_cxdata(vpx_codec_alg_priv_t *ctx, +static const vpx_codec_cx_pkt_t *vp9e_get_cxdata(vpx_codec_alg_priv_t *ctx, vpx_codec_iter_t *iter) { return vpx_codec_pkt_list_get(&ctx->pkt_list.head, iter); } -static vpx_codec_err_t vp8e_set_reference(vpx_codec_alg_priv_t *ctx, +static vpx_codec_err_t vp9e_set_reference(vpx_codec_alg_priv_t *ctx, int ctr_id, va_list args) { vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *); @@ -853,7 +853,7 @@ static vpx_codec_err_t vp8e_set_reference(vpx_codec_alg_priv_t *ctx, } -static vpx_codec_err_t vp8e_copy_reference(vpx_codec_alg_priv_t *ctx, +static vpx_codec_err_t vp9e_copy_reference(vpx_codec_alg_priv_t *ctx, int ctr_id, va_list args) { @@ -886,7 +886,7 @@ static vpx_codec_err_t get_reference(vpx_codec_alg_priv_t *ctx, } } -static vpx_codec_err_t vp8e_set_previewpp(vpx_codec_alg_priv_t *ctx, +static vpx_codec_err_t vp9e_set_previewpp(vpx_codec_alg_priv_t *ctx, int ctr_id, va_list args) { #if CONFIG_POSTPROC @@ -907,7 +907,7 @@ static vpx_codec_err_t vp8e_set_previewpp(vpx_codec_alg_priv_t *ctx, } -static vpx_image_t *vp8e_get_preview(vpx_codec_alg_priv_t *ctx) { +static vpx_image_t *vp9e_get_preview(vpx_codec_alg_priv_t *ctx) { YV12_BUFFER_CONFIG sd; vp9_ppflags_t flags = {0}; @@ -925,7 +925,7 @@ static vpx_image_t *vp8e_get_preview(vpx_codec_alg_priv_t *ctx) { return NULL; } -static vpx_codec_err_t vp8e_update_entropy(vpx_codec_alg_priv_t *ctx, +static vpx_codec_err_t vp9e_update_entropy(vpx_codec_alg_priv_t *ctx, int ctr_id, va_list args) { int update = va_arg(args, int); @@ -934,7 +934,7 @@ static vpx_codec_err_t vp8e_update_entropy(vpx_codec_alg_priv_t *ctx, } -static vpx_codec_err_t vp8e_update_reference(vpx_codec_alg_priv_t *ctx, +static vpx_codec_err_t vp9e_update_reference(vpx_codec_alg_priv_t *ctx, int ctr_id, va_list args) { int update = va_arg(args, int); @@ -942,7 +942,7 @@ static vpx_codec_err_t vp8e_update_reference(vpx_codec_alg_priv_t *ctx, return VPX_CODEC_OK; } -static vpx_codec_err_t vp8e_use_reference(vpx_codec_alg_priv_t *ctx, +static vpx_codec_err_t vp9e_use_reference(vpx_codec_alg_priv_t *ctx, int ctr_id, va_list args) { int reference_flag = va_arg(args, int); @@ -950,7 +950,7 @@ static vpx_codec_err_t vp8e_use_reference(vpx_codec_alg_priv_t *ctx, return VPX_CODEC_OK; } -static vpx_codec_err_t vp8e_set_roi_map(vpx_codec_alg_priv_t *ctx, +static vpx_codec_err_t vp9e_set_roi_map(vpx_codec_alg_priv_t *ctx, int ctr_id, va_list args) { vpx_roi_map_t *data = va_arg(args, vpx_roi_map_t *); @@ -968,7 +968,7 @@ static vpx_codec_err_t vp8e_set_roi_map(vpx_codec_alg_priv_t *ctx, } -static vpx_codec_err_t vp8e_set_activemap(vpx_codec_alg_priv_t *ctx, +static vpx_codec_err_t vp9e_set_activemap(vpx_codec_alg_priv_t *ctx, int ctr_id, va_list args) { vpx_active_map_t *data = va_arg(args, vpx_active_map_t *); @@ -985,7 +985,7 @@ static vpx_codec_err_t vp8e_set_activemap(vpx_codec_alg_priv_t *ctx, return VPX_CODEC_INVALID_PARAM; } -static vpx_codec_err_t vp8e_set_scalemode(vpx_codec_alg_priv_t *ctx, +static vpx_codec_err_t vp9e_set_scalemode(vpx_codec_alg_priv_t *ctx, int ctr_id, va_list args) { @@ -1006,16 +1006,16 @@ static vpx_codec_err_t vp8e_set_scalemode(vpx_codec_alg_priv_t *ctx, } -static vpx_codec_ctrl_fn_map_t vp8e_ctf_maps[] = { - {VP8_SET_REFERENCE, vp8e_set_reference}, - {VP8_COPY_REFERENCE, vp8e_copy_reference}, - {VP8_SET_POSTPROC, vp8e_set_previewpp}, - {VP8E_UPD_ENTROPY, vp8e_update_entropy}, - {VP8E_UPD_REFERENCE, vp8e_update_reference}, - {VP8E_USE_REFERENCE, vp8e_use_reference}, - {VP8E_SET_ROI_MAP, vp8e_set_roi_map}, - {VP8E_SET_ACTIVEMAP, vp8e_set_activemap}, - {VP8E_SET_SCALEMODE, vp8e_set_scalemode}, +static vpx_codec_ctrl_fn_map_t vp9e_ctf_maps[] = { + {VP8_SET_REFERENCE, vp9e_set_reference}, + {VP8_COPY_REFERENCE, vp9e_copy_reference}, + {VP8_SET_POSTPROC, vp9e_set_previewpp}, + {VP8E_UPD_ENTROPY, vp9e_update_entropy}, + {VP8E_UPD_REFERENCE, vp9e_update_reference}, + {VP8E_USE_REFERENCE, vp9e_use_reference}, + {VP8E_SET_ROI_MAP, vp9e_set_roi_map}, + {VP8E_SET_ACTIVEMAP, vp9e_set_activemap}, + {VP8E_SET_SCALEMODE, vp9e_set_scalemode}, {VP8E_SET_CPUUSED, set_param}, {VP8E_SET_NOISE_SENSITIVITY, set_param}, {VP8E_SET_ENABLEAUTOALTREF, set_param}, @@ -1036,7 +1036,7 @@ static vpx_codec_ctrl_fn_map_t vp8e_ctf_maps[] = { { -1, NULL}, }; -static vpx_codec_enc_cfg_map_t vp8e_usage_cfg_map[] = { +static vpx_codec_enc_cfg_map_t vp9e_usage_cfg_map[] = { { 0, { @@ -1101,9 +1101,9 @@ CODEC_INTERFACE(vpx_codec_vp9_cx) = { VPX_CODEC_CAP_ENCODER | VPX_CODEC_CAP_PSNR | VPX_CODEC_CAP_OUTPUT_PARTITION, /* vpx_codec_caps_t caps; */ - vp8e_init, /* vpx_codec_init_fn_t init; */ - vp8e_destroy, /* vpx_codec_destroy_fn_t destroy; */ - vp8e_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */ + vp9e_init, /* vpx_codec_init_fn_t init; */ + vp9e_destroy, /* vpx_codec_destroy_fn_t destroy; */ + vp9e_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */ NOT_IMPLEMENTED, /* vpx_codec_get_mmap_fn_t get_mmap; */ NOT_IMPLEMENTED, /* vpx_codec_set_mmap_fn_t set_mmap; */ { @@ -1113,12 +1113,12 @@ CODEC_INTERFACE(vpx_codec_vp9_cx) = { NOT_IMPLEMENTED, /* vpx_codec_frame_get_fn_t frame_get; */ }, { - vp8e_usage_cfg_map, /* vpx_codec_enc_cfg_map_t peek_si; */ - vp8e_encode, /* vpx_codec_encode_fn_t encode; */ - vp8e_get_cxdata, /* vpx_codec_get_cx_data_fn_t frame_get; */ - vp8e_set_config, + vp9e_usage_cfg_map, /* vpx_codec_enc_cfg_map_t peek_si; */ + vp9e_encode, /* vpx_codec_encode_fn_t encode; */ + vp9e_get_cxdata, /* vpx_codec_get_cx_data_fn_t frame_get; */ + vp9e_set_config, NOT_IMPLEMENTED, - vp8e_get_preview, + vp9e_get_preview, } /* encoder functions */ }; @@ -1130,9 +1130,9 @@ CODEC_INTERFACE(vpx_codec_vp9x_cx) = { VPX_CODEC_INTERNAL_ABI_VERSION, VPX_CODEC_CAP_ENCODER | VPX_CODEC_CAP_PSNR, /* vpx_codec_caps_t caps; */ - vp8e_exp_init, /* vpx_codec_init_fn_t init; */ - vp8e_destroy, /* vpx_codec_destroy_fn_t destroy; */ - vp8e_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */ + vp9e_exp_init, /* vpx_codec_init_fn_t init; */ + vp9e_destroy, /* vpx_codec_destroy_fn_t destroy; */ + vp9e_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */ NOT_IMPLEMENTED, /* vpx_codec_get_mmap_fn_t get_mmap; */ NOT_IMPLEMENTED, /* vpx_codec_set_mmap_fn_t set_mmap; */ { @@ -1142,12 +1142,12 @@ CODEC_INTERFACE(vpx_codec_vp9x_cx) = { NOT_IMPLEMENTED, /* vpx_codec_frame_get_fn_t frame_get; */ }, { - vp8e_usage_cfg_map, /* vpx_codec_enc_cfg_map_t peek_si; */ - vp8e_encode, /* vpx_codec_encode_fn_t encode; */ - vp8e_get_cxdata, /* vpx_codec_get_cx_data_fn_t frame_get; */ - vp8e_set_config, + vp9e_usage_cfg_map, /* vpx_codec_enc_cfg_map_t peek_si; */ + vp9e_encode, /* vpx_codec_encode_fn_t encode; */ + vp9e_get_cxdata, /* vpx_codec_get_cx_data_fn_t frame_get; */ + vp9e_set_config, NOT_IMPLEMENTED, - vp8e_get_preview, + vp9e_get_preview, } /* encoder functions */ }; #endif |