[xiph-commits] r12957 - in trunk/speex: include/speex libspeex
jm at svn.xiph.org
jm at svn.xiph.org
Thu May 17 07:15:00 PDT 2007
Author: jm
Date: 2007-05-17 07:14:59 -0700 (Thu, 17 May 2007)
New Revision: 12957
Modified:
trunk/speex/include/speex/speex.h
trunk/speex/libspeex/nb_celp.c
trunk/speex/libspeex/nb_celp.h
trunk/speex/libspeex/sb_celp.c
Log:
Implemented SPEEX_GET_ACTIVITY
Modified: trunk/speex/include/speex/speex.h
===================================================================
--- trunk/speex/include/speex/speex.h 2007-05-16 17:32:29 UTC (rev 12956)
+++ trunk/speex/include/speex/speex.h 2007-05-17 14:14:59 UTC (rev 12957)
@@ -155,7 +155,11 @@
/** Get status of input/output high-pass filtering */
#define SPEEX_GET_HIGHPASS 45
+/** Get "activity level" of the last decoded frame, i.e.
+ now much damage we cause if we remove the frame */
+#define SPEEX_GET_ACTIVITY 47
+
/* Preserving compatibility:*/
/** Equivalent to SPEEX_SET_ENH */
#define SPEEX_SET_PF 0
Modified: trunk/speex/libspeex/nb_celp.c
===================================================================
--- trunk/speex/libspeex/nb_celp.c 2007-05-16 17:32:29 UTC (rev 12956)
+++ trunk/speex/libspeex/nb_celp.c 2007-05-17 14:14:59 UTC (rev 12957)
@@ -1720,6 +1720,14 @@
/*for (i=0;i<st->frameSize;i++)
printf ("%d\n", (int)st->frame[i]);*/
+ /* Tracking output level */
+ st->level = 1+PSHR32(ol_gain,SIG_SHIFT);
+ st->max_level = MAX16(MULT16_16_Q15(QCONST16(.99f,15), st->max_level), st->level);
+ st->min_level = MIN16(ADD16(1,MULT16_16_Q14(QCONST16(1.01f,14), st->min_level)), st->level);
+ if (st->max_level < st->min_level+1)
+ st->max_level = st->min_level+1;
+ /*printf ("%f %f %f %d\n", og, st->min_level, st->max_level, update);*/
+
/* Store the LSPs for interpolation in the next frame */
for (i=0;i<st->lpcSize;i++)
st->old_qlsp[i] = qlsp[i];
@@ -2013,7 +2021,19 @@
case SPEEX_GET_HIGHPASS:
(*(spx_int32_t*)ptr) = st->highpass_enabled;
break;
-
+ case SPEEX_GET_ACTIVITY:
+ {
+ float ret;
+ ret = log(st->level/st->min_level)/log(st->max_level/st->min_level);
+ if (ret>1)
+ ret = 1;
+ /* Done in a strange way to catch NaNs as well */
+ if (!(ret > 0))
+ ret = 0;
+ /*printf ("%f %f %f %f\n", st->level, st->min_level, st->max_level, ret);*/
+ (*(spx_int32_t*)ptr) = (int)(100*ret);
+ }
+ break;
case SPEEX_GET_PI_GAIN:
{
int i;
Modified: trunk/speex/libspeex/nb_celp.h
===================================================================
--- trunk/speex/libspeex/nb_celp.h 2007-05-16 17:32:29 UTC (rev 12956)
+++ trunk/speex/libspeex/nb_celp.h 2007-05-17 14:14:59 UTC (rev 12957)
@@ -148,8 +148,12 @@
spx_mem_t *mem_sp; /**< Filter memory for synthesis signal */
spx_mem_t mem_hp[2]; /**< High-pass filter memory */
spx_word32_t *pi_gain; /**< Gain of LPC filter at theta=pi (fe/2) */
- spx_word16_t *innov_save; /** If non-NULL, innovation is copied here */
+ spx_word16_t *innov_save; /** If non-NULL, innovation is copied here */
+ spx_word16_t level;
+ spx_word16_t max_level;
+ spx_word16_t min_level;
+
/* This is used in packet loss concealment */
int last_pitch; /**< Pitch of last correctly decoded frame */
spx_word16_t last_pitch_gain; /**< Pitch gain of last correctly decoded frame */
Modified: trunk/speex/libspeex/sb_celp.c
===================================================================
--- trunk/speex/libspeex/sb_celp.c 2007-05-16 17:32:29 UTC (rev 12956)
+++ trunk/speex/libspeex/sb_celp.c 2007-05-17 14:14:59 UTC (rev 12957)
@@ -1441,7 +1441,9 @@
case SPEEX_GET_HIGHPASS:
speex_decoder_ctl(st->st_low, SPEEX_GET_HIGHPASS, ptr);
break;
-
+ case SPEEX_GET_ACTIVITY:
+ speex_decoder_ctl(st->st_low, SPEEX_GET_ACTIVITY, ptr);
+ break;
case SPEEX_GET_PI_GAIN:
{
int i;
More information about the commits
mailing list