};
#if CONFIG_LOOP_RESTORATION
-#define BILATERAL_RANGE 256
-#define BILATERAL_RANGE_SYM (2 * BILATERAL_RANGE + 1)
-static double bilateral_filters_r_kf[BILATERAL_LEVELS_KF + 1]
- [BILATERAL_RANGE_SYM];
-static double bilateral_filters_r[BILATERAL_LEVELS + 1][BILATERAL_RANGE_SYM];
-static double bilateral_filters_s_kf[BILATERAL_LEVELS_KF + 1]
- [BILATERAL_WIN][BILATERAL_WIN];
-static double bilateral_filters_s[BILATERAL_LEVELS + 1]
- [BILATERAL_WIN][BILATERAL_WIN];
-
-void vp10_loop_bilateral_precal() {
+#define RESTORATION_RANGE 256
+#define RESTORATION_RANGE_SYM (2 * RESTORATION_RANGE + 1)
+static double restoration_filters_r_kf[RESTORATION_LEVELS_KF + 1]
+ [RESTORATION_RANGE_SYM];
+static double restoration_filters_r[RESTORATION_LEVELS + 1]
+ [RESTORATION_RANGE_SYM];
+static double restoration_filters_s_kf[RESTORATION_LEVELS_KF + 1]
+ [RESTORATION_WIN][RESTORATION_WIN];
+static double restoration_filters_s[RESTORATION_LEVELS + 1]
+ [RESTORATION_WIN][RESTORATION_WIN];
+
+void vp10_loop_restoration_precal() {
int i;
- for (i = 1; i < BILATERAL_LEVELS_KF + 1; i ++) {
- const bilateral_params_t param = vp10_bilateral_level_to_params(i, 1);
+ for (i = 1; i < RESTORATION_LEVELS_KF + 1; i ++) {
+ const restoration_params_t param = vp10_restoration_level_to_params(i, 1);
const int sigma_x = param.sigma_x;
const int sigma_y = param.sigma_y;
const int sigma_r = param.sigma_r;
- const double sigma_r_d = (double)sigma_r / BILATERAL_PRECISION;
- const double sigma_x_d = (double)sigma_x / BILATERAL_PRECISION;
- const double sigma_y_d = (double)sigma_y / BILATERAL_PRECISION;
+ const double sigma_r_d = (double)sigma_r / RESTORATION_PRECISION;
+ const double sigma_x_d = (double)sigma_x / RESTORATION_PRECISION;
+ const double sigma_y_d = (double)sigma_y / RESTORATION_PRECISION;
- double *fr = bilateral_filters_r_kf[i] + BILATERAL_RANGE;
+ double *fr = restoration_filters_r_kf[i] + RESTORATION_RANGE;
int j, x, y;
- for (j = 0; j <= BILATERAL_RANGE; j++) {
+ for (j = 0; j <= RESTORATION_RANGE; j++) {
fr[j] = exp(-(j * j) / (2 * sigma_r_d * sigma_r_d));
fr[-j] = fr[j];
}
- for (y = -BILATERAL_HALFWIN; y <= BILATERAL_HALFWIN; y++) {
- for (x = -BILATERAL_HALFWIN; x <= BILATERAL_HALFWIN; x++) {
- bilateral_filters_s_kf[i][y + BILATERAL_HALFWIN]
- [x + BILATERAL_HALFWIN] =
+ for (y = -RESTORATION_HALFWIN; y <= RESTORATION_HALFWIN; y++) {
+ for (x = -RESTORATION_HALFWIN; x <= RESTORATION_HALFWIN; x++) {
+ restoration_filters_s_kf[i][y + RESTORATION_HALFWIN]
+ [x + RESTORATION_HALFWIN] =
exp(-(x * x) / (2 * sigma_x_d * sigma_x_d)
-(y * y) / (2 * sigma_y_d * sigma_y_d));
}
}
}
- for (i = 1; i < BILATERAL_LEVELS + 1; i ++) {
- const bilateral_params_t param = vp10_bilateral_level_to_params(i, 0);
+ for (i = 1; i < RESTORATION_LEVELS + 1; i ++) {
+ const restoration_params_t param = vp10_restoration_level_to_params(i, 0);
const int sigma_x = param.sigma_x;
const int sigma_y = param.sigma_y;
const int sigma_r = param.sigma_r;
- const double sigma_r_d = (double)sigma_r / BILATERAL_PRECISION;
- const double sigma_x_d = (double)sigma_x / BILATERAL_PRECISION;
- const double sigma_y_d = (double)sigma_y / BILATERAL_PRECISION;
+ const double sigma_r_d = (double)sigma_r / RESTORATION_PRECISION;
+ const double sigma_x_d = (double)sigma_x / RESTORATION_PRECISION;
+ const double sigma_y_d = (double)sigma_y / RESTORATION_PRECISION;
- double *fr = bilateral_filters_r[i] + BILATERAL_RANGE;
+ double *fr = restoration_filters_r[i] + RESTORATION_RANGE;
int j, x, y;
- for (j = 0; j <= BILATERAL_RANGE; j++) {
+ for (j = 0; j <= RESTORATION_RANGE; j++) {
fr[j] = exp(-(j * j) / (2 * sigma_r_d * sigma_r_d));
fr[-j] = fr[j];
}
- for (y = -BILATERAL_HALFWIN; y <= BILATERAL_HALFWIN; y++) {
- for (x = -BILATERAL_HALFWIN; x <= BILATERAL_HALFWIN; x++) {
- bilateral_filters_s[i][y + BILATERAL_HALFWIN][x + BILATERAL_HALFWIN] =
- exp(-(x * x) / (2 * sigma_x_d * sigma_x_d)
- -(y * y) / (2 * sigma_y_d * sigma_y_d));
+ for (y = -RESTORATION_HALFWIN; y <= RESTORATION_HALFWIN; y++) {
+ for (x = -RESTORATION_HALFWIN; x <= RESTORATION_HALFWIN; x++) {
+ restoration_filters_s
+ [i][y + RESTORATION_HALFWIN][x + RESTORATION_HALFWIN] =
+ exp(-(x * x) / (2 * sigma_x_d * sigma_x_d)
+ -(y * y) / (2 * sigma_y_d * sigma_y_d));
}
}
}
}
-int vp10_bilateral_level_bits(const VP10_COMMON *const cm) {
+int vp10_restoration_level_bits(const VP10_COMMON *const cm) {
return cm->frame_type == KEY_FRAME ?
- BILATERAL_LEVEL_BITS_KF : BILATERAL_LEVEL_BITS;
+ RESTORATION_LEVEL_BITS_KF : RESTORATION_LEVEL_BITS;
}
-int vp10_loop_bilateral_used(int level, int kf) {
- const bilateral_params_t param = vp10_bilateral_level_to_params(level, kf);
+int vp10_loop_restoration_used(int level, int kf) {
+ const restoration_params_t param =
+ vp10_restoration_level_to_params(level, kf);
return (param.sigma_x && param.sigma_y && param.sigma_r);
}
-void vp10_loop_bilateral_init(loop_filter_info_n *lfi, int level, int kf) {
- lfi->bilateral_used = vp10_loop_bilateral_used(level, kf);
+void vp10_loop_restoration_init(loop_filter_info_n *lfi, int level, int kf) {
+ lfi->restoration_used = vp10_loop_restoration_used(level, kf);
- if (lfi->bilateral_used) {
+ if (lfi->restoration_used) {
int i;
- lfi->wr_lut = kf ? bilateral_filters_r_kf[level] :
- bilateral_filters_r[level];
- for (i = 0; i < BILATERAL_WIN; i++)
- lfi->wx_lut[i] = kf ? bilateral_filters_s_kf[level][i] :
- bilateral_filters_s[level][i];
+ lfi->wr_lut = kf ? restoration_filters_r_kf[level] :
+ restoration_filters_r[level];
+ for (i = 0; i < RESTORATION_WIN; i++)
+ lfi->wx_lut[i] = kf ? restoration_filters_s_kf[level][i] :
+ restoration_filters_s[level][i];
}
}
return (x >= 0 && x < width && y >= 0 && y < height);
}
-void loop_bilateral_filter(uint8_t *data, int width, int height,
- int stride, loop_filter_info_n *lfi,
- uint8_t *tmpdata, int tmpstride) {
+void loop_restoration_filter(uint8_t *data, int width, int height,
+ int stride, loop_filter_info_n *lfi,
+ uint8_t *tmpdata, int tmpstride) {
int i, j;
- const double *wr_lut_ = lfi->wr_lut + 256;
+ const double *wr_lut_ = lfi->wr_lut + RESTORATION_RANGE;
uint8_t *data_p = data;
uint8_t *tmpdata_p = tmpdata;
for (j = 0; j < width; ++j) {
int x, y;
double flsum = 0, wtsum = 0, wt;
- uint8_t *data_p2 = data_p + j - BILATERAL_HALFWIN * stride;
- for (y = -BILATERAL_HALFWIN; y <= BILATERAL_HALFWIN; ++y) {
- for (x = -BILATERAL_HALFWIN; x <= BILATERAL_HALFWIN; ++x) {
+ uint8_t *data_p2 = data_p + j - RESTORATION_HALFWIN * stride;
+ for (y = -RESTORATION_HALFWIN; y <= RESTORATION_HALFWIN; ++y) {
+ for (x = -RESTORATION_HALFWIN; x <= RESTORATION_HALFWIN; ++x) {
if (!is_in_image(j + x, i + y, width, height))
continue;
- wt = lfi->wx_lut[y + BILATERAL_HALFWIN][x + BILATERAL_HALFWIN] *
+ wt = lfi->wx_lut[y + RESTORATION_HALFWIN][x + RESTORATION_HALFWIN] *
wr_lut_[data_p2[x] - data_p[j]];
wtsum += wt;
flsum += wt * data_p2[x];
}
}
-#if CONFIG_VP9_HIGHBITDEPTH
-void loop_bilateral_filter_highbd(uint8_t *data8, int width, int height,
+// Normalized non-separable filter where weights all sum to 1
+void loop_restoration_filter_norm(uint8_t *data, int width, int height,
int stride, loop_filter_info_n *lfi,
- uint8_t *tmpdata8, int tmpstride,
- int bit_depth) {
+ uint8_t *tmpdata, int tmpstride) {
+ int i, j;
+ uint8_t *data_p = data;
+ uint8_t *tmpdata_p = tmpdata;
+ for (i = RESTORATION_HALFWIN; i < height - RESTORATION_HALFWIN; ++i) {
+ for (j = RESTORATION_HALFWIN; j < width - RESTORATION_HALFWIN; ++j) {
+ int x, y;
+ double flsum = 0;
+ uint8_t *data_p2 = data_p + j - RESTORATION_HALFWIN * stride;
+ for (y = -RESTORATION_HALFWIN; y <= RESTORATION_HALFWIN; ++y) {
+ for (x = -RESTORATION_HALFWIN; x <= RESTORATION_HALFWIN; ++x) {
+ flsum += data_p2[x] *
+ lfi->wx_lut[y + RESTORATION_HALFWIN][x + RESTORATION_HALFWIN];
+ }
+ data_p2 += stride;
+ }
+ tmpdata_p[j] = clip_pixel((int)(flsum + 0.5));
+ }
+ tmpdata_p += tmpstride;
+ data_p += stride;
+ }
+ for (i = 0; i < height; ++i) {
+ memcpy(data + i * stride, tmpdata + i * tmpstride,
+ width * sizeof(*data));
+ }
+}
+
+#if CONFIG_VP9_HIGHBITDEPTH
+void loop_restoration_filter_highbd(uint8_t *data8, int width, int height,
+ int stride, loop_filter_info_n *lfi,
+ uint8_t *tmpdata8, int tmpstride,
+ int bit_depth) {
int i, j;
- const double *wr_lut_ = lfi->wr_lut + 256;
+ const double *wr_lut_ = lfi->wr_lut + RESTORATION_RANGE;
uint16_t *data = CONVERT_TO_SHORTPTR(data8);
uint16_t *tmpdata = CONVERT_TO_SHORTPTR(tmpdata8);
for (j = 0; j < width; ++j) {
int x, y, diff_r;
double flsum = 0, wtsum = 0, wt;
- uint16_t *data_p2 = data_p + j - BILATERAL_HALFWIN * stride;
+ uint16_t *data_p2 = data_p + j - RESTORATION_HALFWIN * stride;
- for (y = -BILATERAL_HALFWIN; y <= BILATERAL_HALFWIN; ++y) {
- for (x = -BILATERAL_HALFWIN; x <= BILATERAL_HALFWIN; ++x) {
+ for (y = -RESTORATION_HALFWIN; y <= RESTORATION_HALFWIN; ++y) {
+ for (x = -RESTORATION_HALFWIN; x <= RESTORATION_HALFWIN; ++x) {
if (!is_in_image(j + x, i + y, width, height))
continue;
diff_r = (data_p2[x] - data_p[j]) >> (bit_depth - 8);
- assert(diff_r >= -256 && diff_r <= 256);
+ assert(diff_r >= -RESTORATION_RANGE && diff_r <= RESTORATION_RANGE);
- wt = lfi->wx_lut[y + BILATERAL_HALFWIN][x + BILATERAL_HALFWIN] *
+ wt = lfi->wx_lut[y + RESTORATION_HALFWIN][x + RESTORATION_HALFWIN] *
wr_lut_[diff_r];
wtsum += wt;
flsum += wt * data_p2[x];
tmpdata_p += tmpstride;
data_p += stride;
}
+ for (i = 0; i < height; ++i) {
+ memcpy(data + i * stride, tmpdata + i * tmpstride,
+ width * sizeof(*data));
+ }
+}
+// Normalized non-separable filter where weights all sum to 1
+void loop_restoration_filter_norm(uint8_t *data8, int width, int height,
+ int stride, loop_filter_info_n *lfi,
+ uint8_t *tmpdata8, int tmpstride) {
+ int i, j;
+ uint16_t *data = CONVERT_TO_SHORTPTR(data8);
+ uint16_t *tmpdata = CONVERT_TO_SHORTPTR(tmpdata8);
+ uint16_t *data_p = data;
+ uint16_t *tmpdata_p = tmpdata;
+ for (i = RESTORATION_HALFWIN; i < height - RESTORATION_HALFWIN; ++i) {
+ for (j = RESTORATION_HALFWIN; j < width - RESTORATION_HALFWIN; ++j) {
+ int x, y;
+ double flsum = 0;
+ uint16_t *data_p2 = data_p + j - RESTORATION_HALFWIN * stride;
+ for (y = -RESTORATION_HALFWIN; y <= RESTORATION_HALFWIN; ++y) {
+ for (x = -RESTORATION_HALFWIN; x <= RESTORATION_HALFWIN; ++x) {
+ flsum += data_p2[x] *
+ lfi->wx_lut[y + RESTORATION_HALFWIN][x + RESTORATION_HALFWIN];
+ }
+ data_p2 += stride;
+ }
+ tmpdata_p[j] = (int)(flsum + 0.5);
+ }
+ tmpdata_p += tmpstride;
+ data_p += stride;
+ }
for (i = 0; i < height; ++i) {
memcpy(data + i * stride, tmpdata + i * tmpstride,
width * sizeof(*data));
}
#endif // CONFIG_VP9_HIGHBITDEPTH
-void vp10_loop_bilateral_rows(YV12_BUFFER_CONFIG *frame,
- VP10_COMMON *cm,
- int start_mi_row, int end_mi_row,
- int y_only) {
+void vp10_loop_restoration_rows(YV12_BUFFER_CONFIG *frame,
+ VP10_COMMON *cm,
+ int start_mi_row, int end_mi_row,
+ int y_only) {
const int ywidth = frame->y_crop_width;
const int ystride = frame->y_stride;
const int uvwidth = frame->uv_crop_width;
#if CONFIG_VP9_HIGHBITDEPTH
if (cm->use_highbitdepth)
- loop_bilateral_filter_highbd(frame->y_buffer + ystart * ystride,
- ywidth, yend - ystart, ystride, &cm->lf_info,
- tmp_buf->y_buffer + ystart * tmp_buf->y_stride,
- tmp_buf->y_stride, cm->bit_depth);
+ loop_restoration_filter_highbd(
+ frame->y_buffer + ystart * ystride,
+ ywidth, yend - ystart, ystride, &cm->lf_info,
+ tmp_buf->y_buffer + ystart * tmp_buf->y_stride,
+ tmp_buf->y_stride, cm->bit_depth);
else
#endif // CONFIG_VP9_HIGHBITDEPTH
- loop_bilateral_filter(frame->y_buffer + ystart * ystride,
- ywidth, yend - ystart, ystride, &cm->lf_info,
- tmp_buf->y_buffer + ystart * tmp_buf->y_stride,
- tmp_buf->y_stride);
+ loop_restoration_filter(
+ frame->y_buffer + ystart * ystride,
+ ywidth, yend - ystart, ystride, &cm->lf_info,
+ tmp_buf->y_buffer + ystart * tmp_buf->y_stride,
+ tmp_buf->y_stride);
if (!y_only) {
#if CONFIG_VP9_HIGHBITDEPTH
- if (cm->use_highbitdepth) {
- loop_bilateral_filter_highbd(
- frame->u_buffer + uvstart * uvstride,
- uvwidth, uvend - uvstart, uvstride, &cm->lf_info,
- tmp_buf->u_buffer + uvstart * tmp_buf->uv_stride,
- tmp_buf->uv_stride, cm->bit_depth);
- loop_bilateral_filter_highbd(
- frame->v_buffer + uvstart * uvstride,
- uvwidth, uvend - uvstart, uvstride, &cm->lf_info,
- tmp_buf->v_buffer + uvstart * tmp_buf->uv_stride,
- tmp_buf->uv_stride, cm->bit_depth);
+ if (cm->use_highbitdepth) {
+ loop_restoration_filter_highbd(
+ frame->u_buffer + uvstart * uvstride,
+ uvwidth, uvend - uvstart, uvstride, &cm->lf_info,
+ tmp_buf->u_buffer + uvstart * tmp_buf->uv_stride,
+ tmp_buf->uv_stride, cm->bit_depth);
+ loop_restoration_filter_highbd(
+ frame->v_buffer + uvstart * uvstride,
+ uvwidth, uvend - uvstart, uvstride, &cm->lf_info,
+ tmp_buf->v_buffer + uvstart * tmp_buf->uv_stride,
+ tmp_buf->uv_stride, cm->bit_depth);
} else {
#endif // CONFIG_VP9_HIGHBITDEPTH
- loop_bilateral_filter(frame->u_buffer + uvstart * uvstride,
- uvwidth, uvend - uvstart, uvstride, &cm->lf_info,
- tmp_buf->u_buffer + uvstart * tmp_buf->uv_stride,
- tmp_buf->uv_stride);
- loop_bilateral_filter(frame->v_buffer + uvstart * uvstride,
- uvwidth, uvend - uvstart, uvstride, &cm->lf_info,
- tmp_buf->v_buffer + uvstart * tmp_buf->uv_stride,
- tmp_buf->uv_stride);
+ loop_restoration_filter(
+ frame->u_buffer + uvstart * uvstride,
+ uvwidth, uvend - uvstart, uvstride, &cm->lf_info,
+ tmp_buf->u_buffer + uvstart * tmp_buf->uv_stride,
+ tmp_buf->uv_stride);
+ loop_restoration_filter(
+ frame->v_buffer + uvstart * uvstride,
+ uvwidth, uvend - uvstart, uvstride, &cm->lf_info,
+ tmp_buf->v_buffer + uvstart * tmp_buf->uv_stride,
+ tmp_buf->uv_stride);
#if CONFIG_VP9_HIGHBITDEPTH
}
#endif // CONFIG_VP9_HIGHBITDEPTH
memset(lfi->lfthr[lvl].hev_thr, (lvl >> 4), SIMD_WIDTH);
#if CONFIG_LOOP_RESTORATION
- vp10_loop_bilateral_precal();
+ vp10_loop_restoration_precal();
#endif // CONFIG_LOOP_RESTORATION
}
}
#if CONFIG_LOOP_RESTORATION
-void vp10_loop_bilateral_frame(YV12_BUFFER_CONFIG *frame,
+void vp10_loop_restoration_frame(YV12_BUFFER_CONFIG *frame,
VP10_COMMON *cm,
- int bilateral_level,
+ int restoration_level,
int y_only, int partial_frame) {
int start_mi_row, end_mi_row, mi_rows_to_filter;
- // const int loop_bilateral_used = vp10_loop_bilateral_used(
- // bilateral_level, cm->frame_type == KEY_FRAME);
- vp10_loop_bilateral_init(&cm->lf_info, bilateral_level,
+ // const int loop_restoration_used = vp10_loop_restoration_used(
+ // restoration_level, cm->frame_type == KEY_FRAME);
+ vp10_loop_restoration_init(&cm->lf_info, restoration_level,
cm->frame_type == KEY_FRAME);
- if (!cm->lf_info.bilateral_used)
+ if (!cm->lf_info.restoration_used)
return;
start_mi_row = 0;
mi_rows_to_filter = cm->mi_rows;
mi_rows_to_filter = VPXMAX(cm->mi_rows / 8, 8);
}
end_mi_row = start_mi_row + mi_rows_to_filter;
- vp10_loop_bilateral_rows(frame, cm, start_mi_row, end_mi_row, y_only);
+ vp10_loop_restoration_rows(frame, cm, start_mi_row, end_mi_row, y_only);
}
#endif // CONFIG_LOOP_RESTORATION
#define MAX_MODE_LF_DELTAS 2
#if CONFIG_LOOP_RESTORATION
-#define BILATERAL_LEVEL_BITS_KF 4
-#define BILATERAL_LEVELS_KF (1 << BILATERAL_LEVEL_BITS_KF)
-#define BILATERAL_LEVEL_BITS 3
-#define BILATERAL_LEVELS (1 << BILATERAL_LEVEL_BITS)
-#define DEF_BILATERAL_LEVEL 2
+#define RESTORATION_LEVEL_BITS_KF 4
+#define RESTORATION_LEVELS_KF (1 << RESTORATION_LEVEL_BITS_KF)
+#define RESTORATION_LEVEL_BITS 3
+#define RESTORATION_LEVELS (1 << RESTORATION_LEVEL_BITS)
+#define DEF_RESTORATION_LEVEL 2
-#define BILATERAL_PRECISION 16
-#define BILATERAL_HALFWIN 3
-#define BILATERAL_WIN (2 * BILATERAL_HALFWIN + 1)
+#define RESTORATION_PRECISION 16
+#define RESTORATION_HALFWIN 3
+#define RESTORATION_WIN (2 * RESTORATION_HALFWIN + 1)
-typedef struct bilateral_params {
+typedef struct restoration_params {
int sigma_x; // spatial variance x
int sigma_y; // spatial variance y
int sigma_r; // range variance
-} bilateral_params_t;
+} restoration_params_t;
-static bilateral_params_t
- bilateral_level_to_params_arr[BILATERAL_LEVELS + 1] = {
+static restoration_params_t
+ restoration_level_to_params_arr[RESTORATION_LEVELS + 1] = {
// Values are rounded to 1/16 th precision
{0, 0, 0}, // 0 - default
{8, 9, 30},
{32, 32, 40},
};
-static bilateral_params_t
- bilateral_level_to_params_arr_kf[BILATERAL_LEVELS_KF + 1] = {
+static restoration_params_t
+ restoration_level_to_params_arr_kf[RESTORATION_LEVELS_KF + 1] = {
// Values are rounded to 1/16 th precision
{0, 0, 0}, // 0 - default
{8, 8, 30},
{64, 64, 48},
};
-int vp10_bilateral_level_bits(const struct VP10Common *const cm);
-int vp10_loop_bilateral_used(int level, int kf);
+int vp10_restoration_level_bits(const struct VP10Common *const cm);
+int vp10_loop_restoration_used(int level, int kf);
-static INLINE bilateral_params_t vp10_bilateral_level_to_params(
+static INLINE restoration_params_t vp10_restoration_level_to_params(
int index, int kf) {
- return kf ? bilateral_level_to_params_arr_kf[index] :
- bilateral_level_to_params_arr[index];
+ return kf ? restoration_level_to_params_arr_kf[index] :
+ restoration_level_to_params_arr[index];
}
#endif // CONFIG_LOOP_RESTORATION
signed char last_mode_deltas[MAX_MODE_LF_DELTAS];
#if CONFIG_LOOP_RESTORATION
- int bilateral_level;
- int last_bilateral_level;
+ int restoration_level;
+ int last_restoration_level;
#endif // CONFIG_LOOP_RESTORATION
};
loop_filter_thresh lfthr[MAX_LOOP_FILTER + 1];
uint8_t lvl[MAX_SEGMENTS][MAX_REF_FRAMES][MAX_MODE_LF_DELTAS];
#if CONFIG_LOOP_RESTORATION
- double * wx_lut[BILATERAL_WIN];
- double * wr_lut;
- int bilateral_sigma_x_set;
- int bilateral_sigma_y_set;
- int bilateral_sigma_r_set;
- int bilateral_used;
+ double *wx_lut[RESTORATION_WIN];
+ double *wr_lut;
+ int restoration_sigma_x_set;
+ int restoration_sigma_y_set;
+ int restoration_sigma_r_set;
+ int restoration_used;
#endif // CONFIG_LOOP_RESTORATION
} loop_filter_info_n;
void vp10_loop_filter_frame_init(struct VP10Common *cm, int default_filt_lvl);
void vp10_loop_filter_frame(YV12_BUFFER_CONFIG *frame,
- struct VP10Common *cm,
- struct macroblockd *mbd,
- int filter_level,
- int y_only, int partial_frame);
+ struct VP10Common *cm,
+ struct macroblockd *mbd,
+ int filter_level,
+ int y_only, int partial_frame);
// Apply the loop filter to [start, stop) macro block rows in frame_buffer.
void vp10_loop_filter_rows(YV12_BUFFER_CONFIG *frame_buffer,
- struct VP10Common *cm,
- struct macroblockd_plane planes[MAX_MB_PLANE],
- int start, int stop, int y_only);
+ struct VP10Common *cm,
+ struct macroblockd_plane planes[MAX_MB_PLANE],
+ int start, int stop, int y_only);
#if CONFIG_LOOP_RESTORATION
-void vp10_loop_bilateral_frame(YV12_BUFFER_CONFIG *frame,
- struct VP10Common *cm,
- int bilateral_level,
- int y_only, int partial_frame);
-void vp10_loop_filter_bilateral_frame(YV12_BUFFER_CONFIG *frame,
- struct VP10Common *cm,
- struct macroblockd *mbd,
- int frame_filter_level,
- int bilateral_level,
- int y_only, int partial_frame);
-void vp10_loop_bilateral_init(loop_filter_info_n *lfi, int T, int kf);
-void vp10_loop_bilateral_rows(YV12_BUFFER_CONFIG *frame,
- struct VP10Common *cm,
- int start_mi_row, int end_mi_row,
- int y_only);
+void vp10_loop_restoration_frame(YV12_BUFFER_CONFIG *frame,
+ struct VP10Common *cm,
+ int restoration_level,
+ int y_only, int partial_frame);
+void vp10_loop_filter_restoration_frame(YV12_BUFFER_CONFIG *frame,
+ struct VP10Common *cm,
+ struct macroblockd *mbd,
+ int frame_filter_level,
+ int restoration_level,
+ int y_only, int partial_frame);
+void vp10_loop_restoration_init(loop_filter_info_n *lfi, int T, int kf);
+void vp10_loop_restoration_rows(YV12_BUFFER_CONFIG *frame,
+ struct VP10Common *cm,
+ int start_mi_row, int end_mi_row,
+ int y_only);
#endif // CONFIG_LOOP_RESTORATION
typedef struct LoopFilterWorkerData {
}
#if CONFIG_LOOP_RESTORATION
-#define JOINT_FILTER_BILATERAL_SEARCH
+#define JOINT_FILTER_RESTORATION_SEARCH
#define USE_RD_LOOP_POSTFILTER_SEARCH
-static int try_bilateral_frame(const YV12_BUFFER_CONFIG *sd,
- VP10_COMP *const cpi,
- int bilateral_level,
- int partial_frame) {
+static int try_restoration_frame(const YV12_BUFFER_CONFIG *sd,
+ VP10_COMP *const cpi,
+ int restoration_level,
+ int partial_frame) {
VP10_COMMON *const cm = &cpi->common;
int filt_err;
- vp10_loop_bilateral_frame(cm->frame_to_show, cm,
- bilateral_level, 1, partial_frame);
+ vp10_loop_restoration_frame(cm->frame_to_show, cm,
+ restoration_level, 1, partial_frame);
#if CONFIG_VP9_HIGHBITDEPTH
if (cm->use_highbitdepth) {
filt_err = vp10_highbd_get_y_sse(sd, cm->frame_to_show);
return filt_err;
}
-static int search_bilateral_level(const YV12_BUFFER_CONFIG *sd,
- VP10_COMP *cpi,
- int filter_level, int partial_frame,
- double *best_cost_ret) {
+static int search_restoration_level(const YV12_BUFFER_CONFIG *sd,
+ VP10_COMP *cpi,
+ int filter_level, int partial_frame,
+ double *best_cost_ret) {
VP10_COMMON *const cm = &cpi->common;
- int i, bilateral_best, err;
+ int i, restoration_best, err;
double best_cost;
double cost;
- const int bilateral_level_bits = vp10_bilateral_level_bits(&cpi->common);
- const int bilateral_levels = 1 << bilateral_level_bits;
+ const int restoration_level_bits = vp10_restoration_level_bits(&cpi->common);
+ const int restoration_levels = 1 << restoration_level_bits;
#ifdef USE_RD_LOOP_POSTFILTER_SEARCH
MACROBLOCK *x = &cpi->td.mb;
int bits;
1, partial_frame);
vpx_yv12_copy_y(cm->frame_to_show, &cpi->last_frame_db);
- bilateral_best = 0;
- err = try_bilateral_frame(sd, cpi, 0, partial_frame);
+ restoration_best = 0;
+ err = try_restoration_frame(sd, cpi, 0, partial_frame);
#ifdef USE_RD_LOOP_POSTFILTER_SEARCH
- bits = cm->lf.last_bilateral_level == 0 ? 0 : bilateral_level_bits;
+ bits = cm->lf.last_restoration_level == 0 ? 0 : restoration_level_bits;
cost = RDCOST_DBL(x->rdmult, x->rddiv, (bits << 2), err);
#else
cost = (double)err;
#endif // USE_RD_LOOP_POSTFILTER_SEARCH
best_cost = cost;
- for (i = 1; i <= bilateral_levels; ++i) {
- err = try_bilateral_frame(sd, cpi, i, partial_frame);
+ for (i = 1; i <= restoration_levels; ++i) {
+ err = try_restoration_frame(sd, cpi, i, partial_frame);
#ifdef USE_RD_LOOP_POSTFILTER_SEARCH
// Normally the rate is rate in bits * 256 and dist is sum sq err * 64
// when RDCOST is used. However below we just scale both in the correct
// ratios appropriately but not exactly by these values.
- bits = cm->lf.last_bilateral_level == i ? 0 : bilateral_level_bits;
+ bits = cm->lf.last_restoration_level == i ? 0 : restoration_level_bits;
cost = RDCOST_DBL(x->rdmult, x->rddiv, (bits << 2), err);
#else
cost = (double)err;
#endif // USE_RD_LOOP_POSTFILTER_SEARCH
if (cost < best_cost) {
- bilateral_best = i;
+ restoration_best = i;
best_cost = cost;
}
}
if (best_cost_ret) *best_cost_ret = best_cost;
vpx_yv12_copy_y(&cpi->last_frame_uf, cm->frame_to_show);
- return bilateral_best;
+ return restoration_best;
}
-#ifdef JOINT_FILTER_BILATERAL_SEARCH
-static int search_filter_bilateral_level(const YV12_BUFFER_CONFIG *sd,
- VP10_COMP *cpi,
- int partial_frame,
- int *bilateral_level) {
+#ifdef JOINT_FILTER_RESTORATION_SEARCH
+static int search_filter_restoration_level(const YV12_BUFFER_CONFIG *sd,
+ VP10_COMP *cpi,
+ int partial_frame,
+ int *restoration_level) {
const VP10_COMMON *const cm = &cpi->common;
const struct loopfilter *const lf = &cm->lf;
const int min_filter_level = 0;
const int max_filter_level = get_max_filter_level(cpi);
int filt_direction = 0;
- int filt_best, bilateral_best;
+ int filt_best, restoration_best;
double best_err;
int i;
for (i = 0; i <= MAX_LOOP_FILTER; ++i)
ss_err[i] = -1.0;
- bilateral = search_bilateral_level(sd, cpi, filt_mid,
- partial_frame, &best_err);
+ bilateral = search_restoration_level(sd, cpi, filt_mid,
+ partial_frame, &best_err);
filt_best = filt_mid;
- bilateral_best = bilateral;
+ restoration_best = bilateral;
ss_err[filt_mid] = best_err;
while (filter_step > 0) {
if (filt_direction <= 0 && filt_low != filt_mid) {
// Get Low filter error score
if (ss_err[filt_low] < 0) {
- bilateral = search_bilateral_level(sd, cpi, filt_low,
- partial_frame,
- &ss_err[filt_low]);
+ bilateral = search_restoration_level(sd, cpi, filt_low,
+ partial_frame,
+ &ss_err[filt_low]);
}
// If value is close to the best so far then bias towards a lower loop
// filter value.
}
filt_best = filt_low;
- bilateral_best = bilateral;
+ restoration_best = bilateral;
}
}
// Now look at filt_high
if (filt_direction >= 0 && filt_high != filt_mid) {
if (ss_err[filt_high] < 0) {
- bilateral = search_bilateral_level(sd, cpi, filt_high, partial_frame,
- &ss_err[filt_high]);
+ bilateral = search_restoration_level(sd, cpi, filt_high, partial_frame,
+ &ss_err[filt_high]);
}
// Was it better than the previous best?
if (ss_err[filt_high] < (best_err - bias)) {
best_err = ss_err[filt_high];
filt_best = filt_high;
- bilateral_best = bilateral;
+ restoration_best = bilateral;
}
}
filt_mid = filt_best;
}
}
- *bilateral_level = bilateral_best;
+ *restoration_level = restoration_best;
return filt_best;
}
-#endif // JOINT_FILTER_BILATERAL_SEARCH
+#endif // JOINT_FILTER_RESTORATION_SEARCH
#endif // CONFIG_LOOP_RESTORATION
static int search_filter_level(const YV12_BUFFER_CONFIG *sd, VP10_COMP *cpi,
filt_guess -= 4;
lf->filter_level = clamp(filt_guess, min_filter_level, max_filter_level);
#if CONFIG_LOOP_RESTORATION
- lf->bilateral_level = search_bilateral_level(
+ lf->restoration_level = search_restoration_level(
sd, cpi, lf->filter_level, method == LPF_PICK_FROM_SUBIMAGE, NULL);
#endif // CONFIG_LOOP_RESTORATION
} else {
#if CONFIG_LOOP_RESTORATION
-#ifdef JOINT_FILTER_BILATERAL_SEARCH
- lf->filter_level = search_filter_bilateral_level(
- sd, cpi, method == LPF_PICK_FROM_SUBIMAGE, &lf->bilateral_level);
+#ifdef JOINT_FILTER_RESTORATION_SEARCH
+ lf->filter_level = search_filter_restoration_level(
+ sd, cpi, method == LPF_PICK_FROM_SUBIMAGE, &lf->restoration_level);
#else
lf->filter_level = search_filter_level(
sd, cpi, method == LPF_PICK_FROM_SUBIMAGE);
- lf->bilateral_level = search_bilateral_level(
+ lf->restoration_level = search_restoration_level(
sd, cpi, lf->filter_level, method == LPF_PICK_FROM_SUBIMAGE, NULL);
-#endif // JOINT_FILTER_BILATERAL_SEARCH
+#endif // JOINT_FILTER_RESTORATION_SEARCH
#else
lf->filter_level = search_filter_level(
sd, cpi, method == LPF_PICK_FROM_SUBIMAGE);