diff options
author | Yaowu Xu <yaowu@google.com> | 2011-12-08 11:43:09 -0800 |
---|---|---|
committer | Yaowu Xu <yaowu@google.com> | 2011-12-09 12:13:42 -0800 |
commit | ba1a6619b3e06324354b728ec28d1b0750a7cc32 (patch) | |
tree | 43c1cbb398d787f84fdb756d08f746e5f1d7cc12 /vp8/common | |
parent | 7748d833e8dc61c6169529dc105aacea006ee455 (diff) | |
download | libvpx-ba1a6619b3e06324354b728ec28d1b0750a7cc32.tar libvpx-ba1a6619b3e06324354b728ec28d1b0750a7cc32.tar.gz libvpx-ba1a6619b3e06324354b728ec28d1b0750a7cc32.tar.bz2 libvpx-ba1a6619b3e06324354b728ec28d1b0750a7cc32.zip |
Revised coding using adaptive mode context to depend on frame type
A previous commit 76feb965 made the vp8_mode_context adaptive on a frame
frame basis, this commit further made the coding context adaptive to two
frame types separately. Tests on derf set showed a further small gain on
all metrics: avg psnr 0.10%, glb psnr: 0.11%, ssim: 0.08%
http://www.corp.google.com/~yaowu/no_crawl/newNearMode_1209.html
Change-Id: I7b3e32ec8729de1903d14a3f1213f1624b78cdee
Diffstat (limited to 'vp8/common')
-rw-r--r-- | vp8/common/alloccommon.c | 6 | ||||
-rw-r--r-- | vp8/common/entropymode.c | 74 | ||||
-rw-r--r-- | vp8/common/entropymode.h | 2 | ||||
-rw-r--r-- | vp8/common/modecont.c | 34 | ||||
-rw-r--r-- | vp8/common/modecont.h | 4 | ||||
-rw-r--r-- | vp8/common/onyxc_int.h | 3 |
6 files changed, 98 insertions, 25 deletions
diff --git a/vp8/common/alloccommon.c b/vp8/common/alloccommon.c index 0c7a9ef8d..4457c8821 100644 --- a/vp8/common/alloccommon.c +++ b/vp8/common/alloccommon.c @@ -190,12 +190,6 @@ void vp8_create_common(VP8_COMMON *oci) vp8_machine_specific_config(oci); vp8_init_mbmode_probs(oci); -#if CONFIG_NEWNEAR - vp8_init_mv_ref_counts(oci); -#endif - vpx_memcpy( oci->vp8_mode_contexts, - default_vp8_mode_contexts, - sizeof(default_vp8_mode_contexts)); vp8_default_bmode_probs(oci->fc.bmode_prob); diff --git a/vp8/common/entropymode.c b/vp8/common/entropymode.c index 5b1a6d35c..a83c1d4bb 100644 --- a/vp8/common/entropymode.c +++ b/vp8/common/entropymode.c @@ -9,10 +9,12 @@ */ +#include "modecont.h" #include "entropymode.h" #include "entropy.h" #include "vpx_mem/vpx_mem.h" + #if CONFIG_QIMODE const unsigned int kf_y_mode_cts[8][VP8_YMODES] = { @@ -356,43 +358,59 @@ void vp8_entropy_mode_init() } #if CONFIG_NEWNEAR -void vp8_init_mv_ref_counts(VP8_COMMON *pc) +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_memcpy( pc->mode_context, + default_vp8_mode_contexts, + sizeof (pc->mode_context)); + vpx_memcpy( pc->mode_context_a, + default_vp8_mode_contexts, + sizeof (pc->mode_context_a)); + } void vp8_accum_mv_refs(VP8_COMMON *pc, MB_PREDICTION_MODE m, const int ct[4]) { + int (*mv_ref_ct)[4][2]; + + if(pc->refresh_alt_ref_frame) + mv_ref_ct = pc->mv_ref_ct_a; + else + mv_ref_ct = pc->mv_ref_ct; + if (m == ZEROMV) { - ++pc->mv_ref_ct [ct[0]] [0] [0]; + ++mv_ref_ct [ct[0]] [0] [0]; } else { - ++pc->mv_ref_ct [ct[0]] [0] [1]; + ++mv_ref_ct [ct[0]] [0] [1]; if (m == NEARESTMV) { - ++pc->mv_ref_ct [ct[1]] [1] [0]; + ++mv_ref_ct [ct[1]] [1] [0]; } else { - ++pc->mv_ref_ct [ct[1]] [1] [1]; + ++mv_ref_ct [ct[1]] [1] [1]; if (m == NEARMV) { - ++pc->mv_ref_ct [ct[2]] [2] [0]; + ++mv_ref_ct [ct[2]] [2] [0]; } else { - ++pc->mv_ref_ct [ct[2]] [2] [1]; + ++mv_ref_ct [ct[2]] [2] [1]; if (m == NEWMV) { - ++pc->mv_ref_ct [ct[3]] [3] [0]; + ++mv_ref_ct [ct[3]] [3] [0]; } else { - ++pc->mv_ref_ct [ct[3]] [3] [1]; + ++mv_ref_ct [ct[3]] [3] [1]; } } } @@ -402,24 +420,37 @@ void vp8_accum_mv_refs(VP8_COMMON *pc, void vp8_update_mode_context(VP8_COMMON *pc) { int i, j; + int (*mv_ref_ct)[4][2]; + int (*mode_context)[4]; + + if(pc->refresh_alt_ref_frame) + { + mv_ref_ct = pc->mv_ref_ct_a; + mode_context = pc->mode_context_a; + } + else + { + mv_ref_ct = pc->mv_ref_ct; + mode_context = pc->mode_context; + } + for (j = 0; j < 6; j++) { for (i = 0; i < 4; i++) { int this_prob; - int count; - // context probs - count = pc->mv_ref_ct[j][i][0] + pc->mv_ref_ct[j][i][1]; + int count = mv_ref_ct[j][i][0] + mv_ref_ct[j][i][1]; + if (count) - this_prob = 256 * pc->mv_ref_ct[j][i][0] / count; + this_prob = 256 * mv_ref_ct[j][i][0] / count; else this_prob = 128; + this_prob = this_prob? (this_prob<255?this_prob:255):1; if (this_prob == 0) this_prob = 1; if (this_prob == 256) this_prob = 255; - - pc->mode_context[j][i] = this_prob; + mode_context[j][i] = this_prob; } } } @@ -427,14 +458,25 @@ void vp8_update_mode_context(VP8_COMMON *pc) void print_mode_contexts(VP8_COMMON *pc) { int j, i; + printf("====================\n"); for(j=0; j<6; j++) { for (i = 0; i < 4; i++) { - printf( "%4d ", pc->vp8_mode_contexts[j][i]); + printf( "%4d ", pc->mode_context[j][i]); } printf("\n"); } + printf("====================\n"); + for(j=0; j<6; j++) + { + for (i = 0; i < 4; i++) + { + printf( "%4d ", pc->mode_context_a[j][i]); + } + printf("\n"); + } + } void print_mv_ref_cts(VP8_COMMON *pc) { diff --git a/vp8/common/entropymode.h b/vp8/common/entropymode.h index 7f5bdf901..1c6d23560 100644 --- a/vp8/common/entropymode.h +++ b/vp8/common/entropymode.h @@ -63,6 +63,8 @@ void vp8_entropy_mode_init(void); void vp8_init_mbmode_probs(VP8_COMMON *x); +extern void vp8_update_mode_context(VP8_COMMON *pc);; + 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]); diff --git a/vp8/common/modecont.c b/vp8/common/modecont.c index d7491f241..c7f903b16 100644 --- a/vp8/common/modecont.c +++ b/vp8/common/modecont.c @@ -10,7 +10,38 @@ #include "entropy.h" - +#if CONFIG_NEWNEAR +const int default_vp8_mode_contexts[6][4] = +{ + { /* 0 */ + 7, 1, 1, 183}, + { /* 1 */ + 14, 18, 14, 147}, + {/* 2 */ + 135, 64, 57, 68}, + { /* 3 */ + 60, 56, 128, 65}, + {/* 4 */ + 159, 134, 128, 34}, + { /* 5 */ + 234, 188, 128, 28}, +}; +const int default_vp8_mode_contexts_a[6][4] = +{ + { /* 0 */ + 4, 1, 1, 143}, + { /* 1 */ + 7, 9, 7, 107}, + {/* 2 */ + 95, 34, 57, 68}, + { /* 3 */ + 95, 56, 128, 65}, + {/* 4 */ + 159, 67, 128, 34}, + { /* 5 */ + 234, 94, 128, 28}, +}; +#else const int default_vp8_mode_contexts[6][4] = { { @@ -38,3 +69,4 @@ const int default_vp8_mode_contexts[6][4] = 234, 188, 128, 28, }, }; +#endif
\ No newline at end of file diff --git a/vp8/common/modecont.h b/vp8/common/modecont.h index 476ae3fa9..8117e6391 100644 --- a/vp8/common/modecont.h +++ b/vp8/common/modecont.h @@ -13,5 +13,7 @@ #define __INC_MODECONT_H extern const int default_vp8_mode_contexts[6][4]; - +#if CONFIG_NEWNEAR +extern const int default_vp8_mode_contexts_a[6][4]; +#endif #endif diff --git a/vp8/common/onyxc_int.h b/vp8/common/onyxc_int.h index 4bca5af87..3cb63d5af 100644 --- a/vp8/common/onyxc_int.h +++ b/vp8/common/onyxc_int.h @@ -218,12 +218,13 @@ typedef struct VP8Common #if CONFIG_NEWNEAR 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]; #endif int vp8_mode_contexts[6][4]; unsigned int current_video_frame; - int near_boffset[3]; int version; |