Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Copyright (c) 2014 Clément Bœsch | ||
3 | * | ||
4 | * This file is part of FFmpeg. | ||
5 | * | ||
6 | * Permission to use, copy, modify, and/or distribute this software for any | ||
7 | * purpose with or without fee is hereby granted, provided that the above | ||
8 | * copyright notice and this permission notice appear in all copies. | ||
9 | * | ||
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
17 | */ | ||
18 | |||
19 | /** | ||
20 | * @file | ||
21 | * hqx magnification filters (hq2x, hq3x, hq4x) | ||
22 | * | ||
23 | * Originally designed by Maxim Stephin. | ||
24 | * | ||
25 | * @see http://en.wikipedia.org/wiki/Hqx | ||
26 | * @see http://web.archive.org/web/20131114143602/http://www.hiend3d.com/hq3x.html | ||
27 | * @see http://blog.pkh.me/p/19-butchering-hqx-scaling-filters.html | ||
28 | */ | ||
29 | |||
30 | #include "libavutil/opt.h" | ||
31 | #include "libavutil/avassert.h" | ||
32 | #include "libavutil/pixdesc.h" | ||
33 | #include "filters.h" | ||
34 | #include "video.h" | ||
35 | |||
36 | typedef int (*hqxfunc_t)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs); | ||
37 | |||
38 | typedef struct HQXContext { | ||
39 | const AVClass *class; | ||
40 | int n; | ||
41 | hqxfunc_t func; | ||
42 | uint32_t rgbtoyuv[1<<24]; | ||
43 | } HQXContext; | ||
44 | |||
45 | typedef struct ThreadData { | ||
46 | AVFrame *in, *out; | ||
47 | const uint32_t *rgbtoyuv; | ||
48 | } ThreadData; | ||
49 | |||
50 | #define OFFSET(x) offsetof(HQXContext, x) | ||
51 | #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM | ||
52 | static const AVOption hqx_options[] = { | ||
53 | { "n", "set scale factor", OFFSET(n), AV_OPT_TYPE_INT, {.i64 = 3}, 2, 4, .flags = FLAGS }, | ||
54 | { NULL } | ||
55 | }; | ||
56 | |||
57 | AVFILTER_DEFINE_CLASS(hqx); | ||
58 | |||
59 | 1564116 | static av_always_inline uint32_t rgb2yuv(const uint32_t *r2y, uint32_t c) | |
60 | { | ||
61 | 1564116 | return r2y[c & 0xffffff]; | |
62 | } | ||
63 | |||
64 | 1053411 | static av_always_inline int yuv_diff(uint32_t yuv1, uint32_t yuv2) | |
65 | { | ||
66 | #define YMASK 0xff0000 | ||
67 | #define UMASK 0x00ff00 | ||
68 | #define VMASK 0x0000ff | ||
69 | #define ABSDIFF(a,b) (abs((int)(a)-(int)(b))) | ||
70 | |||
71 | 1488443 | return ABSDIFF(yuv1 & YMASK, yuv2 & YMASK) > (48 << 16) || | |
72 |
4/4✓ Branch 0 taken 435032 times.
✓ Branch 1 taken 618379 times.
✓ Branch 2 taken 241679 times.
✓ Branch 3 taken 193353 times.
|
1295090 | ABSDIFF(yuv1 & UMASK, yuv2 & UMASK) > ( 7 << 8) || |
73 |
2/2✓ Branch 0 taken 30757 times.
✓ Branch 1 taken 210922 times.
|
241679 | ABSDIFF(yuv1 & VMASK, yuv2 & VMASK) > ( 6 << 0); |
74 | } | ||
75 | |||
76 | /* (c1*w1 + c2*w2) >> s */ | ||
77 | 1090820 | static av_always_inline uint32_t interp_2px(uint32_t c1, int w1, uint32_t c2, int w2, int s) | |
78 | { | ||
79 | 2181640 | return (((((c1 & 0xff00ff00) >> 8) * w1 + ((c2 & 0xff00ff00) >> 8) * w2) << (8 - s)) & 0xff00ff00) | | |
80 | 1090820 | (((((c1 & 0x00ff00ff) ) * w1 + ((c2 & 0x00ff00ff) ) * w2) >> s ) & 0x00ff00ff); | |
81 | } | ||
82 | |||
83 | /* (c1*w1 + c2*w2 + c3*w3) >> s */ | ||
84 | 1473284 | static av_always_inline uint32_t interp_3px(uint32_t c1, int w1, uint32_t c2, int w2, uint32_t c3, int w3, int s) | |
85 | { | ||
86 | 2946568 | return (((((c1 & 0xff00ff00) >> 8) * w1 + ((c2 & 0xff00ff00) >> 8) * w2 + ((c3 & 0xff00ff00) >> 8) * w3) << (8 - s)) & 0xff00ff00) | | |
87 | 1473284 | (((((c1 & 0x00ff00ff) ) * w1 + ((c2 & 0x00ff00ff) ) * w2 + ((c3 & 0x00ff00ff) ) * w3) >> s ) & 0x00ff00ff); | |
88 | } | ||
89 | |||
90 | /* m is the mask of diff with the center pixel that matters in the pattern, and | ||
91 | * r is the expected result (bit set to 1 if there is difference with the | ||
92 | * center, 0 otherwise) */ | ||
93 | #define P(m, r) ((k_shuffled & (m)) == (r)) | ||
94 | |||
95 | /* adjust 012345678 to 01235678: the mask doesn't contain the (null) diff | ||
96 | * between the center/current pixel and itself */ | ||
97 | #define DROP4(z) ((z) > 4 ? (z)-1 : (z)) | ||
98 | |||
99 | /* shuffle the input mask: move bit n (4-adjusted) to position stored in p<n> */ | ||
100 | #define SHF(x, rot, n) (((x) >> ((rot) ? 7-DROP4(n) : DROP4(n)) & 1) << DROP4(p##n)) | ||
101 | |||
102 | /* used to check if there is YUV difference between 2 pixels */ | ||
103 | #define WDIFF(c1, c2) yuv_diff(rgb2yuv(r2y, c1), rgb2yuv(r2y, c2)) | ||
104 | |||
105 | /* bootstrap template for every interpolation code. It defines the shuffled | ||
106 | * masks and surrounding pixels. The rot flag is used to indicate if it's a | ||
107 | * rotation; its basic effect is to shuffle k using p8..p0 instead of p0..p8 */ | ||
108 | #define INTERP_BOOTSTRAP(rot) \ | ||
109 | const int k_shuffled = SHF(k,rot,0) | SHF(k,rot,1) | SHF(k,rot,2) \ | ||
110 | | SHF(k,rot,3) | 0 | SHF(k,rot,5) \ | ||
111 | | SHF(k,rot,6) | SHF(k,rot,7) | SHF(k,rot,8); \ | ||
112 | \ | ||
113 | const uint32_t w0 = w[p0], w1 = w[p1], \ | ||
114 | w3 = w[p3], w4 = w[p4], w5 = w[p5], \ | ||
115 | w7 = w[p7] | ||
116 | |||
117 | /* Assuming p0..p8 is mapped to pixels 0..8, this function interpolates the | ||
118 | * top-left pixel in the total of the 2x2 pixels to interpolates. The function | ||
119 | * is also used for the 3 other pixels */ | ||
120 | 395752 | static av_always_inline uint32_t hq2x_interp_1x1(const uint32_t *r2y, int k, | |
121 | const uint32_t *w, | ||
122 | int p0, int p1, int p2, | ||
123 | int p3, int p4, int p5, | ||
124 | int p6, int p7, int p8) | ||
125 | { | ||
126 |
16/16✓ Branch 0 taken 197876 times.
✓ Branch 1 taken 197876 times.
✓ Branch 2 taken 197876 times.
✓ Branch 3 taken 197876 times.
✓ Branch 4 taken 197876 times.
✓ Branch 5 taken 197876 times.
✓ Branch 6 taken 197876 times.
✓ Branch 7 taken 197876 times.
✓ Branch 8 taken 197876 times.
✓ Branch 9 taken 197876 times.
✓ Branch 10 taken 197876 times.
✓ Branch 11 taken 197876 times.
✓ Branch 12 taken 197876 times.
✓ Branch 13 taken 197876 times.
✓ Branch 14 taken 197876 times.
✓ Branch 15 taken 197876 times.
|
395752 | INTERP_BOOTSTRAP(0); |
127 | |||
128 |
6/6✓ Branch 0 taken 393760 times.
✓ Branch 1 taken 1992 times.
✓ Branch 2 taken 1580 times.
✓ Branch 3 taken 392180 times.
✓ Branch 7 taken 925 times.
✓ Branch 8 taken 2647 times.
|
395752 | if ((P(0xbf,0x37) || P(0xdb,0x13)) && WDIFF(w1, w5)) |
129 | 925 | return interp_2px(w4, 3, w3, 1, 2); | |
130 |
6/6✓ Branch 0 taken 392527 times.
✓ Branch 1 taken 2300 times.
✓ Branch 2 taken 1743 times.
✓ Branch 3 taken 390784 times.
✓ Branch 7 taken 1196 times.
✓ Branch 8 taken 2847 times.
|
394827 | if ((P(0xdb,0x49) || P(0xef,0x6d)) && WDIFF(w7, w3)) |
131 | 1196 | return interp_2px(w4, 3, w1, 1, 2); | |
132 |
8/8✓ Branch 0 taken 356872 times.
✓ Branch 1 taken 36759 times.
✓ Branch 2 taken 356750 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 140 times.
✓ Branch 5 taken 356610 times.
✓ Branch 9 taken 15433 times.
✓ Branch 10 taken 21588 times.
|
393631 | if ((P(0x0b,0x0b) || P(0xfe,0x4a) || P(0xfe,0x1a)) && WDIFF(w3, w1)) |
133 | 15433 | return w4; | |
134 |
8/8✓ Branch 0 taken 377567 times.
✓ Branch 1 taken 631 times.
✓ Branch 2 taken 376292 times.
✓ Branch 3 taken 1275 times.
✓ Branch 4 taken 376069 times.
✓ Branch 5 taken 223 times.
✓ Branch 6 taken 375685 times.
✓ Branch 7 taken 384 times.
|
378198 | if ((P(0x6f,0x2a) || P(0x5b,0x0a) || P(0xbf,0x3a) || P(0xdf,0x5a) || |
135 |
8/8✓ Branch 0 taken 375397 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 375349 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 375086 times.
✓ Branch 5 taken 263 times.
✓ Branch 6 taken 374898 times.
✓ Branch 7 taken 188 times.
|
375685 | P(0x9f,0x8a) || P(0xcf,0x8a) || P(0xef,0x4e) || P(0x3f,0x0e) || |
136 |
5/8✓ Branch 0 taken 374898 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 374898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 374675 times.
✓ Branch 5 taken 223 times.
✓ Branch 6 taken 374675 times.
✗ Branch 7 not taken.
|
374898 | P(0xfb,0x5a) || P(0xbb,0x8a) || P(0x7f,0x5a) || P(0xaf,0x8a) || |
137 |
4/4✓ Branch 0 taken 289 times.
✓ Branch 1 taken 374386 times.
✓ Branch 5 taken 1364 times.
✓ Branch 6 taken 2448 times.
|
378198 | P(0xeb,0x8a)) && WDIFF(w3, w1)) |
138 | 1364 | return interp_2px(w4, 3, w0, 1, 2); | |
139 |
2/2✓ Branch 0 taken 13377 times.
✓ Branch 1 taken 363457 times.
|
376834 | if (P(0x0b,0x08)) |
140 | 13377 | return interp_3px(w4, 2, w0, 1, w1, 1, 2); | |
141 |
2/2✓ Branch 0 taken 13309 times.
✓ Branch 1 taken 350148 times.
|
363457 | if (P(0x0b,0x02)) |
142 | 13309 | return interp_3px(w4, 2, w0, 1, w3, 1, 2); | |
143 |
2/2✓ Branch 0 taken 6679 times.
✓ Branch 1 taken 343469 times.
|
350148 | if (P(0x2f,0x2f)) |
144 | 6679 | return interp_3px(w4, 14, w3, 1, w1, 1, 4); | |
145 |
4/4✓ Branch 0 taken 342000 times.
✓ Branch 1 taken 1469 times.
✓ Branch 2 taken 1178 times.
✓ Branch 3 taken 340822 times.
|
343469 | if (P(0xbf,0x37) || P(0xdb,0x13)) |
146 | 2647 | return interp_3px(w4, 5, w1, 2, w3, 1, 3); | |
147 |
4/4✓ Branch 0 taken 339291 times.
✓ Branch 1 taken 1531 times.
✓ Branch 2 taken 1316 times.
✓ Branch 3 taken 337975 times.
|
340822 | if (P(0xdb,0x49) || P(0xef,0x6d)) |
148 | 2847 | return interp_3px(w4, 5, w3, 2, w1, 1, 3); | |
149 |
8/8✓ Branch 0 taken 302916 times.
✓ Branch 1 taken 35059 times.
✓ Branch 2 taken 300862 times.
✓ Branch 3 taken 2054 times.
✓ Branch 4 taken 295673 times.
✓ Branch 5 taken 5189 times.
✓ Branch 6 taken 248 times.
✓ Branch 7 taken 295425 times.
|
337975 | if (P(0x1b,0x03) || P(0x4f,0x43) || P(0x8b,0x83) || P(0x6b,0x43)) |
150 | 42550 | return interp_2px(w4, 3, w3, 1, 2); | |
151 |
8/8✓ Branch 0 taken 259441 times.
✓ Branch 1 taken 35984 times.
✓ Branch 2 taken 251717 times.
✓ Branch 3 taken 7724 times.
✓ Branch 4 taken 251380 times.
✓ Branch 5 taken 337 times.
✓ Branch 6 taken 278 times.
✓ Branch 7 taken 251102 times.
|
295425 | if (P(0x4b,0x09) || P(0x8b,0x89) || P(0x1f,0x19) || P(0x3b,0x19)) |
152 | 44323 | return interp_2px(w4, 3, w1, 1, 2); | |
153 |
8/8✓ Branch 0 taken 249571 times.
✓ Branch 1 taken 1531 times.
✓ Branch 2 taken 248255 times.
✓ Branch 3 taken 1316 times.
✓ Branch 4 taken 246786 times.
✓ Branch 5 taken 1469 times.
✓ Branch 6 taken 1178 times.
✓ Branch 7 taken 245608 times.
|
251102 | if (P(0x7e,0x2a) || P(0xef,0xab) || P(0xbf,0x8f) || P(0x7e,0x0e)) |
154 | 5494 | return interp_3px(w4, 2, w3, 3, w1, 3, 3); | |
155 |
8/8✓ Branch 0 taken 245173 times.
✓ Branch 1 taken 435 times.
✓ Branch 2 taken 239438 times.
✓ Branch 3 taken 5735 times.
✓ Branch 4 taken 237436 times.
✓ Branch 5 taken 2002 times.
✓ Branch 6 taken 236958 times.
✓ Branch 7 taken 478 times.
|
245608 | if (P(0xfb,0x6a) || P(0x6f,0x6e) || P(0x3f,0x3e) || P(0xfb,0xfa) || |
156 |
4/4✓ Branch 0 taken 236564 times.
✓ Branch 1 taken 394 times.
✓ Branch 2 taken 148 times.
✓ Branch 3 taken 236416 times.
|
236958 | P(0xdf,0xde) || P(0xdf,0x1e)) |
157 | 9192 | return interp_2px(w4, 3, w0, 1, 2); | |
158 |
8/8✓ Branch 0 taken 11863 times.
✓ Branch 1 taken 224553 times.
✓ Branch 2 taken 7338 times.
✓ Branch 3 taken 4525 times.
✓ Branch 4 taken 7011 times.
✓ Branch 5 taken 327 times.
✓ Branch 6 taken 4407 times.
✓ Branch 7 taken 2604 times.
|
236416 | if (P(0x0a,0x00) || P(0x4f,0x4b) || P(0x9f,0x1b) || P(0x2f,0x0b) || |
159 |
8/8✓ Branch 0 taken 3747 times.
✓ Branch 1 taken 660 times.
✓ Branch 2 taken 3634 times.
✓ Branch 3 taken 113 times.
✓ Branch 4 taken 3546 times.
✓ Branch 5 taken 88 times.
✓ Branch 6 taken 3091 times.
✓ Branch 7 taken 455 times.
|
4407 | P(0xbe,0x0a) || P(0xee,0x0a) || P(0x7e,0x0a) || P(0xeb,0x4b) || |
160 |
2/2✓ Branch 0 taken 1730 times.
✓ Branch 1 taken 1361 times.
|
3091 | P(0x3b,0x1b)) |
161 | 235055 | return interp_3px(w4, 2, w3, 1, w1, 1, 2); | |
162 | 1361 | return interp_3px(w4, 6, w3, 1, w1, 1, 3); | |
163 | } | ||
164 | |||
165 | /* Assuming p0..p8 is mapped to pixels 0..8, this function interpolates the | ||
166 | * top-left and top-center pixel in the total of the 3x3 pixels to | ||
167 | * interpolates. The function is also used for the 3 other couples of pixels | ||
168 | * defining the outline. The center pixel is not defined through this function, | ||
169 | * since it's just the same as the original value. */ | ||
170 | 395752 | static av_always_inline void hq3x_interp_2x1(uint32_t *dst, int dst_linesize, | |
171 | const uint32_t *r2y, int k, | ||
172 | const uint32_t *w, | ||
173 | int pos00, int pos01, | ||
174 | int p0, int p1, int p2, | ||
175 | int p3, int p4, int p5, | ||
176 | int p6, int p7, int p8, | ||
177 | int rotate) | ||
178 | { | ||
179 |
32/32✓ Branch 0 taken 197876 times.
✓ Branch 1 taken 197876 times.
✓ Branch 2 taken 197876 times.
✓ Branch 3 taken 197876 times.
✓ Branch 4 taken 197876 times.
✓ Branch 5 taken 197876 times.
✓ Branch 6 taken 197876 times.
✓ Branch 7 taken 197876 times.
✓ Branch 8 taken 197876 times.
✓ Branch 9 taken 197876 times.
✓ Branch 10 taken 197876 times.
✓ Branch 11 taken 197876 times.
✓ Branch 12 taken 197876 times.
✓ Branch 13 taken 197876 times.
✓ Branch 14 taken 197876 times.
✓ Branch 15 taken 197876 times.
✓ Branch 16 taken 197876 times.
✓ Branch 17 taken 197876 times.
✓ Branch 18 taken 197876 times.
✓ Branch 19 taken 197876 times.
✓ Branch 20 taken 197876 times.
✓ Branch 21 taken 197876 times.
✓ Branch 22 taken 197876 times.
✓ Branch 23 taken 197876 times.
✓ Branch 24 taken 197876 times.
✓ Branch 25 taken 197876 times.
✓ Branch 26 taken 197876 times.
✓ Branch 27 taken 197876 times.
✓ Branch 28 taken 197876 times.
✓ Branch 29 taken 197876 times.
✓ Branch 30 taken 197876 times.
✓ Branch 31 taken 197876 times.
|
395752 | INTERP_BOOTSTRAP(rotate); |
180 | |||
181 | 395752 | uint32_t *dst00 = &dst[dst_linesize*(pos00>>1) + (pos00&1)]; | |
182 | 395752 | uint32_t *dst01 = &dst[dst_linesize*(pos01>>1) + (pos01&1)]; | |
183 | |||
184 |
6/6✓ Branch 0 taken 393713 times.
✓ Branch 1 taken 2039 times.
✓ Branch 2 taken 1557 times.
✓ Branch 3 taken 392156 times.
✓ Branch 7 taken 1054 times.
✓ Branch 8 taken 2542 times.
|
395752 | if ((P(0xdb,0x49) || P(0xef,0x6d)) && WDIFF(w7, w3)) |
185 | 1054 | *dst00 = interp_2px(w4, 3, w1, 1, 2); | |
186 |
6/6✓ Branch 0 taken 392453 times.
✓ Branch 1 taken 2245 times.
✓ Branch 2 taken 1774 times.
✓ Branch 3 taken 390679 times.
✓ Branch 7 taken 1067 times.
✓ Branch 8 taken 2952 times.
|
394698 | else if ((P(0xbf,0x37) || P(0xdb,0x13)) && WDIFF(w1, w5)) |
187 | 1067 | *dst00 = interp_2px(w4, 3, w3, 1, 2); | |
188 |
8/8✓ Branch 0 taken 356872 times.
✓ Branch 1 taken 36759 times.
✓ Branch 2 taken 356741 times.
✓ Branch 3 taken 131 times.
✓ Branch 4 taken 131 times.
✓ Branch 5 taken 356610 times.
✓ Branch 9 taken 15433 times.
✓ Branch 10 taken 21588 times.
|
393631 | else if ((P(0x0b,0x0b) || P(0xfe,0x4a) || P(0xfe,0x1a)) && WDIFF(w3, w1)) |
189 | 15433 | *dst00 = w4; | |
190 |
8/8✓ Branch 0 taken 377602 times.
✓ Branch 1 taken 596 times.
✓ Branch 2 taken 376334 times.
✓ Branch 3 taken 1268 times.
✓ Branch 4 taken 376111 times.
✓ Branch 5 taken 223 times.
✓ Branch 6 taken 375727 times.
✓ Branch 7 taken 384 times.
|
378198 | else if ((P(0x6f,0x2a) || P(0x5b,0x0a) || P(0xbf,0x3a) || P(0xdf,0x5a) || |
191 |
8/8✓ Branch 0 taken 375427 times.
✓ Branch 1 taken 300 times.
✓ Branch 2 taken 375390 times.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 375130 times.
✓ Branch 5 taken 260 times.
✓ Branch 6 taken 374897 times.
✓ Branch 7 taken 233 times.
|
375727 | P(0x9f,0x8a) || P(0xcf,0x8a) || P(0xef,0x4e) || P(0x3f,0x0e) || |
192 |
5/8✓ Branch 0 taken 374897 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 374897 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 374674 times.
✓ Branch 5 taken 223 times.
✓ Branch 6 taken 374674 times.
✗ Branch 7 not taken.
|
374897 | P(0xfb,0x5a) || P(0xbb,0x8a) || P(0x7f,0x5a) || P(0xaf,0x8a) || |
193 |
4/4✓ Branch 0 taken 288 times.
✓ Branch 1 taken 374386 times.
✓ Branch 5 taken 1364 times.
✓ Branch 6 taken 2448 times.
|
378198 | P(0xeb,0x8a)) && WDIFF(w3, w1)) |
194 | 1364 | *dst00 = interp_2px(w4, 3, w0, 1, 2); | |
195 |
8/8✓ Branch 0 taken 341246 times.
✓ Branch 1 taken 35588 times.
✓ Branch 2 taken 333753 times.
✓ Branch 3 taken 7493 times.
✓ Branch 4 taken 333428 times.
✓ Branch 5 taken 325 times.
✓ Branch 6 taken 233 times.
✓ Branch 7 taken 333195 times.
|
376834 | else if (P(0x4b,0x09) || P(0x8b,0x89) || P(0x1f,0x19) || P(0x3b,0x19)) |
196 | 43639 | *dst00 = interp_2px(w4, 3, w1, 1, 2); | |
197 |
8/8✓ Branch 0 taken 297740 times.
✓ Branch 1 taken 35455 times.
✓ Branch 2 taken 295652 times.
✓ Branch 3 taken 2088 times.
✓ Branch 4 taken 290210 times.
✓ Branch 5 taken 5442 times.
✓ Branch 6 taken 249 times.
✓ Branch 7 taken 289961 times.
|
333195 | else if (P(0x1b,0x03) || P(0x4f,0x43) || P(0x8b,0x83) || P(0x6b,0x43)) |
198 | 43234 | *dst00 = interp_2px(w4, 3, w3, 1, 2); | |
199 |
8/8✓ Branch 0 taken 288374 times.
✓ Branch 1 taken 1587 times.
✓ Branch 2 taken 287009 times.
✓ Branch 3 taken 1365 times.
✓ Branch 4 taken 285600 times.
✓ Branch 5 taken 1409 times.
✓ Branch 6 taken 1133 times.
✓ Branch 7 taken 284467 times.
|
289961 | else if (P(0x7e,0x2a) || P(0xef,0xab) || P(0xbf,0x8f) || P(0x7e,0x0e)) |
200 | 5494 | *dst00 = interp_2px(w3, 1, w1, 1, 1); | |
201 |
8/8✓ Branch 0 taken 279958 times.
✓ Branch 1 taken 4509 times.
✓ Branch 2 taken 279627 times.
✓ Branch 3 taken 331 times.
✓ Branch 4 taken 277034 times.
✓ Branch 5 taken 2593 times.
✓ Branch 6 taken 276369 times.
✓ Branch 7 taken 665 times.
|
284467 | else if (P(0x4f,0x4b) || P(0x9f,0x1b) || P(0x2f,0x0b) || P(0xbe,0x0a) || |
202 |
8/8✓ Branch 0 taken 276261 times.
✓ Branch 1 taken 108 times.
✓ Branch 2 taken 276173 times.
✓ Branch 3 taken 88 times.
✓ Branch 4 taken 275726 times.
✓ Branch 5 taken 447 times.
✓ Branch 6 taken 1761 times.
✓ Branch 7 taken 273965 times.
|
276369 | P(0xee,0x0a) || P(0x7e,0x0a) || P(0xeb,0x4b) || P(0x3b,0x1b)) |
203 | 10502 | *dst00 = interp_3px(w4, 2, w3, 7, w1, 7, 4); | |
204 |
8/8✓ Branch 0 taken 260613 times.
✓ Branch 1 taken 13352 times.
✓ Branch 2 taken 260192 times.
✓ Branch 3 taken 421 times.
✓ Branch 4 taken 259951 times.
✓ Branch 5 taken 241 times.
✓ Branch 6 taken 254030 times.
✓ Branch 7 taken 5921 times.
|
273965 | else if (P(0x0b,0x08) || P(0xf9,0x68) || P(0xf3,0x62) || P(0x6d,0x6c) || |
205 |
8/8✓ Branch 0 taken 251900 times.
✓ Branch 1 taken 2130 times.
✓ Branch 2 taken 250096 times.
✓ Branch 3 taken 1804 times.
✓ Branch 4 taken 249152 times.
✓ Branch 5 taken 944 times.
✓ Branch 6 taken 248716 times.
✓ Branch 7 taken 436 times.
|
254030 | P(0x67,0x66) || P(0x3d,0x3c) || P(0x37,0x36) || P(0xf9,0xf8) || |
206 |
8/8✓ Branch 0 taken 248280 times.
✓ Branch 1 taken 436 times.
✓ Branch 2 taken 247992 times.
✓ Branch 3 taken 288 times.
✓ Branch 4 taken 247550 times.
✓ Branch 5 taken 442 times.
✓ Branch 6 taken 247376 times.
✓ Branch 7 taken 174 times.
|
248716 | P(0xdd,0xdc) || P(0xf3,0xf2) || P(0xd7,0xd6) || P(0xdd,0x1c) || |
207 |
4/4✓ Branch 0 taken 245210 times.
✓ Branch 1 taken 2166 times.
✓ Branch 2 taken 7123 times.
✓ Branch 3 taken 238087 times.
|
247376 | P(0xd7,0x16) || P(0x0b,0x02)) |
208 | 35878 | *dst00 = interp_2px(w4, 3, w0, 1, 2); | |
209 | else | ||
210 | 238087 | *dst00 = interp_3px(w4, 2, w3, 1, w1, 1, 2); | |
211 | |||
212 |
8/8✓ Branch 0 taken 393525 times.
✓ Branch 1 taken 2227 times.
✓ Branch 2 taken 386471 times.
✓ Branch 3 taken 7054 times.
✓ Branch 4 taken 385472 times.
✓ Branch 5 taken 999 times.
✓ Branch 6 taken 375829 times.
✓ Branch 7 taken 9643 times.
|
395752 | if ((P(0xfe,0xde) || P(0x9e,0x16) || P(0xda,0x12) || P(0x17,0x16) || |
213 |
6/6✓ Branch 0 taken 375528 times.
✓ Branch 1 taken 301 times.
✓ Branch 2 taken 131 times.
✓ Branch 3 taken 375397 times.
✓ Branch 7 taken 5856 times.
✓ Branch 8 taken 14499 times.
|
395752 | P(0x5b,0x12) || P(0xbb,0x12)) && WDIFF(w1, w5)) |
214 | 5856 | *dst01 = w4; | |
215 |
8/8✓ Branch 0 taken 376373 times.
✓ Branch 1 taken 13523 times.
✓ Branch 2 taken 375374 times.
✓ Branch 3 taken 999 times.
✓ Branch 4 taken 373583 times.
✓ Branch 5 taken 1791 times.
✓ Branch 6 taken 370000 times.
✓ Branch 7 taken 3583 times.
|
389896 | else if ((P(0x0f,0x0b) || P(0x5e,0x0a) || P(0xfb,0x7b) || P(0x3b,0x0b) || |
216 |
6/6✓ Branch 0 taken 369869 times.
✓ Branch 1 taken 131 times.
✓ Branch 2 taken 301 times.
✓ Branch 3 taken 369568 times.
✓ Branch 7 taken 5877 times.
✓ Branch 8 taken 14451 times.
|
389896 | P(0xbe,0x0a) || P(0x7a,0x0a)) && WDIFF(w3, w1)) |
217 | 5877 | *dst01 = w4; | |
218 |
8/8✓ Branch 0 taken 382610 times.
✓ Branch 1 taken 1409 times.
✓ Branch 2 taken 381477 times.
✓ Branch 3 taken 1133 times.
✓ Branch 4 taken 379779 times.
✓ Branch 5 taken 1698 times.
✓ Branch 6 taken 1254 times.
✓ Branch 7 taken 378525 times.
|
384019 | else if (P(0xbf,0x8f) || P(0x7e,0x0e) || P(0xbf,0x37) || P(0xdb,0x13)) |
219 | 5494 | *dst01 = interp_2px(w1, 3, w4, 1, 2); | |
220 |
8/8✓ Branch 0 taken 93385 times.
✓ Branch 1 taken 285140 times.
✓ Branch 2 taken 91798 times.
✓ Branch 3 taken 1587 times.
✓ Branch 4 taken 90433 times.
✓ Branch 5 taken 1365 times.
✓ Branch 6 taken 89024 times.
✓ Branch 7 taken 1409 times.
|
378525 | else if (P(0x02,0x00) || P(0x7c,0x28) || P(0xed,0xa9) || P(0xf5,0xb4) || |
221 |
2/2✓ Branch 0 taken 1133 times.
✓ Branch 1 taken 87891 times.
|
89024 | P(0xd9,0x90)) |
222 | 290634 | *dst01 = interp_2px(w4, 3, w1, 1, 2); | |
223 |
8/8✓ Branch 0 taken 83382 times.
✓ Branch 1 taken 4509 times.
✓ Branch 2 taken 82809 times.
✓ Branch 3 taken 573 times.
✓ Branch 4 taken 80792 times.
✓ Branch 5 taken 2017 times.
✓ Branch 6 taken 80461 times.
✓ Branch 7 taken 331 times.
|
87891 | else if (P(0x4f,0x4b) || P(0xfb,0x7b) || P(0xfe,0x7e) || P(0x9f,0x1b) || |
224 |
8/8✓ Branch 0 taken 77868 times.
✓ Branch 1 taken 2593 times.
✓ Branch 2 taken 77203 times.
✓ Branch 3 taken 665 times.
✓ Branch 4 taken 77115 times.
✓ Branch 5 taken 88 times.
✓ Branch 6 taken 76917 times.
✓ Branch 7 taken 198 times.
|
80461 | P(0x2f,0x0b) || P(0xbe,0x0a) || P(0x7e,0x0a) || P(0xfb,0x4b) || |
225 |
8/8✓ Branch 0 taken 76344 times.
✓ Branch 1 taken 573 times.
✓ Branch 2 taken 76095 times.
✓ Branch 3 taken 249 times.
✓ Branch 4 taken 75764 times.
✓ Branch 5 taken 331 times.
✓ Branch 6 taken 73622 times.
✓ Branch 7 taken 2142 times.
|
76917 | P(0xfb,0xdb) || P(0xfe,0xde) || P(0xfe,0x56) || P(0x57,0x56) || |
226 |
8/8✓ Branch 0 taken 70879 times.
✓ Branch 1 taken 2743 times.
✓ Branch 2 taken 70681 times.
✓ Branch 3 taken 198 times.
✓ Branch 4 taken 70037 times.
✓ Branch 5 taken 644 times.
✓ Branch 6 taken 108 times.
✓ Branch 7 taken 69929 times.
|
73622 | P(0x97,0x16) || P(0x3f,0x1e) || P(0xdb,0x12) || P(0xbb,0x12)) |
227 | 17962 | *dst01 = interp_2px(w4, 7, w1, 1, 3); | |
228 | else | ||
229 | 69929 | *dst01 = w4; | |
230 | 395752 | } | |
231 | |||
232 | /* Assuming p0..p8 is mapped to pixels 0..8, this function interpolates the | ||
233 | * top-left block of 2x2 pixels in the total of the 4x4 pixels (or 4 blocks) to | ||
234 | * interpolates. The function is also used for the 3 other blocks of 2x2 | ||
235 | * pixels. */ | ||
236 | 395752 | static av_always_inline void hq4x_interp_2x2(uint32_t *dst, int dst_linesize, | |
237 | const uint32_t *r2y, int k, | ||
238 | const uint32_t *w, | ||
239 | int pos00, int pos01, | ||
240 | int pos10, int pos11, | ||
241 | int p0, int p1, int p2, | ||
242 | int p3, int p4, int p5, | ||
243 | int p6, int p7, int p8) | ||
244 | { | ||
245 |
16/16✓ Branch 0 taken 197876 times.
✓ Branch 1 taken 197876 times.
✓ Branch 2 taken 197876 times.
✓ Branch 3 taken 197876 times.
✓ Branch 4 taken 197876 times.
✓ Branch 5 taken 197876 times.
✓ Branch 6 taken 197876 times.
✓ Branch 7 taken 197876 times.
✓ Branch 8 taken 197876 times.
✓ Branch 9 taken 197876 times.
✓ Branch 10 taken 197876 times.
✓ Branch 11 taken 197876 times.
✓ Branch 12 taken 197876 times.
✓ Branch 13 taken 197876 times.
✓ Branch 14 taken 197876 times.
✓ Branch 15 taken 197876 times.
|
395752 | INTERP_BOOTSTRAP(0); |
246 | |||
247 | 395752 | uint32_t *dst00 = &dst[dst_linesize*(pos00>>1) + (pos00&1)]; | |
248 | 395752 | uint32_t *dst01 = &dst[dst_linesize*(pos01>>1) + (pos01&1)]; | |
249 | 395752 | uint32_t *dst10 = &dst[dst_linesize*(pos10>>1) + (pos10&1)]; | |
250 | 395752 | uint32_t *dst11 = &dst[dst_linesize*(pos11>>1) + (pos11&1)]; | |
251 | |||
252 |
6/6✓ Branch 0 taken 393760 times.
✓ Branch 1 taken 1992 times.
✓ Branch 2 taken 1580 times.
✓ Branch 3 taken 392180 times.
✓ Branch 7 taken 925 times.
✓ Branch 8 taken 2647 times.
|
395752 | const int cond00 = (P(0xbf,0x37) || P(0xdb,0x13)) && WDIFF(w1, w5); |
253 |
6/6✓ Branch 0 taken 393452 times.
✓ Branch 1 taken 2300 times.
✓ Branch 2 taken 1743 times.
✓ Branch 3 taken 391709 times.
✓ Branch 7 taken 1196 times.
✓ Branch 8 taken 2847 times.
|
395752 | const int cond01 = (P(0xdb,0x49) || P(0xef,0x6d)) && WDIFF(w7, w3); |
254 |
4/4✓ Branch 0 taken 393846 times.
✓ Branch 1 taken 1275 times.
✓ Branch 2 taken 393623 times.
✓ Branch 3 taken 223 times.
|
395121 | const int cond02 = (P(0x6f,0x2a) || P(0x5b,0x0a) || P(0xbf,0x3a) || |
255 |
6/6✓ Branch 0 taken 393239 times.
✓ Branch 1 taken 384 times.
✓ Branch 2 taken 392951 times.
✓ Branch 3 taken 288 times.
✓ Branch 4 taken 392903 times.
✓ Branch 5 taken 48 times.
|
393623 | P(0xdf,0x5a) || P(0x9f,0x8a) || P(0xcf,0x8a) || |
256 |
5/6✓ Branch 0 taken 392640 times.
✓ Branch 1 taken 263 times.
✓ Branch 2 taken 392452 times.
✓ Branch 3 taken 188 times.
✓ Branch 4 taken 392452 times.
✗ Branch 5 not taken.
|
392903 | P(0xef,0x4e) || P(0x3f,0x0e) || P(0xfb,0x5a) || |
257 |
4/6✓ Branch 0 taken 392452 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 392229 times.
✓ Branch 3 taken 223 times.
✓ Branch 4 taken 392229 times.
✗ Branch 5 not taken.
|
392452 | P(0xbb,0x8a) || P(0x7f,0x5a) || P(0xaf,0x8a) || |
258 |
6/6✓ Branch 0 taken 395121 times.
✓ Branch 1 taken 631 times.
✓ Branch 2 taken 289 times.
✓ Branch 3 taken 391940 times.
✓ Branch 7 taken 1364 times.
✓ Branch 8 taken 2448 times.
|
790873 | P(0xeb,0x8a)) && WDIFF(w3, w1); |
259 |
4/4✓ Branch 0 taken 393452 times.
✓ Branch 1 taken 2300 times.
✓ Branch 2 taken 1743 times.
✓ Branch 3 taken 391709 times.
|
395752 | const int cond03 = P(0xdb,0x49) || P(0xef,0x6d); |
260 |
4/4✓ Branch 0 taken 393760 times.
✓ Branch 1 taken 1992 times.
✓ Branch 2 taken 1580 times.
✓ Branch 3 taken 392180 times.
|
395752 | const int cond04 = P(0xbf,0x37) || P(0xdb,0x13); |
261 |
6/6✓ Branch 0 taken 360693 times.
✓ Branch 1 taken 35059 times.
✓ Branch 2 taken 358639 times.
✓ Branch 3 taken 2054 times.
✓ Branch 4 taken 353450 times.
✓ Branch 5 taken 5189 times.
|
749202 | const int cond05 = P(0x1b,0x03) || P(0x4f,0x43) || P(0x8b,0x83) || |
262 |
2/2✓ Branch 0 taken 248 times.
✓ Branch 1 taken 353202 times.
|
353450 | P(0x6b,0x43); |
263 |
6/6✓ Branch 0 taken 359768 times.
✓ Branch 1 taken 35984 times.
✓ Branch 2 taken 352044 times.
✓ Branch 3 taken 7724 times.
✓ Branch 4 taken 351707 times.
✓ Branch 5 taken 337 times.
|
747459 | const int cond06 = P(0x4b,0x09) || P(0x8b,0x89) || P(0x1f,0x19) || |
264 |
2/2✓ Branch 0 taken 278 times.
✓ Branch 1 taken 351429 times.
|
351707 | P(0x3b,0x19); |
265 |
4/4✓ Branch 0 taken 381940 times.
✓ Branch 1 taken 435 times.
✓ Branch 2 taken 381703 times.
✓ Branch 3 taken 237 times.
|
382375 | const int cond07 = P(0x0b,0x08) || P(0xf9,0x68) || P(0xf3,0x62) || |
266 |
6/6✓ Branch 0 taken 375968 times.
✓ Branch 1 taken 5735 times.
✓ Branch 2 taken 373907 times.
✓ Branch 3 taken 2061 times.
✓ Branch 4 taken 371905 times.
✓ Branch 5 taken 2002 times.
|
381703 | P(0x6d,0x6c) || P(0x67,0x66) || P(0x3d,0x3c) || |
267 |
6/6✓ Branch 0 taken 370894 times.
✓ Branch 1 taken 1011 times.
✓ Branch 2 taken 370416 times.
✓ Branch 3 taken 478 times.
✓ Branch 4 taken 370022 times.
✓ Branch 5 taken 394 times.
|
371905 | P(0x37,0x36) || P(0xf9,0xf8) || P(0xdd,0xdc) || |
268 |
6/6✓ Branch 0 taken 369774 times.
✓ Branch 1 taken 248 times.
✓ Branch 2 taken 369310 times.
✓ Branch 3 taken 464 times.
✓ Branch 4 taken 369162 times.
✓ Branch 5 taken 148 times.
|
370022 | P(0xf3,0xf2) || P(0xd7,0xd6) || P(0xdd,0x1c) || |
269 |
6/6✓ Branch 0 taken 382375 times.
✓ Branch 1 taken 13377 times.
✓ Branch 2 taken 366996 times.
✓ Branch 3 taken 2166 times.
✓ Branch 4 taken 7122 times.
✓ Branch 5 taken 359874 times.
|
778127 | P(0xd7,0x16) || P(0x0b,0x02); |
270 |
4/4✓ Branch 0 taken 375152 times.
✓ Branch 1 taken 7050 times.
✓ Branch 2 taken 375030 times.
✓ Branch 3 taken 122 times.
|
382202 | const int cond08 = (P(0x0f,0x0b) || P(0x2b,0x0b) || P(0xfe,0x4a) || |
271 |
6/6✓ Branch 0 taken 382202 times.
✓ Branch 1 taken 13550 times.
✓ Branch 2 taken 140 times.
✓ Branch 3 taken 374890 times.
✓ Branch 7 taken 5953 times.
✓ Branch 8 taken 14909 times.
|
777954 | P(0xfe,0x1a)) && WDIFF(w3, w1); |
272 | 395752 | const int cond09 = P(0x2f,0x2f); | |
273 | 395752 | const int cond10 = P(0x0a,0x00); | |
274 | 395752 | const int cond11 = P(0x0b,0x09); | |
275 |
4/4✓ Branch 0 taken 393452 times.
✓ Branch 1 taken 2300 times.
✓ Branch 2 taken 1743 times.
✓ Branch 3 taken 391709 times.
|
395752 | const int cond12 = P(0x7e,0x2a) || P(0xef,0xab); |
276 |
4/4✓ Branch 0 taken 393760 times.
✓ Branch 1 taken 1992 times.
✓ Branch 2 taken 1580 times.
✓ Branch 3 taken 392180 times.
|
395752 | const int cond13 = P(0xbf,0x8f) || P(0x7e,0x0e); |
277 |
4/4✓ Branch 0 taken 388876 times.
✓ Branch 1 taken 437 times.
✓ Branch 2 taken 385940 times.
✓ Branch 3 taken 2936 times.
|
389313 | const int cond14 = P(0x4f,0x4b) || P(0x9f,0x1b) || P(0x2f,0x0b) || |
278 |
6/6✓ Branch 0 taken 385236 times.
✓ Branch 1 taken 704 times.
✓ Branch 2 taken 385096 times.
✓ Branch 3 taken 140 times.
✓ Branch 4 taken 384991 times.
✓ Branch 5 taken 105 times.
|
385940 | P(0xbe,0x0a) || P(0xee,0x0a) || P(0x7e,0x0a) || |
279 |
6/6✓ Branch 0 taken 389313 times.
✓ Branch 1 taken 6439 times.
✓ Branch 2 taken 384265 times.
✓ Branch 3 taken 726 times.
✓ Branch 4 taken 3060 times.
✓ Branch 5 taken 381205 times.
|
785065 | P(0xeb,0x4b) || P(0x3b,0x1b); |
280 | 395752 | const int cond15 = P(0x0b,0x03); | |
281 | |||
282 |
2/2✓ Branch 0 taken 925 times.
✓ Branch 1 taken 394827 times.
|
395752 | if (cond00) |
283 | 925 | *dst00 = interp_2px(w4, 5, w3, 3, 3); | |
284 |
2/2✓ Branch 0 taken 1196 times.
✓ Branch 1 taken 393631 times.
|
394827 | else if (cond01) |
285 | 1196 | *dst00 = interp_2px(w4, 5, w1, 3, 3); | |
286 |
8/8✓ Branch 0 taken 356872 times.
✓ Branch 1 taken 36759 times.
✓ Branch 2 taken 356750 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 140 times.
✓ Branch 5 taken 356610 times.
✓ Branch 9 taken 15433 times.
✓ Branch 10 taken 21588 times.
|
393631 | else if ((P(0x0b,0x0b) || P(0xfe,0x4a) || P(0xfe,0x1a)) && WDIFF(w3, w1)) |
287 | 15433 | *dst00 = w4; | |
288 |
2/2✓ Branch 0 taken 1364 times.
✓ Branch 1 taken 376834 times.
|
378198 | else if (cond02) |
289 | 1364 | *dst00 = interp_2px(w4, 5, w0, 3, 3); | |
290 |
2/2✓ Branch 0 taken 2847 times.
✓ Branch 1 taken 373987 times.
|
376834 | else if (cond03) |
291 | 2847 | *dst00 = interp_2px(w4, 3, w3, 1, 2); | |
292 |
2/2✓ Branch 0 taken 2647 times.
✓ Branch 1 taken 371340 times.
|
373987 | else if (cond04) |
293 | 2647 | *dst00 = interp_2px(w4, 3, w1, 1, 2); | |
294 |
2/2✓ Branch 0 taken 42550 times.
✓ Branch 1 taken 328790 times.
|
371340 | else if (cond05) |
295 | 42550 | *dst00 = interp_2px(w4, 5, w3, 3, 3); | |
296 |
2/2✓ Branch 0 taken 44323 times.
✓ Branch 1 taken 284467 times.
|
328790 | else if (cond06) |
297 | 44323 | *dst00 = interp_2px(w4, 5, w1, 3, 3); | |
298 |
8/8✓ Branch 0 taken 274377 times.
✓ Branch 1 taken 10090 times.
✓ Branch 2 taken 273520 times.
✓ Branch 3 taken 857 times.
✓ Branch 4 taken 268918 times.
✓ Branch 5 taken 4602 times.
✓ Branch 6 taken 268814 times.
✓ Branch 7 taken 104 times.
|
284467 | else if (P(0x0f,0x0b) || P(0x5e,0x0a) || P(0x2b,0x0b) || P(0xbe,0x0a) || |
299 |
4/4✓ Branch 0 taken 268584 times.
✓ Branch 1 taken 230 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 268471 times.
|
268814 | P(0x7a,0x0a) || P(0xee,0x0a)) |
300 | 15996 | *dst00 = interp_2px(w1, 1, w3, 1, 1); | |
301 |
2/2✓ Branch 0 taken 35878 times.
✓ Branch 1 taken 232593 times.
|
268471 | else if (cond07) |
302 | 35878 | *dst00 = interp_2px(w4, 5, w0, 3, 3); | |
303 | else | ||
304 | 232593 | *dst00 = interp_3px(w4, 2, w1, 1, w3, 1, 2); | |
305 | |||
306 |
2/2✓ Branch 0 taken 925 times.
✓ Branch 1 taken 394827 times.
|
395752 | if (cond00) |
307 | 925 | *dst01 = interp_2px(w4, 7, w3, 1, 3); | |
308 |
2/2✓ Branch 0 taken 5953 times.
✓ Branch 1 taken 388874 times.
|
394827 | else if (cond08) |
309 | 5953 | *dst01 = w4; | |
310 |
2/2✓ Branch 0 taken 1364 times.
✓ Branch 1 taken 387510 times.
|
388874 | else if (cond02) |
311 | 1364 | *dst01 = interp_2px(w4, 3, w0, 1, 2); | |
312 |
2/2✓ Branch 0 taken 16159 times.
✓ Branch 1 taken 371351 times.
|
387510 | else if (cond09) |
313 | 16159 | *dst01 = w4; | |
314 |
2/2✓ Branch 0 taken 224553 times.
✓ Branch 1 taken 146798 times.
|
371351 | else if (cond10) |
315 | 224553 | *dst01 = interp_3px(w4, 5, w1, 2, w3, 1, 3); | |
316 |
2/2✓ Branch 0 taken 13377 times.
✓ Branch 1 taken 133421 times.
|
146798 | else if (P(0x0b,0x08)) |
317 | 13377 | *dst01 = interp_3px(w4, 5, w1, 2, w0, 1, 3); | |
318 |
2/2✓ Branch 0 taken 48366 times.
✓ Branch 1 taken 85055 times.
|
133421 | else if (cond11) |
319 | 48366 | *dst01 = interp_2px(w4, 5, w1, 3, 3); | |
320 |
2/2✓ Branch 0 taken 2647 times.
✓ Branch 1 taken 82408 times.
|
85055 | else if (cond04) |
321 | 2647 | *dst01 = interp_2px(w1, 3, w4, 1, 2); | |
322 |
2/2✓ Branch 0 taken 2847 times.
✓ Branch 1 taken 79561 times.
|
82408 | else if (cond12) |
323 | 2847 | *dst01 = interp_3px(w1, 2, w4, 1, w3, 1, 2); | |
324 |
2/2✓ Branch 0 taken 2647 times.
✓ Branch 1 taken 76914 times.
|
79561 | else if (cond13) |
325 | 2647 | *dst01 = interp_2px(w1, 5, w3, 3, 3); | |
326 |
2/2✓ Branch 0 taken 42550 times.
✓ Branch 1 taken 34364 times.
|
76914 | else if (cond05) |
327 | 42550 | *dst01 = interp_2px(w4, 7, w3, 1, 3); | |
328 |
8/8✓ Branch 0 taken 33692 times.
✓ Branch 1 taken 672 times.
✓ Branch 2 taken 25896 times.
✓ Branch 3 taken 7796 times.
✓ Branch 4 taken 22883 times.
✓ Branch 5 taken 3013 times.
✓ Branch 6 taken 22157 times.
✓ Branch 7 taken 726 times.
|
34364 | else if (P(0xf3,0x62) || P(0x67,0x66) || P(0x37,0x36) || P(0xf3,0xf2) || |
329 |
6/6✓ Branch 0 taken 21299 times.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 18985 times.
✓ Branch 3 taken 2314 times.
✓ Branch 4 taken 7122 times.
✓ Branch 5 taken 11863 times.
|
22157 | P(0xd7,0xd6) || P(0xd7,0x16) || P(0x0b,0x02)) |
330 | 22501 | *dst01 = interp_2px(w4, 3, w0, 1, 2); | |
331 |
2/2✓ Branch 0 taken 10502 times.
✓ Branch 1 taken 1361 times.
|
11863 | else if (cond14) |
332 | 10502 | *dst01 = interp_2px(w1, 1, w4, 1, 1); | |
333 | else | ||
334 | 1361 | *dst01 = interp_2px(w4, 3, w1, 1, 2); | |
335 | |||
336 |
2/2✓ Branch 0 taken 1196 times.
✓ Branch 1 taken 394556 times.
|
395752 | if (cond01) |
337 | 1196 | *dst10 = interp_2px(w4, 7, w1, 1, 3); | |
338 |
2/2✓ Branch 0 taken 5953 times.
✓ Branch 1 taken 388603 times.
|
394556 | else if (cond08) |
339 | 5953 | *dst10 = w4; | |
340 |
2/2✓ Branch 0 taken 1364 times.
✓ Branch 1 taken 387239 times.
|
388603 | else if (cond02) |
341 | 1364 | *dst10 = interp_2px(w4, 3, w0, 1, 2); | |
342 |
2/2✓ Branch 0 taken 16159 times.
✓ Branch 1 taken 371080 times.
|
387239 | else if (cond09) |
343 | 16159 | *dst10 = w4; | |
344 |
2/2✓ Branch 0 taken 224553 times.
✓ Branch 1 taken 146527 times.
|
371080 | else if (cond10) |
345 | 224553 | *dst10 = interp_3px(w4, 5, w3, 2, w1, 1, 3); | |
346 |
2/2✓ Branch 0 taken 13309 times.
✓ Branch 1 taken 133218 times.
|
146527 | else if (P(0x0b,0x02)) |
347 | 13309 | *dst10 = interp_3px(w4, 5, w3, 2, w0, 1, 3); | |
348 |
2/2✓ Branch 0 taken 46122 times.
✓ Branch 1 taken 87096 times.
|
133218 | else if (cond15) |
349 | 46122 | *dst10 = interp_2px(w4, 5, w3, 3, 3); | |
350 |
2/2✓ Branch 0 taken 2847 times.
✓ Branch 1 taken 84249 times.
|
87096 | else if (cond03) |
351 | 2847 | *dst10 = interp_2px(w3, 3, w4, 1, 2); | |
352 |
2/2✓ Branch 0 taken 2647 times.
✓ Branch 1 taken 81602 times.
|
84249 | else if (cond13) |
353 | 2647 | *dst10 = interp_3px(w3, 2, w4, 1, w1, 1, 2); | |
354 |
2/2✓ Branch 0 taken 2847 times.
✓ Branch 1 taken 78755 times.
|
81602 | else if (cond12) |
355 | 2847 | *dst10 = interp_2px(w3, 5, w1, 3, 3); | |
356 |
2/2✓ Branch 0 taken 44323 times.
✓ Branch 1 taken 34432 times.
|
78755 | else if (cond06) |
357 | 44323 | *dst10 = interp_2px(w4, 7, w1, 1, 3); | |
358 |
8/8✓ Branch 0 taken 21055 times.
✓ Branch 1 taken 13377 times.
✓ Branch 2 taken 20620 times.
✓ Branch 3 taken 435 times.
✓ Branch 4 taken 14885 times.
✓ Branch 5 taken 5735 times.
✓ Branch 6 taken 12883 times.
✓ Branch 7 taken 2002 times.
|
34432 | else if (P(0x0b,0x08) || P(0xf9,0x68) || P(0x6d,0x6c) || P(0x3d,0x3c) || |
359 |
6/6✓ Branch 0 taken 12405 times.
✓ Branch 1 taken 478 times.
✓ Branch 2 taken 12011 times.
✓ Branch 3 taken 394 times.
✓ Branch 4 taken 148 times.
✓ Branch 5 taken 11863 times.
|
12883 | P(0xf9,0xf8) || P(0xdd,0xdc) || P(0xdd,0x1c)) |
360 | 22569 | *dst10 = interp_2px(w4, 3, w0, 1, 2); | |
361 |
2/2✓ Branch 0 taken 10502 times.
✓ Branch 1 taken 1361 times.
|
11863 | else if (cond14) |
362 | 10502 | *dst10 = interp_2px(w3, 1, w4, 1, 1); | |
363 | else | ||
364 | 1361 | *dst10 = interp_2px(w4, 3, w3, 1, 2); | |
365 | |||
366 |
10/10✓ Branch 0 taken 393757 times.
✓ Branch 1 taken 1995 times.
✓ Branch 2 taken 392014 times.
✓ Branch 3 taken 1743 times.
✓ Branch 4 taken 390022 times.
✓ Branch 5 taken 1992 times.
✓ Branch 6 taken 1272 times.
✓ Branch 7 taken 388750 times.
✓ Branch 8 taken 1951 times.
✓ Branch 9 taken 5051 times.
|
402754 | if ((P(0x7f,0x2b) || P(0xef,0xab) || P(0xbf,0x8f) || P(0x7f,0x0f)) && |
367 | 7002 | WDIFF(w3, w1)) | |
368 | 1951 | *dst11 = w4; | |
369 |
2/2✓ Branch 0 taken 1364 times.
✓ Branch 1 taken 392437 times.
|
393801 | else if (cond02) |
370 | 1364 | *dst11 = interp_2px(w4, 7, w0, 1, 3); | |
371 |
2/2✓ Branch 0 taken 46122 times.
✓ Branch 1 taken 346315 times.
|
392437 | else if (cond15) |
372 | 46122 | *dst11 = interp_2px(w4, 7, w3, 1, 3); | |
373 |
2/2✓ Branch 0 taken 48366 times.
✓ Branch 1 taken 297949 times.
|
346315 | else if (cond11) |
374 | 48366 | *dst11 = interp_2px(w4, 7, w1, 1, 3); | |
375 |
8/8✓ Branch 0 taken 73396 times.
✓ Branch 1 taken 224553 times.
✓ Branch 2 taken 71865 times.
✓ Branch 3 taken 1531 times.
✓ Branch 4 taken 70549 times.
✓ Branch 5 taken 1316 times.
✓ Branch 6 taken 69080 times.
✓ Branch 7 taken 1469 times.
|
297949 | else if (P(0x0a,0x00) || P(0x7e,0x2a) || P(0xef,0xab) || P(0xbf,0x8f) || |
376 |
2/2✓ Branch 0 taken 1178 times.
✓ Branch 1 taken 67902 times.
|
69080 | P(0x7e,0x0e)) |
377 | 230047 | *dst11 = interp_3px(w4, 6, w3, 1, w1, 1, 3); | |
378 |
2/2✓ Branch 0 taken 35878 times.
✓ Branch 1 taken 32024 times.
|
67902 | else if (cond07) |
379 | 35878 | *dst11 = interp_2px(w4, 7, w0, 1, 3); | |
380 | else | ||
381 | 32024 | *dst11 = w4; | |
382 | 395752 | } | |
383 | |||
384 | 54 | static av_always_inline void hqx_filter(const ThreadData *td, int jobnr, int nb_jobs, int n) | |
385 | { | ||
386 | int x, y; | ||
387 | 54 | AVFrame *in = td->in, *out = td->out; | |
388 | 54 | const uint32_t *r2y = td->rgbtoyuv; | |
389 | 54 | const int height = in->height; | |
390 | 54 | const int width = in->width; | |
391 | 54 | const int slice_start = (height * jobnr ) / nb_jobs; | |
392 | 54 | const int slice_end = (height * (jobnr+1)) / nb_jobs; | |
393 | 54 | const int dst_linesize = out->linesize[0]; | |
394 | 54 | const int src_linesize = in->linesize[0]; | |
395 | 54 | uint8_t *dst = out->data[0] + slice_start * dst_linesize * n; | |
396 | 54 | const uint8_t *src = in->data[0] + slice_start * src_linesize; | |
397 | |||
398 | 54 | const int dst32_linesize = dst_linesize >> 2; | |
399 | 54 | const int src32_linesize = src_linesize >> 2; | |
400 | |||
401 |
2/2✓ Branch 0 taken 1554 times.
✓ Branch 1 taken 54 times.
|
1608 | for (y = slice_start; y < slice_end; y++) { |
402 | 1554 | const uint32_t *src32 = (const uint32_t *)src; | |
403 | 1554 | uint32_t *dst32 = (uint32_t *)dst; | |
404 |
2/2✓ Branch 0 taken 1548 times.
✓ Branch 1 taken 6 times.
|
1554 | const int prevline = y > 0 ? -src32_linesize : 0; |
405 |
2/2✓ Branch 0 taken 1548 times.
✓ Branch 1 taken 6 times.
|
1554 | const int nextline = y < height - 1 ? src32_linesize : 0; |
406 | |||
407 |
2/2✓ Branch 0 taken 296814 times.
✓ Branch 1 taken 1554 times.
|
298368 | for (x = 0; x < width; x++) { |
408 |
2/2✓ Branch 0 taken 295260 times.
✓ Branch 1 taken 1554 times.
|
296814 | const int prevcol = x > 0 ? -1 : 0; |
409 | 296814 | const int nextcol = x < width -1 ? 1 : 0; | |
410 | 296814 | const uint32_t w[3*3] = { | |
411 | 296814 | src32[prevcol + prevline], src32[prevline], src32[prevline + nextcol], | |
412 | 296814 | src32[prevcol ], src32[ 0], src32[ nextcol], | |
413 | 296814 | src32[prevcol + nextline], src32[nextline], src32[nextline + nextcol] | |
414 | }; | ||
415 | 296814 | const uint32_t yuv1 = rgb2yuv(r2y, w[4]); | |
416 |
2/2✓ Branch 0 taken 118860 times.
✓ Branch 1 taken 177954 times.
|
296814 | const int pattern = (w[4] != w[0] ? (yuv_diff(yuv1, rgb2yuv(r2y, w[0]))) : 0) |
417 |
2/2✓ Branch 0 taken 91854 times.
✓ Branch 1 taken 204960 times.
|
296814 | | (w[4] != w[1] ? (yuv_diff(yuv1, rgb2yuv(r2y, w[1]))) : 0) << 1 |
418 |
2/2✓ Branch 0 taken 115710 times.
✓ Branch 1 taken 181104 times.
|
296814 | | (w[4] != w[2] ? (yuv_diff(yuv1, rgb2yuv(r2y, w[2]))) : 0) << 2 |
419 |
2/2✓ Branch 0 taken 93384 times.
✓ Branch 1 taken 203430 times.
|
296814 | | (w[4] != w[3] ? (yuv_diff(yuv1, rgb2yuv(r2y, w[3]))) : 0) << 3 |
420 |
2/2✓ Branch 0 taken 93384 times.
✓ Branch 1 taken 203430 times.
|
296814 | | (w[4] != w[5] ? (yuv_diff(yuv1, rgb2yuv(r2y, w[5]))) : 0) << 4 |
421 |
2/2✓ Branch 0 taken 115674 times.
✓ Branch 1 taken 181140 times.
|
296814 | | (w[4] != w[6] ? (yuv_diff(yuv1, rgb2yuv(r2y, w[6]))) : 0) << 5 |
422 |
2/2✓ Branch 0 taken 91854 times.
✓ Branch 1 taken 204960 times.
|
296814 | | (w[4] != w[7] ? (yuv_diff(yuv1, rgb2yuv(r2y, w[7]))) : 0) << 6 |
423 |
2/2✓ Branch 0 taken 118800 times.
✓ Branch 1 taken 178014 times.
|
296814 | | (w[4] != w[8] ? (yuv_diff(yuv1, rgb2yuv(r2y, w[8]))) : 0) << 7; |
424 | |||
425 |
2/2✓ Branch 0 taken 98938 times.
✓ Branch 1 taken 197876 times.
|
296814 | if (n == 2) { |
426 | 98938 | dst32[dst32_linesize*0 + 0] = hq2x_interp_1x1(r2y, pattern, w, 0,1,2,3,4,5,6,7,8); // 00 | |
427 | 98938 | dst32[dst32_linesize*0 + 1] = hq2x_interp_1x1(r2y, pattern, w, 2,1,0,5,4,3,8,7,6); // 01 (vert mirrored) | |
428 | 98938 | dst32[dst32_linesize*1 + 0] = hq2x_interp_1x1(r2y, pattern, w, 6,7,8,3,4,5,0,1,2); // 10 (horiz mirrored) | |
429 | 98938 | dst32[dst32_linesize*1 + 1] = hq2x_interp_1x1(r2y, pattern, w, 8,7,6,5,4,3,2,1,0); // 11 (center mirrored) | |
430 |
2/2✓ Branch 0 taken 98938 times.
✓ Branch 1 taken 98938 times.
|
197876 | } else if (n == 3) { |
431 | 98938 | hq3x_interp_2x1(dst32, dst32_linesize, r2y, pattern, w, 0,1, 0,1,2,3,4,5,6,7,8, 0); // 00 01 | |
432 | 98938 | hq3x_interp_2x1(dst32 + 1, dst32_linesize, r2y, pattern, w, 1,3, 2,5,8,1,4,7,0,3,6, 1); // 02 12 (rotated to the right) | |
433 | 98938 | hq3x_interp_2x1(dst32 + 1*dst32_linesize, dst32_linesize, r2y, pattern, w, 2,0, 6,3,0,7,4,1,8,5,2, 1); // 20 10 (rotated to the left) | |
434 | 98938 | hq3x_interp_2x1(dst32 + 1*dst32_linesize + 1, dst32_linesize, r2y, pattern, w, 3,2, 8,7,6,5,4,3,2,1,0, 0); // 22 21 (center mirrored) | |
435 | 98938 | dst32[dst32_linesize + 1] = w[4]; // 11 | |
436 |
1/2✓ Branch 0 taken 98938 times.
✗ Branch 1 not taken.
|
98938 | } else if (n == 4) { |
437 | 98938 | hq4x_interp_2x2(dst32, dst32_linesize, r2y, pattern, w, 0,1,2,3, 0,1,2,3,4,5,6,7,8); // 00 01 10 11 | |
438 | 98938 | hq4x_interp_2x2(dst32 + 2, dst32_linesize, r2y, pattern, w, 1,0,3,2, 2,1,0,5,4,3,8,7,6); // 02 03 12 13 (vert mirrored) | |
439 | 98938 | hq4x_interp_2x2(dst32 + 2*dst32_linesize, dst32_linesize, r2y, pattern, w, 2,3,0,1, 6,7,8,3,4,5,0,1,2); // 20 21 30 31 (horiz mirrored) | |
440 | 98938 | hq4x_interp_2x2(dst32 + 2*dst32_linesize + 2, dst32_linesize, r2y, pattern, w, 3,2,1,0, 8,7,6,5,4,3,2,1,0); // 22 23 32 33 (center mirrored) | |
441 | } else { | ||
442 | ✗ | av_assert0(0); | |
443 | } | ||
444 | |||
445 | 296814 | src32 += 1; | |
446 | 296814 | dst32 += n; | |
447 | } | ||
448 | |||
449 | 1554 | src += src_linesize; | |
450 | 1554 | dst += dst_linesize * n; | |
451 | } | ||
452 | 54 | } | |
453 | |||
454 | #define HQX_FUNC(size) \ | ||
455 | static int hq##size##x(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) \ | ||
456 | { \ | ||
457 | hqx_filter(arg, jobnr, nb_jobs, size); \ | ||
458 | return 0; \ | ||
459 | } | ||
460 | |||
461 | 18 | HQX_FUNC(2) | |
462 | 18 | HQX_FUNC(3) | |
463 | 18 | HQX_FUNC(4) | |
464 | |||
465 | 6 | static int config_output(AVFilterLink *outlink) | |
466 | { | ||
467 | 6 | AVFilterContext *ctx = outlink->src; | |
468 | 6 | HQXContext *hqx = ctx->priv; | |
469 | 6 | AVFilterLink *inlink = ctx->inputs[0]; | |
470 | |||
471 | 6 | outlink->w = inlink->w * hqx->n; | |
472 | 6 | outlink->h = inlink->h * hqx->n; | |
473 | 6 | av_log(inlink->dst, AV_LOG_VERBOSE, "fmt:%s size:%dx%d -> size:%dx%d\n", | |
474 | 6 | av_get_pix_fmt_name(inlink->format), | |
475 | inlink->w, inlink->h, outlink->w, outlink->h); | ||
476 | 6 | return 0; | |
477 | } | ||
478 | |||
479 | 6 | static int filter_frame(AVFilterLink *inlink, AVFrame *in) | |
480 | { | ||
481 | 6 | AVFilterContext *ctx = inlink->dst; | |
482 | 6 | AVFilterLink *outlink = ctx->outputs[0]; | |
483 | 6 | HQXContext *hqx = ctx->priv; | |
484 | ThreadData td; | ||
485 | 6 | AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h); | |
486 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if (!out) { |
487 | ✗ | av_frame_free(&in); | |
488 | ✗ | return AVERROR(ENOMEM); | |
489 | } | ||
490 | 6 | av_frame_copy_props(out, in); | |
491 | 6 | out->width = outlink->w; | |
492 | 6 | out->height = outlink->h; | |
493 | |||
494 | 6 | td.in = in; | |
495 | 6 | td.out = out; | |
496 | 6 | td.rgbtoyuv = hqx->rgbtoyuv; | |
497 | 6 | ff_filter_execute(ctx, hqx->func, &td, NULL, | |
498 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | FFMIN(inlink->h, ff_filter_get_nb_threads(ctx))); |
499 | |||
500 | 6 | av_frame_free(&in); | |
501 | 6 | return ff_filter_frame(outlink, out); | |
502 | } | ||
503 | |||
504 | 9 | static av_cold int init(AVFilterContext *ctx) | |
505 | { | ||
506 | 9 | HQXContext *hqx = ctx->priv; | |
507 | static const hqxfunc_t hqxfuncs[] = {hq2x, hq3x, hq4x}; | ||
508 | |||
509 | uint32_t c; | ||
510 | int bg, rg, g; | ||
511 | |||
512 |
2/2✓ Branch 0 taken 4599 times.
✓ Branch 1 taken 9 times.
|
4608 | for (bg=-255; bg<256; bg++) { |
513 |
2/2✓ Branch 0 taken 2350089 times.
✓ Branch 1 taken 4599 times.
|
2354688 | for (rg=-255; rg<256; rg++) { |
514 | 2350089 | const uint32_t u = (uint32_t)((-169*rg + 500*bg)/1000) + 128; | |
515 | 2350089 | const uint32_t v = (uint32_t)(( 500*rg - 81*bg)/1000) + 128; | |
516 |
6/6✓ Branch 0 taken 1172745 times.
✓ Branch 1 taken 1177344 times.
✓ Branch 2 taken 1760265 times.
✓ Branch 3 taken 589824 times.
✓ Branch 4 taken 878985 times.
✓ Branch 5 taken 881280 times.
|
2350089 | int startg = FFMAX3(-bg, -rg, 0); |
517 |
6/6✓ Branch 0 taken 1172745 times.
✓ Branch 1 taken 1177344 times.
✓ Branch 2 taken 585225 times.
✓ Branch 3 taken 1764864 times.
✓ Branch 4 taken 881280 times.
✓ Branch 5 taken 883584 times.
|
2350089 | int endg = FFMIN3(255-bg, 255-rg, 255); |
518 | 2350089 | uint32_t y = (uint32_t)(( 299*rg + 1000*startg + 114*bg)/1000); | |
519 | 2350089 | c = bg + rg * (1 << 16) + 0x010101 * startg; | |
520 |
2/2✓ Branch 0 taken 150994944 times.
✓ Branch 1 taken 2350089 times.
|
153345033 | for (g = startg; g <= endg; g++) { |
521 | 150994944 | hqx->rgbtoyuv[c] = ((y++) << 16) + (u << 8) + v; | |
522 | 150994944 | c+= 0x010101; | |
523 | } | ||
524 | } | ||
525 | } | ||
526 | |||
527 | 9 | hqx->func = hqxfuncs[hqx->n - 2]; | |
528 | 9 | return 0; | |
529 | } | ||
530 | |||
531 | static const AVFilterPad hqx_inputs[] = { | ||
532 | { | ||
533 | .name = "default", | ||
534 | .type = AVMEDIA_TYPE_VIDEO, | ||
535 | .filter_frame = filter_frame, | ||
536 | }, | ||
537 | }; | ||
538 | |||
539 | static const AVFilterPad hqx_outputs[] = { | ||
540 | { | ||
541 | .name = "default", | ||
542 | .type = AVMEDIA_TYPE_VIDEO, | ||
543 | .config_props = config_output, | ||
544 | }, | ||
545 | }; | ||
546 | |||
547 | const AVFilter ff_vf_hqx = { | ||
548 | .name = "hqx", | ||
549 | .description = NULL_IF_CONFIG_SMALL("Scale the input by 2, 3 or 4 using the hq*x magnification algorithm."), | ||
550 | .priv_size = sizeof(HQXContext), | ||
551 | .init = init, | ||
552 | FILTER_INPUTS(hqx_inputs), | ||
553 | FILTER_OUTPUTS(hqx_outputs), | ||
554 | FILTER_SINGLE_PIXFMT(AV_PIX_FMT_RGB32), | ||
555 | .priv_class = &hqx_class, | ||
556 | .flags = AVFILTER_FLAG_SLICE_THREADS, | ||
557 | }; | ||
558 |