diff --git a/ffplay.c b/ffplay.c index 9d9e1083e4..317e273d1c 100644 --- a/ffplay.c +++ b/ffplay.c @@ -67,6 +67,8 @@ const int program_birth_year = 2003; #define MAX_QUEUE_SIZE (15 * 1024 * 1024) #define MIN_FRAMES 5 +#define EXTERNAL_CLOCK_MIN_FRAMES 2 +#define EXTERNAL_CLOCK_MAX_FRAMES 10 /* Minimum SDL audio buffer size, in samples. */ #define SDL_AUDIO_MIN_BUFFER_SIZE 512 @@ -1301,11 +1303,11 @@ static double get_master_clock(VideoState *is) } static void check_external_clock_speed(VideoState *is) { - if (is->video_stream >= 0 && is->videoq.nb_packets <= MIN_FRAMES / 2 || - is->audio_stream >= 0 && is->audioq.nb_packets <= MIN_FRAMES / 2) { + if (is->video_stream >= 0 && is->videoq.nb_packets <= EXTERNAL_CLOCK_MIN_FRAMES || + is->audio_stream >= 0 && is->audioq.nb_packets <= EXTERNAL_CLOCK_MIN_FRAMES) { set_clock_speed(&is->extclk, FFMAX(EXTERNAL_CLOCK_SPEED_MIN, is->extclk.speed - EXTERNAL_CLOCK_SPEED_STEP)); - } else if ((is->video_stream < 0 || is->videoq.nb_packets > MIN_FRAMES * 2) && - (is->audio_stream < 0 || is->audioq.nb_packets > MIN_FRAMES * 2)) { + } else if ((is->video_stream < 0 || is->videoq.nb_packets > EXTERNAL_CLOCK_MAX_FRAMES) && + (is->audio_stream < 0 || is->audioq.nb_packets > EXTERNAL_CLOCK_MAX_FRAMES)) { set_clock_speed(&is->extclk, FFMIN(EXTERNAL_CLOCK_SPEED_MAX, is->extclk.speed + EXTERNAL_CLOCK_SPEED_STEP)); } else { double speed = is->extclk.speed;