From patchwork Thu Jul 4 14:30:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 50332 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:cc64:0:b0:482:c625:d099 with SMTP id k4csp3754397vqv; Thu, 4 Jul 2024 07:31:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXdu2/xZVtPF44uAWVCU2EvZgiagC6ueh4rO3oD7mJTSM3iAdHTuja49ayNz6FJGc3DW5zWZxcqsSSqOyR+oRbW7wblNQIJgvxZSg== X-Google-Smtp-Source: AGHT+IFBHtfGBOv9/p5FG77HoFMIu62ta+5vq7By+Oi0yT7Sydn5o4x23bgm3V3Yo7jOFUE5wClF X-Received: by 2002:a05:6512:3b27:b0:52c:9ab1:a312 with SMTP id 2adb3069b0e04-52ea06157c6mr1729248e87.4.1720103484533; Thu, 04 Jul 2024 07:31:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720103484; cv=none; d=google.com; s=arc-20160816; b=w1RJQzk3iLJ3PyVpY9XZ/mfuKaAtvo82orsRa/gPQaHd5igu0U80/Ij47FcMBBOj4j /GUjg1XHpnue2e0+4fUXI3frvB1A3cGQQO45NeA6i1ngvkHsj3FnG+QNwT68r6HHfSGM GXFGR8TnuLJNPD/cALmX6d6mj0ZwppzomIGYt7tdtqtpRJEwBIRbjuLNs6dpmoddGLDP 1gjQ7xy7ghpPd9E6SV0PS9WoLCui62eY/fZICyBkP8bJoupKQ6HYq7eK4j5WpqCuLGk2 6waFfGLvKjn4tCH1CZuY/aKfxV4Omx1i0ofdIRzwAGA8F9+BAXiahaLWLyEON62XEV32 VyBw== 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:message-id:date:to:from :dkim-signature:delivered-to; bh=531542hJeTFDZmpCYDoxmu5f5Tb21Er2a4er3bcJesQ=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=epBEpieLB+VjNEtNqTSCs8XiK08oPz6TvEq4Xv1Si65u960ZjE7yVVSJjXb5X8jXzr c6EQ+Gh+YFL3kFo1Mn2s7pk7tKlEh5rszcd/BWM/2sq2SXJcNORWpXtvwXIJ6IYFpKXb 8MJQzfRL1cwaunp2Ez/CXedcwwj+P5hSHlY1HH0H/xvsuRUCt+Y4HptZ6zszfSuwOQ2z EBKcfb5ZjavRwR1RaxIV5W1BToWDB+LIIXceK2QV7qF2TcuPt4wEt+znqqwqqiHVT1/X joo5zuqov+25ZVYpc2vYUahguNjfr6I5Mmt9wJ93AM6KZx1ewps/4ZyketBvkWBz6uQn oW/Q==; 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=kT8OJSwC; 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-52e7ab2584asi4416970e87.263.2024.07.04.07.31.24; Thu, 04 Jul 2024 07:31:24 -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=kT8OJSwC; 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 466D768D9AE; Thu, 4 Jul 2024 17:31:15 +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 2AFA268D905 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=1720103466; bh=njzY9Ocn/6dWnV/LQc9JDqH9/D813PFysJ01a37js5I=; h=From:To:Cc:Subject:Date:From; b=kT8OJSwCMaVGjeGJsa7ZGS86ezkRPZpRu7gL25xoC/HaIEQwF3VY2kVQbYBlZiOxT fr3kTOnV7dspZjrFxv1H0eOqRW53/ZaSH8KIy8dMFExjy9SGzaHZ+pm1UtuVbFV2iC yvWrnpVE+28axhDsAPsOGIMOhmAVBA/rKG6gXepA= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id CB280402F2; Thu, 4 Jul 2024 16:31:06 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Jul 2024 16:30:57 +0200 Message-ID: <20240704143104.1821386-1-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/8] swscale: document SWS_FULL_CHR_H_* flags 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: tAl5ZZK6WoF7 From: Niklas Haas Based on my best understanding of what they do, given the source code. --- libswscale/swscale.h | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/libswscale/swscale.h b/libswscale/swscale.h index 9d4612aaf3..e22931cab4 100644 --- a/libswscale/swscale.h +++ b/libswscale/swscale.h @@ -82,11 +82,35 @@ const char *swscale_license(void); #define SWS_PRINT_INFO 0x1000 //the following 3 flags are not completely implemented -//internal chrominance subsampling info + +/** + * Perform full chroma upsampling when converting to RGB as part of scaling. + * + * For example, when converting 50x50 yuv420p to 100x100 rgba, setting this flag + * will scale the chroma plane from 25x25 to 100x100 (4:4:4), and then convert + * the 100x100 yuv444p image to rgba in the final output step. + * + * Without this flag, the chroma plane is instead scaled to 50x100 (4:2:2), + * with a single chroma sample being re-used for both horizontally adjacent RGBA + * output pixels. + */ #define SWS_FULL_CHR_H_INT 0x2000 -//input subsampling info + +/** + * Perform full chroma interpolation when downscaling RGB sources. + * + * For example, when converting a 100x100 rgba source to 50x50 yuv444p, setting + * this flag will generate a 100x100 (4:4:4) chroma plane, which is then + * downscaled to the required 50x50. + * + * Without this flag, the chroma plane is instead generated at 50x100 (dropping + * every other pixel), before then being downscaled to the required 50x50 + * resolution. + */ #define SWS_FULL_CHR_H_INP 0x4000 + #define SWS_DIRECT_BGR 0x8000 + #define SWS_ACCURATE_RND 0x40000 #define SWS_BITEXACT 0x80000 #define SWS_ERROR_DIFFUSION 0x800000 From patchwork Thu Jul 4 14:30:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 50339 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:cc64:0:b0:482:c625:d099 with SMTP id k4csp3764492vqv; Thu, 4 Jul 2024 07:49:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUqw0JhSsalzmifi8Zvqrqs9oPNU9TqRPvHvjYD1Tc7uKegzexRktd1wc7oUoM0h6soACQ1w49P1K0JvGTjQkGWhyqY9YENWKbuNg== X-Google-Smtp-Source: AGHT+IENMaDVxoMQSXnZ/ooNUGNdTcKtBs5N4vVKMbxickg+RJ1H2hXS3bvkf92gPHXfwZiZBdNu X-Received: by 2002:a05:6512:3e19:b0:52e:7542:f469 with SMTP id 2adb3069b0e04-52ea04352edmr2269606e87.0.1720104548871; Thu, 04 Jul 2024 07:49:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720104548; cv=none; d=google.com; s=arc-20160816; b=MH9Mu428HB2CKkVXYW08gxzwrG3gZJTNi01lGKXlT5bzeFX2Zb/Q/EKB5TLNIjy6zr eMATe6tJdQRra6Y1MD5xEML0nAu2fBSp+kOpZjXik36i/9lK6suTjgjxtacqgeaaTCRS Qjuu3ak8YrRcVXzVpWAsSMSqyCb/qnkIZi9oVcDFn+TLRNew5TZW8KjzIwmuyZDNn+0P DseGzUeKaWxyjbpQ64XFtumBHNVajZ3wTGI6b9A7D/3Xs/+lFvSpTfziBSv0XjMhI88s Ci+K8bb5BMLVcW/6DzLMrcO2bwnbFNFJ4bwaigPd5PQgakeae1gveMwq0hLrZjwVVKK9 pt4w== 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=hXB2lwVPaIKpGLxEArgZI78H0KBho68NRciyDkLVE4c=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=t+aEj0yEBw0szuxkAY6gM5ATwm0LMkfS25TMdIDPYVxFmDnbWDNg2D5kOeZGUVgLZz coopYQnmwfcOlK1B4EJaOHtcr6c0hOdEJj7P1ydSc/ClJYof3S4MVzFrI1y+hB0WO93F ZmBgvByvKs0V7+O5PJdeKjTaR3GzioIzcWYtZ2X4RIzbn9QC7ti/hseq4EDF0wpmAFgl vxBKrqcoT4CAO4b7nP04xAe0kMZgKsrtuSncyBc5jOjZg5AWtexKGJmcOOQ2ZfX2Efus C9VRlFHPcfOrBmY7btlOMmc6gRWrSm7MXI1Zu4/SyvVQJDsJsKXzu4ZyuK4sIIDmr/jd iFHw==; 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=V+AqU2+V; 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-52e99fddd2dsi998366e87.578.2024.07.04.07.49.08; Thu, 04 Jul 2024 07:49:08 -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=V+AqU2+V; 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 0F07F68D9FA; Thu, 4 Jul 2024 17:31:17 +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 4DBFF68D9AE 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=dRaAxaJdeXgnr5OlANUQFjp62oieGYX7zyJCc7x2UYY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V+AqU2+V8eeBrj3II1xtei6UrLbZezdWEhDTefCorxmhHgUSHuBt8eB2uu+thSEXx jVH8Yd1p6TRr2w+GHtbCVrGtHFKxRs9JUjDBAXadXFWF8d+NjBTxtFBBG0ApvdfJmw PeOuLjEGvaM9m8uyndrb1U5PVbG9+wUnzrKYsirg= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 0DA94405C5; Thu, 4 Jul 2024 16:31:07 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Jul 2024 16:30:58 +0200 Message-ID: <20240704143104.1821386-2-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 2/8] avfilter/vf_setparams: allow setting chroma location 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: XdBJN989mIca From: Niklas Haas Shockingly, there isn't currently _any_ filter for overriding this. --- doc/filters.texi | 17 +++++++++++++++++ libavfilter/vf_setparams.c | 19 ++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index c9c4f7cf6b..ca8f6e461a 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -22073,6 +22073,23 @@ Keep the same colorspace property (default). @item chroma-derived-c @item ictcp @end table + +@item chroma_location +Set the chroma sample location. +Available values are: + +@table @samp +@item auto +Keep the same chroma location (default). + +@item unspecified, unknown +@item left +@item center +@item topleft +@item top +@item bottomleft +@item bottom +@end table @end table @section sharpen_npp diff --git a/libavfilter/vf_setparams.c b/libavfilter/vf_setparams.c index b7da8eb54b..ba32a6699c 100644 --- a/libavfilter/vf_setparams.c +++ b/libavfilter/vf_setparams.c @@ -41,6 +41,7 @@ typedef struct SetParamsContext { int color_primaries; int color_trc; int colorspace; + int chroma_location; } SetParamsContext; #define OFFSET(x) offsetof(SetParamsContext, x) @@ -119,6 +120,17 @@ static const AVOption setparams_options[] = { {"chroma-derived-c", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_CHROMA_DERIVED_CL}, INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"}, {"ictcp", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_ICTCP}, INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"}, {"ipt-c2", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_IPT_C2}, INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"}, + + {"chroma_location", "select chroma sample location", OFFSET(chroma_location), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCHROMA_LOC_NB-1, FLAGS, .unit = "chroma_location"}, + {"auto", "keep the same chroma location", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, FLAGS, .unit = "chroma_location"}, + {"unspecified", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_UNSPECIFIED}, INT_MIN, INT_MAX, FLAGS, .unit = "chroma_location"}, + {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_UNSPECIFIED}, INT_MIN, INT_MAX, FLAGS, .unit = "chroma_location"}, + {"left", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_LEFT}, INT_MIN, INT_MAX, FLAGS, .unit = "chroma_location"}, + {"center", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_CENTER}, INT_MIN, INT_MAX, FLAGS, .unit = "chroma_location"}, + {"topleft", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_TOPLEFT}, INT_MIN, INT_MAX, FLAGS, .unit = "chroma_location"}, + {"top", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_TOP}, INT_MIN, INT_MAX, FLAGS, .unit = "chroma_location"}, + {"bottomleft", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_BOTTOMLEFT}, INT_MIN, INT_MAX, FLAGS, .unit = "chroma_location"}, + {"bottom", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_BOTTOM}, INT_MIN, INT_MAX, FLAGS, .unit = "chroma_location"}, {NULL} }; @@ -174,17 +186,18 @@ FF_ENABLE_DEPRECATION_WARNINGS frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST; } - /* set range */ + /* set straightforward parameters */ if (s->color_range >= 0) frame->color_range = s->color_range; - - /* set color prim, trc, space */ if (s->color_primaries >= 0) frame->color_primaries = s->color_primaries; if (s->color_trc >= 0) frame->color_trc = s->color_trc; if (s->colorspace >= 0) frame->colorspace = s->colorspace; + if (s->chroma_location >= 0) + frame->chroma_location = s->chroma_location; + return ff_filter_frame(ctx->outputs[0], frame); } 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" }, From patchwork Thu Jul 4 14:31:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 50336 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:cc64:0:b0:482:c625:d099 with SMTP id k4csp3759214vqv; Thu, 4 Jul 2024 07:39:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU+y+hExQOQsTJoDBB5bP897Ton+2zawka56J6D1C3iY5u93phuLxqVaImNjppXcLWkaluGx0uzWwtYxJju7IlVp3fEIuLVle7wJA== X-Google-Smtp-Source: AGHT+IHuiOfkIWng1KBfxQ7cPpVV5WfAf39xM62pY+ClMRpFb6H3RNUj9HsjuXZ2miZizPYRp9l9 X-Received: by 2002:a05:6402:254c:b0:57a:2fe7:6699 with SMTP id 4fb4d7f45d1cf-58e5abdb3b0mr1435761a12.14.1720103950523; Thu, 04 Jul 2024 07:39:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720103950; cv=none; d=google.com; s=arc-20160816; b=WQvZdPTwkmCJAG73eam3CQRLwMAz8hkdkeeFysAFW852E2jpaiYATkygmq1Wr6fWYM st4RT/YWepSuuOpok81dC6OYJoykZRx83nSF7Ig7MTQk3lnFhaXhsi3WbVQLDn/ZgG6G NVA7j05HthX2S5jVv5O3r8cVBU0AdyODWZJbvIL4cHG3svGsw70AZ/lGFj3LnkHRt61u LNKemb3v73lNCNuZk93ckx0Th+l8DoITUpZDpdnZgnvUTHYBAeScQcFEdw7HIRsc4I52 qhBq1bTG4e/R1Ia425EbnmSZSUYICrfpABop5xJFqhYlCH5R4oGVR1HHn1h+OjjOrk5d oCSw== 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=oGhMEOzfMXGtDYddgsjzWvllwAiQGCH/nVqaLtb/1aY=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=eYAXC8Quf8+mDvcGArwLwpp+qyh5aCVZu6dB7ftvL4rtfQXu0tmstUlIwrALACXIUF QsNSHfRfJ/nextljQYjQHwWAmw3jGXbMBFRZKdjbZsPkqT4tWh0Hqgl9RXJLTXK7VnUD dT8BKBFE/eZLv3zU+in4jD+zMJjB1tuOr5fBAU9NWucD8Jg0pVkLXHHeLfexeD/iuva+ FytBjNSSBZWMbajoqdEUEa+cX1V1RjkKWrQ+wVy7jI3pc38c7YC/9tSoggIA4jL0h6Ef IFNKWNX3exhUUjBXyTOsr1ZkDmDRQqbl32lwMqWHVbKZBgq0e4YuOlajh2NsqJt/tgQB srXw==; 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=JB17UmTZ; 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-58c028764fasi2579419a12.546.2024.07.04.07.39.09; Thu, 04 Jul 2024 07:39: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=@haasn.xyz header.s=mail header.b=JB17UmTZ; 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 F10EC68D9BF; Thu, 4 Jul 2024 17:31: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 D3FC468D9AE 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=95knvmWuOEtA4tyVc+nJk7D7pMYalEilxDEYKoRMMsg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JB17UmTZI0ut8bVqmVxsE0qZBxFSWjGbDYIvBah2Xk9bFB1Su5QkVCExO5KlIFBMt 66MQgmhd69bsVPI4kzc1wRQrMdaEZnr8HZ2e+KBhR1vrfJYkUxiIK+syI1yOYUkBuI YM2AaNbjUe5FCGKjuXKzCog0UGo4ljolXH2fO57Y= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 80DFA408E3; Thu, 4 Jul 2024 16:31:07 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Jul 2024 16:31:00 +0200 Message-ID: <20240704143104.1821386-4-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 4/8] avfilter/swscale: always fix interlaced chroma location 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: vjwA9sFC27ZC From: Niklas Haas The current logic only fixes it when the user does not explicitly specify the chroma location. However, this does not make a lot of sense. Since there is no way to specify this property per-field, it effectively *prevents* the user from being able to correctly scale interlaced frames with top-aligned chroma. It makes more sense to consider the user setting in the progressive case only, and automatically adapt it to the correct interlaced field positions, following the details of the MPEG specification. --- libavfilter/vf_scale.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 841075193e..0b6701673f 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -709,12 +709,18 @@ static int config_props(AVFilterLink *outlink) * chroma positions. MPEG chroma positions are used by convention. * Note that this works for both MPEG-1/JPEG and MPEG-2/4 chroma * locations, since they share a vertical alignment */ - if (desc->log2_chroma_h == 1 && scale->in_v_chr_pos == -513) { - in_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192; + if (desc->log2_chroma_h == 1) { + if (in_v_chr_pos == -513) + in_v_chr_pos = 128; /* explicitly default missing info */ + in_v_chr_pos += 256 * (i == 2); /* offset by one luma row for odd rows */ + in_v_chr_pos >>= i > 0; /* double luma row distance */ } - if (outdesc->log2_chroma_h == 1 && scale->out_v_chr_pos == -513) { - out_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192; + if (outdesc->log2_chroma_h == 1) { + if (out_v_chr_pos == -513) + out_v_chr_pos = 128; + out_v_chr_pos += 256 * (i == 2); + out_v_chr_pos >>= i > 0; } av_opt_set_int(s, "src_h_chr_pos", scale->in_h_chr_pos, 0); From patchwork Thu Jul 4 14:31:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 50333 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:cc64:0:b0:482:c625:d099 with SMTP id k4csp3754859vqv; Thu, 4 Jul 2024 07:32:04 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVSoK6VpG9Y9AeFY48dvGkV6g6ikD3yRSaNd3RqqIgGSJiQxrkWtrbTSMI7sULgS1VoyoTVVAUi2Lk+MDatPeruHidFc70ld6NCUQ== X-Google-Smtp-Source: AGHT+IGDfdIXGSB2oMkABBZ5eKBqxMupkfvVZUvv0XA7i9fOqC5uWGb96zA2yZmIYUN42NInm6zk X-Received: by 2002:a17:906:f753:b0:a6f:1872:4e1f with SMTP id a640c23a62f3a-a77ba84a5fbmr113379366b.77.1720103523987; Thu, 04 Jul 2024 07:32:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720103523; cv=none; d=google.com; s=arc-20160816; b=cGIBP7LKX/Z3+WGMzLmBjimn1SJc9M8pPEDHvq7xH+SNZJOI92zkFD8z+KM1j8Ihzn P1m6tPMZgLrxnB3BCKiVl+jErjLh4ojc4aJaSkvGBjGR+sCaJGSXWESjMez9s/xsJ+BS 6IoXDSM983rrofEi8lJfx8aL9iy6DGlorQzdQr4bi+rdPOyh/+4MAKhmLMbVkPgo2o20 vodixGBId7HxGLAsK6oKL0PeocjuTNhBIsSzpMKHekFdT1XTZizE2CGQZbxr9YWykX+3 4gHehdKSSXZxMcBX+J5fRNGMeYlyvolWri3ywVep7UqJInb1zMQxBkxaubmmvmuHcReI Rrjw== 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=Ep4K2zu5ZiXSgdlpZGAHAlIrJtuwJCwK61/Z+R2hL+U=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=R5vYTpotFA8OIRRTcjg1Zmnogeg8sZfyygC1atz9DEQo+w3sXvWAmpeVu+nsQRgJCT v44M7w+x0WqScFqgx9tWe6M3ZKugHkt48y3hskAoQVgFcrh7qi1ixlHUgIAXc0SsMmzh fxnTLtr9Lcu7ut/Fk5oxJi11ceD671Zc5OCkl9AH0guY3ECHXhP0tjOZAw/SRES1c9pR LXo/tomsqOQbDpxGqqz7b1u5uge49nIUEk7Qh9ywsVN6A99RErjwzllLTqSd0Z8YvLDD 3wTJvvqY+rB3vSxQt0kwT/emXTvDtqSYCumYbg0QeMW5Odd7BdAjBAMBlEJlZXDtM/Zu +LJw==; 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=BFc84If2; 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-a72ab04a9f3si688376366b.366.2024.07.04.07.32.03; Thu, 04 Jul 2024 07:32:03 -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=BFc84If2; 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 2CB1E68DA24; Thu, 4 Jul 2024 17:31:23 +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 F338368D9C9 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=D5v0MOZlroThsb6dP6LBE3OQGcsdVuu3DrW6XJWo7WE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BFc84If2Hj4T5ihvCJOmqvkW8kz1PpBCSM8ePjvApCG/owwAr5m5XvuWMVmwmjuW2 OvKLSaJuVQ5Uxz9ktKNvA578iV6z88b8dLCwR7l/jJqn4d/emzICx14d/VsK2T9IRO LhDTY2LE1hSr1nF3qLGOxyQuliHr9tP40jxNAiF0= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id BC04F41A55; Thu, 4 Jul 2024 16:31:07 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Jul 2024 16:31:01 +0200 Message-ID: <20240704143104.1821386-5-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 5/8] avfilter/vf_scale: add in/out_chroma_loc 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: sGXWEMODBb2J From: Niklas Haas Currently, this just functions as a more principled and user-friendly replacement for the (undocumented and hard to use) *_chr_pos fields. However, the goal is to automatically infer these values from the input frames' chroma location, and deprecate the manual use of *_chr_pos altogether. (Indeed, my plans for an swscale replacement will most likely also end up limiting the set of legal chroma locations to those permissible by AVFrame properties) --- doc/filters.texi | 15 ++++++++ libavfilter/vf_scale.c | 86 ++++++++++++++++++++++++++++++------------ 2 files changed, 77 insertions(+), 24 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index ca8f6e461a..3cff4eec1c 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -21137,6 +21137,21 @@ Set full range (0-255 in case of 8-bit luma). Set "MPEG" range (16-235 in case of 8-bit luma). @end table +@item in_chroma_loc +@item out_chroma_loc +Set in/output chroma sample location. If not specified, center-sited chroma +is used by default. Possible values: + +@table @samp +@item auto, unknown +@item left +@item center +@item topleft +@item top +@item bottomleft +@item bottom +@end table + @item force_original_aspect_ratio Enable decreasing or increasing output video width or height if necessary to keep the original aspect ratio. Possible values: diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 0b6701673f..b2c9d0b187 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -168,6 +168,8 @@ typedef struct ScaleContext { int in_range; int out_range; + int in_chroma_loc; + int out_chroma_loc; int out_h_chr_pos; int out_v_chr_pos; int in_h_chr_pos; @@ -617,6 +619,40 @@ fail: return ret; } +static void calc_chroma_pos(int *h_pos_out, int *v_pos_out, int chroma_loc, + int h_pos_override, int v_pos_override, + int h_sub, int v_sub, int index) +{ + int h_pos, v_pos; + + /* Explicitly default to center siting for compatibility with swscale */ + if (chroma_loc == AVCHROMA_LOC_UNSPECIFIED) + chroma_loc = AVCHROMA_LOC_CENTER; + + /* av_chroma_location_enum_to_pos() always gives us values in the range from + * 0 to 256, but we need to adjust this to the true value range of the + * subsampling grid, which may be larger for h/v_sub > 1 */ + av_chroma_location_enum_to_pos(&h_pos, &v_pos, chroma_loc); + h_pos *= (1 << h_sub) - 1; + v_pos *= (1 << v_sub) - 1; + + if (h_pos_override != -513) + h_pos = h_pos_override; + if (v_pos_override != -513) + v_pos = v_pos_override; + + /* Fix vertical chroma position for interlaced frames */ + if (v_sub == 1 && index > 0) { + v_pos += 256 * (index == 2); /* offset by one luma row for odd rows */ + v_pos >>= 1; /* double luma row distance */ + } + + /* Explicitly strip chroma offsets when not subsampling, because it + * interferes with the operation of flags like SWS_FULL_CHR_H_INP */ + *h_pos_out = h_sub ? h_pos : -513; + *v_pos_out = v_sub ? v_pos : -513; +} + static int config_props(AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; @@ -673,15 +709,16 @@ static int config_props(AVFilterLink *outlink) inlink0->h == outlink->h && in_range == outlink->color_range && in_colorspace == outlink->colorspace && - inlink0->format == outlink->format) + inlink0->format == outlink->format && + scale->in_chroma_loc == scale->out_chroma_loc) ; else { struct SwsContext **swscs[3] = {&scale->sws, &scale->isws[0], &scale->isws[1]}; int i; for (i = 0; i < 3; i++) { - int in_v_chr_pos = scale->in_v_chr_pos, out_v_chr_pos = scale->out_v_chr_pos; int in_full, out_full, brightness, contrast, saturation; + int h_chr_pos, v_chr_pos; const int *inv_table, *table; struct SwsContext *const s = sws_alloc_context(); if (!s) @@ -705,28 +742,17 @@ static int config_props(AVFilterLink *outlink) av_opt_set_int(s, "dst_range", outlink->color_range == AVCOL_RANGE_JPEG, 0); - /* Override chroma location default settings to have the correct - * chroma positions. MPEG chroma positions are used by convention. - * Note that this works for both MPEG-1/JPEG and MPEG-2/4 chroma - * locations, since they share a vertical alignment */ - if (desc->log2_chroma_h == 1) { - if (in_v_chr_pos == -513) - in_v_chr_pos = 128; /* explicitly default missing info */ - in_v_chr_pos += 256 * (i == 2); /* offset by one luma row for odd rows */ - in_v_chr_pos >>= i > 0; /* double luma row distance */ - } - - if (outdesc->log2_chroma_h == 1) { - if (out_v_chr_pos == -513) - out_v_chr_pos = 128; - out_v_chr_pos += 256 * (i == 2); - out_v_chr_pos >>= i > 0; - } - - av_opt_set_int(s, "src_h_chr_pos", scale->in_h_chr_pos, 0); - av_opt_set_int(s, "src_v_chr_pos", in_v_chr_pos, 0); - av_opt_set_int(s, "dst_h_chr_pos", scale->out_h_chr_pos, 0); - av_opt_set_int(s, "dst_v_chr_pos", out_v_chr_pos, 0); + calc_chroma_pos(&h_chr_pos, &v_chr_pos, scale->in_chroma_loc, + scale->in_h_chr_pos, scale->in_v_chr_pos, + desc->log2_chroma_w, desc->log2_chroma_h, i); + av_opt_set_int(s, "src_h_chr_pos", h_chr_pos, 0); + av_opt_set_int(s, "src_v_chr_pos", v_chr_pos, 0); + + calc_chroma_pos(&h_chr_pos, &v_chr_pos, scale->out_chroma_loc, + scale->out_h_chr_pos, scale->out_v_chr_pos, + outdesc->log2_chroma_w, outdesc->log2_chroma_h, i); + av_opt_set_int(s, "dst_h_chr_pos", h_chr_pos, 0); + av_opt_set_int(s, "dst_v_chr_pos", v_chr_pos, 0); if ((ret = sws_init_context(s, NULL, NULL)) < 0) return ret; @@ -987,6 +1013,8 @@ scale: out->height = outlink->h; out->color_range = outlink->color_range; out->colorspace = outlink->colorspace; + if (scale->out_chroma_loc != AVCHROMA_LOC_UNSPECIFIED) + out->chroma_location = scale->out_chroma_loc; if (scale->output_is_pal) avpriv_set_systematic_pal2((uint32_t*)out->data[1], outlink->format == AV_PIX_FMT_PAL8 ? AV_PIX_FMT_BGR8 : outlink->format); @@ -1217,6 +1245,16 @@ static const AVOption scale_options[] = { { "mpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_RANGE_MPEG}, 0, 0, FLAGS, .unit = "range" }, { "tv", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_RANGE_MPEG}, 0, 0, FLAGS, .unit = "range" }, { "pc", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_RANGE_JPEG}, 0, 0, FLAGS, .unit = "range" }, + { "in_chroma_loc", "set input chroma sample location", OFFSET(in_chroma_loc), AV_OPT_TYPE_INT, { .i64 = AVCHROMA_LOC_UNSPECIFIED }, 0, AVCHROMA_LOC_NB-1, .flags = FLAGS, .unit = "chroma_loc" }, + { "out_chroma_loc", "set output chroma sample location", OFFSET(out_chroma_loc), AV_OPT_TYPE_INT, { .i64 = AVCHROMA_LOC_UNSPECIFIED }, 0, AVCHROMA_LOC_NB-1, .flags = FLAGS, .unit = "chroma_loc" }, + {"auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_UNSPECIFIED}, 0, 0, FLAGS, .unit = "chroma_loc"}, + {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_UNSPECIFIED}, 0, 0, FLAGS, .unit = "chroma_loc"}, + {"left", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_LEFT}, 0, 0, FLAGS, .unit = "chroma_loc"}, + {"center", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_CENTER}, 0, 0, FLAGS, .unit = "chroma_loc"}, + {"topleft", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_TOPLEFT}, 0, 0, FLAGS, .unit = "chroma_loc"}, + {"top", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_TOP}, 0, 0, FLAGS, .unit = "chroma_loc"}, + {"bottomleft", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_BOTTOMLEFT}, 0, 0, FLAGS, .unit = "chroma_loc"}, + {"bottom", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_BOTTOM}, 0, 0, FLAGS, .unit = "chroma_loc"}, { "in_v_chr_pos", "input vertical chroma position in luma grid/256" , OFFSET(in_v_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513}, -513, 512, FLAGS }, { "in_h_chr_pos", "input horizontal chroma position in luma grid/256", OFFSET(in_h_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513}, -513, 512, FLAGS }, { "out_v_chr_pos", "output vertical chroma position in luma grid/256" , OFFSET(out_v_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513}, -513, 512, FLAGS }, From patchwork Thu Jul 4 14:31:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 50334 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:cc64:0:b0:482:c625:d099 with SMTP id k4csp3754960vqv; Thu, 4 Jul 2024 07:32:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUzdRmdosimUxkOpv7eH0KdpHWBESQoZsLWAz4qyVtwxR7PyBMbagQSYyB/wBBL0hBEgn5duR4mCdai2WKJVhwCGMsNJeTAjW/myw== X-Google-Smtp-Source: AGHT+IGPaTcs6UQyxaVC5bDEU7nCAQbwX1TJM7sZlhXzkDYlBthk35KIGyYGVVAW78RFu/PBNrJD X-Received: by 2002:a05:6402:84b:b0:57c:a7fe:d275 with SMTP id 4fb4d7f45d1cf-58e5b5a6320mr1492183a12.32.1720103533821; Thu, 04 Jul 2024 07:32:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720103533; cv=none; d=google.com; s=arc-20160816; b=womEaR3wMVWu8tcD+qDNWBFBBZ61PDzFOLHGiywEskQnR6bbL9hBY5YsPz0rZK/I4A /DFwzv4ogpWdW174z8w9+wYO239qrOfEponBisS88gYwFh1pfQiJPP/IJJGim87C3Gx9 bXt9fr4/zc3pVZippRQy/sVRf3G8A7aR2dEayLJmqr5bh2SIfrnS3seozRF4lN+BVX0r um8Ibgq9wSIF36b+Mr8z4V5RQFgkNUsygtDca2JLYBZpzSexzE4oaBVsNNaDIE3c4Sj0 pY7Y0U6zgPZ9XMVudNHIXRTU0bJJGwjwosTJ9bH7oqyLHFpEn6DrzWalK19DPcfsrgk8 Nxhw== 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=fgYpKfPdBGSzs+6g+mdPSbav3TGvLY90oy36qeZXlGc=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=npPjK7tbudvHsKU9uU92mJnAFVo+HTn7AMpjwAZd1frcVkm4ZS2I9avQcHO+hm/bLz GL7Magz5UdtbkgL8s/TVa8loxmU3johRssWyKLG8nKzYUAhB8zbXtLRmMBP9H9Wzp+1c q3zBIB13S3nagmsvOpt7HzKxLQ5563O0217Russ75l0M0a1VWEB//s6QwRuzTtHRwkzZ wUHPflxy1TXQpYR8addMhZajX8jOC7IERUtF8CtAqsDDlCTXxm6ImmJ5l67coC903uhf doYOrG75a23O/NQsxVeQ0COQ8aKVPfPKRs/3hlJ4NSLNDvJT6cPZacdB64Ub/IVcZEKj M1nA==; 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=El9KHwA1; 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-58c44d1a72esi2385210a12.79.2024.07.04.07.32.13; Thu, 04 Jul 2024 07:32: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=El9KHwA1; 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 C4A0868DA26; Thu, 4 Jul 2024 17:31:24 +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 609DA68D9FC for ; Thu, 4 Jul 2024 17:31:12 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1720103468; bh=2khgc9946s96WOy2dLPxdNHKKZN53lzbELU1p0FVRiU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=El9KHwA1of6JoIzshou/g0VP++UthnujzGRyxDQM8b67PWp9gGfmfRd0Yj3oEY0Tj 0Eyz1HmA7K66Z5t7nKT7yhcEHhdopKZVpB9VAGF0auf9l9QEVyiPAI+8KXBssX+dgo 3YZt+Vh4127SbYc5flIl+d+1Dv32YGfnR9VSsgpA= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id F26B041F18; Thu, 4 Jul 2024 16:31:07 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Jul 2024 16:31:02 +0200 Message-ID: <20240704143104.1821386-6-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 6/8] avfilter/vf_scale: fix 4:1:0 interlaced chroma pos 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: qlSOcI7icpKo From: Niklas Haas The current logic hard-coded a check for v_sub == 1. We can extend this logic slightly to cover the case of interlaced 4:1:0 (which has v_sub == 2). Here is a diagram explaining this scenario (with center-siting): a a a a a a a a b b b b b b b b X X a a a a a a a a b b b b b b b b a a a a a a a a b b b b b b b b Y Y a a a a a a a a b b b b b b b b a = even luma rows b = odd luma rows X = even chroma sample Y = odd chroma sample In progressive mode, the chroma samples sit at (384, 384) respectively. Relative to the 8x4 grid of even luma samples (a), the X sample sits at: h_chr_pos = 384 v_chr_pos = 192 Relative to the 8x4 grid of odd luma samples (b), the Y sample sits at: h_chr_pos = 384 v_chr_pos = 576 The new code calculates the correct values in all circumstances. --- libavfilter/vf_scale.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index b2c9d0b187..2d82141b70 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -642,9 +642,19 @@ static void calc_chroma_pos(int *h_pos_out, int *v_pos_out, int chroma_loc, v_pos = v_pos_override; /* Fix vertical chroma position for interlaced frames */ - if (v_sub == 1 && index > 0) { - v_pos += 256 * (index == 2); /* offset by one luma row for odd rows */ - v_pos >>= 1; /* double luma row distance */ + if (v_sub && index > 0) { + /* When vertically subsampling, chroma samples are effectively only + * placed next to even rows. To access them from the odd field, we need + * to account for this shift by offsetting the distance of one luma row. + * + * For 4x vertical subsampling (v_sub == 2), they are only placed + * next to every *other* even row, so we need to shift by three luma + * rows to get to the chroma sample. */ + if (index == 2) + v_pos += (256 << v_sub) - 256; + + /* Luma row distance is doubled for fields, so halve offsets */ + v_pos >>= 1; } /* Explicitly strip chroma offsets when not subsampling, because it From patchwork Thu Jul 4 14:31:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 50335 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:cc64:0:b0:482:c625:d099 with SMTP id k4csp3759209vqv; Thu, 4 Jul 2024 07:39:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW/Ixznh0U9TcJTPXVt5pXQkNfUzkkIZCq6QthO2Xep3XAqU0ytOtuUVSrv5YFcmkj8LI9szvE95rD3ZQ3bPv523AZrFGyjyDXtTA== X-Google-Smtp-Source: AGHT+IHbLHf/muvDaKcKYD/sqhL4koKt6OHhtEEu3rFoAwH9aeJ4vFRUVHbA9ZpSGcSdY44PtIq0 X-Received: by 2002:a2e:9c8a:0:b0:2ee:80b2:1ea9 with SMTP id 38308e7fff4ca-2ee8ee21297mr14529471fa.49.1720103949665; Thu, 04 Jul 2024 07:39:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720103949; cv=none; d=google.com; s=arc-20160816; b=fAGQrrmw/mwv8QGLPyQv0LMbd6XjoYdBQJ38ASQcqWsfP6W/SJsEOAGfwvvwDR6DXZ qMNfEYIUy6apaFDllaGgyOM11WC9BdczUNf2YRGmfJ+5cVqIW4gykbMedHHD6xRAwIFr ba0y+mAQQ6i3XprIJJU7WH2bhpjKeLhtHTqwXCxV4a0YmYlALJPVEPFcMAZ28+xEZEJv kKrlyelxhbi4e8xv/f6GSaNP2v/0XvxUVEtsJd36OSuzN9fn+WvYs0p75LcwpYmSubNu RCsVnIUZoC2Ie3sbuWaHnJES1cttUSVjGZo+Vf+ekuG3ptsU2NU0jpuLvZnb2XBxzkKl dI4g== 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=y0fY/Zv8nZCm8JrS6DIWPUPEcPO8CWHfOq5GOdMb0mU=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=GcmVlbli08DhGaxr/m6uZmVLmCrC7IALtSgWqwZ6++9RTZkMCMPKpESm9VuOh7dTDl p58vD5dGR5h/OnibpBVv0Tmu3jVHoRaHFAHM/9c2sQMEdUxKg8KlLOxckO2DAxgVZl7O mScFeBEFzfA+jeGUghFlOZGOv+/4gSKQznQ70PQM/Sn4KY3qlGc97/alR/V9wb/fTf34 JePaDwFVryyysz6Kt2pRZPeaw8u2wVars9Tvb1+ewo0gBzL0u/yajSc1Mhrt1Q3dbZmI M1gLjwms2pes2Fgtmopn7GJl4myoNsSGbE+KCi0PV75BoHI8YebcDIncWfSh3cd6ix4u Gi+Q==; 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=SIbu10GE; 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 38308e7fff4ca-2ee8a631916si6545441fa.442.2024.07.04.07.39.09; Thu, 04 Jul 2024 07:39:09 -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=SIbu10GE; 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 BA5D768DA2F; Thu, 4 Jul 2024 17:31:25 +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 65EAE68D9FE for ; Thu, 4 Jul 2024 17:31:12 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1720103468; bh=Ui+PxSpuFmRVqsLKEUrqqYrkFhws7zLSe4VSXZBhMis=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SIbu10GEdOmPMAVi6x09sD5ptrCWBRW8SD4LcYiC/83mst0CMTvW6qlmaD+X75cUb xuHcYhMVMsC6d1lQpzEpcwShWxLolKcWX01O1zgkDX0FYHJeaQ3VHCGsFV2HCF17Nr JbBbFHaqQJlduqLJmwx3OMGFx/2J/ACGeigXL2w8= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 3156342026; Thu, 4 Jul 2024 16:31:08 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Jul 2024 16:31:03 +0200 Message-ID: <20240704143104.1821386-7-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 7/8] avfilter/vf_zscale: remove unused fields 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: fYclOkTIDQ2C From: Niklas Haas --- libavfilter/vf_zscale.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c index 45f1bd25ce..dd0d1b7f46 100644 --- a/libavfilter/vf_zscale.c +++ b/libavfilter/vf_zscale.c @@ -108,11 +108,6 @@ typedef struct ZScaleContext { char *w_expr; ///< width expression string char *h_expr; ///< height expression string - int out_h_chr_pos; - int out_v_chr_pos; - int in_h_chr_pos; - int in_v_chr_pos; - int first_time; int force_original_aspect_ratio; From patchwork Thu Jul 4 14:31:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 50338 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:cc64:0:b0:482:c625:d099 with SMTP id k4csp3764481vqv; Thu, 4 Jul 2024 07:49:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXmCNzUyTbQ2V1X45/ZymMh1NmSabHsQwraxQQi6zXY7FZti5qcQHTWIykCY5K6kTMTiqS7dhlZ0OOZEATs54sqoKIWWjDGXCBD4A== X-Google-Smtp-Source: AGHT+IExifDI3UdnOM4NHVbsMRLt7tnKGXQl3UCf6+UxMMbqUeLDhd+oUlBfDnraR8lUERffuN67 X-Received: by 2002:a17:906:a415:b0:a71:ddb0:5206 with SMTP id a640c23a62f3a-a77ba709834mr128211366b.60.1720104547741; Thu, 04 Jul 2024 07:49:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720104547; cv=none; d=google.com; s=arc-20160816; b=f35JusfO6cZEu73UdvSL4ptU5PT+UDX2UZvJ3f30GoA6tOw39NkWhUlEgssIyn1Hoa LTCxQCCjuYal1gTfwrUNUOfgrJD+xjU8BWxZYdlm7qd99VWoPR0yvBbl9U06FyUNNp+z zM+auODsYbxLfjgiQF3AIK04WyF9AMIODnleg/cENJg82mRWyTy5lqaGQInIGhcjxbte Hz6C5L+uKcabjrRPApFdeecanj8GuSy2//w8DHX8mDuY0q33ktIV1F9Lsxkf5UN4ImRp sYGMzL0mUsgfFHzDgbhPz8iyA446GDaezmEgldxjfrbQAhM/3ZI9Eof6CYlg3ZFTTpyW Ajmw== 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=Ay9rV7Kkv1lLyi2AvqdIyXe7wj1QoE70pdDojtGgLnw=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=FCXJ5bjRPKGMNpQshwKbV7Hwj4bsg6AKt/ChBNlEHzvBj4VgFvLOMwABTLVxpjW6Ve G+rh04guas/TMiENxSDzyCqS/iCWjdmRaOS7hAZAG7HuN/0VeLnQklrET1D2wkIwmLZN qS1hPvF5CV7jyIiR5+4/H+KzErMV8u/Xw5p69bTBmprS5aFHT227DpCgRFNUpeEYN+S1 cmax8wo1Wc/RvqFWC4fsOvsQ7NNSNhinOyNyLbfleZKYX0UcVMi5T6GMQDnPxvyWWhcE ogiRl94XFI7ji3FiXPdLMlQOqc6PRQh58W36S708sMb3oSn555DTo5icJ6R0u2O4gVmQ pW/Q==; 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=rvjFwvKw; 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-a72ab096a8fsi684533166b.826.2024.07.04.07.49.07; Thu, 04 Jul 2024 07:49:07 -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=rvjFwvKw; 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 A2E7768DA3B; Thu, 4 Jul 2024 17:31:26 +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 7972668DA03 for ; Thu, 4 Jul 2024 17:31:12 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1720103468; bh=G8WTONKekV0epJ37oE1b2mJ08sFe7lI7Hu6EiAbNwNE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rvjFwvKwGq0D6z0POOV4hr0liMTeY6oDQ3gxtj1H04AEKr525C97WTD4eNk64ASlS +yBdcPEvadJxDreY+PZGhk5SqSrmLZpu2tKaCveA2UndRuudhjlRBFPjXYWICowuuu mgscCTIaiF03p/RvgMa60EfLITf6AM46rZ5R/qV0= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 78989426CB; Thu, 4 Jul 2024 16:31:08 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Jul 2024 16:31:04 +0200 Message-ID: <20240704143104.1821386-8-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 8/8] fate/scalechroma: switch to standard chroma location 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: xINC/n4d3I4r From: Niklas Haas Replace the manually specified chroma location by one using standard notation, arbitrarily "bottomleft" as it is a less common path. Required if we want to phase out the use of manual chroma locations. --- tests/fate/filter-video.mak | 2 +- tests/ref/fate/filter-scalechroma | 50 +++++++++++++++---------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index 7f8dc3aa27..cffd67b1f8 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -433,7 +433,7 @@ fate-filter-scale2ref_keep_aspect: CMD = framemd5 -frames:v 5 -/filter_complex $ FATE_FILTER_VSYNTH-$(call FILTERDEMDEC, SCALE, RAWVIDEO, RAWVIDEO) += fate-filter-scalechroma fate-filter-scalechroma: tests/data/vsynth1.yuv -fate-filter-scalechroma: CMD = framecrc -flags bitexact -s 352x288 -pix_fmt yuv444p -i $(TARGET_PATH)/tests/data/vsynth1.yuv -pix_fmt yuv420p -sws_flags +bitexact -vf scale=out_v_chr_pos=33:out_h_chr_pos=151 +fate-filter-scalechroma: CMD = framecrc -flags bitexact -s 352x288 -pix_fmt yuv444p -i $(TARGET_PATH)/tests/data/vsynth1.yuv -pix_fmt yuv420p -sws_flags +bitexact -vf scale=out_chroma_loc=bottomleft FATE_FILTER_VSYNTH_VIDEO_FILTER-$(CONFIG_VFLIP_FILTER) += fate-filter-vflip fate-filter-vflip: CMD = video_filter "vflip" diff --git a/tests/ref/fate/filter-scalechroma b/tests/ref/fate/filter-scalechroma index 842769c2d5..dbe08600ab 100644 --- a/tests/ref/fate/filter-scalechroma +++ b/tests/ref/fate/filter-scalechroma @@ -3,28 +3,28 @@ #codec_id 0: rawvideo #dimensions 0: 352x288 #sar 0: 0/1 -0, 0, 0, 1, 152064, 0xdcab783a -0, 1, 1, 1, 152064, 0x79c7f1f6 -0, 2, 2, 1, 152064, 0x3b810afb -0, 3, 3, 1, 152064, 0x892aca1d -0, 4, 4, 1, 152064, 0x52fdd093 -0, 5, 5, 1, 152064, 0xaa643426 -0, 6, 6, 1, 152064, 0x9ad020ed -0, 7, 7, 1, 152064, 0x5c179057 -0, 8, 8, 1, 152064, 0xa56bf155 -0, 9, 9, 1, 152064, 0x61dcffca -0, 10, 10, 1, 152064, 0x0d51a1d3 -0, 11, 11, 1, 152064, 0x652f9e8d -0, 12, 12, 1, 152064, 0xdc0bb4d8 -0, 13, 13, 1, 152064, 0x561437cf -0, 14, 14, 1, 152064, 0x69ef8e4f -0, 15, 15, 1, 152064, 0xe7244350 -0, 16, 16, 1, 152064, 0xe65651cf -0, 17, 17, 1, 152064, 0xfc9ff646 -0, 18, 18, 1, 152064, 0x6ae10bc4 -0, 19, 19, 1, 152064, 0xd3d1898a -0, 20, 20, 1, 152064, 0xf3f8b139 -0, 21, 21, 1, 152064, 0x68c129be -0, 22, 22, 1, 152064, 0xc3922593 -0, 23, 23, 1, 152064, 0x2b14d96e -0, 24, 24, 1, 152064, 0xab119489 +0, 0, 0, 1, 152064, 0x77bb80f8 +0, 1, 1, 1, 152064, 0x3a21f6e8 +0, 2, 2, 1, 152064, 0xcc0907b0 +0, 3, 3, 1, 152064, 0xaa5cd87b +0, 4, 4, 1, 152064, 0x410bd74d +0, 5, 5, 1, 152064, 0x7a763b14 +0, 6, 6, 1, 152064, 0x3e4020d4 +0, 7, 7, 1, 152064, 0x46be8b5d +0, 8, 8, 1, 152064, 0x8021f16c +0, 9, 9, 1, 152064, 0x82ca033d +0, 10, 10, 1, 152064, 0xa76ca6ca +0, 11, 11, 1, 152064, 0x49019bb7 +0, 12, 12, 1, 152064, 0x3590adf5 +0, 13, 13, 1, 152064, 0xf21235dc +0, 14, 14, 1, 152064, 0x6b5f93a9 +0, 15, 15, 1, 152064, 0x4b8c5137 +0, 16, 16, 1, 152064, 0x698b67cc +0, 17, 17, 1, 152064, 0x3cebef62 +0, 18, 18, 1, 152064, 0x77770da1 +0, 19, 19, 1, 152064, 0xecdd84d4 +0, 20, 20, 1, 152064, 0x873fbc32 +0, 21, 21, 1, 152064, 0x55043c82 +0, 22, 22, 1, 152064, 0xee2b3669 +0, 23, 23, 1, 152064, 0xa64ae990 +0, 24, 24, 1, 152064, 0xb3499e12