libmpcdec  1.2.2
mpc_types.h
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 #include <stdlib.h>
41 #include <memory.h>
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 #ifdef _MSC_VER
48 typedef __int8 mpc_int8_t;
49 typedef unsigned __int8 mpc_uint8_t;
50 typedef __int16 mpc_int16_t;
51 typedef unsigned __int16 mpc_uint16_t;
52 typedef __int32 mpc_int32_t;
53 typedef unsigned __int32 mpc_uint32_t;
54 typedef __int64 mpc_int64_t;
55 typedef unsigned __int64 mpc_uint64_t;
56 #define mpc_inline __inline
57 #else
58 #include <stdint.h>
59 typedef int8_t mpc_int8_t;
60 typedef uint8_t mpc_uint8_t;
61 typedef int16_t mpc_int16_t;
62 typedef uint16_t mpc_uint16_t;
63 typedef int32_t mpc_int32_t;
64 typedef uint32_t mpc_uint32_t;
65 typedef int64_t mpc_int64_t;
66 typedef uint64_t mpc_uint64_t;
67 #define mpc_inline inline
68 #endif
69 
70 typedef int mpc_int_t;
71 typedef unsigned int mpc_uint_t;
72 typedef size_t mpc_size_t;
73 typedef mpc_uint8_t mpc_bool_t;
74 
75 // #define LONG_SEEK_TABLE
76 #ifdef LONG_SEEK_TABLE // define as needed (mpc_uint32_t supports files up to 512 MB)
77 typedef mpc_uint64_t mpc_seek_t;
78 #else
79 typedef mpc_uint32_t mpc_seek_t;
80 #endif
81 
82 # define mpc_int64_min -9223372036854775808ll
83 # define mpc_int64_max 9223372036854775807ll
84 
85 typedef struct mpc_quantizer {
86  mpc_int16_t L [36];
87  mpc_int16_t R [36];
89 
91 typedef enum mpc_status {
92  MPC_STATUS_OK = 0,
93  MPC_STATUS_FILE = -1,
94  MPC_STATUS_SV7BETA = -2,
95  MPC_STATUS_CBR = -3,
96  MPC_STATUS_IS = -4,
97  MPC_STATUS_BLOCKSIZE = -5,
98  MPC_STATUS_INVALIDSV = -6
99 } mpc_status;
100 
101 
102 #define MPC_FIXED_POINT_SHIFT 16
103 
104 #ifdef MPC_FIXED_POINT
105 # define MPC_FIXED_POINT_FRACTPART 14
106 # define MPC_FIXED_POINT_SCALE_SHIFT (MPC_FIXED_POINT_SHIFT + MPC_FIXED_POINT_FRACTPART)
107 # define MPC_FIXED_POINT_SCALE (1 << (MPC_FIXED_POINT_SCALE_SHIFT - 1))
108 typedef mpc_int32_t MPC_SAMPLE_FORMAT;
109 #else
110 typedef float MPC_SAMPLE_FORMAT;
111 #endif
112 
113 enum {
114  MPC_FALSE = 0,
115  MPC_TRUE = !MPC_FALSE
116 };
117 
119 #if defined _WIN32
120 # define mpc_cdecl __cdecl
121 #elif defined __ZTC__
122 # define mpc_cdecl _cdecl
123 #elif defined __TURBOC__
124 # define mpc_cdecl cdecl
125 #else
126 # define mpc_cdecl
127 #endif
128 
129 #ifdef __GNUC__
130 # define MPC_API __attribute__ ((visibility("default")))
131 #else
132 # define MPC_API
133 #endif
134 
135 #ifdef __cplusplus
136 }
137 #endif
138 #endif