[FFmpeg-devel] [PATCH 2/3] base64: optimize av_base64_encode()
Michael Niedermayer
michaelni at gmx.at
Sat Jan 21 00:21:26 CET 2012
On Fri, Jan 20, 2012 at 11:32:46PM +0100, Reimar Döffinger wrote:
> On Fri, Jan 20, 2012 at 10:57:19PM +0100, Michael Niedermayer wrote:
> > This makes the code 2-3 times as fast
> >
> > Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> > ---
> > libavutil/base64.c | 10 ++++++++++
> > 1 files changed, 10 insertions(+), 0 deletions(-)
> >
> > diff --git a/libavutil/base64.c b/libavutil/base64.c
> > index a791a8e..80ab44b 100644
> > --- a/libavutil/base64.c
> > +++ b/libavutil/base64.c
> > @@ -26,6 +26,7 @@
> >
> > #include "common.h"
> > #include "base64.h"
> > +#include "intreadwrite.h"
> >
> > /* ---------------- private code */
> > static const uint8_t map2[] =
> > @@ -82,6 +83,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];
> > + }
>
> Looks fine to me, though I am not sure if it is a bit unfortunate
> we are not requiring alignment on the buffers...
applied, thanks
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120121/57fe5ab8/attachment.asc>
More information about the ffmpeg-devel
mailing list