[FFmpeg-cvslog] r17865 - in trunk/libavutil: fifo.c fifo.h

Michael Niedermayer michaelni
Sun Mar 8 01:33:17 CET 2009


On Sat, Mar 07, 2009 at 02:52:45PM -0800, Baptiste Coudurier wrote:
> Hi guys,
> 
> On 3/7/2009 1:02 PM, michael wrote:
> > Author: michael
> > Date: Sat Mar  7 22:02:08 2009
> > New Revision: 17865
> > 
> > Log:
> > Try to fix the 1 byte cant be used issue.
> > 
> > Modified:
> >    trunk/libavutil/fifo.c
> >    trunk/libavutil/fifo.h
> > 
> > Modified: trunk/libavutil/fifo.c
> > ==============================================================================
> > --- trunk/libavutil/fifo.c	Sat Mar  7 20:56:21 2009	(r17864)
> > +++ trunk/libavutil/fifo.c	Sat Mar  7 22:02:08 2009	(r17865)
> > @@ -24,10 +24,10 @@
> >  
> >  int av_fifo_init(AVFifoBuffer *f, unsigned int size)
> >  {
> > -    size= FFMAX(size, size+1);
> >      f->wptr = f->rptr =
> >      f->buffer = av_malloc(size);
> >      f->end = f->buffer + size;
> > +    f->rndx = f->wndx = 0;
> >      if (!f->buffer)
> >          return -1;
> >      return 0;
> > @@ -40,10 +40,7 @@ void av_fifo_free(AVFifoBuffer *f)
> >  
> >  int av_fifo_size(AVFifoBuffer *f)
> >  {
> > -    int size = f->wptr - f->rptr;
> > -    if (size < 0)
> > -        size += f->end - f->buffer;
> > -    return size;
> > +    return (uint32_t)(f->wndx - f->rndx);
> >  }
> >  
> >  int av_fifo_read(AVFifoBuffer *f, uint8_t *buf, int buf_size)
> > @@ -60,7 +57,7 @@ void av_fifo_realloc(AVFifoBuffer *f, un
> >  int av_fifo_realloc2(AVFifoBuffer *f, unsigned int new_size) {
> >      unsigned int old_size= f->end - f->buffer;
> >  
> > -    if(old_size <= new_size){
> > +    if(old_size < new_size){
> >          int len= av_fifo_size(f);
> >          AVFifoBuffer f2;
> >  
> 
> Btw is it reasonable to have an autorealloc fifo feature ?
> Which would make av_fifo_write return error if memory taken becomes too
> big of course, reasonable limit configurable at compile time ?
> 
> I'd like to have one.

How do you suggest to deal with the thread sync issues?
Currently read & write are thread&SMP safe
and together with av_fifo_size() are almost safe, ignoring a few missing
mem barriers for corner cases ...
but init/realloc is not safe and i dont see if/how it could be made safe

besides there is the smaller issue of the extra code being unneeded and
causing slowdown in some cases

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

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides
-------------- 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-cvslog/attachments/20090308/374038f7/attachment.pgp>



More information about the ffmpeg-cvslog mailing list