[vlc-devel] [PATCH 2/3] vout: Allow vout plugins to request phase offset

Julian Scheel julian at jusst.de
Fri Aug 29 09:25:20 CEST 2014


If the display refresh rate matches the video rate it is desired to show
exactly one picture per frame. Some video renderers take care of this
internally others don't. For those that don't do it we allow the vout to
request a phase offset which is applied to the picture display timestamps, so
that the vout can ensure that pictures are rendered in the desired phase shift
to the display refresh.

Signed-off-by: Julian Scheel <julian at jusst.de>
---
 include/vlc_vout_display.h      | 10 ++++++++++
 src/video_output/display.c      |  8 ++++++++
 src/video_output/video_output.c |  1 +
 3 files changed, 19 insertions(+)

diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index f5f6817..d3cc461 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -110,6 +110,9 @@ typedef struct {
         int den;
     } zoom;
 
+    /* Phase offset to be applied to timestamps */
+    int phase_offset;
+
 } vout_display_cfg_t;
 
 /**
@@ -208,6 +211,9 @@ enum {
     VOUT_DISPLAY_EVENT_MOUSE_PRESSED,
     VOUT_DISPLAY_EVENT_MOUSE_RELEASED,
     VOUT_DISPLAY_EVENT_MOUSE_DOUBLE_CLICK,
+
+    /* Ask the vout core to apply a phase offset to timestamps */
+    VOUT_DISPLAY_EVENT_PHASE_OFFSET,
 };
 
 /**
@@ -385,6 +391,10 @@ static inline void vout_display_SendEventMouseDoubleClick(vout_display_t *vd)
 {
     vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_MOUSE_DOUBLE_CLICK);
 }
+static inline void vout_display_SendEventPhaseOffset(vout_display_t *vd, int offset)
+{
+        vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_PHASE_OFFSET, offset);
+}
 
 /**
  * Asks for a new window with the given configuration as hint.
diff --git a/src/video_output/display.c b/src/video_output/display.c
index 547bc2e..7c8ffd8 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -724,6 +724,13 @@ static void VoutDisplayEvent(vout_display_t *vd, int event, va_list args)
         vlc_mutex_unlock(&osys->lock);
         break;
     }
+    case VOUT_DISPLAY_EVENT_PHASE_OFFSET: {
+        const int offset = (int)va_arg(args, int);
+
+        msg_Dbg(vd, "VoutDisplayEvent 'phase offset' %d", offset);
+        osys->cfg.phase_offset = offset;
+        break;
+    }
     default:
         msg_Err(vd, "VoutDisplayEvent received event %d", event);
         /* TODO add an assert when all event are handled */
@@ -1469,6 +1476,7 @@ static void SplitterEvent(vout_display_t *vd, int event, va_list args)
     case VOUT_DISPLAY_EVENT_FULLSCREEN:
     case VOUT_DISPLAY_EVENT_DISPLAY_SIZE:
     case VOUT_DISPLAY_EVENT_PICTURES_INVALID:
+    case VOUT_DISPLAY_EVENT_PHASE_OFFSET:
         VoutDisplayEvent(vd, event, args);
         break;
 
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 7535a23..1f14101 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -826,6 +826,7 @@ static int ThreadDisplayPreparePicture(vout_thread_t *vout, bool reuse, bool fra
         } else {
             decoded = picture_fifo_Pop(vout->p->decoder_fifo);
             if (decoded) {
+                decoded->date += vout->p->display.vd->cfg->phase_offset;
                 if (is_late_dropped && !decoded->b_force) {
                     const mtime_t predicted = mdate() + 0; /* TODO improve */
                     const mtime_t late = predicted - decoded->date;
-- 
2.1.0




More information about the vlc-devel mailing list