mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-01-29 02:33:04 +00:00
ffplay: fix compute_target_delay to better handle frames with long durations
Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
parent
5b492720ad
commit
e341cb1102
16
ffplay.c
16
ffplay.c
@ -69,8 +69,12 @@ const int program_birth_year = 2003;
|
|||||||
A/V sync as SDL does not have hardware buffer fullness info. */
|
A/V sync as SDL does not have hardware buffer fullness info. */
|
||||||
#define SDL_AUDIO_BUFFER_SIZE 1024
|
#define SDL_AUDIO_BUFFER_SIZE 1024
|
||||||
|
|
||||||
/* no AV sync correction is done if below the AV sync threshold */
|
/* no AV sync correction is done if below the minimum AV sync threshold */
|
||||||
#define AV_SYNC_THRESHOLD 0.01
|
#define AV_SYNC_THRESHOLD_MIN 0.01
|
||||||
|
/* AV sync correction is done if above the maximum AV sync threshold */
|
||||||
|
#define AV_SYNC_THRESHOLD_MAX 0.1
|
||||||
|
/* If a frame duration is longer than this, it will not be duplicated to compensate AV sync */
|
||||||
|
#define AV_SYNC_FRAMEDUP_THRESHOLD 0.1
|
||||||
/* 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
|
||||||
|
|
||||||
@ -1257,10 +1261,12 @@ static double compute_target_delay(double delay, VideoState *is)
|
|||||||
/* skip or repeat frame. We take into account the
|
/* skip or repeat frame. We take into account the
|
||||||
delay to compute the threshold. I still don't know
|
delay to compute the threshold. I still don't know
|
||||||
if it is the best guess */
|
if it is the best guess */
|
||||||
sync_threshold = FFMAX(AV_SYNC_THRESHOLD, delay);
|
sync_threshold = FFMAX(AV_SYNC_THRESHOLD_MIN, FFMIN(AV_SYNC_THRESHOLD_MAX, delay));
|
||||||
if (!isnan(diff) && fabs(diff) < AV_NOSYNC_THRESHOLD) {
|
if (!isnan(diff) && fabs(diff) < is->max_frame_duration) {
|
||||||
if (diff <= -sync_threshold)
|
if (diff <= -sync_threshold)
|
||||||
delay = 0;
|
delay = FFMAX(0, delay + diff);
|
||||||
|
else if (diff >= sync_threshold && delay > AV_SYNC_FRAMEDUP_THRESHOLD)
|
||||||
|
delay = delay + diff;
|
||||||
else if (diff >= sync_threshold)
|
else if (diff >= sync_threshold)
|
||||||
delay = 2 * delay;
|
delay = 2 * delay;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user