Showing the changes to libavfilter (2 of 2 files). Show all
Unified · Split
| @@ -26,6 +26,7 @@ · 25 unmodified lines | |||
| 26 | #undef FMIN | 26 | #undef FMIN |
| 27 | #undef CLIP | 27 | #undef CLIP |
| 28 | #undef SAMPLE_FORMAT | 28 | #undef SAMPLE_FORMAT |
| 29 | #undef EPSILON | ||
| 29 | #undef FABS | 30 | #undef FABS |
| 30 | #if DEPTH == 32 | 31 | #if DEPTH == 32 |
| 31 | #define SAMPLE_FORMAT float | 32 | #define SAMPLE_FORMAT float |
| @@ -39,6 +40,7 @@ · 7 unmodified lines | |||
| 39 | #define CLIP av_clipf | 40 | #define CLIP av_clipf |
| 40 | #define FABS fabsf | 41 | #define FABS fabsf |
| 41 | #define ftype float | 42 | #define ftype float |
| 43 | #define EPSILON (1.f / (1 << 22)) | ||
| 42 | #else | 44 | #else |
| 43 | #define SAMPLE_FORMAT double | 45 | #define SAMPLE_FORMAT double |
| 44 | #define SQRT sqrt | 46 | #define SQRT sqrt |
| @@ -51,6 +53,7 @@ · 6 unmodified lines | |||
| 51 | #define CLIP av_clipd | 53 | #define CLIP av_clipd |
| 52 | #define FABS fabs | 54 | #define FABS fabs |
| 53 | #define ftype double | 55 | #define ftype double |
| 56 | #define EPSILON (1.0 / (1LL << 51)) | ||
| 54 | #endif | 57 | #endif |
| 55 | 58 | ||
| 56 | #define fn3(a,b) a##_##b | 59 | #define fn3(a,b) a##_##b |
| @@ -147,9 +150,7 @@ static int fn(filter_channels)(AVFilterContext *ctx, void *arg, int jobnr, int n · 90 unmodified lines | |||
| 147 | const ftype range = s->range; | 150 | const ftype range = s->range; |
| 148 | const ftype tfrequency = FMIN(s->tfrequency, sample_rate * 0.5); | 151 | const ftype tfrequency = FMIN(s->tfrequency, sample_rate * 0.5); |
| 149 | const ftype release = s->release_coef; | 152 | const ftype release = s->release_coef; |
| 150 | const ftype irelease = ONE - release; | ||
| 151 | const ftype attack = s->attack_coef; | 153 | const ftype attack = s->attack_coef; |
| 152 | const ftype iattack = ONE - attack; | ||
| 153 | const ftype tqfactor = s->tqfactor; | 154 | const ftype tqfactor = s->tqfactor; |
| 154 | const ftype itqfactor = ONE / tqfactor; | 155 | const ftype itqfactor = ONE / tqfactor; |
| 155 | const ftype fg = TAN(M_PI * tfrequency / sample_rate); | 156 | const ftype fg = TAN(M_PI * tfrequency / sample_rate); |
| @@ -198,10 +199,13 @@ static int fn(filter_channels)(AVFilterContext *ctx, void *arg, int jobnr, int n · 42 unmodified lines | |||
| 198 | detect = ONE; | 199 | detect = ONE; |
| 199 | } | 200 | } |
| 200 | 201 | ||
| 201 | if ((direction == 0 && detect > state[4]) || (direction == 1 && detect < state[4])) { | 202 | { |
| 202 | detect = iattack * detect + attack * state[4]; | 203 | ftype delta = detect - state[4]; |
| 203 | } else { | 204 | |
| 204 | detect = irelease * detect + release * state[4]; | 205 | if (delta > EPSILON) |
| 206 | detect = state[4] + attack * delta; | ||
| 207 | else if (delta < -EPSILON) | ||
| 208 | detect = state[4] + release * delta; | ||
| 205 | } | 209 | } |
| 206 | } | 210 | } |
| 207 | 211 | ||
| @@ -76,7 +76,7 @@ static int query_formats(AVFilterContext *ctx) · 75 unmodified lines | |||
| 76 | 76 | ||
| 77 | static double get_coef(double x, double sr) | 77 | static double get_coef(double x, double sr) |
| 78 | { | 78 | { |
| 79 | return exp(-1000. / (x * sr)); | 79 | return 1.0 - exp(-1000. / (x * sr)); |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | typedef struct ThreadData { | 82 | typedef struct ThreadData { |