[FFmpeg-devel,v1,2/2] avfilter/vf_scale: change filter_frame interface to activate interface

Submitted by lance.lmwang@gmail.com on July 27, 2019, 12:18 p.m.

Details

Message ID 20190727121817.22390-2-lance.lmwang@gmail.com
State New
Headers show

Commit Message

lance.lmwang@gmail.com July 27, 2019, 12:18 p.m.
From: Limin Wang <lance.lmwang@gmail.com>

It's for the frame thread support later, once I have finished frame thread
fate testing, I'll submit for review.

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavfilter/vf_scale.c | 38 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index efb480d..cce7ba0 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -27,6 +27,7 @@ 
 #include <string.h>
 
 #include "avfilter.h"
+#include "filters.h"
 #include "formats.h"
 #include "internal.h"
 #include "scale.h"
@@ -545,6 +546,41 @@  static int filter_frame(AVFilterLink *link, AVFrame *in)
     return ret;
 }
 
+static int activate(AVFilterContext *ctx)
+{
+    AVFilterLink *inlink = ctx->inputs[0];
+    AVFilterLink *outlink = ctx->outputs[0];
+    AVFrame *in, *out;
+    int64_t pts;
+    int ret, status;
+    int got_frame = 0;
+
+    FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
+
+    ret = ff_inlink_consume_frame(inlink, &in);
+    if (ret > 0) {
+        ret = scale_frame(inlink, in, &out, &got_frame);
+        if (ret)
+            return ret;
+    }
+
+    if (ff_inlink_acknowledge_status(inlink, &status, &pts)) {
+        if (status == AVERROR_EOF) {
+            /* frame flushing */
+        }
+
+        ff_outlink_set_status(outlink, status, pts);
+        return ret;
+    }
+
+    if (got_frame)
+        return ff_filter_frame(outlink, out);
+
+    FF_FILTER_FORWARD_WANTED(outlink, inlink);
+
+    return FFERROR_NOT_READY;
+}
+
 static int filter_frame_ref(AVFilterLink *link, AVFrame *in)
 {
     AVFilterLink *outlink = link->dst->outputs[1];
@@ -643,7 +679,6 @@  static const AVFilterPad avfilter_vf_scale_inputs[] = {
     {
         .name         = "default",
         .type         = AVMEDIA_TYPE_VIDEO,
-        .filter_frame = filter_frame,
     },
     { NULL }
 };
@@ -662,6 +697,7 @@  AVFilter ff_vf_scale = {
     .description     = NULL_IF_CONFIG_SMALL("Scale the input video size and/or convert the image format."),
     .init_dict       = init_dict,
     .uninit          = uninit,
+    .activate        = activate,
     .query_formats   = query_formats,
     .priv_size       = sizeof(ScaleContext),
     .priv_class      = &scale_class,