diff options
author | Marc Hoffman <mmhoffm@gmail.com> | 2007-07-16 05:28:58 +0400 |
---|---|---|
committer | Marc Hoffman <mmhoffm@gmail.com> | 2007-07-16 05:28:58 +0400 |
commit | 29b4b8351b962c404ccbbdca23d6c254af95e732 (patch) | |
tree | e84456806931d7876a1bdd44836fcd55fd61493a /libavcodec/cook.c | |
parent | 8c9d2954f7395f864261a28289d1aadd316777ca (diff) |
separating saturation codes so that we can support other data formats
Originally committed as revision 9693 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/cook.c')
-rw-r--r-- | libavcodec/cook.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/libavcodec/cook.c b/libavcodec/cook.c index d2e48c45c5..0f3e97cf07 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -819,6 +819,26 @@ decode_bytes_and_gain(COOKContext *q, uint8_t *inbuffer, 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 @@ mlt_compensate_output(COOKContext *q, float *decode_buffer, 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); } |