]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/atrac1.c
ARM: align stack in NEON h264 mc functions
[ffmpeg] / libavcodec / atrac1.c
index cac82b36787876eaec3fb43ebd93909a587bb0bc..2009bba753c55ba48754419f604b1a14dbbe9162 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * @file libavcodec/atrac1.c
  * Atrac 1 compatible decoder.
- * This decoder handles raw ATRAC1 data.
+ * This decoder handles raw ATRAC1 data and probably SDDS data.
  */
 
 /* Many thanks to Tim Craig for all the help! */
@@ -82,8 +82,6 @@ typedef struct {
     DSPContext          dsp;
 } AT1Ctx;
 
-DECLARE_ALIGNED_16(static float, short_window[32]);
-
 /** size of the transform in samples in the long mode for each QMF band */
 static const uint16_t samples_per_band[3] = {128, 128, 256};
 static const uint8_t   mdct_long_nbits[3] = {7, 7, 8};
@@ -110,6 +108,9 @@ static int at1_imdct_block(AT1SUCtx* su, AT1Ctx *q)
     unsigned int start_pos, ref_pos = 0, pos = 0;
 
     for (band_num = 0; band_num < AT1_QMF_BANDS; band_num++) {
+        float *prev_buf;
+        int j;
+
         band_samples = samples_per_band[band_num];
         log2_block_count = su->log2_block_count[band_num];
 
@@ -117,42 +118,38 @@ static int at1_imdct_block(AT1SUCtx* su, AT1Ctx *q)
         /* 4 for short mode(low/middle bands) and 8 for short mode(high band)*/
         num_blocks = 1 << log2_block_count;
 
-        /* mdct block size in samples: 128 (long mode, low & mid bands), */
-        /* 256 (long mode, high band) and 32 (short mode, all bands) */
-        block_size = band_samples >> log2_block_count;
+        if (num_blocks == 1) {
+            /* mdct block size in samples: 128 (long mode, low & mid bands), */
+            /* 256 (long mode, high band) and 32 (short mode, all bands) */
+            block_size = band_samples >> log2_block_count;
 
-        /* calc transform size in bits according to the block_size_mode */
-        nbits = mdct_long_nbits[band_num] - log2_block_count;
+            /* calc transform size in bits according to the block_size_mode */
+            nbits = mdct_long_nbits[band_num] - log2_block_count;
 
-        if (nbits != 5 && nbits != 7 && nbits != 8)
-            return -1;
+            if (nbits != 5 && nbits != 7 && nbits != 8)
+                return -1;
+        } else {
+            block_size = 32;
+            nbits = 5;
+        }
 
-        if (num_blocks == 1) {
-            /* long blocks */
-            at1_imdct(q, &q->spec[pos], &su->spectrum[0][ref_pos], nbits, band_num);
-            pos += block_size; // move to the next mdct block in the spectrum
+        start_pos = 0;
+        prev_buf = &su->spectrum[1][ref_pos + band_samples - 16];
+        for (j=0; j < num_blocks; j++) {
+            at1_imdct(q, &q->spec[pos], &su->spectrum[0][ref_pos + start_pos], nbits, band_num);
 
-            /* overlap and window long blocks */
-            q->dsp.vector_fmul_window(q->bands[band_num], &su->spectrum[1][ref_pos + band_samples - 16],
-                                      &su->spectrum[0][ref_pos], short_window, 0, 16);
-            memcpy(q->bands[band_num] + 32, &su->spectrum[0][ref_pos + 16], 240 * sizeof(float));
-        } else {
-            /* short blocks */
-            float *prev_buf;
-            start_pos = 0;
-            prev_buf = &su->spectrum[1][ref_pos + band_samples - 16];
-            for (; num_blocks != 0; num_blocks--) {
-                at1_imdct(q, &q->spec[pos], &su->spectrum[0][ref_pos + start_pos], 5, band_num);
-
-                /* overlap and window between short blocks */
-                q->dsp.vector_fmul_window(&q->bands[band_num][start_pos], prev_buf,
-                                          &su->spectrum[0][ref_pos + start_pos], short_window, 0, 16);
-
-                prev_buf = &su->spectrum[0][ref_pos+start_pos + 16];
-                start_pos += 32; // use hardcoded block_size
-                pos += 32;
-            }
+            /* overlap and window */
+            q->dsp.vector_fmul_window(&q->bands[band_num][start_pos], prev_buf,
+                                      &su->spectrum[0][ref_pos + start_pos], ff_sine_32, 0, 16);
+
+            prev_buf = &su->spectrum[0][ref_pos+start_pos + 16];
+            start_pos += block_size;
+            pos += block_size;
         }
+
+        if (num_blocks == 1)
+            memcpy(q->bands[band_num] + 32, &su->spectrum[0][ref_pos + 16], 240 * sizeof(float));
+
         ref_pos += band_samples;
     }
 
@@ -342,7 +339,7 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx)
     ff_mdct_init(&q->mdct_ctx[1], 8, 1, -1.0/ (1 << 15));
     ff_mdct_init(&q->mdct_ctx[2], 9, 1, -1.0/ (1 << 15));
 
-    ff_sine_window_init(short_window, 32);
+    ff_sine_window_init(ff_sine_32, 32);
 
     atrac_generate_tables();