Commit 54f93974 authored by Julian Scheel's avatar Julian Scheel Committed by Jean-Baptiste Kempf

mmal: Fix buffer size computation

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: default avatarJulian Scheel <julian@jusst.de>
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 04e9ee96
...@@ -36,10 +36,11 @@ ...@@ -36,10 +36,11 @@
#include <interface/mmal/util/mmal_util.h> #include <interface/mmal/util/mmal_util.h>
#include <interface/mmal/util/mmal_default_components.h> #include <interface/mmal/util/mmal_default_components.h>
/* This value must match the define in video_output/mmal.c #include "mmal_picture.h"
* Think twice before changing this. Incorrect values cause havoc.
*/ /* We need a smaller size of available buffer headers than actual buffers
#define NUM_ACTUAL_OPAQUE_BUFFERS 22 * 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 /* 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 * 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) ...@@ -313,7 +314,7 @@ static int change_output_format(decoder_t *dec)
if (sys->opaque) { if (sys->opaque) {
sys->output->buffer_num = NUM_ACTUAL_OPAQUE_BUFFERS; sys->output->buffer_num = NUM_ACTUAL_OPAQUE_BUFFERS;
pool_size = sys->output->buffer_num_recommended; pool_size = NUM_OPAQUE_BUFFER_HEADERS;
} else { } else {
sys->output->buffer_num = __MAX(sys->output->buffer_num_recommended, sys->output->buffer_num = __MAX(sys->output->buffer_num_recommended,
MIN_NUM_BUFFERS_IN_TRANSIT); MIN_NUM_BUFFERS_IN_TRANSIT);
...@@ -425,7 +426,7 @@ static void fill_output_port(decoder_t *dec) ...@@ -425,7 +426,7 @@ static void fill_output_port(decoder_t *dec)
{ {
decoder_sys_t *sys = dec->p_sys; decoder_sys_t *sys = dec->p_sys;
/* allow at least 2 buffers in transit */ /* 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); MIN_NUM_BUFFERS_IN_TRANSIT);
unsigned buffers_available = mmal_queue_length(sys->output_pool->queue); unsigned buffers_available = mmal_queue_length(sys->output_pool->queue);
unsigned buffers_in_transit = sys->output_pool->headers_num - buffers_available - unsigned buffers_in_transit = sys->output_pool->headers_num - buffers_available -
......
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <interface/mmal/mmal.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 { struct picture_sys_t {
vlc_object_t *owner; vlc_object_t *owner;
......
...@@ -42,11 +42,6 @@ ...@@ -42,11 +42,6 @@
#include <interface/vmcs_host/vc_tvservice.h> #include <interface/vmcs_host/vc_tvservice.h>
#include <interface/vmcs_host/vc_dispmanx.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 MAX_BUFFERS_IN_TRANSIT 2
#define VC_TV_MAX_MODE_IDS 127 #define VC_TV_MAX_MODE_IDS 127
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment