[FFmpeg-cvslog] avcodec/xpmdec: avoid "magic" numbers in function hex_char_to_number()

Paul B Mahol git at videolan.org
Mon Mar 13 00:09:04 EET 2017


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sun Mar 12 22:58:49 2017 +0100| [58f0bbc1eafbe21197bc53ad263005093182a7f2] | committer: Paul B Mahol

avcodec/xpmdec: avoid "magic" numbers in function hex_char_to_number()

Signed-off-by: Paul B Mahol <onemda at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=58f0bbc1eafbe21197bc53ad263005093182a7f2
---

 libavcodec/xpmdec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/xpmdec.c b/libavcodec/xpmdec.c
index b9b2551..605a09d 100644
--- a/libavcodec/xpmdec.c
+++ b/libavcodec/xpmdec.c
@@ -188,9 +188,9 @@ static const ColorEntry color_table[] = {
 static unsigned hex_char_to_number(uint8_t x)
 {
     if (x >= 'a' && x <= 'f')
-        x -= 87;
+        x -= 'a' - 10;
     else if (x >= 'A' && x <= 'F')
-        x -= 55;
+        x -= 'A' - 10;
     else if (x >= '0' && x <= '9')
         x -= '0';
     else



More information about the ffmpeg-cvslog mailing list