From patchwork Sat Jan 23 22:10:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 25138 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 2BDC744B4C2 for ; Sun, 24 Jan 2021 00:17:12 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 098DB68828E; Sun, 24 Jan 2021 00:17:12 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe05-3.mx.upcmail.net (vie01a-dmta-pe05-3.mx.upcmail.net [84.116.36.13]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 03F11688181 for ; Sun, 24 Jan 2021 00:17:05 +0200 (EET) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe05.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1l3R8P-0007MR-0H for ffmpeg-devel@ffmpeg.org; Sat, 23 Jan 2021 23:11:57 +0100 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id 3R7Qlm4fbO4rA3R7QlR7oE; Sat, 23 Jan 2021 23:10:57 +0100 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.68.29 X-CNFS-Analysis: v=2.3 cv=RNDN4Lq+ c=1 sm=1 tr=0 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=vD-G9YIW_5hhpURQb6QA:9 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 23 Jan 2021 23:10:51 +0100 Message-Id: <20210123221056.3366-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-CMAE-Envelope: MS4wfFau8UxwSBrXbltNpx+EZBqrsbOxxFPto6CJqQVCqMuAxY6TNvApOJBW3UXoFxGcSlbtqo8PYz/Loy/5g5XauwRFYpUENCT8iCbdWUTuKNHayLJf2F7D CUmR+hWplJf3zyXj70oS4cqK7uje4UkPHoB63+HM75SAO46IkX7QvgOd Subject: [FFmpeg-devel] [PATCH 1/6] avutil/common: Add FFABSU() for a signed -> unsigned ABS X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Michael Niedermayer --- libavutil/common.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavutil/common.h b/libavutil/common.h index b9fbcc4d60..a60a558b1d 100644 --- a/libavutil/common.h +++ b/libavutil/common.h @@ -80,6 +80,14 @@ */ #define FFNABS(a) ((a) <= 0 ? (a) : (-(a))) +/** + * Unsigned Absolute value. + * This takes the absolute value of a signed int and returns it as a unsigned. + * This also works with INT_MIN which would otherwise not be representable + * As with many macros, this evaluates its argument twice. + */ +#define FFABSU(a) ((a) <= 0 ? -(unsigned)(a) : (unsigned)(a)) + /** * Comparator. * For two numerical expressions x and y, gives 1 if x > y, -1 if x < y, and 0