[vlc-commits] dash: fixed buffer precision bug

Christopher Mueller git at videolan.org
Mon Apr 16 11:05:01 CEST 2012


vlc | branch: master | Christopher Mueller <christopher.mueller at itec.aau.at> | Tue Apr  3 16:41:41 2012 +0200| [af864e981129e8eab29554c63104193393f73cb4] | committer: Hugo Beauzée-Luyssen

dash: fixed buffer precision bug

Signed-off-by: Christopher Mueller <christopher.mueller at itec.aau.at>
Signed-off-by: Hugo Beauzée-Luyssen <beauze.h at gmail.com>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=af864e981129e8eab29554c63104193393f73cb4
---

 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 1db9168..ec20c2c 100644
--- a/modules/stream_filter/dash/buffer/BlockBuffer.cpp
+++ b/modules/stream_filter/dash/buffer/BlockBuffer.cpp
@@ -117,14 +117,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);
@@ -178,47 +178,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 92c8bd6..006fe31 100644
--- a/modules/stream_filter/dash/buffer/BlockBuffer.h
+++ b/modules/stream_filter/dash/buffer/BlockBuffer.h
@@ -70,7 +70,7 @@ namespace dash
 
                 std::vector<IBufferObserver *> bufferObservers;
 
-                void reduceBufferMilliSec(size_t bytes);
+                void updateBufferSize(size_t bytes);
         };
     }
 }



More information about the vlc-commits mailing list