Skip to content

Instantly share code, notes, and snippets.

@awesie
Created January 19, 2020 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awesie/5142bbcf2953d02b3558b59326c97086 to your computer and use it in GitHub Desktop.
Save awesie/5142bbcf2953d02b3558b59326c97086 to your computer and use it in GitHub Desktop.
Patch for faad_imdct in FAAD2 for GCC 9
diff --git a/libfaad/mdct.c b/libfaad/mdct.c
index 247691e..1545357 100644
--- a/libfaad/mdct.c
+++ b/libfaad/mdct.c
@@ -121,21 +121,18 @@ void faad_mdct_end(mdct_info *mdct)
void faad_imdct(mdct_info *mdct, real_t *X_in, real_t *X_out)
{
- uint16_t k;
-
- complex_t x;
#ifdef ALLOW_SMALL_FRAMELENGTH
#ifdef FIXED_POINT
real_t scale, b_scale = 0;
#endif
#endif
ALIGN complex_t Z1[512];
- complex_t *sincos = mdct->sincos;
+ const complex_t *sincos = mdct->sincos;
- uint16_t N = mdct->N;
- uint16_t N2 = N >> 1;
- uint16_t N4 = N >> 2;
- uint16_t N8 = N >> 3;
+ const unsigned int N = mdct->N;
+ const unsigned int N2 = N >> 1;
+ const unsigned int N4 = N >> 2;
+ const unsigned int N8 = N >> 3;
#ifdef PROFILE
int64_t count1, count2 = faad_get_ts();
@@ -155,7 +152,7 @@ void faad_imdct(mdct_info *mdct, real_t *X_in, real_t *X_out)
#endif
/* pre-IFFT complex multiplication */
- for (k = 0; k < N4; k++)
+ for (unsigned int k = 0; k < N4; k++)
{
ComplexMult(&IM(Z1[k]), &RE(Z1[k]),
X_in[2*k], X_in[N2 - 1 - 2*k], RE(sincos[k]), IM(sincos[k]));
@@ -173,12 +170,10 @@ void faad_imdct(mdct_info *mdct, real_t *X_in, real_t *X_out)
#endif
/* post-IFFT complex multiplication */
- for (k = 0; k < N4; k++)
+ for (unsigned int k = 0; k < N4; k++)
{
- RE(x) = RE(Z1[k]);
- IM(x) = IM(Z1[k]);
ComplexMult(&IM(Z1[k]), &RE(Z1[k]),
- IM(x), RE(x), RE(sincos[k]), IM(sincos[k]));
+ IM(Z1[k]), RE(Z1[k]), RE(sincos[k]), IM(sincos[k]));
#ifdef ALLOW_SMALL_FRAMELENGTH
#ifdef FIXED_POINT
@@ -193,7 +188,7 @@ void faad_imdct(mdct_info *mdct, real_t *X_in, real_t *X_out)
}
/* reordering */
- for (k = 0; k < N8; k+=2)
+ for (unsigned int k = 0; k < N8; k+=2)
{
X_out[ 2*k] = IM(Z1[N8 + k]);
X_out[ 2 + 2*k] = IM(Z1[N8 + 1 + k]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment