comparison liba52.c @ 5525:bc4791868c52 libavcodec

various simplifications around recent av_clip_int16() usage
author aurel
date Sat, 11 Aug 2007 23:17:03 +0000
parents c2ab2ac31edb
children f6b691720c7d
comparison
equal deleted inserted replaced
5524:f47bc5359101 5525:bc4791868c52
118 s->frame_size = 0; 118 s->frame_size = 0;
119 119
120 return 0; 120 return 0;
121 } 121 }
122 122
123 /**** the following two functions comes from a52dec */ 123 /**** the following function comes from a52dec */
124 static inline int blah (int32_t i)
125 {
126 return av_clip_int16(i - 0x43c00000);
127 }
128
129 static inline void float_to_int (float * _f, int16_t * s16, int nchannels) 124 static inline void float_to_int (float * _f, int16_t * s16, int nchannels)
130 { 125 {
131 int i, j, c; 126 int i, j, c;
132 int32_t * f = (int32_t *) _f; // XXX assumes IEEE float format 127 int32_t * f = (int32_t *) _f; // XXX assumes IEEE float format
133 128
134 j = 0; 129 j = 0;
135 nchannels *= 256; 130 nchannels *= 256;
136 for (i = 0; i < 256; i++) { 131 for (i = 0; i < 256; i++) {
137 for (c = 0; c < nchannels; c += 256) 132 for (c = 0; c < nchannels; c += 256)
138 s16[j++] = blah (f[i + c]); 133 s16[j++] = av_clip_int16(f[i + c] - 0x43c00000);
139 } 134 }
140 } 135 }
141 136
142 /**** end */ 137 /**** end */
143 138