Commit acd90b71 authored by Luc Trudeau's avatar Luc Trudeau

Small clean up in loop filter code

parent f4ad2720
Pipeline #1060 passed with stage
in 3 minutes and 17 seconds
...@@ -124,13 +124,12 @@ static inline void filter_plane_rows_uv(const Dav1dFrameContext *const f, ...@@ -124,13 +124,12 @@ static inline void filter_plane_rows_uv(const Dav1dFrameContext *const f,
const int starty4, const int endy4) const int starty4, const int endy4)
{ {
const Dav1dDSPContext *const dsp = f->dsp; const Dav1dDSPContext *const dsp = f->dsp;
int y; ptrdiff_t off_l = 0;
ptrdiff_t off_l;
// block1 // block1
// filter edges between rows (e.g. ------) // filter edges between rows (e.g. ------)
// block2 // block2
for (off_l = 0, y = starty4; y < endy4; for (int y = starty4; y < endy4;
y++, off_l += 4 * PXSTRIDE(ls), lvl += b4_stride) y++, off_l += 4 * PXSTRIDE(ls), lvl += b4_stride)
{ {
if (!have_top && !y) continue; if (!have_top && !y) continue;
...@@ -158,7 +157,7 @@ void bytefn(dav1d_loopfilter_sbrow)(const Dav1dFrameContext *const f, ...@@ -158,7 +157,7 @@ void bytefn(dav1d_loopfilter_sbrow)(const Dav1dFrameContext *const f,
const int halign = (f->bh + 31) & ~31; const int halign = (f->bh + 31) & ~31;
const int ss_ver = f->cur.p.p.layout == DAV1D_PIXEL_LAYOUT_I420; const int ss_ver = f->cur.p.p.layout == DAV1D_PIXEL_LAYOUT_I420;
const int ss_hor = f->cur.p.p.layout != DAV1D_PIXEL_LAYOUT_I444; const int ss_hor = f->cur.p.p.layout != DAV1D_PIXEL_LAYOUT_I444;
const int endy4 = starty4 + imin(hy4 - sby * f->sb_step, sbsz); const int endy4 = starty4 + imin(hy4 - sby * sbsz, sbsz);
const int uv_endy4 = (endy4 + ss_ver) >> ss_ver; const int uv_endy4 = (endy4 + ss_ver) >> ss_ver;
// fix lpf strength at tile col boundaries // fix lpf strength at tile col boundaries
......
...@@ -36,21 +36,15 @@ ...@@ -36,21 +36,15 @@
#include "src/lf_mask.h" #include "src/lf_mask.h"
#include "src/tables.h" #include "src/tables.h"
static void decomp_tx(uint8_t (*txa)[2 /* txsz, step */][32 /* y */][32 /* x */], static void decomp_tx(uint8_t (*const txa)[2 /* txsz, step */][32 /* y */][32 /* x */],
const enum RectTxfmSize from, const enum RectTxfmSize from,
const int depth, const int depth,
const int y_off, const int x_off, const int y_off, const int x_off,
const uint16_t *const tx_masks) const uint16_t *const tx_masks)
{ {
const TxfmInfo *const t_dim = &dav1d_txfm_dimensions[from]; const TxfmInfo *const t_dim = &dav1d_txfm_dimensions[from];
int is_split; const int is_split =
depth > 1 ? 0 : (tx_masks[depth] >> (y_off * 4 + x_off)) & 1;
if (depth > 1) {
is_split = 0;
} else {
const int off = y_off * 4 + x_off;
is_split = (tx_masks[depth] >> off) & 1;
}
if (is_split) { if (is_split) {
const enum RectTxfmSize sub = t_dim->sub; const enum RectTxfmSize sub = t_dim->sub;
...@@ -69,9 +63,8 @@ static void decomp_tx(uint8_t (*txa)[2 /* txsz, step */][32 /* y */][32 /* x */] ...@@ -69,9 +63,8 @@ static void decomp_tx(uint8_t (*txa)[2 /* txsz, step */][32 /* y */][32 /* x */]
} }
} else { } else {
const int lw = imin(2, t_dim->lw), lh = imin(2, t_dim->lh); const int lw = imin(2, t_dim->lw), lh = imin(2, t_dim->lh);
int y;
for (y = 0; y < t_dim->h; y++) { for (int y = 0; y < t_dim->h; y++) {
memset(txa[0][0][y], lw, t_dim->w); memset(txa[0][0][y], lw, t_dim->w);
memset(txa[1][0][y], lh, t_dim->w); memset(txa[1][0][y], lh, t_dim->w);
txa[0][1][y][0] = t_dim->w; txa[0][1][y][0] = t_dim->w;
...@@ -80,7 +73,7 @@ static void decomp_tx(uint8_t (*txa)[2 /* txsz, step */][32 /* y */][32 /* x */] ...@@ -80,7 +73,7 @@ static void decomp_tx(uint8_t (*txa)[2 /* txsz, step */][32 /* y */][32 /* x */]
} }
} }
static inline void mask_edges_inter(uint32_t (*masks)[32][3], static inline void mask_edges_inter(uint32_t (*const masks)[32][3],
const int by4, const int bx4, const int by4, const int bx4,
const int w4, const int h4, const int skip, const int w4, const int h4, const int skip,
const enum RectTxfmSize max_tx, const enum RectTxfmSize max_tx,
...@@ -91,9 +84,8 @@ static inline void mask_edges_inter(uint32_t (*masks)[32][3], ...@@ -91,9 +84,8 @@ static inline void mask_edges_inter(uint32_t (*masks)[32][3],
int y, x; int y, x;
uint8_t txa[2 /* edge */][2 /* txsz, step */][32 /* y */][32 /* x */]; uint8_t txa[2 /* edge */][2 /* txsz, step */][32 /* y */][32 /* x */];
int y_off, x_off; for (int y_off = 0, y = 0; y < h4; y += t_dim->h, y_off++)
for (y_off = 0, y = 0; y < h4; y += t_dim->h, y_off++) for (int x_off = 0, x = 0; x < w4; x += t_dim->w, x_off++)
for (x_off = 0, x = 0; x < w4; x += t_dim->w, x_off++)
decomp_tx((uint8_t(*)[2][32][32]) &txa[0][0][y][x], decomp_tx((uint8_t(*)[2][32][32]) &txa[0][0][y][x],
max_tx, 0, y_off, x_off, tx_masks); max_tx, 0, y_off, x_off, tx_masks);
...@@ -103,7 +95,7 @@ static inline void mask_edges_inter(uint32_t (*masks)[32][3], ...@@ -103,7 +95,7 @@ static inline void mask_edges_inter(uint32_t (*masks)[32][3],
masks[0][bx4][imin(txa[0][0][y][0], l[y])] |= mask; masks[0][bx4][imin(txa[0][0][y][0], l[y])] |= mask;
// top block edge // top block edge
for (mask = 1U << bx4, x = 0; x < w4; x++, mask <<= 1) for (x = 0, mask = 1U << bx4; x < w4; x++, mask <<= 1)
masks[1][by4][imin(txa[1][0][0][x], a[x])] |= mask; masks[1][by4][imin(txa[1][0][0][x], a[x])] |= mask;
if (!skip) { if (!skip) {
...@@ -156,7 +148,7 @@ static inline void mask_edges_intra(uint32_t (*const masks)[32][3], ...@@ -156,7 +148,7 @@ static inline void mask_edges_intra(uint32_t (*const masks)[32][3],
masks[0][bx4][imin(twl4c, l[y])] |= mask; masks[0][bx4][imin(twl4c, l[y])] |= mask;
// top block edge // top block edge
for (mask = 1U << bx4, x = 0; x < w4; x++, mask <<= 1) for (x = 0, mask = 1U << bx4; x < w4; x++, mask <<= 1)
masks[1][by4][imin(thl4c, a[x])] |= mask; masks[1][by4][imin(thl4c, a[x])] |= mask;
// inner (tx) left|right edges // inner (tx) left|right edges
...@@ -197,7 +189,7 @@ static inline void mask_edges_chroma(uint32_t (*const masks)[32][2], ...@@ -197,7 +189,7 @@ static inline void mask_edges_chroma(uint32_t (*const masks)[32][2],
masks[0][cbx4][imin(twl4c, l[y])] |= mask; masks[0][cbx4][imin(twl4c, l[y])] |= mask;
// top block edge // top block edge
for (mask = 1U << cbx4, x = 0; x < cw4; x++, mask <<= 1) for (x = 0, mask = 1U << cbx4; x < cw4; x++, mask <<= 1)
masks[1][cby4][imin(thl4c, a[x])] |= mask; masks[1][cby4][imin(thl4c, a[x])] |= mask;
if (!skip_inter) { if (!skip_inter) {
...@@ -344,11 +336,9 @@ void dav1d_create_lf_mask_inter(Av1Filter *const lflvl, ...@@ -344,11 +336,9 @@ void dav1d_create_lf_mask_inter(Av1Filter *const lflvl,
} }
void dav1d_calc_eih(Av1FilterLUT *const lim_lut, const int filter_sharpness) { void dav1d_calc_eih(Av1FilterLUT *const lim_lut, const int filter_sharpness) {
int level;
// set E/I/H values from loopfilter level // set E/I/H values from loopfilter level
const int sharp = filter_sharpness; const int sharp = filter_sharpness;
for (level = 0; level < 64; level++) { for (int level = 0; level < 64; level++) {
int limit = level; int limit = level;
if (sharp > 0) { if (sharp > 0) {
...@@ -364,10 +354,10 @@ void dav1d_calc_eih(Av1FilterLUT *const lim_lut, const int filter_sharpness) { ...@@ -364,10 +354,10 @@ void dav1d_calc_eih(Av1FilterLUT *const lim_lut, const int filter_sharpness) {
lim_lut->sharp[1] = sharp ? 9 - sharp : 0xff; lim_lut->sharp[1] = sharp ? 9 - sharp : 0xff;
} }
static void dav1d_calc_lf_value(uint8_t (*const lflvl_values)[2], static inline void calc_lf_value(uint8_t (*const lflvl_values)[2],
const int is_chroma, const int base_lvl, const int is_chroma, const int base_lvl,
const int lf_delta, const int seg_delta, const int lf_delta, const int seg_delta,
const Av1LoopfilterModeRefDeltas *const mr_delta) const Av1LoopfilterModeRefDeltas *const mr_delta)
{ {
const int base = iclip(iclip(base_lvl + lf_delta, 0, 63) + seg_delta, 0, 63); const int base = iclip(iclip(base_lvl + lf_delta, 0, 63) + seg_delta, 0, 63);
...@@ -407,16 +397,16 @@ void dav1d_calc_lf_values(uint8_t (*const lflvl_values)[4][8][2], ...@@ -407,16 +397,16 @@ void dav1d_calc_lf_values(uint8_t (*const lflvl_values)[4][8][2],
const Av1SegmentationData *const segd = const Av1SegmentationData *const segd =
hdr->segmentation.enabled ? &hdr->segmentation.seg_data.d[s] : NULL; hdr->segmentation.enabled ? &hdr->segmentation.seg_data.d[s] : NULL;
dav1d_calc_lf_value(lflvl_values[s][0], 0, hdr->loopfilter.level_y[0], calc_lf_value(lflvl_values[s][0], 0, hdr->loopfilter.level_y[0],
lf_delta[0], segd ? segd->delta_lf_y_v : 0, mr_deltas); lf_delta[0], segd ? segd->delta_lf_y_v : 0, mr_deltas);
dav1d_calc_lf_value(lflvl_values[s][1], 0, hdr->loopfilter.level_y[1], calc_lf_value(lflvl_values[s][1], 0, hdr->loopfilter.level_y[1],
lf_delta[hdr->delta.lf.multi ? 1 : 0], lf_delta[hdr->delta.lf.multi ? 1 : 0],
segd ? segd->delta_lf_y_h : 0, mr_deltas); segd ? segd->delta_lf_y_h : 0, mr_deltas);
dav1d_calc_lf_value(lflvl_values[s][2], 1, hdr->loopfilter.level_u, calc_lf_value(lflvl_values[s][2], 1, hdr->loopfilter.level_u,
lf_delta[hdr->delta.lf.multi ? 2 : 0], lf_delta[hdr->delta.lf.multi ? 2 : 0],
segd ? segd->delta_lf_u : 0, mr_deltas); segd ? segd->delta_lf_u : 0, mr_deltas);
dav1d_calc_lf_value(lflvl_values[s][3], 1, hdr->loopfilter.level_v, calc_lf_value(lflvl_values[s][3], 1, hdr->loopfilter.level_v,
lf_delta[hdr->delta.lf.multi ? 3 : 0], lf_delta[hdr->delta.lf.multi ? 3 : 0],
segd ? segd->delta_lf_v : 0, mr_deltas); segd ? segd->delta_lf_v : 0, mr_deltas);
} }
} }
...@@ -38,13 +38,12 @@ static NOINLINE void ...@@ -38,13 +38,12 @@ static NOINLINE void
loop_filter(pixel *dst, int E, int I, int H, loop_filter(pixel *dst, int E, int I, int H,
const ptrdiff_t stridea, const ptrdiff_t strideb, const int wd) const ptrdiff_t stridea, const ptrdiff_t strideb, const int wd)
{ {
int i, F = 1 << (BITDEPTH - 8); const int F = 1 << (BITDEPTH - 8);
E <<= BITDEPTH - 8; E <<= BITDEPTH - 8;
I <<= BITDEPTH - 8; I <<= BITDEPTH - 8;
H <<= BITDEPTH - 8; H <<= BITDEPTH - 8;
for (i = 0; i < 4; i++, dst += stridea) { for (int i = 0; i < 4; i++, dst += stridea) {
int p6, p5, p4, p3, p2; int p6, p5, p4, p3, p2;
int p1 = dst[strideb * -2], p0 = dst[strideb * -1]; int p1 = dst[strideb * -2], p0 = dst[strideb * -1];
int q0 = dst[strideb * +0], q1 = dst[strideb * +1]; int q0 = dst[strideb * +0], q1 = dst[strideb * +1];
...@@ -127,7 +126,7 @@ loop_filter(pixel *dst, int E, int I, int H, ...@@ -127,7 +126,7 @@ loop_filter(pixel *dst, int E, int I, int H,
dst[strideb * +0] = (p1 + 2 * p0 + 2 * q0 + 2 * q1 + q2 + 4) >> 3; dst[strideb * +0] = (p1 + 2 * p0 + 2 * q0 + 2 * q1 + q2 + 4) >> 3;
dst[strideb * +1] = (p0 + 2 * q0 + 2 * q1 + 2 * q2 + q2 + 4) >> 3; dst[strideb * +1] = (p0 + 2 * q0 + 2 * q1 + 2 * q2 + q2 + 4) >> 3;
} else { } else {
int hev = abs(p1 - p0) > H || abs(q1 - q0) > H; const int hev = abs(p1 - p0) > H || abs(q1 - q0) > H;
#define iclip_diff(v) iclip(v, -128 * (1 << (BITDEPTH - 8)), \ #define iclip_diff(v) iclip(v, -128 * (1 << (BITDEPTH - 8)), \
128 * (1 << (BITDEPTH - 8)) - 1) 128 * (1 << (BITDEPTH - 8)) - 1)
......
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