[vlc-devel] [PATCH 1/3] mmal: Fix buffer size computation

Julian Scheel julian at jusst.de
Thu Oct 9 14:49:39 CEST 2014


The buffer sizes in opaque case were computed by a mixture of hardcoded values
and mmal defaults. This caused breakage due to changes of the default values
in recent mmal versions. To avoid this in the future, the buffer sizes are
completely hardcoded now. As we have a shared header for mmal now, move the
required define for shared values into that header.
Using this new computation we can reduce the buffer size for opaque case by 2,
which saves some memory.

Signed-off-by: Julian Scheel <julian at jusst.de>
---
 modules/hw/mmal/codec.c        | 13 +++++++------
 modules/hw/mmal/mmal_picture.h |  3 +++
 modules/hw/mmal/vout.c         |  5 -----
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/modules/hw/mmal/codec.c b/modules/hw/mmal/codec.c
index 2e7a0d0..73757a3 100644
--- a/modules/hw/mmal/codec.c
+++ b/modules/hw/mmal/codec.c
@@ -36,10 +36,11 @@
 #include <interface/mmal/util/mmal_util.h>
 #include <interface/mmal/util/mmal_default_components.h>
 
-/* This value must match the define in video_output/mmal.c
- * Think twice before changing this. Incorrect values cause havoc.
- */
-#define NUM_ACTUAL_OPAQUE_BUFFERS 22
+#include "mmal_picture.h"
+
+/* We need a smaller size of available buffer headers than actual buffers
+ * in the decoder to avoid stalls. MMAL seems a a bit picky here */
+#define NUM_OPAQUE_BUFFER_HEADERS (NUM_ACTUAL_OPAQUE_BUFFERS - 2)
 
 /* These are only required when combined with image_fx filter. But as they
  * won't do much harm besides using a few MB GPU memory, keep them always on
@@ -313,7 +314,7 @@ static int change_output_format(decoder_t *dec)
 
     if (sys->opaque) {
         sys->output->buffer_num = NUM_ACTUAL_OPAQUE_BUFFERS;
-        pool_size = sys->output->buffer_num_recommended;
+        pool_size = NUM_OPAQUE_BUFFER_HEADERS;
     } else {
         sys->output->buffer_num = __MAX(sys->output->buffer_num_recommended,
                 MIN_NUM_BUFFERS_IN_TRANSIT);
@@ -425,7 +426,7 @@ static void fill_output_port(decoder_t *dec)
 {
     decoder_sys_t *sys = dec->p_sys;
     /* allow at least 2 buffers in transit */
-    unsigned max_buffers_in_transit = __MAX(sys->output->buffer_num_recommended,
+    unsigned max_buffers_in_transit = __MAX(sys->output_pool->headers_num,
             MIN_NUM_BUFFERS_IN_TRANSIT);
     unsigned buffers_available = mmal_queue_length(sys->output_pool->queue);
     unsigned buffers_in_transit = sys->output_pool->headers_num - buffers_available -
diff --git a/modules/hw/mmal/mmal_picture.h b/modules/hw/mmal/mmal_picture.h
index e538aed..47fbd3e 100644
--- a/modules/hw/mmal/mmal_picture.h
+++ b/modules/hw/mmal/mmal_picture.h
@@ -24,6 +24,9 @@
 #include <vlc_common.h>
 #include <interface/mmal/mmal.h>
 
+/* Think twice before changing this. Incorrect values cause havoc. */
+#define NUM_ACTUAL_OPAQUE_BUFFERS 20
+
 struct picture_sys_t {
     vlc_object_t *owner;
 
diff --git a/modules/hw/mmal/vout.c b/modules/hw/mmal/vout.c
index dd2d6d1..c23f463 100644
--- a/modules/hw/mmal/vout.c
+++ b/modules/hw/mmal/vout.c
@@ -42,11 +42,6 @@
 #include <interface/vmcs_host/vc_tvservice.h>
 #include <interface/vmcs_host/vc_dispmanx.h>
 
-/* This value must match the define in codec/mmal.c
- * Think twice before changing this. Incorrect values cause havoc.
- */
-#define NUM_ACTUAL_OPAQUE_BUFFERS 22
-
 #define MAX_BUFFERS_IN_TRANSIT 2
 #define VC_TV_MAX_MODE_IDS 127
 
-- 
2.1.2




More information about the vlc-devel mailing list