[vlc-devel] [PATCH] mmal: Fix plane offset computation

Julian Scheel julian at jusst.de
Wed Jun 17 11:28:33 CEST 2015


The computation of plane offsets was broken after recent refactorings. Fix it
by doing the actual computation of offsets in the picture lock function.

Signed-off-by: Julian Scheel <julian at jusst.de>
---
 modules/hw/mmal/mmal_picture.c | 8 ++++++--
 modules/hw/mmal/vout.c         | 5 -----
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/modules/hw/mmal/mmal_picture.c b/modules/hw/mmal/mmal_picture.c
index 584227e..d127c27 100644
--- a/modules/hw/mmal/mmal_picture.c
+++ b/modules/hw/mmal/mmal_picture.c
@@ -33,9 +33,13 @@ int mmal_picture_lock(picture_t *picture)
     MMAL_BUFFER_HEADER_T *buffer = pic_sys->buffer;
 
     buffer->user_data = picture;
+
+    int offset = 0;
     picture->p[0].p_pixels = buffer->data;
-    picture->p[1].p_pixels += (ptrdiff_t)buffer->data;
-    picture->p[2].p_pixels += (ptrdiff_t)buffer->data;
+    for (int i = 1; i < picture->i_planes; i++) {
+        offset = offset + picture->p[i - 1].i_pitch * picture->p[i - 1].i_lines;
+        picture->p[i].p_pixels = (ptrdiff_t)buffer->data + offset;
+    }
 
     pic_sys->displayed = false;
 
diff --git a/modules/hw/mmal/vout.c b/modules/hw/mmal/vout.c
index 0d13572..b3223f0 100644
--- a/modules/hw/mmal/vout.c
+++ b/modules/hw/mmal/vout.c
@@ -180,7 +180,6 @@ static int Open(vlc_object_t *object)
     uint32_t buffer_pitch, buffer_height;
     vout_display_place_t place;
     MMAL_DISPLAYREGION_T display_region;
-    uint32_t offsets[3];
     MMAL_STATUS_T status;
     int ret = VLC_SUCCESS;
     unsigned i;
@@ -273,7 +272,6 @@ static int Open(vlc_object_t *object)
         goto out;
     }
 
-    offsets[0] = 0;
     for (i = 0; i < sys->i_planes; ++i) {
         sys->planes[i].i_lines = buffer_height;
         sys->planes[i].i_pitch = buffer_pitch;
@@ -281,14 +279,11 @@ static int Open(vlc_object_t *object)
         sys->planes[i].i_visible_pitch = vd->fmt.i_visible_width;
 
         if (i > 0) {
-            offsets[i] = offsets[i - 1] + sys->planes[i - 1].i_pitch * sys->planes[i - 1].i_lines;
             sys->planes[i].i_lines /= 2;
             sys->planes[i].i_pitch /= 2;
             sys->planes[i].i_visible_lines /= 2;
             sys->planes[i].i_visible_pitch /= 2;
         }
-
-        sys->planes[i].p_pixels = (uint8_t *)offsets[i];
     }
 
     vlc_mutex_init(&sys->buffer_mutex);
-- 
2.4.3





More information about the vlc-devel mailing list