comparison cook.c @ 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
comparison
equal deleted inserted replaced
5342:887509b42d3f 5343:1aa26b974dc3
817 817
818 /* Swap current and previous gains */ 818 /* Swap current and previous gains */
819 FFSWAP(int *, gains_ptr->now, gains_ptr->previous); 819 FFSWAP(int *, gains_ptr->now, gains_ptr->previous);
820 } 820 }
821 821
822 /**
823 * Saturate the output signal to signed 16bit integers.
824 *
825 * @param q pointer to the COOKContext
826 * @param chan channel to saturate
827 * @param out pointer to the output vector
828 */
829 static void
830 saturate_output_float (COOKContext *q, int chan, int16_t *out)
831 {
832 int j;
833 float_t *output = q->mono_mdct_output + q->samples_per_channel;
834 /* Clip and convert floats to 16 bits.
835 */
836 for (j = 0; j < q->samples_per_channel; j++) {
837 out[chan + q->nb_channels * j] =
838 av_clip(lrintf(output[j]), -32768, 32767);
839 }
840 }
841
822 /** 842 /**
823 * Final part of subpacket decoding: 843 * Final part of subpacket decoding:
824 * Apply modulated lapped transform, gain compensation, 844 * Apply modulated lapped transform, gain compensation,
825 * clip and convert to integer. 845 * clip and convert to integer.
826 * 846 *
835 static inline void 855 static inline void
836 mlt_compensate_output(COOKContext *q, float *decode_buffer, 856 mlt_compensate_output(COOKContext *q, float *decode_buffer,
837 cook_gains *gains, float *previous_buffer, 857 cook_gains *gains, float *previous_buffer,
838 int16_t *out, int chan) 858 int16_t *out, int chan)
839 { 859 {
840 float *output = q->mono_mdct_output + q->samples_per_channel;
841 int j;
842
843 imlt_gain(q, decode_buffer, gains, previous_buffer); 860 imlt_gain(q, decode_buffer, gains, previous_buffer);
844 861 saturate_output_float (q, chan, out);
845 /* Clip and convert floats to 16 bits.
846 */
847 for (j = 0; j < q->samples_per_channel; j++) {
848 out[chan + q->nb_channels * j] =
849 av_clip(lrintf(output[j]), -32768, 32767);
850 }
851 } 862 }
852 863
853 864
854 /** 865 /**
855 * Cook subpacket decoding. This function returns one decoded subpacket, 866 * Cook subpacket decoding. This function returns one decoded subpacket,