[MPlayer-cvslog] r20494 - trunk/libmpdemux/demux_ts.c
nicodvb
subversion at mplayerhq.hu
Sat Oct 28 19:42:25 CEST 2006
Author: nicodvb
Date: Sat Oct 28 19:42:25 2006
New Revision: 20494
Modified:
trunk/libmpdemux/demux_ts.c
Log:
in ts_parse() centralized stream_read()+stream_skip(); smaller and cleaner
Modified: trunk/libmpdemux/demux_ts.c
==============================================================================
--- trunk/libmpdemux/demux_ts.c (original)
+++ trunk/libmpdemux/demux_ts.c Sat Oct 28 19:42:25 2006
@@ -2861,6 +2861,27 @@
}
+ if(probe)
+ {
+ p = &packet[base];
+ }
+ else //feeding
+ {
+ if(*dp_offset + buf_size > *buffer_size)
+ {
+ *buffer_size = *dp_offset + buf_size + TS_FEC_PACKET_SIZE;
+ resize_demux_packet(*dp, *buffer_size);
+ }
+ p = &((*dp)->buffer[*dp_offset]);
+ }
+
+ buf_size = stream_read(stream, p, buf_size);
+ if(buf_size==-1)
+ {
+ mp_msg(MSGT_DEMUX, MSGL_DBG2, "\r\nts_parse() couldn't read data\r\n");
+ continue;
+ }
+ stream_skip(stream, junk);
if(is_start)
{
@@ -2868,10 +2889,6 @@
mp_msg(MSGT_DEMUX, MSGL_DBG2, "IS_START\n");
- p = &packet[base];
- stream_read(stream, p, buf_size);
- stream_skip(stream, junk);
-
len = pes_parse2(p, buf_size, es, pid_type, pmt, pid);
if(! len)
{
@@ -2912,14 +2929,7 @@
demuxer->filepos = stream_tell(demuxer->stream) - es->size;
- if(*dp_offset + es->size > *buffer_size)
- {
- *buffer_size = *dp_offset + es->size + TS_FEC_PACKET_SIZE;
- resize_demux_packet(*dp, *buffer_size);
- //we'll skip at least one RESIZE() in the next iteration of ts_parse()
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "RESIZE DP TO %d\n", *buffer_size);
- }
- memcpy(&((*dp)->buffer[*dp_offset]), es->start, es->size);
+ memmove(p, es->start, es->size);
*dp_offset += es->size;
(*dp)->flags = 0;
(*dp)->pos = stream_tell(demuxer->stream);
@@ -2962,7 +2972,6 @@
}
else
{
- stream_skip(stream, buf_size+junk);
continue;
}
}
@@ -2970,23 +2979,8 @@
if(! probe)
{
- if(*dp_offset + sz > *buffer_size)
- {
- *buffer_size = *dp_offset + sz + TS_FEC_PACKET_SIZE;
- resize_demux_packet(*dp, *buffer_size);
- //we'll skip at least one RESIZE() in the next iteration of ts_parse()
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "RESIZE DP TO %d\n", *buffer_size);
- }
-
- stream_read(stream, &((*dp)->buffer[*dp_offset]), sz);
*dp_offset += sz;
- if(buf_size - sz > 0)
- {
- stream_skip(stream, buf_size - sz);
- }
- stream_skip(stream, junk);
-
if(*dp_offset >= MAX_PACK_BYTES)
{
(*dp)->pts = tss->last_pts;
@@ -2998,9 +2992,7 @@
}
else
{
- stream_read(stream, es->start, sz);
- if(buf_size - sz) stream_skip(stream, buf_size-sz);
- stream_skip(stream, junk);
+ memcpy(es->start, p, sz);
if(es->size)
return es->size;
More information about the MPlayer-cvslog
mailing list