[vlc-devel] [PATCH 1/2] add vlc_ancillary

Francois Cartegnie fcvlcdev at free.fr
Tue Jun 19 18:50:35 CEST 2018


Codec sample sidedata support.

sidedata can be known data structures (display metadata, ...),
 or opaque (sample key for encryption) and provide
information for a single sample. (otherwise it is repeated)

While an es_out control way was considered, the
only simple and efficient way is to tie sidedata 
to blocks, since it only requires little changes.

- It passes data between demux/packetizer to decoder without 
the need of post box and re-feed calls ( this means we can also
suppress the get_cc )
- It avoids modifying every es_out proxying module
- avoids modifying Fifos to keep both block and extradata (or other
way to resynchronize it)
- Metadata filtering, dropping and forwarding can be done in decoders,
for example pictures


---
 include/vlc_ancillary.h | 104 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/vlc_common.h    |   3 ++
 src/Makefile.am         |   1 +
 3 files changed, 108 insertions(+)
 create mode 100644 include/vlc_ancillary.h

diff --git a/include/vlc_ancillary.h b/include/vlc_ancillary.h
new file mode 100644
index 0000000000..7a27fb8ca2
--- /dev/null
+++ b/include/vlc_ancillary.h
@@ -0,0 +1,104 @@
+/*****************************************************************************
+ * vlc_ancillary.h: Ancillary data declarations
+ *****************************************************************************
+ * Copyright (C) 2016 VideoLabs, VLC authors and VideoLAN
+ *
+ * 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.
+ *****************************************************************************/
+#ifndef VLC_ANCILLARY_H
+#define VLC_ANCILLARY_H
+
+typedef enum
+{
+    ANCILLARY_UNDEFINED       = 0,
+
+} vlc_ancillary_type_t;
+
+struct vlc_ancillary_t
+{
+    vlc_ancillary_t *p_next;
+    uint8_t *p_data;
+    size_t   i_data;
+    vlc_ancillary_type_t type;
+};
+
+static inline void vlc_ancillary_Delete( vlc_ancillary_t *p_anc )
+{
+    free( p_anc );
+}
+
+static inline vlc_ancillary_t * vlc_ancillary_New( vlc_ancillary_type_t type, size_t i_data )
+{
+    vlc_ancillary_t *p_anc = (vlc_ancillary_t *) malloc(sizeof(*p_anc) + i_data);
+    if(p_anc)
+    {
+        p_anc->type = type;
+        p_anc->i_data = i_data;
+        p_anc->p_data = (uint8_t *) &p_anc[1];
+        p_anc->p_next = NULL;
+    }
+    return p_anc;
+}
+
+static inline void vlc_ancillary_StoragePrepend( vlc_ancillary_t **pp_stor,
+                                                 vlc_ancillary_t *p_anc )
+{
+    p_anc->p_next = *pp_stor;
+    *pp_stor = p_anc;
+}
+
+static inline vlc_ancillary_t * vlc_ancillary_StorageGet( vlc_ancillary_t **pp_stor,
+                                                          vlc_ancillary_type_t type )
+{
+    while( *pp_stor )
+    {
+        vlc_ancillary_t *p_cur = *pp_stor;
+        if( p_cur->type == type )
+        {
+            *pp_stor = p_cur->p_next;
+            p_cur->p_next = NULL;
+            return p_cur;
+        }
+        else pp_stor = &p_cur->p_next;
+    }
+    return NULL;
+}
+
+static inline void vlc_ancillary_StorageRemove( vlc_ancillary_t **pp_stor,
+                                                vlc_ancillary_type_t type )
+{
+    vlc_ancillary_t *p_cur;
+    while( (p_cur = vlc_ancillary_StorageGet( pp_stor, type )) )
+        vlc_ancillary_Delete( p_cur );
+}
+
+static inline void vlc_ancillary_StorageMerge( vlc_ancillary_t **pp_stor,
+                                               vlc_ancillary_t *p_anc )
+{
+    vlc_ancillary_StorageRemove( pp_stor, p_anc->type );
+    vlc_ancillary_StoragePrepend( pp_stor, p_anc );
+}
+
+static inline void vlc_ancillary_StorageEmpty( vlc_ancillary_t **pp_stor )
+{
+    while( *pp_stor )
+    {
+        vlc_ancillary_t *p_cur = *pp_stor;
+        *pp_stor = p_cur->p_next;
+        vlc_ancillary_Delete( p_cur );
+    }
+}
+
+#endif
diff --git a/include/vlc_common.h b/include/vlc_common.h
index cc94b2f374..7937029184 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -403,6 +403,9 @@ typedef struct session_descriptor_t session_descriptor_t;
 typedef struct decoder_t         decoder_t;
 typedef struct decoder_synchro_t decoder_synchro_t;
 
+/* Ancillary */
+typedef struct vlc_ancillary_t vlc_ancillary_t;
+
 /* Encoders */
 typedef struct encoder_t      encoder_t;
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 7a610db868..3b5397df43 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -25,6 +25,7 @@ pluginsinclude_HEADERS = \
 	../include/vlc_access.h \
 	../include/vlc_actions.h \
 	../include/vlc_addons.h \
+	../include/vlc_ancillary.h \
 	../include/vlc_aout.h \
 	../include/vlc_aout_volume.h \
 	../include/vlc_arrays.h \
-- 
2.14.4



More information about the vlc-devel mailing list