From patchwork Wed Mar 13 12:24:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 47023 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:e85:b0:1a3:31a3:7958 with SMTP id ma5csp348737pzb; Wed, 13 Mar 2024 05:24:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUW8jyy4KMVCuPNwGiIwmfr+FwBM8Bi/vV1RbqfkaSyihYE4CjqMLcA/ESujAz+FFOMTLm1kmGBpeGX8Jn12ZiXm75u6JRdVwthzw== X-Google-Smtp-Source: AGHT+IG+yymggpOAiJVeRIAclkcR9vIKXDXkL2Z06KWxULDA6AxptRN7oXExu8gK6uuLTQ9XoT75 X-Received: by 2002:a05:6402:907:b0:568:3362:cccf with SMTP id g7-20020a056402090700b005683362cccfmr8836211edz.7.1710332679642; Wed, 13 Mar 2024 05:24:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710332679; cv=none; d=google.com; s=arc-20160816; b=zqnykNW7Fae4vxSOe4Um4vtsKxQmmNpWnWJ1e+odOIu87x/wSs4m7zraxiDwnz8nOK DWTRouaLgTLR5ycoDtqr2eh5uBWWY2yICn6do6l6aowHB+Jty3AdpjrrVIoRNOYyh7WA aIA36xCF6TH1Nt9f/k+rNkj6EYjPifhDdU421vJDqQrS1YpNORwtuEQX9YJ51rodUq5X AWYsS5xLuxBjKsj7/9T1uYwi/A1XRQyxSUd157lSlFwONSdrVuEEDFsNT5oinO2hGzu3 XE0KFHMutj2dNLz/cuJwcWrLg/XX98Q3YMI281yObu/Tg4Tmtz2GuXTw60v7m/myiFUo bBGw== 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=01CHV3Phksy0geaMevSRy3UmhZ1ut2vhPg4RPntyUmY=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=huINglTATXpuA1dxDGlRq4Ui0hVuqL5j0R0vjDTA5IuasMMSQISqlkswQ+3GxUKCMA x/kBb/TUYQuhNPQ+bZrEXwfViwIaxFGlPacYaKS9qNnAhXv9h3fT+oSGGiaexcuR2EY8 fILk1k732E6KDzcsfgP4R6VmIaRHWoL3t2dF/Ciz1+rx01nd2CzIKtX307rT/e4AD/p2 stDlDhpPacwgGwtKX0IsKYFTHz7EZryTg3UfJKwclUqESLOUF92VwMQVeBMZw3PS+EWf mtAvQ+E13QL5Ydcya5+VR00XRutBwa77sQ0i1lp/CPHvCUikJPY2Gfno0STTxMl6rdRx 3kCA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=ZQ+gk2xg; 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 u22-20020aa7d896000000b00567f50ff747si4673711edq.598.2024.03.13.05.24.39; Wed, 13 Mar 2024 05:24:39 -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=ZQ+gk2xg; 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 EDE5268D0A6; Wed, 13 Mar 2024 14:24:35 +0200 (EET) 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 2757E68C1D5 for ; Wed, 13 Mar 2024 14:24:29 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1710332668; bh=CCmPz7xCJq2eu85cNpCc4IErU6hVkeP/qHVkYacYiF4=; h=From:To:Cc:Subject:Date:From; b=ZQ+gk2xg3w1znGBfZKM1orovV0kSyWl0i8qWowJPMVoYGttzh2SZBDA69yvlNQ5hD gqrGDgi/8J2VeiiUzuO1FH/ceifwb5IkopJ63BeitxxWl88WLLs/PwRpxuBPsPv82k pdLZm6PMfaHpIAavF5wTls7djrhJ/nyjgVV+tR8E= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id BDF2340703; Wed, 13 Mar 2024 13:24:28 +0100 (CET) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 13 Mar 2024 13:24:24 +0100 Message-ID: <20240313122425.92457-1-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avfilter: mark scale2ref as supporting dynamic sizes 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: Y7+aYgduufMn From: Niklas Haas Analogous to the "scale" filter, which this is practically identical with. --- libavfilter/avfilter.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 831871de90b..dcad4d55292 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -1027,7 +1027,8 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame) strcmp(link->dst->filter->name, "format") && strcmp(link->dst->filter->name, "idet") && strcmp(link->dst->filter->name, "null") && - strcmp(link->dst->filter->name, "scale")) { + strcmp(link->dst->filter->name, "scale") && + strcmp(link->dst->filter->name, "scale2ref")) { av_assert1(frame->format == link->format); av_assert1(frame->width == link->w); av_assert1(frame->height == link->h); From patchwork Wed Mar 13 12:24:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 47024 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:e85:b0:1a3:31a3:7958 with SMTP id ma5csp348814pzb; Wed, 13 Mar 2024 05:24:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXStNNZP2ySSatvxbvvmw9DEr5Eb+JtuAnlVdXo3suMWUcRI2ybEJNpGZE4Uh9L8DiulHvEsKNBU+ucS1zHZUqMu3HhC6zjiLN45Q== X-Google-Smtp-Source: AGHT+IFfu3beh7MZ2ECrVehOnLLH44vh9rGnNrzt1golO/ot1lZvKX/oDhvHx5MxJWEaOvVRX1aX X-Received: by 2002:a17:906:3417:b0:a46:2ac1:c3f4 with SMTP id c23-20020a170906341700b00a462ac1c3f4mr4996551ejb.75.1710332690184; Wed, 13 Mar 2024 05:24:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710332690; cv=none; d=google.com; s=arc-20160816; b=owo/l/4vN8kpIxveRMGGWPu7E0m1cQDZbDU4NzWTUhnSlrdOquPJmTP7d8Fk8BZ7yI fbUav6F8K5HyUlNNnkZxMQvdHHjK3FJyUXbFtvbzaPZWlN/BLZvyBJJdR9qBwlRsHKLH o08hgzGtZPeYfxT6tt7ybyEd6YtzUdbSKdb2rI5Xzv2g5SqiYtAoMGczhV2+gSpWkA/K Gq78QRkh6RB96WK+Y0sYCEODn1iUNvIsAZi9DdpkPQyqQB2de6wR72AwfT61l5/jUlL8 7Or7dtIo8uFtfxUu1ONY5TRkJebhHGs+4OFeINpAdGZRBhvhvfWCKD3ICQBwaz++Yzwe dS9w== 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=QP5f5Zu6R1yAhILBiJL2I0ReQr/FSKHdEV3/wD4h2I0=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=DvwfmN3m5A4QQiTC8avSEuhag2vn5r182Hjs8n/5Nx8cyPRNt2aJDXU/1Q2XMo7F4s vtETJHs7H0NBxN3J7Wm3q3RaOvkZgeb79iQwdAIvjNEsnakq+MXtZdcwO8Lum/aGbLUI fFc1U8RN6uZaaHc1HmsbELKdyzpIvGeS/odkMB42Z2fF5DDcLETIaTWiAO32VCY4IPHU 4anIKiKE2LnNlXzTD0AMuJ/rDxVBPORULjukXFJfSyMlS2mneCgfGPA0J5qEHY5CMu7o 8p4bAYQORXvEpsGnv8I+Pm/GnErAa8uMlICSoT1hE7MG8jUs9To2KA5a50fI2+JFikt7 ImkA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=ungYDaPr; 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 x9-20020a170906298900b00a461f0f31b0si3266845eje.64.2024.03.13.05.24.49; Wed, 13 Mar 2024 05:24:50 -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=ungYDaPr; 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 0D18B68CF89; Wed, 13 Mar 2024 14:24:37 +0200 (EET) 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 56CEB68C1D5 for ; Wed, 13 Mar 2024 14:24:29 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1710332669; bh=eX2hGT4sU0JNHeP16YF8cXV5A3Qj5IcsVSJIuIj0vis=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ungYDaPr5bw+R6030/vScmrgJtYeI4/kj8RSPejGDnOEdFAW8SSGSJOBKhBZNphCt lt+nPseXRpe+ZakubqlTtzNVLybkCID2fhyKb+j8pxIRJ5CvH7FkRMEaBhSC00VtP8 tdtYeTqe0N2t1swxur2o5yLQmWLJCJ2o0xtxfZgM= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 1626B426B1; Wed, 13 Mar 2024 13:24:29 +0100 (CET) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 13 Mar 2024 13:24:25 +0100 Message-ID: <20240313122425.92457-2-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313122425.92457-1-ffmpeg@haasn.xyz> References: <20240313122425.92457-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avfilter/vf_scale2ref: switch to FFFrameSync 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: 6T0nT4Nvq2O8 From: Niklas Haas This filter's existing design has a number of issues: - There is no guarantee whatsoever about the order in which frames are pushed onto the main and ref link, due to this being entirely dependent on the order in which downstream filters decide to request frames from their various inputs. As such, there is absolutely no synchronization for ref streams with dynamically changing resolutions (see e.g. fate/h264/reinit-*). - For some (likely historical) reason, this filter outputs its ref stream as a second ref output, which is in principle completely unnecessary (complex filter graph users can just duplicate the input pin), but in practice only required to allow this filter to "eventually" see changes to the ref stream (see first point). In particular, this means that if the user uses the "wrong" pin, this filter may break completely. - The default filter activation function is fundamentally incapable of handling filters with multiple inputs cleanly, because doing so requires both knowledge of how these inputs should be internally ordered, but also how to handle EOF conditions on either input (or downstream). Both of these are best left to the filter specific options. (See #10795 for the consequences of using the default activate with multiple inputs). Switching this filter to framesync fixes all three points: - ff_framesync_activate() correctly handles multiple inputs and EOF conditions (and is configurable with the framesync-specific options) - framesync only supports a single output, so we can (indeed must) drop the redundant ref output stream Update documentation, changelog and tests to correspond to the new usage pattern. Fixes: https://trac.ffmpeg.org/ticket/10795 --- Changelog | 2 + doc/filters.texi | 10 +- libavfilter/vf_scale.c | 130 ++++++++++++----------- tests/filtergraphs/scale2ref_keep_aspect | 3 +- 4 files changed, 76 insertions(+), 69 deletions(-) diff --git a/Changelog b/Changelog index 069b8274489..bacda2524ea 100644 --- a/Changelog +++ b/Changelog @@ -32,6 +32,8 @@ version : - DVD-Video demuxer, powered by libdvdnav and libdvdread - ffprobe -show_stream_groups option - ffprobe (with -export_side_data film_grain) now prints film grain metadata +- scale2ref now only has a single output stream, and supports the framesync + options version 6.1: diff --git a/doc/filters.texi b/doc/filters.texi index e0436a5755c..07e8136adb3 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -21555,9 +21555,9 @@ Deprecated, do not use. Scale (resize) the input video, based on a reference video. See the scale filter for available options, scale2ref supports the same but -uses the reference video instead of the main input as basis. scale2ref also -supports the following additional constants for the @option{w} and -@option{h} options: +uses the reference video instead of the main input as basis. This filter also +supports the @ref{framesync} options. In addition, scale2ref also supports the +following additional constants for the @option{w} and @option{h} options: @table @var @item main_w @@ -21600,13 +21600,13 @@ Only available with @code{eval=frame}. @item Scale a subtitle stream (b) to match the main video (a) in size before overlaying @example -'scale2ref[b][a];[a][b]overlay' +'[b][a]scale2ref[sub];[a][sub]overlay' @end example @item Scale a logo to 1/10th the height of a video, while preserving its display aspect ratio. @example -[logo-in][video-in]scale2ref=w=oh*mdar:h=ih/10[logo-out][video-out] +[logo-in][video]scale2ref=w=oh*mdar:h=ih/10[logo-out] @end example @end itemize diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index fc3b5a91e60..d4173b63097 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -29,6 +29,7 @@ #include "avfilter.h" #include "formats.h" +#include "framesync.h" #include "internal.h" #include "scale_eval.h" #include "video.h" @@ -114,6 +115,7 @@ typedef struct ScaleContext { struct SwsContext *isws[2]; ///< software scaler context for interlaced material // context used for forwarding options to sws struct SwsContext *sws_opts; + FFFrameSync fs; ///< for scale2ref /** * New dimensions. Special values are: @@ -288,6 +290,9 @@ static av_cold int preinit(AVFilterContext *ctx) if (ret < 0) return ret; + if (ctx->filter == &ff_vf_scale2ref) + ff_framesync_preinit(&scale->fs); + return 0; } @@ -303,6 +308,8 @@ static const int sws_colorspaces[] = { -1 }; +static int do_scale2ref(FFFrameSync *fs); + static av_cold int init(AVFilterContext *ctx) { ScaleContext *scale = ctx->priv; @@ -380,6 +387,7 @@ static av_cold int init(AVFilterContext *ctx) if (!threads) av_opt_set_int(scale->sws_opts, "threads", ff_filter_get_nb_threads(ctx), 0); + scale->fs.on_event = do_scale2ref; return 0; } @@ -389,6 +397,7 @@ static av_cold void uninit(AVFilterContext *ctx) av_expr_free(scale->w_pexpr); av_expr_free(scale->h_pexpr); scale->w_pexpr = scale->h_pexpr = NULL; + ff_framesync_uninit(&scale->fs); sws_freeContext(scale->sws_opts); sws_freeContext(scale->sws); sws_freeContext(scale->isws[0]); @@ -678,35 +687,16 @@ static int config_props(AVFilterLink *outlink) flags_val); av_freep(&flags_val); - return 0; - -fail: - return ret; -} - -static int config_props_ref(AVFilterLink *outlink) -{ - AVFilterLink *inlink = outlink->src->inputs[1]; - - outlink->w = inlink->w; - outlink->h = inlink->h; - outlink->sample_aspect_ratio = inlink->sample_aspect_ratio; - outlink->time_base = inlink->time_base; - outlink->frame_rate = inlink->frame_rate; - outlink->colorspace = inlink->colorspace; - outlink->color_range = inlink->color_range; + if (ctx->filter != &ff_vf_scale2ref) + return 0; - return 0; -} + if ((ret = ff_framesync_init_dualinput(&scale->fs, ctx)) < 0) + return ret; -static int request_frame(AVFilterLink *outlink) -{ - return ff_request_frame(outlink->src->inputs[0]); -} + return ff_framesync_configure(&scale->fs); -static int request_frame_ref(AVFilterLink *outlink) -{ - return ff_request_frame(outlink->src->inputs[1]); +fail: + return ret; } static void frame_offset(AVFrame *frame, int dir, int is_pal) @@ -909,43 +899,49 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) return ret; } -static int filter_frame_ref(AVFilterLink *link, AVFrame *in) +static int do_scale2ref(FFFrameSync *fs) { - ScaleContext *scale = link->dst->priv; - AVFilterLink *outlink = link->dst->outputs[1]; - int frame_changed; + AVFilterContext *ctx = fs->parent; + ScaleContext *scale = ctx->priv; + AVFilterLink *reflink = ctx->inputs[1]; + AVFilterLink *outlink = ctx->outputs[0]; + AVFrame *main, *ref, *out; + int ret; - frame_changed = in->width != link->w || - in->height != link->h || - in->format != link->format || - in->sample_aspect_ratio.den != link->sample_aspect_ratio.den || - in->sample_aspect_ratio.num != link->sample_aspect_ratio.num || - in->colorspace != link->colorspace || - in->color_range != link->color_range; + ret = ff_framesync_dualinput_get(fs, &main, &ref); + if (ret < 0) + return ret; - if (frame_changed) { - link->format = in->format; - link->w = in->width; - link->h = in->height; - link->sample_aspect_ratio.num = in->sample_aspect_ratio.num; - link->sample_aspect_ratio.den = in->sample_aspect_ratio.den; - link->colorspace = in->colorspace; - link->color_range = in->color_range; + if (ref) { + reflink->format = ref->format; + reflink->w = ref->width; + reflink->h = ref->height; + reflink->sample_aspect_ratio.num = ref->sample_aspect_ratio.num; + reflink->sample_aspect_ratio.den = ref->sample_aspect_ratio.den; + reflink->colorspace = ref->colorspace; + reflink->color_range = ref->color_range; - config_props_ref(outlink); - } + ret = config_props(outlink); + if (ret < 0) + return ret; - if (scale->eval_mode == EVAL_MODE_FRAME) { - scale->var_values[VAR_N] = link->frame_count_out; - scale->var_values[VAR_T] = TS2T(in->pts, link->time_base); + if (scale->eval_mode == EVAL_MODE_FRAME) { + scale->var_values[VAR_N] = reflink->frame_count_out; + scale->var_values[VAR_T] = TS2T(ref->pts, reflink->time_base); #if FF_API_FRAME_PKT FF_DISABLE_DEPRECATION_WARNINGS - scale->var_values[VAR_POS] = in->pkt_pos == -1 ? NAN : in->pkt_pos; + scale->var_values[VAR_POS] = ref->pkt_pos == -1 ? NAN : ref->pkt_pos; FF_ENABLE_DEPRECATION_WARNINGS #endif + } + } + + ret = scale_frame(ctx->inputs[0], main, &out); + if (out) { + return ff_filter_frame(outlink, out); } - return ff_filter_frame(outlink, in); + return ret; } static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, @@ -973,9 +969,25 @@ static int process_command(AVFilterContext *ctx, const char *cmd, const char *ar return ret; } +static int activate(AVFilterContext *ctx) +{ + ScaleContext *scale = ctx->priv; + return ff_framesync_activate(&scale->fs); +} + static const AVClass *child_class_iterate(void **iter) { - const AVClass *c = *iter ? NULL : sws_get_class(); + void *tmp = NULL; + const AVClass *sws = sws_get_class(); + const AVClass *fs = ff_framesync_child_class_iterate(tmp); + const AVClass *c; + if (!*iter) { + c = sws; + } else if (*iter == (void*)(uintptr_t)sws) { + c = fs; + } else { + c = NULL; + } *iter = (void*)(uintptr_t)c; return c; } @@ -985,6 +997,8 @@ static void *child_next(void *obj, void *prev) ScaleContext *s = obj; if (!prev) return s->sws_opts; + if (prev == s->sws_opts) + return &s->fs; return NULL; } @@ -1082,12 +1096,10 @@ static const AVFilterPad avfilter_vf_scale2ref_inputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .filter_frame = filter_frame, }, { .name = "ref", .type = AVMEDIA_TYPE_VIDEO, - .filter_frame = filter_frame_ref, }, }; @@ -1096,13 +1108,6 @@ static const AVFilterPad avfilter_vf_scale2ref_outputs[] = { .name = "default", .type = AVMEDIA_TYPE_VIDEO, .config_props = config_props, - .request_frame= request_frame, - }, - { - .name = "ref", - .type = AVMEDIA_TYPE_VIDEO, - .config_props = config_props_ref, - .request_frame= request_frame_ref, }, }; @@ -1117,5 +1122,6 @@ const AVFilter ff_vf_scale2ref = { FILTER_INPUTS(avfilter_vf_scale2ref_inputs), FILTER_OUTPUTS(avfilter_vf_scale2ref_outputs), FILTER_QUERY_FUNC(query_formats), + .activate = activate, .process_command = process_command, }; diff --git a/tests/filtergraphs/scale2ref_keep_aspect b/tests/filtergraphs/scale2ref_keep_aspect index f407460ec7c..d63968666a8 100644 --- a/tests/filtergraphs/scale2ref_keep_aspect +++ b/tests/filtergraphs/scale2ref_keep_aspect @@ -1,5 +1,4 @@ sws_flags=+accurate_rnd+bitexact; testsrc=size=320x240 [main]; testsrc=size=640x360 [ref]; -[main][ref] scale2ref=iw/4:ow/mdar [main][ref]; -[ref] nullsink +[main][ref] scale2ref=iw/4:ow/mdar [main]