Reformatting the deringing code

Manally removed the "clang-format off" lines. The rest is done by clang

Change-Id: I88a2028b55a541729b4e8896cdf66b544e9898bb
parent ccc86a35
This diff is collapsed.
......@@ -11,8 +11,6 @@
#ifndef AV1_COMMON_DERING_H_
#define AV1_COMMON_DERING_H_
// clang-format off
#include "av1/common/od_dering.h"
#include "av1/common/onyxc_int.h"
#include "aom/aom_integer.h"
......@@ -33,7 +31,7 @@ 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_compute_dering_list(const AV1_COMMON *const cm, int mi_row, int mi_col,
dering_list *dlist);
dering_list *dlist);
void av1_dering_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
MACROBLOCKD *xd, int global_level);
......
......@@ -12,8 +12,6 @@
#include "config.h"
#endif
// clang-format off
#include <stdlib.h>
#include <math.h>
#include "dering.h"
......@@ -258,40 +256,38 @@ static INLINE int od_adjust_thresh(int threshold, int32_t var) {
return (threshold * OD_THRESH_TABLE_Q8[OD_ILOG(v1)] + 128) >> 8;
}
static INLINE void copy_8x8_16bit_to_16bit(int16_t *dst, int dstride, int16_t *src, int sstride) {
static INLINE void copy_8x8_16bit_to_16bit(int16_t *dst, int dstride,
int16_t *src, int sstride) {
int i, j;
for (i = 0; i < 8; i++)
for (j = 0; j < 8; j++)
dst[i * dstride + j] = src[i * sstride + j];
for (j = 0; j < 8; j++) dst[i * dstride + j] = src[i * sstride + j];
}
static INLINE void copy_4x4_16bit_to_16bit(int16_t *dst, int dstride, int16_t *src, int sstride) {
static INLINE void copy_4x4_16bit_to_16bit(int16_t *dst, int dstride,
int16_t *src, int sstride) {
int i, j;
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++)
dst[i * dstride + j] = src[i * sstride + j];
for (j = 0; j < 4; j++) dst[i * dstride + j] = src[i * sstride + j];
}
/* TODO: Optimize this function for SSE. */
void copy_dering_16bit_to_16bit(int16_t *dst, int dstride, int16_t *src,
dering_list *dlist, 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 = dlist[bi].by;
bx = dlist[bi].bx;
copy_8x8_16bit_to_16bit(&dst[(by << 3) * dstride + (bx << 3)],
dstride,
&src[bi << 2*bsize], 1 << bsize);
copy_8x8_16bit_to_16bit(&dst[(by << 3) * dstride + (bx << 3)], dstride,
&src[bi << 2 * bsize], 1 << bsize);
}
} else {
for (bi = 0; bi < dering_count; bi++) {
by = dlist[bi].by;
bx = dlist[bi].bx;
copy_4x4_16bit_to_16bit(&dst[(by << 2) * dstride + (bx << 2)],
dstride,
&src[bi << 2*bsize], 1 << bsize);
copy_4x4_16bit_to_16bit(&dst[(by << 2) * dstride + (bx << 2)], dstride,
&src[bi << 2 * bsize], 1 << bsize);
}
}
}
......@@ -317,8 +313,8 @@ void od_dering(int16_t *y, int16_t *in, int xdec,
int32_t var;
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);
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
because we want to be conservative. We've presumably already
achieved some deringing, so the amount of change is expected
......@@ -328,7 +324,7 @@ void od_dering(int16_t *y, int16_t *in, int xdec,
since the ringing there tends to be directional, so it doesn't
get removed by the directional filtering. */
filter2_thresh[by][bx] = (filter_dering_direction[bsize - OD_LOG_BSIZE0])(
&y[bi << 2*bsize], 1 << bsize,
&y[bi << 2 * bsize], 1 << bsize,
&in[(by * OD_FILT_BSTRIDE << bsize) + (bx << bsize)],
od_adjust_thresh(threshold, var), dir[by][bx]);
}
......@@ -337,20 +333,20 @@ void od_dering(int16_t *y, int16_t *in, int xdec,
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,
&y[bi << 2 * bsize], 1 << bsize,
&in[(by * OD_FILT_BSTRIDE << bsize) + (bx << bsize)], threshold,
dir[by][bx]);
}
}
copy_dering_16bit_to_16bit(in, OD_FILT_BSTRIDE, y, dlist, dering_count,
bsize);
bsize);
for (bi = 0; bi < dering_count; bi++) {
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,
&in[(by * OD_FILT_BSTRIDE << bsize) + (bx << bsize)], filter2_thresh[by][bx],
dir[by][bx]);
&y[bi << 2 * bsize], 1 << bsize,
&in[(by * OD_FILT_BSTRIDE << bsize) + (bx << bsize)],
filter2_thresh[by][bx], dir[by][bx]);
}
}
......@@ -12,8 +12,6 @@
#if !defined(_dering_H)
#define _dering_H (1)
// clang-format off
#include "odintrin.h"
#define OD_DERINGSIZES (2)
......@@ -47,7 +45,8 @@ typedef void (*od_filter_dering_orthogonal_func)(int16_t *y, int ystride,
const int16_t *in,
int threshold, int dir);
void copy_dering_16bit_to_16bit(int16_t *dst, int dstride, int16_t *src,
dering_list *dlist, 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,
......
......@@ -9,8 +9,6 @@
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
// clang-format off
#include <string.h>
#include <math.h>
......@@ -43,7 +41,7 @@ int av1_dering_search(YV12_BUFFER_CONFIG *frame, const YV12_BUFFER_CONFIG *ref,
int nhsb, nvsb;
int16_t *src;
int16_t *ref_coeff;
dering_list dlist[MAX_MIB_SIZE*MAX_MIB_SIZE];
dering_list dlist[MAX_MIB_SIZE * MAX_MIB_SIZE];
int dir[OD_DERING_NBLOCKS][OD_DERING_NBLOCKS] = { { 0 } };
int stride;
int bsize[3];
......@@ -101,10 +99,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);
dering_count = sb_compute_dering_list(cm, sbr * MAX_MIB_SIZE, sbc * MAX_MIB_SIZE,
dlist);
if (dering_count == 0)
continue;
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++) {
int cur_mse;
......@@ -123,13 +120,16 @@ int av1_dering_search(YV12_BUFFER_CONFIG *frame, const YV12_BUFFER_CONFIG *ref,
}
in = inbuf + OD_FILT_VBORDER * OD_FILT_BSTRIDE + OD_FILT_HBORDER;
/* We avoid filtering the pixels for which some of the pixels to average
are outside the frame. We could change the filter instead, but it would
are outside the frame. We could change the filter instead, but it
would
add special cases for any future vectorization. */
for (i = 0; i < OD_DERING_INBUF_SIZE; i++) inbuf[i] = OD_DERING_VERY_LARGE;
for (i = 0; i < OD_DERING_INBUF_SIZE; i++)
inbuf[i] = OD_DERING_VERY_LARGE;
for (i = -OD_FILT_VBORDER * (sbr != 0);
i < (nvb << bsize[0]) + OD_FILT_VBORDER * (sbr != nvsb - 1); i++) {
for (j = -OD_FILT_HBORDER * (sbc != 0);
j < (nhb << bsize[0]) + OD_FILT_HBORDER * (sbc != nhsb - 1); j++) {
j < (nhb << bsize[0]) + OD_FILT_HBORDER * (sbc != nhsb - 1);
j++) {
int16_t *x;
x = &src[(sbr * stride * MAX_MIB_SIZE << bsize[0]) +
(sbc * MAX_MIB_SIZE << bsize[0])];
......@@ -137,9 +137,9 @@ int av1_dering_search(YV12_BUFFER_CONFIG *frame, const YV12_BUFFER_CONFIG *ref,
}
}
od_dering(tmp_dst, in, 0, dir, 0, dlist, dering_count, threshold,
coeff_shift);
copy_dering_16bit_to_16bit(dst, MAX_MIB_SIZE << bsize[0], tmp_dst, dlist,
dering_count, bsize[0]);
coeff_shift);
copy_dering_16bit_to_16bit(dst, MAX_MIB_SIZE << bsize[0], tmp_dst,
dlist, dering_count, bsize[0]);
cur_mse = (int)compute_dist(
dst, MAX_MIB_SIZE << bsize[0],
&ref_coeff[(sbr * stride * 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