Commit 0e7b1d7b authored by Thomas Davies's avatar Thomas Davies

NEW_MULTISYMBOL: adapt remaining bits in the magnitude.

Reduce the number of contexts from 10 to 6.

BUG=aomedia:830

Change-Id: If0ec302816975293b7dbd164c867feb66fa76847
parent b98ea58d
......@@ -2255,6 +2255,7 @@ void av1_average_tile_mv_cdfs(FRAME_CONTEXT *fc, FRAME_CONTEXT *ec_ctxs[],
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)
AVERAGE_TILE_CDFS(nmvc[j].comps[k].bits_cdf)
#endif
}
}
......
......@@ -68,6 +68,12 @@ static const nmv_context default_nmv_context = {
{ AOM_ICDF(160 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(216 * 128), AOM_ICDF(32768), 0 },
{ { AOM_ICDF(128 * 196), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 198), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 208), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 224), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 245), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 240), AOM_ICDF(32768), 0 } }, // bits_cdf
#endif
},
{
......@@ -93,6 +99,12 @@ static const nmv_context default_nmv_context = {
{ AOM_ICDF(160 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(216 * 128), AOM_ICDF(32768), 0 },
{ { AOM_ICDF(128 * 196), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 198), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 208), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 224), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 245), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 240), AOM_ICDF(32768), 0 } }, // bits_cdf
#endif
} },
};
......
......@@ -66,6 +66,9 @@ typedef enum {
#define CLASS0_BITS 1 /* bits at integer precision for class 0 */
#define CLASS0_SIZE (1 << CLASS0_BITS)
#define MV_OFFSET_BITS (MV_CLASSES + CLASS0_BITS - 2)
#if CONFIG_NEW_MULTISYMBOL
#define MV_BITS_CONTEXTS 6
#endif
#define MV_FP_SIZE 4
#define MV_MAX_BITS (MV_CLASSES + CLASS0_BITS + 2)
......@@ -97,6 +100,7 @@ typedef struct {
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)];
aom_cdf_prob bits_cdf[MV_BITS_CONTEXTS][CDF_SIZE(2)];
#endif
} nmv_component;
......
......@@ -5723,7 +5723,9 @@ void av1_decode_tg_tiles_and_wrapup(AV1Decoder *pbi, const uint8_t *data,
if (!frame_is_intra_only(cm)) {
av1_adapt_inter_frame_probs(cm);
#if !CONFIG_NEW_MULTISYMBOL
av1_adapt_mv_probs(cm, cm->allow_high_precision_mv);
#endif
av1_average_tile_inter_cdfs(&pbi->common, pbi->common.fc, tile_ctxs,
cdf_ptrs, cm->tile_rows * cm->tile_cols);
av1_average_tile_mv_cdfs(pbi->common.fc, tile_ctxs, cdf_ptrs,
......
......@@ -1274,9 +1274,13 @@ static int read_mv_component(aom_reader *r, nmv_component *mvcomp,
} else {
int i;
const int n = mv_class + CLASS0_BITS - 1; // number of bits
d = 0;
#if CONFIG_NEW_MULTISYMBOL
for (i = 0; i < n; ++i)
d |= aom_read_symbol(r, mvcomp->bits_cdf[(i + 1) / 2], 2, ACCT_STR) << i;
#else
for (i = 0; i < n; ++i) d |= aom_read(r, mvcomp->bits[i], ACCT_STR) << i;
#endif
mag = CLASS0_SIZE << (mv_class + 2);
}
......
......@@ -62,9 +62,13 @@ 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 || CONFIG_AMVR
if (precision > MV_SUBPEL_NONE)
......
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