diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2005-09-06 20:35:14 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2005-09-06 20:35:14 +0000 |
commit | cb1bcc8b7954382079099a64dae3037fd8b399c3 (patch) | |
tree | ae657f1c09b991a73dd8e5fc10ca88282c65a276 /libmpdemux | |
parent | a6c5758715bfa048d857d57a238c3a71df3dc836 (diff) |
better bitrate calculation
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@16415 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r-- | libmpdemux/demux_mpc.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libmpdemux/demux_mpc.c b/libmpdemux/demux_mpc.c index cf4a87203a..1faa6ee613 100644 --- a/libmpdemux/demux_mpc.c +++ b/libmpdemux/demux_mpc.c @@ -62,6 +62,8 @@ static int demux_mpc_check(demuxer_t* demuxer) { if (hdr[0] != 'M' || hdr[1] != 'P' || hdr[2] != '+') return 0; + demuxer->movi_start = stream_tell(s) - HDR_SIZE; + demuxer->movi_end = s->end_pos; demuxer->priv = malloc(HDR_SIZE); memcpy(demuxer->priv, hdr, HDR_SIZE); return DEMUXER_TYPE_MPC; @@ -78,16 +80,23 @@ static demuxer_t *demux_mpc_open(demuxer_t* demuxer) { char *wf = (char *)calloc(1, sizeof(WAVEFORMATEX) + HDR_SIZE); char *header = &wf[sizeof(WAVEFORMATEX)]; const int freqs[4] = {44100, 48000, 37800, 32000}; + int frames; + int seconds; sh_audio->format = mmioFOURCC('M', 'P', 'C', ' '); memcpy(header, priv, HDR_SIZE); free(priv); + frames = header[4] | header[5] << 8 | header[6] << 16 | header[7] << 24; sh_audio->wf = (WAVEFORMATEX *)wf; sh_audio->wf->wFormatTag = sh_audio->format; sh_audio->wf->nChannels = 2; sh_audio->wf->nSamplesPerSec = freqs[header[10] & 3]; sh_audio->wf->nBlockAlign = 32 * 36; sh_audio->wf->wBitsPerSample = 16; - sh_audio->wf->nAvgBytesPerSec = 128 * 1024; // dummy to make mencoder not hang + seconds = 1152 * frames / sh_audio->wf->nSamplesPerSec; + if (demuxer->movi_end > demuxer->movi_start && seconds > 0) + sh_audio->wf->nAvgBytesPerSec = (demuxer->movi_end - demuxer->movi_start) / seconds; + else + sh_audio->wf->nAvgBytesPerSec = 32 * 1024; // dummy to make mencoder not hang sh_audio->wf->cbSize = HDR_SIZE; demuxer->movi_start = stream_tell(s); demuxer->movi_end = s->end_pos; |