From patchwork Thu Jul 4 11:51: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: 50325 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:cc64:0:b0:482:c625:d099 with SMTP id k4csp3658170vqv; Thu, 4 Jul 2024 04:54:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW6MSqcL9u19OcOjlqpkSmAVbMkAasA8qxk/BKuA1En9JIh61xNUNel6WsjdwfgeuxrdUR1dFLnpBN0ZXSwpi+ewgc2ggM2ocsv3w== X-Google-Smtp-Source: AGHT+IH8RHQIBNeJoqAGSh0tVksMDPDdW5pMZ/UrZ57xwMTdMpBd0UmziFaPBS1VrKhPsF9fLP4d X-Received: by 2002:ac2:5b0e:0:b0:52e:9fda:f18a with SMTP id 2adb3069b0e04-52ea06cbe66mr917074e87.44.1720094043248; Thu, 04 Jul 2024 04:54:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720094043; cv=none; d=google.com; s=arc-20160816; b=SSYEDT9+g2maleHYwqugp6ykC8qDlGJZU6HQCycMyu/VyZFgFtDpBrQ+p+jgwtaOJc mgnHAvI8NudP8+q1gDf2ROD6NmxcLjRfRULMnc7D/JvHw+QFJVm4z44cQMA0C0Kblw/y bVpEdzR1ueZgJs2T8WY9IOL9CStoIP5fIjDkWLawowh1WdxbiVgQy00NbUJM2k7PPPhl Ep6GEOnwmXghWYMLM/gxo4MVQ8XH6Bc4t7hbcKmsIs8WD7yWXGwL0kgetu5d9kExn6mD LuuARx23E4ynmUyhomwHDWFImph+WgmikHrzjN9+S0t05jie3a9/eOnGX2+3VHE8023W s58g== 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=S1mYzoyil/2rhKDF/fY9QBw2ugyoGY+bs0RMkYIUSS+sPwvfxu92Gp/i1rxJ3LMwyE Ri+qpONU1z2EAxS1t1Ec+XY7Ua12MXxO4fb8OtMQsTLarsCxyg7CTVWePmHqbqufmbQ5 jC2wmZovBTLRMyNLtyAOUGCOdBdaND12CBH8BMyk6xgV33BeClT5Iz5MDGdHcbUdr89t 3YJspEZXUf8BWhAaGM9F3ZKZT2WyKWm31WH6JA/j+vvv2sJs75C2h5A6YaLG5MPcLt+a Enhlzy9cYKCvZNEI8f2hqqaZkI7IIiCu1E0O7xiDsjn3g0KY2B4eQx62+LKTGV9Y+/Il cUWg==; 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=quiL41ab; 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-58d8873ab76si1249774a12.320.2024.07.04.04.54.02; Thu, 04 Jul 2024 04:54: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=quiL41ab; 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 EC70F68D9DA; Thu, 4 Jul 2024 14:53:59 +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 E253368D9DA for ; Thu, 4 Jul 2024 14:53:50 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1720094030; bh=dRaAxaJdeXgnr5OlANUQFjp62oieGYX7zyJCc7x2UYY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=quiL41ab2LFSlc6gGxAiCeIicki5zLdV3Xu1Xa9tnn/1hXJ7X3a3FLRjtjNXTzupx 4ztoTi+7EfhJ+GVYgAxmiJo1BbfbRWGpDIkSL64QHIM0t9yUGKbDW2cPQJ800IJAL6 etkquAyP/KEMSrFcArfUlejQdavbGNX05IWEluN0= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 12DD04033D; Thu, 4 Jul 2024 13:53:50 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Jul 2024 13:51:58 +0200 Message-ID: <20240704115202.1235954-2-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240704115202.1235954-1-ffmpeg@haasn.xyz> References: <20240704115202.1235954-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/6] 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: aqMqOUzfRGpK 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); }