[FFmpeg-devel] [PATCH v3 3/7] avformat: Add av_stream_add_coded_side_data()

Nicolas Gaullier nicolas.gaullier at cji.paris
Fri Dec 20 11:42:22 EET 2019


This will allow avformat_find_stream_info() get side data from the codec context.
---
 doc/APIchanges         |  3 +++
 libavformat/avformat.h | 11 +++++++++++
 libavformat/utils.c    | 15 +++++++++++++++
 libavformat/version.h  |  4 ++--
 4 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 401c65a753..62b5effda7 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil:     2017-10-21
 
 API changes, most recent first:
 
+2019-12-19 - xxxxxxxxxx - lavf 58.36.101 - avformat.h
+  Add av_stream_add_coded_side_data().
+
 2019-11-17 - 1c23abc88f - lavu 56.36.100 - eval API
   Add av_expr_count_vars().
 
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index d4d9a3b06e..4dee1a272a 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2191,6 +2191,17 @@ int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type,
  */
 uint8_t *av_stream_new_side_data(AVStream *stream,
                                  enum AVPacketSideDataType type, int size);
+
+/**
+ * Add stream side_data from the coded_side_data of the supplied context.
+ *
+ * @param stream stream
+ * @param avctx the codec context that may contain coded_side_data
+ * @return >= 0 in case of success, a negative AVERROR code in case of
+ * failure
+ */
+int av_stream_add_coded_side_data(AVStream *stream, AVCodecContext *avctx);
+
 /**
  * Get side information from stream.
  *
diff --git a/libavformat/utils.c b/libavformat/utils.c
index b472762dd1..fe92ad4a1d 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -5556,6 +5556,21 @@ uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type,
     return data;
 }
 
+int av_stream_add_coded_side_data(AVStream *st, AVCodecContext *avctx)
+{
+    int i;
+
+    for (i = 0; i < avctx->nb_coded_side_data; i++) {
+        const AVPacketSideData *sd_src = &avctx->coded_side_data[i];
+        uint8_t *dst_data;
+        dst_data = av_stream_new_side_data(st, sd_src->type, sd_src->size);
+        if (!dst_data)
+            return AVERROR(ENOMEM);
+        memcpy(dst_data, sd_src->data, sd_src->size);
+    }
+    return 0;
+}
+
 int ff_stream_add_bitstream_filter(AVStream *st, const char *name, const char *args)
 {
     int ret;
diff --git a/libavformat/version.h b/libavformat/version.h
index 213b66b45f..f72fb9478a 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,8 +32,8 @@
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
-#define LIBAVFORMAT_VERSION_MINOR  35
-#define LIBAVFORMAT_VERSION_MICRO 101
+#define LIBAVFORMAT_VERSION_MINOR  36
+#define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                LIBAVFORMAT_VERSION_MINOR, \
-- 
2.14.1.windows.1



More information about the ffmpeg-devel mailing list