Commit 9dc74649 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Really fix ps_pkt_size()

The original commit description is rather terse
  "ps demux: fix an issue in ps_pkt_read()"
so I don't really know what the "issue" is. But ps_pkt_size() really
made no sense as is.

This reverts commit d761cf6f.

Conflicts:

	modules/demux/ps.h
parent 2bbfeddf
......@@ -582,15 +582,11 @@ static block_t *ps_pkt_read( stream_t *s, uint32_t i_code )
{
const uint8_t *p_peek;
int i_peek = stream_Peek( s, &p_peek, 14 );
int i_size;
VLC_UNUSED(i_code);
/* Smallest valid packet */
if( i_peek < 6 ) return NULL;
i_size = ps_pkt_size( p_peek, i_peek );
if( i_peek < 4 )
return NULL;
if( i_size < 0 || ( i_size <= 6 && p_peek[3] > 0xba ) )
int i_size = ps_pkt_size( p_peek, i_peek );
if( i_size <= 6 && p_peek[3] > 0xba )
{
/* Special case, search the next start code */
i_size = 6;
......@@ -618,5 +614,6 @@ static block_t *ps_pkt_read( stream_t *s, uint32_t i_code )
return stream_Block( s, i_size );
}
VLC_UNUSED(i_code);
return NULL;
}
......@@ -299,13 +299,14 @@ static inline int ps_pkt_id( block_t *p_pkt )
return p_pkt->p_buffer[3];
}
/* return the size of the next packet
* You need to give him at least 14 bytes (and it need to start as a
* valid packet) It does not handle less than 6 bytes */
/* return the size of the next packet */
static inline int ps_pkt_size( const uint8_t *p, int i_peek )
{
assert( i_peek >= 6 );
if( p[3] == 0xb9 && i_peek >= 4 )
if( unlikely(i_peek < 4) )
{
return -1;
}
else if( p[3] == 0xb9 )
{
return 4;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment