is->video_current_pts = vp->pts; is->video_current_pts_time = av_gettime();   delay = vp->pts - is->frame_last_pts; if (delay <= 0 || delay >= 1.0) {  delay = is->frame_last_delay; } is->frame_last_delay = delay; is->frame_last_pts = vp->pts;   if (((is->av_sync_type == AV_SYNC_AUDIO_MASTER && is->audio_st) || is->av_sync_type == AV_SYNC_EXTERNAL_CLOCK)) {  ref_clock = get_master_clock(is); diff = vp->pts - ref_clock;   sync_threshold = AV_SYNC_THRESHOLD; if (delay > sync_threshold) sync_threshold = delay; if (fabs(diff) < AV_NOSYNC_THRESHOLD) { if (diff <= -sync_threshold) delay = 0; else if (diff >= sync_threshold) delay = 2 * delay; } }  is->frame_timer += delay;  actual_delay = is->frame_timer - (av_gettime() / 1000000.0); if (actual_delay < 0.010) {  actual_delay = 0.010; }
static void video_refresh_timer(void *opaque){    VideoState *is = opaque;    VideoPicture *vp;    if (is->video_st) {        if (is->pictq_size == 0) {            /* if no picture, need to wait */            schedule_refresh(is, 40);        } else {            vp = &is->pictq[is->pictq_rindex];                        /* launch timer for next picture */            schedule_refresh(is, vp->delay);            /* display picture */            video_display(is);                        /* update queue size and signal for next picture */            if (++is->pictq_rindex == VIDEO_PICTURE_QUEUE_SIZE)                is->pictq_rindex = 0;                        SDL_LockMutex(is->pictq_mutex);            is->pictq_size--;            SDL_CondSignal(is->pictq_cond);            SDL_UnlockMutex(is->pictq_mutex);        }    } else if (is->audio_st) {        /* draw the next audio frame */        schedule_refresh(is, 40);        /* if only audio stream, then display the audio bars (better           than nothing, just to test the implementation */                /* display picture */        video_display(is);    } else {        schedule_refresh(is, 100);    }    if (show_status) {        static int64_t last_time;        int64_t cur_time;        int aqsize, vqsize;                cur_time = av_gettime();        if (!last_time || (cur_time - last_time) >= 500 * 1000) {            aqsize = 0;            vqsize = 0;            if (is->audio_st)                aqsize = is->audioq.size;            if (is->video_st)                vqsize = is->videoq.size;            printf("A:%7.2f V:%7.2f aq=%5dKB vq=%5dKB    \r",                    is->audio_clock, is->video_clock, aqsize / 1024, vqsize / 1024);            fflush(stdout);            last_time = cur_time;        }    }}