Skip to content

Commit

Permalink
Clip after reducing core bit width to source res.
Browse files Browse the repository at this point in the history
  • Loading branch information
foo86 committed Apr 18, 2015
1 parent b6c0736 commit 18038c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions libdcadec/core_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -1044,8 +1044,13 @@ int core_filter(struct core_decoder *core, int flags)
for (int spkr = 0; spkr < SPEAKER_COUNT; spkr++) {
if (core->ch_mask & (1 << spkr)) {
int *samples = core->output_samples[spkr];
for (int n = 0; n < nsamples; n++)
samples[n] = (samples[n] + round) >> shift;
if (core->source_pcm_res == 16) {
for (int n = 0; n < nsamples; n++)
samples[n] = clip15((samples[n] + round) >> shift);
} else {
for (int n = 0; n < nsamples; n++)
samples[n] = clip19((samples[n] + round) >> shift);
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions libdcadec/fixed_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ static inline int32_t mul23(int32_t a, int32_t b) { return mul__(a, b, 23); }
static inline int32_t mul31(int32_t a, int32_t b) { return mul__(a, b, 31); }

static inline int32_t clip15(int32_t a) { return clip__(a, 15); }
static inline int32_t clip19(int32_t a) { return clip__(a, 19); }
static inline int32_t clip23(int32_t a) { return clip__(a, 23); }

#endif

0 comments on commit 18038c3

Please sign in to comment.