From patchwork Fri Jun 16 09:29:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42132 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1390522pzb; Fri, 16 Jun 2023 02:30:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ51mg0cV4kbTGjRPYLFfe0srhfDv7I/B1QL9VDA2PsVqZdO3SB8ZYn3f8A6jKC9SRNt8Ajo X-Received: by 2002:a17:907:cca0:b0:978:82fd:758b with SMTP id up32-20020a170907cca000b0097882fd758bmr835869ejc.29.1686907831040; Fri, 16 Jun 2023 02:30:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686907831; cv=none; d=google.com; s=arc-20160816; b=QBetxdQ89XK3VPv9ia0MFgEA0DFwLVBpCaEoXmMqQCP99Pbh9ZPRHgP5EvTjbzE8LY dX6EngdOqsTf2BH3Z4KUNgNf49zHWCubukVbqk2bd2H++9I47/lJskF92TLttaLzOLUy QjXp5P5lwfNX1WCuO20mo5CLbjdl0xQhgJjwceKTZyu8a3o6L089ThGYs06PUwBDVGd/ ChTC1/AedWnuvqMTTue2pQRUjPKA+PHLc4y70ZSWuDZ5qNu8rr0JlNuFXNOKuOr/R8dk j9fcbhO26h/hs5qiayC3122jOjRFVqMNSB9G4JLq69sQuT04BPrl/WcA0X+VkpQ847fr VcFg== 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=eeObws+OzfhBci6b3dfVBPRQacABsZcasptrrTtIoVM=; b=0210ysMl/1OCIjQWY6dsLWNc8SDslmPT7X+iJSRgsAlsPieX1rrK7jQPzargOEljnG AFY2fQR9b9vYSLcEyzkQ928kpPvUY+ui3dYlrLMAlZIiEAvoi7IRJabzap51mHhsIgVC /e1LPKIyvEVSBqLXee6TKVeq74VI1KhlsBjjRGNBWuqzKNUSdLHaY5nANZpln46U6j5X Yp2QE4lY0q1P16KlwVfk6K02UTDYx2Cf5T2+OW/FHANLgjlNnGImj4axGXFKHs22upNG 3MQ/cbev2y3QOXyxqf/FiZgBIxE9ZDzPQaa54F7Ytxn2wTZ4F4nLEGRL9DtYOkeb3LNc ZAUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=rCvH0lcA; 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 v7-20020a1709067d8700b0098696189723si55216ejo.43.2023.06.16.02.30.30; Fri, 16 Jun 2023 02:30: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=@haasn.xyz header.s=mail header.b=rCvH0lcA; 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 C8A3768C59A; Fri, 16 Jun 2023 12:30: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 485AF68C500 for ; Fri, 16 Jun 2023 12:30:20 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id E76E6401C9; Fri, 16 Jun 2023 11:30:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907820; bh=yp+lrFIFwttiY36r8ANOFFPfbkxhXePsTPwGMjApsxM=; h=From:To:Cc:Subject:Date:From; b=rCvH0lcAOcP8VT7uw7rk2NYD+E3jztfReLgNPVu1qjKStWmm7EGmvAEBOSLxJv+s8 eJAcDf5xc31c9fwSFiY8lD4MQc3Q23UhQg/21Vv/oAb8M7Oil9qfJ98aheJ2PsRD8V zuQEsXbxCsliaTDQUy78fnSt293wHq5WYeFp8PHg= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:38 +0200 Message-ID: <20230616092959.5247-1-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/22] lavfi/vf_libplacebo: drop redundant case 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: /5UC07tKObv1 From: Niklas Haas If the input queue is EOF, then the s->status check should already have covered it, and prevented the code from getting this far. If we still hit this case for some reason, it's probably a bug. Better to hit the AVERROR_BUG branch. --- libavfilter/vf_libplacebo.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 242c8a13f5..a048424cec 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -949,9 +949,6 @@ static int libplacebo_activate(AVFilterContext *ctx) if (!s->fps.num) av_fifo_drain2(s->out_pts, 1); return output_frame_mix(ctx, &mix, pts); - case PL_QUEUE_EOF: - ff_outlink_set_status(outlink, AVERROR_EOF, pts); - return 0; case PL_QUEUE_ERR: return AVERROR_EXTERNAL; } From patchwork Fri Jun 16 09:29:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42133 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1390636pzb; Fri, 16 Jun 2023 02:30:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7IuRnyzREh4g0uYEk5BOWV+zvEnYjOi+cfMOaZvbJh+0HKg29KXNhITmB31L8XWbWEasul X-Received: by 2002:a17:907:97cb:b0:979:7624:1f71 with SMTP id js11-20020a17090797cb00b0097976241f71mr1417585ejc.26.1686907842862; Fri, 16 Jun 2023 02:30:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686907842; cv=none; d=google.com; s=arc-20160816; b=WWKwvHJWzxO4jaW4AdMNtZcMNp22RIyt6626YqfEBs3jIODGbGGn5X6ZH9CaZwVPGc Y4XRuSqRGO7jmuOr2880r6zI8wjASGJ2eDUoEmixp5kpBb5/HtHiuZ4zLRvPILAPAI6a v1aEnWPr5fmplUsEpZ3JRB/mrljYYU1WHdP7LUWncqkjn6ZoYUFYcM+tes5f+QufU1UK SQOkgKPWSkUJq28UF3Zi2xbAOVeOtEbq4aVbSqkgoIPEhM9VS5AUMJ0ppxWy0cwdzWdG EXJl3PRDtMp2sa7YX9zwJFNenrM7+BgPgAP2vAcStQhtIB7OFDNICvVXHzZe0u5iCqo8 gNmg== 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=y1VlNYKng2Ofv476157X2oQ9N2vhUNGhR19Qerskx3g=; b=dSKtSVb1SLypnAjnlrYM9ygePcVcX1nLvy7vLzyu+Ug1zg1BWwQr2TW+yCaHUFu0f3 6YbOmQ6WoJH1nrtM/AR2gu4Y/izoaUKgBD1DBvf1/Itv/t7X8u7u5GQRerGD6rraiRCn HdndaBu0c4AIIPsCd+eX3zDk5VEu9DUTRrrHefJL0Nmg3bDmgRPss0YNjzeFdkLd2dGs 4klKaVM9EWmy5xHnBAf5ZyLx7GEqi8maeRPKkcPtCkY3vCrTK4/dKjyE/mzUabHV3GD0 x9ByomFqzwaj7IGRM9GGg8vMZdXxzEnV4irj59iQEiyf//VtY5lZQL8zPRowOCLJE5wL M7/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=YBTSl5mP; 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 gf5-20020a170906e20500b00977c9989f33si10311463ejb.858.2023.06.16.02.30.42; Fri, 16 Jun 2023 02:30:42 -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=YBTSl5mP; 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 0C6D868C597; Fri, 16 Jun 2023 12:30:28 +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 D1C5A68C500 for ; Fri, 16 Jun 2023 12:30:20 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id 870BE41B2C; Fri, 16 Jun 2023 11:30:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907820; bh=NZkdY9HQh/6ffmv2Q8E72w8z4j4LhcDeENFR8rSQhHo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YBTSl5mPFm/CVBJxP6mqDUZ9BkeehN/MqFbk/0J4SVpkBKnqyHmI0BkfURAQcsGjn aX4VgLN4lDa528RwmVYrOyWXzoGL8UwU4K+dn20vq8JUDD/RW+Jn0UMVwn+oItLQ3j 4rKCFLaDxlEFiVnLG2ffcJsk+OoUIa8KgD01r+gE= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:39 +0200 Message-ID: <20230616092959.5247-2-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/22] lavfi/vf_libplacebo: move input-specific state to struct 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: UhBct09anYLZ From: Niklas Haas In anticipation of a refactor which will enable multiple input support. Note: the renderer is also input-specific because it maintains a frame cache, HDR peak detection state and mixing cache, all of which are tied to a specific input stream. --- libavfilter/vf_libplacebo.c | 80 ++++++++++++++++++++++++------------- 1 file changed, 52 insertions(+), 28 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index a048424cec..10fd432745 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -113,6 +113,16 @@ enum var_name { VAR_VARS_NB }; +/* per-input dynamic filter state */ +typedef struct LibplaceboInput { + pl_renderer renderer; + pl_queue queue; + AVFilterLink *link; + AVFifo *out_pts; ///< timestamps of wanted output frames + int64_t status_pts; + int status; +} LibplaceboInput; + typedef struct LibplaceboContext { /* lavfi vulkan*/ FFVulkanContext vkctx; @@ -121,14 +131,10 @@ typedef struct LibplaceboContext { pl_log log; pl_vulkan vulkan; pl_gpu gpu; - pl_renderer renderer; - pl_queue queue; pl_tex tex[4]; - /* filter state */ - AVFifo *out_pts; ///< timestamps of wanted output frames - int64_t status_pts; - int status; + /* input state */ + LibplaceboInput input; /* settings */ char *out_format_string; @@ -536,8 +542,6 @@ static int libplacebo_init(AVFilterContext *avctx) RET(av_expr_parse(&s->pos_h_pexpr, s->pos_h_expr, var_names, NULL, NULL, NULL, NULL, 0, s)); - /* Initialize dynamic filter state */ - s->out_pts = av_fifo_alloc2(1, sizeof(int64_t), AV_FIFO_FLAG_AUTO_GROW); if (strcmp(s->fps_string, "none") != 0) RET(av_parse_video_rate(&s->fps, s->fps_string)); @@ -564,6 +568,28 @@ static void unlock_queue(void *priv, uint32_t qf, uint32_t qidx) } #endif +static int input_init(AVFilterContext *avctx, AVFilterLink *link, + LibplaceboInput *input) +{ + LibplaceboContext *s = avctx->priv; + + input->out_pts = av_fifo_alloc2(1, sizeof(int64_t), AV_FIFO_FLAG_AUTO_GROW); + if (!input->out_pts) + return AVERROR(ENOMEM); + input->queue = pl_queue_create(s->gpu); + input->renderer = pl_renderer_create(s->log, s->gpu); + input->link = link; + + return 0; +} + +static void input_uninit(LibplaceboInput *input) +{ + pl_renderer_destroy(&input->renderer); + pl_queue_destroy(&input->queue); + av_fifo_freep2(&input->out_pts); +} + static int init_vulkan(AVFilterContext *avctx, const AVVulkanDeviceContext *hwctx) { int err = 0; @@ -620,10 +646,7 @@ static int init_vulkan(AVFilterContext *avctx, const AVVulkanDeviceContext *hwct goto fail; } - /* Create the renderer */ s->gpu = s->vulkan->gpu; - s->renderer = pl_renderer_create(s->log, s->gpu); - s->queue = pl_queue_create(s->gpu); /* Parse the user shaders, if requested */ if (s->shader_bin_len) @@ -634,6 +657,9 @@ static int init_vulkan(AVFilterContext *avctx, const AVVulkanDeviceContext *hwct RET(parse_shader(avctx, buf, buf_len)); } + /* Initialize inputs */ + RET(input_init(avctx, avctx->inputs[0], &s->input)); + /* fall through */ fail: if (buf) @@ -649,8 +675,7 @@ static void libplacebo_uninit(AVFilterContext *avctx) pl_tex_destroy(s->gpu, &s->tex[i]); for (int i = 0; i < s->num_hooks; i++) pl_mpv_user_shader_destroy(&s->hooks[i]); - pl_renderer_destroy(&s->renderer); - pl_queue_destroy(&s->queue); + input_uninit(&s->input); pl_vulkan_destroy(&s->vulkan); pl_log_destroy(&s->log); ff_vk_uninit(&s->vkctx); @@ -664,7 +689,6 @@ static void libplacebo_uninit(AVFilterContext *avctx) av_expr_free(s->pos_y_pexpr); av_expr_free(s->pos_w_pexpr); av_expr_free(s->pos_h_pexpr); - av_fifo_freep2(&s->out_pts); } static int libplacebo_process_command(AVFilterContext *ctx, const char *cmd, @@ -826,7 +850,7 @@ static int output_frame_mix(AVFilterContext *ctx, } update_crops(ctx, mix, &target, ref_sig, out->pts * av_q2d(outlink->time_base)); - pl_render_image_mix(s->renderer, mix, &target, &s->params); + pl_render_image_mix(s->input.renderer, mix, &target, &s->params); if (outdesc->flags & AV_PIX_FMT_FLAG_HWACCEL) { pl_unmap_avframe(s->gpu, &target); @@ -886,7 +910,7 @@ static int libplacebo_activate(AVFilterContext *ctx) while ((ret = ff_inlink_consume_frame(inlink, &in)) > 0) { in->opaque = s; - pl_queue_push(s->queue, &(struct pl_source_frame) { + pl_queue_push(s->input.queue, &(struct pl_source_frame) { .pts = in->pts * av_q2d(inlink->time_base), .duration = in->duration * av_q2d(inlink->time_base), .first_field = pl_field_from_avframe(in), @@ -899,19 +923,19 @@ static int libplacebo_activate(AVFilterContext *ctx) if (!s->fps.num) { /* Internally queue an output frame for the same PTS */ av_assert1(!av_cmp_q(inlink->time_base, outlink->time_base)); - av_fifo_write(s->out_pts, &in->pts, 1); + av_fifo_write(s->input.out_pts, &in->pts, 1); } } if (ret < 0) return ret; - if (!s->status && ff_inlink_acknowledge_status(inlink, &status, &pts)) { + if (!s->input.status && ff_inlink_acknowledge_status(inlink, &status, &pts)) { pts = av_rescale_q_rnd(pts, inlink->time_base, outlink->time_base, AV_ROUND_UP); - pl_queue_push(s->queue, NULL); /* Signal EOF to pl_queue */ - s->status = status; - s->status_pts = pts; + pl_queue_push(s->input.queue, NULL); /* Signal EOF to pl_queue */ + s->input.status = status; + s->input.status_pts = pts; } if (ff_outlink_frame_wanted(outlink)) { @@ -920,22 +944,22 @@ static int libplacebo_activate(AVFilterContext *ctx) if (s->fps.num) { pts = outlink->frame_count_out; - } else if (av_fifo_peek(s->out_pts, &pts, 1, 0) < 0) { + } else if (av_fifo_peek(s->input.out_pts, &pts, 1, 0) < 0) { /* No frames queued */ - if (s->status) { - pts = s->status_pts; + if (s->input.status) { + pts = s->input.status_pts; } else { ff_inlink_request_frame(inlink); return 0; } } - if (s->status && pts >= s->status_pts) { - ff_outlink_set_status(outlink, s->status, s->status_pts); + if (s->input.status && pts >= s->input.status_pts) { + ff_outlink_set_status(outlink, s->input.status, s->input.status_pts); return 0; } - ret = pl_queue_update(s->queue, &mix, pl_queue_params( + ret = pl_queue_update(s->input.queue, &mix, pl_queue_params( .pts = pts * av_q2d(outlink->time_base), .radius = pl_frame_mix_radius(&s->params), .vsync_duration = av_q2d(av_inv_q(outlink->frame_rate)), @@ -947,7 +971,7 @@ static int libplacebo_activate(AVFilterContext *ctx) return 0; case PL_QUEUE_OK: if (!s->fps.num) - av_fifo_drain2(s->out_pts, 1); + av_fifo_drain2(s->input.out_pts, 1); return output_frame_mix(ctx, &mix, pts); case PL_QUEUE_ERR: return AVERROR_EXTERNAL; From patchwork Fri Jun 16 09:29:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42131 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1390738pzb; Fri, 16 Jun 2023 02:30:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4fQ3q4zN9DQoYhAu3FL7qrRoQAiPqg5yicJC1lBFRTln3h/B0i3STLIWzPIZOa5fqDth1/ X-Received: by 2002:a17:907:7e90:b0:974:6335:4239 with SMTP id qb16-20020a1709077e9000b0097463354239mr1310104ejc.34.1686907853640; Fri, 16 Jun 2023 02:30:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686907853; cv=none; d=google.com; s=arc-20160816; b=RJt1cxhNPqbeBtAPUiMR6YsqfIxviB2NwSSeb8QOf00VQNeHaOp6OzcyE+I+FkMLI7 KCtAzhloz94NVP+y8WuZiCboOWzpQtDspyL6IZL7Ol8hjVfBAjchbHC3bNywTfHkUFxN nVOyPnrX9oBI+0ykwMn1xAlfMHeZbgGVxB/HfAJ6b8sjYOqGRGpVH+4d194JT0HApTY6 fRxMeHIOW2ua9Db3v8gNSoE4WyaDMJAwQX4h3E6gPtyc08H2/QVndm94EHZWKOte/yJR OnXEY1iHVKUlcEjdmgmlxd6iE3z+G8184v/PoeHeYJlG51KEoJFu9fjNMvtQk9R61oVJ SHxA== 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=NbpXF1nT996AcsIX9hUe1f1dyELBwpTDVEc1iEXMrCc=; b=HzTgVMcAGG/nTMY/2XpjKbClWD8tnSvWr2KInOPb0e039OT86NelZQ3lIkVHIEM8ua JNhkGZF3PUYgxmrpwMZpPATlXhMRD468EB9Ei9LJSfaSKTQh/b0KBPKgJ3waCzF6HMoy ZeIVLf0GAVXl73faNbFEpQsD1WmIb4V2E7kjTf6ZGj6RjvxVYiojy1A1qicwvz7UHF9H PT1m9vAe5tDOK3WpRnT1ZYo1p1HRG+tbjWtNZTE1YJwlZ0UEhjGVWdanlonqr8gTRGKw Nm9BNJa8iyoChJrVd0qyoQtoG4nlf/JZZuCq5j9x0CdyDIwo7DFs1ZyecgpXvXobCCUt 5cgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b="P4hKzyK/"; 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 ca19-20020aa7cd73000000b005149e348be9si11009449edb.86.2023.06.16.02.30.53; Fri, 16 Jun 2023 02:30:53 -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="P4hKzyK/"; 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 1773C68C5B3; Fri, 16 Jun 2023 12:30:29 +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 8127868C59A for ; Fri, 16 Jun 2023 12:30:21 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id 2C16941BA3; Fri, 16 Jun 2023 11:30:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907821; bh=kiXpPxna9a7qKPDBSSCsx5xLtsYjGOAFOlb7BNov67k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P4hKzyK/oCzxW8w51il2Ju6ubQyu7XbwIrkhkTFcGGMB99PgGWRiL0WaaGsrTFAZ9 TMNyVYkPB1MGszzKv8jUYrvt7VoGjRnhbvUXvX+qf/8jZZ/99/mLyVE8hHGENKwBwd zYxQG772C3nzmLgCij3GALm5Y8VcigaFXzcs1QeA= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:40 +0200 Message-ID: <20230616092959.5247-3-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/22] lavfi/vf_libplacebo: move input handling to separate function 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: 0utzxdjpDB8b From: Niklas Haas To be re-used once we support more than one input. --- libavfilter/vf_libplacebo.c | 45 ++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 10fd432745..879a3a0508 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -896,23 +896,19 @@ static void discard_frame(const struct pl_source_frame *src) av_frame_free(&avframe); } -static int libplacebo_activate(AVFilterContext *ctx) +static int handle_input(AVFilterContext *ctx, LibplaceboInput *input) { int ret, status; LibplaceboContext *s = ctx->priv; - AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; AVFrame *in; int64_t pts; - FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); - pl_log_level_update(s->log, get_log_level()); - - while ((ret = ff_inlink_consume_frame(inlink, &in)) > 0) { + while ((ret = ff_inlink_consume_frame(input->link, &in)) > 0) { in->opaque = s; - pl_queue_push(s->input.queue, &(struct pl_source_frame) { - .pts = in->pts * av_q2d(inlink->time_base), - .duration = in->duration * av_q2d(inlink->time_base), + pl_queue_push(input->queue, &(struct pl_source_frame) { + .pts = in->pts * av_q2d(input->link->time_base), + .duration = in->duration * av_q2d(input->link->time_base), .first_field = pl_field_from_avframe(in), .frame_data = in, .map = map_frame, @@ -922,22 +918,39 @@ static int libplacebo_activate(AVFilterContext *ctx) if (!s->fps.num) { /* Internally queue an output frame for the same PTS */ - av_assert1(!av_cmp_q(inlink->time_base, outlink->time_base)); - av_fifo_write(s->input.out_pts, &in->pts, 1); + pts = av_rescale_q(in->pts, input->link->time_base, outlink->time_base); + av_fifo_write(input->out_pts, &pts, 1); } } if (ret < 0) return ret; - if (!s->input.status && ff_inlink_acknowledge_status(inlink, &status, &pts)) { - pts = av_rescale_q_rnd(pts, inlink->time_base, outlink->time_base, + if (!input->status && ff_inlink_acknowledge_status(input->link, &status, &pts)) { + pts = av_rescale_q_rnd(pts, input->link->time_base, outlink->time_base, AV_ROUND_UP); - pl_queue_push(s->input.queue, NULL); /* Signal EOF to pl_queue */ - s->input.status = status; - s->input.status_pts = pts; + pl_queue_push(input->queue, NULL); /* Signal EOF to pl_queue */ + input->status = status; + input->status_pts = pts; } + return 0; +} + +static int libplacebo_activate(AVFilterContext *ctx) +{ + int ret; + LibplaceboContext *s = ctx->priv; + AVFilterLink *inlink = ctx->inputs[0]; + AVFilterLink *outlink = ctx->outputs[0]; + int64_t pts; + + FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); + pl_log_level_update(s->log, get_log_level()); + + if ((ret = handle_input(ctx, &s->input)) < 0) + return ret; + if (ff_outlink_frame_wanted(outlink)) { struct pl_frame_mix mix; enum pl_queue_status ret; From patchwork Fri Jun 16 09:29:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42135 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1390831pzb; Fri, 16 Jun 2023 02:31:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7XqL7HOOJ8QZxn0k2UA02BtO8FbcjF0LUS3AlcgNOhTFoEPzpL+dImRkx+6KJJfY6HcYqP X-Received: by 2002:a17:907:7213:b0:982:4325:ce51 with SMTP id dr19-20020a170907721300b009824325ce51mr1330032ejc.47.1686907862742; Fri, 16 Jun 2023 02:31:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686907862; cv=none; d=google.com; s=arc-20160816; b=Sf8yk+WWffKmzs+VglOoIU/UmJ2BpciZhh2HTdG7hd7P/lIW4hI60zQDY8ugBu2Sc7 vv7qTiCEQZI0Aw3mZGMA4VEUgwIMD/Q9ig8ymzi3WuvhxqhR8X+5OYZkGe7iGwUsNFR1 DnO5dLxSBgSuueCNLqmRqNLXGW8L8JfWO7IKNPRfPN2X3ZGl2n6x7PLkrWXOq70v6bSz k3p2fUy+sHDln1XW07z6SmP/FbyDSHic53twBSusFvCvs2LicAFbEXhI+NvodhHO5g0w 7eeCRPgqhG8dPnB+jUK/lEPehfqPcDblkuQfkR41F8JD+OnTM19/s3OEzJnS4Wyf+VNI ACOg== 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=kyijRUQUgUcCHCJX0w56MhkSHG28zznLuXa54ZukLso=; b=dt3m11GvVYhyC1OpTa2gBt7ACb8mxuK6o9VsE4AX6sjLoNDBzcVMMPQH+fb/kDShss rNc21OePXxCRNW+ZIrDMjjTOMhDW9Lf2pAARSAD4diftYs7KqYhz/nu62JMHLdEtwaA5 oty9jv3NmJ/MV447jPQNXV+ExUj/N2PBnjYNnyvIvE3yxmmC8tX6eMjB7dl5AHPuOhYP TL7jNjUwlaWLQ//+oFl9HRJHR1ophuiBx6Oz30lIDSl7LWMWovrgwaleNLy59mVtGyEG gT22MHAfI+i6I8X9YIynl9lP+vS1SIspw3c0Bqt/CMaBKSjiISr7zSaijl2iiZ5WQoTM wjLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=aU6MmsX+; 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 p22-20020a170906499600b00977cb7af75asi10112919eju.719.2023.06.16.02.31.02; Fri, 16 Jun 2023 02:31:02 -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=aU6MmsX+; 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 3355768C59C; Fri, 16 Jun 2023 12:30:30 +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 F3EC868C59E for ; Fri, 16 Jun 2023 12:30:21 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id ACE8A424F2; Fri, 16 Jun 2023 11:30:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907821; bh=gJ/W9Tf0955IBFUSlhWzHWpj/yErSA7ZMFW4m21R7qw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aU6MmsX++msy6lSkERrH9VJMaT30V6VmMfs+YF/CSqtpcyzr2D3+zMuM++3yPHMul 2R04yeVzOznyNWWVe1tlBqyxGzq4lB4tfcS90aAIh92jE1MUMoXb/E+x3TPOaqKBrR jAdRtuBE3w5dKEVFOUdudI3PhqtVQxd29STiClQU= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:41 +0200 Message-ID: <20230616092959.5247-4-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/22] lavfi/vf_libplacebo: cosmetic 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: UUzc33aedUZC From: Niklas Haas Assign local variable 'in' for 's->input' and replace 'inlink' by 'in->link' to avoid hard-coding ID 0 in more than one place. --- libavfilter/vf_libplacebo.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 879a3a0508..beddd2f796 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -941,14 +941,14 @@ static int libplacebo_activate(AVFilterContext *ctx) { int ret; LibplaceboContext *s = ctx->priv; - AVFilterLink *inlink = ctx->inputs[0]; + LibplaceboInput *in = &s->input; AVFilterLink *outlink = ctx->outputs[0]; int64_t pts; - FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); + FF_FILTER_FORWARD_STATUS_BACK(outlink, in->link); pl_log_level_update(s->log, get_log_level()); - if ((ret = handle_input(ctx, &s->input)) < 0) + if ((ret = handle_input(ctx, in)) < 0) return ret; if (ff_outlink_frame_wanted(outlink)) { @@ -957,22 +957,22 @@ static int libplacebo_activate(AVFilterContext *ctx) if (s->fps.num) { pts = outlink->frame_count_out; - } else if (av_fifo_peek(s->input.out_pts, &pts, 1, 0) < 0) { + } else if (av_fifo_peek(in->out_pts, &pts, 1, 0) < 0) { /* No frames queued */ - if (s->input.status) { - pts = s->input.status_pts; + if (in->status) { + pts = in->status_pts; } else { - ff_inlink_request_frame(inlink); + ff_inlink_request_frame(in->link); return 0; } } - if (s->input.status && pts >= s->input.status_pts) { - ff_outlink_set_status(outlink, s->input.status, s->input.status_pts); + if (in->status && pts >= in->status_pts) { + ff_outlink_set_status(outlink, in->status, in->status_pts); return 0; } - ret = pl_queue_update(s->input.queue, &mix, pl_queue_params( + ret = pl_queue_update(in->queue, &mix, pl_queue_params( .pts = pts * av_q2d(outlink->time_base), .radius = pl_frame_mix_radius(&s->params), .vsync_duration = av_q2d(av_inv_q(outlink->frame_rate)), @@ -980,11 +980,11 @@ static int libplacebo_activate(AVFilterContext *ctx) switch (ret) { case PL_QUEUE_MORE: - ff_inlink_request_frame(inlink); + ff_inlink_request_frame(in->link); return 0; case PL_QUEUE_OK: if (!s->fps.num) - av_fifo_drain2(s->input.out_pts, 1); + av_fifo_drain2(in->out_pts, 1); return output_frame_mix(ctx, &mix, pts); case PL_QUEUE_ERR: return AVERROR_EXTERNAL; From patchwork Fri Jun 16 09:29:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42136 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1390932pzb; Fri, 16 Jun 2023 02:31:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6PriEofh0rfcbF891JhabbCk6F67JiEAVdDVKORlQxxFFKjsoUuZxmzyz56FllHtMELjfJ X-Received: by 2002:a17:907:6d81:b0:974:e767:e1db with SMTP id sb1-20020a1709076d8100b00974e767e1dbmr1483250ejc.46.1686907871975; Fri, 16 Jun 2023 02:31:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686907871; cv=none; d=google.com; s=arc-20160816; b=sfQRDUJYjaVd5/Xvzfxbf+2YwsuaWpAy9uBOBHTYIkzScyiqRiU34oVli8/in1gL4i wF+F5R7cpLfIENcx/G8jcRcZyw7Nc0Vbl8M1Az/kWS+k1G5GHrqMZDguoyFARreW9Ni2 ov2LmTUF4tUdYL0E5dJAFgsNtXKGlqxEVwQz8P6c+GanTNuLt6FVCW5PSTMIEtiatvM8 HeIWZFFgoIbKyAE87PBT0rBhu7fQOVXZnSIjUgSgPza2/QZrBBwAcr5MtuD5YW7LlglS +hpWVhFOUpRiSFWoiHLSnx8D3QcxoZ58pm7OO1ks1dPywLr6Ne6g17BZ2QkscM/HxG/H 9ydA== 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=G5OOg96muz2u7nqLR6KpX7YLLT8HOJI7RQwW219GMl4=; b=EjwffLnKqeILReTYGbBmsyQQFVHItPHC5zRxD52oeNDXY74TZF55VCIG2QR+K5Abl4 9Qsmmeog3iqN1Ip3UN30WKwdDmXst15C2IU4qkm1zP1goIZPUn33fdMVMWKvX00pguFv uthSyUpGeuuUGFJcB8aWk/vHYLg2YQ+X0rszLU/MsAXo4TQ+ieDYZOSZZM7aSLNrsPhq IbLSRNQlb6n+YjaH3PnLC/NmSum8jAqfcOf5635GaFHb7IvyBnqM1/R6TmZq5SugwYUL 43J+jmGetZKpj37CAM4Phu1GnnUWAy/H3AykJ68t2n6fMUFpiU04u7dGZphByJ6/1XPs wDnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=mMhXntWQ; 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 y17-20020a17090668d100b009854fd4c76asi675089ejr.388.2023.06.16.02.31.11; Fri, 16 Jun 2023 02:31:11 -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=mMhXntWQ; 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 4C48A68C500; Fri, 16 Jun 2023 12:30:31 +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 855BC68C597 for ; Fri, 16 Jun 2023 12:30:22 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id 423EF426BF; Fri, 16 Jun 2023 11:30:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907822; bh=L+Wo1QZZ3WFB/XrngSAYnNdbcfFWUsC7wN2sUYtCoh0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mMhXntWQk6LL4gJS+Jv1+z/Nxu1G4BHDYaHRqFPnCNbz+g8/Dsh9IQpyaILyRjGaj zu4w/RDoH4f94zrN13PuOrsX48ijS0AwnnfK0EnWu5vZXE33pMWdmW1gLMKV1AU7fD 2gzpfuMNpkHZDM5kaV4xA5ljqaU0cY5vHv8a46Xg= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:42 +0200 Message-ID: <20230616092959.5247-5-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/22] lavfi/vf_libplacebo: move temporary vars into per-input struct 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: 0a9JkHTUl/wl From: Niklas Haas Including the queue status, because these will need to be re-queried inside output_frame_mix when that function is refactored to handle multiple inputs. --- libavfilter/vf_libplacebo.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index beddd2f796..4baa766bac 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -117,6 +117,8 @@ enum var_name { typedef struct LibplaceboInput { pl_renderer renderer; pl_queue queue; + enum pl_queue_status qstatus; + struct pl_frame_mix mix; ///< temporary storage AVFilterLink *link; AVFifo *out_pts; ///< timestamps of wanted output frames int64_t status_pts; @@ -952,9 +954,6 @@ static int libplacebo_activate(AVFilterContext *ctx) return ret; if (ff_outlink_frame_wanted(outlink)) { - struct pl_frame_mix mix; - enum pl_queue_status ret; - if (s->fps.num) { pts = outlink->frame_count_out; } else if (av_fifo_peek(in->out_pts, &pts, 1, 0) < 0) { @@ -972,20 +971,20 @@ static int libplacebo_activate(AVFilterContext *ctx) return 0; } - ret = pl_queue_update(in->queue, &mix, pl_queue_params( + in->qstatus = pl_queue_update(in->queue, &in->mix, pl_queue_params( .pts = pts * av_q2d(outlink->time_base), .radius = pl_frame_mix_radius(&s->params), .vsync_duration = av_q2d(av_inv_q(outlink->frame_rate)), )); - switch (ret) { + switch (in->qstatus) { case PL_QUEUE_MORE: ff_inlink_request_frame(in->link); return 0; case PL_QUEUE_OK: if (!s->fps.num) av_fifo_drain2(in->out_pts, 1); - return output_frame_mix(ctx, &mix, pts); + return output_frame_mix(ctx, &in->mix, pts); case PL_QUEUE_ERR: return AVERROR_EXTERNAL; } From patchwork Fri Jun 16 09:29:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42141 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1391398pzb; Fri, 16 Jun 2023 02:31:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6oUq19S2IUd2UJCQQ6G9hKSFHDAuypbfPBEuA7nK20GoJpOMRhtTxLwjnVRu0hHlhKFhJG X-Received: by 2002:a05:6402:11d4:b0:516:a279:1c1b with SMTP id j20-20020a05640211d400b00516a2791c1bmr7923206edw.4.1686907917523; Fri, 16 Jun 2023 02:31:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686907917; cv=none; d=google.com; s=arc-20160816; b=ZY0bbATJDsjag8jmSDFZ+kwPt9t/ENwMQSYcMEVXcdisMCghVssbdzD7DdYnm4YyiW Y23iGxXPah9D7cVnJLAcFUsMYzA8D+0dm8sFYe0fqV7MtHr9deeftvyPiJemH76r3+tG YOdHVDjzQbZJhhDP748+TTBk3cKY35LKY6LRfZrOTJOH4bCzwz3q/iSQU4Pk0ibsJrpP PUAe2EIS21HtDlZdWyO3aAuyCehSO8A1sAeEQVVw6GUF7afiVZEqUq82GoGK85cBqLkv Yf2o8JRtqosGoE3htMK1CqgmA2JMqIM6OV1z2E/F+wyfMNruUcoeoOX/kKz+uXm9qEEs nvig== 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=l1P4gljQZMje4ZFid0LMYfJxLTvilZ9x7C+C9A88DYY=; b=rZ8K/pBEUlyfFsePzU5nbIS5nbR1nWMO8STF7BRNrLKztI5sO6F0ujkCZndzqj4X0x rG0iTWjlrwcKqOt27yDHi7geP67KO4sUz5AuBYahlY7P8oPU7UsQApx/j1NZIAuFicEL vI/Tscw7kOQ8hPMdk+VQobiCJx6yY9GqaIq226IxMOt0GSrGPhvAOIppxVlAVj8pdUBk qaqO+bVj36kw4hQSrflWZBdrFOeuXqa8rjwMy91atBZR8fB6JvfVGvRoEwSPlVYC/cfh 27TTarECnwmzKlSgZxVGBMTKVyNIA4NbaQaAYhgSvWTy4XWL6MJxvo1pDVRDLoWbi1Cu 1l5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=MpkJmbo5; 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 o6-20020aa7c506000000b005187bd4fcb2si3423014edq.569.2023.06.16.02.31.56; Fri, 16 Jun 2023 02:31:57 -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=MpkJmbo5; 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 2601A68C5F1; Fri, 16 Jun 2023 12:30:36 +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 7649D68C500 for ; Fri, 16 Jun 2023 12:30:25 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id CC05F42DAF; Fri, 16 Jun 2023 11:30:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907822; bh=LC7JXbAU2VSMG8XZvVFOB7bHn3DvWAwowDpRdf6zXt0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MpkJmbo5tpw7efV6L7YmFp+yE1LH1bwD2HIuca4qWdew3bvDuMFFoKMWWK70NZ8FG AakChv4ex6YpBdhnbMUirLdQb/2aVpGjpy1dHajESn/abE3QnbDk5a2UxKzGYhd25C IFq9JUbWXwHkxsxmzMbGOa+jDUHco4K39rHSFzjA= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:43 +0200 Message-ID: <20230616092959.5247-6-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/22] lavif/vf_libplacebo: remove pl_frame_mix from output_frame_mix 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: RkgLlZSkAKFY From: Niklas Haas Instead, rename this function to `output_frame` and make it pull the `pl_frame_mix` from the input structure. Step towards handling multiple inputs. --- libavfilter/vf_libplacebo.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 4baa766bac..0289187b46 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -760,20 +760,19 @@ static void update_crops(AVFilterContext *ctx, } } -/* Construct and emit an output frame for a given frame mix */ -static int output_frame_mix(AVFilterContext *ctx, - struct pl_frame_mix *mix, - int64_t pts) +/* Construct and emit an output frame for a given timestamp */ +static int output_frame(AVFilterContext *ctx, int64_t pts) { int err = 0, ok, changed_csp; LibplaceboContext *s = ctx->priv; + LibplaceboInput *in = &s->input; AVFilterLink *outlink = ctx->outputs[0]; const AVPixFmtDescriptor *outdesc = av_pix_fmt_desc_get(outlink->format); struct pl_frame target; const AVFrame *ref; AVFrame *out; uint64_t ref_sig; - if (!mix->num_frames) + if (!in->mix.num_frames) return 0; out = ff_get_video_buffer(outlink, outlink->w, outlink->h); @@ -781,11 +780,11 @@ static int output_frame_mix(AVFilterContext *ctx, return AVERROR(ENOMEM); /* Use the last frame before current PTS value as reference */ - for (int i = 0; i < mix->num_frames; i++) { - if (i && mix->timestamps[i] > 0.0f) + for (int i = 0; i < in->mix.num_frames; i++) { + if (i && in->mix.timestamps[i] > 0.0f) break; - ref = pl_get_mapped_avframe(mix->frames[i]); - ref_sig = mix->signatures[i]; + ref = pl_get_mapped_avframe(in->mix.frames[i]); + ref_sig = in->mix.signatures[i]; } RET(av_frame_copy_props(out, ref)); @@ -851,8 +850,8 @@ static int output_frame_mix(AVFilterContext *ctx, goto fail; } - update_crops(ctx, mix, &target, ref_sig, out->pts * av_q2d(outlink->time_base)); - pl_render_image_mix(s->input.renderer, mix, &target, &s->params); + update_crops(ctx, &in->mix, &target, ref_sig, out->pts * av_q2d(outlink->time_base)); + pl_render_image_mix(in->renderer, &in->mix, &target, &s->params); if (outdesc->flags & AV_PIX_FMT_FLAG_HWACCEL) { pl_unmap_avframe(s->gpu, &target); @@ -984,7 +983,7 @@ static int libplacebo_activate(AVFilterContext *ctx) case PL_QUEUE_OK: if (!s->fps.num) av_fifo_drain2(in->out_pts, 1); - return output_frame_mix(ctx, &in->mix, pts); + return output_frame(ctx, pts); case PL_QUEUE_ERR: return AVERROR_EXTERNAL; } From patchwork Fri Jun 16 09:29:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42142 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1391493pzb; Fri, 16 Jun 2023 02:32:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6rgnd3LjaW/dxCzdJJt0LGymDaocWcACfhUgABrH7EymdlqmRGA16ByZjlhKVp336+Ssgq X-Received: by 2002:a17:907:a41e:b0:96f:f6a6:58dd with SMTP id sg30-20020a170907a41e00b0096ff6a658ddmr1508981ejc.5.1686907925903; Fri, 16 Jun 2023 02:32:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686907925; cv=none; d=google.com; s=arc-20160816; b=AMC808S1Mkuq4JA3g+WpjUFDYYqhTNUCwdspJv8VAQ58EpJ+OMY/oWZf2mfRDdSUMd 21aVMhaiV4UCTHRwDRI9auETb+2PQC49f9kazjoLGcxF1PkzbmZ83sZK54adcmBwZOQd yJhK/LZXHQj+XY4zub4iXkIYJ7zRWFJ5IRmUwwrYXDakJCdz0wgdVhg4SZbe3qPvrGiE hUyGojsMffC1U3TR54pwq4gAHnsfE8pQteybGIQsAdD377l5qKNqudfgCm1ByvUpEQc2 qXp96MysM4gU+zPutduPnDR54Adit0vH/xbTWK2YsHQctVocot3leP2CyBzFnRs00fFO qYEw== 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=Au0CETddz/uGeHH12/V6bhnyMn4/WrGEmEJM9coZNu0=; b=ew8ogCPQ+o9O+AejhqXiSDQTU1HY32KqElyfknqJdrQWId+fUCdso70Ggn16ya6EAd 4QJF5xAxjqo4GKTqABPczuDNyRzGKdu0YHRehQWWmKsnUY6VyDyWJPYpNKAm4w6jBRy4 T1EnCzY9yPwZgsvV41x/8RBLZ5yILhrFlJ0sPyCylLQ7Nxko6jLdGC7K7g6mjfOnKlTr Y7f9dbL1EcYib29lTH2RQuRKLIy+Rax1mw4h+rOg5f9lpWNWwpnXYp4UuF8kvpIXkxHL Qk2jmxlceqkZGnGANKASFbkmxuEQDXyVL0/clkkhHYWg0ISrxyy3Wqd0QJiVm9dnEOoT iSlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b="J12k9Q/N"; 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 p5-20020a170906838500b0094f791be3c0si9952898ejx.268.2023.06.16.02.32.05; Fri, 16 Jun 2023 02:32:05 -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="J12k9Q/N"; 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 1DF5D68C5F8; Fri, 16 Jun 2023 12:30:37 +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 7EEF368C5BB for ; Fri, 16 Jun 2023 12:30:25 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id 67947436B4; Fri, 16 Jun 2023 11:30:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907823; bh=TQv+QL92w+szjSjseDX8j6f2uQfHndzdocG+7D4VDzw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J12k9Q/N3E/Flum5Erl1ZUMiSxWGAmB7i9Na5dp8MXQzJSC2i3M7ateK0k22GC4yi TkXl9JaFIsDOI31ccMd2D0BCw1hDV9oVi9ycMTUVm1rhs8IpL6960NtYYoQ8Xb/W+e OEsBV5aUow/dhz2PZrqT2PFcvBpM8ErdpOxFtQ4w= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:44 +0200 Message-ID: <20230616092959.5247-7-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/22] lavfi/vf_libplacebo: factor out ref frame logic 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: vkwU5tj/imRv From: Niklas Haas Instead of finding the ref frame in output_frame() and then passing its signature to update_crops(), pull out the logic and invoke it a second time inside update_crops(). This may seem wasteful at present, but will actually become required in the future, since update_crops() runs on *every* input, and needs values specific to that input (which the signature isn't), while output_frame() is only interested in a single input. It's much easier to just split the logic cleanly. --- libavfilter/vf_libplacebo.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 0289187b46..b83df24a84 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -706,11 +706,21 @@ fail: return err; } +static const AVFrame *ref_frame(const struct pl_frame_mix *mix) +{ + for (int i = 0; i < mix->num_frames; i++) { + if (i+1 == mix->num_frames || mix->timestamps[i+1] > 0) + return pl_get_mapped_avframe(mix->frames[i]); + } + return NULL; +} + static void update_crops(AVFilterContext *ctx, struct pl_frame_mix *mix, struct pl_frame *target, - uint64_t ref_sig, double target_pts) + double target_pts) { LibplaceboContext *s = ctx->priv; + const AVFrame *ref = ref_frame(mix); for (int i = 0; i < mix->num_frames; i++) { // Mutate the `pl_frame.crop` fields in-place. This is fine because we @@ -745,7 +755,7 @@ static void update_crops(AVFilterContext *ctx, image->crop.x1 = image->crop.x0 + s->var_values[VAR_CROP_W]; image->crop.y1 = image->crop.y0 + s->var_values[VAR_CROP_H]; - if (mix->signatures[i] == ref_sig) { + if (src == ref) { /* Only update the target crop once, for the 'reference' frame */ target->crop.x0 = av_expr_eval(s->pos_x_pexpr, s->var_values, NULL); target->crop.y0 = av_expr_eval(s->pos_y_pexpr, s->var_values, NULL); @@ -768,25 +778,16 @@ static int output_frame(AVFilterContext *ctx, int64_t pts) LibplaceboInput *in = &s->input; AVFilterLink *outlink = ctx->outputs[0]; const AVPixFmtDescriptor *outdesc = av_pix_fmt_desc_get(outlink->format); + const AVFrame *ref = ref_frame(&in->mix); struct pl_frame target; - const AVFrame *ref; AVFrame *out; - uint64_t ref_sig; - if (!in->mix.num_frames) + if (!ref) return 0; out = ff_get_video_buffer(outlink, outlink->w, outlink->h); if (!out) return AVERROR(ENOMEM); - /* Use the last frame before current PTS value as reference */ - for (int i = 0; i < in->mix.num_frames; i++) { - if (i && in->mix.timestamps[i] > 0.0f) - break; - ref = pl_get_mapped_avframe(in->mix.frames[i]); - ref_sig = in->mix.signatures[i]; - } - RET(av_frame_copy_props(out, ref)); out->pts = pts; out->width = outlink->w; @@ -850,7 +851,7 @@ static int output_frame(AVFilterContext *ctx, int64_t pts) goto fail; } - update_crops(ctx, &in->mix, &target, ref_sig, out->pts * av_q2d(outlink->time_base)); + update_crops(ctx, &in->mix, &target, out->pts * av_q2d(outlink->time_base)); pl_render_image_mix(in->renderer, &in->mix, &target, &s->params); if (outdesc->flags & AV_PIX_FMT_FLAG_HWACCEL) { From patchwork Fri Jun 16 09:29:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42144 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1391692pzb; Fri, 16 Jun 2023 02:32:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4bhzd40GNY3f3hMwL8at03ZjLJYlc7+eiqglsTOpBlLvzgJXRCNZJxPGq+n2s3A/Bka9K9 X-Received: by 2002:a17:906:7312:b0:96a:3119:ac0 with SMTP id di18-20020a170906731200b0096a31190ac0mr1179647ejc.69.1686907944187; Fri, 16 Jun 2023 02:32:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686907944; cv=none; d=google.com; s=arc-20160816; b=VFkkXfiWzsFQYOWIudDBChkXDH3UYY866cCHeQOqlScoZB3bO3TUekhQrtJ9Vfprs/ MVXdJUV2j1/21B1yo2+Kn79yT+Ux8/8QT4aIobMoXDR6aup8qsZLX3tGOFZY69YKx9vM tnVjV3YGFzo9X37WnClamso+zv+BQXvCWsPDKHuzBGqN/TJOI3Nz4UhoGoJm396qDbRP 39PmhW2REt/wCOpHw9m2F98P1PTAkWuNGaZPHwUXfO6gcH8tTUd/X66r++OE992CAl56 2IgBTMElFNx5SFGaImKrd+/JawccK+MIDF2hnERZSoeFTihfDbFGaAmrwpt7o0s3ycV8 ZpHQ== 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=9xNLhHLWU27c/O1FapcY+/KNpflZuXCYTr9eO5VNvKM=; b=z6TMLEEwyiyTptYY2Uu6WhZwDC8DqDOoEx241lwBfCygSq74gvUboMaEHxdrZWU676 gk/LRk4SusNHn+lKDj3Bd5ZuujOQy1nYsyCHuiR3Qrdp3pDaknMgO0TOZpqAA4qrlSMa iRw3bkVbJdp5BL9yeo5bS+fnDRB2OjaSWaEGbZGcNOkfB3s5g1R1744tJMa1h1xTjsAo iJsO5OF82bTRVVqQ9md++ex4PsXuYJ71oQacZxu1OeoNXApFj5Hp/Fho9A3lVJQhep5V AjpMdjrMYjSY9z3kCr6nJFHVkyJ4cqkqYWFEIXH3yDtEH2pnROf79Kkin0+NWLKrNXUd zNzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=FE5o4xlz; 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 a7-20020a1709065f8700b009828e8bec17si2427139eju.531.2023.06.16.02.32.23; Fri, 16 Jun 2023 02:32: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=FE5o4xlz; 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 1AEBD68C5FF; Fri, 16 Jun 2023 12:30:39 +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 1198268C5C1 for ; Fri, 16 Jun 2023 12:30:26 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id EF537436F9; Fri, 16 Jun 2023 11:30:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907824; bh=xHp5X9Z6xRxUqeUMMO+b0XnKEq9TfTtVJiLuG1mgIUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FE5o4xlzAAdAbRP2YRELGuGAuL/nQPsWpf0PKEt3T4aJFlO2Y4e+pTRmLTsu0ucH/ TDt9NxqjwB5RrlVJuPp+m7N3NhZJNlb0d8KR9COaQYzkeEBsEjDYkCkJEWVI4gU9hh siaLwcea3RHCclgJaLNdXRuEh49b15sI2GmJOkSw= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:45 +0200 Message-ID: <20230616092959.5247-8-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/22] lavfi/vf_libplacebo: use correct link in update_crops() 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: 3a0naTgect+E From: Niklas Haas Instead of hard-coding input 0, pass the per-input structure and use the link contained inside it. --- libavfilter/vf_libplacebo.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index b83df24a84..408fb3918a 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -715,19 +715,18 @@ static const AVFrame *ref_frame(const struct pl_frame_mix *mix) return NULL; } -static void update_crops(AVFilterContext *ctx, - struct pl_frame_mix *mix, struct pl_frame *target, - double target_pts) +static void update_crops(AVFilterContext *ctx, LibplaceboInput *in, + struct pl_frame *target, double target_pts) { LibplaceboContext *s = ctx->priv; - const AVFrame *ref = ref_frame(mix); + const AVFrame *ref = ref_frame(&in->mix); - for (int i = 0; i < mix->num_frames; i++) { + for (int i = 0; i < in->mix.num_frames; i++) { // Mutate the `pl_frame.crop` fields in-place. This is fine because we // own the entire pl_queue, and hence, the pointed-at frames. - struct pl_frame *image = (struct pl_frame *) mix->frames[i]; + struct pl_frame *image = (struct pl_frame *) in->mix.frames[i]; const AVFrame *src = pl_get_mapped_avframe(image); - double image_pts = src->pts * av_q2d(ctx->inputs[0]->time_base); + double image_pts = src->pts * av_q2d(in->link->time_base); /* Update dynamic variables */ s->var_values[VAR_IN_T] = s->var_values[VAR_T] = image_pts; @@ -851,7 +850,7 @@ static int output_frame(AVFilterContext *ctx, int64_t pts) goto fail; } - update_crops(ctx, &in->mix, &target, out->pts * av_q2d(outlink->time_base)); + update_crops(ctx, in, &target, out->pts * av_q2d(outlink->time_base)); pl_render_image_mix(in->renderer, &in->mix, &target, &s->params); if (outdesc->flags & AV_PIX_FMT_FLAG_HWACCEL) { From patchwork Fri Jun 16 09:29:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42143 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1391589pzb; Fri, 16 Jun 2023 02:32:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5n0cIUEzM6elMWm/qs7agznglmoqnCR009yErGD+mCqJkyLit1uYnSs+Y9DUisq+7UMXNG X-Received: by 2002:a50:fe8f:0:b0:518:7a3b:e9fb with SMTP id d15-20020a50fe8f000000b005187a3be9fbmr841485edt.19.1686907935161; Fri, 16 Jun 2023 02:32:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686907935; cv=none; d=google.com; s=arc-20160816; b=mNW0DpNEubklmM3kqQBMDpzdmPfTiB81fh8FH4sXlgswaCxiI+B/5jE7TDQT557QVC /p7Y/VzI7JM+HGsJ0+v4PneKmTaJhNcdq5jiy0kY7i4PBSqd8gdqF1RwoGlCWqXrvGSW P346LW6hfLEm9vFHqPQYleNgGnP2jJoVmMk0912LXiWxJgQxXO33loThgb2WnjS9nDd/ /s/8ISYN8SWETWMjm8NcigWWFpJztm9YUOaXur10iyjHgSFtzTDCi+qchp2L39mPxtcs 1vTFAmwu0xRPl3gedksmx7hLr+NIcMKQjCj9d3VUPhBmb7h1p+H9ggS599i/zo91CUD4 +wYQ== 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=c8/fM0+iSIJUDFN12ax46O57S8wgXcTuxPstD2Z0sl0=; b=U0S9ZVDtsvtzvImH3s1xBP6ExiOyWGi9CydrksNvWiDXw2Ko85K8fQK+11ikZJc+3V SlvBZ2r1XkSFF2tPHVjr9zhhRBgLb0tmhSlleXtFYyrNIT5vaEadAeoTBbO4aJywxZHR 3PJucyL5mv3Y5ND8PJc/OwDmgJ2RkCd7COxm6dihrjV21d2DPqINYJuAP00vEqHA9ZmM yNV6Xl0OZF21f+BL9MXI+YnOVdJ7inyAX6916dTr+rcAjk9sWdgnaH24VTHQrtGtdXBP djtubmNPbr2G26TG3Nrk8RrwbCDAmac9Rw5c3t/ZmfuI7OKxZAK9B4xtQFZxWts0bS3O uugw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b="tEiZQ/+T"; 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 n18-20020aa7c692000000b005187a786308si3956395edq.688.2023.06.16.02.32.14; Fri, 16 Jun 2023 02:32:15 -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="tEiZQ/+T"; 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 F32DC68C5C4; Fri, 16 Jun 2023 12:30:37 +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 0B07468C5C0 for ; Fri, 16 Jun 2023 12:30:26 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id 7897743714; Fri, 16 Jun 2023 11:30:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907824; bh=vNiGGHp2lazVo5ammIAKiWvdA2xRkhwsCSBH7lv/Jps=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tEiZQ/+T6CofS9rFUKk7rIuLsqhWF/pnhCZ/exJISUByDeuwzBT3higv9jqA5Eza8 6Il/vLOnABLsFLbEuZAdhLCHLb6fYc/sCVs/3XwhHLtwtIBhBYs1C1PKbxohXus1l8 lo9HpfhV07hOWnDeH5pVuIGm9WBbO0eEvCqyrG2c= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:46 +0200 Message-ID: <20230616092959.5247-9-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/22] lavfi/vf_libplacebo: replace s->input by dynamic array 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: VnYCj1i1kXrG From: Niklas Haas For now, hard-coded to 1 element. --- libavfilter/vf_libplacebo.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 408fb3918a..fbac1b0354 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -136,7 +136,8 @@ typedef struct LibplaceboContext { pl_tex tex[4]; /* input state */ - LibplaceboInput input; + LibplaceboInput *inputs; + int nb_inputs; /* settings */ char *out_format_string; @@ -660,7 +661,12 @@ static int init_vulkan(AVFilterContext *avctx, const AVVulkanDeviceContext *hwct } /* Initialize inputs */ - RET(input_init(avctx, avctx->inputs[0], &s->input)); + s->nb_inputs = 1; + s->inputs = av_calloc(s->nb_inputs, sizeof(*s->inputs)); + if (!s->inputs) + return AVERROR(ENOMEM); + for (int i = 0; i < s->nb_inputs; i++) + RET(input_init(avctx, avctx->inputs[i], &s->inputs[i])); /* fall through */ fail: @@ -677,7 +683,9 @@ static void libplacebo_uninit(AVFilterContext *avctx) pl_tex_destroy(s->gpu, &s->tex[i]); for (int i = 0; i < s->num_hooks; i++) pl_mpv_user_shader_destroy(&s->hooks[i]); - input_uninit(&s->input); + for (int i = 0; i < s->nb_inputs && s->inputs; i++) + input_uninit(&s->inputs[i]); + av_freep(&s->inputs); pl_vulkan_destroy(&s->vulkan); pl_log_destroy(&s->log); ff_vk_uninit(&s->vkctx); @@ -774,7 +782,7 @@ static int output_frame(AVFilterContext *ctx, int64_t pts) { int err = 0, ok, changed_csp; LibplaceboContext *s = ctx->priv; - LibplaceboInput *in = &s->input; + LibplaceboInput *in = &s->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; const AVPixFmtDescriptor *outdesc = av_pix_fmt_desc_get(outlink->format); const AVFrame *ref = ref_frame(&in->mix); @@ -942,7 +950,7 @@ static int libplacebo_activate(AVFilterContext *ctx) { int ret; LibplaceboContext *s = ctx->priv; - LibplaceboInput *in = &s->input; + LibplaceboInput *in = &s->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; int64_t pts; From patchwork Fri Jun 16 09:29:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42147 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1392023pzb; Fri, 16 Jun 2023 02:33:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ65mZW8KOMvKzgY4AWtecNztADQcLZ3pUuPSEhG6TTixqO2pH2j/v/PP7Hu5YD33ao/JavK X-Received: by 2002:a2e:b0ca:0:b0:2af:3147:86c8 with SMTP id g10-20020a2eb0ca000000b002af314786c8mr1215839ljl.16.1686907980241; Fri, 16 Jun 2023 02:33:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686907980; cv=none; d=google.com; s=arc-20160816; b=og886RM0oXX376jJXYzEOSS0EACHjoZwzXLfoNyOu4i4Wi9lRNyn/thbbk1UEQXQEa cFN34V865zFYved6i8zMO/0mJbx65FqfdWdpaRM0F/k7aiSR9PJnDD4poceZEO33W86J hvrEIHKieOAFuKQEt06bjE+bTPdMW7QbihRoW0EfFLOJG5czCACp2n15qpszPU08Kd/F fnJtxGk52/kpG3MvAk3fpWL1sTrZNdBNmzWdu+7p+THR9IKkNQOp6yauZ6SzQxKhT1En r1MDZlWNc8o2qC+C+VC+MTSQ2SSyBNNWD/iVkNSSerD0PpgxHSGSgxiVt40HGtsHWUkR mikQ== 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=zIkqVNk/gJUzRdBbbkZoSBFx/uDhvk0IK5qSXUlSM7E=; b=0sf2WYQ1DAxLXWHuVLAcIneBs334vKNAZrwFX3pQhq5eoakd3l+wP0Ht4QqJvpJJQH qwBdkvnXd7po6++f/VnItjhN/yAIHy8xdSuB5A4Lla1a5fV7lxCw1/5ZWXz81oTQgt05 XkntXfqeGFM5IjPtEoFuFEnEEa//39LQhWPvHcfj76nj+NlWqDjry0p+EqhWPNpfSmaL L7aa3iZPL2eufo7wlAYAVBkiPPCXFBnIyTeBLkM/GSxy/zlhTsmap2BF0SLqcd6LQZvg pZG0YETEAXIIf49PHb2mqpUuO12Dk+Im44S1sXiZWkAkCSCDvrHtLDYaKRvS4EmygADg vq7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=qrG8KOa0; 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 l17-20020a056402345100b0051a1fc52396si2144530edc.392.2023.06.16.02.32.59; Fri, 16 Jun 2023 02:33:00 -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=qrG8KOa0; 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 D5BC568C612; Fri, 16 Jun 2023 12:30:42 +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 B484968C5CF for ; Fri, 16 Jun 2023 12:30:26 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id 10CF544571; Fri, 16 Jun 2023 11:30:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907825; bh=5agOSN6S0yPg0d9d6Hethew24x/NAlPgvvBL54J56x4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qrG8KOa00ns4yCeWTgnYpCt74bGCwJNtcLGGXioDLsRRn0Z+iqhe9xR/NkCjF8T9g DI3uGuZKKW/Z2KUHJe+b/WiEXZ5C8a1TokHJvH6kdC866cHxVcbB8OzUzDx1OTthVE viJ08ShNzcaZctpmjS93gtxLiFnKiEhL/e864ISc= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:47 +0200 Message-ID: <20230616092959.5247-10-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/22] lavfi/vf_libplacebo: keep track of latest status globally 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: gfffKVwNheVp From: Niklas Haas This field will effectively hold the most recent status set by any input. Currently functionally equivalent to input->status, but will change soon. --- libavfilter/vf_libplacebo.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index fbac1b0354..d6f19f166d 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -138,6 +138,8 @@ typedef struct LibplaceboContext { /* input state */ LibplaceboInput *inputs; int nb_inputs; + int64_t status_pts; ///< tracks status of most recently used input + int status; /* settings */ char *out_format_string; @@ -941,6 +943,11 @@ static int handle_input(AVFilterContext *ctx, LibplaceboInput *input) pl_queue_push(input->queue, NULL); /* Signal EOF to pl_queue */ input->status = status; input->status_pts = pts; + if (pts >= s->status_pts) { + /* Also propagate to output unless overwritten by later status change */ + s->status = status; + s->status_pts = pts; + } } return 0; @@ -973,8 +980,8 @@ static int libplacebo_activate(AVFilterContext *ctx) } } - if (in->status && pts >= in->status_pts) { - ff_outlink_set_status(outlink, in->status, in->status_pts); + if (s->status && pts >= s->status_pts) { + ff_outlink_set_status(outlink, s->status, s->status_pts); return 0; } From patchwork Fri Jun 16 09:29:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42146 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1391942pzb; Fri, 16 Jun 2023 02:32:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4c2tyV8WbHEV4LkJZlqghNOjXryfYneVW95zAz0CM/KUJg9ffM85fsIFkqMkR7WXs5rH2g X-Received: by 2002:a17:907:3687:b0:94f:449e:75db with SMTP id bi7-20020a170907368700b0094f449e75dbmr1451093ejc.52.1686907971307; Fri, 16 Jun 2023 02:32:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686907971; cv=none; d=google.com; s=arc-20160816; b=t7AawQsMF6MttRBmADm4g8Lh7NBJXTpxQgBzeEZSb4YCgU8bBDQzwxKVhneBjGdCIh Zwmh1o5585rGB6SRmMYrjl/xCGZR9mRB1fLu9Xu2axrbsa8CGb7T/wpo44R8j1zHLwIt /z3VI1SNGmV3Mjqae0SWExLeNR54mcBsCeeHpyPD5oTw42785HEZHsbOJGKRZLmGU6dE SKlv5Pq4i68szfS1V96QDvYahQoNyDDVwvj3GFk62s1UgoDkigjwQ1uwFaPNXDyFm/2h X3tS+VJFyIIvgQlbb8xSZUPGtY49uuXPhvy1SiwXOO45sLL8rQ2A0CQSdFJGXbFvsemZ dMag== 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=QsMRlup2KDehiTS7/S4ZT4WRoMSffTW0zhBpBHTAnlk=; b=wgxkyjgA2aqMvQpRkhJtygOSfbewCzbWsFSiDka+cS3T9YimKAlJrcMAo2JAFoYQ7D jYMLuuPtLg6Q7qOllcofdJQi5Z9M/dQ+J998mLaPge6WmDvt+vpOC95Xrt9m87aMcwQo 0aeXKBbpy7CyXSaDiOYL5eyi48nSmo+U378tIVyhcmFh7Fn78LbtGpVWT/hU/kShwpv8 y6YwzFcaicKr99sXmZEAWwkOA8xBZtLsIba9wlJIieHQ7uZYWz8B3Z/hZnWeVs2NzJQc 1Wk7aR0IVkqK1hk53QS9R1Za9wfQy+UjMORTmE86exZuTXL/pBc7GQZ5E8WlrNGTfS4n uU/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=rRmYna41; 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 n18-20020aa7d052000000b00510dfff2057si1055988edo.62.2023.06.16.02.32.50; Fri, 16 Jun 2023 02:32:51 -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=rRmYna41; 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 0B4DA68C60D; Fri, 16 Jun 2023 12:30:42 +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 ACDB668C5C1 for ; Fri, 16 Jun 2023 12:30:26 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id 93B01401C9; Fri, 16 Jun 2023 11:30:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907825; bh=2tTB0IMGtozgW9u82SARVZ//nWaM1y+3xxPJ1k1hf0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rRmYna41lghluao6risBgqsGAvQiwPp5hIOyMXdd51w51LsU4HN0r6qzTeuAChiP3 rVCvJp7R1MFIIU3ZFRUXfYfSEMqSraJCflalVz0TXcwcJRn/KrY8wHkIcvLGHwR6AO bTI1PWs0M9l69ygcN0JQoPyJc/mfdCS/ep2xrh50= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:48 +0200 Message-ID: <20230616092959.5247-11-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/22] lavfi/vf_libplacebo: support blending multiple inputs 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: BHyZpERA9tKc From: Niklas Haas Subsequent inputs required frame blending to be enable, in order to not overwrite the existing frame contents. For output metadata, we implicitly copy the metadata of the *first* available stream (falling back to the second stream if the first has already reached EOF, and so on). This is done to resolve any conflicts between inputs with differing metadata. So when e.g. input 1 is HDR and output 2 is SDR, the output will be HDR, and vice versa. This logic could probablly be improved by dynamically determining some "superior" set of metadata, but I don't want to handle that complexity in this series. --- libavfilter/vf_libplacebo.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index d6f19f166d..3d812569f1 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -784,12 +784,18 @@ static int output_frame(AVFilterContext *ctx, int64_t pts) { int err = 0, ok, changed_csp; LibplaceboContext *s = ctx->priv; - LibplaceboInput *in = &s->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; const AVPixFmtDescriptor *outdesc = av_pix_fmt_desc_get(outlink->format); - const AVFrame *ref = ref_frame(&in->mix); struct pl_frame target; + const AVFrame *ref = NULL; AVFrame *out; + + /* Use the first active input as metadata reference */ + for (int i = 0; i < s->nb_inputs; i++) { + const LibplaceboInput *in = &s->inputs[i]; + if (in->qstatus == PL_QUEUE_OK && (ref = ref_frame(&in->mix))) + break; + } if (!ref) return 0; @@ -860,8 +866,18 @@ static int output_frame(AVFilterContext *ctx, int64_t pts) goto fail; } - update_crops(ctx, in, &target, out->pts * av_q2d(outlink->time_base)); - pl_render_image_mix(in->renderer, &in->mix, &target, &s->params); + /* Draw first frame opaque, others with blending */ + s->params.skip_target_clearing = false; + s->params.blend_params = NULL; + for (int i = 0; i < s->nb_inputs; i++) { + LibplaceboInput *in = &s->inputs[i]; + if (in->qstatus != PL_QUEUE_OK) + continue; + update_crops(ctx, in, &target, out->pts * av_q2d(outlink->time_base)); + pl_render_image_mix(in->renderer, &in->mix, &target, &s->params); + s->params.skip_target_clearing = true; + s->params.blend_params = &pl_alpha_overlay; + } if (outdesc->flags & AV_PIX_FMT_FLAG_HWACCEL) { pl_unmap_avframe(s->gpu, &target); From patchwork Fri Jun 16 09:29:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42148 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1392110pzb; Fri, 16 Jun 2023 02:33:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7AqFJ4N6ngLOJ7S7Rgdx9ALtdcJds/pOYfMroAKM8mB+VpeLCNJ+1FnpUfPbKFcgRJTGnD X-Received: by 2002:a17:907:8687:b0:973:91a5:bff1 with SMTP id qa7-20020a170907868700b0097391a5bff1mr1253238ejc.68.1686907988859; Fri, 16 Jun 2023 02:33:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686907988; cv=none; d=google.com; s=arc-20160816; b=TVzore1fFS3U3Ibi/VR0nvcycGSt4PX6zB+in5HD3CjxbE7Tp7ADay6kNKcXW90/7T aKvQNdXalDpQ5mUTXbis4PWwK1QM8yc8EmQlJNjT9ZU9eVVnW0ZnSX4M5MqFQalyhs3W BRx6/+NMjVxj/H+HbGQYZkfvXxVOCIhJ/TvvwaJpjHb2ylU9x95km0FH+z1+I/H8TVZG sph6jXcxnwlBNR0whJNwovGrGZtxaob7Bz7QarGC8ynkRC+ZsV2fX6il0/MmKfPWZc+4 WcIk9JZLqOgCm0n4RrpYExBL2JrWTMQ6FoadFw3vaUZ2SQ8BL3kyJikN5woYMm5K2//C QPDw== 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=iH8oK9ADuLAtWZBBjwHHDjP2yQ3iWqrNLA0IIf8CoRU=; b=Qs6hVW2zlr5JsRL8TU3wpOyGpcBhGDrI64YenSMRRdIj8lOa4yNZfh36tLCMgpqBJ0 DunwMS78y9HJdS8jXHCE4gHBcr1SSbWQ69mD4EeliWfrAmsf7HNs9oKrra7IBGbRMUCU 6fa7JJCrElLL3ERwUM6oiJ0l8cuG2INE7d1kQKRIGp2u7303QiZaqb/96e84bMMxC/Pw K/6Kx1XDq0YeARaQt8CB7x6RMRPX1AbZOSP7bAFs4HOfe3pl13LWMj+X7DKDQtgxOvC7 +xsfxZpBUX430zhLNiABcJT4HvuFLsdFr3oMvtDQy5KumYKgGDcqno23+v+gXqCpZwch WNPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=q7BVta9W; 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 f2-20020a1709064dc200b00982abce5796si1125033ejw.293.2023.06.16.02.33.08; Fri, 16 Jun 2023 02:33: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=q7BVta9W; 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 AD81368C617; Fri, 16 Jun 2023 12:30:43 +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 2CBC668C5D4 for ; Fri, 16 Jun 2023 12:30:27 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id 317D641B2C; Fri, 16 Jun 2023 11:30:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907826; bh=PTMfEW/TlTUKIvx0dmIMYlILpRkSjKu5Y+UGF5Ro6lY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q7BVta9WvP1e2Y9C1e6YWwmroKcUUcNLuDYvTHxNj58SCxWDsWqcwk2MD7UlUGdme JvE/gcXQ7+VRDq2eYmL4daxgnzmQFXZu+xfam5Ag8m/enHbILkwgPMtDY/pEhRO0j6 ZpR3Ux2UNyn4hTm9UG7A53B+SGB/B5ooW8lNZSHM= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:49 +0200 Message-ID: <20230616092959.5247-12-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/22] lavfi/vf_libplacebo: handle multiple inputs 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: FDa+QVCtXyZV From: Niklas Haas This commit still relies on a single input for PTS determination, to be changed in the next commit. --- libavfilter/vf_libplacebo.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 3d812569f1..08bb468c6b 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -977,11 +977,13 @@ static int libplacebo_activate(AVFilterContext *ctx) AVFilterLink *outlink = ctx->outputs[0]; int64_t pts; - FF_FILTER_FORWARD_STATUS_BACK(outlink, in->link); + FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, ctx); pl_log_level_update(s->log, get_log_level()); - if ((ret = handle_input(ctx, in)) < 0) - return ret; + for (int i = 0; i < s->nb_inputs; i++) { + if ((ret = handle_input(ctx, &s->inputs[i])) < 0) + return ret; + } if (ff_outlink_frame_wanted(outlink)) { if (s->fps.num) { From patchwork Fri Jun 16 09:29:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42150 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1392262pzb; Fri, 16 Jun 2023 02:33:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4JBMWrQkdgrHfiH+JZxdkvsMxvlGPYXTBupMK4+6Nam6b3qye2wbscCgDhjtbh05oJrB5M X-Received: by 2002:a17:906:730d:b0:982:a198:29f8 with SMTP id di13-20020a170906730d00b00982a19829f8mr1854009ejc.19.1686908005815; Fri, 16 Jun 2023 02:33:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686908005; cv=none; d=google.com; s=arc-20160816; b=bEBgDsE/4hfiT0TO+NITB4SPAYsDQVyzErXsIMlOdEZhjfzbp/Fa0uNQOssoPp/tFT 0Bv4V3d8YZI5b1DY7pycQTPiL4BxmUUJpr7MRs6o+1juFWXLkzl6La5hDSYCNR/PkJgw +UnJX89d142fRdTYOuh6stW7cGY2sQXEu7WLhTEqXGm+GZTkK/4g4ALVgBaHMBRsIAz1 Y6pZ67OxqaMlh4DrRODQfzYejARYbJ7fETgUp6j1AKUs3krQHX5BKDfCsI70kY+NIyqp uzdX6Xc3/ICEkQQPe7N4STGiQBy9XVsOKdzGnyBPcBgBjfDvpRPKp2GiGmBs7vBcxMVN szPQ== 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=d/pVd4pq2NrBR7ZK0VCjZtj8QzJ86QFDl5jz6vQN+RY=; b=IzwhepbYNevm7mHboMnwIv3h1TQnff1VKD4sni/A66+PjvvYfu4e+mjKtXeA7jWHko X6VdIlidrFy+J1pdHtP7LclwJ5de5KbBgzjOaf2KGjn+b3lhAWRVAcTA5jt5MEYyDdss 1DumutimXUF5P98g8fXaovICiI+0p7n6xEk7kT1wBm+xjmtRRBUljv9rXHWmeZonMBTb 7i2h5QAN2zwd3ivHKJx+lmtGUKoqcwnO7OwP/y+1MIHqJHwDrjGb4Vd0FNNSG8Se9tT5 39nZEWUoXhQB6ODj7gNoXTUudn4wiRe1KSV3+rKAyezWOaJ1/XLmL8DQlawJma5FSSrD hZTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=WZuqMKKh; 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 kl17-20020a170907995100b009780cfaae1bsi10908742ejc.32.2023.06.16.02.33.25; Fri, 16 Jun 2023 02:33:25 -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=WZuqMKKh; 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 B430A68C57C; Fri, 16 Jun 2023 12:30:45 +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 3396768C5D6 for ; Fri, 16 Jun 2023 12:30:27 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id C0E1F41BA3; Fri, 16 Jun 2023 11:30:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907826; bh=HKWjlu8KKEg6OlLK2OancmXPiWY/FBr2CWdzCUWqUn0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WZuqMKKhVV5eDAz/5o3GEzMFPsj5jB8I2xYbb0T1cXqIEpyL9rfrdppotUHqUtH03 thXnP7EqcLPKNptFr5Ij4QvamwKDRH87JgUEsfkbtGNzVlJsCSWhmDiWn2AxLOynpK J8a3WJhM28stnJLaSGXLYlvuxoKrQ/StHZKdWKjo= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:50 +0200 Message-ID: <20230616092959.5247-13-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 13/22] lavfi/vf_libplacebo: determine PTS of next frame from any input 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: wjhgTl9CyVz+ From: Niklas Haas When combining multiple inputs with different PTS and durations, in input-timed mode, we emit one output frame for every input frame PTS, from *any* input. So when combining a low FPS stream with a high FPS stream, the output framerate would match the higher FPS, independent of which order they are specified in. --- libavfilter/vf_libplacebo.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 08bb468c6b..5903bd5a01 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -971,11 +971,11 @@ static int handle_input(AVFilterContext *ctx, LibplaceboInput *input) static int libplacebo_activate(AVFilterContext *ctx) { - int ret; + int ret, retry = 0; LibplaceboContext *s = ctx->priv; LibplaceboInput *in = &s->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; - int64_t pts; + int64_t pts, out_pts; FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, ctx); pl_log_level_update(s->log, get_log_level()); @@ -987,24 +987,31 @@ static int libplacebo_activate(AVFilterContext *ctx) if (ff_outlink_frame_wanted(outlink)) { if (s->fps.num) { - pts = outlink->frame_count_out; - } else if (av_fifo_peek(in->out_pts, &pts, 1, 0) < 0) { - /* No frames queued */ - if (in->status) { - pts = in->status_pts; - } else { - ff_inlink_request_frame(in->link); - return 0; + out_pts = outlink->frame_count_out; + } else { + /* Determine the PTS of the next frame from any active input */ + out_pts = INT64_MAX; + for (int i = 0; i < s->nb_inputs; i++) { + LibplaceboInput *in = &s->inputs[i]; + if (av_fifo_peek(in->out_pts, &pts, 1, 0) >= 0) { + out_pts = FFMIN(out_pts, pts); + } else if (!in->status) { + ff_inlink_request_frame(in->link); + retry = true; + } } + + if (retry) /* some inputs are incomplete */ + return 0; } - if (s->status && pts >= s->status_pts) { + if (s->status && out_pts >= s->status_pts) { ff_outlink_set_status(outlink, s->status, s->status_pts); return 0; } in->qstatus = pl_queue_update(in->queue, &in->mix, pl_queue_params( - .pts = pts * av_q2d(outlink->time_base), + .pts = out_pts * av_q2d(outlink->time_base), .radius = pl_frame_mix_radius(&s->params), .vsync_duration = av_q2d(av_inv_q(outlink->frame_rate)), )); @@ -1016,7 +1023,7 @@ static int libplacebo_activate(AVFilterContext *ctx) case PL_QUEUE_OK: if (!s->fps.num) av_fifo_drain2(in->out_pts, 1); - return output_frame(ctx, pts); + return output_frame(ctx, out_pts); case PL_QUEUE_ERR: return AVERROR_EXTERNAL; } From patchwork Fri Jun 16 09:29:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42137 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1391046pzb; Fri, 16 Jun 2023 02:31:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4xdFrTQlllmVCl5elkfGAIpODJm9JR2RKFx73OuGkqg51rLVF7F2zQeIA7s33drCFaTCoQ X-Received: by 2002:a17:906:58c5:b0:982:4a23:3a97 with SMTP id e5-20020a17090658c500b009824a233a97mr1524582ejs.50.1686907881660; Fri, 16 Jun 2023 02:31:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686907881; cv=none; d=google.com; s=arc-20160816; b=BpJAlB/erV3a/jpvsdGzfbT759QZo1w9rzzhs6yaz8uvZaUNnVYiGl73xSVYiRTqzv RwNtC1s9hiQU3LSTvZ99+Xd7B5opSYrxk6eITKhDIbF4oUFou8Vx9Y2HdBLez1YjWFSY yK37KcWA2feI4SxUu9Cq+YK4YvyhcGZUOY7Q4/kqV0vw32tNZTs58jBhBkagopuJf+on gjF6P7z5BH0SsWZ2PDtpH3c9dK4dkNXpkwrFvfZ1P+Aqt5+WCcHj1NQqM+kLIF8dKTWH D8x3OdHNuGHcSRloApwbX8NbW1vC4tCl1LNyFiJXRA7TtedMBg1zFdb0I/FLFBTx2aBd YOPw== 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=CaDVwC2YlIziw0NTL6m1SnKGQqlSPKhoEC2jn+2ieTs=; b=SXD1z0j0Vhsco9K/cgSmnK4WrIPw05fBE09Yts82S3Zd28BA97ogJWkn33+3qiHp8N gL+dSF6g3mBNExIYaUiPRxUe397N8LDsTX/WujX7NErYFXsrpaLTfdq6MAdBhZqs0aV+ mPJUZIG4FHFYI/cfIjK3iyPnw+u2qo/xMTpx60YC+O53SP29qaah2CSe+OJsDg6GTZoS mZX1cJrDPBUkU25q/WD9uF4YltsHaefzlParGUZuDkaeIe6uZgx94EzcoRmmDYWZ49sH 1/Rc/rqlg0XPxFNXifyvDJ7XFdAftv1FBgNnJ2PUH5ADCvGYJJ8v2kUG6obrvA3zlREG xY0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=qfcM479F; 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 p16-20020a170906839000b009745659639csi10331294ejx.814.2023.06.16.02.31.20; Fri, 16 Jun 2023 02:31: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=@haasn.xyz header.s=mail header.b=qfcM479F; 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 34A7A68C5D7; Fri, 16 Jun 2023 12:30:32 +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 B197568C597 for ; Fri, 16 Jun 2023 12:30:27 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id 58A5D424F2; Fri, 16 Jun 2023 11:30:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907827; bh=6sbsxwKPGn1jHabq8v1fJ72/ssvyDWP5vqO8aBJdwTA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qfcM479Fyui4/9ozTobH+IirDjr3oAotqxqTBXbCdbcgPS9lo6Oe1cNAPruFBl0RI s71JSVUromvu/DhjbDucP8bXskQsNyYQLz3u32Lv3Q+Br0z/eeBHtdNk429UKMU2RF wYds5C+VW+Et4IWvvAp8c1HJ2BObuBKFH4IoXnXg= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:51 +0200 Message-ID: <20230616092959.5247-14-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 14/22] lavfi/vf_libplacebo: only drain actually used PTS 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: lppGOVpfosh/ From: Niklas Haas When combining multiple inputs, the output PTS may be less than the PTS of the input. In this case, the current's code assumption of always draining one value from the FIFO is incorrect. Replace by a smarter function which drains only those PTS values that were actually consumed. --- libavfilter/vf_libplacebo.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 5903bd5a01..896bdb4eb8 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -969,6 +969,13 @@ static int handle_input(AVFilterContext *ctx, LibplaceboInput *input) return 0; } +static void drain_input_pts(LibplaceboInput *in, int64_t until) +{ + int64_t pts; + while (av_fifo_peek(in->out_pts, &pts, 1, 0) >= 0 && pts <= until) + av_fifo_drain2(in->out_pts, 1); +} + static int libplacebo_activate(AVFilterContext *ctx) { int ret, retry = 0; @@ -1021,8 +1028,7 @@ static int libplacebo_activate(AVFilterContext *ctx) ff_inlink_request_frame(in->link); return 0; case PL_QUEUE_OK: - if (!s->fps.num) - av_fifo_drain2(in->out_pts, 1); + drain_input_pts(in, out_pts); return output_frame(ctx, out_pts); case PL_QUEUE_ERR: return AVERROR_EXTERNAL; From patchwork Fri Jun 16 09:29:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42138 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1391173pzb; Fri, 16 Jun 2023 02:31:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7YlF12gpXRlcRgk6VoW99VUPOqmQ8n/caAU1e8XAkXVDRRx9/ZxWoNY3EM8kr9p12pTa6k X-Received: by 2002:a17:907:97c3:b0:96f:cb13:8715 with SMTP id js3-20020a17090797c300b0096fcb138715mr1200627ejc.69.1686907891902; Fri, 16 Jun 2023 02:31:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686907891; cv=none; d=google.com; s=arc-20160816; b=QpiJiCv2noHSWEqUkBgNieX+9NooZDXA92gNYS8dU2ASbppavYFc2/em2cpWDgKMXv Lyr5gRtLhMkAdQJX59KlIqM7X0HoiK7r+RjWzd4XjCvd12QcglKMKS/330pW6T+m5uh2 mPqdGebf/zI2br7pqFyrpKvOfFmDvsHc6UJWXAceHkHE5x3DUBKJh60rRZW40XVHPnWd DxTCuktaYH94LYTWtRNhOSQlTlSkhEWytHVnysL5DhGog8icPjA3jAB9PXOO0p4HslK6 cjNdThn34AT45jIEVBhxMBjT4ITq+mGKv2vE62yeIncGAynN7gsEUnSI2Cwoa38rjHPH G2aA== 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=UvXm6K/+WuCQR+AkM+E4QkILl231PlVhf3YlOjMCbfk=; b=krnqvaL5au2sTpnYmq7P6sbxOfPkQwHQ/vES5r2p/xB9azwEVpzqZq/pa6W3kZgN64 glbVHTDS3Or684nUXhjflsvbo72Y+UuWMX7+CyGOsuNEpQsrQBz7/SyAfTcSMxTgRKg1 cQiTHX7SeCekj9sWm8X4Z7ao5Nmca7PUAOOnqiwARWHstPSqu718xqeAUEsfk5blpqdG TCTi1tvwFwbs8fVZ9NBB3c3RRcJ3vnrjQPHSzD2h5G0OE26UoXwSKSXPmaKUTKRweXpq yZzkYeotMnPC6C5xu/ehdONA0qMSATj87KynTgDOHRZ2YwGz6TGhZyHl9PD4JSHHScz6 MgwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=vg1prxRA; 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 a7-20020a1709065f8700b0098285fc55e1si2383045eju.340.2023.06.16.02.31.29; Fri, 16 Jun 2023 02:31: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=@haasn.xyz header.s=mail header.b=vg1prxRA; 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 6071368C5BF; Fri, 16 Jun 2023 12:30:33 +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 1E8EF68C5AA for ; Fri, 16 Jun 2023 12:30:28 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id DB5E2424F2; Fri, 16 Jun 2023 11:30:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907827; bh=WVldC3ir5z3UuiDb7PsTINiO7z8QIpNqUdgiss9pUb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vg1prxRADdlMhkgz9apoUBslqdUdUGIFTcf+kCro/yZO+IZp9QLulxn/227j4WP5J GtErHvIv26JgHx69cKq6I4cZVgZWWft0DXx0kj+9c8NAan99MiqN509B+mchOqAfyq P4fQGuX0lM5SQoSciTas/r0MzKsO+uEKKLfpSGfM= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:52 +0200 Message-ID: <20230616092959.5247-15-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 15/22] lavfi/vf_libplacebo: generalize frame update to multiple inputs 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: Hjp56+sGofMZ From: Niklas Haas In the event that some frame mixes are OK while others are not, the priority goes: 1. Errors in updating any frame -> return error 2. Any input incomplete -> request frames and return 3. Any inputs OK -> ignore EOF streams and render remaining inputs 4. No inputs OK -> set output to most recent status This logic ensures that we can continue rendering the remaining streams, no matter which streams reach their end of life, until we have no streams left at which point we forward the last EOF. --- libavfilter/vf_libplacebo.c | 52 ++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 896bdb4eb8..5af8167bb3 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -978,9 +978,8 @@ static void drain_input_pts(LibplaceboInput *in, int64_t until) static int libplacebo_activate(AVFilterContext *ctx) { - int ret, retry = 0; + int ret, ok = 0, retry = 0; LibplaceboContext *s = ctx->priv; - LibplaceboInput *in = &s->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; int64_t pts, out_pts; @@ -1012,26 +1011,43 @@ static int libplacebo_activate(AVFilterContext *ctx) return 0; } - if (s->status && out_pts >= s->status_pts) { - ff_outlink_set_status(outlink, s->status, s->status_pts); - return 0; - } + /* Update all input queues to the chosen out_pts */ + for (int i = 0; i < s->nb_inputs; i++) { + LibplaceboInput *in = &s->inputs[i]; + if (in->status && out_pts >= in->status_pts) { + in->qstatus = PL_QUEUE_EOF; + continue; + } - in->qstatus = pl_queue_update(in->queue, &in->mix, pl_queue_params( - .pts = out_pts * av_q2d(outlink->time_base), - .radius = pl_frame_mix_radius(&s->params), - .vsync_duration = av_q2d(av_inv_q(outlink->frame_rate)), - )); + in->qstatus = pl_queue_update(in->queue, &in->mix, pl_queue_params( + .pts = out_pts * av_q2d(outlink->time_base), + .radius = pl_frame_mix_radius(&s->params), + .vsync_duration = av_q2d(av_inv_q(outlink->frame_rate)), + )); + + switch (in->qstatus) { + case PL_QUEUE_MORE: + ff_inlink_request_frame(in->link); + retry = true; + break; + case PL_QUEUE_OK: + ok = true; + break; + case PL_QUEUE_ERR: + return AVERROR_EXTERNAL; + } + } - switch (in->qstatus) { - case PL_QUEUE_MORE: - ff_inlink_request_frame(in->link); + if (retry) { return 0; - case PL_QUEUE_OK: - drain_input_pts(in, out_pts); + } else if (ok) { + /* Got any valid frame mixes, drain PTS queue and render output */ + for (int i = 0; i < s->nb_inputs; i++) + drain_input_pts(&s->inputs[i], out_pts); return output_frame(ctx, out_pts); - case PL_QUEUE_ERR: - return AVERROR_EXTERNAL; + } else if (s->status) { + ff_outlink_set_status(outlink, s->status, s->status_pts); + return 0; } return AVERROR_BUG; From patchwork Fri Jun 16 09:29:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42139 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1391224pzb; Fri, 16 Jun 2023 02:31:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6mIkKiexRLIDoI9olp54azlJfAkNq1U3CaQfj3Qmw23DjaAts7QFB9ruSmbrDtlsLL2HoT X-Received: by 2002:a17:906:52d6:b0:982:a198:29ec with SMTP id w22-20020a17090652d600b00982a19829ecmr974261ejn.39.1686907898948; Fri, 16 Jun 2023 02:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686907898; cv=none; d=google.com; s=arc-20160816; b=0e/tW/U762y+B6aW/2WJYEaPqDZ72MZQr+BO1QupqGXgnCZttFiOFXP4J65ytuqa2O z91/o4sfcbaZr+tVORtoiUcug3zhiUbmjSk2RfcHRd/zJnJcWRYDEg0lWDVzS27WGd6M gD4LA6aVfnHkYZxPQMRPD2dy6C0Novq90ET92uTrIYLDppLKhsuyOUgvK7tQLnLATowB lqY03or34vJuxxq+KRQBSPmo/JPdi7zYuV3MzmCp/wcwIwV9Tmsat0C+g1CwdnXdqfXM Ku96mEO3WvXLX3MQMpluamDnTz4fWBv6iuAIpHfMTNzZ7/KHkCrY8PBJGKY8rjmGxA2X 4G3A== 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=FzWbN4iONy166M50fHXmN93whQb37pfiDz8tYnR8GGk=; b=ZDPD5twm2s+sT2GjlyRHPVa1OZoGFBMBZciI6yrwUfvlmXxiLzrlE5MdYuQ+j8h7Qa dz7ZnWoypsPGep7WnwqY4gMZ+skOJmJjAMIl9Ucz3o7pfjXFb1l0ca479WfKcsmjH6R4 6KVDBbjlnOr3mMVwmmE1AXsk4hD1NpKAQmNfwMSzeKdUyGK6XZ4lX8Ze1X/yjqAXkBpj XSB30IHNz9M2JumRv2FUuQKSkPD1nORdz64rJxfKVPSiC5lyvTm/huC7haHP2VElRi/E O50NlYrKYfbDds96LRN0IrX8bQ8BjO76O9WhR3XogdsXxyh0QVZiVIzu2LVVYpLXCKcM NyyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=tb3zqw4D; 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 a7-20020a1709065f8700b0098285fc55e1si2383182eju.340.2023.06.16.02.31.38; Fri, 16 Jun 2023 02:31:38 -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=tb3zqw4D; 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 55AA868C5D4; Fri, 16 Jun 2023 12:30:34 +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 9A64568C5AD for ; Fri, 16 Jun 2023 12:30:28 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id 76D72424F2; Fri, 16 Jun 2023 11:30:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907828; bh=4F4+XGKPudXwutHjxAfPxr+1Onluwdo91LnTRbdp2tQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tb3zqw4DxhOrjOgrlvGWxBiXw/hiWPobh/TAtD5gdGWucCNCJ6aEWrAH8LHrVgqG1 z6fkvjGuHeZIBQS9z4wRQiHy/P6PxirT3j6pV5YDO/QEhDu5+lABxmwf95wsip0Def 4J0wAZMS96el2wKhZh5JYbIIxtTmkRgeY4a93xDw= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:53 +0200 Message-ID: <20230616092959.5247-16-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 16/22] lavfi/vf_libplacebo: make input-dependent vars dynamic 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: tl7+mBtGMqMf From: Niklas Haas Because these can differ based on the input, for multiple inputs. --- libavfilter/vf_libplacebo.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 5af8167bb3..f86493f4e2 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -739,6 +739,11 @@ static void update_crops(AVFilterContext *ctx, LibplaceboInput *in, double image_pts = src->pts * av_q2d(in->link->time_base); /* Update dynamic variables */ + s->var_values[VAR_IN_W] = s->var_values[VAR_IW] = in->link->w; + s->var_values[VAR_IN_H] = s->var_values[VAR_IH] = in->link->h; + s->var_values[VAR_A] = (double) in->link->w / in->link->h; + s->var_values[VAR_SAR] = in->link->sample_aspect_ratio.num ? + av_q2d(in->link->sample_aspect_ratio) : 1.0; s->var_values[VAR_IN_T] = s->var_values[VAR_T] = image_pts; s->var_values[VAR_OUT_T] = s->var_values[VAR_OT] = target_pts; s->var_values[VAR_N] = ctx->outputs[0]->frame_count_out; @@ -1191,13 +1196,8 @@ static int libplacebo_config_output(AVFilterLink *outlink) } /* Static variables */ - s->var_values[VAR_IN_W] = s->var_values[VAR_IW] = inlink->w; - s->var_values[VAR_IN_H] = s->var_values[VAR_IH] = inlink->h; s->var_values[VAR_OUT_W] = s->var_values[VAR_OW] = outlink->w; s->var_values[VAR_OUT_H] = s->var_values[VAR_OH] = outlink->h; - s->var_values[VAR_A] = (double) inlink->w / inlink->h; - s->var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ? - av_q2d(inlink->sample_aspect_ratio) : 1.0; s->var_values[VAR_DAR] = outlink->sample_aspect_ratio.num ? av_q2d(outlink->sample_aspect_ratio) : 1.0; s->var_values[VAR_HSUB] = 1 << desc->log2_chroma_w; From patchwork Fri Jun 16 09:29:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42140 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1391307pzb; Fri, 16 Jun 2023 02:31:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7a5zSiUKS6lmqXf0XQFxN2T4qcSBpfZjToOU1VDWbeix8+r3qSaBvgCwbVldeNSwXJZzzQ X-Received: by 2002:a17:907:3ea2:b0:978:9b09:ccaf with SMTP id hs34-20020a1709073ea200b009789b09ccafmr1573102ejc.14.1686907907984; Fri, 16 Jun 2023 02:31:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686907907; cv=none; d=google.com; s=arc-20160816; b=XkZIQNAyI0UD1ROB3fB6l2nET8sLnkuTDNNrkaaLYV/gXKBW+P2az3fCgcRbWpoVwL 3t0mUvyWwJkuzufhZZc2/EEQTA2JPWTrNi6lsxHtHE/2iigDUVBjJFOFci9ZHiXvEvCZ OSbPZs0daf7P5ul3sZyU43jhnfrq6xp84zvp148+XSV5iNxku8fr9NskGdAJmsobW3Sh WYUEdMQGvzu3G7vynwwLdzyx0RkMRq/dosVZ899KdYGJPyOoTcfi+NxurS4cVUibPNqs Zx6O/TzA35UFvP5tkErr40+lCPQixtfMu3Ll8iLFI2vqEFt2RX+zElUjXmwGzP2Yrj9m 3dIw== 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=dkkp/PhBSRW7xuux1T7afSIJNMRYXMgwYSjcmh+f/MQ=; b=TRL3268nG2mVfg3UJfBuIi4+83g2ZSvRhC6CDL6ffKtE9n4pEopFnhm1vGCId660K+ CxDfjtITHRremQQ9v9UrYAkYkKXehTEo7EA8fbzjGjodpdRWQbmBxGaDO6ei0pLBBi9c 7Jp+kxN4wAGbfrNIu/p4iknAbDBbJjXy7qlaElrxt8krqrzdNeLg95m0W0LbIkbKDnW0 TH6Ov9j/LUmnLKGWrlPvVENEEIFF/9kYztgQRM3Ved9A/6xsLl56LWWKI6CfopXSlcgN 4YsvnmK2hG/elG9ksZlFAH/3EEWSgkha0NZPBXm0ZFeO0WxA0ULadIH1D4k1RQOsE7N9 M3IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=QA+OyPRU; 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 a23-20020a17090640d700b009827a0ca95dsi3015293ejk.136.2023.06.16.02.31.47; Fri, 16 Jun 2023 02:31:47 -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=QA+OyPRU; 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 5614A68C5D6; Fri, 16 Jun 2023 12:30:35 +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 4325668C5B8 for ; Fri, 16 Jun 2023 12:30:29 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id 0904D424F2; Fri, 16 Jun 2023 11:30:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907829; bh=1oh4G4Ds7q0J7DTduOpRx2H5qxG/LUfZcHKxCRHx57I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QA+OyPRUAXBHMYSI4vb84u2L0IqMsXrjciVZsOJoYOmJS+r+iEBQbdEWKkX+CCSQ+ bBcAIgCYvrSK6sCerFUt5astrhYKSw4H8+uVxTn7xjumjJi+/Zd8nLhZZzqrjVvnTo smZZGZWtyvEOIAZK+QLy5Y3R0Bp9dHXh+nf0Q85w= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:54 +0200 Message-ID: <20230616092959.5247-17-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 17/22] lavfi/vf_libplacebo: add in_idx variable 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: vkXL49r0/C4E From: Niklas Haas To allow placing an input dynamically, as a function of the input index. --- doc/filters.texi | 2 ++ libavfilter/vf_libplacebo.c | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index a46357bfd8..2ea4083c3e 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -16197,6 +16197,8 @@ the @option{crop_w}, @option{crop_h}, @option{crop_x}, @option{crop_y}, also contain the following constants: @table @option +@item in_idx, idx +The (0-based) numeric index of the currently active input stream. @item crop_w, cw @item crop_h, ch The computed values of @option{crop_w} and @option{crop_h}. diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index f86493f4e2..427a15dc47 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -70,6 +70,7 @@ enum { }; static const char *const var_names[] = { + "in_idx", "idx",///< index of input "in_w", "iw", ///< width of the input video frame "in_h", "ih", ///< height of the input video frame "out_w", "ow", ///< width of the output video frame @@ -92,6 +93,7 @@ static const char *const var_names[] = { }; enum var_name { + VAR_IN_IDX, VAR_IDX, VAR_IN_W, VAR_IW, VAR_IN_H, VAR_IH, VAR_OUT_W, VAR_OW, @@ -115,6 +117,7 @@ enum var_name { /* per-input dynamic filter state */ typedef struct LibplaceboInput { + int idx; pl_renderer renderer; pl_queue queue; enum pl_queue_status qstatus; @@ -574,7 +577,7 @@ static void unlock_queue(void *priv, uint32_t qf, uint32_t qidx) #endif static int input_init(AVFilterContext *avctx, AVFilterLink *link, - LibplaceboInput *input) + LibplaceboInput *input, int idx) { LibplaceboContext *s = avctx->priv; @@ -584,6 +587,7 @@ static int input_init(AVFilterContext *avctx, AVFilterLink *link, input->queue = pl_queue_create(s->gpu); input->renderer = pl_renderer_create(s->log, s->gpu); input->link = link; + input->idx = idx; return 0; } @@ -668,7 +672,7 @@ static int init_vulkan(AVFilterContext *avctx, const AVVulkanDeviceContext *hwct if (!s->inputs) return AVERROR(ENOMEM); for (int i = 0; i < s->nb_inputs; i++) - RET(input_init(avctx, avctx->inputs[i], &s->inputs[i])); + RET(input_init(avctx, avctx->inputs[i], &s->inputs[i], i)); /* fall through */ fail: @@ -739,6 +743,7 @@ static void update_crops(AVFilterContext *ctx, LibplaceboInput *in, double image_pts = src->pts * av_q2d(in->link->time_base); /* Update dynamic variables */ + s->var_values[VAR_IN_IDX] = s->var_values[VAR_IDX] = in->idx; s->var_values[VAR_IN_W] = s->var_values[VAR_IW] = in->link->w; s->var_values[VAR_IN_H] = s->var_values[VAR_IH] = in->link->h; s->var_values[VAR_A] = (double) in->link->w / in->link->h; From patchwork Fri Jun 16 09:29:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42151 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1392349pzb; Fri, 16 Jun 2023 02:33:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7EQOtGxcjPvIMhrHWpy0UDcCOQ0iXUb+4q6/f9L1penzKOly47XQ/ngcqBiv8cu331v3KY X-Received: by 2002:a17:907:9814:b0:973:afe2:a01 with SMTP id ji20-20020a170907981400b00973afe20a01mr1394428ejc.75.1686908015082; Fri, 16 Jun 2023 02:33:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686908015; cv=none; d=google.com; s=arc-20160816; b=I7Eed1OTks0nx7pFF6fLKZs+eIU5V8KuU5qo8dufvo6Scv0LVumcj28KhPc7TyBZ2H qTyGr6QGt6s7J/q9T252IoEIg4z0WX8+IkRftITiQ0Z1F64QsVi7eG84yd916/Z20LdG GXu0WGYDdobI2Z7YtwAEB/3mXEWgLaDUMEQxWyfaQ2296mCKnXGeMr/WiDCZdEjz9SyZ gfHZuS2X3mHlynSFbrG+gft1yS4nh25okax8XZkFT9ouLjUQuP9ciRujJpcbjiohmryn i8r5MK9g7+Lmt88d5vSTzY/jMI/eAYIwNJmPJFUW8EUKKjNuhIGkJ5VwDDeqcbofgL/W zcsA== 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=soJDD8ZMXLKnrEFLml+e1BCXc685LM4o9A3yyzuvWcY=; b=iwF9SoxgOviXWJEF+jGCRDdzI9eGzkvtw0bsrtMrxjf5pE5jEfQaB8lS8U7XiEJB6B Dk6lRiV8QJPbNqMm6yBnhcbXqtKVFsYd3pp+FO97vrQzqFHpehc8MhwPOkXPH6+hw4i1 RotgwTaFns3uM9+9K8/H/RsCtaokayPupJfcsNDSFUhMUOE903r4tvCysh6okEFg39gI soE3aTb12dmQqta6TJNjVYcJlSQAwg5IAmxBwEWFXN1QimQ2C3G7UlAPrw45M47UFoKI xieisJ/akUJfCLnfIcLapsWWoKQpzAfnm97KYl3LQeQirYB4mZ6WVKNVPULo3byjDNGx rE1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=mUSN9MwR; 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 z23-20020a1709060ad700b00982b34a9871si1359352ejf.233.2023.06.16.02.33.34; Fri, 16 Jun 2023 02:33:35 -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=mUSN9MwR; 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 9E39068C627; Fri, 16 Jun 2023 12:30:46 +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 B9AA568C5E7 for ; Fri, 16 Jun 2023 12:30:29 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id 90596424F2; Fri, 16 Jun 2023 11:30:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907829; bh=scxCkcRLJujdoqMuZdO1zkCGSH0W5DLHF6fSdJQ/JD8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mUSN9MwRFEZBM8iGSikHiKKH5PApvl7WHeb2yT0h8e3sY8awh668xN4Gc+BuH8ie3 XAIE0+rmIHWi1MXQ15CQCZtJVJzSSe4n38CIO/p82KRA8RHLrs/GWkiSdqu8/jNRdY bY8oNnPE+6mdJ324lO/nU5tnU9jh9BvK9/mFevi0= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:55 +0200 Message-ID: <20230616092959.5247-18-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 18/22] lavfi/vf_libplacebo: set format list for all inputs 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: 7Xqu9XkvMdxr From: Niklas Haas --- libavfilter/vf_libplacebo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 427a15dc47..a30b244843 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -1129,7 +1129,8 @@ static int libplacebo_query_format(AVFilterContext *ctx) goto fail; } - RET(ff_formats_ref(infmts, &ctx->inputs[0]->outcfg.formats)); + for (int i = 0; i < s->nb_inputs; i++) + RET(ff_formats_ref(infmts, &ctx->inputs[i]->outcfg.formats)); RET(ff_formats_ref(outfmts, &ctx->outputs[0]->incfg.formats)); return 0; From patchwork Fri Jun 16 09:29:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42152 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1392404pzb; Fri, 16 Jun 2023 02:33:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4NaH9R6WfGfonHWwtrchCKs7iRzTHxaE+sjiMtRlAA/rrm1Ur7XkzH0v+fLaggUF/3ctI7 X-Received: by 2002:a17:907:7f9f:b0:982:7b47:14e6 with SMTP id qk31-20020a1709077f9f00b009827b4714e6mr1259873ejc.12.1686908023503; Fri, 16 Jun 2023 02:33:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686908023; cv=none; d=google.com; s=arc-20160816; b=eH2JLOj6TmjbG6g6sdNN7AgP9zqJyWCY8pPz/2Qy0/E2vbZPj59pR4RiCXODud5TdV nmnahnTWrVWA27zfvIZmF++cv/J3mjZgQJ7tIhapo7ZfvWAlF+gNnQWeiXW1HcYLVW+L vsFyfJ5XijWy8Lsl9eNDsr7bVZn24tUlSnPBGZrTgmFfwkYGp3BzCApNNeykKawNv29O SOHB6QWmJCH8xITx4Kc9yITJl/9z2RXmLoPlxUDkMvAyl6P0o4ShWibbVPTyv3lVWpF8 4C5bERpMJwVOAWj6NQ6pSk958lAjzROSHvxA5lgET4eh9pz3zhmXxtjThe9jmDloPJyB z5XA== 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=FMN4Jq1L/ozAZYjOVgYsHNdUJosSyJI8Rb+IcxCldtY=; b=ubyVo4XEsOc6HZX8W29XDe9ayluz8P9nihG1rhabFZV4aZlSbfCFZaw6RbnzUeTsjG GLknjZlDPPfMRhG0IPHPYjditWNVjOQSXbkqE7AXPMzPgrsqbEoVLLa4QV9tFxN8B1TD gQw3guImtNYSYnEavfGVXiH3Eu7yFP8QflON7M+XKDGsgKZTWApPUTplJ8QxjNSifxMk wNQ24LBSykRGPrdgMkZuH797G3DyKiSMTR1pmjRN5qhK3Xt52we1vyJa7MGGcKcBnW3Z o4hp60b3+MO4f8reRw/iHom1gopO2KbFhDpgSyTXUn/nNLSal4x3eNYZBw5FPIh9XmpY RCSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=fT13E767; 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 y15-20020a1709060a8f00b0098658f7c1ebsi288827ejf.372.2023.06.16.02.33.43; Fri, 16 Jun 2023 02:33:43 -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=fT13E767; 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 7812368C62C; Fri, 16 Jun 2023 12:30:47 +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 6DA4E68C5E5 for ; Fri, 16 Jun 2023 12:30:30 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id 33A9A426BF; Fri, 16 Jun 2023 11:30:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907830; bh=CAdoohvrzuZk8G4lBSyuQJRUmcaeQMGXsWuNUiwVpSU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fT13E76777U5DWLA17oRJIpFyeXpSSYR8Z4JqA8qHXKaj5p/KbK2nWhAEcn8R5dkc 8iZa64d2LfeO5/teME0I0vfy2zHRkpr10dBjQqnma3NOVodpaBwQx2u01eOoxghWLP HGilSSEFIB3JyIHJBxB76QeJ8h+CwUmERaTpMAkg= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:56 +0200 Message-ID: <20230616092959.5247-19-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 19/22] lavfi/vf_libplacebo: skip cache selectively per-input 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: 3Oqv4k1Nh7Bh From: Niklas Haas It may be the case that we want to skip the single frame cache for some inputs but not others. --- libavfilter/vf_libplacebo.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index a30b244843..b78391441a 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -182,7 +182,6 @@ typedef struct LibplaceboContext { float antiringing; int sigmoid; int skip_aa; - int skip_cache; float polar_cutoff; int disable_linear; int disable_builtin; @@ -471,7 +470,6 @@ static int update_settings(AVFilterContext *ctx) .num_hooks = s->num_hooks, .skip_anti_aliasing = s->skip_aa, - .skip_caching_single_frame = s->skip_cache, .polar_cutoff = s->polar_cutoff, .disable_linear_scaling = s->disable_linear, .disable_builtin_scalers = s->disable_builtin, @@ -881,8 +879,10 @@ static int output_frame(AVFilterContext *ctx, int64_t pts) s->params.blend_params = NULL; for (int i = 0; i < s->nb_inputs; i++) { LibplaceboInput *in = &s->inputs[i]; + int high_fps = av_cmp_q(in->link->frame_rate, outlink->frame_rate) > 0; if (in->qstatus != PL_QUEUE_OK) continue; + s->params.skip_caching_single_frame = high_fps; update_crops(ctx, in, &target, out->pts * av_q2d(outlink->time_base)); pl_render_image_mix(in->renderer, &in->mix, &target, &s->params); s->params.skip_target_clearing = true; @@ -1196,9 +1196,6 @@ static int libplacebo_config_output(AVFilterLink *outlink) if (s->fps.num) { outlink->frame_rate = s->fps; outlink->time_base = av_inv_q(s->fps); - s->skip_cache = av_cmp_q(inlink->frame_rate, s->fps) > 0; - } else { - s->skip_cache = true; } /* Static variables */ From patchwork Fri Jun 16 09:29:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42145 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1391775pzb; Fri, 16 Jun 2023 02:32:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5hIuMxWUROmb6ORau+Ir2t5y3KZ91rDhzokSfs/CNkLDvumLOlokiYZU398E7mkeLorgzy X-Received: by 2002:a17:907:16a1:b0:980:1db8:d961 with SMTP id hc33-20020a17090716a100b009801db8d961mr1429614ejc.67.1686907953208; Fri, 16 Jun 2023 02:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686907953; cv=none; d=google.com; s=arc-20160816; b=DKkrpTLp8AMliorhzvruCdWhEmRSe8DlZpHbnLy/P6jnajkUYaOxvh5BM9unNXu/uV w0KW7bgzBn7/iE+nKu3F8jDKsSCG/+1fvfC/pn/8MZdMXGynuI+TTX+zqvWFD/5zkWk9 7tsBg83TE9dImLSDI2L/7etRW4qG4JxO+mJtQZhmvDW/K5gI6sDI3EpTjJi3wdrAJiFy YNm6KgJjt8JMGtrctDf2Ei5eTAYHM8XKHmMT0ZQ+TDOqutAH9/nQPqeuyykohIk2br1o 2dlz/RIgn2hqi5xBpDUx1VemdzHGGXVqD5m4rzt4v2nzSt7f1Gu+1Mj2yAB7OgV6G2nm dvpA== 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=V+o8rlFC5aIYBFHnuLT2wKNvzoghJ68EhVLBlDaNS0c=; b=VMUcJcJRkVE9C7We+3hIv71Sb4NpVRoENFmgTPl2v+pCP6NkO+3de7RScIElPeGAoo QprvVqv9D63WQzEih8P96+2lnsd3iXGuHZiXpq9p6uRSffUq2a4cXCLEp7mGpZ6xIAMU +XovVXDTnUVyFrwnU4XtZmw6dWsUz/hLD1t3m+gwVNfNxAa/ebKK94fr0HsfeX6b15Iv 4q+QT9F7YNjLZogEeyysbLFVuMr/ozksEemANwN94iqDdBPVlLfWLEn04EvmOsFSLMaw 53O1SOSivuhMfo20cLRH/Z0p5wp73q4Bs74RoVQmsC+8ujjIgJd84EDf2/aDf7ZsMvkh V9/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=qsdc03wF; 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 q13-20020a1709064c8d00b0097860824fc1si10438775eju.819.2023.06.16.02.32.32; Fri, 16 Jun 2023 02:32:33 -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=qsdc03wF; 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 17F7E68C605; Fri, 16 Jun 2023 12:30:40 +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 4E12A68C5C1 for ; Fri, 16 Jun 2023 12:30:30 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id BEE2242DAF; Fri, 16 Jun 2023 11:30:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907830; bh=IPTvDd1ypQPPAWWAWTghunKyOk5l4etsIQxERXNSV/g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qsdc03wFZf4lt7xys5QnpiQHFMcnr6nw9jAldyNgjFroQZ8ymek58GSryalhavJQJ mDf98mlCJQ3yhH48hJyRgBTZkpuXj3cwcHedp4bmorEIg/Ja7Ea/jTBx1GEkrUq0/o AdnZRUOR50/pkkVEvz8WY0LmAL2XRP1DPCVzNXdU= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:57 +0200 Message-ID: <20230616092959.5247-20-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 20/22] lavfi/vf_libplacebo: also skip cache if in FPS == out FPS 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: WZUtUU4j6duS From: Niklas Haas Fixes an oversight in the previous code which should have been >=, not >. --- libavfilter/vf_libplacebo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index b78391441a..9b1526f19e 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -879,7 +879,7 @@ static int output_frame(AVFilterContext *ctx, int64_t pts) s->params.blend_params = NULL; for (int i = 0; i < s->nb_inputs; i++) { LibplaceboInput *in = &s->inputs[i]; - int high_fps = av_cmp_q(in->link->frame_rate, outlink->frame_rate) > 0; + int high_fps = av_cmp_q(in->link->frame_rate, outlink->frame_rate) >= 0; if (in->qstatus != PL_QUEUE_OK) continue; s->params.skip_caching_single_frame = high_fps; From patchwork Fri Jun 16 09:29:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42134 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1391867pzb; Fri, 16 Jun 2023 02:32:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4zcgc7J7fJVOcLFNUJhGIO9Ijb3uyxlAsvtE74hvGWLjz00QBRbvQTie92P9Be9LOHGFSg X-Received: by 2002:a17:907:3f18:b0:975:942e:81d5 with SMTP id hq24-20020a1709073f1800b00975942e81d5mr1655660ejc.1.1686907962466; Fri, 16 Jun 2023 02:32:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686907962; cv=none; d=google.com; s=arc-20160816; b=G/+sSFDvXuS9rHNILByo2wpXbUZxvjAgh45bHiTsW+INI3nBcZ0RQc1rXyjudp5/33 kzY8E7WdoQpd/TR2ZIZB9yeB3UWN81pynkcHTlMpKQ7tXrYICznzfg/xXb1TKmZVKYZC gSD+QHGvLCoQYzANVKc9I60sc7C9MOzxkTj2Gq7d+SpBp07pGImpnBR/tI57CRg8l7zu Kt6DHw60Szsa2MFcLow1bcriN26VIlJ5xNyv4FyXzT7oBD+poZr/YGyaol1Uk8vqfdQj E9Ve8kuMPO3aeL0vn8+96q0t3LrHTbK+PrRTXEfF0gSK2EEgdYEJ+QGwbz1lLsaIDyeD +W1g== 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=zO4n6Zi1zCei9OBYFKiFI/GlGjMWj+3cEEuPe2PrGto=; b=TkULwkWyJsYRBdqmO/xBKpm/TagWjmT2T1SSWnvr/mL78JboHkpK4DurnuaM2Tgl47 qNBtg4Yvmd7lP/4dwU2Vyyk9H/BDptzxNN0Z0KfImeUepeR9x4qqoOLMYWFLdvnN7AZr PgTlkwEsWmh7a7fvLO7Zu+7WOCo6H5SzlusFi0SL8xPuJidzn2aSrx+oUHbcNYizCCpb FmRYqFdmqkyrl37mknkxIy6LPSx3ORd+dk5EDD6TIpsboBVnIKLRLyzonGxcwKsQx7Qx sP0ibb21onLNxnbpRVt+NH6aI0ngFbDLltr8E1vZiM31c2TNN5oprpaAjvCMHj7X4+Dn d+fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b="DvY1td4/"; 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 qt21-20020a170906ecf500b0098288d36168si1670896ejb.76.2023.06.16.02.32.42; Fri, 16 Jun 2023 02:32:42 -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="DvY1td4/"; 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 36A5768C5A9; Fri, 16 Jun 2023 12:30:41 +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 79EAB68C5C1 for ; Fri, 16 Jun 2023 12:30:31 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id 55301436B4; Fri, 16 Jun 2023 11:30:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907831; bh=Bu6cXQFW7flVz2N+p3SkLuhVfsVN4MBHUxoCNHn6ysQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DvY1td4/OyFChzBX8YYN+/lcHFc59GxuaPOdfw/fM2SmgOTM/rIZspUwy5vYdQCpX PfP3WBqUHHZ4E4GI4f9Tdh33rSqOX3+BCX/yAj8UqfJEprMiJBxcAxG5yNBSmy3Pgy wEI0rhGGCW2lQfLgyG208KfZgbK1fLpLJqTL5cTs= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:58 +0200 Message-ID: <20230616092959.5247-21-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 21/22] lavfi/vf_libplacebo: set time_base/frame_rate dynamically 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: i46KBxzGwAiT From: Niklas Haas Use the gcd of all input timebases to ensure PTS accuracy. For the framerate, just pick the highest of all the inputs, under the assumption that we will render frames with approximately this frequency. Of course, this is not 100% accurate, in particular if the input frames are badly misaligned. But this field is informational to begin with. Importantly, it covers the "common" case of combining high FPS and low FPS streams with aligned frames. --- libavfilter/vf_libplacebo.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 9b1526f19e..7840677b06 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -1156,6 +1156,11 @@ static int libplacebo_config_input(AVFilterLink *inlink) return 0; } +static inline AVRational max_q(AVRational a, AVRational b) +{ + return av_cmp_q(a, b) < 0 ? b : a; +} + static int libplacebo_config_output(AVFilterLink *outlink) { int err; @@ -1196,6 +1201,16 @@ static int libplacebo_config_output(AVFilterLink *outlink) if (s->fps.num) { outlink->frame_rate = s->fps; outlink->time_base = av_inv_q(s->fps); + } else { + outlink->frame_rate = avctx->inputs[0]->frame_rate; + outlink->time_base = avctx->inputs[0]->time_base; + for (int i = 1; i < s->nb_inputs; i++) { + outlink->frame_rate = max_q(outlink->frame_rate, + avctx->inputs[i]->frame_rate); + outlink->time_base = av_gcd_q(outlink->time_base, + avctx->inputs[i]->time_base, + AV_TIME_BASE / 2, AV_TIME_BASE_Q); + } } /* Static variables */ From patchwork Fri Jun 16 09:29:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42149 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1392190pzb; Fri, 16 Jun 2023 02:33:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ53eLMZ7NhrG12qw/52OuX0l8t5zUd7EakDCqwiUeCIRlFDtF5QR0VGTaUbfIVW5OvObP3k X-Received: by 2002:a17:906:fe4e:b0:96f:c46f:d8fe with SMTP id wz14-20020a170906fe4e00b0096fc46fd8femr1311141ejb.27.1686907997329; Fri, 16 Jun 2023 02:33:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686907997; cv=none; d=google.com; s=arc-20160816; b=l8tdqktpIht/SHrTkwuSy7LXPsPaggCnpeDQX1fMURTgk8e5Szw9HrBU95dQ9Z1Tfk BfQULOOh2DY1oOEqzXFFXf5cpJBfT0cpgS+Dw3ahXVJrGhtEhtiwDI2Am+jt+C7w8hVb a0gJxlnfAnyQ7JGFA16vhagQ6wE8nE+IJz2j1D66YSKcyGPP+LnfsSIDSE3jF+LQGqD1 Pshk/PGBhVGy6o5oi2WP/gB96vjQ/fWs+y5WE852w6XXhtPpRSFkOj0m8NmMU+a5jL1l V/7sMoqvpWsWJeEn6KM/1NjGDOWqFZiLVEvQNYtro4Hmn3WdgvVc4nY9iEJf+6lut+Av h6cg== 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=R1rrOSwDmcjsP2KVxvhhNnNdahl/dIXso3e4Dn4kjOs=; b=UQ58/8mdOofdJ9yUT5FMcmoVrP7geufA5depNH8mNGFHJT0JYfEIVdOipFBBwErf3n knGEn19ODp6xLDf9WwNMGuWT+0tR+NHoqJhCr7Mq0IdNj8QGdBkIXYhqrlVKFsG4kbT8 ppxHB32ypx+21qNLAZc7+lvuo6I6b7NdM6HdaylKxSMatPhDJCpDtyAYuzcDOuZ3bis3 4a64l9Zy6sZnTEPfbd8jie+2oF6JpmNtqjhj2Qan7II+4NTbIgJtMqrN1w915PgTx+GR e2nTu1y4KxWR6v7rMXrQMe/4+7rXuhZOMrjbEgFMSw0sLP6w0GAEuEf1l0k3wIds+tie j7sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=HIs3VkUz; 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 ci23-20020a170906c35700b00982a8f5ce55si1701581ejb.98.2023.06.16.02.33.17; Fri, 16 Jun 2023 02:33:17 -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=HIs3VkUz; 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 ACB8568C619; Fri, 16 Jun 2023 12:30:44 +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 2D0D068C5D5 for ; Fri, 16 Jun 2023 12:30:32 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id E77EE401C9; Fri, 16 Jun 2023 11:30:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907832; bh=pQ2x5jBAcwBxvGlTjfWKpaxzCo1TG1Ys5luv1rs1ydw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HIs3VkUz4+YjW7xMVvyr3Xk1q5BSUHboAzu2fpMmWkKJ4dfWrsnRWjKURuMhDnDVi 2tlheqmGDn7moGYruVdnyauGBIcnFL7DYC8aYREPmtKMY0SN1FmLzq1IfKf37zShyW EJbZJy1Z3Us6nQu2UX0POWMoKR/YDH/Z4hNkV168= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:59 +0200 Message-ID: <20230616092959.5247-22-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 22/22] lavfi/vf_libplacebo: add nb_inputs option 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: Pz1i0q93XVCR From: Niklas Haas To control the number of inputs. --- doc/filters.texi | 5 +++++ libavfilter/vf_libplacebo.c | 25 ++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 2ea4083c3e..41cf4976cb 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -16101,6 +16101,11 @@ to preserve the source colorimetry and size as best as it can, but it will apply any embedded film grain, dolby vision metadata or anamorphic SAR present in source frames. @table @option +@item inputs +Set the number of inputs. This can be used, alongside the @code{idx} variable, +to allow placing/blending multiple inputs inside the output frame. This +effectively enables functionality similar to @ref{hstack}, @ref{overlay}, etc. + @item w @item h Set the output video dimension expression. Default values are @code{iw} and diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 7840677b06..cd3a156731 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -502,6 +502,7 @@ static int parse_shader(AVFilterContext *avctx, const void *shader, size_t len) } static void libplacebo_uninit(AVFilterContext *avctx); +static int libplacebo_config_input(AVFilterLink *inlink); static int libplacebo_init(AVFilterContext *avctx) { @@ -530,6 +531,17 @@ static int libplacebo_init(AVFilterContext *avctx) s->out_format = AV_PIX_FMT_NONE; } + for (int i = 0; i < s->nb_inputs; i++) { + AVFilterPad pad = { + .name = av_asprintf("input%d", i), + .type = AVMEDIA_TYPE_VIDEO, + .config_props = &libplacebo_config_input, + }; + if (!pad.name) + return AVERROR(ENOMEM); + RET(ff_append_inpad_free_name(avctx, &pad)); + } + RET(update_settings(avctx)); RET(av_expr_parse(&s->crop_x_pexpr, s->crop_x_expr, var_names, NULL, NULL, NULL, NULL, 0, s)); @@ -665,7 +677,6 @@ static int init_vulkan(AVFilterContext *avctx, const AVVulkanDeviceContext *hwct } /* Initialize inputs */ - s->nb_inputs = 1; s->inputs = av_calloc(s->nb_inputs, sizeof(*s->inputs)); if (!s->inputs) return AVERROR(ENOMEM); @@ -1250,6 +1261,7 @@ fail: #define DYNAMIC (STATIC | AV_OPT_FLAG_RUNTIME_PARAM) static const AVOption libplacebo_options[] = { + { "inputs", "Number of inputs", OFFSET(nb_inputs), AV_OPT_TYPE_INT, {.i64 = 1}, 1, INT_MAX, .flags = STATIC }, { "w", "Output video frame width", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, .flags = STATIC }, { "h", "Output video frame height", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, .flags = STATIC }, { "fps", "Output video frame rate", OFFSET(fps_string), AV_OPT_TYPE_STRING, {.str = "none"}, .flags = STATIC }, @@ -1441,14 +1453,6 @@ static const AVOption libplacebo_options[] = { AVFILTER_DEFINE_CLASS(libplacebo); -static const AVFilterPad libplacebo_inputs[] = { - { - .name = "default", - .type = AVMEDIA_TYPE_VIDEO, - .config_props = &libplacebo_config_input, - }, -}; - static const AVFilterPad libplacebo_outputs[] = { { .name = "default", @@ -1465,10 +1469,9 @@ const AVFilter ff_vf_libplacebo = { .uninit = &libplacebo_uninit, .activate = &libplacebo_activate, .process_command = &libplacebo_process_command, - FILTER_INPUTS(libplacebo_inputs), FILTER_OUTPUTS(libplacebo_outputs), FILTER_QUERY_FUNC(libplacebo_query_format), .priv_class = &libplacebo_class, .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, - .flags = AVFILTER_FLAG_HWDEVICE, + .flags = AVFILTER_FLAG_HWDEVICE | AVFILTER_FLAG_DYNAMIC_INPUTS, };