comparison utils.c @ 3789:aa89bbf3fa48 libavformat

Change implementation for ff_data_to_hex(), this is faster. See discussion on mailinglist in "Realmedia patch" thread.
author rbultje
date Thu, 28 Aug 2008 12:00:58 +0000
parents ca6df1ecb412
children 6a1d266be2fc
comparison
equal deleted inserted replaced
3788:ca6df1ecb412 3789:aa89bbf3fa48
3211 av_strlcpy(hostname, p, 3211 av_strlcpy(hostname, p,
3212 FFMIN(ls + 1 - p, hostname_size)); 3212 FFMIN(ls + 1 - p, hostname_size));
3213 } 3213 }
3214 } 3214 }
3215 3215
3216 static void digit_to_char(char *dst, uint8_t src)
3217 {
3218 if (src < 10) {
3219 *dst = '0' + src;
3220 } else {
3221 *dst = 'A' + src - 10;
3222 }
3223 }
3224
3225 char *ff_data_to_hex(char *buff, const uint8_t *src, int s) 3216 char *ff_data_to_hex(char *buff, const uint8_t *src, int s)
3226 { 3217 {
3227 int i; 3218 int i;
3219 static const char hex_table[16] = { '0', '1', '2', '3',
3220 '4', '5', '6', '7',
3221 '8', '9', 'A', 'B',
3222 'C', 'D', 'E', 'F' };
3228 3223
3229 for(i = 0; i < s; i++) { 3224 for(i = 0; i < s; i++) {
3230 digit_to_char(buff + 2 * i, src[i] >> 4); 3225 buff[i * 2] = hex_table[src[i] >> 4];
3231 digit_to_char(buff + 2 * i + 1, src[i] & 0xF); 3226 buff[i * 2 + 1] = hex_table[src[i] & 0xF];
3232 } 3227 }
3233 3228
3234 return buff; 3229 return buff;
3235 } 3230 }
3236 3231