From patchwork Mon Nov 11 07:56:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 52678 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:650d:10b0:4a6:526f:395 with SMTP id ml13-n1csp124484vqb; Sun, 10 Nov 2024 23:58:11 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXLumdqNeIqw8Hlhtu/cyqW1jNMI3sxXQfXj0VTCVPlyE060dGZNU4jFROy292tUjEq7ZQzdOjGx98/xB2Qs4WD@gmail.com X-Google-Smtp-Source: AGHT+IHqObCIT4ZhJEsqSHDlK7H5SO7Uqm8Q9aQSOjkMNiFAJEWqgNjBWc9ke04X8kpaahfTWQsg X-Received: by 2002:a05:6402:4406:b0:5cb:dd06:90d5 with SMTP id 4fb4d7f45d1cf-5cf0a44177bmr8954281a12.26.1731311891350; Sun, 10 Nov 2024 23:58:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731311891; cv=none; d=google.com; s=arc-20240605; b=MPaHuZwKs1jdOJ7aPlOckdH72IrqGMIdtgVa+LUtaZXDrUJFdNxFrwg1hk6abdCCGy 8oV1ptbbzwrz671TtSxX2xX+oOsW7t7Rb6fR0eRuP0D2WHeCndQWGXoMSCPu8SbU0VEM hdlX7u6plc3UoD6jYd4wKccLObX3VlHP8XscozL0o2PuT/jaonA4Evq/wZ0fTnQma0A2 meuudya7/Qd837oRZsK5XnZEUVmG8I1rihjiHzkxVWwYv64JLtmbabJ5+NGnG2gnZJHB zLz8XX+0joPH+I7jKCX9QovxiCDriti+GwtgQLBxv6iuHtCbr7af7s4QBlbfBfMnv4vi YZcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:cc: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=oHk+wD4BIvl4TW24bQmDbSHjy7Nn5s+Iv15hka90AwY=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=MFlLTW+EFcwCpk90M+r1MLlxj3K7x3rKSrWhwa95sin4w2uP1f1Cqmvf579Nys53iS mSVnm+SYXe2aI6pwG77VyjQa5BJ/BuLnLTo+LHyQ9Rr0Wr1mrF8+LAEpIm7t81+6l7e+ h/KrwmcFTC4ACrc9bcu3ogWCzW7qIP9LBYchbzf/xG/mMqa1P49V560vtjNE7vVspw5Q oXyB2oJrAM7GToY+dZB2WdBy5nLSK7MZI51LfeNWwV4KjPpBU5Qn64vTh5AUDtr2q1jP 352nlJRyv6OztSWNaiqcjvsAL/kU7+9vm0Yb7hXGyNXo6coYTtOFJbID/4uxsDmCoOGA JkYw==; dara=google.com 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 ESMTPS id 4fb4d7f45d1cf-5cf03bb4601si6132052a12.136.2024.11.10.23.58.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 23:58:11 -0800 (PST) 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 4E1F268DC37; Mon, 11 Nov 2024 09:57:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 82EDD68DC37 for ; Mon, 11 Nov 2024 09:57:35 +0200 (EET) Received: from haasn.dev (unknown [10.30.1.1]) by haasn.dev (Postfix) with ESMTP id 3AA8241A4B; Mon, 11 Nov 2024 08:57:35 +0100 (CET) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Mon, 11 Nov 2024 08:56:06 +0100 Message-ID: <20241111075733.14603-3-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241111075733.14603-1-ffmpeg@haasn.xyz> References: <20241111075733.14603-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v5 02/12] swscale/internal: use static_assert for enforcing offsets 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 Cc: Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: V2hEO+MC5gnz From: Niklas Haas Instead of sprinkling av_assert0 into random init functions. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas --- libswscale/swscale_internal.h | 11 +++++++++++ libswscale/utils.c | 2 -- libswscale/x86/swscale.c | 4 ---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index 0035168997..0ab4e67270 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -22,6 +22,7 @@ #define SWSCALE_SWSCALE_INTERNAL_H #include +#include #include "config.h" #include "swscale.h" @@ -705,6 +706,16 @@ struct SwsInternal { }; //FIXME check init (where 0) +static_assert(offsetof(SwsInternal, redDither) + DITHER32_INT == offsetof(SwsInternal, dither32), + "dither32 must be at the same offset as redDither + DITHER32_INT"); + +#if ARCH_X86_64 +/* x86 yuv2gbrp uses the SwsInternal for yuv coefficients + if struct offsets change the asm needs to be updated too */ +static_assert(offsetof(SwsInternal, yuv2rgb_y_offset) == 40292, + "yuv2rgb_y_offset must be updated in x86 asm"); +#endif + SwsFunc ff_yuv2rgb_get_func_ptr(SwsInternal *c); int ff_yuv2rgb_c_init_tables(SwsInternal *c, const int inv_table[4], int fullRange, int brightness, diff --git a/libswscale/utils.c b/libswscale/utils.c index 5c21f9de4a..f71c63c17f 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1228,8 +1228,6 @@ SwsContext *sws_alloc_context(void) { SwsInternal *c = av_mallocz(sizeof(SwsInternal)); - av_assert0(offsetof(SwsInternal, redDither) + DITHER32_INT == offsetof(SwsInternal, dither32)); - if (c) { c->av_class = &ff_sws_context_class; av_opt_set_defaults(c); diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c index ceafdf4aef..40bfe4a2f6 100644 --- a/libswscale/x86/swscale.c +++ b/libswscale/x86/swscale.c @@ -791,10 +791,6 @@ switch(c->dstBpc){ \ if(c->flags & SWS_FULL_CHR_H_INT) { - /* yuv2gbrp uses the SwsInternal for yuv coefficients - if struct offsets change the asm needs to be updated too */ - av_assert0(offsetof(SwsInternal, yuv2rgb_y_offset) == 40292); - #define YUV2ANYX_FUNC_CASE(fmt, name, opt) \ case fmt: \ c->yuv2anyX = ff_yuv2##name##_full_X_##opt; \