aboutsummaryrefslogtreecommitdiff
path: root/src/analysis.c
diff options
context:
space:
mode:
authorRalph Giles <giles@mozilla.com>2015-12-30 10:00:17 -0800
committerRalph Giles <giles@mozilla.com>2015-12-31 00:42:43 -0800
commitd43445f350ff4e4f36442590697f9ce9a366848a (patch)
tree817c24b93f796874fdadab914bad61bdd4c67447 /src/analysis.c
parentbd1fb513c136c76f46f7e42a68ea20ddc41a94b2 (diff)
downloadlibopus-d43445f350ff4e4f36442590697f9ce9a366848a.tar.gz
Add an initializer for TonalityAnalysisState.
This interns the asm flags parameter in the state struct so we don't need to pass it with every call. It can be expensive, so we don't want to query every run_analysis() call, but since this (private) api is used by webrtc code we need to provide a supportable interface for filling in the correct value. Note the initialization code is partially duplicated between opus_encoder_init and the OPUS_RESET_STATE switch case, so we must re-initialize it there. Signed-off-by: Jean-Marc Valin <jmvalin@jmvalin.ca>
Diffstat (limited to 'src/analysis.c')
-rw-r--r--src/analysis.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/analysis.c b/src/analysis.c
index 322e53c4..f8187d03 100644
--- a/src/analysis.c
+++ b/src/analysis.c
@@ -138,6 +138,13 @@ static OPUS_INLINE float fast_atan2f(float y, float x) {
}
}
+void tonality_analysis_init(TonalityAnalysisState *tonal)
+{
+ /* Initialize reusable fields. */
+ tonal->arch = opus_select_arch();
+ /* Other fields will be overwritten in use. */
+}
+
void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int len)
{
int pos;
@@ -187,7 +194,7 @@ void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int
info_out->music_prob = psum;
}
-static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt_mode, const void *x, int len, int offset, int c1, int c2, int C, int lsb_depth, downmix_func downmix, int arch)
+static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt_mode, const void *x, int len, int offset, int c1, int c2, int C, int lsb_depth, downmix_func downmix)
{
int i, b;
const kiss_fft_state *kfft;
@@ -260,7 +267,7 @@ static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt
remaining = len - (ANALYSIS_BUF_SIZE-tonal->mem_fill);
downmix(x, &tonal->inmem[240], remaining, offset+ANALYSIS_BUF_SIZE-tonal->mem_fill, c1, c2, C);
tonal->mem_fill = 240 + remaining;
- opus_fft(kfft, in, out, arch);
+ opus_fft(kfft, in, out, tonal->arch);
#ifndef FIXED_POINT
/* If there's any NaN on the input, the entire output will be NaN, so we only need to check one value. */
if (celt_isnan(out[0].r))
@@ -633,7 +640,7 @@ static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt
void run_analysis(TonalityAnalysisState *analysis, const CELTMode *celt_mode, const void *analysis_pcm,
int analysis_frame_size, int frame_size, int c1, int c2, int C, opus_int32 Fs,
- int lsb_depth, downmix_func downmix, AnalysisInfo *analysis_info, int arch)
+ int lsb_depth, downmix_func downmix, AnalysisInfo *analysis_info)
{
int offset;
int pcm_len;
@@ -646,7 +653,7 @@ void run_analysis(TonalityAnalysisState *analysis, const CELTMode *celt_mode, co
pcm_len = analysis_frame_size - analysis->analysis_offset;
offset = analysis->analysis_offset;
do {
- tonality_analysis(analysis, celt_mode, analysis_pcm, IMIN(480, pcm_len), offset, c1, c2, C, lsb_depth, downmix, arch);
+ tonality_analysis(analysis, celt_mode, analysis_pcm, IMIN(480, pcm_len), offset, c1, c2, C, lsb_depth, downmix);
offset += 480;
pcm_len -= 480;
} while (pcm_len>0);