summaryrefslogtreecommitdiffstats
path: root/audio/filter
diff options
context:
space:
mode:
authorferreum <code@ferreum.de>2023-08-19 10:14:02 +0200
committerNiklas Haas <github-daiK1o@haasn.dev>2023-09-20 14:36:23 +0200
commitde09ec9ea48ed40caefe2deebbd168f69a2b1d78 (patch)
treea16e7eb561a980f3e80fc1e8aa7308932043805c /audio/filter
parent87cc7ed9554cc18486fedd4645a4bd48fb863fd7 (diff)
downloadmpv-de09ec9ea48ed40caefe2deebbd168f69a2b1d78.tar.bz2
mpv-de09ec9ea48ed40caefe2deebbd168f69a2b1d78.tar.xz
af_scaletempo2: fix inconsistent search block position after init
`output_time` is used to set the center of the search block. Init of both `search_block_index` and `output_time` with 0 caused inconsistent search block movement for the first iterations. Initialize with `search_block_center_offset` for consistency with initial `search_block_index`.
Diffstat (limited to 'audio/filter')
-rw-r--r--audio/filter/af_scaletempo2_internals.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/audio/filter/af_scaletempo2_internals.c b/audio/filter/af_scaletempo2_internals.c
index e8cd59d3c9..a8fd91cebb 100644
--- a/audio/filter/af_scaletempo2_internals.c
+++ b/audio/filter/af_scaletempo2_internals.c
@@ -720,7 +720,7 @@ void mp_scaletempo2_destroy(struct mp_scaletempo2 *p)
void mp_scaletempo2_reset(struct mp_scaletempo2 *p)
{
p->input_buffer_frames = 0;
- p->output_time = 0.0;
+ p->output_time = p->search_block_center_offset;
p->search_block_index = 0;
p->target_block_index = 0;
// Clear the queue of decoded packets.
@@ -741,7 +741,6 @@ static void get_symmetric_hanning_window(int window_length, float* window)
void mp_scaletempo2_init(struct mp_scaletempo2 *p, int channels, int rate)
{
p->muted_partial_frame = 0;
- p->output_time = 0;
p->search_block_center_offset = 0;
p->search_block_index = 0;
p->num_complete_frames = 0;
@@ -783,6 +782,8 @@ void mp_scaletempo2_init(struct mp_scaletempo2 *p, int channels, int rate)
sizeof(float) * p->ola_window_size * 2);
get_symmetric_hanning_window(2 * p->ola_window_size, p->transition_window);
+ p->output_time = p->search_block_center_offset;
+
p->wsola_output_size = p->ola_window_size + p->ola_hop_size;
p->wsola_output = realloc_2d(p->wsola_output, p->channels, p->wsola_output_size);
// Initialize for overlap-and-add of the first block.