forked from teamnwah/openmw-tes3coop
Avoid showing a video picture if we're late
Ideally we should skip decoding, or at least YUV->RGB conversion, too.
This commit is contained in:
parent
157cb10f56
commit
8db5d10f10
1 changed files with 12 additions and 11 deletions
|
@ -447,8 +447,6 @@ void VideoState::video_display()
|
||||||
buffer->blitFromMemory(pb);
|
buffer->blitFromMemory(pb);
|
||||||
this->display_ready = 1;
|
this->display_ready = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(vp->data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoState::video_refresh_timer()
|
void VideoState::video_refresh_timer()
|
||||||
|
@ -504,17 +502,21 @@ void VideoState::video_refresh_timer()
|
||||||
actual_delay = this->frame_timer - (av_gettime() / 1000000.0);
|
actual_delay = this->frame_timer - (av_gettime() / 1000000.0);
|
||||||
if(actual_delay < 0.010)
|
if(actual_delay < 0.010)
|
||||||
{
|
{
|
||||||
/* Really it should skip the picture instead */
|
/* Skip this picture */
|
||||||
actual_delay = 0.010;
|
this->refresh = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
this->schedule_refresh((int)(actual_delay * 1000 + 0.5));
|
this->schedule_refresh((int)(actual_delay * 1000 + 0.5));
|
||||||
|
|
||||||
/* show the picture! */
|
/* show the picture! */
|
||||||
this->video_display();
|
this->video_display();
|
||||||
|
}
|
||||||
|
|
||||||
|
free(vp->data);
|
||||||
|
vp->data = NULL;
|
||||||
|
|
||||||
/* update queue for next picture! */
|
/* update queue for next picture! */
|
||||||
if(++this->pictq_rindex == VIDEO_PICTURE_QUEUE_SIZE)
|
this->pictq_rindex = (this->pictq_rindex+1) % VIDEO_PICTURE_QUEUE_SIZE;
|
||||||
this->pictq_rindex = 0;
|
|
||||||
this->pictq_mutex.lock();
|
this->pictq_mutex.lock();
|
||||||
this->pictq_size--;
|
this->pictq_size--;
|
||||||
this->pictq_cond.notify_one();
|
this->pictq_cond.notify_one();
|
||||||
|
@ -550,13 +552,12 @@ int VideoState::queue_picture(AVFrame *pFrame, double pts)
|
||||||
throw std::runtime_error("Cannot initialize the conversion context!\n");
|
throw std::runtime_error("Cannot initialize the conversion context!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vp->pts = pts;
|
||||||
vp->data = (uint8_t*)malloc(this->video_st->codec->width * this->video_st->codec->height * 4);
|
vp->data = (uint8_t*)malloc(this->video_st->codec->width * this->video_st->codec->height * 4);
|
||||||
|
|
||||||
sws_scale(this->sws_context, pFrame->data, pFrame->linesize,
|
sws_scale(this->sws_context, pFrame->data, pFrame->linesize,
|
||||||
0, this->video_st->codec->height, &vp->data, this->rgbaFrame->linesize);
|
0, this->video_st->codec->height, &vp->data, this->rgbaFrame->linesize);
|
||||||
|
|
||||||
vp->pts = pts;
|
|
||||||
|
|
||||||
// now we inform our display thread that we have a pic ready
|
// now we inform our display thread that we have a pic ready
|
||||||
this->pictq_windex = (this->pictq_windex+1) % VIDEO_PICTURE_QUEUE_SIZE;
|
this->pictq_windex = (this->pictq_windex+1) % VIDEO_PICTURE_QUEUE_SIZE;
|
||||||
this->pictq_mutex.lock();
|
this->pictq_mutex.lock();
|
||||||
|
|
Loading…
Reference in a new issue