[FFmpeg-cvslog] avformat/utils: Move adding AVProgram to avformat.c

Andreas Rheinhardt git at videolan.org
Tue May 10 09:35:47 EEST 2022


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sat May  7 05:25:19 2022 +0200| [b516302cfe8bf6ca6983a1b36f24c8f2487f718a] | committer: Andreas Rheinhardt

avformat/utils: Move adding AVProgram to avformat.c

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b516302cfe8bf6ca6983a1b36f24c8f2487f718a
---

 libavformat/avformat.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++
 libavformat/utils.c    | 58 --------------------------------------------------
 2 files changed, 58 insertions(+), 58 deletions(-)

diff --git a/libavformat/avformat.c b/libavformat/avformat.c
index baad2acde1..0b86ff025c 100644
--- a/libavformat/avformat.c
+++ b/libavformat/avformat.c
@@ -196,3 +196,61 @@ uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type,
 
     return data;
 }
+
+AVProgram *av_new_program(AVFormatContext *ac, int id)
+{
+    AVProgram *program = NULL;
+    int ret;
+
+    av_log(ac, AV_LOG_TRACE, "new_program: id=0x%04x\n", id);
+
+    for (unsigned i = 0; i < ac->nb_programs; i++)
+        if (ac->programs[i]->id == id)
+            program = ac->programs[i];
+
+    if (!program) {
+        program = av_mallocz(sizeof(*program));
+        if (!program)
+            return NULL;
+        ret = av_dynarray_add_nofree(&ac->programs, &ac->nb_programs, program);
+        if (ret < 0) {
+            av_free(program);
+            return NULL;
+        }
+        program->discard = AVDISCARD_NONE;
+        program->pmt_version = -1;
+        program->id = id;
+        program->pts_wrap_reference = AV_NOPTS_VALUE;
+        program->pts_wrap_behavior = AV_PTS_WRAP_IGNORE;
+        program->start_time =
+        program->end_time   = AV_NOPTS_VALUE;
+    }
+    return program;
+}
+
+void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned idx)
+{
+    AVProgram *program = NULL;
+    void *tmp;
+
+    if (idx >= ac->nb_streams) {
+        av_log(ac, AV_LOG_ERROR, "stream index %d is not valid\n", idx);
+        return;
+    }
+
+    for (unsigned i = 0; i < ac->nb_programs; i++) {
+        if (ac->programs[i]->id != progid)
+            continue;
+        program = ac->programs[i];
+        for (unsigned j = 0; j < program->nb_stream_indexes; j++)
+            if (program->stream_index[j] == idx)
+                return;
+
+        tmp = av_realloc_array(program->stream_index, program->nb_stream_indexes+1, sizeof(unsigned int));
+        if (!tmp)
+            return;
+        program->stream_index = tmp;
+        program->stream_index[program->nb_stream_indexes++] = idx;
+        return;
+    }
+}
diff --git a/libavformat/utils.c b/libavformat/utils.c
index e7788f3f40..3267db432e 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -457,64 +457,6 @@ int ff_stream_side_data_copy(AVStream *dst, const AVStream *src)
     return 0;
 }
 
-AVProgram *av_new_program(AVFormatContext *ac, int id)
-{
-    AVProgram *program = NULL;
-    int ret;
-
-    av_log(ac, AV_LOG_TRACE, "new_program: id=0x%04x\n", id);
-
-    for (unsigned i = 0; i < ac->nb_programs; i++)
-        if (ac->programs[i]->id == id)
-            program = ac->programs[i];
-
-    if (!program) {
-        program = av_mallocz(sizeof(AVProgram));
-        if (!program)
-            return NULL;
-        ret = av_dynarray_add_nofree(&ac->programs, &ac->nb_programs, program);
-        if (ret < 0) {
-            av_free(program);
-            return NULL;
-        }
-        program->discard = AVDISCARD_NONE;
-        program->pmt_version = -1;
-        program->id = id;
-        program->pts_wrap_reference = AV_NOPTS_VALUE;
-        program->pts_wrap_behavior = AV_PTS_WRAP_IGNORE;
-        program->start_time =
-        program->end_time   = AV_NOPTS_VALUE;
-    }
-    return program;
-}
-
-void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned idx)
-{
-    AVProgram *program = NULL;
-    void *tmp;
-
-    if (idx >= ac->nb_streams) {
-        av_log(ac, AV_LOG_ERROR, "stream index %d is not valid\n", idx);
-        return;
-    }
-
-    for (unsigned i = 0; i < ac->nb_programs; i++) {
-        if (ac->programs[i]->id != progid)
-            continue;
-        program = ac->programs[i];
-        for (unsigned j = 0; j < program->nb_stream_indexes; j++)
-            if (program->stream_index[j] == idx)
-                return;
-
-        tmp = av_realloc_array(program->stream_index, program->nb_stream_indexes+1, sizeof(unsigned int));
-        if (!tmp)
-            return;
-        program->stream_index = tmp;
-        program->stream_index[program->nb_stream_indexes++] = idx;
-        return;
-    }
-}
-
 uint64_t ff_ntp_time(void)
 {
     return (av_gettime() / 1000) * 1000 + NTP_OFFSET_US;



More information about the ffmpeg-cvslog mailing list