| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright (c) 2026 Shreesh Adiga <16567adigashreesh@gmail.com> | ||
| 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 "checkasm.h" | ||
| 22 | #include "libavutil/base64.h" | ||
| 23 | #include "libavutil/base64_internal.h" | ||
| 24 | #include "libavutil/mem_internal.h" | ||
| 25 | #if ARCH_AARCH64 | ||
| 26 | #include "libavutil/aarch64/cpu.h" | ||
| 27 | #include "libavutil/aarch64/base64.h" | ||
| 28 | #endif | ||
| 29 | #include <string.h> | ||
| 30 | |||
| 31 | #define BUF_SIZE (1024) | ||
| 32 | |||
| 33 | 14 | static char *(*base64_encode_get_fn(void))(char *, const uint8_t *, int, const char *) { | |
| 34 | #if ARCH_AARCH64 | ||
| 35 | int cpu_flags = av_get_cpu_flags(); | ||
| 36 | if (have_neon(cpu_flags)) | ||
| 37 | return ff_base64_encode_neon; | ||
| 38 | else | ||
| 39 | #endif | ||
| 40 | 14 | return ff_base64_encode_c; | |
| 41 | } | ||
| 42 | |||
| 43 | 14 | static void check_base64_encode(void) | |
| 44 | { | ||
| 45 | 14 | LOCAL_ALIGNED_32(uint8_t, buf, [BUF_SIZE]); | |
| 46 | 14 | LOCAL_ALIGNED_32(uint8_t, out1, [AV_BASE64_SIZE(BUF_SIZE)]); | |
| 47 | 14 | LOCAL_ALIGNED_32(uint8_t, out2, [AV_BASE64_SIZE(BUF_SIZE)]); | |
| 48 | static const char b64[] = | ||
| 49 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | ||
| 50 | |||
| 51 |
2/2✓ Branch 0 taken 14336 times.
✓ Branch 1 taken 14 times.
|
14350 | for (int i = 0; i < BUF_SIZE; i++) |
| 52 | 14336 | buf[i] = rnd(); | |
| 53 | |||
| 54 | 14 | declare_func(char *, char *out, const uint8_t *in, int in_size, const char *b64); | |
| 55 | |||
| 56 | 14 | func_type *fn = base64_encode_get_fn(); | |
| 57 | |||
| 58 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 13 times.
|
14 | if (check_func(fn, "av_base64_encode")) { |
| 59 |
2/2✓ Branch 0 taken 240 times.
✓ Branch 1 taken 1 times.
|
241 | for (int i = 0; i < 48 * 5; i++) { |
| 60 | 240 | size_t offset = rnd() % (BUF_SIZE - i); | |
| 61 |
2/2✓ Branch 1 taken 239 times.
✓ Branch 2 taken 1 times.
|
240 | call_new(out1, i ? buf + offset : NULL, i, b64); |
| 62 |
3/4✓ Branch 1 taken 239 times.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 240 times.
|
240 | call_ref(out2, i ? buf + offset : NULL, i, b64); |
| 63 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 240 times.
|
240 | if (memcmp(out1, out2, AV_BASE64_SIZE(i))) |
| 64 | ✗ | fail(); | |
| 65 | } | ||
| 66 | |||
| 67 |
1/18✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
|
1 | bench_new(out1, buf, BUF_SIZE, b64); |
| 68 | } | ||
| 69 | 14 | } | |
| 70 | |||
| 71 | 14 | void checkasm_check_base64(void) | |
| 72 | { | ||
| 73 | 14 | check_base64_encode(); | |
| 74 | 14 | report("base64"); | |
| 75 | 14 | } | |
| 76 |