Commit 1cb757cb authored by Debargha Mukherjee's avatar Debargha Mukherjee

Adds the option to use 5x5 Wiener for chroma

Change-Id: I1b789acc18f1e69fb5db069ccd8bd17815938e9d
parent d02642f2
......@@ -78,6 +78,10 @@ extern "C" {
#define WIENER_TMPBUF_SIZE (0)
#define WIENER_EXTBUF_SIZE (0)
// If WIENER_WIN_CHROMA == WIENER_WIN - 2, that implies 5x5 filters are used for
// chroma. To use 7x7 for chroma set WIENER_WIN_CHROMA to WIENER_WIN.
#define WIENER_WIN_CHROMA (WIENER_WIN - 2)
#define WIENER_FILT_PREC_BITS 7
#define WIENER_FILT_STEP (1 << WIENER_FILT_PREC_BITS)
......
......@@ -2685,14 +2685,17 @@ static void decode_restoration_mode(AV1_COMMON *cm,
cm->rst_info[2].restoration_tilesize = cm->rst_info[1].restoration_tilesize;
}
static void read_wiener_filter(WienerInfo *wiener_info,
static void read_wiener_filter(int wiener_win, WienerInfo *wiener_info,
WienerInfo *ref_wiener_info, aom_reader *rb) {
if (wiener_win == WIENER_WIN)
wiener_info->vfilter[0] = wiener_info->vfilter[WIENER_WIN - 1] =
aom_read_primitive_refsubexpfin(
rb, WIENER_FILT_TAP0_MAXV - WIENER_FILT_TAP0_MINV + 1,
WIENER_FILT_TAP0_SUBEXP_K,
ref_wiener_info->vfilter[0] - WIENER_FILT_TAP0_MINV, ACCT_STR) +
WIENER_FILT_TAP0_MINV;
else
wiener_info->vfilter[0] = wiener_info->vfilter[WIENER_WIN - 1] = 0;
wiener_info->vfilter[1] = wiener_info->vfilter[WIENER_WIN - 2] =
aom_read_primitive_refsubexpfin(
rb, WIENER_FILT_TAP1_MAXV - WIENER_FILT_TAP1_MINV + 1,
......@@ -2710,12 +2713,15 @@ static void read_wiener_filter(WienerInfo *wiener_info,
-2 * (wiener_info->vfilter[0] + wiener_info->vfilter[1] +
wiener_info->vfilter[2]);
if (wiener_win == WIENER_WIN)
wiener_info->hfilter[0] = wiener_info->hfilter[WIENER_WIN - 1] =
aom_read_primitive_refsubexpfin(
rb, WIENER_FILT_TAP0_MAXV - WIENER_FILT_TAP0_MINV + 1,
WIENER_FILT_TAP0_SUBEXP_K,
ref_wiener_info->hfilter[0] - WIENER_FILT_TAP0_MINV, ACCT_STR) +
WIENER_FILT_TAP0_MINV;
else
wiener_info->hfilter[0] = wiener_info->hfilter[WIENER_WIN - 1] = 0;
wiener_info->hfilter[1] = wiener_info->hfilter[WIENER_WIN - 2] =
aom_read_primitive_refsubexpfin(
rb, WIENER_FILT_TAP1_MAXV - WIENER_FILT_TAP1_MINV + 1,
......@@ -2779,7 +2785,8 @@ static void decode_restoration(AV1_COMMON *cm, aom_reader *rb) {
aom_read_tree(rb, av1_switchable_restore_tree,
cm->fc->switchable_restore_prob, ACCT_STR);
if (rsi->restoration_type[i] == RESTORE_WIENER) {
read_wiener_filter(&rsi->wiener_info[i], &ref_wiener_info, rb);
read_wiener_filter(WIENER_WIN, &rsi->wiener_info[i], &ref_wiener_info,
rb);
} else if (rsi->restoration_type[i] == RESTORE_SGRPROJ) {
read_sgrproj_filter(&rsi->sgrproj_info[i], &ref_sgrproj_info, rb);
}
......@@ -2788,7 +2795,8 @@ static void decode_restoration(AV1_COMMON *cm, aom_reader *rb) {
for (i = 0; i < ntiles; ++i) {
if (aom_read(rb, RESTORE_NONE_WIENER_PROB, ACCT_STR)) {
rsi->restoration_type[i] = RESTORE_WIENER;
read_wiener_filter(&rsi->wiener_info[i], &ref_wiener_info, rb);
read_wiener_filter(WIENER_WIN, &rsi->wiener_info[i], &ref_wiener_info,
rb);
} else {
rsi->restoration_type[i] = RESTORE_NONE;
}
......@@ -2817,7 +2825,8 @@ static void decode_restoration(AV1_COMMON *cm, aom_reader *rb) {
else
rsi->restoration_type[i] = RESTORE_WIENER;
if (rsi->restoration_type[i] == RESTORE_WIENER) {
read_wiener_filter(&rsi->wiener_info[i], &ref_wiener_info, rb);
read_wiener_filter(WIENER_WIN_CHROMA, &rsi->wiener_info[i],
&ref_wiener_info, rb);
}
}
} else if (rsi->frame_restoration_type == RESTORE_SGRPROJ) {
......
......@@ -3283,13 +3283,17 @@ static void encode_restoration_mode(AV1_COMMON *cm,
}
}
static void write_wiener_filter(WienerInfo *wiener_info,
static void write_wiener_filter(int wiener_win, WienerInfo *wiener_info,
WienerInfo *ref_wiener_info, aom_writer *wb) {
if (wiener_win == WIENER_WIN)
aom_write_primitive_refsubexpfin(
wb, WIENER_FILT_TAP0_MAXV - WIENER_FILT_TAP0_MINV + 1,
WIENER_FILT_TAP0_SUBEXP_K,
ref_wiener_info->vfilter[0] - WIENER_FILT_TAP0_MINV,
wiener_info->vfilter[0] - WIENER_FILT_TAP0_MINV);
else
assert(wiener_info->vfilter[0] == 0 &&
wiener_info->vfilter[WIENER_WIN - 1] == 0);
aom_write_primitive_refsubexpfin(
wb, WIENER_FILT_TAP1_MAXV - WIENER_FILT_TAP1_MINV + 1,
WIENER_FILT_TAP1_SUBEXP_K,
......@@ -3300,11 +3304,15 @@ static void write_wiener_filter(WienerInfo *wiener_info,
WIENER_FILT_TAP2_SUBEXP_K,
ref_wiener_info->vfilter[2] - WIENER_FILT_TAP2_MINV,
wiener_info->vfilter[2] - WIENER_FILT_TAP2_MINV);
if (wiener_win == WIENER_WIN)
aom_write_primitive_refsubexpfin(
wb, WIENER_FILT_TAP0_MAXV - WIENER_FILT_TAP0_MINV + 1,
WIENER_FILT_TAP0_SUBEXP_K,
ref_wiener_info->hfilter[0] - WIENER_FILT_TAP0_MINV,
wiener_info->hfilter[0] - WIENER_FILT_TAP0_MINV);
else
assert(wiener_info->hfilter[0] == 0 &&
wiener_info->hfilter[WIENER_WIN - 1] == 0);
aom_write_primitive_refsubexpfin(
wb, WIENER_FILT_TAP1_MAXV - WIENER_FILT_TAP1_MINV + 1,
WIENER_FILT_TAP1_SUBEXP_K,
......@@ -3362,7 +3370,8 @@ static void encode_restoration(AV1_COMMON *cm, aom_writer *wb) {
wb, av1_switchable_restore_tree, cm->fc->switchable_restore_prob,
&switchable_restore_encodings[rsi->restoration_type[i]]);
if (rsi->restoration_type[i] == RESTORE_WIENER) {
write_wiener_filter(&rsi->wiener_info[i], &ref_wiener_info, wb);
write_wiener_filter(WIENER_WIN, &rsi->wiener_info[i],
&ref_wiener_info, wb);
} else if (rsi->restoration_type[i] == RESTORE_SGRPROJ) {
write_sgrproj_filter(&rsi->sgrproj_info[i], &ref_sgrproj_info, wb);
}
......@@ -3372,7 +3381,8 @@ static void encode_restoration(AV1_COMMON *cm, aom_writer *wb) {
aom_write(wb, rsi->restoration_type[i] != RESTORE_NONE,
RESTORE_NONE_WIENER_PROB);
if (rsi->restoration_type[i] != RESTORE_NONE) {
write_wiener_filter(&rsi->wiener_info[i], &ref_wiener_info, wb);
write_wiener_filter(WIENER_WIN, &rsi->wiener_info[i],
&ref_wiener_info, wb);
}
}
} else if (rsi->frame_restoration_type == RESTORE_SGRPROJ) {
......@@ -3395,7 +3405,8 @@ static void encode_restoration(AV1_COMMON *cm, aom_writer *wb) {
aom_write(wb, rsi->restoration_type[i] != RESTORE_NONE,
RESTORE_NONE_WIENER_PROB);
if (rsi->restoration_type[i] != RESTORE_NONE) {
write_wiener_filter(&rsi->wiener_info[i], &ref_wiener_info, wb);
write_wiener_filter(WIENER_WIN_CHROMA, &rsi->wiener_info[i],
&ref_wiener_info, wb);
}
}
} else if (rsi->frame_restoration_type == RESTORE_SGRPROJ) {
......
This diff is collapsed.
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