1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-08 07:08:12 +00:00

Rename af_volnorm to af_drc

The previous name of this filter was misleading, because it doesn’t actually
normalize volume levels. What it does is closer to performing low-quality
dynamic range compression, hence it is now called af_drc.
This commit is contained in:
Martin 2013-02-12 09:53:33 +01:00
parent f7636474eb
commit 1f7decc1a0
4 changed files with 27 additions and 23 deletions

View File

@ -428,8 +428,9 @@ extrastereo[=mul]
(average of both channels), with 1.0 sound will be unchanged, with
-1.0 left and right channels will be swapped.
volnorm[=method:target]
Maximizes the volume without distorting the sound.
drc[=method:target]
Applies dynamic range compression. This maximizes the volume by compressing
the audio signal's dynamic range.
<method>
Sets the used method.
@ -445,6 +446,9 @@ volnorm[=method:target]
Sets the target amplitude as a fraction of the maximum for the sample
type (default: 0.25).
*NOTE*: This filter can cause distortion with audio signals that have a
very large dynamic range.
ladspa=file:label[:controls...]
Load a LADSPA (Linux Audio Developer's Simple Plugin API) plugin. This
filter is reentrant, so multiple LADSPA plugins can be used at once.

View File

@ -143,7 +143,7 @@ SOURCES = talloc.c \
audio/filter/af_surround.c \
audio/filter/af_sweep.c \
audio/filter/af_tools.c \
audio/filter/af_volnorm.c \
audio/filter/af_drc.c \
audio/filter/af_volume.c \
audio/filter/filter.c \
audio/filter/window.c \

View File

@ -35,7 +35,7 @@ extern struct af_info af_info_pan;
extern struct af_info af_info_surround;
extern struct af_info af_info_sub;
extern struct af_info af_info_export;
extern struct af_info af_info_volnorm;
extern struct af_info af_info_drc;
extern struct af_info af_info_extrastereo;
extern struct af_info af_info_lavcac3enc;
extern struct af_info af_info_lavcresample;
@ -62,7 +62,7 @@ static struct af_info* filter_list[]={
#ifdef HAVE_SYS_MMAN_H
&af_info_export,
#endif
&af_info_volnorm,
&af_info_drc,
&af_info_extrastereo,
&af_info_lavcac3enc,
&af_info_lavcresample,

View File

@ -75,12 +75,12 @@ typedef struct af_volume_s
// "Ideal" level
float mid_s16;
float mid_float;
}af_volnorm_t;
}af_drc_t;
// Initialization and runtime control
static int control(struct af_instance* af, int cmd, void* arg)
{
af_volnorm_t* s = (af_volnorm_t*)af->setup;
af_drc_t* s = (af_drc_t*)af->setup;
switch(cmd){
case AF_CONTROL_REINIT:
@ -120,7 +120,7 @@ static void uninit(struct af_instance* af)
free(af->setup);
}
static void method1_int16(af_volnorm_t *s, struct mp_audio *c)
static void method1_int16(af_drc_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, struct mp_audio *c)
s->lastavg = (1.0 - SMOOTH_LASTAVG) * s->lastavg + SMOOTH_LASTAVG * newavg;
}
static void method1_float(af_volnorm_t *s, struct mp_audio *c)
static void method1_float(af_drc_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, struct mp_audio *c)
s->lastavg = (1.0 - SMOOTH_LASTAVG) * s->lastavg + SMOOTH_LASTAVG * newavg;
}
static void method2_int16(af_volnorm_t *s, struct mp_audio *c)
static void method2_int16(af_drc_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, struct mp_audio *c)
s->idx = (s->idx + 1) % NSAMPLES;
}
static void method2_float(af_volnorm_t *s, struct mp_audio *c)
static void method2_float(af_drc_t *s, struct mp_audio *c)
{
register int i = 0;
float *data = (float*)c->audio; // Audio data
@ -298,7 +298,7 @@ static void method2_float(af_volnorm_t *s, struct mp_audio *c)
// Filter data through filter
static struct mp_audio* play(struct af_instance* af, struct mp_audio* data)
{
af_volnorm_t *s = af->setup;
af_drc_t *s = af->setup;
if(af->data->format == (AF_FORMAT_S16_NE))
{
@ -325,27 +325,27 @@ static int af_open(struct af_instance* af){
af->play=play;
af->mul=1;
af->data=calloc(1,sizeof(struct mp_audio));
af->setup=calloc(1,sizeof(af_volnorm_t));
af->setup=calloc(1,sizeof(af_drc_t));
if(af->data == NULL || af->setup == NULL)
return AF_ERROR;
((af_volnorm_t*)af->setup)->mul = MUL_INIT;
((af_volnorm_t*)af->setup)->lastavg = ((float)SHRT_MAX) * DEFAULT_TARGET;
((af_volnorm_t*)af->setup)->idx = 0;
((af_volnorm_t*)af->setup)->mid_s16 = ((float)SHRT_MAX) * DEFAULT_TARGET;
((af_volnorm_t*)af->setup)->mid_float = DEFAULT_TARGET;
((af_drc_t*)af->setup)->mul = MUL_INIT;
((af_drc_t*)af->setup)->lastavg = ((float)SHRT_MAX) * DEFAULT_TARGET;
((af_drc_t*)af->setup)->idx = 0;
((af_drc_t*)af->setup)->mid_s16 = ((float)SHRT_MAX) * DEFAULT_TARGET;
((af_drc_t*)af->setup)->mid_float = DEFAULT_TARGET;
for (i = 0; i < NSAMPLES; i++)
{
((af_volnorm_t*)af->setup)->mem[i].len = 0;
((af_volnorm_t*)af->setup)->mem[i].avg = 0;
((af_drc_t*)af->setup)->mem[i].len = 0;
((af_drc_t*)af->setup)->mem[i].avg = 0;
}
return AF_OK;
}
// Description of this filter
struct af_info af_info_volnorm = {
"Volume normalizer filter",
"volnorm",
struct af_info af_info_drc = {
"Dynamic range compression filter",
"drc",
"Alex Beregszaszi & Pierre Lombard",
"",
AF_FLAGS_NOT_REENTRANT,