MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / process_float

Function process_float

libavcodec/wavpackenc.c:226–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224#define get_sign(f) (((f) >> 31) & 0x1)
225
226static void process_float(WavPackEncodeContext *s, int32_t *sample)
227{
228 int32_t shift_count, value, f = *sample;
229
230 if (get_exponent(f) == 255) {
231 s->float_flags |= FLOAT_EXCEPTIONS;
232 value = 0x1000000;
233 shift_count = 0;
234 } else if (get_exponent(f)) {
235 shift_count = s->max_exp - get_exponent(f);
236 value = 0x800000 + get_mantissa(f);
237 } else {
238 shift_count = s->max_exp ? s->max_exp - 1 : 0;
239 value = get_mantissa(f);
240 }
241
242 if (shift_count < 25)
243 value >>= shift_count;
244 else
245 value = 0;
246
247 if (!value) {
248 if (get_exponent(f) || get_mantissa(f))
249 s->false_zeros++;
250 else if (get_sign(f))
251 s->neg_zeros++;
252 } else if (shift_count) {
253 int32_t mask = (1 << shift_count) - 1;
254
255 if (!(get_mantissa(f) & mask))
256 s->shifted_zeros++;
257 else if ((get_mantissa(f) & mask) == mask)
258 s->shifted_ones++;
259 else
260 s->shifted_both++;
261 }
262
263 s->ordata |= value;
264 *sample = get_sign(f) ? -value : value;
265}
266
267static int scan_float(WavPackEncodeContext *s,
268 int32_t *samples_l, int32_t *samples_r,

Callers 1

scan_floatFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected