From patchwork Sat Sep 14 10:45:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51587 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:9fc3:0:b0:48e:c0f8:d0de with SMTP id k3csp305326vqy; Sat, 14 Sep 2024 04:24:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW0l9Go5DxqbH6DEjVzdQs4mb6ATRSuYcLMbOeJS/iWS0XZORZa5fdtNjAIgf/PxQf72lXps3qVifYl66mhk57k@gmail.com X-Google-Smtp-Source: AGHT+IFGQrDH4VDsUpkL9QLXQ4AMs6akEQxYKqJCs9+tM90KzxD39rDwoLobPttEbzp5od9SAXam X-Received: by 2002:a05:6402:1f49:b0:5a2:5bd2:ca50 with SMTP id 4fb4d7f45d1cf-5c413e4a430mr7415592a12.25.1726313059356; Sat, 14 Sep 2024 04:24:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726313059; cv=none; d=google.com; s=arc-20240605; b=V8c950Z0mcl0KsNqBupS0QzVxdILRtxJQLYepSd6TF5ViVTAwgdxp4Hzbh3Ufv7+vJ YiZqXgb1DCXfX9oWN6SbeAuYR3Slfpi1iRT6z51u/tqX0aoZq/lWwciFjZdAwMqw2k8p bc7iGpZi6BqdODy9Ml6q07m4d1BkGfPDgY6+DZrWgeFaDxjNhb+TuPvpzoY7G5qLfOHB ZUMuBtF553emI0zgPqoJadMoiJLGj/HEBaowD8zqyt/8A16lEsk9ZXZP5zoQbrn3HMVR 3Id8ma8l0A0K1e3ahF85uNCgAsownYzALWJlmnYc9uKVZ/6zJprlo4AXGUVaSf+bGaKM 9ydw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=9KM0df2x9DKydAiCS/6/F1zOGQsEu3AdM8LMGKMuCQ8=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=F+8aD0LVV8bjT9qqeJqLMADOGfrdb+ydMjzSyXphlDDhclD6VhYOMQPuqF2HkRcw6J yqGB3DIeGVyIwGvD0F4twvf5AWjv2YAlkY6bJ02uOo8ICJwCDZ+KT6GqpIhqRoDws8Y1 CFnTJFajrMKUBtNyIyI6m+CLXI6ALe7qm3hs1WmVkQtOp1kvWPeFWJssyeJcUvwXLCh4 4q6YiDcwKQwAhRTN4333+yPP/ABDTRpidXsCMPQQG8SK0qSl8PTXy9w3mcxKUjfWdWbS 1E9LiiDOXMLmGDLm1zdigBBB5WYZ3kIHitxlgBJkc0FOPSvpGgxobTs2IAqNijGUzkWO pn7A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=rH+YIBeY; 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-5c42bcad6cbsi894019a12.590.2024.09.14.04.24.19; Sat, 14 Sep 2024 04:24:19 -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=@khirnov.net header.s=mail header.b=rH+YIBeY; 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 12DAF68DEBC; Sat, 14 Sep 2024 14:11:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 594C568DDB8 for ; Sat, 14 Sep 2024 14:10:54 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=rH+YIBeY; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 723934E18 for ; Sat, 14 Sep 2024 13:10:53 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id wBm-eDz8cq7r for ; Sat, 14 Sep 2024 13:10:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1726312247; bh=7K/ZePx6g8YsvW3xlAQjL4Ml731S26xthAl/ld0zQgI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=rH+YIBeYG285j/bBPNLLTlQ5+gKinP2CdzPm+hPWwtdEoHoeyaFwUiUjmCk5bXmpC /AsEUmEcRsNJWZrbmnkau2JsGHf81SqTdF9gyJVlgBf4O8y7Jh35vPKv1A/GFlmlg6 lA8pDN4K95KQRAj/3uIAK6j/HTn0fqheHmAqakEIyCgGZq+rfQUhlb2Df+C9zfmXL3 PGvvTt0WgaoI7HhYTnjBdw+ANqYzMkl41kw8HeyrIumpijSnKjsuJHpQBha0z/GGV4 01R5CnDFp94G2jQgSbJ/CiAdWHYLSiand7QwTvx3UbsFvW8zvbN//sh7gIOIzN6jNp dZs+jydpgkF0Q== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id AA7FC4E2B for ; Sat, 14 Sep 2024 13:10:47 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 0914F3A0F41 for ; Sat, 14 Sep 2024 13:10:41 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 14 Sep 2024 12:45:29 +0200 Message-ID: <20240914111036.17164-5-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240914111036.17164-1-anton@khirnov.net> References: <20240914111036.17164-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/23] lavfi/f_select: allow selection based on view ID 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: /2vEf1cZzNFa Can be used together with the split filter to decompose multiview video into individual views. --- doc/filters.texi | 3 +++ libavfilter/f_select.c | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/doc/filters.texi b/doc/filters.texi index db2f4b7ea7..428986a1e9 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -31111,6 +31111,9 @@ Represents the width of the input video frame. @item ih @emph{(video only)} Represents the height of the input video frame. +@item view @emph{(video only)} +View ID for multi-view video. + @end table The default value of the select expression is "1". diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c index 6ba96bd7c5..ba0ae31f1b 100644 --- a/libavfilter/f_select.c +++ b/libavfilter/f_select.c @@ -93,6 +93,8 @@ static const char *const var_names[] = { "ih", ///< ih: Represents the height of the input video frame. "iw", ///< iw: Represents the width of the input video frame. + "view", + NULL }; @@ -150,6 +152,8 @@ enum var_name { VAR_IH, VAR_IW, + VAR_VIEW, + VAR_VARS_NB }; @@ -343,6 +347,7 @@ static void select_frame(AVFilterContext *ctx, AVFrame *frame) SelectContext *select = ctx->priv; AVFilterLink *inlink = ctx->inputs[0]; FilterLink *inl = ff_filter_link(inlink); + const AVFrameSideData *sd; double res; if (isnan(select->var_values[VAR_START_PTS])) @@ -381,6 +386,10 @@ FF_ENABLE_DEPRECATION_WARNINGS snprintf(buf, sizeof(buf), "%f", select->var_values[VAR_SCENE]); av_dict_set(&frame->metadata, "lavfi.scene_score", buf, 0); } + + sd = av_frame_side_data_get(frame->side_data, frame->nb_side_data, + AV_FRAME_DATA_VIEW_ID); + select->var_values[VAR_VIEW] = sd ? *(int*)sd->data : NAN; break; }