Clean up unused code in loop-restoration
Removes domain transform recursive filters and non-approximate
guided filter code.
Change-Id: Ib7ae7a6b6526a0908b3dc1787ab3561442da4e2d
diff --git a/av1/common/entropymode.c b/av1/common/entropymode.c
index 732ddc3..7e061d2 100644
--- a/av1/common/entropymode.c
+++ b/av1/common/entropymode.c
@@ -1059,17 +1059,6 @@
};
#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 @@
default_switchable_restore_prob[RESTORE_SWITCHABLE_TYPES - 1] = {
32, 128,
};
-#endif // USE_DOMAINTXFMRF
#endif // CONFIG_LOOP_RESTORATION
#if CONFIG_PALETTE
diff --git a/av1/common/enums.h b/av1/common/enums.h
index 806727d..1e868ae 100644
--- a/av1/common/enums.h
+++ b/av1/common/enums.h
@@ -504,14 +504,10 @@
#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,
diff --git a/av1/common/restoration.c b/av1/common/restoration.c
index a2077f6..9bb8840 100644
--- a/av1/common/restoration.c
+++ b/av1/common/restoration.c
@@ -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 @@
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 @@
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 @@
(((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 @@
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 @@
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 @@
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 @@
(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 @@
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 @@
}
}
-#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 @@
} 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 @@
}
}
-#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 @@
} 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 @@
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
diff --git a/av1/common/restoration.h b/av1/common/restoration.h
index e532172..7964da9 100644
--- a/av1/common/restoration.h
+++ b/av1/common/restoration.h
@@ -28,29 +28,6 @@
#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 @@
// 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 @@
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 @@
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 @@
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,
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 051a338..0a298bf 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -2542,16 +2542,8 @@
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;
-#else
rsi->frame_restoration_type =
aom_rb_read_bit(rb) ? RESTORE_SGRPROJ : RESTORE_WIENER;
-#endif // USE_DOMAINTXFMRF
} else {
rsi->frame_restoration_type =
aom_rb_read_bit(rb) ? RESTORE_SWITCHABLE : RESTORE_NONE;
@@ -2615,14 +2607,6 @@
aom_read_literal(rb, SGRPROJ_PRJ_BITS, ACCT_STR) + SGRPROJ_PRJ_MIN1;
}
-#if USE_DOMAINTXFMRF
-static void read_domaintxfmrf_filter(DomaintxfmrfInfo *domaintxfmrf_info,
- aom_reader *rb) {
- domaintxfmrf_info->sigma_r =
- aom_read_literal(rb, DOMAINTXFMRF_PARAMS_BITS, ACCT_STR);
-}
-#endif // USE_DOMAINTXFMRF
-
static void decode_restoration(AV1_COMMON *cm, aom_reader *rb) {
int i, p;
const int ntiles = av1_get_rest_ntiles(cm->width, cm->height,
@@ -2643,10 +2627,6 @@
read_wiener_filter(&rsi->wiener_info[i], rb);
} else if (rsi->restoration_type[i] == RESTORE_SGRPROJ) {
read_sgrproj_filter(&rsi->sgrproj_info[i], rb);
-#if USE_DOMAINTXFMRF
- } else if (rsi->restoration_type[i] == RESTORE_DOMAINTXFMRF) {
- read_domaintxfmrf_filter(&rsi->domaintxfmrf_info[i], rb);
-#endif // USE_DOMAINTXFMRF
}
}
} else if (rsi->frame_restoration_type == RESTORE_WIENER) {
@@ -2667,17 +2647,6 @@
rsi->restoration_type[i] = RESTORE_NONE;
}
}
-#if USE_DOMAINTXFMRF
- } else if (rsi->frame_restoration_type == RESTORE_DOMAINTXFMRF) {
- for (i = 0; i < ntiles; ++i) {
- if (aom_read(rb, RESTORE_NONE_DOMAINTXFMRF_PROB, ACCT_STR)) {
- rsi->restoration_type[i] = RESTORE_DOMAINTXFMRF;
- read_domaintxfmrf_filter(&rsi->domaintxfmrf_info[i], rb);
- } else {
- rsi->restoration_type[i] = RESTORE_NONE;
- }
- }
-#endif // USE_DOMAINTXFMRF
}
}
for (p = 1; p < MAX_MB_PLANE; ++p) {
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index f37a23a..437f33b 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -3371,23 +3371,10 @@
aom_wb_write_bit(wb, 1);
aom_wb_write_bit(wb, 0);
break;
-#if USE_DOMAINTXFMRF
- case RESTORE_SGRPROJ:
- aom_wb_write_bit(wb, 1);
- aom_wb_write_bit(wb, 1);
- aom_wb_write_bit(wb, 0);
- break;
- case RESTORE_DOMAINTXFMRF:
- aom_wb_write_bit(wb, 1);
- aom_wb_write_bit(wb, 1);
- aom_wb_write_bit(wb, 1);
- break;
-#else
case RESTORE_SGRPROJ:
aom_wb_write_bit(wb, 1);
aom_wb_write_bit(wb, 1);
break;
-#endif // USE_DOMAINTXFMRF
case RESTORE_SWITCHABLE:
aom_wb_write_bit(wb, 0);
aom_wb_write_bit(wb, 1);
@@ -3440,13 +3427,6 @@
SGRPROJ_PRJ_BITS);
}
-#if USE_DOMAINTXFMRF
-static void write_domaintxfmrf_filter(DomaintxfmrfInfo *domaintxfmrf_info,
- aom_writer *wb) {
- aom_write_literal(wb, domaintxfmrf_info->sigma_r, DOMAINTXFMRF_PARAMS_BITS);
-}
-#endif // USE_DOMAINTXFMRF
-
static void encode_restoration(AV1_COMMON *cm, aom_writer *wb) {
int i, p;
const int ntiles = av1_get_rest_ntiles(cm->width, cm->height,
@@ -3468,10 +3448,6 @@
write_wiener_filter(&rsi->wiener_info[i], wb);
} else if (rsi->restoration_type[i] == RESTORE_SGRPROJ) {
write_sgrproj_filter(&rsi->sgrproj_info[i], wb);
-#if USE_DOMAINTXFMRF
- } else if (rsi->restoration_type[i] == RESTORE_DOMAINTXFMRF) {
- write_domaintxfmrf_filter(&rsi->domaintxfmrf_info[i], wb);
-#endif // USE_DOMAINTXFMRF
}
}
} else if (rsi->frame_restoration_type == RESTORE_WIENER) {
@@ -3490,16 +3466,6 @@
write_sgrproj_filter(&rsi->sgrproj_info[i], wb);
}
}
-#if USE_DOMAINTXFMRF
- } else if (rsi->frame_restoration_type == RESTORE_DOMAINTXFMRF) {
- for (i = 0; i < ntiles; ++i) {
- aom_write(wb, rsi->restoration_type[i] != RESTORE_NONE,
- RESTORE_NONE_DOMAINTXFMRF_PROB);
- if (rsi->restoration_type[i] != RESTORE_NONE) {
- write_domaintxfmrf_filter(&rsi->domaintxfmrf_info[i], wb);
- }
- }
-#endif // USE_DOMAINTXFMRF
}
}
for (p = 1; p < MAX_MB_PLANE; ++p) {
diff --git a/av1/encoder/pickrst.c b/av1/encoder/pickrst.c
index 1a990f8..47f2bbb 100644
--- a/av1/encoder/pickrst.c
+++ b/av1/encoder/pickrst.c
@@ -37,11 +37,7 @@
double *best_tile_cost,
YV12_BUFFER_CONFIG *dst_frame);
-#if USE_DOMAINTXFMRF
-const int frame_level_restore_bits[RESTORE_TYPES] = { 2, 2, 3, 3, 2 };
-#else
const int frame_level_restore_bits[RESTORE_TYPES] = { 2, 2, 2, 2 };
-#endif // USE_DOMAINTXFMRF
static int64_t sse_restoration_tile(const YV12_BUFFER_CONFIG *src,
const YV12_BUFFER_CONFIG *dst,
@@ -413,225 +409,6 @@
return cost_sgrproj;
}
-#if USE_DOMAINTXFMRF
-static int64_t compute_sse(uint8_t *dgd, int width, int height, int dgd_stride,
- uint8_t *src, int src_stride) {
- int64_t sse = 0;
- int i, j;
- for (i = 0; i < height; ++i) {
- for (j = 0; j < width; ++j) {
- const int diff =
- (int)dgd[i * dgd_stride + j] - (int)src[i * src_stride + j];
- sse += diff * diff;
- }
- }
- return sse;
-}
-
-#if CONFIG_AOM_HIGHBITDEPTH
-static int64_t compute_sse_highbd(uint16_t *dgd, int width, int height,
- int dgd_stride, uint16_t *src,
- int src_stride) {
- int64_t sse = 0;
- int i, j;
- for (i = 0; i < height; ++i) {
- for (j = 0; j < width; ++j) {
- const int diff =
- (int)dgd[i * dgd_stride + j] - (int)src[i * src_stride + j];
- sse += diff * diff;
- }
- }
- return sse;
-}
-#endif // CONFIG_AOM_HIGHBITDEPTH
-
-static void search_domaintxfmrf_restoration(uint8_t *dgd8, int width,
- int height, int dgd_stride,
- uint8_t *src8, int src_stride,
- int bit_depth, int *sigma_r,
- uint8_t *fltbuf, int32_t *tmpbuf) {
- const int first_p_step = 8;
- const int second_p_range = first_p_step >> 1;
- const int second_p_step = 2;
- const int third_p_range = second_p_step >> 1;
- const int third_p_step = 1;
- int p, best_p0, best_p = -1;
- int64_t best_sse = INT64_MAX, sse;
- if (bit_depth == 8) {
- uint8_t *flt = fltbuf;
- uint8_t *dgd = dgd8;
- uint8_t *src = src8;
- // First phase
- for (p = first_p_step / 2; p < DOMAINTXFMRF_PARAMS; p += first_p_step) {
- av1_domaintxfmrf_restoration(dgd, width, height, dgd_stride, p, flt,
- width, tmpbuf);
- sse = compute_sse(flt, width, height, width, src, src_stride);
- if (sse < best_sse || best_p == -1) {
- best_p = p;
- best_sse = sse;
- }
- }
- // Second Phase
- best_p0 = best_p;
- for (p = best_p0 - second_p_range; p <= best_p0 + second_p_range;
- p += second_p_step) {
- if (p < 0 || p == best_p || p >= DOMAINTXFMRF_PARAMS) continue;
- av1_domaintxfmrf_restoration(dgd, width, height, dgd_stride, p, flt,
- width, tmpbuf);
- sse = compute_sse(flt, width, height, width, src, src_stride);
- if (sse < best_sse) {
- best_p = p;
- best_sse = sse;
- }
- }
- // Third Phase
- best_p0 = best_p;
- for (p = best_p0 - third_p_range; p <= best_p0 + third_p_range;
- p += third_p_step) {
- if (p < 0 || p == best_p || p >= DOMAINTXFMRF_PARAMS) continue;
- av1_domaintxfmrf_restoration(dgd, width, height, dgd_stride, p, flt,
- width, tmpbuf);
- sse = compute_sse(flt, width, height, width, src, src_stride);
- if (sse < best_sse) {
- best_p = p;
- best_sse = sse;
- }
- }
- } else {
-#if CONFIG_AOM_HIGHBITDEPTH
- uint16_t *flt = (uint16_t *)fltbuf;
- uint16_t *dgd = CONVERT_TO_SHORTPTR(dgd8);
- uint16_t *src = CONVERT_TO_SHORTPTR(src8);
- // First phase
- for (p = first_p_step / 2; p < DOMAINTXFMRF_PARAMS; p += first_p_step) {
- av1_domaintxfmrf_restoration_highbd(dgd, width, height, dgd_stride, p,
- bit_depth, flt, width, tmpbuf);
- sse = compute_sse_highbd(flt, width, height, width, src, src_stride);
- if (sse < best_sse || best_p == -1) {
- best_p = p;
- best_sse = sse;
- }
- }
- // Second Phase
- best_p0 = best_p;
- for (p = best_p0 - second_p_range; p <= best_p0 + second_p_range;
- p += second_p_step) {
- if (p < 0 || p == best_p || p >= DOMAINTXFMRF_PARAMS) continue;
- av1_domaintxfmrf_restoration_highbd(dgd, width, height, dgd_stride, p,
- bit_depth, flt, width, tmpbuf);
- sse = compute_sse_highbd(flt, width, height, width, src, src_stride);
- if (sse < best_sse) {
- best_p = p;
- best_sse = sse;
- }
- }
- // Third Phase
- best_p0 = best_p;
- for (p = best_p0 - third_p_range; p <= best_p0 + third_p_range;
- p += third_p_step) {
- if (p < 0 || p == best_p || p >= DOMAINTXFMRF_PARAMS) continue;
- av1_domaintxfmrf_restoration_highbd(dgd, width, height, dgd_stride, p,
- bit_depth, flt, width, tmpbuf);
- sse = compute_sse_highbd(flt, width, height, width, src, src_stride);
- if (sse < best_sse) {
- best_p = p;
- best_sse = sse;
- }
- }
-#else
- assert(0);
-#endif // CONFIG_AOM_HIGHBITDEPTH
- }
- *sigma_r = best_p;
-}
-
-static double search_domaintxfmrf(const YV12_BUFFER_CONFIG *src, AV1_COMP *cpi,
- int partial_frame, RestorationInfo *info,
- RestorationType *type, double *best_tile_cost,
- YV12_BUFFER_CONFIG *dst_frame) {
- DomaintxfmrfInfo *domaintxfmrf_info = info->domaintxfmrf_info;
- double cost_norestore, cost_domaintxfmrf;
- int64_t err;
- int bits;
- MACROBLOCK *x = &cpi->td.mb;
- AV1_COMMON *const cm = &cpi->common;
- const YV12_BUFFER_CONFIG *dgd = cm->frame_to_show;
- RestorationInfo *rsi = &cpi->rst_search[0];
- int tile_idx, tile_width, tile_height, nhtiles, nvtiles;
- int h_start, h_end, v_start, v_end;
- const int ntiles = av1_get_rest_ntiles(
- cm->width, cm->height, cm->rst_info[0].restoration_tilesize, &tile_width,
- &tile_height, &nhtiles, &nvtiles);
-
- rsi->frame_restoration_type = RESTORE_DOMAINTXFMRF;
-
- for (tile_idx = 0; tile_idx < ntiles; ++tile_idx) {
- rsi->restoration_type[tile_idx] = RESTORE_NONE;
- }
- // Compute best Domaintxfm filters for each tile
- for (tile_idx = 0; tile_idx < ntiles; ++tile_idx) {
- av1_get_rest_tile_limits(tile_idx, 0, 0, nhtiles, nvtiles, tile_width,
- tile_height, cm->width, cm->height, 0, 0, &h_start,
- &h_end, &v_start, &v_end);
- err = sse_restoration_tile(src, cm->frame_to_show, cm, h_start,
- h_end - h_start, v_start, v_end - v_start, 1);
- // #bits when a tile is not restored
- bits = av1_cost_bit(RESTORE_NONE_DOMAINTXFMRF_PROB, 0);
- cost_norestore = RDCOST_DBL(x->rdmult, x->rddiv, (bits >> 4), err);
- best_tile_cost[tile_idx] = DBL_MAX;
-
- search_domaintxfmrf_restoration(
- dgd->y_buffer + v_start * dgd->y_stride + h_start, h_end - h_start,
- v_end - v_start, dgd->y_stride,
- src->y_buffer + v_start * src->y_stride + h_start, src->y_stride,
-#if CONFIG_AOM_HIGHBITDEPTH
- cm->bit_depth,
-#else
- 8,
-#endif // CONFIG_AOM_HIGHBITDEPTH
- &rsi->domaintxfmrf_info[tile_idx].sigma_r, cpi->extra_rstbuf,
- cm->rst_internal.tmpbuf);
-
- rsi->restoration_type[tile_idx] = RESTORE_DOMAINTXFMRF;
- err = try_restoration_tile(src, cpi, rsi, 1, partial_frame, tile_idx, 0, 0,
- dst_frame);
- bits = DOMAINTXFMRF_PARAMS_BITS << AV1_PROB_COST_SHIFT;
- bits += av1_cost_bit(RESTORE_NONE_DOMAINTXFMRF_PROB, 1);
- cost_domaintxfmrf = RDCOST_DBL(x->rdmult, x->rddiv, (bits >> 4), err);
- if (cost_domaintxfmrf >= cost_norestore) {
- type[tile_idx] = RESTORE_NONE;
- } else {
- type[tile_idx] = RESTORE_DOMAINTXFMRF;
- memcpy(&domaintxfmrf_info[tile_idx], &rsi->domaintxfmrf_info[tile_idx],
- sizeof(domaintxfmrf_info[tile_idx]));
- bits = DOMAINTXFMRF_PARAMS_BITS << AV1_PROB_COST_SHIFT;
- best_tile_cost[tile_idx] = RDCOST_DBL(
- x->rdmult, x->rddiv,
- (bits + cpi->switchable_restore_cost[RESTORE_DOMAINTXFMRF]) >> 4,
- err);
- }
- rsi->restoration_type[tile_idx] = RESTORE_NONE;
- }
- // Cost for Domaintxfmrf filtering
- bits = frame_level_restore_bits[rsi->frame_restoration_type]
- << AV1_PROB_COST_SHIFT;
- for (tile_idx = 0; tile_idx < ntiles; ++tile_idx) {
- bits += av1_cost_bit(RESTORE_NONE_DOMAINTXFMRF_PROB,
- type[tile_idx] != RESTORE_NONE);
- memcpy(&rsi->domaintxfmrf_info[tile_idx], &domaintxfmrf_info[tile_idx],
- sizeof(domaintxfmrf_info[tile_idx]));
- if (type[tile_idx] == RESTORE_DOMAINTXFMRF) {
- bits += (DOMAINTXFMRF_PARAMS_BITS << AV1_PROB_COST_SHIFT);
- }
- rsi->restoration_type[tile_idx] = type[tile_idx];
- }
- err = try_restoration_frame(src, cpi, rsi, 1, partial_frame, dst_frame);
- cost_domaintxfmrf = RDCOST_DBL(x->rdmult, x->rddiv, (bits >> 4), err);
-
- return cost_domaintxfmrf;
-}
-#endif // USE_DOMAINTXFMRF
-
static double find_average(uint8_t *src, int h_start, int h_end, int v_start,
int v_end, int stride) {
uint64_t sum = 0;
@@ -1278,12 +1055,7 @@
void av1_pick_filter_restoration(const YV12_BUFFER_CONFIG *src, AV1_COMP *cpi,
LPF_PICK_METHOD method) {
static search_restore_type search_restore_fun[RESTORE_SWITCHABLE_TYPES] = {
- search_norestore,
- search_wiener,
- search_sgrproj,
-#if USE_DOMAINTXFMRF
- search_domaintxfmrf,
-#endif // USE_DOMAINTXFMRF
+ search_norestore, search_wiener, search_sgrproj,
};
AV1_COMMON *const cm = &cpi->common;
double cost_restore[RESTORE_TYPES];
@@ -1339,19 +1111,10 @@
cm->rst_info[0].frame_restoration_type,
cm->rst_info[1].frame_restoration_type,
cm->rst_info[2].frame_restoration_type);
- */
- /*
-#if USE_DOMAINTXFMRF
- printf("Frame %d/%d frame_restore_type %d : %f %f %f %f %f\n",
- cm->current_video_frame, cm->show_frame,
- cm->rst_info[0].frame_restoration_type, cost_restore[0],
- cost_restore[1], cost_restore[2], cost_restore[3], cost_restore[4]);
-#else
printf("Frame %d/%d frame_restore_type %d : %f %f %f %f\n",
cm->current_video_frame, cm->show_frame,
cm->rst_info[0].frame_restoration_type, cost_restore[0],
cost_restore[1], cost_restore[2], cost_restore[3]);
-#endif // USE_DOMAINTXFMRF
*/
for (r = 0; r < RESTORE_SWITCHABLE_TYPES; r++) {