FFmpeg
aacencdsp.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_internal.h"
24 
26 #include "libavcodec/aacencdsp.h"
27 #include "libavcodec/aactab.h"
28 
29 #include "checkasm.h"
30 
31 #define randomize_float(buf, len) \
32  do { \
33  int i; \
34  for (i = 0; i < len; i++) { \
35  float f = (float)rnd() / (UINT_MAX >> 5) - 16.0f; \
36  buf[i] = f; \
37  } \
38  } while (0)
39 
40 #define randomize_elem(tab) (tab[rnd() % FF_ARRAY_ELEMS(tab)])
41 
43 {
44 #define BUF_SIZE 1024
45  LOCAL_ALIGNED_32(float, in, [BUF_SIZE]);
46 
47  declare_func(void, float *, const float *, int);
48 
50 
51  if (check_func(s->abs_pow34, "abs_pow34")) {
52  LOCAL_ALIGNED_32(float, out, [BUF_SIZE]);
53  LOCAL_ALIGNED_32(float, out2, [BUF_SIZE]);
54 
55  call_ref(out, in, BUF_SIZE);
56  call_new(out2, in, BUF_SIZE);
57 
58  if (!float_near_ulp_array(out, out2, 1, BUF_SIZE))
59  fail();
60 
61  bench_new(out, in, BUF_SIZE);
62  }
63 
64  report("abs_pow34");
65 }
66 
68 {
69  int maxval = randomize_elem(aac_cb_maxval);
71  float rounding = (rnd() & 1) ? ROUND_TO_ZERO : ROUND_STANDARD;
72  LOCAL_ALIGNED_16(float, in, [BUF_SIZE]);
73  LOCAL_ALIGNED_16(float, scaled, [BUF_SIZE]);
74 
75  declare_func(void, int *, const float *, const float *, int, int, int,
76  const float, const float);
77 
79  randomize_float(scaled, BUF_SIZE);
80 
81  for (int sign = 0; sign <= 1; sign++) {
82  if (check_func(s->quant_bands, "quant_bands_%s",
83  sign ? "signed" : "unsigned")) {
84  LOCAL_ALIGNED_32(int, out, [BUF_SIZE]);
85  LOCAL_ALIGNED_32(int, out2, [BUF_SIZE]);
86 
87  call_ref(out, in, scaled, BUF_SIZE, sign, maxval, q34, rounding);
88  call_new(out2, in, scaled, BUF_SIZE, sign, maxval, q34, rounding);
89 
90  if (memcmp(out, out2, BUF_SIZE * sizeof (int)))
91  fail();
92 
93  bench_new(out, in, scaled, BUF_SIZE, sign, maxval, q34, rounding);
94  }
95  }
96 
97  report("quant_bands");
98 }
99 
101 {
102  AACEncDSPContext s = { 0 };
104 
105  test_abs_pow34(&s);
107 }
mem_internal.h
out
FILE * out
Definition: movenc.c:55
AACEncDSPContext
Definition: aacencdsp.h:28
check_func
#define check_func(func,...)
Definition: checkasm.h:184
ROUND_TO_ZERO
#define ROUND_TO_ZERO
Definition: aacenc_utils.h:37
aac_cb_maxval
static const uint8_t aac_cb_maxval[12]
Definition: aacenctab.h:121
call_ref
#define call_ref(...)
Definition: checkasm.h:199
fail
#define fail()
Definition: checkasm.h:193
checkasm.h
BUF_SIZE
#define BUF_SIZE
test_quant_bands
static void test_quant_bands(AACEncDSPContext *s)
Definition: aacencdsp.c:67
rnd
#define rnd()
Definition: checkasm.h:177
s
#define s(width, name)
Definition: cbs_vp9.c:198
LOCAL_ALIGNED_16
#define LOCAL_ALIGNED_16(t, v,...)
Definition: mem_internal.h:130
call_new
#define call_new(...)
Definition: checkasm.h:302
LOCAL_ALIGNED_32
#define LOCAL_ALIGNED_32(t, v,...)
Definition: mem_internal.h:132
checkasm_check_aacencdsp
void checkasm_check_aacencdsp(void)
Definition: aacencdsp.c:100
aactab.h
ff_aac_pow34sf_tab
float ff_aac_pow34sf_tab[428]
test_abs_pow34
static void test_abs_pow34(AACEncDSPContext *s)
Definition: aacencdsp.c:42
ROUND_STANDARD
#define ROUND_STANDARD
Definition: aacenc_utils.h:36
randomize_float
#define randomize_float(buf, len)
Definition: aacencdsp.c:31
report
#define report
Definition: checkasm.h:196
bench_new
#define bench_new(...)
Definition: checkasm.h:373
aacencdsp.h
randomize_elem
#define randomize_elem(tab)
Definition: aacencdsp.c:40
float_near_ulp_array
int float_near_ulp_array(const float *a, const float *b, unsigned max_ulp, unsigned len)
Definition: checkasm.c:439
declare_func
#define declare_func(ret,...)
Definition: checkasm.h:188
aacenc_utils.h
ff_aacenc_dsp_init
static void ff_aacenc_dsp_init(AACEncDSPContext *s)
Definition: aacencdsp.h:60