changeset 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 a8a70ae19206
files utils.c
diffstat 1 files changed, 6 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/utils.c	Wed Aug 27 23:43:28 2008 +0000
+++ b/utils.c	Thu Aug 28 12:00:58 2008 +0000
@@ -3213,22 +3213,17 @@
     }
 }
 
-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;