FFmpeg
Loading...
Searching...
No Matches
base64.c
Go to the documentation of this file.
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"
25#if ARCH_AARCH64
28#endif
29#include <string.h>
30
31#define BUF_SIZE (1024)
32
33static char *(*base64_encode_get_fn(void))(char *, const uint8_t *, int, const char *) {
34#if ARCH_AARCH64
38 else
39#endif
40 return ff_base64_encode_c;
41}
42
43static void check_base64_encode(void)
44{
45 LOCAL_ALIGNED_32(uint8_t, buf, [BUF_SIZE]);
46 LOCAL_ALIGNED_32(uint8_t, out1, [AV_BASE64_SIZE(BUF_SIZE)]);
47 LOCAL_ALIGNED_32(uint8_t, out2, [AV_BASE64_SIZE(BUF_SIZE)]);
48 static const char b64[] =
49 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
50
51 for (int i = 0; i < BUF_SIZE; i++)
52 buf[i] = rnd();
53
54 declare_func(char *, char *out, const uint8_t *in, int in_size, const char *b64);
55
56 func_type *fn = base64_encode_get_fn();
57
58 if (check_func(fn, "av_base64_encode")) {
59 for (int i = 0; i < 48 * 5; i++) {
60 size_t offset = rnd() % (BUF_SIZE - i);
61 call_new(out1, i ? buf + offset : NULL, i, b64);
62 call_ref(out2, i ? buf + offset : NULL, i, b64);
63 if (memcmp(out1, out2, AV_BASE64_SIZE(i)))
64 fail();
65 }
66
67 bench_new(out1, buf, BUF_SIZE, b64);
68 }
69}
70
72{
74 report("base64");
75}
#define fn(a)
char * ff_base64_encode_neon(char *out, const uint8_t *in, int in_size, const char *tbl)
static FILE * out
static char * ff_base64_encode_c(char *out, const uint8_t *in, int in_size, const char *b64)
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define rnd
Definition checkasm.h:136
#define NULL
Definition coverity.c:32
#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 AV_BASE64_SIZE(x)
Calculate the output size needed to base64-encode x bytes to a null-terminated string.
Definition base64.h:66
unsigned offset
Definition libaomenc.c:763
#define have_neon(flags)
Definition cpu.h:26
static atomic_int cpu_flags
Definition cpu.c:56
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition cpu.c:109
#define LOCAL_ALIGNED_32(t, v,...)
#define BUF_SIZE
Definition setpts.c:159
static void check_base64_encode(void)
Definition base64.c:43
static char *(*)(char *, const uint8_t *, int, const char *) base64_encode_get_fn(void)
Definition base64.c:33
void checkasm_check_base64(void)
Definition base64.c:71