FFmpeg
Loading...
Searching...
No Matches
takdsp.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Institute of Software Chinese Academy of Sciences (ISCAS).
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21#include <string.h>
22
23#include "libavutil/mem.h"
25
26#include "libavcodec/takdsp.h"
27#include "libavcodec/mathops.h"
28
29#include "checkasm.h"
30
31#define randomize(buf, len) \
32 do { \
33 for (int i = 0; i < len; i++) \
34 buf[i] = rnd(); \
35 } while (0)
36
37#define BUF_SIZE 1024
38
40 declare_func(void, const int32_t *, int32_t *, int);
41
42 if (check_func(s->decorrelate_ls, "decorrelate_ls")) {
46
49 memcpy(p2_2, p2, BUF_SIZE * sizeof(*p2));
50
51 call_ref(p1, p2, BUF_SIZE);
52 call_new(p1, p2_2, BUF_SIZE);
53
54 if (memcmp(p2, p2_2, BUF_SIZE * sizeof(*p2)) != 0) {
55 fail();
56 }
57
58 bench_new(p1, p2, BUF_SIZE);
59 }
60
61 report("decorrelate_ls");
62}
63
65 declare_func(void, int32_t *, const int32_t *, int);
66
67 if (check_func(s->decorrelate_sr, "decorrelate_sr")) {
71
73 memcpy(p1_2, p1, BUF_SIZE * sizeof(*p1));
75
76 call_ref(p1, p2, BUF_SIZE);
77 call_new(p1_2, p2, BUF_SIZE);
78
79 if (memcmp(p1, p1_2, BUF_SIZE * sizeof(*p1)) != 0) {
80 fail();
81 }
82
83 bench_new(p1, p2, BUF_SIZE);
84 }
85
86 report("decorrelate_sr");
87}
88
90 declare_func(void, int32_t *, int32_t *, int);
91
92 if (check_func(s->decorrelate_sm, "decorrelate_sm")) {
97
99 memcpy(p1_2, p1, BUF_SIZE * sizeof(*p1));
100 randomize(p2, BUF_SIZE);
101 memcpy(p2_2, p2, BUF_SIZE * sizeof(*p2));
102
103 call_ref(p1, p2, BUF_SIZE);
104 call_new(p1_2, p2_2, BUF_SIZE);
105
106 if (memcmp(p1, p1_2, BUF_SIZE * sizeof(*p1)) != 0 ||
107 memcmp(p2, p2_2, BUF_SIZE * sizeof(*p2)) != 0) {
108 fail();
109 }
110
111 bench_new(p1, p2, BUF_SIZE);
112 }
113
114 report("decorrelate_sm");
115}
116
118 declare_func(void, int32_t *, const int32_t *, int, int, int);
119
120 if (check_func(s->decorrelate_sf, "decorrelate_sf")) {
124 int dshift, dfactor;
125
126 randomize(p1, BUF_SIZE);
127 memcpy(p1_2, p1, BUF_SIZE * sizeof(*p1));
128 randomize(p2, BUF_SIZE);
129 dshift = (rnd() & 0xF) + 1;
130 dfactor = sign_extend(rnd(), 10);
131
132 call_ref(p1, p2, BUF_SIZE, dshift, dfactor);
133 call_new(p1_2, p2, BUF_SIZE, dshift, dfactor);
134
135 if (memcmp(p1, p1_2, BUF_SIZE * sizeof(*p1)) != 0) {
136 fail();
137 }
138
139 bench_new(p1, p2, BUF_SIZE, dshift, dfactor);
140 }
141
142 report("decorrelate_sf");
143}
144
int32_t
#define s(width, name)
Definition cbs_vp9.c:198
#define rnd
Definition checkasm.h:136
#define declare_func
Definition test.h:489
#define fail
Definition test.h:479
#define bench_new
Definition test.h:487
#define check_func
Definition test.h:481
#define call_new
Definition test.h:486
#define call_ref
Definition test.h:485
#define report
Definition test.h:480
av_cold void ff_takdsp_init(TAKDSPContext *c)
Definition takdsp.c:73
static av_const int sign_extend(int val, unsigned bits)
Definition mathops.h:135
Memory handling functions.
#define LOCAL_ALIGNED_32(t, v,...)
#define BUF_SIZE
Definition setpts.c:159
static void test_decorrelate_sr(TAKDSPContext *s)
Definition takdsp.c:64
#define randomize(buf, len)
Definition takdsp.c:31
void checkasm_check_takdsp(void)
Definition takdsp.c:145
static void test_decorrelate_ls(TAKDSPContext *s)
Definition takdsp.c:39
static void test_decorrelate_sf(TAKDSPContext *s)
Definition takdsp.c:117
static void test_decorrelate_sm(TAKDSPContext *s)
Definition takdsp.c:89