Commit d2d8e1e5 authored by Marton Balint's avatar Marton Balint

ffplay: remove early frame drop functionality

The current impementation of early frame drops (dropping frames before adding
them to the picture queue) has multiple problems:

Even after gettin A-V sync, the frame droping continues until
VideoState->skip_frames reaches 1, which can take a lot of time causing useless
additional frame drops and bad AV-sync. This issue can be easily triggered with
for example changing the audio stream.

Also video_refresh currenly does not handle early skipped frames in every case,
for example if we skip a frame, then the last frame duration calculation will
compute the duration of the sum of the skipped frame and the duration of the
frame before that, and in compute_target_delay we may multiply this unusually
big delay.
Signed-off-by: 's avatarMarton Balint <cus@passwd.hu>
parent 4e268aae
...@@ -71,8 +71,6 @@ const int program_birth_year = 2003; ...@@ -71,8 +71,6 @@ const int program_birth_year = 2003;
/* no AV correction is done if too big error */ /* no AV correction is done if too big error */
#define AV_NOSYNC_THRESHOLD 10.0 #define AV_NOSYNC_THRESHOLD 10.0
#define FRAME_SKIP_FACTOR 0.05
/* maximum audio speed change to get correct sync */ /* maximum audio speed change to get correct sync */
#define SAMPLE_CORRECTION_PERCENT_MAX 10 #define SAMPLE_CORRECTION_PERCENT_MAX 10
...@@ -221,8 +219,6 @@ typedef struct VideoState { ...@@ -221,8 +219,6 @@ typedef struct VideoState {
AVFilterContext *out_video_filter; ///<the last filter in the video chain AVFilterContext *out_video_filter; ///<the last filter in the video chain
#endif #endif
float skip_frames;
float skip_frames_index;
int refresh; int refresh;
} VideoState; } VideoState;
...@@ -1161,7 +1157,6 @@ retry: ...@@ -1161,7 +1157,6 @@ retry:
} }
if((framedrop>0 || (framedrop && is->audio_st)) && time > is->frame_timer + duration){ if((framedrop>0 || (framedrop && is->audio_st)) && time > is->frame_timer + duration){
is->skip_frames *= 1.0 + FRAME_SKIP_FACTOR;
if(is->pictq_size > 1){ if(is->pictq_size > 1){
pictq_next_picture(is); pictq_next_picture(is);
goto retry; goto retry;
...@@ -1248,10 +1243,9 @@ retry: ...@@ -1248,10 +1243,9 @@ retry:
av_diff = 0; av_diff = 0;
if (is->audio_st && is->video_st) if (is->audio_st && is->video_st)
av_diff = get_audio_clock(is) - get_video_clock(is); av_diff = get_audio_clock(is) - get_video_clock(is);
printf("%7.2f A-V:%7.3f s:%3.1f aq=%5dKB vq=%5dKB sq=%5dB f=%"PRId64"/%"PRId64" \r", printf("%7.2f A-V:%7.3f aq=%5dKB vq=%5dKB sq=%5dB f=%"PRId64"/%"PRId64" \r",
get_master_clock(is), get_master_clock(is),
av_diff, av_diff,
FFMAX(is->skip_frames-1, 0),
aqsize / 1024, aqsize / 1024,
vqsize / 1024, vqsize / 1024,
sqsize, sqsize,
...@@ -1335,9 +1329,6 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts1, int64_ ...@@ -1335,9 +1329,6 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts1, int64_
/* wait until we have space to put a new picture */ /* wait until we have space to put a new picture */
SDL_LockMutex(is->pictq_mutex); SDL_LockMutex(is->pictq_mutex);
if(is->pictq_size>=VIDEO_PICTURE_QUEUE_SIZE && !is->refresh)
is->skip_frames= FFMAX(1.0 - FRAME_SKIP_FACTOR, is->skip_frames * (1.0-FRAME_SKIP_FACTOR));
while (is->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE && while (is->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE &&
!is->videoq.abort_request) { !is->videoq.abort_request) {
SDL_CondWait(is->pictq_cond, is->pictq_mutex); SDL_CondWait(is->pictq_cond, is->pictq_mutex);
...@@ -1465,8 +1456,6 @@ static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacke ...@@ -1465,8 +1456,6 @@ static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacke
is->frame_last_pts = AV_NOPTS_VALUE; is->frame_last_pts = AV_NOPTS_VALUE;
is->frame_last_duration = 0; is->frame_last_duration = 0;
is->frame_timer = (double)av_gettime() / 1000000.0; is->frame_timer = (double)av_gettime() / 1000000.0;
is->skip_frames = 1;
is->skip_frames_index = 0;
return 0; return 0;
} }
...@@ -1485,11 +1474,7 @@ static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacke ...@@ -1485,11 +1474,7 @@ static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacke
*pts = 0; *pts = 0;
} }
is->skip_frames_index += 1;
if(is->skip_frames_index >= is->skip_frames){
is->skip_frames_index -= FFMAX(is->skip_frames, 1.0);
return 1; return 1;
}
} }
return 0; return 0;
......
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