+static int al_decode_frame(AVCodecContext *avctx, const uint8_t *databuf,
+ int size, float **out_samples)
+{
+ ATRAC3Context *q = avctx->priv_data;
+ int ret, i;
+
+ /* Set the bitstream reader at the start of a channel sound unit. */
+ init_get_bits(&q->gb, databuf, size * 8);
+ /* single channels */
+ /* Decode the channel sound units. */
+ for (i = 0; i < avctx->channels; i++) {
+ ret = decode_channel_sound_unit(q, &q->gb, &q->units[i],
+ out_samples[i], i, q->coding_mode);
+ if (ret != 0)
+ return ret;
+ while (i < avctx->channels && get_bits_left(&q->gb) > 6 && show_bits(&q->gb, 6) != 0x28) {
+ skip_bits(&q->gb, 1);
+ }
+ }
+
+ /* Apply the iQMF synthesis filter. */
+ for (i = 0; i < avctx->channels; i++) {
+ float *p1 = out_samples[i];
+ float *p2 = p1 + 256;
+ float *p3 = p2 + 256;
+ float *p4 = p3 + 256;
+ ff_atrac_iqmf(p1, p2, 256, p1, q->units[i].delay_buf1, q->temp_buf);
+ ff_atrac_iqmf(p4, p3, 256, p3, q->units[i].delay_buf2, q->temp_buf);
+ ff_atrac_iqmf(p1, p3, 512, p1, q->units[i].delay_buf3, q->temp_buf);
+ }
+
+ return 0;
+}
+