From patchwork Tue Jul 27 14:48:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 29063 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp4919589pxb; Tue, 27 Jul 2021 07:48:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYMvej0L83SoTh1xgeKKE6STJgH/r+iEJfonqrXiM/JBSwB3bMyOEL5ESVXUf35PTftZWp X-Received: by 2002:a17:907:94c6:: with SMTP id dn6mr11769564ejc.287.1627397333220; Tue, 27 Jul 2021 07:48:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627397333; cv=none; d=google.com; s=arc-20160816; b=dlabgqWUkT20yskc89dsM0hRTHZ43puUoM0w1nA2+0Va+JOALmACx5RUoY0RL+p6L8 x6QzdxcuXmUXNx+rZsBWJILXWkVENEeMFGRslG4OVF6i13daseURFIRzhxPv0Sw65pyz UYtdRK76tth+aGEVYG+haYNziYYT7TB8ekkHYbikXryUqTp6lxuzN3gD6CylWK7qTYgD OJCmGY8QJ/aR+rGKKjerHYonFAUGvgxjOWNiekFfq3OGHmr45SqghJRLyMD5a7lX0/B8 bX9WpxkQBqLnIc5puJ+zNFn0CpqVOBIwze4IdCwB+OBAA8NIU434IAxRjcewT9LNx/Ub Tiqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=YjUYSe/ZY2F2Cus/VDM2n9KPSsGrEPmyeOS/+baW7Pg=; b=zOa+FHtYtaTeQAwxSLAlcADkvBi6AcF3j1GflsfGLhHBCsllN8DMBTrAuuR1SAHot4 JAj+B7+UH/6eMkGNMDclUO4/C21SfTcdfCxWj8jv9T+2aUkon08SYoELBjBLpv/n/xvC zPSScvmp09t/2YfMHSThpLdOU/0j0S6RUDCL6C0vOj8TpMI0p/JIdFuiwyMYbOECYbeD tINPUBHhhOZjwa+d6151p3z/ToOvlOIAey/aBXMz+wY9VsFg9jqxkYhnyd1UsQ/Zmz1S d4h5tYc7k9gBb5mo2yHOK8qDBAU5CKlZIueQDV228Dh1TajpIrhEWfC1Sy4W7zLhBFr6 msIQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h17si3164707edb.607.2021.07.27.07.48.52; Tue, 27 Jul 2021 07:48:53 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D395168A009; Tue, 27 Jul 2021 17:48:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B9D99689BC9 for ; Tue, 27 Jul 2021 17:48:17 +0300 (EEST) X-ENS-nef-client: 129.199.129.80 ( name = phare.normalesup.org ) Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef.ens.fr (8.14.4/1.01.28121999) with ESMTP id 16REmGEo026196 for ; Tue, 27 Jul 2021 16:48:17 +0200 Received: by phare.normalesup.org (Postfix, from userid 1001) id E86E1E0027; Tue, 27 Jul 2021 16:48:16 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Tue, 27 Jul 2021 16:48:05 +0200 Message-Id: <20210727144813.452917-3-george@nsup.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210727144813.452917-1-george@nsup.org> References: <20210727144813.452917-1-george@nsup.org> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Tue, 27 Jul 2021 16:48:17 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 02/10] lavu/opt: use ff_hexpair2int(). X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: aNR/rlc3BeNN Signed-off-by: Nicolas George --- 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;