diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h index 36e7e8300893278bf08f5c0074c6c3df7650e386..31959c150d2d4721ce658fef41873917e7546f2b 100644 --- a/vp9/common/vp9_blockd.h +++ b/vp9/common/vp9_blockd.h @@ -222,8 +222,6 @@ typedef struct macroblockd { struct subpix_fn_table subpix; - int allow_high_precision_mv; - int corrupted; unsigned char sb_index; // index of 32x32 block inside the 64x64 block diff --git a/vp9/common/vp9_findnearmv.c b/vp9/common/vp9_findnearmv.c index ed9e9823e509b6eaa8609c4192fac3ce7aef6869..592ef6afa0c40b79fec8789e2e962a16bbd0c00e 100644 --- a/vp9/common/vp9_findnearmv.c +++ b/vp9/common/vp9_findnearmv.c @@ -22,14 +22,12 @@ static void lower_mv_precision(MV *mv, int allow_hp) { } -void vp9_find_best_ref_mvs(MACROBLOCKD *xd, - int_mv *mvlist, - int_mv *nearest, - int_mv *near) { +void vp9_find_best_ref_mvs(MACROBLOCKD *xd, int allow_hp, + int_mv *mvlist, int_mv *nearest, int_mv *near) { int i; // Make sure all the candidates are properly clamped etc for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) { - lower_mv_precision(&mvlist[i].as_mv, xd->allow_high_precision_mv); + lower_mv_precision(&mvlist[i].as_mv, allow_hp); clamp_mv2(&mvlist[i].as_mv, xd); } *nearest = mvlist[0]; diff --git a/vp9/common/vp9_findnearmv.h b/vp9/common/vp9_findnearmv.h index 50dfdc7fb7fd490dfa29b1dc24dc07b3c8c5e414..4746a8f64ffa8a12635a4d7b632522c3859d08c7 100644 --- a/vp9/common/vp9_findnearmv.h +++ b/vp9/common/vp9_findnearmv.h @@ -23,10 +23,8 @@ // check a list of motion vectors by sad score using a number rows of pixels // above and a number cols of pixels in the left to select the one with best // score to use as ref motion vector -void vp9_find_best_ref_mvs(MACROBLOCKD *xd, - int_mv *mvlist, - int_mv *nearest, - int_mv *near); +void vp9_find_best_ref_mvs(MACROBLOCKD *xd, int allow_hp, + int_mv *mvlist, int_mv *nearest, int_mv *near); // TODO(jingning): this mv clamping function should be block size dependent. static void clamp_mv2(MV *mv, const MACROBLOCKD *xd) { diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h index 3111852eed1a9a09622733f342ffa225688de5cc..5fc180bb5a70505d70dbd92e4450737f89602a12 100644 --- a/vp9/common/vp9_onyxc_int.h +++ b/vp9/common/vp9_onyxc_int.h @@ -129,6 +129,8 @@ typedef struct VP9Common { // Flag signaling that the frame is encoded using only INTRA modes. int intra_only; + int allow_high_precision_mv; + // Flag signaling that the frame context should be reset to default values. // 0 or 1 implies don't reset, 2 reset just the context specified in the // frame header, 3 reset all contexts. diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c index 6615530a445ba26525ea86a3e4151413db37d940..5d7ca77623e37085504783dfb26f54b5c6930a01 100644 --- a/vp9/decoder/vp9_decodemv.c +++ b/vp9/decoder/vp9_decodemv.c @@ -487,7 +487,7 @@ static void read_inter_block_mode_info(VP9_COMMON *const cm, int mi_row, int mi_col, vp9_reader *r) { MB_MODE_INFO *const mbmi = &mi->mbmi; const BLOCK_SIZE bsize = mbmi->sb_type; - const int allow_hp = xd->allow_high_precision_mv; + const int allow_hp = cm->allow_high_precision_mv; int_mv nearest[2], nearmv[2], best[2]; uint8_t inter_mode_ctx; @@ -518,7 +518,8 @@ static void read_inter_block_mode_info(VP9_COMMON *const cm, // nearest, nearby if (bsize < BLOCK_8X8 || mbmi->mode != ZEROMV) { - vp9_find_best_ref_mvs(xd, mbmi->ref_mvs[ref0], &nearest[0], &nearmv[0]); + vp9_find_best_ref_mvs(xd, allow_hp, + mbmi->ref_mvs[ref0], &nearest[0], &nearmv[0]); best[0].as_int = nearest[0].as_int; } @@ -528,7 +529,8 @@ static void read_inter_block_mode_info(VP9_COMMON *const cm, ref1, mbmi->ref_mvs[ref1], mi_row, mi_col); if (bsize < BLOCK_8X8 || mbmi->mode != ZEROMV) { - vp9_find_best_ref_mvs(xd, mbmi->ref_mvs[ref1], &nearest[1], &nearmv[1]); + vp9_find_best_ref_mvs(xd, allow_hp, + mbmi->ref_mvs[ref1], &nearest[1], &nearmv[1]); best[1].as_int = nearest[1].as_int; } } @@ -630,8 +632,7 @@ static void read_comp_pred(VP9_COMMON *cm, vp9_reader *r) { vp9_diff_update_prob(r, &cm->fc.comp_ref_prob[i]); } -void vp9_prepare_read_mode_info(VP9D_COMP* pbi, vp9_reader *r) { - VP9_COMMON *const cm = &pbi->common; +void vp9_prepare_read_mode_info(VP9_COMMON *cm, vp9_reader *r) { int k; // TODO(jkoleszar): does this clear more than MBSKIP_CONTEXTS? Maybe remove. @@ -640,8 +641,7 @@ void vp9_prepare_read_mode_info(VP9D_COMP* pbi, vp9_reader *r) { vp9_diff_update_prob(r, &cm->fc.mbskip_probs[k]); if (!frame_is_intra_only(cm)) { - nmv_context *const nmvc = &pbi->common.fc.nmvc; - MACROBLOCKD *const xd = &pbi->mb; + nmv_context *const nmvc = &cm->fc.nmvc; int i, j; read_inter_mode_probs(&cm->fc, r); @@ -662,7 +662,7 @@ void vp9_prepare_read_mode_info(VP9D_COMP* pbi, vp9_reader *r) { for (i = 0; i < PARTITION_TYPES - 1; ++i) vp9_diff_update_prob(r, &cm->fc.partition_prob[INTER_FRAME][j][i]); - read_mv_probs(r, nmvc, xd->allow_high_precision_mv); + read_mv_probs(r, nmvc, cm->allow_high_precision_mv); } } diff --git a/vp9/decoder/vp9_decodemv.h b/vp9/decoder/vp9_decodemv.h index 7f2517c5a35f5a18eb724ff60c15a59ed74df99e..981e8fed2dde911bf027c2cc2a9ae8eaed6c2c0e 100644 --- a/vp9/decoder/vp9_decodemv.h +++ b/vp9/decoder/vp9_decodemv.h @@ -14,7 +14,7 @@ #include "vp9/decoder/vp9_onyxd_int.h" #include "vp9/decoder/vp9_dboolhuff.h" -void vp9_prepare_read_mode_info(VP9D_COMP *pbi, vp9_reader *r); +void vp9_prepare_read_mode_info(VP9_COMMON* cm, vp9_reader *r); void vp9_read_mode_info(VP9_COMMON *cm, MACROBLOCKD *xd, int mi_row, int mi_col, vp9_reader *r); diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c index 698456282ac22b402df40de1c1c781f7808b808a..5ac5c2be3efb568864bdb09dbecf5c68a5b437ea 100644 --- a/vp9/decoder/vp9_decodframe.c +++ b/vp9/decoder/vp9_decodframe.c @@ -796,7 +796,6 @@ static void setup_inter_inter(VP9_COMMON *cm) { static size_t read_uncompressed_header(VP9D_COMP *pbi, struct vp9_read_bit_buffer *rb) { VP9_COMMON *const cm = &pbi->common; - MACROBLOCKD *const xd = &pbi->mb; size_t sz; int i; @@ -875,7 +874,7 @@ static size_t read_uncompressed_header(VP9D_COMP *pbi, setup_frame_size_with_refs(pbi, rb); - xd->allow_high_precision_mv = vp9_rb_read_bit(rb); + cm->allow_high_precision_mv = vp9_rb_read_bit(rb); cm->mcomp_filter_type = read_interp_filter_type(rb); for (i = 0; i < ALLOWED_REFS_PER_FRAME; ++i) @@ -925,7 +924,7 @@ static int read_compressed_header(VP9D_COMP *pbi, const uint8_t *data, read_tx_probs(&cm->fc.tx_probs, &r); read_coef_probs(&cm->fc, cm->tx_mode, &r); - vp9_prepare_read_mode_info(pbi, &r); + vp9_prepare_read_mode_info(cm, &r); return vp9_reader_has_error(&r); } @@ -1030,7 +1029,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { if (!frame_is_intra_only(cm)) { vp9_adapt_mode_probs(cm); - vp9_adapt_mv_probs(cm, xd->allow_high_precision_mv); + vp9_adapt_mv_probs(cm, cm->allow_high_precision_mv); } } diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c index ed795f03161664928bea6257426fbf15623cca08..b2c6e0368540c98091bd47a7e313639984b7c620 100644 --- a/vp9/encoder/vp9_bitstream.c +++ b/vp9/encoder/vp9_bitstream.c @@ -402,7 +402,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc) { const int segment_id = mi->segment_id; int skip_coeff; const BLOCK_SIZE bsize = mi->sb_type; - const int allow_hp = xd->allow_high_precision_mv; + const int allow_hp = cm->allow_high_precision_mv; #ifdef ENTROPY_STATS active_section = 9; @@ -1309,7 +1309,6 @@ static void write_sync_code(struct vp9_write_bit_buffer *wb) { static void write_uncompressed_header(VP9_COMP *cpi, struct vp9_write_bit_buffer *wb) { VP9_COMMON *const cm = &cpi->common; - MACROBLOCKD *const xd = &cpi->mb.e_mbd; // frame marker bits vp9_wb_write_literal(wb, 0x2, 2); @@ -1374,7 +1373,7 @@ static void write_uncompressed_header(VP9_COMP *cpi, write_frame_size_with_refs(cpi, wb); - vp9_wb_write_bit(wb, xd->allow_high_precision_mv); + vp9_wb_write_bit(wb, cm->allow_high_precision_mv); fix_mcomp_filter_type(cpi); write_interp_filter_type(cm->mcomp_filter_type, wb); @@ -1472,7 +1471,7 @@ static size_t write_compressed_header(VP9_COMP *cpi, uint8_t *data) { (unsigned int *)cpi->partition_count[i]); } - vp9_write_nmv_probs(cpi, xd->allow_high_precision_mv, &header_bc); + vp9_write_nmv_probs(cpi, cm->allow_high_precision_mv, &header_bc); } vp9_stop_encode(&header_bc); diff --git a/vp9/encoder/vp9_mbgraph.c b/vp9/encoder/vp9_mbgraph.c index ea4c9e8b261b057f29149cd7c91aed82b9335c66..644363158766315126b1857b619161f80afba812 100644 --- a/vp9/encoder/vp9_mbgraph.c +++ b/vp9/encoder/vp9_mbgraph.c @@ -61,7 +61,7 @@ static unsigned int do_16x16_motion_iteration(VP9_COMP *cpi, best_err = cpi->find_fractional_mv_step( x, &dst_mv->as_mv, &ref_mv->as_mv, - xd->allow_high_precision_mv, + cpi->common.allow_high_precision_mv, x->errorperbit, &v_fn_ptr, 0, cpi->sf.subpel_iters_per_step, NULL, NULL, & distortion, &sse); diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index a8a7ba6f195f63969d343af4d0b23dc69da64ec7..db74df75d8844c81d0e3bdfdac25357118f17734 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -237,8 +237,9 @@ static int get_active_quality(int q, return active_best_quality; } -static void set_mvcost(MACROBLOCK *mb) { - if (mb->e_mbd.allow_high_precision_mv) { +static void set_mvcost(VP9_COMP *cpi) { + MACROBLOCK *const mb = &cpi->mb; + if (cpi->common.allow_high_precision_mv) { mb->mvcost = mb->nmvcost_hp; mb->mvsadcost = mb->nmvsadcost_hp; } else { @@ -1262,8 +1263,8 @@ void vp9_change_config(VP9_PTR ptr, VP9_CONFIG *oxcf) { cm->reset_frame_context = 0; setup_features(cm); - cpi->mb.e_mbd.allow_high_precision_mv = 0; // Default mv precision - set_mvcost(&cpi->mb); + cpi->common.allow_high_precision_mv = 0; // Default mv precision + set_mvcost(cpi); { int i; @@ -2820,7 +2821,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, unsigned char *dest, unsigned int *frame_flags) { VP9_COMMON *const cm = &cpi->common; - MACROBLOCKD *const xd = &cpi->mb.e_mbd; TX_SIZE t; int q; int frame_over_shoot_limit; @@ -2989,8 +2989,8 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, if (!frame_is_intra_only(cm)) { cm->mcomp_filter_type = DEFAULT_INTERP_FILTER; /* TODO: Decide this more intelligently */ - xd->allow_high_precision_mv = q < HIGH_PRECISION_MV_QTHRESH; - set_mvcost(&cpi->mb); + cm->allow_high_precision_mv = q < HIGH_PRECISION_MV_QTHRESH; + set_mvcost(cpi); } #if CONFIG_VP9_POSTPROC @@ -3279,7 +3279,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, if (!cpi->common.error_resilient_mode && !cpi->common.frame_parallel_decoding_mode) { vp9_adapt_mode_probs(&cpi->common); - vp9_adapt_mv_probs(&cpi->common, cpi->mb.e_mbd.allow_high_precision_mv); + vp9_adapt_mv_probs(&cpi->common, cpi->common.allow_high_precision_mv); } } @@ -3606,8 +3606,8 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags, cpi->source = NULL; - cpi->mb.e_mbd.allow_high_precision_mv = ALTREF_HIGH_PRECISION_MV; - set_mvcost(&cpi->mb); + cpi->common.allow_high_precision_mv = ALTREF_HIGH_PRECISION_MV; + set_mvcost(cpi); // Should we code an alternate reference frame. if (cpi->oxcf.play_alternate && cpi->source_alt_ref_pending) { diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index 30cdb3f3c0510ffe8ef1050139b35957bef95d57..0fc715299b4baaf58e8527fcd71569b9701010cd 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -261,10 +261,10 @@ void vp9_initialize_rd_consts(VP9_COMP *cpi) { if (!frame_is_intra_only(&cpi->common)) { vp9_build_nmv_cost_table( cpi->mb.nmvjointcost, - cpi->mb.e_mbd.allow_high_precision_mv ? + cpi->common.allow_high_precision_mv ? cpi->mb.nmvcost_hp : cpi->mb.nmvcost, &cpi->common.fc.nmvc, - cpi->mb.e_mbd.allow_high_precision_mv, 1, 1); + cpi->common.allow_high_precision_mv, 1, 1); for (i = 0; i < INTER_MODE_CONTEXTS; i++) { MB_PREDICTION_MODE m; @@ -1860,7 +1860,7 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x, cpi->find_fractional_mv_step(x, &mode_mv[NEWMV].as_mv, &bsi->ref_mv->as_mv, - x->e_mbd.allow_high_precision_mv, + cpi->common.allow_high_precision_mv, x->errorperbit, v_fn_ptr, 0, cpi->sf.subpel_iters_per_step, x->nmvjointcost, x->mvcost, @@ -2293,7 +2293,7 @@ static void setup_buffer_inter(VP9_COMP *cpi, MACROBLOCK *x, mbmi->ref_mvs[frame_type], mi_row, mi_col); // Candidate refinement carried out at encoder and decoder - vp9_find_best_ref_mvs(xd, + vp9_find_best_ref_mvs(xd, cm->allow_high_precision_mv, mbmi->ref_mvs[frame_type], &frame_nearest_mv[frame_type], &frame_near_mv[frame_type]); @@ -2441,7 +2441,7 @@ static void single_motion_search(VP9_COMP *cpi, MACROBLOCK *x, int dis; /* TODO: use dis in distortion calculation later. */ unsigned int sse; cpi->find_fractional_mv_step(x, &tmp_mv->as_mv, &ref_mv.as_mv, - xd->allow_high_precision_mv, + cm->allow_high_precision_mv, x->errorperbit, &cpi->fn_ptr[block_size], 0, cpi->sf.subpel_iters_per_step, @@ -2577,7 +2577,7 @@ static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x, bestsme = cpi->find_fractional_mv_step_comp( x, &tmp_mv.as_mv, &ref_mv[id].as_mv, - xd->allow_high_precision_mv, + cpi->common.allow_high_precision_mv, x->errorperbit, &cpi->fn_ptr[block_size], 0, cpi->sf.subpel_iters_per_step, diff --git a/vp9/encoder/vp9_temporal_filter.c b/vp9/encoder/vp9_temporal_filter.c index 5cf8143fc6b7b498d9e74ea51dca08c6226826ca..6ea05793da2129c0dc8a697bbdfec97d5dcb893b 100644 --- a/vp9/encoder/vp9_temporal_filter.c +++ b/vp9/encoder/vp9_temporal_filter.c @@ -166,7 +166,7 @@ static int temporal_filter_find_matching_mb_c(VP9_COMP *cpi, // Ignore mv costing by sending NULL pointer instead of cost array bestsme = cpi->find_fractional_mv_step(x, &ref_mv->as_mv, &best_ref_mv1.as_mv, - xd->allow_high_precision_mv, + cpi->common.allow_high_precision_mv, x->errorperbit, &cpi->fn_ptr[BLOCK_16X16], 0, cpi->sf.subpel_iters_per_step,