Assuming 0 pts may lead to bad framedrop decisions...
Signed-off-by: Marton Balint <cus@passwd.hu>
... | ... |
@@ -1361,7 +1361,7 @@ retry: |
1361 | 1361 |
|
1362 | 1362 |
/* compute nominal last_duration */ |
1363 | 1363 |
last_duration = vp->pts - is->frame_last_pts; |
1364 |
- if (last_duration > 0 && last_duration < is->max_frame_duration) { |
|
1364 |
+ if (!isnan(last_duration) && last_duration > 0 && last_duration < is->max_frame_duration) { |
|
1365 | 1365 |
/* if duration of the last frame was sane, update last_duration in video state */ |
1366 | 1366 |
is->frame_last_duration = last_duration; |
1367 | 1367 |
} |
... | ... |
@@ -1377,7 +1377,8 @@ retry: |
1377 | 1377 |
is->frame_timer += delay * FFMAX(1, floor((time-is->frame_timer) / delay)); |
1378 | 1378 |
|
1379 | 1379 |
SDL_LockMutex(is->pictq_mutex); |
1380 |
- update_video_pts(is, vp->pts, vp->pos, vp->serial); |
|
1380 |
+ if (!isnan(vp->pts)) |
|
1381 |
+ update_video_pts(is, vp->pts, vp->pos, vp->serial); |
|
1381 | 1382 |
SDL_UnlockMutex(is->pictq_mutex); |
1382 | 1383 |
|
1383 | 1384 |
if (is->pictq_size > 1) { |
... | ... |
@@ -1671,6 +1672,7 @@ static int get_video_frame(VideoState *is, AVFrame *frame, AVPacket *pkt, int *s |
1671 | 1671 |
|
1672 | 1672 |
if (got_picture) { |
1673 | 1673 |
int ret = 1; |
1674 |
+ double dpts = NAN; |
|
1674 | 1675 |
|
1675 | 1676 |
if (decoder_reorder_pts == -1) { |
1676 | 1677 |
frame->pts = av_frame_get_best_effort_timestamp(frame); |
... | ... |
@@ -1680,21 +1682,19 @@ static int get_video_frame(VideoState *is, AVFrame *frame, AVPacket *pkt, int *s |
1680 | 1680 |
frame->pts = frame->pkt_dts; |
1681 | 1681 |
} |
1682 | 1682 |
|
1683 |
- if (frame->pts == AV_NOPTS_VALUE) { |
|
1684 |
- frame->pts = 0; |
|
1685 |
- } |
|
1683 |
+ if (frame->pts != AV_NOPTS_VALUE) |
|
1684 |
+ dpts = av_q2d(is->video_st->time_base) * frame->pts; |
|
1686 | 1685 |
|
1687 | 1686 |
frame->sample_aspect_ratio = av_guess_sample_aspect_ratio(is->ic, is->video_st, frame); |
1688 | 1687 |
|
1689 | 1688 |
if (framedrop>0 || (framedrop && get_master_sync_type(is) != AV_SYNC_VIDEO_MASTER)) { |
1690 | 1689 |
SDL_LockMutex(is->pictq_mutex); |
1691 |
- if (is->frame_last_pts != AV_NOPTS_VALUE && frame->pts) { |
|
1690 |
+ if (is->frame_last_pts != AV_NOPTS_VALUE && frame->pts != AV_NOPTS_VALUE) { |
|
1692 | 1691 |
double clockdiff = get_video_clock(is) - get_master_clock(is); |
1693 |
- double dpts = av_q2d(is->video_st->time_base) * frame->pts; |
|
1694 | 1692 |
double ptsdiff = dpts - is->frame_last_pts; |
1695 | 1693 |
if (!isnan(clockdiff) && fabs(clockdiff) < AV_NOSYNC_THRESHOLD && |
1696 |
- ptsdiff > 0 && ptsdiff < AV_NOSYNC_THRESHOLD && |
|
1697 |
- clockdiff + ptsdiff - is->frame_last_filter_delay < 0) { |
|
1694 |
+ !isnan(ptsdiff) && ptsdiff > 0 && ptsdiff < AV_NOSYNC_THRESHOLD && |
|
1695 |
+ clockdiff + ptsdiff - is->frame_last_filter_delay < 0) { |
|
1698 | 1696 |
is->frame_last_dropped_pos = pkt->pos; |
1699 | 1697 |
is->frame_last_dropped_pts = dpts; |
1700 | 1698 |
is->frame_last_dropped_serial = *serial; |
... | ... |
@@ -1955,12 +1955,12 @@ static int video_thread(void *arg) |
1955 | 1955 |
if (fabs(is->frame_last_filter_delay) > AV_NOSYNC_THRESHOLD / 10.0) |
1956 | 1956 |
is->frame_last_filter_delay = 0; |
1957 | 1957 |
|
1958 |
- pts = frame->pts * av_q2d(filt_out->inputs[0]->time_base); |
|
1958 |
+ pts = (frame->pts == AV_NOPTS_VALUE) ? NAN : frame->pts * av_q2d(filt_out->inputs[0]->time_base); |
|
1959 | 1959 |
ret = queue_picture(is, frame, pts, av_frame_get_pkt_pos(frame), serial); |
1960 | 1960 |
av_frame_unref(frame); |
1961 | 1961 |
} |
1962 | 1962 |
#else |
1963 |
- pts = frame->pts * av_q2d(is->video_st->time_base); |
|
1963 |
+ pts = (frame->pts == AV_NOPTS_VALUE) ? NAN : frame->pts * av_q2d(is->video_st->time_base); |
|
1964 | 1964 |
ret = queue_picture(is, frame, pts, pkt.pos, serial); |
1965 | 1965 |
av_frame_unref(frame); |
1966 | 1966 |
#endif |