summaryrefslogtreecommitdiffstats
path: root/audio/filter/af_scaletempo2_internals.h
diff options
context:
space:
mode:
authorferreum <code@ferreum.de>2023-08-13 13:10:58 +0200
committerNiklas Haas <github-daiK1o@haasn.dev>2023-09-20 14:36:23 +0200
commit8080d00d7f31a0e1ba25418e0f08474f1a2f1f61 (patch)
tree3c0841b6ae303a9d94feba57df321682e17ca9fd /audio/filter/af_scaletempo2_internals.h
parentcf8b7ff0d666a4c13b32d8d9e973435df419b5ef (diff)
downloadmpv-8080d00d7f31a0e1ba25418e0f08474f1a2f1f61.tar.bz2
mpv-8080d00d7f31a0e1ba25418e0f08474f1a2f1f61.tar.xz
af_scaletempo2: fix processing of final packet
After the final input packet, the filter padded with silence to allow one more iteration. That was not enough to process the final frames. Continue padding the end of `input_buffer` with silence until the final frames have been processed. Implementation: Instead of padding when adding final samples, pad before running WSOLA iteration. Count number of added silent frames and remaining input frames for time keeping.
Diffstat (limited to 'audio/filter/af_scaletempo2_internals.h')
-rw-r--r--audio/filter/af_scaletempo2_internals.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/audio/filter/af_scaletempo2_internals.h b/audio/filter/af_scaletempo2_internals.h
index 622d6e20da..6c3c94c0a9 100644
--- a/audio/filter/af_scaletempo2_internals.h
+++ b/audio/filter/af_scaletempo2_internals.h
@@ -112,6 +112,13 @@ struct mp_scaletempo2 {
float **input_buffer;
int input_buffer_size;
int input_buffer_frames;
+ // How many frames in |input_buffer| need to be flushed by padding with
+ // silence to process the final packet. While this is nonzero, the filter
+ // appends silence to |input_buffer| until these frames are processed.
+ int input_buffer_final_frames;
+ // How many additional frames of silence have been added to |input_buffer|
+ // for padding after the final packet.
+ int input_buffer_added_silence;
float *energy_candidate_blocks;
};
@@ -120,7 +127,8 @@ void mp_scaletempo2_reset(struct mp_scaletempo2 *p);
void mp_scaletempo2_init(struct mp_scaletempo2 *p, int channels, int rate);
double mp_scaletempo2_get_latency(struct mp_scaletempo2 *p, double playback_rate);
int mp_scaletempo2_fill_input_buffer(struct mp_scaletempo2 *p,
- uint8_t **planes, int frame_size, bool final, double playback_rate);
+ uint8_t **planes, int frame_size, double playback_rate);
+void mp_scaletempo2_set_final(struct mp_scaletempo2 *p);
int mp_scaletempo2_fill_buffer(struct mp_scaletempo2 *p,
float **dest, int dest_size, double playback_rate);
bool mp_scaletempo2_frames_available(struct mp_scaletempo2 *p, double playback_rate);