[MPlayer-cvslog] CVS: main/libmpdemux demux_audio.c,1.50,1.51

Reimar Döffinger CVS syncmail at mplayerhq.hu
Tue Apr 11 12:46:54 CEST 2006


CVS change done by Reimar Döffinger CVS

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

Modified Files:
	demux_audio.c 
Log Message:
try to detect flac bitrate early on to avoid division by zero problems.
Should also help with mencoder and -oac copy


Index: demux_audio.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_audio.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- demux_audio.c	11 Apr 2006 10:43:20 -0000	1.50
+++ demux_audio.c	11 Apr 2006 10:46:52 -0000	1.51
@@ -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;
   }




More information about the MPlayer-cvslog mailing list