[FFmpeg-devel] [PATCH] implement frame buffering in vsrc buffer

Michael Niedermayer michaelni
Thu May 20 22:06:38 CEST 2010


On Thu, May 20, 2010 at 01:26:34AM -0700, Baptiste Coudurier wrote:
> Hi
>
> $subject.
>
> -- 
> Baptiste COUDURIER
> Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
> FFmpeg maintainer                                  http://www.ffmpeg.org

>  vsrc_buffer.c |   76 +++++++++++++++++++++++++++++-----------------------------
>  1 file changed, 38 insertions(+), 38 deletions(-)
> ca598907c4fbbc4bff577654401342454c48dbb2  vsrc_buffer_fifo.patch
> Index: libavfilter/vsrc_buffer.c
> ===================================================================
> --- libavfilter/vsrc_buffer.c	(revision 23153)
> +++ libavfilter/vsrc_buffer.c	(working copy)
> @@ -19,15 +19,13 @@
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>   */
>  
> +#include "libavutil/fifo.h"
>  #include "avfilter.h"
>  #include "vsrc_buffer.h"
>  
>  typedef struct {
> -    int64_t           pts;
> -    AVFrame           frame;
> -    int               has_frame;
> +    AVFifoBuffer      *fifo;
>      int               h, w, pix_fmt;
> -    AVRational        pixel_aspect;
>  } BufferSourceContext;
>  
>  
> @@ -35,23 +33,27 @@
>                               int64_t pts, AVRational pixel_aspect)
>  {
>      BufferSourceContext *c = buffer_filter->priv;
> +    AVFilterLink *link = buffer_filter->outputs[0];
> +    AVFilterPicRef *picref;
>  
> -    if (c->has_frame) {
> -        av_log(buffer_filter, AV_LOG_ERROR,
> -               "Buffering several frames is not supported. "
> -               "Please consume all available frames before adding a new one.\n"
> -            );
> -        //return -1;
> -    }
> +    if (av_fifo_space(c->fifo) < sizeof(picref))
> +        if (av_fifo_realloc2(c->fifo, av_fifo_size(c->fifo)*2) < 0)
> +            return -1;
>  
> -    memcpy(c->frame.data    , frame->data    , sizeof(frame->data));
> -    memcpy(c->frame.linesize, frame->linesize, sizeof(frame->linesize));
> -    c->frame.interlaced_frame= frame->interlaced_frame;
> -    c->frame.top_field_first = frame->top_field_first;
> -    c->pts = pts;
> -    c->pixel_aspect = pixel_aspect;
> -    c->has_frame = 1;
> +    picref = avfilter_get_video_buffer(link, AV_PERM_WRITE | AV_PERM_PRESERVE |
> +                                       AV_PERM_REUSE2,

why AV_PERM_REUSE2 ?
and dont we need AV_PERM_READ ?

anyway that patch should be ok if its tested, works and you see no
problems being added by it for future no-copy support.

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

> ... defining _GNU_SOURCE...
For the love of all that is holy, and some that is not, don't do that.
-- Luca & Mans
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100520/89cb0949/attachment.pgp>



More information about the ffmpeg-devel mailing list