summaryrefslogtreecommitdiff
path: root/src/demuxers
diff options
context:
space:
mode:
Diffstat (limited to 'src/demuxers')
-rw-r--r--src/demuxers/demux_mpeg.c36
-rw-r--r--src/demuxers/demux_mpeg_block.c38
2 files changed, 47 insertions, 27 deletions
diff --git a/src/demuxers/demux_mpeg.c b/src/demuxers/demux_mpeg.c
index d473f3aca..4a9674922 100644
--- a/src/demuxers/demux_mpeg.c
+++ b/src/demuxers/demux_mpeg.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: demux_mpeg.c,v 1.119 2003/05/20 19:21:23 jcdutton Exp $
+ * $Id: demux_mpeg.c,v 1.120 2003/06/18 13:03:44 mroi Exp $
*
* demultiplexer for mpeg 1/2 program streams
* reads streams of variable blocksizes
@@ -184,7 +184,7 @@ static void find_mdat_atom(input_plugin_t *input, off_t *mdat_offset,
}
}
-static uint32_t read_bytes (demux_mpeg_t *this, int n) {
+static uint32_t read_bytes (demux_mpeg_t *this, uint32_t n) {
uint32_t res;
uint32_t i;
@@ -251,7 +251,7 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int stream_id, int64_t scr)
int len, i;
uint32_t w, flags, header_len;
- int64_t pts;
+ int64_t pts, dts;
buf_element_t *buf = NULL;
len = read_bytes(this, 2);
@@ -434,6 +434,7 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int stream_id, int64_t scr)
len -= header_len + 3;
pts = 0;
+ dts = 0;
if ((flags & 0x80) == 0x80) {
@@ -446,6 +447,18 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int stream_id, int64_t scr)
header_len -= 5 ;
}
+
+ if ((flags & 0x40) == 0x40) {
+
+ w = read_bytes(this, 1);
+ dts = (w & 0x0e) << 29 ;
+ w = read_bytes(this, 2);
+ dts |= (w & 0xFFFE) << 14;
+ w = read_bytes(this, 2);
+ dts |= (w & 0xFFFE) >> 1;
+
+ header_len -= 5 ;
+ }
/* read rest of header */
i = this->input->read (this->input, this->dummy_space, header_len);
@@ -463,6 +476,7 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int stream_id, int64_t scr)
buf->type = BUF_VIDEO_MPEG;
buf->pts = pts;
+ buf->decoder_info[0] = pts - dts;
check_newpts( this, pts, PTS_VIDEO );
pts = 0;
@@ -490,12 +504,13 @@ static void parse_mpeg1_packet (demux_mpeg_t *this, int stream_id, int64_t scr)
int len;
uint32_t w;
int i;
- int64_t pts;
+ int64_t pts, dts;
buf_element_t *buf = NULL;
len = read_bytes(this, 2);
pts=0;
+ dts=0;
if (stream_id != 0xbf) {
@@ -546,14 +561,16 @@ static void parse_mpeg1_packet (demux_mpeg_t *this, int stream_id, int64_t scr)
pts |= (w & 0xFFFE) << 14;
w = read_bytes(this, 2); len -= 2;
-
+
pts |= (w & 0xFFFE) >> 1;
-/* printf ("pts2=%lld\n",pts); */
-
- /* Decoding Time Stamp */
- w = read_bytes(this, 3); len -= 3;
+ w = read_bytes(this, 1); len -= 1;
+ dts = (w & 0x0e) << 29 ;
+ w = read_bytes(this, 2); len -= 2;
+ dts |= (w & 0xFFFE) << 14;
w = read_bytes(this, 2); len -= 2;
+ dts |= (w & 0xFFFE) >> 1;
+
} else {
/*
@@ -623,6 +640,7 @@ static void parse_mpeg1_packet (demux_mpeg_t *this, int stream_id, int64_t scr)
buf->type = BUF_VIDEO_MPEG;
buf->pts = pts;
+ buf->decoder_info[0] = pts - dts;
check_newpts( this, pts, PTS_VIDEO );
pts = 0;
diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c
index 18d6cbf2d..648e23507 100644
--- a/src/demuxers/demux_mpeg_block.c
+++ b/src/demuxers/demux_mpeg_block.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: demux_mpeg_block.c,v 1.191 2003/06/07 14:01:38 jcdutton Exp $
+ * $Id: demux_mpeg_block.c,v 1.192 2003/06/18 13:03:45 mroi Exp $
*
* demultiplexer for mpeg 1/2 program streams
* used with fixed blocksize devices (like dvd/vcd)
@@ -85,6 +85,7 @@ typedef struct demux_mpeg_block_s {
int64_t scr;
uint32_t packet_len;
int64_t pts;
+ int64_t dts;
uint32_t stream_id;
int32_t mpeg1;
@@ -604,6 +605,8 @@ static int32_t parse_pes_for_pts(demux_mpeg_block_t *this, uint8_t *p, buf_eleme
}
this->pts = 0;
+ this->dts = 0;
+
if ((p[0] & 0xf0) == 0x20) {
this->pts = (p[ 0] & 0x0E) << 29 ;
this->pts |= p[ 1] << 22 ;
@@ -620,13 +623,13 @@ static int32_t parse_pes_for_pts(demux_mpeg_block_t *this, uint8_t *p, buf_eleme
this->pts |= (p[ 2] & 0xFE) << 14 ;
this->pts |= p[ 3] << 7 ;
this->pts |= (p[ 4] & 0xFE) >> 1 ;
- /* DTS decoding code is working, but not used in xine
- DTS = (p[ 5] & 0x0E) << 29 ;
- DTS |= p[ 6] << 22 ;
- DTS |= (p[ 7] & 0xFE) << 14 ;
- DTS |= p[ 8] << 7 ;
- DTS |= (p[ 9] & 0xFE) >> 1 ;
- */
+
+ this->dts = (p[ 5] & 0x0E) << 29 ;
+ this->dts |= p[ 6] << 22 ;
+ this->dts |= (p[ 7] & 0xFE) << 14 ;
+ this->dts |= p[ 8] << 7 ;
+ this->dts |= (p[ 9] & 0xFE) >> 1 ;
+
p += 10;
header_len += 10;
this->packet_len -= 10;
@@ -679,18 +682,16 @@ static int32_t parse_pes_for_pts(demux_mpeg_block_t *this, uint8_t *p, buf_eleme
} else
this->pts = 0;
- /* code is working but not used in xine
- if (p[7] & 0x40) {
+ if (p[7] & 0x40) { /* dts avail */
- DTS = (p[14] & 0x0E) << 29 ;
- DTS |= p[15] << 22 ;
- DTS |= (p[16] & 0xFE) << 14 ;
- DTS |= p[17] << 7 ;
- DTS |= (p[18] & 0xFE) >> 1 ;
+ this->dts = (p[14] & 0x0E) << 29 ;
+ this->dts |= p[15] << 22 ;
+ this->dts |= (p[16] & 0xFE) << 14 ;
+ this->dts |= p[17] << 7 ;
+ this->dts |= (p[18] & 0xFE) >> 1 ;
- } else
- DTS = 0;
- */
+ } else
+ this->dts = 0;
header_len = p[8];
@@ -888,6 +889,7 @@ static int32_t parse_video_stream(demux_mpeg_block_t *this, uint8_t *p, buf_elem
buf->size = this->packet_len;
buf->type = BUF_VIDEO_MPEG;
buf->pts = this->pts;
+ buf->decoder_info[0] = this->pts - this->dts;
if( !this->preview_mode )
check_newpts( this, this->pts, PTS_VIDEO );