Commit 8e07ff9c authored by Laurent Aimar's avatar Laurent Aimar

Moved out the code retreiving a decoded picture from ThreadDisplayPicture.

No functional changes.
parent b8a46d56
...@@ -549,88 +549,103 @@ static int VoutVideoFilterAllocationSetup(filter_t *filter, void *data) ...@@ -549,88 +549,103 @@ static int VoutVideoFilterAllocationSetup(filter_t *filter, void *data)
} }
/* */ /* */
static int ThreadDisplayPicture(vout_thread_t *vout, static picture_t *ThreadDisplayGetDecodedPicture(vout_thread_t *vout,
bool now, mtime_t *deadline) int *lost_count, bool *is_forced,
bool now, mtime_t *deadline)
{ {
vout_display_t *vd = vout->p->display.vd; vout_display_t *vd = vout->p->display.vd;
int displayed_count = 0;
int lost_count = 0;
for (;;) { const mtime_t date = mdate();
const mtime_t date = mdate(); const bool is_paused = vout->p->pause.is_on;
const bool is_paused = vout->p->pause.is_on; bool redisplay = is_paused && !now && vout->p->displayed.decoded;
bool redisplay = is_paused && !now && vout->p->displayed.decoded;
bool is_forced; /* FIXME/XXX we must redisplay the last decoded picture (because
* of potential vout updated, or filters update or SPU update)
/* FIXME/XXX we must redisplay the last decoded picture (because * For now a high update period is needed but it coulmd be removed
* of potential vout updated, or filters update or SPU update) * if and only if:
* For now a high update period is needed but it coulmd be removed * - vout module emits events from theselves.
* if and only if: * - *and* SPU is modified to emit an event or a deadline when needed.
* - vout module emits events from theselves. *
* - *and* SPU is modified to emit an event or a deadline when needed. * So it will be done latter.
* */
* So it will be done latter. if (!redisplay) {
*/ picture_t *peek = picture_fifo_Peek(vout->p->decoder_fifo);
if (!redisplay) { if (peek) {
picture_t *peek = picture_fifo_Peek(vout->p->decoder_fifo); *is_forced = peek->b_force || is_paused || now;
if (peek) { *deadline = (*is_forced ? date : peek->date) - vout_chrono_GetHigh(&vout->p->render);
is_forced = peek->b_force || is_paused || now; picture_Release(peek);
*deadline = (is_forced ? date : peek->date) - vout_chrono_GetHigh(&vout->p->render); } else {
picture_Release(peek); redisplay = true;
} else {
redisplay = true;
}
} }
if (redisplay) { }
/* FIXME a better way for this delay is needed */ if (redisplay) {
const mtime_t date_update = vout->p->displayed.date + VOUT_REDISPLAY_DELAY; /* FIXME a better way for this delay is needed */
if (date_update > date || !vout->p->displayed.decoded) { const mtime_t date_update = vout->p->displayed.date + VOUT_REDISPLAY_DELAY;
*deadline = vout->p->displayed.decoded ? date_update : VLC_TS_INVALID; if (date_update > date || !vout->p->displayed.decoded) {
break; *deadline = vout->p->displayed.decoded ? date_update : VLC_TS_INVALID;
} return NULL;
/* */
is_forced = true;
*deadline = date - vout_chrono_GetHigh(&vout->p->render);
} }
if (*deadline > VOUT_MWAIT_TOLERANCE) /* */
*deadline -= VOUT_MWAIT_TOLERANCE; *is_forced = true;
*deadline = date - vout_chrono_GetHigh(&vout->p->render);
}
if (*deadline > VOUT_MWAIT_TOLERANCE)
*deadline -= VOUT_MWAIT_TOLERANCE;
/* If we are too early and can wait, do it */ /* If we are too early and can wait, do it */
if (date < *deadline && !now) if (date < *deadline && !now)
break; return NULL;
picture_t *decoded; picture_t *decoded;
if (redisplay) { if (redisplay) {
decoded = vout->p->displayed.decoded; decoded = vout->p->displayed.decoded;
vout->p->displayed.decoded = NULL; vout->p->displayed.decoded = NULL;
} else { } else {
decoded = picture_fifo_Pop(vout->p->decoder_fifo); decoded = picture_fifo_Pop(vout->p->decoder_fifo);
assert(decoded); assert(decoded);
if (!is_forced && !vout->p->is_late_dropped) { if (!*is_forced && !vout->p->is_late_dropped) {
const mtime_t predicted = date + vout_chrono_GetLow(&vout->p->render); const mtime_t predicted = date + vout_chrono_GetLow(&vout->p->render);
const mtime_t late = predicted - decoded->date; const mtime_t late = predicted - decoded->date;
if (late > 0) { if (late > 0) {
msg_Dbg(vout, "picture might be displayed late (missing %d ms)", (int)(late/1000)); msg_Dbg(vout, "picture might be displayed late (missing %d ms)", (int)(late/1000));
if (late > VOUT_DISPLAY_LATE_THRESHOLD) { if (late > VOUT_DISPLAY_LATE_THRESHOLD) {
msg_Warn(vout, "rejected picture because of render time"); msg_Warn(vout, "rejected picture because of render time");
/* TODO */ /* TODO */
picture_Release(decoded); picture_Release(decoded);
lost_count++; (*lost_count)++;
break; return NULL;
}
} }
} }
vout->p->displayed.is_interlaced = !decoded->b_progressive;
vout->p->displayed.qtype = decoded->i_qtype;
} }
vout->p->displayed.timestamp = decoded->date;
/* */ vout->p->displayed.is_interlaced = !decoded->b_progressive;
if (vout->p->displayed.decoded) vout->p->displayed.qtype = decoded->i_qtype;
picture_Release(vout->p->displayed.decoded); }
picture_Hold(decoded); vout->p->displayed.timestamp = decoded->date;
vout->p->displayed.decoded = decoded;
/* */
if (vout->p->displayed.decoded)
picture_Release(vout->p->displayed.decoded);
picture_Hold(decoded);
vout->p->displayed.decoded = decoded;
return decoded;
}
static int ThreadDisplayPicture(vout_thread_t *vout,
bool now, mtime_t *deadline)
{
vout_display_t *vd = vout->p->display.vd;
int displayed_count = 0;
int lost_count = 0;
for (;;) {
bool is_forced;
picture_t *decoded = ThreadDisplayGetDecodedPicture(vout,
&lost_count, &is_forced,
now, deadline);
if (!decoded)
break;
/* */ /* */
vout_chrono_Start(&vout->p->render); vout_chrono_Start(&vout->p->render);
......
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