2005-08-23 19:29:38 +00:00
|
|
|
/* Resampling library
|
|
|
|
* Copyright (C) <2001> David Schleef <ds@schleef.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __RESAMPLE_H__
|
|
|
|
#define __RESAMPLE_H__
|
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
#include "functable.h"
|
|
|
|
#include "buffer.h"
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2006-04-09 17:14:22 +00:00
|
|
|
#ifndef M_PI
|
|
|
|
#define M_PI 3.14159265358979323846
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
#define rint(x) (floor((x)+0.5))
|
|
|
|
#endif
|
|
|
|
|
2005-08-23 19:29:38 +00:00
|
|
|
typedef enum {
|
2005-12-06 19:42:02 +00:00
|
|
|
RESAMPLE_FORMAT_S16 = 0,
|
|
|
|
RESAMPLE_FORMAT_S32,
|
|
|
|
RESAMPLE_FORMAT_F32,
|
2005-08-23 19:29:38 +00:00
|
|
|
RESAMPLE_FORMAT_F64
|
|
|
|
} ResampleFormat;
|
|
|
|
|
|
|
|
typedef void (*ResampleCallback) (void *);
|
|
|
|
|
|
|
|
typedef struct _ResampleState ResampleState;
|
|
|
|
|
|
|
|
struct _ResampleState {
|
2005-12-06 19:42:02 +00:00
|
|
|
/* parameters */
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-12-06 19:42:02 +00:00
|
|
|
int n_channels;
|
|
|
|
ResampleFormat format;
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-12-06 19:42:02 +00:00
|
|
|
int filter_length;
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-12-06 19:42:02 +00:00
|
|
|
double i_rate;
|
|
|
|
double o_rate;
|
2005-08-23 19:29:38 +00:00
|
|
|
|
|
|
|
int method;
|
|
|
|
|
2005-12-06 19:42:02 +00:00
|
|
|
/* internal parameters */
|
2005-08-23 19:29:38 +00:00
|
|
|
|
|
|
|
int need_reinit;
|
|
|
|
|
2005-12-06 19:42:02 +00:00
|
|
|
double halftaps;
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-12-06 19:42:02 +00:00
|
|
|
/* filter state */
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2006-01-03 17:33:16 +00:00
|
|
|
unsigned char *o_buf;
|
2005-08-23 19:29:38 +00:00
|
|
|
int o_size;
|
|
|
|
|
|
|
|
AudioresampleBufferQueue *queue;
|
|
|
|
int eos;
|
|
|
|
int started;
|
|
|
|
|
2005-12-06 19:42:02 +00:00
|
|
|
int sample_size;
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2006-01-03 17:27:13 +00:00
|
|
|
unsigned char *buffer;
|
2005-12-06 19:42:02 +00:00
|
|
|
int buffer_len;
|
|
|
|
int buffer_filled;
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-12-06 19:42:02 +00:00
|
|
|
double i_start;
|
|
|
|
double o_start;
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-12-06 19:42:02 +00:00
|
|
|
double i_inc;
|
|
|
|
double o_inc;
|
2005-08-23 19:29:38 +00:00
|
|
|
|
|
|
|
double sinc_scale;
|
|
|
|
|
2005-12-06 19:42:02 +00:00
|
|
|
double i_end;
|
|
|
|
double o_end;
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-12-06 19:42:02 +00:00
|
|
|
int i_samples;
|
|
|
|
int o_samples;
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-12-06 19:42:02 +00:00
|
|
|
//void *i_buf;
|
2005-08-23 19:29:38 +00:00
|
|
|
|
|
|
|
Functable *ft;
|
|
|
|
|
|
|
|
double *out_tmp;
|
|
|
|
};
|
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
void resample_init (void);
|
|
|
|
void resample_cleanup (void);
|
2005-08-23 19:29:38 +00:00
|
|
|
|
|
|
|
ResampleState *resample_new (void);
|
|
|
|
void resample_free (ResampleState *state);
|
|
|
|
|
|
|
|
void resample_add_input_data (ResampleState * r, void *data, int size,
|
|
|
|
ResampleCallback free_func, void *closure);
|
|
|
|
void resample_input_eos (ResampleState *r);
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
void resample_input_flush (ResampleState *r);
|
|
|
|
void resample_input_pushthrough (ResampleState *r);
|
2005-08-24 14:08:58 +00:00
|
|
|
|
|
|
|
int resample_get_output_size_for_input (ResampleState * r, int size);
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
int resample_get_input_size_for_output (ResampleState * r, int size);
|
|
|
|
|
2005-08-23 19:29:38 +00:00
|
|
|
int resample_get_output_size (ResampleState *r);
|
|
|
|
int resample_get_output_data (ResampleState *r, void *data, int size);
|
|
|
|
|
|
|
|
void resample_set_filter_length (ResampleState *r, int length);
|
|
|
|
void resample_set_input_rate (ResampleState *r, double rate);
|
|
|
|
void resample_set_output_rate (ResampleState *r, double rate);
|
|
|
|
void resample_set_n_channels (ResampleState *r, int n_channels);
|
|
|
|
void resample_set_format (ResampleState *r, ResampleFormat format);
|
|
|
|
void resample_set_method (ResampleState *r, int method);
|
|
|
|
int resample_format_size (ResampleFormat format);
|
|
|
|
|
|
|
|
#endif /* __RESAMPLE_H__ */
|
|
|
|
|