mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-04-14 00:58:38 +02:00
base64: optimize av_base64_encode()
This makes the code 2-3 times as fast Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
a41687c2d6
commit
112bca91b0
@ -27,6 +27,7 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
#include "avassert.h"
|
#include "avassert.h"
|
||||||
|
#include "intreadwrite.h"
|
||||||
|
|
||||||
/* ---------------- private code */
|
/* ---------------- private code */
|
||||||
static const uint8_t map2[] =
|
static const uint8_t map2[] =
|
||||||
@ -85,6 +86,15 @@ char *av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size)
|
|||||||
out_size < AV_BASE64_SIZE(in_size))
|
out_size < AV_BASE64_SIZE(in_size))
|
||||||
return NULL;
|
return NULL;
|
||||||
ret = dst = out;
|
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) {
|
while (bytes_remaining) {
|
||||||
i_bits = (i_bits << 8) + *in++;
|
i_bits = (i_bits << 8) + *in++;
|
||||||
bytes_remaining--;
|
bytes_remaining--;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user