Commit 599395ee authored by Thomas Davies's avatar Thomas Davies

NEW_MULTISYMBOL: adapt binary MV values.

Change-Id: I00f98e0e03a44aa894566b7a47bb0f32b56da766
parent 4c5df105
......@@ -5641,6 +5641,11 @@ void av1_average_tile_mv_cdfs(FRAME_CONTEXT *fc, FRAME_CONTEXT *ec_ctxs[],
AVERAGE_TILE_CDFS(nmvc[j].comps[k].class_cdf)
AVERAGE_TILE_CDFS(nmvc[j].comps[k].class0_fp_cdf)
AVERAGE_TILE_CDFS(nmvc[j].comps[k].fp_cdf)
#if CONFIG_NEW_MULTISYMBOL
AVERAGE_TILE_CDFS(nmvc[j].comps[k].hp_cdf)
AVERAGE_TILE_CDFS(nmvc[j].comps[k].class0_hp_cdf)
AVERAGE_TILE_CDFS(nmvc[j].comps[k].class0_cdf)
#endif
}
}
}
......
......@@ -64,6 +64,11 @@ static const nmv_context default_nmv_context = {
0 }, // fp_cdf
160, // class0_hp bit
128, // hp
#if CONFIG_NEW_MULTISYMBOL
{ AOM_ICDF(160 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(216 * 128), AOM_ICDF(32768), 0 },
#endif
},
{
// Horizontal component
......@@ -84,6 +89,11 @@ static const nmv_context default_nmv_context = {
0 }, // fp_cdf
160, // class0_hp bit
128, // hp
#if CONFIG_NEW_MULTISYMBOL
{ AOM_ICDF(160 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(216 * 128), AOM_ICDF(32768), 0 },
#endif
} },
};
......
......@@ -93,6 +93,11 @@ typedef struct {
aom_cdf_prob fp_cdf[CDF_SIZE(MV_FP_SIZE)];
aom_prob class0_hp;
aom_prob hp;
#if CONFIG_NEW_MULTISYMBOL
aom_cdf_prob class0_hp_cdf[CDF_SIZE(2)];
aom_cdf_prob hp_cdf[CDF_SIZE(2)];
aom_cdf_prob class0_cdf[CDF_SIZE(CLASS0_SIZE)];
#endif
} nmv_component;
typedef struct {
......
......@@ -248,6 +248,7 @@ static void read_frame_reference_mode_probs(AV1_COMMON *cm, aom_reader *r) {
}
}
#if !CONFIG_NEW_MULTISYMBOL
static void update_mv_probs(aom_prob *p, int n, aom_reader *r) {
int i;
for (i = 0; i < n; ++i) av1_diff_update_prob(r, &p[i], ACCT_STR);
......@@ -263,6 +264,7 @@ static void read_mv_probs(nmv_context *ctx, int allow_hp, aom_reader *r) {
}
}
}
#endif
static void inverse_transform_block(MACROBLOCKD *xd, int plane,
#if CONFIG_LGT
......@@ -4936,9 +4938,11 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
#if CONFIG_SUPERTX
MACROBLOCKD *const xd = &pbi->mb;
#endif
FRAME_CONTEXT *const fc = cm->fc;
aom_reader r;
#if !CONFIG_NEW_MULTISYMBOL
FRAME_CONTEXT *const fc = cm->fc;
int i;
#endif
#if CONFIG_ANS && ANS_MAX_SYMBOLS
r.window_size = 1 << cm->ans_window_size_log2;
......@@ -5035,8 +5039,10 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
av1_diff_update_prob(&r, &fc->comp_inter_mode_prob[i], ACCT_STR);
#endif // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
#if !CONFIG_NEW_MULTISYMBOL
for (i = 0; i < NMV_CONTEXTS; ++i)
read_mv_probs(&fc->nmvc[i], cm->allow_high_precision_mv, &r);
#endif
#if CONFIG_SUPERTX
if (!xd->lossless[0]) read_supertx_probs(fc, &r);
#endif
......
......@@ -1259,14 +1259,22 @@ static int read_mv_component(aom_reader *r, nmv_component *mvcomp,
#endif // CONFIG_INTRABC
int usehp) {
int mag, d, fr, hp;
#if CONFIG_NEW_MULTISYMBOL
const int sign = aom_read_bit(r, ACCT_STR);
#else
const int sign = aom_read(r, mvcomp->sign, ACCT_STR);
#endif
const int mv_class =
aom_read_symbol(r, mvcomp->class_cdf, MV_CLASSES, ACCT_STR);
const int class0 = mv_class == MV_CLASS_0;
// Integer part
if (class0) {
#if CONFIG_NEW_MULTISYMBOL
d = aom_read_symbol(r, mvcomp->class0_cdf, CLASS0_SIZE, ACCT_STR);
#else
d = aom_read(r, mvcomp->class0[0], ACCT_STR);
#endif
mag = 0;
} else {
int i;
......@@ -1284,9 +1292,16 @@ static int read_mv_component(aom_reader *r, nmv_component *mvcomp,
fr = aom_read_symbol(r, class0 ? mvcomp->class0_fp_cdf[d] : mvcomp->fp_cdf,
MV_FP_SIZE, ACCT_STR);
// High precision part (if hp is not used, the default value of the hp is 1)
hp = usehp ? aom_read(r, class0 ? mvcomp->class0_hp : mvcomp->hp, ACCT_STR)
// High precision part (if hp is not used, the default value of the hp is 1)
#if CONFIG_NEW_MULTISYMBOL
hp = usehp ? aom_read_symbol(
r, class0 ? mvcomp->class0_hp_cdf : mvcomp->hp_cdf, 2,
ACCT_STR)
: 1;
#else
hp = usehp ? aom_read(r, class0 ? mvcomp->class0_hp : mvcomp->hp, ACCT_STR)
: 1;
#endif
#if CONFIG_INTRABC
} else {
fr = 3;
......
......@@ -4557,10 +4557,10 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
MACROBLOCKD *const xd = &cpi->td.mb.e_mbd;
#endif // CONFIG_SUPERTX
FRAME_CONTEXT *const fc = cm->fc;
FRAME_COUNTS *counts = cpi->td.counts;
aom_writer *header_bc;
int i;
#if !CONFIG_NEW_MULTISYMBOL
FRAME_COUNTS *counts = cpi->td.counts;
int j;
#endif
......@@ -4712,7 +4712,9 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
counts->comp_inter_mode[i], probwt);
#endif // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
#if !CONFIG_NEW_MULTISYMBOL
av1_write_nmv_probs(cm, cm->allow_high_precision_mv, header_bc, counts->mv);
#endif
#if CONFIG_SUPERTX
if (!xd->lossless[0]) update_supertx_probs(cm, probwt, header_bc);
#endif // CONFIG_SUPERTX
......
......@@ -42,15 +42,23 @@ static void encode_mv_component(aom_writer *w, int comp, nmv_component *mvcomp,
assert(comp != 0);
// Sign
// Sign
#if CONFIG_NEW_MULTISYMBOL
aom_write_bit(w, sign);
#else
aom_write(w, sign, mvcomp->sign);
#endif
// Class
aom_write_symbol(w, mv_class, mvcomp->class_cdf, MV_CLASSES);
// Integer bits
if (mv_class == MV_CLASS_0) {
#if CONFIG_NEW_MULTISYMBOL
aom_write_symbol(w, d, mvcomp->class0_cdf, CLASS0_SIZE);
#else
aom_write(w, d, mvcomp->class0[0]);
#endif
} else {
int i;
const int n = mv_class + CLASS0_BITS - 1; // number of bits
......@@ -69,7 +77,13 @@ static void encode_mv_component(aom_writer *w, int comp, nmv_component *mvcomp,
// High precision bit
if (precision > MV_SUBPEL_LOW_PRECISION)
#if CONFIG_NEW_MULTISYMBOL
aom_write_symbol(
w, hp, mv_class == MV_CLASS_0 ? mvcomp->class0_hp_cdf : mvcomp->hp_cdf,
2);
#else
aom_write(w, hp, mv_class == MV_CLASS_0 ? mvcomp->class0_hp : mvcomp->hp);
#endif
}
static void build_nmv_component_cost_table(int *mvcost,
......@@ -137,6 +151,7 @@ static void build_nmv_component_cost_table(int *mvcost,
}
}
#if !CONFIG_NEW_MULTISYMBOL
static void update_mv(aom_writer *w, const unsigned int ct[2], aom_prob *cur_p,
aom_prob upd_p) {
(void)upd_p;
......@@ -163,6 +178,7 @@ void av1_write_nmv_probs(AV1_COMMON *cm, int usehp, aom_writer *w,
}
}
}
#endif
void av1_encode_mv(AV1_COMP *cpi, aom_writer *w, const MV *mv, const MV *ref,
nmv_context *mvctx, int usehp) {
......
......@@ -20,8 +20,10 @@ extern "C" {
void av1_entropy_mv_init(void);
#if !CONFIG_NEW_MULTISYMBOL
void av1_write_nmv_probs(AV1_COMMON *cm, int usehp, aom_writer *w,
nmv_context_counts *const counts);
#endif
void av1_encode_mv(AV1_COMP *cpi, aom_writer *w, const MV *mv, const MV *ref,
nmv_context *mvctx, int usehp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment