aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/vf_scale.c
diff options
context:
space:
mode:
authorLimin Wang <lance.lmwang@gmail.com>2019-09-07 23:11:25 +0800
committerMichael Niedermayer <michael@niedermayer.cc>2019-09-08 02:15:46 +0200
commitcbc63d61b284190979739ae7632511c12c17e54c (patch)
tree5facfddc02afae6b00cea5d40162a5081af6e2e7 /libavfilter/vf_scale.c
parent5b12a47e088da3388e7285dc9e44e70ea7bfd2d4 (diff)
downloadffmpeg-cbc63d61b284190979739ae7632511c12c17e54c.tar.gz
avfilter/vf_scale: split the scale_frame function from filter_frame for activate function support
Signed-off-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavfilter/vf_scale.c')
-rw-r--r--libavfilter/vf_scale.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index bf340b8e7b..cb42794086 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -412,7 +412,7 @@ static int scale_slice(AVFilterLink *link, AVFrame *out_buf, AVFrame *cur_pic, s
out,out_stride);
}
-static int filter_frame(AVFilterLink *link, AVFrame *in)
+static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame **frame_out)
{
ScaleContext *scale = link->dst->priv;
AVFilterLink *outlink = link->dst->outputs[0];
@@ -421,6 +421,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
char buf[32];
int in_range;
+ *frame_out = NULL;
if (in->colorspace == AVCOL_SPC_YCGCO)
av_log(link->dst, AV_LOG_WARNING, "Detected unsupported YCgCo colorspace.\n");
@@ -449,8 +450,10 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
return ret;
}
- if (!scale->sws)
- return ff_filter_frame(outlink, in);
+ if (!scale->sws) {
+ *frame_out = in;
+ return 0;
+ }
scale->hsub = desc->log2_chroma_w;
scale->vsub = desc->log2_chroma_h;
@@ -460,6 +463,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
av_frame_free(&in);
return AVERROR(ENOMEM);
}
+ *frame_out = out;
av_frame_copy_props(out, in);
out->width = outlink->w;
@@ -533,7 +537,21 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
}
av_frame_free(&in);
- return ff_filter_frame(outlink, out);
+ return 0;
+}
+
+static int filter_frame(AVFilterLink *link, AVFrame *in)
+{
+ AVFilterContext *ctx = link->dst;
+ AVFilterLink *outlink = ctx->outputs[0];
+ AVFrame *out;
+ int ret;
+
+ ret = scale_frame(link, in, &out);
+ if (out)
+ return ff_filter_frame(outlink, out);
+
+ return ret;
}
static int filter_frame_ref(AVFilterLink *link, AVFrame *in)