Commit c2606259 authored by Stefano Sabatini's avatar Stefano Sabatini

ffplay: move output_picture() code to queue_picture()

Move output_picture() code to queue_picture(), and remove it.
Simplify code path.
parent 4a22ea4d
...@@ -1359,13 +1359,30 @@ static void alloc_picture(void *opaque) ...@@ -1359,13 +1359,30 @@ static void alloc_picture(void *opaque)
SDL_UnlockMutex(is->pictq_mutex); SDL_UnlockMutex(is->pictq_mutex);
} }
/** static int queue_picture(VideoState *is, AVFrame *src_frame, double pts1, int64_t pos)
*
* @param pts the dts of the pkt / pts of the frame and guessed if not known
*/
static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, int64_t pos)
{ {
VideoPicture *vp; VideoPicture *vp;
double frame_delay, pts = pts1;
/* compute the exact PTS for the picture if it is omitted in the stream
* pts1 is the dts of the pkt / pts of the frame */
if (pts != 0) {
/* update video clock with pts, if present */
is->video_clock = pts;
} else {
pts = is->video_clock;
}
/* update video clock for next frame */
frame_delay = av_q2d(is->video_st->codec->time_base);
/* for MPEG2, the frame can be repeated, so we update the
clock accordingly */
frame_delay += src_frame->repeat_pict * (frame_delay * 0.5);
is->video_clock += frame_delay;
#if defined(DEBUG_SYNC) && 0
printf("frame_type=%c clock=%0.3f pts=%0.3f\n",
av_get_pict_type_char(src_frame->pict_type), pts, pts1);
#endif
/* 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);
...@@ -1469,36 +1486,6 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, int64_t ...@@ -1469,36 +1486,6 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, int64_t
return 0; return 0;
} }
/**
* compute the exact PTS for the picture if it is omitted in the stream
* @param pts1 the dts of the pkt / pts of the frame
*/
static int output_picture(VideoState *is, AVFrame *src_frame, double pts1, int64_t pos)
{
double frame_delay, pts;
pts = pts1;
if (pts != 0) {
/* update video clock with pts, if present */
is->video_clock = pts;
} else {
pts = is->video_clock;
}
/* update video clock for next frame */
frame_delay = av_q2d(is->video_st->codec->time_base);
/* for MPEG2, the frame can be repeated, so we update the
clock accordingly */
frame_delay += src_frame->repeat_pict * (frame_delay * 0.5);
is->video_clock += frame_delay;
#if defined(DEBUG_SYNC) && 0
printf("frame_type=%c clock=%0.3f pts=%0.3f\n",
av_get_pict_type_char(src_frame->pict_type), pts, pts1);
#endif
return queue_picture(is, src_frame, pts, pos);
}
static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacket *pkt) static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacket *pkt)
{ {
int len1, got_picture, i; int len1, got_picture, i;
...@@ -1853,7 +1840,7 @@ static int video_thread(void *arg) ...@@ -1853,7 +1840,7 @@ static int video_thread(void *arg)
pts = pts_int*av_q2d(is->video_st->time_base); pts = pts_int*av_q2d(is->video_st->time_base);
ret = output_picture(is, frame, pts, pos); ret = queue_picture(is, frame, pts, pos);
#if !CONFIG_AVFILTER #if !CONFIG_AVFILTER
av_free_packet(&pkt); av_free_packet(&pkt);
#endif #endif
......
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