From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 7C6E3432B6 for ; Fri, 26 Aug 2022 19:31:08 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 194ED68B9B5; Fri, 26 Aug 2022 22:31:06 +0300 (EEST) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D901F68B84E for ; Fri, 26 Aug 2022 22:30:59 +0300 (EEST) Received: by mail-lf1-f47.google.com with SMTP id m3so3207866lfg.10 for ; Fri, 26 Aug 2022 12:30:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc; bh=CCzJ/W5QuQBYU0xeS9VEiVzb521qpiQ4TeVJteTEUNg=; b=SU+5YzX/ia2ef6WdSXKqzGDtNERJITKIa9MVCEJWXCySws/b+RDpt3pIeVyLpS8wpM cASvh5NI81N80f/PVyGG4TbCAUB9mIXWYYwn6PWTB/4zDcGKjSs0R76mOoXA1V4Lqa9n M8mEIMKMiF44vnxWRs73YsI8Pj/sM8lnoicI+WnwTZqV5diRIzptc3Q28AQx6TmClMlb fjlB715wn9MMmA70kcPfe3dMqKOiBTP8pW2pOwCLnd+/FMN4ds6HBVv9JyRt1+4M5+qV MxwUTNjJXcXTHdmq41eiTx1UUBhHVDfXW08qkSq4J4SmA4EOxY5KOVTi71vHCvqByZ9a M0Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=CCzJ/W5QuQBYU0xeS9VEiVzb521qpiQ4TeVJteTEUNg=; b=3Sz5wwcg6PzSRbf4v0O6YCzBvKpN0a7tIbUzIKaiKf/xtG3t2j+lMwMnzC3sB7NFTd CEgWWI5PARveuPHuHHT5MfqmgdHrX0IXARzJLR9h+Sy7KXVt1nGyouFq7Fwkpw+Nsv5Q wW70dVreXnswJbXy1Yzh3TXymtpCGNOp+IrILM9aV1SF+eCn4E683Ld2nxATDJClF80v CX/XgZMkB6yQiKsTSp7WLXfGZi6ILYThMkt2itF+1CaU2oLLdZFq1NVQQxAwxMkuMNrI FTi7a3UO4Sh43znaQY+UIFKRSi2185LU0d2dRaU4sO/pCbemfA+zliw+elJGbZzg+kzV 5ndQ== X-Gm-Message-State: ACgBeo1EYGcKFcfrjGC2oeZEeH/IJAQNbUprZw8deWIDyA3MsFPkJuc3 dE4Q4ivX4yCPBG+yBXDFiTvSJWZhZYEdZKq5 X-Google-Smtp-Source: AA6agR75OsXhnAg0lpsKbnQeC1fWGvJBs1ph2LolDRrigJ97uLn7xQoXl+7Y51xHAW26J+Kwhu0rXg== X-Received: by 2002:a05:6512:3e2a:b0:492:dc16:a743 with SMTP id i42-20020a0565123e2a00b00492dc16a743mr2781222lfv.280.1661542258554; Fri, 26 Aug 2022 12:30:58 -0700 (PDT) Received: from localhost.localdomain (dsl-tkubng21-58c01c-243.dhcp.inet.fi. [88.192.28.243]) by smtp.gmail.com with ESMTPSA id 22-20020ac25f56000000b0048b18700dddsm458385lfz.106.2022.08.26.12.30.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 12:30:57 -0700 (PDT) From: =?UTF-8?q?Martin=20Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 26 Aug 2022 22:30:57 +0300 Message-Id: <20220826193057.3016569-1-martin@martin.st> X-Mailer: git-send-email 2.25.1 In-Reply-To: <2756bf93-56c9-fbca-2683-620e4d172e5c@gmail.com> References: <2756bf93-56c9-fbca-2683-620e4d172e5c@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] arm: Check the build time constants in av_clip_*intp2 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: This fixes building for arm targets with optimizations disabled. --- libavutil/arm/intmath.h | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/libavutil/arm/intmath.h b/libavutil/arm/intmath.h index 5311a7d52b..f19b21e98d 100644 --- a/libavutil/arm/intmath.h +++ b/libavutil/arm/intmath.h @@ -65,17 +65,29 @@ static av_always_inline av_const int av_clip_int16_arm(int a) #define av_clip_intp2 av_clip_intp2_arm static av_always_inline av_const int av_clip_intp2_arm(int a, int p) { - unsigned x; - __asm__ ("ssat %0, %2, %1" : "=r"(x) : "r"(a), "i"(p+1)); - return x; + if (av_builtin_constant_p(p)) { + unsigned x; + __asm__ ("ssat %0, %2, %1" : "=r"(x) : "r"(a), "i"(p+1)); + return x; + } else { + if (((unsigned)a + (1 << p)) & ~((2 << p) - 1)) + return (a >> 31) ^ ((1 << p) - 1); + else + return a; + } } #define av_clip_uintp2 av_clip_uintp2_arm static av_always_inline av_const unsigned av_clip_uintp2_arm(int a, int p) { - unsigned x; - __asm__ ("usat %0, %2, %1" : "=r"(x) : "r"(a), "i"(p)); - return x; + if (av_builtin_constant_p(p)) { + unsigned x; + __asm__ ("usat %0, %2, %1" : "=r"(x) : "r"(a), "i"(p)); + return x; + } else { + if (a & ~((1<> 31 & ((1<