[vlc-commits] vout: avoid picture copy when decoder and output format do not match
Rémi Denis-Courmont
git at videolan.org
Tue Jul 2 23:16:19 CEST 2013
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Jul 2 20:51:47 2013 +0300| [39da8edda36f87b393f67acefbca654bd4a986f9] | committer: Rafaël Carré
vout: avoid picture copy when decoder and output format do not match
When the decoder output and the display video formats are different,
the picture copy comes for "free" during the conversion from the
earlier format to the latter one. So do not bother with copying the
picture before the conversion.
The straight copy is still required however in the case that the video
formats are identical but the display pool is inadequate (too few
pictures, slow memory bus...).
Signed-off-by: Rafaël Carré <funman at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=39da8edda36f87b393f67acefbca654bd4a986f9
---
src/video_output/video_output.c | 43 ++++++++++++++++++++-------------------
1 file changed, 22 insertions(+), 21 deletions(-)
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 8c4b329..d2a898d 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -986,37 +986,38 @@ static int ThreadDisplayRenderPicture(vout_thread_t *vout, bool is_forced)
return VLC_EGENERIC;
}
- picture_t *direct;
- if (!is_direct) {
- direct = picture_pool_Get(vout->p->display_pool);
- if (direct) {
- VideoFormatCopyCropAr(&direct->format, &todisplay->format);
- picture_Copy(direct, todisplay);
+ assert(vout_IsDisplayFiltered(vd) == !sys->display.use_dr);
+ if (sys->display.use_dr && !is_direct) {
+ picture_t *direct = picture_pool_Get(vout->p->display_pool);
+ if (!direct) {
+ picture_Release(todisplay);
+ if (subpic)
+ subpicture_Delete(subpic);
+ return VLC_EGENERIC;
}
- picture_Release(todisplay);
- } else {
- direct = todisplay;
- }
- if (!direct) {
- if (subpic)
- subpicture_Delete(subpic);
- return VLC_EGENERIC;
+ /* The display uses direct rendering (no conversion), but its pool of
+ * pictures is not usable by the decoder (too few, too slow or
+ * subject to invalidation...). Since there are no filters, copying
+ * pictures from the decoder to the output is unavoidable. */
+ VideoFormatCopyCropAr(&direct->format, &todisplay->format);
+ picture_Copy(direct, todisplay);
+ picture_Release(todisplay);
+ todisplay = direct;
}
/*
* Take a snapshot if requested
*/
if (do_snapshot)
- vout_snapshot_Set(&vout->p->snapshot, &vd->source, direct);
+ vout_snapshot_Set(&vout->p->snapshot, &vd->source, todisplay);
/* Render the direct buffer */
- assert(vout_IsDisplayFiltered(vd) == !sys->display.use_dr);
- vout_UpdateDisplaySourceProperties(vd, &direct->format);
+ vout_UpdateDisplaySourceProperties(vd, &todisplay->format);
if (sys->display.use_dr) {
- vout_display_Prepare(vd, direct, subpic);
+ vout_display_Prepare(vd, todisplay, subpic);
} else {
- sys->display.filtered = vout_FilterDisplay(vd, direct);
+ sys->display.filtered = vout_FilterDisplay(vd, todisplay);
if (sys->display.filtered) {
if (!do_dr_spu && !do_early_spu && vout->p->spu_blend && subpic)
picture_BlendSubpicture(sys->display.filtered, vout->p->spu_blend, subpic);
@@ -1045,13 +1046,13 @@ static int ThreadDisplayRenderPicture(vout_thread_t *vout, bool is_forced)
msg_Warn(vout, "picture is late (%lld ms)", delay / 1000);
#endif
if (!is_forced)
- mwait(direct->date);
+ mwait(todisplay->date);
/* Display the direct buffer returned by vout_RenderPicture */
vout->p->displayed.date = mdate();
vout_display_Display(vd,
sys->display.filtered ? sys->display.filtered
- : direct,
+ : todisplay,
subpic);
sys->display.filtered = NULL;
More information about the vlc-commits
mailing list