FFmpeg
ac3dsp.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 Institue 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"
24 #include "libavutil/mem_internal.h"
25 
26 #include "libavcodec/ac3dsp.h"
27 
28 #include "checkasm.h"
29 
30 #define randomize_float(buf, len) \
31  do { \
32  int i; \
33  for (i = 0; i < len; i++) { \
34  float f = (float)rnd() / (UINT_MAX >> 5) - 16.0f; \
35  buf[i] = f; \
36  } \
37  } while (0)
38 
40 #define BUF_SIZE 1024
41  LOCAL_ALIGNED_32(float, src, [BUF_SIZE]);
42 
43  declare_func(void, int32_t *, const float *, size_t);
44 
46 
47  if (check_func(c->float_to_fixed24, "float_to_fixed24")) {
50 
51  call_ref(dst, src, BUF_SIZE);
52  call_new(dst2, src, BUF_SIZE);
53 
54  if (memcmp(dst, dst2, BUF_SIZE) != 0)
55  fail();
56 
57  bench_new(dst, src, BUF_SIZE);
58  }
59 
60 
61  report("float_to_fixed24");
62 }
63 
65 {
67  ff_ac3dsp_init(&c);
68 
70 }
mem_internal.h
AC3DSPContext
Definition: ac3dsp.h:34
check_func
#define check_func(func,...)
Definition: checkasm.h:170
BUF_SIZE
#define BUF_SIZE
call_ref
#define call_ref(...)
Definition: checkasm.h:185
ff_ac3dsp_init
av_cold void ff_ac3dsp_init(AC3DSPContext *c)
Definition: ac3dsp.c:377
fail
#define fail()
Definition: checkasm.h:179
checkasm.h
call_new
#define call_new(...)
Definition: checkasm.h:288
LOCAL_ALIGNED_32
#define LOCAL_ALIGNED_32(t, v,...)
Definition: mem_internal.h:156
ac3dsp.h
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
report
#define report
Definition: checkasm.h:182
bench_new
#define bench_new(...)
Definition: checkasm.h:358
checkasm_check_ac3dsp
void checkasm_check_ac3dsp(void)
Definition: ac3dsp.c:64
check_float_to_fixed24
static void check_float_to_fixed24(AC3DSPContext *c)
Definition: ac3dsp.c:39
randomize_float
#define randomize_float(buf, len)
Definition: ac3dsp.c:30
mem.h
declare_func
#define declare_func(ret,...)
Definition: checkasm.h:174
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
int32_t
int32_t
Definition: audioconvert.c:56