~ubuntu-branches/ubuntu/jaunty/xvidcap/jaunty-proposed

« back to all changes in this revision

Viewing changes to ffmpeg/libavutil/base64.c

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc, Andrew Starr-Bochicchio, Lionel Le Folgoc
  • Date: 2008-12-26 00:10:06 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20081226001006-2040ls9680bd1blt
Tags: 1.1.7-0.2ubuntu1
[ Andrew Starr-Bochicchio ]
* Merge from debian-multimedia (LP: #298547), Ubuntu Changes:
 - For ffmpeg-related build-deps, fix versionized dependencies
   as the ubuntu versioning is different than debian-multimedia's.

[ Lionel Le Folgoc ]
* LP: #311412 is fixed since the 1.1.7~rc1-0.1 revision.
* debian/patches/03_ffmpeg.diff: updated to fix FTBFS due to libswscale API
  change (cherry-pick from Gentoo #234383).

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include "base64.h"
30
30
 
31
31
/* ---------------- private code */
32
 
static uint8_t map2[] =
 
32
static const uint8_t map2[] =
33
33
{
34
34
    0x3e, 0xff, 0xff, 0xff, 0x3f, 0x34, 0x35, 0x36,
35
35
    0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0xff,
70
70
* fixed edge cases and made it work from data (vs. strings) by ryan.
71
71
*****************************************************************************/
72
72
 
73
 
char *av_base64_encode(uint8_t * src, int len)
 
73
char *av_base64_encode(char * buf, int buf_len, const uint8_t * src, int len)
74
74
{
75
75
    static const char b64[] =
76
76
        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
79
79
    int i_shift = 0;
80
80
    int bytes_remaining = len;
81
81
 
82
 
    if (len < UINT_MAX / 4) {
83
 
        ret = dst = av_malloc(len * 4 / 3 + 12);
84
 
    } else
 
82
    if (len >= UINT_MAX / 4 ||
 
83
        buf_len < len * 4 / 3 + 12)
85
84
        return NULL;
86
 
 
87
 
    if (len) {                  // special edge case, what should we really do here?
88
 
        while (bytes_remaining) {
89
 
            i_bits = (i_bits << 8) + *src++;
90
 
            bytes_remaining--;
91
 
            i_shift += 8;
92
 
 
93
 
            do {
94
 
                *dst++ = b64[(i_bits << 6 >> i_shift) & 0x3f];
95
 
                i_shift -= 6;
96
 
            } while (i_shift > 6 || (bytes_remaining == 0 && i_shift > 0));
97
 
        }
98
 
        while ((dst - ret) & 3)
99
 
            *dst++ = '=';
 
85
    ret = dst = buf;
 
86
    while (bytes_remaining) {
 
87
        i_bits = (i_bits << 8) + *src++;
 
88
        bytes_remaining--;
 
89
        i_shift += 8;
 
90
 
 
91
        do {
 
92
            *dst++ = b64[(i_bits << 6 >> i_shift) & 0x3f];
 
93
            i_shift -= 6;
 
94
        } while (i_shift > 6 || (bytes_remaining == 0 && i_shift > 0));
100
95
    }
 
96
    while ((dst - ret) & 3)
 
97
        *dst++ = '=';
101
98
    *dst = '\0';
102
99
 
103
100
    return ret;