From patchwork Thu Jul 4 14:30:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 50337 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:cc64:0:b0:482:c625:d099 with SMTP id k4csp3759235vqv; Thu, 4 Jul 2024 07:39:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXlND95aHFTrmmjlJ9ojqj/uT3mmksbb5VpylLg+IdvNeyxlu5NRNlVGaFwzCuToPdPWMYnIqfLUo4WY4bEmNy2tXjbp+DUk3D7pw== X-Google-Smtp-Source: AGHT+IGxnN7keniHaNwUt+2BHlZr3L60PwiM9drUL5VXr8+LMusCP2Inp5SCQGZdANXrRH0vNWjY X-Received: by 2002:a17:906:af86:b0:a6e:f793:461f with SMTP id a640c23a62f3a-a77ba489ff5mr152316966b.38.1720103953260; Thu, 04 Jul 2024 07:39:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720103953; cv=none; d=google.com; s=arc-20160816; b=hbs73h/WK1qOYMW+rMOem3pf3DkthXr+4R9Vib1EXV+izt0/XZ53+DmjyDzDKfayis iNf3pVcd1ANopngl5jrApjMZl/NnyGjFHTkm+NZhNGZpHrpkvBlec6aW5FijCPbbUiY9 8axYC8+tnf16X5NcvdmV2+L/LznrfBqqQXylFFfOZMaxYu+B55hEz/bgdMFEsQLU8v3E WaQf3vWeh0YE+x1e7rrKrLCzl2LvEMOJNL7MRPh6xUivL7pW9e8Q6xOgD8qAWVabVV7M KaBYbnnMTaRtJtahJehmzGPdJFd8CikEv2Y2nHcqcu/zfdncxcAyqAk3c/3/swHPnQHv l8Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=uRFKHdb4yIMX4npgVMTlvEmmpLx69+qbxljlExm2obk=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=BghxICKn4WzY5VdnF2xmxwDVkfh0Sx+KNAFw+fF8Etx288BT3Azn/ziSkAHDyfgAuU mKvBs8+e2gncXkfMvERnwYSGvf3OLKhSllew47pZTXu8FagWwdWCi193AhcPv2pXAhPo TAALmRo7xhSKbPAH3dHjQCiTkg/n7yfyO3zWcScS30sYKuXQItS9CUPgnZM7QSnDAIjg rDtLwpS8MqHDK9q37XgPFES9ASjZ8qJ824LpzT4Eg2NyDOF3LZIfV/lYiJ0rXKvp0Rzv xlbpeL0/aZ9TWu4QG4CONFrGIJOrnMvBKSs1tfFmNswgcrnC8MNhUhFv/UO2AVmvKzTu HKWg==; 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=G5OIBDLn; 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 a640c23a62f3a-a72ab095e5fsi661182866b.804.2024.07.04.07.39.12; Thu, 04 Jul 2024 07:39:13 -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=G5OIBDLn; 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 E10F668D9FC; Thu, 4 Jul 2024 17:31:18 +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 9A1CE68D9AE for ; Thu, 4 Jul 2024 17:31:07 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1720103467; bh=heRpCOHHT7WQVl5lELF8qQ4GsbooJsrzFy1RUOXvXJM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G5OIBDLne4D8Ut2yFKn+hQPMHpxKCX2Cu7X567HuLk/yvasmTa7DrFR+cjfD7fzFW iKkQyJGT+UyUoVnGPhXunElEHc9iHZC7zhyPPzTZecvS65DQy7W0rRzc11uliDvgud 5B9ID38Cr+lSjBH3a1QtAROZHK3KMx/shZa3YnJc= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 4C268406C7; Thu, 4 Jul 2024 16:31:07 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Jul 2024 16:30:59 +0200 Message-ID: <20240704143104.1821386-3-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240704143104.1821386-1-ffmpeg@haasn.xyz> References: <20240704143104.1821386-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 3/8] swscale/options: relax src/dst_h/v_chr_pos value range 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: Kh4guzuwxvY1 From: Niklas Haas When dealing with 4x subsampling ratios (log2 == 2), such as can arise with 4:1:1 or 4:1:0, a value range of 512 is not enough to cover the range of possible scenarios. For example, bottom-sited chroma in 4:1:0 would require an offset of 768 (three luma rows). Simply double the limit to 1024. I don't see any place in initFilter() that would experience overflow as a result of this change, especially since get_local_pos() right-shifts it by the subsampling ratio again. --- libswscale/options.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libswscale/options.c b/libswscale/options.c index b36f13c872..53c4f0651b 100644 --- a/libswscale/options.c +++ b/libswscale/options.c @@ -62,10 +62,10 @@ static const AVOption swscale_options[] = { { "param0", "scaler param 0", OFFSET(param[0]), AV_OPT_TYPE_DOUBLE, { .dbl = SWS_PARAM_DEFAULT }, INT_MIN, INT_MAX, VE }, { "param1", "scaler param 1", OFFSET(param[1]), AV_OPT_TYPE_DOUBLE, { .dbl = SWS_PARAM_DEFAULT }, INT_MIN, INT_MAX, VE }, - { "src_v_chr_pos", "source vertical chroma position in luma grid/256" , OFFSET(src_v_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513 }, -513, 512, VE }, - { "src_h_chr_pos", "source horizontal chroma position in luma grid/256", OFFSET(src_h_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513 }, -513, 512, VE }, - { "dst_v_chr_pos", "destination vertical chroma position in luma grid/256" , OFFSET(dst_v_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513 }, -513, 512, VE }, - { "dst_h_chr_pos", "destination horizontal chroma position in luma grid/256", OFFSET(dst_h_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513 }, -513, 512, VE }, + { "src_v_chr_pos", "source vertical chroma position in luma grid/256" , OFFSET(src_v_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513 }, -513, 1024, VE }, + { "src_h_chr_pos", "source horizontal chroma position in luma grid/256", OFFSET(src_h_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513 }, -513, 1024, VE }, + { "dst_v_chr_pos", "destination vertical chroma position in luma grid/256" , OFFSET(dst_v_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513 }, -513, 1024, VE }, + { "dst_h_chr_pos", "destination horizontal chroma position in luma grid/256", OFFSET(dst_h_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513 }, -513, 1024, VE }, { "sws_dither", "set dithering algorithm", OFFSET(dither), AV_OPT_TYPE_INT, { .i64 = SWS_DITHER_AUTO }, 0, NB_SWS_DITHER, VE, .unit = "sws_dither" }, { "auto", "leave choice to sws", 0, AV_OPT_TYPE_CONST, { .i64 = SWS_DITHER_AUTO }, INT_MIN, INT_MAX, VE, .unit = "sws_dither" },