]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vsrc_buffer.c
get_buffers: Check that pix_fmt is not NONE.
[ffmpeg] / libavfilter / vsrc_buffer.c
index 6f44368a32348fb98a0dd1cb3012630ba759a6d6..743698eff952752f07469dc5ac00da12fc71cfaf 100644 (file)
@@ -39,6 +39,12 @@ typedef struct {
     char              sws_param[256];
 } BufferSourceContext;
 
+#define CHECK_PARAM_CHANGE(s, c, width, height, format)\
+    if (c->w != width || c->h != height || c->pix_fmt != format) {\
+        av_log(s, AV_LOG_ERROR, "Changing frame properties on the fly is not supported.\n");\
+        return AVERROR(EINVAL);\
+    }
+
 int av_vsrc_buffer_add_video_buffer_ref(AVFilterContext *buffer_filter,
                                         AVFilterBufferRef *picref, int flags)
 {
@@ -125,6 +131,8 @@ int av_buffersrc_buffer(AVFilterContext *s, AVFilterBufferRef *buf)
         return AVERROR(EINVAL);
     }
 
+//     CHECK_PARAM_CHANGE(s, c, buf->video->w, buf->video->h, buf->format);
+
     c->picref = buf;
 
     return 0;
@@ -174,6 +182,14 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
     return 0;
 }
 
+static av_cold void uninit(AVFilterContext *ctx)
+{
+    BufferSourceContext *s = ctx->priv;
+    if (s->picref)
+        avfilter_unref_buffer(s->picref);
+    s->picref = NULL;
+}
+
 static int query_formats(AVFilterContext *ctx)
 {
     BufferSourceContext *c = ctx->priv;
@@ -217,7 +233,7 @@ static int request_frame(AVFilterLink *link)
 static int poll_frame(AVFilterLink *link)
 {
     BufferSourceContext *c = link->src->priv;
-    return !!(c->picref);
+    return !!c->picref;
 }
 
 AVFilter avfilter_vsrc_buffer = {
@@ -227,6 +243,7 @@ AVFilter avfilter_vsrc_buffer = {
     .query_formats = query_formats,
 
     .init      = init,
+    .uninit    = uninit,
 
     .inputs    = (const AVFilterPad[]) {{ .name = NULL }},
     .outputs   = (const AVFilterPad[]) {{ .name      = "default",