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

Christopher at mailsrv.uni-klu.ac.at Christopher at mailsrv.uni-klu.ac.at
Tue Mar 13 15:18:23 CET 2012


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




More information about the vlc-devel mailing list