comparison src/madplug/decoder.c @ 738:6ea974a229a8 trunk

[svn] - add read/write support for TLEN frame.
author yaz
date Tue, 27 Feb 2007 04:17:49 -0800
parents 1733b12ef974
children 59b4bce10c3b
comparison
equal deleted inserted replaced
737:eecd54a11610 738:6ea974a229a8
254 mad_timer_count(header.duration, 254 mad_timer_count(header.duration,
255 MAD_UNITS_MILLISECONDS)); 255 MAD_UNITS_MILLISECONDS));
256 g_message("size = %d", stream.next_frame - stream.this_frame); 256 g_message("size = %d", stream.next_frame - stream.this_frame);
257 #endif 257 #endif
258 #endif 258 #endif
259 mad_timer_add(&info->duration, header.duration); 259 if(info->tuple->length == -1)
260 mad_timer_add(&info->duration, header.duration);
261 else {
262 info->duration.seconds = info->tuple->length / 1000;
263 info->duration.fraction = info->tuple->length % 1000;
264 }
260 data_used += stream.next_frame - stream.this_frame; 265 data_used += stream.next_frame - stream.this_frame;
261 if (info->frames == 1) { 266 if (info->frames == 1) {
262 /* most of these *should* remain constant */ 267 /* most of these *should* remain constant */
263 info->bitrate = header.bitrate; 268 info->bitrate = header.bitrate;
264 info->freq = header.samplerate; 269 info->freq = header.samplerate;
281 g_message("found xing header"); 286 g_message("found xing header");
282 #endif /* DEBUG */ 287 #endif /* DEBUG */
283 has_xing = TRUE; 288 has_xing = TRUE;
284 info->vbr = TRUE; /* otherwise xing header would have been 'Info' */ 289 info->vbr = TRUE; /* otherwise xing header would have been 'Info' */
285 info->frames = info->xing.frames; 290 info->frames = info->xing.frames;
286 mad_timer_multiply(&info->duration, info->frames); 291 if(info->tuple->length == -1)
292 mad_timer_multiply(&info->duration, info->frames);
293 else {
294 info->duration.seconds = info->tuple->length / 1000;
295 info->duration.fraction = info->tuple->length % 1000;
296 }
287 info->bitrate = 297 info->bitrate =
288 8.0 * info->xing.bytes / 298 8.0 * info->xing.bytes /
289 mad_timer_count(info->duration, 299 mad_timer_count(info->duration,
290 MAD_UNITS_SECONDS); 300 MAD_UNITS_SECONDS);
291 break; 301 break;
311 } 321 }
312 no_xing: 322 no_xing:
313 if (fast && info->frames >= N_AVERAGE_FRAMES) { 323 if (fast && info->frames >= N_AVERAGE_FRAMES) {
314 float frame_size = ((double) data_used) / N_AVERAGE_FRAMES; 324 float frame_size = ((double) data_used) / N_AVERAGE_FRAMES;
315 info->frames = (info->size - tagsize) / frame_size; 325 info->frames = (info->size - tagsize) / frame_size;
316 info->duration.seconds /= N_AVERAGE_FRAMES; 326 if(info->tuple->length == -1) {
317 info->duration.fraction /= N_AVERAGE_FRAMES; 327 info->duration.seconds /= N_AVERAGE_FRAMES;
318 mad_timer_multiply(&info->duration, info->frames); 328 info->duration.fraction /= N_AVERAGE_FRAMES;
329 mad_timer_multiply(&info->duration, info->frames);
330 }
331 else {
332 info->duration.seconds = info->tuple->length / 1000;
333 info->duration.fraction = info->tuple->length % 1000;
334 }
319 #ifdef DEBUG 335 #ifdef DEBUG
320 g_message("using fast playtime calculation"); 336 g_message("using fast playtime calculation");
321 g_message("data used = %d [tagsize=%d framesize=%f]", 337 g_message("data used = %d [tagsize=%d framesize=%f]",
322 data_used, tagsize, frame_size); 338 data_used, tagsize, frame_size);
323 g_message("frames = %d, frequency = %d, channels = %d", 339 g_message("frames = %d, frequency = %d, channels = %d",