From e969d2c6042b92971f92910ebc6475078224a6e2 Mon Sep 17 00:00:00 2001 From: Christian Spielberger Date: Fri, 6 Oct 2023 12:07:32 +0200 Subject: [PATCH] jbuf: support also min size zero --- src/jbuf.c | 12 ++++++++++-- tools/jbuf/jbuf.plot | 28 +++++++++++++++++++--------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/jbuf.c b/src/jbuf.c index 04992e9e38..3ec569317b 100644 --- a/src/jbuf.c +++ b/src/jbuf.c @@ -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; } @@ -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; @@ -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; diff --git a/tools/jbuf/jbuf.plot b/tools/jbuf/jbuf.plot index 0d059523a4..e3fb04a38c 100755 --- a/tools/jbuf/jbuf.plot +++ b/tools/jbuf/jbuf.plot @@ -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"