--- libmpdemux/demux_nuv.c.1 2006-11-05 18:33:51.000000000 -0500 +++ libmpdemux/demux_nuv.c 2006-11-05 18:40:36.000000000 -0500 @@ -70,7 +70,6 @@ struct rtframeheader rtjpeg_frameheader; off_t orig_pos; off_t curr_pos; - float current_time = 0; float start_time = MAX_TIME; float target_time = start_time + rel_seek_secs * 1000; /* target_time, start_time are ms, rel_seek_secs s */ @@ -79,7 +78,7 @@ /* Seeking forward */ - while(current_time < target_time ) + for(;;) { orig_pos = stream_tell ( demuxer->stream ); @@ -89,12 +88,18 @@ if ( rtjpeg_frameheader.frametype == 'V' ) { - priv->current_position->next = (nuv_position_t*) malloc ( sizeof ( nuv_position_t ) ); - priv->current_position = priv->current_position->next; - priv->current_position->frame = priv->current_video_frame++; - priv->current_position->time = rtjpeg_frameheader.timecode; - priv->current_position->offset = orig_pos; - priv->current_position->next = NULL; + if(rtjpeg_frameheader.keyframe == 0) { + if(rtjpeg_frameheader.timecode >= target_time) { + stream_seek(demuxer->stream, stream_tell(demuxer->stream) - sizeof(rtjpeg_frameheader)); + break; + } + priv->current_position->next = (nuv_position_t*) malloc ( sizeof ( nuv_position_t ) ); + priv->current_position = priv->current_position->next; + priv->current_position->frame = priv->current_video_frame++; + priv->current_position->time = rtjpeg_frameheader.timecode; + priv->current_position->offset = orig_pos; + priv->current_position->next = NULL; + } if ( start_time == MAX_TIME ) { @@ -103,8 +108,6 @@ target_time = start_time + rel_seek_secs*1000; } - current_time = rtjpeg_frameheader.timecode; - curr_pos = stream_tell ( demuxer->stream ); stream_seek ( demuxer->stream, curr_pos + rtjpeg_frameheader.packetlength ); @@ -118,7 +121,6 @@ /* Recalculate target time with real start time */ target_time = start_time + rel_seek_secs * 1000; } - current_time = rtjpeg_frameheader.timecode; curr_pos = stream_tell ( demuxer->stream ); @@ -187,7 +189,7 @@ (rtjpeg_frameheader.comptype == 'R')) || (rtjpeg_frameheader.frametype == 'V')) { - if ( rtjpeg_frameheader.frametype == 'V' ) + if ( rtjpeg_frameheader.frametype == 'V' && rtjpeg_frameheader.keyframe == 0 ) { priv->current_video_frame++; priv->current_position->next = (nuv_position_t*) malloc(sizeof(nuv_position_t));