summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2016-11-24 13:52:32 -0500
committerJean-Marc Valin <jmvalin@jmvalin.ca>2016-11-24 13:52:32 -0500
commitfebe46b6db9fca343ad5bfb49f9811df02f8b7f8 (patch)
treee476f767d328304a0f4f50436fb835016f677e50
parentc1619c25f99d341fe85bf965fca5859cc8651461 (diff)
downloadopus-exp_24k_analysis3.tar.gz
Adds support for running the analysis on 16 kHz inputexp_24k_analysis3
-rw-r--r--src/analysis.c5
-rw-r--r--src/opus_encoder.c40
2 files changed, 40 insertions, 5 deletions
diff --git a/src/analysis.c b/src/analysis.c
index 91a9cc84..48e3ec8a 100644
--- a/src/analysis.c
+++ b/src/analysis.c
@@ -180,7 +180,7 @@ void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int
for (;i<DETECT_SIZE;i++)
psum += tonal->pspeech[i];
psum = psum*tonal->music_confidence + (1-psum)*tonal->speech_confidence;
- /*printf("%f %f %f %f %f\n", psum, info_out->music_prob, info_out->vad_prob, info_out->activity_probability, info_out->tonality);*/
+ printf("%f %f %f %f %f\n", psum, info_out->music_prob, info_out->vad_prob, info_out->activity_probability, info_out->tonality);
info_out->music_prob = psum;
}
@@ -239,6 +239,9 @@ static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt
/* len and offset are now at 24 kHz. */
len/= 2;
offset /= 2;
+ } else if (tonal->Fs == 16000) {
+ len = 3*len/2;
+ offset = 3*offset/2;
}
if (tonal->count<4)
diff --git a/src/opus_encoder.c b/src/opus_encoder.c
index 79f80cda..ed487ae6 100644
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -640,6 +640,9 @@ opus_val32 downmix_float(const void *_x, opus_val32 *sub, opus_val32 S[3], int s
{
subframe *= 2;
offset *= 2;
+ } else if (Fs == 16000) {
+ subframe = subframe*2/3;
+ offset = offset*2/3;
}
ALLOC(tmp, subframe, opus_val32);
@@ -673,8 +676,21 @@ opus_val32 downmix_float(const void *_x, opus_val32 *sub, opus_val32 S[3], int s
if (Fs == 48000)
{
ret = silk_resampler_down2_hp(S, sub, tmp, subframe);
- } else /*if (Fs == 12000)*/ {
+ } else if (Fs == 24000) {
OPUS_COPY(sub, tmp, subframe);
+ } else if (Fs == 16000) {
+ VARDECL(opus_val32, tmp3x);
+ ALLOC(tmp3x, 3*subframe, opus_val32);
+ /* Don't do this at home! This resampler is horrible and it's only (barely)
+ usable for the purpose of the analysis because we don't care about all
+ the aliasing between 8 kHz and 12 kHz. */
+ for (j=0;j<subframe;j++)
+ {
+ tmp3x[3*j] = tmp[j];
+ tmp3x[3*j+1] = tmp[j];
+ tmp3x[3*j+2] = tmp[j];
+ }
+ silk_resampler_down2_hp(S, sub, tmp3x, 3*subframe);
}
RESTORE_STACK;
return ret;
@@ -695,6 +711,9 @@ opus_val32 downmix_int(const void *_x, opus_val32 *sub, opus_val32 S[3], int sub
{
subframe *= 2;
offset *= 2;
+ } else if (Fs == 16000) {
+ subframe = subframe*2/3;
+ offset = offset*2/3;
}
ALLOC(tmp, subframe, opus_val32);
@@ -728,8 +747,21 @@ opus_val32 downmix_int(const void *_x, opus_val32 *sub, opus_val32 S[3], int sub
if (Fs == 48000)
{
ret = silk_resampler_down2_hp(S, sub, tmp, subframe);
- } else /*if (Fs == 12000)*/ {
+ } else if (Fs == 24000) {
OPUS_COPY(sub, tmp, subframe);
+ } else if (Fs == 16000) {
+ VARDECL(opus_val32, tmp3x);
+ ALLOC(tmp3x, 3*subframe, opus_val32);
+ /* Don't do this at home! This resampler is horrible and it's only (barely)
+ usable for the purpose of the analysis because we don't care about all
+ the aliasing between 8 kHz and 12 kHz. */
+ for (j=0;j<subframe;j++)
+ {
+ tmp3x[3*j] = tmp[j];
+ tmp3x[3*j+1] = tmp[j];
+ tmp3x[3*j+2] = tmp[j];
+ }
+ silk_resampler_down2_hp(S, sub, tmp3x, 3*subframe);
}
RESTORE_STACK;
return ret;
@@ -1222,9 +1254,9 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
#ifndef DISABLE_FLOAT_API
analysis_info.valid = 0;
#ifdef FIXED_POINT
- if (st->silk_mode.complexity >= 10 && st->Fs>=24000)
+ if (st->silk_mode.complexity >= 10 && st->Fs>=16000)
#else
- if (st->silk_mode.complexity >= 7 && st->Fs>=24000)
+ if (st->silk_mode.complexity >= 7 && st->Fs>=16000)
#endif
{
if (is_digital_silence(pcm, frame_size, st->channels, lsb_depth))