FFmpeg
Loading...
Searching...
No Matches
tests
checkasm
fmtconvert.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 Janne Grunau
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 <math.h>
22
#include <stdint.h>
23
#include <string.h>
24
25
#include "
libavutil/internal.h
"
26
#include "
libavutil/common.h
"
27
#include "
libavutil/mem_internal.h
"
28
29
#include "
libavcodec/fmtconvert.h
"
30
31
#include "
checkasm.h
"
32
33
#define BUF_SIZE 1024
34
35
#define randomize_input(len) \
36
do { \
37
int k; \
38
for (k = 0; k < len; k++) { \
39
in[k] = rnd() - INT32_MAX; \
40
} \
41
for ( ; k < BUF_SIZE; k++) { \
42
in[k] = INT32_MAX; \
43
} \
44
} while (0)
45
46
void
checkasm_check_fmtconvert
(
void
)
47
{
48
FmtConvertContext
c
;
49
LOCAL_ALIGNED
(32,
float
, dst0, [
BUF_SIZE
]);
50
LOCAL_ALIGNED
(32,
float
, dst1, [
BUF_SIZE
]);
51
LOCAL_ALIGNED
(32,
int32_t
, in, [
BUF_SIZE
]);
52
float
scale_arr[128];
53
int
length[] = {8, 16, 24, 56, 72, 128, 512, 520, 656, 768, 992};
54
int
i
, j;
55
56
for
(
i
= 0;
i
<
FF_ARRAY_ELEMS
(scale_arr);
i
++)
57
scale_arr[
i
] = (
FF_ARRAY_ELEMS
(scale_arr) -
FF_ARRAY_ELEMS
(scale_arr) / 2) / 13;
58
59
ff_fmt_convert_init
(&
c
);
60
61
memset(dst0, 0,
sizeof
(*dst0) *
BUF_SIZE
);
62
memset(dst1, 0,
sizeof
(*dst1) *
BUF_SIZE
);
63
64
if
(
check_func
(
c
.int32_to_float_fmul_scalar,
"int32_to_float_fmul_scalar"
)) {
65
declare_func
(
void
,
float
*,
const
int32_t
*,
float
,
int
);
66
67
for
(
i
= 0;
i
<
FF_ARRAY_ELEMS
(scale_arr);
i
++) {
68
for
(j = 0; j <
FF_ARRAY_ELEMS
(length); j++) {
69
70
randomize_input
(length[j]);
71
72
call_ref
(dst0, in, scale_arr[
i
], length[j]);
73
call_new
(dst1, in, scale_arr[
i
], length[j]);
74
75
if
(!
float_near_ulp_array
(dst0, dst1, 3, length[j])) {
76
fail
();
77
break
;
78
}
79
80
bench_new
(dst1, in, scale_arr[
i
], length[j]);
81
}
82
}
83
}
84
report
(
"fmtconvert"
);
85
}
int32_t
int32_t
Definition
audioconvert.c:56
i
#define i(width, name, range_min, range_max)
Definition
cbs_h264.c:63
checkasm.h
common.h
common internal and external API header
fmtconvert.h
declare_func
#define declare_func
Definition
test.h:489
fail
#define fail
Definition
test.h:479
bench_new
#define bench_new
Definition
test.h:487
check_func
#define check_func
Definition
test.h:481
call_new
#define call_new
Definition
test.h:486
call_ref
#define call_ref
Definition
test.h:485
report
#define report
Definition
test.h:480
float_near_ulp_array
#define float_near_ulp_array
Definition
utils.h:451
ff_fmt_convert_init
av_cold void ff_fmt_convert_init(FmtConvertContext *c)
Definition
fmtconvert.c:35
internal.h
common internal API header
mem_internal.h
LOCAL_ALIGNED
#define LOCAL_ALIGNED(a, t, v,...)
Definition
mem_internal.h:124
BUF_SIZE
#define BUF_SIZE
Definition
setpts.c:159
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition
sinewin_tablegen.c:29
FmtConvertContext
Definition
fmtconvert.h:28
randomize_input
#define randomize_input(len)
Definition
fmtconvert.c:35
checkasm_check_fmtconvert
void checkasm_check_fmtconvert(void)
Definition
fmtconvert.c:46
c
static double c[64]
Definition
vsrc_mptestsrc.c:89
Generated on Mon Aug 17 2026 20:20:54 for FFmpeg by
1.13.2