- We should be able to attach statically allocated metadata to a buffer. This
is for metadata that does not change much.
+Use cases
+---------
+
+ * DSP vs CPU caches
+
+ Both DSP and CPU have separate MMUs and memory caches. When we exchange buffers
+ between two subsystems we need to flush caches so that one CPU can see the
+ modifications done by the other CPU. These cashes must only be flushed when one
+ CPU performed a write and the other CPU needs to do a read.
+
+ In order to implement this we need to be able to mark our read and write
+ operations on the buffer data.
+
+
GstMiniObject
~~~~~~~~~~~~~
GstCaps *caps;
GstBuffer *parent;
+ GstBufferDataMap mmap_func;
+ GstBufferDataUnmap munmap_func;
+
gpointer _gst_padding[10];
};
Buffers point to a GstCaps structure that contains the caps of the buffer data.
+We add two functions, map and unmap. We introduce explicit read and write transactions
+on the buffer data in order to be able to implement flushing of the data between
+different caches and mapping between different MMUs.
+
+ typedef enum {
+ GST_BUFFER_MAP_NONE,
+ GST_BUFFER_MAP_READ,
+ GST_BUFFER_MAP_WRITE,
+ } GstBufferMapFlags
+
+ gpointer gst_buffer_map (GstBuffer *, guint offset, guint *size, GstBufferMapFlags);
+ gboolean gst_buffer_unmap (GstBuffer *, gpointer data, guint size);
+
+The map functions always create a contiguous memory space for the requested
+area of the buffer. This might involve memcpy and other expensive operations. It
+is assumed that more specialized elements can deal with the different memory
+metadata structures in order to optimize access to the memory.
+
GstBufferMeta
~~~~~~~~~~~~~
A GstBufferMeta is a structure as follows:
struct _GstBufferMeta {
- GstBufferMetaInfo *info; /* tag and info for the meta item */
- GstBufferMeta *next; /* pointer to the next item */
- }
+ GstBufferMetaInfo *info; /* tag and info for the meta item */
+ };
The purpose of the this structure is to serve as a common header for all metadata
information that we can attach to a buffer. Specific metadata, such as timing metadata,
GstBufferMeta meta;
/* pointer to data and its size */
- guint8 *data;
+ gpointer *data;
guint size;
- guint8 *malloc_data;
+ gpointer *data_orig;
GFreeFunc data_free;
gpointer data_user;
};
GQuark api; /* api name */
GQuark impl; /* implementation name */
gsize size; /* size of the structure */
+ GstBufferMetaInfo *parent /* parent info */
GstMetaInitFunction init_func;
GstMetaFreeFunction free_func;
GstMetaSerializeFunction serialize_func
GstMetaDeserializeFunction deserialize_func
GstMetaConvFunction conv_func;
- }
+ };
Tag will contain a GQuark of the metadata name. We will be able to refer to specific
metadata by name or by its (cached) GQuark. A repository of registered MetaInfo
+-------------------------------------+
GstBuffer | caps, parent, subfunc |
+.....................................+
+ | next ---+
+ | parent ------> NULL
+- | info ------> GstBufferMetaInfo
-GstBufferMetaTiming | | next ---+
- | | | |
+GstBufferMetaTiming | | | |
| | dts | |
| | pts | |
| | duration | |
+- | clock_rate | |
+ . . . . . . . . . . . . . . . . . . + |
- +- | info <--+ -> GstBufferMetaInfo
-GstBufferMetaMemory | | next ---+
+ | next <--+
+ | parent ------> NULL
+GstBufferMetaMemory +- | info ------> GstBufferMetaInfo
| | | |
| | data | |
| | size | |
+ . . . . . . . . . . . . . . . . . . + .
. .
+
API examples
~~~~~~~~~~~~
+Video Buffers
+-------------
+
+ #define GST_VIDEO_MAX_PLANES 4
+
+ struct GstVideoPlane {
+ guint8 *data;
+ guint size;
+ guint stride;
+
+ guint8 *data_orig;
+ guint size_orig;
+ GFreeFunc data_free;
+ gpointer data_user;
+ };
+
+ struct GstBufferVideoMeta {
+ GstBufferMeta meta
+
+ GstBufferVideoFlags flags
+
+ guint n_planes;
+ GstVideoPlane plane[GST_VIDEO_MAX_PLANES];
+ };
+