MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / video_refresh_timer

Function video_refresh_timer

ffplay.c:1160–1296  ·  view source on GitHub ↗

called to display each frame */

Source from the content-addressed store, hash-verified

1158
1159/* called to display each frame */
1160static void video_refresh_timer(void *opaque)
1161{
1162 VideoState *is = opaque;
1163 VideoPicture *vp;
1164
1165 SubPicture *sp, *sp2;
1166
1167 if (is->video_st) {
1168retry:
1169 if (is->pictq_size == 0) {
1170 //nothing to do, no picture to display in the que
1171 } else {
1172 double time= av_gettime()/1000000.0;
1173 double next_target;
1174 /* dequeue the picture */
1175 vp = &is->pictq[is->pictq_rindex];
1176
1177 if(time < vp->target_clock)
1178 return;
1179 /* update current video pts */
1180 is->video_current_pts = vp->pts;
1181 is->video_current_pts_drift = is->video_current_pts - time;
1182 is->video_current_pos = vp->pos;
1183 if(is->pictq_size > 1){
1184 VideoPicture *nextvp= &is->pictq[(is->pictq_rindex+1)%VIDEO_PICTURE_QUEUE_SIZE];
1185 assert(nextvp->target_clock >= vp->target_clock);
1186 next_target= nextvp->target_clock;
1187 }else{
1188 next_target= vp->target_clock + is->video_clock - vp->pts; //FIXME pass durations cleanly
1189 }
1190 if(framedrop && time > next_target){
1191 is->skip_frames *= 1.0 + FRAME_SKIP_FACTOR;
1192 if(is->pictq_size > 1 || time > next_target + 0.5){
1193 /* update queue size and signal for next picture */
1194 if (++is->pictq_rindex == VIDEO_PICTURE_QUEUE_SIZE)
1195 is->pictq_rindex = 0;
1196
1197 SDL_LockMutex(is->pictq_mutex);
1198 is->pictq_size--;
1199 SDL_CondSignal(is->pictq_cond);
1200 SDL_UnlockMutex(is->pictq_mutex);
1201 goto retry;
1202 }
1203 }
1204
1205 if(is->subtitle_st) {
1206 if (is->subtitle_stream_changed) {
1207 SDL_LockMutex(is->subpq_mutex);
1208
1209 while (is->subpq_size) {
1210 free_subpicture(&is->subpq[is->subpq_rindex]);
1211
1212 /* update queue size and signal for next picture */
1213 if (++is->subpq_rindex == SUBPICTURE_QUEUE_SIZE)
1214 is->subpq_rindex = 0;
1215
1216 is->subpq_size--;
1217 }

Callers 1

event_loopFunction · 0.85

Calls 6

av_gettimeFunction · 0.85
free_subpictureFunction · 0.85
video_displayFunction · 0.85
get_audio_clockFunction · 0.85
get_video_clockFunction · 0.85
get_master_clockFunction · 0.85

Tested by

no test coverage detected