Commit 71089d39 authored by François Cartegnie's avatar François Cartegnie 🤞

demux: ts: early reject corrupted packets

There's no way to know if any of the bits is valid.
We can't even flag pid with corrupted/discontinuity
as its number can also be corrupted.
parent d9d6a959
...@@ -623,6 +623,15 @@ static int Demux( demux_t *p_demux ) ...@@ -623,6 +623,15 @@ static int Demux( demux_t *p_demux )
continue; continue;
} }
/* Reject any fully uncorrected packet. Even PID can be incorrect */
if( p_pkt->p_buffer[1]&0x80 )
{
msg_Dbg( p_demux, "transport_error_indicator set (pid=%d)",
PIDGet( p_pkt ) );
block_Release( p_pkt );
continue;
}
/* Parse the TS packet */ /* Parse the TS packet */
ts_pid_t *p_pid = GetPID( p_sys, PIDGet( p_pkt ) ); ts_pid_t *p_pid = GetPID( p_sys, PIDGet( p_pkt ) );
...@@ -1940,7 +1949,8 @@ static int ProbeChunk( demux_t *p_demux, int i_program, bool b_end, int64_t *pi_ ...@@ -1940,7 +1949,8 @@ static int ProbeChunk( demux_t *p_demux, int i_program, bool b_end, int64_t *pi_
break; break;
} }
if( p_pkt->i_size < TS_PACKET_SIZE_188 ) if( p_pkt->i_size < TS_PACKET_SIZE_188 &&
( p_pkt->p_buffer[1]&0x80 ) /* transport error */ )
{ {
block_Release( p_pkt ); block_Release( p_pkt );
continue; continue;
...@@ -2351,14 +2361,6 @@ static bool ProcessTSPacket( demux_t *p_demux, ts_pid_t *pid, block_t *p_pkt ) ...@@ -2351,14 +2361,6 @@ static bool ProcessTSPacket( demux_t *p_demux, ts_pid_t *pid, block_t *p_pkt )
* TODO: handle Reed-Solomon 204,188 error correction */ * TODO: handle Reed-Solomon 204,188 error correction */
p_pkt->i_buffer = TS_PACKET_SIZE_188; p_pkt->i_buffer = TS_PACKET_SIZE_188;
if( p[1]&0x80 )
{
msg_Dbg( p_demux, "transport_error_indicator set (pid=%d)",
pid->i_pid );
if( p_pes->gather.p_data ) //&& pid->es->fmt.i_cat == VIDEO_ES )
p_pes->gather.p_data->i_flags |= BLOCK_FLAG_CORRUPTED;
}
if( SCRAMBLED(*pid) ) if( SCRAMBLED(*pid) )
{ {
if( p_demux->p_sys->csa ) if( p_demux->p_sys->csa )
......
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