diff options
author | Ralph Giles <giles@mozilla.com> | 2015-12-30 15:27:02 -0800 |
---|---|---|
committer | Ralph Giles <giles@mozilla.com> | 2015-12-31 00:43:27 -0800 |
commit | 9e3872a8161d657407c55b6a29882664d1a6320c (patch) | |
tree | 6117661754b737a69e83346355a07ed80c570b53 /src/analysis.c | |
parent | d43445f350ff4e4f36442590697f9ce9a366848a (diff) | |
download | libopus-9e3872a8161d657407c55b6a29882664d1a6320c.tar.gz |
Add tonality_analysis_reset().
Add a reset function for the TonalityAnalysisState struct
and call it on encoder reset.
Move the state struct above the clear line in OpusEncoder
so reset doesn't clobber reusable fields. Currently this
is only the arch field, which is moved to to top of the
struct so we can use the same memset-to-the-end pattern
as OpusEncoder.
Signed-off-by: Jean-Marc Valin <jmvalin@jmvalin.ca>
Diffstat (limited to 'src/analysis.c')
-rw-r--r-- | src/analysis.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/analysis.c b/src/analysis.c index f8187d03..360ebcc8 100644 --- a/src/analysis.c +++ b/src/analysis.c @@ -142,7 +142,15 @@ void tonality_analysis_init(TonalityAnalysisState *tonal) { /* Initialize reusable fields. */ tonal->arch = opus_select_arch(); - /* Other fields will be overwritten in use. */ + /* Clear remaining fields. */ + tonality_analysis_reset(tonal); +} + +void tonality_analysis_reset(TonalityAnalysisState *tonal) +{ + /* Clear non-reusable fields. */ + char *start = (char*)&tonal->TONALITY_ANALYSIS_RESET_START; + OPUS_CLEAR(start, sizeof(TonalityAnalysisState) - (start - (char*)tonal)); } void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int len) |