summaryrefslogtreecommitdiffstats
path: root/audio/filter
diff options
context:
space:
mode:
authorferreum <code@ferreum.de>2023-08-15 19:45:12 +0200
committerNiklas Haas <github-daiK1o@haasn.dev>2023-09-20 14:36:23 +0200
commitc0728249a18f5e7ec40332e002f4cd9fedc8e91c (patch)
treeb532f85b04f064b7fc3c8fe9123e84ac9f51c91d /audio/filter
parentf52cf90fedc3daf94fbf2118c6a5dd474c8e6c74 (diff)
downloadmpv-c0728249a18f5e7ec40332e002f4cd9fedc8e91c.tar.bz2
mpv-c0728249a18f5e7ec40332e002f4cd9fedc8e91c.tar.xz
af_scaletempo2: restore exact audio sync on return to 1x speed
Target block can be anywhere in the previous search-block, varying by `search-interval` while the filter is active. This resulted in constant audio offset when returning to 1x playback speed. - Move the search block to the target block to sync up exactly. - Drop old frames to minimize input_buffer usage.
Diffstat (limited to 'audio/filter')
-rw-r--r--audio/filter/af_scaletempo2_internals.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/audio/filter/af_scaletempo2_internals.c b/audio/filter/af_scaletempo2_internals.c
index 5597d531b0..eb2d4bb20b 100644
--- a/audio/filter/af_scaletempo2_internals.c
+++ b/audio/filter/af_scaletempo2_internals.c
@@ -702,7 +702,15 @@ int mp_scaletempo2_fill_buffer(struct mp_scaletempo2 *p,
// Optimize the most common |playback_rate| ~= 1 case to use a single copy
// instead of copying frame by frame.
if (p->ola_window_size <= faster_step && slower_step >= p->ola_window_size) {
- p->wsola_output_started = false;
+
+ if (p->wsola_output_started) {
+ p->wsola_output_started = false;
+
+ // sync audio precisely again
+ set_output_time(p, p->target_block_index + p->search_block_center_offset);
+ remove_old_input_frames(p);
+ }
+
return read_input_buffer(p, dest_size, dest);
}