comparison libmpdemux/demux_ty.c @ 24450:d8b25c8a4ea4

Small simplifications
author reimar
date Fri, 14 Sep 2007 16:21:12 +0000
parents 1007f99949af
children abcfa91fcc9a
comparison
equal deleted inserted replaced
24449:1007f99949af 24450:d8b25c8a4ea4
138 char header[ 512 ]; 138 char header[ 512 ];
139 char *name; 139 char *name;
140 char *sizestr; 140 char *sizestr;
141 int size; 141 int size;
142 int count; 142 int count;
143 int blocks;
144 int done; 143 int done;
145 off_t offset; 144 off_t offset;
146 off_t totalsize; 145 off_t totalsize;
147 off_t skip; 146 off_t skip;
148 int error = 0; 147 int error = 0;
183 name[99] = 0; 182 name[99] = 0;
184 sizestr = &header[124]; 183 sizestr = &header[124];
185 sizestr[11] = 0; 184 sizestr[11] = 0;
186 size = strtol(sizestr, NULL, 8); 185 size = strtol(sizestr, NULL, 8);
187 186
188 blocks = size / 512; 187 // size rounded up to blocks + header size
189 if ( size % 512 > 0 ) blocks++; 188 skip = 512 + ((size + 511) & ~511);
190 skip = ( blocks + 1 ) * 512;
191 189
192 if ( offset + skip > totalsize ) 190 if ( offset + skip > totalsize )
193 { 191 {
194 size = totalsize - offset; 192 size = totalsize - offset;
195 } 193 }
202 if ( isty ) 200 if ( isty )
203 { 201 {
204 tivo->tmfparts[ parts ].fileNo = parts; 202 tivo->tmfparts[ parts ].fileNo = parts;
205 tivo->tmfparts[ parts ].fileSize = size; 203 tivo->tmfparts[ parts ].fileSize = size;
206 tivo->tmfparts[ parts ].startOffset = offset + 512; 204 tivo->tmfparts[ parts ].startOffset = offset + 512;
207 tivo->tmfparts[ parts ].chunks = 205 tivo->tmfparts[ parts ].chunks = size / CHUNKSIZE;
208 tivo->tmfparts[ parts ].fileSize / CHUNKSIZE;
209 mp_msg 206 mp_msg
210 ( 207 (
211 MSGT_DEMUX, MSGL_DBG3, 208 MSGT_DEMUX, MSGL_DBG3,
212 "tmf_filetoparts(): index %d, file %d, chunks %d\n", 209 "tmf_filetoparts(): index %d, file %d, chunks %d\n",
213 parts, 210 parts,
249 tivo->tmf_totalsize = 0; 246 tivo->tmf_totalsize = 0;
250 tivo->tmf_totalchunks = 0; 247 tivo->tmf_totalchunks = 0;
251 for( index = 0 ; index < tivo->tmf_totalparts ; index++ ) 248 for( index = 0 ; index < tivo->tmf_totalparts ; index++ )
252 { 249 {
253 tivo->tmf_totalsize += tivo->tmfparts[ index ].fileSize; 250 tivo->tmf_totalsize += tivo->tmfparts[ index ].fileSize;
254 tivo->tmf_totalchunks += tivo->tmfparts[ index ].fileSize / CHUNKSIZE; 251 tivo->tmf_totalchunks += tivo->tmfparts[ index ].chunks;
255 } 252 }
256 mp_msg( MSGT_DEMUX, MSGL_DBG3, 253 mp_msg( MSGT_DEMUX, MSGL_DBG3,
257 "tmf_filetoparts():total size %"PRId64"\n", (int64_t)tivo->tmf_totalsize ); 254 "tmf_filetoparts():total size %"PRId64"\n", (int64_t)tivo->tmf_totalsize );
258 mp_msg( MSGT_DEMUX, MSGL_DBG3, 255 mp_msg( MSGT_DEMUX, MSGL_DBG3,
259 "tmf_filetoparts():total chunks %"PRId64"\n", (int64_t)tivo->tmf_totalchunks ); 256 "tmf_filetoparts():total chunks %"PRId64"\n", (int64_t)tivo->tmf_totalchunks );