diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-04-11 10:46:52 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-04-11 10:46:52 +0000 |
commit | 827ccaa94176f2555486aac97e2fa8726b8c33b0 (patch) | |
tree | e3a634a155693374c6f40e9a795385f9eb5dd84e /libmpdemux | |
parent | b72ebc6fb8bc52666cb40bdbb38478466628df48 (diff) |
try to detect flac bitrate early on to avoid division by zero problems.
Should also help with mencoder and -oac copy
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18076 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r-- | libmpdemux/demux_audio.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/libmpdemux/demux_audio.c b/libmpdemux/demux_audio.c index de9dd87bd9..3d1d00ffc4 100644 --- a/libmpdemux/demux_audio.c +++ b/libmpdemux/demux_audio.c @@ -332,7 +332,6 @@ static int demux_audio_open(demuxer_t* demuxer) { } } 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 @@ static int demux_audio_open(demuxer_t* demuxer) { } 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; } |