diff options
author | trav90 <travawine@palemoon.org> | 2018-10-18 21:53:44 -0500 |
---|---|---|
committer | trav90 <travawine@palemoon.org> | 2018-10-18 21:53:44 -0500 |
commit | ec910d81405c736a4490383a250299a7837c2e64 (patch) | |
tree | 4f27cc226f93a863121aef6c56313e4153a69b3e /third_party/aom/av1/encoder/encodemv.c | |
parent | 01eb57073ba97b2d6cbf20f745dfcc508197adc3 (diff) | |
download | UXP-ec910d81405c736a4490383a250299a7837c2e64.tar UXP-ec910d81405c736a4490383a250299a7837c2e64.tar.gz UXP-ec910d81405c736a4490383a250299a7837c2e64.tar.lz UXP-ec910d81405c736a4490383a250299a7837c2e64.tar.xz UXP-ec910d81405c736a4490383a250299a7837c2e64.zip |
Update aom to commit id e87fb2378f01103d5d6e477a4ef6892dc714e614
Diffstat (limited to 'third_party/aom/av1/encoder/encodemv.c')
-rw-r--r-- | third_party/aom/av1/encoder/encodemv.c | 115 |
1 files changed, 76 insertions, 39 deletions
diff --git a/third_party/aom/av1/encoder/encodemv.c b/third_party/aom/av1/encoder/encodemv.c index fd61fe6b2..f8a546999 100644 --- a/third_party/aom/av1/encoder/encodemv.c +++ b/third_party/aom/av1/encoder/encodemv.c @@ -62,17 +62,22 @@ static void encode_mv_component(aom_writer *w, int comp, nmv_component *mvcomp, } else { int i; const int n = mv_class + CLASS0_BITS - 1; // number of bits +#if CONFIG_NEW_MULTISYMBOL + for (i = 0; i < n; ++i) + aom_write_symbol(w, (d >> i) & 1, mvcomp->bits_cdf[(i + 1) / 2], 2); +#else for (i = 0; i < n; ++i) aom_write(w, (d >> i) & 1, mvcomp->bits[i]); +#endif } - // Fractional bits -#if CONFIG_INTRABC +#if CONFIG_INTRABC || CONFIG_AMVR if (precision > MV_SUBPEL_NONE) -#endif // CONFIG_INTRABC +#endif // CONFIG_INTRABC || CONFIG_AMVR { - aom_write_symbol(w, fr, mv_class == MV_CLASS_0 ? mvcomp->class0_fp_cdf[d] - : mvcomp->fp_cdf, - MV_FP_SIZE); + aom_write_symbol( + w, fr, + mv_class == MV_CLASS_0 ? mvcomp->class0_fp_cdf[d] : mvcomp->fp_cdf, + MV_FP_SIZE); } // High precision bit @@ -129,9 +134,9 @@ static void build_nmv_component_cost_table(int *mvcost, const int b = c + CLASS0_BITS - 1; /* number of bits */ for (i = 0; i < b; ++i) cost += bits_cost[i][((d >> i) & 1)]; } -#if CONFIG_INTRABC +#if CONFIG_INTRABC || CONFIG_AMVR if (precision > MV_SUBPEL_NONE) -#endif // CONFIG_INTRABC +#endif // CONFIG_INTRABC || CONFIG_AMVR { if (c == MV_CLASS_0) { cost += class0_fp_cost[d][f]; @@ -165,6 +170,11 @@ void av1_write_nmv_probs(AV1_COMMON *cm, int usehp, aom_writer *w, nmv_context_counts *const nmv_counts) { int i; int nmv_ctx = 0; +#if CONFIG_AMVR + if (cm->cur_frame_mv_precision_level) { + return; + } +#endif for (nmv_ctx = 0; nmv_ctx < NMV_CONTEXTS; ++nmv_ctx) { nmv_context *const mvc = &cm->fc->nmvc[nmv_ctx]; nmv_context_counts *const counts = &nmv_counts[nmv_ctx]; @@ -184,6 +194,11 @@ void av1_encode_mv(AV1_COMP *cpi, aom_writer *w, const MV *mv, const MV *ref, nmv_context *mvctx, int usehp) { const MV diff = { mv->row - ref->row, mv->col - ref->col }; const MV_JOINT_TYPE j = av1_get_mv_joint(&diff); +#if CONFIG_AMVR + if (cpi->common.cur_frame_mv_precision_level) { + usehp = MV_SUBPEL_NONE; + } +#endif aom_write_symbol(w, j, mvctx->joint_cdf, MV_JOINTS); if (mv_joint_vertical(j)) encode_mv_component(w, diff.row, &mvctx->comps[0], usehp); @@ -222,10 +237,14 @@ void av1_build_nmv_cost_table(int *mvjoint, int *mvcost[2], build_nmv_component_cost_table(mvcost[1], &ctx->comps[1], precision); } -#if CONFIG_EXT_INTER static void inc_mvs(const MB_MODE_INFO *mbmi, const MB_MODE_INFO_EXT *mbmi_ext, const int_mv mvs[2], const int_mv pred_mvs[2], - nmv_context_counts *nmv_counts) { + nmv_context_counts *nmv_counts +#if CONFIG_AMVR + , + MvSubpelPrecision precision +#endif + ) { int i; PREDICTION_MODE mode = mbmi->mode; @@ -240,7 +259,11 @@ static void inc_mvs(const MB_MODE_INFO *mbmi, const MB_MODE_INFO_EXT *mbmi_ext, mbmi_ext->ref_mv_stack[rf_type], i, mbmi->ref_mv_idx); nmv_context_counts *counts = &nmv_counts[nmv_ctx]; (void)pred_mvs; +#if CONFIG_AMVR + av1_inc_mv(&diff, counts, precision); +#else av1_inc_mv(&diff, counts, 1); +#endif } } else if (mode == NEAREST_NEWMV || mode == NEAR_NEWMV) { const MV *ref = &mbmi_ext->ref_mvs[mbmi->ref_frame[1]][0].as_mv; @@ -251,7 +274,11 @@ static void inc_mvs(const MB_MODE_INFO *mbmi, const MB_MODE_INFO_EXT *mbmi_ext, av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type], mbmi_ext->ref_mv_stack[rf_type], 1, mbmi->ref_mv_idx); nmv_context_counts *counts = &nmv_counts[nmv_ctx]; +#if CONFIG_AMVR + av1_inc_mv(&diff, counts, precision); +#else av1_inc_mv(&diff, counts, 1); +#endif } else if (mode == NEW_NEARESTMV || mode == NEW_NEARMV) { const MV *ref = &mbmi_ext->ref_mvs[mbmi->ref_frame[0]][0].as_mv; const MV diff = { mvs[0].as_mv.row - ref->row, @@ -261,7 +288,11 @@ static void inc_mvs(const MB_MODE_INFO *mbmi, const MB_MODE_INFO_EXT *mbmi_ext, av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type], mbmi_ext->ref_mv_stack[rf_type], 0, mbmi->ref_mv_idx); nmv_context_counts *counts = &nmv_counts[nmv_ctx]; +#if CONFIG_AMVR + av1_inc_mv(&diff, counts, precision); +#else av1_inc_mv(&diff, counts, 1); +#endif #if CONFIG_COMPOUND_SINGLEREF } else { assert( // mode == SR_NEAREST_NEWMV || @@ -288,7 +319,12 @@ static void inc_mvs(const MB_MODE_INFO *mbmi, const MB_MODE_INFO_EXT *mbmi_ext, static void inc_mvs_sub8x8(const MODE_INFO *mi, int block, const int_mv mvs[2], const MB_MODE_INFO_EXT *mbmi_ext, - nmv_context_counts *nmv_counts) { + nmv_context_counts *nmv_counts +#if CONFIG_AMVR + , + MvSubpelPrecision precision +#endif + ) { int i; PREDICTION_MODE mode = mi->bmi[block].as_mode; const MB_MODE_INFO *mbmi = &mi->mbmi; @@ -303,7 +339,11 @@ static void inc_mvs_sub8x8(const MODE_INFO *mi, int block, const int_mv mvs[2], av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type], mbmi_ext->ref_mv_stack[rf_type], i, mbmi->ref_mv_idx); nmv_context_counts *counts = &nmv_counts[nmv_ctx]; +#if CONFIG_AMVR + av1_inc_mv(&diff, counts, precision); +#else av1_inc_mv(&diff, counts, 1); +#endif } } else if (mode == NEAREST_NEWMV || mode == NEAR_NEWMV) { const MV *ref = &mi->bmi[block].ref_mv[1].as_mv; @@ -314,7 +354,11 @@ static void inc_mvs_sub8x8(const MODE_INFO *mi, int block, const int_mv mvs[2], av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type], mbmi_ext->ref_mv_stack[rf_type], 1, mbmi->ref_mv_idx); nmv_context_counts *counts = &nmv_counts[nmv_ctx]; +#if CONFIG_AMVR + av1_inc_mv(&diff, counts, precision); +#else av1_inc_mv(&diff, counts, 1); +#endif } else if (mode == NEW_NEARESTMV || mode == NEW_NEARMV) { const MV *ref = &mi->bmi[block].ref_mv[0].as_mv; const MV diff = { mvs[0].as_mv.row - ref->row, @@ -324,28 +368,13 @@ static void inc_mvs_sub8x8(const MODE_INFO *mi, int block, const int_mv mvs[2], av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type], mbmi_ext->ref_mv_stack[rf_type], 0, mbmi->ref_mv_idx); nmv_context_counts *counts = &nmv_counts[nmv_ctx]; +#if CONFIG_AMVR + av1_inc_mv(&diff, counts, precision); +#else av1_inc_mv(&diff, counts, 1); +#endif } } -#else // !CONFIG_EXT_INTER -static void inc_mvs(const MB_MODE_INFO *mbmi, const MB_MODE_INFO_EXT *mbmi_ext, - const int_mv mvs[2], const int_mv pred_mvs[2], - nmv_context_counts *nmv_counts) { - int i; - - for (i = 0; i < 1 + has_second_ref(mbmi); ++i) { - int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame); - int nmv_ctx = - av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type], - mbmi_ext->ref_mv_stack[rf_type], i, mbmi->ref_mv_idx); - nmv_context_counts *counts = &nmv_counts[nmv_ctx]; - const MV *ref = &pred_mvs[i].as_mv; - const MV diff = { mvs[i].as_mv.row - ref->row, - mvs[i].as_mv.col - ref->col }; - av1_inc_mv(&diff, counts, 1); - } -} -#endif // CONFIG_EXT_INTER void av1_update_mv_count(ThreadData *td) { const MACROBLOCKD *xd = &td->mb.e_mbd; @@ -357,6 +386,12 @@ void av1_update_mv_count(ThreadData *td) { #else const int unify_bsize = 0; #endif +#if CONFIG_AMVR + MvSubpelPrecision precision = 1; + if (xd->cur_frame_mv_precision_level) { + precision = MV_SUBPEL_NONE; + } +#endif if (mbmi->sb_type < BLOCK_8X8 && !unify_bsize) { const int num_4x4_w = num_4x4_blocks_wide_lookup[mbmi->sb_type]; @@ -367,22 +402,24 @@ void av1_update_mv_count(ThreadData *td) { for (idx = 0; idx < 2; idx += num_4x4_w) { const int i = idy * 2 + idx; -#if CONFIG_EXT_INTER if (have_newmv_in_inter_mode(mi->bmi[i].as_mode)) - inc_mvs_sub8x8(mi, i, mi->bmi[i].as_mv, mbmi_ext, td->counts->mv); + +#if CONFIG_AMVR + inc_mvs_sub8x8(mi, i, mi->bmi[i].as_mv, mbmi_ext, td->counts->mv, + precision); #else - if (mi->bmi[i].as_mode == NEWMV) - inc_mvs(mbmi, mbmi_ext, mi->bmi[i].as_mv, mi->bmi[i].pred_mv, - td->counts->mv); -#endif // CONFIG_EXT_INTER + inc_mvs_sub8x8(mi, i, mi->bmi[i].as_mv, mbmi_ext, td->counts->mv); +#endif } } } else { -#if CONFIG_EXT_INTER if (have_newmv_in_inter_mode(mbmi->mode)) + +#if CONFIG_AMVR + inc_mvs(mbmi, mbmi_ext, mbmi->mv, mbmi->pred_mv, td->counts->mv, + precision); #else - if (mbmi->mode == NEWMV) -#endif // CONFIG_EXT_INTER inc_mvs(mbmi, mbmi_ext, mbmi->mv, mbmi->pred_mv, td->counts->mv); +#endif } } |