FFmpeg
Loading...
Searching...
No Matches
aacencdsp.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
24
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
62 }
63
64 report("abs_pow34");
65}
66
68{
69 int maxval = randomize_elem(aac_cb_maxval);
70 float q34 = (float)rnd() / (UINT_MAX / 1024);
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
80
81 for (int sign = 0; sign <= 1; sign++) {
82 if (check_func(s->quant_bands, "quant_bands_%s",
83 sign ? "signed" : "unsigned")) {
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
107}
AAC encoder utilities.
#define ROUND_TO_ZERO
#define ROUND_STANDARD
static const uint8_t aac_cb_maxval[12]
Definition aacenctab.h:139
AAC data declarations.
#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
#define float_near_ulp_array
Definition utils.h:451
void ff_aacenc_dsp_init(AACEncDSPContext *s)
Definition aacencdsp.c:75
#define LOCAL_ALIGNED_32(t, v,...)
#define LOCAL_ALIGNED_16(t, v,...)
#define BUF_SIZE
Definition setpts.c:159
#define randomize_elem(tab)
Definition aacencdsp.c:40
void checkasm_check_aacencdsp(void)
Definition aacencdsp.c:100
static void test_abs_pow34(AACEncDSPContext *s)
Definition aacencdsp.c:42
static void test_quant_bands(AACEncDSPContext *s)
Definition aacencdsp.c:67
#define randomize_float(buf, len)
Definition aacencdsp.c:31
static FILE * out
Definition movenc.c:55