FS#11195, plus. Simplified hotkey struct, thanks alle!
[kugel-rb.git] / apps / codecs / libwavpack / float.c
blob6e5c4e4f61d7739e3e15981b52897ae8f899f1a6
1 ////////////////////////////////////////////////////////////////////////////
2 // **** WAVPACK **** //
3 // Hybrid Lossless Wavefile Compressor //
4 // Copyright (c) 1998 - 2004 Conifer Software. //
5 // All Rights Reserved. //
6 // Distributed under the BSD Software License (see license.txt) //
7 ////////////////////////////////////////////////////////////////////////////
9 // float.c
11 #include "wavpack.h"
13 int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd)
15 int bytecnt = wpmd->byte_length;
16 char *byteptr = wpmd->data;
18 if (bytecnt != 4)
19 return FALSE;
21 wps->float_flags = *byteptr++;
22 wps->float_shift = *byteptr++;
23 wps->float_max_exp = *byteptr++;
24 wps->float_norm_exp = *byteptr;
25 return TRUE;
28 /* This function converts WavPack floating point data into standard Rockbox
29 * 28-bit integers. It is assumed that clipping will be taken care of later.
32 void float_values (WavpackStream *wps, int32_t *values, int32_t num_values)
34 int shift = wps->float_max_exp - wps->float_norm_exp + wps->float_shift + 5;
36 if (shift > 32)
37 shift = 32;
38 else if (shift < -32)
39 shift = -32;
41 if (shift > 0)
42 while (num_values--)
43 *values++ <<= shift;
44 else if (shift < 0)
45 while (num_values--)
46 *values++ >>= -shift;