[MPlayer-dev-eng] PATCH for demux_ts
Marcus Metzler
mocm at mocm.de
Sat Nov 20 12:37:16 CET 2004
Hi,
I have a patch for demux_ts.c that checks for and allows TS packets
larger than 188 bytes. Those packages exits if the FEC information is
not stripped from the packets received by a DVB card (204 bytes), or
if some cards add time stamp information to the packets (192 bytes).
Here is a diff -u against the latest CVS:
Index: demux_ts.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_ts.c,v
retrieving revision 1.20
diff -u -r1.20 demux_ts.c
--- demux_ts.c 15 Nov 2004 20:56:10 -0000 1.20
+++ demux_ts.c 20 Nov 2004 11:28:20 -0000
@@ -37,6 +37,7 @@
#include "bswap.h"
#include "../unrarlib.h"
+#define TS_PH_PACKET_SIZE 192
#define TS_FEC_PACKET_SIZE 204
#define TS_PACKET_SIZE 188
#define NB_PID_MAX 8192
@@ -173,10 +174,20 @@
try_fec:
for(i=0; i<NUM_CONSECUTIVE_TS_PACKETS; i++)
{
- if (buf[i * TS_FEC_PACKET_SIZE] != 0x47)
- return 0;
+ if (buf[i * TS_FEC_PACKET_SIZE] != 0x47){
+ mp_msg(MSGT_DEMUX, MSGL_DBG2, "GET_PACKET_SIZE, pos %d, char: %2x\n", i, buf[i * TS_PACKET_SIZE]);
+ goto try_philips;
+ }
}
return TS_FEC_PACKET_SIZE;
+
+ try_philips:
+ for(i=0; i<NUM_CONSECUTIVE_TS_PACKETS; i++)
+ {
+ if (buf[i * TS_PH_PACKET_SIZE] != 0x47)
+ return 0;
+ }
+ return TS_PH_PACKET_SIZE;
}
@@ -1682,7 +1693,7 @@
demux_packet_t **dp = NULL;
int *dp_offset = 0, *buffer_size = 0;
int32_t progid, pid_type, bad, ts_error;
-
+ int junk = 0;
while(! done)
{
@@ -1692,6 +1703,7 @@
dp_offset = buffer_size = NULL;
buf_size = priv->ts.packet_size;
+ junk = buf_size-TS_PACKET_SIZE;
if(stream_eof(stream))
{
@@ -1804,11 +1816,11 @@
//TABLE PARSING
- base = priv->ts.packet_size - buf_size;
+ base = priv->ts.packet_size - buf_size-junk;
if(pid == 0)
{
- stream_read(stream,&packet[base], buf_size);
- parse_pat(priv, is_start, &packet[base], buf_size);
+ stream_read(stream,&packet[base], buf_size-junk);
+ parse_pat(priv, is_start, &packet[base], buf_size-junk);
continue;
}
else
@@ -1818,8 +1830,8 @@
{
if(pid != demuxer->video->id && pid != demuxer->audio->id && pid != demuxer->sub->id)
{
- stream_read(stream,&packet[base], buf_size);
- parse_pmt(priv, progid, pid, is_start, &packet[base], buf_size);
+ stream_read(stream,&packet[base], buf_size-junk);
+ parse_pmt(priv, progid, pid, is_start, &packet[base], buf_size-junk);
continue;
}
else
@@ -1949,7 +1961,7 @@
p = &packet[base];
stream_read(stream, p, buf_size);
- len = pes_parse2(p, buf_size, es, pid_type);
+ len = pes_parse2(p, buf_size-junk, es, pid_type);
es->pid = tss->pid;
if(probe)
@@ -1960,7 +1972,7 @@
{
if(tss->type != UNKNOWN)
{
- es->size = buf_size;
+ es->size = buf_size-junk;
es->start = p;
return 1;
}
@@ -1988,7 +2000,7 @@
{
if(tss->type != UNKNOWN)
{
- len = es->size = buf_size; //push the whole packet to the fifo
+ len = es->size = buf_size-junk; //push the whole packet to the fifo
//(we already learned what it is during the probe phase)
es->start = p;
}
@@ -2058,7 +2070,7 @@
if(tss->payload_size > 0)
{
- sz = min(tss->payload_size, buf_size);
+ sz = min(tss->payload_size, buf_size-junk);
tss->payload_size -= sz;
es->size = sz;
}
@@ -2066,7 +2078,7 @@
{
if(is_video)
{
- sz = es->size = buf_size;
+ sz = es->size = buf_size-junk;
}
else
{
I tested it with streams that have 188 and 192 byte packets.
Marcus
--
/--------------------------------------------------------------------\
| Dr. Marcus O.C. Metzler | |
| mocm at metzlerbros.de | http://www.metzlerbros.de/ |
\--------------------------------------------------------------------/
|>>> Quis custodiet ipsos custodies <<<|
More information about the MPlayer-dev-eng
mailing list