From patchwork Fri Jun 7 14:05:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 49676 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:c209:0:b0:460:55fa:d5ed with SMTP id d9csp1049691vqo; Fri, 7 Jun 2024 07:05:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXFB4cUM2Sh0HUbttwNwtCr3iyMdbncfuycaRxzHCIAk7QBKcfuSsTNNDGcc7lEmnq6hZ8kHUIOVuiQmDghKFUAI9EDg9wVxPYCGA== X-Google-Smtp-Source: AGHT+IFalWgUyo7FAmCviay7KdNcGLm/qjhNImpYKv12xuvr5/b5o+0wmYFFQLC5xxTlegMLcPVl X-Received: by 2002:a2e:2e0c:0:b0:2ea:eaa1:1bf3 with SMTP id 38308e7fff4ca-2eaeaa11daemr7182471fa.21.1717769158781; Fri, 07 Jun 2024 07:05:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717769158; cv=none; d=google.com; s=arc-20160816; b=MfmLqcDNfowSp5hwy5XXMuNMM31XvUCEtPC0UvS1RZ82HDXxGtSu7Xas1PBHq3CM/E XmXISS6S3BCKCnNQUZj2eLgIu8qwYeT1p/ieHgvQ/G55xJynEPEJRaRT7Lps66fhArwa Z1bBmi1445QLEceHjM501aXB+//DpCbiSdAaJejJDJVVHsJyYlWF4tNgIQ4kudwvZhiN f2Qb2yIXWYiP8KwD01LZ7/6Bhli9feLHNRmU11eNV/NNKPwe2i/2DdjQg62nuGPJQhLh xooECJnwKreTST5re7wRLacwLDlDg5W6Wylm638hj/Rh7tYtoW2XUIvDY2koJ3LoBj9P TXXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=1rZiUYbRsk340S2snYcKpLLvCPMV3qwslV8EwHUAMvs=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=xlyzu56FWJ+u7AuU6TEExjDbCeSrm8PxjCb/zr2Q+QqFr/v6s4TRcDhPOUo2Wx4IRl jhzpxfCfYxTq8h8rcSIAeyrK4Y1aBR1Mr0Dv9RFIemRYO2UpDuZJPQU9b7Kpr0WZQ2KB aPdWJBlHgRrK8fDNw24HvpLwGPNzK3OXe0OwuSmi5XYof3/2UM66qoB+orwAO11oqjHf mXs+4Q5EQvDa28svwx+9980ASoA6/YflKJR8RebkjZNaKJKknRZFCiYYLWs7303o2sjZ L5jHJBt816kziRpXqKwR8+3/v9czkgGXEl8H+CruLETay0C92LJO+vcC69W5Kj5x/I/N hlwQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=Fttn1f7t; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-57c61e173besi166335a12.640.2024.06.07.07.05.58; Fri, 07 Jun 2024 07:05:58 -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=@gmail.com header.s=20230601 header.b=Fttn1f7t; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E76F268D605; Fri, 7 Jun 2024 17:05:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 291AD68D4E4 for ; Fri, 7 Jun 2024 17:05:47 +0300 (EEST) Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2eab0bc74cdso22662791fa.3 for ; Fri, 07 Jun 2024 07:05:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717769146; x=1718373946; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=clxltKczUl/5SuJfpIagrFr363iFELQ8n9hnot+1bqM=; b=Fttn1f7t1ftwn1Ahbp3H9S93uWzDjGj84K1wr1zsCn2nve/m1f4+y+Ds4MLRoN3Osz l26P8/VbHvwuFDOAIWmDjIc/Q72y1siwWbiTEtiqM7EBel0QSeJXVyzRJ3PK/9vsbT8f Z1IHXHSxmRbdBZCG/dAajG8SAj9Amimc1Q7VQW8v58pmmN4XOL4qBmPm7eI6BxwW06x8 EJ4Wq1/OUpoBVKLVg96vVm7//K5Cmzi0dEK34Wnl+IJRrg0DD/NCLs8K3xCjbWiKI9GC YT2F6V++bzIjSbGN8FVNhe9SSpuRUZoc7twgGS9eBsgN2LL5HPSDbaN5G0YUmCuUEH+u 7AHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717769146; x=1718373946; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=clxltKczUl/5SuJfpIagrFr363iFELQ8n9hnot+1bqM=; b=lLtToCD2GHMxcUCbTzGKDqns5vVv1yjQO9FkgGwtR825PK6aQjEkIX1cKpUSiibJGt hiWkVbUBjcwgEZo5uNP43DVLapM/JIEsmAEzLIcV3dBVceoCWBwaAnShyT4XQBlMfmCj Gl5AE/0/kHck3piqV0mmDLPZygy+lJXg6ORrmNlMghgPmFCyvbe/xSXAL2XEq8H0YZk8 JGhvatbt++FoSLEyiehkrDfE2S6ykctUgRy63+BYnYW+NoCVlOC5+/unTO3McmXp1Sgt qkh3NmgesxTSKvw8nnPxD+3BSgXbuY9c+ofGSmEO5Ar/EhVFaMaQkDXnGxD2Yq4txJU4 8dsA== X-Gm-Message-State: AOJu0YxPoMAVDsJmiAdeVxQUzDwPedwoxg2NbQdNYq4cziS9wJOPPggZ i4cHdaokOLZtCXJGZYjebwM0Thssouqt8TPUUKwT/DSRBTP46DeNpnQm1A== X-Received: by 2002:a2e:9c96:0:b0:2e9:794c:19ae with SMTP id 38308e7fff4ca-2eadce37222mr16865281fa.23.1717769145489; Fri, 07 Jun 2024 07:05:45 -0700 (PDT) Received: from localhost.localdomain (80.164-182-91.adsl-dyn.isp.belgacom.be. [91.182.164.80]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4215814f6c0sm87282795e9.46.2024.06.07.07.05.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 07:05:45 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Fri, 7 Jun 2024 16:05:40 +0200 Message-Id: <20240607140543.130761-1-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/4] tests/checkasm: cosmetics, one object per line in Makefile 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: RXdz14BWFmFv --- tests/checkasm/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index 6eb94d10d5..3ce152e818 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -63,7 +63,9 @@ AVFILTEROBJS-$(CONFIG_SOBEL_FILTER) += vf_convolution.o CHECKASMOBJS-$(CONFIG_AVFILTER) += $(AVFILTEROBJS-yes) # swscale tests -SWSCALEOBJS += sw_gbrp.o sw_rgb.o sw_scale.o +SWSCALEOBJS += sw_gbrp.o +SWSCALEOBJS += sw_rgb.o +SWSCALEOBJS += sw_scale.o CHECKASMOBJS-$(CONFIG_SWSCALE) += $(SWSCALEOBJS) From patchwork Fri Jun 7 14:05:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 49677 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:c209:0:b0:460:55fa:d5ed with SMTP id d9csp1049851vqo; Fri, 7 Jun 2024 07:06:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX/uc3nUcDJVGZvVvdvnFFRT/HGzHNRqgYqHE6/ObeOv+xI88HWkKFIzYUZdTWpQaFCVo+/cEgBfJLhG0ovBw7L46QQOTm10C8wvw== X-Google-Smtp-Source: AGHT+IHt91GRg78Q/KS291bc2539VwNcj1hsbPD0ZP1RPre3Zo/Wx2KKU0HdZqjwEtCBL4Xjmswr X-Received: by 2002:a17:906:e949:b0:a62:2eca:4f12 with SMTP id a640c23a62f3a-a6cdb203fc6mr177925766b.59.1717769170385; Fri, 07 Jun 2024 07:06:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717769170; cv=none; d=google.com; s=arc-20160816; b=CTZGlA6ixi2qYf9spS48zTIQSJTv2PUoz+DolTKfiu/PnHAJxxBrUQD3UB+ez7tSnl ygWtaBLmI46utOC78JxAg+sW+wJSZZ9kuhPpQC8G5Y6Wo67BTcS1wTe/52la6Kui5g2a 3KfPyFoVzeoQRob0jtJhZWygCDNiF7Sn2s21GnXEfdVH07wR6NVZcLqhROexfyELz41k AWgB/vT+7IYJD75OMbXts1MMnjnecreDFNpj+IvXFlkngV0tiUXrXCGkg2U6VWTf6SfC 0myGjnWVyIrwllh/2tYac+E7q87M2jg3aS4a9s5cwS2FWnYrajgzdVNJCd3i6GStaBIi aztw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=QjwqtOTHrI4fmF4fbeELz33Htue6gXF+M0dOCUmfTBQ=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=T40/orCl7S7F4HQTnbw+RlKRl9odRspUimczhS0IyBaSU8jKoTnpDOjYl+ihC1Z6n8 yAiVrG6qgvwiJn73FT3eTxGVfSxvw2z0XtpFApT4MEIQX2AuQ2WuLJWnPEWDKFL3Tq7X uxMKatKAfNW1zhskOAxrtBkxQ/Fiage0brROfwR37g+gPj8HnOjpc4K8wsYJWh4JnStu Yk175Kp/E8G3JaNTzIW/nyjUWROmtqs0vytGFUNCq79W5QyZP2H/mFLwJtJ9lZqES86G pyqyBXWYoLcqawntDgyWHT7Ldw5FrV9FiJhySD811oqjdQM8tAMpnjVbrpwaAraDfu+a y41w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=Jscz1vPB; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a6ef71e428dsi11940566b.62.2024.06.07.07.06.09; Fri, 07 Jun 2024 07:06:10 -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=@gmail.com header.s=20230601 header.b=Jscz1vPB; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 33A1068D534; Fri, 7 Jun 2024 17:05:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 26DAD68D534 for ; Fri, 7 Jun 2024 17:05:48 +0300 (EEST) Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-52b992fd796so2291284e87.0 for ; Fri, 07 Jun 2024 07:05:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717769147; x=1718373947; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=HFbcJnXCxUjRtXhXwqVeu4JOX5LA8I0bv5HKm7X/MNY=; b=Jscz1vPBAtfL8Q2i4cAd1hzEz95Lmz5QynmvPwpZswsV3U0QestIKd8iHcEVY60drS ROQts4TKXDRkQ1uYrGR/oWRaS1838JKlaQ7rOYW1t6YcCafh71YefNDwzXnWmc4QipAF jugSIcnAeg3xUdNw719WNkjZbQ0zihsTj5Qr+Rm9oyT4Wu00O1WDSP5SFK/nTbUiBECt PpBYZGbf14obPVkHHCFi9L3ZKLPyBbRAeSqmgQYVwfE/brdaCkKLudehdzocnkJAVjVc FMGhVTv5C2WPH4xhGKs87ECDb7gY1AtoXfXG3oBfCTiJ0A8zttofcS/KmW3MbNzDieA/ Fucg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717769147; x=1718373947; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HFbcJnXCxUjRtXhXwqVeu4JOX5LA8I0bv5HKm7X/MNY=; b=aaDWBjiUyhflFKpqdIhPs3S8Dg/1JkqNXF2YAOcgEaMYQym9MYBd/iBIBNDfELVrtW 2E8nD09HP0QSepOOwPXjCXh9Ozcj5nv31YNDY4laeWq31pF69iWRzyGSbjogLoB5mcLM YdRsSMo7sS08v1LFFGANrzLY0YcHY2m7HiL7qoSGrIVWpwvYEB4YQwMWHoZVTYJuJoIQ FtoLEA6NDZ1naDNKOM5B8sw83yHy4U53FblsltHJGp2XRN1aBRl1rss0QIJSaLySKEUQ 9bTlAkEkSCV3q34fHR3Smx33e2q6aqDNUp58EEnYSN0B8+FTYsrLUV1nuo+QNZnmGA2r 1yxw== X-Gm-Message-State: AOJu0Yyp4+pVa8I3Xbdw86HKvv5KaYiWFyxCkwf1LpjDjArazbBCnr+6 CbFfpWwsDPLBR9pQ3upvZvSOz36E+VGP2FZ9aSyJYt6oFwHm9l0uJOcNCw== X-Received: by 2002:ac2:5ece:0:b0:51f:6a38:be0c with SMTP id 2adb3069b0e04-52bb9f6ef1emr1610467e87.22.1717769146480; Fri, 07 Jun 2024 07:05:46 -0700 (PDT) Received: from localhost.localdomain (80.164-182-91.adsl-dyn.isp.belgacom.be. [91.182.164.80]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4215814f6c0sm87282795e9.46.2024.06.07.07.05.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 07:05:46 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Fri, 7 Jun 2024 16:05:41 +0200 Message-Id: <20240607140543.130761-2-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240607140543.130761-1-ramiro.polla@gmail.com> References: <20240607140543.130761-1-ramiro.polla@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/4] checkasm: add tests for {lum, chr}ConvertRange 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 3Sj/u2ls4wRr --- tests/checkasm/Makefile | 1 + tests/checkasm/checkasm.c | 1 + tests/checkasm/checkasm.h | 1 + tests/checkasm/sw_range_convert.c | 134 ++++++++++++++++++++++++++++++ 4 files changed, 137 insertions(+) create mode 100644 tests/checkasm/sw_range_convert.c diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index 3ce152e818..e4ec6a27ec 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -64,6 +64,7 @@ CHECKASMOBJS-$(CONFIG_AVFILTER) += $(AVFILTEROBJS-yes) # swscale tests SWSCALEOBJS += sw_gbrp.o +SWSCALEOBJS += sw_range_convert.o SWSCALEOBJS += sw_rgb.o SWSCALEOBJS += sw_scale.o diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index d7aa2a9c09..d2b50c023a 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -248,6 +248,7 @@ static const struct { #endif #if CONFIG_SWSCALE { "sw_gbrp", checkasm_check_sw_gbrp }, + { "sw_range_convert", checkasm_check_sw_range_convert }, { "sw_rgb", checkasm_check_sw_rgb }, { "sw_scale", checkasm_check_sw_scale }, #endif diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 211d7f52e6..e544007b67 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -119,6 +119,7 @@ void checkasm_check_rv40dsp(void); void checkasm_check_svq1enc(void); void checkasm_check_synth_filter(void); void checkasm_check_sw_gbrp(void); +void checkasm_check_sw_range_convert(void); void checkasm_check_sw_rgb(void); void checkasm_check_sw_scale(void); void checkasm_check_takdsp(void); diff --git a/tests/checkasm/sw_range_convert.c b/tests/checkasm/sw_range_convert.c new file mode 100644 index 0000000000..6d7e22ad40 --- /dev/null +++ b/tests/checkasm/sw_range_convert.c @@ -0,0 +1,134 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include + +#include "libavutil/common.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/mem.h" +#include "libavutil/mem_internal.h" + +#include "libswscale/swscale.h" +#include "libswscale/swscale_internal.h" + +#include "checkasm.h" + +static void check_lumConvertRange(int from) +{ + const char *func_str = from ? "lumRangeFromJpeg" : "lumRangeToJpeg"; +#define LARGEST_INPUT_SIZE 512 +#define INPUT_SIZES 6 + static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; + struct SwsContext *ctx; + + LOCAL_ALIGNED_32(int16_t, dst0, [LARGEST_INPUT_SIZE]); + LOCAL_ALIGNED_32(int16_t, dst1, [LARGEST_INPUT_SIZE]); + + declare_func(void, int16_t *dst, int width); + + ctx = sws_alloc_context(); + if (sws_init_context(ctx, NULL, NULL) < 0) + fail(); + + ctx->srcFormat = from ? AV_PIX_FMT_YUVJ444P : AV_PIX_FMT_YUV444P; + ctx->dstFormat = from ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P; + ctx->srcRange = from; + ctx->dstRange = !from; + + for (int dstWi = 0; dstWi < INPUT_SIZES; dstWi++) { + int width = input_sizes[dstWi]; + for (int i = 0; i < width; i++) { + uint8_t r = rnd(); + dst0[i] = (int16_t) r << 7; + dst1[i] = (int16_t) r << 7; + } + ff_sws_init_scale(ctx); + if (check_func(ctx->lumConvertRange, "%s_%d", func_str, width)) { + call_ref(dst0, width); + call_new(dst1, width); + if (memcmp(dst0, dst1, width * sizeof(int16_t))) + fail(); + bench_new(dst1, width); + } + } + + sws_freeContext(ctx); +} +#undef LARGEST_INPUT_SIZE +#undef INPUT_SIZES + +static void check_chrConvertRange(int from) +{ + const char *func_str = from ? "chrRangeFromJpeg" : "chrRangeToJpeg"; +#define LARGEST_INPUT_SIZE 512 +#define INPUT_SIZES 6 + static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; + struct SwsContext *ctx; + + LOCAL_ALIGNED_32(int16_t, dstU0, [LARGEST_INPUT_SIZE]); + LOCAL_ALIGNED_32(int16_t, dstV0, [LARGEST_INPUT_SIZE]); + LOCAL_ALIGNED_32(int16_t, dstU1, [LARGEST_INPUT_SIZE]); + LOCAL_ALIGNED_32(int16_t, dstV1, [LARGEST_INPUT_SIZE]); + + declare_func(void, int16_t *dstU, int16_t *dstV, int width); + + ctx = sws_alloc_context(); + if (sws_init_context(ctx, NULL, NULL) < 0) + fail(); + + ctx->srcFormat = from ? AV_PIX_FMT_YUVJ444P : AV_PIX_FMT_YUV444P; + ctx->dstFormat = from ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P; + ctx->srcRange = from; + ctx->dstRange = !from; + + for (int dstWi = 0; dstWi < INPUT_SIZES; dstWi++) { + int width = input_sizes[dstWi]; + for (int i = 0; i < width; i++) { + uint8_t r = rnd(); + dstU0[i] = (int16_t) r << 7; + dstV0[i] = (int16_t) r << 7; + dstU1[i] = (int16_t) r << 7; + dstV1[i] = (int16_t) r << 7; + } + ff_sws_init_scale(ctx); + if (check_func(ctx->chrConvertRange, "%s_%d", func_str, width)) { + call_ref(dstU0, dstV0, width); + call_new(dstU1, dstV1, width); + if (memcmp(dstU0, dstU1, width * sizeof(int16_t)) + || memcmp(dstV0, dstV1, width * sizeof(int16_t))) + fail(); + bench_new(dstU1, dstV1, width); + } + } + + sws_freeContext(ctx); +} +#undef LARGEST_INPUT_SIZE +#undef INPUT_SIZES + +void checkasm_check_sw_range_convert(void) +{ + check_lumConvertRange(1); + report("lumRangeFromJpeg"); + check_chrConvertRange(1); + report("chrRangeFromJpeg"); + check_lumConvertRange(0); + report("lumRangeToJpeg"); + check_chrConvertRange(0); + report("chrRangeToJpeg"); +} From patchwork Fri Jun 7 14:05:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 49678 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:c209:0:b0:460:55fa:d5ed with SMTP id d9csp1050004vqo; Fri, 7 Jun 2024 07:06:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWMC18YqjZJWEY+TtK29h9vPgxz1PmHVDtH+aD5F8ArmY1sJKswrAw1n+TMJK2kmbRseMAdPABV8PUyjBkUTWrC8s8+B9qDgYQa1A== X-Google-Smtp-Source: AGHT+IEo7DwK5VdgWyEm9OvSWJm2r/tDqRzl2aStosxfg8Cr1f7xF5H+rfdk8CqKLjI9wTv5G4YO X-Received: by 2002:a2e:1f01:0:b0:2ea:8442:2096 with SMTP id 38308e7fff4ca-2eadce343efmr15074981fa.2.1717769181558; Fri, 07 Jun 2024 07:06:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717769181; cv=none; d=google.com; s=arc-20160816; b=D9lpXhOuzSNRu+z/rzQT/a3Pqg3DXcYnwAMgpaThqLKZIjZuvUORCCwClRK+OPcs0D RsPnkoF6EBx2+4cSEUI0XdyUadKykxAXiGRIktKtnPgwX2xrJww+SB1pMArqWV1je9MO 7JlXV4lH1TdBQ3Mhx5q/+5oOEsthv5Co+I8lX7eagjKzpykfYZjRbcRv0Cf2xd9LxKt+ qz6hTksxZDXZeHfbfT2dFoMqcBbUi6B8DCKRFkktSjkaUuVNpIVNABY3du8K3JBKlstK RxrDkXbpwkdMJwxwqn82hKO+2NEcHGZE5wmwVa2gClkmqI2glz4RUwmZOe4KUZjuRof2 A6Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=BE3KFEtxCoNC+oTGukh5h4nNkFpfez7SWO0mgWt6bxg=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=KPXaMujDeeT2yzzGiHUoTA2UbrrnhLW5+1kT7Gcqa5sXmhxuuDegwONg0DG2d4RhqT 6iakqX1BbBTqn/awXqTxmtGs8TS4JW2Iw2mjEWnAfK+RuJvDowhXWvuJ6DPqDi+0VEvO wFEnVH0JVluLGZBFv+tSn1+Ikmzjmj/hCoKzG6vgaNEpmJibuPz9Ql28r/nL+7Xs3stG NfjnoUKrKG7vlk81/K7ixZH1FaBNsypSglLVJKeExa8F7zDw72r6JWB40Tc++mxqPGWH DPDYb6pYC3q2CZfjIas8MJtlOy/QNM2nWEVxc9vb1bMV4ru+b6BI3QAAMwtvovWsgA4a +wzg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=XV4FZJqG; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 38308e7fff4ca-2ead40699d9si10401951fa.132.2024.06.07.07.06.20; Fri, 07 Jun 2024 07:06:21 -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=@gmail.com header.s=20230601 header.b=XV4FZJqG; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8863768D590; Fri, 7 Jun 2024 17:05:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 69A7F68D745 for ; Fri, 7 Jun 2024 17:05:49 +0300 (EEST) Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2e73359b900so23841971fa.2 for ; Fri, 07 Jun 2024 07:05:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717769148; x=1718373948; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=1FJU3mSqmZJvts3xAl8fX2uUMCmStM88/oV4EAmKnXg=; b=XV4FZJqGeQOWzHzo/WKEXkEtqcvwxrQ3fsJJzdgXmIedy6YnxU9urxY53JfQz6AZLn tRSRYESjfbsDb0FCD2IjKRiIDpag2FUT46onWMHTDy0wGqKDGGkfqsEjLBvU6oNcAOQr vZfoHphpKfvxF6BytCkGwmPuIqb3756/+/zOq2klSKid5E6CXNroEQSEg+WJfIaioqaL xsBZAwG7hRgCpHeSELDk96YtOxvobRP7vDln5P+FRspOb4fYmREFRQHVFaU1iLbIx9e6 Wxqoc8VwDPGXiQrp+DJOKGN6K60AlhGc4XSHWihIy6vWO/55s35gqAAyVUVduUX6Yyic hj9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717769148; x=1718373948; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1FJU3mSqmZJvts3xAl8fX2uUMCmStM88/oV4EAmKnXg=; b=enmvrzUJYFbzUf6llbDW6wc/wWWtzZ86eBsOssNrkZ9Jm2mTUYisDpihyjJc08Nfd5 6g1MCiXQ7Gmte9oAzKuIRPi7kUIsAXXHSkbjXBtO9bigrFfj/W+FmSO8srN1fVD7AAyq 2YhnuaCfeqtyUyIyJ36WUWatkPPZih9BTv+vDU73JAw2o2wwhZ1tIMU44kEFcbZ/OM7x b3MjrhDI6bEYWBCvMnNickvSbBV/v01PH2yiEMq3Xk2Sl166ZPHfFgOkppaKmiRm437k H1XXufJlZ99SWQHdpjKs2Tdwe/yoxqUfNUrMSQ5Tl7N1D4Adf0bsOax+5LyS1SpNAONd Xlqw== X-Gm-Message-State: AOJu0YzRnFCfjpz3vRyg9vSTCJrfJhSHXDvJ2etXq+AdqK7kmUUVH0Cj 5zDHFSj040fKVaCVFh4qBfj0thbbMxChNAqFdVm9pM4HMJTnXQ3qAoE0Rg== X-Received: by 2002:a2e:9187:0:b0:2ea:83d1:4802 with SMTP id 38308e7fff4ca-2eadce3e25fmr16782721fa.27.1717769147514; Fri, 07 Jun 2024 07:05:47 -0700 (PDT) Received: from localhost.localdomain (80.164-182-91.adsl-dyn.isp.belgacom.be. [91.182.164.80]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4215814f6c0sm87282795e9.46.2024.06.07.07.05.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 07:05:47 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Fri, 7 Jun 2024 16:05:42 +0200 Message-Id: <20240607140543.130761-3-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240607140543.130761-1-ramiro.polla@gmail.com> References: <20240607140543.130761-1-ramiro.polla@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/4] swscale/x86: add sse4 {lum, chr}ConvertRange 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: lmhlLu8TwH5e chrRangeFromJpeg_8_c: 19.9 chrRangeFromJpeg_8_sse4: 16.2 chrRangeFromJpeg_24_c: 60.7 chrRangeFromJpeg_24_sse4: 28.9 chrRangeFromJpeg_128_c: 325.7 chrRangeFromJpeg_128_sse4: 160.2 chrRangeFromJpeg_144_c: 364.2 chrRangeFromJpeg_144_sse4: 194.9 chrRangeFromJpeg_256_c: 630.7 chrRangeFromJpeg_256_sse4: 337.4 chrRangeFromJpeg_512_c: 1240.4 chrRangeFromJpeg_512_sse4: 668.4 chrRangeToJpeg_8_c: 37.7 chrRangeToJpeg_8_sse4: 19.7 chrRangeToJpeg_24_c: 114.7 chrRangeToJpeg_24_sse4: 30.2 chrRangeToJpeg_128_c: 636.4 chrRangeToJpeg_128_sse4: 161.7 chrRangeToJpeg_144_c: 715.7 chrRangeToJpeg_144_sse4: 272.9 chrRangeToJpeg_256_c: 1256.7 chrRangeToJpeg_256_sse4: 341.9 chrRangeToJpeg_512_c: 2498.7 chrRangeToJpeg_512_sse4: 668.4 lumRangeFromJpeg_8_c: 11.7 lumRangeFromJpeg_8_sse4: 12.4 lumRangeFromJpeg_24_c: 36.9 lumRangeFromJpeg_24_sse4: 17.7 lumRangeFromJpeg_128_c: 228.4 lumRangeFromJpeg_128_sse4: 85.2 lumRangeFromJpeg_144_c: 272.9 lumRangeFromJpeg_144_sse4: 96.9 lumRangeFromJpeg_256_c: 463.4 lumRangeFromJpeg_256_sse4: 183.9 lumRangeFromJpeg_512_c: 879.9 lumRangeFromJpeg_512_sse4: 355.9 lumRangeToJpeg_8_c: 17.7 lumRangeToJpeg_8_sse4: 15.4 lumRangeToJpeg_24_c: 56.2 lumRangeToJpeg_24_sse4: 18.4 lumRangeToJpeg_128_c: 331.4 lumRangeToJpeg_128_sse4: 84.4 lumRangeToJpeg_144_c: 375.2 lumRangeToJpeg_144_sse4: 96.9 lumRangeToJpeg_256_c: 649.7 lumRangeToJpeg_256_sse4: 184.4 lumRangeToJpeg_512_c: 1281.9 lumRangeToJpeg_512_sse4: 355.9 --- libswscale/swscale_internal.h | 1 + libswscale/utils.c | 2 + libswscale/x86/Makefile | 1 + libswscale/x86/range_convert.asm | 100 +++++++++++++++++++++++++++++++ libswscale/x86/swscale.c | 36 +++++++++++ 5 files changed, 140 insertions(+) create mode 100644 libswscale/x86/range_convert.asm diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index d4b0c3cee2..92f6105443 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -698,6 +698,7 @@ void ff_updateMMXDitherTables(SwsContext *c, int dstY); av_cold void ff_sws_init_range_convert(SwsContext *c); av_cold void ff_sws_init_range_convert_loongarch(SwsContext *c); +av_cold void ff_sws_init_range_convert_x86(SwsContext *c); SwsFunc ff_yuv2rgb_init_x86(SwsContext *c); SwsFunc ff_yuv2rgb_init_ppc(SwsContext *c); diff --git a/libswscale/utils.c b/libswscale/utils.c index 476a24fea5..8dfa57b5ff 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1082,6 +1082,8 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], ff_sws_init_range_convert(c); #if ARCH_LOONGARCH64 ff_sws_init_range_convert_loongarch(c); +#elif ARCH_X86 + ff_sws_init_range_convert_x86(c); #endif } diff --git a/libswscale/x86/Makefile b/libswscale/x86/Makefile index 68391494be..f00154941d 100644 --- a/libswscale/x86/Makefile +++ b/libswscale/x86/Makefile @@ -12,6 +12,7 @@ X86ASM-OBJS += x86/input.o \ x86/output.o \ x86/scale.o \ x86/scale_avx2.o \ + x86/range_convert.o \ x86/rgb_2_rgb.o \ x86/yuv_2_rgb.o \ x86/yuv2yuvX.o \ diff --git a/libswscale/x86/range_convert.asm b/libswscale/x86/range_convert.asm new file mode 100644 index 0000000000..333265fb65 --- /dev/null +++ b/libswscale/x86/range_convert.asm @@ -0,0 +1,100 @@ +;****************************************************************************** +;* Copyright (c) 2024 Ramiro Polla +;* +;* This file is part of FFmpeg. +;* +;* FFmpeg is free software; you can redistribute it and/or +;* modify it under the terms of the GNU Lesser General Public +;* License as published by the Free Software Foundation; either +;* version 2.1 of the License, or (at your option) any later version. +;* +;* FFmpeg is distributed in the hope that it will be useful, +;* but WITHOUT ANY WARRANTY; without even the implied warranty of +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;* Lesser General Public License for more details. +;* +;* You should have received a copy of the GNU Lesser General Public +;* License along with FFmpeg; if not, write to the Free Software +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** + +%include "libavutil/x86/x86util.asm" + +; NOTE: there is no need to clamp the input when converting to jpeg range +; (like we do in the C code) because packssdw will saturate the output. + +;----------------------------------------------------------------------------- +; lumConvertRange +; +; void ff_lumRangeToJpeg_(int16_t *dst, int width); +; void ff_lumRangeFromJpeg_(int16_t *dst, int width); +; +;----------------------------------------------------------------------------- + +%macro LUMCONVERTRANGE 4 +SECTION_RODATA +mult_%1: times 4 dd %2 +offset_%1: times 4 dd %3 +SECTION .text +cglobal %1, 2, 3, 3, dst, width, x + movsxdifnidn widthq, widthd + xor xq, xq + mova m1, [mult_%1] + mova m2, [offset_%1] +.loop: + pmovsxwd m0, [dstq+xq*2] + pmulld m0, m1 + paddd m0, m2 + psrad m0, %4 + packssdw m0, m0 + movh [dstq+xq*2], m0 + add xq, mmsize / 4 + cmp xd, widthd + jl .loop + RET +%endmacro + +;----------------------------------------------------------------------------- +; chrConvertRange +; +; void ff_chrRangeToJpeg_(int16_t *dstU, int16_t *dstV, int width); +; void ff_chrRangeFromJpeg_(int16_t *dstU, int16_t *dstV, int width); +; +;----------------------------------------------------------------------------- + +%macro CHRCONVERTRANGE 4 +SECTION_RODATA +mult_%1: times 4 dd %2 +offset_%1: times 4 dd %3 +SECTION .text +cglobal %1, 3, 4, 4, dstU, dstV, width, x + movsxdifnidn widthq, widthd + xor xq, xq + mova m1, [mult_%1] + mova m2, [offset_%1] +.loop: + pmovsxwd m0, [dstUq+xq*2] + pmulld m0, m1 + paddd m0, m2 + psrad m0, %4 + packssdw m0, m0 + movh [dstUq+xq*2], m0 + pmovsxwd m0, [dstVq+xq*2] + pmulld m0, m1 + paddd m0, m2 + psrad m0, %4 + packssdw m0, m0 + movh [dstVq+xq*2], m0 + add xq, mmsize / 4 + cmp xd, widthd + jl .loop + RET +%endmacro + +%if ARCH_X86_64 +INIT_XMM sse4 +LUMCONVERTRANGE lumRangeToJpeg, 19077, -39057361, 14 +CHRCONVERTRANGE chrRangeToJpeg, 4663, -9289992, 12 +LUMCONVERTRANGE lumRangeFromJpeg, 14071, 33561947, 14 +CHRCONVERTRANGE chrRangeFromJpeg, 1799, 4081085, 11 +%endif diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c index fff8bb4396..c5ddfb5605 100644 --- a/libswscale/x86/swscale.c +++ b/libswscale/x86/swscale.c @@ -447,6 +447,38 @@ INPUT_PLANAR_RGB_UV_ALL_DECL(avx2); INPUT_PLANAR_RGB_A_ALL_DECL(avx2); #endif +#if ARCH_X86_64 +#define RANGE_CONVERT_FUNCS(opt) do { \ + if (c->dstBpc <= 14) { \ + if (c->srcRange) { \ + c->lumConvertRange = ff_lumRangeFromJpeg_ ##opt; \ + c->chrConvertRange = ff_chrRangeFromJpeg_ ##opt; \ + } else { \ + c->lumConvertRange = ff_lumRangeToJpeg_ ##opt; \ + c->chrConvertRange = ff_chrRangeToJpeg_ ##opt; \ + } \ + } \ +} while (0) + +#define RANGE_CONVERT_FUNCS_DECL(opt) \ +void ff_lumRangeFromJpeg_ ##opt(int16_t *dst, int width); \ +void ff_chrRangeFromJpeg_ ##opt(int16_t *dstU, int16_t *dstV, int width); \ +void ff_lumRangeToJpeg_ ##opt(int16_t *dst, int width); \ +void ff_chrRangeToJpeg_ ##opt(int16_t *dstU, int16_t *dstV, int width); \ + +RANGE_CONVERT_FUNCS_DECL(sse4); + +av_cold void ff_sws_init_range_convert_x86(SwsContext *c) +{ + if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { + int cpu_flags = av_get_cpu_flags(); + if (EXTERNAL_SSE4(cpu_flags)) { + RANGE_CONVERT_FUNCS(sse4); + } + } +} +#endif + av_cold void ff_sws_init_swscale_x86(SwsContext *c) { int cpu_flags = av_get_cpu_flags(); @@ -805,4 +837,8 @@ switch(c->dstBpc){ \ } #endif + +#if ARCH_X86_64 + ff_sws_init_range_convert_x86(c); +#endif } From patchwork Fri Jun 7 14:05:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 49679 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:c209:0:b0:460:55fa:d5ed with SMTP id d9csp1050145vqo; Fri, 7 Jun 2024 07:06:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVnxmQTIaGO6iafJZ7fDZYTLBJnN3tt3sKLtDjxit8r6ml6XSHxOOlblK3zLKt9X0wemkt8FzDHlb0KxLkLL7Q03d1lYVHgcG1iNg== X-Google-Smtp-Source: AGHT+IEdAxBuGJ0iobzxs6WcTEyWml9grFj5kC74juZPqtLvdZCMjIAIEYusfzxC7eaz9qJ6sohX X-Received: by 2002:a2e:a16f:0:b0:2ea:e26d:c9b5 with SMTP id 38308e7fff4ca-2eae26dca5amr10324911fa.30.1717769191902; Fri, 07 Jun 2024 07:06:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717769191; cv=none; d=google.com; s=arc-20160816; b=vDPp41ILFNo7QhLJEfqrbIUO3/TBYdg8r9Dg6wgWr84mV77RcO/Gn8jC2PVb1+pYQH m356407DsDMxnxmZHZuI0L6qsvJOepyf++locwDchFk6g1zFf3tPA7qQ5bYRBBTxmiip NTAAzXaUBy3hg7vBP9J7Z0/NQ/DcUmc6ecMzrZd20H6egbQ35Oyh70/HL6yygFNv5s0A IUtJtULlS96obqfOQbfNJzXR52k8gCFItD1SPjaqlkowyNGmEO1W50Ti6vMt/rRt+UId ozB0INqP2ieOgnzuTwO9IZaQu8U5g6kqQ0/IwK/N1Ajg4Z+qEpmX/UT7FYr5nWKggujV jHwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=PE4DXLRk6U6tGMF9+DmRuAOiS8swpczeTVzb9PEiSz4=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=vPahki3yJgn6sRFonA6pjJ2ayoa6og/1uQLT+S1NNp+swt3sqUszJjdlbjCAN+M8Rh M4ClxSYvKHj2KVTRmZl/J0QEWFWNQXemL+x/I687YNmR61nhyTkohmfv1P1iozdbtXmx jqi8wbKPajxbsMQbltkzVT5Lzg3COVzhQ9MHnp3nor4ELvToLH9ihh3FvUmt7oMipADk m2ek/N5HJ+DsUtmLH55GEVcIOX4hUi9rHxRP9KdjG6jtK7PoBjS3Yu/QCO8ZSGfMrbOZ MZSKamxqEIguuhlgq4KkWX+8m6TcPGikq1piExHG0XCEln9OqkQgi3QeTfA79YMc2EyQ A3NA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=JpLXXdk+; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 38308e7fff4ca-2ead419c4c0si10062481fa.591.2024.06.07.07.06.31; Fri, 07 Jun 2024 07:06:31 -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=@gmail.com header.s=20230601 header.b=JpLXXdk+; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0226B68D7FA; Fri, 7 Jun 2024 17:05:58 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CBB5968D534 for ; Fri, 7 Jun 2024 17:05:49 +0300 (EEST) Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4210aa012e5so22712385e9.0 for ; Fri, 07 Jun 2024 07:05:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717769149; x=1718373949; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=pKcuD3xoIgjcpS5Rdk1kHB3hI5aYjaHIiA2V43eC65E=; b=JpLXXdk+bDlGVeTBTaEBvXqsMcPt9hk+eA9VAOjiT1T6SpBnuXD2yGKfHiTjG8iP2d l7m5BDDxrdhh+wCO7D9Sk3FHSUBzIHWXEWsN95h0jOLCYaeb2dSjP1hA6mPTg2imr99z oCmyv7RjlAzXq7gFaMzBjhpccrOMlVO2qdfs8Rx96hkombgsg/jvhlbVhgxkLX30AYNe eJ++netA9ISwQt7MVeKkSI9YzUuNRsMnDt0HxK2LM3lX/yZV77udW+pp9VcAJRN+k+qE 6kxIUaGsly7VJctQ5saWXEW0T1dQwq1/HbIZ99SJZiDUfZeoSmW5dNYnyBizfuDwoG34 5qEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717769149; x=1718373949; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pKcuD3xoIgjcpS5Rdk1kHB3hI5aYjaHIiA2V43eC65E=; b=d38fynNTG3F3dLoVFb/b+YY3SuXYDywOrEnlyDupz0rs1JGqPnyj1RmQFQOHSgiTW0 BOMoyeFwaZMY9xZsV/JK+EL9mzC5jzjt2AfrBDSIfD0y9Zt9WCNs5K+zTwh+XGnCRNcz AdapNtY+4t3+tKXekzbygseNkk6UOnxxDJiRzv2GTnVI1CqzMuN3bKXZ4dRQOeuHPKxl 6Bi0r1fL2Xkbq3v3J41pUo0WQ86SvxncXCz9sLtBY3hjFJgxjtdKzDXGKxKBjUcyNmpA ovHc8FB8JXIy7jvYt6yWh4JP08d58+afLiVS/EvDn/1y4V+41weHYFuwX26aU8MFIKQc zfyA== X-Gm-Message-State: AOJu0YzE6oa1XKEohSRVFmo66lbiUkUojmLf79rQQ/IG8lOMRY/vbZhu lNAxI9Wv0km2f6bBLG9nRBkKPH8UbgkfuKXwIvtIJ70kalb0REzGXRTD/Q== X-Received: by 2002:a05:600c:1d03:b0:421:54f7:c294 with SMTP id 5b1f17b1804b1-42164a20c82mr24087765e9.29.1717769148389; Fri, 07 Jun 2024 07:05:48 -0700 (PDT) Received: from localhost.localdomain (80.164-182-91.adsl-dyn.isp.belgacom.be. [91.182.164.80]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4215814f6c0sm87282795e9.46.2024.06.07.07.05.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 07:05:48 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Fri, 7 Jun 2024 16:05:43 +0200 Message-Id: <20240607140543.130761-4-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240607140543.130761-1-ramiro.polla@gmail.com> References: <20240607140543.130761-1-ramiro.polla@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] swscale/aarch64: add neon {lum, chr}ConvertRange 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: MnHEEx4Luz/8 chrRangeFromJpeg_8_c: 28.5 chrRangeFromJpeg_8_neon: 21.2 chrRangeFromJpeg_24_c: 81.2 chrRangeFromJpeg_24_neon: 34.7 chrRangeFromJpeg_128_c: 425.2 chrRangeFromJpeg_128_neon: 162.0 chrRangeFromJpeg_144_c: 480.2 chrRangeFromJpeg_144_neon: 180.2 chrRangeFromJpeg_256_c: 838.2 chrRangeFromJpeg_256_neon: 318.0 chrRangeFromJpeg_512_c: 1698.2 chrRangeFromJpeg_512_neon: 630.0 chrRangeToJpeg_8_c: 56.0 chrRangeToJpeg_8_neon: 23.5 chrRangeToJpeg_24_c: 147.7 chrRangeToJpeg_24_neon: 38.2 chrRangeToJpeg_128_c: 760.2 chrRangeToJpeg_128_neon: 182.5 chrRangeToJpeg_144_c: 857.7 chrRangeToJpeg_144_neon: 204.5 chrRangeToJpeg_256_c: 1504.2 chrRangeToJpeg_256_neon: 358.5 chrRangeToJpeg_512_c: 3025.7 chrRangeToJpeg_512_neon: 710.5 lumRangeFromJpeg_8_c: 24.0 lumRangeFromJpeg_8_neon: 18.2 lumRangeFromJpeg_24_c: 64.0 lumRangeFromJpeg_24_neon: 22.2 lumRangeFromJpeg_128_c: 289.2 lumRangeFromJpeg_128_neon: 79.2 lumRangeFromJpeg_144_c: 334.7 lumRangeFromJpeg_144_neon: 87.7 lumRangeFromJpeg_256_c: 579.5 lumRangeFromJpeg_256_neon: 152.0 lumRangeFromJpeg_512_c: 1208.0 lumRangeFromJpeg_512_neon: 299.0 lumRangeToJpeg_8_c: 30.0 lumRangeToJpeg_8_neon: 19.0 lumRangeToJpeg_24_c: 82.2 lumRangeToJpeg_24_neon: 24.0 lumRangeToJpeg_128_c: 440.7 lumRangeToJpeg_128_neon: 90.5 lumRangeToJpeg_144_c: 502.0 lumRangeToJpeg_144_neon: 102.2 lumRangeToJpeg_256_c: 893.7 lumRangeToJpeg_256_neon: 178.0 lumRangeToJpeg_512_c: 1793.7 lumRangeToJpeg_512_neon: 355.0 --- libswscale/aarch64/Makefile | 1 + libswscale/aarch64/range_convert_neon.S | 103 ++++++++++++++++++++++++ libswscale/aarch64/swscale.c | 21 +++++ libswscale/swscale_internal.h | 1 + libswscale/utils.c | 4 +- 5 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 libswscale/aarch64/range_convert_neon.S diff --git a/libswscale/aarch64/Makefile b/libswscale/aarch64/Makefile index da1d909561..6923827f82 100644 --- a/libswscale/aarch64/Makefile +++ b/libswscale/aarch64/Makefile @@ -4,5 +4,6 @@ OBJS += aarch64/rgb2rgb.o \ NEON-OBJS += aarch64/hscale.o \ aarch64/output.o \ + aarch64/range_convert_neon.o \ aarch64/rgb2rgb_neon.o \ aarch64/yuv2rgb_neon.o \ diff --git a/libswscale/aarch64/range_convert_neon.S b/libswscale/aarch64/range_convert_neon.S new file mode 100644 index 0000000000..5e104971f0 --- /dev/null +++ b/libswscale/aarch64/range_convert_neon.S @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2024 Ramiro Polla + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/aarch64/asm.S" + +.macro lumConvertRange name max mult offset shift +const offset_\name, align=4 + .word \offset, \offset, \offset, \offset +endconst +function ff_\name, export=1 +.if \max != 0 + mov w3, #\max + dup v24.8h, w3 +.endif + mov w3, #\mult + dup v25.4s, w3 + movrel x3, offset_\name + ld1 {v26.4s}, [x3] +1: + ld1 {v0.8h}, [x0] +.if \max != 0 + smin v0.8h, v0.8h, v24.8h +.endif + mov v16.16b, v26.16b + mov v18.16b, v26.16b + sxtl v20.4s, v0.4h + sxtl2 v22.4s, v0.8h + mla v16.4s, v20.4s, v25.4s + mla v18.4s, v22.4s, v25.4s + shrn v0.4h, v16.4s, #\shift + shrn2 v0.8h, v18.4s, #\shift + subs w1, w1, #8 + st1 {v0.8h}, [x0], #16 + b.gt 1b + ret +endfunc +.endm + +.macro chrConvertRange name max mult offset shift +const offset_\name, align=4 + .word \offset, \offset, \offset, \offset +endconst +function ff_\name, export=1 +.if \max != 0 + mov w3, #\max + dup v24.8h, w3 +.endif + mov w3, #\mult + dup v25.4s, w3 + movrel x3, offset_\name + ld1 {v26.4s}, [x3] +1: + ld1 {v0.8h}, [x0] + ld1 {v1.8h}, [x1] +.if \max != 0 + smin v0.8h, v0.8h, v24.8h + smin v1.8h, v1.8h, v24.8h +.endif + mov v16.16b, v26.16b + mov v17.16b, v26.16b + mov v18.16b, v26.16b + mov v19.16b, v26.16b + sxtl v20.4s, v0.4h + sxtl v21.4s, v1.4h + sxtl2 v22.4s, v0.8h + sxtl2 v23.4s, v1.8h + mla v16.4s, v20.4s, v25.4s + mla v17.4s, v21.4s, v25.4s + mla v18.4s, v22.4s, v25.4s + mla v19.4s, v23.4s, v25.4s + shrn v0.4h, v16.4s, #\shift + shrn v1.4h, v17.4s, #\shift + shrn2 v0.8h, v18.4s, #\shift + shrn2 v1.8h, v19.4s, #\shift + subs w2, w2, #8 + st1 {v0.8h}, [x0], #16 + st1 {v1.8h}, [x1], #16 + b.gt 1b + ret +endfunc +.endm + +lumConvertRange lumRangeToJpeg_neon, 30189, 19077, -39057361, 14 +chrConvertRange chrRangeToJpeg_neon, 30775, 4663, -9289992, 12 +lumConvertRange lumRangeFromJpeg_neon, 0, 14071, 33561947, 14 +chrConvertRange chrRangeFromJpeg_neon, 0, 1799, 4081085, 11 diff --git a/libswscale/aarch64/swscale.c b/libswscale/aarch64/swscale.c index bbd9719a44..7344f75b2e 100644 --- a/libswscale/aarch64/swscale.c +++ b/libswscale/aarch64/swscale.c @@ -201,6 +201,26 @@ void ff_yuv2plane1_8_neon( default: break; \ } +void ff_lumRangeFromJpeg_neon(int16_t *dst, int width); +void ff_chrRangeFromJpeg_neon(int16_t *dstU, int16_t *dstV, int width); +void ff_lumRangeToJpeg_neon(int16_t *dst, int width); +void ff_chrRangeToJpeg_neon(int16_t *dstU, int16_t *dstV, int width); + +av_cold void ff_sws_init_range_convert_aarch64(SwsContext *c) +{ + if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { + if (c->dstBpc <= 14) { + if (c->srcRange) { + c->lumConvertRange = ff_lumRangeFromJpeg_neon; + c->chrConvertRange = ff_chrRangeFromJpeg_neon; + } else { + c->lumConvertRange = ff_lumRangeToJpeg_neon; + c->chrConvertRange = ff_chrRangeToJpeg_neon; + } + } + } +} + av_cold void ff_sws_init_swscale_aarch64(SwsContext *c) { int cpu_flags = av_get_cpu_flags(); @@ -212,5 +232,6 @@ av_cold void ff_sws_init_swscale_aarch64(SwsContext *c) if (c->dstBpc == 8) { c->yuv2planeX = ff_yuv2planeX_8_neon; } + ff_sws_init_range_convert_aarch64(c); } } diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index 92f6105443..1059f8a6de 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -697,6 +697,7 @@ void ff_yuv2rgb_init_tables_ppc(SwsContext *c, const int inv_table[4], void ff_updateMMXDitherTables(SwsContext *c, int dstY); av_cold void ff_sws_init_range_convert(SwsContext *c); +av_cold void ff_sws_init_range_convert_aarch64(SwsContext *c); av_cold void ff_sws_init_range_convert_loongarch(SwsContext *c); av_cold void ff_sws_init_range_convert_x86(SwsContext *c); diff --git a/libswscale/utils.c b/libswscale/utils.c index 8dfa57b5ff..12dba712c1 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1080,7 +1080,9 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], if (need_reinit) { ff_sws_init_range_convert(c); -#if ARCH_LOONGARCH64 +#if ARCH_AARCH64 + ff_sws_init_range_convert_aarch64(c); +#elif ARCH_LOONGARCH64 ff_sws_init_range_convert_loongarch(c); #elif ARCH_X86 ff_sws_init_range_convert_x86(c);