mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-05-17 15:08:09 +08:00
avformat/utils: Move ff_stream_side_data_copy to avformat.c
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user