Commit 2afe7320 authored by hui su's avatar hui su

Add identity transform to ext-tx experiment

ext-tx on derflr: +1.756% (was +1.648)

Change-Id: I8a87970fa589e8f5f96db7aa68ec9b6c98e20188
parent 4b7043f8
......@@ -249,6 +249,7 @@ static TX_TYPE ext_tx_to_txtype[EXT_TX_TYPES] = {
DST_FLIPADST,
FLIPADST_DST,
DST_DST,
IDTX,
};
#endif // CONFIG_EXT_TX
......
......@@ -316,27 +316,31 @@ static const vpx_prob default_switchable_interp_prob[SWITCHABLE_FILTER_CONTEXTS]
#if CONFIG_EXT_TX
const vpx_tree_index vp10_ext_tx_tree[TREE_SIZE(EXT_TX_TYPES)] = {
-NORM, 2,
-ALT15, 4,
6, 16,
8, 10,
-ALT16, 2
-NORM, 4,
-ALT15, 6,
8, 18,
10, 12,
-ALT9, -ALT10,
12, 14,
14, 16,
-ALT1, -ALT2,
-ALT4, -ALT5,
18, 24,
20, 22,
20, 26,
22, 24,
-ALT11, -ALT12,
-ALT13, -ALT14,
26, 28,
28, 30,
-ALT3, -ALT6,
-ALT7, -ALT8
};
static const vpx_prob default_ext_tx_prob[EXT_TX_SIZES][EXT_TX_TYPES - 1] = {
{ 112, 16, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 112, 16, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 112, 16, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 12, 112, 16, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128 },
{ 12, 112, 16, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128 },
{ 12, 112, 16, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128 },
};
#endif // CONFIG_EXT_TX
......
......@@ -107,6 +107,7 @@ typedef enum {
DST_FLIPADST = 13,
FLIPADST_DST = 14,
DST_DST = 15,
IDTX = 16,
#endif // CONFIG_EXT_TX
TX_TYPES,
} TX_TYPE;
......@@ -130,6 +131,7 @@ typedef enum {
ALT13 = 13,
ALT14 = 14,
ALT15 = 15,
ALT16 = 16,
EXT_TX_TYPES
} EXT_TX_TYPE;
#endif // CONFIG_EXT_TX
......
......@@ -181,6 +181,52 @@ void idst16_c(const tran_low_t *input, tran_low_t *output) {
output[15] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
}
static void fliplr(uint8_t *dest, int stride, int l) {
int i, j;
for (i = 0; i < l; ++i) {
for (j = 0; j < l / 2; ++j) {
const uint8_t tmp = dest[i * stride + j];
dest[i * stride + j] = dest[i * stride + l - 1 - j];
dest[i * stride + l - 1 - j] = tmp;
}
}
}
static void flipud(uint8_t *dest, int stride, int l) {
int i, j;
for (j = 0; j < l; ++j) {
for (i = 0; i < l / 2; ++i) {
const uint8_t tmp = dest[i * stride + j];
dest[i * stride + j] = dest[(l - 1 - i) * stride + j];
dest[(l - 1 - i) * stride + j] = tmp;
}
}
}
static void fliplrud(uint8_t *dest, int stride, int l) {
int i, j;
for (i = 0; i < l / 2; ++i) {
for (j = 0; j < l; ++j) {
const uint8_t tmp = dest[i * stride + j];
dest[i * stride + j] = dest[(l - 1 - i) * stride + l - 1 - j];
dest[(l - 1 - i) * stride + l - 1 - j] = tmp;
}
}
}
// Inverse identiy transform and add.
static void inv_idtx_add_c(const tran_low_t *input, uint8_t *dest, int stride,
int bs) {
int r, c;
const int shift = bs < 32 ? 3 : 2;
for (r = 0; r < bs; ++r) {
for (c = 0; c < bs; ++c)
dest[c] = clip_pixel_add(dest[c], input[c] >> shift);
dest += stride;
input += bs;
}
}
#if CONFIG_VP9_HIGHBITDEPTH
void highbd_idst4_c(const tran_low_t *input, tran_low_t *output, int bd) {
// {sin(pi/5), sin(pi*2/5)} * sqrt(2/5) * sqrt(2)
......@@ -346,79 +392,58 @@ void highbd_idst16_c(const tran_low_t *input, tran_low_t *output, int bd) {
d69 * sinvalue_lookup[6] - d78 * sinvalue_lookup[7];
output[15] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
}
#endif // CONFIG_VP9_HIGHBITDEPTH
#endif // CONFIG_EXT_TX
#if CONFIG_EXT_TX
void fliplr(uint8_t *dest, int stride, int l) {
static void fliplr16(uint16_t *dest, int stride, int l) {
int i, j;
for (i = 0; i < l; ++i) {
for (j = 0; j < l / 2; ++j) {
const uint8_t tmp = dest[i * stride + j];
const uint16_t tmp = dest[i * stride + j];
dest[i * stride + j] = dest[i * stride + l - 1 - j];
dest[i * stride + l - 1 - j] = tmp;
}
}
}
void flipud(uint8_t *dest, int stride, int l) {
static void flipud16(uint16_t *dest, int stride, int l) {
int i, j;
for (j = 0; j < l; ++j) {
for (i = 0; i < l / 2; ++i) {
const uint8_t tmp = dest[i * stride + j];
const uint16_t tmp = dest[i * stride + j];
dest[i * stride + j] = dest[(l - 1 - i) * stride + j];
dest[(l - 1 - i) * stride + j] = tmp;
}
}
}
void fliplrud(uint8_t *dest, int stride, int l) {
static void fliplrud16(uint16_t *dest, int stride, int l) {
int i, j;
for (i = 0; i < l / 2; ++i) {
for (j = 0; j < l; ++j) {
const uint8_t tmp = dest[i * stride + j];
const uint16_t tmp = dest[i * stride + j];
dest[i * stride + j] = dest[(l - 1 - i) * stride + l - 1 - j];
dest[(l - 1 - i) * stride + l - 1 - j] = tmp;
}
}
}
void fliplr16(uint16_t *dest, int stride, int l) {
int i, j;
for (i = 0; i < l; ++i) {
for (j = 0; j < l / 2; ++j) {
const uint16_t tmp = dest[i * stride + j];
dest[i * stride + j] = dest[i * stride + l - 1 - j];
dest[i * stride + l - 1 - j] = tmp;
}
}
}
void flipud16(uint16_t *dest, int stride, int l) {
int i, j;
for (j = 0; j < l; ++j) {
for (i = 0; i < l / 2; ++i) {
const uint16_t tmp = dest[i * stride + j];
dest[i * stride + j] = dest[(l - 1 - i) * stride + j];
dest[(l - 1 - i) * stride + j] = tmp;
}
}
}
static void highbd_inv_idtx_add_c(const tran_low_t *input, uint8_t *dest8,
int stride, int bs, int bd) {
int r, c;
const int shift = bs < 32 ? 3 : 2;
uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
void fliplrud16(uint16_t *dest, int stride, int l) {
int i, j;
for (i = 0; i < l / 2; ++i) {
for (j = 0; j < l; ++j) {
const uint16_t tmp = dest[i * stride + j];
dest[i * stride + j] = dest[(l - 1 - i) * stride + l - 1 - j];
dest[(l - 1 - i) * stride + l - 1 - j] = tmp;
}
for (r = 0; r < bs; ++r) {
for (c = 0; c < bs; ++c)
dest[c] = highbd_clip_pixel_add(dest[c], input[c] >> shift, bd);
dest += stride;
input += bs;
}
}
#endif // CONFIG_VP9_HIGHBITDEPTH
#endif // CONFIG_EXT_TX
void vp10_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int stride,
int tx_type) {
int tx_type) {
const transform_2d IHT_4[] = {
{ idct4_c, idct4_c }, // DCT_DCT = 0
{ iadst4_c, idct4_c }, // ADST_DCT = 1
......@@ -679,6 +704,9 @@ void vp10_inv_txfm_add_4x4(const tran_low_t *input, uint8_t *dest,
vp10_iht4x4_16_add_c(input, dest, stride, DST_ADST);
fliplr(dest, stride, 4);
break;
case IDTX:
inv_idtx_add_c(input, dest, stride, 4);
break;
#endif // CONFIG_EXT_TX
default:
assert(0);
......@@ -742,6 +770,9 @@ void vp10_inv_txfm_add_8x8(const tran_low_t *input, uint8_t *dest,
vp10_iht8x8_64_add_c(input, dest, stride, DST_ADST);
fliplr(dest, stride, 8);
break;
case IDTX:
inv_idtx_add_c(input, dest, stride, 8);
break;
#endif // CONFIG_EXT_TX
default:
assert(0);
......@@ -804,6 +835,9 @@ void vp10_inv_txfm_add_16x16(const tran_low_t *input, uint8_t *dest,
vp10_iht16x16_256_add_c(input, dest, stride, DST_ADST);
fliplr(dest, stride, 16);
break;
case IDTX:
inv_idtx_add_c(input, dest, stride, 16);
break;
#endif // CONFIG_EXT_TX
default:
assert(0);
......@@ -1098,6 +1132,9 @@ void vp10_highbd_inv_txfm_add_4x4(const tran_low_t *input, uint8_t *dest,
vp10_highbd_iht4x4_16_add_c(input, dest, stride, DST_ADST, bd);
fliplr16(CONVERT_TO_SHORTPTR(dest), stride, 4);
break;
case IDTX:
highbd_inv_idtx_add_c(input, dest, stride, 4, bd);
break;
#endif // CONFIG_EXT_TX
default:
assert(0);
......@@ -1162,6 +1199,9 @@ void vp10_highbd_inv_txfm_add_8x8(const tran_low_t *input, uint8_t *dest,
vp10_highbd_iht8x8_64_add_c(input, dest, stride, DST_ADST, bd);
fliplr16(CONVERT_TO_SHORTPTR(dest), stride, 8);
break;
case IDTX:
highbd_inv_idtx_add_c(input, dest, stride, 8, bd);
break;
#endif // CONFIG_EXT_TX
default:
assert(0);
......@@ -1225,6 +1265,9 @@ void vp10_highbd_inv_txfm_add_16x16(const tran_low_t *input, uint8_t *dest,
vp10_highbd_iht16x16_256_add_c(input, dest, stride, DST_ADST, bd);
fliplr16(CONVERT_TO_SHORTPTR(dest), stride, 16);
break;
case IDTX:
highbd_inv_idtx_add_c(input, dest, stride, 16, bd);
break;
#endif // CONFIG_EXT_TX
default:
assert(0);
......
This diff is collapsed.
......@@ -385,6 +385,20 @@ static void copy_fliplrud(const int16_t *src, int src_stride, int l,
copy_block(src, src_stride, l, dest, dest_stride);
fliplrud(dest, dest_stride, l);
}
// Forward identity transform.
static void fwd_idtx_c(const int16_t *src_diff, tran_low_t *coeff, int stride,
int bs) {
int r, c;
const int shift = bs < 32 ? 3 : 2;
for (r = 0; r < bs; ++r) {
for (c = 0; c < bs; ++c)
coeff[c] = src_diff[c] << shift;
src_diff += stride;
coeff += bs;
}
}
#endif // CONFIG_EXT_TX
void vp10_fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff,
......@@ -441,6 +455,9 @@ void vp10_fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff,
copy_flipud(src_diff, diff_stride, 4, src_diff2, 4);
vp10_fht4x4_c(src_diff2, coeff, 4, ADST_DST);
break;
case IDTX:
fwd_idtx_c(src_diff, coeff, diff_stride, 4);
break;
#endif // CONFIG_EXT_TX
default:
assert(0);
......@@ -498,6 +515,9 @@ static void fwd_txfm_8x8(const int16_t *src_diff, tran_low_t *coeff,
copy_flipud(src_diff, diff_stride, 8, src_diff2, 8);
vp10_fht8x8_c(src_diff2, coeff, 8, ADST_DST);
break;
case IDTX:
fwd_idtx_c(src_diff, coeff, diff_stride, 8);
break;
#endif // CONFIG_EXT_TX
default:
assert(0);
......@@ -554,6 +574,9 @@ static void fwd_txfm_8x8_1(const int16_t *src_diff, tran_low_t *coeff,
copy_flipud(src_diff, diff_stride, 8, src_diff2, 8);
vp10_fht8x8_c(src_diff2, coeff, 8, ADST_DST);
break;
case IDTX:
fwd_idtx_c(src_diff, coeff, diff_stride, 8);
break;
#endif // CONFIG_EXT_TX
default:
assert(0);
......@@ -610,6 +633,9 @@ static void fwd_txfm_16x16(const int16_t *src_diff, tran_low_t *coeff,
copy_flipud(src_diff, diff_stride, 16, src_diff2, 16);
vp10_fht16x16_c(src_diff2, coeff, 16, ADST_DST);
break;
case IDTX:
fwd_idtx_c(src_diff, coeff, diff_stride, 16);
break;
#endif // CONFIG_EXT_TX
default:
assert(0);
......@@ -666,6 +692,9 @@ static void fwd_txfm_16x16_1(const int16_t *src_diff, tran_low_t *coeff,
copy_flipud(src_diff, diff_stride, 16, src_diff2, 16);
vp10_fht16x16_c(src_diff2, coeff, 16, ADST_DST);
break;
case IDTX:
fwd_idtx_c(src_diff, coeff, diff_stride, 16);
break;
#endif // CONFIG_EXT_TX
default:
assert(0);
......@@ -765,6 +794,9 @@ void vp10_highbd_fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff,
copy_flipud(src_diff, diff_stride, 4, src_diff2, 4);
vp10_highbd_fht4x4_c(src_diff2, coeff, 4, ADST_DST);
break;
case IDTX:
fwd_idtx_c(src_diff, coeff, diff_stride, 4);
break;
#endif // CONFIG_EXT_TX
default:
assert(0);
......@@ -824,6 +856,9 @@ static void highbd_fwd_txfm_8x8(const int16_t *src_diff, tran_low_t *coeff,
copy_flipud(src_diff, diff_stride, 8, src_diff2, 8);
vp10_highbd_fht8x8_c(src_diff2, coeff, 8, ADST_DST);
break;
case IDTX:
fwd_idtx_c(src_diff, coeff, diff_stride, 8);
break;
#endif // CONFIG_EXT_TX
default:
assert(0);
......@@ -882,6 +917,9 @@ static void highbd_fwd_txfm_8x8_1(const int16_t *src_diff, tran_low_t *coeff,
copy_flipud(src_diff, diff_stride, 8, src_diff2, 8);
vp10_highbd_fht8x8_c(src_diff2, coeff, 8, ADST_DST);
break;
case IDTX:
fwd_idtx_c(src_diff, coeff, diff_stride, 8);
break;
#endif // CONFIG_EXT_TX
default:
assert(0);
......@@ -940,6 +978,9 @@ static void highbd_fwd_txfm_16x16(const int16_t *src_diff, tran_low_t *coeff,
copy_flipud(src_diff, diff_stride, 16, src_diff2, 16);
vp10_highbd_fht16x16_c(src_diff2, coeff, 16, ADST_DST);
break;
case IDTX:
fwd_idtx_c(src_diff, coeff, diff_stride, 16);
break;
#endif // CONFIG_EXT_TX
default:
assert(0);
......@@ -998,6 +1039,9 @@ static void highbd_fwd_txfm_16x16_1(const int16_t *src_diff, tran_low_t *coeff,
copy_flipud(src_diff, diff_stride, 16, src_diff2, 16);
vp10_highbd_fht16x16_c(src_diff2, coeff, 16, ADST_DST);
break;
case IDTX:
fwd_idtx_c(src_diff, coeff, diff_stride, 16);
break;
#endif // CONFIG_EXT_TX
default:
assert(0);
......
......@@ -700,19 +700,19 @@ static void choose_tx_size_from_rd(VP10_COMP *cpi, MACROBLOCK *x,
for (tx_type = start_tx_type; tx_type <= end_tx_type; ++tx_type) {
mbmi->ext_txfrm = tx_type;
// TODO(huisu): clean up the logic.
if (mbmi->ext_txfrm >= ALT11 && mbmi->ext_txfrm < ALT16 &&
best_tx_type == NORM) {
tx_type = ALT16 - 1;
continue;
}
#endif // CONFIG_EXT_TX
for (n = start_tx; n >= end_tx; --n) {
int r_tx_size = 0;
#if CONFIG_EXT_TX
if (is_inter_block(mbmi)) {
if (mbmi->ext_txfrm >= GET_EXT_TX_TYPES(n)) {
continue;
} else if (mbmi->ext_txfrm >= ALT11 && best_tx_type == NORM) {
// Terminate if the best so far is still NORM
break;
}
}
if (mbmi->ext_txfrm >= GET_EXT_TX_TYPES(n))
continue;
#endif // CONFIG_EXT_TX
for (m = 0; m <= n - (n == (int) max_tx_size); ++m) {
......@@ -727,7 +727,7 @@ static void choose_tx_size_from_rd(VP10_COMP *cpi, MACROBLOCK *x,
cpi->sf.use_fast_coef_costing);
#if CONFIG_EXT_TX
if (is_inter_block(mbmi) && bs >= BLOCK_8X8 &&
!xd->lossless && r != INT_MAX)
!xd->lossless && r != INT_MAX && n < TX_32X32)
r += cpi->ext_tx_costs[n][mbmi->ext_txfrm];
#endif // CONFIG_EXT_TX
......@@ -783,7 +783,7 @@ static void choose_tx_size_from_rd(VP10_COMP *cpi, MACROBLOCK *x,
mbmi->tx_size = best_tx;
#if CONFIG_EXT_TX
mbmi->ext_txfrm = best_tx_type > -1 ? best_tx_type : NORM;
mbmi->ext_txfrm = best_tx_type;
txfm_rd_in_plane(x, &r, &d, &s,
&sse, ref_best_rd, 0, bs, best_tx,
cpi->sf.use_fast_coef_costing);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment