[vlc-commits] mmal: add a decoder device
Steve Lhomme
git at videolan.org
Fri Jan 24 14:15:36 CET 2020
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Jan 10 13:39:54 2020 +0100| [ea6525e5bc74109335d78d61338fbc95b1556073] | committer: Steve Lhomme
mmal: add a decoder device
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ea6525e5bc74109335d78d61338fbc95b1556073
---
modules/hw/mmal/Makefile.am | 7 ++++
modules/hw/mmal/decoder_device.c | 76 ++++++++++++++++++++++++++++++++++++++++
modules/hw/mmal/mmal_picture.c | 9 +++++
modules/hw/mmal/mmal_picture.h | 25 +++++++++----
4 files changed, 110 insertions(+), 7 deletions(-)
diff --git a/modules/hw/mmal/Makefile.am b/modules/hw/mmal/Makefile.am
index 1dd7aa25ed..5335ff33cf 100644
--- a/modules/hw/mmal/Makefile.am
+++ b/modules/hw/mmal/Makefile.am
@@ -24,3 +24,10 @@ libmmal_deinterlace_plugin_la_CFLAGS = $(AM_CFLAGS)
libmmal_deinterlace_plugin_la_LDFLAGS = $(AM_LDFLAGS)
libmmal_deinterlace_plugin_la_LIBADD = $(LIBS_mmal)
mmal_LTLIBRARIES += libmmal_deinterlace_plugin.la
+
+libmmal_device_plugin_la_SOURCES = decoder_device.c mmal_picture.c mmal_picture.h \
+ mmal_cma.c mmal_cma.h
+libmmal_device_plugin_la_CFLAGS = $(AM_CFLAGS)
+libmmal_device_plugin_la_LDFLAGS = $(AM_LDFLAGS)
+libmmal_device_plugin_la_LIBADD = $(LIBS_mmal)
+mmal_LTLIBRARIES += libmmal_device_plugin.la
diff --git a/modules/hw/mmal/decoder_device.c b/modules/hw/mmal/decoder_device.c
new file mode 100644
index 0000000000..67e92d6fcd
--- /dev/null
+++ b/modules/hw/mmal/decoder_device.c
@@ -0,0 +1,76 @@
+/*****************************************************************************
+ * decoder_device.c: MMAL-based decoder plugin for Raspberry Pi
+ *****************************************************************************
+ * Copyright © 2020 Steve Lhomme
+ *
+ * Authors: Steve Lhomme <robux4 at videolabs.io>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+#include <vlc_vout_window.h>
+#include <vlc_codec.h>
+
+#include "mmal_picture.h"
+
+static int OpenDecoderDevice(vlc_decoder_device *, vout_window_t *);
+
+vlc_module_begin()
+ set_description(N_("MMAL"))
+ set_callback_dec_device(OpenDecoderDevice, 100)
+ add_shortcut("mmal-device")
+vlc_module_end()
+
+static void CloseDecoderDevice(vlc_decoder_device *device)
+{
+ mmal_decoder_device_t *sys = device->opaque;
+ cma_vcsm_exit(sys->vcsm_init_type);
+}
+
+static const struct vlc_decoder_device_operations mmal_device_ops = {
+ .close = CloseDecoderDevice,
+};
+
+static int OpenDecoderDevice(vlc_decoder_device *device, vout_window_t *window)
+{
+ VLC_UNUSED(window);
+
+ mmal_decoder_device_t *sys = vlc_obj_malloc(VLC_OBJECT(device), sizeof(mmal_decoder_device_t));
+ if (unlikely(sys==NULL))
+ return VLC_ENOMEM;
+
+ vcsm_init_type_t vcsm_init_type = cma_vcsm_init();
+ if (vcsm_init_type == VCSM_INIT_NONE) {
+ msg_Err(device, "VCSM init failed");
+ return VLC_EGENERIC;
+ }
+
+ sys->vcsm_init_type = vcsm_init_type;
+
+ device->ops = &mmal_device_ops;
+ device->opaque = sys;
+ device->type = VLC_DECODER_DEVICE_MMAL;
+ device->sys = sys;
+
+ msg_Warn(device, "VCSM init succeeded: %s", cma_vcsm_init_str(vcsm_init_type));
+
+ return VLC_SUCCESS;
+}
diff --git a/modules/hw/mmal/mmal_picture.c b/modules/hw/mmal/mmal_picture.c
index 3db21a32b9..65b068876f 100644
--- a/modules/hw/mmal/mmal_picture.c
+++ b/modules/hw/mmal/mmal_picture.c
@@ -174,6 +174,15 @@ bool hw_mmal_vlc_pic_to_mmal_fmt_update(MMAL_ES_FORMAT_T *const es_fmt, const pi
}
+//----------------------------------------------------------------------------
+
+struct mmal_port_pool_ref_s
+{
+ atomic_uint refs;
+ MMAL_POOL_T * pool;
+ MMAL_PORT_T * port;
+};
+
static hw_mmal_port_pool_ref_t * hw_mmal_port_pool_ref_create(MMAL_PORT_T * const port,
const unsigned int headers, const uint32_t payload_size)
{
diff --git a/modules/hw/mmal/mmal_picture.h b/modules/hw/mmal/mmal_picture.h
index 045a4f9d28..2f9fc9b6a9 100644
--- a/modules/hw/mmal/mmal_picture.h
+++ b/modules/hw/mmal/mmal_picture.h
@@ -25,6 +25,7 @@
#define VLC_MMAL_MMAL_PICTURE_H_
#include <vlc_common.h>
+#include <vlc_codec.h>
#include <interface/mmal/mmal.h>
#include "mmal_cma.h"
@@ -32,13 +33,6 @@
/* Think twice before changing this. Incorrect values cause havoc. */
#define NUM_ACTUAL_OPAQUE_BUFFERS 30
-typedef struct mmal_port_pool_ref_s
-{
- atomic_uint refs;
- MMAL_POOL_T * pool;
- MMAL_PORT_T * port;
-} hw_mmal_port_pool_ref_t;
-
#define CTX_BUFS_MAX 4
typedef struct pic_ctx_mmal_s {
@@ -62,6 +56,11 @@ bool hw_mmal_vlc_pic_to_mmal_fmt_update(MMAL_ES_FORMAT_T *const es_fmt, const pi
int hw_mmal_copy_pic_to_buf(void * const buf_data, uint32_t * const pLength,
const MMAL_ES_FORMAT_T * const fmt, const picture_t * const pic);
+//----------------------------------------------------------------------------
+
+struct mmal_port_pool_ref_s;
+typedef struct mmal_port_pool_ref_s hw_mmal_port_pool_ref_t;
+
void hw_mmal_port_pool_ref_release(hw_mmal_port_pool_ref_t * const ppr, const bool in_cb);
bool hw_mmal_port_pool_ref_recycle(hw_mmal_port_pool_ref_t * const ppr, MMAL_BUFFER_HEADER_T * const buf);
MMAL_STATUS_T hw_mmal_port_pool_ref_fill(hw_mmal_port_pool_ref_t * const ppr);
@@ -164,4 +163,16 @@ const char * cma_vcsm_init_str(const vcsm_init_type_t init_mode);
#define MMAL_COMPONENT_ISP_RESIZER "vc.ril.isp"
#define MMAL_COMPONENT_HVS "vc.ril.hvs"
+typedef struct
+{
+ vcsm_init_type_t vcsm_init_type;
+} mmal_decoder_device_t;
+
+static inline mmal_decoder_device_t *GetMMALDeviceOpaque(vlc_decoder_device *dec_dev)
+{
+ if (!dec_dev || dec_dev->type != VLC_DECODER_DEVICE_MMAL)
+ return NULL;
+ return dec_dev->opaque;
+}
+
#endif
More information about the vlc-commits
mailing list