1 /* 2 Copyright (c) 2005-2009, The Musepack Development Team 3 All rights reserved. 4 5 Redistribution and use in source and binary forms, with or without 6 modification, are permitted provided that the following conditions are 7 met: 8 9 * Redistributions of source code must retain the above copyright 10 notice, this list of conditions and the following disclaimer. 11 12 * Redistributions in binary form must reproduce the above 13 copyright notice, this list of conditions and the following 14 disclaimer in the documentation and/or other materials provided 15 with the distribution. 16 17 * Neither the name of the The Musepack Development Team nor the 18 names of its contributors may be used to endorse or promote 19 products derived from this software without specific prior 20 written permission. 21 22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 */ 34 #ifndef _MPC_TYPES_H_ 35 #define _MPC_TYPES_H_ 36 #ifdef WIN32 37 #pragma once 38 #endif 39 40 #ifdef HAVE_CONFIG_H 41 #include <config.h> 42 #endif 43 44 #include <stdlib.h> 45 #include <memory.h> 46 47 #ifdef __cplusplus 48 extern "C" { 49 #endif 50 51 #ifdef _MSC_VER 52 typedef __int8 mpc_int8_t; 53 typedef unsigned __int8 mpc_uint8_t; 54 typedef __int16 mpc_int16_t; 55 typedef unsigned __int16 mpc_uint16_t; 56 typedef __int32 mpc_int32_t; 57 typedef unsigned __int32 mpc_uint32_t; 58 typedef __int64 mpc_int64_t; 59 typedef unsigned __int64 mpc_uint64_t; 60 #define mpc_inline __inline 61 #else 62 #include <stdint.h> 63 typedef int8_t mpc_int8_t; 64 typedef uint8_t mpc_uint8_t; 65 typedef int16_t mpc_int16_t; 66 typedef uint16_t mpc_uint16_t; 67 typedef int32_t mpc_int32_t; 68 typedef uint32_t mpc_uint32_t; 69 typedef int64_t mpc_int64_t; 70 typedef uint64_t mpc_uint64_t; 71 #define mpc_inline inline 72 #endif 73 74 typedef int mpc_int_t; 75 typedef unsigned int mpc_uint_t; 76 typedef size_t mpc_size_t; 77 typedef mpc_uint8_t mpc_bool_t; 78 79 // #define LONG_SEEK_TABLE 80 #ifdef LONG_SEEK_TABLE // define as needed (mpc_uint32_t supports files up to 512 MB) 81 typedef mpc_uint64_t mpc_seek_t; 82 #else 83 typedef mpc_uint32_t mpc_seek_t; 84 #endif 85 86 # define mpc_int64_min -9223372036854775808ll 87 # define mpc_int64_max 9223372036854775807ll 88 89 typedef struct mpc_quantizer { 90 mpc_int16_t L [36]; 91 mpc_int16_t R [36]; 92 } mpc_quantizer; 93 94 /// Libmpcdec error codes 95 typedef enum mpc_status { 96 // Success. 97 MPC_STATUS_OK = 0, 98 // Generic failure (I/O error or invalid file). 99 MPC_STATUS_FAIL = -1 100 } mpc_status; 101 102 103 #define MPC_FIXED_POINT_SHIFT 16 104 105 #ifdef MPC_FIXED_POINT 106 # define MPC_FIXED_POINT_FRACTPART 14 107 # define MPC_FIXED_POINT_SCALE_SHIFT (MPC_FIXED_POINT_SHIFT + MPC_FIXED_POINT_FRACTPART) 108 # define MPC_FIXED_POINT_SCALE (1 << (MPC_FIXED_POINT_SCALE_SHIFT - 1)) 109 typedef mpc_int32_t MPC_SAMPLE_FORMAT; 110 #else 111 typedef float MPC_SAMPLE_FORMAT; 112 #endif 113 114 enum { 115 MPC_FALSE = 0, 116 MPC_TRUE = !MPC_FALSE 117 }; 118 119 //// 'Cdecl' forces the use of standard C/C++ calling convention /////// 120 #if defined _WIN32 121 # define mpc_cdecl __cdecl 122 #elif defined __ZTC__ 123 # define mpc_cdecl _cdecl 124 #elif defined __TURBOC__ 125 # define mpc_cdecl cdecl 126 #else 127 # define mpc_cdecl 128 #endif 129 130 /* DLL building support on win32 hosts */ 131 #ifndef MPC_API 132 # ifdef DLL_EXPORT /* defined by libtool (if required) */ 133 # define MPC_API __declspec(dllexport) 134 # endif 135 # ifdef MPC_DLL_IMPORT /* define if linking with this dll */ 136 # define MPC_API __declspec(dllimport) 137 # endif 138 # ifndef MPC_API /* static linking or !_WIN32 */ 139 # if defined(__GNUC__) && (__GNUC__ >= 4) 140 # define MPC_API __attribute__ ((visibility("default"))) 141 # else 142 # define MPC_API 143 # endif 144 # endif 145 #endif 146 147 #ifdef __cplusplus 148 } 149 #endif 150 #endif 151