Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-05-07 10:17:33 +0300
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-05-10 08:49:18 +0300
commit6aca6146d9a89e4344c13870052214698b40f6fd (patch)
tree3a5f04a8a38fd104f7e9d0c5ce24dd992e10cf54 /libavformat/avformat.c
parent60fa58b8357984867b9104ad5e902a21ba2d78b0 (diff)
avformat/utils: Move ff_stream_side_data_copy to avformat.c
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/avformat.c')
-rw-r--r--libavformat/avformat.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/libavformat/avformat.c b/libavformat/avformat.c
index 2a919ad89f..3eae41d109 100644
--- a/libavformat/avformat.c
+++ b/libavformat/avformat.c
@@ -204,6 +204,36 @@ uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type,
return data;
}
+int ff_stream_side_data_copy(AVStream *dst, const AVStream *src)
+{
+ /* Free existing side data*/
+ for (int i = 0; i < dst->nb_side_data; i++)
+ av_free(dst->side_data[i].data);
+ av_freep(&dst->side_data);
+ dst->nb_side_data = 0;
+
+ /* Copy side data if present */
+ if (src->nb_side_data) {
+ dst->side_data = av_calloc(src->nb_side_data,
+ sizeof(*dst->side_data));
+ if (!dst->side_data)
+ return AVERROR(ENOMEM);
+ dst->nb_side_data = src->nb_side_data;
+
+ for (int i = 0; i < src->nb_side_data; i++) {
+ uint8_t *data = av_memdup(src->side_data[i].data,
+ src->side_data[i].size);
+ if (!data)
+ return AVERROR(ENOMEM);
+ dst->side_data[i].type = src->side_data[i].type;
+ dst->side_data[i].size = src->side_data[i].size;
+ dst->side_data[i].data = data;
+ }
+ }
+
+ return 0;
+}
+
AVProgram *av_new_program(AVFormatContext *ac, int id)
{
AVProgram *program = NULL;