diff options
| author | Michael Roitzsch <mroi@users.sourceforge.net> | 2003-06-18 13:03:44 +0000 |
|---|---|---|
| committer | Michael Roitzsch <mroi@users.sourceforge.net> | 2003-06-18 13:03:44 +0000 |
| commit | e2e501f9edee1453b2c44a78f23cf4a4e40d4164 (patch) | |
| tree | 70d82f5ad9137bb8485cc73aa72315032bf25b25 /src/demuxers/demux_mpeg.c | |
| parent | 06f2301713235341fe3d43b1b959f414d2cfc340 (diff) | |
| download | xine-lib-e2e501f9edee1453b2c44a78f23cf4a4e40d4164.tar.gz xine-lib-e2e501f9edee1453b2c44a78f23cf4a4e40d4164.tar.bz2 | |
extract DTS (decoder timestamps) from the MPEG stream,
the DXR3 decoder can use them to improve sync
(this removes a magic number from the DXR3 decoder)
CVS patchset: 5065
CVS date: 2003/06/18 13:03:44
Diffstat (limited to 'src/demuxers/demux_mpeg.c')
| -rw-r--r-- | src/demuxers/demux_mpeg.c | 36 |
1 files changed, 27 insertions, 9 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; |
