diff libmpdemux/mp3_hdr.c @ 15199:980910eb6f0c

assign correct tag, dwScale and dwBlockAlign to mpeg audio; optionally assign layer and samples_per_frame when parsing mpa header
author nicodvb
date Sun, 17 Apr 2005 09:42:51 +0000
parents c9e2d75a9013
children c39173a67cbb
line wrap: on
line diff
--- a/libmpdemux/mp3_hdr.c	Sun Apr 17 09:13:48 2005 +0000
+++ b/libmpdemux/mp3_hdr.c	Sun Apr 17 09:42:51 2005 +0000
@@ -34,7 +34,7 @@
 /*
  * return frame size or -1 (bad frame)
  */
-int mp_get_mp3_header(unsigned char* hbuf,int* chans, int* srate){
+int mp_get_mp3_header(unsigned char* hbuf,int* chans, int* srate, int* spf, int* mpa_layer){
     int stereo,ssize,lsf,framesize,padding,bitrate_index,sampling_frequency;
     int layer, mult[3] = { 12000, 144000, 144000 };
     unsigned long newhead = 
@@ -115,7 +115,20 @@
       framesize += padding;
 
 //    if(framesize<=0 || framesize>MAXFRAMESIZE) return FALSE;
-    if(srate) *srate = freqs[sampling_frequency];
+    if(srate) {
+      *srate = freqs[sampling_frequency];
+      if(spf) {
+        if(layer == 1)
+	  *spf = 384;
+        else if(layer == 2)
+	  *spf = 1152;
+        else if(*srate < 32000)
+          *spf = 576;
+        else
+	  *spf = 1152;
+      }
+    }
+    if(mpa_layer) *mpa_layer = layer;
     if(chans) *chans = stereo;
 
     return framesize;