[Xineliboutput-cvslog] vdr-xineliboutput/xine ts2es.c,1.16,1.17
Brought to you by:
phintuka
From: Petri H. <phi...@us...> - 2012-08-30 08:33:04
|
Update of /cvsroot/xineliboutput/vdr-xineliboutput/xine In directory vz-cvs-3.sog:/tmp/cvs-serv17635/xine Modified Files: ts2es.c Log Message: demux-ts: flush complete PES packets immediately Index: ts2es.c =================================================================== RCS file: /cvsroot/xineliboutput/vdr-xineliboutput/xine/ts2es.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- ts2es.c 30 Aug 2012 08:25:47 -0000 1.16 +++ ts2es.c 30 Aug 2012 08:33:02 -0000 1.17 @@ -31,6 +31,7 @@ int first_pusi_seen; int video; int pes_error; + int pes_len; /* PES payload length left */ }; @@ -46,7 +47,6 @@ /* parse PES header */ uint hdr_len = PES_HEADER_LEN(this->buf->content); uint8_t pes_pid = this->buf->content[3]; - uint pes_len = (this->buf->content[4] << 8) | this->buf->content[5]; /* Check if header is complete */ if (this->buf->size < 9 || this->buf->size < hdr_len) { @@ -55,9 +55,17 @@ return; } + /* Check if PES packet size is known */ + this->pes_len = (this->buf->content[4] << 8) | this->buf->content[5]; + if (this->pes_len > hdr_len + 6) { + this->pes_len += 6; + } else { + this->pes_len = 0; + } + /* parse PTS */ this->buf->pts = pes_get_pts(this->buf->content, this->buf->size); - if (this->buf->pts <= 0) + if (this->buf->pts < 0) this->buf->pts = 0; /* parse DTS */ @@ -134,7 +142,9 @@ if (this->buf->content[0] != 0x20 || this->buf->content[1] != 0x00) LOGMSG("ts2es: DVB SPU, invalid PES substream header"); - this->buf->decoder_info[2] = pes_len - hdr_len - 3 + 9; + if (this->pes_len > hdr_len) { + this->buf->decoder_info[2] = this->pes_len - hdr_len; + } return; } } @@ -219,6 +229,17 @@ ts2es_parse_pes(this); } + /* check if PES packet is complete */ + if (this->pes_len > 0) { + if (this->pes_len <= bytes) { + result = this->buf; + this->buf = NULL; + this->pes_error = 1; /* to drop rest of data */ + } else { + this->pes_len -= bytes; + } + } + return result; } |