1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-19 18:05:21 +00:00

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`.
This commit is contained in:
ferreum 2023-08-19 10:14:02 +02:00 committed by Niklas Haas
parent 87cc7ed955
commit de09ec9ea4

View File

@ -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.