[MPlayer-cvslog] CVS: main/libmpdemux demux_mpc.c,1.6,1.7

Reimar Döffinger CVS syncmail at mplayerhq.hu
Tue Sep 6 22:35:17 CEST 2005


CVS change done by Reimar Döffinger CVS

Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv19315/libmpdemux

Modified Files:
	demux_mpc.c 
Log Message:
better bitrate calculation


Index: demux_mpc.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mpc.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- demux_mpc.c	6 Sep 2005 19:40:19 -0000	1.6
+++ demux_mpc.c	6 Sep 2005 20:35:14 -0000	1.7
@@ -62,6 +62,8 @@
 
   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 @@
     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;




More information about the MPlayer-cvslog mailing list