Mercurial > libavcodec.hg
changeset 5343:1aa26b974dc3 libavcodec
separating saturation codes so that we can support other data formats
author | mhoffman |
---|---|
date | Mon, 16 Jul 2007 01:28:58 +0000 |
parents | 887509b42d3f |
children | b0d49997bd92 |
files | cook.c |
diffstat | 1 files changed, 21 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/cook.c Sun Jul 15 22:06:08 2007 +0000 +++ b/cook.c Mon Jul 16 01:28:58 2007 +0000 @@ -819,6 +819,26 @@ FFSWAP(int *, gains_ptr->now, gains_ptr->previous); } + /** + * Saturate the output signal to signed 16bit integers. + * + * @param q pointer to the COOKContext + * @param chan channel to saturate + * @param out pointer to the output vector + */ +static void +saturate_output_float (COOKContext *q, int chan, int16_t *out) +{ + int j; + float_t *output = q->mono_mdct_output + q->samples_per_channel; + /* Clip and convert floats to 16 bits. + */ + for (j = 0; j < q->samples_per_channel; j++) { + out[chan + q->nb_channels * j] = + av_clip(lrintf(output[j]), -32768, 32767); + } +} + /** * Final part of subpacket decoding: * Apply modulated lapped transform, gain compensation, @@ -837,17 +857,8 @@ cook_gains *gains, float *previous_buffer, int16_t *out, int chan) { - float *output = q->mono_mdct_output + q->samples_per_channel; - int j; - imlt_gain(q, decode_buffer, gains, previous_buffer); - - /* Clip and convert floats to 16 bits. - */ - for (j = 0; j < q->samples_per_channel; j++) { - out[chan + q->nb_channels * j] = - av_clip(lrintf(output[j]), -32768, 32767); - } + saturate_output_float (q, chan, out); }