2 * Copyright (c) 2015 Janne Grunau
4 * This file is part of FFmpeg.
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.
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.
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.
25 #include "libavutil/internal.h"
26 #include "libavutil/common.h"
27 #include "libavcodec/fmtconvert.h"
33 #define randomize_input(len) \
36 for (k = 0; k < len; k++) { \
37 in[k] = rnd() - INT32_MAX; \
39 for ( ; k < BUF_SIZE; k++) { \
44 void checkasm_check_fmtconvert(void)
47 LOCAL_ALIGNED(32, float, dst0, [BUF_SIZE]);
48 LOCAL_ALIGNED(32, float, dst1, [BUF_SIZE]);
49 LOCAL_ALIGNED(32, int32_t, in, [BUF_SIZE]);
51 int length[] = {8, 16, 24, 56, 72, 128, 512, 520, 656, 768, 992};
54 for (i = 0; i < FF_ARRAY_ELEMS(scale_arr); i++)
55 scale_arr[i] = (FF_ARRAY_ELEMS(scale_arr) - FF_ARRAY_ELEMS(scale_arr) / 2) / 13;
57 ff_fmt_convert_init(&c, NULL);
59 memset(dst0, 0, sizeof(*dst0) * BUF_SIZE);
60 memset(dst1, 0, sizeof(*dst1) * BUF_SIZE);
62 if (check_func(c.int32_to_float_fmul_scalar, "int32_to_float_fmul_scalar")) {
63 declare_func(void, float *, const int32_t *, float, int);
65 for (i = 0; i < FF_ARRAY_ELEMS(scale_arr); i++) {
66 for (j = 0; j < FF_ARRAY_ELEMS(length); j++) {
68 randomize_input(length[j]);
70 call_ref(dst0, in, scale_arr[i], length[j]);
71 call_new(dst1, in, scale_arr[i], length[j]);
73 if (!float_near_ulp_array(dst0, dst1, 3, length[j])) {
78 bench_new(dst1, in, scale_arr[i], length[j]);
82 if (check_func(c.int32_to_float_fmul_array8, "int32_to_float_fmul_array8")) {
83 declare_func(void, FmtConvertContext *, float *, const int32_t *,
86 for (i = 0; i < 4; i++) {
87 for (j = 0; j < FF_ARRAY_ELEMS(length); j++) {
89 randomize_input(length[j]);
91 call_ref(&c, dst0, in, scale_arr, length[j]);
92 call_new(&c, dst1, in, scale_arr, length[j]);
94 if (!float_near_ulp_array(dst0, dst1, 3, length[j])) {
96 fprintf(stderr, "int32_to_float_fmul_array8: len: %d\n", length[j]);
100 bench_new(&c, dst1, in, scale_arr, length[j]);
104 report("fmtconvert");