diff options
author | nicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-07-07 08:22:47 +0000 |
---|---|---|
committer | nicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-07-07 08:22:47 +0000 |
commit | 1c4710b11042b2aa7ccd5f7de9fb8b038189d251 (patch) | |
tree | 9f2fc16f7a8847c6a4227f744f12f4078d7766b5 | |
parent | fd11b253b9d1e6dea4c7d5e818d35ad291e7545e (diff) |
proper parsing of pes_extension[12] fields (replaces the previous code that relied on specific flags set
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23729 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | libmpdemux/demux_mpg.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/libmpdemux/demux_mpg.c b/libmpdemux/demux_mpg.c index a2a3d369e6..cbac67167a 100644 --- a/libmpdemux/demux_mpg.c +++ b/libmpdemux/demux_mpg.c @@ -365,8 +365,41 @@ static int demux_mpg_read_packet(demuxer_t *demux,int id){ else if(hdrlen>=3) { c=stream_read_char(demux->stream); hdrlen--; - if(c != 0x1F && c!= 0x0F) { mp_msg(MSGT_DEMUX,MSGL_V,"demux_mpg: invalid pes_extension field \n"); return -1;} - if(c == 0x1F) { + + if((c & 0x0F) != 0x0F) { + mp_msg(MSGT_DEMUX,MSGL_V,"demux_mpg: pes_extension_flag2 not set, discarding pes packet\n"); + return -1; + } + if(c & 0x80) { //pes_private_data_flag + if(hdrlen<16) { + mp_msg(MSGT_DEMUX,MSGL_V,"demux_mpg: not enough pes_private_data bytes: %d < 16, discarding pes packet\n", hdrlen); + return -1; + } + stream_skip(demux->stream, 16); + hdrlen-=16; + } + if(c & 0x40) { //pack_header_field_flag + int l = stream_read_char(demux->stream); + if(l < 0) //couldn't read from the stream? + return -1; + hdrlen--; + if(l < 0 || hdrlen < l) { + mp_msg(MSGT_DEMUX,MSGL_V,"demux_mpg: not enough pack_header bytes: hdrlen: %d < skip: %d, discarding pes packet\n", + hdrlen, l); + return -1; + } + stream_skip(demux->stream, l); + hdrlen-=l; + } + if(c & 0x20) { //program_packet_sequence_counter_flag + if(hdrlen < 2) { + mp_msg(MSGT_DEMUX,MSGL_V,"demux_mpg: not enough program_packet bytes: hdrlen: %d, discarding pes packet\n", hdrlen); + return -1; + } + stream_skip(demux->stream, 2); + hdrlen-=2; + } + if(c & 0x10) { //STD stream_skip(demux->stream, 2); hdrlen-=2; |