[FFmpeg-cvslog] r11451 - in trunk/libavformat: mpeg.c mpeg.h

ivo subversion
Tue Jan 8 00:32:57 CET 2008


Author: ivo
Date: Tue Jan  8 00:32:57 2008
New Revision: 11451

Log:
Move parsing of MPEG-PES timestamp to mpeg.h (as an inline function) so it
can easily be reused by other demuxers for formats that encapsulate MPEG-PES.


Modified:
   trunk/libavformat/mpeg.c
   trunk/libavformat/mpeg.h

Modified: trunk/libavformat/mpeg.c
==============================================================================
--- trunk/libavformat/mpeg.c	(original)
+++ trunk/libavformat/mpeg.c	Tue Jan  8 00:32:57 2008
@@ -120,17 +120,12 @@ static int mpegps_read_header(AVFormatCo
 
 static int64_t get_pts(ByteIOContext *pb, int c)
 {
-    int64_t pts;
-    int val;
+    uint8_t buf[5];
 
-    if (c < 0)
-        c = get_byte(pb);
-    pts = (int64_t)(c & 0x0e) << 29;
-    val = get_be16(pb);
-    pts |= (int64_t)(val >> 1) << 15;
-    val = get_be16(pb);
-    pts |= (int64_t)(val >> 1);
-    return pts;
+    buf[0] = c<0 ? get_byte(pb) : c;
+    get_buffer(pb, buf+1, 4);
+
+    return ff_parse_pes_pts(buf);
 }
 
 static int find_next_start_code(ByteIOContext *pb, int *size_ptr,

Modified: trunk/libavformat/mpeg.h
==============================================================================
--- trunk/libavformat/mpeg.h	(original)
+++ trunk/libavformat/mpeg.h	Tue Jan  8 00:32:57 2008
@@ -57,4 +57,13 @@
 
 static const int lpcm_freq_tab[4] = { 48000, 96000, 44100, 32000 };
 
+/**
+ * Parse MPEG-PES five-byte timestamp
+ */
+static inline int64_t ff_parse_pes_pts(uint8_t *buf) {
+    return (int64_t)(*buf & 0x0e) << 29 |
+            (AV_RB16(buf+1) >> 1) << 15 |
+             AV_RB16(buf+3) >> 1;
+}
+
 #endif /* FFMPEG_MPEG_H */




More information about the ffmpeg-cvslog mailing list