Mercurial > audlegacy-plugins
diff src/madplug/decoder.c @ 959:b2fbf53360cf trunk
[svn] bug fix for #897
- make mp3 header parsing continue even if xing header is located first.
- if xing header does not provide enough information to calculate average bitrate, scan_file() now calculate it from frames.
| author | yaz |
|---|---|
| date | Sat, 14 Apr 2007 22:08:50 -0700 |
| parents | 3673bbab7372 |
| children | 6ba4a4bfd127 |
line wrap: on
line diff
--- a/src/madplug/decoder.c Sat Apr 14 18:09:55 2007 -0700 +++ b/src/madplug/decoder.c Sat Apr 14 22:08:50 2007 -0700 @@ -178,6 +178,7 @@ struct mad_frame frame; /* to read xing data */ gboolean has_xing = FALSE; int bitrate_frames = 0; + guint xing_bitrate = 0; mad_stream_init(&stream); mad_header_init(&header); @@ -299,11 +300,14 @@ info->duration.seconds = info->tuple->length / 1000; info->duration.fraction = info->tuple->length % 1000; } - info->bitrate = + xing_bitrate = 8.0 * info->xing.bytes / mad_timer_count(info->duration, MAD_UNITS_SECONDS); - break; +#ifdef DEBUG + g_message("xing: bitrate = %d", xing_bitrate); +#endif + continue; } } @@ -363,8 +367,12 @@ break; } - if (info->vbr && !has_xing) + if (info->vbr && xing_bitrate == 0) { info->bitrate = info->bitrate / bitrate_frames; +#ifdef DEBUG + g_message("info->bitrate = %d", info->bitrate); +#endif + } mad_frame_finish(&frame); mad_header_finish(&header); @@ -372,6 +380,7 @@ xing_finish(&info->xing); #ifdef DEBUG + g_message("scan_file: info->frames = %d", info->frames); g_message("e: scan_file"); #endif /* DEBUG */ return (info->frames != 0 || info->remote == TRUE);
