mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-10-28 10:04:37 +08:00
Add NEON implementation using LD3 to load 48 bytes with de-interleaving using which 6 bits are extracted using USHR and SLI to get 4 registers, which is used as a index into lookup table using TBL with 4 registers to translate into the 64-byte output, which is written using ST4 to interleave. Add a checkasm test to validate the input lengths from 0 to 239 bytes to cover all the code paths introduced in the NEON implementation. Refactored the C implementation into a header file so that it can be used from checkasm test without having to duplicate the code there. Observed about 4x speedup by checkasm on A720 core on 1kB input: C: - base64.base64 [OK] NEON: - base64.base64 [OK] checkasm: all 1 tests passed Benchmark results: name nsecs (vs ref) av_base64_encode_c: 1286.9 av_base64_encode_neon: 315.5 ( 4.08x)
67 lines
2.1 KiB
C
67 lines
2.1 KiB
C
/*
|
|
* Copyright (c) 2006 Ryan Martell. (rdm4@martellventures.com)
|
|
*
|
|
* This file is part of FFmpeg.
|
|
*
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#ifndef AVUTIL_BASE64_INTERNAL_H
|
|
#define AVUTIL_BASE64_INTERNAL_H
|
|
|
|
#include <stdint.h>
|
|
#include "intreadwrite.h"
|
|
|
|
/*****************************************************************************
|
|
* b64_encode: Stolen from VLC's http.c.
|
|
* Simplified by Michael.
|
|
* Fixed edge cases and made it work from data (vs. strings) by Ryan.
|
|
*****************************************************************************/
|
|
|
|
static inline char *ff_base64_encode_c(char *out, const uint8_t *in, int in_size, const char *b64)
|
|
{
|
|
char *ret, *dst;
|
|
unsigned i_bits = 0;
|
|
int i_shift = 0;
|
|
int bytes_remaining = in_size;
|
|
|
|
ret = dst = out;
|
|
while (bytes_remaining > 3) {
|
|
i_bits = AV_RB32(in);
|
|
in += 3; bytes_remaining -= 3;
|
|
*dst++ = b64[ i_bits>>26 ];
|
|
*dst++ = b64[(i_bits>>20) & 0x3F];
|
|
*dst++ = b64[(i_bits>>14) & 0x3F];
|
|
*dst++ = b64[(i_bits>>8 ) & 0x3F];
|
|
}
|
|
i_bits = 0;
|
|
while (bytes_remaining) {
|
|
i_bits = (i_bits << 8) + *in++;
|
|
bytes_remaining--;
|
|
i_shift += 8;
|
|
}
|
|
while (i_shift > 0) {
|
|
*dst++ = b64[(i_bits << 6 >> i_shift) & 0x3f];
|
|
i_shift -= 6;
|
|
}
|
|
while ((dst - ret) & 3)
|
|
*dst++ = '=';
|
|
*dst = '\0';
|
|
|
|
return ret;
|
|
}
|
|
|
|
#endif /* AVUTIL_BASE64_INTERNAL_H */
|