Mercurial > mplayer.hg
changeset 18075:2373ed2ee546
try to detect flac bitrate early on to avoid division by zero problems.
Should also help with mencoder and -oac copy
author | reimar |
---|---|
date | Tue, 11 Apr 2006 10:46:52 +0000 |
parents | a491d7628cdc |
children | d30afd14867f |
files | libmpdemux/demux_audio.c |
diffstat | 1 files changed, 16 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/demux_audio.c Tue Apr 11 10:43:20 2006 +0000 +++ b/libmpdemux/demux_audio.c Tue Apr 11 10:46:52 2006 +0000 @@ -332,7 +332,6 @@ } } else if( hdr[0] == 'f' && hdr[1] == 'L' && hdr[2] == 'a' && hdr[3] == 'C' ) { frmt = fLaC; - stream_skip(s,-4); break; } // Add here some other audio format detection @@ -502,8 +501,23 @@ } break; case fLaC: sh_audio->format = mmioFOURCC('f', 'L', 'a', 'C'); - demuxer->movi_start = stream_tell(s); + demuxer->movi_start = stream_tell(s) - 4; demuxer->movi_end = s->end_pos; + if (demuxer->movi_end > demuxer->movi_start) { + // try to find out approx. bitrate + int64_t size = demuxer->movi_end - demuxer->movi_start; + int64_t num_samples = 0; + int32_t srate = 0; + stream_skip(s, 14); + stream_read(s, (char *)&srate, 3); + srate = be2me_32(srate) >> 12; + stream_read(s, (char *)&num_samples, 5); + num_samples = (be2me_64(num_samples) >> 24) & 0xfffffffff; + if (num_samples && srate) + sh_audio->i_bps = size * srate / num_samples; + } + if (sh_audio->i_bps < 1) // guess value to prevent crash + sh_audio->i_bps = 64 * 1024; get_flac_metadata (demuxer); break; }