<div dir="ltr">ping?<div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 10, 2016 at 11:35 AM, Zhao Zhili <span dir="ltr"><<a href="mailto:wantlamy@gmail.com" target="_blank">wantlamy@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">A new version is attached.<br><div>---<br> modules/demux/mpeg/ts.c | 104 ++++++++++++++++++++++++++------------------<br> modules/demux/mpeg/ts_psi.c | 2 +-<br> 2 files changed, 62 insertions(+), 44 deletions(-)<br><br>diff --git a/modules/demux/mpeg/ts.c b/modules/demux/mpeg/ts.c<br>index f70844b..046cac5 100644<br>--- a/modules/demux/mpeg/ts.c<br>+++ b/modules/demux/mpeg/ts.c<br>@@ -1844,19 +1844,29 @@ static int SeekToTime( demux_t *p_demux, const ts_pmt_t *p_pmt, int64_t i_scaled<br> return VLC_SUCCESS;<br> }<br> <br>-#define PROBE_CHUNK_COUNT 250<br>-<br>-static int ProbeChunk( demux_t *p_demux, int i_program, bool b_end, int64_t *pi_pcr, bool *pb_found )<br>+typedef struct<br>+{<br>+ int i_program;<br>+ bool b_end;<br>+ mtime_t i_pcr;<br>+ bool b_found;<br>+ int i_packet_num;<br>+} ts_probe_chunk_t;<br>+<br>+static int ProbeChunk( demux_t *p_demux, ts_probe_chunk_t *p_chunk_info )<br> {<br> demux_sys_t *p_sys = p_demux->p_sys;<br> int i_count = 0;<br> block_t *p_pkt = NULL;<br>+ int i_packet_max = p_chunk_info->i_packet_num;<br>+ int i_program = p_chunk_info->i_program;<br>+ mtime_t i_pcr;<br> <br> for( ;; )<br> {<br>- *pi_pcr = -1;<br>+ i_pcr = -1;<br> <br>- if( i_count++ > PROBE_CHUNK_COUNT || !( p_pkt = ReadTSPacket( p_demux ) ) )<br>+ if( i_count++ > i_packet_max || !( p_pkt = ReadTSPacket( p_demux ) ) )<br> {<br> break;<br> }<br>@@ -1872,9 +1882,9 @@ static int ProbeChunk( demux_t *p_demux, int i_program, bool b_end, int64_t *pi_<br> bool b_adaptfield = p_pkt->p_buffer[3] & 0x20;<br> <br> if( b_adaptfield && p_pkt->i_buffer >= 4 + 2 + 5 )<br>- *pi_pcr = GetPCR( p_pkt );<br>+ i_pcr = GetPCR( p_pkt );<br> <br>- if( *pi_pcr == -1 &&<br>+ if( i_pcr == -1 &&<br> (p_pkt->p_buffer[1] & 0xC0) == 0x40 && /* payload start */<br> (p_pkt->p_buffer[3] & 0xD0) == 0x10 && /* Has payload but is not encrypted */<br> p_pid->type == TYPE_PES &&<br>@@ -1894,13 +1904,13 @@ static int ProbeChunk( demux_t *p_demux, int i_program, bool b_end, int64_t *pi_<br> &i_dts, &i_pts, &i_stream_id ) )<br> {<br> if( i_dts != -1 )<br>- *pi_pcr = i_dts;<br>+ i_pcr = i_dts;<br> else if( i_pts != -1 )<br>- *pi_pcr = i_pts;<br>+ i_pcr = i_pts;<br> }<br> }<br> <br>- if( *pi_pcr != -1 )<br>+ if( i_pcr != -1 )<br> {<br> ts_pat_t *p_pat = GetPID(p_sys, 0)->u.p_pat;<br> for( int i=0; i<p_pat->programs.i_size; i++ )<br>@@ -1911,22 +1921,22 @@ static int ProbeChunk( demux_t *p_demux, int i_program, bool b_end, int64_t *pi_<br> PIDReferencedByProgram( p_pmt, p_pid->i_pid ) )<br> )<br> {<br>- if( b_end )<br>+ if( p_chunk_info->b_end )<br> {<br>- p_pmt->i_last_dts = *pi_pcr;<br>+ p_pmt->i_last_dts = i_pcr;<br> }<br> /* Start, only keep first */<br> else if( b_pcrresult && p_pmt->pcr.i_first == -1 )<br> {<br>- p_pmt->pcr.i_first = *pi_pcr;<br>+ p_pmt->pcr.i_first = i_pcr;<br> }<br> else if( p_pmt->pcr.i_first_dts < VLC_TS_0 )<br> {<br>- p_pmt->pcr.i_first_dts = FROM_SCALE(*pi_pcr);<br>+ p_pmt->pcr.i_first_dts = FROM_SCALE(i_pcr);<br> }<br> <br> if( i_program == 0 || i_program == p_pmt->i_number )<br>- *pb_found = true;<br>+ p_chunk_info->b_found = true;<br> }<br> }<br> }<br>@@ -1935,6 +1945,8 @@ static int ProbeChunk( demux_t *p_demux, int i_program, bool b_end, int64_t *pi_<br> block_Release( p_pkt );<br> }<br> <br>+ p_chunk_info->i_pcr = i_pcr;<br>+<br> return i_count;<br> }<br> <br>@@ -1942,31 +1954,23 @@ int ProbeStart( demux_t *p_demux, int i_program )<br> {<br> demux_sys_t *p_sys = p_demux->p_sys;<br> const int64_t i_initial_pos = stream_Tell( p_sys->stream );<br>- int64_t i_stream_size = stream_Size( p_sys->stream );<br>-<br>- int i_probe_count = 0;<br>- int64_t i_pos;<br>- mtime_t i_pcr = -1;<br>- bool b_found = false;<br>-<br>- do<br>- {<br>- i_pos = p_sys->i_packet_size * i_probe_count;<br>- i_pos = __MIN( i_pos, i_stream_size );<br>-<br>- if( stream_Seek( p_sys->stream, i_pos ) )<br>- return VLC_EGENERIC;<br>-<br>- ProbeChunk( p_demux, i_program, false, &i_pcr, &b_found );<br>+ ts_probe_chunk_t chunk_info = {<br>+ .i_program = i_program,<br>+ .b_end = false,<br>+ .i_pcr = -1,<br>+ .b_found = false,<br>+ .i_packet_num = 500,<br>+ };<br>+<br>+ if( stream_Seek( p_sys->stream, 0 ) )<br>+ return VLC_EGENERIC;<br> <br>- /* Go ahead one more chunk if end of file contained only stuffing packets */<br>- i_probe_count += PROBE_CHUNK_COUNT;<br>- } while( i_pos > 0 && (i_pcr == -1 || !b_found) && i_probe_count < (2 * PROBE_CHUNK_COUNT) );<br>+ ProbeChunk( p_demux, &chunk_info );<span class=""><br> <br> if( stream_Seek( p_sys->stream, i_initial_pos ) )<br> return VLC_EGENERIC;<br> <br></span>- return (b_found) ? VLC_SUCCESS : VLC_EGENERIC;<br>+ return (chunk_info.b_found) ? VLC_SUCCESS : VLC_EGENERIC;<span class=""><br> }<br> <br> int ProbeEnd( demux_t *p_demux, int i_program )<br></span>@@ -1975,11 +1979,23 @@ int ProbeEnd( demux_t *p_demux, int i_program )<br> const int64_t i_initial_pos = stream_Tell( p_sys->stream );<span class=""><br> int64_t i_stream_size = stream_Size( p_sys->stream );<br> <br></span>- int i_probe_count = PROBE_CHUNK_COUNT;<br> int64_t i_pos;<br>- mtime_t i_pcr = -1;<br>- bool b_found = false;<br>-<br>+ int i_probe_count, i_probe_max;<br>+ ts_probe_chunk_t chunk_info = {<br>+ .i_program = i_program,<br>+ .b_end = true,<br>+ .i_pcr = -1,<br>+ .b_found = false,<br>+ .i_packet_num = 250,<br>+ };<br>+<br>+ i_probe_max = 5 * chunk_info.i_packet_num;<br>+<br>+ /* Probe a single big chunk for non fastseekable */<span class=""><br>+ if ( p_sys->b_canfastseek == false )<br></span>+ chunk_info.i_packet_num = i_probe_max;<br>+<br>+ i_probe_count = chunk_info.i_packet_num;<span class=""><br> do<br> {<br> i_pos = i_stream_size - (p_sys->i_packet_size * i_probe_count);<br></span>@@ -1988,16 +2004,18 @@ int ProbeEnd( demux_t *p_demux, int i_program )<br> if( stream_Seek( p_sys->stream, i_pos ) )<br> return VLC_EGENERIC;<br> <br>- ProbeChunk( p_demux, i_program, true, &i_pcr, &b_found );<br>+ ProbeChunk( p_demux, &chunk_info );<span class=""><br> <br> /* Go ahead one more chunk if end of file contained only stuffing packets */<br></span>- i_probe_count += PROBE_CHUNK_COUNT;<span class=""><br>- } while( i_pos > 0 && (i_pcr == -1 || !b_found) && i_probe_count < (6 * PROBE_CHUNK_COUNT) );<br></span>+ i_probe_count += chunk_info.i_packet_num;<span class=""><br>+ } while( i_pos > 0 &&<br></span>+ (chunk_info.i_pcr == -1 || chunk_info.b_found == false) &&<br>+ i_probe_count <= i_probe_max );<span class=""><br> <br> if( stream_Seek( p_sys->stream, i_initial_pos ) )<br> return VLC_EGENERIC;<br> <br></span>- return (b_found) ? VLC_SUCCESS : VLC_EGENERIC;<br>+ return (chunk_info.b_found) ? VLC_SUCCESS : VLC_EGENERIC;<br> }<br> <br> static void ProgramSetPCR( demux_t *p_demux, ts_pmt_t *p_pmt, mtime_t i_pcr )<span class=""><br>diff --git a/modules/demux/mpeg/ts_psi.c b/modules/demux/mpeg/ts_psi.c<br>index ac14b79..05623ac 100644<br>--- a/modules/demux/mpeg/ts_psi.c<br>+++ b/modules/demux/mpeg/ts_psi.c<br>@@ -1714,7 +1714,7 @@ static void PMTCallBack( void *data, dvbpsi_pmt_t *p_dvbpsipmt )<br> }<br> <br> /* Probe Boundaries */<br>- if( p_sys->b_canfastseek && p_pmt->i_last_dts == -1 )<br>+ if( p_sys->b_canseek && p_pmt->i_last_dts == -1 )<br> {<br> p_pmt->i_last_dts = 0;<br> ProbeStart( p_demux, p_pmt->i_number );<br>-- <br>1.9.1<br></span></div></div>
</blockquote></div><br></div></div>