diff options
author | Ronald S. Bultje <rsbultje@gmail.com> | 2008-08-28 12:00:58 +0000 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2008-08-28 12:00:58 +0000 |
commit | 452d3edb376fc205f8251e7c9ca443b6d881f24f (patch) | |
tree | c3573a54ec19ea8b5a497b69c4555971095d4120 | |
parent | a169f49881fb9ce7cd55fdb654fb4b3057f8ddad (diff) | |
download | ffmpeg-452d3edb376fc205f8251e7c9ca443b6d881f24f.tar.gz |
Change implementation for ff_data_to_hex(), this is faster. See discussion on
mailinglist in "Realmedia patch" thread.
Originally committed as revision 15006 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavformat/utils.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index b61535af8d..91b105f3e1 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3213,22 +3213,17 @@ void url_split(char *proto, int proto_size, } } -static void digit_to_char(char *dst, uint8_t src) -{ - if (src < 10) { - *dst = '0' + src; - } else { - *dst = 'A' + src - 10; - } -} - char *ff_data_to_hex(char *buff, const uint8_t *src, int s) { int i; + static const char hex_table[16] = { '0', '1', '2', '3', + '4', '5', '6', '7', + '8', '9', 'A', 'B', + 'C', 'D', 'E', 'F' }; for(i = 0; i < s; i++) { - digit_to_char(buff + 2 * i, src[i] >> 4); - digit_to_char(buff + 2 * i + 1, src[i] & 0xF); + buff[i * 2] = hex_table[src[i] >> 4]; + buff[i * 2 + 1] = hex_table[src[i] & 0xF]; } return buff; |