Signed-off-by: Nicolas George <geo...@nsup.org>
---
 libavutil/opt.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 41284d4ecd..c7844d6241 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -167,16 +167,6 @@ static int write_number(void *obj, const AVOption *o, void 
*dst, double num, int
     return 0;
 }
 
-static int hexchar2int(char c) {
-    if (c >= '0' && c <= '9')
-        return c - '0';
-    if (c >= 'a' && c <= 'f')
-        return c - 'a' + 10;
-    if (c >= 'A' && c <= 'F')
-        return c - 'A' + 10;
-    return -1;
-}
-
 static int set_string_binary(void *obj, const AVOption *o, const char *val, 
uint8_t **dst)
 {
     int *lendst = (int *)(dst + 1);
@@ -197,13 +187,13 @@ static int set_string_binary(void *obj, const AVOption 
*o, const char *val, uint
     if (!ptr)
         return AVERROR(ENOMEM);
     while (*val) {
-        int a = hexchar2int(*val++);
-        int b = hexchar2int(*val++);
-        if (a < 0 || b < 0) {
+        int a = ff_hexpair2int(val);
+        if (a < 0) {
             av_free(bin);
             return AVERROR(EINVAL);
         }
-        *ptr++ = (a << 4) | b;
+        *ptr++ = a;
+        val += 2;
     }
     *dst    = bin;
     *lendst = len;
-- 
2.30.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to