[vlc-commits] mmal/vout: Fix abuse of vd->fmt

Julian Scheel git at videolan.org
Wed Oct 15 10:28:58 CEST 2014


vlc | branch: master | Julian Scheel <julian at jusst.de> | Wed Oct 15 10:23:14 2014 +0200| [6837ebd2743e2301cd0373acdc88e2fa7e3bbcbe] | committer: Jean-Baptiste Kempf

mmal/vout: Fix abuse of vd->fmt

The fmt in vout_display_t is not allowed to be written to after opening the
plugin without invalidating all the pictures. Instead of doing invalid writes
to vd->fmt, just make use of vd->source and event arguments directly which
shall hold correct values.
As framerate changes are not announced by the core we need to add a local
storage for comparion now as vd->fmt must not be used for it.

Signed-off-by: Julian Scheel <julian at jusst.de>
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6837ebd2743e2301cd0373acdc88e2fa7e3bbcbe
---

 modules/hw/mmal/vout.c |   37 +++++++++++--------------------------
 1 file changed, 11 insertions(+), 26 deletions(-)

diff --git a/modules/hw/mmal/vout.c b/modules/hw/mmal/vout.c
index 80aa86b..855f76f 100644
--- a/modules/hw/mmal/vout.c
+++ b/modules/hw/mmal/vout.c
@@ -116,6 +116,9 @@ struct vout_display_sys_t {
     unsigned display_width;
     unsigned display_height;
 
+    int i_frame_rate_base;
+    int i_frame_rate;
+
     int next_phase_check;
     int phase_offset;
     int layer;
@@ -193,9 +196,6 @@ static int Open(vlc_object_t *object)
     vd->info.has_hide_mouse = true;
     sys->opaque = vd->fmt.i_chroma == VLC_CODEC_MMAL_OPAQUE;
 
-    vd->fmt.i_sar_num = vd->source.i_sar_num;
-    vd->fmt.i_sar_den = vd->source.i_sar_den;
-
     status = mmal_component_create(MMAL_COMPONENT_DEFAULT_VIDEO_RENDERER, &sys->component);
     if (status != MMAL_SUCCESS) {
         msg_Err(vd, "Failed to create MMAL component %s (status=%"PRIx32" %s)",
@@ -398,7 +398,7 @@ static int configure_display(vout_display_t *vd, const vout_display_cfg_t *cfg,
             return -EINVAL;
         }
     } else {
-        fmt = &vd->fmt;
+        fmt = &vd->source;
     }
 
     if (!cfg)
@@ -435,9 +435,6 @@ static int configure_display(vout_display_t *vd, const vout_display_cfg_t *cfg,
         set_latency_target(vd, true);
     }
 
-    if (fmt != &vd->fmt)
-        memcpy(&vd->fmt, fmt, sizeof(video_format_t));
-
     return 0;
 }
 
@@ -549,12 +546,14 @@ static void vd_display(vout_display_t *vd, picture_t *picture,
     MMAL_BUFFER_HEADER_T *buffer = pic_sys->buffer;
     MMAL_STATUS_T status;
 
-    if (picture->format.i_frame_rate != vd->fmt.i_frame_rate ||
-        picture->format.i_frame_rate_base != vd->fmt.i_frame_rate_base ||
+    if (picture->format.i_frame_rate != sys->i_frame_rate ||
+        picture->format.i_frame_rate_base != sys->i_frame_rate_base ||
         picture->b_progressive != sys->b_progressive ||
         picture->b_top_field_first != sys->b_top_field_first) {
         sys->b_top_field_first = picture->b_top_field_first;
         sys->b_progressive = picture->b_progressive;
+        sys->i_frame_rate = picture->format.i_frame_rate;
+        sys->i_frame_rate_base = picture->format.i_frame_rate_base;
         configure_display(vd, NULL, &picture->format);
     }
 
@@ -596,7 +595,6 @@ static int vd_control(vout_display_t *vd, int query, va_list args)
     vout_display_sys_t *sys = vd->sys;
     vout_display_cfg_t cfg;
     const vout_display_cfg_t *tmp_cfg;
-    video_format_t fmt;
     const video_format_t *tmp_fmt;
     int ret = VLC_EGENERIC;
 
@@ -634,22 +632,9 @@ static int vd_control(vout_display_t *vd, int query, va_list args)
             break;
 
         case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
-            fmt = vd->fmt;
-            tmp_fmt = va_arg(args, const video_format_t *);
-            fmt.i_sar_num = tmp_fmt->i_sar_num;
-            fmt.i_sar_den = tmp_fmt->i_sar_den;
-            if (configure_display(vd, NULL, &fmt) >= 0)
-                ret = VLC_SUCCESS;
-            break;
-
         case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
-            fmt = vd->fmt;
             tmp_fmt = va_arg(args, const video_format_t *);
-            fmt.i_x_offset = tmp_fmt->i_x_offset;
-            fmt.i_y_offset = tmp_fmt->i_y_offset;
-            fmt.i_visible_width = tmp_fmt->i_visible_width;
-            fmt.i_visible_height = tmp_fmt->i_visible_height;
-            if (configure_display(vd, NULL, &fmt) >= 0)
+            if (configure_display(vd, NULL, tmp_fmt) >= 0)
                 ret = VLC_SUCCESS;
             break;
 
@@ -984,8 +969,8 @@ static void maintain_phase_sync(vout_display_t *vd)
         .hdr = { MMAL_PARAMETER_VIDEO_RENDER_STATS, sizeof(render_stats) },
     };
     int32_t frame_duration = 1000000 /
-        ((double)vd->fmt.i_frame_rate /
-        vd->fmt.i_frame_rate_base);
+        ((double)vd->source.i_frame_rate /
+        vd->source.i_frame_rate_base);
     vout_display_sys_t *sys = vd->sys;
     int32_t phase_offset;
     MMAL_STATUS_T status;



More information about the vlc-commits mailing list