/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 | 733k | { |
48 | 733k | const int cdef_backup = !lr_backup; |
49 | 733k | const int dst_w = f->frame_hdr->super_res.enabled ? |
50 | 458k | (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 | 733k | int stripe_h = ((64 << (cdef_backup & sb128)) - 8 * !row) >> ss_ver; |
54 | 733k | src += (stripe_h - 2) * PXSTRIDE(src_stride); |
55 | | |
56 | 733k | 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 | 733k | if (lr_backup && (f->frame_hdr->width[0] != f->frame_hdr->width[1])) { |
74 | 152k | while (row + stripe_h <= row_h) { |
75 | 79.0k | const int n_lines = 4 - (row + stripe_h + 1 == h); |
76 | 79.0k | f->dsp->mc.resize(dst, dst_stride, src, src_stride, |
77 | 79.0k | dst_w, n_lines, src_w, f->resize_step[ss_hor], |
78 | 79.0k | f->resize_start[ss_hor] HIGHBD_CALL_SUFFIX); |
79 | 79.0k | row += stripe_h; // unmodified stripe_h for the 1st stripe |
80 | 79.0k | stripe_h = 64 >> ss_ver; |
81 | 79.0k | src += stripe_h * PXSTRIDE(src_stride); |
82 | 79.0k | dst += n_lines * PXSTRIDE(dst_stride); |
83 | 79.0k | if (n_lines == 3) { |
84 | 1.59k | pixel_copy(dst, &dst[-PXSTRIDE(dst_stride)], dst_w); |
85 | 1.59k | dst += PXSTRIDE(dst_stride); |
86 | 1.59k | } |
87 | 79.0k | } |
88 | 659k | } else { |
89 | 1.29M | while (row + stripe_h <= row_h) { |
90 | 637k | const int n_lines = 4 - (row + stripe_h + 1 == h); |
91 | 3.18M | for (int i = 0; i < 4; i++) { |
92 | 2.54M | pixel_copy(dst, i == n_lines ? &dst[-PXSTRIDE(dst_stride)] : |
93 | 2.54M | src, src_w); |
94 | 2.54M | dst += PXSTRIDE(dst_stride); |
95 | 2.54M | src += PXSTRIDE(src_stride); |
96 | 2.54M | } |
97 | 637k | row += stripe_h; // unmodified stripe_h for the 1st stripe |
98 | 637k | stripe_h = 64 >> ss_ver; |
99 | 637k | src += (stripe_h - 4) * PXSTRIDE(src_stride); |
100 | 637k | } |
101 | 659k | } |
102 | 733k | } |
103 | | |
104 | | void bytefn(dav1d_copy_lpf)(Dav1dFrameContext *const f, |
105 | | /*const*/ pixel *const src[3], const int sby) |
106 | 324k | { |
107 | 324k | const int have_tt = f->c->n_tc > 1; |
108 | 324k | const int resize = f->frame_hdr->width[0] != f->frame_hdr->width[1]; |
109 | 324k | const int offset = 8 * !!sby; |
110 | 324k | const ptrdiff_t *const src_stride = f->cur.stride; |
111 | 324k | const ptrdiff_t *const lr_stride = f->sr_cur.p.stride; |
112 | 324k | const int tt_off = have_tt * sby * (4 << f->seq_hdr->sb128); |
113 | 324k | pixel *const dst[3] = { |
114 | 324k | f->lf.lr_lpf_line[0] + tt_off * PXSTRIDE(lr_stride[0]), |
115 | 324k | f->lf.lr_lpf_line[1] + tt_off * PXSTRIDE(lr_stride[1]), |
116 | 324k | f->lf.lr_lpf_line[2] + tt_off * PXSTRIDE(lr_stride[1]) |
117 | 324k | }; |
118 | | |
119 | | // TODO Also check block level restore type to reduce copying. |
120 | 324k | const int restore_planes = f->lf.restore_planes; |
121 | 324k | const int cdef_planes = f->lf.cdef_planes; |
122 | | |
123 | 324k | if ((cdef_planes & 1) || (restore_planes & LR_RESTORE_Y)) { |
124 | 283k | const int h = f->cur.p.h; |
125 | 283k | const int w = f->bw << 2; |
126 | 283k | const int row_h = imin((sby + 1) << (6 + f->seq_hdr->sb128), h - 1); |
127 | 283k | const int y_stripe = (sby << (6 + f->seq_hdr->sb128)) - offset; |
128 | 283k | if (restore_planes & LR_RESTORE_Y || !resize) |
129 | 264k | backup_lpf(f, dst[0], lr_stride[0], |
130 | 264k | src[0] - offset * PXSTRIDE(src_stride[0]), src_stride[0], |
131 | 264k | 0, f->seq_hdr->sb128, y_stripe, row_h, w, h, 0, 1); |
132 | 283k | if (have_tt && resize && (cdef_planes & 1)) { |
133 | 35.8k | const ptrdiff_t cdef_off_y = sby * 4 * PXSTRIDE(src_stride[0]); |
134 | 35.8k | backup_lpf(f, f->lf.cdef_lpf_line[0] + cdef_off_y, src_stride[0], |
135 | 35.8k | src[0] - offset * PXSTRIDE(src_stride[0]), src_stride[0], |
136 | 35.8k | 0, f->seq_hdr->sb128, y_stripe, row_h, w, h, 0, 0); |
137 | 35.8k | } |
138 | 283k | } |
139 | 324k | if (((cdef_planes & 2) || (restore_planes & (LR_RESTORE_U | LR_RESTORE_V))) && |
140 | 246k | f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400) |
141 | 246k | { |
142 | 246k | const int ss_ver = f->sr_cur.p.p.layout == DAV1D_PIXEL_LAYOUT_I420; |
143 | 246k | const int ss_hor = f->sr_cur.p.p.layout != DAV1D_PIXEL_LAYOUT_I444; |
144 | 246k | const int h = (f->cur.p.h + ss_ver) >> ss_ver; |
145 | 246k | const int w = f->bw << (2 - ss_hor); |
146 | 246k | const int row_h = imin((sby + 1) << ((6 - ss_ver) + f->seq_hdr->sb128), h - 1); |
147 | 246k | const int offset_uv = offset >> ss_ver; |
148 | 246k | const int y_stripe = (sby << ((6 - ss_ver) + f->seq_hdr->sb128)) - offset_uv; |
149 | 246k | const ptrdiff_t cdef_off_uv = sby * 4 * PXSTRIDE(src_stride[1]); |
150 | 246k | if ((cdef_planes & 2) || (restore_planes & LR_RESTORE_U)) { |
151 | 174k | if (restore_planes & LR_RESTORE_U || !resize) |
152 | 152k | backup_lpf(f, dst[1], lr_stride[1], |
153 | 152k | src[1] - offset_uv * PXSTRIDE(src_stride[1]), |
154 | 152k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, |
155 | 152k | row_h, w, h, ss_hor, 1); |
156 | 174k | if (have_tt && resize && (cdef_planes & 2)) |
157 | 29.1k | backup_lpf(f, f->lf.cdef_lpf_line[1] + cdef_off_uv, src_stride[1], |
158 | 29.1k | src[1] - offset_uv * PXSTRIDE(src_stride[1]), |
159 | 29.1k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, |
160 | 29.1k | row_h, w, h, ss_hor, 0); |
161 | 174k | } |
162 | 246k | if ((cdef_planes & 2) || (restore_planes & LR_RESTORE_V)) { |
163 | 236k | if (restore_planes & LR_RESTORE_V || !resize) |
164 | 221k | backup_lpf(f, dst[2], lr_stride[1], |
165 | 221k | src[2] - offset_uv * PXSTRIDE(src_stride[1]), |
166 | 221k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, |
167 | 221k | row_h, w, h, ss_hor, 1); |
168 | 236k | if (have_tt && resize && (cdef_planes & 2)) |
169 | 29.1k | backup_lpf(f, f->lf.cdef_lpf_line[2] + cdef_off_uv, src_stride[1], |
170 | 29.1k | src[2] - offset_uv * PXSTRIDE(src_stride[1]), |
171 | 29.1k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, |
172 | 29.1k | row_h, w, h, ss_hor, 0); |
173 | 236k | } |
174 | 246k | } |
175 | 324k | } Line | Count | Source | 106 | 162k | { | 107 | 162k | const int have_tt = f->c->n_tc > 1; | 108 | 162k | const int resize = f->frame_hdr->width[0] != f->frame_hdr->width[1]; | 109 | 162k | const int offset = 8 * !!sby; | 110 | 162k | const ptrdiff_t *const src_stride = f->cur.stride; | 111 | 162k | const ptrdiff_t *const lr_stride = f->sr_cur.p.stride; | 112 | 162k | const int tt_off = have_tt * sby * (4 << f->seq_hdr->sb128); | 113 | 162k | pixel *const dst[3] = { | 114 | 162k | f->lf.lr_lpf_line[0] + tt_off * PXSTRIDE(lr_stride[0]), | 115 | 162k | f->lf.lr_lpf_line[1] + tt_off * PXSTRIDE(lr_stride[1]), | 116 | 162k | f->lf.lr_lpf_line[2] + tt_off * PXSTRIDE(lr_stride[1]) | 117 | 162k | }; | 118 | | | 119 | | // TODO Also check block level restore type to reduce copying. | 120 | 162k | const int restore_planes = f->lf.restore_planes; | 121 | 162k | const int cdef_planes = f->lf.cdef_planes; | 122 | | | 123 | 162k | if ((cdef_planes & 1) || (restore_planes & LR_RESTORE_Y)) { | 124 | 134k | const int h = f->cur.p.h; | 125 | 134k | const int w = f->bw << 2; | 126 | 134k | const int row_h = imin((sby + 1) << (6 + f->seq_hdr->sb128), h - 1); | 127 | 134k | const int y_stripe = (sby << (6 + f->seq_hdr->sb128)) - offset; | 128 | 134k | if (restore_planes & LR_RESTORE_Y || !resize) | 129 | 125k | backup_lpf(f, dst[0], lr_stride[0], | 130 | 125k | src[0] - offset * PXSTRIDE(src_stride[0]), src_stride[0], | 131 | 125k | 0, f->seq_hdr->sb128, y_stripe, row_h, w, h, 0, 1); | 132 | 134k | if (have_tt && resize && (cdef_planes & 1)) { | 133 | 15.0k | const ptrdiff_t cdef_off_y = sby * 4 * PXSTRIDE(src_stride[0]); | 134 | 15.0k | backup_lpf(f, f->lf.cdef_lpf_line[0] + cdef_off_y, src_stride[0], | 135 | 15.0k | src[0] - offset * PXSTRIDE(src_stride[0]), src_stride[0], | 136 | 15.0k | 0, f->seq_hdr->sb128, y_stripe, row_h, w, h, 0, 0); | 137 | 15.0k | } | 138 | 134k | } | 139 | 162k | if (((cdef_planes & 2) || (restore_planes & (LR_RESTORE_U | LR_RESTORE_V))) && | 140 | 126k | f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400) | 141 | 126k | { | 142 | 126k | const int ss_ver = f->sr_cur.p.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 143 | 126k | const int ss_hor = f->sr_cur.p.p.layout != DAV1D_PIXEL_LAYOUT_I444; | 144 | 126k | const int h = (f->cur.p.h + ss_ver) >> ss_ver; | 145 | 126k | const int w = f->bw << (2 - ss_hor); | 146 | 126k | const int row_h = imin((sby + 1) << ((6 - ss_ver) + f->seq_hdr->sb128), h - 1); | 147 | 126k | const int offset_uv = offset >> ss_ver; | 148 | 126k | const int y_stripe = (sby << ((6 - ss_ver) + f->seq_hdr->sb128)) - offset_uv; | 149 | 126k | const ptrdiff_t cdef_off_uv = sby * 4 * PXSTRIDE(src_stride[1]); | 150 | 126k | if ((cdef_planes & 2) || (restore_planes & LR_RESTORE_U)) { | 151 | 84.0k | if (restore_planes & LR_RESTORE_U || !resize) | 152 | 74.9k | backup_lpf(f, dst[1], lr_stride[1], | 153 | 74.9k | src[1] - offset_uv * PXSTRIDE(src_stride[1]), | 154 | 74.9k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, | 155 | 74.9k | row_h, w, h, ss_hor, 1); | 156 | 84.0k | if (have_tt && resize && (cdef_planes & 2)) | 157 | 12.4k | backup_lpf(f, f->lf.cdef_lpf_line[1] + cdef_off_uv, src_stride[1], | 158 | 12.4k | src[1] - offset_uv * PXSTRIDE(src_stride[1]), | 159 | 12.4k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, | 160 | 12.4k | row_h, w, h, ss_hor, 0); | 161 | 84.0k | } | 162 | 126k | if ((cdef_planes & 2) || (restore_planes & LR_RESTORE_V)) { | 163 | 120k | if (restore_planes & LR_RESTORE_V || !resize) | 164 | 113k | backup_lpf(f, dst[2], lr_stride[1], | 165 | 113k | src[2] - offset_uv * PXSTRIDE(src_stride[1]), | 166 | 113k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, | 167 | 113k | row_h, w, h, ss_hor, 1); | 168 | 120k | if (have_tt && resize && (cdef_planes & 2)) | 169 | 12.4k | backup_lpf(f, f->lf.cdef_lpf_line[2] + cdef_off_uv, src_stride[1], | 170 | 12.4k | src[2] - offset_uv * PXSTRIDE(src_stride[1]), | 171 | 12.4k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, | 172 | 12.4k | row_h, w, h, ss_hor, 0); | 173 | 120k | } | 174 | 126k | } | 175 | 162k | } |
Line | Count | Source | 106 | 161k | { | 107 | 161k | const int have_tt = f->c->n_tc > 1; | 108 | 161k | const int resize = f->frame_hdr->width[0] != f->frame_hdr->width[1]; | 109 | 161k | const int offset = 8 * !!sby; | 110 | 161k | const ptrdiff_t *const src_stride = f->cur.stride; | 111 | 161k | const ptrdiff_t *const lr_stride = f->sr_cur.p.stride; | 112 | 161k | const int tt_off = have_tt * sby * (4 << f->seq_hdr->sb128); | 113 | 161k | pixel *const dst[3] = { | 114 | 161k | f->lf.lr_lpf_line[0] + tt_off * PXSTRIDE(lr_stride[0]), | 115 | 161k | f->lf.lr_lpf_line[1] + tt_off * PXSTRIDE(lr_stride[1]), | 116 | 161k | f->lf.lr_lpf_line[2] + tt_off * PXSTRIDE(lr_stride[1]) | 117 | 161k | }; | 118 | | | 119 | | // TODO Also check block level restore type to reduce copying. | 120 | 161k | const int restore_planes = f->lf.restore_planes; | 121 | 161k | const int cdef_planes = f->lf.cdef_planes; | 122 | | | 123 | 161k | if ((cdef_planes & 1) || (restore_planes & LR_RESTORE_Y)) { | 124 | 148k | const int h = f->cur.p.h; | 125 | 148k | const int w = f->bw << 2; | 126 | 148k | const int row_h = imin((sby + 1) << (6 + f->seq_hdr->sb128), h - 1); | 127 | 148k | const int y_stripe = (sby << (6 + f->seq_hdr->sb128)) - offset; | 128 | 148k | if (restore_planes & LR_RESTORE_Y || !resize) | 129 | 139k | backup_lpf(f, dst[0], lr_stride[0], | 130 | 139k | src[0] - offset * PXSTRIDE(src_stride[0]), src_stride[0], | 131 | 139k | 0, f->seq_hdr->sb128, y_stripe, row_h, w, h, 0, 1); | 132 | 148k | if (have_tt && resize && (cdef_planes & 1)) { | 133 | 20.7k | const ptrdiff_t cdef_off_y = sby * 4 * PXSTRIDE(src_stride[0]); | 134 | 20.7k | backup_lpf(f, f->lf.cdef_lpf_line[0] + cdef_off_y, src_stride[0], | 135 | 20.7k | src[0] - offset * PXSTRIDE(src_stride[0]), src_stride[0], | 136 | 20.7k | 0, f->seq_hdr->sb128, y_stripe, row_h, w, h, 0, 0); | 137 | 20.7k | } | 138 | 148k | } | 139 | 161k | if (((cdef_planes & 2) || (restore_planes & (LR_RESTORE_U | LR_RESTORE_V))) && | 140 | 119k | f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400) | 141 | 119k | { | 142 | 119k | const int ss_ver = f->sr_cur.p.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 143 | 119k | const int ss_hor = f->sr_cur.p.p.layout != DAV1D_PIXEL_LAYOUT_I444; | 144 | 119k | const int h = (f->cur.p.h + ss_ver) >> ss_ver; | 145 | 119k | const int w = f->bw << (2 - ss_hor); | 146 | 119k | const int row_h = imin((sby + 1) << ((6 - ss_ver) + f->seq_hdr->sb128), h - 1); | 147 | 119k | const int offset_uv = offset >> ss_ver; | 148 | 119k | const int y_stripe = (sby << ((6 - ss_ver) + f->seq_hdr->sb128)) - offset_uv; | 149 | 119k | const ptrdiff_t cdef_off_uv = sby * 4 * PXSTRIDE(src_stride[1]); | 150 | 119k | if ((cdef_planes & 2) || (restore_planes & LR_RESTORE_U)) { | 151 | 90.3k | if (restore_planes & LR_RESTORE_U || !resize) | 152 | 77.9k | backup_lpf(f, dst[1], lr_stride[1], | 153 | 77.9k | src[1] - offset_uv * PXSTRIDE(src_stride[1]), | 154 | 77.9k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, | 155 | 77.9k | row_h, w, h, ss_hor, 1); | 156 | 90.3k | if (have_tt && resize && (cdef_planes & 2)) | 157 | 16.7k | backup_lpf(f, f->lf.cdef_lpf_line[1] + cdef_off_uv, src_stride[1], | 158 | 16.7k | src[1] - offset_uv * PXSTRIDE(src_stride[1]), | 159 | 16.7k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, | 160 | 16.7k | row_h, w, h, ss_hor, 0); | 161 | 90.3k | } | 162 | 119k | if ((cdef_planes & 2) || (restore_planes & LR_RESTORE_V)) { | 163 | 115k | if (restore_planes & LR_RESTORE_V || !resize) | 164 | 108k | backup_lpf(f, dst[2], lr_stride[1], | 165 | 108k | src[2] - offset_uv * PXSTRIDE(src_stride[1]), | 166 | 108k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, | 167 | 108k | row_h, w, h, ss_hor, 1); | 168 | 115k | if (have_tt && resize && (cdef_planes & 2)) | 169 | 16.7k | backup_lpf(f, f->lf.cdef_lpf_line[2] + cdef_off_uv, src_stride[1], | 170 | 16.7k | src[2] - offset_uv * PXSTRIDE(src_stride[1]), | 171 | 16.7k | src_stride[1], ss_ver, f->seq_hdr->sb128, y_stripe, | 172 | 16.7k | row_h, w, h, ss_hor, 0); | 173 | 115k | } | 174 | 119k | } | 175 | 161k | } |
|
176 | | |
177 | | static inline void filter_plane_cols_y(const Dav1dFrameContext *const f, |
178 | | const int have_left, |
179 | | const uint8_t (*lvl)[2], |
180 | | const ptrdiff_t b4_stride, |
181 | | const uint16_t (*const mask)[3][2], |
182 | | pixel *dst, const ptrdiff_t ls, |
183 | | const int w, |
184 | | const int starty4, const int endy4) |
185 | 575k | { |
186 | 575k | const Dav1dDSPContext *const dsp = f->dsp; |
187 | 575k | const loopfilter_sb_fn loop_filter_sb = dsp->lf.loop_filter_sb[0][0]; |
188 | | |
189 | | // filter edges between columns (e.g. block1 | block2) |
190 | 7.92M | for (int x = 0; x < w; x++) { |
191 | 7.35M | if (!have_left && !x) continue; |
192 | 6.92M | uint32_t hmask[4]; |
193 | 6.92M | if (!starty4) { |
194 | 5.80M | hmask[0] = mask[x][0][0]; |
195 | 5.80M | hmask[1] = mask[x][1][0]; |
196 | 5.80M | hmask[2] = mask[x][2][0]; |
197 | 5.80M | if (endy4 > 16) { |
198 | 1.70M | hmask[0] |= (unsigned) mask[x][0][1] << 16; |
199 | 1.70M | hmask[1] |= (unsigned) mask[x][1][1] << 16; |
200 | 1.70M | hmask[2] |= (unsigned) mask[x][2][1] << 16; |
201 | 1.70M | } |
202 | 5.80M | } else { |
203 | 1.11M | hmask[0] = mask[x][0][1]; |
204 | 1.11M | hmask[1] = mask[x][1][1]; |
205 | 1.11M | hmask[2] = mask[x][2][1]; |
206 | 1.11M | } |
207 | 6.92M | hmask[3] = 0; |
208 | 6.92M | loop_filter_sb(&dst[x * 4], ls, hmask, &lvl[x], b4_stride, |
209 | 6.92M | &f->lf.lim_lut, endy4 - starty4 HIGHBD_CALL_SUFFIX); |
210 | 6.92M | } |
211 | 575k | } |
212 | | |
213 | | static inline void filter_plane_rows_y(const Dav1dFrameContext *const f, |
214 | | const int have_top, |
215 | | const uint8_t (*lvl)[2], |
216 | | const ptrdiff_t b4_stride, |
217 | | const uint16_t (*const mask)[3][2], |
218 | | pixel *dst, const ptrdiff_t ls, |
219 | | const int w, |
220 | | const int starty4, const int endy4) |
221 | 573k | { |
222 | 573k | const Dav1dDSPContext *const dsp = f->dsp; |
223 | 573k | const loopfilter_sb_fn loop_filter_sb = dsp->lf.loop_filter_sb[0][1]; |
224 | | |
225 | | // block1 |
226 | | // filter edges between rows (e.g. ------) |
227 | | // block2 |
228 | 9.48M | for (int y = starty4; y < endy4; |
229 | 8.91M | y++, dst += 4 * PXSTRIDE(ls), lvl += b4_stride) |
230 | 8.91M | { |
231 | 8.91M | if (!have_top && !y) continue; |
232 | 8.71M | const uint32_t vmask[4] = { |
233 | 8.71M | mask[y][0][0] | ((unsigned) mask[y][0][1] << 16), |
234 | 8.71M | mask[y][1][0] | ((unsigned) mask[y][1][1] << 16), |
235 | 8.71M | mask[y][2][0] | ((unsigned) mask[y][2][1] << 16), |
236 | 8.71M | 0, |
237 | 8.71M | }; |
238 | 8.71M | loop_filter_sb(dst, ls, vmask, (const uint8_t(*)[2]) &lvl[0][1], |
239 | 8.71M | b4_stride, &f->lf.lim_lut, w HIGHBD_CALL_SUFFIX); |
240 | 8.71M | } |
241 | 573k | } |
242 | | |
243 | | static inline void filter_plane_cols_uv(const Dav1dFrameContext *const f, |
244 | | const int have_left, |
245 | | const uint8_t (*lvl)[2], |
246 | | const ptrdiff_t b4_stride, |
247 | | const uint16_t (*const mask)[2][2], |
248 | | pixel *const u, pixel *const v, |
249 | | const ptrdiff_t ls, const int w, |
250 | | const int starty4, const int endy4, |
251 | | const int ss_ver) |
252 | 438k | { |
253 | 438k | const Dav1dDSPContext *const dsp = f->dsp; |
254 | 438k | const loopfilter_sb_fn loop_filter_sb = dsp->lf.loop_filter_sb[1][0]; |
255 | | |
256 | | // filter edges between columns (e.g. block1 | block2) |
257 | 4.27M | for (int x = 0; x < w; x++) { |
258 | 3.83M | if (!have_left && !x) continue; |
259 | 3.50M | uint32_t hmask[3]; |
260 | 3.50M | if (!starty4) { |
261 | 3.01M | hmask[0] = mask[x][0][0]; |
262 | 3.01M | hmask[1] = mask[x][1][0]; |
263 | 3.01M | if (endy4 > (16 >> ss_ver)) { |
264 | 914k | hmask[0] |= (unsigned) mask[x][0][1] << (16 >> ss_ver); |
265 | 914k | hmask[1] |= (unsigned) mask[x][1][1] << (16 >> ss_ver); |
266 | 914k | } |
267 | 3.01M | } else { |
268 | 492k | hmask[0] = mask[x][0][1]; |
269 | 492k | hmask[1] = mask[x][1][1]; |
270 | 492k | } |
271 | 3.50M | hmask[2] = 0; |
272 | 3.50M | loop_filter_sb(&u[x * 4], ls, hmask, &lvl[x], b4_stride, |
273 | 3.50M | &f->lf.lim_lut, endy4 - starty4 HIGHBD_CALL_SUFFIX); |
274 | 3.50M | loop_filter_sb(&v[x * 4], ls, hmask, (const uint8_t(*)[2]) &lvl[x][1], |
275 | 3.50M | b4_stride, &f->lf.lim_lut, endy4 - starty4 HIGHBD_CALL_SUFFIX); |
276 | 3.50M | } |
277 | 438k | } |
278 | | |
279 | | static inline void filter_plane_rows_uv(const Dav1dFrameContext *const f, |
280 | | const int have_top, |
281 | | const uint8_t (*lvl)[2], |
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 | 437k | { |
289 | 437k | const Dav1dDSPContext *const dsp = f->dsp; |
290 | 437k | const loopfilter_sb_fn loop_filter_sb = dsp->lf.loop_filter_sb[1][1]; |
291 | 437k | ptrdiff_t off_l = 0; |
292 | | |
293 | | // block1 |
294 | | // filter edges between rows (e.g. ------) |
295 | | // block2 |
296 | 4.87M | for (int y = starty4; y < endy4; |
297 | 4.43M | y++, off_l += 4 * PXSTRIDE(ls), lvl += b4_stride) |
298 | 4.43M | { |
299 | 4.43M | if (!have_top && !y) continue; |
300 | 4.28M | const uint32_t vmask[3] = { |
301 | 4.28M | mask[y][0][0] | ((unsigned) mask[y][0][1] << (16 >> ss_hor)), |
302 | 4.28M | mask[y][1][0] | ((unsigned) mask[y][1][1] << (16 >> ss_hor)), |
303 | 4.28M | 0, |
304 | 4.28M | }; |
305 | 4.28M | loop_filter_sb(&u[off_l], ls, vmask, lvl, b4_stride, |
306 | 4.28M | &f->lf.lim_lut, w HIGHBD_CALL_SUFFIX); |
307 | 4.28M | loop_filter_sb(&v[off_l], ls, vmask, (const uint8_t(*)[2]) &lvl[0][1], |
308 | 4.28M | b4_stride, &f->lf.lim_lut, w HIGHBD_CALL_SUFFIX); |
309 | 4.28M | } |
310 | 437k | } |
311 | | |
312 | | void bytefn(dav1d_loopfilter_sbrow_cols)(const Dav1dFrameContext *const f, |
313 | | pixel *const p[3], Av1Filter *const lflvl, |
314 | | int sby, const int start_of_tile_row) |
315 | 430k | { |
316 | 430k | int x, have_left; |
317 | | // Don't filter outside the frame |
318 | 430k | const int is_sb64 = !f->seq_hdr->sb128; |
319 | 430k | const int starty4 = (sby & is_sb64) << 4; |
320 | 430k | const int sbsz = 32 >> is_sb64; |
321 | 430k | const int sbl2 = 5 - is_sb64; |
322 | 430k | const int halign = (f->bh + 31) & ~31; |
323 | 430k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; |
324 | 430k | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; |
325 | 430k | const int vmask = 16 >> ss_ver, hmask = 16 >> ss_hor; |
326 | 430k | const unsigned vmax = 1U << vmask, hmax = 1U << hmask; |
327 | 430k | const unsigned endy4 = starty4 + imin(f->h4 - sby * sbsz, sbsz); |
328 | 430k | const unsigned uv_endy4 = (endy4 + ss_ver) >> ss_ver; |
329 | | |
330 | | // fix lpf strength at tile col boundaries |
331 | 430k | const uint8_t *lpf_y = &f->lf.tx_lpf_right_edge[0][sby << sbl2]; |
332 | 430k | const uint8_t *lpf_uv = &f->lf.tx_lpf_right_edge[1][sby << (sbl2 - ss_ver)]; |
333 | 440k | for (int tile_col = 1;; tile_col++) { |
334 | 440k | x = f->frame_hdr->tiling.col_start_sb[tile_col]; |
335 | 440k | if ((x << sbl2) >= f->bw) break; |
336 | 10.3k | const int bx4 = x & is_sb64 ? 16 : 0, cbx4 = bx4 >> ss_hor; |
337 | 10.3k | x >>= is_sb64; |
338 | | |
339 | 10.3k | uint16_t (*const y_hmask)[2] = lflvl[x].filter_y[0][bx4]; |
340 | 179k | for (unsigned y = starty4, mask = 1 << y; y < endy4; y++, mask <<= 1) { |
341 | 168k | const int sidx = mask >= 0x10000U; |
342 | 168k | const unsigned smask = mask >> (sidx << 4); |
343 | 168k | const int idx = 2 * !!(y_hmask[2][sidx] & smask) + |
344 | 168k | !!(y_hmask[1][sidx] & smask); |
345 | 168k | y_hmask[2][sidx] &= ~smask; |
346 | 168k | y_hmask[1][sidx] &= ~smask; |
347 | 168k | y_hmask[0][sidx] &= ~smask; |
348 | 168k | y_hmask[imin(idx, lpf_y[y - starty4])][sidx] |= smask; |
349 | 168k | } |
350 | | |
351 | 10.3k | if (f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400) { |
352 | 7.75k | uint16_t (*const uv_hmask)[2] = lflvl[x].filter_uv[0][cbx4]; |
353 | 85.2k | for (unsigned y = starty4 >> ss_ver, uv_mask = 1 << y; y < uv_endy4; |
354 | 77.4k | y++, uv_mask <<= 1) |
355 | 77.4k | { |
356 | 77.4k | const int sidx = uv_mask >= vmax; |
357 | 77.4k | const unsigned smask = uv_mask >> (sidx << (4 - ss_ver)); |
358 | 77.4k | const int idx = !!(uv_hmask[1][sidx] & smask); |
359 | 77.4k | uv_hmask[1][sidx] &= ~smask; |
360 | 77.4k | uv_hmask[0][sidx] &= ~smask; |
361 | 77.4k | uv_hmask[imin(idx, lpf_uv[y - (starty4 >> ss_ver)])][sidx] |= smask; |
362 | 77.4k | } |
363 | 7.75k | } |
364 | 10.3k | lpf_y += halign; |
365 | 10.3k | lpf_uv += halign >> ss_ver; |
366 | 10.3k | } |
367 | | |
368 | | // fix lpf strength at tile row boundaries |
369 | 430k | if (start_of_tile_row) { |
370 | 5.21k | const BlockContext *a; |
371 | 5.21k | for (x = 0, a = &f->a[f->sb128w * (start_of_tile_row - 1)]; |
372 | 14.2k | x < f->sb128w; x++, a++) |
373 | 9.03k | { |
374 | 9.03k | uint16_t (*const y_vmask)[2] = lflvl[x].filter_y[1][starty4]; |
375 | 9.03k | const unsigned w = imin(32, f->w4 - (x << 5)); |
376 | 171k | for (unsigned mask = 1, i = 0; i < w; mask <<= 1, i++) { |
377 | 162k | const int sidx = mask >= 0x10000U; |
378 | 162k | const unsigned smask = mask >> (sidx << 4); |
379 | 162k | const int idx = 2 * !!(y_vmask[2][sidx] & smask) + |
380 | 162k | !!(y_vmask[1][sidx] & smask); |
381 | 162k | y_vmask[2][sidx] &= ~smask; |
382 | 162k | y_vmask[1][sidx] &= ~smask; |
383 | 162k | y_vmask[0][sidx] &= ~smask; |
384 | 162k | y_vmask[imin(idx, a->tx_lpf_y[i])][sidx] |= smask; |
385 | 162k | } |
386 | | |
387 | 9.03k | if (f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400) { |
388 | 7.33k | const unsigned cw = (w + ss_hor) >> ss_hor; |
389 | 7.33k | uint16_t (*const uv_vmask)[2] = lflvl[x].filter_uv[1][starty4 >> ss_ver]; |
390 | 91.2k | for (unsigned uv_mask = 1, i = 0; i < cw; uv_mask <<= 1, i++) { |
391 | 83.9k | const int sidx = uv_mask >= hmax; |
392 | 83.9k | const unsigned smask = uv_mask >> (sidx << (4 - ss_hor)); |
393 | 83.9k | const int idx = !!(uv_vmask[1][sidx] & smask); |
394 | 83.9k | uv_vmask[1][sidx] &= ~smask; |
395 | 83.9k | uv_vmask[0][sidx] &= ~smask; |
396 | 83.9k | uv_vmask[imin(idx, a->tx_lpf_uv[i])][sidx] |= smask; |
397 | 83.9k | } |
398 | 7.33k | } |
399 | 9.03k | } |
400 | 5.21k | } |
401 | | |
402 | 430k | pixel *ptr; |
403 | 430k | uint8_t (*level_ptr)[2] = f->lf.level[0] + f->b4_stride * sby * sbsz; |
404 | 1.00M | for (ptr = p[0], have_left = 0, x = 0; x < f->sb128w; |
405 | 575k | x++, have_left = 1, ptr += 128, level_ptr += 32) |
406 | 575k | { |
407 | 575k | filter_plane_cols_y(f, have_left, level_ptr, f->b4_stride, |
408 | 575k | lflvl[x].filter_y[0], ptr, f->cur.stride[0], |
409 | 575k | imin(32, f->w4 - x * 32), starty4, endy4); |
410 | 575k | } |
411 | | |
412 | 430k | if (!f->frame_hdr->loopfilter.level_u && !f->frame_hdr->loopfilter.level_v) |
413 | 103k | return; |
414 | | |
415 | 326k | ptrdiff_t uv_off; |
416 | 326k | level_ptr = f->lf.level[1] + f->b4_stride * (sby * sbsz >> ss_ver); |
417 | 765k | for (uv_off = 0, have_left = 0, x = 0; x < f->sb128w; |
418 | 438k | x++, have_left = 1, uv_off += 128 >> ss_hor, level_ptr += 32 >> ss_hor) |
419 | 438k | { |
420 | 438k | filter_plane_cols_uv(f, have_left, level_ptr, f->b4_stride, |
421 | 438k | lflvl[x].filter_uv[0], |
422 | 438k | &p[1][uv_off], &p[2][uv_off], f->cur.stride[1], |
423 | 438k | (imin(32, f->w4 - x * 32) + ss_hor) >> ss_hor, |
424 | 438k | starty4 >> ss_ver, uv_endy4, ss_ver); |
425 | 438k | } |
426 | 326k | } dav1d_loopfilter_sbrow_cols_8bpc Line | Count | Source | 315 | 215k | { | 316 | 215k | int x, have_left; | 317 | | // Don't filter outside the frame | 318 | 215k | const int is_sb64 = !f->seq_hdr->sb128; | 319 | 215k | const int starty4 = (sby & is_sb64) << 4; | 320 | 215k | const int sbsz = 32 >> is_sb64; | 321 | 215k | const int sbl2 = 5 - is_sb64; | 322 | 215k | const int halign = (f->bh + 31) & ~31; | 323 | 215k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 324 | 215k | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; | 325 | 215k | const int vmask = 16 >> ss_ver, hmask = 16 >> ss_hor; | 326 | 215k | const unsigned vmax = 1U << vmask, hmax = 1U << hmask; | 327 | 215k | const unsigned endy4 = starty4 + imin(f->h4 - sby * sbsz, sbsz); | 328 | 215k | const unsigned uv_endy4 = (endy4 + ss_ver) >> ss_ver; | 329 | | | 330 | | // fix lpf strength at tile col boundaries | 331 | 215k | const uint8_t *lpf_y = &f->lf.tx_lpf_right_edge[0][sby << sbl2]; | 332 | 215k | const uint8_t *lpf_uv = &f->lf.tx_lpf_right_edge[1][sby << (sbl2 - ss_ver)]; | 333 | 221k | for (int tile_col = 1;; tile_col++) { | 334 | 221k | x = f->frame_hdr->tiling.col_start_sb[tile_col]; | 335 | 221k | if ((x << sbl2) >= f->bw) break; | 336 | 6.02k | const int bx4 = x & is_sb64 ? 16 : 0, cbx4 = bx4 >> ss_hor; | 337 | 6.02k | x >>= is_sb64; | 338 | | | 339 | 6.02k | uint16_t (*const y_hmask)[2] = lflvl[x].filter_y[0][bx4]; | 340 | 102k | for (unsigned y = starty4, mask = 1 << y; y < endy4; y++, mask <<= 1) { | 341 | 96.3k | const int sidx = mask >= 0x10000U; | 342 | 96.3k | const unsigned smask = mask >> (sidx << 4); | 343 | 96.3k | const int idx = 2 * !!(y_hmask[2][sidx] & smask) + | 344 | 96.3k | !!(y_hmask[1][sidx] & smask); | 345 | 96.3k | y_hmask[2][sidx] &= ~smask; | 346 | 96.3k | y_hmask[1][sidx] &= ~smask; | 347 | 96.3k | y_hmask[0][sidx] &= ~smask; | 348 | 96.3k | y_hmask[imin(idx, lpf_y[y - starty4])][sidx] |= smask; | 349 | 96.3k | } | 350 | | | 351 | 6.02k | if (f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400) { | 352 | 4.81k | uint16_t (*const uv_hmask)[2] = lflvl[x].filter_uv[0][cbx4]; | 353 | 50.3k | for (unsigned y = starty4 >> ss_ver, uv_mask = 1 << y; y < uv_endy4; | 354 | 45.5k | y++, uv_mask <<= 1) | 355 | 45.5k | { | 356 | 45.5k | const int sidx = uv_mask >= vmax; | 357 | 45.5k | const unsigned smask = uv_mask >> (sidx << (4 - ss_ver)); | 358 | 45.5k | const int idx = !!(uv_hmask[1][sidx] & smask); | 359 | 45.5k | uv_hmask[1][sidx] &= ~smask; | 360 | 45.5k | uv_hmask[0][sidx] &= ~smask; | 361 | 45.5k | uv_hmask[imin(idx, lpf_uv[y - (starty4 >> ss_ver)])][sidx] |= smask; | 362 | 45.5k | } | 363 | 4.81k | } | 364 | 6.02k | lpf_y += halign; | 365 | 6.02k | lpf_uv += halign >> ss_ver; | 366 | 6.02k | } | 367 | | | 368 | | // fix lpf strength at tile row boundaries | 369 | 215k | if (start_of_tile_row) { | 370 | 2.22k | const BlockContext *a; | 371 | 2.22k | for (x = 0, a = &f->a[f->sb128w * (start_of_tile_row - 1)]; | 372 | 6.62k | x < f->sb128w; x++, a++) | 373 | 4.40k | { | 374 | 4.40k | uint16_t (*const y_vmask)[2] = lflvl[x].filter_y[1][starty4]; | 375 | 4.40k | const unsigned w = imin(32, f->w4 - (x << 5)); | 376 | 93.8k | for (unsigned mask = 1, i = 0; i < w; mask <<= 1, i++) { | 377 | 89.4k | const int sidx = mask >= 0x10000U; | 378 | 89.4k | const unsigned smask = mask >> (sidx << 4); | 379 | 89.4k | const int idx = 2 * !!(y_vmask[2][sidx] & smask) + | 380 | 89.4k | !!(y_vmask[1][sidx] & smask); | 381 | 89.4k | y_vmask[2][sidx] &= ~smask; | 382 | 89.4k | y_vmask[1][sidx] &= ~smask; | 383 | 89.4k | y_vmask[0][sidx] &= ~smask; | 384 | 89.4k | y_vmask[imin(idx, a->tx_lpf_y[i])][sidx] |= smask; | 385 | 89.4k | } | 386 | | | 387 | 4.40k | if (f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400) { | 388 | 3.87k | const unsigned cw = (w + ss_hor) >> ss_hor; | 389 | 3.87k | uint16_t (*const uv_vmask)[2] = lflvl[x].filter_uv[1][starty4 >> ss_ver]; | 390 | 52.1k | for (unsigned uv_mask = 1, i = 0; i < cw; uv_mask <<= 1, i++) { | 391 | 48.2k | const int sidx = uv_mask >= hmax; | 392 | 48.2k | const unsigned smask = uv_mask >> (sidx << (4 - ss_hor)); | 393 | 48.2k | const int idx = !!(uv_vmask[1][sidx] & smask); | 394 | 48.2k | uv_vmask[1][sidx] &= ~smask; | 395 | 48.2k | uv_vmask[0][sidx] &= ~smask; | 396 | 48.2k | uv_vmask[imin(idx, a->tx_lpf_uv[i])][sidx] |= smask; | 397 | 48.2k | } | 398 | 3.87k | } | 399 | 4.40k | } | 400 | 2.22k | } | 401 | | | 402 | 215k | pixel *ptr; | 403 | 215k | uint8_t (*level_ptr)[2] = f->lf.level[0] + f->b4_stride * sby * sbsz; | 404 | 503k | for (ptr = p[0], have_left = 0, x = 0; x < f->sb128w; | 405 | 288k | x++, have_left = 1, ptr += 128, level_ptr += 32) | 406 | 288k | { | 407 | 288k | filter_plane_cols_y(f, have_left, level_ptr, f->b4_stride, | 408 | 288k | lflvl[x].filter_y[0], ptr, f->cur.stride[0], | 409 | 288k | imin(32, f->w4 - x * 32), starty4, endy4); | 410 | 288k | } | 411 | | | 412 | 215k | if (!f->frame_hdr->loopfilter.level_u && !f->frame_hdr->loopfilter.level_v) | 413 | 55.4k | return; | 414 | | | 415 | 160k | ptrdiff_t uv_off; | 416 | 160k | level_ptr = f->lf.level[1] + f->b4_stride * (sby * sbsz >> ss_ver); | 417 | 373k | for (uv_off = 0, have_left = 0, x = 0; x < f->sb128w; | 418 | 213k | x++, have_left = 1, uv_off += 128 >> ss_hor, level_ptr += 32 >> ss_hor) | 419 | 213k | { | 420 | 213k | filter_plane_cols_uv(f, have_left, level_ptr, f->b4_stride, | 421 | 213k | lflvl[x].filter_uv[0], | 422 | 213k | &p[1][uv_off], &p[2][uv_off], f->cur.stride[1], | 423 | 213k | (imin(32, f->w4 - x * 32) + ss_hor) >> ss_hor, | 424 | 213k | starty4 >> ss_ver, uv_endy4, ss_ver); | 425 | 213k | } | 426 | 160k | } |
dav1d_loopfilter_sbrow_cols_16bpc Line | Count | Source | 315 | 214k | { | 316 | 214k | int x, have_left; | 317 | | // Don't filter outside the frame | 318 | 214k | const int is_sb64 = !f->seq_hdr->sb128; | 319 | 214k | const int starty4 = (sby & is_sb64) << 4; | 320 | 214k | const int sbsz = 32 >> is_sb64; | 321 | 214k | const int sbl2 = 5 - is_sb64; | 322 | 214k | const int halign = (f->bh + 31) & ~31; | 323 | 214k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 324 | 214k | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; | 325 | 214k | const int vmask = 16 >> ss_ver, hmask = 16 >> ss_hor; | 326 | 214k | const unsigned vmax = 1U << vmask, hmax = 1U << hmask; | 327 | 214k | const unsigned endy4 = starty4 + imin(f->h4 - sby * sbsz, sbsz); | 328 | 214k | const unsigned uv_endy4 = (endy4 + ss_ver) >> ss_ver; | 329 | | | 330 | | // fix lpf strength at tile col boundaries | 331 | 214k | const uint8_t *lpf_y = &f->lf.tx_lpf_right_edge[0][sby << sbl2]; | 332 | 214k | const uint8_t *lpf_uv = &f->lf.tx_lpf_right_edge[1][sby << (sbl2 - ss_ver)]; | 333 | 218k | for (int tile_col = 1;; tile_col++) { | 334 | 218k | x = f->frame_hdr->tiling.col_start_sb[tile_col]; | 335 | 218k | if ((x << sbl2) >= f->bw) break; | 336 | 4.36k | const int bx4 = x & is_sb64 ? 16 : 0, cbx4 = bx4 >> ss_hor; | 337 | 4.36k | x >>= is_sb64; | 338 | | | 339 | 4.36k | uint16_t (*const y_hmask)[2] = lflvl[x].filter_y[0][bx4]; | 340 | 77.0k | for (unsigned y = starty4, mask = 1 << y; y < endy4; y++, mask <<= 1) { | 341 | 72.6k | const int sidx = mask >= 0x10000U; | 342 | 72.6k | const unsigned smask = mask >> (sidx << 4); | 343 | 72.6k | const int idx = 2 * !!(y_hmask[2][sidx] & smask) + | 344 | 72.6k | !!(y_hmask[1][sidx] & smask); | 345 | 72.6k | y_hmask[2][sidx] &= ~smask; | 346 | 72.6k | y_hmask[1][sidx] &= ~smask; | 347 | 72.6k | y_hmask[0][sidx] &= ~smask; | 348 | 72.6k | y_hmask[imin(idx, lpf_y[y - starty4])][sidx] |= smask; | 349 | 72.6k | } | 350 | | | 351 | 4.36k | if (f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400) { | 352 | 2.93k | uint16_t (*const uv_hmask)[2] = lflvl[x].filter_uv[0][cbx4]; | 353 | 34.8k | for (unsigned y = starty4 >> ss_ver, uv_mask = 1 << y; y < uv_endy4; | 354 | 31.9k | y++, uv_mask <<= 1) | 355 | 31.9k | { | 356 | 31.9k | const int sidx = uv_mask >= vmax; | 357 | 31.9k | const unsigned smask = uv_mask >> (sidx << (4 - ss_ver)); | 358 | 31.9k | const int idx = !!(uv_hmask[1][sidx] & smask); | 359 | 31.9k | uv_hmask[1][sidx] &= ~smask; | 360 | 31.9k | uv_hmask[0][sidx] &= ~smask; | 361 | 31.9k | uv_hmask[imin(idx, lpf_uv[y - (starty4 >> ss_ver)])][sidx] |= smask; | 362 | 31.9k | } | 363 | 2.93k | } | 364 | 4.36k | lpf_y += halign; | 365 | 4.36k | lpf_uv += halign >> ss_ver; | 366 | 4.36k | } | 367 | | | 368 | | // fix lpf strength at tile row boundaries | 369 | 214k | if (start_of_tile_row) { | 370 | 2.99k | const BlockContext *a; | 371 | 2.99k | for (x = 0, a = &f->a[f->sb128w * (start_of_tile_row - 1)]; | 372 | 7.62k | x < f->sb128w; x++, a++) | 373 | 4.63k | { | 374 | 4.63k | uint16_t (*const y_vmask)[2] = lflvl[x].filter_y[1][starty4]; | 375 | 4.63k | const unsigned w = imin(32, f->w4 - (x << 5)); | 376 | 77.7k | for (unsigned mask = 1, i = 0; i < w; mask <<= 1, i++) { | 377 | 73.1k | const int sidx = mask >= 0x10000U; | 378 | 73.1k | const unsigned smask = mask >> (sidx << 4); | 379 | 73.1k | const int idx = 2 * !!(y_vmask[2][sidx] & smask) + | 380 | 73.1k | !!(y_vmask[1][sidx] & smask); | 381 | 73.1k | y_vmask[2][sidx] &= ~smask; | 382 | 73.1k | y_vmask[1][sidx] &= ~smask; | 383 | 73.1k | y_vmask[0][sidx] &= ~smask; | 384 | 73.1k | y_vmask[imin(idx, a->tx_lpf_y[i])][sidx] |= smask; | 385 | 73.1k | } | 386 | | | 387 | 4.63k | if (f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400) { | 388 | 3.45k | const unsigned cw = (w + ss_hor) >> ss_hor; | 389 | 3.45k | uint16_t (*const uv_vmask)[2] = lflvl[x].filter_uv[1][starty4 >> ss_ver]; | 390 | 39.1k | for (unsigned uv_mask = 1, i = 0; i < cw; uv_mask <<= 1, i++) { | 391 | 35.6k | const int sidx = uv_mask >= hmax; | 392 | 35.6k | const unsigned smask = uv_mask >> (sidx << (4 - ss_hor)); | 393 | 35.6k | const int idx = !!(uv_vmask[1][sidx] & smask); | 394 | 35.6k | uv_vmask[1][sidx] &= ~smask; | 395 | 35.6k | uv_vmask[0][sidx] &= ~smask; | 396 | 35.6k | uv_vmask[imin(idx, a->tx_lpf_uv[i])][sidx] |= smask; | 397 | 35.6k | } | 398 | 3.45k | } | 399 | 4.63k | } | 400 | 2.99k | } | 401 | | | 402 | 214k | pixel *ptr; | 403 | 214k | uint8_t (*level_ptr)[2] = f->lf.level[0] + f->b4_stride * sby * sbsz; | 404 | 501k | for (ptr = p[0], have_left = 0, x = 0; x < f->sb128w; | 405 | 287k | x++, have_left = 1, ptr += 128, level_ptr += 32) | 406 | 287k | { | 407 | 287k | filter_plane_cols_y(f, have_left, level_ptr, f->b4_stride, | 408 | 287k | lflvl[x].filter_y[0], ptr, f->cur.stride[0], | 409 | 287k | imin(32, f->w4 - x * 32), starty4, endy4); | 410 | 287k | } | 411 | | | 412 | 214k | if (!f->frame_hdr->loopfilter.level_u && !f->frame_hdr->loopfilter.level_v) | 413 | 47.5k | return; | 414 | | | 415 | 166k | ptrdiff_t uv_off; | 416 | 166k | level_ptr = f->lf.level[1] + f->b4_stride * (sby * sbsz >> ss_ver); | 417 | 392k | for (uv_off = 0, have_left = 0, x = 0; x < f->sb128w; | 418 | 225k | x++, have_left = 1, uv_off += 128 >> ss_hor, level_ptr += 32 >> ss_hor) | 419 | 225k | { | 420 | 225k | filter_plane_cols_uv(f, have_left, level_ptr, f->b4_stride, | 421 | 225k | lflvl[x].filter_uv[0], | 422 | 225k | &p[1][uv_off], &p[2][uv_off], f->cur.stride[1], | 423 | 225k | (imin(32, f->w4 - x * 32) + ss_hor) >> ss_hor, | 424 | 225k | starty4 >> ss_ver, uv_endy4, ss_ver); | 425 | 225k | } | 426 | 166k | } |
|
427 | | |
428 | | void bytefn(dav1d_loopfilter_sbrow_rows)(const Dav1dFrameContext *const f, |
429 | | pixel *const p[3], Av1Filter *const lflvl, |
430 | | int sby) |
431 | 428k | { |
432 | 428k | int x; |
433 | | // Don't filter outside the frame |
434 | 428k | const int have_top = sby > 0; |
435 | 428k | const int is_sb64 = !f->seq_hdr->sb128; |
436 | 428k | const int starty4 = (sby & is_sb64) << 4; |
437 | 428k | const int sbsz = 32 >> is_sb64; |
438 | 428k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; |
439 | 428k | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; |
440 | 428k | const unsigned endy4 = starty4 + imin(f->h4 - sby * sbsz, sbsz); |
441 | 428k | const unsigned uv_endy4 = (endy4 + ss_ver) >> ss_ver; |
442 | | |
443 | 428k | pixel *ptr; |
444 | 428k | uint8_t (*level_ptr)[2] = f->lf.level[0] + f->b4_stride * sby * sbsz; |
445 | 1.00M | for (ptr = p[0], x = 0; x < f->sb128w; x++, ptr += 128, level_ptr += 32) { |
446 | 573k | filter_plane_rows_y(f, have_top, level_ptr, f->b4_stride, |
447 | 573k | lflvl[x].filter_y[1], ptr, f->cur.stride[0], |
448 | 573k | imin(32, f->w4 - x * 32), starty4, endy4); |
449 | 573k | } |
450 | | |
451 | 428k | if (!f->frame_hdr->loopfilter.level_u && !f->frame_hdr->loopfilter.level_v) |
452 | 102k | return; |
453 | | |
454 | 326k | ptrdiff_t uv_off; |
455 | 326k | level_ptr = f->lf.level[1] + f->b4_stride * (sby * sbsz >> ss_ver); |
456 | 763k | for (uv_off = 0, x = 0; x < f->sb128w; |
457 | 437k | x++, uv_off += 128 >> ss_hor, level_ptr += 32 >> ss_hor) |
458 | 437k | { |
459 | 437k | filter_plane_rows_uv(f, have_top, level_ptr, f->b4_stride, |
460 | 437k | lflvl[x].filter_uv[1], |
461 | 437k | &p[1][uv_off], &p[2][uv_off], f->cur.stride[1], |
462 | 437k | (imin(32, f->w4 - x * 32) + ss_hor) >> ss_hor, |
463 | 437k | starty4 >> ss_ver, uv_endy4, ss_hor); |
464 | 437k | } |
465 | 326k | } dav1d_loopfilter_sbrow_rows_8bpc Line | Count | Source | 431 | 214k | { | 432 | 214k | int x; | 433 | | // Don't filter outside the frame | 434 | 214k | const int have_top = sby > 0; | 435 | 214k | const int is_sb64 = !f->seq_hdr->sb128; | 436 | 214k | const int starty4 = (sby & is_sb64) << 4; | 437 | 214k | const int sbsz = 32 >> is_sb64; | 438 | 214k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 439 | 214k | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; | 440 | 214k | const unsigned endy4 = starty4 + imin(f->h4 - sby * sbsz, sbsz); | 441 | 214k | const unsigned uv_endy4 = (endy4 + ss_ver) >> ss_ver; | 442 | | | 443 | 214k | pixel *ptr; | 444 | 214k | uint8_t (*level_ptr)[2] = f->lf.level[0] + f->b4_stride * sby * sbsz; | 445 | 502k | for (ptr = p[0], x = 0; x < f->sb128w; x++, ptr += 128, level_ptr += 32) { | 446 | 287k | filter_plane_rows_y(f, have_top, level_ptr, f->b4_stride, | 447 | 287k | lflvl[x].filter_y[1], ptr, f->cur.stride[0], | 448 | 287k | imin(32, f->w4 - x * 32), starty4, endy4); | 449 | 287k | } | 450 | | | 451 | 214k | if (!f->frame_hdr->loopfilter.level_u && !f->frame_hdr->loopfilter.level_v) | 452 | 55.0k | return; | 453 | | | 454 | 159k | ptrdiff_t uv_off; | 455 | 159k | level_ptr = f->lf.level[1] + f->b4_stride * (sby * sbsz >> ss_ver); | 456 | 372k | for (uv_off = 0, x = 0; x < f->sb128w; | 457 | 212k | x++, uv_off += 128 >> ss_hor, level_ptr += 32 >> ss_hor) | 458 | 212k | { | 459 | 212k | filter_plane_rows_uv(f, have_top, level_ptr, f->b4_stride, | 460 | 212k | lflvl[x].filter_uv[1], | 461 | 212k | &p[1][uv_off], &p[2][uv_off], f->cur.stride[1], | 462 | 212k | (imin(32, f->w4 - x * 32) + ss_hor) >> ss_hor, | 463 | 212k | starty4 >> ss_ver, uv_endy4, ss_hor); | 464 | 212k | } | 465 | 159k | } |
dav1d_loopfilter_sbrow_rows_16bpc Line | Count | Source | 431 | 213k | { | 432 | 213k | int x; | 433 | | // Don't filter outside the frame | 434 | 213k | const int have_top = sby > 0; | 435 | 213k | const int is_sb64 = !f->seq_hdr->sb128; | 436 | 213k | const int starty4 = (sby & is_sb64) << 4; | 437 | 213k | const int sbsz = 32 >> is_sb64; | 438 | 213k | const int ss_ver = f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420; | 439 | 213k | const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444; | 440 | 213k | const unsigned endy4 = starty4 + imin(f->h4 - sby * sbsz, sbsz); | 441 | 213k | const unsigned uv_endy4 = (endy4 + ss_ver) >> ss_ver; | 442 | | | 443 | 213k | pixel *ptr; | 444 | 213k | uint8_t (*level_ptr)[2] = f->lf.level[0] + f->b4_stride * sby * sbsz; | 445 | 500k | for (ptr = p[0], x = 0; x < f->sb128w; x++, ptr += 128, level_ptr += 32) { | 446 | 286k | filter_plane_rows_y(f, have_top, level_ptr, f->b4_stride, | 447 | 286k | lflvl[x].filter_y[1], ptr, f->cur.stride[0], | 448 | 286k | imin(32, f->w4 - x * 32), starty4, endy4); | 449 | 286k | } | 450 | | | 451 | 213k | if (!f->frame_hdr->loopfilter.level_u && !f->frame_hdr->loopfilter.level_v) | 452 | 47.5k | return; | 453 | | | 454 | 166k | ptrdiff_t uv_off; | 455 | 166k | level_ptr = f->lf.level[1] + f->b4_stride * (sby * sbsz >> ss_ver); | 456 | 391k | for (uv_off = 0, x = 0; x < f->sb128w; | 457 | 225k | x++, uv_off += 128 >> ss_hor, level_ptr += 32 >> ss_hor) | 458 | 225k | { | 459 | 225k | filter_plane_rows_uv(f, have_top, level_ptr, f->b4_stride, | 460 | 225k | lflvl[x].filter_uv[1], | 461 | 225k | &p[1][uv_off], &p[2][uv_off], f->cur.stride[1], | 462 | 225k | (imin(32, f->w4 - x * 32) + ss_hor) >> ss_hor, | 463 | 225k | starty4 >> ss_ver, uv_endy4, ss_hor); | 464 | 225k | } | 465 | 166k | } |
|