From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 136804CA5D for ; Tue, 27 May 2025 08:24:43 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 95D9468D481; Tue, 27 May 2025 11:24:39 +0300 (EEST) Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 8E58868C416 for ; Tue, 27 May 2025 11:24:32 +0300 (EEST) Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-54b0d638e86so5103406e87.1 for ; Tue, 27 May 2025 01:24:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20230601.gappssmtp.com; s=20230601; t=1748334271; x=1748939071; darn=ffmpeg.org; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=qaUIvBj9nQ655MlUlx3gsq431C/UZxGa9WSBb/ABrR8=; b=Vi2d/R2uJNYTNVseSxtp/TjCKF3WrgzRVQvCmiuBhDizJGJI+88qCzY/D2NhTAzObt 1myOrARRFkh7n19PVAEJ5N9r9z66+LyyUPbYjdlugywHyGxUoGf70cmcEwim5BcCPa7d UxgfhRAeJVbDZaA7LO4Ar9ZiviJHxTikeX7TfZxCgIT9e9OUfh0knU0ak4v4SQUKp7jH dXdUw8Cus7abQ/+QXsfCn7i98VdOH7QJFVbw0ju/C6jKMBIXEqeGXTyrDwW9xyRmch8L ibfSa79DIOorT4FZMvc90L0ierSWuLTE0VoTd02zGbX5mywxRd3MUNcRnoWe7ORE6hv9 7xrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748334271; x=1748939071; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qaUIvBj9nQ655MlUlx3gsq431C/UZxGa9WSBb/ABrR8=; b=K74hqJfeNRm8CF5lmNJnxHDFBYN5N/0wKOPsoaPL+x/r9PYLpGD8AI4WRGiR+hSbWR 6VsI6OrkZJh2H0rLlRDU++EzA6DuhthK7+0AzIDcmB5Kt92kzq87h21yV/HC5RLpmM/T 6e2lBkbz8vVc1+SUiDIFYIgIcEWrR56W/sZAjmOn/nbT2fcdRI0IgWDhiW/rm7WoCSIb DYssxovQ2rvhe06UQpNrLKJmSv2frcyqQUKIonCdjNAyCGQOLlucixYehwAw3uF39AW9 RPQI/9VGmh3B8ah/QWzmYu2pFdxN5K2R8i5jEGRTppD8dRmOpCanz0bOwQaYCvj6azgu 705w== X-Gm-Message-State: AOJu0YwLgoUXFYEcGPb/JuVi3bG95bNeQOuvf3zpJmcAHgaXlBA3cgTO xzJGTLEc3oMP4T2OMkH/Khuzoq5u8JLfm90H7airNawsKJ9bDn6DDQczsqAIH1/w9yDtG/TRkre yCrGP0g== X-Gm-Gg: ASbGnct13dw0ju+Z5fKwXxpPXRRujghTAFSDiZ8djzJWGI7KVguypdT6TsHh7Z/Q58E 6T0vd1+cWvcXu4WCOAHIq67Diq5wDjN+/VnaWis5x39jkTkw1OfAljY7FkD1QPnkNELj6fndZzT nDCPRAt0FFj9X7jZCdlxWMwwIEAclFbACJB9ggrykK7GvmNaJEJyYiNqW0yTXPBB37a+9aOZTlv IUuq3S1xNF6c51ngR097lUKfeg21LCrRikqPbPjmVvRouOqIDFQtcJQd+BRFT/nDYzKC3AUte5B P90jtwYBN5wCBUzBy7YVX1TSTyNPUXvqX8NIibiVZs68o9EX4vRoKWTkmpyD6lYRBuVnGUwemk1 Zn8ljhZpA6nI6J8z3dM39FSUEDk12g9/zGxXbUmROYUut2I8= X-Google-Smtp-Source: AGHT+IHe/b87HqQcBpLNf0MUbwv+f/PJwogSJM+ppqgnTUUJe8uDeChzDb3oH50E0+ctVIadmja/zg== X-Received: by 2002:a05:6512:2388:b0:553:22b3:1a3b with SMTP id 2adb3069b0e04-55322b31b34mr2106662e87.44.1748334271220; Tue, 27 May 2025 01:24:31 -0700 (PDT) Received: from tunnel335574-pt.tunnel.tserv24.sto1.ipv6.he.net (tunnel335574-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:11::2]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-553252e4afbsm524971e87.34.2025.05.27.01.24.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 May 2025 01:24:30 -0700 (PDT) Date: Tue, 27 May 2025 11:24:26 +0300 (EEST) From: =?ISO-8859-15?Q?Martin_Storsj=F6?= To: FFmpeg development discussions and patches In-Reply-To: <20250527081242.22892-5-ffmpeg@haasn.xyz> Message-ID: <739d1310-7b32-b97f-d533-f1536ea659a@martin.st> References: <20250527081242.22892-1-ffmpeg@haasn.xyz> <20250527081242.22892-5-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH v3 04/17] tests/checkasm: generalize DEF_CHECKASM_CHECK_FUNC to floats 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Tue, 27 May 2025, Niklas Haas wrote: > From: Niklas Haas > > We split the standard macro into its body (implementation) and declaration, > and use a macro argument in place of the raw `memcmp` call, with the major > difference that we now take the number of pixels to compare instead of the > number of bytes (to match the signature of float_near_ulp_array). > --- > tests/checkasm/checkasm.c | 52 ++++++++++++++++++++++++++------------- > tests/checkasm/checkasm.h | 7 ++++++ > 2 files changed, 42 insertions(+), 17 deletions(-) > > diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c > index 71d1e5766c..f393a0cb96 100644 > --- a/tests/checkasm/checkasm.c > +++ b/tests/checkasm/checkasm.c > @@ -1187,14 +1187,8 @@ static int check_err(const char *file, int line, > return 0; > } > > -#define DEF_CHECKASM_CHECK_FUNC(type, fmt) \ > -int checkasm_check_##type(const char *file, int line, \ > - const type *buf1, ptrdiff_t stride1, \ > - const type *buf2, ptrdiff_t stride2, \ > - int w, int h, const char *name, \ > - int align_w, int align_h, \ > - int padding) \ > -{ \ > +#define DEF_CHECKASM_CHECK_BODY(compare, type, fmt) \ > +do { \ > int64_t aligned_w = (w - 1LL + align_w) & ~(align_w - 1); \ > int64_t aligned_h = (h - 1LL + align_h) & ~(align_h - 1); \ > int err = 0; \ > @@ -1204,7 +1198,7 @@ int checkasm_check_##type(const char *file, int line, \ > stride1 /= sizeof(*buf1); \ > stride2 /= sizeof(*buf2); \ > for (y = 0; y < h; y++) \ > - if (memcmp(&buf1[y*stride1], &buf2[y*stride2], w*sizeof(*buf1))) \ > + if (!compare(&buf1[y*stride1], &buf2[y*stride2], w)) \ > break; \ > if (y != h) { \ > if (check_err(file, line, name, w, h, &err)) \ > @@ -1226,38 +1220,50 @@ int checkasm_check_##type(const char *file, int line, \ > buf2 -= h*stride2; \ > } \ > for (y = -padding; y < 0; y++) \ > - if (memcmp(&buf1[y*stride1 - padding], &buf2[y*stride2 - padding], \ > - (w + 2*padding)*sizeof(*buf1))) { \ > + if (!compare(&buf1[y*stride1 - padding], &buf2[y*stride2 - padding], \ > + w + 2*padding)) { \ > if (check_err(file, line, name, w, h, &err)) \ > return 1; \ > fprintf(stderr, " overwrite above\n"); \ > break; \ > } \ > for (y = aligned_h; y < aligned_h + padding; y++) \ > - if (memcmp(&buf1[y*stride1 - padding], &buf2[y*stride2 - padding], \ > - (w + 2*padding)*sizeof(*buf1))) { \ > + if (!compare(&buf1[y*stride1 - padding], &buf2[y*stride2 - padding], \ > + w + 2*padding)) { \ > if (check_err(file, line, name, w, h, &err)) \ > return 1; \ > fprintf(stderr, " overwrite below\n"); \ > break; \ > } \ > for (y = 0; y < h; y++) \ > - if (memcmp(&buf1[y*stride1 - padding], &buf2[y*stride2 - padding], \ > - padding*sizeof(*buf1))) { \ > + if (!compare(&buf1[y*stride1 - padding], &buf2[y*stride2 - padding], \ > + padding)) { \ > if (check_err(file, line, name, w, h, &err)) \ > return 1; \ > fprintf(stderr, " overwrite left\n"); \ > break; \ > } \ > for (y = 0; y < h; y++) \ > - if (memcmp(&buf1[y*stride1 + aligned_w], &buf2[y*stride2 + aligned_w], \ > - padding*sizeof(*buf1))) { \ > + if (!compare(&buf1[y*stride1 + aligned_w], &buf2[y*stride2 + aligned_w], \ > + padding)) { \ > if (check_err(file, line, name, w, h, &err)) \ > return 1; \ > fprintf(stderr, " overwrite right\n"); \ > break; \ > } \ > return err; \ > +} while (0) > + > +#define cmp_int(a, b, len) (!memcmp(a, b, (len) * sizeof(*(a)))) > +#define DEF_CHECKASM_CHECK_FUNC(type, fmt) \ > +int checkasm_check_##type(const char *file, int line, \ > + const type *buf1, ptrdiff_t stride1, \ > + const type *buf2, ptrdiff_t stride2, \ > + int w, int h, const char *name, \ > + int align_w, int align_h, \ > + int padding) \ > +{ \ > + DEF_CHECKASM_CHECK_BODY(cmp_int, type, fmt); \ > } > > DEF_CHECKASM_CHECK_FUNC(uint8_t, "%02x") > @@ -1265,3 +1271,15 @@ DEF_CHECKASM_CHECK_FUNC(uint16_t, "%04x") > DEF_CHECKASM_CHECK_FUNC(uint32_t, "%08x") > DEF_CHECKASM_CHECK_FUNC(int16_t, "%6d") > DEF_CHECKASM_CHECK_FUNC(int32_t, "%9d") > + > +int checkasm_check_float_ulp(const char *file, int line, > + const float *buf1, ptrdiff_t stride1, > + const float *buf2, ptrdiff_t stride2, > + int w, int h, const char *name, > + unsigned max_ulp, int align_w, int align_h, > + int padding) > +{ > + #define cmp_float(a, b, len) float_near_ulp_array(a, b, max_ulp, len) > + DEF_CHECKASM_CHECK_BODY(cmp_float, float, "%g"); > + #undef cmp_float > +} > diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h > index ad7ed10613..ec01bd6207 100644 > --- a/tests/checkasm/checkasm.h > +++ b/tests/checkasm/checkasm.h > @@ -423,6 +423,13 @@ DECL_CHECKASM_CHECK_FUNC(uint32_t); > DECL_CHECKASM_CHECK_FUNC(int16_t); > DECL_CHECKASM_CHECK_FUNC(int32_t); > > +int checkasm_check_float_ulp(const char *file, int line, > + const float *buf1, ptrdiff_t stride1, > + const float *buf2, ptrdiff_t stride2, > + int w, int h, const char *name, > + unsigned max_elp, int align_w, int align_h, Typo - max_ulp? Other than that, thanks, this looks reasonable! // Martin _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".