[vlc-devel] [PATCH 1/2] mmal/vout: Properly populate plane specification

Julian Scheel julian at jusst.de
Wed Sep 3 10:40:47 CEST 2014


The pictures plane specifications were always filled with the size information
obtained from the vlc picture format combined with the assumption of having 3
planes. As this is not correct for the opaque case were only one plane with a
fixed size, which matches the mmal video_render input size, is used, change
the code to take care of this.
This change is required to provide other plugins reliable information about
the allocated data buffer size.

Signed-off-by: Julian Scheel <julian at jusst.de>
---
 modules/hw/mmal/vout.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/modules/hw/mmal/vout.c b/modules/hw/mmal/vout.c
index f25ac32..763f213 100644
--- a/modules/hw/mmal/vout.c
+++ b/modules/hw/mmal/vout.c
@@ -98,6 +98,7 @@ struct vout_display_sys_t {
     MMAL_POOL_T *pool;
     struct dmx_region_t *dmx_region;
     plane_t planes[3];
+    int i_planes;
 
     vlc_mutex_t buffer_mutex;
     vlc_mutex_t manage_mutex;
@@ -193,15 +194,9 @@ static int Open(vlc_object_t *object)
     vd->info.has_hide_mouse = true;
     sys->opaque = vd->fmt.i_chroma == VLC_CODEC_MMAL_OPAQUE;
 
-    if (!sys->opaque)
-        vd->fmt.i_chroma = VLC_CODEC_I420;
     vd->fmt.i_sar_num = vd->source.i_sar_num;
     vd->fmt.i_sar_den = vd->source.i_sar_den;
 
-    buffer_pitch = align(vd->fmt.i_width, 32);
-    buffer_height = align(vd->fmt.i_height, 16);
-    sys->buffer_size = 3 * buffer_pitch * buffer_height / 2;
-
     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)",
@@ -222,6 +217,17 @@ static int Open(vlc_object_t *object)
     sys->input = sys->component->input[0];
     sys->input->userdata = (struct MMAL_PORT_USERDATA_T *)vd;
 
+    if (!sys->opaque) {
+        vd->fmt.i_chroma = VLC_CODEC_I420;
+        buffer_pitch = align(vd->fmt.i_width, 32);
+        buffer_height = align(vd->fmt.i_height, 16);
+        sys->i_planes = 3;
+        sys->buffer_size = 3 * buffer_pitch * buffer_height / 2;
+    } else {
+        sys->i_planes = 1;
+        sys->buffer_size = sys->input->buffer_size_recommended;
+    }
+
     status = mmal_port_parameter_set(sys->input, &latency_target.hdr);
     if (status != MMAL_SUCCESS) {
         msg_Err(vd, "Failed to configure latency target on input port %s (status=%"PRIx32" %s)",
@@ -276,7 +282,7 @@ static int Open(vlc_object_t *object)
     }
 
     offsets[0] = 0;
-    for (i = 0; i < 3; ++i) {
+    for (i = 0; i < sys->i_planes; ++i) {
         sys->planes[i].i_lines = buffer_height;
         sys->planes[i].i_pitch = buffer_pitch;
         sys->planes[i].i_visible_lines = vd->fmt.i_visible_height;
@@ -504,7 +510,8 @@ static picture_pool_t *vd_pool(vout_display_t *vd, unsigned count)
             goto out;
         }
 
-        memcpy(sys->pictures[i]->p, sys->planes, sizeof(sys->planes));
+        sys->pictures[i]->i_planes = sys->i_planes;
+        memcpy(sys->pictures[i]->p, sys->planes, sys->i_planes * sizeof(plane_t));
     }
 
     memset(&picture_pool_cfg, 0, sizeof(picture_pool_configuration_t));
-- 
2.1.0




More information about the vlc-devel mailing list