Skip to content

Commit c1dcd55

Browse files
committed
remove vlas in celt_lpc.c and pitch.c
1 parent 90ec41e commit c1dcd55

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/celt_lpc.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void celt_fir(
9696
int ord)
9797
{
9898
int i,j;
99-
opus_val16 rnum[ord];
99+
opus_val16 *rnum = calloc(sizeof(opus_val16), ord);
100100
for(i=0;i<ord;i++)
101101
rnum[i] = num[ord-i-1];
102102
for (i=0;i<N-3;i+=4)
@@ -119,6 +119,7 @@ void celt_fir(
119119
sum = MAC16_16(sum,rnum[j],x[i+j-ord]);
120120
y[i] = ROUND16(sum, SIG_SHIFT);
121121
}
122+
free(rnum);
122123
}
123124

124125
void celt_iir(const opus_val32 *_x,
@@ -147,8 +148,9 @@ void celt_iir(const opus_val32 *_x,
147148
#else
148149
int i,j;
149150
celt_assert((ord&3)==0);
150-
opus_val16 rden[ord];
151-
opus_val16 y[N+ord];
151+
opus_val16 *rden = calloc(sizeof(opus_val16), ord);
152+
opus_val16 *y = calloc(sizeof(opus_val16), N+ord);
153+
152154
for(i=0;i<ord;i++)
153155
rden[i] = den[ord-i-1];
154156
for(i=0;i<ord;i++)
@@ -192,6 +194,8 @@ void celt_iir(const opus_val32 *_x,
192194
}
193195
for(i=0;i<ord;i++)
194196
mem[i] = _y[N-i-1];
197+
free(rden);
198+
free(y);
195199
#endif
196200
}
197201

@@ -208,7 +212,8 @@ int _celt_autocorr(
208212
int fastN=n-lag;
209213
int shift;
210214
const opus_val16 *xptr;
211-
opus_val16 xx[n];
215+
opus_val16 *xx = calloc(sizeof(opus_val16), n);
216+
212217
celt_assert(n>0);
213218
celt_assert(overlap>=0);
214219
if (overlap == 0)
@@ -274,6 +279,6 @@ int _celt_autocorr(
274279
shift += shift2;
275280
}
276281
#endif
277-
282+
free(xx);
278283
return shift;
279284
}

src/pitch.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,9 @@ void pitch_search(const opus_val16 *x_lp, opus_val16 *y,
297297
celt_assert(max_pitch>0);
298298
lag = len+max_pitch;
299299

300-
opus_val16 x_lp4[len>>2];
301-
opus_val16 y_lp4[lag>>2];
302-
opus_val32 xcorr[max_pitch>>1];
300+
opus_val16 *x_lp4 = calloc(sizeof(opus_val16), len>>2);
301+
opus_val16 *y_lp4 = calloc(sizeof(opus_val16), lag>>2);
302+
opus_val32 *xcorr = calloc(sizeof(opus_val32), max_pitch>>1);
303303

304304
/* Downsample by 2 again */
305305
for (j=0;j<len>>2;j++)
@@ -382,6 +382,9 @@ void pitch_search(const opus_val16 *x_lp, opus_val16 *y,
382382
offset = 0;
383383
}
384384
*pitch = 2*best_pitch[0]-offset;
385+
free(xcorr);
386+
free(x_lp4);
387+
free(y_lp4);
385388
}
386389

387390
#ifdef FIXED_POINT
@@ -443,7 +446,7 @@ opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod,
443446
*T0_=maxperiod-1;
444447

445448
T = T0 = *T0_;
446-
opus_val32 yy_lookup[maxperiod+1];
449+
opus_val32 *yy_lookup = calloc(sizeof(opus_val32), maxperiod+1);
447450
dual_inner_prod(x, x, x-T0, N, &xx, &xy);
448451
yy_lookup[0] = xx;
449452
yy=xx;
@@ -502,6 +505,7 @@ opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod,
502505
g = g1;
503506
}
504507
}
508+
free(yy_lookup);
505509
best_xy = MAX32(0, best_xy);
506510
if (best_yy <= best_xy)
507511
pg = Q15ONE;

0 commit comments

Comments
 (0)