Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -385,45 +385,32 @@ static int read_channels(AVFilterContext *ctx, int channels, uint8_t *item_str, · 384 unmodified lines | |||
| 385 | return 0; | 385 | return 0; |
| 386 | } | 386 | } |
| 387 | 387 | ||
| 388 | static void multiply(double wre, double wim, int npz, double *coeffs) | 388 | static void cmul(double re, double im, double re2, double im2, double *RE, double *IM) |
| 389 | { | 389 | { |
| 390 | double nwre = -wre, nwim = -wim; | 390 | *RE = re * re2 - im * im2; |
| 391 | double cre, cim; | 391 | *IM = re * im2 + re2 * im; |
| 392 | int i; | ||
| 393 | |||
| 394 | for (i = npz; i >= 1; i--) { | ||
| 395 | cre = coeffs[2 * i + 0]; | ||
| 396 | cim = coeffs[2 * i + 1]; | ||
| 397 | |||
| 398 | coeffs[2 * i + 0] = (nwre * cre - nwim * cim) + coeffs[2 * (i - 1) + 0]; | ||
| 399 | coeffs[2 * i + 1] = (nwre * cim + nwim * cre) + coeffs[2 * (i - 1) + 1]; | ||
| 400 | } | ||
| 401 | |||
| 402 | cre = coeffs[0]; | ||
| 403 | cim = coeffs[1]; | ||
| 404 | coeffs[0] = nwre * cre - nwim * cim; | ||
| 405 | coeffs[1] = nwre * cim + nwim * cre; | ||
| 406 | } | 392 | } |
| 407 | 393 | ||
| 408 | static int expand(AVFilterContext *ctx, double *pz, int nb, double *coeffs) | 394 | static int expand(AVFilterContext *ctx, double *pz, int n, double *coefs) |
| 409 | { | 395 | { |
| 410 | int i; | 396 | coefs[2 * n] = 1.0; |
| 411 | 397 | ||
| 412 | coeffs[0] = 1.0; | 398 | for (int i = 1; i <= n; i++) { |
| 413 | coeffs[1] = 0.0; | 399 | for (int j = n - i; j < n; j++) { |
| 400 | double re, im; | ||
| 414 | 401 | ||
| 415 | for (i = 0; i < nb; i++) { | 402 | cmul(coefs[2 * (j + 1)], coefs[2 * (j + 1) + 1], |
| 416 | coeffs[2 * (i + 1) ] = 0.0; | 403 | pz[2 * (i - 1)], pz[2 * (i - 1) + 1], &re, &im); |
| 417 | coeffs[2 * (i + 1) + 1] = 0.0; | ||
| 418 | } | ||
| 419 | 404 | ||
| 420 | for (i = 0; i < nb; i++) | 405 | coefs[2 * j] -= re; |
| 421 | multiply(pz[2 * i], pz[2 * i + 1], nb, coeffs); | 406 | coefs[2 * j + 1] -= im; |
| 407 | } | ||
| 408 | } | ||
| 422 | 409 | ||
| 423 | for (i = 0; i < nb + 1; i++) { | 410 | for (int i = 0; i < n + 1; i++) { |
| 424 | if (fabs(coeffs[2 * i + 1]) > FLT_EPSILON) { | 411 | if (fabs(coefs[2 * i + 1]) > FLT_EPSILON) { |
| 425 | av_log(ctx, AV_LOG_ERROR, "coeff: %f of z^%d is not real; poles/zeros are not complex conjugates.\n", | 412 | av_log(ctx, AV_LOG_ERROR, "coefs: %f of z^%d is not real; poles/zeros are not complex conjugates.\n", |
| 426 | coeffs[2 * i + 1], i); | 413 | coefs[2 * i + 1], i); |
| 427 | return AVERROR(EINVAL); | 414 | return AVERROR(EINVAL); |
| 428 | } | 415 | } |
| 429 | } | 416 | } |