]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/video.c
configure: add decimate filter dependency on avcodec
[ffmpeg] / libavfilter / video.c
index eb92edd8f23aa39803276e487e39eb855e915169..9ab8edb12cfd9c8f26913ba4faaab624f230a21a 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <string.h>
+#include <stdio.h>
+
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
+#include "libavutil/mem.h"
 
 #include "avfilter.h"
 #include "internal.h"
@@ -39,6 +43,10 @@ AVFilterBufferRef *ff_default_get_video_buffer(AVFilterLink *link, int perms, in
     int i;
     AVFilterBufferRef *picref = NULL;
     AVFilterPool *pool = link->pool;
+    int full_perms = AV_PERM_READ | AV_PERM_WRITE | AV_PERM_PRESERVE |
+                     AV_PERM_REUSE | AV_PERM_REUSE2 | AV_PERM_ALIGN;
+
+    av_assert1(!(perms & ~(full_perms | AV_PERM_NEG_LINESIZES)));
 
     if (pool) {
         for (i = 0; i < POOL_SIZE; i++) {
@@ -49,7 +57,7 @@ AVFilterBufferRef *ff_default_get_video_buffer(AVFilterLink *link, int perms, in
                 pool->count--;
                 picref->video->w = w;
                 picref->video->h = h;
-                picref->perms = perms | AV_PERM_READ;
+                picref->perms = full_perms;
                 picref->format = link->format;
                 pic->refcount = 1;
                 memcpy(picref->data,     pic->data,     sizeof(picref->data));
@@ -68,7 +76,7 @@ AVFilterBufferRef *ff_default_get_video_buffer(AVFilterLink *link, int perms, in
         return NULL;
 
     picref = avfilter_get_video_buffer_ref_from_arrays(data, linesize,
-                                                       perms, w, h, link->format);
+                                                       full_perms, w, h, link->format);
     if (!picref) {
         av_free(data[0]);
         return NULL;
@@ -165,7 +173,7 @@ int ff_inplace_start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
     AVFilterBufferRef *outpicref = NULL, *for_next_filter;
     int ret = 0;
 
-    if ((inpicref->perms & AV_PERM_WRITE) && !(inpicref->perms & AV_PERM_PRESERVE)) {
+    if (inpicref->perms & AV_PERM_WRITE) {
         outpicref = avfilter_ref_buffer(inpicref, ~0);
         if (!outpicref)
             return AVERROR(ENOMEM);
@@ -232,16 +240,26 @@ static void clear_link(AVFilterLink *link)
 int ff_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
 {
     int (*start_frame)(AVFilterLink *, AVFilterBufferRef *);
+    AVFilterPad *src = link->srcpad;
     AVFilterPad *dst = link->dstpad;
-    int ret, perms = picref->perms;
+    int ret, perms;
     AVFilterCommand *cmd= link->dst->command_queue;
     int64_t pts;
 
     FF_TPRINTF_START(NULL, start_frame); ff_tlog_link(NULL, link, 0); ff_tlog(NULL, " "); ff_tlog_ref(NULL, picref, 1);
 
+    if (link->closed) {
+        avfilter_unref_buffer(picref);
+        return AVERROR_EOF;
+    }
+
     if (!(start_frame = dst->start_frame))
         start_frame = default_start_frame;
 
+    av_assert1((picref->perms & src->min_perms) == src->min_perms);
+    picref->perms &= ~ src->rej_perms;
+    perms = picref->perms;
+
     if (picref->linesize[0] < 0)
         perms |= AV_PERM_NEG_LINESIZES;
     /* prepare to copy the picture if it has insufficient permissions */