@@ -191,17 +191,19 @@ static const ColorEntry color_table[] = {
{ "YellowGreen", 0xFF9ACD32 }
};
-static unsigned hex_char_to_number(uint8_t x)
+static unsigned int hex_char_to_number(uint8_t x)
{
- if (x >= 'a' && x <= 'f')
- x -= 'a' - 10;
- else if (x >= 'A' && x <= 'F')
- x -= 'A' - 10;
- else if (x >= '0' && x <= '9')
- x -= '0';
- else
- x = 0;
- return x;
+ int ret = 0;
+
+ if (x <= '9') {
+ if (x >= '0')
+ ret = x - '0';
+ } else if (x >= 'a') {
+ if (x <= 'f')
+ ret = x - ('a' - 10);
+ } else if (x >= 'A' && x <= 'F')
+ ret = x - ('A' - 10);
+ return ret;
}
/*
Search for 0 to 9 first as this is 10/16th of possible choices we want, then search for lowercase 6/16th, or uppercase 6/16th possible choices. This gives us a minor speed increase similar to xbmdec.c nibble search. Some modern compilers complain if using "unsigned" without using "int". Signed-off-by: Jose Da Silva <digital@joescat.com> --- libavcodec/xpmdec.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) -- 2.30.1