[FFmpeg-devel] [PATCH 04/21] libavcodec: added a structure AVData for decoding timed metadata
erkki.seppala.ext at nokia.com
erkki.seppala.ext at nokia.com
Tue Aug 23 12:03:22 EEST 2016
From: Erkki Seppälä <erkki.seppala.ext at nokia.com>
Also added avdata_alloc and avdata_free for dealing with it. AVData
can contain arbitrary binary data and comes with a format-field so far
unused.
The purpose is that AVMEDIA_TYPE_DATA -kind codecs can store frames in
this format.
Signed-off-by: Erkki Seppälä <erkki.seppala.ext at nokia.com>
Signed-off-by: OZOPlayer <OZOPL at nokia.com>
---
libavcodec/avcodec.h | 20 ++++++++++++++++++++
libavcodec/utils.c | 19 +++++++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 6ac6646..fb8f363 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3934,6 +3934,14 @@ typedef struct AVSubtitle {
int64_t pts; ///< Same as packet pts, in AV_TIME_BASE
} AVSubtitle;
+typedef struct AVData {
+ uint16_t format; /** 0 = timed metadata */
+ int64_t pts;
+ int64_t dts;
+
+ AVBufferRef *data;
+} AVData;
+
/**
* This struct describes the properties of an encoded stream.
*
@@ -4317,6 +4325,18 @@ int avcodec_close(AVCodecContext *avctx);
void avsubtitle_free(AVSubtitle *sub);
/**
+ * Allocate an empty data (typically use with timed metadata)
+ */
+AVData *avdata_alloc(void);
+
+/**
+ * Free all allocated data in the given data struct.
+ *
+ * @param sub AVData to free.
+ */
+void avdata_free(AVData *sub);
+
+/**
* @}
*/
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 138125a..dabe97e 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -2955,6 +2955,25 @@ int attribute_align_arg avcodec_receive_packet(AVCodecContext *avctx, AVPacket *
return 0;
}
+AVData *avdata_alloc(void)
+{
+ AVData *data = av_mallocz(sizeof(*data));
+
+ if (!data)
+ return NULL;
+
+ return data;
+}
+
+void avdata_free(AVData *data)
+{
+ av_buffer_unref(&data->data);
+
+ memset(data, 0, sizeof(AVData));
+
+ av_free(data);
+}
+
av_cold int avcodec_close(AVCodecContext *avctx)
{
int i;
--
2.7.4
More information about the ffmpeg-devel
mailing list