]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/fifo.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavfilter / fifo.c
index 16a86b3565e67ff4ec7f60d7350cb3d02bfd936c..8c978cc93cf77c9ed0d45ac270194f7218aa33ae 100644 (file)
@@ -1,20 +1,20 @@
 /*
  * Copyright (c) 2007 Bobby Bingham
  *
- * This file is part of Libav.
+ * This file is part of FFmpeg.
  *
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
@@ -25,6 +25,7 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/audioconvert.h"
+#include "libavutil/common.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/samplefmt.h"
 
@@ -65,11 +66,11 @@ static av_cold void uninit(AVFilterContext *ctx)
 
     for (buf = fifo->root.next; buf; buf = tmp) {
         tmp = buf->next;
-        avfilter_unref_buffer(buf->buf);
+        avfilter_unref_bufferp(&buf->buf);
         av_free(buf);
     }
 
-    avfilter_unref_buffer(fifo->buf_out);
+    avfilter_unref_bufferp(&fifo->buf_out);
 }
 
 static int add_to_queue(AVFilterLink *inlink, AVFilterBufferRef *buf)
@@ -169,6 +170,9 @@ static int return_audio_frame(AVFilterContext *ctx)
             queue_pop(s);
         } else {
             buf_out = avfilter_ref_buffer(head, AV_PERM_READ);
+            if (!buf_out)
+                return AVERROR(ENOMEM);
+
             buf_out->audio->nb_samples = link->request_samples;
             buffer_offset(link, head, link->request_samples);
         }
@@ -241,9 +245,11 @@ static int request_frame(AVFilterLink *outlink)
      * so we don't have to worry about dereferencing it ourselves. */
     switch (outlink->type) {
     case AVMEDIA_TYPE_VIDEO:
-        ff_start_frame(outlink, fifo->root.next->buf);
-        ff_draw_slice (outlink, 0, outlink->h, 1);
-        ff_end_frame  (outlink);
+        if ((ret = ff_start_frame(outlink, fifo->root.next->buf)) < 0 ||
+            (ret = ff_draw_slice(outlink, 0, outlink->h, 1)) < 0 ||
+            (ret = ff_end_frame(outlink)) < 0)
+            return ret;
+
         queue_pop(fifo);
         break;
     case AVMEDIA_TYPE_AUDIO:
@@ -276,7 +282,7 @@ AVFilter avfilter_vf_fifo = {
                                           .start_frame     = add_to_queue,
                                           .draw_slice      = draw_slice,
                                           .end_frame       = end_frame,
-                                          .rej_perms       = AV_PERM_REUSE2, },
+                                          .min_perms       = AV_PERM_PRESERVE, },
                                         { .name = NULL}},
     .outputs   = (const AVFilterPad[]) {{ .name            = "default",
                                           .type            = AVMEDIA_TYPE_VIDEO,
@@ -297,7 +303,7 @@ AVFilter avfilter_af_afifo = {
                                           .type             = AVMEDIA_TYPE_AUDIO,
                                           .get_audio_buffer = ff_null_get_audio_buffer,
                                           .filter_samples   = add_to_queue,
-                                          .rej_perms        = AV_PERM_REUSE2, },
+                                          .min_perms        = AV_PERM_PRESERVE, },
                                         { .name = NULL}},
     .outputs   = (const AVFilterPad[]) {{ .name             = "default",
                                           .type             = AVMEDIA_TYPE_AUDIO,