What is MMAL?

Ian Auty edited this page Nov 5, 2018 · 4 revisions

In progress

MMAL (Multimedia Abstraction Layer) is a C library designed by Broadcom for use with the Videocore IV GPU found on the Raspberry Pi. Providing an abstraction layer upon another C library "OpenMAX", MMAL exposes an API allowing developers to take images and record video from their Raspberry Pi which is easier to understand and consume.

Components

Introduction

MMAL introduces the concept of "Components" - virtual resources which are able to produce and manipulate image data. Components are constructed manually by the user when required; below you'll find a list of components featured in MMAL.

Camera component

The camera component is a virtual representation of the camera module attached to the Raspberry Pi. This component has the ability to capture still images, video and also render textual outputs to the Pi display.

Encoders / Decoders

MMAL allows for image encoders/decoders and video encoders/decoders to be constructed within the pipeline which allow an end user to manipulate the image data.

Renderers

There are two main renderers which are found natively in MMAL: Null sink and video. The main purpose of a renderer is to calculate exposure compensation so the images captured by the camera look correct and are not under/over exposed. The video renderer also has the added bonus of displaying the frames captured by your camera onto the HDMI output on your Raspberry Pi. In addition, the video renderer has the ability to be manipulated such that user-provided image and textual data can be fed onto the HDMI output also; MMALSharp has this functionality built-in to the library.

Resizer

A resizer component, as the name suggests, has the ability to alter the width/height of image frames. This is a useful component when mixed with the splitter component seen below.

Splitter

The splitter component exclusively connects to the video output port of the camera component. After doing so, the splitter provides a further 4 output ports which can further extend your pipeline and increase your application's use cases. When combined with the resizer component, multiple outputs can be stored using different frame sizes and encoding types.

Ports

A Port in MMAL is responsible for receiving/transmitting image data, and also for connecting components together. Components commonly feature a mixture of input/output ports but also clock and control ports too. In order to connect two Components together, a connection is constructed between an output port and the input port of a Downstream Component. An example pipeline could feature the Camera component which exposes 3 output ports: Still, Video and Preview. Following this, a user could connect an Image or Video Encoder which allows you to convert the raw image data into an encoded format such as JPEG or H.264.

Buffer headers

Buffer headers in MMAL are the entities that hold a reference to the image data being passed through your pipeline. These themselves do not hold the data in full, but instead reference a pointer to the beginning of the image data, this is so that the memory for the data can be allocated outside of MMAL.

After ports are configured by the consumer of the framework, the recommended number of buffer headers required for optimum performance is calculated, as well as the size of each buffer header. It is then the responsibility of the end user to construct the buffer pool and then send these to the output port of the component that shall be processing data.

For more detailed information on the native MMAL framework, please refer to the MMAL API documentation found here

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.