Add configurations for hbd identity transform

This adds the proper cfgs to av1_{inv/fwd}_txfm1d_cfg for
the identity transform so all hbd transforms can use
the same codepath. This has no impact on performance
since the new identity transforms that correspond with
the cfgs are not yet being called. Once this is checked in,
we should be able to delete all deprecated transform functions
and have a single code flow for all hbd transforms.

BUG=aomedia:524

Change-Id: I3d1bfbc8bc29b367e8ddf7dcd27525af0bd31067
diff --git a/av1/common/av1_fwd_txfm1d.c b/av1/common/av1_fwd_txfm1d.c
index 7b961aa..cfe2741 100644
--- a/av1/common/av1_fwd_txfm1d.c
+++ b/av1/common/av1_fwd_txfm1d.c
@@ -10,6 +10,7 @@
  */
 
 #include <stdlib.h>
+#include "aom_dsp/inv_txfm.h"
 #include "av1/common/av1_fwd_txfm1d.h"
 #if CONFIG_COEFFICIENT_RANGE_CHECKING
 
@@ -1516,6 +1517,38 @@
   range_check(stage, input, bf1, size, stage_range[stage]);
 }
 
+#if CONFIG_EXT_TX
+void av1_fidentity4_c(const int32_t *input, int32_t *output,
+                      const int8_t *cos_bit, const int8_t *stage_range) {
+  (void)cos_bit;
+  for (int i = 0; i < 4; ++i)
+    output[i] = (int32_t)dct_const_round_shift(input[i] * Sqrt2);
+  range_check(0, input, output, 4, stage_range[0]);
+}
+
+void av1_fidentity8_c(const int32_t *input, int32_t *output,
+                      const int8_t *cos_bit, const int8_t *stage_range) {
+  (void)cos_bit;
+  for (int i = 0; i < 8; ++i) output[i] = input[i] * 2;
+  range_check(0, input, output, 8, stage_range[0]);
+}
+
+void av1_fidentity16_c(const int32_t *input, int32_t *output,
+                       const int8_t *cos_bit, const int8_t *stage_range) {
+  (void)cos_bit;
+  for (int i = 0; i < 16; ++i)
+    output[i] = (int32_t)dct_const_round_shift(input[i] * 2 * Sqrt2);
+  range_check(0, input, output, 16, stage_range[0]);
+}
+
+void av1_fidentity32_c(const int32_t *input, int32_t *output,
+                       const int8_t *cos_bit, const int8_t *stage_range) {
+  (void)cos_bit;
+  for (int i = 0; i < 32; ++i) output[i] = input[i] * 4;
+  range_check(0, input, output, 32, stage_range[0]);
+}
+#endif  // CONFIG_EXT_TX
+
 #if CONFIG_TX64X64
 void av1_fdct64_new(const int32_t *input, int32_t *output,
                     const int8_t *cos_bit, const int8_t *stage_range) {
diff --git a/av1/common/av1_fwd_txfm1d.h b/av1/common/av1_fwd_txfm1d.h
index 9f24671..f641930 100644
--- a/av1/common/av1_fwd_txfm1d.h
+++ b/av1/common/av1_fwd_txfm1d.h
@@ -37,6 +37,16 @@
                      const int8_t *cos_bit, const int8_t *stage_range);
 void av1_fadst32_new(const int32_t *input, int32_t *output,
                      const int8_t *cos_bit, const int8_t *stage_range);
+#if CONFIG_EXT_TX
+void av1_fidentity4_c(const int32_t *input, int32_t *output,
+                      const int8_t *cos_bit, const int8_t *stage_range);
+void av1_fidentity8_c(const int32_t *input, int32_t *output,
+                      const int8_t *cos_bit, const int8_t *stage_range);
+void av1_fidentity16_c(const int32_t *input, int32_t *output,
+                       const int8_t *cos_bit, const int8_t *stage_range);
+void av1_fidentity32_c(const int32_t *input, int32_t *output,
+                       const int8_t *cos_bit, const int8_t *stage_range);
+#endif  // CONFIG_EXT_TX
 
 #ifdef __cplusplus
 }
diff --git a/av1/common/av1_fwd_txfm1d_cfg.h b/av1/common/av1_fwd_txfm1d_cfg.h
index 53ef60b..c794268 100644
--- a/av1/common/av1_fwd_txfm1d_cfg.h
+++ b/av1/common/av1_fwd_txfm1d_cfg.h
@@ -13,6 +13,9 @@
 #define AV1_FWD_TXFM2D_CFG_H_
 #include "av1/common/enums.h"
 #include "av1/common/av1_fwd_txfm1d.h"
+// Identity will always use max bitdepth regardless of size
+static const int8_t fwd_stage_range_identity[1] = { 12 };
+
 //  ---------------- 4x4 1D constants -----------------------
 // shift
 static const int8_t fwd_shift_4[3] = { 2, 0, 0 };
@@ -311,4 +314,51 @@
   fwd_cos_bit_col_adst_32,      // .cos_bit
   TXFM_TYPE_ADST32,             // .txfm_type
 };
+
+#if CONFIG_EXT_TX
+// identity does not need to differentiate between row and col
+//  ---------------- row/col config fwd_identity_4 ----------
+static const TXFM_1D_CFG fwd_txfm_1d_cfg_identity_4 = {
+  4,  // .txfm_size
+  1,  // .stage_num
+  // 0,  // .log_scale
+  fwd_shift_4,               // .shift
+  fwd_stage_range_identity,  // .stage_range
+  NULL,                      // .cos_bit
+  TXFM_TYPE_IDENTITY4,       // .txfm_type
+};
+
+//  ---------------- row/col config fwd_identity_8 ----------------
+static const TXFM_1D_CFG fwd_txfm_1d_cfg_identity_8 = {
+  8,  // .txfm_size
+  1,  // .stage_num
+  // 0,  // .log_scale
+  fwd_shift_8,               // .shift
+  fwd_stage_range_identity,  // .stage_range
+  NULL,                      // .cos_bit
+  TXFM_TYPE_IDENTITY8,       // .txfm_type
+};
+
+//  ---------------- row/col config fwd_identity_16 ----------------
+static const TXFM_1D_CFG fwd_txfm_1d_cfg_identity_16 = {
+  16,  // .txfm_size
+  1,   // .stage_num
+  // 0,  // .log_scale
+  fwd_shift_16,              // .shift
+  fwd_stage_range_identity,  // .stage_range
+  NULL,                      // .cos_bit
+  TXFM_TYPE_IDENTITY16,      // .txfm_type
+};
+
+//  ---------------- row/col config fwd_identity_32 ----------------
+static const TXFM_1D_CFG fwd_txfm_1d_cfg_identity_32 = {
+  32,  // .txfm_size
+  1,   // .stage_num
+  // 1,  // .log_scale
+  fwd_shift_32,              // .shift
+  fwd_stage_range_identity,  // .stage_range
+  NULL,                      // .cos_bit
+  TXFM_TYPE_IDENTITY32,      // .txfm_type
+};
+#endif  // CONFIG_EXT_TX
 #endif  // AV1_FWD_TXFM2D_CFG_H_
diff --git a/av1/common/av1_fwd_txfm2d.c b/av1/common/av1_fwd_txfm2d.c
index 5ee4691..96443ac 100644
--- a/av1/common/av1_fwd_txfm2d.c
+++ b/av1/common/av1_fwd_txfm2d.c
@@ -27,6 +27,12 @@
     case TXFM_TYPE_ADST8: return av1_fadst8_new;
     case TXFM_TYPE_ADST16: return av1_fadst16_new;
     case TXFM_TYPE_ADST32: return av1_fadst32_new;
+#if CONFIG_EXT_TX
+    case TXFM_TYPE_IDENTITY4: return av1_fidentity4_c;
+    case TXFM_TYPE_IDENTITY8: return av1_fidentity8_c;
+    case TXFM_TYPE_IDENTITY16: return av1_fidentity16_c;
+    case TXFM_TYPE_IDENTITY32: return av1_fidentity32_c;
+#endif  // CONFIG_EXT_TX
     default: assert(0); return NULL;
   }
 }
@@ -141,13 +147,13 @@
 #endif
       &fwd_txfm_1d_col_cfg_adst_4, &fwd_txfm_1d_col_cfg_adst_8,
       &fwd_txfm_1d_col_cfg_adst_16, &fwd_txfm_1d_col_cfg_adst_32 },
-  // IDENTITY PLACEHOLDER
+  // IDENTITY
   {
 #if CONFIG_CB4X4
       NULL,
 #endif
-      &fwd_txfm_1d_col_cfg_adst_4, &fwd_txfm_1d_col_cfg_adst_8,
-      &fwd_txfm_1d_col_cfg_adst_16, &fwd_txfm_1d_col_cfg_adst_32 },
+      &fwd_txfm_1d_cfg_identity_4, &fwd_txfm_1d_cfg_identity_8,
+      &fwd_txfm_1d_cfg_identity_16, &fwd_txfm_1d_cfg_identity_32 },
 #endif  // CONFIG_EXT_TX
 };
 
@@ -174,13 +180,13 @@
 #endif
       &fwd_txfm_1d_row_cfg_adst_4, &fwd_txfm_1d_row_cfg_adst_8,
       &fwd_txfm_1d_row_cfg_adst_16, &fwd_txfm_1d_row_cfg_adst_32 },
-  // IDENTITY PLACEHOLDER
+  // IDENTITY
   {
 #if CONFIG_CB4X4
       NULL,
 #endif
-      &fwd_txfm_1d_row_cfg_adst_4, &fwd_txfm_1d_row_cfg_adst_8,
-      &fwd_txfm_1d_row_cfg_adst_16, &fwd_txfm_1d_row_cfg_adst_32 },
+      &fwd_txfm_1d_cfg_identity_4, &fwd_txfm_1d_cfg_identity_8,
+      &fwd_txfm_1d_cfg_identity_16, &fwd_txfm_1d_cfg_identity_32 },
 #endif  // CONFIG_EXT_TX
 };
 
diff --git a/av1/common/av1_inv_txfm1d.c b/av1/common/av1_inv_txfm1d.c
index a07d79e..e9f04d3 100644
--- a/av1/common/av1_inv_txfm1d.c
+++ b/av1/common/av1_inv_txfm1d.c
@@ -10,6 +10,7 @@
  */
 
 #include <stdlib.h>
+#include "aom_dsp/inv_txfm.h"
 #include "av1/common/av1_inv_txfm1d.h"
 #if CONFIG_COEFFICIENT_RANGE_CHECKING
 
@@ -1538,6 +1539,38 @@
   range_check(stage, input, bf1, size, stage_range[stage]);
 }
 
+#if CONFIG_EXT_TX
+void av1_iidentity4_c(const int32_t *input, int32_t *output,
+                      const int8_t *cos_bit, const int8_t *stage_range) {
+  (void)cos_bit;
+  for (int i = 0; i < 4; ++i)
+    output[i] = (int32_t)dct_const_round_shift(input[i] * Sqrt2);
+  range_check(0, input, output, 4, stage_range[0]);
+}
+
+void av1_iidentity8_c(const int32_t *input, int32_t *output,
+                      const int8_t *cos_bit, const int8_t *stage_range) {
+  (void)cos_bit;
+  for (int i = 0; i < 8; ++i) output[i] = input[i] * 2;
+  range_check(0, input, output, 8, stage_range[0]);
+}
+
+void av1_iidentity16_c(const int32_t *input, int32_t *output,
+                       const int8_t *cos_bit, const int8_t *stage_range) {
+  (void)cos_bit;
+  for (int i = 0; i < 16; ++i)
+    output[i] = (int32_t)dct_const_round_shift(input[i] * 2 * Sqrt2);
+  range_check(0, input, output, 16, stage_range[0]);
+}
+
+void av1_iidentity32_c(const int32_t *input, int32_t *output,
+                       const int8_t *cos_bit, const int8_t *stage_range) {
+  (void)cos_bit;
+  for (int i = 0; i < 32; ++i) output[i] = input[i] * 4;
+  range_check(0, input, output, 32, stage_range[0]);
+}
+#endif  // CONFIG_EXT_TX
+
 #if CONFIG_TX64X64
 void av1_idct64_new(const int32_t *input, int32_t *output,
                     const int8_t *cos_bit, const int8_t *stage_range) {
diff --git a/av1/common/av1_inv_txfm1d.h b/av1/common/av1_inv_txfm1d.h
index 9e7a232..037a3c6 100644
--- a/av1/common/av1_inv_txfm1d.h
+++ b/av1/common/av1_inv_txfm1d.h
@@ -37,6 +37,16 @@
                      const int8_t *cos_bit, const int8_t *stage_range);
 void av1_iadst32_new(const int32_t *input, int32_t *output,
                      const int8_t *cos_bit, const int8_t *stage_range);
+#if CONFIG_EXT_TX
+void av1_iidentity4_c(const int32_t *input, int32_t *output,
+                      const int8_t *cos_bit, const int8_t *stage_range);
+void av1_iidentity8_c(const int32_t *input, int32_t *output,
+                      const int8_t *cos_bit, const int8_t *stage_range);
+void av1_iidentity16_c(const int32_t *input, int32_t *output,
+                       const int8_t *cos_bit, const int8_t *stage_range);
+void av1_iidentity32_c(const int32_t *input, int32_t *output,
+                       const int8_t *cos_bit, const int8_t *stage_range);
+#endif  // CONFIG_EXT_TX
 
 #ifdef __cplusplus
 }
diff --git a/av1/common/av1_inv_txfm1d_cfg.h b/av1/common/av1_inv_txfm1d_cfg.h
index bd0cc65..04d2b3b 100644
--- a/av1/common/av1_inv_txfm1d_cfg.h
+++ b/av1/common/av1_inv_txfm1d_cfg.h
@@ -12,6 +12,9 @@
 #ifndef AV1_INV_TXFM2D_CFG_H_
 #define AV1_INV_TXFM2D_CFG_H_
 #include "av1/common/av1_inv_txfm1d.h"
+// Identity will always use max bitdepth regardless of size
+static const int8_t inv_stage_range_identity[1] = { 12 };
+
 //  ---------------- 4x4 1D config -----------------------
 // shift
 static const int8_t inv_shift_4[2] = { 0, -4 };
@@ -309,4 +312,51 @@
   inv_cos_bit_col_adst_32,      // .cos_bit
   TXFM_TYPE_ADST32,             // .txfm_type
 };
+
+#if CONFIG_EXT_TX
+// identity does not need to differentiate between row and col
+//  ---------------- row/col config inv_identity_4 ----------
+static const TXFM_1D_CFG inv_txfm_1d_cfg_identity_4 = {
+  4,  // .txfm_size
+  1,  // .stage_num
+  // 0,  // .log_scale
+  inv_shift_4,               // .shift
+  inv_stage_range_identity,  // .stage_range
+  NULL,                      // .cos_bit
+  TXFM_TYPE_IDENTITY4,       // .txfm_type
+};
+
+//  ---------------- row/col config inv_identity_8 ----------------
+static const TXFM_1D_CFG inv_txfm_1d_cfg_identity_8 = {
+  8,  // .txfm_size
+  1,  // .stage_num
+  // 0,  // .log_scale
+  inv_shift_8,               // .shift
+  inv_stage_range_identity,  // .stage_range
+  NULL,                      // .cos_bit
+  TXFM_TYPE_IDENTITY8,       // .txfm_type
+};
+
+//  ---------------- row/col config inv_identity_16 ----------------
+static const TXFM_1D_CFG inv_txfm_1d_cfg_identity_16 = {
+  16,  // .txfm_size
+  1,   // .stage_num
+  // 0,  // .log_scale
+  inv_shift_16,              // .shift
+  inv_stage_range_identity,  // .stage_range
+  NULL,                      // .cos_bit
+  TXFM_TYPE_IDENTITY16,      // .txfm_type
+};
+
+//  ---------------- row/col config inv_identity_32 ----------------
+static const TXFM_1D_CFG inv_txfm_1d_cfg_identity_32 = {
+  32,  // .txfm_size
+  1,   // .stage_num
+  // 1,  // .log_scale
+  inv_shift_32,              // .shift
+  inv_stage_range_identity,  // .stage_range
+  NULL,                      // .cos_bit
+  TXFM_TYPE_IDENTITY32,      // .txfm_type
+};
+#endif  // CONFIG_EXT_TX
 #endif  // AV1_INV_TXFM2D_CFG_H_
diff --git a/av1/common/av1_inv_txfm2d.c b/av1/common/av1_inv_txfm2d.c
index 197b9d1..6191053 100644
--- a/av1/common/av1_inv_txfm2d.c
+++ b/av1/common/av1_inv_txfm2d.c
@@ -25,6 +25,12 @@
     case TXFM_TYPE_ADST8: return av1_iadst8_new;
     case TXFM_TYPE_ADST16: return av1_iadst16_new;
     case TXFM_TYPE_ADST32: return av1_iadst32_new;
+#if CONFIG_EXT_TX
+    case TXFM_TYPE_IDENTITY4: return av1_iidentity4_c;
+    case TXFM_TYPE_IDENTITY8: return av1_iidentity8_c;
+    case TXFM_TYPE_IDENTITY16: return av1_iidentity16_c;
+    case TXFM_TYPE_IDENTITY32: return av1_iidentity32_c;
+#endif  // CONFIG_EXT_TX
     default: assert(0); return NULL;
   }
 }
@@ -52,13 +58,13 @@
 #endif
       &inv_txfm_1d_col_cfg_adst_4, &inv_txfm_1d_col_cfg_adst_8,
       &inv_txfm_1d_col_cfg_adst_16, &inv_txfm_1d_col_cfg_adst_32 },
-  // IDENTITY PLACEHOLDER
+  // IDENTITY
   {
 #if CONFIG_CB4X4
       NULL,
 #endif
-      &inv_txfm_1d_col_cfg_adst_4, &inv_txfm_1d_col_cfg_adst_8,
-      &inv_txfm_1d_col_cfg_adst_16, &inv_txfm_1d_col_cfg_adst_32 },
+      &inv_txfm_1d_cfg_identity_4, &inv_txfm_1d_cfg_identity_8,
+      &inv_txfm_1d_cfg_identity_16, &inv_txfm_1d_cfg_identity_32 },
 #endif  // CONFIG_EXT_TX
 };
 
@@ -85,13 +91,13 @@
 #endif
       &inv_txfm_1d_row_cfg_adst_4, &inv_txfm_1d_row_cfg_adst_8,
       &inv_txfm_1d_row_cfg_adst_16, &inv_txfm_1d_row_cfg_adst_32 },
-  // IDENTITY PLACEHOLDER
+  // IDENTITY
   {
 #if CONFIG_CB4X4
       NULL,
 #endif
-      &inv_txfm_1d_row_cfg_adst_4, &inv_txfm_1d_row_cfg_adst_8,
-      &inv_txfm_1d_row_cfg_adst_16, &inv_txfm_1d_row_cfg_adst_32 },
+      &inv_txfm_1d_cfg_identity_4, &inv_txfm_1d_cfg_identity_8,
+      &inv_txfm_1d_cfg_identity_16, &inv_txfm_1d_cfg_identity_32 },
 #endif  // CONFIG_EXT_TX
 };
 
diff --git a/av1/common/av1_txfm.h b/av1/common/av1_txfm.h
index 0666769..b341cb7 100644
--- a/av1/common/av1_txfm.h
+++ b/av1/common/av1_txfm.h
@@ -143,6 +143,10 @@
   TXFM_TYPE_ADST8,
   TXFM_TYPE_ADST16,
   TXFM_TYPE_ADST32,
+  TXFM_TYPE_IDENTITY4,
+  TXFM_TYPE_IDENTITY8,
+  TXFM_TYPE_IDENTITY16,
+  TXFM_TYPE_IDENTITY32,
 } TXFM_TYPE;
 
 typedef struct TXFM_1D_CFG {
@@ -172,13 +176,23 @@
       cfg->lr_flip = 0;
       break;
 #if CONFIG_EXT_TX
+    case IDTX:
+    case V_DCT:
+    case H_DCT:
+    case V_ADST:
+    case H_ADST:
+      cfg->ud_flip = 0;
+      cfg->lr_flip = 0;
+      break;
     case FLIPADST_DCT:
     case FLIPADST_ADST:
+    case V_FLIPADST:
       cfg->ud_flip = 1;
       cfg->lr_flip = 0;
       break;
     case DCT_FLIPADST:
     case ADST_FLIPADST:
+    case H_FLIPADST:
       cfg->ud_flip = 0;
       cfg->lr_flip = 1;
       break;
diff --git a/av1/common/idct.c b/av1/common/idct.c
index 5275df5..e3aad5a 100644
--- a/av1/common/idct.c
+++ b/av1/common/idct.c
@@ -115,6 +115,10 @@
 
 #if CONFIG_HIGHBITDEPTH
 #if CONFIG_EXT_TX
+// TODO(sarahparker) these functions will be removed once the highbitdepth
+// codepath works properly for rectangular transforms. They have almost
+// identical versions in av1_inv_txfm1d.c, but those are currently only
+// being used for square transforms.
 static void highbd_iidtx4_c(const tran_low_t *input, tran_low_t *output,
                             int bd) {
   int i;
diff --git a/av1/encoder/dct.c b/av1/encoder/dct.c
index 412363e..049cc2b 100644
--- a/av1/encoder/dct.c
+++ b/av1/encoder/dct.c
@@ -1022,6 +1022,10 @@
 }
 
 #if CONFIG_EXT_TX
+// TODO(sarahparker) these functions will be removed once the highbitdepth
+// codepath works properly for rectangular transforms. They have almost
+// identical versions in av1_fwd_txfm1d.c, but those are currently only
+// being used for square transforms.
 static void fidtx4(const tran_low_t *input, tran_low_t *output) {
   int i;
   for (i = 0; i < 4; ++i)