[vlc-commits] mmal: deinterlace: don't use deinterlace if we don't have enough memory
John Cox
git at videolan.org
Mon Jan 27 11:29:58 CET 2020
vlc | branch: master | John Cox <jc at kynesim.co.uk> | Fri Jan 17 11:20:22 2020 +0100| [59ddce955a93ee1e596d825762c3134953ae8fbb] | committer: Steve Lhomme
mmal: deinterlace: don't use deinterlace if we don't have enough memory
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=59ddce955a93ee1e596d825762c3134953ae8fbb
---
configure.ac | 2 +-
modules/hw/mmal/deinterlace.c | 14 ++++++++++++
modules/hw/mmal/mmal_picture.c | 52 ++++++++++++++++++++++++++++++++++++++++++
modules/hw/mmal/mmal_picture.h | 2 ++
4 files changed, 69 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 0d7af8a01e..aeb2bb23e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3669,7 +3669,7 @@ if test "${enable_mmal}" != "no"; then
VLC_ADD_PLUGIN([mmal])
VLC_ADD_LDFLAGS([mmal],[ -L/opt/vc/lib ])
VLC_ADD_CFLAGS([mmal],[ -isystem /opt/vc/include -isystem /opt/vc/include/interface/vcos/pthreads -isystem /opt/vc/include/interface/vmcs_host/linux ])
- VLC_ADD_LIBS([mmal],[ -lbcm_host -lmmal -lmmal_core -lmmal_components -lmmal_util -lvchostif -lvcsm ]) ], [
+ VLC_ADD_LIBS([mmal],[ -lbcm_host -lmmal -lmmal_core -lmmal_components -lmmal_util -lvchostif -lvcsm -lvchiq_arm ]) ], [
AS_IF([test "${enable_mmal}" = "yes"],
[ AC_MSG_ERROR([Cannot find bcm library...]) ],
[ AC_MSG_WARN([Cannot find bcm library...]) ])
diff --git a/modules/hw/mmal/deinterlace.c b/modules/hw/mmal/deinterlace.c
index b198d07ec5..6cd5974d37 100644
--- a/modules/hw/mmal/deinterlace.c
+++ b/modules/hw/mmal/deinterlace.c
@@ -467,8 +467,22 @@ static int OpenMmalDeinterlace(vlc_object_t *p_this)
if (filter->fmt_in.video.i_width * filter->fmt_in.video.i_height > 768 * 576)
{
+ vlc_decoder_device *dec_dev = vlc_video_context_HoldDevice(filter->vctx_in);
+ assert(dec_dev != NULL);
+ mmal_decoder_device_t *devsys = GetMMALDeviceOpaque(dec_dev);
+ assert(devsys != NULL);
// We get stressed if we have to try too hard - so make life easier
sys->half_rate = true;
+ // Also check we actually have enough memory to do this
+ // Memory always comes from GPU if Opaque
+ // Assume we have plenty of memory if it comes from CMA
+ if (!devsys->is_cma &&
+ hw_mmal_get_gpu_mem() < (96 << 20))
+ {
+ sys->use_passthrough = true;
+ msg_Warn(filter, "Deinterlace bypassed due to lack of GPU memory");
+ }
+ vlc_decoder_device_Release(dec_dev);
}
if (var_InheritBool(filter, MMAL_DEINTERLACE_NO_QPU))
diff --git a/modules/hw/mmal/mmal_picture.c b/modules/hw/mmal/mmal_picture.c
index 06b3eb7763..6f6a0727f1 100644
--- a/modules/hw/mmal/mmal_picture.c
+++ b/modules/hw/mmal/mmal_picture.c
@@ -667,6 +667,58 @@ fail:
+
+int hw_mmal_get_gpu_mem(void) {
+ static int stashed_val = -2;
+ VCHI_INSTANCE_T vchi_instance;
+ VCHI_CONNECTION_T *vchi_connection = NULL;
+ char rbuf[1024] = { 0 };
+
+ if (stashed_val >= -1)
+ return stashed_val;
+
+ if (vchi_initialise(&vchi_instance) != 0)
+ goto fail0;
+
+ //create a vchi connection
+ if (vchi_connect(NULL, 0, vchi_instance) != 0)
+ goto fail0;
+
+ vc_vchi_gencmd_init(vchi_instance, &vchi_connection, 1);
+
+ //send the gencmd for the argument
+ if (vc_gencmd_send("get_mem gpu") != 0)
+ goto fail;
+
+ if (vc_gencmd_read_response(rbuf, sizeof(rbuf) - 1) != 0)
+ goto fail;
+
+ if (strncmp(rbuf, "gpu=", 4) != 0)
+ goto fail;
+
+ char *p;
+ unsigned long m = strtoul(rbuf + 4, &p, 10);
+
+ if (p[0] != 'M' || p[1] != '\0')
+ stashed_val = -1;
+ else
+ stashed_val = (int)m << 20;
+
+ vc_gencmd_stop();
+
+ //close the vchi connection
+ vchi_disconnect(vchi_instance);
+
+ return stashed_val;
+
+fail:
+ vc_gencmd_stop();
+ vchi_disconnect(vchi_instance);
+fail0:
+ stashed_val = -1;
+ return -1;
+};
+
// ===========================================================================
typedef struct pool_ent_s
diff --git a/modules/hw/mmal/mmal_picture.h b/modules/hw/mmal/mmal_picture.h
index 7804c7780b..cd613ccaff 100644
--- a/modules/hw/mmal/mmal_picture.h
+++ b/modules/hw/mmal/mmal_picture.h
@@ -70,6 +70,8 @@ static inline bool hw_mmal_chroma_is_mmal(const vlc_fourcc_t chroma)
picture_context_t * hw_mmal_gen_context(
MMAL_BUFFER_HEADER_T * buf, hw_mmal_port_pool_ref_t * const ppr);
+int hw_mmal_get_gpu_mem(void);
+
static inline MMAL_STATUS_T port_parameter_set_uint32(MMAL_PORT_T * port, uint32_t id, uint32_t val)
{
More information about the vlc-commits
mailing list