void-packages/srcpkgs/faad2/patches/fix-stack_usage.patch

52 lines
2.0 KiB
Diff

Since there are reports of crashes in libfaad2 when called from
firefox and icecat in the function ps_decode(), this is a try
to reduce the stack footprint of faad2 decoding by making the
main arrays X_left[][] and X_right[][] use static __thread storage.
--- libfaad/sbr_dec.c 2009-01-26 23:32:31.000000000 +0100
+++ libfaad/sbr_dec.c 2015-09-11 12:44:28.305989011 +0200
@@ -602,8 +602,12 @@
uint8_t l, k;
uint8_t dont_process = 0;
uint8_t ret = 0;
- ALIGN qmf_t X_left[38][64] = {{0}};
- ALIGN qmf_t X_right[38][64] = {{0}}; /* must set this to 0 */
+ /* 2015-09-11 jbu: make static to reduce stack footprint */
+ static __thread ALIGN qmf_t X_left[38][64];
+ static __thread ALIGN qmf_t X_right[38][64];
+ /* must set this to 0 */
+ memset(X_left, 0, sizeof(X_left));
+ memset(X_right, 0, sizeof(X_right));
if (sbr == NULL)
return 20;
--- libfaad/ps_dec.c 2009-01-26 23:32:31.000000000 +0100
+++ libfaad/ps_dec.c 2015-09-11 13:02:37.898985783 +0200
@@ -1039,10 +1039,10 @@
const complex_t *Phi_Fract_SubQmf;
uint8_t temp_delay_ser[NO_ALLPASS_LINKS];
real_t P_SmoothPeakDecayDiffNrg, nrg;
- real_t P[32][34];
- real_t G_TransientRatio[32][34] = {{0}};
+ static __thread real_t P[32][34];
+ static __thread real_t G_TransientRatio[32][34];
complex_t inputLeft;
-
+ memset(G_TransientRatio, 0, sizeof(G_TransientRatio));
/* chose hybrid filterbank: 20 or 34 band case */
if (ps->use34hybrid_bands)
@@ -1963,8 +1963,10 @@
/* main Parametric Stereo decoding function */
uint8_t ps_decode(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64])
{
- qmf_t X_hybrid_left[32][32] = {{0}};
- qmf_t X_hybrid_right[32][32] = {{0}};
+ static __thread qmf_t X_hybrid_left[32][32];
+ static __thread qmf_t X_hybrid_right[32][32];
+ memset(X_hybrid_left, 0, sizeof(X_hybrid_left));
+ memset(X_hybrid_right, 0, sizeof(X_hybrid_right));
/* delta decoding of the bitstream data */
ps_data_decode(ps);