mirror of
https://github.com/mpv-player/mpv
synced 2025-01-23 08:03:19 +00:00
Adding commandline options for filters and fixing stupid bug in cfg
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7999 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
95760a746d
commit
437aa67937
@ -121,7 +121,7 @@ extern float monitor_aspect;
|
||||
extern af_cfg_t af_cfg; // Audio filter configuration, defined in libmpcodecs/dec_audio.c
|
||||
struct config audio_filter_conf[]={
|
||||
{"list", &af_cfg.list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL},
|
||||
{"force", &af_cfg.force, CONF_TYPE_INT, CONF_RANGE, 0, 2, NULL},
|
||||
{"force", &af_cfg.force, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL},
|
||||
{NULL, NULL, 0, 0, 0, 0, NULL}
|
||||
};
|
||||
|
||||
|
@ -63,6 +63,7 @@ af_instance_t* af_create(af_stream_t* s, char* name)
|
||||
{
|
||||
char* cmdline = name;
|
||||
char* delim = "=";
|
||||
|
||||
// Allocate space for the new filter and reset all pointers
|
||||
af_instance_t* new=malloc(sizeof(af_instance_t));
|
||||
if(!new){
|
||||
|
@ -89,6 +89,11 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
||||
af->mul.n = af->data->nch;
|
||||
af->mul.d = ((af_data_t*)arg)->nch;
|
||||
return AF_OK;
|
||||
case AF_CONTROL_COMMAND_LINE:{
|
||||
int nch = 0;
|
||||
sscanf((char*)arg,"%i",&nch);
|
||||
return af->control(af,AF_CONTROL_CHANNELS,&nch);
|
||||
}
|
||||
case AF_CONTROL_CHANNELS:
|
||||
// Reinit must be called after this function has been called
|
||||
|
||||
|
@ -32,6 +32,11 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
||||
|
||||
return af->control(af,AF_CONTROL_DELAY_SET_LEN,&((af_delay_t*)af->setup)->tlen);
|
||||
}
|
||||
case AF_CONTROL_COMMAND_LINE:{
|
||||
float d = 0;
|
||||
sscanf((char*)arg,"%f",&d);
|
||||
return af->control(af,AF_CONTROL_DELAY_SET_LEN,&d);
|
||||
}
|
||||
case AF_CONTROL_DELAY_SET_LEN:{
|
||||
af_delay_t* s = (af_delay_t*)af->setup;
|
||||
void* bt = s->buf; // Old buffer
|
||||
|
@ -88,6 +88,11 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
||||
af->mul.n = af->data->bps;
|
||||
af->mul.d = ((af_data_t*)arg)->bps;
|
||||
return AF_OK;
|
||||
case AF_CONTROL_COMMAND_LINE:{
|
||||
af_data_t d;
|
||||
sscanf((char*)arg,"%i:%i",&(d.format),&(d.bps));
|
||||
return af->control(af,AF_CONTROL_FORMAT,&d);
|
||||
}
|
||||
case AF_CONTROL_FORMAT:
|
||||
// Reinit must be called after this function has been called
|
||||
|
||||
|
@ -69,6 +69,8 @@ typedef struct af_resample_s
|
||||
uint32_t i; // Number of new samples to put in x queue
|
||||
uint32_t dn; // Down sampling factor
|
||||
uint32_t up; // Up sampling factor
|
||||
int sloppy; // Enable sloppy resampling to reduce memory usage
|
||||
int fast; // Enable linear interpolation instead of filtering
|
||||
} af_resample_t;
|
||||
|
||||
// Euclids algorithm for calculating Greatest Common Divisor GCD(a,b)
|
||||
@ -222,6 +224,19 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
||||
// Calculate up and down sampling factors
|
||||
d=gcd(af->data->rate,n->rate);
|
||||
|
||||
// If sloppy resampling is enabled limit the upsampling factor
|
||||
if(s->sloppy && (af->data->rate/d > 5000)){
|
||||
int up=af->data->rate/2;
|
||||
int dn=n->rate/2;
|
||||
int m=2;
|
||||
while(af->data->rate/(d*m) > 5000){
|
||||
d=gcd(up,dn);
|
||||
up/=2; dn/=2; m*=2;
|
||||
}
|
||||
d*=m;
|
||||
}
|
||||
printf("\n%i %i %i\n",d,af->data->rate/d,n->rate/d);
|
||||
|
||||
// Check if the the design needs to be redone
|
||||
if(s->up != af->data->rate/d || s->dn != n->rate/d){
|
||||
float* w;
|
||||
@ -264,6 +279,12 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
||||
af->mul.d = s->dn;
|
||||
return rv;
|
||||
}
|
||||
case AF_CONTROL_COMMAND_LINE:{
|
||||
af_resample_t* s = (af_resample_t*)af->setup;
|
||||
int rate=0;
|
||||
sscanf((char*)arg,"%i:%i:%i",&rate,&(s->sloppy), &(s->fast));
|
||||
return af->control(af,AF_CONTROL_RESAMPLE,&rate);
|
||||
}
|
||||
case AF_CONTROL_RESAMPLE:
|
||||
// Reinit must be called after this function has been called
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user