wavpack.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. ////////////////////////////////////////////////////////////////////////////
  2. // **** WAVPACK **** //
  3. // Hybrid Lossless Wavefile Compressor //
  4. // Copyright (c) 1998 - 2024 David Bryant. //
  5. // All Rights Reserved. //
  6. // Distributed under the BSD Software License (see license.txt) //
  7. ////////////////////////////////////////////////////////////////////////////
  8. // wavpack.h
  9. #ifndef WAVPACK_H
  10. #define WAVPACK_H
  11. // This header file contains all the definitions required to use the
  12. // functions in "wputils.c" to read and write WavPack files and streams.
  13. #include <sys/types.h>
  14. #if defined(_MSC_VER) && _MSC_VER < 1600
  15. typedef unsigned __int64 uint64_t;
  16. typedef unsigned __int32 uint32_t;
  17. typedef unsigned __int16 uint16_t;
  18. typedef unsigned __int8 uint8_t;
  19. typedef __int64 int64_t;
  20. typedef __int32 int32_t;
  21. typedef __int16 int16_t;
  22. typedef __int8 int8_t;
  23. #else
  24. #include <stdint.h>
  25. #endif
  26. // RIFF / wav header formats (these occur at the beginning of both wav files
  27. // and pre-4.0 WavPack files that are not in the "raw" mode). Generally, an
  28. // application using the library to read or write WavPack files will not be
  29. // concerned with any of these.
  30. typedef struct {
  31. char ckID [4];
  32. uint32_t ckSize;
  33. char formType [4];
  34. } RiffChunkHeader;
  35. typedef struct {
  36. char ckID [4];
  37. uint32_t ckSize;
  38. } ChunkHeader;
  39. #define ChunkHeaderFormat "4L"
  40. typedef struct {
  41. uint16_t FormatTag, NumChannels;
  42. uint32_t SampleRate, BytesPerSecond;
  43. uint16_t BlockAlign, BitsPerSample;
  44. uint16_t cbSize, ValidBitsPerSample;
  45. int32_t ChannelMask;
  46. uint16_t SubFormat;
  47. char GUID [14];
  48. } WaveHeader;
  49. #define WaveHeaderFormat "SSLLSSSSLS"
  50. // This is the ONLY structure that occurs in WavPack files (as of version
  51. // 4.0), and is the preamble to every block in both the .wv and .wvc
  52. // files (in little-endian format). Normally, this structure has no use
  53. // to an application using the library to read or write WavPack files,
  54. // but if an application needs to manually parse WavPack files then this
  55. // would be used (with appropriate endian correction).
  56. typedef struct {
  57. char ckID [4];
  58. uint32_t ckSize;
  59. int16_t version;
  60. unsigned char block_index_u8;
  61. unsigned char total_samples_u8;
  62. uint32_t total_samples, block_index, block_samples, flags, crc;
  63. } WavpackHeader;
  64. #define WavpackHeaderFormat "4LS2LLLLL"
  65. // Macros to access the 40-bit block_index field
  66. #define GET_BLOCK_INDEX(hdr) ( (int64_t) (hdr).block_index + ((int64_t) (hdr).block_index_u8 << 32) )
  67. #define SET_BLOCK_INDEX(hdr,value) do { \
  68. int64_t tmp = (value); \
  69. (hdr).block_index = (uint32_t) tmp; \
  70. (hdr).block_index_u8 = \
  71. (unsigned char) (tmp >> 32); \
  72. } while (0)
  73. // Macros to access the 40-bit total_samples field, which is complicated by the fact that
  74. // all 1's in the lower 32 bits indicates "unknown" (regardless of upper 8 bits)
  75. #define GET_TOTAL_SAMPLES(hdr) ( ((hdr).total_samples == (uint32_t) -1) ? -1 : \
  76. (int64_t) (hdr).total_samples + ((int64_t) (hdr).total_samples_u8 << 32) - (hdr).total_samples_u8 )
  77. #define SET_TOTAL_SAMPLES(hdr,value) do { \
  78. int64_t tmp = (value); \
  79. if (tmp < 0) \
  80. (hdr).total_samples = (uint32_t) -1; \
  81. else { \
  82. tmp += (tmp / 0xffffffffLL); \
  83. (hdr).total_samples = (uint32_t) tmp; \
  84. (hdr).total_samples_u8 = \
  85. (unsigned char) (tmp >> 32); \
  86. } \
  87. } while (0)
  88. // or-values for WavpackHeader.flags
  89. #define BYTES_STORED 3 // 1-4 bytes/sample
  90. #define MONO_FLAG 4 // not stereo
  91. #define HYBRID_FLAG 8 // hybrid mode
  92. #define JOINT_STEREO 0x10 // joint stereo
  93. #define CROSS_DECORR 0x20 // no-delay cross decorrelation
  94. #define HYBRID_SHAPE 0x40 // noise shape (hybrid mode only)
  95. #define FLOAT_DATA 0x80 // ieee 32-bit floating point data
  96. #define INT32_DATA 0x100 // special extended int handling
  97. #define HYBRID_BITRATE 0x200 // bitrate noise (hybrid mode only)
  98. #define HYBRID_BALANCE 0x400 // balance noise (hybrid stereo mode only)
  99. #define INITIAL_BLOCK 0x800 // initial block of multichannel segment
  100. #define FINAL_BLOCK 0x1000 // final block of multichannel segment
  101. #define SHIFT_LSB 13
  102. #define SHIFT_MASK (0x1fL << SHIFT_LSB)
  103. #define MAG_LSB 18
  104. #define MAG_MASK (0x1fL << MAG_LSB)
  105. #define SRATE_LSB 23
  106. #define SRATE_MASK (0xfL << SRATE_LSB)
  107. #define FALSE_STEREO 0x40000000 // block is stereo, but data is mono
  108. #define NEW_SHAPING 0x20000000 // use IIR filter for negative shaping
  109. #define MONO_DATA (MONO_FLAG | FALSE_STEREO)
  110. // Introduced in WavPack 5.0:
  111. #define HAS_CHECKSUM 0x10000000 // block contains a trailing checksum
  112. #define DSD_FLAG 0x80000000 // block is encoded DSD (1-bit PCM)
  113. #define IGNORED_FLAGS 0x08000000 // reserved, but ignore if encountered
  114. #define UNKNOWN_FLAGS 0x00000000 // we no longer have any of these spares
  115. #define MIN_STREAM_VERS 0x402 // lowest stream version we'll decode
  116. #define MAX_STREAM_VERS 0x410 // highest stream version we'll decode or encode
  117. #define WAVPACK_MAX_CHANS 4096 // max channels handled by WavPack format & library
  118. // This sets the maximum number of channels that the current WavPack CLI applications
  119. // accept. It's somewhat arbitrary because the actual WavPack format and library can
  120. // handle up to 4096 channels. However, anything beyond 256 channels is obviously
  121. // a niche case and is not well tested, so this lower limit is defined for now.
  122. #define WAVPACK_MAX_CLI_CHANS 256
  123. // These are the mask bit definitions for the metadata chunk id byte (see format.txt)
  124. #define ID_UNIQUE 0x3f
  125. #define ID_OPTIONAL_DATA 0x20
  126. #define ID_ODD_SIZE 0x40
  127. #define ID_LARGE 0x80
  128. #define ID_DUMMY 0x0
  129. #define ID_ENCODER_INFO 0x1
  130. #define ID_DECORR_TERMS 0x2
  131. #define ID_DECORR_WEIGHTS 0x3
  132. #define ID_DECORR_SAMPLES 0x4
  133. #define ID_ENTROPY_VARS 0x5
  134. #define ID_HYBRID_PROFILE 0x6
  135. #define ID_SHAPING_WEIGHTS 0x7
  136. #define ID_FLOAT_INFO 0x8
  137. #define ID_INT32_INFO 0x9
  138. #define ID_WV_BITSTREAM 0xa
  139. #define ID_WVC_BITSTREAM 0xb
  140. #define ID_WVX_BITSTREAM 0xc
  141. #define ID_CHANNEL_INFO 0xd
  142. #define ID_DSD_BLOCK 0xe
  143. #define ID_RIFF_HEADER (ID_OPTIONAL_DATA | 0x1)
  144. #define ID_RIFF_TRAILER (ID_OPTIONAL_DATA | 0x2)
  145. #define ID_ALT_HEADER (ID_OPTIONAL_DATA | 0x3)
  146. #define ID_ALT_TRAILER (ID_OPTIONAL_DATA | 0x4)
  147. #define ID_CONFIG_BLOCK (ID_OPTIONAL_DATA | 0x5)
  148. #define ID_MD5_CHECKSUM (ID_OPTIONAL_DATA | 0x6)
  149. #define ID_SAMPLE_RATE (ID_OPTIONAL_DATA | 0x7)
  150. #define ID_ALT_EXTENSION (ID_OPTIONAL_DATA | 0x8)
  151. #define ID_ALT_MD5_CHECKSUM (ID_OPTIONAL_DATA | 0x9)
  152. #define ID_NEW_CONFIG_BLOCK (ID_OPTIONAL_DATA | 0xa)
  153. #define ID_CHANNEL_IDENTITIES (ID_OPTIONAL_DATA | 0xb)
  154. #define ID_WVX_NEW_BITSTREAM (ID_OPTIONAL_DATA | ID_WVX_BITSTREAM)
  155. #define ID_BLOCK_CHECKSUM (ID_OPTIONAL_DATA | 0xf)
  156. ///////////////////////// WavPack Configuration ///////////////////////////////
  157. // This external structure is used during encode to provide configuration to
  158. // the encoding engine and during decoding to provide fle information back to
  159. // the higher level functions. Not all fields are used in both modes.
  160. typedef struct {
  161. float bitrate, shaping_weight;
  162. int bits_per_sample, bytes_per_sample;
  163. int qmode, flags, xmode, num_channels, float_norm_exp;
  164. int32_t block_samples, worker_threads, sample_rate, channel_mask;
  165. unsigned char md5_checksum [16], md5_read;
  166. int num_tag_strings; // this field is not used
  167. char **tag_strings; // this field is not used
  168. } WavpackConfig;
  169. #define CONFIG_HYBRID_FLAG 8 // hybrid mode
  170. #define CONFIG_JOINT_STEREO 0x10 // joint stereo
  171. #define CONFIG_CROSS_DECORR 0x20 // no-delay cross decorrelation
  172. #define CONFIG_HYBRID_SHAPE 0x40 // noise shape (hybrid mode only)
  173. #define CONFIG_FAST_FLAG 0x200 // fast mode
  174. #define CONFIG_HIGH_FLAG 0x800 // high quality mode
  175. #define CONFIG_VERY_HIGH_FLAG 0x1000 // very high
  176. #define CONFIG_BITRATE_KBPS 0x2000 // bitrate is kbps, not bits / sample
  177. #define CONFIG_SHAPE_OVERRIDE 0x8000 // shaping mode specified
  178. #define CONFIG_JOINT_OVERRIDE 0x10000 // joint-stereo mode specified
  179. #define CONFIG_DYNAMIC_SHAPING 0x20000 // dynamic noise shaping
  180. #define CONFIG_CREATE_EXE 0x40000 // create executable
  181. #define CONFIG_CREATE_WVC 0x80000 // create correction file
  182. #define CONFIG_OPTIMIZE_WVC 0x100000 // maximize hybrid compression
  183. #define CONFIG_COMPATIBLE_WRITE 0x400000 // write files for decoders < 4.3
  184. #define CONFIG_CALC_NOISE 0x800000 // calc noise in hybrid mode
  185. #define CONFIG_EXTRA_MODE 0x2000000 // extra processing mode
  186. #define CONFIG_SKIP_WVX 0x4000000 // no wvx stream w/ floats & big ints
  187. #define CONFIG_MD5_CHECKSUM 0x8000000 // store MD5 signature
  188. #define CONFIG_MERGE_BLOCKS 0x10000000 // merge blocks of equal redundancy (for lossyWAV)
  189. #define CONFIG_PAIR_UNDEF_CHANS 0x20000000 // encode undefined channels in stereo pairs
  190. #define CONFIG_OPTIMIZE_32BIT 0x40000000 // new optimizations for 32-bit integer files
  191. #define CONFIG_OPTIMIZE_MONO 0x80000000 // optimize for mono streams posing as stereo
  192. // The lower 8 bits of qmode indicate the use of new features in version 5 that (presently)
  193. // only apply to Core Audio Files (CAF) and DSD files, but could apply to other things too.
  194. // These flags are stored in the file and can be retrieved by a decoder that is aware of
  195. // them, but the individual bits are meaningless to the library. If ANY of these bits are
  196. // set then the MD5 sum is written with a new ID so that old decoders will not see it
  197. // (because these features will cause the MD5 sum to be different and fail).
  198. #define QMODE_BIG_ENDIAN 0x1 // big-endian data format (opposite of WAV format)
  199. #define QMODE_SIGNED_BYTES 0x2 // 8-bit audio data is signed (opposite of WAV format)
  200. #define QMODE_UNSIGNED_WORDS 0x4 // audio data (other than 8-bit) is unsigned (opposite of WAV format)
  201. #define QMODE_REORDERED_CHANS 0x8 // source channels were not Microsoft order, so they were reordered
  202. #define QMODE_DSD_LSB_FIRST 0x10 // DSD bytes, LSB first (most Sony .dsf files)
  203. #define QMODE_DSD_MSB_FIRST 0x20 // DSD bytes, MSB first (Philips .dff files)
  204. #define QMODE_DSD_IN_BLOCKS 0x40 // DSD data is blocked by channels (Sony .dsf only)
  205. #define QMODE_DSD_AUDIO (QMODE_DSD_LSB_FIRST | QMODE_DSD_MSB_FIRST)
  206. // The rest of the qmode word is reserved for the private use of the command-line programs
  207. // and are ignored by the library (and not stored either). They really should not be defined
  208. // here, but I thought it would be a good idea to have all the definitions together.
  209. #define QMODE_ADOBE_MODE 0x100 // user specified Adobe mode
  210. #define QMODE_NO_STORE_WRAPPER 0x200 // user specified to not store audio file wrapper (RIFF, CAFF, etc.)
  211. #define QMODE_CHANS_UNASSIGNED 0x400 // user specified "..." in --channel-order option
  212. #define QMODE_IGNORE_LENGTH 0x800 // user specified to ignore length in file header
  213. #define QMODE_RAW_PCM 0x1000 // user specified raw PCM format (no header present)
  214. #define QMODE_EVEN_BYTE_DEPTH 0x2000 // user specified to force even byte bit-depth
  215. ////////////// Callbacks used for reading & writing WavPack streams //////////
  216. typedef struct {
  217. int32_t (*read_bytes)(void *id, void *data, int32_t bcount);
  218. uint32_t (*get_pos)(void *id);
  219. int (*set_pos_abs)(void *id, uint32_t pos);
  220. int (*set_pos_rel)(void *id, int32_t delta, int mode);
  221. int (*push_back_byte)(void *id, int c);
  222. uint32_t (*get_length)(void *id);
  223. int (*can_seek)(void *id);
  224. // this callback is for writing edited tags only
  225. int32_t (*write_bytes)(void *id, void *data, int32_t bcount);
  226. } WavpackStreamReader;
  227. // Extended version of structure for handling large files and added
  228. // functionality for truncating and closing files
  229. typedef struct {
  230. int32_t (*read_bytes)(void *id, void *data, int32_t bcount);
  231. int32_t (*write_bytes)(void *id, void *data, int32_t bcount);
  232. int64_t (*get_pos)(void *id); // new signature for large files
  233. int (*set_pos_abs)(void *id, int64_t pos); // new signature for large files
  234. int (*set_pos_rel)(void *id, int64_t delta, int mode); // new signature for large files
  235. int (*push_back_byte)(void *id, int c);
  236. int64_t (*get_length)(void *id); // new signature for large files
  237. int (*can_seek)(void *id);
  238. int (*truncate_here)(void *id); // new function to truncate file at current position
  239. int (*close)(void *id); // new function to close file
  240. } WavpackStreamReader64;
  241. typedef int (*WavpackBlockOutput)(void *id, void *data, int32_t bcount);
  242. //////////////////////////// function prototypes /////////////////////////////
  243. typedef struct WavpackContext WavpackContext;
  244. #ifdef __cplusplus
  245. extern "C" {
  246. #endif
  247. #define MAX_WAVPACK_SAMPLES ((1LL << 40) - 257)
  248. WavpackContext *WavpackOpenRawDecoder (
  249. void *main_data, int32_t main_size,
  250. void *corr_data, int32_t corr_size,
  251. int16_t version, char *error, int flags, int norm_offset);
  252. WavpackContext *WavpackOpenFileInputEx64 (WavpackStreamReader64 *reader, void *wv_id, void *wvc_id, char *error, int flags, int norm_offset);
  253. WavpackContext *WavpackOpenFileInputEx (WavpackStreamReader *reader, void *wv_id, void *wvc_id, char *error, int flags, int norm_offset);
  254. WavpackContext *WavpackOpenFileInput (const char *infilename, char *error, int flags, int norm_offset);
  255. #define OPEN_WVC 0x1 // open/read "correction" file
  256. #define OPEN_TAGS 0x2 // read ID3v1 / APEv2 tags (seekable file)
  257. #define OPEN_WRAPPER 0x4 // make audio wrapper available (i.e. RIFF)
  258. #define OPEN_2CH_MAX 0x8 // open multichannel as stereo (no downmix)
  259. #define OPEN_NORMALIZE 0x10 // normalize floating point data to +/- 1.0
  260. #define OPEN_STREAMING 0x20 // "streaming" mode blindly unpacks blocks
  261. // w/o regard to header file position info
  262. #define OPEN_EDIT_TAGS 0x40 // allow editing of tags
  263. #define OPEN_FILE_UTF8 0x80 // assume filenames are UTF-8 encoded, not ANSI (Windows only)
  264. // new for version 5
  265. #define OPEN_DSD_NATIVE 0x100 // open DSD files as bitstreams
  266. // (returned as 8-bit "samples" stored in 32-bit words)
  267. #define OPEN_DSD_AS_PCM 0x200 // open DSD files as 24-bit PCM (decimated 8x)
  268. #define OPEN_ALT_TYPES 0x400 // application is aware of alternate file types & qmode
  269. // (just affects retrieving wrappers & MD5 checksums)
  270. #define OPEN_NO_CHECKSUM 0x800 // don't verify block checksums before decoding
  271. // new for multithreaded
  272. #define OPEN_THREADS_SHFT 12 // specify number of additional worker threads here for
  273. #define OPEN_THREADS_MASK 0xF000 // decode; 0 to disable, otherwise 1-15 added threads
  274. int WavpackGetMode (WavpackContext *wpc);
  275. #define MODE_WVC 0x1
  276. #define MODE_LOSSLESS 0x2
  277. #define MODE_HYBRID 0x4
  278. #define MODE_FLOAT 0x8
  279. #define MODE_VALID_TAG 0x10
  280. #define MODE_HIGH 0x20
  281. #define MODE_FAST 0x40
  282. #define MODE_EXTRA 0x80 // extra mode used, see MODE_XMODE for possible level
  283. #define MODE_APETAG 0x100
  284. #define MODE_SFX 0x200
  285. #define MODE_VERY_HIGH 0x400
  286. #define MODE_MD5 0x800
  287. #define MODE_XMODE 0x7000 // mask for extra level (1-6, 0=unknown)
  288. #define MODE_DNS 0x8000
  289. int WavpackVerifySingleBlock (unsigned char *buffer, int verify_checksum);
  290. int WavpackGetQualifyMode (WavpackContext *wpc);
  291. char *WavpackGetErrorMessage (WavpackContext *wpc);
  292. int WavpackGetVersion (WavpackContext *wpc);
  293. char *WavpackGetFileExtension (WavpackContext *wpc);
  294. unsigned char WavpackGetFileFormat (WavpackContext *wpc);
  295. uint32_t WavpackUnpackSamples (WavpackContext *wpc, int32_t *buffer, uint32_t samples);
  296. uint32_t WavpackGetNumSamples (WavpackContext *wpc);
  297. int64_t WavpackGetNumSamples64 (WavpackContext *wpc);
  298. uint32_t WavpackGetNumSamplesInFrame (WavpackContext *wpc);
  299. uint32_t WavpackGetSampleIndex (WavpackContext *wpc);
  300. int64_t WavpackGetSampleIndex64 (WavpackContext *wpc);
  301. int WavpackGetNumErrors (WavpackContext *wpc);
  302. int WavpackLossyBlocks (WavpackContext *wpc);
  303. int WavpackSeekSample (WavpackContext *wpc, uint32_t sample);
  304. int WavpackSeekSample64 (WavpackContext *wpc, int64_t sample);
  305. WavpackContext *WavpackCloseFile (WavpackContext *wpc);
  306. uint32_t WavpackGetSampleRate (WavpackContext *wpc);
  307. uint32_t WavpackGetNativeSampleRate (WavpackContext *wpc);
  308. int WavpackGetBitsPerSample (WavpackContext *wpc);
  309. int WavpackGetBytesPerSample (WavpackContext *wpc);
  310. int WavpackGetNumChannels (WavpackContext *wpc);
  311. int WavpackGetChannelMask (WavpackContext *wpc);
  312. int WavpackGetReducedChannels (WavpackContext *wpc);
  313. int WavpackGetFloatNormExp (WavpackContext *wpc);
  314. int WavpackGetMD5Sum (WavpackContext *wpc, unsigned char data [16]);
  315. void WavpackGetChannelIdentities (WavpackContext *wpc, unsigned char *identities);
  316. uint32_t WavpackGetChannelLayout (WavpackContext *wpc, unsigned char *reorder);
  317. uint32_t WavpackGetWrapperBytes (WavpackContext *wpc);
  318. unsigned char *WavpackGetWrapperData (WavpackContext *wpc);
  319. void WavpackFreeWrapper (WavpackContext *wpc);
  320. void WavpackSeekTrailingWrapper (WavpackContext *wpc);
  321. double WavpackGetProgress (WavpackContext *wpc);
  322. uint32_t WavpackGetFileSize (WavpackContext *wpc);
  323. int64_t WavpackGetFileSize64 (WavpackContext *wpc);
  324. double WavpackGetRatio (WavpackContext *wpc);
  325. double WavpackGetAverageBitrate (WavpackContext *wpc, int count_wvc);
  326. double WavpackGetInstantBitrate (WavpackContext *wpc);
  327. int WavpackGetNumTagItems (WavpackContext *wpc);
  328. int WavpackGetTagItem (WavpackContext *wpc, const char *item, char *value, int size);
  329. int WavpackGetTagItemIndexed (WavpackContext *wpc, int index, char *item, int size);
  330. int WavpackGetNumBinaryTagItems (WavpackContext *wpc);
  331. int WavpackGetBinaryTagItem (WavpackContext *wpc, const char *item, char *value, int size);
  332. int WavpackGetBinaryTagItemIndexed (WavpackContext *wpc, int index, char *item, int size);
  333. int WavpackAppendTagItem (WavpackContext *wpc, const char *item, const char *value, int vsize);
  334. int WavpackAppendBinaryTagItem (WavpackContext *wpc, const char *item, const char *value, int vsize);
  335. int WavpackDeleteTagItem (WavpackContext *wpc, const char *item);
  336. int WavpackWriteTag (WavpackContext *wpc);
  337. WavpackContext *WavpackOpenFileOutput (WavpackBlockOutput blockout, void *wv_id, void *wvc_id);
  338. void WavpackSetFileInformation (WavpackContext *wpc, char *file_extension, unsigned char file_format);
  339. #define WP_FORMAT_WAV 0 // Microsoft RIFF, including BWF and RF64 variants
  340. #define WP_FORMAT_W64 1 // Sony Wave64
  341. #define WP_FORMAT_CAF 2 // Apple CoreAudio
  342. #define WP_FORMAT_DFF 3 // Philips DSDIFF
  343. #define WP_FORMAT_DSF 4 // Sony DSD Format
  344. #define WP_FORMAT_AIF 5 // Apple AIFF
  345. int WavpackSetConfiguration (WavpackContext *wpc, WavpackConfig *config, uint32_t total_samples);
  346. int WavpackSetConfiguration64 (WavpackContext *wpc, WavpackConfig *config, int64_t total_samples, const unsigned char *chan_ids);
  347. int WavpackSetChannelLayout (WavpackContext *wpc, uint32_t layout_tag, const unsigned char *reorder);
  348. int WavpackAddWrapper (WavpackContext *wpc, void *data, uint32_t bcount);
  349. int WavpackStoreMD5Sum (WavpackContext *wpc, unsigned char data [16]);
  350. int WavpackPackInit (WavpackContext *wpc);
  351. int WavpackPackSamples (WavpackContext *wpc, int32_t *sample_buffer, uint32_t sample_count);
  352. int WavpackFlushSamples (WavpackContext *wpc);
  353. void WavpackUpdateNumSamples (WavpackContext *wpc, void *first_block);
  354. void *WavpackGetWrapperLocation (void *first_block, uint32_t *size);
  355. double WavpackGetEncodedNoise (WavpackContext *wpc, double *peak);
  356. void WavpackFloatNormalize (int32_t *values, int32_t num_values, int delta_exp);
  357. void WavpackLittleEndianToNative (void *data, char *format);
  358. void WavpackNativeToLittleEndian (void *data, char *format);
  359. void WavpackBigEndianToNative (void *data, char *format);
  360. void WavpackNativeToBigEndian (void *data, char *format);
  361. uint32_t WavpackGetLibraryVersion (void);
  362. const char *WavpackGetLibraryVersionString (void);
  363. #ifdef __cplusplus
  364. }
  365. #endif
  366. #endif