[FFmpeg-devel] [PATCH v1 1/2] avfilter/vf_scale: split the scale_frame function from filter_frame for activate function support
lance.lmwang at gmail.com
lance.lmwang at gmail.com
Sat Jul 27 15:18:16 EEST 2019
From: Limin Wang <lance.lmwang at gmail.com>
Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
---
libavfilter/vf_scale.c | 29 +++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 7aebf56..efb480d 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -400,7 +400,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, int *got_frame)
{
ScaleContext *scale = link->dst->priv;
AVFilterLink *outlink = link->dst->outputs[0];
@@ -409,6 +409,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
char buf[32];
int in_range;
+ *got_frame = 0;
if (in->colorspace == AVCOL_SPC_YCGCO)
av_log(link->dst, AV_LOG_WARNING, "Detected unsupported YCgCo colorspace.\n");
@@ -437,8 +438,11 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
return ret;
}
- if (!scale->sws)
- return ff_filter_frame(outlink, in);
+ if (!scale->sws) {
+ *got_frame = 1;
+ *frame_out = in;
+ return 0;
+ }
scale->hsub = desc->log2_chroma_w;
scale->vsub = desc->log2_chroma_h;
@@ -448,6 +452,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;
@@ -521,7 +526,23 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
}
av_frame_free(&in);
- return ff_filter_frame(outlink, out);
+ *got_frame = 1;
+ return 0;
+}
+
+static int filter_frame(AVFilterLink *link, AVFrame *in)
+{
+ AVFilterContext *ctx = link->dst;
+ AVFilterLink *outlink = ctx->outputs[0];
+ int got_frame = 0;
+ AVFrame *out;
+ int ret;
+
+ ret = scale_frame(link, in, &out, &got_frame);
+ if (got_frame)
+ return ff_filter_frame(outlink, out);
+
+ return ret;
}
static int filter_frame_ref(AVFilterLink *link, AVFrame *in)
--
2.6.4
More information about the ffmpeg-devel
mailing list