mirror of https://github.com/mpv-player/mpv
audio: untypedef af_data and rename it to mp_audio
this is to have something specular to mp_image
This commit is contained in:
parent
e0aef8cf12
commit
0374ddb79d
24
libaf/af.c
24
libaf/af.c
|
@ -240,7 +240,7 @@ void af_remove(af_stream_t* s, af_instance_t* af)
|
|||
free(af);
|
||||
}
|
||||
|
||||
static void print_fmt(af_data_t *d)
|
||||
static void print_fmt(struct mp_audio *d)
|
||||
{
|
||||
if (d) {
|
||||
mp_msg(MSGT_AFILTER, MSGL_V, "%dHz/%dch/%s", d->rate, d->nch,
|
||||
|
@ -280,7 +280,7 @@ static void af_print_filter_chain(af_stream_t* s)
|
|||
int af_reinit(af_stream_t* s, af_instance_t* af)
|
||||
{
|
||||
do{
|
||||
af_data_t in; // Format of the input to current filter
|
||||
struct mp_audio in; // Format of the input to current filter
|
||||
int rv=0; // Return value
|
||||
|
||||
// Check if there are any filters left in the list
|
||||
|
@ -293,9 +293,9 @@ int af_reinit(af_stream_t* s, af_instance_t* af)
|
|||
|
||||
// Check if this is the first filter
|
||||
if(!af->prev)
|
||||
memcpy(&in,&(s->input),sizeof(af_data_t));
|
||||
memcpy(&in,&(s->input),sizeof(struct mp_audio));
|
||||
else
|
||||
memcpy(&in,af->prev->data,sizeof(af_data_t));
|
||||
memcpy(&in,af->prev->data,sizeof(struct mp_audio));
|
||||
// Reset just in case...
|
||||
in.audio=NULL;
|
||||
in.len=0;
|
||||
|
@ -319,9 +319,9 @@ int af_reinit(af_stream_t* s, af_instance_t* af)
|
|||
return rv;
|
||||
// Initialize channels filter
|
||||
if(!new->prev)
|
||||
memcpy(&in,&(s->input),sizeof(af_data_t));
|
||||
memcpy(&in,&(s->input),sizeof(struct mp_audio));
|
||||
else
|
||||
memcpy(&in,new->prev->data,sizeof(af_data_t));
|
||||
memcpy(&in,new->prev->data,sizeof(struct mp_audio));
|
||||
if(AF_OK != (rv = new->control(new,AF_CONTROL_REINIT,&in)))
|
||||
return rv;
|
||||
}
|
||||
|
@ -336,9 +336,9 @@ int af_reinit(af_stream_t* s, af_instance_t* af)
|
|||
return rv;
|
||||
// Initialize format filter
|
||||
if(!new->prev)
|
||||
memcpy(&in,&(s->input),sizeof(af_data_t));
|
||||
memcpy(&in,&(s->input),sizeof(struct mp_audio));
|
||||
else
|
||||
memcpy(&in,new->prev->data,sizeof(af_data_t));
|
||||
memcpy(&in,new->prev->data,sizeof(struct mp_audio));
|
||||
if(AF_OK != (rv = new->control(new,AF_CONTROL_REINIT,&in)))
|
||||
return rv;
|
||||
}
|
||||
|
@ -595,7 +595,7 @@ af_instance_t* af_add(af_stream_t* s, char* name){
|
|||
}
|
||||
|
||||
// Filter data chunk through the filters in the list
|
||||
af_data_t* af_play(af_stream_t* s, af_data_t* data)
|
||||
struct mp_audio* af_play(af_stream_t* s, struct mp_audio* data)
|
||||
{
|
||||
af_instance_t* af=s->first;
|
||||
// Iterate through all filters
|
||||
|
@ -611,7 +611,7 @@ af_data_t* af_play(af_stream_t* s, af_data_t* data)
|
|||
* when using the RESIZE_LOCAL_BUFFER macro. The +t+1 part ensures the
|
||||
* value is >= len*mul rounded upwards to whole samples even if the
|
||||
* double 'mul' is inexact. */
|
||||
int af_lencalc(double mul, af_data_t* d)
|
||||
int af_lencalc(double mul, struct mp_audio* d)
|
||||
{
|
||||
int t = d->bps * d->nch;
|
||||
return d->len * mul + t + 1;
|
||||
|
@ -647,7 +647,7 @@ double af_calc_delay(af_stream_t* s)
|
|||
|
||||
/* Helper function called by the macro with the same name this
|
||||
function should not be called directly */
|
||||
int af_resize_local_buffer(af_instance_t* af, af_data_t* data)
|
||||
int af_resize_local_buffer(af_instance_t* af, struct mp_audio* data)
|
||||
{
|
||||
// Calculate new length
|
||||
register int len = af_lencalc(af->mul,data);
|
||||
|
@ -690,7 +690,7 @@ void af_help (void) {
|
|||
}
|
||||
}
|
||||
|
||||
void af_fix_parameters(af_data_t *data)
|
||||
void af_fix_parameters(struct mp_audio *data)
|
||||
{
|
||||
if (data->nch < 0 || data->nch > AF_NCH) {
|
||||
mp_msg(MSGT_AFILTER, MSGL_ERR, "Invalid number of channels %i, assuming 2.\n", data->nch);
|
||||
|
|
25
libaf/af.h
25
libaf/af.h
|
@ -37,15 +37,14 @@ struct af_instance_s;
|
|||
#endif
|
||||
|
||||
// Audio data chunk
|
||||
typedef struct af_data_s
|
||||
{
|
||||
struct mp_audio {
|
||||
void* audio; // data buffer
|
||||
int len; // buffer length
|
||||
int rate; // sample rate
|
||||
int nch; // number of channels
|
||||
int format; // format
|
||||
int bps; // bytes per sample
|
||||
} af_data_t;
|
||||
};
|
||||
|
||||
|
||||
// Flags used for defining the behavior of an audio filter
|
||||
|
@ -70,9 +69,9 @@ typedef struct af_instance_s
|
|||
af_info_t* info;
|
||||
int (*control)(struct af_instance_s* af, int cmd, void* arg);
|
||||
void (*uninit)(struct af_instance_s* af);
|
||||
af_data_t* (*play)(struct af_instance_s* af, af_data_t* data);
|
||||
struct mp_audio* (*play)(struct af_instance_s* af, struct mp_audio* data);
|
||||
void* setup; // setup data for this specific instance and filter
|
||||
af_data_t* data; // configuration for outgoing data stream
|
||||
struct mp_audio* data; // configuration for outgoing data stream
|
||||
struct af_instance_s* next;
|
||||
struct af_instance_s* prev;
|
||||
double delay; /* Delay caused by the filter, in units of bytes read without
|
||||
|
@ -113,8 +112,8 @@ typedef struct af_stream
|
|||
af_instance_t* first;
|
||||
af_instance_t* last;
|
||||
// Storage for input and output data formats
|
||||
af_data_t input;
|
||||
af_data_t output;
|
||||
struct mp_audio input;
|
||||
struct mp_audio output;
|
||||
// Configuration for this stream
|
||||
af_cfg_t cfg;
|
||||
struct MPOpts *opts;
|
||||
|
@ -203,7 +202,7 @@ af_instance_t* af_get(af_stream_t* s, char* name);
|
|||
* \return resulting data
|
||||
* \ingroup af_chain
|
||||
*/
|
||||
af_data_t* af_play(af_stream_t* s, af_data_t* data);
|
||||
struct mp_audio* af_play(af_stream_t* s, struct mp_audio* data);
|
||||
|
||||
/**
|
||||
* \brief send control to all filters, starting with the last until
|
||||
|
@ -237,12 +236,12 @@ double af_calc_delay(af_stream_t* s);
|
|||
|
||||
/* Helper function called by the macro with the same name only to be
|
||||
called from inside filters */
|
||||
int af_resize_local_buffer(af_instance_t* af, af_data_t* data);
|
||||
int af_resize_local_buffer(af_instance_t* af, struct mp_audio* data);
|
||||
|
||||
/* Helper function used to calculate the exact buffer length needed
|
||||
when buffers are resized. The returned length is >= than what is
|
||||
needed */
|
||||
int af_lencalc(double mul, af_data_t* data);
|
||||
int af_lencalc(double mul, struct mp_audio* data);
|
||||
|
||||
/**
|
||||
* \brief convert dB to gain value
|
||||
|
@ -297,7 +296,7 @@ int af_to_ms(int n, int* in, float* out, int rate);
|
|||
*
|
||||
* compares the format, bps, rate and nch values of af->data with out
|
||||
*/
|
||||
int af_test_output(struct af_instance_s* af, af_data_t* out);
|
||||
int af_test_output(struct af_instance_s* af, struct mp_audio* out);
|
||||
|
||||
/**
|
||||
* \brief soft clipping function using sin()
|
||||
|
@ -312,13 +311,13 @@ float af_softclip(float a);
|
|||
void af_help(void);
|
||||
|
||||
/**
|
||||
* \brief fill the missing parameters in the af_data_t structure
|
||||
* \brief fill the missing parameters in the struct mp_audio structure
|
||||
* \param data structure to fill
|
||||
* \ingroup af_filter
|
||||
*
|
||||
* Currently only sets bps based on format
|
||||
*/
|
||||
void af_fix_parameters(af_data_t *data);
|
||||
void af_fix_parameters(struct mp_audio *data);
|
||||
|
||||
/** Memory reallocation macro: if a local buffer is used (i.e. if the
|
||||
filter doesn't operate on the incoming buffer this macro must be
|
||||
|
|
|
@ -38,7 +38,7 @@ struct af_bs2b {
|
|||
};
|
||||
|
||||
#define PLAY(name, type) \
|
||||
static af_data_t *play_##name(struct af_instance_s *af, af_data_t *data) \
|
||||
static struct mp_audio *play_##name(struct af_instance_s *af, struct mp_audio *data) \
|
||||
{ \
|
||||
/* filter is called for all pairs of samples available in the buffer */ \
|
||||
bs2b_cross_feed_##name(((struct af_bs2b*)(af->setup))->filter, \
|
||||
|
@ -103,10 +103,10 @@ static int control(struct af_instance_s *af, int cmd, void *arg)
|
|||
// Sanity check
|
||||
if (!arg) return AF_ERROR;
|
||||
|
||||
format = ((af_data_t*)arg)->format;
|
||||
af->data->rate = ((af_data_t*)arg)->rate;
|
||||
format = ((struct mp_audio*)arg)->format;
|
||||
af->data->rate = ((struct mp_audio*)arg)->rate;
|
||||
af->data->nch = 2; // bs2b is useful only for 2ch audio
|
||||
af->data->bps = ((af_data_t*)arg)->bps;
|
||||
af->data->bps = ((struct mp_audio*)arg)->bps;
|
||||
af->data->format = format;
|
||||
|
||||
/* check for formats supported by libbs2b
|
||||
|
@ -179,7 +179,7 @@ static int control(struct af_instance_s *af, int cmd, void *arg)
|
|||
mp_msg(MSGT_AFILTER, MSGL_V, "[bs2b] using format %s\n",
|
||||
af_fmt2str(af->data->format,buf,256));
|
||||
|
||||
return af_test_output(af,(af_data_t*)arg);
|
||||
return af_test_output(af,(struct mp_audio*)arg);
|
||||
}
|
||||
case AF_CONTROL_COMMAND_LINE: {
|
||||
const opt_t subopts[] = {
|
||||
|
@ -243,7 +243,7 @@ static int af_open(af_instance_t *af)
|
|||
af->control = control;
|
||||
af->uninit = uninit;
|
||||
af->mul = 1;
|
||||
if (!(af->data = calloc(1, sizeof(af_data_t))))
|
||||
if (!(af->data = calloc(1, sizeof(struct mp_audio))))
|
||||
return AF_ERROR;
|
||||
if (!(af->setup = s = calloc(1, sizeof(struct af_bs2b)))) {
|
||||
free(af->data);
|
||||
|
|
|
@ -47,12 +47,12 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
// Sanity check
|
||||
if(!arg) return AF_ERROR;
|
||||
|
||||
af->data->rate = ((af_data_t*)arg)->rate;
|
||||
af->data->nch = max(s->ch+1,((af_data_t*)arg)->nch);
|
||||
af->data->rate = ((struct mp_audio*)arg)->rate;
|
||||
af->data->nch = max(s->ch+1,((struct mp_audio*)arg)->nch);
|
||||
af->data->format = AF_FORMAT_FLOAT_NE;
|
||||
af->data->bps = 4;
|
||||
|
||||
return af_test_output(af,(af_data_t*)arg);
|
||||
return af_test_output(af,(struct mp_audio*)arg);
|
||||
}
|
||||
case AF_CONTROL_COMMAND_LINE:{
|
||||
int ch=1;
|
||||
|
@ -83,9 +83,9 @@ static void uninit(struct af_instance_s* af)
|
|||
}
|
||||
|
||||
// Filter data through filter
|
||||
static af_data_t* play(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
af_data_t* c = data; // Current working data
|
||||
struct mp_audio* c = data; // Current working data
|
||||
af_center_t* s = af->setup; // Setup for this instance
|
||||
float* a = c->audio; // Audio data
|
||||
int len = c->len/4; // Number of samples in current audio block
|
||||
|
@ -109,7 +109,7 @@ static int af_open(af_instance_t* af){
|
|||
af->uninit=uninit;
|
||||
af->play=play;
|
||||
af->mul=1;
|
||||
af->data=calloc(1,sizeof(af_data_t));
|
||||
af->data=calloc(1,sizeof(struct mp_audio));
|
||||
af->setup=s=calloc(1,sizeof(af_center_t));
|
||||
if(af->data == NULL || af->setup == NULL)
|
||||
return AF_ERROR;
|
||||
|
|
|
@ -143,11 +143,11 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
if(!s->router){
|
||||
int i;
|
||||
// Make sure this filter isn't redundant
|
||||
if(af->data->nch == ((af_data_t*)arg)->nch)
|
||||
if(af->data->nch == ((struct mp_audio*)arg)->nch)
|
||||
return AF_DETACH;
|
||||
|
||||
// If mono: fake stereo
|
||||
if(((af_data_t*)arg)->nch == 1){
|
||||
if(((struct mp_audio*)arg)->nch == 1){
|
||||
s->nr = min(af->data->nch,2);
|
||||
for(i=0;i<s->nr;i++){
|
||||
s->route[i][FR] = 0;
|
||||
|
@ -155,7 +155,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
}
|
||||
}
|
||||
else{
|
||||
s->nr = min(af->data->nch, ((af_data_t*)arg)->nch);
|
||||
s->nr = min(af->data->nch, ((struct mp_audio*)arg)->nch);
|
||||
for(i=0;i<s->nr;i++){
|
||||
s->route[i][FR] = i;
|
||||
s->route[i][TO] = i;
|
||||
|
@ -163,11 +163,11 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
}
|
||||
}
|
||||
|
||||
af->data->rate = ((af_data_t*)arg)->rate;
|
||||
af->data->format = ((af_data_t*)arg)->format;
|
||||
af->data->bps = ((af_data_t*)arg)->bps;
|
||||
af->mul = (double)af->data->nch / ((af_data_t*)arg)->nch;
|
||||
return check_routes(s,((af_data_t*)arg)->nch,af->data->nch);
|
||||
af->data->rate = ((struct mp_audio*)arg)->rate;
|
||||
af->data->format = ((struct mp_audio*)arg)->format;
|
||||
af->data->bps = ((struct mp_audio*)arg)->bps;
|
||||
af->mul = (double)af->data->nch / ((struct mp_audio*)arg)->nch;
|
||||
return check_routes(s,((struct mp_audio*)arg)->nch,af->data->nch);
|
||||
case AF_CONTROL_COMMAND_LINE:{
|
||||
int nch = 0;
|
||||
int n = 0;
|
||||
|
@ -256,10 +256,10 @@ static void uninit(struct af_instance_s* af)
|
|||
}
|
||||
|
||||
// Filter data through filter
|
||||
static af_data_t* play(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
af_data_t* c = data; // Current working data
|
||||
af_data_t* l = af->data; // Local data
|
||||
struct mp_audio* c = data; // Current working data
|
||||
struct mp_audio* l = af->data; // Local data
|
||||
af_channels_t* s = af->setup;
|
||||
int i;
|
||||
|
||||
|
@ -288,7 +288,7 @@ static int af_open(af_instance_t* af){
|
|||
af->uninit=uninit;
|
||||
af->play=play;
|
||||
af->mul=1;
|
||||
af->data=calloc(1,sizeof(af_data_t));
|
||||
af->data=calloc(1,sizeof(struct mp_audio));
|
||||
af->setup=calloc(1,sizeof(af_channels_t));
|
||||
if((af->data == NULL) || (af->setup == NULL))
|
||||
return AF_ERROR;
|
||||
|
|
|
@ -52,10 +52,10 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
for(i=0;i<af->data->nch;i++)
|
||||
free(s->q[i]);
|
||||
|
||||
af->data->rate = ((af_data_t*)arg)->rate;
|
||||
af->data->nch = ((af_data_t*)arg)->nch;
|
||||
af->data->format = ((af_data_t*)arg)->format;
|
||||
af->data->bps = ((af_data_t*)arg)->bps;
|
||||
af->data->rate = ((struct mp_audio*)arg)->rate;
|
||||
af->data->nch = ((struct mp_audio*)arg)->nch;
|
||||
af->data->format = ((struct mp_audio*)arg)->format;
|
||||
af->data->bps = ((struct mp_audio*)arg)->bps;
|
||||
|
||||
// Allocate new delay queues
|
||||
for(i=0;i<af->data->nch;i++){
|
||||
|
@ -118,9 +118,9 @@ static void uninit(struct af_instance_s* af)
|
|||
}
|
||||
|
||||
// Filter data through filter
|
||||
static af_data_t* play(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
af_data_t* c = data; // Current working data
|
||||
struct mp_audio* c = data; // Current working data
|
||||
af_delay_t* s = af->setup; // Setup for this instance
|
||||
int nch = c->nch; // Number of channels
|
||||
int len = c->len/c->bps; // Number of sample in data chunk
|
||||
|
@ -182,7 +182,7 @@ static int af_open(af_instance_t* af){
|
|||
af->uninit=uninit;
|
||||
af->play=play;
|
||||
af->mul=1;
|
||||
af->data=calloc(1,sizeof(af_data_t));
|
||||
af->data=calloc(1,sizeof(struct mp_audio));
|
||||
af->setup=calloc(1,sizeof(af_delay_t));
|
||||
if(af->data == NULL || af->setup == NULL)
|
||||
return AF_ERROR;
|
||||
|
|
|
@ -30,7 +30,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
{
|
||||
switch(cmd){
|
||||
case AF_CONTROL_REINIT:
|
||||
memcpy(af->data,(af_data_t*)arg,sizeof(af_data_t));
|
||||
memcpy(af->data,(struct mp_audio*)arg,sizeof(struct mp_audio));
|
||||
mp_msg(MSGT_AFILTER, MSGL_V, "[dummy] Was reinitialized: %iHz/%ich/%s\n",
|
||||
af->data->rate,af->data->nch,af_fmt2str_short(af->data->format));
|
||||
return AF_OK;
|
||||
|
@ -45,7 +45,7 @@ static void uninit(struct af_instance_s* af)
|
|||
}
|
||||
|
||||
// Filter data through filter
|
||||
static af_data_t* play(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
// Do something necessary to get rid of annoying warning during compile
|
||||
if(!af)
|
||||
|
@ -59,7 +59,7 @@ static int af_open(af_instance_t* af){
|
|||
af->uninit=uninit;
|
||||
af->play=play;
|
||||
af->mul=1;
|
||||
af->data=malloc(sizeof(af_data_t));
|
||||
af->data=malloc(sizeof(struct mp_audio));
|
||||
if(af->data == NULL)
|
||||
return AF_ERROR;
|
||||
return AF_OK;
|
||||
|
|
|
@ -96,8 +96,8 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
// Sanity check
|
||||
if(!arg) return AF_ERROR;
|
||||
|
||||
af->data->rate = ((af_data_t*)arg)->rate;
|
||||
af->data->nch = ((af_data_t*)arg)->nch;
|
||||
af->data->rate = ((struct mp_audio*)arg)->rate;
|
||||
af->data->nch = ((struct mp_audio*)arg)->nch;
|
||||
af->data->format = AF_FORMAT_FLOAT_NE;
|
||||
af->data->bps = 4;
|
||||
|
||||
|
@ -186,9 +186,9 @@ static void uninit(struct af_instance_s* af)
|
|||
}
|
||||
|
||||
// Filter data through filter
|
||||
static af_data_t* play(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
af_data_t* c = data; // Current working data
|
||||
struct mp_audio* c = data; // Current working data
|
||||
af_equalizer_t* s = (af_equalizer_t*)af->setup; // Setup
|
||||
uint32_t ci = af->data->nch; // Index for channels
|
||||
uint32_t nch = af->data->nch; // Number of channels
|
||||
|
@ -230,7 +230,7 @@ static int af_open(af_instance_t* af){
|
|||
af->uninit=uninit;
|
||||
af->play=play;
|
||||
af->mul=1;
|
||||
af->data=calloc(1,sizeof(af_data_t));
|
||||
af->data=calloc(1,sizeof(struct mp_audio));
|
||||
af->setup=calloc(1,sizeof(af_equalizer_t));
|
||||
if(af->data == NULL || af->setup == NULL)
|
||||
return AF_ERROR;
|
||||
|
|
|
@ -84,8 +84,8 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
close(s->fd);
|
||||
|
||||
// Accept only int16_t as input format (which sucks)
|
||||
af->data->rate = ((af_data_t*)arg)->rate;
|
||||
af->data->nch = ((af_data_t*)arg)->nch;
|
||||
af->data->rate = ((struct mp_audio*)arg)->rate;
|
||||
af->data->nch = ((struct mp_audio*)arg)->nch;
|
||||
af->data->format = AF_FORMAT_S16_NE;
|
||||
af->data->bps = 2;
|
||||
|
||||
|
@ -129,7 +129,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
msync(s->mmap_area, mapsize, MS_ASYNC);
|
||||
|
||||
// Use test_output to return FALSE if necessary
|
||||
return af_test_output(af, (af_data_t*)arg);
|
||||
return af_test_output(af, (struct mp_audio*)arg);
|
||||
}
|
||||
case AF_CONTROL_COMMAND_LINE:{
|
||||
int i=0;
|
||||
|
@ -201,9 +201,9 @@ static void uninit( struct af_instance_s* af )
|
|||
af audio filter instance
|
||||
data audio data
|
||||
*/
|
||||
static af_data_t* play( struct af_instance_s* af, af_data_t* data )
|
||||
static struct mp_audio* play( struct af_instance_s* af, struct mp_audio* data )
|
||||
{
|
||||
af_data_t* c = data; // Current working data
|
||||
struct mp_audio* c = data; // Current working data
|
||||
af_export_t* s = af->setup; // Setup for this instance
|
||||
int16_t* a = c->audio; // Incomming sound
|
||||
int nch = c->nch; // Number of channels
|
||||
|
@ -252,7 +252,7 @@ static int af_open( af_instance_t* af )
|
|||
af->uninit = uninit;
|
||||
af->play = play;
|
||||
af->mul=1;
|
||||
af->data = calloc(1, sizeof(af_data_t));
|
||||
af->data = calloc(1, sizeof(struct mp_audio));
|
||||
af->setup = calloc(1, sizeof(af_export_t));
|
||||
if((af->data == NULL) || (af->setup == NULL))
|
||||
return AF_ERROR;
|
||||
|
|
|
@ -34,8 +34,8 @@ typedef struct af_extrastereo_s
|
|||
float mul;
|
||||
}af_extrastereo_t;
|
||||
|
||||
static af_data_t* play_s16(struct af_instance_s* af, af_data_t* data);
|
||||
static af_data_t* play_float(struct af_instance_s* af, af_data_t* data);
|
||||
static struct mp_audio* play_s16(struct af_instance_s* af, struct mp_audio* data);
|
||||
static struct mp_audio* play_float(struct af_instance_s* af, struct mp_audio* data);
|
||||
|
||||
// Initialization and runtime control
|
||||
static int control(struct af_instance_s* af, int cmd, void* arg)
|
||||
|
@ -47,9 +47,9 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
// Sanity check
|
||||
if(!arg) return AF_ERROR;
|
||||
|
||||
af->data->rate = ((af_data_t*)arg)->rate;
|
||||
af->data->rate = ((struct mp_audio*)arg)->rate;
|
||||
af->data->nch = 2;
|
||||
if (((af_data_t*)arg)->format == AF_FORMAT_FLOAT_NE)
|
||||
if (((struct mp_audio*)arg)->format == AF_FORMAT_FLOAT_NE)
|
||||
{
|
||||
af->data->format = AF_FORMAT_FLOAT_NE;
|
||||
af->data->bps = 4;
|
||||
|
@ -61,7 +61,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
af->play = play_s16;
|
||||
}
|
||||
|
||||
return af_test_output(af,(af_data_t*)arg);
|
||||
return af_test_output(af,(struct mp_audio*)arg);
|
||||
}
|
||||
case AF_CONTROL_COMMAND_LINE:{
|
||||
float f;
|
||||
|
@ -87,7 +87,7 @@ static void uninit(struct af_instance_s* af)
|
|||
}
|
||||
|
||||
// Filter data through filter
|
||||
static af_data_t* play_s16(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play_s16(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
af_extrastereo_t *s = af->setup;
|
||||
register int i = 0;
|
||||
|
@ -109,7 +109,7 @@ static af_data_t* play_s16(struct af_instance_s* af, af_data_t* data)
|
|||
return data;
|
||||
}
|
||||
|
||||
static af_data_t* play_float(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play_float(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
af_extrastereo_t *s = af->setup;
|
||||
register int i = 0;
|
||||
|
@ -137,7 +137,7 @@ static int af_open(af_instance_t* af){
|
|||
af->uninit=uninit;
|
||||
af->play=play_s16;
|
||||
af->mul=1;
|
||||
af->data=calloc(1,sizeof(af_data_t));
|
||||
af->data=calloc(1,sizeof(struct mp_audio));
|
||||
af->setup=calloc(1,sizeof(af_extrastereo_t));
|
||||
if(af->data == NULL || af->setup == NULL)
|
||||
return AF_ERROR;
|
||||
|
|
|
@ -52,10 +52,10 @@ static void float2int(float* in, void* out, int len, int bps);
|
|||
// From signed int to float
|
||||
static void int2float(void* in, float* out, int len, int bps);
|
||||
|
||||
static af_data_t* play(struct af_instance_s* af, af_data_t* data);
|
||||
static af_data_t* play_swapendian(struct af_instance_s* af, af_data_t* data);
|
||||
static af_data_t* play_float_s16(struct af_instance_s* af, af_data_t* data);
|
||||
static af_data_t* play_s16_float(struct af_instance_s* af, af_data_t* data);
|
||||
static struct mp_audio* play(struct af_instance_s* af, struct mp_audio* data);
|
||||
static struct mp_audio* play_swapendian(struct af_instance_s* af, struct mp_audio* data);
|
||||
static struct mp_audio* play_float_s16(struct af_instance_s* af, struct mp_audio* data);
|
||||
static struct mp_audio* play_s16_float(struct af_instance_s* af, struct mp_audio* data);
|
||||
|
||||
// Helper functions to check sanity for input arguments
|
||||
|
||||
|
@ -92,7 +92,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
case AF_CONTROL_REINIT:{
|
||||
char buf1[256];
|
||||
char buf2[256];
|
||||
af_data_t *data = arg;
|
||||
struct mp_audio *data = arg;
|
||||
|
||||
// Make sure this filter isn't redundant
|
||||
if(af->data->format == data->format &&
|
||||
|
@ -176,10 +176,10 @@ static void uninit(struct af_instance_s* af)
|
|||
af->setup = 0;
|
||||
}
|
||||
|
||||
static af_data_t* play_swapendian(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play_swapendian(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
af_data_t* l = af->data; // Local data
|
||||
af_data_t* c = data; // Current working data
|
||||
struct mp_audio* l = af->data; // Local data
|
||||
struct mp_audio* c = data; // Current working data
|
||||
int len = c->len/c->bps; // Length in samples of current audio block
|
||||
|
||||
if(AF_OK != RESIZE_LOCAL_BUFFER(af,data))
|
||||
|
@ -193,10 +193,10 @@ static af_data_t* play_swapendian(struct af_instance_s* af, af_data_t* data)
|
|||
return c;
|
||||
}
|
||||
|
||||
static af_data_t* play_float_s16(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play_float_s16(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
af_data_t* l = af->data; // Local data
|
||||
af_data_t* c = data; // Current working data
|
||||
struct mp_audio* l = af->data; // Local data
|
||||
struct mp_audio* c = data; // Current working data
|
||||
int len = c->len/4; // Length in samples of current audio block
|
||||
|
||||
if(AF_OK != RESIZE_LOCAL_BUFFER(af,data))
|
||||
|
@ -212,10 +212,10 @@ static af_data_t* play_float_s16(struct af_instance_s* af, af_data_t* data)
|
|||
return c;
|
||||
}
|
||||
|
||||
static af_data_t* play_s16_float(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play_s16_float(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
af_data_t* l = af->data; // Local data
|
||||
af_data_t* c = data; // Current working data
|
||||
struct mp_audio* l = af->data; // Local data
|
||||
struct mp_audio* c = data; // Current working data
|
||||
int len = c->len/2; // Length in samples of current audio block
|
||||
|
||||
if(AF_OK != RESIZE_LOCAL_BUFFER(af,data))
|
||||
|
@ -232,10 +232,10 @@ static af_data_t* play_s16_float(struct af_instance_s* af, af_data_t* data)
|
|||
}
|
||||
|
||||
// Filter data through filter
|
||||
static af_data_t* play(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
af_data_t* l = af->data; // Local data
|
||||
af_data_t* c = data; // Current working data
|
||||
struct mp_audio* l = af->data; // Local data
|
||||
struct mp_audio* c = data; // Current working data
|
||||
int len = c->len/c->bps; // Length in samples of current audio block
|
||||
|
||||
if(AF_OK != RESIZE_LOCAL_BUFFER(af,data))
|
||||
|
@ -318,7 +318,7 @@ static int af_open(af_instance_t* af){
|
|||
af->uninit=uninit;
|
||||
af->play=play;
|
||||
af->mul=1;
|
||||
af->data=calloc(1,sizeof(af_data_t));
|
||||
af->data=calloc(1,sizeof(struct mp_audio));
|
||||
if(af->data == NULL)
|
||||
return AF_ERROR;
|
||||
return AF_OK;
|
||||
|
|
|
@ -290,7 +290,7 @@ static int control(struct af_instance_s *af, int cmd, void* arg)
|
|||
|
||||
switch(cmd) {
|
||||
case AF_CONTROL_REINIT:
|
||||
af->data->rate = ((af_data_t*)arg)->rate;
|
||||
af->data->rate = ((struct mp_audio*)arg)->rate;
|
||||
if(af->data->rate != 48000) {
|
||||
// automatic samplerate adjustment in the filter chain
|
||||
// is not yet supported.
|
||||
|
@ -299,7 +299,7 @@ static int control(struct af_instance_s *af, int cmd, void* arg)
|
|||
af->data->rate);
|
||||
return AF_ERROR;
|
||||
}
|
||||
af->data->nch = ((af_data_t*)arg)->nch;
|
||||
af->data->nch = ((struct mp_audio*)arg)->nch;
|
||||
if(af->data->nch == 2) {
|
||||
/* 2 channel input */
|
||||
if(s->decode_mode != HRTF_MIX_MATRIX2CH) {
|
||||
|
@ -311,7 +311,7 @@ static int control(struct af_instance_s *af, int cmd, void* arg)
|
|||
af->data->nch = 5;
|
||||
af->data->format = AF_FORMAT_S16_NE;
|
||||
af->data->bps = 2;
|
||||
test_output_res = af_test_output(af, (af_data_t*)arg);
|
||||
test_output_res = af_test_output(af, (struct mp_audio*)arg);
|
||||
af->mul = 2.0 / af->data->nch;
|
||||
// after testing input set the real output format
|
||||
af->data->nch = 2;
|
||||
|
@ -381,7 +381,7 @@ frequencies).
|
|||
2. A bass compensation is introduced to ensure that 0-200 Hz are not
|
||||
damped (without any real 3D acoustical image, however).
|
||||
*/
|
||||
static af_data_t* play(struct af_instance_s *af, af_data_t *data)
|
||||
static struct mp_audio* play(struct af_instance_s *af, struct mp_audio *data)
|
||||
{
|
||||
af_hrtf_t *s = af->setup;
|
||||
short *in = data->audio; // Input audio data
|
||||
|
@ -603,7 +603,7 @@ static int af_open(af_instance_t* af)
|
|||
af->uninit = uninit;
|
||||
af->play = play;
|
||||
af->mul = 1;
|
||||
af->data = calloc(1, sizeof(af_data_t));
|
||||
af->data = calloc(1, sizeof(struct mp_audio));
|
||||
af->setup = calloc(1, sizeof(af_hrtf_t));
|
||||
if((af->data == NULL) || (af->setup == NULL))
|
||||
return AF_ERROR;
|
||||
|
|
|
@ -34,11 +34,11 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
{
|
||||
switch(cmd){
|
||||
case AF_CONTROL_REINIT:
|
||||
af->data->rate = ((af_data_t*)arg)->rate;
|
||||
af->data->nch = ((af_data_t*)arg)->nch;
|
||||
af->data->rate = ((struct mp_audio*)arg)->rate;
|
||||
af->data->nch = ((struct mp_audio*)arg)->nch;
|
||||
af->data->format= AF_FORMAT_FLOAT_NE;
|
||||
af->data->bps = 4;
|
||||
return af_test_output(af,(af_data_t*)arg);
|
||||
return af_test_output(af,(struct mp_audio*)arg);
|
||||
}
|
||||
return AF_UNKNOWN;
|
||||
}
|
||||
|
@ -50,9 +50,9 @@ static void uninit(struct af_instance_s* af)
|
|||
}
|
||||
|
||||
// Filter data through filter
|
||||
static af_data_t* play(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
af_data_t* c = data; // Current working data
|
||||
struct mp_audio* c = data; // Current working data
|
||||
float* a = c->audio; // Audio data
|
||||
int len = c->len/4; // Number of samples in current audio block
|
||||
int nch = c->nch; // Number of channels
|
||||
|
@ -79,7 +79,7 @@ static int af_open(af_instance_t* af){
|
|||
af->uninit = uninit;
|
||||
af->play = play;
|
||||
af->mul = 1;
|
||||
af->data = calloc(1,sizeof(af_data_t));
|
||||
af->data = calloc(1,sizeof(struct mp_audio));
|
||||
|
||||
if(af->data == NULL)
|
||||
return AF_ERROR;
|
||||
|
|
|
@ -498,8 +498,8 @@ static int control(struct af_instance_s *af, int cmd, void *arg) {
|
|||
|
||||
/* accept FLOAT, let af_format do conversion */
|
||||
|
||||
af->data->rate = ((af_data_t*)arg)->rate;
|
||||
af->data->nch = ((af_data_t*)arg)->nch;
|
||||
af->data->rate = ((struct mp_audio*)arg)->rate;
|
||||
af->data->nch = ((struct mp_audio*)arg)->nch;
|
||||
af->data->format = AF_FORMAT_FLOAT_NE;
|
||||
af->data->bps = 4;
|
||||
|
||||
|
@ -507,7 +507,7 @@ static int control(struct af_instance_s *af, int cmd, void *arg) {
|
|||
* filter, has to be done in play() :-/
|
||||
*/
|
||||
|
||||
return af_test_output(af, (af_data_t*)arg);
|
||||
return af_test_output(af, (struct mp_audio*)arg);
|
||||
case AF_CONTROL_COMMAND_LINE: {
|
||||
char *buf;
|
||||
char *line = arg;
|
||||
|
@ -710,7 +710,7 @@ static void uninit(struct af_instance_s *af) {
|
|||
* \return Either AF_ERROR or AF_OK
|
||||
*/
|
||||
|
||||
static af_data_t* play(struct af_instance_s *af, af_data_t *data) {
|
||||
static struct mp_audio* play(struct af_instance_s *af, struct mp_audio *data) {
|
||||
af_ladspa_t *setup = af->setup;
|
||||
const LADSPA_Descriptor *pdes = setup->plugin_descriptor;
|
||||
float *audio = (float*)data->audio;
|
||||
|
@ -889,7 +889,7 @@ static int af_open(af_instance_t *af) {
|
|||
af->play=play;
|
||||
af->mul=1;
|
||||
|
||||
af->data = calloc(1, sizeof(af_data_t));
|
||||
af->data = calloc(1, sizeof(struct mp_audio));
|
||||
if (af->data == NULL)
|
||||
return af_ladspa_malloc_failed((char*)af_info_ladspa.name);
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ typedef struct af_ac3enc_s {
|
|||
static int control(struct af_instance_s *af, int cmd, void *arg)
|
||||
{
|
||||
af_ac3enc_t *s = af->setup;
|
||||
af_data_t *data = arg;
|
||||
struct mp_audio *data = arg;
|
||||
int i, bit_rate, test_output_res;
|
||||
static const int default_bit_rate[AC3_MAX_CHANNELS+1] = \
|
||||
{0, 96000, 192000, 256000, 384000, 448000, 448000};
|
||||
|
@ -170,11 +170,11 @@ static void uninit(struct af_instance_s* af)
|
|||
}
|
||||
|
||||
// Filter data through filter
|
||||
static af_data_t* play(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
af_ac3enc_t *s = af->setup;
|
||||
af_data_t *c = data; // Current working data
|
||||
af_data_t *l;
|
||||
struct mp_audio *c = data; // Current working data
|
||||
struct mp_audio *l;
|
||||
int len, left, outsize = 0, destsize;
|
||||
char *buf, *src, *dest;
|
||||
int max_output_len;
|
||||
|
@ -282,7 +282,7 @@ static int af_open(af_instance_t* af){
|
|||
af->uninit=uninit;
|
||||
af->play=play;
|
||||
af->mul=1;
|
||||
af->data=calloc(1,sizeof(af_data_t));
|
||||
af->data=calloc(1,sizeof(struct mp_audio));
|
||||
af->setup=s;
|
||||
|
||||
s->lavc_acodec = avcodec_find_encoder_by_name("ac3");
|
||||
|
|
|
@ -53,7 +53,7 @@ typedef struct af_resample_s{
|
|||
static int control(struct af_instance_s* af, int cmd, void* arg)
|
||||
{
|
||||
af_resample_t* s = (af_resample_t*)af->setup;
|
||||
af_data_t *data= (af_data_t*)arg;
|
||||
struct mp_audio *data= (struct mp_audio*)arg;
|
||||
int out_rate, test_output_res; // helpers for checking input format
|
||||
|
||||
switch(cmd){
|
||||
|
@ -83,7 +83,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
// hack to make af_test_output ignore the samplerate change
|
||||
out_rate = af->data->rate;
|
||||
af->data->rate = data->rate;
|
||||
test_output_res = af_test_output(af, (af_data_t*)arg);
|
||||
test_output_res = af_test_output(af, (struct mp_audio*)arg);
|
||||
af->data->rate = out_rate;
|
||||
return test_output_res;
|
||||
case AF_CONTROL_COMMAND_LINE:{
|
||||
|
@ -116,7 +116,7 @@ static void uninit(struct af_instance_s* af)
|
|||
}
|
||||
|
||||
// Filter data through filter
|
||||
static af_data_t* play(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
af_resample_t *s = af->setup;
|
||||
int i, j, consumed, ret = 0;
|
||||
|
@ -194,7 +194,7 @@ static int af_open(af_instance_t* af){
|
|||
af->uninit=uninit;
|
||||
af->play=play;
|
||||
af->mul=1;
|
||||
af->data=calloc(1,sizeof(af_data_t));
|
||||
af->data=calloc(1,sizeof(struct mp_audio));
|
||||
s->filter_length= 16;
|
||||
s->cutoff= max(1.0 - 6.5/(s->filter_length+8), 0.80);
|
||||
s->phase_shift= 10;
|
||||
|
|
|
@ -44,16 +44,16 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
// Sanity check
|
||||
if(!arg) return AF_ERROR;
|
||||
|
||||
af->data->rate = ((af_data_t*)arg)->rate;
|
||||
af->data->rate = ((struct mp_audio*)arg)->rate;
|
||||
af->data->format = AF_FORMAT_FLOAT_NE;
|
||||
af->data->bps = 4;
|
||||
af->data->nch = s->nch ? s->nch: ((af_data_t*)arg)->nch;
|
||||
af->mul = (double)af->data->nch / ((af_data_t*)arg)->nch;
|
||||
af->data->nch = s->nch ? s->nch: ((struct mp_audio*)arg)->nch;
|
||||
af->mul = (double)af->data->nch / ((struct mp_audio*)arg)->nch;
|
||||
|
||||
if((af->data->format != ((af_data_t*)arg)->format) ||
|
||||
(af->data->bps != ((af_data_t*)arg)->bps)){
|
||||
((af_data_t*)arg)->format = af->data->format;
|
||||
((af_data_t*)arg)->bps = af->data->bps;
|
||||
if((af->data->format != ((struct mp_audio*)arg)->format) ||
|
||||
(af->data->bps != ((struct mp_audio*)arg)->bps)){
|
||||
((struct mp_audio*)arg)->format = af->data->format;
|
||||
((struct mp_audio*)arg)->bps = af->data->bps;
|
||||
return AF_FALSE;
|
||||
}
|
||||
return AF_OK;
|
||||
|
@ -148,10 +148,10 @@ static void uninit(struct af_instance_s* af)
|
|||
}
|
||||
|
||||
// Filter data through filter
|
||||
static af_data_t* play(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
af_data_t* c = data; // Current working data
|
||||
af_data_t* l = af->data; // Local data
|
||||
struct mp_audio* c = data; // Current working data
|
||||
struct mp_audio* l = af->data; // Local data
|
||||
af_pan_t* s = af->setup; // Setup for this instance
|
||||
float* in = c->audio; // Input audio data
|
||||
float* out = NULL; // Output audio data
|
||||
|
@ -192,7 +192,7 @@ static int af_open(af_instance_t* af){
|
|||
af->uninit=uninit;
|
||||
af->play=play;
|
||||
af->mul=1;
|
||||
af->data=calloc(1,sizeof(af_data_t));
|
||||
af->data=calloc(1,sizeof(struct mp_audio));
|
||||
af->setup=calloc(1,sizeof(af_pan_t));
|
||||
if(af->data == NULL || af->setup == NULL)
|
||||
return AF_ERROR;
|
||||
|
|
|
@ -75,7 +75,7 @@ typedef struct af_resample_s
|
|||
} af_resample_t;
|
||||
|
||||
// Fast linear interpolation resample with modest audio quality
|
||||
static int linint(af_data_t* c,af_data_t* l, af_resample_t* s)
|
||||
static int linint(struct mp_audio* c,struct mp_audio* l, af_resample_t* s)
|
||||
{
|
||||
uint32_t len = 0; // Number of input samples
|
||||
uint32_t nch = l->nch; // Words pre transfer
|
||||
|
@ -122,7 +122,7 @@ static int linint(af_data_t* c,af_data_t* l, af_resample_t* s)
|
|||
}
|
||||
|
||||
/* Determine resampling type and format */
|
||||
static int set_types(struct af_instance_s* af, af_data_t* data)
|
||||
static int set_types(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
af_resample_t* s = af->setup;
|
||||
int rv = AF_OK;
|
||||
|
@ -175,7 +175,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
switch(cmd){
|
||||
case AF_CONTROL_REINIT:{
|
||||
af_resample_t* s = af->setup;
|
||||
af_data_t* n = arg; // New configuration
|
||||
struct mp_audio* n = arg; // New configuration
|
||||
int i,d = 0;
|
||||
int rv = AF_OK;
|
||||
|
||||
|
@ -317,11 +317,11 @@ static void uninit(struct af_instance_s* af)
|
|||
}
|
||||
|
||||
// Filter data through filter
|
||||
static af_data_t* play(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
int len = 0; // Length of output data
|
||||
af_data_t* c = data; // Current working data
|
||||
af_data_t* l = af->data; // Local data
|
||||
struct mp_audio* c = data; // Current working data
|
||||
struct mp_audio* l = af->data; // Local data
|
||||
af_resample_t* s = af->setup;
|
||||
|
||||
if(AF_OK != RESIZE_LOCAL_BUFFER(af,data))
|
||||
|
@ -375,7 +375,7 @@ static int af_open(af_instance_t* af){
|
|||
af->uninit=uninit;
|
||||
af->play=play;
|
||||
af->mul=1;
|
||||
af->data=calloc(1,sizeof(af_data_t));
|
||||
af->data=calloc(1,sizeof(struct mp_audio));
|
||||
af->setup=calloc(1,sizeof(af_resample_t));
|
||||
if(af->data == NULL || af->setup == NULL)
|
||||
return AF_ERROR;
|
||||
|
|
|
@ -78,7 +78,7 @@ typedef struct af_scaletempo_s
|
|||
short speed_pitch;
|
||||
} af_scaletempo_t;
|
||||
|
||||
static int fill_queue(struct af_instance_s* af, af_data_t* data, int offset)
|
||||
static int fill_queue(struct af_instance_s* af, struct mp_audio* data, int offset)
|
||||
{
|
||||
af_scaletempo_t* s = af->setup;
|
||||
int bytes_in = data->len - offset;
|
||||
|
@ -219,7 +219,7 @@ static void output_overlap_s16(af_scaletempo_t* s, void* buf_out,
|
|||
}
|
||||
|
||||
// Filter data through filter
|
||||
static af_data_t* play(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
af_scaletempo_t* s = af->setup;
|
||||
int offset_in;
|
||||
|
@ -290,7 +290,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
af_scaletempo_t* s = af->setup;
|
||||
switch(cmd){
|
||||
case AF_CONTROL_REINIT:{
|
||||
af_data_t* data = (af_data_t*)arg;
|
||||
struct mp_audio* data = (struct mp_audio*)arg;
|
||||
float srate = data->rate / 1000;
|
||||
int nch = data->nch;
|
||||
int bps;
|
||||
|
@ -305,7 +305,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
if (s->scale == 1.0) {
|
||||
if (s->speed_tempo && s->speed_pitch)
|
||||
return AF_DETACH;
|
||||
memcpy(af->data, data, sizeof(af_data_t));
|
||||
memcpy(af->data, data, sizeof(struct mp_audio));
|
||||
af->delay = 0;
|
||||
af->mul = 1;
|
||||
return af_test_output(af, data);
|
||||
|
@ -439,7 +439,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
(int)(s->bytes_queue / nch / bps),
|
||||
(use_int?"s16":"float"));
|
||||
|
||||
return af_test_output(af, (af_data_t*)arg);
|
||||
return af_test_output(af, (struct mp_audio*)arg);
|
||||
}
|
||||
case AF_CONTROL_PLAYBACK_SPEED | AF_CONTROL_SET:{
|
||||
if (s->speed_tempo) {
|
||||
|
@ -554,7 +554,7 @@ static int af_open(af_instance_t* af){
|
|||
af->uninit = uninit;
|
||||
af->play = play;
|
||||
af->mul = 1;
|
||||
af->data = calloc(1,sizeof(af_data_t));
|
||||
af->data = calloc(1,sizeof(struct mp_audio));
|
||||
af->setup = calloc(1,sizeof(af_scaletempo_t));
|
||||
if(af->data == NULL || af->setup == NULL)
|
||||
return AF_ERROR;
|
||||
|
|
|
@ -41,8 +41,8 @@ typedef struct af_sinesuppress_s
|
|||
double pos;
|
||||
}af_sinesuppress_t;
|
||||
|
||||
static af_data_t* play_s16(struct af_instance_s* af, af_data_t* data);
|
||||
//static af_data_t* play_float(struct af_instance_s* af, af_data_t* data);
|
||||
static struct mp_audio* play_s16(struct af_instance_s* af, struct mp_audio* data);
|
||||
//static struct mp_audio* play_float(struct af_instance_s* af, struct mp_audio* data);
|
||||
|
||||
// Initialization and runtime control
|
||||
static int control(struct af_instance_s* af, int cmd, void* arg)
|
||||
|
@ -54,10 +54,10 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
// Sanity check
|
||||
if(!arg) return AF_ERROR;
|
||||
|
||||
af->data->rate = ((af_data_t*)arg)->rate;
|
||||
af->data->rate = ((struct mp_audio*)arg)->rate;
|
||||
af->data->nch = 1;
|
||||
#if 0
|
||||
if (((af_data_t*)arg)->format == AF_FORMAT_FLOAT_NE)
|
||||
if (((struct mp_audio*)arg)->format == AF_FORMAT_FLOAT_NE)
|
||||
{
|
||||
af->data->format = AF_FORMAT_FLOAT_NE;
|
||||
af->data->bps = 4;
|
||||
|
@ -70,7 +70,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
af->play = play_s16;
|
||||
}
|
||||
|
||||
return af_test_output(af,(af_data_t*)arg);
|
||||
return af_test_output(af,(struct mp_audio*)arg);
|
||||
}
|
||||
case AF_CONTROL_COMMAND_LINE:{
|
||||
float f1,f2;
|
||||
|
@ -103,7 +103,7 @@ static void uninit(struct af_instance_s* af)
|
|||
}
|
||||
|
||||
// Filter data through filter
|
||||
static af_data_t* play_s16(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play_s16(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
af_sinesuppress_t *s = af->setup;
|
||||
register int i = 0;
|
||||
|
@ -134,7 +134,7 @@ static af_data_t* play_s16(struct af_instance_s* af, af_data_t* data)
|
|||
}
|
||||
|
||||
#if 0
|
||||
static af_data_t* play_float(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play_float(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
af_sinesuppress_t *s = af->setup;
|
||||
register int i = 0;
|
||||
|
@ -163,7 +163,7 @@ static int af_open(af_instance_t* af){
|
|||
af->uninit=uninit;
|
||||
af->play=play_s16;
|
||||
af->mul=1;
|
||||
af->data=calloc(1,sizeof(af_data_t));
|
||||
af->data=calloc(1,sizeof(struct mp_audio));
|
||||
af->setup=calloc(1,sizeof(af_sinesuppress_t));
|
||||
if(af->data == NULL || af->setup == NULL)
|
||||
return AF_ERROR;
|
||||
|
|
|
@ -69,8 +69,8 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
// Sanity check
|
||||
if(!arg) return AF_ERROR;
|
||||
|
||||
af->data->rate = ((af_data_t*)arg)->rate;
|
||||
af->data->nch = max(s->ch+1,((af_data_t*)arg)->nch);
|
||||
af->data->rate = ((struct mp_audio*)arg)->rate;
|
||||
af->data->nch = max(s->ch+1,((struct mp_audio*)arg)->nch);
|
||||
af->data->format = AF_FORMAT_FLOAT_NE;
|
||||
af->data->bps = 4;
|
||||
|
||||
|
@ -81,7 +81,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
(-1 == af_filter_szxform(sp[1].a, sp[1].b, Q, s->fc,
|
||||
(float)af->data->rate, &s->k, s->w[1])))
|
||||
return AF_ERROR;
|
||||
return af_test_output(af,(af_data_t*)arg);
|
||||
return af_test_output(af,(struct mp_audio*)arg);
|
||||
}
|
||||
case AF_CONTROL_COMMAND_LINE:{
|
||||
int ch=5;
|
||||
|
@ -139,9 +139,9 @@ static void uninit(struct af_instance_s* af)
|
|||
#endif
|
||||
|
||||
// Filter data through filter
|
||||
static af_data_t* play(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
af_data_t* c = data; // Current working data
|
||||
struct mp_audio* c = data; // Current working data
|
||||
af_sub_t* s = af->setup; // Setup for this instance
|
||||
float* a = c->audio; // Audio data
|
||||
int len = c->len/4; // Number of samples in current audio block
|
||||
|
@ -167,7 +167,7 @@ static int af_open(af_instance_t* af){
|
|||
af->uninit=uninit;
|
||||
af->play=play;
|
||||
af->mul=1;
|
||||
af->data=calloc(1,sizeof(af_data_t));
|
||||
af->data=calloc(1,sizeof(struct mp_audio));
|
||||
af->setup=s=calloc(1,sizeof(af_sub_t));
|
||||
if(af->data == NULL || af->setup == NULL)
|
||||
return AF_ERROR;
|
||||
|
|
|
@ -92,8 +92,8 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
switch(cmd){
|
||||
case AF_CONTROL_REINIT:{
|
||||
float fc;
|
||||
af->data->rate = ((af_data_t*)arg)->rate;
|
||||
af->data->nch = ((af_data_t*)arg)->nch*2;
|
||||
af->data->rate = ((struct mp_audio*)arg)->rate;
|
||||
af->data->nch = ((struct mp_audio*)arg)->nch*2;
|
||||
af->data->format = AF_FORMAT_FLOAT_NE;
|
||||
af->data->bps = 4;
|
||||
|
||||
|
@ -123,10 +123,10 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
// printf("%i\n",s->wi);
|
||||
s->ri = 0;
|
||||
|
||||
if((af->data->format != ((af_data_t*)arg)->format) ||
|
||||
(af->data->bps != ((af_data_t*)arg)->bps)){
|
||||
((af_data_t*)arg)->format = af->data->format;
|
||||
((af_data_t*)arg)->bps = af->data->bps;
|
||||
if((af->data->format != ((struct mp_audio*)arg)->format) ||
|
||||
(af->data->bps != ((struct mp_audio*)arg)->bps)){
|
||||
((struct mp_audio*)arg)->format = af->data->format;
|
||||
((struct mp_audio*)arg)->bps = af->data->bps;
|
||||
return AF_FALSE;
|
||||
}
|
||||
return AF_OK;
|
||||
|
@ -167,7 +167,7 @@ static float steering_matrix[][12] = {
|
|||
//static int amp_L = 0, amp_R = 0, amp_C = 0, amp_S = 0;
|
||||
|
||||
// Filter data through filter
|
||||
static af_data_t* play(struct af_instance_s* af, af_data_t* data){
|
||||
static struct mp_audio* play(struct af_instance_s* af, struct mp_audio* data){
|
||||
af_surround_t* s = (af_surround_t*)af->setup;
|
||||
float* m = steering_matrix[0];
|
||||
float* in = data->audio; // Input audio data
|
||||
|
@ -254,7 +254,7 @@ static int af_open(af_instance_t* af){
|
|||
af->uninit=uninit;
|
||||
af->play=play;
|
||||
af->mul=2;
|
||||
af->data=calloc(1,sizeof(af_data_t));
|
||||
af->data=calloc(1,sizeof(struct mp_audio));
|
||||
af->setup=calloc(1,sizeof(af_surround_t));
|
||||
if(af->data == NULL || af->setup == NULL)
|
||||
return AF_ERROR;
|
||||
|
|
|
@ -37,7 +37,7 @@ typedef struct af_sweep_s{
|
|||
static int control(struct af_instance_s* af, int cmd, void* arg)
|
||||
{
|
||||
af_sweept* s = (af_sweept*)af->setup;
|
||||
af_data_t *data= (af_data_t*)arg;
|
||||
struct mp_audio *data= (struct mp_audio*)arg;
|
||||
|
||||
switch(cmd){
|
||||
case AF_CONTROL_REINIT:
|
||||
|
@ -65,7 +65,7 @@ static void uninit(struct af_instance_s* af)
|
|||
}
|
||||
|
||||
// Filter data through filter
|
||||
static af_data_t* play(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
af_sweept *s = af->setup;
|
||||
int i, j;
|
||||
|
@ -88,7 +88,7 @@ static int af_open(af_instance_t* af){
|
|||
af->uninit=uninit;
|
||||
af->play=play;
|
||||
af->mul=1;
|
||||
af->data=calloc(1,sizeof(af_data_t));
|
||||
af->data=calloc(1,sizeof(struct mp_audio));
|
||||
af->setup=calloc(1,sizeof(af_sweept));
|
||||
return AF_OK;
|
||||
}
|
||||
|
|
|
@ -85,13 +85,13 @@ int af_to_ms(int n, int* in, float* out, int rate)
|
|||
}
|
||||
|
||||
/* Helper function for testing the output format */
|
||||
int af_test_output(struct af_instance_s* af, af_data_t* out)
|
||||
int af_test_output(struct af_instance_s* af, struct mp_audio* out)
|
||||
{
|
||||
if((af->data->format != out->format) ||
|
||||
(af->data->bps != out->bps) ||
|
||||
(af->data->rate != out->rate) ||
|
||||
(af->data->nch != out->nch)){
|
||||
memcpy(out,af->data,sizeof(af_data_t));
|
||||
memcpy(out,af->data,sizeof(struct mp_audio));
|
||||
return AF_FALSE;
|
||||
}
|
||||
return AF_OK;
|
||||
|
|
|
@ -87,17 +87,17 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
// Sanity check
|
||||
if(!arg) return AF_ERROR;
|
||||
|
||||
af->data->rate = ((af_data_t*)arg)->rate;
|
||||
af->data->nch = ((af_data_t*)arg)->nch;
|
||||
af->data->rate = ((struct mp_audio*)arg)->rate;
|
||||
af->data->nch = ((struct mp_audio*)arg)->nch;
|
||||
|
||||
if(((af_data_t*)arg)->format == (AF_FORMAT_S16_NE)){
|
||||
if(((struct mp_audio*)arg)->format == (AF_FORMAT_S16_NE)){
|
||||
af->data->format = AF_FORMAT_S16_NE;
|
||||
af->data->bps = 2;
|
||||
}else{
|
||||
af->data->format = AF_FORMAT_FLOAT_NE;
|
||||
af->data->bps = 4;
|
||||
}
|
||||
return af_test_output(af,(af_data_t*)arg);
|
||||
return af_test_output(af,(struct mp_audio*)arg);
|
||||
case AF_CONTROL_COMMAND_LINE:{
|
||||
int i = 0;
|
||||
float target = DEFAULT_TARGET;
|
||||
|
@ -120,7 +120,7 @@ static void uninit(struct af_instance_s* af)
|
|||
free(af->setup);
|
||||
}
|
||||
|
||||
static void method1_int16(af_volnorm_t *s, af_data_t *c)
|
||||
static void method1_int16(af_volnorm_t *s, struct mp_audio *c)
|
||||
{
|
||||
register int i = 0;
|
||||
int16_t *data = (int16_t*)c->audio; // Audio data
|
||||
|
@ -162,7 +162,7 @@ static void method1_int16(af_volnorm_t *s, af_data_t *c)
|
|||
s->lastavg = (1.0 - SMOOTH_LASTAVG) * s->lastavg + SMOOTH_LASTAVG * newavg;
|
||||
}
|
||||
|
||||
static void method1_float(af_volnorm_t *s, af_data_t *c)
|
||||
static void method1_float(af_volnorm_t *s, struct mp_audio *c)
|
||||
{
|
||||
register int i = 0;
|
||||
float *data = (float*)c->audio; // Audio data
|
||||
|
@ -199,7 +199,7 @@ static void method1_float(af_volnorm_t *s, af_data_t *c)
|
|||
s->lastavg = (1.0 - SMOOTH_LASTAVG) * s->lastavg + SMOOTH_LASTAVG * newavg;
|
||||
}
|
||||
|
||||
static void method2_int16(af_volnorm_t *s, af_data_t *c)
|
||||
static void method2_int16(af_volnorm_t *s, struct mp_audio *c)
|
||||
{
|
||||
register int i = 0;
|
||||
int16_t *data = (int16_t*)c->audio; // Audio data
|
||||
|
@ -249,7 +249,7 @@ static void method2_int16(af_volnorm_t *s, af_data_t *c)
|
|||
s->idx = (s->idx + 1) % NSAMPLES;
|
||||
}
|
||||
|
||||
static void method2_float(af_volnorm_t *s, af_data_t *c)
|
||||
static void method2_float(af_volnorm_t *s, struct mp_audio *c)
|
||||
{
|
||||
register int i = 0;
|
||||
float *data = (float*)c->audio; // Audio data
|
||||
|
@ -296,7 +296,7 @@ static void method2_float(af_volnorm_t *s, af_data_t *c)
|
|||
}
|
||||
|
||||
// Filter data through filter
|
||||
static af_data_t* play(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
af_volnorm_t *s = af->setup;
|
||||
|
||||
|
@ -324,7 +324,7 @@ static int af_open(af_instance_t* af){
|
|||
af->uninit=uninit;
|
||||
af->play=play;
|
||||
af->mul=1;
|
||||
af->data=calloc(1,sizeof(af_data_t));
|
||||
af->data=calloc(1,sizeof(struct mp_audio));
|
||||
af->setup=calloc(1,sizeof(af_volnorm_t));
|
||||
if(af->data == NULL || af->setup == NULL)
|
||||
return AF_ERROR;
|
||||
|
|
|
@ -66,10 +66,10 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
// Sanity check
|
||||
if(!arg) return AF_ERROR;
|
||||
|
||||
af->data->rate = ((af_data_t*)arg)->rate;
|
||||
af->data->nch = ((af_data_t*)arg)->nch;
|
||||
af->data->rate = ((struct mp_audio*)arg)->rate;
|
||||
af->data->nch = ((struct mp_audio*)arg)->nch;
|
||||
|
||||
if(s->fast && (((af_data_t*)arg)->format != (AF_FORMAT_FLOAT_NE))){
|
||||
if(s->fast && (((struct mp_audio*)arg)->format != (AF_FORMAT_FLOAT_NE))){
|
||||
af->data->format = AF_FORMAT_S16_NE;
|
||||
af->data->bps = 2;
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
|||
af->data->format = AF_FORMAT_FLOAT_NE;
|
||||
af->data->bps = 4;
|
||||
}
|
||||
return af_test_output(af,(af_data_t*)arg);
|
||||
return af_test_output(af,(struct mp_audio*)arg);
|
||||
case AF_CONTROL_COMMAND_LINE:{
|
||||
float v=0.0;
|
||||
float vol[AF_NCH];
|
||||
|
@ -138,9 +138,9 @@ static void uninit(struct af_instance_s* af)
|
|||
}
|
||||
|
||||
// Filter data through filter
|
||||
static af_data_t* play(struct af_instance_s* af, af_data_t* data)
|
||||
static struct mp_audio* play(struct af_instance_s* af, struct mp_audio* data)
|
||||
{
|
||||
af_data_t* c = data; // Current working data
|
||||
struct mp_audio* c = data; // Current working data
|
||||
af_volume_t* s = (af_volume_t*)af->setup; // Setup for this instance
|
||||
register int nch = c->nch; // Number of channels
|
||||
register int i = 0;
|
||||
|
@ -203,7 +203,7 @@ static int af_open(af_instance_t* af){
|
|||
af->uninit=uninit;
|
||||
af->play=play;
|
||||
af->mul=1;
|
||||
af->data=calloc(1,sizeof(af_data_t));
|
||||
af->data=calloc(1,sizeof(struct mp_audio));
|
||||
af->setup=calloc(1,sizeof(af_volume_t));
|
||||
if(af->data == NULL || af->setup == NULL)
|
||||
return AF_ERROR;
|
||||
|
|
|
@ -89,7 +89,7 @@ typedef struct af_control_ext_s{
|
|||
// MANDATORY CALLS
|
||||
|
||||
/* Reinitialize filter. The optional argument contains the new
|
||||
configuration in form of a af_data_t struct. If the filter does not
|
||||
configuration in form of a struct mp_audio struct. If the filter does not
|
||||
support the new format the struct should be changed and AF_FALSE
|
||||
should be returned. If the incoming and outgoing data streams are
|
||||
identical the filter can return AF_DETACH. This will remove the
|
||||
|
|
|
@ -353,7 +353,7 @@ static int filter_n_bytes(sh_audio_t *sh, struct bstr *outbuf, int len)
|
|||
}
|
||||
|
||||
// Filter
|
||||
af_data_t filter_input = {
|
||||
struct mp_audio filter_input = {
|
||||
.audio = sh->a_buffer,
|
||||
.len = len,
|
||||
.rate = sh->samplerate,
|
||||
|
@ -361,7 +361,7 @@ static int filter_n_bytes(sh_audio_t *sh, struct bstr *outbuf, int len)
|
|||
.format = sh->sample_format
|
||||
};
|
||||
af_fix_parameters(&filter_input);
|
||||
af_data_t *filter_output = af_play(sh->afilter, &filter_input);
|
||||
struct mp_audio *filter_output = af_play(sh->afilter, &filter_input);
|
||||
if (!filter_output)
|
||||
return -1;
|
||||
set_min_out_buffer_size(outbuf, outbuf->len + filter_output->len);
|
||||
|
|
Loading…
Reference in New Issue