Commit 4bfd72ee authored by Debargha Mukherjee's avatar Debargha Mukherjee

Clean up unused code in loop-restoration

Removes domain transform recursive filters and non-approximate
guided filter code.

Change-Id: Ib7ae7a6b6526a0908b3dc1787ab3561442da4e2d
parent 625bc26c
......@@ -1059,17 +1059,6 @@ static const aom_prob default_tx_size_prob[MAX_TX_DEPTH][TX_SIZE_CONTEXTS]
};
#if CONFIG_LOOP_RESTORATION
#if USE_DOMAINTXFMRF
const aom_tree_index av1_switchable_restore_tree[TREE_SIZE(
RESTORE_SWITCHABLE_TYPES)] = {
-RESTORE_NONE, 2, -RESTORE_WIENER, 4, -RESTORE_SGRPROJ, -RESTORE_DOMAINTXFMRF,
};
static const aom_prob
default_switchable_restore_prob[RESTORE_SWITCHABLE_TYPES - 1] = {
32, 128, 128,
};
#else
const aom_tree_index
av1_switchable_restore_tree[TREE_SIZE(RESTORE_SWITCHABLE_TYPES)] = {
-RESTORE_NONE, 2, -RESTORE_WIENER, -RESTORE_SGRPROJ,
......@@ -1079,7 +1068,6 @@ static const aom_prob
default_switchable_restore_prob[RESTORE_SWITCHABLE_TYPES - 1] = {
32, 128,
};
#endif // USE_DOMAINTXFMRF
#endif // CONFIG_LOOP_RESTORATION
#if CONFIG_PALETTE
......
......@@ -504,14 +504,10 @@ typedef uint8_t TXFM_CONTEXT;
#endif // CONFIG_SUPERTX
#if CONFIG_LOOP_RESTORATION
#define USE_DOMAINTXFMRF 0
typedef enum {
RESTORE_NONE = 0,
RESTORE_WIENER = 1,
RESTORE_SGRPROJ = 2,
#if USE_DOMAINTXFMRF
RESTORE_DOMAINTXFMRF = 3,
#endif // USE_DOMAINTXFMRF
RESTORE_SWITCHABLE,
RESTORE_SWITCHABLE_TYPES = RESTORE_SWITCHABLE,
RESTORE_TYPES,
......
......@@ -21,29 +21,12 @@
#include "aom_mem/aom_mem.h"
#include "aom_ports/mem.h"
#if USE_DOMAINTXFMRF
static int domaintxfmrf_vtable[DOMAINTXFMRF_ITERS][DOMAINTXFMRF_PARAMS][256];
static const int domaintxfmrf_params[DOMAINTXFMRF_PARAMS] = {
32, 40, 48, 56, 64, 68, 72, 76, 80, 82, 84, 86, 88,
90, 92, 94, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 130, 132, 134,
136, 138, 140, 142, 146, 150, 154, 158, 162, 166, 170, 174
};
#endif // USE_DOMAINTXFMRF
const sgr_params_type sgr_params[SGRPROJ_PARAMS] = {
// r1, eps1, r2, eps2
#if SGRPROJ_PARAMS_BITS == 3
{ 2, 25, 1, 11 }, { 2, 35, 1, 12 }, { 2, 45, 1, 13 }, { 2, 55, 1, 14 },
{ 2, 65, 1, 15 }, { 3, 50, 2, 25 }, { 3, 60, 2, 35 }, { 3, 70, 2, 45 },
#elif SGRPROJ_PARAMS_BITS == 4
// r1, eps1, r2, eps2
{ 2, 12, 1, 4 }, { 2, 15, 1, 6 }, { 2, 18, 1, 8 }, { 2, 20, 1, 9 },
{ 2, 22, 1, 10 }, { 2, 25, 1, 11 }, { 2, 35, 1, 12 }, { 2, 45, 1, 13 },
{ 2, 55, 1, 14 }, { 2, 65, 1, 15 }, { 2, 75, 1, 16 }, { 3, 30, 1, 10 },
{ 3, 50, 1, 12 }, { 3, 50, 2, 25 }, { 3, 60, 2, 35 }, { 3, 70, 2, 45 },
#endif // SGRPROJ_PARAMS_BITS == 3
};
typedef void (*restore_func_type)(uint8_t *data8, int width, int height,
......@@ -73,12 +56,6 @@ int av1_alloc_restoration_struct(AV1_COMMON *cm, RestorationInfo *rst_info,
CHECK_MEM_ERROR(
cm, rst_info->sgrproj_info,
(SgrprojInfo *)aom_malloc(sizeof(*rst_info->sgrproj_info) * ntiles));
#if USE_DOMAINTXFMRF
aom_free(rst_info->domaintxfmrf_info);
CHECK_MEM_ERROR(cm, rst_info->domaintxfmrf_info,
(DomaintxfmrfInfo *)aom_malloc(
sizeof(*rst_info->domaintxfmrf_info) * ntiles));
#endif // USE_DOMAINTXFMRF
return ntiles;
}
......@@ -89,36 +66,8 @@ void av1_free_restoration_struct(RestorationInfo *rst_info) {
rst_info->wiener_info = NULL;
aom_free(rst_info->sgrproj_info);
rst_info->sgrproj_info = NULL;
#if USE_DOMAINTXFMRF
aom_free(rst_info->domaintxfmrf_info);
rst_info->domaintxfmrf_info = NULL;
#endif // USE_DOMAINTXFMRF
}
#if USE_DOMAINTXFMRF
static void GenDomainTxfmRFVtable() {
int i, j;
const double sigma_s = sqrt(2.0);
for (i = 0; i < DOMAINTXFMRF_ITERS; ++i) {
const int nm = (1 << (DOMAINTXFMRF_ITERS - i - 1));
const double A = exp(-DOMAINTXFMRF_MULT / (sigma_s * nm));
for (j = 0; j < DOMAINTXFMRF_PARAMS; ++j) {
const double sigma_r =
(double)domaintxfmrf_params[j] / DOMAINTXFMRF_SIGMA_SCALE;
const double scale = sigma_s / sigma_r;
int k;
for (k = 0; k < 256; ++k) {
domaintxfmrf_vtable[i][j][k] =
RINT(DOMAINTXFMRF_VTABLE_PREC * pow(A, 1.0 + k * scale));
}
}
}
}
#endif // USE_DOMAINTXFMRF
#define APPROXIMATE_SGR 1
#if APPROXIMATE_SGR
#define MAX_RADIUS 3 // Only 1, 2, 3 allowed
#define MAX_EPS 80 // Max value of eps
#define MAX_NELEM ((2 * MAX_RADIUS + 1) * (2 * MAX_RADIUS + 1))
......@@ -138,16 +87,8 @@ static void GenSgrprojVtable() {
(((1 << SGRPROJ_MTABLE_BITS) + n2e / 2) / n2e);
}
}
#endif // APPROXIMATE_SGR
void av1_loop_restoration_precal() {
#if APPROXIMATE_SGR
GenSgrprojVtable();
#endif // APPROXIMATE_SGR
#if USE_DOMAINTXFMRF
GenDomainTxfmRFVtable();
#endif // USE_DOMAINTXFMRF
}
void av1_loop_restoration_precal() { GenSgrprojVtable(); }
static void loop_restoration_init(RestorationInternal *rst, int kf) {
rst->keyframe = kf;
......@@ -581,7 +522,6 @@ void decode_xq(int *xqd, int *xq) {
xq[1] = (1 << SGRPROJ_PRJ_BITS) - xq[0] - xqd[1];
}
#if APPROXIMATE_SGR
const int32_t x_by_xplus1[256] = {
0, 128, 171, 192, 205, 213, 219, 224, 228, 230, 233, 235, 236, 238, 239,
240, 241, 242, 243, 243, 244, 244, 245, 245, 246, 246, 247, 247, 247, 247,
......@@ -609,7 +549,6 @@ const int32_t one_by_x[MAX_NELEM] = {
152, 146, 141, 137, 132, 128, 124, 120, 117, 114, 111, 108, 105,
102, 100, 98, 95, 93, 91, 89, 87, 85, 84
};
#endif // APPROXIMATE_SGR
static void av1_selfguided_restoration_internal(int32_t *dgd, int width,
int height, int stride,
......@@ -636,7 +575,7 @@ static void av1_selfguided_restoration_internal(int32_t *dgd, int width,
for (j = 0; j < width; ++j) {
const int k = i * buf_stride + j;
const int n = num[i * width + j];
#if APPROXIMATE_SGR
// a < 2^16 * n < 2^22 regardless of bit depth
uint32_t a = ROUND_POWER_OF_TWO(A[k], 2 * (bit_depth - 8));
// b < 2^8 * n < 2^14 regardless of bit depth
......@@ -665,16 +604,8 @@ static void av1_selfguided_restoration_internal(int32_t *dgd, int width,
(uint32_t)B[k] *
(uint32_t)one_by_x[n - 1],
SGRPROJ_RECIP_BITS);
#else
const uint32_t p = (uint32_t)((uint64_t)A[k] * n - (uint64_t)B[k] * B[k]);
const uint32_t q = (uint32_t)(p + n * n * eps);
assert((uint64_t)A[k] * n - (uint64_t)B[k] * B[k] < (25 * 25U << 22));
A[k] = (int32_t)(((uint64_t)p << SGRPROJ_SGR_BITS) + (q >> 1)) / q;
B[k] = ((SGRPROJ_SGR - A[k]) * B[k] + (n >> 1)) / n;
#endif // APPROXIMATE_SGR
}
}
#if APPROXIMATE_SGR
i = 0;
j = 0;
{
......@@ -796,21 +727,6 @@ static void av1_selfguided_restoration_internal(int32_t *dgd, int width,
dgd[l] = ROUND_POWER_OF_TWO(v, SGRPROJ_SGR_BITS + nb - SGRPROJ_RST_BITS);
}
}
#else
if (r > 1) boxnum(width, height, r = 1, num, width);
boxsum(A, width, height, width, r, 0, A, width);
boxsum(B, width, height, width, r, 0, B, width);
for (i = 0; i < height; ++i) {
for (j = 0; j < width; ++j) {
const int k = i * buf_stride + j;
const int l = i * stride + j;
const int n = num[k];
const int32_t v =
(((A[k] * dgd[l] + B[k]) << SGRPROJ_RST_BITS) + (n >> 1)) / n;
dgd[l] = ROUND_POWER_OF_TWO(v, SGRPROJ_SGR_BITS);
}
}
#endif // APPROXIMATE_SGR
}
void av1_selfguided_restoration_c(uint8_t *dgd, int width, int height,
......@@ -895,165 +811,6 @@ static void loop_sgrproj_filter(uint8_t *data, int width, int height,
}
}
#if USE_DOMAINTXFMRF
static void apply_domaintxfmrf(int iter, int param, uint8_t *diff_right,
uint8_t *diff_down, int width, int height,
int32_t *dat, int dat_stride) {
int i, j, acc;
// Do first row separately, to initialize the top to bottom filter
i = 0;
{
// left to right
acc = dat[i * dat_stride] * DOMAINTXFMRF_VTABLE_PREC;
dat[i * dat_stride] = acc;
for (j = 1; j < width; ++j) {
const int in = dat[i * dat_stride + j];
const int diff =
diff_right[i * width + j - 1]; // Left absolute difference
const int v = domaintxfmrf_vtable[iter][param][diff];
acc = in * (DOMAINTXFMRF_VTABLE_PREC - v) +
ROUND_POWER_OF_TWO(v * acc, DOMAINTXFMRF_VTABLE_PRECBITS);
dat[i * dat_stride + j] = acc;
}
// right to left
for (j = width - 2; j >= 0; --j) {
const int in = dat[i * dat_stride + j];
const int diff = diff_right[i * width + j]; // Right absolute difference
const int v = domaintxfmrf_vtable[iter][param][diff];
acc = ROUND_POWER_OF_TWO(in * (DOMAINTXFMRF_VTABLE_PREC - v) + acc * v,
DOMAINTXFMRF_VTABLE_PRECBITS);
dat[i * dat_stride + j] = acc;
}
}
for (i = 1; i < height; ++i) {
// left to right
acc = dat[i * dat_stride] * DOMAINTXFMRF_VTABLE_PREC;
dat[i * dat_stride] = acc;
for (j = 1; j < width; ++j) {
const int in = dat[i * dat_stride + j];
const int diff =
diff_right[i * width + j - 1]; // Left absolute difference
const int v = domaintxfmrf_vtable[iter][param][diff];
acc = in * (DOMAINTXFMRF_VTABLE_PREC - v) +
ROUND_POWER_OF_TWO(v * acc, DOMAINTXFMRF_VTABLE_PRECBITS);
dat[i * dat_stride + j] = acc;
}
// right to left
for (j = width - 2; j >= 0; --j) {
const int in = dat[i * dat_stride + j];
const int diff = diff_right[i * width + j]; // Right absolute difference
const int v = domaintxfmrf_vtable[iter][param][diff];
acc = ROUND_POWER_OF_TWO(in * (DOMAINTXFMRF_VTABLE_PREC - v) + acc * v,
DOMAINTXFMRF_VTABLE_PRECBITS);
dat[i * dat_stride + j] = acc;
}
// top to bottom
for (j = 0; j < width; ++j) {
const int in = dat[i * dat_stride + j];
const int in_above = dat[(i - 1) * dat_stride + j];
const int diff =
diff_down[(i - 1) * width + j]; // Upward absolute difference
const int v = domaintxfmrf_vtable[iter][param][diff];
acc =
ROUND_POWER_OF_TWO(in * (DOMAINTXFMRF_VTABLE_PREC - v) + in_above * v,
DOMAINTXFMRF_VTABLE_PRECBITS);
dat[i * dat_stride + j] = acc;
}
}
for (j = 0; j < width; ++j) {
// bottom to top + output rounding
acc = dat[(height - 1) * dat_stride + j];
dat[(height - 1) * dat_stride + j] =
ROUND_POWER_OF_TWO(acc, DOMAINTXFMRF_VTABLE_PRECBITS);
for (i = height - 2; i >= 0; --i) {
const int in = dat[i * dat_stride + j];
const int diff =
diff_down[i * width + j]; // Downward absolute difference
const int v = domaintxfmrf_vtable[iter][param][diff];
acc = ROUND_POWER_OF_TWO(in * (DOMAINTXFMRF_VTABLE_PREC - v) + acc * v,
DOMAINTXFMRF_VTABLE_PRECBITS);
dat[i * dat_stride + j] =
ROUND_POWER_OF_TWO(acc, DOMAINTXFMRF_VTABLE_PRECBITS);
}
}
}
void av1_domaintxfmrf_restoration(uint8_t *dgd, int width, int height,
int stride, int param, uint8_t *dst,
int dst_stride, int32_t *tmpbuf) {
int32_t *dat = tmpbuf;
uint8_t *diff_right = (uint8_t *)(tmpbuf + RESTORATION_TILEPELS_MAX);
uint8_t *diff_down = diff_right + RESTORATION_TILEPELS_MAX;
int i, j, t;
for (i = 0; i < height; ++i) {
int cur_px = dgd[i * stride];
for (j = 0; j < width - 1; ++j) {
const int next_px = dgd[i * stride + j + 1];
diff_right[i * width + j] = abs(cur_px - next_px);
cur_px = next_px;
}
}
for (j = 0; j < width; ++j) {
int cur_px = dgd[j];
for (i = 0; i < height - 1; ++i) {
const int next_px = dgd[(i + 1) * stride + j];
diff_down[i * width + j] = abs(cur_px - next_px);
cur_px = next_px;
}
}
for (i = 0; i < height; ++i) {
for (j = 0; j < width; ++j) {
dat[i * width + j] = dgd[i * stride + j];
}
}
for (t = 0; t < DOMAINTXFMRF_ITERS; ++t) {
apply_domaintxfmrf(t, param, diff_right, diff_down, width, height, dat,
width);
}
for (i = 0; i < height; ++i) {
for (j = 0; j < width; ++j) {
dst[i * dst_stride + j] = clip_pixel(dat[i * width + j]);
}
}
}
static void loop_domaintxfmrf_filter_tile(uint8_t *data, int tile_idx,
int width, int height, int stride,
RestorationInternal *rst,
uint8_t *dst, int dst_stride) {
const int tile_width = rst->tile_width;
const int tile_height = rst->tile_height;
int h_start, h_end, v_start, v_end;
int32_t *tmpbuf = (int32_t *)rst->tmpbuf;
if (rst->rsi->restoration_type[tile_idx] == RESTORE_NONE) {
loop_copy_tile(data, tile_idx, 0, 0, width, height, stride, rst, dst,
dst_stride);
return;
}
av1_get_rest_tile_limits(tile_idx, 0, 0, rst->nhtiles, rst->nvtiles,
tile_width, tile_height, width, height, 0, 0,
&h_start, &h_end, &v_start, &v_end);
av1_domaintxfmrf_restoration(
data + h_start + v_start * stride, h_end - h_start, v_end - v_start,
stride, rst->rsi->domaintxfmrf_info[tile_idx].sigma_r,
dst + h_start + v_start * dst_stride, dst_stride, tmpbuf);
}
static void loop_domaintxfmrf_filter(uint8_t *data, int width, int height,
int stride, RestorationInternal *rst,
uint8_t *dst, int dst_stride) {
int tile_idx;
for (tile_idx = 0; tile_idx < rst->ntiles; ++tile_idx) {
loop_domaintxfmrf_filter_tile(data, tile_idx, width, height, stride, rst,
dst, dst_stride);
}
}
#endif // USE_DOMAINTXFMRF
static void loop_switchable_filter(uint8_t *data, int width, int height,
int stride, RestorationInternal *rst,
uint8_t *dst, int dst_stride) {
......@@ -1069,11 +826,6 @@ static void loop_switchable_filter(uint8_t *data, int width, int height,
} else if (rst->rsi->restoration_type[tile_idx] == RESTORE_SGRPROJ) {
loop_sgrproj_filter_tile(data, tile_idx, width, height, stride, rst, dst,
dst_stride);
#if USE_DOMAINTXFMRF
} else if (rst->rsi->restoration_type[tile_idx] == RESTORE_DOMAINTXFMRF) {
loop_domaintxfmrf_filter_tile(data, tile_idx, width, height, stride, rst,
dst, dst_stride);
#endif // USE_DOMAINTXFMRF
}
}
}
......@@ -1248,87 +1000,6 @@ static void loop_sgrproj_filter_highbd(uint8_t *data8, int width, int height,
}
}
#if USE_DOMAINTXFMRF
void av1_domaintxfmrf_restoration_highbd(uint16_t *dgd, int width, int height,
int stride, int param, int bit_depth,
uint16_t *dst, int dst_stride,
int32_t *tmpbuf) {
int32_t *dat = tmpbuf;
uint8_t *diff_right = (uint8_t *)(tmpbuf + RESTORATION_TILEPELS_MAX);
uint8_t *diff_down = diff_right + RESTORATION_TILEPELS_MAX;
const int shift = (bit_depth - 8);
int i, j, t;
for (i = 0; i < height; ++i) {
int cur_px = dgd[i * stride] >> shift;
for (j = 0; j < width - 1; ++j) {
const int next_px = dgd[i * stride + j + 1] >> shift;
diff_right[i * width + j] = abs(cur_px - next_px);
cur_px = next_px;
}
}
for (j = 0; j < width; ++j) {
int cur_px = dgd[j] >> shift;
for (i = 0; i < height - 1; ++i) {
const int next_px = dgd[(i + 1) * stride + j] >> shift;
diff_down[i * width + j] = abs(cur_px - next_px);
cur_px = next_px;
}
}
for (i = 0; i < height; ++i) {
for (j = 0; j < width; ++j) {
dat[i * width + j] = dgd[i * stride + j];
}
}
for (t = 0; t < DOMAINTXFMRF_ITERS; ++t) {
apply_domaintxfmrf(t, param, diff_right, diff_down, width, height, dat,
width);
}
for (i = 0; i < height; ++i) {
for (j = 0; j < width; ++j) {
dst[i * dst_stride + j] =
clip_pixel_highbd(dat[i * width + j], bit_depth);
}
}
}
static void loop_domaintxfmrf_filter_tile_highbd(
uint16_t *data, int tile_idx, int width, int height, int stride,
RestorationInternal *rst, int bit_depth, uint16_t *dst, int dst_stride) {
const int tile_width = rst->tile_width;
const int tile_height = rst->tile_height;
int h_start, h_end, v_start, v_end;
int32_t *tmpbuf = (int32_t *)rst->tmpbuf;
if (rst->rsi->restoration_type[tile_idx] == RESTORE_NONE) {
loop_copy_tile_highbd(data, tile_idx, 0, 0, width, height, stride, rst, dst,
dst_stride);
return;
}
av1_get_rest_tile_limits(tile_idx, 0, 0, rst->nhtiles, rst->nvtiles,
tile_width, tile_height, width, height, 0, 0,
&h_start, &h_end, &v_start, &v_end);
av1_domaintxfmrf_restoration_highbd(
data + h_start + v_start * stride, h_end - h_start, v_end - v_start,
stride, rst->rsi->domaintxfmrf_info[tile_idx].sigma_r, bit_depth,
dst + h_start + v_start * dst_stride, dst_stride, tmpbuf);
}
static void loop_domaintxfmrf_filter_highbd(uint8_t *data8, int width,
int height, int stride,
RestorationInternal *rst,
int bit_depth, uint8_t *dst8,
int dst_stride) {
int tile_idx;
uint16_t *data = CONVERT_TO_SHORTPTR(data8);
uint16_t *dst = CONVERT_TO_SHORTPTR(dst8);
for (tile_idx = 0; tile_idx < rst->ntiles; ++tile_idx) {
loop_domaintxfmrf_filter_tile_highbd(data, tile_idx, width, height, stride,
rst, bit_depth, dst, dst_stride);
}
}
#endif // USE_DOMAINTXFMRF
static void loop_switchable_filter_highbd(uint8_t *data8, int width, int height,
int stride, RestorationInternal *rst,
int bit_depth, uint8_t *dst8,
......@@ -1347,12 +1018,6 @@ static void loop_switchable_filter_highbd(uint8_t *data8, int width, int height,
} else if (rst->rsi->restoration_type[tile_idx] == RESTORE_SGRPROJ) {
loop_sgrproj_filter_tile_highbd(data, tile_idx, width, height, stride,
rst, bit_depth, dst, dst_stride);
#if USE_DOMAINTXFMRF
} else if (rst->rsi->restoration_type[tile_idx] == RESTORE_DOMAINTXFMRF) {
loop_domaintxfmrf_filter_tile_highbd(data, tile_idx, width, height,
stride, rst, bit_depth, dst,
dst_stride);
#endif // USE_DOMAINTXFMRF
}
}
}
......@@ -1371,22 +1036,11 @@ static void loop_restoration_rows(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
int yend = end_mi_row << MI_SIZE_LOG2;
int uvend = yend >> cm->subsampling_y;
restore_func_type restore_funcs[RESTORE_TYPES] = {
NULL,
loop_wiener_filter,
loop_sgrproj_filter,
#if USE_DOMAINTXFMRF
loop_domaintxfmrf_filter,
#endif // USE_DOMAINTXFMRF
loop_switchable_filter
NULL, loop_wiener_filter, loop_sgrproj_filter, loop_switchable_filter
};
#if CONFIG_AOM_HIGHBITDEPTH
restore_func_highbd_type restore_funcs_highbd[RESTORE_TYPES] = {
NULL,
loop_wiener_filter_highbd,
loop_sgrproj_filter_highbd,
#if USE_DOMAINTXFMRF
loop_domaintxfmrf_filter_highbd,
#endif // USE_DOMAINTXFMRF
NULL, loop_wiener_filter_highbd, loop_sgrproj_filter_highbd,
loop_switchable_filter_highbd
};
#endif // CONFIG_AOM_HIGHBITDEPTH
......
......@@ -28,29 +28,6 @@ extern "C" {
#define RESTORATION_TILEPELS_MAX \
(RESTORATION_TILESIZE_MAX * RESTORATION_TILESIZE_MAX * 9 / 4)
#if USE_DOMAINTXFMRF
#define DOMAINTXFMRF_PARAMS_BITS 6
#define DOMAINTXFMRF_PARAMS (1 << DOMAINTXFMRF_PARAMS_BITS)
#define DOMAINTXFMRF_SIGMA_SCALEBITS 4
#define DOMAINTXFMRF_SIGMA_SCALE (1 << DOMAINTXFMRF_SIGMA_SCALEBITS)
#define DOMAINTXFMRF_ITERS 3
#define DOMAINTXFMRF_VTABLE_PRECBITS 8
#define DOMAINTXFMRF_VTABLE_PREC (1 << DOMAINTXFMRF_VTABLE_PRECBITS)
#define DOMAINTXFMRF_MULT \
sqrt(((1 << (DOMAINTXFMRF_ITERS * 2)) - 1) * 2.0 / 3.0)
// 1 32-bit and 2 8-bit buffers needed for the filter
#define DOMAINTXFMRF_TMPBUF_SIZE \
(RESTORATION_TILEPELS_MAX * (sizeof(int32_t) + 2 * sizeof(uint8_t)))
// One extra buffer needed in encoder, which is either 8-bit or 16-bit
// depending on the video bit depth.
#if CONFIG_AOM_HIGHBITDEPTH
#define DOMAINTXFMRF_EXTBUF_SIZE (RESTORATION_TILEPELS_MAX * sizeof(uint16_t))
#else
#define DOMAINTXFMRF_EXTBUF_SIZE (RESTORATION_TILEPELS_MAX * sizeof(uint8_t))
#endif
#define DOMAINTXFMRF_BITS (DOMAINTXFMRF_PARAMS_BITS)
#endif // USE_DOMAINTXFMRF
// 4 32-bit buffers needed for the filter:
// 2 for the restored versions of the frame and
// 2 for each restoration operation
......@@ -123,12 +100,8 @@ extern "C" {
// Max of SGRPROJ_TMPBUF_SIZE, DOMAINTXFMRF_TMPBUF_SIZE, WIENER_TMPBUF_SIZE
#define RESTORATION_TMPBUF_SIZE (SGRPROJ_TMPBUF_SIZE)
#if USE_DOMAINTXFMRF
// Max of SGRPROJ_EXTBUF_SIZE, DOMAINTXFMRF_EXTBUF_SIZE, WIENER_EXTBUF_SIZE
#define RESTORATION_EXTBUF_SIZE (DOMAINTXFMRF_EXTBUF_SIZE)
#else
// Max of SGRPROJ_EXTBUF_SIZE, WIENER_EXTBUF_SIZE
#define RESTORATION_EXTBUF_SIZE (WIENER_EXTBUF_SIZE)
#endif // USE_DOMAINTXFMRF
// Check the assumptions of the existing code
#if SUBPEL_TAPS != WIENER_WIN + 1
......@@ -154,10 +127,6 @@ typedef struct {
int xqd[2];
} SgrprojInfo;
#if USE_DOMAINTXFMRF
typedef struct { int sigma_r; } DomaintxfmrfInfo;
#endif // USE_DOMAINTXFMRF
typedef struct {
int restoration_tilesize;
RestorationType frame_restoration_type;
......@@ -166,10 +135,6 @@ typedef struct {
WienerInfo *wiener_info;
// Selfguided proj filter
SgrprojInfo *sgrproj_info;
#if USE_DOMAINTXFMRF
// Domain transform filter
DomaintxfmrfInfo *domaintxfmrf_info;
#endif // USE_DOMAINTXFMRF
} RestorationInfo;
typedef struct {
......@@ -241,19 +206,8 @@ int av1_alloc_restoration_struct(struct AV1Common *cm,
void av1_free_restoration_struct(RestorationInfo *rst_info);
void extend_frame(uint8_t *data, int width, int height, int stride);
#if USE_DOMAINTXFMRF
void av1_domaintxfmrf_restoration(uint8_t *dgd, int width, int height,
int stride, int param, uint8_t *dst,
int dst_stride, int32_t *tmpbuf);
#endif // USE_DOMAINTXFMRF
#if CONFIG_AOM_HIGHBITDEPTH
void extend_frame_highbd(uint16_t *data, int width, int height, int stride);
#if USE_DOMAINTXFMRF
void av1_domaintxfmrf_restoration_highbd(uint16_t *dgd, int width, int height,
int stride, int param, int bit_depth,
uint16_t *dst, int dst_stride,
int32_t *tmpbuf);
#endif // USE_DOMAINTXFMRF
#endif // CONFIG_AOM_HIGHBITDEPTH
void decode_xq(int *xqd, int *xq);
void av1_loop_restoration_frame(YV12_BUFFER_CONFIG *frame, struct AV1Common *cm,
......
......@@ -2542,16 +2542,8 @@ static void decode_restoration_mode(AV1_COMMON *cm,
int p;
RestorationInfo *rsi = &cm->rst_info[0];
if (aom_rb_read_bit(rb)) {
#if USE_DOMAINTXFMRF
if (aom_rb_read_bit(rb))
rsi->frame_restoration_type =
(aom_rb_read_bit(rb) ? RESTORE_DOMAINTXFMRF : RESTORE_SGRPROJ);
else
rsi->frame_restoration_type = RESTORE_WIENER;