summaryrefslogtreecommitdiff
path: root/apps/codecs/libspeex/ltp.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libspeex/ltp.c')
-rw-r--r--apps/codecs/libspeex/ltp.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/apps/codecs/libspeex/ltp.c b/apps/codecs/libspeex/ltp.c
index 2f86b678d9..04c1115b3f 100644
--- a/apps/codecs/libspeex/ltp.c
+++ b/apps/codecs/libspeex/ltp.c
@@ -40,6 +40,7 @@
40#include "filters.h" 40#include "filters.h"
41#include <speex/speex_bits.h> 41#include <speex/speex_bits.h>
42#include "math_approx.h" 42#include "math_approx.h"
43#include "os_support.h"
43 44
44#ifndef NULL 45#ifndef NULL
45#define NULL 0 46#define NULL 0
@@ -498,8 +499,7 @@ int scaledown
498 *cdbk_index=best_cdbk; 499 *cdbk_index=best_cdbk;
499 } 500 }
500 501
501 for (i=0;i<nsf;i++) 502 SPEEX_MEMSET(exc, 0, nsf);
502 exc[i]=0;
503 for (i=0;i<3;i++) 503 for (i=0;i<3;i++)
504 { 504 {
505 int j; 505 int j;
@@ -551,7 +551,7 @@ int plc_tuning,
551spx_word32_t *cumul_gain 551spx_word32_t *cumul_gain
552) 552)
553{ 553{
554 int i,j; 554 int i;
555 int cdbk_index, pitch=0, best_gain_index=0; 555 int cdbk_index, pitch=0, best_gain_index=0;
556 VARDECL(spx_sig_t *best_exc); 556 VARDECL(spx_sig_t *best_exc);
557 VARDECL(spx_word16_t *new_target); 557 VARDECL(spx_word16_t *new_target);
@@ -583,8 +583,7 @@ spx_word32_t *cumul_gain
583 { 583 {
584 speex_bits_pack(bits, 0, params->pitch_bits); 584 speex_bits_pack(bits, 0, params->pitch_bits);
585 speex_bits_pack(bits, 0, params->gain_bits); 585 speex_bits_pack(bits, 0, params->gain_bits);
586 for (i=0;i<nsf;i++) 586 SPEEX_MEMSET(exc, 0, nsf);
587 exc[i]=0;
588 return start; 587 return start;
589 } 588 }
590 589
@@ -621,16 +620,13 @@ spx_word32_t *cumul_gain
621 for (i=0;i<N;i++) 620 for (i=0;i<N;i++)
622 { 621 {
623 pitch=nbest[i]; 622 pitch=nbest[i];
624 for (j=0;j<nsf;j++) 623 SPEEX_MEMSET(exc, 0, nsf);
625 exc[j]=0;
626 err=pitch_gain_search_3tap(target, ak, awk1, awk2, exc, gain_cdbk, gain_cdbk_size, pitch, p, nsf, 624 err=pitch_gain_search_3tap(target, ak, awk1, awk2, exc, gain_cdbk, gain_cdbk_size, pitch, p, nsf,
627 bits, stack, exc2, r, new_target, &cdbk_index, plc_tuning, *cumul_gain, scaledown); 625 bits, stack, exc2, r, new_target, &cdbk_index, plc_tuning, *cumul_gain, scaledown);
628 if (err<best_err || best_err<0) 626 if (err<best_err || best_err<0)
629 { 627 {
630 for (j=0;j<nsf;j++) 628 SPEEX_COPY(best_exc, exc, nsf);
631 best_exc[j]=exc[j]; 629 SPEEX_COPY(best_target, new_target, nsf);
632 for (j=0;j<nsf;j++)
633 best_target[j]=new_target[j];
634 best_err=err; 630 best_err=err;
635 best_pitch=pitch; 631 best_pitch=pitch;
636 best_gain_index=cdbk_index; 632 best_gain_index=cdbk_index;
@@ -646,10 +642,8 @@ spx_word32_t *cumul_gain
646#endif 642#endif
647 /*printf ("%f\n", cumul_gain);*/ 643 /*printf ("%f\n", cumul_gain);*/
648 /*printf ("encode pitch: %d %d\n", best_pitch, best_gain_index);*/ 644 /*printf ("encode pitch: %d %d\n", best_pitch, best_gain_index);*/
649 for (i=0;i<nsf;i++) 645 SPEEX_COPY(exc, best_exc, nsf);
650 exc[i]=best_exc[i]; 646 SPEEX_COPY(target, best_target, nsf);
651 for (i=0;i<nsf;i++)
652 target[i]=best_target[i];
653#ifdef FIXED_POINT 647#ifdef FIXED_POINT
654 /* Scale target back up if needed */ 648 /* Scale target back up if needed */
655 if (scaledown) 649 if (scaledown)
@@ -739,8 +733,7 @@ int cdbk_offset
739 gain[0] = SHL16(gain[0],7); 733 gain[0] = SHL16(gain[0],7);
740 gain[1] = SHL16(gain[1],7); 734 gain[1] = SHL16(gain[1],7);
741 gain[2] = SHL16(gain[2],7); 735 gain[2] = SHL16(gain[2],7);
742 for (i=0;i<nsf;i++) 736 SPEEX_MEMSET(exc_out, 0, nsf);
743 exc_out[i]=0;
744 for (i=0;i<3;i++) 737 for (i=0;i<3;i++)
745 { 738 {
746 int j; 739 int j;