Commit 1fe85a35 authored by Deb Mukherjee's avatar Deb Mukherjee

Adaptive entropy coding of coefficients, modes, mv.

This patch incorporates adaptive entropy coding of coefficient tokens,
and mode/mv information based on distributions encountered in a frame.
Specifically, there is an initial forward update to the probabilities
in the bitstream as before for coding the symbols in the frame, however
at the end of decoding each frame, the forward update to the
probabilities is reverted and instead the probabilities are updated
towards the actual distributions encountered within the frame.
The amount of update is weighted by the number of hits within each
context.

Results on derf/hd/std-hd are all up by 1.6%.

On derf, the most of the gains come from coefficients, however for the
hd and std-hd sets, the most of the gains come from the mode/mv
information updates.

Change-Id: I708c0e11fdacafee04940fe7ae159ba6844005fd
parent 378ba611
......@@ -230,6 +230,7 @@ EXPERIMENT_LIST="
expanded_coef_context
int_8x8fdct
newintramodes
adaptive_entropy
"
CONFIG_LIST="
external_build
......
......@@ -15,6 +15,7 @@
#include "onyxc_int.h"
#include "findnearmv.h"
#include "entropymode.h"
#include "entropymv.h"
#include "systemdependent.h"
......@@ -239,6 +240,8 @@ void vp8_initialize_common()
vp8_entropy_mode_init();
vp8_entropy_mv_init();
vp8_init_scan_order_mask();
}
File mode changed from 100755 to 100644
......@@ -15,6 +15,7 @@
#include "string.h"
#include "blockd.h"
#include "onyxc_int.h"
#include "entropymode.h"
#include "vpx_mem/vpx_mem.h"
#define uchar unsigned char /* typedefs can clash */
......@@ -192,3 +193,139 @@ void vp8_coef_tree_initialize()
init_bit_trees();
vp8_tokens_from_tree(vp8_coef_encodings, vp8_coef_tree);
}
#if CONFIG_ADAPTIVE_ENTROPY
//#define COEF_COUNT_TESTING
#define COEF_COUNT_SAT 24
#define COEF_MAX_UPDATE_FACTOR 112
#define COEF_COUNT_SAT_KEY 24
#define COEF_MAX_UPDATE_FACTOR_KEY 112
#define COEF_COUNT_SAT_AFTER_KEY 24
#define COEF_MAX_UPDATE_FACTOR_AFTER_KEY 128
void vp8_adapt_coef_probs(VP8_COMMON *cm)
{
int t, i, j, k, count;
unsigned int branch_ct[ENTROPY_NODES][2];
vp8_prob coef_probs[ENTROPY_NODES];
int update_factor; /* denominator 256 */
int factor;
int count_sat;
//printf("Frame type: %d\n", cm->frame_type);
if (cm->frame_type == KEY_FRAME)
{
update_factor = COEF_MAX_UPDATE_FACTOR_KEY;
count_sat = COEF_COUNT_SAT_KEY;
}
else if (cm->last_frame_type == KEY_FRAME)
{
update_factor = COEF_MAX_UPDATE_FACTOR_AFTER_KEY; /* adapt quickly */
count_sat = COEF_COUNT_SAT_AFTER_KEY;
}
else
{
update_factor = COEF_MAX_UPDATE_FACTOR;
count_sat = COEF_COUNT_SAT;
}
#ifdef COEF_COUNT_TESTING
{
printf("static const unsigned int\ncoef_counts"
"[BLOCK_TYPES] [COEF_BANDS]"
"[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS] = {\n");
for (i = 0; i<BLOCK_TYPES; ++i)
{
printf(" {\n");
for (j = 0; j<COEF_BANDS; ++j)
{
printf(" {\n");
for (k = 0; k<PREV_COEF_CONTEXTS; ++k)
{
printf(" {");
for (t = 0; t<MAX_ENTROPY_TOKENS; ++t) printf("%d, ", cm->fc.coef_counts[i][j][k][t]);
printf("},\n");
}
printf(" },\n");
}
printf(" },\n");
}
printf("};\n");
printf("static const unsigned int\ncoef_counts_8x8"
"[BLOCK_TYPES_8X8] [COEF_BANDS]"
"[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS] = {\n");
for (i = 0; i<BLOCK_TYPES_8X8; ++i)
{
printf(" {\n");
for (j = 0; j<COEF_BANDS; ++j)
{
printf(" {\n");
for (k = 0; k<PREV_COEF_CONTEXTS; ++k)
{
printf(" {");
for (t = 0; t<MAX_ENTROPY_TOKENS; ++t) printf("%d, ", cm->fc.coef_counts_8x8[i][j][k][t]);
printf("},\n");
}
printf(" },\n");
}
printf(" },\n");
}
printf("};\n");
}
#endif
for (i = 0; i<BLOCK_TYPES; ++i)
for (j = 0; j<COEF_BANDS; ++j)
for (k = 0; k<PREV_COEF_CONTEXTS; ++k)
{
#if CONFIG_EXPANDED_COEF_CONTEXT
if (k >=3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
continue;
#endif
vp8_tree_probs_from_distribution(
MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
coef_probs, branch_ct, cm->fc.coef_counts [i][j][k],
256, 1);
for (t=0; t<ENTROPY_NODES; ++t)
{
int prob;
count = branch_ct[t][0] + branch_ct[t][1];
count = count > count_sat ? count_sat : count;
factor = (update_factor * count / count_sat);
prob = ((int)cm->fc.pre_coef_probs[i][j][k][t] * (256-factor) +
(int)coef_probs[t] * factor + 128) >> 8;
if (prob <= 0) cm->fc.coef_probs[i][j][k][t] = 1;
else if (prob > 255) cm->fc.coef_probs[i][j][k][t] = 255;
else cm->fc.coef_probs[i][j][k][t] = prob;
}
}
for (i = 0; i<BLOCK_TYPES_8X8; ++i)
for (j = 0; j<COEF_BANDS; ++j)
for (k = 0; k<PREV_COEF_CONTEXTS; ++k)
{
#if CONFIG_EXPANDED_COEF_CONTEXT
if (k >=3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
continue;
#endif
vp8_tree_probs_from_distribution(
MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
coef_probs, branch_ct, cm->fc.coef_counts_8x8 [i][j][k],
256, 1);
for (t=0; t<ENTROPY_NODES; ++t)
{
int prob;
count = branch_ct[t][0] + branch_ct[t][1];
count = count > count_sat ? count_sat : count;
factor = (update_factor * count / count_sat);
prob = ((int)cm->fc.pre_coef_probs_8x8[i][j][k][t] * (256-factor) +
(int)coef_probs[t] * factor + 128) >> 8;
if (prob <= 0) cm->fc.coef_probs_8x8[i][j][k][t] = 1;
else if (prob > 255) cm->fc.coef_probs_8x8[i][j][k][t] = 255;
else cm->fc.coef_probs_8x8[i][j][k][t] = prob;
}
}
}
#endif
......@@ -92,9 +92,9 @@ extern DECLARE_ALIGNED(64, const unsigned char, vp8_coef_bands_8x8[64]);
#endif
#if CONFIG_NEWUPDATE
#define SUBEXP_PARAM 2 /* Subexponential code parameter */
#define MODULUS_PARAM 21 /* Modulus parameter */
#define COEFUPDATETYPE 2 /* coef update type to use (1/2/3) */
#define SUBEXP_PARAM 4 /* Subexponential code parameter */
#define MODULUS_PARAM 13 /* Modulus parameter */
#define COEFUPDATETYPE 1 /* coef update type to use (1/2/3) */
#endif
......@@ -107,4 +107,8 @@ extern short vp8_default_zig_zag_mask[16];
extern DECLARE_ALIGNED(64, const int, vp8_default_zig_zag1d_8x8[64]);
extern short vp8_default_zig_zag_mask_8x8[64];//int64_t
void vp8_coef_tree_initialize(void);
#if CONFIG_ADAPTIVE_ENTROPY
void vp8_adapt_coef_probs(struct VP8Common *);
#endif
#endif
......@@ -11,6 +11,7 @@
#include "modecont.h"
#include "entropymode.h"
#include "entropymv.h"
#include "entropy.h"
#include "vpx_mem/vpx_mem.h"
......@@ -325,40 +326,6 @@ struct vp8_token_struct vp8_mbsplit_encodings [VP8_NUMMBSPLITS];
struct vp8_token_struct vp8_mv_ref_encoding_array [VP8_MVREFS];
struct vp8_token_struct vp8_sub_mv_ref_encoding_array [VP8_SUBMVREFS];
#if CONFIG_HIGH_PRECISION_MV
const vp8_tree_index vp8_small_mvtree_hp [30] =
{
2, 16,
4, 10,
6, 8,
-0, -1,
-2, -3,
12, 14,
-4, -5,
-6, -7,
18, 24,
20, 22,
-8, -9,
-10, -11,
26, 28,
-12, -13,
-14, -15
};
struct vp8_token_struct vp8_small_mvencodings_hp [16];
#endif /* CONFIG_HIGH_PRECISION_MV */
const vp8_tree_index vp8_small_mvtree [14] =
{
2, 8,
4, 6,
-0, -1,
-2, -3,
10, 12,
-4, -5,
-6, -7
};
struct vp8_token_struct vp8_small_mvencodings [8];
void vp8_init_mbmode_probs(VP8_COMMON *x)
......@@ -396,7 +363,7 @@ void vp8_init_mbmode_probs(VP8_COMMON *x)
vp8_tree_probs_from_distribution(
VP8_I8X8_MODES, vp8_i8x8_mode_encodings, vp8_i8x8_mode_tree,
x->i8x8_mode_prob, bct, i8x8_mode_cts,
x->fc.i8x8_mode_prob, bct, i8x8_mode_cts,
256, 1);
vpx_memcpy(x->fc.sub_mv_ref_prob, sub_mv_ref_prob, sizeof(sub_mv_ref_prob));
......@@ -458,11 +425,6 @@ void vp8_entropy_mode_init()
vp8_mv_ref_tree, NEARESTMV);
vp8_tokens_from_tree_offset(vp8_sub_mv_ref_encoding_array,
vp8_sub_mv_ref_tree, LEFT4X4);
vp8_tokens_from_tree(vp8_small_mvencodings, vp8_small_mvtree);
#if CONFIG_HIGH_PRECISION_MV
vp8_tokens_from_tree(vp8_small_mvencodings_hp, vp8_small_mvtree_hp);
#endif
}
void vp8_init_mode_contexts(VP8_COMMON *pc)
......@@ -595,3 +557,110 @@ void print_mv_ref_cts(VP8_COMMON *pc)
printf("\n");
}
}
#if CONFIG_ADAPTIVE_ENTROPY
//#define MODE_COUNT_TESTING
#define MODE_COUNT_SAT 16
#define MODE_MAX_UPDATE_FACTOR 96
void vp8_adapt_mode_probs(VP8_COMMON *cm)
{
int i, t, count, factor;
unsigned int branch_ct[32][2];
int update_factor = MODE_MAX_UPDATE_FACTOR; /* denominator 256 */
int count_sat = MODE_COUNT_SAT;
vp8_prob ymode_probs[VP8_YMODES-1];
vp8_prob uvmode_probs[VP8_UV_MODES-1];
vp8_prob bmode_probs[VP8_BINTRAMODES-1];
vp8_prob i8x8_mode_probs[VP8_I8X8_MODES-1];
#ifdef MODE_COUNT_TESTING
printf("static const unsigned int\nymode_counts"
"[VP8_YMODES] = {\n");
for (t = 0; t<VP8_YMODES; ++t) printf("%d, ", cm->fc.ymode_counts[t]);
printf("};\n");
printf("static const unsigned int\nuv_mode_counts"
"[VP8_YMODES] [VP8_UV_MODES] = {\n");
for (i = 0; i < VP8_YMODES; ++i)
{
printf(" {");
for (t = 0; t < VP8_UV_MODES; ++t) printf("%d, ", cm->fc.uv_mode_counts[i][t]);
printf("},\n");
}
printf("};\n");
printf("static const unsigned int\nbmode_counts"
"[VP8_BINTRAMODES] = {\n");
for (t = 0; t<VP8_BINTRAMODES; ++t) printf("%d, ", cm->fc.bmode_counts[t]);
printf("};\n");
printf("static const unsigned int\ni8x8_mode_counts"
"[VP8_I8X8_MODES] = {\n");
for (t = 0; t<VP8_I8X8_MODES; ++t) printf("%d, ", cm->fc.i8x8_mode_counts[t]);
printf("};\n");
#endif
vp8_tree_probs_from_distribution(
VP8_YMODES, vp8_ymode_encodings, vp8_ymode_tree,
ymode_probs, branch_ct, cm->fc.ymode_counts,
256, 1);
for (t=0; t<VP8_YMODES-1; ++t)
{
int prob;
count = branch_ct[t][0] + branch_ct[t][1];
count = count > count_sat ? count_sat : count;
factor = (update_factor * count / count_sat);
prob = ((int)cm->fc.pre_ymode_prob[t] * (256-factor) +
(int)ymode_probs[t] * factor + 128) >> 8;
if (prob <= 0) cm->fc.ymode_prob[t] = 1;
else if (prob > 255) cm->fc.ymode_prob[t] = 255;
else cm->fc.ymode_prob[t] = prob;
}
for (i = 0; i < VP8_YMODES; ++i)
{
vp8_tree_probs_from_distribution(
VP8_UV_MODES, vp8_uv_mode_encodings, vp8_uv_mode_tree,
uvmode_probs, branch_ct, cm->fc.uv_mode_counts[i],
256, 1);
for (t = 0; t < VP8_UV_MODES-1; ++t)
{
int prob;
count = branch_ct[t][0] + branch_ct[t][1];
count = count > count_sat ? count_sat : count;
factor = (update_factor * count / count_sat);
prob = ((int)cm->fc.pre_uv_mode_prob[i][t] * (256-factor) +
(int)uvmode_probs[t] * factor + 128) >> 8;
if (prob <= 0) cm->fc.uv_mode_prob[i][t] = 1;
else if (prob > 255) cm->fc.uv_mode_prob[i][t] = 255;
else cm->fc.uv_mode_prob[i][t] = prob;
}
}
vp8_tree_probs_from_distribution(
VP8_BINTRAMODES, vp8_bmode_encodings, vp8_bmode_tree,
bmode_probs, branch_ct, cm->fc.bmode_counts,
256, 1);
for (t=0; t<VP8_BINTRAMODES-1; ++t)
{
int prob;
count = branch_ct[t][0] + branch_ct[t][1];
count = count > count_sat ? count_sat : count;
factor = (update_factor * count / count_sat);
prob = ((int)cm->fc.pre_bmode_prob[t] * (256-factor) +
(int)bmode_probs[t] * factor + 128) >> 8;
if (prob <= 0) cm->fc.bmode_prob[t] = 1;
else if (prob > 255) cm->fc.bmode_prob[t] = 255;
else cm->fc.bmode_prob[t] = prob;
}
vp8_tree_probs_from_distribution(
VP8_I8X8_MODES, vp8_i8x8_mode_encodings, vp8_i8x8_mode_tree,
i8x8_mode_probs, branch_ct, cm->fc.i8x8_mode_counts,
256, 1);
for (t=0; t<VP8_I8X8_MODES-1; ++t)
{
int prob;
count = branch_ct[t][0] + branch_ct[t][1];
count = count > count_sat ? count_sat : count;
factor = (update_factor * count / count_sat);
prob = ((int)cm->fc.pre_i8x8_mode_prob[t] * (256-factor) +
(int)i8x8_mode_probs[t] * factor + 128) >> 8;
if (prob <= 0) cm->fc.i8x8_mode_prob[t] = 1;
else if (prob > 255) cm->fc.i8x8_mode_prob[t] = 255;
else cm->fc.i8x8_mode_prob[t] = prob;
}
}
#endif
......@@ -55,13 +55,6 @@ extern struct vp8_token_struct vp8_mbsplit_encodings [VP8_NUMMBSPLITS];
extern struct vp8_token_struct vp8_mv_ref_encoding_array [VP8_MVREFS];
extern struct vp8_token_struct vp8_sub_mv_ref_encoding_array [VP8_SUBMVREFS];
extern const vp8_tree_index vp8_small_mvtree[];
extern struct vp8_token_struct vp8_small_mvencodings [8];
#if CONFIG_HIGH_PRECISION_MV
extern const vp8_tree_index vp8_small_mvtree_hp[];
extern struct vp8_token_struct vp8_small_mvencodings_hp [16];
#endif
void vp8_entropy_mode_init(void);
void vp8_init_mbmode_probs(VP8_COMMON *x);
......@@ -71,7 +64,10 @@ extern void vp8_accum_mv_refs(VP8_COMMON *pc,
MB_PREDICTION_MODE m,
const int ct[4]);
void vp8_default_bmode_probs(vp8_prob dest [VP8_BINTRAMODES-1]);
void vp8_default_bmode_probs(vp8_prob dest [VP8_BINTRAMODES-1]);
void vp8_kf_default_bmode_probs(vp8_prob dest [VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES-1]);
#if CONFIG_ADAPTIVE_ENTROPY
void vp8_adapt_mode_probs(struct VP8Common *);
#endif
#endif
This diff is collapsed.
......@@ -71,6 +71,16 @@ typedef struct mv_context_hp
} MV_CONTEXT_HP;
extern const MV_CONTEXT_HP vp8_mv_update_probs_hp[2], vp8_default_mv_context_hp[2];
#endif /* CONFIG_HIGH_PRECISION_MV */
extern const vp8_tree_index vp8_small_mvtree[];
extern struct vp8_token_struct vp8_small_mvencodings [8];
#if CONFIG_HIGH_PRECISION_MV
extern const vp8_tree_index vp8_small_mvtree_hp[];
extern struct vp8_token_struct vp8_small_mvencodings_hp [16];
#endif
void vp8_entropy_mv_init();
#endif
......@@ -47,6 +47,7 @@ typedef struct frame_contexts
vp8_prob bmode_prob [VP8_BINTRAMODES-1];
vp8_prob ymode_prob [VP8_YMODES-1]; /* interframe intra mode probs */
vp8_prob uv_mode_prob [VP8_YMODES][VP8_UV_MODES-1];
vp8_prob i8x8_mode_prob [VP8_I8X8_MODES-1];
vp8_prob sub_mv_ref_prob [VP8_SUBMVREFS-1];
vp8_prob coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
vp8_prob coef_probs_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
......@@ -54,6 +55,31 @@ typedef struct frame_contexts
#if CONFIG_HIGH_PRECISION_MV
MV_CONTEXT_HP mvc_hp[2];
#endif
#if CONFIG_ADAPTIVE_ENTROPY
MV_CONTEXT pre_mvc[2];
#if CONFIG_HIGH_PRECISION_MV
MV_CONTEXT_HP pre_mvc_hp[2];
#endif
vp8_prob pre_bmode_prob [VP8_BINTRAMODES-1];
vp8_prob pre_ymode_prob [VP8_YMODES-1]; /* interframe intra mode probs */
vp8_prob pre_uv_mode_prob [VP8_YMODES][VP8_UV_MODES-1];
vp8_prob pre_i8x8_mode_prob [VP8_I8X8_MODES-1];
unsigned int bmode_counts [VP8_BINTRAMODES];
unsigned int ymode_counts [VP8_YMODES]; /* interframe intra mode probs */
unsigned int uv_mode_counts [VP8_YMODES][VP8_UV_MODES];
unsigned int i8x8_mode_counts [VP8_I8X8_MODES]; /* interframe intra mode probs */
vp8_prob pre_coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
vp8_prob pre_coef_probs_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
unsigned int coef_counts [BLOCK_TYPES] [COEF_BANDS]
[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
unsigned int coef_counts_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS]
[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
unsigned int MVcount [2] [MVvals];
#if CONFIG_HIGH_PRECISION_MV
unsigned int MVcount_hp [2] [MVvals_hp];
#endif
#endif /* CONFIG_ADAPTIVE_ENTROPY */
} FRAME_CONTEXT;
typedef enum
......@@ -104,7 +130,6 @@ typedef struct VP8_COMMON_RTCD
} VP8_COMMON_RTCD;
typedef struct VP8Common
{
struct vpx_internal_error_info error;
......@@ -205,7 +230,6 @@ typedef struct VP8Common
int kf_ymode_probs_index;
int kf_ymode_probs_update;
vp8_prob kf_uv_mode_prob[VP8_YMODES] [VP8_UV_MODES-1];
vp8_prob i8x8_mode_prob [VP8_UV_MODES-1];
vp8_prob prob_intra_coded;
vp8_prob prob_last_coded;
......
File mode changed from 100755 to 100644
......@@ -171,7 +171,7 @@ static void vp8_kfread_modes(VP8D_COMP *pbi,
for(i=0;i<4;i++)
{
int ib = vp8_i8x8_block[i];
mode8x8 = vp8_read_i8x8_mode(bc, pbi->common.i8x8_mode_prob);
mode8x8 = vp8_read_i8x8_mode(bc, pbi->common.fc.i8x8_mode_prob);
m->bmi[ib+0].as_mode.first= mode8x8;
m->bmi[ib+1].as_mode.first= mode8x8;
m->bmi[ib+4].as_mode.first= mode8x8;
......@@ -789,10 +789,22 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
case NEW4X4:
#if CONFIG_HIGH_PRECISION_MV
if (xd->allow_high_precision_mv)
{
read_mv_hp(bc, &blockmv.as_mv, (const MV_CONTEXT_HP *) mvc_hp);
#if CONFIG_ADAPTIVE_ENTROPY
cm->fc.MVcount_hp[0][mv_max_hp+(blockmv.as_mv.row)]++;
cm->fc.MVcount_hp[1][mv_max_hp+(blockmv.as_mv.col)]++;
#endif
}
else
#endif
read_mv(bc, &blockmv.as_mv, (const MV_CONTEXT *) mvc);
{
read_mv(bc, &blockmv.as_mv, (const MV_CONTEXT *) mvc);
#if CONFIG_ADAPTIVE_ENTROPY
cm->fc.MVcount[0][mv_max+(blockmv.as_mv.row>>1)]++;
cm->fc.MVcount[1][mv_max+(blockmv.as_mv.col>>1)]++;
#endif
}
blockmv.as_mv.row += best_mv.as_mv.row;
blockmv.as_mv.col += best_mv.as_mv.col;
......@@ -807,25 +819,25 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
secondmv.as_mv.row += best_mv_second.as_mv.row;
secondmv.as_mv.col += best_mv_second.as_mv.col;
}
#ifdef VPX_MODE_COUNT
#ifdef VPX_MODE_COUNT
vp8_mv_cont_count[mv_contz][3]++;
#endif
#endif
break;
case LEFT4X4:
blockmv.as_int = leftmv.as_int;
if (mbmi->second_ref_frame)
secondmv.as_int = second_leftmv.as_int;
#ifdef VPX_MODE_COUNT
#ifdef VPX_MODE_COUNT
vp8_mv_cont_count[mv_contz][0]++;
#endif
#endif
break;
case ABOVE4X4:
blockmv.as_int = abovemv.as_int;
if (mbmi->second_ref_frame)
secondmv.as_int = second_abovemv.as_int;
#ifdef VPX_MODE_COUNT
#ifdef VPX_MODE_COUNT
vp8_mv_cont_count[mv_contz][1]++;
#endif
#endif
break;
case ZERO4X4:
blockmv.as_int = 0;
......@@ -914,10 +926,22 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
case NEWMV:
#if CONFIG_HIGH_PRECISION_MV
if (xd->allow_high_precision_mv)
{
read_mv_hp(bc, &mv->as_mv, (const MV_CONTEXT_HP *) mvc_hp);
#if CONFIG_ADAPTIVE_ENTROPY
cm->fc.MVcount_hp[0][mv_max_hp+(mv->as_mv.row)]++;
cm->fc.MVcount_hp[1][mv_max_hp+(mv->as_mv.col)]++;
#endif
}
else
#endif
read_mv(bc, &mv->as_mv, (const MV_CONTEXT *) mvc);
{
read_mv(bc, &mv->as_mv, (const MV_CONTEXT *) mvc);
#if CONFIG_ADAPTIVE_ENTROPY
cm->fc.MVcount[0][mv_max+(mv->as_mv.row>>1)]++;
cm->fc.MVcount[1][mv_max+(mv->as_mv.col>>1)]++;
#endif
}
mv->as_mv.row += best_mv.as_mv.row;
mv->as_mv.col += best_mv.as_mv.col;
......@@ -967,6 +991,9 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
{
mbmi->mode = (MB_PREDICTION_MODE)
vp8_read_ymode(bc, pbi->common.fc.ymode_prob);
#if CONFIG_ADAPTIVE_ENTROPY
pbi->common.fc.ymode_counts[mbmi->mode]++;
#endif
}
#if CONFIG_COMP_INTRA_PRED
mbmi->second_mode = (MB_PREDICTION_MODE) (DC_PRED - 1);
......@@ -982,6 +1009,9 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
do
{
mi->bmi[j].as_mode.first = (B_PREDICTION_MODE)vp8_read_bmode(bc, pbi->common.fc.bmode_prob);
#if CONFIG_ADAPTIVE_ENTROPY
pbi->common.fc.bmode_counts[mi->bmi[j].as_mode.first]++;
#endif
#if CONFIG_COMP_INTRA_PRED
if (use_comp_pred)
{
......@@ -1003,11 +1033,14 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
for(i=0;i<4;i++)
{
int ib = vp8_i8x8_block[i];
mode8x8 = vp8_read_i8x8_mode(bc, pbi->common.i8x8_mode_prob);
mode8x8 = vp8_read_i8x8_mode(bc, pbi->common.fc.i8x8_mode_prob);
mi->bmi[ib+0].as_mode.first= mode8x8;
mi->bmi[ib+1].as_mode.first= mode8x8;
mi->bmi[ib+4].as_mode.first= mode8x8;
mi->bmi[ib+5].as_mode.first= mode8x8;
#if CONFIG_ADAPTIVE_ENTROPY
pbi->common.fc.i8x8_mode_counts[mode8x8]++;
#endif
#if CONFIG_COMP_INTRA_PRED
mi->bmi[ib+0].as_mode.second= (MB_PREDICTION_MODE) (DC_PRED - 1);
mi->bmi[ib+1].as_mode.second= (MB_PREDICTION_MODE) (DC_PRED - 1);
......@@ -1017,8 +1050,13 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
}
}
else
{
mbmi->uv_mode = (MB_PREDICTION_MODE)vp8_read_uv_mode(bc,
pbi->common.fc.uv_mode_prob[mbmi->mode]);
#if CONFIG_ADAPTIVE_ENTROPY
pbi->common.fc.uv_mode_counts[mbmi->mode][mbmi->uv_mode]++;
#endif
}
#if CONFIG_COMP_INTRA_PRED
mbmi->second_uv_mode = (MB_PREDICTION_MODE) (DC_PRED - 1);
......
......@@ -44,6 +44,8 @@
int dec_debug = 0;
#endif
#define COEFCOUNT_TESTING
#if CONFIG_NEWUPDATE
static int merge_index(int v, int n, int modulus)
......@@ -1019,6 +1021,7 @@ int vp8_decode_frame(VP8D_COMP *pbi)
}
else
{
pc->last_frame_type = pc->frame_type;
pc->frame_type = (FRAME_TYPE)(data[0] & 1);
pc->version = (data[0] >> 1) & 7;
pc->show_frame = (data[0] >> 4) & 1;
......@@ -1426,6 +1429,28 @@ int vp8_decode_frame(VP8D_COMP *pbi)
fclose(z);
}
#if CONFIG_ADAPTIVE_ENTROPY
vp8_copy(pbi->common.fc.pre_coef_probs, pbi->common.fc.coef_probs);
vp8_copy(pbi->common.fc.pre_coef_probs_8x8, pbi->common.fc.coef_probs_8x8);
vp8_copy(pbi->common.fc.pre_ymode_prob, pbi->common.fc.ymode_prob);
vp8_copy(pbi->common.fc.pre_uv_mode_prob, pbi->common.fc.uv_mode_prob);
vp8_copy(pbi->common.fc.pre_bmode_prob, pbi->common.fc.bmode_prob);
vp8_copy(pbi->common.fc.pre_i8x8_mode_prob, pbi->common.fc.i8x8_mode_prob);
vp8_copy(pbi->common.fc.pre_mvc, pbi->common.fc.mvc);
#if CONFIG_HIGH_PRECISION_MV
vp8_copy(pbi->common.fc.pre_mvc_hp, pbi->common.fc.mvc_hp);
#endif
vp8_zero(pbi->common.fc.coef_counts);
vp8_zero(pbi->common.fc.coef_counts_8x8);
vp8_zero(pbi->common.fc.ymode_counts);
vp8_zero(pbi->common.fc.uv_mode_counts);
vp8_zero(pbi->common.fc.bmode_counts);
vp8_zero(pbi->common.fc.i8x8_mode_counts);
vp8_zero(pbi->common.fc.MVcount);
#if CONFIG_HIGH_PRECISION_MV
vp8_zero(pbi->common.fc.MVcount_hp);
#endif
#endif
#if COEFUPDATETYPE == 2
read_coef_probs2(pbi);
#elif COEFUPDATETYPE == 3
......@@ -1437,8 +1462,8 @@ int vp8_decode_frame(VP8D_COMP *pbi)
vpx_memcpy(&xd->pre, &pc->yv12_fb[pc->lst_fb_idx], sizeof(YV12_BUFFER_CONFIG));
vpx_memcpy(&xd->dst, &pc->yv12_fb[pc->new_fb_idx], sizeof(YV12_BUFFER_CONFIG));
// Create the segmentation map structure and set to 0
if (!pc->last_frame_seg_map)
// Create the segmentation map structure and set to 0