Redesigned recursive filters adapted to block-sizes

Recursive intra filters for 4x4 and 8x8 blocks are separately designed.
Fixed bugs in rd loop.

Change-Id: Id0b1752769f596ce8ea850863cadbc6a739804be
diff --git a/vp9/common/vp9_entropymode.c b/vp9/common/vp9_entropymode.c
index aaac4d9..bc4c6fd 100644
--- a/vp9/common/vp9_entropymode.c
+++ b/vp9/common/vp9_entropymode.c
@@ -217,8 +217,8 @@
 #if CONFIG_FILTERINTRA
 const vp9_prob vp9_default_filterintra_prob[TX_SIZES][VP9_INTRA_MODES] = {
   // DC   V    H    D45  D135 D117 D153 D27  D63  TM
-    {160, 160, 160, 160, 160, 160, 160, 160, 160, 160},  // TX_4X4
-    {180, 180, 180, 180, 180, 180, 180, 180, 180, 180},  // TX_8X8
+    {160, 153, 171, 160, 140, 117, 115, 160, 160, 116},  // TX_4X4
+    {180, 151, 191, 180, 118,  66,  97, 180, 180, 120},  // TX_8X8
     {200, 200, 200, 200, 200, 200, 200, 200, 200, 200},  // TX_16X16
     {220, 220, 220, 220, 220, 220, 220, 220, 220, 220},  // TX_32X32
 };
diff --git a/vp9/common/vp9_reconintra.c b/vp9/common/vp9_reconintra.c
index a8bd656..46d4fdb 100644
--- a/vp9/common/vp9_reconintra.c
+++ b/vp9/common/vp9_reconintra.c
@@ -408,23 +408,36 @@
   static const int prec_bits = 10;
   static const int round_val = 511;
   static const int taps[10][3] = {
-      {438 , 660, -352},  // DC
-      {1014, 565, -559},  // V
-      {312, 1017, -312},  // H
-      {0, 0, 0},          // D45
-      {478, 483, 153},    // D135
-      {699, 470, -122},   // D117
-      {356, 707, 35},     // D153
-      {0, 0, 0},          // D27
-      {0, 0, 0},          // D63
-      {877, 896, -812}    // TM
-      };
+      {   0,   0,    0},  // DC
+      { 972, 563, -534},  // V
+      { 441, 975, -417},  // H
+      {   0,   0,    0},  // D45
+      { 502, 546,  -48},  // D135
+      { 744, 523, -259},  // D117
+      { 379, 760,  -73},  // D153
+      {   0,   0,    0},  // D27
+      {   0,   0,    0},  // D63
+      { 783, 839, -687},  // TM
+  };
+  static const int taps8x8[10][3] = {
+      {  0,    0,    0},  // DC
+      {991,  655, -637},  // V
+      {522,  987, -493},  // H
+      {  0,    0,    0},  // d45
+      {551,  608, -193},  // d135
+      {762,  612, -392},  // d117
+      {492,  781, -260},  // d153
+      {  0,    0,    0},  // d27
+      {  0,    0,    0},  // d63
+      {823,  873, -715},  // TM
+  };
+
   int k, r, c;
   int pred[17][17];
   int mean, ipred;
-  const int c1 = taps[mode][0];
-  const int c2 = taps[mode][1];
-  const int c3 = taps[mode][2];
+  const int c1 = (bs == 4) ? taps[mode][0]: taps8x8[mode][0];
+  const int c2 = (bs == 4) ? taps[mode][1]: taps8x8[mode][1];
+  const int c3 = (bs == 4) ? taps[mode][2]: taps8x8[mode][2];
 
   k = 0;
   mean = 0;
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index d257482..37b3644 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -1498,7 +1498,10 @@
 
   x->e_mbd.mode_info_context->mbmi.mode = mode_selected;
 #if CONFIG_FILTERINTRA
-  x->e_mbd.mode_info_context->mbmi.filterbit = fbit_selected;
+  if (best_tx <= TX_8X8)
+    x->e_mbd.mode_info_context->mbmi.filterbit = fbit_selected;
+  else
+    x->e_mbd.mode_info_context->mbmi.filterbit = 0;
 #endif
   x->e_mbd.mode_info_context->mbmi.txfm_size = best_tx;
 
@@ -1558,8 +1561,7 @@
 
     if (fbit && !is_filter_allowed(mode))
       continue;
-    if (fbit && is_filter_allowed(mode) &&
-        (get_uv_tx_size(&(x->e_mbd.mode_info_context->mbmi)) != TX_4X4))
+    if (fbit && (get_uv_tx_size(&(x->e_mbd.mode_info_context->mbmi)) > TX_8X8))
       continue;
 
     x->e_mbd.mode_info_context->mbmi.uv_filterbit = fbit;