From patchwork Thu Feb 4 16:08:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 25390 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 B4B0544BBCE for ; Thu, 4 Feb 2021 18:09:17 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9C437689CFA; Thu, 4 Feb 2021 18:09:17 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6AA75689D16 for ; Thu, 4 Feb 2021 18:09:11 +0200 (EET) Received: by mail-ed1-f41.google.com with SMTP id i5so4787149edu.10 for ; Thu, 04 Feb 2021 08:09:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Owt+R+sdrmsuHWUp848rJXuBgPgJKjOuw1FC9Qm620w=; b=R5tAf7npbmWE6+RHrwOYUNEYRkNgAzvG62xcXyU5xosK2rxW5zFLe9sDJPG164JzfU 1iHMtbfbFVYiCdeYy+mQdtqa3p3v0vzuEkCa7JULgK2Xiqd8j6b5hPguvivhhvz57Zg7 URtjDHIZLGuyIqSKiXsJNhvl7EPw2VAocHGNwbMTN3BYorQnm0LKazBrg64DhhkMmn57 pdGyciXx1ulF7BzLy3g+wKU2A4CvPi50wOZB9a9KCMxNTKpt7yCRhaCoIqPC6tmGrL29 YBLQNONHxAKey+WWGsGgTeE5leVcciTjy0tFfD9lCjraZgePvI96IL/shyYpyG52Quhw 2ugQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Owt+R+sdrmsuHWUp848rJXuBgPgJKjOuw1FC9Qm620w=; b=HAaOytfEQCyxSVo8tS0exPGri9TG+LVUvEkE/boC1fDuMQXVMG0JwfBubu+d1xxnG3 wx+czQWtZHvme5+yU9eilP7Jx1A+VuQpVstcqt9rid13zrTwcHWUXcfMtjOC27CE9MGL 21Tnb+oQs+hhqP/bll3a2nP2GEDDDFmypUAvLRCTbKkpHyMZROlA/3eb0aVfBC6fyqz+ x4te93kTZnVjCa6jTKWjdl+JkW2LjKhmGBKfiqHSxLAveBZ37aLGrMxW2Blbd7SMmjxk oZcE85iVtq8rQaPJj+2605tWZurXOOCEXW0oiTlA7TK3lcMCRoDMrl3L7icsQdb3WdtT Svhg== X-Gm-Message-State: AOAM533nO+nVG9f9f5msQQK+kbrTkyS6b+sDUXnreaA+/zND5CNHL2nX VzTI/iAhkzPEL31wiAuTenR8p+8LwwI= X-Google-Smtp-Source: ABdhPJynYABZVbvlx8W9JoH0OgYJxoYqfsZC2d+HdrzEVM76kYOXHEyn83BappA47fN7OD+QW5sLAQ== X-Received: by 2002:aa7:d2d2:: with SMTP id k18mr8701791edr.222.1612454950648; Thu, 04 Feb 2021 08:09:10 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id h25sm2659710ejy.7.2021.02.04.08.09.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 08:09:10 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Feb 2021 17:08:29 +0100 Message-Id: <20210204160829.1214634-4-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210204160829.1214634-1-andreas.rheinhardt@gmail.com> References: <20210204160829.1214634-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] avutil/common: Move everything inside inclusion guards 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" libavutil/common.h is a public header that provides generic math functions whereas libavutil/intmath.h is a private header that contains plattform-specific optimized versions of said math functions. common.h includes intmath.h (when building the FFmpeg libraries) so that the optimized versions are used for them. This interdependency sometimes causes trouble: intmath.h once contained an inlined ff_sqrt function that relied upon av_log2_16bit. In case there was no optimized logarithm available on this plattform, intmath.h needed to include common.h to get the generic implementation and this has been done after the optimized versions (if any) have been provided so that common.h used the optimized versions; it also needed to be done before ff_sqrt. Yet when intmath.h was included from common.h and if an ordinary inclusion guard was used by common.h, the #include "common.h" in intmath.h was a no-op and therefore av_log2_16bit was still unknown at the end of intmath.h (and also in ff_sqrt) if no optimized version was available. Before a955b5965825631986ba854d007d4e934e466c7d this was solved by duplicating the #ifndef av_log2_16bit check after the inclusion of common.h in intmath.h; said commit instead moved these checks to the end of common.h, outside the inclusion guards and made common.h include itself to get these unguarded defines. This is still the current state of affairs. Yet this is unnecessary since 9734b8ba56d05e970c353dfd5baafa43fdb08024 as said commit removed ff_sqrt as well as the #include "common.h" from intmath.h. Therefore this commit moves everything inside the inclusion guards and makes common.h not include itself. Signed-off-by: Andreas Rheinhardt --- libavutil/common.h | 140 +++++++++++++++++++++------------------------ 1 file changed, 66 insertions(+), 74 deletions(-) diff --git a/libavutil/common.h b/libavutil/common.h index a60a558b1d..fde90182ee 100644 --- a/libavutil/common.h +++ b/libavutil/common.h @@ -114,8 +114,72 @@ # include "intmath.h" #endif -/* Pull in unguarded fallback defines at the end of this file. */ -#include "common.h" +#ifndef av_ceil_log2 +# define av_ceil_log2 av_ceil_log2_c +#endif +#ifndef av_clip +# define av_clip av_clip_c +#endif +#ifndef av_clip64 +# define av_clip64 av_clip64_c +#endif +#ifndef av_clip_uint8 +# define av_clip_uint8 av_clip_uint8_c +#endif +#ifndef av_clip_int8 +# define av_clip_int8 av_clip_int8_c +#endif +#ifndef av_clip_uint16 +# define av_clip_uint16 av_clip_uint16_c +#endif +#ifndef av_clip_int16 +# define av_clip_int16 av_clip_int16_c +#endif +#ifndef av_clipl_int32 +# define av_clipl_int32 av_clipl_int32_c +#endif +#ifndef av_clip_intp2 +# define av_clip_intp2 av_clip_intp2_c +#endif +#ifndef av_clip_uintp2 +# define av_clip_uintp2 av_clip_uintp2_c +#endif +#ifndef av_mod_uintp2 +# define av_mod_uintp2 av_mod_uintp2_c +#endif +#ifndef av_sat_add32 +# define av_sat_add32 av_sat_add32_c +#endif +#ifndef av_sat_dadd32 +# define av_sat_dadd32 av_sat_dadd32_c +#endif +#ifndef av_sat_sub32 +# define av_sat_sub32 av_sat_sub32_c +#endif +#ifndef av_sat_dsub32 +# define av_sat_dsub32 av_sat_dsub32_c +#endif +#ifndef av_sat_add64 +# define av_sat_add64 av_sat_add64_c +#endif +#ifndef av_sat_sub64 +# define av_sat_sub64 av_sat_sub64_c +#endif +#ifndef av_clipf +# define av_clipf av_clipf_c +#endif +#ifndef av_clipd +# define av_clipd av_clipd_c +#endif +#ifndef av_popcount +# define av_popcount av_popcount_c +#endif +#ifndef av_popcount64 +# define av_popcount64 av_popcount64_c +#endif +#ifndef av_parity +# define av_parity av_parity_c +#endif #ifndef av_log2 av_const int av_log2(unsigned v); @@ -541,75 +605,3 @@ static av_always_inline av_const int av_parity_c(uint32_t v) #endif /* HAVE_AV_CONFIG_H */ #endif /* AVUTIL_COMMON_H */ - -/* - * The following definitions are outside the multiple inclusion guard - * to ensure they are immediately available in intmath.h. - */ - -#ifndef av_ceil_log2 -# define av_ceil_log2 av_ceil_log2_c -#endif -#ifndef av_clip -# define av_clip av_clip_c -#endif -#ifndef av_clip64 -# define av_clip64 av_clip64_c -#endif -#ifndef av_clip_uint8 -# define av_clip_uint8 av_clip_uint8_c -#endif -#ifndef av_clip_int8 -# define av_clip_int8 av_clip_int8_c -#endif -#ifndef av_clip_uint16 -# define av_clip_uint16 av_clip_uint16_c -#endif -#ifndef av_clip_int16 -# define av_clip_int16 av_clip_int16_c -#endif -#ifndef av_clipl_int32 -# define av_clipl_int32 av_clipl_int32_c -#endif -#ifndef av_clip_intp2 -# define av_clip_intp2 av_clip_intp2_c -#endif -#ifndef av_clip_uintp2 -# define av_clip_uintp2 av_clip_uintp2_c -#endif -#ifndef av_mod_uintp2 -# define av_mod_uintp2 av_mod_uintp2_c -#endif -#ifndef av_sat_add32 -# define av_sat_add32 av_sat_add32_c -#endif -#ifndef av_sat_dadd32 -# define av_sat_dadd32 av_sat_dadd32_c -#endif -#ifndef av_sat_sub32 -# define av_sat_sub32 av_sat_sub32_c -#endif -#ifndef av_sat_dsub32 -# define av_sat_dsub32 av_sat_dsub32_c -#endif -#ifndef av_sat_add64 -# define av_sat_add64 av_sat_add64_c -#endif -#ifndef av_sat_sub64 -# define av_sat_sub64 av_sat_sub64_c -#endif -#ifndef av_clipf -# define av_clipf av_clipf_c -#endif -#ifndef av_clipd -# define av_clipd av_clipd_c -#endif -#ifndef av_popcount -# define av_popcount av_popcount_c -#endif -#ifndef av_popcount64 -# define av_popcount64 av_popcount64_c -#endif -#ifndef av_parity -# define av_parity av_parity_c -#endif