Fixed a bug allowing the pitch to be larger than the maximum allowed
authorjmvalin <jmvalin@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Thu, 6 Jun 2002 04:04:49 +0000 (04:04 +0000)
committerjmvalin <jmvalin@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Thu, 6 Jun 2002 04:04:49 +0000 (04:04 +0000)
(hence screwing up at the decoder)

git-svn-id: http://svn.xiph.org/trunk/speex@3353 0101bb08-14d6-0310-b084-bc0e0c8e3800

libspeex/ltp.c

index 6a15539..4a201dc 100644 (file)
@@ -376,8 +376,10 @@ int  *cdbk_index
       {
          if (j-pp<0)
             e[i][j]=exc2[j-pp];
-         else
+         else if (j-pp-pitch<0)
             e[i][j]=exc2[j-pp-pitch];
+         else
+            e[i][j]=0;
       }
       residue_zero(e[i],awk1,x[i],nsf,p);
       syn_filt_zero(x[i],ak,x[i],nsf,p);
@@ -506,6 +508,11 @@ float *exc2
 
    open_loop_pitch(sw, nsf, end, nsf, &ol_pitch);
 
+   if (ol_pitch-N<start)
+      ol_pitch=start+N;
+   if (ol_pitch+N>end)
+      ol_pitch=end-N;
+
    for (pitch=ol_pitch-N; pitch<=ol_pitch+N; pitch++)
    {
       for (j=0;j<nsf;j++)