Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jbuf: use float ratio #817

Merged
merged 1 commit into from
Jun 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/jbuf/jbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ static void calc_rdiff(struct jbuf *jb, uint16_t seq)
int32_t rdiff;
int32_t adiff;
int32_t s; /**< EMA coefficient */
uint32_t fpr = 1; /**< Frame packet ratio */
float ratio = 1.0; /**< Frame packet ratio */
uint32_t wish;
uint32_t max = jb->max;
bool down = false;
Expand All @@ -265,25 +265,22 @@ static void calc_rdiff(struct jbuf *jb, uint16_t seq)
return;

if (jb->nf) {
fpr = jb->n / jb->nf;
if (!fpr)
fpr = 1;
ratio = (float)jb->n / (float)jb->nf;
max = (uint32_t)(max / ratio);
}

max = max / fpr;

rdiff = (int16_t)(jb->seq_put + 1 - seq);
adiff = abs(rdiff * JBUF_RDIFF_EMA_COEFF);
s = adiff > jb->rdiff ? JBUF_RDIFF_UP_SPEED :
jb->wish > 2 ? 1 :
jb->wish > 1 ? 2 : 3;
jb->rdiff += (adiff - jb->rdiff) * s / JBUF_RDIFF_EMA_COEFF;

wish = (uint32_t) (jb->rdiff / JBUF_RDIFF_EMA_COEFF / fpr);
wish = (uint32_t)(jb->rdiff / (float)JBUF_RDIFF_EMA_COEFF / ratio);
if (wish < jb->min)
wish = jb->min;

if (wish >= max)
if (max && wish >= max)
wish = max - 1;

if (wish > jb->wish) {
Expand Down