avfilter/af_atempo: fix drift calculation, ticket #6157
authorPavel Koshevoy <pkoshevoy@gmail.com>
Mon, 20 Feb 2017 02:51:28 +0000 (10:51 +0800)
committerSteven Liu <lq@chinaffmpeg.org>
Mon, 20 Feb 2017 02:51:28 +0000 (10:51 +0800)
ticket #6157

Reported-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Pavel Koshevoy <pkoshevoy@gmail.com>
libavfilter/af_atempo.c

index a487882..eb62656 100644 (file)
@@ -697,11 +697,11 @@ static int yae_adjust_position(ATempoContext *atempo)
     AudioFragment       *frag = yae_curr_frag(atempo);
 
     const double prev_output_position =
-        (double)(prev->position[1] - atempo->origin[1] + atempo->window / 2);
+        (double)(prev->position[1] - atempo->origin[1] + atempo->window / 2) *
+        atempo->tempo;
 
     const double ideal_output_position =
-        (double)(prev->position[0] - atempo->origin[0] + atempo->window / 2) /
-        atempo->tempo;
+        (double)(prev->position[0] - atempo->origin[0] + atempo->window / 2);
 
     const int drift = (int)(prev_output_position - ideal_output_position);