libmp3splt
|
00001 /********************************************************** 00002 * 00003 * libmp3splt -- library based on mp3splt, 00004 * for mp3/ogg splitting without decoding 00005 * 00006 * Copyright (c) 2002-2005 M. Trotta - <mtrotta@users.sourceforge.net> 00007 * Copyright (c) 2005-2011 Alexandru Munteanu - io_fx@yahoo.fr 00008 * 00009 * http://mp3splt.sourceforge.net 00010 * 00011 *********************************************************/ 00012 00013 /********************************************************** 00014 * 00015 * This program is free software; you can redistribute it and/or 00016 * modify it under the terms of the GNU General Public License 00017 * as published by the Free Software Foundation; either version 2 00018 * of the License, or (at your option) any later version. 00019 * 00020 * This program is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * You should have received a copy of the GNU General Public License 00026 * along with this program; if not, write to the Free Software 00027 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00028 * 02111-1307, 00029 * USA. 00030 * 00031 *********************************************************/ 00032 00033 #ifndef MP3SPLT_MP3_H 00034 00035 #ifndef NO_ID3TAG 00036 #include <id3tag.h> 00037 #endif 00038 00039 #include <mad.h> 00040 00041 /**********************************/ 00042 /* Mp3 structures */ 00043 00044 #define SPLT_MAD_BSIZE 4032 00045 00046 // Struct that will contain header's useful infos 00047 struct splt_header { 00048 off_t ptr; // Offset of header 00049 int bitrate; 00050 int padding; 00051 int framesize; 00052 }; 00053 00054 // Struct that will contains infos on mp3 and an header struct of first valid header 00055 struct splt_mp3 { 00056 int mpgid; // 0 or 1 00057 int layer; // mpg1, mpg2, or mpg3 00058 int channels; 00059 //0 = single channel 00060 //1 = dual channel 00061 //2 = joint stereo 00062 //3 = stereo 00063 //4 = other 00064 //frequency 00065 int freq; 00066 //bitrate 00067 int bitrate; 00068 //frames per second 00069 float fps; 00070 //used for the xing header 00071 int xing; 00072 char *xingbuffer; 00073 off_t xing_offset; 00074 //length of the mp3 file 00075 off_t len; 00076 //where we begin reading 00077 off_t firsth; 00078 struct splt_header firsthead; 00079 }; 00080 00081 typedef struct { 00082 FILE *file_input; 00083 struct splt_header h; 00084 //if we are in framemode or not 00085 short framemode; 00086 //total frames 00087 unsigned long frames; 00088 int syncdetect; 00089 off_t end; 00090 off_t end2; 00091 off_t bytes; 00092 int first; 00093 unsigned long headw; 00094 00095 //see the mp3 structure 00096 struct splt_mp3 mp3file; 00097 00098 //used internally, libmad structures 00099 struct mad_stream stream; 00100 struct mad_frame frame; 00101 struct mad_synth synth; 00102 //internally used by the silence detection functions 00103 mad_fixed_t temp_level; 00104 //the offset 00105 float off; 00106 //used internally when reading the file 00107 unsigned char inputBuffer[SPLT_MAD_BSIZE]; 00108 //mad timer 00109 mad_timer_t timer; 00110 //used internally, pointer to the beginning of a frame 00111 unsigned char *data_ptr; 00112 //used internally, length of a frame 00113 long data_len; 00114 //length of a buffer when reading a frame 00115 int buf_len; 00116 } splt_mp3_state; 00117 00118 /****************************/ 00119 /* mp3 constants */ 00120 00121 /* 00122 Frame per second: 00123 Each MPEG1 frame decodes to 1152 PCM 00124 samples, 576 with MPEG2. 00125 32000/1152 = 27.77778 = 16000/576 00126 44100/1152 = 38.28125 = 22050/576 00127 48000/1152 = 41.66667 = 24000/576 00128 */ 00129 00130 #define SPLT_MP3_TAG "TAG" 00131 #define SPLT_MP3_PCM 1152 00132 #define SPLT_MP3_BYTE 8 00133 00134 #define SPLT_MP3_XING_MAGIC 0x58696E67 00135 #define SPLT_MP3_INFO_MAGIC 0x496E666F 00136 00137 #define SPLT_MP3_XING_FRAMES 0x00000001L 00138 #define SPLT_MP3_XING_BYTES 0x00000002L 00139 00140 #define SPLT_MP3_ID3_ARTIST 1 00141 #define SPLT_MP3_ID3_ALBUM 2 00142 #define SPLT_MP3_ID3_TITLE 3 00143 #define SPLT_MP3_ID3_YEAR 4 00144 #define SPLT_MP3_ID3_GENRE 5 00145 #define SPLT_MP3_ID3_TRACK 6 00146 #define SPLT_MP3_ID3_COMMENT 7 00147 00148 #define SPLT_MP3_CRCLEN 4 00149 #define SPLT_MP3_ABWINDEXOFFSET 0x539 00150 #define SPLT_MP3_ABWLEN 0x1f5 00151 #define SPLT_MP3_INDEXVERSION 1 00152 #define SPLT_MP3_READBSIZE 1024 00153 00154 #define SPLT_MP3EXT ".mp3" 00155 00156 #define MP3SPLT_MP3_H 00157 00158 #endif 00159