From 3a85fd97e5fb3a1e026f1572f30d526cc14c219e Mon Sep 17 00:00:00 2001 From: Christoph Heinrich Date: Fri, 29 Sep 2023 20:10:07 +0200 Subject: [PATCH] af_scaletempo: add comment to overlap calculation Also reduce pointer dereferences by one. That won't make much of a difference (if at all), but since it already needs two lines we might as well. --- audio/filter/af_scaletempo.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/audio/filter/af_scaletempo.c b/audio/filter/af_scaletempo.c index e7b101b260..74e45bf542 100644 --- a/audio/filter/af_scaletempo.c +++ b/audio/filter/af_scaletempo.c @@ -211,8 +211,9 @@ static void output_overlap_float(struct priv *s, void *buf_out, float *po = s->buf_overlap; float *pin = (float *)(s->buf_queue + bytes_off); for (int i = 0; i < s->samples_overlap; i++) { - *pout++ = *po - *pb++ *(*po - *pin++); - po++; + // the math is equal to *po * (1 - *pb) + *pin * *pb + float o = *po++; + *pout++ = o - *pb++ * (o - *pin++); } } @@ -224,8 +225,9 @@ static void output_overlap_s16(struct priv *s, void *buf_out, int16_t *po = s->buf_overlap; int16_t *pin = (int16_t *)(s->buf_queue + bytes_off); for (int i = 0; i < s->samples_overlap; i++) { - *pout++ = *po - ((*pb++ *(*po - *pin++)) >> 16); - po++; + // the math is equal to *po * (1 - *pb) + *pin * *pb + int32_t o = *po++; + *pout++ = o - ((*pb++ *(o - *pin++)) >> 16); } }