1 /*
2 * Copyright © 2023, VideoLAN and dav1d authors
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice, this
9 * list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
19 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27 #include "tests/checkasm/checkasm.h"
28 #include "src/pal.h"
29
30 #include <stdio.h>
31
check_pal_idx_finish(const Dav1dPalDSPContext * const c)32 static void check_pal_idx_finish(const Dav1dPalDSPContext *const c) {
33 ALIGN_STK_64(uint8_t, src, 64 * 64,);
34 ALIGN_STK_64(uint8_t, c_dst, 32 * 64,);
35 ALIGN_STK_64(uint8_t, a_dst, 32 * 64,);
36
37 declare_func(void, uint8_t *dst, const uint8_t *src,
38 int bw, int bh, int w, int h);
39
40 for (int bw = 4; bw <= 64; bw <<= 1) {
41 if (check_func(c->pal_idx_finish, "pal_idx_finish_w%d", bw)) {
42 for (int bh = imax(bw / 4, 4); bh <= imin(bw * 4, 64); bh <<= 1) {
43 const int w = (rnd() & (bw - 4)) + 4;
44 const int h = (rnd() & (bh - 4)) + 4;
45 const int dst_bw = bw / 2;
46
47 for (int i = 0; i < bw * bh; i++)
48 src[i] = rnd() & 7;
49
50 memset(c_dst, 0x88, dst_bw * bh);
51 memset(a_dst, 0x88, dst_bw * bh);
52
53 call_ref(c_dst, src, bw, bh, w, h);
54 call_new(a_dst, src, bw, bh, w, h);
55 checkasm_check(uint8_t, c_dst, dst_bw, a_dst, dst_bw,
56 dst_bw, bh, "dst");
57
58 bench_new(a_dst, src, bw, bh, bw, bh);
59 }
60 }
61 }
62
63 report("pal_idx_finish");
64 }
65
checkasm_check_pal(void)66 void checkasm_check_pal(void) {
67 Dav1dPalDSPContext c;
68 dav1d_pal_dsp_init(&c);
69
70 check_pal_idx_finish(&c);
71 }
72