Commit ddc23721 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: ts: factorize PES timestamp reading

parent bf31a6b4
...@@ -626,6 +626,15 @@ static void vlc_dvbpsi_reset( demux_t *p_demux ) ...@@ -626,6 +626,15 @@ static void vlc_dvbpsi_reset( demux_t *p_demux )
} }
#endif #endif
static inline mtime_t ExtractPESTimestamp( const uint8_t *p_data )
{
return ((mtime_t)(p_data[ 0]&0x0e ) << 29)|
(mtime_t)(p_data[1] << 22)|
((mtime_t)(p_data[2]&0xfe) << 14)|
(mtime_t)(p_data[3] << 7)|
(mtime_t)(p_data[4] >> 1);
}
/***************************************************************************** /*****************************************************************************
* Open * Open
*****************************************************************************/ *****************************************************************************/
...@@ -1768,20 +1777,10 @@ static void ParsePES( demux_t *p_demux, ts_pid_t *pid, block_t *p_pes ) ...@@ -1768,20 +1777,10 @@ static void ParsePES( demux_t *p_demux, ts_pid_t *pid, block_t *p_pes )
if( header[7]&0x80 ) /* has pts */ if( header[7]&0x80 ) /* has pts */
{ {
i_pts = ((mtime_t)(header[ 9]&0x0e ) << 29)| i_pts = ExtractPESTimestamp( &header[9] );
(mtime_t)(header[10] << 22)|
((mtime_t)(header[11]&0xfe) << 14)|
(mtime_t)(header[12] << 7)|
(mtime_t)(header[13] >> 1);
if( header[7]&0x40 ) /* has dts */ if( header[7]&0x40 ) /* has dts */
{ i_dts = ExtractPESTimestamp( &header[14] );
i_dts = ((mtime_t)(header[14]&0x0e ) << 29)|
(mtime_t)(header[15] << 22)|
((mtime_t)(header[16]&0xfe) << 14)|
(mtime_t)(header[17] << 7)|
(mtime_t)(header[18] >> 1);
}
} }
} }
else else
...@@ -1804,19 +1803,11 @@ static void ParsePES( demux_t *p_demux, ts_pid_t *pid, block_t *p_pes ) ...@@ -1804,19 +1803,11 @@ static void ParsePES( demux_t *p_demux, ts_pid_t *pid, block_t *p_pes )
if( header[i_skip]&0x20 ) if( header[i_skip]&0x20 )
{ {
i_pts = ((mtime_t)(header[i_skip]&0x0e ) << 29)| i_pts = ExtractPESTimestamp( &header[i_skip] );
(mtime_t)(header[i_skip+1] << 22)|
((mtime_t)(header[i_skip+2]&0xfe) << 14)|
(mtime_t)(header[i_skip+3] << 7)|
(mtime_t)(header[i_skip+4] >> 1);
if( header[i_skip]&0x10 ) /* has dts */ if( header[i_skip]&0x10 ) /* has dts */
{ {
i_dts = ((mtime_t)(header[i_skip+5]&0x0e ) << 29)| i_dts = ExtractPESTimestamp( &header[i_skip+5] );
(mtime_t)(header[i_skip+6] << 22)|
((mtime_t)(header[i_skip+7]&0xfe) << 14)|
(mtime_t)(header[i_skip+8] << 7)|
(mtime_t)(header[i_skip+9] >> 1);
i_skip += 10; i_skip += 10;
} }
else else
......
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