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

Baptiste Coudurier baptiste.coudurier
Thu May 20 23:03:38 CEST 2010


On 05/20/2010 01:06 PM, Michael Niedermayer wrote:
> 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 ?

Well, Im not really familiar with the perms yet.
REUSE2 is a obfuscated name IMHO.
Also why isn't READ always set ?

[...]

-- 
Baptiste COUDURIER
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer                                  http://www.ffmpeg.org



More information about the ffmpeg-devel mailing list