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>
This commit is contained in:
Michael Niedermayer
2015-01-27 18:16:42 +01:00
3 changed files with 47 additions and 23 deletions

View File

@@ -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;
}