void-packages/srcpkgs/faad2/patches/fix-stack_usage.patch
Đoàn Trần Công Danh be5369a0cb srcpkgs/f*: convert patches to -Np1
* fpc is kept at -Np0

```sh
git grep -l '^patch_args=-Np0' "srcpkgs/$1*/template" |
while read template; do
	for p in ${template%/template}/patches/*; do
		sed -i '
			\,^[+-][+-][+-] /dev/null,b
			/^[*-]\+ [0-9]\+\(,[0-9]\+\)\? [*-]\+$/b
			s,^[*][*][*] ,&a/,
			/^--- /{
				s,\(^--- \)\(./\)*,\1a/,
				s,[.][Oo][Rr][Ii][Gg]\([	/]\),\1,
				s/[.][Oo][Rr][Ii][Gg]$//
				s/[.]patched[.]\([^.]\)/.\1/
				h
			}
			/^+++ -/{
				g
				s/^--- a/+++ b/
				b
			}
			s,\(^+++ \)\(./\)*,\1b/,
		' "$p"
	done
	sed -i '/^patch_args=/d' $template
done
```
2021-06-20 13:17:29 +07:00

51 lines
2 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.
--- a/libfaad/sbr_dec.c 2009-01-26 23:32:31.000000000 +0100
+++ b/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;
--- a/libfaad/ps_dec.c 2009-01-26 23:32:31.000000000 +0100
+++ b/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);