Revision 0105f497 libavcodec/atrac1.c

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[512]);               ///< buffer for the short mode
77 76

  
78 77
    DECLARE_ALIGNED_16(float, low[256]);
79 78
    DECLARE_ALIGNED_16(float, mid[256]);
......
133 132
            return -1;
134 133

  
135 134
        if (num_blocks == 1) {
135
            /* long blocks */
136 136
            at1_imdct(q, &q->spec[pos], &su->spectrum[0][ref_pos], nbits, band_num);
137 137
            pos += block_size; // move to the next mdct block in the spectrum
138 138

  
......
142 142
            memcpy(q->bands[band_num]+32, &su->spectrum[0][ref_pos+16], 240 * sizeof(float));
143 143

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

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

  
156 152
                /* overlap and window between short blocks */
157
                q->dsp.vector_fmul_window(&su->spectrum[0][ref_pos+start_pos],
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];
153
                q->dsp.vector_fmul_window(&q->bands[band_num][start_pos], prev_buf,
154
                                          &su->spectrum[0][ref_pos+start_pos], short_window, 0, 16);
162 155

  
156
                prev_buf = &su->spectrum[0][ref_pos+start_pos+16];
163 157
                start_pos += 32; // use hardcoded block_size
164 158
                pos += 32;
165
                short_pos +=32;
166 159
            }
167
            memcpy(q->bands[band_num], &su->spectrum[0][ref_pos], band_samples*sizeof(float));
168 160
        }
169 161
        ref_pos += band_samples;
170 162
    }

Also available in: Unified diff