diff options
author | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2007-08-15 13:42:38 +0100 |
---|---|---|
committer | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2007-08-15 13:42:38 +0100 |
commit | 7047d9e5acf97c91a523c99ccc4b008a35a3e094 (patch) | |
tree | 80a7a22b47640a7b97f4f027797abf2d704d07e5 /src/post/audio/stretch.c | |
parent | 27aeb069aa930c0c8fa0e0f41885bbedc69d0bcb (diff) | |
download | xine-lib-7047d9e5acf97c91a523c99ccc4b008a35a3e094.tar.gz xine-lib-7047d9e5acf97c91a523c99ccc4b008a35a3e094.tar.bz2 |
Fix an audio resampling problem which was causing regular clicking.
The cause was that the resampling code was using only the samples in the buffer
but not really handling the transition between two buffers (which it would
handle completely independently). The new code remembers the last sample from
the previous buffer and uses it in the resampling. We therefore end up one
sample behind and without the clicks.
Diffstat (limited to 'src/post/audio/stretch.c')
-rw-r--r-- | src/post/audio/stretch.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/post/audio/stretch.c b/src/post/audio/stretch.c index a1e921e03..054468517 100644 --- a/src/post/audio/stretch.c +++ b/src/post/audio/stretch.c @@ -225,6 +225,8 @@ struct post_plugin_stretch_s { int frames_per_frag; int frames_per_outfrag; int num_frames; /* current # of frames on audiofrag */ + + int16_t last_sample[RESAMPLE_MAX_CHANNELS]; int64_t pts; /* pts for audiofrag */ @@ -353,12 +355,16 @@ static void stretch_process_fragment( post_audio_port_t *port, if( !this->params.preserve_pitch ) { if( this->channels == 2 ) - _x_audio_out_resample_stereo(this->audiofrag, num_frames_in, + _x_audio_out_resample_stereo(this->last_sample, this->audiofrag, num_frames_in, this->outfrag, num_frames_out); else if( this->channels == 1 ) - _x_audio_out_resample_mono(this->audiofrag, num_frames_in, + _x_audio_out_resample_mono(this->last_sample, this->audiofrag, num_frames_in, this->outfrag, num_frames_out); } else { + if (this->channels == 2) + memcpy (this->last_sample, &this->audiofrag[(num_frames_in - 1) * 2], 2 * sizeof (this->last_sample[0])); + else if (this->channels == 1) + memcpy (this->last_sample, &this->audiofrag[num_frames_in - 1], sizeof (this->last_sample[0])); if( num_frames_in > num_frames_out ) { /* |