summaryrefslogtreecommitdiff
path: root/libavformat/http.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2006-07-18 18:51:35 +0000
committerMichael Niedermayer <michaelni@gmx.at>2006-07-18 18:51:35 +0000
commit7028259a0da450fcff4059df9bc4d4eb542e0f60 (patch)
tree91cdb89e4fb70ff22b62f43f5d1634999d6a774a /libavformat/http.c
parent4b45de0e87fd67bab5f4261006130223304ee7a6 (diff)
simplify b64_encode()
maybe this should be moved to libavutil ... Originally committed as revision 5782 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/http.c')
-rw-r--r--libavformat/http.c32
1 files changed, 9 insertions, 23 deletions
diff --git a/libavformat/http.c b/libavformat/http.c
index cb6ba49e50..48099c35ee 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -285,6 +285,7 @@ URLProtocol http_protocol = {
/*****************************************************************************
* b64_encode: stolen from VLC's http.c
+ * simplified by michael
*****************************************************************************/
static char *b64_encode( const unsigned char *src )
@@ -300,32 +301,17 @@ static char *b64_encode( const unsigned char *src )
}else
return NULL;
- for( ;; )
- {
- if( *src )
- {
- i_bits = ( i_bits << 8 )|( *src++ );
- i_shift += 8;
- }
- else if( i_shift > 0 )
- {
- i_bits <<= 6 - i_shift;
- i_shift = 6;
- }
- else
- {
- *dst++ = '=';
- break;
- }
+ while(*src){
+ i_bits = (i_bits << 8) + *src++;
+ i_shift += 8;
- while( i_shift >= 6 )
- {
+ do{
+ *dst++ = b64[(i_bits << 6 >> i_shift) & 0x3f];
i_shift -= 6;
- *dst++ = b64[(i_bits >> i_shift)&0x3f];
- }
+ }while( i_shift > 6 || (*src == 0 && i_shift>0));
}
-
- *dst++ = '\0';
+ *dst++ = '=';
+ *dst = '\0';
return ret;
}