1 /* Based on common.h from libavcodec. Modified extensively by Matt Campbell 2 <mattcampbell@pobox.com> for the stand-alone mpaudec library. */ 3 4 #ifndef INTERNAL_H 5 #define INTERNAL_H 6 7 #if defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) 8 # define CONFIG_WIN32 9 #endif 10 11 #include <stdlib.h> 12 #include <stdio.h> 13 #include <string.h> 14 #include <ctype.h> 15 #include <math.h> 16 #include <stddef.h> 17 #include "mpaudec.h" 18 19 #ifndef M_PI 20 #define M_PI 3.14159265358979323846 21 #endif 22 23 #ifdef CONFIG_WIN32 24 25 /* windows */ 26 27 typedef unsigned short uint16_t; 28 typedef signed short int16_t; 29 typedef unsigned char uint8_t; 30 typedef unsigned int uint32_t; 31 typedef unsigned __int64 uint64_t; 32 typedef signed char int8_t; 33 typedef signed int int32_t; 34 typedef signed __int64 int64_t; 35 36 # ifdef _DEBUG 37 # define DEBUG 38 # endif 39 40 /* CONFIG_WIN32 end */ 41 #else 42 43 /* unix */ 44 45 #include <inttypes.h> 46 47 #endif /* !CONFIG_WIN32 */ 48 49 /* debug stuff */ 50 51 #if !defined(DEBUG) && !defined(NDEBUG) 52 # define NDEBUG 53 #endif 54 #include <assert.h> 55 56 /* bit input */ 57 58 typedef struct GetBitContext { 59 const uint8_t *buffer; 60 int index; 61 int size_in_bits; 62 } GetBitContext; 63 64 int get_bits_count(const GetBitContext *s); 65 66 #define VLC_TYPE int16_t 67 68 typedef struct VLC { 69 int bits; 70 VLC_TYPE (*table)[2]; 71 int table_size, table_allocated; 72 } VLC; 73 74 unsigned int get_bits(GetBitContext *s, int n); 75 unsigned int show_bits(const GetBitContext *s, int n); 76 void skip_bits(GetBitContext *s, int n); 77 void init_get_bits(GetBitContext *s, 78 const uint8_t *buffer, int buffer_size); 79 80 int init_vlc(VLC *vlc, int nb_bits, int nb_codes, 81 const void *bits, int bits_wrap, int bits_size, 82 const void *codes, int codes_wrap, int codes_size); 83 void free_vlc(VLC *vlc); 84 int get_vlc(GetBitContext *s, const VLC *vlc); 85 86 #endif /* INTERNAL_H */ 87