Commit cd669728 authored by Jean-Marc Valin's avatar Jean-Marc Valin Committed by Jean-Marc Valin

Refactoring deringed block list code

Using a struct named dlist rather than an array named bskip. Simplified some
code.

No change in output

Change-Id: Id40d40b19b5d8f2ebafe347590fa1bb8cb80e6e1
parent 00f3f72b
......@@ -47,13 +47,12 @@ int sb_all_skip(const AV1_COMMON *const cm, int mi_row, int mi_col) {
return skip;
}
int sb_all_skip_out(const AV1_COMMON *const cm, int mi_row, int mi_col,
unsigned char (*bskip)[2], int *count_ptr) {
int sb_compute_dering_list(const AV1_COMMON *const cm, int mi_row, int mi_col,
dering_list *dlist) {
int r, c;
int maxc, maxr;
int skip = 1;
MODE_INFO **grid;
int count=0;
int count = 0;
grid = cm->mi_grid_visible;
maxc = cm->mi_cols - mi_col;
maxr = cm->mi_rows - mi_row;
......@@ -64,15 +63,13 @@ int sb_all_skip_out(const AV1_COMMON *const cm, int mi_row, int mi_col,
grid_row = &grid[(mi_row + r) * cm->mi_stride + mi_col];
for (c = 0; c < maxc; c++) {
if (!grid_row[c]->mbmi.skip) {
skip = 0;
bskip[count][0] = r;
bskip[count][1] = c;
dlist[count].by = r;
dlist[count].bx = c;
count++;
}
}
}
*count_ptr = count;
return skip;
return count;
}
static INLINE void copy_8x8_16_8bit(uint8_t *dst, int dstride, int16_t *src, int sstride) {
......@@ -91,21 +88,21 @@ static INLINE void copy_4x4_16_8bit(uint8_t *dst, int dstride, int16_t *src, int
/* TODO: Optimize this function for SSE. */
void copy_blocks_16_8bit(uint8_t *dst, int dstride, int16_t *src,
unsigned char (*bskip)[2], int dering_count, int bsize)
dering_list *dlist, int dering_count, int bsize)
{
int bi, bx, by;
if (bsize == 3) {
for (bi = 0; bi < dering_count; bi++) {
by = bskip[bi][0];
bx = bskip[bi][1];
by = dlist[bi].by;
bx = dlist[bi].bx;
copy_8x8_16_8bit(&dst[(by << 3) * dstride + (bx << 3)],
dstride,
&src[bi << 2*bsize], 1 << bsize);
}
} else {
for (bi = 0; bi < dering_count; bi++) {
by = bskip[bi][0];
bx = bskip[bi][1];
by = dlist[bi].by;
bx = dlist[bi].bx;
copy_4x4_16_8bit(&dst[(by << 2) * dstride + (bx << 2)],
dstride,
&src[bi << 2*bsize], 1 << bsize);
......@@ -149,7 +146,7 @@ void av1_dering_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
od_dering_in src[OD_DERING_INBUF_SIZE];
int16_t *linebuf[3];
int16_t colbuf[3][OD_BSIZE_MAX + 2*OD_FILT_VBORDER][OD_FILT_HBORDER];
unsigned char bskip[MAX_MIB_SIZE*MAX_MIB_SIZE][2];
dering_list dlist[MAX_MIB_SIZE*MAX_MIB_SIZE];
unsigned char *row_dering, *prev_row_dering, *curr_row_dering;
int dering_count;
int dir[OD_DERING_NBLOCKS][OD_DERING_NBLOCKS] = { { 0 } };
......@@ -203,7 +200,8 @@ void av1_dering_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
->mbmi.dering_gain);
curr_row_dering[sbc] = 0;
if (level == 0 ||
sb_all_skip_out(cm, sbr * MAX_MIB_SIZE, sbc * MAX_MIB_SIZE, bskip, &dering_count))
(dering_count = sb_compute_dering_list(cm, sbr * MAX_MIB_SIZE,
sbc * MAX_MIB_SIZE, dlist)) == 0)
continue;
curr_row_dering[sbc] = 1;
for (pli = 0; pli < nplanes; pli++) {
......@@ -341,7 +339,7 @@ void av1_dering_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
if (threshold == 0) continue;
od_dering(dst, &src[OD_FILT_VBORDER * OD_FILT_BSTRIDE
+ OD_FILT_HBORDER],
dec[pli], dir, pli, bskip, dering_count, threshold, coeff_shift);
dec[pli], dir, pli, dlist, dering_count, threshold, coeff_shift);
#if CONFIG_AOM_HIGHBITDEPTH
if (cm->use_highbitdepth) {
copy_blocks_16bit(
......@@ -349,7 +347,7 @@ void av1_dering_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
xd->plane[pli].dst.buf)[xd->plane[pli].dst.stride *
(MAX_MIB_SIZE * sbr << bsize[pli]) +
(sbc * MAX_MIB_SIZE << bsize[pli])],
xd->plane[pli].dst.stride, dst, bskip,
xd->plane[pli].dst.stride, dst, dlist,
dering_count, 3 - dec[pli]);
} else {
#endif
......@@ -357,7 +355,7 @@ void av1_dering_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
&xd->plane[pli].dst.buf[xd->plane[pli].dst.stride *
(MAX_MIB_SIZE * sbr << bsize[pli]) +
(sbc * MAX_MIB_SIZE << bsize[pli])],
xd->plane[pli].dst.stride, dst, bskip,
xd->plane[pli].dst.stride, dst, dlist,
dering_count, 3 - dec[pli]);
#if CONFIG_AOM_HIGHBITDEPTH
}
......
......@@ -18,6 +18,7 @@
#include "aom/aom_integer.h"
#include "./aom_config.h"
#include "aom_ports/mem.h"
#include "od_dering.h"
#ifdef __cplusplus
extern "C" {
......@@ -31,8 +32,8 @@ extern "C" {
int compute_level_from_index(int global_level, int gi);
int sb_all_skip(const AV1_COMMON *const cm, int mi_row, int mi_col);
int sb_all_skip_out(const AV1_COMMON *const cm, int mi_row, int mi_col,
unsigned char (*bskip)[2], int *count_ptr);
int sb_compute_dering_list(const AV1_COMMON *const cm, int mi_row, int mi_col,
dering_list *dlist);
void av1_dering_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
MACROBLOCKD *xd, int global_level);
......
......@@ -274,21 +274,21 @@ static INLINE void copy_4x4_16bit(int16_t *dst, int dstride, int16_t *src, int s
/* TODO: Optimize this function for SSE. */
void copy_blocks_16bit(int16_t *dst, int dstride, int16_t *src,
unsigned char (*bskip)[2], int dering_count, int bsize)
dering_list *dlist, int dering_count, int bsize)
{
int bi, bx, by;
if (bsize == 3) {
for (bi = 0; bi < dering_count; bi++) {
by = bskip[bi][0];
bx = bskip[bi][1];
by = dlist[bi].by;
bx = dlist[bi].bx;
copy_8x8_16bit(&dst[(by << 3) * dstride + (bx << 3)],
dstride,
&src[bi << 2*bsize], 1 << bsize);
}
} else {
for (bi = 0; bi < dering_count; bi++) {
by = bskip[bi][0];
bx = bskip[bi][1];
by = dlist[bi].by;
bx = dlist[bi].bx;
copy_4x4_16bit(&dst[(by << 2) * dstride + (bx << 2)],
dstride,
&src[bi << 2*bsize], 1 << bsize);
......@@ -298,7 +298,7 @@ void copy_blocks_16bit(int16_t *dst, int dstride, int16_t *src,
void od_dering(int16_t *y, int16_t *in, int xdec,
int dir[OD_DERING_NBLOCKS][OD_DERING_NBLOCKS], int pli,
unsigned char (*bskip)[2], int dering_count, int threshold,
dering_list *dlist, int dering_count, int threshold,
int coeff_shift) {
int bi;
int bx;
......@@ -315,8 +315,8 @@ void od_dering(int16_t *y, int16_t *in, int xdec,
if (pli == 0) {
for (bi = 0; bi < dering_count; bi++) {
int32_t var;
by = bskip[bi][0];
bx = bskip[bi][1];
by = dlist[bi].by;
bx = dlist[bi].bx;
dir[by][bx] = od_dir_find8(&in[8 * by * OD_FILT_BSTRIDE + 8 * bx], OD_FILT_BSTRIDE,
&var, coeff_shift);
/* Deringing orthogonal to the direction uses a tighter threshold
......@@ -334,19 +334,19 @@ void od_dering(int16_t *y, int16_t *in, int xdec,
}
} else {
for (bi = 0; bi < dering_count; bi++) {
by = bskip[bi][0];
bx = bskip[bi][1];
by = dlist[bi].by;
bx = dlist[bi].bx;
filter2_thresh[by][bx] = (filter_dering_direction[bsize - OD_LOG_BSIZE0])(
&y[bi << 2*bsize], 1 << bsize,
&in[(by * OD_FILT_BSTRIDE << bsize) + (bx << bsize)], threshold,
dir[by][bx]);
}
}
copy_blocks_16bit(in, OD_FILT_BSTRIDE, y, bskip, dering_count,
copy_blocks_16bit(in, OD_FILT_BSTRIDE, y, dlist, dering_count,
bsize);
for (bi = 0; bi < dering_count; bi++) {
by = bskip[bi][0];
bx = bskip[bi][1];
by = dlist[bi].by;
bx = dlist[bi].bx;
if (filter2_thresh[by][bx] == 0) continue;
(filter_dering_orthogonal[bsize - OD_LOG_BSIZE0])(
&y[bi << 2*bsize], 1 << bsize,
......
......@@ -38,6 +38,11 @@ typedef int16_t od_dering_in;
extern const int OD_DIRECTION_OFFSETS_TABLE[8][3];
typedef struct {
unsigned char by;
unsigned char bx;
} dering_list;
typedef int (*od_filter_dering_direction_func)(int16_t *y, int ystride,
const int16_t *in, int threshold,
int dir);
......@@ -45,11 +50,11 @@ typedef void (*od_filter_dering_orthogonal_func)(int16_t *y, int ystride,
const int16_t *in,
int threshold, int dir);
void copy_blocks_16bit(int16_t *dst, int dstride, int16_t *src,
unsigned char (*bskip)[2], int dering_count, int bsize);
dering_list *dlist, int dering_count, int bsize);
void od_dering(int16_t *y, int16_t *in, int xdec,
int dir[OD_DERING_NBLOCKS][OD_DERING_NBLOCKS], int pli,
unsigned char (*bskip)[2], int skip_stride, int threshold,
dering_list *dlist, int skip_stride, int threshold,
int coeff_shift);
int od_filter_dering_direction_4x4_c(int16_t *y, int ystride, const int16_t *in,
int threshold, int dir);
......
......@@ -43,7 +43,7 @@ int av1_dering_search(YV12_BUFFER_CONFIG *frame, const YV12_BUFFER_CONFIG *ref,
int nhsb, nvsb;
od_dering_in *src;
int16_t *ref_coeff;
unsigned char bskip[MAX_MIB_SIZE*MAX_MIB_SIZE][2];
dering_list dlist[MAX_MIB_SIZE*MAX_MIB_SIZE];
int dir[OD_DERING_NBLOCKS][OD_DERING_NBLOCKS] = { { 0 } };
int stride;
int bsize[3];
......@@ -101,7 +101,9 @@ int av1_dering_search(YV12_BUFFER_CONFIG *frame, const YV12_BUFFER_CONFIG *ref,
int16_t tmp_dst[MAX_MIB_SIZE * MAX_MIB_SIZE * 8 * 8];
nhb = AOMMIN(MAX_MIB_SIZE, cm->mi_cols - MAX_MIB_SIZE * sbc);
nvb = AOMMIN(MAX_MIB_SIZE, cm->mi_rows - MAX_MIB_SIZE * sbr);
if (sb_all_skip_out(cm, sbr * MAX_MIB_SIZE, sbc * MAX_MIB_SIZE, bskip, &dering_count))
dering_count = sb_compute_dering_list(cm, sbr * MAX_MIB_SIZE, sbc * MAX_MIB_SIZE,
dlist);
if (dering_count == 0)
continue;
best_gi = 0;
for (gi = 0; gi < DERING_REFINEMENT_LEVELS; gi++) {
......@@ -134,9 +136,9 @@ int av1_dering_search(YV12_BUFFER_CONFIG *frame, const YV12_BUFFER_CONFIG *ref,
in[i * OD_FILT_BSTRIDE + j] = x[i * stride + j];
}
}
od_dering(tmp_dst, in, 0, dir, 0, bskip, dering_count, threshold,
od_dering(tmp_dst, in, 0, dir, 0, dlist, dering_count, threshold,
coeff_shift);
copy_blocks_16bit(dst, MAX_MIB_SIZE << bsize[0], tmp_dst, bskip,
copy_blocks_16bit(dst, MAX_MIB_SIZE << bsize[0], tmp_dst, dlist,
dering_count, 3);
cur_mse = (int)compute_dist(
dst, MAX_MIB_SIZE << bsize[0],
......
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