/work/dav1d/src/lf_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/lf_apply.h" |
35 | | #include "src/lr_apply.h" |
36 | | |
37 | | // The loop filter buffer stores 12 rows of pixels. A superblock block will |
38 | | // contain at most 2 stripes. Each stripe requires 4 rows pixels (2 above |
39 | | // and 2 below) the final 4 rows are used to swap the bottom of the last |
40 | | // stripe with the top of the next super block row. |
41 | | static void backup_lpf(const Dav1dFrameContext *const f, |
42 | | pixel *dst, const ptrdiff_t dst_stride, |
43 | | const pixel *src, const ptrdiff_t src_stride, |
44 | | const int ss_ver, const int sb128, |
45 | | int row, const int row_h, const int src_w, |
46 | | const int h, const int ss_hor, const int lr_backup) |
47 | 908k | { |
48 | 908k | const int cdef_backup = !lr_backup; |
49 | 908k | const int dst_w = f->frame_hdr->super_res.enabled ? |
50 | 530k | (f->frame_hdr->width[1] + ss_hor) >> ss_hor : src_w; |
51 | | |
52 | | // The first stripe of the frame is shorter by 8 luma pixel rows. |
53 | 908k | int stripe_h = ((64 << (cdef_backup & sb128)) - 8 * !row) >> ss_ver; |
54 | 908k | src += (stripe_h - 2) * PXSTRIDE(src_stride); |
55 | | |
56 | 908k | if (f->c->n_tc == 1) { |
57 | 0 | if (row) { |
58 | 0 | const int top = 4 << sb128; |
59 | | // Copy the top part of the stored loop filtered pixels from the |
60 | | // previous sb row needed above the first stripe of this sb row. |
61 | 0 | pixel_copy(&dst[PXSTRIDE(dst_stride) * 0], |
62 | 0 | &dst[PXSTRIDE(dst_stride) * top], dst_w); |
63 | 0 | pixel_copy(&dst[PXSTRIDE(dst_stride) * 1], |
64 | 0 | &dst[PXSTRIDE(dst_stride) * (top + 1)], dst_w); |
65 | 0 | pixel_copy(&dst[PXSTRIDE(dst_stride) * 2], |
66 | 0 | &dst[PXSTRIDE(dst_stride) * (top + 2)], dst_w); |
67 | 0 | pixel_copy(&dst[PXSTRIDE(dst_stride) * 3], |
68 | 0 | &dst[PXSTRIDE(dst_stride) * (top + 3)], dst_w); |
69 | 0 | } |
70 | 0 | dst += 4 * PXSTRIDE(dst_stride); |
71 | 0 | } |
72 | | |
73 | 908k | if (lr_backup && (f->frame_hdr->width[0] != f->frame_hdr->width[1])) { |
74 | 155k | while (row + stripe_h <= row_h) { |
75 | 69.0k | const int n_lines = 4 - (row + stripe_h + 1 == h); |
76 | 69.0k | f->dsp->mc.resize(dst, dst_stride, src, src_stride, |
77 | 69.0k | dst_w, n_lines, src_w, f->resize_step[ss_hor], |
78 | 69.0k | f->resize_start[ss_hor] HIGHBD_CALL_SUFFIX); |
79 | 69.0k | row += stripe_h; // unmodified stripe_h for the 1st stripe |
80 | 69.0k | stripe_h = 64 >> ss_ver; |
81 | 69.0k | src += stripe_h * PXSTRIDE(src_stride); |
82 | 69.0k | dst += n_lines * PXSTRIDE(dst_stride); |
83 | 69.0k | if (n_lines == 3) { |
84 | 1.06k | pixel_copy(dst, &dst[-PXSTRIDE(dst_stride)], dst_w); |
85 | 1.06k | dst += PXSTRIDE(dst_stride); |
86 | 1.06k | } |
87 | 69.0k | } |
88 | 821k | } else { |
89 | 1.39M | while (row + stripe_h <= row_h) { |
90 | 575k | const int n_lines = 4 - (row + stripe_h + 1 == h); |
91 | 2.87M | for (int i = 0; i < 4; i++) { |
92 | 2.30M | pixel_copy(dst, i == n_lines ? &dst[-PXSTRIDE(dst_stride)] : |
93 | 2.30M | src, src_w); |
94 | 2.30M | dst += PXSTRIDE(dst_stride); |
95 | 2.30M | src += PXSTRIDE(src_stride); |
96 | 2.30M | } |
97 | 575k | row += stripe_h; // unmodified stripe_h for the 1st stripe |
98 | 575k | stripe_h = 64 >> ss_ver; |
99 | 575k | src += (stripe_h - 4) * PXSTRIDE(src_stride); |
100 | 575k | } |
101 | 821k | } |
102 | 908k | } |
103 | | |
104 | | void bytefn(dav1d_copy_lpf)(Dav1dFrameContext *const f, |
105 | | /*const*/ pixel *const src[3], const int sby) |
106 | 350k | { |
107 | 350k | const int have_tt = f->c->n_tc > 1; |
108 | 350k | const int resize = f->frame_hdr->width[0] != f->frame_hdr->width[1]; |
109 | 350k | const int offset = 8 * !!sby; |
110 | 350k | const ptrdiff_t *const src_stride = f->cur.stride; |
111 | 350k | const ptrdiff_t *const lr_stride = f->sr_cur.p.stride; |
112 | 350k | const int tt_off = have_tt * sby * (4 << f->seq_hdr->sb128); |
113 | 350k | pixel *const dst[3] = { |
114 | 350k | f->lf.lr_lpf_line[0] + tt_off * PXSTRIDE(lr_stride[0]), |
115 | 350k | f->lf.lr_lpf_line[1] + tt_off * PXSTRIDE(lr_stride[1]), |
116 | 350k | f->lf.lr_lpf_line[2] + tt_off * PXSTRIDE(lr_stride[1]) |
117 | 350k | }; |
118 | | |
119 | | // TODO Also check block level restore type to reduce copying. |
120 | 350k | const int restore_planes = f->lf.restore_planes; |
121 | | |
122 | 350k | if (f->seq_hdr->cdef || restore_planes & LR_RESTORE_Y) { |
123 | 340k | const int h = f->cur.p.h; |
124 | 340k | const int w = f->bw << 2; |
125 | 340k | const int row_h = imin((sby + 1) << (6 + f->seq_hdr->sb128), h - 1); |
126 | 340k | const int y_stripe = (sby << (6 + f->seq_hdr->sb128)) - offset; |
127 | 340k | if (restore_planes & LR_RESTORE_Y || !resize) |
128 | 318k | backup_lpf(f, dst[0], lr_stride[0], |
129 | 318k | src[0] - offset * PXSTRIDE(src_stride[0]), src_stride[0], |
130 | 318k | 0, f->seq_hdr->sb128, y_stripe, row_h, w, h, 0, 1); |
131 | 340k | if (have_tt && resize) { |
132 | 56.6k | const ptrdiff_t cdef_off_y = sby * 4 * PXSTRIDE(src_stride[0]); |
133 | 56.6k | backup_lpf(f, f->lf.cdef_lpf_line[0] + cdef_off_y, src_stride[0], |
134 | 56.6k | src[0] - offset * PXSTRIDE(src_stride[0]), src_stride[0], |
135 | 56.6k | 0, f->seq_hdr->sb128, y_stripe, row_h, w, h, 0, 0); |
136 | 56.6k | } |
137 | 340k | } |
138 | 350k | if ((f->seq_hdr->cdef || restore_planes & (LR_RESTORE_U | LR_RESTORE_V)) && |
139 | 317k | f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400) |
140 | 263k | { |
141 | 263k | const int ss_ver = f->sr_cur.p.p.layout == DAV1D_PIXEL_LAYOUT_I420; |
142 | 263k | const int ss_hor = f->sr_cur.p.p.layout != DAV1D_PIXEL_LAYOUT_I444; |
143 | 263k | const int h = (f->cur.p.h + ss_ver) >> ss_ver; |
144 | 263k | const int w = f->bw << (2 - ss_hor); |
145 | 263k | const int row_h = imin((sby + 1) << ((6 - ss_ver) + f->seq_hdr->sb128), h - 1); |
146 | 263k | const int offset_uv = offset >> ss_ver; |
147 | 263k | const int y_stripe = (sby << ((6 - ss_ver) + f->seq_hdr->sb128)) - offset_uv; |
148 | 263k | const ptrdiff_t cdef_off_uv = sby * 4 * PXSTRIDE(src_stride[1]); |
149 | 263k | if (f->seq_hdr->cdef || restore_planes & LR_RESTORE_U) { |
150 | 225k | if (restore_planes & LR_RESTORE_U || !resize) |
151 | 201k | backup_lpf(f, dst[1], lr_stride[1], |
152 | 201k | src[1] - offset_uv * PXSTRIDE(src_stride[1]), |
153 | 201k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, |
154 | 201k | row_h, w, h, ss_hor, 1); |
155 | 225k | if (have_tt && resize) |
156 | 44.0k | backup_lpf(f, f->lf.cdef_lpf_line[1] + cdef_off_uv, src_stride[1], |
157 | 44.0k | src[1] - offset_uv * PXSTRIDE(src_stride[1]), |
158 | 44.0k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, |
159 | 44.0k | row_h, w, h, ss_hor, 0); |
160 | 225k | } |
161 | 263k | if (f->seq_hdr->cdef || restore_planes & LR_RESTORE_V) { |
162 | 256k | if (restore_planes & LR_RESTORE_V || !resize) |
163 | 239k | backup_lpf(f, dst[2], lr_stride[1], |
164 | 239k | src[2] - offset_uv * PXSTRIDE(src_stride[1]), |
165 | 239k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, |
166 | 239k | row_h, w, h, ss_hor, 1); |
167 | 256k | if (have_tt && resize) |
168 | 48.9k | backup_lpf(f, f->lf.cdef_lpf_line[2] + cdef_off_uv, src_stride[1], |
169 | 48.9k | src[2] - offset_uv * PXSTRIDE(src_stride[1]), |
170 | 48.9k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, |
171 | 48.9k | row_h, w, h, ss_hor, 0); |
172 | 256k | } |
173 | 263k | } |
174 | 350k | } Line | Count | Source | 106 | 171k | { | 107 | 171k | const int have_tt = f->c->n_tc > 1; | 108 | 171k | const int resize = f->frame_hdr->width[0] != f->frame_hdr->width[1]; | 109 | 171k | const int offset = 8 * !!sby; | 110 | 171k | const ptrdiff_t *const src_stride = f->cur.stride; | 111 | 171k | const ptrdiff_t *const lr_stride = f->sr_cur.p.stride; | 112 | 171k | const int tt_off = have_tt * sby * (4 << f->seq_hdr->sb128); | 113 | 171k | pixel *const dst[3] = { | 114 | 171k | f->lf.lr_lpf_line[0] + tt_off * PXSTRIDE(lr_stride[0]), | 115 | 171k | f->lf.lr_lpf_line[1] + tt_off * PXSTRIDE(lr_stride[1]), | 116 | 171k | f->lf.lr_lpf_line[2] + tt_off * PXSTRIDE(lr_stride[1]) | 117 | 171k | }; | 118 | | | 119 | | // TODO Also check block level restore type to reduce copying. | 120 | 171k | const int restore_planes = f->lf.restore_planes; | 121 | | | 122 | 171k | if (f->seq_hdr->cdef || restore_planes & LR_RESTORE_Y) { | 123 | 167k | const int h = f->cur.p.h; | 124 | 167k | const int w = f->bw << 2; | 125 | 167k | const int row_h = imin((sby + 1) << (6 + f->seq_hdr->sb128), h - 1); | 126 | 167k | const int y_stripe = (sby << (6 + f->seq_hdr->sb128)) - offset; | 127 | 167k | if (restore_planes & LR_RESTORE_Y || !resize) | 128 | 158k | backup_lpf(f, dst[0], lr_stride[0], | 129 | 158k | src[0] - offset * PXSTRIDE(src_stride[0]), src_stride[0], | 130 | 158k | 0, f->seq_hdr->sb128, y_stripe, row_h, w, h, 0, 1); | 131 | 167k | if (have_tt && resize) { | 132 | 26.1k | const ptrdiff_t cdef_off_y = sby * 4 * PXSTRIDE(src_stride[0]); | 133 | 26.1k | backup_lpf(f, f->lf.cdef_lpf_line[0] + cdef_off_y, src_stride[0], | 134 | 26.1k | src[0] - offset * PXSTRIDE(src_stride[0]), src_stride[0], | 135 | 26.1k | 0, f->seq_hdr->sb128, y_stripe, row_h, w, h, 0, 0); | 136 | 26.1k | } | 137 | 167k | } | 138 | 171k | if ((f->seq_hdr->cdef || restore_planes & (LR_RESTORE_U | LR_RESTORE_V)) && | 139 | 165k | f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400) | 140 | 140k | { | 141 | 140k | const int ss_ver = f->sr_cur.p.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 142 | 140k | const int ss_hor = f->sr_cur.p.p.layout != DAV1D_PIXEL_LAYOUT_I444; | 143 | 140k | const int h = (f->cur.p.h + ss_ver) >> ss_ver; | 144 | 140k | const int w = f->bw << (2 - ss_hor); | 145 | 140k | const int row_h = imin((sby + 1) << ((6 - ss_ver) + f->seq_hdr->sb128), h - 1); | 146 | 140k | const int offset_uv = offset >> ss_ver; | 147 | 140k | const int y_stripe = (sby << ((6 - ss_ver) + f->seq_hdr->sb128)) - offset_uv; | 148 | 140k | const ptrdiff_t cdef_off_uv = sby * 4 * PXSTRIDE(src_stride[1]); | 149 | 140k | if (f->seq_hdr->cdef || restore_planes & LR_RESTORE_U) { | 150 | 119k | if (restore_planes & LR_RESTORE_U || !resize) | 151 | 108k | backup_lpf(f, dst[1], lr_stride[1], | 152 | 108k | src[1] - offset_uv * PXSTRIDE(src_stride[1]), | 153 | 108k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, | 154 | 108k | row_h, w, h, ss_hor, 1); | 155 | 119k | if (have_tt && resize) | 156 | 20.6k | backup_lpf(f, f->lf.cdef_lpf_line[1] + cdef_off_uv, src_stride[1], | 157 | 20.6k | src[1] - offset_uv * PXSTRIDE(src_stride[1]), | 158 | 20.6k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, | 159 | 20.6k | row_h, w, h, ss_hor, 0); | 160 | 119k | } | 161 | 140k | if (f->seq_hdr->cdef || restore_planes & LR_RESTORE_V) { | 162 | 137k | if (restore_planes & LR_RESTORE_V || !resize) | 163 | 130k | backup_lpf(f, dst[2], lr_stride[1], | 164 | 130k | src[2] - offset_uv * PXSTRIDE(src_stride[1]), | 165 | 130k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, | 166 | 130k | row_h, w, h, ss_hor, 1); | 167 | 137k | if (have_tt && resize) | 168 | 22.6k | backup_lpf(f, f->lf.cdef_lpf_line[2] + cdef_off_uv, src_stride[1], | 169 | 22.6k | src[2] - offset_uv * PXSTRIDE(src_stride[1]), | 170 | 22.6k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, | 171 | 22.6k | row_h, w, h, ss_hor, 0); | 172 | 137k | } | 173 | 140k | } | 174 | 171k | } |
Line | Count | Source | 106 | 179k | { | 107 | 179k | const int have_tt = f->c->n_tc > 1; | 108 | 179k | const int resize = f->frame_hdr->width[0] != f->frame_hdr->width[1]; | 109 | 179k | const int offset = 8 * !!sby; | 110 | 179k | const ptrdiff_t *const src_stride = f->cur.stride; | 111 | 179k | const ptrdiff_t *const lr_stride = f->sr_cur.p.stride; | 112 | 179k | const int tt_off = have_tt * sby * (4 << f->seq_hdr->sb128); | 113 | 179k | pixel *const dst[3] = { | 114 | 179k | f->lf.lr_lpf_line[0] + tt_off * PXSTRIDE(lr_stride[0]), | 115 | 179k | f->lf.lr_lpf_line[1] + tt_off * PXSTRIDE(lr_stride[1]), | 116 | 179k | f->lf.lr_lpf_line[2] + tt_off * PXSTRIDE(lr_stride[1]) | 117 | 179k | }; | 118 | | | 119 | | // TODO Also check block level restore type to reduce copying. | 120 | 179k | const int restore_planes = f->lf.restore_planes; | 121 | | | 122 | 179k | if (f->seq_hdr->cdef || restore_planes & LR_RESTORE_Y) { | 123 | 172k | const int h = f->cur.p.h; | 124 | 172k | const int w = f->bw << 2; | 125 | 172k | const int row_h = imin((sby + 1) << (6 + f->seq_hdr->sb128), h - 1); | 126 | 172k | const int y_stripe = (sby << (6 + f->seq_hdr->sb128)) - offset; | 127 | 172k | if (restore_planes & LR_RESTORE_Y || !resize) | 128 | 159k | backup_lpf(f, dst[0], lr_stride[0], | 129 | 159k | src[0] - offset * PXSTRIDE(src_stride[0]), src_stride[0], | 130 | 159k | 0, f->seq_hdr->sb128, y_stripe, row_h, w, h, 0, 1); | 131 | 172k | if (have_tt && resize) { | 132 | 30.4k | const ptrdiff_t cdef_off_y = sby * 4 * PXSTRIDE(src_stride[0]); | 133 | 30.4k | backup_lpf(f, f->lf.cdef_lpf_line[0] + cdef_off_y, src_stride[0], | 134 | 30.4k | src[0] - offset * PXSTRIDE(src_stride[0]), src_stride[0], | 135 | 30.4k | 0, f->seq_hdr->sb128, y_stripe, row_h, w, h, 0, 0); | 136 | 30.4k | } | 137 | 172k | } | 138 | 179k | if ((f->seq_hdr->cdef || restore_planes & (LR_RESTORE_U | LR_RESTORE_V)) && | 139 | 151k | f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400) | 140 | 123k | { | 141 | 123k | const int ss_ver = f->sr_cur.p.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 142 | 123k | const int ss_hor = f->sr_cur.p.p.layout != DAV1D_PIXEL_LAYOUT_I444; | 143 | 123k | const int h = (f->cur.p.h + ss_ver) >> ss_ver; | 144 | 123k | const int w = f->bw << (2 - ss_hor); | 145 | 123k | const int row_h = imin((sby + 1) << ((6 - ss_ver) + f->seq_hdr->sb128), h - 1); | 146 | 123k | const int offset_uv = offset >> ss_ver; | 147 | 123k | const int y_stripe = (sby << ((6 - ss_ver) + f->seq_hdr->sb128)) - offset_uv; | 148 | 123k | const ptrdiff_t cdef_off_uv = sby * 4 * PXSTRIDE(src_stride[1]); | 149 | 123k | if (f->seq_hdr->cdef || restore_planes & LR_RESTORE_U) { | 150 | 105k | if (restore_planes & LR_RESTORE_U || !resize) | 151 | 92.2k | backup_lpf(f, dst[1], lr_stride[1], | 152 | 92.2k | src[1] - offset_uv * PXSTRIDE(src_stride[1]), | 153 | 92.2k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, | 154 | 92.2k | row_h, w, h, ss_hor, 1); | 155 | 105k | if (have_tt && resize) | 156 | 23.3k | backup_lpf(f, f->lf.cdef_lpf_line[1] + cdef_off_uv, src_stride[1], | 157 | 23.3k | src[1] - offset_uv * PXSTRIDE(src_stride[1]), | 158 | 23.3k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, | 159 | 23.3k | row_h, w, h, ss_hor, 0); | 160 | 105k | } | 161 | 123k | if (f->seq_hdr->cdef || restore_planes & LR_RESTORE_V) { | 162 | 118k | if (restore_planes & LR_RESTORE_V || !resize) | 163 | 109k | backup_lpf(f, dst[2], lr_stride[1], | 164 | 109k | src[2] - offset_uv * PXSTRIDE(src_stride[1]), | 165 | 109k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, | 166 | 109k | row_h, w, h, ss_hor, 1); | 167 | 118k | if (have_tt && resize) | 168 | 26.3k | backup_lpf(f, f->lf.cdef_lpf_line[2] + cdef_off_uv, src_stride[1], | 169 | 26.3k | src[2] - offset_uv * PXSTRIDE(src_stride[1]), | 170 | 26.3k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, | 171 | 26.3k | row_h, w, h, ss_hor, 0); | 172 | 118k | } | 173 | 123k | } | 174 | 179k | } |
|
175 | | |
176 | | static inline void filter_plane_cols_y(const Dav1dFrameContext *const f, |
177 | | const int have_left, |
178 | | const uint8_t (*lvl)[4], |
179 | | const ptrdiff_t b4_stride, |
180 | | const uint16_t (*const mask)[3][2], |
181 | | pixel *dst, const ptrdiff_t ls, |
182 | | const int w, |
183 | | const int starty4, const int endy4) |
184 | 449k | { |
185 | 449k | const Dav1dDSPContext *const dsp = f->dsp; |
186 | | |
187 | | // filter edges between columns (e.g. block1 | block2) |
188 | 5.16M | for (int x = 0; x < w; x++) { |
189 | 4.71M | if (!have_left && !x) continue; |
190 | 4.35M | uint32_t hmask[4]; |
191 | 4.35M | if (!starty4) { |
192 | 3.49M | hmask[0] = mask[x][0][0]; |
193 | 3.49M | hmask[1] = mask[x][1][0]; |
194 | 3.49M | hmask[2] = mask[x][2][0]; |
195 | 3.49M | if (endy4 > 16) { |
196 | 1.08M | hmask[0] |= (unsigned) mask[x][0][1] << 16; |
197 | 1.08M | hmask[1] |= (unsigned) mask[x][1][1] << 16; |
198 | 1.08M | hmask[2] |= (unsigned) mask[x][2][1] << 16; |
199 | 1.08M | } |
200 | 3.49M | } else { |
201 | 860k | hmask[0] = mask[x][0][1]; |
202 | 860k | hmask[1] = mask[x][1][1]; |
203 | 860k | hmask[2] = mask[x][2][1]; |
204 | 860k | } |
205 | 4.35M | hmask[3] = 0; |
206 | 4.35M | dsp->lf.loop_filter_sb[0][0](&dst[x * 4], ls, hmask, |
207 | 4.35M | (const uint8_t(*)[4]) &lvl[x][0], b4_stride, |
208 | 4.35M | &f->lf.lim_lut, endy4 - starty4 HIGHBD_CALL_SUFFIX); |
209 | 4.35M | } |
210 | 449k | } |
211 | | |
212 | | static inline void filter_plane_rows_y(const Dav1dFrameContext *const f, |
213 | | const int have_top, |
214 | | const uint8_t (*lvl)[4], |
215 | | const ptrdiff_t b4_stride, |
216 | | const uint16_t (*const mask)[3][2], |
217 | | pixel *dst, const ptrdiff_t ls, |
218 | | const int w, |
219 | | const int starty4, const int endy4) |
220 | 449k | { |
221 | 449k | const Dav1dDSPContext *const dsp = f->dsp; |
222 | | |
223 | | // block1 |
224 | | // filter edges between rows (e.g. ------) |
225 | | // block2 |
226 | 6.06M | for (int y = starty4; y < endy4; |
227 | 5.61M | y++, dst += 4 * PXSTRIDE(ls), lvl += b4_stride) |
228 | 5.61M | { |
229 | 5.61M | if (!have_top && !y) continue; |
230 | 5.36M | const uint32_t vmask[4] = { |
231 | 5.36M | mask[y][0][0] | ((unsigned) mask[y][0][1] << 16), |
232 | 5.36M | mask[y][1][0] | ((unsigned) mask[y][1][1] << 16), |
233 | 5.36M | mask[y][2][0] | ((unsigned) mask[y][2][1] << 16), |
234 | 5.36M | 0, |
235 | 5.36M | }; |
236 | 5.36M | dsp->lf.loop_filter_sb[0][1](dst, ls, vmask, |
237 | 5.36M | (const uint8_t(*)[4]) &lvl[0][1], b4_stride, |
238 | 5.36M | &f->lf.lim_lut, w HIGHBD_CALL_SUFFIX); |
239 | 5.36M | } |
240 | 449k | } |
241 | | |
242 | | static inline void filter_plane_cols_uv(const Dav1dFrameContext *const f, |
243 | | const int have_left, |
244 | | const uint8_t (*lvl)[4], |
245 | | const ptrdiff_t b4_stride, |
246 | | const uint16_t (*const mask)[2][2], |
247 | | pixel *const u, pixel *const v, |
248 | | const ptrdiff_t ls, const int w, |
249 | | const int starty4, const int endy4, |
250 | | const int ss_ver) |
251 | 327k | { |
252 | 327k | const Dav1dDSPContext *const dsp = f->dsp; |
253 | | |
254 | | // filter edges between columns (e.g. block1 | block2) |
255 | 2.76M | for (int x = 0; x < w; x++) { |
256 | 2.43M | if (!have_left && !x) continue; |
257 | 2.17M | uint32_t hmask[3]; |
258 | 2.17M | if (!starty4) { |
259 | 1.74M | hmask[0] = mask[x][0][0]; |
260 | 1.74M | hmask[1] = mask[x][1][0]; |
261 | 1.74M | if (endy4 > (16 >> ss_ver)) { |
262 | 530k | hmask[0] |= (unsigned) mask[x][0][1] << (16 >> ss_ver); |
263 | 530k | hmask[1] |= (unsigned) mask[x][1][1] << (16 >> ss_ver); |
264 | 530k | } |
265 | 1.74M | } else { |
266 | 424k | hmask[0] = mask[x][0][1]; |
267 | 424k | hmask[1] = mask[x][1][1]; |
268 | 424k | } |
269 | 2.17M | hmask[2] = 0; |
270 | 2.17M | dsp->lf.loop_filter_sb[1][0](&u[x * 4], ls, hmask, |
271 | 2.17M | (const uint8_t(*)[4]) &lvl[x][2], b4_stride, |
272 | 2.17M | &f->lf.lim_lut, endy4 - starty4 HIGHBD_CALL_SUFFIX); |
273 | 2.17M | dsp->lf.loop_filter_sb[1][0](&v[x * 4], ls, hmask, |
274 | 2.17M | (const uint8_t(*)[4]) &lvl[x][3], b4_stride, |
275 | 2.17M | &f->lf.lim_lut, endy4 - starty4 HIGHBD_CALL_SUFFIX); |
276 | 2.17M | } |
277 | 327k | } |
278 | | |
279 | | static inline void filter_plane_rows_uv(const Dav1dFrameContext *const f, |
280 | | const int have_top, |
281 | | const uint8_t (*lvl)[4], |
282 | | const ptrdiff_t b4_stride, |
283 | | const uint16_t (*const mask)[2][2], |
284 | | pixel *const u, pixel *const v, |
285 | | const ptrdiff_t ls, const int w, |
286 | | const int starty4, const int endy4, |
287 | | const int ss_hor) |
288 | 326k | { |
289 | 326k | const Dav1dDSPContext *const dsp = f->dsp; |
290 | 326k | ptrdiff_t off_l = 0; |
291 | | |
292 | | // block1 |
293 | | // filter edges between rows (e.g. ------) |
294 | | // block2 |
295 | 3.14M | for (int y = starty4; y < endy4; |
296 | 2.82M | y++, off_l += 4 * PXSTRIDE(ls), lvl += b4_stride) |
297 | 2.82M | { |
298 | 2.82M | if (!have_top && !y) continue; |
299 | 2.64M | const uint32_t vmask[3] = { |
300 | 2.64M | mask[y][0][0] | ((unsigned) mask[y][0][1] << (16 >> ss_hor)), |
301 | 2.64M | mask[y][1][0] | ((unsigned) mask[y][1][1] << (16 >> ss_hor)), |
302 | 2.64M | 0, |
303 | 2.64M | }; |
304 | 2.64M | dsp->lf.loop_filter_sb[1][1](&u[off_l], ls, vmask, |
305 | 2.64M | (const uint8_t(*)[4]) &lvl[0][2], b4_stride, |
306 | 2.64M | &f->lf.lim_lut, w HIGHBD_CALL_SUFFIX); |
307 | 2.64M | dsp->lf.loop_filter_sb[1][1](&v[off_l], ls, vmask, |
308 | 2.64M | (const uint8_t(*)[4]) &lvl[0][3], b4_stride, |
309 | 2.64M | &f->lf.lim_lut, w HIGHBD_CALL_SUFFIX); |
310 | 2.64M | } |
311 | 326k | } |
312 | | |
313 | | void bytefn(dav1d_loopfilter_sbrow_cols)(const Dav1dFrameContext *const f, |
314 | | pixel *const p[3], Av1Filter *const lflvl, |
315 | | int sby, const int start_of_tile_row) |
316 | 360k | { |
317 | 360k | int x, have_left; |
318 | | // Don't filter outside the frame |
319 | 360k | const int is_sb64 = !f->seq_hdr->sb128; |
320 | 360k | const int starty4 = (sby & is_sb64) << 4; |
321 | 360k | const int sbsz = 32 >> is_sb64; |
322 | 360k | const int sbl2 = 5 - is_sb64; |
323 | 360k | const int halign = (f->bh + 31) & ~31; |
324 | 360k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; |
325 | 360k | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; |
326 | 360k | const int vmask = 16 >> ss_ver, hmask = 16 >> ss_hor; |
327 | 360k | const unsigned vmax = 1U << vmask, hmax = 1U << hmask; |
328 | 360k | const unsigned endy4 = starty4 + imin(f->h4 - sby * sbsz, sbsz); |
329 | 360k | const unsigned uv_endy4 = (endy4 + ss_ver) >> ss_ver; |
330 | | |
331 | | // fix lpf strength at tile col boundaries |
332 | 360k | const uint8_t *lpf_y = &f->lf.tx_lpf_right_edge[0][sby << sbl2]; |
333 | 360k | const uint8_t *lpf_uv = &f->lf.tx_lpf_right_edge[1][sby << (sbl2 - ss_ver)]; |
334 | 363k | for (int tile_col = 1;; tile_col++) { |
335 | 363k | x = f->frame_hdr->tiling.col_start_sb[tile_col]; |
336 | 363k | if ((x << sbl2) >= f->bw) break; |
337 | 2.70k | const int bx4 = x & is_sb64 ? 16 : 0, cbx4 = bx4 >> ss_hor; |
338 | 2.70k | x >>= is_sb64; |
339 | | |
340 | 2.70k | uint16_t (*const y_hmask)[2] = lflvl[x].filter_y[0][bx4]; |
341 | 33.0k | for (unsigned y = starty4, mask = 1 << y; y < endy4; y++, mask <<= 1) { |
342 | 30.3k | const int sidx = mask >= 0x10000U; |
343 | 30.3k | const unsigned smask = mask >> (sidx << 4); |
344 | 30.3k | const int idx = 2 * !!(y_hmask[2][sidx] & smask) + |
345 | 30.3k | !!(y_hmask[1][sidx] & smask); |
346 | 30.3k | y_hmask[2][sidx] &= ~smask; |
347 | 30.3k | y_hmask[1][sidx] &= ~smask; |
348 | 30.3k | y_hmask[0][sidx] &= ~smask; |
349 | 30.3k | y_hmask[imin(idx, lpf_y[y - starty4])][sidx] |= smask; |
350 | 30.3k | } |
351 | | |
352 | 2.70k | if (f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400) { |
353 | 2.14k | uint16_t (*const uv_hmask)[2] = lflvl[x].filter_uv[0][cbx4]; |
354 | 18.1k | for (unsigned y = starty4 >> ss_ver, uv_mask = 1 << y; y < uv_endy4; |
355 | 15.9k | y++, uv_mask <<= 1) |
356 | 15.9k | { |
357 | 15.9k | const int sidx = uv_mask >= vmax; |
358 | 15.9k | const unsigned smask = uv_mask >> (sidx << (4 - ss_ver)); |
359 | 15.9k | const int idx = !!(uv_hmask[1][sidx] & smask); |
360 | 15.9k | uv_hmask[1][sidx] &= ~smask; |
361 | 15.9k | uv_hmask[0][sidx] &= ~smask; |
362 | 15.9k | uv_hmask[imin(idx, lpf_uv[y - (starty4 >> ss_ver)])][sidx] |= smask; |
363 | 15.9k | } |
364 | 2.14k | } |
365 | 2.70k | lpf_y += halign; |
366 | 2.70k | lpf_uv += halign >> ss_ver; |
367 | 2.70k | } |
368 | | |
369 | | // fix lpf strength at tile row boundaries |
370 | 360k | if (start_of_tile_row) { |
371 | 2.17k | const BlockContext *a; |
372 | 2.17k | for (x = 0, a = &f->a[f->sb128w * (start_of_tile_row - 1)]; |
373 | 5.14k | x < f->sb128w; x++, a++) |
374 | 2.97k | { |
375 | 2.97k | uint16_t (*const y_vmask)[2] = lflvl[x].filter_y[1][starty4]; |
376 | 2.97k | const unsigned w = imin(32, f->w4 - (x << 5)); |
377 | 48.1k | for (unsigned mask = 1, i = 0; i < w; mask <<= 1, i++) { |
378 | 45.1k | const int sidx = mask >= 0x10000U; |
379 | 45.1k | const unsigned smask = mask >> (sidx << 4); |
380 | 45.1k | const int idx = 2 * !!(y_vmask[2][sidx] & smask) + |
381 | 45.1k | !!(y_vmask[1][sidx] & smask); |
382 | 45.1k | y_vmask[2][sidx] &= ~smask; |
383 | 45.1k | y_vmask[1][sidx] &= ~smask; |
384 | 45.1k | y_vmask[0][sidx] &= ~smask; |
385 | 45.1k | y_vmask[imin(idx, a->tx_lpf_y[i])][sidx] |= smask; |
386 | 45.1k | } |
387 | | |
388 | 2.97k | if (f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400) { |
389 | 2.28k | const unsigned cw = (w + ss_hor) >> ss_hor; |
390 | 2.28k | uint16_t (*const uv_vmask)[2] = lflvl[x].filter_uv[1][starty4 >> ss_ver]; |
391 | 29.8k | for (unsigned uv_mask = 1, i = 0; i < cw; uv_mask <<= 1, i++) { |
392 | 27.6k | const int sidx = uv_mask >= hmax; |
393 | 27.6k | const unsigned smask = uv_mask >> (sidx << (4 - ss_hor)); |
394 | 27.6k | const int idx = !!(uv_vmask[1][sidx] & smask); |
395 | 27.6k | uv_vmask[1][sidx] &= ~smask; |
396 | 27.6k | uv_vmask[0][sidx] &= ~smask; |
397 | 27.6k | uv_vmask[imin(idx, a->tx_lpf_uv[i])][sidx] |= smask; |
398 | 27.6k | } |
399 | 2.28k | } |
400 | 2.97k | } |
401 | 2.17k | } |
402 | | |
403 | 360k | pixel *ptr; |
404 | 360k | uint8_t (*level_ptr)[4] = f->lf.level + f->b4_stride * sby * sbsz; |
405 | 810k | for (ptr = p[0], have_left = 0, x = 0; x < f->sb128w; |
406 | 449k | x++, have_left = 1, ptr += 128, level_ptr += 32) |
407 | 449k | { |
408 | 449k | filter_plane_cols_y(f, have_left, level_ptr, f->b4_stride, |
409 | 449k | lflvl[x].filter_y[0], ptr, f->cur.stride[0], |
410 | 449k | imin(32, f->w4 - x * 32), starty4, endy4); |
411 | 449k | } |
412 | | |
413 | 360k | if (!f->frame_hdr->loopfilter.level_u && !f->frame_hdr->loopfilter.level_v) |
414 | 94.9k | return; |
415 | | |
416 | 266k | ptrdiff_t uv_off; |
417 | 266k | level_ptr = f->lf.level + f->b4_stride * (sby * sbsz >> ss_ver); |
418 | 593k | for (uv_off = 0, have_left = 0, x = 0; x < f->sb128w; |
419 | 327k | x++, have_left = 1, uv_off += 128 >> ss_hor, level_ptr += 32 >> ss_hor) |
420 | 327k | { |
421 | 327k | filter_plane_cols_uv(f, have_left, level_ptr, f->b4_stride, |
422 | 327k | lflvl[x].filter_uv[0], |
423 | 327k | &p[1][uv_off], &p[2][uv_off], f->cur.stride[1], |
424 | 327k | (imin(32, f->w4 - x * 32) + ss_hor) >> ss_hor, |
425 | 327k | starty4 >> ss_ver, uv_endy4, ss_ver); |
426 | 327k | } |
427 | 266k | } dav1d_loopfilter_sbrow_cols_8bpc Line | Count | Source | 316 | 175k | { | 317 | 175k | int x, have_left; | 318 | | // Don't filter outside the frame | 319 | 175k | const int is_sb64 = !f->seq_hdr->sb128; | 320 | 175k | const int starty4 = (sby & is_sb64) << 4; | 321 | 175k | const int sbsz = 32 >> is_sb64; | 322 | 175k | const int sbl2 = 5 - is_sb64; | 323 | 175k | const int halign = (f->bh + 31) & ~31; | 324 | 175k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 325 | 175k | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; | 326 | 175k | const int vmask = 16 >> ss_ver, hmask = 16 >> ss_hor; | 327 | 175k | const unsigned vmax = 1U << vmask, hmax = 1U << hmask; | 328 | 175k | const unsigned endy4 = starty4 + imin(f->h4 - sby * sbsz, sbsz); | 329 | 175k | const unsigned uv_endy4 = (endy4 + ss_ver) >> ss_ver; | 330 | | | 331 | | // fix lpf strength at tile col boundaries | 332 | 175k | const uint8_t *lpf_y = &f->lf.tx_lpf_right_edge[0][sby << sbl2]; | 333 | 175k | const uint8_t *lpf_uv = &f->lf.tx_lpf_right_edge[1][sby << (sbl2 - ss_ver)]; | 334 | 176k | for (int tile_col = 1;; tile_col++) { | 335 | 176k | x = f->frame_hdr->tiling.col_start_sb[tile_col]; | 336 | 176k | if ((x << sbl2) >= f->bw) break; | 337 | 1.11k | const int bx4 = x & is_sb64 ? 16 : 0, cbx4 = bx4 >> ss_hor; | 338 | 1.11k | x >>= is_sb64; | 339 | | | 340 | 1.11k | uint16_t (*const y_hmask)[2] = lflvl[x].filter_y[0][bx4]; | 341 | 10.9k | for (unsigned y = starty4, mask = 1 << y; y < endy4; y++, mask <<= 1) { | 342 | 9.81k | const int sidx = mask >= 0x10000U; | 343 | 9.81k | const unsigned smask = mask >> (sidx << 4); | 344 | 9.81k | const int idx = 2 * !!(y_hmask[2][sidx] & smask) + | 345 | 9.81k | !!(y_hmask[1][sidx] & smask); | 346 | 9.81k | y_hmask[2][sidx] &= ~smask; | 347 | 9.81k | y_hmask[1][sidx] &= ~smask; | 348 | 9.81k | y_hmask[0][sidx] &= ~smask; | 349 | 9.81k | y_hmask[imin(idx, lpf_y[y - starty4])][sidx] |= smask; | 350 | 9.81k | } | 351 | | | 352 | 1.11k | if (f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400) { | 353 | 855 | uint16_t (*const uv_hmask)[2] = lflvl[x].filter_uv[0][cbx4]; | 354 | 6.58k | for (unsigned y = starty4 >> ss_ver, uv_mask = 1 << y; y < uv_endy4; | 355 | 5.72k | y++, uv_mask <<= 1) | 356 | 5.72k | { | 357 | 5.72k | const int sidx = uv_mask >= vmax; | 358 | 5.72k | const unsigned smask = uv_mask >> (sidx << (4 - ss_ver)); | 359 | 5.72k | const int idx = !!(uv_hmask[1][sidx] & smask); | 360 | 5.72k | uv_hmask[1][sidx] &= ~smask; | 361 | 5.72k | uv_hmask[0][sidx] &= ~smask; | 362 | 5.72k | uv_hmask[imin(idx, lpf_uv[y - (starty4 >> ss_ver)])][sidx] |= smask; | 363 | 5.72k | } | 364 | 855 | } | 365 | 1.11k | lpf_y += halign; | 366 | 1.11k | lpf_uv += halign >> ss_ver; | 367 | 1.11k | } | 368 | | | 369 | | // fix lpf strength at tile row boundaries | 370 | 175k | if (start_of_tile_row) { | 371 | 1.28k | const BlockContext *a; | 372 | 1.28k | for (x = 0, a = &f->a[f->sb128w * (start_of_tile_row - 1)]; | 373 | 2.89k | x < f->sb128w; x++, a++) | 374 | 1.60k | { | 375 | 1.60k | uint16_t (*const y_vmask)[2] = lflvl[x].filter_y[1][starty4]; | 376 | 1.60k | const unsigned w = imin(32, f->w4 - (x << 5)); | 377 | 23.0k | for (unsigned mask = 1, i = 0; i < w; mask <<= 1, i++) { | 378 | 21.4k | const int sidx = mask >= 0x10000U; | 379 | 21.4k | const unsigned smask = mask >> (sidx << 4); | 380 | 21.4k | const int idx = 2 * !!(y_vmask[2][sidx] & smask) + | 381 | 21.4k | !!(y_vmask[1][sidx] & smask); | 382 | 21.4k | y_vmask[2][sidx] &= ~smask; | 383 | 21.4k | y_vmask[1][sidx] &= ~smask; | 384 | 21.4k | y_vmask[0][sidx] &= ~smask; | 385 | 21.4k | y_vmask[imin(idx, a->tx_lpf_y[i])][sidx] |= smask; | 386 | 21.4k | } | 387 | | | 388 | 1.60k | if (f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400) { | 389 | 1.31k | const unsigned cw = (w + ss_hor) >> ss_hor; | 390 | 1.31k | uint16_t (*const uv_vmask)[2] = lflvl[x].filter_uv[1][starty4 >> ss_ver]; | 391 | 16.1k | for (unsigned uv_mask = 1, i = 0; i < cw; uv_mask <<= 1, i++) { | 392 | 14.8k | const int sidx = uv_mask >= hmax; | 393 | 14.8k | const unsigned smask = uv_mask >> (sidx << (4 - ss_hor)); | 394 | 14.8k | const int idx = !!(uv_vmask[1][sidx] & smask); | 395 | 14.8k | uv_vmask[1][sidx] &= ~smask; | 396 | 14.8k | uv_vmask[0][sidx] &= ~smask; | 397 | 14.8k | uv_vmask[imin(idx, a->tx_lpf_uv[i])][sidx] |= smask; | 398 | 14.8k | } | 399 | 1.31k | } | 400 | 1.60k | } | 401 | 1.28k | } | 402 | | | 403 | 175k | pixel *ptr; | 404 | 175k | uint8_t (*level_ptr)[4] = f->lf.level + f->b4_stride * sby * sbsz; | 405 | 392k | for (ptr = p[0], have_left = 0, x = 0; x < f->sb128w; | 406 | 216k | x++, have_left = 1, ptr += 128, level_ptr += 32) | 407 | 216k | { | 408 | 216k | filter_plane_cols_y(f, have_left, level_ptr, f->b4_stride, | 409 | 216k | lflvl[x].filter_y[0], ptr, f->cur.stride[0], | 410 | 216k | imin(32, f->w4 - x * 32), starty4, endy4); | 411 | 216k | } | 412 | | | 413 | 175k | if (!f->frame_hdr->loopfilter.level_u && !f->frame_hdr->loopfilter.level_v) | 414 | 31.7k | return; | 415 | | | 416 | 144k | ptrdiff_t uv_off; | 417 | 144k | level_ptr = f->lf.level + f->b4_stride * (sby * sbsz >> ss_ver); | 418 | 317k | for (uv_off = 0, have_left = 0, x = 0; x < f->sb128w; | 419 | 173k | x++, have_left = 1, uv_off += 128 >> ss_hor, level_ptr += 32 >> ss_hor) | 420 | 173k | { | 421 | 173k | filter_plane_cols_uv(f, have_left, level_ptr, f->b4_stride, | 422 | 173k | lflvl[x].filter_uv[0], | 423 | 173k | &p[1][uv_off], &p[2][uv_off], f->cur.stride[1], | 424 | 173k | (imin(32, f->w4 - x * 32) + ss_hor) >> ss_hor, | 425 | 173k | starty4 >> ss_ver, uv_endy4, ss_ver); | 426 | 173k | } | 427 | 144k | } |
dav1d_loopfilter_sbrow_cols_16bpc Line | Count | Source | 316 | 185k | { | 317 | 185k | int x, have_left; | 318 | | // Don't filter outside the frame | 319 | 185k | const int is_sb64 = !f->seq_hdr->sb128; | 320 | 185k | const int starty4 = (sby & is_sb64) << 4; | 321 | 185k | const int sbsz = 32 >> is_sb64; | 322 | 185k | const int sbl2 = 5 - is_sb64; | 323 | 185k | const int halign = (f->bh + 31) & ~31; | 324 | 185k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 325 | 185k | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; | 326 | 185k | const int vmask = 16 >> ss_ver, hmask = 16 >> ss_hor; | 327 | 185k | const unsigned vmax = 1U << vmask, hmax = 1U << hmask; | 328 | 185k | const unsigned endy4 = starty4 + imin(f->h4 - sby * sbsz, sbsz); | 329 | 185k | const unsigned uv_endy4 = (endy4 + ss_ver) >> ss_ver; | 330 | | | 331 | | // fix lpf strength at tile col boundaries | 332 | 185k | const uint8_t *lpf_y = &f->lf.tx_lpf_right_edge[0][sby << sbl2]; | 333 | 185k | const uint8_t *lpf_uv = &f->lf.tx_lpf_right_edge[1][sby << (sbl2 - ss_ver)]; | 334 | 186k | for (int tile_col = 1;; tile_col++) { | 335 | 186k | x = f->frame_hdr->tiling.col_start_sb[tile_col]; | 336 | 186k | if ((x << sbl2) >= f->bw) break; | 337 | 1.59k | const int bx4 = x & is_sb64 ? 16 : 0, cbx4 = bx4 >> ss_hor; | 338 | 1.59k | x >>= is_sb64; | 339 | | | 340 | 1.59k | uint16_t (*const y_hmask)[2] = lflvl[x].filter_y[0][bx4]; | 341 | 22.1k | for (unsigned y = starty4, mask = 1 << y; y < endy4; y++, mask <<= 1) { | 342 | 20.5k | const int sidx = mask >= 0x10000U; | 343 | 20.5k | const unsigned smask = mask >> (sidx << 4); | 344 | 20.5k | const int idx = 2 * !!(y_hmask[2][sidx] & smask) + | 345 | 20.5k | !!(y_hmask[1][sidx] & smask); | 346 | 20.5k | y_hmask[2][sidx] &= ~smask; | 347 | 20.5k | y_hmask[1][sidx] &= ~smask; | 348 | 20.5k | y_hmask[0][sidx] &= ~smask; | 349 | 20.5k | y_hmask[imin(idx, lpf_y[y - starty4])][sidx] |= smask; | 350 | 20.5k | } | 351 | | | 352 | 1.59k | if (f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400) { | 353 | 1.29k | uint16_t (*const uv_hmask)[2] = lflvl[x].filter_uv[0][cbx4]; | 354 | 11.5k | for (unsigned y = starty4 >> ss_ver, uv_mask = 1 << y; y < uv_endy4; | 355 | 10.2k | y++, uv_mask <<= 1) | 356 | 10.2k | { | 357 | 10.2k | const int sidx = uv_mask >= vmax; | 358 | 10.2k | const unsigned smask = uv_mask >> (sidx << (4 - ss_ver)); | 359 | 10.2k | const int idx = !!(uv_hmask[1][sidx] & smask); | 360 | 10.2k | uv_hmask[1][sidx] &= ~smask; | 361 | 10.2k | uv_hmask[0][sidx] &= ~smask; | 362 | 10.2k | uv_hmask[imin(idx, lpf_uv[y - (starty4 >> ss_ver)])][sidx] |= smask; | 363 | 10.2k | } | 364 | 1.29k | } | 365 | 1.59k | lpf_y += halign; | 366 | 1.59k | lpf_uv += halign >> ss_ver; | 367 | 1.59k | } | 368 | | | 369 | | // fix lpf strength at tile row boundaries | 370 | 185k | if (start_of_tile_row) { | 371 | 888 | const BlockContext *a; | 372 | 888 | for (x = 0, a = &f->a[f->sb128w * (start_of_tile_row - 1)]; | 373 | 2.25k | x < f->sb128w; x++, a++) | 374 | 1.36k | { | 375 | 1.36k | uint16_t (*const y_vmask)[2] = lflvl[x].filter_y[1][starty4]; | 376 | 1.36k | const unsigned w = imin(32, f->w4 - (x << 5)); | 377 | 25.0k | for (unsigned mask = 1, i = 0; i < w; mask <<= 1, i++) { | 378 | 23.7k | const int sidx = mask >= 0x10000U; | 379 | 23.7k | const unsigned smask = mask >> (sidx << 4); | 380 | 23.7k | const int idx = 2 * !!(y_vmask[2][sidx] & smask) + | 381 | 23.7k | !!(y_vmask[1][sidx] & smask); | 382 | 23.7k | y_vmask[2][sidx] &= ~smask; | 383 | 23.7k | y_vmask[1][sidx] &= ~smask; | 384 | 23.7k | y_vmask[0][sidx] &= ~smask; | 385 | 23.7k | y_vmask[imin(idx, a->tx_lpf_y[i])][sidx] |= smask; | 386 | 23.7k | } | 387 | | | 388 | 1.36k | if (f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400) { | 389 | 967 | const unsigned cw = (w + ss_hor) >> ss_hor; | 390 | 967 | uint16_t (*const uv_vmask)[2] = lflvl[x].filter_uv[1][starty4 >> ss_ver]; | 391 | 13.7k | for (unsigned uv_mask = 1, i = 0; i < cw; uv_mask <<= 1, i++) { | 392 | 12.8k | const int sidx = uv_mask >= hmax; | 393 | 12.8k | const unsigned smask = uv_mask >> (sidx << (4 - ss_hor)); | 394 | 12.8k | const int idx = !!(uv_vmask[1][sidx] & smask); | 395 | 12.8k | uv_vmask[1][sidx] &= ~smask; | 396 | 12.8k | uv_vmask[0][sidx] &= ~smask; | 397 | 12.8k | uv_vmask[imin(idx, a->tx_lpf_uv[i])][sidx] |= smask; | 398 | 12.8k | } | 399 | 967 | } | 400 | 1.36k | } | 401 | 888 | } | 402 | | | 403 | 185k | pixel *ptr; | 404 | 185k | uint8_t (*level_ptr)[4] = f->lf.level + f->b4_stride * sby * sbsz; | 405 | 418k | for (ptr = p[0], have_left = 0, x = 0; x < f->sb128w; | 406 | 233k | x++, have_left = 1, ptr += 128, level_ptr += 32) | 407 | 233k | { | 408 | 233k | filter_plane_cols_y(f, have_left, level_ptr, f->b4_stride, | 409 | 233k | lflvl[x].filter_y[0], ptr, f->cur.stride[0], | 410 | 233k | imin(32, f->w4 - x * 32), starty4, endy4); | 411 | 233k | } | 412 | | | 413 | 185k | if (!f->frame_hdr->loopfilter.level_u && !f->frame_hdr->loopfilter.level_v) | 414 | 63.1k | return; | 415 | | | 416 | 121k | ptrdiff_t uv_off; | 417 | 121k | level_ptr = f->lf.level + f->b4_stride * (sby * sbsz >> ss_ver); | 418 | 275k | for (uv_off = 0, have_left = 0, x = 0; x < f->sb128w; | 419 | 154k | x++, have_left = 1, uv_off += 128 >> ss_hor, level_ptr += 32 >> ss_hor) | 420 | 154k | { | 421 | 154k | filter_plane_cols_uv(f, have_left, level_ptr, f->b4_stride, | 422 | 154k | lflvl[x].filter_uv[0], | 423 | 154k | &p[1][uv_off], &p[2][uv_off], f->cur.stride[1], | 424 | 154k | (imin(32, f->w4 - x * 32) + ss_hor) >> ss_hor, | 425 | 154k | starty4 >> ss_ver, uv_endy4, ss_ver); | 426 | 154k | } | 427 | 121k | } |
|
428 | | |
429 | | void bytefn(dav1d_loopfilter_sbrow_rows)(const Dav1dFrameContext *const f, |
430 | | pixel *const p[3], Av1Filter *const lflvl, |
431 | | int sby) |
432 | 360k | { |
433 | 360k | int x; |
434 | | // Don't filter outside the frame |
435 | 360k | const int have_top = sby > 0; |
436 | 360k | const int is_sb64 = !f->seq_hdr->sb128; |
437 | 360k | const int starty4 = (sby & is_sb64) << 4; |
438 | 360k | const int sbsz = 32 >> is_sb64; |
439 | 360k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; |
440 | 360k | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; |
441 | 360k | const unsigned endy4 = starty4 + imin(f->h4 - sby * sbsz, sbsz); |
442 | 360k | const unsigned uv_endy4 = (endy4 + ss_ver) >> ss_ver; |
443 | | |
444 | 360k | pixel *ptr; |
445 | 360k | uint8_t (*level_ptr)[4] = f->lf.level + f->b4_stride * sby * sbsz; |
446 | 809k | for (ptr = p[0], x = 0; x < f->sb128w; x++, ptr += 128, level_ptr += 32) { |
447 | 449k | filter_plane_rows_y(f, have_top, level_ptr, f->b4_stride, |
448 | 449k | lflvl[x].filter_y[1], ptr, f->cur.stride[0], |
449 | 449k | imin(32, f->w4 - x * 32), starty4, endy4); |
450 | 449k | } |
451 | | |
452 | 360k | if (!f->frame_hdr->loopfilter.level_u && !f->frame_hdr->loopfilter.level_v) |
453 | 94.9k | return; |
454 | | |
455 | 265k | ptrdiff_t uv_off; |
456 | 265k | level_ptr = f->lf.level + f->b4_stride * (sby * sbsz >> ss_ver); |
457 | 592k | for (uv_off = 0, x = 0; x < f->sb128w; |
458 | 326k | x++, uv_off += 128 >> ss_hor, level_ptr += 32 >> ss_hor) |
459 | 326k | { |
460 | 326k | filter_plane_rows_uv(f, have_top, level_ptr, f->b4_stride, |
461 | 326k | lflvl[x].filter_uv[1], |
462 | 326k | &p[1][uv_off], &p[2][uv_off], f->cur.stride[1], |
463 | 326k | (imin(32, f->w4 - x * 32) + ss_hor) >> ss_hor, |
464 | 326k | starty4 >> ss_ver, uv_endy4, ss_hor); |
465 | 326k | } |
466 | 265k | } dav1d_loopfilter_sbrow_rows_8bpc Line | Count | Source | 432 | 175k | { | 433 | 175k | int x; | 434 | | // Don't filter outside the frame | 435 | 175k | const int have_top = sby > 0; | 436 | 175k | const int is_sb64 = !f->seq_hdr->sb128; | 437 | 175k | const int starty4 = (sby & is_sb64) << 4; | 438 | 175k | const int sbsz = 32 >> is_sb64; | 439 | 175k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 440 | 175k | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; | 441 | 175k | const unsigned endy4 = starty4 + imin(f->h4 - sby * sbsz, sbsz); | 442 | 175k | const unsigned uv_endy4 = (endy4 + ss_ver) >> ss_ver; | 443 | | | 444 | 175k | pixel *ptr; | 445 | 175k | uint8_t (*level_ptr)[4] = f->lf.level + f->b4_stride * sby * sbsz; | 446 | 391k | for (ptr = p[0], x = 0; x < f->sb128w; x++, ptr += 128, level_ptr += 32) { | 447 | 215k | filter_plane_rows_y(f, have_top, level_ptr, f->b4_stride, | 448 | 215k | lflvl[x].filter_y[1], ptr, f->cur.stride[0], | 449 | 215k | imin(32, f->w4 - x * 32), starty4, endy4); | 450 | 215k | } | 451 | | | 452 | 175k | if (!f->frame_hdr->loopfilter.level_u && !f->frame_hdr->loopfilter.level_v) | 453 | 31.7k | return; | 454 | | | 455 | 144k | ptrdiff_t uv_off; | 456 | 144k | level_ptr = f->lf.level + f->b4_stride * (sby * sbsz >> ss_ver); | 457 | 316k | for (uv_off = 0, x = 0; x < f->sb128w; | 458 | 172k | x++, uv_off += 128 >> ss_hor, level_ptr += 32 >> ss_hor) | 459 | 172k | { | 460 | 172k | filter_plane_rows_uv(f, have_top, level_ptr, f->b4_stride, | 461 | 172k | lflvl[x].filter_uv[1], | 462 | 172k | &p[1][uv_off], &p[2][uv_off], f->cur.stride[1], | 463 | 172k | (imin(32, f->w4 - x * 32) + ss_hor) >> ss_hor, | 464 | 172k | starty4 >> ss_ver, uv_endy4, ss_hor); | 465 | 172k | } | 466 | 144k | } |
dav1d_loopfilter_sbrow_rows_16bpc Line | Count | Source | 432 | 184k | { | 433 | 184k | int x; | 434 | | // Don't filter outside the frame | 435 | 184k | const int have_top = sby > 0; | 436 | 184k | const int is_sb64 = !f->seq_hdr->sb128; | 437 | 184k | const int starty4 = (sby & is_sb64) << 4; | 438 | 184k | const int sbsz = 32 >> is_sb64; | 439 | 184k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 440 | 184k | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; | 441 | 184k | const unsigned endy4 = starty4 + imin(f->h4 - sby * sbsz, sbsz); | 442 | 184k | const unsigned uv_endy4 = (endy4 + ss_ver) >> ss_ver; | 443 | | | 444 | 184k | pixel *ptr; | 445 | 184k | uint8_t (*level_ptr)[4] = f->lf.level + f->b4_stride * sby * sbsz; | 446 | 418k | for (ptr = p[0], x = 0; x < f->sb128w; x++, ptr += 128, level_ptr += 32) { | 447 | 233k | filter_plane_rows_y(f, have_top, level_ptr, f->b4_stride, | 448 | 233k | lflvl[x].filter_y[1], ptr, f->cur.stride[0], | 449 | 233k | imin(32, f->w4 - x * 32), starty4, endy4); | 450 | 233k | } | 451 | | | 452 | 184k | if (!f->frame_hdr->loopfilter.level_u && !f->frame_hdr->loopfilter.level_v) | 453 | 63.1k | return; | 454 | | | 455 | 121k | ptrdiff_t uv_off; | 456 | 121k | level_ptr = f->lf.level + f->b4_stride * (sby * sbsz >> ss_ver); | 457 | 275k | for (uv_off = 0, x = 0; x < f->sb128w; | 458 | 153k | x++, uv_off += 128 >> ss_hor, level_ptr += 32 >> ss_hor) | 459 | 153k | { | 460 | 153k | filter_plane_rows_uv(f, have_top, level_ptr, f->b4_stride, | 461 | 153k | lflvl[x].filter_uv[1], | 462 | 153k | &p[1][uv_off], &p[2][uv_off], f->cur.stride[1], | 463 | 153k | (imin(32, f->w4 - x * 32) + ss_hor) >> ss_hor, | 464 | 153k | starty4 >> ss_ver, uv_endy4, ss_hor); | 465 | 153k | } | 466 | 121k | } |
|