Skip to content

Commit 85a2fb1

Browse files
committed
comb_filter(): Move stack alloc to ALLOC()
Move qext buffer to ALLOC() to reduce main stack use.
1 parent 2c9f132 commit 85a2fb1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

celt/celt.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,13 @@ void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N,
207207
{QCONST16(0.3066406250f, 15), QCONST16(0.2170410156f, 15), QCONST16(0.1296386719f, 15)},
208208
{QCONST16(0.4638671875f, 15), QCONST16(0.2680664062f, 15), QCONST16(0.f, 15)},
209209
{QCONST16(0.7998046875f, 15), QCONST16(0.1000976562f, 15), QCONST16(0.f, 15)}};
210+
SAVE_STACK;
210211
#ifdef ENABLE_QEXT
211212
if (overlap==240) {
212-
opus_val32 mem_buf[COMBFILTER_MAXPERIOD+960];
213-
opus_val32 buf[COMBFILTER_MAXPERIOD+960];
213+
VARDECL(opus_val32, mem_buf);
214+
VARDECL(opus_val32, buf);
215+
ALLOC(mem_buf, COMBFILTER_MAXPERIOD+960, opus_val32);
216+
ALLOC(buf, COMBFILTER_MAXPERIOD+960, opus_val32);
214217
celt_coef new_window[120];
215218
int s;
216219
int N2;
@@ -233,6 +236,7 @@ void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N,
233236
comb_filter(yptr, mem_buf+COMBFILTER_MAXPERIOD, T0, T1, N2, g0, g1, tapset0, tapset1, new_window, overlap2, arch);
234237
for (i=0;i<N2;i++) y[2*i+s] = yptr[i];
235238
}
239+
RESTORE_STACK;
236240
return;
237241
}
238242
#endif
@@ -241,6 +245,7 @@ void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N,
241245
/* OPT: Happens to work without the OPUS_MOVE(), but only because the current encoder already copies x to y */
242246
if (x!=y)
243247
OPUS_MOVE(y, x, N);
248+
RESTORE_STACK;
244249
return;
245250
}
246251
/* When the gain is zero, T0 and/or T1 is set to zero. We need
@@ -288,11 +293,13 @@ void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N,
288293
/* OPT: Happens to work without the OPUS_MOVE(), but only because the current encoder already copies x to y */
289294
if (x!=y)
290295
OPUS_MOVE(y+overlap, x+overlap, N-overlap);
296+
RESTORE_STACK;
291297
return;
292298
}
293299

294300
/* Compute the part with the constant filter. */
295301
comb_filter_const(y+i, x+i, T1, N-i, g10, g11, g12, arch);
302+
RESTORE_STACK;
296303
}
297304
#endif /* OVERRIDE_comb_filter */
298305

0 commit comments

Comments
 (0)