summaryrefslogtreecommitdiff
path: root/ffplay.c
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2013-04-01 15:04:14 +0200
committerMarton Balint <cus@passwd.hu>2013-04-08 22:21:45 +0200
commit85b9bf5693c821bcfec89ea0964f52a7eeff233f (patch)
tree779505fe7c7bfcdbe7750f6aec0b68f4417e8687 /ffplay.c
parent5dacf7b1ab40276c4d56b86081cbad7552a85f70 (diff)
ffplay: simplify video pts calculation
Also use frame->pts instead of a standalone variable Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'ffplay.c')
-rw-r--r--ffplay.c41
1 files changed, 12 insertions, 29 deletions
diff --git a/ffplay.c b/ffplay.c
index dd530b6a24..13125391bb 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -1648,7 +1648,7 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, int64_t
return 0;
}
-static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacket *pkt, int *serial)
+static int get_video_frame(VideoState *is, AVFrame *frame, AVPacket *pkt, int *serial)
{
int got_picture;
@@ -1679,22 +1679,22 @@ static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacke
int ret = 1;
if (decoder_reorder_pts == -1) {
- *pts = av_frame_get_best_effort_timestamp(frame);
+ frame->pts = av_frame_get_best_effort_timestamp(frame);
} else if (decoder_reorder_pts) {
- *pts = frame->pkt_pts;
+ frame->pts = frame->pkt_pts;
} else {
- *pts = frame->pkt_dts;
+ frame->pts = frame->pkt_dts;
}
- if (*pts == AV_NOPTS_VALUE) {
- *pts = 0;
+ if (frame->pts == AV_NOPTS_VALUE) {
+ frame->pts = 0;
}
if (framedrop>0 || (framedrop && get_master_sync_type(is) != AV_SYNC_VIDEO_MASTER)) {
SDL_LockMutex(is->pictq_mutex);
- if (is->frame_last_pts != AV_NOPTS_VALUE && *pts) {
+ if (is->frame_last_pts != AV_NOPTS_VALUE && frame->pts) {
double clockdiff = get_video_clock(is) - get_master_clock(is);
- double dpts = av_q2d(is->video_st->time_base) * *pts;
+ double dpts = av_q2d(is->video_st->time_base) * frame->pts;
double ptsdiff = dpts - is->frame_last_pts;
if (!isnan(clockdiff) && fabs(clockdiff) < AV_NOSYNC_THRESHOLD &&
ptsdiff > 0 && ptsdiff < AV_NOSYNC_THRESHOLD &&
@@ -1886,7 +1886,6 @@ static int video_thread(void *arg)
AVPacket pkt = { 0 };
VideoState *is = arg;
AVFrame *frame = av_frame_alloc();
- int64_t pts_int = AV_NOPTS_VALUE, pos = -1;
double pts;
int ret;
int serial = 0;
@@ -1901,19 +1900,15 @@ static int video_thread(void *arg)
#endif
for (;;) {
-#if CONFIG_AVFILTER
- AVRational tb;
-#endif
while (is->paused && !is->videoq.abort_request)
SDL_Delay(10);
avcodec_get_frame_defaults(frame);
av_free_packet(&pkt);
- ret = get_video_frame(is, frame, &pts_int, &pkt, &serial);
+ ret = get_video_frame(is, frame, &pkt, &serial);
if (ret < 0)
goto the_end;
-
if (!ret)
continue;
@@ -1946,7 +1941,6 @@ static int video_thread(void *arg)
last_serial = serial;
}
- frame->pts = pts_int;
frame->sample_aspect_ratio = av_guess_sample_aspect_ratio(is->ic, is->video_st, frame);
ret = av_buffersrc_add_frame(filt_in, frame);
if (ret < 0)
@@ -1968,23 +1962,12 @@ static int video_thread(void *arg)
if (fabs(is->frame_last_filter_delay) > AV_NOSYNC_THRESHOLD / 10.0)
is->frame_last_filter_delay = 0;
- pts_int = frame->pts;
- tb = filt_out->inputs[0]->time_base;
- pos = av_frame_get_pkt_pos(frame);
- if (av_cmp_q(tb, is->video_st->time_base)) {
- av_unused int64_t pts1 = pts_int;
- pts_int = av_rescale_q(pts_int, tb, is->video_st->time_base);
- av_dlog(NULL, "video_thread(): "
- "tb:%d/%d pts:%"PRId64" -> tb:%d/%d pts:%"PRId64"\n",
- tb.num, tb.den, pts1,
- is->video_st->time_base.num, is->video_st->time_base.den, pts_int);
- }
- pts = pts_int * av_q2d(is->video_st->time_base);
- ret = queue_picture(is, frame, pts, pos, serial);
+ pts = frame->pts * av_q2d(filt_out->inputs[0]->time_base);
+ ret = queue_picture(is, frame, pts, av_frame_get_pkt_pos(frame), serial);
av_frame_unref(frame);
}
#else
- pts = pts_int * av_q2d(is->video_st->time_base);
+ pts = frame->pts * av_q2d(is->video_st->time_base);
ret = queue_picture(is, frame, pts, pkt.pos, serial);
av_frame_unref(frame);
#endif