From 75caa597a37bf419cd104c6eac61c295b69355fb Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Thu, 26 Jul 2018 15:07:33 +0200 Subject: [PATCH] Untangle fft third party lib from dependon WebRTC TBR=phoglund Bug: webrtc:9558 Change-Id: I6cc1936549f008694c3617c1d990524c34da16e3 Reviewed-on: https://webrtc-review.googlesource.com/90411 Commit-Queue: Artem Titov Reviewed-by: Mirko Bonadei Reviewed-by: Oskar Sundbom Cr-Commit-Position: refs/heads/master@{#24115} --- modules/audio_coding/BUILD.gn | 4 +++- .../codecs/isac/fix/source/transform.c | 1 + .../codecs/isac/main/source/codec.h | 1 + .../codecs/isac/main/source/settings.h | 3 --- .../codecs/isac/main/source/structs.h | 13 +----------- modules/third_party/fft/BUILD.gn | 4 ---- modules/third_party/fft/README.chromium | 2 +- modules/third_party/fft/fft.c | 2 +- modules/third_party/fft/fft.h | 21 +++++++++++++++---- 9 files changed, 25 insertions(+), 26 deletions(-) diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn index 5dc93d36e3..41bd7a9420 100644 --- a/modules/audio_coding/BUILD.gn +++ b/modules/audio_coding/BUILD.gn @@ -498,6 +498,7 @@ rtc_source_set("isac_vad") { "../../rtc_base:compile_assert_c", "../../rtc_base/system:arch", "../../rtc_base/system:ignore_warnings", + "../third_party/fft", ] } @@ -559,7 +560,7 @@ rtc_static_library("isac_c") { "../../rtc_base:compile_assert_c", "../../rtc_base:rtc_base_approved", "../../rtc_base/system:arch", - "../third_party/fft:fft", + "../third_party/fft", ] } @@ -676,6 +677,7 @@ rtc_source_set("isac_fix_c") { "../../rtc_base:rtc_base_approved", "../../rtc_base:sanitizer", "../../system_wrappers:cpu_features_api", + "../third_party/fft", ] public_deps = [ diff --git a/modules/audio_coding/codecs/isac/fix/source/transform.c b/modules/audio_coding/codecs/isac/fix/source/transform.c index 2f1275da5c..80b244b5f1 100644 --- a/modules/audio_coding/codecs/isac/fix/source/transform.c +++ b/modules/audio_coding/codecs/isac/fix/source/transform.c @@ -18,6 +18,7 @@ #include "modules/audio_coding/codecs/isac/fix/source/codec.h" #include "modules/audio_coding/codecs/isac/fix/source/fft.h" #include "modules/audio_coding/codecs/isac/fix/source/settings.h" +#include "modules/third_party/fft/fft.h" /* Tables are defined in transform_tables.c file or ARM assembly files. */ /* Cosine table 1 in Q14 */ diff --git a/modules/audio_coding/codecs/isac/main/source/codec.h b/modules/audio_coding/codecs/isac/main/source/codec.h index c3867047c5..a7c7ddc14a 100644 --- a/modules/audio_coding/codecs/isac/main/source/codec.h +++ b/modules/audio_coding/codecs/isac/main/source/codec.h @@ -22,6 +22,7 @@ #include #include "modules/audio_coding/codecs/isac/main/source/structs.h" +#include "modules/third_party/fft/fft.h" void WebRtcIsac_ResetBitstream(Bitstr* bit_stream); diff --git a/modules/audio_coding/codecs/isac/main/source/settings.h b/modules/audio_coding/codecs/isac/main/source/settings.h index 14a5be812c..abce90c4f5 100644 --- a/modules/audio_coding/codecs/isac/main/source/settings.h +++ b/modules/audio_coding/codecs/isac/main/source/settings.h @@ -24,9 +24,6 @@ /* number of samples per frame (either 320 (20ms), 480 (30ms) or 960 (60ms)) */ #define INITIAL_FRAMESAMPLES 960 -#define MAXFFTSIZE 2048 -#define NFACTOR 11 - /* do not modify the following; this will have to be modified if we * have a 20ms framesize option */ /**********************************************************************/ diff --git a/modules/audio_coding/codecs/isac/main/source/structs.h b/modules/audio_coding/codecs/isac/main/source/structs.h index 1d730c7e65..1255d5b16c 100644 --- a/modules/audio_coding/codecs/isac/main/source/structs.h +++ b/modules/audio_coding/codecs/isac/main/source/structs.h @@ -20,6 +20,7 @@ #include "modules/audio_coding/codecs/isac/bandwidth_info.h" #include "modules/audio_coding/codecs/isac/main/source/settings.h" +#include "modules/third_party/fft/fft.h" typedef struct Bitstreamstruct { uint8_t stream[STREAM_SIZE_MAX]; @@ -228,18 +229,6 @@ typedef struct { } RateModel; -typedef struct { - unsigned int SpaceAlloced; - unsigned int MaxPermAlloced; - double Tmp0[MAXFFTSIZE]; - double Tmp1[MAXFFTSIZE]; - double Tmp2[MAXFFTSIZE]; - double Tmp3[MAXFFTSIZE]; - int Perm[MAXFFTSIZE]; - int factor[NFACTOR]; - -} FFTstr; - /* The following strutc is used to store data from encoding, to make it fast and easy to construct a new bitstream with a different Bandwidth estimate. All values (except framelength and minBytes) is double size to diff --git a/modules/third_party/fft/BUILD.gn b/modules/third_party/fft/BUILD.gn index 1a8e79b8a3..dd362a0502 100644 --- a/modules/third_party/fft/BUILD.gn +++ b/modules/third_party/fft/BUILD.gn @@ -9,12 +9,8 @@ import("../../../webrtc.gni") rtc_source_set("fft") { - poisonous = [ "audio_codecs" ] sources = [ "fft.c", "fft.h", ] - deps = [ - "../../audio_coding:isac_vad", - ] } diff --git a/modules/third_party/fft/README.chromium b/modules/third_party/fft/README.chromium index a373b99552..94d20d422f 100644 --- a/modules/third_party/fft/README.chromium +++ b/modules/third_party/fft/README.chromium @@ -2,7 +2,7 @@ Name: fft Short Name: fft URL: Version: 0 -Date: 2018-02-01 +Date: 2018-07-26 License: Custom license License File: LICENSE Security Critical: yes diff --git a/modules/third_party/fft/fft.c b/modules/third_party/fft/fft.c index ffce99b020..72604626d9 100644 --- a/modules/third_party/fft/fft.c +++ b/modules/third_party/fft/fft.c @@ -415,7 +415,7 @@ static int FFTRADIX (REAL Re[], } /* test that mfactors is in range */ - if (mfactor > NFACTOR) + if (mfactor > FFT_NFACTOR) { return -1; } diff --git a/modules/third_party/fft/fft.h b/modules/third_party/fft/fft.h index 34e5f94542..6f997e4e4d 100644 --- a/modules/third_party/fft/fft.h +++ b/modules/third_party/fft/fft.h @@ -27,10 +27,23 @@ * See the comments in the code for correct usage! */ -#ifndef MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_FFT_H_ -#define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_FFT_H_ +#ifndef MODULES_THIRD_PARTY_FFT_FFT_H_ +#define MODULES_THIRD_PARTY_FFT_FFT_H_ -#include "modules/audio_coding/codecs/isac/main/source/structs.h" +#define FFT_MAXFFTSIZE 2048 +#define FFT_NFACTOR 11 + +typedef struct { + unsigned int SpaceAlloced; + unsigned int MaxPermAlloced; + double Tmp0[FFT_MAXFFTSIZE]; + double Tmp1[FFT_MAXFFTSIZE]; + double Tmp2[FFT_MAXFFTSIZE]; + double Tmp3[FFT_MAXFFTSIZE]; + int Perm[FFT_MAXFFTSIZE]; + int factor[FFT_NFACTOR]; + +} FFTstr; /* double precision routine */ @@ -42,4 +55,4 @@ int WebRtcIsac_Fftns(unsigned int ndim, double scaling, FFTstr* fftstate); -#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_FFT_H_ */ +#endif /* MODULES_THIRD_PARTY_FFT_FFT_H_ */