changeset 37108:a88581872033

scaletempo: add hack for smoother speed changes.
author reimar
date Sun, 18 May 2014 16:43:34 +0000
parents 3c5c93a30fb7
children a625ce680fc3
files libaf/af_scaletempo.c
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libaf/af_scaletempo.c	Sat May 17 01:38:00 2014 +0000
+++ b/libaf/af_scaletempo.c	Sun May 18 16:43:34 2014 +0000
@@ -333,6 +333,7 @@
       s->samples_standing = s->bytes_standing / bps;
       s->output_overlap   = NULL;
     } else {
+      int old_overlap = s->bytes_overlap;
       s->samples_overlap  = frames_overlap * nch;
       s->bytes_overlap    = frames_overlap * nch * bps;
       s->bytes_standing   = s->bytes_stride - s->bytes_overlap;
@@ -343,7 +344,10 @@
         mp_msg(MSGT_AFILTER, MSGL_FATAL, "[scaletempo] Out of memory\n");
         return AF_ERROR;
       }
-      memset(s->buf_overlap, 0, s->bytes_overlap);
+      // not necessarily correct, but keeping old data if possible
+      // avoids clicks when changing speed.
+      if (s->bytes_overlap != old_overlap)
+        memset(s->buf_overlap, 0, s->bytes_overlap);
       if (use_int) {
         int32_t* pb = s->table_blend;
         int64_t blend = 0;