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>2012-11-13 11:24:07 +0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2012-11-20 01:52:49 +0400
commitc4203215651b2051b7ccfa3904478dbeb9d11150 (patch)
tree6323264dec537f35cc90b6fc22e2af3686603c2f
parent413caa00c5e2e90d405662335f88bbcdac64a8cc (diff)
Moves analysis to the beginning of opus_encode()
-rw-r--r--src/analysis.c18
-rw-r--r--src/analysis.h1
-rw-r--r--src/opus_encoder.c41
3 files changed, 31 insertions, 29 deletions
diff --git a/src/analysis.c b/src/analysis.c
index b3be892a..188764c1 100644
--- a/src/analysis.c
+++ b/src/analysis.c
@@ -180,19 +180,21 @@ void tonality_analysis(TonalityAnalysisState *tonal, AnalysisInfo *info, CELTEnc
for (i=0;i<N2;i++)
{
float w = analysis_window[i];
- in[i].r = MULT16_16(w, x[i]);
- in[i].i = MULT16_16(w, x[N-N2+i]);
- in[N-i-1].r = MULT16_16(w, x[N-i-1]);
- in[N-i-1].i = MULT16_16(w, x[2*N-N2-i-1]);
+ in[i].r = MULT16_16(w, tonal->inmem[i]);
+ in[i].i = MULT16_16(w, x[i]);
+ in[N-i-1].r = MULT16_16(w, x[N2-i-1]);
+ in[N-i-1].i = MULT16_16(w, x[N-i-1]);
+ tonal->inmem[i] = x[N2+i];
}
} else {
for (i=0;i<N2;i++)
{
float w = analysis_window[i];
- in[i].r = MULT16_16(w, x[2*i]+x[2*i+1]);
- in[i].i = MULT16_16(w, x[2*(N-N2+i)]+x[2*(N-N2+i)+1]);
- in[N-i-1].r = MULT16_16(w, x[2*(N-i-1)]+x[2*(N-i-1)+1]);
- in[N-i-1].i = MULT16_16(w, x[2*(2*N-N2-i-1)]+x[2*(2*N-N2-i-1)+1]);
+ in[i].r = MULT16_16(w, tonal->inmem[i]);
+ in[i].i = MULT16_16(w, x[2*i]+x[2*i+1]);
+ in[N-i-1].r = MULT16_16(w, x[2*(N2-i-1)]+x[2*(N2-i-1)+1]);
+ in[N-i-1].i = MULT16_16(w, x[2*(N-i-1)]+x[2*(N-i-1)+1]);
+ tonal->inmem[i] = x[2*(N2+i)]+x[2*(N2+i)+1];
}
}
opus_fft(kfft, in, out);
diff --git a/src/analysis.h b/src/analysis.h
index 09d1036a..0e6f774e 100644
--- a/src/analysis.h
+++ b/src/analysis.h
@@ -36,6 +36,7 @@ typedef struct {
float angle[240];
float d_angle[240];
float d2_angle[240];
+ float inmem[240];
float prev_band_tonality[NB_TBANDS];
float prev_tonality;
float E[NB_FRAMES][NB_TBANDS];
diff --git a/src/opus_encoder.c b/src/opus_encoder.c
index 6c491b59..a26b047a 100644
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -594,18 +594,30 @@ opus_int32 opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_s
celt_enc = (CELTEncoder*)((char*)st+st->celt_enc_offset);
#ifndef FIXED_POINT
- perform_analysis = st->silk_mode.complexity >= 7 && frame_size >= st->Fs/100 && st->Fs==48000;
+ /* Only perform analysis for 10- and 20-ms frames. We don't have enough buffering for shorter
+ ones and longer ones will be split if they're in CELT-only mode. */
+ perform_analysis = st->silk_mode.complexity >= 7
+ && (frame_size >= st->Fs/100 || frame_size >= st->Fs/50)
+ && st->Fs==48000;
+ if (perform_analysis)
+ {
+ int nb_analysis_frames;
+ nb_analysis_frames = frame_size/(st->Fs/100);
+ for (i=0;i<nb_analysis_frames;i++)
+ tonality_analysis(&st->analysis, &analysis_info, celt_enc, pcm+i*(st->Fs/100)*st->channels, st->channels);
+ if (st->signal_type == OPUS_AUTO)
+ st->voice_ratio = (int)floor(.5+100*(1-analysis_info.music_prob));
+ } else {
+ analysis_info.valid = 0;
+ st->voice_ratio = -1;
+ }
#endif
+
if (st->application == OPUS_APPLICATION_RESTRICTED_LOWDELAY)
delay_compensation = 0;
else
delay_compensation = st->delay_compensation;
- if (perform_analysis)
- {
- total_buffer = IMAX(st->Fs/200, delay_compensation);
- } else {
- total_buffer = delay_compensation;
- }
+ total_buffer = delay_compensation;
extra_buffer = total_buffer-delay_compensation;
st->bitrate_bps = user_bitrate_to_bitrate(st, frame_size, max_data_bytes);
@@ -970,20 +982,7 @@ opus_int32 opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_s
dc_reject(pcm, 3, &pcm_buf[total_buffer*st->channels], st->hp_mem, frame_size, st->channels, st->Fs);
}
-#ifndef FIXED_POINT
- if (perform_analysis)
- {
- int nb_analysis_frames;
- nb_analysis_frames = frame_size/(st->Fs/100);
- for (i=0;i<nb_analysis_frames;i++)
- tonality_analysis(&st->analysis, &analysis_info, celt_enc, pcm_buf+i*(st->Fs/100)*st->channels, st->channels);
- if (st->signal_type == OPUS_AUTO)
- st->voice_ratio = (int)floor(.5+100*(1-analysis_info.music_prob));
- } else {
- analysis_info.valid = 0;
- st->voice_ratio = -1;
- }
-#endif
+
/* SILK processing */
HB_gain = Q15ONE;