Skip to content

Commit

Permalink
jbuf: support also min size zero
Browse files Browse the repository at this point in the history
  • Loading branch information
cspiel1 committed Oct 6, 2023
1 parent 77821a6 commit e969d2c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
12 changes: 10 additions & 2 deletions src/jbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@ static bool jbuf_frame_ready(struct jbuf *jb)
if (!jb->end)
return false;

if (!jb->min && !jb->wish)
return true;

return jb->ncf > jb->wish;
}

Expand Down Expand Up @@ -595,7 +598,7 @@ int jbuf_get(struct jbuf *jb, struct rtp_header *hdr, void **mem)
jb->nf, jb->ncf, jb->min, jb->nfa, jb->wish);
STAT_INC(n_underrun);
jb->wish = jb->nf > 2 ? jb->nf : 2;
int32_t nfa = (int32_t) (jb->nf + 1) * JBUF_EMA_FAC;
int32_t nfa = (int32_t) (jb->nf + 2) * JBUF_EMA_FAC;
if (nfa > jb->nfa)
jb->nfa = nfa;

Expand Down Expand Up @@ -633,7 +636,12 @@ int jbuf_get(struct jbuf *jb, struct rtp_header *hdr, void **mem)
packet_deref(jb, p);
jb->newframe = false;

int32_t nfa = ((int32_t) jb->nf - jb->ncf + jb->min) * JBUF_EMA_FAC;
int32_t nfa;
if (jb->min)
nfa = ((int32_t) jb->nf - jb->ncf) * (JBUF_EMA_FAC*3/2);
else
nfa = ((int32_t) jb->nf - jb->ncf - 1) * (JBUF_EMA_FAC*5);

int32_t s = nfa > jb->nfa ? JBUF_UP_SPEED : 1;

jb->nfa += (nfa - jb->nfa) * s / JBUF_EMA_COEFF;
Expand Down
28 changes: 19 additions & 9 deletions tools/jbuf/jbuf.plot
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,28 @@ set xlabel "time/[ms]"
set ylabel "#packets"

stats "jbuf.dat" using ($4) name "N"
event_h(i) = (0.5*N_max) + 0.3*N_max*(i/6.0)
stats "jbuf.dat" using ($5) name "Nf"
stats "jbuf.dat" using ($7) name "Nfa"
event_h(i) = (0.15*Nf_max) + 0.1*Nf_max*i

ymin = Nf_max
ymax = N_max
if (Nfa_max > ymax) { ymax = Nfa_max }

yr = ymax
if (2*ymin < yr) { yr = 2*ymin }
set yrange [0:yr]

plot \
'jbuf.dat' using 3:4 title 'n' with linespoints lc "skyblue", \
'jbuf.dat' using 3:5 title 'nf' with linespoints lc "blue", \
'jbuf.dat' using 3:6 title 'ncf' with linespoints lc "green", \
'jbuf.dat' using 3:7 title 'nfa' with linespoints lc "pink", \
'overrun.dat' using 3:(event_h(1)) title 'overrun' pt 7 ps 1.5 lc "#FF0000", \
'underrun.dat' using 3:(event_h(2)) title 'underrun' pt 7 ps 1.5 lc "#A52222", \
'toolate.dat' using 3:(event_h(3)) title 'toolate' pt 7 ps 1.5 lc "#BB5454", \
'duplicate.dat' using 3:(event_h(4)) title 'duplicate' pt 7 ps 1.5 lc "#E919C6", \
'oosequence.dat' using 3:(event_h(5)) title 'out of seq' pt 7 ps 1.5 lc "#BB7777", \
'lost.dat' using 3:(event_h(6)) title 'lost' pt 7 ps 1.5 lc "#C08DBC", \
'x.dat' using 3:(event_h(.5)) title 'x' pt 7 ps 1.5 lc "#407740", \
'y.dat' using 3:(event_h(.7)) title 'y' pt 7 ps 1.5 lc "#404077"
'overrun.dat' using 3:(event_h(0)) title 'overrun' pt 7 ps 1.5 lc "#FF0000", \
'underrun.dat' using 3:(event_h(1)) title 'underrun' pt 7 ps 1.5 lc "#A52222", \
'toolate.dat' using 3:(event_h(2)) title 'toolate' pt 7 ps 1.5 lc "#BB5454", \
'duplicate.dat' using 3:(event_h(3)) title 'duplicate' pt 7 ps 1.5 lc "#E919C6", \
'oosequence.dat' using 3:(event_h(4)) title 'out of seq' pt 7 ps 1.5 lc "#BB7777", \
'lost.dat' using 3:(event_h(5)) title 'lost' pt 7 ps 1.5 lc "#C08DBC", \
'x.dat' using 3:(event_h(6)) title 'x' pt 7 ps 1.5 lc "#407740", \
'y.dat' using 3:(event_h(7)) title 'y' pt 7 ps 1.5 lc "#404077"

0 comments on commit e969d2c

Please sign in to comment.