Browse code

lavfi/buffersrc: add av_buffersrc_close().

Nicolas George authored on 2017/04/03 22:01:45
Showing 4 changed files
... ...
@@ -15,6 +15,9 @@ libavutil:     2015-08-28
15 15
 
16 16
 API changes, most recent first:
17 17
 
18
+2017-09-08 - xxxxxxx - lavfi 6.103.100 - buffersrc.h
19
+  Add av_buffersrc_close().
20
+
18 21
 2017-09-04 - xxxxxxx - lavc 57.105.100 - avcodec.h
19 22
   Add AV_HWACCEL_CODEC_CAP_EXPERIMENTAL, replacing the deprecated
20 23
   HWACCEL_CODEC_CAP_EXPERIMENTAL flag.
... ...
@@ -196,16 +196,9 @@ static int av_buffersrc_add_frame_internal(AVFilterContext *ctx,
196 196
 
197 197
     s->nb_failed_requests = 0;
198 198
 
199
-    if (!frame) {
200
-        s->eof = 1;
201
-        ff_avfilter_link_set_in_status(ctx->outputs[0], AVERROR_EOF, AV_NOPTS_VALUE);
202
-        if ((flags & AV_BUFFERSRC_FLAG_PUSH)) {
203
-            ret = push_frame(ctx->graph);
204
-            if (ret < 0)
205
-                return ret;
206
-        }
207
-        return 0;
208
-    } else if (s->eof)
199
+    if (!frame)
200
+        return av_buffersrc_close(ctx, AV_NOPTS_VALUE, flags);
201
+    if (s->eof)
209 202
         return AVERROR(EINVAL);
210 203
 
211 204
     refcounted = !!frame->buf[0];
... ...
@@ -267,6 +260,15 @@ static int av_buffersrc_add_frame_internal(AVFilterContext *ctx,
267 267
     return 0;
268 268
 }
269 269
 
270
+int av_buffersrc_close(AVFilterContext *ctx, int64_t pts, unsigned flags)
271
+{
272
+    BufferSourceContext *s = ctx->priv;
273
+
274
+    s->eof = 1;
275
+    ff_avfilter_link_set_in_status(ctx->outputs[0], AVERROR_EOF, pts);
276
+    return (flags & AV_BUFFERSRC_FLAG_PUSH) ? push_frame(ctx->graph) : 0;
277
+}
278
+
270 279
 static av_cold int init_video(AVFilterContext *ctx)
271 280
 {
272 281
     BufferSourceContext *c = ctx->priv;
... ...
@@ -193,6 +193,14 @@ av_warn_unused_result
193 193
 int av_buffersrc_add_frame_flags(AVFilterContext *buffer_src,
194 194
                                  AVFrame *frame, int flags);
195 195
 
196
+/**
197
+ * Close the buffer source after EOF.
198
+ *
199
+ * This is similar to passing NULL to av_buffersrc_add_frame_flags()
200
+ * except it takes the timestamp of the EOF, i.e. the timestamp of the end
201
+ * of the last frame.
202
+ */
203
+int av_buffersrc_close(AVFilterContext *ctx, int64_t pts, unsigned flags);
196 204
 
197 205
 /**
198 206
  * @}
... ...
@@ -30,7 +30,7 @@
30 30
 #include "libavutil/version.h"
31 31
 
32 32
 #define LIBAVFILTER_VERSION_MAJOR   6
33
-#define LIBAVFILTER_VERSION_MINOR 102
33
+#define LIBAVFILTER_VERSION_MINOR 103
34 34
 #define LIBAVFILTER_VERSION_MICRO 100
35 35
 
36 36
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \