diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-01-27 20:16:42 +0300 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-01-27 20:16:42 +0300 |
commit | 0bdcc27d9598254e79a80f1e016227778b428dbb (patch) | |
tree | 87c268fd30634dcb7323ebe0f9c2fcb54b3776f3 /libavformat/utils.c | |
parent | 62a82c66cd3f03e045867471c5edcc84b4d2b54e (diff) | |
parent | 4227e4fe7443733fb906f6fb6c265105e8269c74 (diff) |
Merge commit '4227e4fe7443733fb906f6fb6c265105e8269c74'
* commit '4227e4fe7443733fb906f6fb6c265105e8269c74':
lavf: add a convenience function for adding side data to a stream
Conflicts:
libavformat/internal.h
libavformat/replaygain.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 11247838ea..f6df49bf0f 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -4433,3 +4433,40 @@ uint8_t *av_stream_get_side_data(AVStream *st, enum AVPacketSideDataType type, } return NULL; } + +uint8_t *ff_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type, + int size) +{ + AVPacketSideData *sd, *tmp; + int i; + uint8_t *data = av_malloc(size); + + if (!data) + return NULL; + + for (i = 0; i < st->nb_side_data; i++) { + sd = &st->side_data[i]; + + if (sd->type == type) { + av_freep(&sd->data); + sd->data = data; + sd->size = size; + return sd->data; + } + } + + tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp)); + if (!tmp) { + av_freep(&data); + return NULL; + } + + st->side_data = tmp; + st->nb_side_data++; + + sd = &st->side_data[st->nb_side_data - 1]; + sd->type = type; + sd->data = data; + sd->size = size; + return data; +} |