mirror of
https://github.com/mpv-player/mpv
synced 2024-12-24 15:52:25 +00:00
Changing the behavour of the commandline parameter -af to conform with -vop. Adding new commanline parameter -af-adv for advanced af options. Adding changes to volume control to support commandline parameters.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7994 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
aae5309747
commit
a72b161551
@ -181,7 +181,8 @@ static config_t mplayer_opts[]={
|
||||
{"fixed-vo", &fixed_vo, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
||||
|
||||
{"aop", ao_plugin_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
|
||||
{"af", audio_filter_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
|
||||
{"af-adv", audio_filter_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
|
||||
{"af", &af_cfg.list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL},
|
||||
{"dsp", "Use -ao oss:dsp_path!\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
|
||||
{"mixer", &mixer_device, CONF_TYPE_STRING, 0, 0, 0, NULL},
|
||||
{"master", "Option -master has been removed, use -aop list=volume instead.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL},
|
||||
|
27
libaf/af.c
27
libaf/af.c
@ -57,9 +57,12 @@ af_instance_t* af_get(af_stream_t* s, char* name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Function for creating a new filter of type name
|
||||
/*/ Function for creating a new filter of type name. The name may
|
||||
contain the commandline parameters for the filter */
|
||||
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){
|
||||
@ -68,11 +71,15 @@ af_instance_t* af_create(af_stream_t* s, char* name)
|
||||
}
|
||||
memset(new,0,sizeof(af_instance_t));
|
||||
|
||||
// Check for commandline parameters
|
||||
strsep(&cmdline, delim);
|
||||
|
||||
// Find filter from name
|
||||
if(NULL == (new->info=af_find(name)))
|
||||
return NULL;
|
||||
|
||||
// Make sure that the filter is not already in the list if it is non-reentrant
|
||||
/* Make sure that the filter is not already in the list if it is
|
||||
non-reentrant */
|
||||
if(new->info->flags & AF_FLAGS_NOT_REENTRANT){
|
||||
if(af_get(s,name)){
|
||||
mp_msg(MSGT_AFILTER,MSGL_ERR,"There can only be one instance of the filter '%s' in each stream\n",name);
|
||||
@ -80,14 +87,22 @@ af_instance_t* af_create(af_stream_t* s, char* name)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mp_msg(MSGT_AFILTER,MSGL_V,"Adding filter %s \n",name);
|
||||
|
||||
// Initialize the new filter
|
||||
if(AF_OK == new->info->open(new) &&
|
||||
AF_ERROR < new->control(new,AF_CONTROL_POST_CREATE,&s->cfg))
|
||||
return new;
|
||||
AF_ERROR < new->control(new,AF_CONTROL_POST_CREATE,&s->cfg)){
|
||||
if(cmdline){
|
||||
if(AF_ERROR<new->control(new,AF_CONTROL_COMMAND_LINE,cmdline))
|
||||
return new;
|
||||
}
|
||||
else
|
||||
return new;
|
||||
}
|
||||
|
||||
free(new);
|
||||
mp_msg(MSGT_AFILTER,MSGL_ERR,"Couldn't create audio filter '%s'\n",name);
|
||||
mp_msg(MSGT_AFILTER,MSGL_ERR,"Couldn't create or open audio filter '%s'\n",name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* This audio filter changes the volume of the sound, and can be used
|
||||
when the mixer doesn't support the PCM channel. It can handel
|
||||
between 1 and 6 channels. The volume can be adjusted between -60dB
|
||||
to +10dB and is set on a per channels basis. The volume can be
|
||||
to +20dB and is set on a per channels basis. The volume can be
|
||||
written ad read by AF_CONTROL_VOLUME_SET and AF_CONTROL_VOLUME_GET
|
||||
respectivly.
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
#define MIN_S16 -32650
|
||||
#define MAX_S16 32650
|
||||
|
||||
#define MAX_VOL +10.0
|
||||
#define MAX_VOL +20.0
|
||||
#define MIN_VOL -60.0
|
||||
|
||||
// Number of channels
|
||||
@ -55,7 +55,7 @@ typedef struct af_volume_s
|
||||
|
||||
/* Convert to gain value from dB. Returns AF_OK if of and AF_ERROR if
|
||||
fail */
|
||||
inline int from_dB(double* in, double* out)
|
||||
inline int from_dB(double* in, double* out, double k)
|
||||
{
|
||||
int i = 0;
|
||||
// Sanity check
|
||||
@ -63,13 +63,13 @@ inline int from_dB(double* in, double* out)
|
||||
return AF_ERROR;
|
||||
|
||||
for(i=0;i<NCH;i++)
|
||||
out[i]=pow(10.0,clamp(in[i],MIN_VOL,MAX_VOL)/10.0);
|
||||
out[i]=pow(10.0,clamp(in[i],MIN_VOL,MAX_VOL)/k);
|
||||
return AF_OK;
|
||||
}
|
||||
|
||||
/* Convert from gain value to dB. Returns AF_OK if of and AF_ERROR if
|
||||
fail */
|
||||
inline int to_dB(double* in, double* out)
|
||||
inline int to_dB(double* in, double* out, double k)
|
||||
{
|
||||
int i = 0;
|
||||
// Sanity check
|
||||
@ -77,7 +77,7 @@ inline int to_dB(double* in, double* out)
|
||||
return AF_ERROR;
|
||||
|
||||
for(i=0;i<NCH;i++)
|
||||
out[i]=10.0*log10(clamp(in[i],MIN_VOL,MAX_VOL));
|
||||
out[i]=k*log10(clamp(in[i],MIN_VOL,MAX_VOL));
|
||||
return AF_OK;
|
||||
}
|
||||
|
||||
@ -104,14 +104,21 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
|
||||
af->data->bps != ((af_data_t*)arg)->bps)
|
||||
return AF_FALSE;
|
||||
return AF_OK;
|
||||
case AF_CONTROL_COMMAND_LINE:{
|
||||
double vol[6]={-10.0,-10.0,-10.0,-10.0,-10.0,-10.0};
|
||||
sscanf((char*)arg,"%lf:%lf:%lf:%lf:%lf:%lf:%i:%i:%i",
|
||||
&vol[0], &vol[1], &vol[2], &vol[3], &vol[4], &vol[5],
|
||||
&(s->softclip), &(s->probe), &(s->onoff));
|
||||
return from_dB(vol,s->volume,20.0);
|
||||
}
|
||||
case AF_CONTROL_VOLUME_SET:
|
||||
return from_dB((double*)arg,s->volume);
|
||||
return from_dB((double*)arg,s->volume,20.0);
|
||||
case AF_CONTROL_VOLUME_GET:
|
||||
return to_dB(s->volume,(double*)arg);
|
||||
return to_dB(s->volume,(double*)arg,20.0);
|
||||
case AF_CONTROL_VOLUME_PROBE_GET:
|
||||
return to_dB(s->power,(double*)arg);
|
||||
return to_dB(s->power,(double*)arg,10.0);
|
||||
case AF_CONTROL_VOLUME_PROBE_GET_MAX:
|
||||
return to_dB(s->maxpower,(double*)arg);
|
||||
return to_dB(s->maxpower,(double*)arg,10.0);
|
||||
case AF_CONTROL_VOLUME_SOFTCLIP:
|
||||
s->softclip = (int)arg;
|
||||
return AF_OK;
|
||||
@ -203,10 +210,13 @@ static int open(af_instance_t* af){
|
||||
af->setup=calloc(1,sizeof(af_volume_t));
|
||||
if(af->data == NULL || af->setup == NULL)
|
||||
return AF_ERROR;
|
||||
// Enable volume control and set initial volume to 0.1
|
||||
/* Enable volume control and set initial volume to 0.1 this is a
|
||||
safety mesure to ensure that the user doesn't blow his
|
||||
speakers. If the user isn't happy with this he can use the
|
||||
commandline parameters to set the initial volume */
|
||||
((af_volume_t*)af->setup)->onoff = 1;
|
||||
for(i=0;i<NCH;i++)
|
||||
((af_volume_t*)af->setup)->volume[i]=1.0; //0.1;
|
||||
((af_volume_t*)af->setup)->volume[i]=0.1;
|
||||
|
||||
return AF_OK;
|
||||
}
|
||||
|
@ -29,12 +29,17 @@
|
||||
|
||||
/* Called just after creation with the af_cfg for the stream in which
|
||||
the filter resides as input parameter this call can be used by the
|
||||
filter to initialize itself using commandline parameters */
|
||||
filter to initialize itself */
|
||||
#define AF_CONTROL_POST_CREATE 1 + AF_CONTROL_OPTIONAL_BASE
|
||||
|
||||
// Called just before destruction of a filter
|
||||
#define AF_CONTROL_PRE_DESTROY 2 + AF_CONTROL_OPTIONAL_BASE
|
||||
|
||||
/* Commandline parameters. If there were any commandline parameters
|
||||
for this specific filter, they will be given as a char* in the
|
||||
argument */
|
||||
#define AF_CONTROL_COMMAND_LINE 3 + AF_CONTROL_OPTIONAL_BASE
|
||||
|
||||
|
||||
// FILTER SPECIFIC CALLS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user