summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vp8/common/entropy.h5
-rw-r--r--vp8/common/entropymode.c123
-rw-r--r--vp8/common/entropymode.h5
-rw-r--r--vp8/common/findnearmv.c8
-rw-r--r--vp8/common/onyxc_int.h22
-rw-r--r--vp8/decoder/decodemv.c40
-rw-r--r--vp8/decoder/decodframe.c37
-rw-r--r--vp8/encoder/bitstream.c54
-rw-r--r--vp8/encoder/block.h1
-rw-r--r--vp8/encoder/encodeframe.c8
-rw-r--r--vp8/encoder/modecosts.c11
-rw-r--r--vp8/encoder/onyx_if.c5
-rw-r--r--vp8/encoder/onyx_int.h7
-rw-r--r--vp8/encoder/ratectrl.c44
-rw-r--r--vp8/encoder/rdopt.c49
-rw-r--r--vp8/encoder/rdopt.h5
16 files changed, 320 insertions, 104 deletions
diff --git a/vp8/common/entropy.h b/vp8/common/entropy.h
index 78f8d5d03..04339742b 100644
--- a/vp8/common/entropy.h
+++ b/vp8/common/entropy.h
@@ -16,6 +16,11 @@
#include "blockd.h"
#include "common.h"
#include "coefupdateprobs.h"
+
+
+#define SUBMVREF_COUNT 5
+#define VP8_NUMMBSPLITS 4
+
/* Coefficient token alphabet */
#define ZERO_TOKEN 0 /* 0 Extra Bits 0+0 */
diff --git a/vp8/common/entropymode.c b/vp8/common/entropymode.c
index 436774604..26179bef2 100644
--- a/vp8/common/entropymode.c
+++ b/vp8/common/entropymode.c
@@ -142,7 +142,7 @@ int vp8_mv_cont(const int_mv *l, const int_mv *a)
return SUBMVREF_NORMAL;
}
-static const vp8_prob sub_mv_ref_prob [VP8_SUBMVREFS-1] = { 180, 162, 25};
+const vp8_prob vp8_sub_mv_ref_prob [VP8_SUBMVREFS-1] = { 180, 162, 25};
const vp8_prob vp8_sub_mv_ref_prob2 [SUBMVREF_COUNT][VP8_SUBMVREFS-1] =
{
@@ -372,7 +372,8 @@ void vp8_init_mbmode_probs(VP8_COMMON *x)
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));
+ vpx_memcpy(x->fc.sub_mv_ref_prob, vp8_sub_mv_ref_prob2, sizeof(vp8_sub_mv_ref_prob2));
+ vpx_memcpy(x->fc.mbsplit_prob, vp8_mbsplit_probs, sizeof(vp8_mbsplit_probs));
}
@@ -435,15 +436,15 @@ void vp8_entropy_mode_init()
void vp8_init_mode_contexts(VP8_COMMON *pc)
{
- vpx_memset(pc->mv_ref_ct, 0, sizeof(pc->mv_ref_ct));
- vpx_memset(pc->mv_ref_ct_a, 0, sizeof(pc->mv_ref_ct_a));
+ vpx_memset(pc->fc.mv_ref_ct, 0, sizeof(pc->fc.mv_ref_ct));
+ vpx_memset(pc->fc.mv_ref_ct_a, 0, sizeof(pc->fc.mv_ref_ct_a));
- vpx_memcpy( pc->mode_context,
+ vpx_memcpy( pc->fc.mode_context,
default_vp8_mode_contexts,
- sizeof (pc->mode_context));
- vpx_memcpy( pc->mode_context_a,
+ sizeof (pc->fc.mode_context));
+ vpx_memcpy( pc->fc.mode_context_a,
default_vp8_mode_contexts,
- sizeof (pc->mode_context_a));
+ sizeof (pc->fc.mode_context_a));
}
@@ -454,9 +455,9 @@ void vp8_accum_mv_refs(VP8_COMMON *pc,
int (*mv_ref_ct)[4][2];
if(pc->refresh_alt_ref_frame)
- mv_ref_ct = pc->mv_ref_ct_a;
+ mv_ref_ct = pc->fc.mv_ref_ct_a;
else
- mv_ref_ct = pc->mv_ref_ct;
+ mv_ref_ct = pc->fc.mv_ref_ct;
if (m == ZEROMV)
{
@@ -492,6 +493,8 @@ void vp8_accum_mv_refs(VP8_COMMON *pc,
}
}
+#define MVREF_COUNT_SAT 20
+#define MVREF_MAX_UPDATE_FACTOR 128
void vp8_update_mode_context(VP8_COMMON *pc)
{
int i, j;
@@ -500,13 +503,13 @@ void vp8_update_mode_context(VP8_COMMON *pc)
if(pc->refresh_alt_ref_frame)
{
- mv_ref_ct = pc->mv_ref_ct_a;
- mode_context = pc->mode_context_a;
+ mv_ref_ct = pc->fc.mv_ref_ct_a;
+ mode_context = pc->fc.mode_context_a;
}
else
{
- mv_ref_ct = pc->mv_ref_ct;
- mode_context = pc->mode_context;
+ mv_ref_ct = pc->fc.mv_ref_ct;
+ mode_context = pc->fc.mode_context;
}
for (j = 0; j < 6; j++)
@@ -515,6 +518,18 @@ void vp8_update_mode_context(VP8_COMMON *pc)
{
int this_prob;
int count = mv_ref_ct[j][i][0] + mv_ref_ct[j][i][1];
+#if CONFIG_ADAPTIVE_ENTROPY
+ int factor;
+ {
+ this_prob = count > 0 ? 256 * mv_ref_ct[j][i][0] / count : 128;
+ count = count > MVREF_COUNT_SAT ? MVREF_COUNT_SAT : count;
+ factor = (MVREF_MAX_UPDATE_FACTOR * count / MVREF_COUNT_SAT);
+ this_prob = (pc->fc.vp8_mode_contexts[j][i] * (256 - factor) +
+ this_prob * factor + 128) >> 8;
+ this_prob = this_prob? (this_prob<255?this_prob:255):1;
+ mode_context[j][i] = this_prob;
+ }
+#else
/* preventing rare occurances from skewing the probs */
if (count>=4)
{
@@ -522,9 +537,11 @@ void vp8_update_mode_context(VP8_COMMON *pc)
this_prob = this_prob? (this_prob<255?this_prob:255):1;
mode_context[j][i] = this_prob;
}
+#endif
}
}
}
+
#include "vp8/common/modecont.h"
void print_mode_contexts(VP8_COMMON *pc)
{
@@ -534,7 +551,7 @@ void print_mode_contexts(VP8_COMMON *pc)
{
for (i = 0; i < 4; i++)
{
- printf( "%4d ", pc->mode_context[j][i]);
+ printf( "%4d ", pc->fc.mode_context[j][i]);
}
printf("\n");
}
@@ -543,7 +560,7 @@ void print_mode_contexts(VP8_COMMON *pc)
{
for (i = 0; i < 4; i++)
{
- printf( "%4d ", pc->mode_context_a[j][i]);
+ printf( "%4d ", pc->fc.mode_context_a[j][i]);
}
printf("\n");
}
@@ -557,8 +574,8 @@ void print_mv_ref_cts(VP8_COMMON *pc)
for (i = 0; i < 4; i++)
{
printf("(%4d:%4d) ",
- pc->mv_ref_ct[j][i][0],
- pc->mv_ref_ct[j][i][1]);
+ pc->fc.mv_ref_ct[j][i][0],
+ pc->fc.mv_ref_ct[j][i][1]);
}
printf("\n");
}
@@ -567,17 +584,17 @@ void print_mv_ref_cts(VP8_COMMON *pc)
#if CONFIG_ADAPTIVE_ENTROPY
//#define MODE_COUNT_TESTING
#define MODE_COUNT_SAT 16
-#define MODE_MAX_UPDATE_FACTOR 96
+#define MODE_MAX_UPDATE_FACTOR 128
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];
+ vp8_prob sub_mv_ref_probs[VP8_SUBMVREFS-1];
+ vp8_prob mbsplit_probs[VP8_NUMMBSPLITS-1];
#ifdef MODE_COUNT_TESTING
printf("static const unsigned int\nymode_counts"
"[VP8_YMODES] = {\n");
@@ -600,6 +617,19 @@ void vp8_adapt_mode_probs(VP8_COMMON *cm)
"[VP8_I8X8_MODES] = {\n");
for (t = 0; t<VP8_I8X8_MODES; ++t) printf("%d, ", cm->fc.i8x8_mode_counts[t]);
printf("};\n");
+ printf("static const unsigned int\nsub_mv_ref_counts"
+ "[SUBMVREF_COUNT] [VP8_SUBMVREFS] = {\n");
+ for (i = 0; i < SUBMVREF_COUNT; ++i)
+ {
+ printf(" {");
+ for (t = 0; t < VP8_SUBMVREFS; ++t) printf("%d, ", cm->fc.sub_mv_ref_counts[i][t]);
+ printf("},\n");
+ }
+ printf("};\n");
+ printf("static const unsigned int\nmbsplit_counts"
+ "[VP8_NUMMBSPLITS] = {\n");
+ for (t = 0; t<VP8_NUMMBSPLITS; ++t) printf("%d, ", cm->fc.mbsplit_counts[t]);
+ printf("};\n");
#endif
vp8_tree_probs_from_distribution(
VP8_YMODES, vp8_ymode_encodings, vp8_ymode_tree,
@@ -609,8 +639,8 @@ void vp8_adapt_mode_probs(VP8_COMMON *cm)
{
int prob;
count = branch_ct[t][0] + branch_ct[t][1];
- count = count > count_sat ? count_sat : count;
- factor = (update_factor * count / count_sat);
+ count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
+ factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_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;
@@ -627,8 +657,8 @@ void vp8_adapt_mode_probs(VP8_COMMON *cm)
{
int prob;
count = branch_ct[t][0] + branch_ct[t][1];
- count = count > count_sat ? count_sat : count;
- factor = (update_factor * count / count_sat);
+ count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
+ factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_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;
@@ -644,8 +674,8 @@ void vp8_adapt_mode_probs(VP8_COMMON *cm)
{
int prob;
count = branch_ct[t][0] + branch_ct[t][1];
- count = count > count_sat ? count_sat : count;
- factor = (update_factor * count / count_sat);
+ count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
+ factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_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;
@@ -660,13 +690,48 @@ void vp8_adapt_mode_probs(VP8_COMMON *cm)
{
int prob;
count = branch_ct[t][0] + branch_ct[t][1];
- count = count > count_sat ? count_sat : count;
- factor = (update_factor * count / count_sat);
+ count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
+ factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_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;
}
+ for (i = 0; i < SUBMVREF_COUNT; ++i)
+ {
+ vp8_tree_probs_from_distribution(
+ VP8_SUBMVREFS, vp8_sub_mv_ref_encoding_array, vp8_sub_mv_ref_tree,
+ sub_mv_ref_probs, branch_ct, cm->fc.sub_mv_ref_counts[i],
+ 256, 1);
+ for (t = 0; t < VP8_SUBMVREFS-1; ++t)
+ {
+ int prob;
+ count = branch_ct[t][0] + branch_ct[t][1];
+ count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
+ factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
+ prob = ((int)cm->fc.pre_sub_mv_ref_prob[i][t] * (256-factor) +
+ (int)sub_mv_ref_probs[t] * factor + 128) >> 8;
+ if (prob <= 0) cm->fc.sub_mv_ref_prob[i][t] = 1;
+ else if (prob > 255) cm->fc.sub_mv_ref_prob[i][t] = 255;
+ else cm->fc.sub_mv_ref_prob[i][t] = prob;
+ }
+ }
+ vp8_tree_probs_from_distribution(
+ VP8_NUMMBSPLITS, vp8_mbsplit_encodings, vp8_mbsplit_tree,
+ mbsplit_probs, branch_ct, cm->fc.mbsplit_counts,
+ 256, 1);
+ for (t = 0; t < VP8_NUMMBSPLITS-1; ++t)
+ {
+ int prob;
+ count = branch_ct[t][0] + branch_ct[t][1];
+ count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
+ factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
+ prob = ((int)cm->fc.pre_mbsplit_prob[t] * (256 - factor) +
+ (int)mbsplit_probs[t] * factor + 128) >> 8;
+ if (prob <= 0) cm->fc.mbsplit_prob[t] = 1;
+ else if (prob > 255) cm->fc.mbsplit_prob[t] = 255;
+ else cm->fc.mbsplit_prob[t] = prob;
+ }
}
#endif
diff --git a/vp8/common/entropymode.h b/vp8/common/entropymode.h
index cfd532736..e8f22df9b 100644
--- a/vp8/common/entropymode.h
+++ b/vp8/common/entropymode.h
@@ -17,8 +17,6 @@
typedef const int vp8_mbsplit[16];
-#define VP8_NUMMBSPLITS 4
-
extern vp8_mbsplit vp8_mbsplits [VP8_NUMMBSPLITS];
extern const int vp8_mbsplit_count [VP8_NUMMBSPLITS]; /* # of subsets */
@@ -26,7 +24,8 @@ extern const int vp8_mbsplit_count [VP8_NUMMBSPLITS]; /* # of subsets */
extern const vp8_prob vp8_mbsplit_probs [VP8_NUMMBSPLITS-1];
extern int vp8_mv_cont(const int_mv *l, const int_mv *a);
-#define SUBMVREF_COUNT 5
+
+extern const vp8_prob vp8_sub_mv_ref_prob [VP8_SUBMVREFS-1];
extern const vp8_prob vp8_sub_mv_ref_prob2 [SUBMVREF_COUNT][VP8_SUBMVREFS-1];
diff --git a/vp8/common/findnearmv.c b/vp8/common/findnearmv.c
index 955f54ad1..ada9d3aca 100644
--- a/vp8/common/findnearmv.c
+++ b/vp8/common/findnearmv.c
@@ -177,9 +177,9 @@ vp8_prob *vp8_mv_ref_probs(VP8_COMMON *pc,
vp8_prob p[VP8_MVREFS-1], const int near_mv_ref_ct[4]
)
{
- p[0] = pc->vp8_mode_contexts [near_mv_ref_ct[0]] [0];
- p[1] = pc->vp8_mode_contexts [near_mv_ref_ct[1]] [1];
- p[2] = pc->vp8_mode_contexts [near_mv_ref_ct[2]] [2];
- p[3] = pc->vp8_mode_contexts [near_mv_ref_ct[3]] [3];
+ p[0] = pc->fc.vp8_mode_contexts [near_mv_ref_ct[0]] [0];
+ p[1] = pc->fc.vp8_mode_contexts [near_mv_ref_ct[1]] [1];
+ p[2] = pc->fc.vp8_mode_contexts [near_mv_ref_ct[2]] [2];
+ p[3] = pc->fc.vp8_mode_contexts [near_mv_ref_ct[3]] [3];
return p;
}
diff --git a/vp8/common/onyxc_int.h b/vp8/common/onyxc_int.h
index a068b43ae..f2795a8f8 100644
--- a/vp8/common/onyxc_int.h
+++ b/vp8/common/onyxc_int.h
@@ -48,7 +48,8 @@ typedef struct frame_contexts
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 sub_mv_ref_prob [SUBMVREF_COUNT][VP8_SUBMVREFS-1];
+ vp8_prob mbsplit_prob [VP8_NUMMBSPLITS-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];
MV_CONTEXT mvc[2];
@@ -64,10 +65,14 @@ typedef struct frame_contexts
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];
+ vp8_prob pre_sub_mv_ref_prob [SUBMVREF_COUNT][VP8_SUBMVREFS-1];
+ vp8_prob pre_mbsplit_prob [VP8_NUMMBSPLITS-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 */
+ unsigned int sub_mv_ref_counts [SUBMVREF_COUNT][VP8_SUBMVREFS];
+ unsigned int mbsplit_counts [VP8_NUMMBSPLITS];
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];
@@ -80,6 +85,11 @@ typedef struct frame_contexts
unsigned int MVcount_hp [2] [MVvals_hp];
#endif
#endif /* CONFIG_ADAPTIVE_ENTROPY */
+ int mode_context[6][4];
+ int mode_context_a[6][4];
+ int vp8_mode_contexts[6][4];
+ int mv_ref_ct[6][4][2];
+ int mv_ref_ct_a[6][4][2];
} FRAME_CONTEXT;
typedef enum
@@ -254,11 +264,11 @@ typedef struct VP8Common
FRAME_CONTEXT lfc; /* last frame entropy */
FRAME_CONTEXT fc; /* this frame entropy */
- int mv_ref_ct[6][4][2];
- int mode_context[6][4];
- int mv_ref_ct_a[6][4][2];
- int mode_context_a[6][4];
- int vp8_mode_contexts[6][4];
+ //int mv_ref_ct[6][4][2];
+ //int mv_ref_ct_a[6][4][2];
+ //int mode_context[6][4];
+ //int mode_context_a[6][4];
+ //int vp8_mode_contexts[6][4];
unsigned int current_video_frame;
int near_boffset[3];
diff --git a/vp8/decoder/decodemv.c b/vp8/decoder/decodemv.c
index 3b9a098c5..b7b5e49b1 100644
--- a/vp8/decoder/decodemv.c
+++ b/vp8/decoder/decodemv.c
@@ -759,9 +759,12 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
case SPLITMV:
{
const int s = mbmi->partitioning =
- vp8_treed_read(bc, vp8_mbsplit_tree, vp8_mbsplit_probs);
+ vp8_treed_read(bc, vp8_mbsplit_tree, cm->fc.mbsplit_prob);
const int num_p = vp8_mbsplit_count [s];
int j = 0;
+#if CONFIG_ADAPTIVE_ENTROPY
+ cm->fc.mbsplit_counts[s]++;
+#endif
mbmi->need_to_clamp_mvs = 0;
do /* for each subset j */
@@ -782,7 +785,10 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
second_abovemv.as_int = above_block_second_mv(mi, k, mis);
}
mv_contz = vp8_mv_cont(&leftmv, &abovemv);
- blockmode = sub_mv_ref(bc, vp8_sub_mv_ref_prob2 [mv_contz]);
+ blockmode = sub_mv_ref(bc, cm->fc.sub_mv_ref_prob [mv_contz]);
+#if CONFIG_ADAPTIVE_ENTROPY
+ cm->fc.sub_mv_ref_counts[mv_contz][blockmode-LEFT4X4]++;
+#endif
switch (blockmode)
{
@@ -812,10 +818,22 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
{
#if CONFIG_HIGH_PRECISION_MV
if (xd->allow_high_precision_mv)
+ {
read_mv_hp(bc, &secondmv.as_mv, (const MV_CONTEXT_HP *) mvc_hp);
+#if CONFIG_ADAPTIVE_ENTROPY
+ cm->fc.MVcount_hp[0][mv_max_hp+(secondmv.as_mv.row)]++;
+ cm->fc.MVcount_hp[1][mv_max_hp+(secondmv.as_mv.col)]++;
+#endif
+ }
else
#endif
+ {
read_mv(bc, &secondmv.as_mv, (const MV_CONTEXT *) mvc);
+#if CONFIG_ADAPTIVE_ENTROPY
+ cm->fc.MVcount[0][mv_max+(secondmv.as_mv.row>>1)]++;
+ cm->fc.MVcount[1][mv_max+(secondmv.as_mv.col>>1)]++;
+#endif
+ }
secondmv.as_mv.row += best_mv_second.as_mv.row;
secondmv.as_mv.col += best_mv_second.as_mv.col;
}
@@ -843,9 +861,9 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
blockmv.as_int = 0;
if (mbmi->second_ref_frame)
secondmv.as_int = 0;
- #ifdef VPX_MODE_COUNT
+#ifdef VPX_MODE_COUNT
vp8_mv_cont_count[mv_contz][2]++;
- #endif
+#endif
break;
default:
break;
@@ -959,11 +977,23 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
{
#if CONFIG_HIGH_PRECISION_MV
if (xd->allow_high_precision_mv)
+ {
read_mv_hp(bc, &mbmi->second_mv.as_mv,
(const MV_CONTEXT_HP *) mvc_hp);
+#if CONFIG_ADAPTIVE_ENTROPY
+ cm->fc.MVcount_hp[0][mv_max_hp+(mbmi->second_mv.as_mv.row)]++;
+ cm->fc.MVcount_hp[1][mv_max_hp+(mbmi->second_mv.as_mv.col)]++;
+#endif
+ }
else
#endif
- read_mv(bc, &mbmi->second_mv.as_mv, (const MV_CONTEXT *) mvc);
+ {
+ read_mv(bc, &mbmi->second_mv.as_mv, (const MV_CONTEXT *) mvc);
+#if CONFIG_ADAPTIVE_ENTROPY
+ cm->fc.MVcount[0][mv_max+(mbmi->second_mv.as_mv.row>>1)]++;
+ cm->fc.MVcount[1][mv_max+(mbmi->second_mv.as_mv.col>>1)]++;
+#endif
+ }
mbmi->second_mv.as_mv.row += best_mv_second.as_mv.row;
mbmi->second_mv.as_mv.col += best_mv_second.as_mv.col;
mbmi->need_to_clamp_secondmv |= vp8_check_mv_bounds(&mbmi->second_mv,
diff --git a/vp8/decoder/decodframe.c b/vp8/decoder/decodframe.c
index d720c007d..cb1f6d14e 100644
--- a/vp8/decoder/decodframe.c
+++ b/vp8/decoder/decodframe.c
@@ -729,13 +729,13 @@ static void init_frame(VP8D_COMP *pbi)
pc->ref_frame_sign_bias[GOLDEN_FRAME] = 0;
pc->ref_frame_sign_bias[ALTREF_FRAME] = 0;
+ vp8_init_mode_contexts(&pbi->common);
vpx_memcpy(&pc->lfc, &pc->fc, sizeof(pc->fc));
vpx_memcpy(&pc->lfc_a, &pc->fc, sizeof(pc->fc));
- vp8_init_mode_contexts(&pbi->common);
- vpx_memcpy( pbi->common.vp8_mode_contexts,
- pbi->common.mode_context,
- sizeof(pbi->common.mode_context));
+ vpx_memcpy( pbi->common.fc.vp8_mode_contexts,
+ pbi->common.fc.mode_context,
+ sizeof(pbi->common.fc.mode_context));
}
else
{
@@ -1331,16 +1331,16 @@ int vp8_decode_frame(VP8D_COMP *pbi)
if(pc->refresh_alt_ref_frame)
{
vpx_memcpy(&pc->fc, &pc->lfc_a, sizeof(pc->fc));
- vpx_memcpy( pc->vp8_mode_contexts,
- pc->mode_context_a,
- sizeof(pc->vp8_mode_contexts));
+ vpx_memcpy( pc->fc.vp8_mode_contexts,
+ pc->fc.mode_context_a,
+ sizeof(pc->fc.vp8_mode_contexts));
}
else
{
vpx_memcpy(&pc->fc, &pc->lfc, sizeof(pc->fc));
- vpx_memcpy( pc->vp8_mode_contexts,
- pc->mode_context,
- sizeof(pc->vp8_mode_contexts));
+ vpx_memcpy( pc->fc.vp8_mode_contexts,
+ pc->fc.mode_context,
+ sizeof(pc->fc.vp8_mode_contexts));
}
/* Buffer to buffer copy flags. */
@@ -1436,6 +1436,8 @@ int vp8_decode_frame(VP8D_COMP *pbi)
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_sub_mv_ref_prob, pbi->common.fc.sub_mv_ref_prob);
+ vp8_copy(pbi->common.fc.pre_mbsplit_prob, pbi->common.fc.mbsplit_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);
@@ -1446,14 +1448,18 @@ int vp8_decode_frame(VP8D_COMP *pbi)
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.sub_mv_ref_counts);
+ vp8_zero(pbi->common.fc.mbsplit_counts);
vp8_zero(pbi->common.fc.MVcount);
#if CONFIG_HIGH_PRECISION_MV
vp8_zero(pbi->common.fc.MVcount_hp);
#endif
-#endif
-#if COEFUPDATETYPE == 2
+ vp8_zero(pbi->common.fc.mv_ref_ct);
+ vp8_zero(pbi->common.fc.mv_ref_ct_a);
+#endif /* CONFIG_ADAPTIVE_ENTROPY */
+#if CONFIG_NEWUPDATE && COEFUPDATETYPE == 2
read_coef_probs2(pbi);
-#elif COEFUPDATETYPE == 3
+#elif CONFIG_NEWUPDATE && COEFUPDATETYPE == 3
read_coef_probs3(pbi);
#else
read_coef_probs(pbi);
@@ -1481,10 +1487,12 @@ int vp8_decode_frame(VP8D_COMP *pbi)
pc->mb_no_coeff_skip = (int)vp8_read_bit(bc);
vp8_decode_mode_mvs(pbi);
- if(pbi->common.frame_type != KEY_FRAME)
+#if CONFIG_ADAPTIVE_ENTROPY == 0
+ if (pc->frame_type != KEY_FRAME)
{
vp8_update_mode_context(&pbi->common);
}
+#endif
vpx_memset(pc->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) * pc->mb_cols);
@@ -1521,6 +1529,7 @@ int vp8_decode_frame(VP8D_COMP *pbi)
{
vp8_adapt_mode_probs(pc);
vp8_adapt_mv_probs(pc);
+ vp8_update_mode_context(&pbi->common);
}
#endif
diff --git a/vp8/encoder/bitstream.c b/vp8/encoder/bitstream.c
index ee805110b..e0cb2d48c 100644
--- a/vp8/encoder/bitstream.c
+++ b/vp8/encoder/bitstream.c
@@ -300,10 +300,10 @@ static void write_bmode(vp8_writer *bc, int m, const vp8_prob *p)
vp8_write_token(bc, vp8_bmode_tree, p, vp8_bmode_encodings + m);
}
-static void write_split(vp8_writer *bc, int x)
+static void write_split(vp8_writer *bc, int x, const vp8_prob *p)
{
vp8_write_token(
- bc, vp8_mbsplit_tree, vp8_mbsplit_probs, vp8_mbsplit_encodings + x
+ bc, vp8_mbsplit_tree, p, vp8_mbsplit_encodings + x
);
}
@@ -856,7 +856,7 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
vp8_write_mvprobs_hp(cpi);
else
#endif
- vp8_write_mvprobs(cpi);
+ vp8_write_mvprobs(cpi);
mb_row = 0;
for (row=0; row < pc->mb_rows; row += 2)
@@ -1061,21 +1061,29 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
#if CONFIG_HIGH_PRECISION_MV
if (xd->allow_high_precision_mv)
+ {
write_mv_hp(w, &mi->mv.as_mv, &best_mv, mvc_hp);
+ }
else
#endif
- write_mv(w, &mi->mv.as_mv, &best_mv, mvc);
+ {
+ write_mv(w, &mi->mv.as_mv, &best_mv, mvc);
+ }
if (mi->second_ref_frame)
{
#if CONFIG_HIGH_PRECISION_MV
if (xd->allow_high_precision_mv)
+ {
write_mv_hp(w, &mi->second_mv.as_mv,
&best_second_mv, mvc_hp);
+ }
else
#endif
- write_mv(w, &mi->second_mv.as_mv,
+ {
+ write_mv(w, &mi->second_mv.as_mv,
&best_second_mv, mvc);
+ }
}
break;
case SPLITMV:
@@ -1086,7 +1094,10 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
++count_mb_seg [mi->partitioning];
#endif
- write_split(w, mi->partitioning);
+ write_split(w, mi->partitioning, cpi->common.fc.mbsplit_prob);
+#if CONFIG_ADAPTIVE_ENTROPY
+ cpi->mbsplit_count[mi->partitioning]++;
+#endif
do
{
@@ -1112,8 +1123,10 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
mv_contz = vp8_mv_cont(&leftmv, &abovemv);
write_sub_mv_ref(w, blockmode,
- vp8_sub_mv_ref_prob2 [mv_contz]);
-
+ cpi->common.fc.sub_mv_ref_prob [mv_contz]);
+#if CONFIG_ADAPTIVE_ENTROPY
+ cpi->sub_mv_ref_count[mv_contz][blockmode-LEFT4X4]++;
+#endif
if (blockmode == NEW4X4)
{
#ifdef ENTROPY_STATS
@@ -1121,23 +1134,31 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
#endif
#if CONFIG_HIGH_PRECISION_MV
if (xd->allow_high_precision_mv)
+ {
write_mv_hp(w, &blockmv.as_mv, &best_mv,
(const MV_CONTEXT_HP *) mvc_hp);
+ }
else
#endif
- write_mv(w, &blockmv.as_mv, &best_mv,
+ {
+ write_mv(w, &blockmv.as_mv, &best_mv,
(const MV_CONTEXT *) mvc);
+ }
if (mi->second_ref_frame)
{
#if CONFIG_HIGH_PRECISION_MV
if (xd->allow_high_precision_mv)
+ {
write_mv_hp(w, &cpi->mb.partition_info->bmi[j].second_mv.as_mv,
&best_second_mv, (const MV_CONTEXT_HP *) mvc_hp);
+ }
else
#endif
+ {
write_mv(w, &cpi->mb.partition_info->bmi[j].second_mv.as_mv,
&best_second_mv, (const MV_CONTEXT *) mvc);
+ }
}
}
}
@@ -2229,8 +2250,6 @@ static void segment_reference_frames(VP8_COMP *cpi)
enable_segfeature(xd,i,SEG_LVL_REF_FRAME);
set_segdata( xd,i, SEG_LVL_REF_FRAME, ref[i]);
}
-
-
}
void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned long *size)
@@ -2628,15 +2647,21 @@ void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned long *size)
vp8_copy(cpi->common.fc.pre_ymode_prob, cpi->common.fc.ymode_prob);
vp8_copy(cpi->common.fc.pre_uv_mode_prob, cpi->common.fc.uv_mode_prob);
vp8_copy(cpi->common.fc.pre_bmode_prob, cpi->common.fc.bmode_prob);
+ vp8_copy(cpi->common.fc.pre_sub_mv_ref_prob, cpi->common.fc.sub_mv_ref_prob);
+ vp8_copy(cpi->common.fc.pre_mbsplit_prob, cpi->common.fc.mbsplit_prob);
vp8_copy(cpi->common.fc.pre_i8x8_mode_prob, cpi->common.fc.i8x8_mode_prob);
vp8_copy(cpi->common.fc.pre_mvc, cpi->common.fc.mvc);
#if CONFIG_HIGH_PRECISION_MV
vp8_copy(cpi->common.fc.pre_mvc_hp, cpi->common.fc.mvc_hp);
#endif
+ vp8_zero(cpi->sub_mv_ref_count);
+ vp8_zero(cpi->mbsplit_count);
+ vp8_zero(cpi->common.fc.mv_ref_ct)
+ vp8_zero(cpi->common.fc.mv_ref_ct_a)
#endif
-#if COEFUPDATETYPE == 2
+#if CONFIG_NEWUPDATE && COEFUPDATETYPE == 2
update_coef_probs2(cpi);
-#elif COEFUPDATETYPE == 3
+#elif CONFIG_NEWUPDATE && COEFUPDATETYPE == 3
update_coef_probs3(cpi);
#else
update_coef_probs(cpi);
@@ -2661,8 +2686,9 @@ void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned long *size)
else
{
pack_inter_mode_mvs(cpi);
-
+#if CONFIG_ADAPTIVE_ENTROPY == 0
vp8_update_mode_context(&cpi->common);
+#endif
#ifdef ENTROPY_STATS
active_section = 1;
diff --git a/vp8/encoder/block.h b/vp8/encoder/block.h
index 98bc13277..fb309f461 100644
--- a/vp8/encoder/block.h
+++ b/vp8/encoder/block.h
@@ -72,6 +72,7 @@ typedef struct
MODE_INFO mic;
PARTITION_INFO partition_info;
int_mv best_ref_mv;
+ int_mv second_best_ref_mv;
int rate;
int distortion;
int intra_error;
diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c
index a92bdbcda..55041c5a6 100644
--- a/vp8/encoder/encodeframe.c
+++ b/vp8/encoder/encodeframe.c
@@ -458,7 +458,7 @@ static void update_state (VP8_COMP *cpi, MACROBLOCK *x, PICK_MODE_CONTEXT *ctx)
// Note how often each mode chosen as best
cpi->mode_chosen_counts[mb_mode_index]++;
- rd_update_mvcount(cpi, x, &ctx->best_ref_mv);
+ rd_update_mvcount(cpi, x, &ctx->best_ref_mv, &ctx->second_best_ref_mv);
cpi->prediction_error += ctx->distortion;
cpi->intra_error += ctx->intra_error;
@@ -1068,6 +1068,12 @@ void init_encode_frame_mb_context(VP8_COMP *cpi)
vp8_zero(cpi->ymode_count)
vp8_zero(cpi->i8x8_mode_count)
vp8_zero(cpi->y_uv_mode_count)
+ vp8_zero(cpi->sub_mv_ref_count)
+ vp8_zero(cpi->mbsplit_count)
+#if CONFIG_ADAPTIVE_ENTROPY
+ vp8_zero(cpi->common.fc.mv_ref_ct)
+ vp8_zero(cpi->common.fc.mv_ref_ct_a)
+#endif
//vp8_zero(cpi->uv_mode_count)
x->mvc = cm->fc.mvc;
diff --git a/vp8/encoder/modecosts.c b/vp8/encoder/modecosts.c
index e7d071124..6cd0da56a 100644
--- a/vp8/encoder/modecosts.c
+++ b/vp8/encoder/modecosts.c
@@ -37,8 +37,14 @@ void vp8_init_mode_costs(VP8_COMP *c)
vp8_cost_tokens((int *)c->mb.inter_bmode_costs, x->fc.bmode_prob, T);
}
+#if CONFIG_ADAPTIVE_ENTROPY
vp8_cost_tokens((int *)c->mb.inter_bmode_costs,
- x->fc.sub_mv_ref_prob, vp8_sub_mv_ref_tree);
+ vp8_sub_mv_ref_prob, vp8_sub_mv_ref_tree);
+ //x->fc.sub_mv_ref_prob[1], vp8_sub_mv_ref_tree);
+#else
+ vp8_cost_tokens((int *)c->mb.inter_bmode_costs,
+ vp8_sub_mv_ref_prob, vp8_sub_mv_ref_tree);
+#endif
vp8_cost_tokens(c->mb.mbmode_cost[1], x->fc.ymode_prob, vp8_ymode_tree);
vp8_cost_tokens(c->mb.mbmode_cost[0],
@@ -48,6 +54,7 @@ void vp8_init_mode_costs(VP8_COMP *c)
x->fc.uv_mode_prob[VP8_YMODES-1], vp8_uv_mode_tree);
vp8_cost_tokens(c->mb.intra_uv_mode_cost[0],
x->kf_uv_mode_prob[VP8_YMODES-1], vp8_uv_mode_tree);
- vp8_cost_tokens((int *)c->mb.i8x8_mode_costs,
+ vp8_cost_tokens(c->mb.i8x8_mode_costs,
x->fc.i8x8_mode_prob,vp8_i8x8_mode_tree);
+
}
diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c
index aa46fb073..decb31b4b 100644
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -3702,6 +3702,8 @@ static void encode_frame_to_data_rate
vp8_copy(cpi->common.fc.uv_mode_counts, cpi->y_uv_mode_count);
vp8_copy(cpi->common.fc.bmode_counts, cpi->bmode_count);
vp8_copy(cpi->common.fc.i8x8_mode_counts, cpi->i8x8_mode_count);
+ vp8_copy(cpi->common.fc.sub_mv_ref_counts, cpi->sub_mv_ref_count);
+ vp8_copy(cpi->common.fc.mbsplit_counts, cpi->mbsplit_count);
vp8_adapt_mode_probs(&cpi->common);
vp8_copy(cpi->common.fc.MVcount, cpi->MVcount);
@@ -3709,6 +3711,7 @@ static void encode_frame_to_data_rate
vp8_copy(cpi->common.fc.MVcount_hp, cpi->MVcount_hp);
#endif
vp8_adapt_mv_probs(&cpi->common);
+ vp8_update_mode_context(&cpi->common);
}
#endif /* CONFIG_ADAPTIVE_ENTROPY */
@@ -3809,7 +3812,7 @@ static void encode_frame_to_data_rate
// in this frame.
update_base_skip_probs( cpi );
-#if 1 && CONFIG_INTERNAL_STATS
+#if 0//1 && CONFIG_INTERNAL_STATS
{
FILE *f = fopen("tmp.stt", "a");
int recon_err;
diff --git a/vp8/encoder/onyx_int.h b/vp8/encoder/onyx_int.h
index f4e6f9490..54ed23340 100644
--- a/vp8/encoder/onyx_int.h
+++ b/vp8/encoder/onyx_int.h
@@ -23,6 +23,7 @@
#include "encodemb.h"
#include "quantize.h"
#include "vp8/common/entropy.h"
+#include "vp8/common/entropymode.h"
#include "vpx_ports/mem.h"
#include "vpx/internal/vpx_codec_internal.h"
#include "mcomp.h"
@@ -99,6 +100,8 @@ typedef struct
vp8_prob uv_mode_prob [VP8_YMODES][VP8_UV_MODES-1];
vp8_prob bmode_prob [VP8_BINTRAMODES-1];
vp8_prob i8x8_mode_prob [VP8_I8X8_MODES-1];
+ vp8_prob sub_mv_ref_prob [SUBMVREF_COUNT][VP8_SUBMVREFS-1];
+ vp8_prob mbsplit_prob [VP8_NUMMBSPLITS-1];
int mv_ref_ct[6][4][2];
int mode_context[6][4];
@@ -458,7 +461,10 @@ typedef struct VP8_COMP
int ymode_count [VP8_YMODES]; /* intra MB type cts this frame */
int bmode_count [VP8_BINTRAMODES];
int i8x8_mode_count [VP8_I8X8_MODES];
+ int sub_mv_ref_count [SUBMVREF_COUNT][VP8_SUBMVREFS];
+ int mbsplit_count [VP8_NUMMBSPLITS];
//int uv_mode_count[VP8_UV_MODES]; /* intra MB type cts this frame */
+ int y_uv_mode_count[VP8_YMODES][VP8_UV_MODES];
unsigned int MVcount [2] [MVvals]; /* (row,col) MV cts this frame */
#if CONFIG_HIGH_PRECISION_MV
@@ -542,7 +548,6 @@ typedef struct VP8_COMP
int t4x4_count;
int t8x8_count;
- int y_uv_mode_count[VP8_YMODES][VP8_UV_MODES];
unsigned char *segmentation_map;
// segment threashold for encode breakout
diff --git a/vp8/encoder/ratectrl.c b/vp8/encoder/ratectrl.c
index 6d510e9d9..75246fca2 100644
--- a/vp8/encoder/ratectrl.c
+++ b/vp8/encoder/ratectrl.c
@@ -150,15 +150,17 @@ void vp8_save_coding_context(VP8_COMP *cpi)
vp8_copy(cc->mvcosts_hp, cpi->mb.mvcosts_hp);
#endif
- vp8_copy( cc->mv_ref_ct, cm->mv_ref_ct );
- vp8_copy( cc->mode_context, cm->mode_context );
- vp8_copy( cc->mv_ref_ct_a, cm->mv_ref_ct_a );
- vp8_copy( cc->mode_context_a, cm->mode_context_a );
+ vp8_copy( cc->mv_ref_ct, cm->fc.mv_ref_ct );
+ vp8_copy( cc->mode_context, cm->fc.mode_context );
+ vp8_copy( cc->mv_ref_ct_a, cm->fc.mv_ref_ct_a );
+ vp8_copy( cc->mode_context_a, cm->fc.mode_context_a );
vp8_copy( cc->ymode_prob, cm->fc.ymode_prob );
vp8_copy( cc->bmode_prob, cm->fc.bmode_prob );
vp8_copy( cc->uv_mode_prob, cm->fc.uv_mode_prob );
vp8_copy( cc->i8x8_mode_prob, cm->fc.i8x8_mode_prob );
+ vp8_copy( cc->sub_mv_ref_prob, cm->fc.sub_mv_ref_prob );
+ vp8_copy( cc->mbsplit_prob, cm->fc.mbsplit_prob );
// Stats
#ifdef MODE_STATS
@@ -201,15 +203,17 @@ void vp8_restore_coding_context(VP8_COMP *cpi)
vp8_copy(cpi->mb.mvcosts_hp, cc->mvcosts_hp);
#endif
- vp8_copy( cm->mv_ref_ct, cc->mv_ref_ct );
- vp8_copy( cm->mode_context, cc->mode_context );
- vp8_copy( cm->mv_ref_ct_a, cc->mv_ref_ct_a );
- vp8_copy( cm->mode_context_a, cc->mode_context_a );
+ vp8_copy( cm->fc.mv_ref_ct, cc->mv_ref_ct );
+ vp8_copy( cm->fc.mode_context, cc->mode_context );
+ vp8_copy( cm->fc.mv_ref_ct_a, cc->mv_ref_ct_a );
+ vp8_copy( cm->fc.mode_context_a, cc->mode_context_a );
vp8_copy( cm->fc.ymode_prob, cc->ymode_prob);
vp8_copy( cm->fc.bmode_prob, cc->bmode_prob);
vp8_copy( cm->fc.i8x8_mode_prob, cc->i8x8_mode_prob);
vp8_copy( cm->fc.uv_mode_prob, cc->uv_mode_prob);
+ vp8_copy( cm->fc.sub_mv_ref_prob, cc->sub_mv_ref_prob);
+ vp8_copy( cm->fc.mbsplit_prob, cc->mbsplit_prob );
// Stats
#ifdef MODE_STATS
@@ -271,14 +275,16 @@ void vp8_setup_key_frame(VP8_COMP *cpi)
cpi->common.refresh_golden_frame = TRUE;
cpi->common.refresh_alt_ref_frame = TRUE;
+ vp8_init_mode_contexts(&cpi->common);
vpx_memcpy(&cpi->common.lfc, &cpi->common.fc, sizeof(cpi->common.fc));
vpx_memcpy(&cpi->common.lfc_a, &cpi->common.fc, sizeof(cpi->common.fc));
- vp8_init_mode_contexts(&cpi->common);
- vpx_memcpy( cpi->common.vp8_mode_contexts,
- cpi->common.mode_context,
- sizeof(cpi->common.mode_context));
- vpx_memcpy( cpi->common.vp8_mode_contexts,
+ /*
+ vpx_memcpy( cpi->common.fc.vp8_mode_contexts,
+ cpi->common.fc.mode_context,
+ sizeof(cpi->common.fc.mode_context));
+ */
+ vpx_memcpy( cpi->common.fc.vp8_mode_contexts,
default_vp8_mode_contexts,
sizeof(default_vp8_mode_contexts));
@@ -293,18 +299,18 @@ void vp8_setup_inter_frame(VP8_COMP *cpi)
vpx_memcpy( &cpi->common.fc,
&cpi->common.lfc_a,
sizeof(cpi->common.fc));
- vpx_memcpy( cpi->common.vp8_mode_contexts,
- cpi->common.mode_context_a,
- sizeof(cpi->common.vp8_mode_contexts));
+ vpx_memcpy( cpi->common.fc.vp8_mode_contexts,
+ cpi->common.fc.mode_context_a,
+ sizeof(cpi->common.fc.vp8_mode_contexts));
}
else
{
vpx_memcpy( &cpi->common.fc,
&cpi->common.lfc,
sizeof(cpi->common.fc));
- vpx_memcpy( cpi->common.vp8_mode_contexts,
- cpi->common.mode_context,
- sizeof(cpi->common.vp8_mode_contexts));
+ vpx_memcpy( cpi->common.fc.vp8_mode_contexts,
+ cpi->common.fc.mode_context,
+ sizeof(cpi->common.fc.vp8_mode_contexts));
}
}
diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c
index e8ddd66d5..18b62bf59 100644
--- a/vp8/encoder/rdopt.c
+++ b/vp8/encoder/rdopt.c
@@ -2502,7 +2502,8 @@ void vp8_cal_sad(VP8_COMP *cpi, MACROBLOCKD *xd, MACROBLOCK *x, int recon_yoffse
}
}
-void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, int_mv *best_ref_mv)
+void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x,
+ int_mv *best_ref_mv, int_mv *second_best_ref_mv)
{
if (x->e_mbd.mode_info_context->mbmi.mode == SPLITMV)
{
@@ -2519,6 +2520,15 @@ void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, int_mv *best_ref_mv)
- best_ref_mv->as_mv.row)]++;
cpi->MVcount_hp[1][mv_max_hp+(x->partition_info->bmi[i].mv.as_mv.col
- best_ref_mv->as_mv.col)]++;
+#if CONFIG_ADAPTIVE_ENTROPY
+ if (x->e_mbd.mode_info_context->mbmi.second_ref_frame)
+ {
+ cpi->MVcount_hp[0][mv_max_hp+(x->partition_info->bmi[i].second_mv.as_mv.row
+ - second_best_ref_mv->as_mv.row)]++;
+ cpi->MVcount_hp[1][mv_max_hp+(x->partition_info->bmi[i].second_mv.as_mv.col
+ - second_best_ref_mv->as_mv.col)]++;
+ }
+#endif
}
else
#endif
@@ -2527,6 +2537,15 @@ void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, int_mv *best_ref_mv)
- best_ref_mv->as_mv.row) >> 1)]++;
cpi->MVcount[1][mv_max+((x->partition_info->bmi[i].mv.as_mv.col
- best_ref_mv->as_mv.col) >> 1)]++;
+#if CONFIG_ADAPTIVE_ENTROPY
+ if (x->e_mbd.mode_info_context->mbmi.second_ref_frame)
+ {
+ cpi->MVcount[0][mv_max+((x->partition_info->bmi[i].second_mv.as_mv.row
+ - second_best_ref_mv->as_mv.row) >> 1)]++;
+ cpi->MVcount[1][mv_max+((x->partition_info->bmi[i].second_mv.as_mv.col
+ - second_best_ref_mv->as_mv.col) >> 1)]++;
+ }
+#endif
}
}
}
@@ -2540,6 +2559,15 @@ void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, int_mv *best_ref_mv)
- best_ref_mv->as_mv.row)]++;
cpi->MVcount_hp[1][mv_max_hp+(x->e_mbd.mode_info_context->mbmi.mv.as_mv.col
- best_ref_mv->as_mv.col)]++;
+#if CONFIG_ADAPTIVE_ENTROPY
+ if (x->e_mbd.mode_info_context->mbmi.second_ref_frame)
+ {
+ cpi->MVcount_hp[0][mv_max_hp+(x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.row
+ - second_best_ref_mv->as_mv.row)]++;
+ cpi->MVcount_hp[1][mv_max_hp+(x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.col
+ - second_best_ref_mv->as_mv.col)]++;
+ }
+#endif
}
else
#endif
@@ -2548,6 +2576,15 @@ void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, int_mv *best_ref_mv)
- best_ref_mv->as_mv.row) >> 1)]++;
cpi->MVcount[1][mv_max+((x->e_mbd.mode_info_context->mbmi.mv.as_mv.col
- best_ref_mv->as_mv.col) >> 1)]++;
+#if CONFIG_ADAPTIVE_ENTROPY
+ if (x->e_mbd.mode_info_context->mbmi.second_ref_frame)
+ {
+ cpi->MVcount[0][mv_max+((x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.row
+ - second_best_ref_mv->as_mv.row) >> 1)]++;
+ cpi->MVcount[1][mv_max+((x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.col
+ - second_best_ref_mv->as_mv.col) >> 1)]++;
+ }
+#endif
}
}
}
@@ -2740,7 +2777,8 @@ static void vp8_estimate_ref_frame_costs(VP8_COMP *cpi, int segment_id, unsigned
static void store_coding_context (MACROBLOCK *x, int mb_index,
int mode_index,
PARTITION_INFO *partition,
- int_mv *ref_mv)
+ int_mv *ref_mv,
+ int_mv *second_ref_mv)
{
MACROBLOCKD *xd = &x->e_mbd;
@@ -2752,6 +2790,7 @@ static void store_coding_context (MACROBLOCK *x, int mb_index,
vpx_memcpy(&x->mb_context[mb_index].partition_info, partition,
sizeof(PARTITION_INFO));
x->mb_context[mb_index].best_ref_mv.as_int = ref_mv->as_int;
+ x->mb_context[mb_index].second_best_ref_mv.as_int = second_ref_mv->as_int;
//x->mb_context[mb_index].rddiv = x->rddiv;
//x->mb_context[mb_index].rdmult = x->rdmult;
@@ -3847,7 +3886,8 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
*best_single_rd_diff = *best_comp_rd_diff = *best_hybrid_rd_diff = 0;
store_coding_context (x, mb_index, best_mode_index, &best_partition,
- &frame_best_ref_mv[xd->mode_info_context->mbmi.ref_frame] );
+ &frame_best_ref_mv[xd->mode_info_context->mbmi.ref_frame],
+ &frame_best_ref_mv[xd->mode_info_context->mbmi.second_ref_frame]);
return;
}
@@ -3898,7 +3938,8 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
*best_hybrid_rd_diff = best_rd - best_hybrid_rd;
store_coding_context (x, mb_index, best_mode_index, &best_partition,
- &frame_best_ref_mv[xd->mode_info_context->mbmi.ref_frame] );
+ &frame_best_ref_mv[xd->mode_info_context->mbmi.ref_frame],
+ &frame_best_ref_mv[xd->mode_info_context->mbmi.second_ref_frame]);
}
int vp8_rd_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x)
diff --git a/vp8/encoder/rdopt.h b/vp8/encoder/rdopt.h
index 0a1920a1a..5e11c8d49 100644
--- a/vp8/encoder/rdopt.h
+++ b/vp8/encoder/rdopt.h
@@ -35,6 +35,9 @@ extern void vp8_mv_pred
extern void vp8_cal_sad(VP8_COMP *cpi, MACROBLOCKD *xd, MACROBLOCK *x, int recon_yoffset, int near_sadidx[]);
extern void vp8_init_me_luts();
extern void vp8_set_mbmode_and_mvs(MACROBLOCK *x, MB_PREDICTION_MODE mb, int_mv *mv);
-void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, int_mv *best_ref_mv);
+extern void rd_update_mvcount(VP8_COMP *cpi,
+ MACROBLOCK *x,
+ int_mv *best_ref_mv,
+ int_mv *second_best_ref_mv);
#endif