Commit 84f567c7 authored by Debargha Mukherjee's avatar Debargha Mukherjee

Add chorma tilesize option in loop-restoration

Adds an option bit in the bitstream syntax to allow chroma to
have restoration tilesize that is coupled to luma based on
subsmapling of the color components.

This is meant to ease encoder hardware implementation.

Change-Id: Ic3cc2b68c0f33701ed3ff2fe19cf57cd864da67f
parent 81ec2619
......@@ -2792,9 +2792,16 @@ static void decode_restoration_mode(AV1_COMMON *cm,
if (rsi->restoration_tilesize != RESTORATION_TILESIZE_MAX) {
rsi->restoration_tilesize >>= aom_rb_read_bit(rb);
}
}
int s = AOMMIN(cm->subsampling_x, cm->subsampling_y);
if (s && (cm->rst_info[1].frame_restoration_type != RESTORE_NONE ||
cm->rst_info[2].frame_restoration_type != RESTORE_NONE)) {
cm->rst_info[1].restoration_tilesize =
cm->rst_info[0].restoration_tilesize >> (aom_rb_read_bit(rb) * s);
} else {
cm->rst_info[1].restoration_tilesize = cm->rst_info[0].restoration_tilesize;
cm->rst_info[2].restoration_tilesize = cm->rst_info[0].restoration_tilesize;
}
cm->rst_info[2].restoration_tilesize = cm->rst_info[1].restoration_tilesize;
}
static void read_wiener_filter(WienerInfo *wiener_info,
......
......@@ -3540,6 +3540,23 @@ static void encode_restoration_mode(AV1_COMMON *cm,
wb, rsi->restoration_tilesize != (RESTORATION_TILESIZE_MAX >> 1));
}
}
int s = AOMMIN(cm->subsampling_x, cm->subsampling_y);
if (s && (cm->rst_info[1].frame_restoration_type != RESTORE_NONE ||
cm->rst_info[2].frame_restoration_type != RESTORE_NONE)) {
aom_wb_write_bit(wb, cm->rst_info[1].restoration_tilesize !=
cm->rst_info[0].restoration_tilesize);
assert(cm->rst_info[1].restoration_tilesize ==
cm->rst_info[0].restoration_tilesize ||
cm->rst_info[1].restoration_tilesize ==
(cm->rst_info[0].restoration_tilesize >> s));
assert(cm->rst_info[2].restoration_tilesize ==
cm->rst_info[1].restoration_tilesize);
} else if (!s) {
assert(cm->rst_info[1].restoration_tilesize ==
cm->rst_info[0].restoration_tilesize);
assert(cm->rst_info[2].restoration_tilesize ==
cm->rst_info[1].restoration_tilesize);
}
}
static void write_wiener_filter(WienerInfo *wiener_info,
......
......@@ -3644,13 +3644,22 @@ static void init_motion_estimation(AV1_COMP *cpi) {
}
#if CONFIG_LOOP_RESTORATION
static void set_restoration_tilesize(int width, int height,
#define COUPLED_CHROMA_FROM_LUMA_RESTORATION 0
static void set_restoration_tilesize(int width, int height, int sx, int sy,
RestorationInfo *rst) {
(void)width;
(void)height;
(void)sx;
(void)sy;
#if COUPLED_CHROMA_FROM_LUMA_RESTORATION
int s = AOMMIN(sx, sy);
#else
int s = 0;
#endif // !COUPLED_CHROMA_FROM_LUMA_RESTORATION
rst[0].restoration_tilesize = (RESTORATION_TILESIZE_MAX >> 1);
rst[1].restoration_tilesize = rst[0].restoration_tilesize;
rst[2].restoration_tilesize = rst[0].restoration_tilesize;
rst[1].restoration_tilesize = rst[0].restoration_tilesize >> s;
rst[2].restoration_tilesize = rst[1].restoration_tilesize;
}
#endif // CONFIG_LOOP_RESTORATION
......@@ -3691,7 +3700,7 @@ static void set_frame_size(AV1_COMP *cpi, int width, int height) {
#else
cm->width, cm->height,
#endif // CONFIG_FRAME_SUPERRES
cm->rst_info);
cm->subsampling_x, cm->subsampling_y, cm->rst_info);
for (int i = 0; i < MAX_MB_PLANE; ++i)
cm->rst_info[i].frame_restoration_type = RESTORE_NONE;
av1_alloc_restoration_buffers(cm);
......
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