[vlc-devel] [PATCH 10/12] dash: fixed buffer precision bug

Christopher Müller christopher.mueller at itec.uni-klu.ac.at
Tue Mar 13 17:06:48 CET 2012



> -----Ursprüngliche Nachricht-----
> Von: Hugo Beauzée-Luyssen [mailto:beauze.h at gmail.com]
> Gesendet: Dienstag, 13. März 2012 16:42
> An: Mailing list for VLC media player developers
> Cc: Christopher Mueller
> Betreff: Re: [vlc-devel] [PATCH 10/12] dash: fixed buffer precision bug
> 
> On Tue, Mar 13, 2012 at 3:18 PM,  <Christopher at mailsrv.uni-klu.ac.at>
> wrote:
> > From: Christopher Mueller <christopher.mueller at itec.aau.at>
> >
> > ---
> >  modules/stream_filter/dash/buffer/BlockBuffer.cpp |   42
> > +++-----------------
> >  modules/stream_filter/dash/buffer/BlockBuffer.h   |    2 +-
> >  2 files changed, 8 insertions(+), 36 deletions(-)
> >
> > diff --git a/modules/stream_filter/dash/buffer/BlockBuffer.cpp
> > b/modules/stream_filter/dash/buffer/BlockBuffer.cpp
> > index 056c481..c05056d 100644
> > --- a/modules/stream_filter/dash/buffer/BlockBuffer.cpp
> > +++ b/modules/stream_filter/dash/buffer/BlockBuffer.cpp
> > @@ -101,14 +101,14 @@ int     BlockBuffer::get                  (void
> > *p_data, unsigned int len)
> >
> >     int ret = len > this->sizeBytes ? this->sizeBytes : len;
> >
> > -    this->reduceBufferMilliSec(ret);
> > -
> >     if(p_data == NULL)
> >         block_SkipBytes(&this->buffer, ret);
> >     else
> >         block_GetBytes(&this->buffer, (uint8_t *)p_data, ret);
> >
> >     block_BytestreamFlush(&this->buffer);
> > +    this->updateBufferSize(ret);
> > +
> >     this->notify();
> >
> >     vlc_cond_signal(&this->empty);
> > @@ -162,47 +162,19 @@ void    BlockBuffer::notify               ()
> >     for(size_t i = 0; i < this->bufferObservers.size(); i++)
> >
> > this->bufferObservers.at(i)->bufferLevelChanged(this->sizeMicroSec,
> > ((float)this->sizeMicroSec / this->capacityMicroSec) * 100);
> >  }
> > -void    BlockBuffer::reduceBufferMilliSec (size_t bytes)
> > +void    BlockBuffer::updateBufferSize     (size_t bytes)
> >  {
> > -    size_t  pos      = 0;
> > -    float   microsec = 0;
> > -
> >     block_t *block = this->buffer.p_block;
> >
> > -    if(bytes < (block->i_buffer - this->buffer.i_offset))
> > -    {
> > -        pos = bytes;
> > -        microsec = ((float)block->i_length / block->i_buffer) *
> > bytes;
> > -    }
> > -    else
> > -    {
> > -        pos = block->i_buffer - this->buffer.i_offset;
> > -        microsec = ((float)block->i_length / block->i_buffer) *
> > (block->i_buffer - this->buffer.i_offset);
> > -    }
> > +    this->sizeMicroSec = 0;
> >
> > -    while(pos < bytes)
> > +    while(block)
> >     {
> > +        this->sizeMicroSec += block->i_length;
> >         block = block->p_next;
> > -        if((bytes - pos) < (block->i_buffer - this-
> >buffer.i_offset))
> > -        {
> > -            pos = bytes;
> > -            microsec += ((float)block->i_length / block->i_buffer) *
> > (bytes - pos);
> > -        }
> > -        else
> > -        {
> > -            pos += block->i_buffer;
> > -            microsec += block->i_length;
> > -        }
> >     }
> >
> > -    this->sizeMicroSec  -= microsec;
> > -    this->sizeBytes     -= bytes;
> > -
> > -    if(this->sizeMicroSec < 0)
> > -        this->sizeMicroSec = 0;
> > -
> > -    if(this->sizeBytes == 0)
> > -        this->sizeMicroSec = 0;
> > +    this->sizeBytes -= bytes;
> >  }
> >  mtime_t BlockBuffer::size                 ()
> >  {
> > diff --git a/modules/stream_filter/dash/buffer/BlockBuffer.h
> > b/modules/stream_filter/dash/buffer/BlockBuffer.h
> > index 570861f..06a35fc 100644
> > --- a/modules/stream_filter/dash/buffer/BlockBuffer.h
> > +++ b/modules/stream_filter/dash/buffer/BlockBuffer.h
> > @@ -69,7 +69,7 @@ namespace dash
> >
> >                 std::vector<IBufferObserver *> bufferObservers;
> >
> > -                void reduceBufferMilliSec(size_t bytes);
> > +                void updateBufferSize(size_t bytes);
> >         };
> >     }
> >  }
> > --
> > 1.7.0.4
> >
> > _______________________________________________
> > vlc-devel mailing list
> > To unsubscribe or modify your subscription options:
> > http://mailman.videolan.org/listinfo/vlc-devel
> 
> Can't this be avoided by keeping the ammount of available bytes in a
> BlockBuffer attribute?

The problem is that the bytes belong to different bitrates. The size in microsec is stored in each block so an iteration over all blocks is the most accurate way to calculate the buffer size. The other solution had problems with small bitrates and a small blocks so that the buffer runs out of bytes but the system thinks that there are still a couple of seconds in the buffer.

BR
Chris




More information about the vlc-devel mailing list