Commit 584b75bb authored by Jeremy Vignelles's avatar Jeremy Vignelles Committed by François Cartegnie

demux: ts: fixed duration probing

Symptoms: I have a recorded .ts file that is around 15 seconds long for
testing.
VLC can play the stream fine, but the displayed duration is 10s.
When VLC reaches the end of the file, it seems to realize that there is
more data and increases the duration as the file plays.

Digging into ProbeEnd:
I digged into the code and found the ProbeEnd method.
It calls ProbeChunk, with output args (the pcr and a found boolean).

If pcr == -1, the previous chunk is taken, until PROBE_MAX is reached.

However, the i_pcr received from the ProbeChunk method is the pcr of the
last packet, and not the pcr of the last packet with a pcr.
It means that most of the time, the pcr is -1 and the previous chunk is
read, even though b_found is true.

What's the use of that condition? I removed it, please correct me if I'm
wrong.

The ProbeStart has the same suspicious condition, so I removed it too. I
also saw the suspicious `i_pos > 0` which is always false at the first
iteration.
Signed-off-by: François Cartegnie's avatarFrancois Cartegnie <fcvlcdev@free.fr>
parent 6a923aeb
......@@ -2122,7 +2122,7 @@ int ProbeStart( demux_t *p_demux, int i_program )
/* Go ahead one more chunk if end of file contained only stuffing packets */
i_probe_count += PROBE_CHUNK_COUNT;
} while( i_pos > 0 && (i_pcr == -1 || !b_found) &&
} while( i_pos < i_stream_size && !b_found &&
i_probe_count < PROBE_MAX );
if( vlc_stream_Seek( p_sys->stream, i_initial_pos ) )
......@@ -2154,7 +2154,7 @@ int ProbeEnd( demux_t *p_demux, int i_program )
/* Go ahead one more chunk if end of file contained only stuffing packets */
i_probe_count += PROBE_CHUNK_COUNT;
} while( i_pos > 0 && (i_pcr == -1 || !b_found) &&
} while( i_pos > 0 && !b_found &&
i_probe_count < PROBE_MAX );
if( vlc_stream_Seek( p_sys->stream, i_initial_pos ) )
......
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