- for (i = 0; i < subframe_len; i++)
- for (j = 0; j < s->num_channels; j++) {
- if (s->bits_per_sample == 16)
- *s->samples_16++ = (int16_t) s->channel_residues[j][i];
- else
- *s->samples_32++ = s->channel_residues[j][i];
+ for (i = 0; i < s->channels_for_cur_subframe; i++) {
+ int c = s->channel_indexes_for_cur_subframe[i];
+ int subframe_len = s->channel[c].subframe_len[s->channel[c].cur_subframe];
+
+ for (j = 0; j < subframe_len; j++) {
+ if (s->bits_per_sample == 16) {
+ *s->samples_16[c] = (int16_t) s->channel_residues[c][j];
+ s->samples_16[c] += s->num_channels;
+ } else {
+ *s->samples_32[c] = s->channel_residues[c][j];
+ s->samples_32[c] += s->num_channels;
+ }