Revision 10634c03

View differences:

libavcodec/atrac1.c
73 73
typedef struct {
74 74
    AT1SUCtx            SUs[AT1_MAX_CHANNELS];              ///< channel sound unit
75 75
    DECLARE_ALIGNED_16(float,spec[AT1_SU_SAMPLES]);         ///< the mdct spectrum buffer
76
    DECLARE_ALIGNED_16(float,short_buf[64]);                ///< buffer for the short mode
76
    DECLARE_ALIGNED_16(float,short_buf[512]);               ///< buffer for the short mode
77

  
77 78
    DECLARE_ALIGNED_16(float, low[256]);
78 79
    DECLARE_ALIGNED_16(float, mid[256]);
79 80
    DECLARE_ALIGNED_16(float,high[512]);
......
84 85
    DSPContext          dsp;
85 86
} AT1Ctx;
86 87

  
87
static float *short_window;
88
static float *mid_window;
89
DECLARE_ALIGNED_16(static float, long_window[256]);
90
static float *window_per_band[3];
88
DECLARE_ALIGNED_16(static float, short_window[32]);
91 89

  
92 90
/** size of the transform in samples in the long mode for each QMF band */
93 91
static const uint16_t samples_per_band[3] = {128, 128, 256};
......
137 135
        if (num_blocks == 1) {
138 136
            at1_imdct(q, &q->spec[pos], &su->spectrum[0][ref_pos], nbits, band_num);
139 137
            pos += block_size; // move to the next mdct block in the spectrum
138

  
139
            /* overlap and window long blocks */
140
            q->dsp.vector_fmul_window(q->bands[band_num], &su->spectrum[1][ref_pos+band_samples-16],
141
                &su->spectrum[0][ref_pos], short_window, 0, 16);
142
            memcpy(q->bands[band_num]+32, &su->spectrum[0][ref_pos+16], 240 * sizeof(float));
143

  
140 144
        } else {
141 145
            /* calc start position for the 1st short block: 96(128) or 112(256) */
146
            int short_pos = 32;
147
            float *prev_buf;
142 148
            start_pos = (band_samples * (num_blocks - 1)) >> (log2_block_count + 1);
143 149
            memset(&su->spectrum[0][ref_pos], 0, sizeof(float) * (band_samples * 2));
144 150

  
151
            prev_buf = &su->spectrum[1][ref_pos+band_samples-16];
145 152
            for (; num_blocks!=0 ; num_blocks--) {
146 153
                /* use hardcoded nbits for the short mode */
147
                at1_imdct(q, &q->spec[pos], q->short_buf, 5, band_num);
154
                at1_imdct(q, &q->spec[pos], &q->short_buf[short_pos], 5, band_num);
148 155

  
149 156
                /* overlap and window between short blocks */
150 157
                q->dsp.vector_fmul_window(&su->spectrum[0][ref_pos+start_pos],
151
                                          &su->spectrum[0][ref_pos+start_pos],
152
                                          q->short_buf,short_window, 0, 16);
158
                                          &q->short_buf[short_pos-16],
159
                                          &q->short_buf[short_pos],short_window, 0, 16);
160

  
161
                prev_buf = &q->short_buf[short_pos+16];
162

  
153 163
                start_pos += 32; // use hardcoded block_size
154 164
                pos += 32;
165
                short_pos +=32;
155 166
            }
167
            memcpy(q->bands[band_num], &su->spectrum[0][ref_pos], band_samples*sizeof(float));
156 168
        }
157

  
158
        /* overlap and window with the previous frame and output the result */
159
        q->dsp.vector_fmul_window(q->bands[band_num], &su->spectrum[1][ref_pos+band_samples/2],
160
            &su->spectrum[0][ref_pos], window_per_band[band_num], 0, band_samples/2);
161

  
162 169
        ref_pos += band_samples;
163 170
    }
164 171

  
......
331 338
}
332 339

  
333 340

  
334
static av_cold void init_mdct_windows(void)
335
{
336
    int i;
337

  
338
    /** The mid and long windows uses the same sine window splitted
339
     *  in the middle and wrapped into zero/one regions as follows:
340
     *
341
     *                   region of "ones"
342
     *               -------------
343
     *              /
344
     *             / 1st half
345
     *            / of the sine
346
     *           /  window
347
     * ---------/
348
     * zero region
349
     *
350
     * The mid and short windows are subsets of the long window.
351
     */
352

  
353
    /* Build "zero" region */
354
    memset(long_window, 0, sizeof(long_window));
355
    /* Build sine window region */
356
    short_window = &long_window[112];
357
    ff_sine_window_init(short_window,32);
358
    /* Build "ones" region */
359
    for (i = 0; i < 112; i++)
360
        long_window[144 + i] = 1.0f;
361
    /* Save the mid window subset start */
362
    mid_window = &long_window[64];
363

  
364
    /* Prepare the window table */
365
    window_per_band[0] = mid_window;
366
    window_per_band[1] = mid_window;
367
    window_per_band[2] = long_window;
368
}
369

  
370 341
static av_cold int atrac1_decode_init(AVCodecContext *avctx)
371 342
{
372 343
    AT1Ctx *q = avctx->priv_data;
......
379 350
    ff_mdct_init(&q->mdct_ctx[0], 6, 1, -1.0/ (1<<15));
380 351
    ff_mdct_init(&q->mdct_ctx[1], 8, 1, -1.0/ (1<<15));
381 352
    ff_mdct_init(&q->mdct_ctx[2], 9, 1, -1.0/ (1<<15));
382
    init_mdct_windows();
353

  
354
    ff_sine_window_init(short_window, 32);
383 355

  
384 356
    atrac_generate_tables();
385 357

  

Also available in: Unified diff