00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef MP3SPLT_MP3_H
00034
00035 #include <string.h>
00036 #include <unistd.h>
00037 #include <sys/stat.h>
00038 #include <dirent.h>
00039 #include <math.h>
00040 #include <ctype.h>
00041
00042 #ifdef __WIN32__
00043 #include <io.h>
00044 #include <fcntl.h>
00045 #endif
00046
00047 #ifndef NO_ID3TAG
00048 #include <id3tag.h>
00049 #endif
00050
00051 #include <mad.h>
00052
00053
00054
00055
00056 #define SPLT_MAD_BSIZE 4032
00057
00058 #ifndef NO_ID3TAG
00059 typedef struct {
00060 id3_byte_t *tag_bytes;
00061 id3_length_t tag_length;
00062 } tag_bytes_and_size;
00063 #endif
00064
00065
00066 struct splt_header {
00067 off_t ptr;
00068 int bitrate;
00069 int padding;
00070 int framesize;
00071 };
00072
00073
00074 struct splt_mp3 {
00075 int mpgid;
00076 int layer;
00077 int channels;
00078
00079
00080
00081
00082
00083
00084 int freq;
00085
00086 int bitrate;
00087
00088 float fps;
00089
00090 int xing;
00091 char *xingbuffer;
00092 off_t xing_offset;
00093
00094 off_t len;
00095
00096 off_t firsth;
00097 struct splt_header firsthead;
00098 };
00099
00100 typedef struct {
00101 FILE *file_input;
00102 struct splt_header h;
00103
00104 short framemode;
00105
00106 unsigned long frames;
00107 int syncdetect;
00108 off_t end;
00109 off_t end_non_zero;
00110 off_t end2;
00111 off_t bytes;
00112 int first;
00113 unsigned long headw;
00114
00115
00116 struct splt_mp3 mp3file;
00117
00118
00119 struct mad_stream stream;
00120 struct mad_frame frame;
00121 struct mad_synth synth;
00122
00123 mad_fixed_t temp_level;
00124
00125 float off;
00126
00127 unsigned char inputBuffer[SPLT_MAD_BSIZE];
00128
00129 mad_timer_t timer;
00130
00131 unsigned char *data_ptr;
00132
00133 long data_len;
00134
00135 int buf_len;
00136 } splt_mp3_state;
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 #define SPLT_MP3_TAG "TAG"
00151 #define SPLT_MP3_PCM 1152
00152 #define SPLT_MP3_BYTE 8
00153
00154 #define SPLT_MP3_XING_MAGIC 0x58696E67
00155 #define SPLT_MP3_INFO_MAGIC 0x496E666F
00156
00157 #define SPLT_MP3_XING_FRAMES 0x00000001L
00158 #define SPLT_MP3_XING_BYTES 0x00000002L
00159
00160 #define SPLT_MP3_ID3_ARTIST 1
00161 #define SPLT_MP3_ID3_ALBUM 2
00162 #define SPLT_MP3_ID3_TITLE 3
00163 #define SPLT_MP3_ID3_YEAR 4
00164 #define SPLT_MP3_ID3_GENRE 5
00165 #define SPLT_MP3_ID3_TRACK 6
00166 #define SPLT_MP3_ID3_COMMENT 7
00167
00168 #define SPLT_MP3_CRCLEN 4
00169 #define SPLT_MP3_ABWINDEXOFFSET 0x539
00170 #define SPLT_MP3_ABWLEN 0x1f5
00171 #define SPLT_MP3_INDEXVERSION 1
00172 #define SPLT_MP3_READBSIZE 1024
00173
00174 #define SPLT_MP3EXT ".mp3"
00175
00177 static const int splt_mp3_tabsel_123[2][3][16] = {
00178 { {128,32,64,96,128,160,192,224,256,288,320,352,384,416,448,},
00179 {128,32,48,56, 64, 80, 96,112,128,160,192,224,256,320,384,},
00180 {128,32,40,48, 56, 64, 80, 96,112,128,160,192,224,256,320,} },
00181
00182 { {128,32,48,56,64,80,96,112,128,144,160,176,192,224,256,},
00183 {128,8,16,24,32,40,48,56,64,80,96,112,128,144,160,},
00184 {128,8,16,24,32,40,48,56,64,80,96,112,128,144,160,} }
00185 };
00186
00187 #define MP3SPLT_MP3_H
00188
00189 #endif
00190