[xiph-commits] r12290 - trunk/speex/libspeex
jm at svn.xiph.org
jm at svn.xiph.org
Tue Jan 2 05:37:39 PST 2007
Author: jm
Date: 2007-01-02 05:37:37 -0800 (Tue, 02 Jan 2007)
New Revision: 12290
Modified:
trunk/speex/libspeex/nb_celp.c
Log:
simplified the double_codebook code and improved accuracy slightly
Modified: trunk/speex/libspeex/nb_celp.c
===================================================================
--- trunk/speex/libspeex/nb_celp.c 2007-01-02 12:24:26 UTC (rev 12289)
+++ trunk/speex/libspeex/nb_celp.c 2007-01-02 13:37:37 UTC (rev 12290)
@@ -961,11 +961,6 @@
for (i=0;i<st->subframeSize;i++)
exc[i] = EXTRACT16(SATURATE32(PSHR32(ADD32(SHL32(exc32[i],1),innov[i]),SIG_SHIFT),32767));
- if (innov_save)
- {
- for (i=0;i<st->subframeSize;i++)
- innov_save[i] = EXTRACT16(PSHR32(innov[i],SIG_SHIFT));
- }
/* In some (rare) modes, we do a second search (more bits) to reduce noise even more */
if (SUBMODE(double_codebook)) {
char *tmp_stack=stack;
@@ -980,14 +975,16 @@
innov2, syn_resp, bits, stack, st->complexity, 0);
signal_mul(innov2, innov2, MULT16_32_Q15(QCONST16(0.454545f,15),ener), st->subframeSize);
for (i=0;i<st->subframeSize;i++)
- exc[i] = ADD32(exc[i],PSHR32(innov2[i],SIG_SHIFT));
- if (innov_save)
- {
- for (i=0;i<st->subframeSize;i++)
- innov_save[i] = ADD16(innov_save[i],EXTRACT16(PSHR32(innov2[i],SIG_SHIFT)));
- }
+ innov[i] = ADD32(innov[i],innov2[i]);
stack = tmp_stack;
}
+ for (i=0;i<st->subframeSize;i++)
+ exc[i] = EXTRACT16(SATURATE32(PSHR32(ADD32(SHL32(exc32[i],1),innov[i]),SIG_SHIFT),32767));
+ if (innov_save)
+ {
+ for (i=0;i<st->subframeSize;i++)
+ innov_save[i] = EXTRACT16(PSHR32(innov[i],SIG_SHIFT));
+ }
} else {
speex_error("No fixed codebook");
}
@@ -1575,16 +1572,38 @@
{
/*Fixed codebook contribution*/
SUBMODE(innovation_unquant)(innov, SUBMODE(innovation_params), st->subframeSize, bits, stack, &st->seed);
+ /* De-normalize innovation and update excitation */
+#ifdef FIXED_POINT
+ signal_mul(innov, innov, ener, st->subframeSize);
+#else
+ signal_mul(innov, innov, ener, st->subframeSize);
+#endif
+ /* Decode second codebook (only for some modes) */
+ if (SUBMODE(double_codebook))
+ {
+ char *tmp_stack=stack;
+ VARDECL(spx_sig_t *innov2);
+ ALLOC(innov2, st->subframeSize, spx_sig_t);
+ for (i=0;i<st->subframeSize;i++)
+ innov2[i]=0;
+ SUBMODE(innovation_unquant)(innov2, SUBMODE(innovation_params), st->subframeSize, bits, stack, &st->seed);
+ signal_mul(innov2, innov2, MULT16_32_Q15(QCONST16(0.454545f,15),ener), st->subframeSize);
+ for (i=0;i<st->subframeSize;i++)
+ innov[i] = ADD32(innov[i], innov2[i]);
+ stack = tmp_stack;
+ }
+ for (i=0;i<st->subframeSize;i++)
+ exc[i]=EXTRACT16(SATURATE32(PSHR32(ADD32(SHL32(exc32[i],1),innov[i]),SIG_SHIFT),32767));
+ /*print_vec(exc, 40, "innov");*/
+ if (innov_save)
+ {
+ for (i=0;i<st->subframeSize;i++)
+ innov_save[i] = EXTRACT16(PSHR32(innov[i], SIG_SHIFT));
+ }
} else {
speex_error("No fixed codebook");
}
- /* De-normalize innovation and update excitation */
-#ifdef FIXED_POINT
- signal_mul(innov, innov, ener, st->subframeSize);
-#else
- signal_mul(innov, innov, ener, st->subframeSize);
-#endif
/*Vocoder mode*/
if (st->submodeID==1)
{
@@ -1616,35 +1635,8 @@
st->voc_mean = .95*st->voc_mean + .05*exc[i];
exc[i]-=st->voc_mean;
}
- } else {
- for (i=0;i<st->subframeSize;i++)
- exc[i]=EXTRACT16(SATURATE32(PSHR32(ADD32(SHL32(exc32[i],1),innov[i]),SIG_SHIFT),32767));
- /*print_vec(exc, 40, "innov");*/
}
- if (innov_save)
- {
- for (i=0;i<st->subframeSize;i++)
- innov_save[i] = EXTRACT16(PSHR32(innov[i], SIG_SHIFT));
- }
- /* Decode second codebook (only for some modes) */
- if (SUBMODE(double_codebook))
- {
- char *tmp_stack=stack;
- VARDECL(spx_sig_t *innov2);
- ALLOC(innov2, st->subframeSize, spx_sig_t);
- for (i=0;i<st->subframeSize;i++)
- innov2[i]=0;
- SUBMODE(innovation_unquant)(innov2, SUBMODE(innovation_params), st->subframeSize, bits, stack, &st->seed);
- signal_mul(innov2, innov2, MULT16_32_Q15(QCONST16(0.454545f,15),ener), st->subframeSize);
- for (i=0;i<st->subframeSize;i++)
- exc[i] = EXTRACT16(SATURATE32(ADD32(EXTEND32(exc[i]),PSHR32(innov2[i],SIG_SHIFT)),32767));
- if (innov_save)
- {
- for (i=0;i<st->subframeSize;i++)
- innov_save[i] = ADD16(innov_save[i],EXTRACT16(PSHR32(innov2[i], SIG_SHIFT)));
- }
- stack = tmp_stack;
- }
+
}
}
More information about the commits
mailing list