Commit 1a033fe0 authored by Laurent Aimar's avatar Laurent Aimar

Finished avi correction about disabled tracks.

It is about [a0d23587].
Without this patch, with files that have a shorter track, the demuxer
would try seeking the track every time the Demux() function was called.
parent 1a912ab7
...@@ -113,6 +113,7 @@ typedef struct ...@@ -113,6 +113,7 @@ typedef struct
typedef struct typedef struct
{ {
bool b_activated; bool b_activated;
bool b_eof;
unsigned int i_cat; /* AUDIO_ES, VIDEO_ES */ unsigned int i_cat; /* AUDIO_ES, VIDEO_ES */
vlc_fourcc_t i_codec; vlc_fourcc_t i_codec;
...@@ -361,7 +362,9 @@ static int Open( vlc_object_t * p_this ) ...@@ -361,7 +362,9 @@ static int Open( vlc_object_t * p_this )
avi_chunk_strf_vids_t *p_vids = NULL; avi_chunk_strf_vids_t *p_vids = NULL;
es_format_t fmt; es_format_t fmt;
memset( tk, 0, sizeof( avi_track_t ) ); memset( tk, 0, sizeof(*tk) );
tk->b_eof = false;
tk->b_activated = true;
p_vids = (avi_chunk_strf_vids_t*)AVI_ChunkFind( p_strl, AVIFOURCC_strf, 0 ); p_vids = (avi_chunk_strf_vids_t*)AVI_ChunkFind( p_strl, AVIFOURCC_strf, 0 );
p_auds = (avi_chunk_strf_auds_t*)AVI_ChunkFind( p_strl, AVIFOURCC_strf, 0 ); p_auds = (avi_chunk_strf_auds_t*)AVI_ChunkFind( p_strl, AVIFOURCC_strf, 0 );
...@@ -876,7 +879,7 @@ static int Demux_Seekable( demux_t *p_demux ) ...@@ -876,7 +879,7 @@ static int Demux_Seekable( demux_t *p_demux )
avi_track_t *tk = p_sys->track[i_track]; avi_track_t *tk = p_sys->track[i_track];
mtime_t i_dpts; mtime_t i_dpts;
toread[i_track].b_ok = tk->b_activated; toread[i_track].b_ok = tk->b_activated && !tk->b_eof;
if( tk->i_idxposc < tk->i_idxnb ) if( tk->i_idxposc < tk->i_idxnb )
{ {
toread[i_track].i_posf = tk->p_index[tk->i_idxposc].i_pos; toread[i_track].i_posf = tk->p_index[tk->i_idxposc].i_pos;
...@@ -1081,7 +1084,7 @@ static int Demux_Seekable( demux_t *p_demux ) ...@@ -1081,7 +1084,7 @@ static int Demux_Seekable( demux_t *p_demux )
if( ( p_frame = stream_Block( p_demux->s, __EVEN( i_size ) ) )==NULL ) if( ( p_frame = stream_Block( p_demux->s, __EVEN( i_size ) ) )==NULL )
{ {
msg_Warn( p_demux, "failed reading data" ); msg_Warn( p_demux, "failed reading data" );
tk->b_activated = false; tk->b_eof = false;
toread[i_track].b_ok = false; toread[i_track].b_ok = false;
continue; continue;
} }
...@@ -1339,16 +1342,16 @@ static int Seek( demux_t *p_demux, mtime_t i_date, int i_percent ) ...@@ -1339,16 +1342,16 @@ static int Seek( demux_t *p_demux, mtime_t i_date, int i_percent )
/* try to find chunk that is at i_percent or the file */ /* try to find chunk that is at i_percent or the file */
i_pos = __MAX( i_percent * stream_Size( p_demux->s ) / 100, i_pos = __MAX( i_percent * stream_Size( p_demux->s ) / 100,
p_sys->i_movi_begin ); p_sys->i_movi_begin );
/* search first selected stream */ /* search first selected stream (and prefer non eof ones) */
for( i_stream = 0, p_stream = NULL; for( i_stream = 0, p_stream = NULL;
i_stream < p_sys->i_track; i_stream++ ) i_stream < p_sys->i_track; i_stream++ )
{ {
if( !p_stream || p_stream->b_eof )
p_stream = p_sys->track[i_stream]; p_stream = p_sys->track[i_stream];
if( p_stream->b_activated )
{ if( p_stream->b_activated && !p_stream->b_eof )
break; break;
} }
}
if( !p_stream || !p_stream->b_activated ) if( !p_stream || !p_stream->b_activated )
{ {
msg_Warn( p_demux, "cannot find any selected stream" ); msg_Warn( p_demux, "cannot find any selected stream" );
...@@ -1387,7 +1390,7 @@ static int Seek( demux_t *p_demux, mtime_t i_date, int i_percent ) ...@@ -1387,7 +1390,7 @@ static int Seek( demux_t *p_demux, mtime_t i_date, int i_percent )
if( !p_stream->b_activated ) if( !p_stream->b_activated )
continue; continue;
AVI_TrackSeek( p_demux, i_stream, i_date ); p_stream->b_eof = AVI_TrackSeek( p_demux, i_stream, i_date ) != 0;
} }
es_out_Control( p_demux->out, ES_OUT_SET_NEXT_DISPLAY_TIME, i_date ); es_out_Control( p_demux->out, ES_OUT_SET_NEXT_DISPLAY_TIME, i_date );
p_sys->i_time = i_date; p_sys->i_time = i_date;
...@@ -2460,7 +2463,7 @@ static int AVI_TrackStopFinishedStreams( demux_t *p_demux ) ...@@ -2460,7 +2463,7 @@ static int AVI_TrackStopFinishedStreams( demux_t *p_demux )
avi_track_t *tk = p_sys->track[i]; avi_track_t *tk = p_sys->track[i];
if( tk->i_idxposc >= tk->i_idxnb ) if( tk->i_idxposc >= tk->i_idxnb )
{ {
tk->b_activated = false; tk->b_eof = true;
} }
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