Commit ee31841e authored by François Cartegnie's avatar François Cartegnie 🤞
Browse files

demux: adptative: add missing remainder doing stats

parent 2ff8049f
......@@ -38,7 +38,7 @@ using namespace adaptative::logic;
RateBasedAdaptationLogic::RateBasedAdaptationLogic (int w, int h) :
AbstractAdaptationLogic (),
bpsAvg(0), bpsSamplecount(0),
bpsAvg(0), bpsRemainder(0), bpsSamplecount(0),
currentBps(0)
{
width = w;
......@@ -68,12 +68,18 @@ void RateBasedAdaptationLogic::updateDownloadRate(size_t size, mtime_t time)
if(unlikely(time == 0))
return;
size_t current = size * 8000 / time;
size_t current = bpsRemainder + size * 8000 / time;
if (current >= bpsAvg)
bpsAvg = bpsAvg + (current - bpsAvg) / ++bpsSamplecount;
{
bpsAvg += (current - bpsAvg) / ++bpsSamplecount;
bpsRemainder = (current - bpsAvg) % bpsSamplecount;
}
else
bpsAvg = bpsAvg - (bpsAvg - current) / ++bpsSamplecount;
{
bpsAvg -= (bpsAvg - current) / ++bpsSamplecount;
bpsRemainder = (bpsAvg - current) % bpsSamplecount;
}
cumulatedTime += time;
if(cumulatedTime > 4 * CLOCK_FREQ / stabilizer)
......
......@@ -46,6 +46,7 @@ namespace adaptative
int width;
int height;
size_t bpsAvg;
size_t bpsRemainder;
size_t bpsSamplecount;
size_t currentBps;
mtime_t cumulatedTime;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment