[FFmpeg-devel] [PATCH 2/5] avfilter/scale2ref: update links and re-eval expr upon ref frame change
Gyan
ffmpeg at gyani.pro
Sun Dec 15 19:06:43 EET 2019
2nd of 5 factorized patches; supersedes
https://patchwork.ffmpeg.org/patch/16272/
-------------- next part --------------
From f5055424fb9988644d413c2599fe7ed4526c8334 Mon Sep 17 00:00:00 2001
From: Gyan Doshi <ffmpeg at gyani.pro>
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);
}
--
2.24.0
More information about the ffmpeg-devel
mailing list