From patchwork Sun Oct 20 20:05:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 52414 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:143:b0:48e:c0f8:d0de with SMTP id h3csp2241994vqi; Sun, 20 Oct 2024 13:19:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWFH9fcziobtN4vfo1oH3DfU57ITNmsd8efPUZm3Bqe/fIgLhNVnzB9Udz2Ko4EiXRl9HutWo05pnKVcC/FTON9@gmail.com X-Google-Smtp-Source: AGHT+IG9oCPPA5Q6kHMFK/wJMcrGjNyde7t87gAeQvkzwVCyNK9gniqXXa2p4zH6/yDrSVqQq1yq X-Received: by 2002:a05:600c:3b9c:b0:42c:b9c8:2b95 with SMTP id 5b1f17b1804b1-4316168fec8mr29746045e9.6.1729455551511; Sun, 20 Oct 2024 13:19:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729455551; cv=none; d=google.com; s=arc-20240605; b=T2QxPWxjfqMF/0bAs3gnf+/VSiQCClCGMsuA36P1hl4JnyoXTmzk223UW7/WVBROz6 lABBhWqlQJT2VNp3Ua4xaqa9cPvkrQ6iIBy+068MxbF1IuPdUp9c19ZfX3JQasdwxYqy hnSTL4qVU0yQ/6gqt62Us/CVBK73YtPM26Xmd1IfaQ8I1YS/HFWhLKRw2uevrF5/J3ud /TniATUQfJ3Q1e7zyauLAaW9sSLOv/KqC/NOhjz5k8vtoZ3YAkbTcN+FL3hGss4mIUZr jyufKxctlOoJXSRrMm+JsG4NaN3jMeheVQUx7/7Cn5bTdCBuN2BYE38hxenGFakGQkQb GXVA== 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:dkim-signature:delivered-to; bh=/xuXJjz54IDlApjAgIVqg1B5+Cnm20F43y0eJ08Z/tw=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=NjwvCb7yHXjTDWOE0A1o+PrVRB4ouOGhI04tKA+DMPJGdXOUl1jPPz22+x5Kwl0Zmz wWu4yHSn7AQXbohbm90X7bfoAg7m4Ox/7kPVsvNC59bSrDmnK5XFaBh6+sJrOMqetCee 4cwUhBac7wBJfvygmW1Zg8lWq926oTHZWPTG4V+255j6BvQ2xuhusC4J7bpUwhnf0BrT iuE2HainJtqGFKVjEgarNZ3qS1W9NaTYBOSQV0A7S4HAVV7T3coeTP6KBIKPQOd37rqR LrpMaRSyoGYTkEVjIwNRts0CyCat8omCVVyJI1I8JAxppvmKWrb766pk/qpogrWnvhtu YFzA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=hEeWiYUm; 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 4fb4d7f45d1cf-5cb66e70f59si1550531a12.611.2024.10.20.13.19.11; Sun, 20 Oct 2024 13:19:11 -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; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=hEeWiYUm; 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 B70E568DD86; Sun, 20 Oct 2024 23:09:19 +0300 (EEST) 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 4F54E68DC29 for ; Sun, 20 Oct 2024 23:09:00 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1729454936; bh=ElqGUZhMrwOEStFi9iSCjeHlfoYrBXaCOi+0dWO285Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hEeWiYUmmKnCZy9znig2/Y5WdVGwjoOiCkpLod1lupgZuDgFF1hDKytTeqvvaWKqQ vzIKldoS+k182B6DI2SfmdqFQuycJuhOWWQfJsyf9C9P05FPpkAsQrVMkfJpUgL0Fb HoTrK4YTFdU7VX11pXN5JT5dlTFfXwJXT5shUw10= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 73E994BE87; Sun, 20 Oct 2024 22:08:56 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Sun, 20 Oct 2024 22:05:18 +0200 Message-ID: <20241020200851.1414766-10-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241020200851.1414766-1-ffmpeg@haasn.xyz> References: <20241020200851.1414766-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 09/18] 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: UNh4xSAK11yL 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 1817815b01..5b92c3f72a 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" @@ -704,6 +705,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 5dff3c5476..3ce9a92504 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1233,8 +1233,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 16182124c0..48f0aea3f2 100644 --- a/libswscale/x86/swscale.c +++ b/libswscale/x86/swscale.c @@ -792,10 +792,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; \