Mercurial > mplayer.hg
comparison libao2/pl_volnorm.c @ 4943:511e8d8117e9
proper bsd fix & preventive fix for other archs w/o INT_MAX
(INT_MAX is 0x7fffffff in the freebsd headers I have)
author | pl |
---|---|
date | Tue, 05 Mar 2002 20:15:25 +0000 |
parents | acdff5b36ea9 |
children | 6d8971d55e40 |
comparison
equal
deleted
inserted
replaced
4942:acdff5b36ea9 | 4943:511e8d8117e9 |
---|---|
21 #include "audio_out.h" | 21 #include "audio_out.h" |
22 #include "audio_plugin.h" | 22 #include "audio_plugin.h" |
23 #include "audio_plugin_internal.h" | 23 #include "audio_plugin_internal.h" |
24 #include "afmt.h" | 24 #include "afmt.h" |
25 | 25 |
26 #ifdef __FreeBSD__ | |
27 #include "machine/limits.h" | |
28 #define INT16_MAX INT_MAX | |
29 #define INT16_MIN INT_MIN | |
30 #endif | |
31 | |
32 static ao_info_t info = { | 26 static ao_info_t info = { |
33 "Volume normalizer", | 27 "Volume normalizer", |
34 "volnorm", | 28 "volnorm", |
35 "pl <p_l@gmx.fr>", | 29 "pl <p_l@gmx.fr>", |
36 "" | 30 "" |
51 // SMOOTH_* must be in ]0.0, 1.0[ | 45 // SMOOTH_* must be in ]0.0, 1.0[ |
52 // The new value accounts for SMOOTH_MUL in the value and history | 46 // The new value accounts for SMOOTH_MUL in the value and history |
53 #define SMOOTH_MUL 0.06 | 47 #define SMOOTH_MUL 0.06 |
54 #define SMOOTH_LASTAVG 0.06 | 48 #define SMOOTH_LASTAVG 0.06 |
55 | 49 |
50 // Some limits | |
51 #define MIN_S16 -32768 | |
52 #define MAX_S16 32767 | |
53 | |
56 // ideal average level | 54 // ideal average level |
57 #define MID_S16 (INT16_MAX * 0.25) | 55 #define MID_S16 (MAX_S16 * 0.25) |
58 | 56 |
59 // silence level | 57 // silence level |
60 #define SIL_S16 (INT16_MAX * 0.02) | 58 #define SIL_S16 (MAX_S16 * 0.02) |
61 | 59 |
62 // local data | 60 // local data |
63 static struct { | 61 static struct { |
64 int inuse; // This plugin is in use TRUE, FALSE | 62 int inuse; // This plugin is in use TRUE, FALSE |
65 int format; // sample fomat | 63 int format; // sample fomat |
149 } | 147 } |
150 | 148 |
151 // Scale & clamp the samples | 149 // Scale & clamp the samples |
152 for (i=0; i < len ; ++i) { | 150 for (i=0; i < len ; ++i) { |
153 tmp = data[i] * mul; | 151 tmp = data[i] * mul; |
154 CLAMP(tmp, INT16_MIN, INT16_MAX); | 152 CLAMP(tmp, MIN_S16, MAX_S16); |
155 data[i] = tmp; | 153 data[i] = tmp; |
156 } | 154 } |
157 | 155 |
158 // Evaluation of newavg (not 100% accurate because of values clamping) | 156 // Evaluation of newavg (not 100% accurate because of values clamping) |
159 newavg = mul * curavg; | 157 newavg = mul * curavg; |