FFmpeg
ttadsp.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #include <string.h>
20 
21 #include "config_components.h"
22 
23 #include "checkasm.h"
24 
25 #include "libavcodec/ttadata.h"
26 #include "libavcodec/ttadsp.h"
27 #include "libavcodec/ttaencdsp.h"
28 #include "libavutil/mem_internal.h"
29 
30 #define randomize_buffer(NAME) \
31 do { \
32  checkasm_randomize(NAME ## _ref, sizeof(NAME ## _ref)); \
33  memcpy(NAME ## _new, NAME ## _ref, sizeof(NAME ## _new)); \
34 } while (0)
35 
36 static void check_filter_process(void)
37 {
44  int bps = 1 + rnd() % 3;
46  int32_t in = rnd(), error_ref = rnd(), error_new = error_ref;
47 
50 
51  randomize_buffer(qm);
52  randomize_buffer(dx);
53  randomize_buffer(dl);
54 
55  int32_t out_ref = call_ref(qm_ref, dx_ref, dl_ref, &error_ref, in, shift, round);
56  int32_t out_new = call_new(qm_new, dx_new, dl_new, &error_new, in, shift, round);
57 
58  if (out_ref != out_new || error_ref != error_new ||
59  memcmp(qm_ref, qm_new, sizeof(qm_ref)) ||
60  memcmp(dx_ref, dx_new, sizeof(dx_ref)) ||
61  memcmp(dl_ref, dl_new, sizeof(dl_ref)))
62  fail();
63 #define alt(var) checkasm_alternate(var ## _ref, var ## _new)
64  bench_new(alt(qm), alt(dx), alt(dl), alt(&error), in, shift, round);
65 }
66 
67 #if CONFIG_TTA_DECODER
68 void checkasm_check_ttadsp(void)
69 {
70  TTADSPContext ttadsp;
71 
72  ff_ttadsp_init(&ttadsp);
73 
74  if (check_func(ttadsp.filter_process, "filter_process"))
76  report("filter_process");
77 }
78 #endif
79 
80 #if CONFIG_TTA_ENCODER
81 void checkasm_check_ttaencdsp(void)
82 {
83  TTAEncDSPContext ttaencdsp;
84 
85  ff_ttaencdsp_init(&ttaencdsp);
86 
87  if (check_func(ttaencdsp.filter_process, "filter_process"))
89  report("filter_process");
90 }
91 #endif
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:32
mem_internal.h
MAX_ORDER
#define MAX_ORDER
Definition: ttadata.h:28
ff_ttadsp_init
av_cold void ff_ttadsp_init(TTADSPContext *c)
Definition: ttadsp.c:58
check_func
#define check_func
Definition: test.h:481
check_filter_process
static void check_filter_process(void)
Definition: ttadsp.c:36
ff_ttaencdsp_init
av_cold void ff_ttaencdsp_init(TTAEncDSPContext *c)
Definition: ttaencdsp.c:58
bench_new
#define bench_new
Definition: test.h:487
call_ref
#define call_ref
Definition: test.h:485
checkasm.h
alt
#define alt(var)
declare_func
#define declare_func
Definition: test.h:489
checkasm_check_ttadsp
void checkasm_check_ttadsp(void)
fail
#define fail
Definition: test.h:479
TTADSPContext
Definition: ttadsp.h:24
shift
static int shift(int a, int b)
Definition: bonk.c:261
bps
unsigned bps
Definition: movenc.c:2074
rnd
#define rnd
Definition: checkasm.h:136
ff_tta_shift_1
const uint32_t ff_tta_shift_1[]
Definition: ttadata.c:24
checkasm_check_ttaencdsp
void checkasm_check_ttaencdsp(void)
round
static av_always_inline av_const double round(double x)
Definition: libm.h:446
ff_tta_filter_configs
const uint8_t ff_tta_filter_configs[]
Definition: ttadata.c:40
ttadata.h
call_new
#define call_new
Definition: test.h:486
TTADSPContext::filter_process
int32_t(* filter_process)(int32_t *qm, int32_t *dx, int32_t *dl, int32_t *error, int32_t in, int32_t shift, int32_t round)
Definition: ttadsp.h:25
randomize_buffer
#define randomize_buffer(NAME)
Definition: ttadsp.c:30
TTAEncDSPContext
Definition: ttaencdsp.h:24
TTAEncDSPContext::filter_process
int32_t(* filter_process)(int32_t *qm, int32_t *dx, int32_t *dl, int32_t *error, int32_t in, int32_t shift, int32_t round)
Definition: ttaencdsp.h:25
report
#define report
Definition: test.h:480
ttadsp.h
DECLARE_ALIGNED_16
#define DECLARE_ALIGNED_16(t, v)
Definition: mem_internal.h:112
int32_t
int32_t
Definition: audioconvert.c:56
ttaencdsp.h