aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-05-07 05:25:19 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-05-10 07:46:52 +0200
commitb516302cfe8bf6ca6983a1b36f24c8f2487f718a (patch)
tree35bce151f00d5ba46a6ca10021c2653c08171cb8
parent21f3dc0ad646e21ba0130f83ad304cc2c3baf000 (diff)
downloadffmpeg-b516302cfe8bf6ca6983a1b36f24c8f2487f718a.tar.gz
avformat/utils: Move adding AVProgram to avformat.c
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r--libavformat/avformat.c58
-rw-r--r--libavformat/utils.c58
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;