Coverage Report

Created: 2026-05-16 06:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/dav1d/src/cdef_apply_tmpl.c
Line
Count
Source
1
/*
2
 * Copyright © 2018, VideoLAN and dav1d authors
3
 * Copyright © 2018, Two Orioles, LLC
4
 * All rights reserved.
5
 *
6
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions are met:
8
 *
9
 * 1. Redistributions of source code must retain the above copyright notice, this
10
 *    list of conditions and the following disclaimer.
11
 *
12
 * 2. Redistributions in binary form must reproduce the above copyright notice,
13
 *    this list of conditions and the following disclaimer in the documentation
14
 *    and/or other materials provided with the distribution.
15
 *
16
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 */
27
28
#include "config.h"
29
30
#include <string.h>
31
32
#include "common/intops.h"
33
34
#include "src/cdef_apply.h"
35
36
enum Backup2x8Flags {
37
    BACKUP_2X8_Y = 1 << 0,
38
    BACKUP_2X8_UV = 1 << 1,
39
};
40
41
static void backup2lines(pixel *const dst[3], /*const*/ pixel *const src[3],
42
                         const ptrdiff_t stride[2],
43
                         const enum Dav1dPixelLayout layout)
44
40
{
45
40
    const ptrdiff_t y_stride = PXSTRIDE(stride[0]);
46
40
    if (y_stride < 0)
47
0
        pixel_copy(dst[0] + y_stride, src[0] + 7 * y_stride, -2 * y_stride);
48
40
    else
49
40
        pixel_copy(dst[0], src[0] + 6 * y_stride, 2 * y_stride);
50
51
40
    if (layout != DAV1D_PIXEL_LAYOUT_I400) {
52
40
        const ptrdiff_t uv_stride = PXSTRIDE(stride[1]);
53
40
        if (uv_stride < 0) {
54
0
            const int uv_off = layout == DAV1D_PIXEL_LAYOUT_I420 ? 3 : 7;
55
0
            pixel_copy(dst[1] + uv_stride, src[1] + uv_off * uv_stride, -2 * uv_stride);
56
0
            pixel_copy(dst[2] + uv_stride, src[2] + uv_off * uv_stride, -2 * uv_stride);
57
40
        } else {
58
40
            const int uv_off = layout == DAV1D_PIXEL_LAYOUT_I420 ? 2 : 6;
59
40
            pixel_copy(dst[1], src[1] + uv_off * uv_stride, 2 * uv_stride);
60
40
            pixel_copy(dst[2], src[2] + uv_off * uv_stride, 2 * uv_stride);
61
40
        }
62
40
    }
63
40
}
64
65
static void backup2x8(pixel dst[3][8][2],
66
                      /*const*/ pixel *const src[3],
67
                      const ptrdiff_t src_stride[2], int x_off,
68
                      const enum Dav1dPixelLayout layout,
69
                      const enum Backup2x8Flags flag)
70
0
{
71
0
    ptrdiff_t y_off = 0;
72
0
    if (flag & BACKUP_2X8_Y) {
73
0
        for (int y = 0; y < 8; y++, y_off += PXSTRIDE(src_stride[0]))
74
0
            pixel_copy(dst[0][y], &src[0][y_off + x_off - 2], 2);
75
0
    }
76
77
0
    if (layout == DAV1D_PIXEL_LAYOUT_I400 || !(flag & BACKUP_2X8_UV))
78
0
        return;
79
80
0
    const int ss_ver = layout == DAV1D_PIXEL_LAYOUT_I420;
81
0
    const int ss_hor = layout != DAV1D_PIXEL_LAYOUT_I444;
82
83
0
    x_off >>= ss_hor;
84
0
    y_off = 0;
85
0
    for (int y = 0; y < (8 >> ss_ver); y++, y_off += PXSTRIDE(src_stride[1])) {
86
0
        pixel_copy(dst[1][y], &src[1][y_off + x_off - 2], 2);
87
0
        pixel_copy(dst[2][y], &src[2][y_off + x_off - 2], 2);
88
0
    }
89
0
}
90
91
0
static int adjust_strength(const int strength, const unsigned var) {
92
0
    if (!var) return 0;
93
0
    const int i = var >> 6 ? imin(ulog2(var >> 6), 12) : 0;
94
0
    return (strength * (4 + i) + 8) >> 4;
95
0
}
96
97
void bytefn(dav1d_cdef_brow)(Dav1dTaskContext *const tc,
98
                             pixel *const p[3],
99
                             const Av1Filter *const lflvl,
100
                             const int by_start, const int by_end,
101
                             const int sbrow_start, const int sby)
102
4
{
103
4
    Dav1dFrameContext *const f = (Dav1dFrameContext *)tc->f;
104
4
    const int bitdepth_min_8 = BITDEPTH == 8 ? 0 : f->cur.p.bpc - 8;
105
4
    const Dav1dDSPContext *const dsp = f->dsp;
106
4
    enum CdefEdgeFlags edges = CDEF_HAVE_BOTTOM | (by_start > 0 ? CDEF_HAVE_TOP : 0);
107
4
    pixel *ptrs[3] = { p[0], p[1], p[2] };
108
4
    const int sbsz = 16;
109
4
    const int sb64w = f->sb128w << 1;
110
4
    const int damping = f->frame_hdr->cdef.damping + bitdepth_min_8;
111
4
    const enum Dav1dPixelLayout layout = f->cur.p.layout;
112
4
    const int uv_idx = DAV1D_PIXEL_LAYOUT_I444 - layout;
113
4
    const int ss_ver = layout == DAV1D_PIXEL_LAYOUT_I420;
114
4
    const int ss_hor = layout != DAV1D_PIXEL_LAYOUT_I444;
115
4
    static const uint8_t uv_dirs[2][8] = { { 0, 1, 2, 3, 4, 5, 6, 7 },
116
4
                                           { 7, 0, 2, 4, 5, 6, 6, 6 } };
117
4
    const uint8_t *uv_dir = uv_dirs[layout == DAV1D_PIXEL_LAYOUT_I422];
118
4
    const int have_tt = f->c->n_tc > 1;
119
4
    const int sb128 = f->seq_hdr->sb128;
120
4
    const int resize = f->frame_hdr->width[0] != f->frame_hdr->width[1];
121
4
    const ptrdiff_t y_stride = PXSTRIDE(f->cur.stride[0]);
122
4
    const ptrdiff_t uv_stride = PXSTRIDE(f->cur.stride[1]);
123
124
48
    for (int bit = 0, by = by_start; by < by_end; by += 2, edges |= CDEF_HAVE_TOP) {
125
44
        const int tf = tc->top_pre_cdef_toggle;
126
44
        const int by_idx = (by & 30) >> 1;
127
44
        if (by + 2 >= f->bh) edges &= ~CDEF_HAVE_BOTTOM;
128
129
44
        if ((!have_tt || sbrow_start || by + 2 < by_end) &&
130
40
            edges & CDEF_HAVE_BOTTOM)
131
40
        {
132
            // backup pre-filter data for next iteration
133
40
            pixel *const cdef_top_bak[3] = {
134
40
                f->lf.cdef_line[!tf][0] + have_tt * sby * 4 * y_stride,
135
40
                f->lf.cdef_line[!tf][1] + have_tt * sby * 8 * uv_stride,
136
40
                f->lf.cdef_line[!tf][2] + have_tt * sby * 8 * uv_stride
137
40
            };
138
40
            backup2lines(cdef_top_bak, ptrs, f->cur.stride, layout);
139
40
        }
140
141
44
        ALIGN_STK_16(pixel, lr_bak, 2 /* idx */, [3 /* plane */][8 /* y */][2 /* x */]);
142
44
        pixel *iptrs[3] = { ptrs[0], ptrs[1], ptrs[2] };
143
44
        edges &= ~CDEF_HAVE_LEFT;
144
44
        edges |= CDEF_HAVE_RIGHT;
145
44
        enum Backup2x8Flags prev_flag = 0;
146
924
        for (int sbx = 0; sbx < sb64w; sbx++, edges |= CDEF_HAVE_LEFT) {
147
880
            const int sb128x = sbx >> 1;
148
880
            const int sb64_idx = ((by & sbsz) >> 3) + (sbx & 1);
149
880
            const int cdef_idx = lflvl[sb128x].cdef_idx[sb64_idx];
150
880
            if (cdef_idx == -1 ||
151
880
                (!f->frame_hdr->cdef.y_strength[cdef_idx] &&
152
880
                 !f->frame_hdr->cdef.uv_strength[cdef_idx]))
153
880
            {
154
880
                prev_flag = 0;
155
880
                goto next_sb;
156
880
            }
157
158
            // Create a complete 32-bit mask for the sb row ahead of time.
159
0
            const uint16_t (*noskip_row)[2] = &lflvl[sb128x].noskip_mask[by_idx];
160
0
            const unsigned noskip_mask = (unsigned) noskip_row[0][1] << 16 |
161
0
                                                    noskip_row[0][0];
162
163
0
            const int y_lvl = f->frame_hdr->cdef.y_strength[cdef_idx];
164
0
            const int uv_lvl = f->frame_hdr->cdef.uv_strength[cdef_idx];
165
0
            const enum Backup2x8Flags flag = !!y_lvl + (!!uv_lvl << 1);
166
167
0
            const int y_pri_lvl = (y_lvl >> 2) << bitdepth_min_8;
168
0
            int y_sec_lvl = y_lvl & 3;
169
0
            y_sec_lvl += y_sec_lvl == 3;
170
0
            y_sec_lvl <<= bitdepth_min_8;
171
172
0
            const int uv_pri_lvl = (uv_lvl >> 2) << bitdepth_min_8;
173
0
            int uv_sec_lvl = uv_lvl & 3;
174
0
            uv_sec_lvl += uv_sec_lvl == 3;
175
0
            uv_sec_lvl <<= bitdepth_min_8;
176
177
0
            pixel *bptrs[3] = { iptrs[0], iptrs[1], iptrs[2] };
178
0
            for (int bx = sbx * sbsz; bx < imin((sbx + 1) * sbsz, f->bw);
179
0
                 bx += 2, edges |= CDEF_HAVE_LEFT)
180
0
            {
181
0
                if (bx + 2 >= f->bw) edges &= ~CDEF_HAVE_RIGHT;
182
183
                // check if this 8x8 block had any coded coefficients; if not,
184
                // go to the next block
185
0
                const uint32_t bx_mask = 3U << (bx & 30);
186
0
                if (!(noskip_mask & bx_mask)) {
187
0
                    prev_flag = 0;
188
0
                    goto next_b;
189
0
                }
190
0
                const enum Backup2x8Flags do_left = (prev_flag ^ flag) & flag;
191
0
                prev_flag = flag;
192
0
                if (do_left && edges & CDEF_HAVE_LEFT) {
193
                    // we didn't backup the prefilter data because it wasn't
194
                    // there, so do it here instead
195
0
                    backup2x8(lr_bak[bit], bptrs, f->cur.stride, 0, layout, do_left);
196
0
                }
197
0
                if (edges & CDEF_HAVE_RIGHT) {
198
                    // backup pre-filter data for next iteration
199
0
                    backup2x8(lr_bak[!bit], bptrs, f->cur.stride, 8, layout, flag);
200
0
                }
201
202
0
                int dir;
203
0
                unsigned variance;
204
0
                if (y_pri_lvl || uv_pri_lvl)
205
0
                    dir = dsp->cdef.dir(bptrs[0], f->cur.stride[0],
206
0
                                        &variance HIGHBD_CALL_SUFFIX);
207
208
0
                const pixel *top, *bot;
209
0
                ptrdiff_t offset;
210
211
0
                if (!have_tt) goto st_y;
212
0
                if (sbrow_start && by == by_start) {
213
0
                    if (resize) {
214
0
                        offset = (sby - 1) * 4 * y_stride + bx * 4;
215
0
                        top = &f->lf.cdef_lpf_line[0][offset];
216
0
                    } else {
217
0
                        offset = (sby * (4 << sb128) - 4) * y_stride + bx * 4;
218
0
                        top = &f->lf.lr_lpf_line[0][offset];
219
0
                    }
220
0
                    bot = bptrs[0] + 8 * y_stride;
221
0
                } else if (!sbrow_start && by + 2 >= by_end) {
222
0
                    top = &f->lf.cdef_line[tf][0][sby * 4 * y_stride + bx * 4];
223
0
                    if (resize) {
224
0
                        offset = (sby * 4 + 2) * y_stride + bx * 4;
225
0
                        bot = &f->lf.cdef_lpf_line[0][offset];
226
0
                    } else {
227
0
                        const int line = sby * (4 << sb128) + 4 * sb128 + 2;
228
0
                        offset = line * y_stride + bx * 4;
229
0
                        bot = &f->lf.lr_lpf_line[0][offset];
230
0
                    }
231
0
                } else {
232
0
            st_y:;
233
0
                    offset = sby * 4 * y_stride;
234
0
                    top = &f->lf.cdef_line[tf][0][have_tt * offset + bx * 4];
235
0
                    bot = bptrs[0] + 8 * y_stride;
236
0
                }
237
0
                if (y_pri_lvl) {
238
0
                    const int adj_y_pri_lvl = adjust_strength(y_pri_lvl, variance);
239
0
                    if (adj_y_pri_lvl || y_sec_lvl)
240
0
                        dsp->cdef.fb[0](bptrs[0], f->cur.stride[0], lr_bak[bit][0],
241
0
                                        top, bot, adj_y_pri_lvl, y_sec_lvl,
242
0
                                        dir, damping, edges HIGHBD_CALL_SUFFIX);
243
0
                } else if (y_sec_lvl)
244
0
                    dsp->cdef.fb[0](bptrs[0], f->cur.stride[0], lr_bak[bit][0],
245
0
                                    top, bot, 0, y_sec_lvl, 0, damping,
246
0
                                    edges HIGHBD_CALL_SUFFIX);
247
248
0
                if (!uv_lvl) goto skip_uv;
249
0
                assert(layout != DAV1D_PIXEL_LAYOUT_I400);
250
251
0
                const int uvdir = uv_pri_lvl ? uv_dir[dir] : 0;
252
0
                for (int pl = 1; pl <= 2; pl++) {
253
0
                    if (!have_tt) goto st_uv;
254
0
                    if (sbrow_start && by == by_start) {
255
0
                        if (resize) {
256
0
                            offset = (sby - 1) * 4 * uv_stride + (bx * 4 >> ss_hor);
257
0
                            top = &f->lf.cdef_lpf_line[pl][offset];
258
0
                        } else {
259
0
                            const int line = sby * (4 << sb128) - 4;
260
0
                            offset = line * uv_stride + (bx * 4 >> ss_hor);
261
0
                            top = &f->lf.lr_lpf_line[pl][offset];
262
0
                        }
263
0
                        bot = bptrs[pl] + (8 >> ss_ver) * uv_stride;
264
0
                    } else if (!sbrow_start && by + 2 >= by_end) {
265
0
                        const ptrdiff_t top_offset = sby * 8 * uv_stride +
266
0
                                                     (bx * 4 >> ss_hor);
267
0
                        top = &f->lf.cdef_line[tf][pl][top_offset];
268
0
                        if (resize) {
269
0
                            offset = (sby * 4 + 2) * uv_stride + (bx * 4 >> ss_hor);
270
0
                            bot = &f->lf.cdef_lpf_line[pl][offset];
271
0
                        } else {
272
0
                            const int line = sby * (4 << sb128) + 4 * sb128 + 2;
273
0
                            offset = line * uv_stride + (bx * 4 >> ss_hor);
274
0
                            bot = &f->lf.lr_lpf_line[pl][offset];
275
0
                        }
276
0
                    } else {
277
0
                st_uv:;
278
0
                        const ptrdiff_t offset = sby * 8 * uv_stride;
279
0
                        top = &f->lf.cdef_line[tf][pl][have_tt * offset + (bx * 4 >> ss_hor)];
280
0
                        bot = bptrs[pl] + (8 >> ss_ver) * uv_stride;
281
0
                    }
282
0
                    dsp->cdef.fb[uv_idx](bptrs[pl], f->cur.stride[1],
283
0
                                         lr_bak[bit][pl], top, bot,
284
0
                                         uv_pri_lvl, uv_sec_lvl, uvdir,
285
0
                                         damping - 1, edges HIGHBD_CALL_SUFFIX);
286
0
                }
287
288
0
            skip_uv:
289
0
                bit ^= 1;
290
291
0
            next_b:
292
0
                bptrs[0] += 8;
293
0
                bptrs[1] += 8 >> ss_hor;
294
0
                bptrs[2] += 8 >> ss_hor;
295
0
            }
296
297
880
        next_sb:
298
880
            iptrs[0] += sbsz * 4;
299
880
            iptrs[1] += sbsz * 4 >> ss_hor;
300
880
            iptrs[2] += sbsz * 4 >> ss_hor;
301
880
        }
302
303
44
        ptrs[0] += 8 * PXSTRIDE(f->cur.stride[0]);
304
44
        ptrs[1] += 8 * PXSTRIDE(f->cur.stride[1]) >> ss_ver;
305
44
        ptrs[2] += 8 * PXSTRIDE(f->cur.stride[1]) >> ss_ver;
306
44
        tc->top_pre_cdef_toggle ^= 1;
307
44
    }
308
4
}
dav1d_cdef_brow_8bpc
Line
Count
Source
102
4
{
103
4
    Dav1dFrameContext *const f = (Dav1dFrameContext *)tc->f;
104
4
    const int bitdepth_min_8 = BITDEPTH == 8 ? 0 : f->cur.p.bpc - 8;
105
4
    const Dav1dDSPContext *const dsp = f->dsp;
106
4
    enum CdefEdgeFlags edges = CDEF_HAVE_BOTTOM | (by_start > 0 ? CDEF_HAVE_TOP : 0);
107
4
    pixel *ptrs[3] = { p[0], p[1], p[2] };
108
4
    const int sbsz = 16;
109
4
    const int sb64w = f->sb128w << 1;
110
4
    const int damping = f->frame_hdr->cdef.damping + bitdepth_min_8;
111
4
    const enum Dav1dPixelLayout layout = f->cur.p.layout;
112
4
    const int uv_idx = DAV1D_PIXEL_LAYOUT_I444 - layout;
113
4
    const int ss_ver = layout == DAV1D_PIXEL_LAYOUT_I420;
114
4
    const int ss_hor = layout != DAV1D_PIXEL_LAYOUT_I444;
115
4
    static const uint8_t uv_dirs[2][8] = { { 0, 1, 2, 3, 4, 5, 6, 7 },
116
4
                                           { 7, 0, 2, 4, 5, 6, 6, 6 } };
117
4
    const uint8_t *uv_dir = uv_dirs[layout == DAV1D_PIXEL_LAYOUT_I422];
118
4
    const int have_tt = f->c->n_tc > 1;
119
4
    const int sb128 = f->seq_hdr->sb128;
120
4
    const int resize = f->frame_hdr->width[0] != f->frame_hdr->width[1];
121
4
    const ptrdiff_t y_stride = PXSTRIDE(f->cur.stride[0]);
122
4
    const ptrdiff_t uv_stride = PXSTRIDE(f->cur.stride[1]);
123
124
48
    for (int bit = 0, by = by_start; by < by_end; by += 2, edges |= CDEF_HAVE_TOP) {
125
44
        const int tf = tc->top_pre_cdef_toggle;
126
44
        const int by_idx = (by & 30) >> 1;
127
44
        if (by + 2 >= f->bh) edges &= ~CDEF_HAVE_BOTTOM;
128
129
44
        if ((!have_tt || sbrow_start || by + 2 < by_end) &&
130
40
            edges & CDEF_HAVE_BOTTOM)
131
40
        {
132
            // backup pre-filter data for next iteration
133
40
            pixel *const cdef_top_bak[3] = {
134
40
                f->lf.cdef_line[!tf][0] + have_tt * sby * 4 * y_stride,
135
40
                f->lf.cdef_line[!tf][1] + have_tt * sby * 8 * uv_stride,
136
40
                f->lf.cdef_line[!tf][2] + have_tt * sby * 8 * uv_stride
137
40
            };
138
40
            backup2lines(cdef_top_bak, ptrs, f->cur.stride, layout);
139
40
        }
140
141
44
        ALIGN_STK_16(pixel, lr_bak, 2 /* idx */, [3 /* plane */][8 /* y */][2 /* x */]);
142
44
        pixel *iptrs[3] = { ptrs[0], ptrs[1], ptrs[2] };
143
44
        edges &= ~CDEF_HAVE_LEFT;
144
44
        edges |= CDEF_HAVE_RIGHT;
145
44
        enum Backup2x8Flags prev_flag = 0;
146
924
        for (int sbx = 0; sbx < sb64w; sbx++, edges |= CDEF_HAVE_LEFT) {
147
880
            const int sb128x = sbx >> 1;
148
880
            const int sb64_idx = ((by & sbsz) >> 3) + (sbx & 1);
149
880
            const int cdef_idx = lflvl[sb128x].cdef_idx[sb64_idx];
150
880
            if (cdef_idx == -1 ||
151
880
                (!f->frame_hdr->cdef.y_strength[cdef_idx] &&
152
880
                 !f->frame_hdr->cdef.uv_strength[cdef_idx]))
153
880
            {
154
880
                prev_flag = 0;
155
880
                goto next_sb;
156
880
            }
157
158
            // Create a complete 32-bit mask for the sb row ahead of time.
159
0
            const uint16_t (*noskip_row)[2] = &lflvl[sb128x].noskip_mask[by_idx];
160
0
            const unsigned noskip_mask = (unsigned) noskip_row[0][1] << 16 |
161
0
                                                    noskip_row[0][0];
162
163
0
            const int y_lvl = f->frame_hdr->cdef.y_strength[cdef_idx];
164
0
            const int uv_lvl = f->frame_hdr->cdef.uv_strength[cdef_idx];
165
0
            const enum Backup2x8Flags flag = !!y_lvl + (!!uv_lvl << 1);
166
167
0
            const int y_pri_lvl = (y_lvl >> 2) << bitdepth_min_8;
168
0
            int y_sec_lvl = y_lvl & 3;
169
0
            y_sec_lvl += y_sec_lvl == 3;
170
0
            y_sec_lvl <<= bitdepth_min_8;
171
172
0
            const int uv_pri_lvl = (uv_lvl >> 2) << bitdepth_min_8;
173
0
            int uv_sec_lvl = uv_lvl & 3;
174
0
            uv_sec_lvl += uv_sec_lvl == 3;
175
0
            uv_sec_lvl <<= bitdepth_min_8;
176
177
0
            pixel *bptrs[3] = { iptrs[0], iptrs[1], iptrs[2] };
178
0
            for (int bx = sbx * sbsz; bx < imin((sbx + 1) * sbsz, f->bw);
179
0
                 bx += 2, edges |= CDEF_HAVE_LEFT)
180
0
            {
181
0
                if (bx + 2 >= f->bw) edges &= ~CDEF_HAVE_RIGHT;
182
183
                // check if this 8x8 block had any coded coefficients; if not,
184
                // go to the next block
185
0
                const uint32_t bx_mask = 3U << (bx & 30);
186
0
                if (!(noskip_mask & bx_mask)) {
187
0
                    prev_flag = 0;
188
0
                    goto next_b;
189
0
                }
190
0
                const enum Backup2x8Flags do_left = (prev_flag ^ flag) & flag;
191
0
                prev_flag = flag;
192
0
                if (do_left && edges & CDEF_HAVE_LEFT) {
193
                    // we didn't backup the prefilter data because it wasn't
194
                    // there, so do it here instead
195
0
                    backup2x8(lr_bak[bit], bptrs, f->cur.stride, 0, layout, do_left);
196
0
                }
197
0
                if (edges & CDEF_HAVE_RIGHT) {
198
                    // backup pre-filter data for next iteration
199
0
                    backup2x8(lr_bak[!bit], bptrs, f->cur.stride, 8, layout, flag);
200
0
                }
201
202
0
                int dir;
203
0
                unsigned variance;
204
0
                if (y_pri_lvl || uv_pri_lvl)
205
0
                    dir = dsp->cdef.dir(bptrs[0], f->cur.stride[0],
206
0
                                        &variance HIGHBD_CALL_SUFFIX);
207
208
0
                const pixel *top, *bot;
209
0
                ptrdiff_t offset;
210
211
0
                if (!have_tt) goto st_y;
212
0
                if (sbrow_start && by == by_start) {
213
0
                    if (resize) {
214
0
                        offset = (sby - 1) * 4 * y_stride + bx * 4;
215
0
                        top = &f->lf.cdef_lpf_line[0][offset];
216
0
                    } else {
217
0
                        offset = (sby * (4 << sb128) - 4) * y_stride + bx * 4;
218
0
                        top = &f->lf.lr_lpf_line[0][offset];
219
0
                    }
220
0
                    bot = bptrs[0] + 8 * y_stride;
221
0
                } else if (!sbrow_start && by + 2 >= by_end) {
222
0
                    top = &f->lf.cdef_line[tf][0][sby * 4 * y_stride + bx * 4];
223
0
                    if (resize) {
224
0
                        offset = (sby * 4 + 2) * y_stride + bx * 4;
225
0
                        bot = &f->lf.cdef_lpf_line[0][offset];
226
0
                    } else {
227
0
                        const int line = sby * (4 << sb128) + 4 * sb128 + 2;
228
0
                        offset = line * y_stride + bx * 4;
229
0
                        bot = &f->lf.lr_lpf_line[0][offset];
230
0
                    }
231
0
                } else {
232
0
            st_y:;
233
0
                    offset = sby * 4 * y_stride;
234
0
                    top = &f->lf.cdef_line[tf][0][have_tt * offset + bx * 4];
235
0
                    bot = bptrs[0] + 8 * y_stride;
236
0
                }
237
0
                if (y_pri_lvl) {
238
0
                    const int adj_y_pri_lvl = adjust_strength(y_pri_lvl, variance);
239
0
                    if (adj_y_pri_lvl || y_sec_lvl)
240
0
                        dsp->cdef.fb[0](bptrs[0], f->cur.stride[0], lr_bak[bit][0],
241
0
                                        top, bot, adj_y_pri_lvl, y_sec_lvl,
242
0
                                        dir, damping, edges HIGHBD_CALL_SUFFIX);
243
0
                } else if (y_sec_lvl)
244
0
                    dsp->cdef.fb[0](bptrs[0], f->cur.stride[0], lr_bak[bit][0],
245
0
                                    top, bot, 0, y_sec_lvl, 0, damping,
246
0
                                    edges HIGHBD_CALL_SUFFIX);
247
248
0
                if (!uv_lvl) goto skip_uv;
249
0
                assert(layout != DAV1D_PIXEL_LAYOUT_I400);
250
251
0
                const int uvdir = uv_pri_lvl ? uv_dir[dir] : 0;
252
0
                for (int pl = 1; pl <= 2; pl++) {
253
0
                    if (!have_tt) goto st_uv;
254
0
                    if (sbrow_start && by == by_start) {
255
0
                        if (resize) {
256
0
                            offset = (sby - 1) * 4 * uv_stride + (bx * 4 >> ss_hor);
257
0
                            top = &f->lf.cdef_lpf_line[pl][offset];
258
0
                        } else {
259
0
                            const int line = sby * (4 << sb128) - 4;
260
0
                            offset = line * uv_stride + (bx * 4 >> ss_hor);
261
0
                            top = &f->lf.lr_lpf_line[pl][offset];
262
0
                        }
263
0
                        bot = bptrs[pl] + (8 >> ss_ver) * uv_stride;
264
0
                    } else if (!sbrow_start && by + 2 >= by_end) {
265
0
                        const ptrdiff_t top_offset = sby * 8 * uv_stride +
266
0
                                                     (bx * 4 >> ss_hor);
267
0
                        top = &f->lf.cdef_line[tf][pl][top_offset];
268
0
                        if (resize) {
269
0
                            offset = (sby * 4 + 2) * uv_stride + (bx * 4 >> ss_hor);
270
0
                            bot = &f->lf.cdef_lpf_line[pl][offset];
271
0
                        } else {
272
0
                            const int line = sby * (4 << sb128) + 4 * sb128 + 2;
273
0
                            offset = line * uv_stride + (bx * 4 >> ss_hor);
274
0
                            bot = &f->lf.lr_lpf_line[pl][offset];
275
0
                        }
276
0
                    } else {
277
0
                st_uv:;
278
0
                        const ptrdiff_t offset = sby * 8 * uv_stride;
279
0
                        top = &f->lf.cdef_line[tf][pl][have_tt * offset + (bx * 4 >> ss_hor)];
280
0
                        bot = bptrs[pl] + (8 >> ss_ver) * uv_stride;
281
0
                    }
282
0
                    dsp->cdef.fb[uv_idx](bptrs[pl], f->cur.stride[1],
283
0
                                         lr_bak[bit][pl], top, bot,
284
0
                                         uv_pri_lvl, uv_sec_lvl, uvdir,
285
0
                                         damping - 1, edges HIGHBD_CALL_SUFFIX);
286
0
                }
287
288
0
            skip_uv:
289
0
                bit ^= 1;
290
291
0
            next_b:
292
0
                bptrs[0] += 8;
293
0
                bptrs[1] += 8 >> ss_hor;
294
0
                bptrs[2] += 8 >> ss_hor;
295
0
            }
296
297
880
        next_sb:
298
880
            iptrs[0] += sbsz * 4;
299
880
            iptrs[1] += sbsz * 4 >> ss_hor;
300
880
            iptrs[2] += sbsz * 4 >> ss_hor;
301
880
        }
302
303
44
        ptrs[0] += 8 * PXSTRIDE(f->cur.stride[0]);
304
44
        ptrs[1] += 8 * PXSTRIDE(f->cur.stride[1]) >> ss_ver;
305
44
        ptrs[2] += 8 * PXSTRIDE(f->cur.stride[1]) >> ss_ver;
306
44
        tc->top_pre_cdef_toggle ^= 1;
307
44
    }
308
4
}
Unexecuted instantiation: dav1d_cdef_brow_16bpc