[vlc-commits] demux: avi: start decoding from lowest seek point
Francois Cartegnie
git at videolan.org
Fri Oct 6 11:00:28 CEST 2017
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Oct 6 10:24:56 2017 +0200| [72e434da7fd4025c124489bc605c67b4bee20e83] | committer: Francois Cartegnie
demux: avi: start decoding from lowest seek point
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=72e434da7fd4025c124489bc605c67b4bee20e83
---
modules/demux/avi/avi.c | 33 ++++++++++++++++++++++++++-------
1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c
index b521f61954..dd5c03c98e 100644
--- a/modules/demux/avi/avi.c
+++ b/modules/demux/avi/avi.c
@@ -1592,18 +1592,37 @@ static int Seek( demux_t *p_demux, mtime_t i_date, int i_percent )
}
/* */
- for( unsigned i_stream = 0; i_stream < p_sys->i_track; i_stream++ )
+ mtime_t i_wanted = i_date;
+ mtime_t i_start = i_date;
+ /* Do a 2 pass seek, first with video (can seek ahead due to keyframes),
+ so we can seek audio to the same starting time */
+ for(int i=0; i<2; i++)
{
- avi_track_t *p_stream = p_sys->track[i_stream];
+ for( unsigned i_stream = 0; i_stream < p_sys->i_track; i_stream++ )
+ {
+ avi_track_t *p_stream = p_sys->track[i_stream];
- if( !p_stream->b_activated )
- continue;
+ if( !p_stream->b_activated )
+ continue;
+
+ if( (i==0 && p_stream->fmt.i_cat != VIDEO_ES) ||
+ (i!=0 && p_stream->fmt.i_cat == VIDEO_ES) )
+ continue;
- p_stream->b_eof = AVI_TrackSeek( p_demux, i_stream, i_date ) != 0;
+ p_stream->b_eof = AVI_TrackSeek( p_demux, i_stream, i_wanted ) != 0;
+ if( !p_stream->b_eof )
+ {
+ if( p_stream->fmt.i_cat == AUDIO_ES || p_stream->fmt.i_cat == VIDEO_ES )
+ i_start = __MIN(i_start, AVI_GetPTS( p_stream ));
+
+ if( i == 0 && p_stream->fmt.i_cat == VIDEO_ES )
+ i_wanted = i_start;
+ }
+ }
}
- p_sys->i_time = i_date;
+ p_sys->i_time = i_start;
es_out_SetPCR( p_demux->out, VLC_TS_0 + p_sys->i_time );
- es_out_Control( p_demux->out, ES_OUT_SET_NEXT_DISPLAY_TIME, VLC_TS_0 + p_sys->i_time );
+ es_out_Control( p_demux->out, ES_OUT_SET_NEXT_DISPLAY_TIME, VLC_TS_0 + i_date );
msg_Dbg( p_demux, "seek: %"PRId64" seconds", p_sys->i_time /CLOCK_FREQ );
return VLC_SUCCESS;
More information about the vlc-commits
mailing list