From c5ddb7f0160ff9e2b8f2f67491fe27947e709923 Mon Sep 17 00:00:00 2001 From: Deb Mukherjee Date: Mon, 14 May 2012 16:21:01 -0700 Subject: [PATCH] Adds new Directional Intra prediction modes. Adds 6 directional intra predictiom modes for 16x16 and 8x8 blocks. Change-Id: I25eccc0836f28d8d74922e4e9231568a648b47d1 --- configure | 1 + vp8/common/blockd.h | 10 +- vp8/common/entropymode.c | 129 +++++++++- vp8/common/loopfilter.c | 8 + vp8/common/postproc.c | 9 + vp8/common/reconintra.c | 350 ++++++++++++++++++++++++++- vp8/common/reconintra.h | 16 ++ vp8/common/x86/x86_systemdependent.c | 6 +- vp8/encoder/bitstream.c | 13 +- vp8/encoder/block.h | 2 +- vp8/encoder/encodeframe.c | 24 +- vp8/encoder/onyx_if.c | 129 +++++++--- vp8/encoder/onyx_int.h | 61 +++-- vp8/encoder/ratectrl.c | 12 +- vp8/encoder/rdopt.c | 35 ++- 15 files changed, 703 insertions(+), 102 deletions(-) diff --git a/configure b/configure index 52ff9c898..8c3716e7a 100755 --- a/configure +++ b/configure @@ -229,6 +229,7 @@ EXPERIMENT_LIST=" superblocks expanded_coef_context int_8x8fdct + newintramodes " CONFIG_LIST=" external_build diff --git a/vp8/common/blockd.h b/vp8/common/blockd.h index 791571412..19511f31d 100644 --- a/vp8/common/blockd.h +++ b/vp8/common/blockd.h @@ -86,8 +86,16 @@ typedef enum DC_PRED, /* average of above and left pixels */ V_PRED, /* vertical prediction */ H_PRED, /* horizontal prediction */ +#if CONFIG_NEWINTRAMODES + D45_PRED, /* Directional 45 deg prediction [anti-clockwise from 0 deg hor] */ + D135_PRED, /* Directional 135 deg prediction [anti-clockwise from 0 deg hor] */ + D117_PRED, /* Directional 112 deg prediction [anti-clockwise from 0 deg hor] */ + D153_PRED, /* Directional 157 deg prediction [anti-clockwise from 0 deg hor] */ + D27_PRED, /* Directional 22 deg prediction [anti-clockwise from 0 deg hor] */ + D63_PRED, /* Directional 67 deg prediction [anti-clockwise from 0 deg hor] */ +#endif TM_PRED, /* Truemotion prediction */ - I8X8_PRED, /* 8x8 based prediction, each 8x8 has its own prediction mode */ + I8X8_PRED, /* 8x8 based prediction, each 8x8 has its own prediction mode */ B_PRED, /* block based prediction, each block has its own prediction mode */ NEARESTMV, diff --git a/vp8/common/entropymode.c b/vp8/common/entropymode.c index aa8d03717..0ae6a9343 100644 --- a/vp8/common/entropymode.c +++ b/vp8/common/entropymode.c @@ -17,6 +17,16 @@ const unsigned int kf_y_mode_cts[8][VP8_YMODES] = { +#if CONFIG_NEWINTRAMODES + {12, 6, 5, 5, 5, 5, 5, 5, 5, 2, 22, 200}, + {25, 13, 13, 7, 7, 7, 7, 7, 7, 6, 27, 160}, + {31, 17, 18, 8, 8, 8, 8, 8, 8, 9, 26, 139}, + {40, 22, 23, 8, 8, 8, 8, 8, 8, 12, 27, 116}, + {53, 26, 28, 8, 8, 8, 8, 8, 8, 13, 26, 94}, + {68, 33, 35, 8, 8, 8, 8, 8, 8, 17, 20, 68}, + {78, 38, 38, 8, 8, 8, 8, 8, 8, 19, 16, 52}, + {89, 42, 42, 8, 8, 8, 8, 8, 8, 21, 12, 34}, +#else {17, 6, 5, 2, 22, 203}, {27, 13, 13, 6, 27, 170}, {35, 17, 18, 9, 26, 152}, @@ -25,29 +35,69 @@ const unsigned int kf_y_mode_cts[8][VP8_YMODES] = {73, 33, 36, 17, 20, 78}, {88, 38, 39, 19, 16, 57}, {99, 42, 43, 21, 12, 39}, +#endif }; -static const unsigned int y_mode_cts [VP8_YMODES] = { - 106, 25, 21, 13, 16, 74}; +static const unsigned int y_mode_cts [VP8_YMODES] = +#if CONFIG_NEWINTRAMODES + {98, 19, 15, 14, 14, 14, 14, 12, 12, 13, 16, 70}; +#else + {106, 25, 21, 13, 16, 74}; +#endif static const unsigned int uv_mode_cts [VP8_YMODES] [VP8_UV_MODES] ={ +#if CONFIG_NEWINTRAMODES + { 200, 15, 15, 10, 10, 10, 10, 10, 10, 6}, + { 130, 75, 10, 10, 10, 10, 10, 10, 10, 6}, + { 130, 10, 75, 10, 10, 10, 10, 10, 10, 6}, + { 130, 15, 10, 75, 10, 10, 10, 10, 10, 6}, + { 150, 15, 10, 10, 75, 10, 10, 10, 10, 6}, + { 150, 15, 10, 10, 10, 75, 10, 10, 10, 6}, + { 150, 15, 10, 10, 10, 10, 75, 10, 10, 6}, + { 150, 15, 10, 10, 10, 10, 10, 75, 10, 6}, + { 150, 15, 10, 10, 10, 10, 10, 10, 75, 6}, + { 160, 30, 30, 10, 10, 10, 10, 10, 10, 16}, + { 132, 46, 40, 10, 10, 10, 10, 10, 10, 18}, /* never used */ + { 150, 35, 41, 10, 10, 10, 10, 10, 10, 10}, +#else { 210, 20, 20, 6}, { 180, 60, 10, 6}, { 150, 20, 80, 6}, { 170, 35, 35, 16}, { 142, 51, 45, 18}, /* never used */ { 160, 40, 46, 10}, +#endif }; -static const unsigned int i8x8_mode_cts [VP8_UV_MODES] = {93, 69, 81, 13}; +static const unsigned int i8x8_mode_cts [VP8_I8X8_MODES] = +#if CONFIG_NEWINTRAMODES + {73, 49, 61, 30, 30, 30, 30, 30, 30, 13}; +#else + {93, 69, 81, 13}; +#endif static const unsigned int kf_uv_mode_cts [VP8_YMODES] [VP8_UV_MODES] ={ +#if CONFIG_NEWINTRAMODES + { 160, 24, 24, 20, 20, 20, 20, 20, 20, 8}, + { 102, 64, 30, 20, 20, 20, 20, 20, 20, 10}, + { 102, 30, 64, 20, 20, 20, 20, 20, 20, 10}, + { 102, 33, 20, 64, 20, 20, 20, 20, 20, 14}, + { 102, 33, 20, 20, 64, 20, 20, 20, 20, 14}, + { 122, 33, 20, 20, 20, 64, 20, 20, 20, 14}, + { 102, 33, 20, 20, 20, 20, 64, 20, 20, 14}, + { 102, 33, 20, 20, 20, 20, 20, 64, 20, 14}, + { 102, 33, 20, 20, 20, 20, 20, 20, 64, 14}, + { 132, 36, 30, 20, 20, 20, 20, 20, 20, 18}, + { 122, 41, 35, 20, 20, 20, 20, 20, 20, 18}, /* never used */ + { 122, 41, 35, 20, 20, 20, 20, 20, 20, 18}, +#else { 180, 34, 34, 8}, { 132, 74, 40, 10}, { 132, 40, 74, 10}, { 152, 46, 40, 18}, { 142, 51, 45, 18}, /* never used */ { 142, 51, 45, 18}, +#endif }; static const unsigned int bmode_cts[VP8_BINTRAMODES] = @@ -133,7 +183,7 @@ const vp8_prob vp8_mbsplit_probs [VP8_NUMMBSPLITS-1] = { 110, 111, 150}; /* Array indices are identical to previously-existing INTRAMODECONTEXTNODES. */ -const vp8_tree_index vp8_bmode_tree[18] = /* INTRAMODECONTEXTNODE value */ +const vp8_tree_index vp8_bmode_tree[VP8_BINTRAMODES*2-2] = /* INTRAMODECONTEXTNODE value */ { -B_DC_PRED, 2, /* 0 = DC_NODE */ -B_TM_PRED, 4, /* 1 = TM_NODE */ @@ -146,6 +196,67 @@ const vp8_tree_index vp8_bmode_tree[18] = /* INTRAMODECONTEXTNODE value */ -B_HD_PRED, -B_HU_PRED /* 8 = HD_NODE */ }; +#if CONFIG_NEWINTRAMODES +/* Again, these trees use the same probability indices as their + explicitly-programmed predecessors. */ +const vp8_tree_index vp8_ymode_tree[VP8_YMODES*2-2] = +{ + 2, 14, + -DC_PRED, 4, + 6, 8, + -D45_PRED, -D135_PRED, + 10, 12, + -D117_PRED, -D153_PRED, + -D27_PRED, -D63_PRED, + 16, 18, + -V_PRED, -H_PRED, + -TM_PRED, 20, + -B_PRED, -I8X8_PRED +}; + +const vp8_tree_index vp8_kf_ymode_tree[VP8_YMODES*2-2] = +{ + 2, 14, + -DC_PRED, 4, + 6, 8, + -D45_PRED, -D135_PRED, + 10, 12, + -D117_PRED, -D153_PRED, + -D27_PRED, -D63_PRED, + 16, 18, + -V_PRED, -H_PRED, + -TM_PRED, 20, + -B_PRED, -I8X8_PRED +}; + +const vp8_tree_index vp8_i8x8_mode_tree[VP8_I8X8_MODES*2-2] = +{ + 2, 14, + -DC_PRED, 4, + 6, 8, + -D45_PRED, -D135_PRED, + 10, 12, + -D117_PRED, -D153_PRED, + -D27_PRED, -D63_PRED, + -V_PRED, 16, + -H_PRED, -TM_PRED +}; + +const vp8_tree_index vp8_uv_mode_tree[VP8_UV_MODES*2-2] = +{ + 2, 14, + -DC_PRED, 4, + 6, 8, + -D45_PRED, -D135_PRED, + 10, 12, + -D117_PRED, -D153_PRED, + -D27_PRED, -D63_PRED, + -V_PRED, 16, + -H_PRED, -TM_PRED +}; + +#else /* CONFIG_NEWINTRAMODES */ + /* Again, these trees use the same probability indices as their explicitly-programmed predecessors. */ const vp8_tree_index vp8_ymode_tree[10] = @@ -179,6 +290,8 @@ const vp8_tree_index vp8_uv_mode_tree[6] = -H_PRED, -TM_PRED }; +#endif /* CONFIG_NEWINTRAMODES */ + const vp8_tree_index vp8_mbsplit_tree[6] = { -3, 2, @@ -282,10 +395,10 @@ void vp8_init_mbmode_probs(VP8_COMMON *x) } vp8_tree_probs_from_distribution( - VP8_UV_MODES, vp8_i8x8_mode_encodings, vp8_i8x8_mode_tree, + VP8_I8X8_MODES, vp8_i8x8_mode_encodings, vp8_i8x8_mode_tree, x->i8x8_mode_prob, bct, i8x8_mode_cts, - 256, 1 - ); + 256, 1); + vpx_memcpy(x->fc.sub_mv_ref_prob, sub_mv_ref_prob, sizeof(sub_mv_ref_prob)); } @@ -448,7 +561,7 @@ void vp8_update_mode_context(VP8_COMMON *pc) void print_mode_contexts(VP8_COMMON *pc) { int j, i; - printf("====================\n"); + printf("\n====================\n"); for(j=0; j<6; j++) { for (i = 0; i < 4; i++) diff --git a/vp8/common/loopfilter.c b/vp8/common/loopfilter.c index 1cac063e0..6f57d49b4 100644 --- a/vp8/common/loopfilter.c +++ b/vp8/common/loopfilter.c @@ -149,6 +149,14 @@ static void lf_init_lut(loop_filter_info_n *lfi) } lfi->mode_lf_lut[DC_PRED] = 1; +#if CONFIG_NEWINTRAMODES + lfi->mode_lf_lut[D45_PRED] = 1; + lfi->mode_lf_lut[D135_PRED] = 1; + lfi->mode_lf_lut[D117_PRED] = 1; + lfi->mode_lf_lut[D153_PRED] = 1; + lfi->mode_lf_lut[D27_PRED] = 1; + lfi->mode_lf_lut[D63_PRED] = 1; +#endif lfi->mode_lf_lut[V_PRED] = 1; lfi->mode_lf_lut[H_PRED] = 1; lfi->mode_lf_lut[TM_PRED] = 1; diff --git a/vp8/common/postproc.c b/vp8/common/postproc.c index d88b419bc..7e7ed3cb7 100644 --- a/vp8/common/postproc.c +++ b/vp8/common/postproc.c @@ -32,6 +32,14 @@ static const unsigned char MB_PREDICTION_MODE_colors[MB_MODE_COUNT][3] = { RGB_TO_YUV(0x98FB98) }, /* PaleGreen */ { RGB_TO_YUV(0x00FF00) }, /* Green */ { RGB_TO_YUV(0xADFF2F) }, /* GreenYellow */ +#if CONFIG_NEWINTRAMODES + { RGB_TO_YUV(0x8F0000) }, /* Dark Red */ + { RGB_TO_YUV(0x008F8F) }, /* Dark Cyan */ + { RGB_TO_YUV(0x008F8F) }, /* Dark Cyan */ + { RGB_TO_YUV(0x008F8F) }, /* Dark Cyan */ + { RGB_TO_YUV(0x8F0000) }, /* Dark Red */ + { RGB_TO_YUV(0x8F0000) }, /* Dark Red */ +#endif { RGB_TO_YUV(0x228B22) }, /* ForestGreen */ { RGB_TO_YUV(0x006400) }, /* DarkGreen */ { RGB_TO_YUV(0x98F5FF) }, /* Cadet Blue */ @@ -39,6 +47,7 @@ static const unsigned char MB_PREDICTION_MODE_colors[MB_MODE_COUNT][3] = { RGB_TO_YUV(0x00008B) }, /* Dark blue */ { RGB_TO_YUV(0x551A8B) }, /* Purple */ { RGB_TO_YUV(0xFF0000) } /* Red */ + { RGB_TO_YUV(0xCC33FF) }, /* Magenta */ }; static const unsigned char B_PREDICTION_MODE_colors[B_MODE_COUNT][3] = diff --git a/vp8/common/reconintra.c b/vp8/common/reconintra.c index 501eacab2..27b47926e 100644 --- a/vp8/common/reconintra.c +++ b/vp8/common/reconintra.c @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ - +#include #include "vpx_ports/config.h" #include "recon.h" #include "reconintra.h" @@ -17,6 +17,217 @@ /* For skip_recon_mb(), add vp8_build_intra_predictors_mby_s(MACROBLOCKD *x) and * vp8_build_intra_predictors_mbuv_s(MACROBLOCKD *x). */ + +#if CONFIG_NEWINTRAMODES +void d27_predictor(unsigned char *ypred_ptr, int y_stride, int n, + unsigned char *yabove_row, unsigned char *yleft_col) +{ + int r, c, h, w, v; + int a, b; + r = 0; + for (c = 0; c < n-2; c++) + { + if (c&1) + a = yleft_col[r + 1]; + else + a = (yleft_col[r] + yleft_col[r + 1] + 1) >> 1; + b = yabove_row[c + 2]; + ypred_ptr[c] = (2 * a + (c + 1) * b + (c + 3)/2) / (c + 3); + } + for (r = 1; r < n/2 - 1; r++) + { + for (c = 0; c < n - 2 - 2 * r; c++) + { + if (c&1) + a = yleft_col[r + 1]; + else + a = (yleft_col[r] + yleft_col[r + 1] + 1) >> 1; + b = ypred_ptr[(r - 1) * y_stride + c + 2]; + ypred_ptr[r * y_stride + c] = (2 * a + (c + 1) * b + (c + 3)/2) / (c + 3); + } + } + for (; r < n - 1; ++r) + { + for (c = 0; c < n; c++) + { + v = (c & 1 ? yleft_col[r + 1] : (yleft_col[r] + yleft_col[r + 1] + 1) >> 1); + h = r - c/2; + ypred_ptr[h * y_stride + c] = v; + } + } + c = 0; + r = n - 1; + ypred_ptr[r * y_stride] = (ypred_ptr[(r - 1) * y_stride] + + yleft_col[r] + 1) >> 1; + for (r = n - 2; r >= n/2; --r) + { + w = c + (n - 1 - r) * 2; + ypred_ptr[r * y_stride + w] = (ypred_ptr[(r - 1) * y_stride + w] + + ypred_ptr[r * y_stride + w - 1] + 1) >> 1; + } + for (c = 1; c < n; c++) + { + for (r = n - 1; r >= n/2 + c/2; --r) + { + w = c + (n - 1 - r) * 2; + ypred_ptr[r * y_stride + w] = (ypred_ptr[(r - 1) * y_stride + w] + + ypred_ptr[r * y_stride + w - 1] + 1) >> 1; + } + } +} + +void d63_predictor(unsigned char *ypred_ptr, int y_stride, int n, + unsigned char *yabove_row, unsigned char *yleft_col) +{ + int r, c, h, w, v; + int a, b; + c = 0; + for (r = 0; r < n-2; r++) + { + if (r&1) + a = yabove_row[c + 1]; + else + a = (yabove_row[c] + yabove_row[c + 1] + 1) >> 1; + b = yleft_col[r + 2]; + ypred_ptr[r * y_stride] = (2 * a + (r + 1) * b + (r + 3)/2) / (r + 3); + } + for (c = 1; c < n/2 - 1; c++) + { + for (r = 0; r < n - 2 - 2 * c; r++) + { + if (r&1) + a = yabove_row[c + 1]; + else + a = (yabove_row[c] + yabove_row[c + 1] + 1) >> 1; + b = ypred_ptr[(r + 2) * y_stride + c - 1]; + ypred_ptr[r * y_stride + c] = (2 * a + (c + 1) * b + (c + 3)/2) / (c + 3); + } + } + for (; c < n - 1; ++c) + { + for (r = 0; r < n; r++) + { + v = (r & 1 ? yabove_row[c + 1] : (yabove_row[c] + yabove_row[c + 1] + 1) >> 1); + w = c - r/2; + ypred_ptr[r * y_stride + w] = v; + } + } + r = 0; + c = n - 1; + ypred_ptr[c] = (ypred_ptr[(c - 1)] + yabove_row[c] + 1) >> 1; + for (c = n - 2; c >= n/2; --c) + { + h = r + (n - 1 - c) * 2; + ypred_ptr[h * y_stride + c] = (ypred_ptr[h * y_stride + c - 1] + + ypred_ptr[(h - 1) * y_stride + c] + 1) >> 1; + } + for (r = 1; r < n; r++) + { + for (c = n - 1; c >= n/2 + r/2; --c) + { + h = r + (n - 1 - c) * 2; + ypred_ptr[h * y_stride + c] = (ypred_ptr[h * y_stride + c - 1] + + ypred_ptr[(h - 1) * y_stride + c] + 1) >> 1; + } + } +} + +void d45_predictor(unsigned char *ypred_ptr, int y_stride, int n, + unsigned char *yabove_row, unsigned char *yleft_col) +{ + int r, c; + for (r = 0; r < n - 1; ++r) + { + for (c = 0; c <= r; ++c) + { + ypred_ptr[(r - c) * y_stride + c] = + (yabove_row[r+1] * (c + 1) + + yleft_col[r+1] * (r - c + 1) + r/2 + 1) / (r + 2); + } + } + for (c = 0; c <= r; ++c) + { + int yabove_ext = yabove_row[r]; //2*yabove_row[r] - yabove_row[r-1]; + int yleft_ext = yleft_col[r]; //2*yleft_col[r] - yleft_col[r-1]; + yabove_ext = (yabove_ext > 255 ? 255 : (yabove_ext < 0 ? 0 : yabove_ext)); + yleft_ext = (yleft_ext > 255 ? 255 : (yleft_ext < 0 ? 0 : yleft_ext)); + ypred_ptr[(r - c) * y_stride + c] = + (yabove_ext * (c + 1) + + yleft_ext * (r - c + 1) + r/2 + 1) / (r + 2); + } + for (r = 1; r < n; ++r) + { + for (c = n - r; c < n; ++c) + ypred_ptr[r * y_stride + c] = (ypred_ptr[(r - 1) * y_stride + c] + + ypred_ptr[r * y_stride + c - 1] + 1) >> 1; + } +} + +void d117_predictor(unsigned char *ypred_ptr, int y_stride, int n, + unsigned char *yabove_row, unsigned char *yleft_col) +{ + int r, c; + for (c = 0; c < n; c++) + ypred_ptr[c] = (yabove_row[c-1] + yabove_row[c] + 1) >> 1; + ypred_ptr += y_stride; + for (c = 0; c < n; c++) + ypred_ptr[c] = yabove_row[c-1]; + ypred_ptr += y_stride; + for (r = 2; r < n; ++r) + { + ypred_ptr[0] = yleft_col[r - 2]; + for (c = 1; c < n; c++) + ypred_ptr[c] = ypred_ptr[-2*y_stride+c-1]; + ypred_ptr += y_stride; + } +} + +void d135_predictor(unsigned char *ypred_ptr, int y_stride, int n, + unsigned char *yabove_row, unsigned char *yleft_col) +{ + int r, c; + ypred_ptr[0] = yabove_row[-1]; + for (c = 1; c < n; c++) + ypred_ptr[c] = yabove_row[c - 1]; + for (r = 1; r < n; ++r) + ypred_ptr[r * y_stride] = yleft_col[r - 1]; + + ypred_ptr += y_stride; + for (r = 1; r < n; ++r) + { + for (c = 1; c < n; c++) + { + ypred_ptr[c] = ypred_ptr[-y_stride + c - 1]; + } + ypred_ptr += y_stride; + } +} + +void d153_predictor(unsigned char *ypred_ptr, int y_stride, int n, + unsigned char *yabove_row, unsigned char *yleft_col) +{ + int r, c; + ypred_ptr[0] = (yabove_row[-1] + yleft_col[0] + 1) >> 1; + for (r = 1; r < n; r++) + ypred_ptr[r * y_stride] = (yleft_col[r-1] + yleft_col[r] + 1) >> 1; + ypred_ptr++; + ypred_ptr[0] = yabove_row[-1]; + for (r = 1; r < n; r++) + ypred_ptr[r * y_stride] = yleft_col[r-1]; + ypred_ptr++; + + for (c = 0; c < n - 2; c++) + ypred_ptr[c] = yabove_row[c]; + ypred_ptr += y_stride; + for (r = 1; r < n; ++r) + { + for (c = 0; c < n - 2; c++) + ypred_ptr[c] = ypred_ptr[-y_stride+c-2]; + ypred_ptr += y_stride; + } +} +#endif /* CONFIG_NEWINTRAMODES */ + void vp8_recon_intra_mbuv(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x) { int i; @@ -64,7 +275,6 @@ void vp8_build_intra_predictors_mby_internal(MACROBLOCKD *x, unsigned char *ypre if (x->left_available) { - for (i = 0; i < 16; i++) { average += yleft_col[i]; @@ -134,6 +344,38 @@ void vp8_build_intra_predictors_mby_internal(MACROBLOCKD *x, unsigned char *ypre } break; +#if CONFIG_NEWINTRAMODES + case D45_PRED: + { + d45_predictor(ypred_ptr, y_stride, 16, yabove_row, yleft_col); + } + break; + case D135_PRED: + { + d135_predictor(ypred_ptr, y_stride, 16, yabove_row, yleft_col); + } + break; + case D117_PRED: + { + d117_predictor(ypred_ptr, y_stride, 16, yabove_row, yleft_col); + } + break; + case D153_PRED: + { + d153_predictor(ypred_ptr, y_stride, 16, yabove_row, yleft_col); + } + break; + case D27_PRED: + { + d27_predictor(ypred_ptr, y_stride, 16, yabove_row, yleft_col); + } + break; + case D63_PRED: + { + d63_predictor(ypred_ptr, y_stride, 16, yabove_row, yleft_col); + } + break; +#endif #if CONIFG_I8X8 case I8X8_PRED: #endif @@ -313,6 +555,44 @@ void vp8_build_intra_predictors_mbuv_internal(MACROBLOCKD *x, } break; +#if CONFIG_NEWINTRAMODES + case D45_PRED: + { + d45_predictor(upred_ptr, uv_stride, 8, uabove_row, uleft_col); + d45_predictor(vpred_ptr, uv_stride, 8, vabove_row, vleft_col); + } + break; + case D135_PRED: + { + d135_predictor(upred_ptr, uv_stride, 8, uabove_row, uleft_col); + d135_predictor(vpred_ptr, uv_stride, 8, vabove_row, vleft_col); + } + break; + case D117_PRED: + { + d117_predictor(upred_ptr, uv_stride, 8, uabove_row, uleft_col); + d117_predictor(vpred_ptr, uv_stride, 8, vabove_row, vleft_col); + } + break; + case D153_PRED: + { + d153_predictor(upred_ptr, uv_stride, 8, uabove_row, uleft_col); + d153_predictor(vpred_ptr, uv_stride, 8, vabove_row, vleft_col); + } + break; + case D27_PRED: + { + d27_predictor(upred_ptr, uv_stride, 8, uabove_row, uleft_col); + d27_predictor(vpred_ptr, uv_stride, 8, vabove_row, vleft_col); + } + break; + case D63_PRED: + { + d63_predictor(upred_ptr, uv_stride, 8, uabove_row, uleft_col); + d63_predictor(vpred_ptr, uv_stride, 8, vabove_row, vleft_col); + } + break; +#endif case B_PRED: case NEARESTMV: case NEARMV: @@ -403,7 +683,6 @@ void vp8_intra8x8_predict(BLOCKD *x, { for (c = 0; c < 8; c++) { - predictor[c] = yabove_row[c]; } predictor += 16; @@ -444,6 +723,38 @@ void vp8_intra8x8_predict(BLOCKD *x, } } break; +#if CONFIG_NEWINTRAMODES + case D45_PRED: + { + d45_predictor(predictor, 16, 8, yabove_row, yleft_col); + } + break; + case D135_PRED: + { + d135_predictor(predictor, 16, 8, yabove_row, yleft_col); + } + break; + case D117_PRED: + { + d117_predictor(predictor, 16, 8, yabove_row, yleft_col); + } + break; + case D153_PRED: + { + d153_predictor(predictor, 16, 8, yabove_row, yleft_col); + } + break; + case D27_PRED: + { + d27_predictor(predictor, 16, 8, yabove_row, yleft_col); + } + break; + case D63_PRED: + { + d63_predictor(predictor, 16, 8, yabove_row, yleft_col); + } + break; +#endif } } @@ -452,7 +763,6 @@ void vp8_comp_intra8x8_predict(BLOCKD *x, int mode, int second_mode, unsigned char *out_predictor) { - unsigned char predictor[2][8*16]; int i, j; @@ -553,6 +863,38 @@ void vp8_intra_uv4x4_predict(BLOCKD *x, } } break; +#if CONFIG_NEWINTRAMODES + case D45_PRED: + { + d45_predictor(predictor, 8, 4, above_row, left_col); + } + break; + case D135_PRED: + { + d135_predictor(predictor, 8, 4, above_row, left_col); + } + break; + case D117_PRED: + { + d117_predictor(predictor, 8, 4, above_row, left_col); + } + break; + case D153_PRED: + { + d153_predictor(predictor, 8, 4, above_row, left_col); + } + break; + case D27_PRED: + { + d27_predictor(predictor, 8, 4, above_row, left_col); + } + break; + case D63_PRED: + { + d63_predictor(predictor, 8, 4, above_row, left_col); + } + break; +#endif } } diff --git a/vp8/common/reconintra.h b/vp8/common/reconintra.h index 47e479285..03b50f2c1 100644 --- a/vp8/common/reconintra.h +++ b/vp8/common/reconintra.h @@ -12,6 +12,22 @@ #ifndef __INC_RECONINTRA_H #define __INC_RECONINTRA_H +#include "blockd.h" +#if CONFIG_NEWINTRAMODES +void d45_predictor(unsigned char *ypred_ptr, int y_stride, int n, + unsigned char *yabove_row, unsigned char *yleft_col); +void d135_predictor(unsigned char *ypred_ptr, int y_stride, int n, + unsigned char *yabove_row, unsigned char *yleft_col); +void d116_predictor(unsigned char *ypred_ptr, int y_stride, int n, + unsigned char *yabove_row, unsigned char *yleft_col); +void d153_predictor(unsigned char *ypred_ptr, int y_stride, int n, + unsigned char *yabove_row, unsigned char *yleft_col); +void d27_predictor(unsigned char *ypred_ptr, int y_stride, int n, + unsigned char *yabove_row, unsigned char *yleft_col); +void d64_predictor(unsigned char *ypred_ptr, int y_stride, int n, + unsigned char *yabove_row, unsigned char *yleft_col); +#endif /* CONFIG_NEWINTRAMODES */ + extern void init_intra_left_above_pixels(MACROBLOCKD *x); #endif diff --git a/vp8/common/x86/x86_systemdependent.c b/vp8/common/x86/x86_systemdependent.c index 53009502c..b88eb3dc8 100644 --- a/vp8/common/x86/x86_systemdependent.c +++ b/vp8/common/x86/x86_systemdependent.c @@ -84,10 +84,12 @@ void vp8_arch_x86_common_init(VP8_COMMON *ctx) rtcd->recon.recon2 = vp8_recon2b_sse2; rtcd->recon.recon4 = vp8_recon4b_sse2; rtcd->recon.copy16x16 = vp8_copy_mem16x16_sse2; +#if CONFIG_NEWINTRAMODES == 0 rtcd->recon.build_intra_predictors_mbuv = vp8_build_intra_predictors_mbuv_sse2; rtcd->recon.build_intra_predictors_mbuv_s = vp8_build_intra_predictors_mbuv_s_sse2; +#endif rtcd->idct.iwalsh16 = vp8_short_inv_walsh4x4_sse2; @@ -122,7 +124,7 @@ void vp8_arch_x86_common_init(VP8_COMMON *ctx) if (flags & HAS_SSSE3) { -#if CONFIG_ENHANCED_INTERP == 0 && CONFIG_HIGH_PRECISION_MV == 0 +#if CONFIG_ENHANCED_INTERP == 0 && CONFIG_HIGH_PRECISION_MV == 0 && CONFIG_SIXTEENTH_SUBPEL_UV == 0 rtcd->subpix.sixtap16x16 = vp8_sixtap_predict16x16_ssse3; rtcd->subpix.sixtap8x8 = vp8_sixtap_predict8x8_ssse3; rtcd->subpix.sixtap8x4 = vp8_sixtap_predict8x4_ssse3; @@ -131,10 +133,12 @@ void vp8_arch_x86_common_init(VP8_COMMON *ctx) rtcd->subpix.bilinear8x8 = vp8_bilinear_predict8x8_ssse3; #endif +#if CONFIG_NEWINTRAMODES == 0 rtcd->recon.build_intra_predictors_mbuv = vp8_build_intra_predictors_mbuv_ssse3; rtcd->recon.build_intra_predictors_mbuv_s = vp8_build_intra_predictors_mbuv_s_ssse3; +#endif } #endif diff --git a/vp8/encoder/bitstream.c b/vp8/encoder/bitstream.c index 4918e2cb2..6ebf282ed 100644 --- a/vp8/encoder/bitstream.c +++ b/vp8/encoder/bitstream.c @@ -34,15 +34,18 @@ unsigned __int64 Sectionbits[500]; #endif #ifdef ENTROPY_STATS -int intra_mode_stats[10][10][10]; +int intra_mode_stats[VP8_BINTRAMODES] + [VP8_BINTRAMODES] + [VP8_BINTRAMODES]; static unsigned int tree_update_hist [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] - [ENTROPY_NODES][2]={0}; + [ENTROPY_NODES] [2]={0}; static unsigned int tree_update_hist_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES] [2]={0}; + extern unsigned int active_section; #endif @@ -1224,6 +1227,7 @@ static void write_kfmodes(VP8_COMP *cpi) int row_delta[4] = { 0, +1, 0, -1}; int col_delta[4] = {+1, -1, +1, +1}; + //printf("write_kfmodes\n"); if (c->mb_no_coeff_skip) { // Divide by 0 check. 0 case possible with segment features @@ -1349,6 +1353,7 @@ static void write_kfmodes(VP8_COMP *cpi) #endif write_bmode(bc, bm, c->kf_bmode_prob [A] [L]); + //printf(" mode: %d\n", bm); #if CONFIG_COMP_INTRA_PRED if (uses_second) { @@ -1362,12 +1367,16 @@ static void write_kfmodes(VP8_COMP *cpi) { write_i8x8_mode(bc, m->bmi[0].as_mode.first, c->i8x8_mode_prob); + //printf(" mode: %d\n", m->bmi[0].as_mode.first); fflush(stdout); write_i8x8_mode(bc, m->bmi[2].as_mode.first, c->i8x8_mode_prob); + //printf(" mode: %d\n", m->bmi[2].as_mode.first); fflush(stdout); write_i8x8_mode(bc, m->bmi[8].as_mode.first, c->i8x8_mode_prob); + //printf(" mode: %d\n", m->bmi[8].as_mode.first); fflush(stdout); write_i8x8_mode(bc, m->bmi[10].as_mode.first, c->i8x8_mode_prob); + //printf(" mode: %d\n", m->bmi[10].as_mode.first); fflush(stdout); } else write_uv_mode(bc, m->mbmi.uv_mode, c->kf_uv_mode_prob[ym]); diff --git a/vp8/encoder/block.h b/vp8/encoder/block.h index 2b21fa2b2..98bc13277 100644 --- a/vp8/encoder/block.h +++ b/vp8/encoder/block.h @@ -124,7 +124,7 @@ typedef struct #endif int mbmode_cost[2][MB_MODE_COUNT]; int intra_uv_mode_cost[2][MB_MODE_COUNT]; - unsigned int bmode_costs[10][10][10]; + unsigned int bmode_costs[VP8_BINTRAMODES][VP8_BINTRAMODES][VP8_BINTRAMODES]; unsigned int i8x8_mode_costs[MB_MODE_COUNT]; unsigned int inter_bmode_costs[B_MODE_COUNT]; diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c index ec3e1602c..80d1f7045 100644 --- a/vp8/encoder/encodeframe.c +++ b/vp8/encoder/encodeframe.c @@ -71,22 +71,14 @@ static void adjust_act_zbin( VP8_COMP *cpi, MACROBLOCK *x ); #ifdef MODE_STATS -unsigned int inter_y_modes[MB_MODE_COUNT] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -unsigned int inter_uv_modes[VP8_UV_MODES] = {0, 0, 0, 0}; -unsigned int inter_b_modes[B_MODE_COUNT] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -unsigned int y_modes[VP8_YMODES] = {0, 0, 0, 0, 0, 0}; -unsigned int i8x8_modes[VP8_I8X8_MODES]={0 }; -unsigned int uv_modes[VP8_UV_MODES] = {0, 0, 0, 0}; -unsigned int uv_modes_y[VP8_YMODES][VP8_UV_MODES]= -{ -{0, 0, 0, 0}, -{0, 0, 0, 0}, -{0, 0, 0, 0}, -{0, 0, 0, 0}, -{0, 0, 0, 0}, -{0, 0, 0, 0} -}; -unsigned int b_modes[B_MODE_COUNT] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +unsigned int inter_y_modes[MB_MODE_COUNT]; +unsigned int inter_uv_modes[VP8_UV_MODES]; +unsigned int inter_b_modes[B_MODE_COUNT]; +unsigned int y_modes[VP8_YMODES]; +unsigned int i8x8_modes[VP8_I8X8_MODES]; +unsigned int uv_modes[VP8_UV_MODES]; +unsigned int uv_modes_y[VP8_YMODES][VP8_UV_MODES]; +unsigned int b_modes[B_MODE_COUNT]; #endif diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c index 1a174c125..a66e71af4 100644 --- a/vp8/encoder/onyx_if.c +++ b/vp8/encoder/onyx_if.c @@ -140,7 +140,7 @@ extern int skip_false_count; #ifdef ENTROPY_STATS -extern int intra_mode_stats[10][10][10]; +extern int intra_mode_stats[VP8_BINTRAMODES][VP8_BINTRAMODES][VP8_BINTRAMODES]; #endif #ifdef SPEEDSTATS @@ -156,13 +156,13 @@ extern unsigned __int64 Sectionbits[500]; #endif #ifdef MODE_STATS extern INT64 Sectionbits[500]; -extern int y_modes[VP8_YMODES] ; -extern int i8x8_modes[VP8_I8X8_MODES]; -extern int uv_modes[VP8_UV_MODES] ; -extern int uv_modes_y[VP8_YMODES][VP8_UV_MODES]; -extern int b_modes[B_MODE_COUNT]; -extern int inter_y_modes[MB_MODE_COUNT] ; -extern int inter_uv_modes[VP8_UV_MODES] ; +extern unsigned int y_modes[VP8_YMODES] ; +extern unsigned int i8x8_modes[VP8_I8X8_MODES]; +extern unsigned int uv_modes[VP8_UV_MODES] ; +extern unsigned int uv_modes_y[VP8_YMODES][VP8_UV_MODES]; +extern unsigned int b_modes[B_MODE_COUNT]; +extern unsigned int inter_y_modes[MB_MODE_COUNT] ; +extern unsigned int inter_uv_modes[VP8_UV_MODES] ; extern unsigned int inter_b_modes[B_MODE_COUNT]; #endif @@ -760,6 +760,14 @@ void vp8_set_speed_features(VP8_COMP *cpi) sf->thresh_mult[THR_V_PRED ] = 1000; sf->thresh_mult[THR_H_PRED ] = 1000; +#if CONFIG_NEWINTRAMODES + sf->thresh_mult[THR_D45_PRED ] = 1000; + sf->thresh_mult[THR_D135_PRED] = 1000; + sf->thresh_mult[THR_D117_PRED] = 1000; + sf->thresh_mult[THR_D153_PRED] = 1000; + sf->thresh_mult[THR_D27_PRED ] = 1000; + sf->thresh_mult[THR_D63_PRED ] = 1000; +#endif sf->thresh_mult[THR_B_PRED ] = 2000; sf->thresh_mult[THR_I8X8_PRED] = 2000; sf->thresh_mult[THR_TM ] = 1000; @@ -803,6 +811,14 @@ void vp8_set_speed_features(VP8_COMP *cpi) sf->thresh_mult[THR_NEARMV ] = 0; sf->thresh_mult[THR_V_PRED ] = 1000; sf->thresh_mult[THR_H_PRED ] = 1000; +#if CONFIG_NEWINTRAMODES + sf->thresh_mult[THR_D45_PRED ] = 1000; + sf->thresh_mult[THR_D135_PRED] = 1000; + sf->thresh_mult[THR_D117_PRED] = 1000; + sf->thresh_mult[THR_D153_PRED] = 1000; + sf->thresh_mult[THR_D27_PRED ] = 1000; + sf->thresh_mult[THR_D63_PRED ] = 1000; +#endif sf->thresh_mult[THR_B_PRED ] = 2500; sf->thresh_mult[THR_I8X8_PRED] = 2500; sf->thresh_mult[THR_TM ] = 1000; @@ -881,6 +897,14 @@ void vp8_set_speed_features(VP8_COMP *cpi) sf->thresh_mult[THR_TM ] = 1500; sf->thresh_mult[THR_V_PRED ] = 1500; sf->thresh_mult[THR_H_PRED ] = 1500; +#if CONFIG_NEWINTRAMODES + sf->thresh_mult[THR_D45_PRED ] = 1500; + sf->thresh_mult[THR_D135_PRED] = 1500; + sf->thresh_mult[THR_D117_PRED] = 1500; + sf->thresh_mult[THR_D153_PRED] = 1500; + sf->thresh_mult[THR_D27_PRED ] = 1500; + sf->thresh_mult[THR_D63_PRED ] = 1500; +#endif sf->thresh_mult[THR_B_PRED ] = 5000; sf->thresh_mult[THR_I8X8_PRED] = 5000; @@ -939,6 +963,14 @@ void vp8_set_speed_features(VP8_COMP *cpi) sf->thresh_mult[THR_TM ] = 2000; sf->thresh_mult[THR_V_PRED ] = 2000; sf->thresh_mult[THR_H_PRED ] = 2000; +#if CONFIG_NEWINTRAMODES + sf->thresh_mult[THR_D45_PRED ] = 2000; + sf->thresh_mult[THR_D135_PRED] = 2000; + sf->thresh_mult[THR_D117_PRED] = 2000; + sf->thresh_mult[THR_D153_PRED] = 2000; + sf->thresh_mult[THR_D27_PRED ] = 2000; + sf->thresh_mult[THR_D63_PRED ] = 2000; +#endif sf->thresh_mult[THR_B_PRED ] = 7500; sf->thresh_mult[THR_I8X8_PRED] = 7500; @@ -1719,6 +1751,16 @@ VP8_PTR vp8_create_compressor(VP8_CONFIG *oxcf) #ifdef ENTROPY_STATS init_context_counters(); #endif +#ifdef MODE_STATS + vp8_zero(y_modes); + vp8_zero(i8x8_modes); + vp8_zero(uv_modes); + vp8_zero(uv_modes_y); + vp8_zero(b_modes); + vp8_zero(inter_y_modes); + vp8_zero(inter_uv_modes); + vp8_zero(inter_b_modes); +#endif /*Initialize the feed-forward activity masking.*/ cpi->activity_avg = 90<<12; @@ -2006,32 +2048,49 @@ void vp8_remove_compressor(VP8_PTR *ptr) sprintf(modes_stats_file, "modes_q%03d.stt",cpi->common.base_qindex); f = fopen(modes_stats_file, "w"); fprintf(f, "intra_mode in Intra Frames:\n"); - fprintf(f, "Y: %8d, %8d, %8d, %8d, %8d, %8d\n", y_modes[0], y_modes[1], y_modes[2], y_modes[3], y_modes[4], y_modes[5]); - fprintf(f, "I8:%8d, %8d, %8d, %8d\n", i8x8_modes[0], i8x8_modes[1], i8x8_modes[2], i8x8_modes[3]); - fprintf(f, "UV:%8d, %8d, %8d, %8d\n", uv_modes[0], uv_modes[1], uv_modes[2], uv_modes[3]); - fprintf(f, "KeyFrame Y-UV:\n"); { int i; + fprintf(f, "Y: "); + for (i=0;iy_uv_mode_count[i][0], - cpi->y_uv_mode_count[i][1], cpi->y_uv_mode_count[i][2], cpi->y_uv_mode_count[i][3]); + fprintf(f, "%2d:", i); + for (j=0; jy_uv_mode_count[i][j]); + fprintf(f, "\n"); } } - fprintf(f, "B: "); { int i; - for (i = 0; i < 10; i++) + fprintf(f, "B: "); + for (i = 0; i < VP8_BINTRAMODES; i++) fprintf(f, "%8d, ", b_modes[i]); fprintf(f, "\n"); @@ -2039,23 +2098,23 @@ void vp8_remove_compressor(VP8_PTR *ptr) } fprintf(f, "Modes in Inter Frames:\n"); - fprintf(f, - "Y: %8d, %8d, %8d, %8d, %8d, %8d, %8d, %8d, %8d, %8d, %8d\n", - inter_y_modes[0], inter_y_modes[1], inter_y_modes[2], - inter_y_modes[3], inter_y_modes[4], inter_y_modes[5], - inter_y_modes[6], inter_y_modes[7], inter_y_modes[8], - inter_y_modes[9], inter_y_modes[10]); - fprintf(f, "UV:%8d, %8d, %8d, %8d\n", inter_uv_modes[0], - inter_uv_modes[1], inter_uv_modes[2], inter_uv_modes[3]); - fprintf(f, "B: "); { int i; - - for (i = 0; i < 15; i++) - fprintf(f, "%8d, ", inter_b_modes[i]); - + fprintf(f, "Y: "); + for (i=0;i