double frame_last_returned_time;
double frame_last_filter_delay;
int64_t frame_last_dropped_pos;
- double video_clock; // pts of last decoded frame / predicted pts of next decoded frame
int video_stream;
AVStream *video_st;
PacketQueue videoq;
- double video_current_pts; // current displayed pts (different from video_clock if frame fifos are used)
+ double video_current_pts; // current displayed pts
double video_current_pts_drift; // video_current_pts - time (av_gettime) at which we updated video_current_pts - used to have running video pts
int64_t video_current_pos; // current displayed file pos
double max_frame_duration; // maximum duration of a frame - above this, we consider the jump a timestamp discontinuity
}
}
-static int queue_picture(VideoState *is, AVFrame *src_frame, double pts1, int64_t pos, int serial)
+static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, int64_t pos, int serial)
{
VideoPicture *vp;
- double frame_delay, pts = pts1;
-
- /* compute the exact PTS for the picture if it is omitted in the stream
- * pts1 is the dts of the pkt / pts of the frame */
- if (pts != 0) {
- /* update video clock with pts, if present */
- is->video_clock = pts;
- } else {
- pts = is->video_clock;
- }
- /* update video clock for next frame */
- frame_delay = av_q2d(is->video_st->codec->time_base);
- /* for MPEG2, the frame can be repeated, so we update the
- clock accordingly */
- frame_delay += src_frame->repeat_pict * (frame_delay * 0.5);
- is->video_clock += frame_delay;
#if defined(DEBUG_SYNC) && 0
- printf("frame_type=%c clock=%0.3f pts=%0.3f\n",
- av_get_picture_type_char(src_frame->pict_type), pts, pts1);
+ printf("frame_type=%c pts=%0.3f\n",
+ av_get_picture_type_char(src_frame->pict_type), pts);
#endif
/* wait until we have space to put a new picture */
max_nb_samples = ((nb_samples * (100 + SAMPLE_CORRECTION_PERCENT_MAX) / 100));
wanted_nb_samples = FFMIN(FFMAX(wanted_nb_samples, min_nb_samples), max_nb_samples);
}
- av_dlog(NULL, "diff=%f adiff=%f sample_diff=%d apts=%0.3f vpts=%0.3f %f\n",
+ av_dlog(NULL, "diff=%f adiff=%f sample_diff=%d apts=%0.3f %f\n",
diff, avg_diff, wanted_nb_samples - nb_samples,
- is->audio_clock, is->video_clock, is->audio_diff_threshold);
+ is->audio_clock, is->audio_diff_threshold);
}
} else {
/* too big difference : may be initial PTS errors, so
}
static void refresh_loop_wait_event(VideoState *is, SDL_Event *event) {
- int got_event;
- double remaining_time;
- do {
+ double remaining_time = 0.0;
+ SDL_PumpEvents();
+ while (!SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_ALLEVENTS)) {
if (!cursor_hidden && av_gettime() - cursor_last_shown > CURSOR_HIDE_DELAY) {
SDL_ShowCursor(0);
cursor_hidden = 1;
}
+ if (remaining_time > 0.0)
+ av_usleep((int64_t)(remaining_time * 1000000.0));
remaining_time = REFRESH_RATE;
if (is->show_mode != SHOW_MODE_NONE && (!is->paused || is->force_refresh))
video_refresh(is, &remaining_time);
SDL_PumpEvents();
- got_event = SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_ALLEVENTS);
- if (!got_event)
- av_usleep((int64_t)(remaining_time * 1000000.0));
- } while (!got_event);
+ }
}
/* handle an event sent by the GUI */