Changeset 414 for libmpc/trunk/mpcchap/mpcchap.c
- Timestamp:
- 11/02/08 01:21:42 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpc/trunk/mpcchap/mpcchap.c
r411 r414 38 38 39 39 #ifdef _MSC_VER 40 #define atoll _atoi64 40 # include <io.h> 41 # define atoll _atoi64 42 # define ftruncate chsize 43 # define strcasecmp stricmp 41 44 #endif 42 45 … … 66 69 struct stat stbuf; 67 70 FILE * in_file; 68 int chap_pos, end_pos, chap_size, i; 71 int chap_pos, end_pos, chap_size, i, nchap; 72 char * tmp_buff; 73 dictionary * dict; 69 74 70 75 chap_pos = (demux->chap_pos >> 3) + si->header_position; … … 73 78 74 79 stat(mpc_file, &stbuf); 75 char *tmp_buff = malloc(stbuf.st_size - chap_pos - chap_size);80 tmp_buff = malloc(stbuf.st_size - chap_pos - chap_size); 76 81 in_file = fopen( mpc_file, "r+b" ); 77 82 fseek(in_file, chap_pos + chap_size, SEEK_SET); … … 79 84 fseek(in_file, chap_pos, SEEK_SET); 80 85 81 dict ionary * dict= iniparser_load(chap_file);82 83 intnchap = iniparser_getnsec(dict);86 dict = iniparser_load(chap_file); 87 88 nchap = iniparser_getnsec(dict); 84 89 for (i = 0; i < nchap; i++) { 85 int j, nitem, ntags = 0, tag_len = 0 ;90 int j, nitem, ntags = 0, tag_len = 0, offset_size; 86 91 mpc_uint16_t gain = 0, peak = 0; 87 char * chap_sec = iniparser_getsecname(dict, i) ;92 char * chap_sec = iniparser_getsecname(dict, i), block_header[12] = "CT", sample_offset[10]; 88 93 mpc_int64_t chap_pos = atoll(chap_sec); 89 94 … … 112 117 } 113 118 if (ntags > 0) tag_len += 24 + ntags * 9; 114 char block_header[12] = "CT"; 115 char sample_offset[10]; 116 int offset_size = encodeSize(chap_pos, sample_offset, MPC_FALSE); 119 120 offset_size = encodeSize(chap_pos, sample_offset, MPC_FALSE); 117 121 tag_len = encodeSize(tag_len + 4 + offset_size + 2, block_header + 2, MPC_TRUE); 118 122 fwrite(block_header, 1, tag_len + 2, in_file); … … 143 147 FILE * in_file; 144 148 int chap_pos, end_pos, chap_size, i; 149 char * tmp_buff; 145 150 146 151 if (0 == (cd = cf_parse(chap_file, &format))) { … … 154 159 155 160 stat(mpc_file, &stbuf); 156 char *tmp_buff = malloc(stbuf.st_size - chap_pos - chap_size);161 tmp_buff = malloc(stbuf.st_size - chap_pos - chap_size); 157 162 in_file = fopen( mpc_file, "r+b" ); 158 163 fseek(in_file, chap_pos + chap_size, SEEK_SET); … … 162 167 nchap = cd_get_ntrack(cd); 163 168 for (i = 1; i <= nchap; i++) { 164 int j, nitem = 0, tag_len = 0, key_len, item_len; 169 char track_buf[16], block_header[12] = "CT", sample_offset[10]; 170 int j, nitem = 0, tag_len = 0, key_len, item_len, offset_size; 165 171 Track * track; 166 172 Cdtext *cdtext; 173 mpc_int64_t chap_pos; 167 174 168 175 track = cd_get_track (cd, i); … … 170 177 171 178 // position du chapitre 172 mpc_int64_tchap_pos = (mpc_int64_t) si->sample_freq * track_get_start (track) / 75;179 chap_pos = (mpc_int64_t) si->sample_freq * track_get_start (track) / 75; 173 180 174 181 if (chap_pos > si->samples - si->beg_silence) … … 178 185 Init_Tags(); 179 186 180 char track_buf[16];181 187 sprintf(track_buf, "%i/%i", i, nchap); 182 188 key_len = 5; … … 199 205 200 206 tag_len += 24 + nitem * 9; 201 char block_header[12] = "CT"; 202 char sample_offset[10]; 203 int offset_size = encodeSize(chap_pos, sample_offset, MPC_FALSE); 207 offset_size = encodeSize(chap_pos, sample_offset, MPC_FALSE); 204 208 tag_len = encodeSize(tag_len + 4 + offset_size + 2, block_header + 2, MPC_TRUE); 205 209 fwrite(block_header, 1, tag_len + 2, in_file); … … 262 266 mpc_status err; 263 267 FILE * test_file; 268 int chap_nb; 264 269 265 270 if (argc != 3) … … 281 286 } 282 287 283 intchap_nb = mpc_demux_chap_nb(demux);288 chap_nb = mpc_demux_chap_nb(demux); 284 289 285 290 test_file = fopen(chap_file, "rb" );
Note: See TracChangeset
for help on using the changeset viewer.