[FFmpeg-cvslog] avformat/utils: Move av_stream_*_side_data API to avformat.c
Andreas Rheinhardt
git at videolan.org
Tue May 10 09:35:45 EEST 2022
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sat May 7 05:20:30 2022 +0200| [21f3dc0ad646e21ba0130f83ad304cc2c3baf000] | committer: Andreas Rheinhardt
avformat/utils: Move av_stream_*_side_data API to avformat.c
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=21f3dc0ad646e21ba0130f83ad304cc2c3baf000
---
libavformat/avformat.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++
libavformat/utils.c | 68 --------------------------------------------------
2 files changed, 68 insertions(+), 68 deletions(-)
diff --git a/libavformat/avformat.c b/libavformat/avformat.c
index 88acae018e..baad2acde1 100644
--- a/libavformat/avformat.c
+++ b/libavformat/avformat.c
@@ -128,3 +128,71 @@ void avformat_free_context(AVFormatContext *s)
av_freep(&s->url);
av_free(s);
}
+
+uint8_t *av_stream_get_side_data(const AVStream *st,
+ enum AVPacketSideDataType type, size_t *size)
+{
+ for (int i = 0; i < st->nb_side_data; i++) {
+ if (st->side_data[i].type == type) {
+ if (size)
+ *size = st->side_data[i].size;
+ return st->side_data[i].data;
+ }
+ }
+ if (size)
+ *size = 0;
+ return NULL;
+}
+
+int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type,
+ uint8_t *data, size_t size)
+{
+ AVPacketSideData *sd, *tmp;
+
+ for (int 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 0;
+ }
+ }
+
+ if (st->nb_side_data + 1U > FFMIN(INT_MAX, SIZE_MAX / sizeof(*tmp)))
+ return AVERROR(ERANGE);
+
+ tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp));
+ if (!tmp) {
+ return AVERROR(ENOMEM);
+ }
+
+ 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 0;
+}
+
+uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type,
+ size_t size)
+{
+ int ret;
+ uint8_t *data = av_malloc(size);
+
+ if (!data)
+ return NULL;
+
+ ret = av_stream_add_side_data(st, type, data, size);
+ if (ret < 0) {
+ av_freep(&data);
+ return NULL;
+ }
+
+ return data;
+}
diff --git a/libavformat/utils.c b/libavformat/utils.c
index b3806fe87b..e7788f3f40 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1091,74 +1091,6 @@ error:
return ret;
}
-uint8_t *av_stream_get_side_data(const AVStream *st,
- enum AVPacketSideDataType type, size_t *size)
-{
- for (int i = 0; i < st->nb_side_data; i++) {
- if (st->side_data[i].type == type) {
- if (size)
- *size = st->side_data[i].size;
- return st->side_data[i].data;
- }
- }
- if (size)
- *size = 0;
- return NULL;
-}
-
-int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type,
- uint8_t *data, size_t size)
-{
- AVPacketSideData *sd, *tmp;
-
- for (int 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 0;
- }
- }
-
- if (st->nb_side_data + 1U > FFMIN(INT_MAX, SIZE_MAX / sizeof(*tmp)))
- return AVERROR(ERANGE);
-
- tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp));
- if (!tmp) {
- return AVERROR(ENOMEM);
- }
-
- 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 0;
-}
-
-uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type,
- size_t size)
-{
- int ret;
- uint8_t *data = av_malloc(size);
-
- if (!data)
- return NULL;
-
- ret = av_stream_add_side_data(st, type, data, size);
- if (ret < 0) {
- av_freep(&data);
- return NULL;
- }
-
- return data;
-}
-
void ff_format_io_close_default(AVFormatContext *s, AVIOContext *pb)
{
avio_close(pb);
More information about the ffmpeg-cvslog
mailing list