Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2019-02-13 03:33:26 +0300
committerJean-Marc Valin <jmvalin@jmvalin.ca>2019-02-13 21:51:08 +0300
commit843121b356685ff5a8c40211951f392f77f689cc (patch)
treef8896b370ce4e45f01ca4ca4b50b065a464b7888 /src/opus_encoder.c
parent0619d0848520ce2cd45ec3c9fc3a2c9743b4608e (diff)
Fixes analysis buffering for silence and complexity changes
The previous code would go out of sync in those cases.
Diffstat (limited to 'src/opus_encoder.c')
-rw-r--r--src/opus_encoder.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/opus_encoder.c b/src/opus_encoder.c
index cbeb40ae..ab08bff8 100644
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -837,7 +837,7 @@ static opus_int32 compute_equiv_rate(opus_int32 bitrate, int channels,
#ifndef DISABLE_FLOAT_API
-static int is_digital_silence(const opus_val16* pcm, int frame_size, int channels, int lsb_depth)
+int is_digital_silence(const opus_val16* pcm, int frame_size, int channels, int lsb_depth)
{
int silence = 0;
opus_val32 sample_max = 0;
@@ -1140,21 +1140,19 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
if (st->silk_mode.complexity >= 7 && st->Fs>=16000)
#endif
{
- if (is_digital_silence(pcm, frame_size, st->channels, lsb_depth))
- {
- is_silence = 1;
- } else {
- analysis_read_pos_bak = st->analysis.read_pos;
- analysis_read_subframe_bak = st->analysis.read_subframe;
- run_analysis(&st->analysis, celt_mode, analysis_pcm, analysis_size, frame_size,
- c1, c2, analysis_channels, st->Fs,
- lsb_depth, downmix, &analysis_info);
- }
+ is_silence = is_digital_silence(pcm, frame_size, st->channels, lsb_depth);
+ analysis_read_pos_bak = st->analysis.read_pos;
+ analysis_read_subframe_bak = st->analysis.read_subframe;
+ run_analysis(&st->analysis, celt_mode, analysis_pcm, analysis_size, frame_size,
+ c1, c2, analysis_channels, st->Fs,
+ lsb_depth, downmix, &analysis_info);
/* Track the peak signal energy */
if (!is_silence && analysis_info.activity_probability > DTX_ACTIVITY_THRESHOLD)
st->peak_signal_energy = MAX32(MULT16_32_Q15(QCONST16(0.999f, 15), st->peak_signal_energy),
compute_frame_energy(pcm, frame_size, st->channels, st->arch));
+ } else if (st->analysis.initialized) {
+ tonality_analysis_reset(&st->analysis);
}
#else
(void)analysis_pcm;