| @@ -0,0 +1,70 @@ |
| 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/aacenc.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 | + |
| 39 | +static void test_abs_pow34(AACEncContext *s) { |
| 40 | +#define BUF_SIZE 1024 |
| 41 | + LOCAL_ALIGNED_32(float, in, [BUF_SIZE]); |
| 42 | + |
| 43 | + declare_func(void, float *, const float *, int); |
| 44 | + |
| 45 | + randomize_float(in, BUF_SIZE); |
| 46 | + |
| 47 | + if (check_func(s->abs_pow34, "abs_pow34")) { |
| 48 | + LOCAL_ALIGNED_32(float, out, [BUF_SIZE]); |
| 49 | + LOCAL_ALIGNED_32(float, out2, [BUF_SIZE]); |
| 50 | + |
| 51 | + call_ref(out, in, BUF_SIZE); |
| 52 | + call_new(out2, in, BUF_SIZE); |
| 53 | + |
| 54 | + if (memcmp(out, out2, BUF_SIZE * sizeof(float)) != 0) |
| 55 | + fail(); |
| 56 | + |
| 57 | + bench_new(out, in, BUF_SIZE); |
| 58 | + } |
| 59 | + |
| 60 | + report("abs_pow34"); |
| 61 | +} |
| 62 | + |
| 63 | + |
| 64 | +void checkasm_check_aacencdsp(void) |
| 65 | +{ |
| 66 | + AACEncContext s = { 0 }; |
| 67 | + ff_aac_dsp_init(&s); |
| 68 | + |
| 69 | + test_abs_pow34(&s); |
| 70 | +} |