[MPlayer-cvslog] r31929 - in trunk/libmpdemux: demux_ts.c demux_ts.h parse_es.c parse_es.h

diego subversion at mplayerhq.hu
Thu Aug 5 11:01:30 CEST 2010


Author: diego
Date: Thu Aug  5 11:01:30 2010
New Revision: 31929

Log:
Move mp_a52_framesize from demux_ts.c to parse_es.c.
The function is used in the MPEG muxer as well and not specific to MPEG-TS.
Jointly developed by Nico Sabbi and myself.

Modified:
   trunk/libmpdemux/demux_ts.c
   trunk/libmpdemux/demux_ts.h
   trunk/libmpdemux/parse_es.c
   trunk/libmpdemux/parse_es.h

Modified: trunk/libmpdemux/demux_ts.c
==============================================================================
--- trunk/libmpdemux/demux_ts.c	Thu Aug  5 09:37:58 2010	(r31928)
+++ trunk/libmpdemux/demux_ts.c	Thu Aug  5 11:01:30 2010	(r31929)
@@ -622,47 +622,6 @@ typedef struct {
 	off_t probe;
 } tsdemux_init_t;
 
-//stripped down version of a52_syncinfo() from liba52
-//copyright belongs to Michel Lespinasse <walken at zoy.org> and Aaron Holtzman <aholtzma at ess.engr.uvic.ca>
-int mp_a52_framesize(uint8_t * buf, int *srate)
-{
-	int rate[] = {	32,  40,  48,  56,  64,  80,  96, 112,
-			128, 160, 192, 224, 256, 320, 384, 448,
-			512, 576, 640
-	};
-	uint8_t halfrate[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3};
-	int frmsizecod, bitrate, half;
-
-	if((buf[0] != 0x0b) || (buf[1] != 0x77))	/* syncword */
-		return 0;
-
-	if(buf[5] >= 0x60)		/* bsid >= 12 */
-		return 0;
-
-	half = halfrate[buf[5] >> 3];
-
-	frmsizecod = buf[4] & 63;
-	if(frmsizecod >= 38)
-		return 0;
-
-	bitrate = rate[frmsizecod >> 1];
-
-	switch(buf[4] & 0xc0)
-	{
-		case 0:	/* 48 KHz */
-			*srate = 48000 >> half;
-			return 4 * bitrate;
-		case 0x40:	/* 44.1 KHz */
-			*srate = 44100 >> half;
-			return 2 * (320 * bitrate / 147 + (frmsizecod & 1));
-		case 0x80: /* 32 KHz */
-			*srate = 32000 >> half;
-			return 6 * bitrate;
-	}
-
-	return 0;
-}
-
 //second stage: returns the count of A52 syncwords found
 static int a52_check(char *buf, int len)
 {

Modified: trunk/libmpdemux/demux_ts.h
==============================================================================
--- trunk/libmpdemux/demux_ts.h	Thu Aug  5 09:37:58 2010	(r31928)
+++ trunk/libmpdemux/demux_ts.h	Thu Aug  5 11:01:30 2010	(r31929)
@@ -19,8 +19,6 @@
 #ifndef MPLAYER_DEMUX_TS_H
 #define MPLAYER_DEMUX_TS_H
 
-#include <stdint.h>
-
 #define TS_MAX_PROBE_SIZE 2000000
 
 extern off_t ts_probe;
@@ -28,6 +26,4 @@ extern int   ts_prog;
 extern int   ts_keep_broken;
 extern int audio_substream_id;
 
-int mp_a52_framesize(uint8_t *buf, int *srate);
-
 #endif /* MPLAYER_DEMUX_TS_H */

Modified: trunk/libmpdemux/parse_es.c
==============================================================================
--- trunk/libmpdemux/parse_es.c	Thu Aug  5 09:37:58 2010	(r31928)
+++ trunk/libmpdemux/parse_es.c	Thu Aug  5 11:01:30 2010	(r31929)
@@ -18,6 +18,7 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -115,3 +116,44 @@ int skip_video_packet(demux_stream_t *ds
   // SYNC AGAIN:
   return sync_video_packet(ds);
 }
+
+/* stripped down version of a52_syncinfo() from liba52
+ * copyright belongs to Michel Lespinasse <walken at zoy.org>
+ * and Aaron Holtzman <aholtzma at ess.engr.uvic.ca> */
+int mp_a52_framesize(uint8_t * buf, int *srate)
+{
+    int rate[] = {  32,  40,  48,  56,  64,  80,  96, 112,
+                   128, 160, 192, 224, 256, 320, 384, 448,
+                   512, 576, 640
+    };
+    uint8_t halfrate[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3 };
+    int frmsizecod, bitrate, half;
+
+    if ((buf[0] != 0x0b) || (buf[1] != 0x77))    /* syncword */
+        return 0;
+
+    if (buf[5] >= 0x60)                          /* bsid >= 12 */
+        return 0;
+
+    half = halfrate[buf[5] >> 3];
+
+    frmsizecod = buf[4] & 63;
+    if (frmsizecod >= 38)
+        return 0;
+
+    bitrate = rate[frmsizecod >> 1];
+
+    switch (buf[4] & 0xc0) {
+    case 0:    /* 48 KHz */
+        *srate = 48000 >> half;
+        return 4 * bitrate;
+    case 0x40: /* 44.1 KHz */
+        *srate = 44100 >> half;
+        return 2 * (320 * bitrate / 147 + (frmsizecod & 1));
+    case 0x80: /* 32 KHz */
+        *srate = 32000 >> half;
+        return 6 * bitrate;
+    }
+
+    return 0;
+}

Modified: trunk/libmpdemux/parse_es.h
==============================================================================
--- trunk/libmpdemux/parse_es.h	Thu Aug  5 09:37:58 2010	(r31928)
+++ trunk/libmpdemux/parse_es.h	Thu Aug  5 11:01:30 2010	(r31929)
@@ -19,6 +19,8 @@
 #ifndef MPLAYER_PARSE_ES_H
 #define MPLAYER_PARSE_ES_H
 
+#include <stdint.h>
+
 #include "demuxer.h"
 
 #define MAX_VIDEO_PACKET_SIZE (224*1024+4)
@@ -38,4 +40,6 @@ int read_video_packet(demux_stream_t *ds
 // return: next packet code
 int skip_video_packet(demux_stream_t *ds);
 
+int mp_a52_framesize(uint8_t *buf, int *srate);
+
 #endif /* MPLAYER_PARSE_ES_H */


More information about the MPlayer-cvslog mailing list