diff options
Diffstat (limited to 'src/post/audio/stretch.c')
-rw-r--r-- | src/post/audio/stretch.c | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/src/post/audio/stretch.c b/src/post/audio/stretch.c index a1e921e03..bc079fd8d 100644 --- a/src/post/audio/stretch.c +++ b/src/post/audio/stretch.c @@ -15,21 +15,18 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * * Time stretch by a given factor, optionally preserving pitch - * - * $Id: stretch.c,v 1.8 2006/01/27 07:46:12 tmattern Exp $ - * */ #include <stdio.h> -#include "xine_internal.h" -#include "xineutils.h" -#include "post.h" +#include <xine/xine_internal.h> +#include <xine/xineutils.h> +#include <xine/post.h> #include "dsp.h" -#include "resample.h" +#include <xine/resample.h> #include "audio_filters.h" @@ -225,6 +222,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 */ @@ -305,7 +304,7 @@ static int stretch_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream, /* force updating on stretch_port_put_buffer */ this->params_changed = 1; - return port->original_port->open(port->original_port, stream, bits, rate, mode); + return (port->original_port->open) (port->original_port, stream, bits, rate, mode); } static void stretch_port_close(xine_audio_port_t *port_gen, xine_stream_t *stream ) { @@ -353,12 +352,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 ) { /* @@ -656,21 +659,6 @@ static post_plugin_t *stretch_open_plugin(post_class_t *class_gen, int inputs, return &this->post; } -static char *stretch_get_identifier(post_class_t *class_gen) -{ - return "stretch"; -} - -static char *stretch_get_description(post_class_t *class_gen) -{ - return "Time stretch by a given factor, optionally preserving pitch"; -} - -static void stretch_class_dispose(post_class_t *class_gen) -{ - free(class_gen); -} - /* plugin class initialization function */ void *stretch_init_plugin(xine_t *xine, void *data) { @@ -680,9 +668,9 @@ void *stretch_init_plugin(xine_t *xine, void *data) return NULL; class->post_class.open_plugin = stretch_open_plugin; - class->post_class.get_identifier = stretch_get_identifier; - class->post_class.get_description = stretch_get_description; - class->post_class.dispose = stretch_class_dispose; + class->post_class.identifier = "stretch"; + class->post_class.description = N_("Time stretch by a given factor, optionally preserving pitch"); + class->post_class.dispose = default_post_class_dispose; class->xine = xine; |