From patchwork Sun Dec 15 17:06:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 16802 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id D32B2449BB4 for ; Sun, 15 Dec 2019 19:07:02 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BDF8F68A2CE; Sun, 15 Dec 2019 19:07:02 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D5F67689D14 for ; Sun, 15 Dec 2019 19:06:56 +0200 (EET) Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 47bW683K4CzQlCj for ; Sun, 15 Dec 2019 18:06:56 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter04.heinlein-hosting.de (spamfilter04.heinlein-hosting.de [80.241.56.122]) (amavisd-new, port 10030) with ESMTP id oa-iWUgoe2CR for ; Sun, 15 Dec 2019 18:06:52 +0100 (CET) To: FFmpeg development discussions and patches From: Gyan Message-ID: <95da4784-aa5c-a24b-0d96-62549a57ccc9@gyani.pro> Date: Sun, 15 Dec 2019 22:36:43 +0530 MIME-Version: 1.0 Content-Language: en-US Subject: [FFmpeg-devel] [PATCH 2/5] avfilter/scale2ref: update links and re-eval expr upon ref frame change X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 2nd of 5 factorized patches; supersedes https://patchwork.ffmpeg.org/patch/16272/ From f5055424fb9988644d413c2599fe7ed4526c8334 Mon Sep 17 00:00:00 2001 From: Gyan Doshi Date: Sun, 8 Dec 2019 15:54:28 +0530 Subject: [PATCH 2/5] avfilter/scale2ref: update links and re-eval expr upon ref frame change Needed when filtergraph reinit is disabled for the ref input. --- libavfilter/vf_scale.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index ba693bb601..5a375fac5d 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -392,8 +392,9 @@ static int scale_slice(AVFilterLink *link, AVFrame *out_buf, AVFrame *cur_pic, s static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame **frame_out) { - ScaleContext *scale = link->dst->priv; - AVFilterLink *outlink = link->dst->outputs[0]; + AVFilterContext *ctx = link->dst; + ScaleContext *scale = ctx->priv; + AVFilterLink *outlink = ctx->outputs[0]; AVFrame *out; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format); char buf[32]; @@ -410,7 +411,9 @@ static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame **frame_out) in->sample_aspect_ratio.den != link->sample_aspect_ratio.den || in->sample_aspect_ratio.num != link->sample_aspect_ratio.num; - if (frame_changed) { + if (frame_changed || + (scale->eval_mode == EVAL_MODE_FRAME && + ctx->filter == &ff_vf_scale2ref) ) { int ret; if (scale->eval_mode == EVAL_MODE_INIT) { @@ -538,6 +541,23 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) static int filter_frame_ref(AVFilterLink *link, AVFrame *in) { AVFilterLink *outlink = link->dst->outputs[1]; + int frame_changed; + + 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; + + 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; + + config_props_ref(outlink); + } return ff_filter_frame(outlink, in); }