/*1* This file is part of FFmpeg.2*3* FFmpeg is free software; you can redistribute it and/or4* modify it under the terms of the GNU Lesser General Public5* License as published by the Free Software Foundation; either6* version 2.1 of the License, or (at your option) any later version.7*8* FFmpeg is distributed in the hope that it will be useful,9* but WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU11* Lesser General Public License for more details.12*13* You should have received a copy of the GNU Lesser General Public14* License along with FFmpeg; if not, write to the Free Software15* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA16*/1718/*19* Based on libavutil/base64.c20*/2122#include <stdio.h>2324int main(void)25{26static const char b64[] =27"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";28unsigned i_bits = 0;29int i_shift = 0;30int out_len = 0;31int in;3233#define putb64() \34do { \35putchar(b64[(i_bits << 6 >> i_shift) & 0x3f]); \36out_len++; \37i_shift -= 6; \38} while (0)3940while ((in = getchar()) != EOF) {41i_bits = (i_bits << 8) + in;42i_shift += 8;43while (i_shift > 6)44putb64();45}46while (i_shift > 0)47putb64();48while (out_len++ & 3)49putchar('=');50putchar('\n');5152return 0;53}545556