diff options
Diffstat (limited to 'libavfilter/defaults.c')
-rw-r--r-- | libavfilter/defaults.c | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/libavfilter/defaults.c b/libavfilter/defaults.c index 146f1c7105..9ee23e57b7 100644 --- a/libavfilter/defaults.c +++ b/libavfilter/defaults.c @@ -2,20 +2,20 @@ * Filter layer - default implementations * 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,7 +25,6 @@ #include "avfilter.h" #include "internal.h" -/* TODO: buffer pool. see comment for avfilter_default_get_video_buffer() */ void ff_avfilter_default_free_buffer(AVFilterBuffer *ptr) { av_free(ptr->data[0]); @@ -39,10 +38,30 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per { int linesize[4]; uint8_t *data[4]; + int i; AVFilterBufferRef *picref = NULL; + AVFilterPool *pool= link->pool; + + if(pool) for(i=0; i<POOL_SIZE; i++){ + picref= pool->pic[i]; + if(picref && picref->buf->format == link->format && picref->buf->w == w && picref->buf->h == h){ + AVFilterBuffer *pic= picref->buf; + pool->pic[i]= NULL; + pool->count--; + picref->video->w = w; + picref->video->h = h; + picref->perms = perms | AV_PERM_READ; + picref->format= link->format; + pic->refcount = 1; + memcpy(picref->data, pic->data, sizeof(picref->data)); + memcpy(picref->linesize, pic->linesize, sizeof(picref->linesize)); + return picref; + } + }else + pool = link->pool = av_mallocz(sizeof(AVFilterPool)); // +2 is needed for swscaler, +16 to be SIMD-friendly - if (av_image_alloc(data, linesize, w, h, link->format, 16) < 0) + if ((i=av_image_alloc(data, linesize, w, h, link->format, 16)) < 0) return NULL; picref = avfilter_get_video_buffer_ref_from_arrays(data, linesize, @@ -51,6 +70,10 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per av_free(data[0]); return NULL; } + memset(data[0], 128, i); + + picref->buf->priv= pool; + picref->buf->free= NULL; return picref; } |