yading@11: /* yading@11: * Copyright (c) 2006 Ryan Martell. (rdm4@martellventures.com) yading@11: * yading@11: * This file is part of FFmpeg. yading@11: * yading@11: * FFmpeg is free software; you can redistribute it and/or yading@11: * modify it under the terms of the GNU Lesser General Public yading@11: * License as published by the Free Software Foundation; either yading@11: * version 2.1 of the License, or (at your option) any later version. yading@11: * yading@11: * FFmpeg is distributed in the hope that it will be useful, yading@11: * but WITHOUT ANY WARRANTY; without even the implied warranty of yading@11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yading@11: * Lesser General Public License for more details. yading@11: * yading@11: * You should have received a copy of the GNU Lesser General Public yading@11: * License along with FFmpeg; if not, write to the Free Software yading@11: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA yading@11: */ yading@11: yading@11: #ifndef AVUTIL_BASE64_H yading@11: #define AVUTIL_BASE64_H yading@11: yading@11: #include yading@11: yading@11: /** yading@11: * @defgroup lavu_base64 Base64 yading@11: * @ingroup lavu_crypto yading@11: * @{ yading@11: */ yading@11: yading@11: yading@11: /** yading@11: * Decode a base64-encoded string. yading@11: * yading@11: * @param out buffer for decoded data yading@11: * @param in null-terminated input string yading@11: * @param out_size size in bytes of the out buffer, must be at yading@11: * least 3/4 of the length of in yading@11: * @return number of bytes written, or a negative value in case of yading@11: * invalid input yading@11: */ yading@11: int av_base64_decode(uint8_t *out, const char *in, int out_size); yading@11: yading@11: /** yading@11: * Encode data to base64 and null-terminate. yading@11: * yading@11: * @param out buffer for encoded data yading@11: * @param out_size size in bytes of the out buffer (including the yading@11: * null terminator), must be at least AV_BASE64_SIZE(in_size) yading@11: * @param in input buffer containing the data to encode yading@11: * @param in_size size in bytes of the in buffer yading@11: * @return out or NULL in case of error yading@11: */ yading@11: char *av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size); yading@11: yading@11: /** yading@11: * Calculate the output size needed to base64-encode x bytes to a yading@11: * null-terminated string. yading@11: */ yading@11: #define AV_BASE64_SIZE(x) (((x)+2) / 3 * 4 + 1) yading@11: yading@11: /** yading@11: * @} yading@11: */ yading@11: yading@11: #endif /* AVUTIL_BASE64_H */