From patchwork Thu Oct 24 10:25:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 52465 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:1c41:b0:48e:c0f8:d0de with SMTP id im1csp231038vqb; Thu, 24 Oct 2024 03:28:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWOMArd96cH8Djk80QJrNa/Tgkag66u2a4pGDLnUqQH533fQgPoorcMR4BmxxZigHz2hqrcOJOLzYGR5tzQAO4k@gmail.com X-Google-Smtp-Source: AGHT+IFnf02aDgjayH/sWlJY/lSj/C55GoUli7Ap41cpi63GJwCUfsrGKMkrTZTQ2nK9zGZXZ0/P X-Received: by 2002:a05:6512:31c5:b0:536:a275:9d58 with SMTP id 2adb3069b0e04-53b1a3a9e81mr1028682e87.7.1729765707308; Thu, 24 Oct 2024 03:28:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729765707; cv=none; d=google.com; s=arc-20240605; b=PMxUrxb1HxcBIRVaCe0xI/bGhcHGMxPzBtnVWOmMb/mxS+wJWzdVz3GO81dTwgB7md 4JGhhRS62Fp8yCvO9dUGwabGrCH645RuzkeF5XlvTYCs4T1nMa3pNf/V30gO3gtkjtL6 Gp0w3vrtlxiMiDxQb/+XRGNwJa3KmBGxUdHYktlhnvOulyeqTt8wifBkzupktw7KIULi 6sfifWTqWkVkY+LsDxdZxhYod/KwnUIB5VFeRz6HvXK7rz2B0U4u7eJtVfA0A5rz+Ei9 wOyvXAJ/0HlS1emPxfTbphm88KjjdFZ8gl+Z8DrKhBQqD1s7m+2TezL0gTy9kRox6VD5 0OyA== 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=mdiDSemHkAwsQieXkhLjWMdVTk/Y1aghW7GZfg3Y0j8=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=fQVUMFzkmFoZ2UP7TeuTgo3Qp6UW9FyFRBtitLOPEQ+ZKJ/+9qmX5uSIXIU44UTTGp EA5UA5GPYAB1h77Wv69BkHViXExzTogcqMK3TPaHUhOWkz4EfWUo0rAmcBGOpsTVW9k+ RGeS3Vqk180D8tA8NCV6tV0l7eBuC/h3/ctXoU+t8vpAUnuyG/jV1DcEcQ9s2b13TKQN pAPFyY1h5ONJPCXzVAtEMru7vvOcGWgOwGUzilc6uaPkTnrJ2DVhmFD+MNJaCFIYMQVp +y7OLPjgp+bpwkI0oCjkng6RUqSB9lWvfr8hBMX9y+mU5EfOkeSwmKsvUg/QlwoHKceA CFtg==; 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="R9vpc/gw"; 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 2adb3069b0e04-53a224264d3si3220546e87.294.2024.10.24.03.28.26; Thu, 24 Oct 2024 03:28:27 -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="R9vpc/gw"; 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 7041D68DD2B; Thu, 24 Oct 2024 13:27:55 +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 264C468DBC1 for ; Thu, 24 Oct 2024 13:27:43 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1729765662; bh=uX/0ldnqJUEN6lFLXRzYeNUmycqvJwxnTtctzMspr94=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R9vpc/gwV6NRQmOYWOmqFehmLagVehuAaPtNYGk1tdamMM3FEqe8wJcQTqQSDSnc2 bFxBSRINw6fs3LttnEXUh3PQwUnIM78JvhxWEuw2InH5Ui+6DPON209RHEEaaJ661T 90OyqjgrlLYNjKg9oEd+mmLhVGq3gYBWVn5ht/6w= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id D552D434F7; Thu, 24 Oct 2024 12:27:42 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Thu, 24 Oct 2024 12:25:13 +0200 Message-ID: <20241024102737.792421-4-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241024102737.792421-1-ffmpeg@haasn.xyz> References: <20241024102737.792421-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 03/13] 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: PY/8nse253bO 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 b8820ea0ba..6b85ecadae 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 31c136ad15..87591bdabd 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1234,8 +1234,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; \