Commit 32d150b6 authored by Rupert Swarbrick's avatar Rupert Swarbrick Committed by Debargha Mukherjee
Browse files

Fix loop-restoration with 8-bit data on highbd path

The code was incorrectly using "bit_depth == 8" as a test for whether
to use the highbd path or not.

BUG=aomedia:714

Change-Id: Ib3995dcda949adfe9307bc4c8273c6c375c5a2c7
parent 6c545216
...@@ -174,14 +174,14 @@ static int64_t try_restoration_frame(const YV12_BUFFER_CONFIG *src, ...@@ -174,14 +174,14 @@ static int64_t try_restoration_frame(const YV12_BUFFER_CONFIG *src,
static int64_t get_pixel_proj_error(const uint8_t *src8, int width, int height, static int64_t get_pixel_proj_error(const uint8_t *src8, int width, int height,
int src_stride, const uint8_t *dat8, int src_stride, const uint8_t *dat8,
int dat_stride, int bit_depth, int dat_stride, int use_highbitdepth,
int32_t *flt1, int flt1_stride, int32_t *flt1, int flt1_stride,
int32_t *flt2, int flt2_stride, int *xqd) { int32_t *flt2, int flt2_stride, int *xqd) {
int i, j; int i, j;
int64_t err = 0; int64_t err = 0;
int xq[2]; int xq[2];
decode_xq(xqd, xq); decode_xq(xqd, xq);
if (bit_depth == 8) { if (!use_highbitdepth) {
const uint8_t *src = src8; const uint8_t *src = src8;
const uint8_t *dat = dat8; const uint8_t *dat = dat8;
for (i = 0; i < height; ++i) { for (i = 0; i < height; ++i) {
...@@ -220,11 +220,11 @@ static int64_t get_pixel_proj_error(const uint8_t *src8, int width, int height, ...@@ -220,11 +220,11 @@ static int64_t get_pixel_proj_error(const uint8_t *src8, int width, int height,
#define USE_SGRPROJ_REFINEMENT_SEARCH 1 #define USE_SGRPROJ_REFINEMENT_SEARCH 1
static int64_t finer_search_pixel_proj_error( static int64_t finer_search_pixel_proj_error(
const uint8_t *src8, int width, int height, int src_stride, const uint8_t *src8, int width, int height, int src_stride,
const uint8_t *dat8, int dat_stride, int bit_depth, int32_t *flt1, const uint8_t *dat8, int dat_stride, int use_highbitdepth, int32_t *flt1,
int flt1_stride, int32_t *flt2, int flt2_stride, int start_step, int *xqd) { int flt1_stride, int32_t *flt2, int flt2_stride, int start_step, int *xqd) {
int64_t err = get_pixel_proj_error(src8, width, height, src_stride, dat8, int64_t err = get_pixel_proj_error(src8, width, height, src_stride, dat8,
dat_stride, bit_depth, flt1, flt1_stride, dat_stride, use_highbitdepth, flt1,
flt2, flt2_stride, xqd); flt1_stride, flt2, flt2_stride, xqd);
(void)start_step; (void)start_step;
#if USE_SGRPROJ_REFINEMENT_SEARCH #if USE_SGRPROJ_REFINEMENT_SEARCH
int64_t err2; int64_t err2;
...@@ -237,8 +237,8 @@ static int64_t finer_search_pixel_proj_error( ...@@ -237,8 +237,8 @@ static int64_t finer_search_pixel_proj_error(
if (xqd[p] - s >= tap_min[p]) { if (xqd[p] - s >= tap_min[p]) {
xqd[p] -= s; xqd[p] -= s;
err2 = get_pixel_proj_error(src8, width, height, src_stride, dat8, err2 = get_pixel_proj_error(src8, width, height, src_stride, dat8,
dat_stride, bit_depth, flt1, flt1_stride, dat_stride, use_highbitdepth, flt1,
flt2, flt2_stride, xqd); flt1_stride, flt2, flt2_stride, xqd);
if (err2 > err) { if (err2 > err) {
xqd[p] += s; xqd[p] += s;
} else { } else {
...@@ -255,8 +255,8 @@ static int64_t finer_search_pixel_proj_error( ...@@ -255,8 +255,8 @@ static int64_t finer_search_pixel_proj_error(
if (xqd[p] + s <= tap_max[p]) { if (xqd[p] + s <= tap_max[p]) {
xqd[p] += s; xqd[p] += s;
err2 = get_pixel_proj_error(src8, width, height, src_stride, dat8, err2 = get_pixel_proj_error(src8, width, height, src_stride, dat8,
dat_stride, bit_depth, flt1, flt1_stride, dat_stride, use_highbitdepth, flt1,
flt2, flt2_stride, xqd); flt1_stride, flt2, flt2_stride, xqd);
if (err2 > err) { if (err2 > err) {
xqd[p] -= s; xqd[p] -= s;
} else { } else {
...@@ -275,8 +275,9 @@ static int64_t finer_search_pixel_proj_error( ...@@ -275,8 +275,9 @@ static int64_t finer_search_pixel_proj_error(
static void get_proj_subspace(const uint8_t *src8, int width, int height, static void get_proj_subspace(const uint8_t *src8, int width, int height,
int src_stride, uint8_t *dat8, int dat_stride, int src_stride, uint8_t *dat8, int dat_stride,
int bit_depth, int32_t *flt1, int flt1_stride, int use_highbitdepth, int32_t *flt1,
int32_t *flt2, int flt2_stride, int *xq) { int flt1_stride, int32_t *flt2, int flt2_stride,
int *xq) {
int i, j; int i, j;
double H[2][2] = { { 0, 0 }, { 0, 0 } }; double H[2][2] = { { 0, 0 }, { 0, 0 } };
double C[2] = { 0, 0 }; double C[2] = { 0, 0 };
...@@ -289,7 +290,7 @@ static void get_proj_subspace(const uint8_t *src8, int width, int height, ...@@ -289,7 +290,7 @@ static void get_proj_subspace(const uint8_t *src8, int width, int height,
// Default // Default
xq[0] = 0; xq[0] = 0;
xq[1] = 0; xq[1] = 0;
if (bit_depth == 8) { if (!use_highbitdepth) {
const uint8_t *src = src8; const uint8_t *src = src8;
const uint8_t *dat = dat8; const uint8_t *dat = dat8;
for (i = 0; i < height; ++i) { for (i = 0; i < height; ++i) {
...@@ -347,8 +348,9 @@ void encode_xq(int *xq, int *xqd) { ...@@ -347,8 +348,9 @@ void encode_xq(int *xq, int *xqd) {
static void search_selfguided_restoration(uint8_t *dat8, int width, int height, static void search_selfguided_restoration(uint8_t *dat8, int width, int height,
int dat_stride, const uint8_t *src8, int dat_stride, const uint8_t *src8,
int src_stride, int bit_depth, int src_stride, int use_highbitdepth,
int *eps, int *xqd, int32_t *rstbuf) { int bit_depth, int *eps, int *xqd,
int32_t *rstbuf) {
int32_t *flt1 = rstbuf; int32_t *flt1 = rstbuf;
int32_t *flt2 = flt1 + RESTORATION_TILEPELS_MAX; int32_t *flt2 = flt1 + RESTORATION_TILEPELS_MAX;
int32_t *tmpbuf2 = flt2 + RESTORATION_TILEPELS_MAX; int32_t *tmpbuf2 = flt2 + RESTORATION_TILEPELS_MAX;
...@@ -359,7 +361,7 @@ static void search_selfguided_restoration(uint8_t *dat8, int width, int height, ...@@ -359,7 +361,7 @@ static void search_selfguided_restoration(uint8_t *dat8, int width, int height,
for (ep = 0; ep < SGRPROJ_PARAMS; ep++) { for (ep = 0; ep < SGRPROJ_PARAMS; ep++) {
int exq[2]; int exq[2];
#if CONFIG_HIGHBITDEPTH #if CONFIG_HIGHBITDEPTH
if (bit_depth > 8) { if (use_highbitdepth) {
uint16_t *dat = CONVERT_TO_SHORTPTR(dat8); uint16_t *dat = CONVERT_TO_SHORTPTR(dat8);
#if USE_HIGHPASS_IN_SGRPROJ #if USE_HIGHPASS_IN_SGRPROJ
av1_highpass_filter_highbd(dat, width, height, dat_stride, flt1, width, av1_highpass_filter_highbd(dat, width, height, dat_stride, flt1, width,
...@@ -388,7 +390,7 @@ static void search_selfguided_restoration(uint8_t *dat8, int width, int height, ...@@ -388,7 +390,7 @@ static void search_selfguided_restoration(uint8_t *dat8, int width, int height,
#endif #endif
aom_clear_system_state(); aom_clear_system_state();
get_proj_subspace(src8, width, height, src_stride, dat8, dat_stride, get_proj_subspace(src8, width, height, src_stride, dat8, dat_stride,
bit_depth, flt1, width, flt2, width, exq); use_highbitdepth, flt1, width, flt2, width, exq);
aom_clear_system_state(); aom_clear_system_state();
encode_xq(exq, exqd); encode_xq(exq, exqd);
err = finer_search_pixel_proj_error(src8, width, height, src_stride, dat8, err = finer_search_pixel_proj_error(src8, width, height, src_stride, dat8,
...@@ -558,9 +560,9 @@ static void search_sgrproj_for_rtile(const struct rest_search_ctxt *ctxt, ...@@ -558,9 +560,9 @@ static void search_sgrproj_for_rtile(const struct rest_search_ctxt *ctxt,
search_selfguided_restoration(dgd_start, h_end - h_start, v_end - v_start, search_selfguided_restoration(dgd_start, h_end - h_start, v_end - v_start,
ctxt->dgd_stride, src_start, ctxt->src_stride, ctxt->dgd_stride, src_start, ctxt->src_stride,
#if CONFIG_HIGHBITDEPTH #if CONFIG_HIGHBITDEPTH
cm->bit_depth, cm->use_highbitdepth, cm->bit_depth,
#else #else
8, 0, 8,
#endif // CONFIG_HIGHBITDEPTH #endif // CONFIG_HIGHBITDEPTH
&rtile_sgrproj_info->ep, &rtile_sgrproj_info->ep,
rtile_sgrproj_info->xqd, rtile_sgrproj_info->xqd,
......
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