aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGanesh Ajjanagadde <gajjanagadde@gmail.com>2015-12-21 17:12:04 -0800
committerGanesh Ajjanagadde <gajjanagadde@gmail.com>2015-12-23 09:22:59 -0800
commit520a5d33f0ea9f8838dbc7282470db700d248065 (patch)
tree4602726be342894896dbbe5af366ba3c05185ef0
parenta0ec4aebabe1f816cc69e20309981907ba5d1395 (diff)
downloadffmpeg-520a5d33f0ea9f8838dbc7282470db700d248065.tar.gz
lavfi/af_aemphasis: remove unnecessary complex number usage
complex is not available on all platforms. Furthermore, it is trivial to rewrite complex number expressions to real arithmetic, and in fact sometimes advantageous for performance reasons: by wrapping as a complex, one forces a particular Cartesian representation that is not necessarily optimal for the purpose. Configure dependencies also removed, and aemphasis is now available across all platforms. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
-rwxr-xr-xconfigure1
-rw-r--r--libavfilter/af_aemphasis.c13
2 files changed, 6 insertions, 8 deletions
diff --git a/configure b/configure
index 54c97897b2..5de470c583 100755
--- a/configure
+++ b/configure
@@ -2836,7 +2836,6 @@ unix_protocol_deps="sys_un_h"
unix_protocol_select="network"
# filters
-aemphasis_filter_deps="cabs cexp"
amovie_filter_deps="avcodec avformat"
aresample_filter_deps="swresample"
ass_filter_deps="libass"
diff --git a/libavfilter/af_aemphasis.c b/libavfilter/af_aemphasis.c
index 2966f7721f..a5b8e3058a 100644
--- a/libavfilter/af_aemphasis.c
+++ b/libavfilter/af_aemphasis.c
@@ -18,8 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <complex.h>
-
#include "libavutil/opt.h"
#include "avfilter.h"
#include "internal.h"
@@ -189,14 +187,15 @@ static inline void set_lp_rbj(BiquadD2 *bq, double fc, double q, double sr, doub
static double freq_gain(BiquadCoeffs *c, double freq, double sr)
{
- double complex z, w;
+ double zr, zi;
freq *= 2.0 * M_PI / sr;
- w = 0 + I * freq;
- z = 1.0 / cexp(w);
+ zr = cos(freq);
+ zi = -sin(freq);
- return cabs(((double complex)c->a0 + c->a1 * z + c->a2 * z*z) /
- ((double complex)1.0 + c->b1 * z + c->b2 * z*z));
+ /* |(a0 + a1*z + a2*z^2)/(1 + b1*z + b2*z^2)| */
+ return hypot(c->a0 + c->a1*zr + c->a2*(zr*zr-zi*zi), c->a1*zi + 2*c->a2*zr*zi) /
+ hypot(1 + c->b1*zr + c->b2*(zr*zr-zi*zi), c->b1*zi + 2*c->b2*zr*zi);
}
static int config_input(AVFilterLink *inlink)