diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-01-20 22:46:14 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-01-21 00:24:10 +0100 |
commit | 112bca91b054e61dd4ec8ec19dd423afc41be14c (patch) | |
tree | 603cf787764208d30d85298eb3986119fdb5dfaf /libavutil/base64.c | |
parent | a41687c2d673f3dc375cdd2be97877991df49463 (diff) | |
download | ffmpeg-112bca91b054e61dd4ec8ec19dd423afc41be14c.tar.gz |
base64: optimize av_base64_encode()
This makes the code 2-3 times as fast
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/base64.c')
-rw-r--r-- | libavutil/base64.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libavutil/base64.c b/libavutil/base64.c index 654c280827..26e28b719f 100644 --- a/libavutil/base64.c +++ b/libavutil/base64.c @@ -27,6 +27,7 @@ #include "common.h" #include "base64.h" #include "avassert.h" +#include "intreadwrite.h" /* ---------------- private code */ 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)) return NULL; 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--; |