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