Mercurial > audlegacy-plugins
diff 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 |
line wrap: on
line diff
--- a/src/madplug/decoder.c Tue Feb 27 03:45:34 2007 -0800 +++ b/src/madplug/decoder.c Tue Feb 27 04:17:49 2007 -0800 @@ -256,7 +256,12 @@ g_message("size = %d", stream.next_frame - stream.this_frame); #endif #endif - mad_timer_add(&info->duration, header.duration); + if(info->tuple->length == -1) + mad_timer_add(&info->duration, header.duration); + else { + info->duration.seconds = info->tuple->length / 1000; + info->duration.fraction = info->tuple->length % 1000; + } data_used += stream.next_frame - stream.this_frame; if (info->frames == 1) { /* most of these *should* remain constant */ @@ -283,7 +288,12 @@ has_xing = TRUE; info->vbr = TRUE; /* otherwise xing header would have been 'Info' */ info->frames = info->xing.frames; - mad_timer_multiply(&info->duration, info->frames); + if(info->tuple->length == -1) + mad_timer_multiply(&info->duration, info->frames); + else { + info->duration.seconds = info->tuple->length / 1000; + info->duration.fraction = info->tuple->length % 1000; + } info->bitrate = 8.0 * info->xing.bytes / mad_timer_count(info->duration, @@ -313,9 +323,15 @@ if (fast && info->frames >= N_AVERAGE_FRAMES) { float frame_size = ((double) data_used) / N_AVERAGE_FRAMES; info->frames = (info->size - tagsize) / frame_size; - info->duration.seconds /= N_AVERAGE_FRAMES; - info->duration.fraction /= N_AVERAGE_FRAMES; - mad_timer_multiply(&info->duration, info->frames); + if(info->tuple->length == -1) { + info->duration.seconds /= N_AVERAGE_FRAMES; + info->duration.fraction /= N_AVERAGE_FRAMES; + mad_timer_multiply(&info->duration, info->frames); + } + else { + info->duration.seconds = info->tuple->length / 1000; + info->duration.fraction = info->tuple->length % 1000; + } #ifdef DEBUG g_message("using fast playtime calculation"); g_message("data used = %d [tagsize=%d framesize=%f]",
