Skip to content

Commit

Permalink
Shift XLL samples after channel reordering.
Browse files Browse the repository at this point in the history
Saves some lines of code.
  • Loading branch information
foo86 committed Mar 25, 2015
1 parent 87ed40e commit fe3348f
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions libdcadec/dca_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,24 +370,17 @@ static int filter_hd_ma_frame(struct dcadec_context *dca)
return ret;
}

// Shift samples to account for storage bit width
int shift = p->storage_bit_res - p->pcm_bit_res;
if (shift > 0) {
for (int spkr = 0; spkr < SPEAKER_COUNT; spkr++) {
if (ch_mask & (1 << spkr)) {
int *buf = spkr_map[spkr];
if (!buf)
return -DCADEC_EINVAL;
for (int n = 0; n < xll->nframesamples; n++)
buf[n] <<= shift;
}
}
}

// Reorder sample buffer pointers
if (reorder_samples(dca, spkr_map, ch_mask) <= 0)
if ((ret = reorder_samples(dca, spkr_map, ch_mask)) <= 0)
return -DCADEC_EINVAL;

// Shift samples to account for storage bit width
int shift = p->storage_bit_res - p->pcm_bit_res;
if (shift > 0)
for (int ch = 0; ch < ret; ch++)
for (int n = 0; n < xll->nframesamples; n++)
dca->samples[ch][n] <<= shift;

dca->nframesamples = xll->nframesamples;
dca->sample_rate = p->freq;
dca->bits_per_sample = p->storage_bit_res;
Expand Down

0 comments on commit fe3348f

Please sign in to comment.