diff --git a/celt/celt_encoder.c b/celt/celt_encoder.c index 241fb3721e832b3d3c7c32bdbf3b109eca0f0011..59dcc5c61eabca745030b6fa89f3369b842912a5 100644 --- a/celt/celt_encoder.c +++ b/celt/celt_encoder.c @@ -1179,7 +1179,7 @@ static int compute_vbr(const CELTMode *mode, AnalysisInfo *analysis, opus_int32 tonal_target = target + (opus_int32)((coded_bins<<BITRES)*1.2f*tonal); if (pitch_change) tonal_target += (opus_int32)((coded_bins<<BITRES)*.8f); - /*printf("%f %f ", st->analysis.tonality, tonal);*/ + /*printf("%f %f ", analysis->tonality, tonal);*/ target = tonal_target; } #endif @@ -1543,7 +1543,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, opus_val32 mask_avg=0; opus_val32 diff=0; int count=0; - mask_end = st->lastCodedBands; + mask_end = IMAX(2,st->lastCodedBands); for (c=0;c<C;c++) { for(i=0;i<mask_end;i++) diff --git a/celt/mathops.h b/celt/mathops.h index 44fa97c69751570143fb11c4802827083706b653..7e7d906c0bbad70979723bdbdc986f4461c5a45b 100644 --- a/celt/mathops.h +++ b/celt/mathops.h @@ -165,6 +165,7 @@ opus_val32 celt_sqrt(opus_val32 x); opus_val16 celt_cos_norm(opus_val32 x); +/** Base-2 logarithm approximation (log2(x)). (Q14 input, Q10 output) */ static inline opus_val16 celt_log2(opus_val32 x) { int i; diff --git a/src/opus_multistream_encoder.c b/src/opus_multistream_encoder.c index 01ed30f53b88e193abc58949b302ea8daf428fdc..84f96763e887f05d09b78175e1e44da74cf05e49 100644 --- a/src/opus_multistream_encoder.c +++ b/src/opus_multistream_encoder.c @@ -227,6 +227,7 @@ void surround_analysis(const CELTMode *celt_mode, const void *pcm, opus_val16 *b int pos[8] = {0}; int upsample; int frame_size; + opus_val16 channel_offset; opus_val32 bandE[21]; opus_val16 maskLogE[3][21]; VARDECL(opus_val32, in); @@ -293,7 +294,6 @@ void surround_analysis(const CELTMode *celt_mode, const void *pcm, opus_val16 *b #if 0 for (i=0;i<21;i++) printf("%f ", bandLogE[21*c+i]); -//#else float sum=0; for (i=0;i<21;i++) sum += bandLogE[21*c+i]; @@ -303,9 +303,10 @@ void surround_analysis(const CELTMode *celt_mode, const void *pcm, opus_val16 *b } for (i=0;i<21;i++) maskLogE[1][i] = MIN32(maskLogE[0][i],maskLogE[2][i]); + channel_offset = HALF16(celt_log2(QCONST32(2.f,14)/(channels-1))); for (c=0;c<3;c++) for (i=0;i<21;i++) - maskLogE[c][i] += QCONST16(.5f, DB_SHIFT)*log2(2.f/(channels-1)); + maskLogE[c][i] += channel_offset; #if 0 for (c=0;c<3;c++) { @@ -334,7 +335,7 @@ void surround_analysis(const CELTMode *celt_mode, const void *pcm, opus_val16 *b float sum=0; for (i=0;i<21;i++) sum += bandLogE[21*c+i]; - printf("%f ", sum/21); + printf("%f ", sum/(float)QCONST32(21.f, DB_SHIFT)); printf("\n"); #endif }