From 50d017a28171177b89c367194ec8d02f963e7e9e Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 23 Mar 2016 02:52:03 +0100 Subject: avformat/mpegtsenc: Keep track of the program for each service Simplifies code Signed-off-by: Michael Niedermayer --- libavformat/mpegtsenc.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'libavformat/mpegtsenc.c') diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 68f98673da..3e4e418cff 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -56,6 +56,7 @@ typedef struct MpegTSService { int pcr_pid; int pcr_packet_count; int pcr_packet_period; + AVProgram *program; } MpegTSService; // service_type values as defined in ETSI 300 468 @@ -275,15 +276,12 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0); if (s->nb_programs) { - int j, k, found = 0; - - for (j = 0; j < s->nb_programs; j++) - if (s->programs[j]->id == service->sid) { - for (k = 0; k < s->programs[j]->nb_stream_indexes; k++) - if (s->programs[j]->stream_index[k] == i) { - found = 1; - break; - } + int k, found = 0; + AVProgram *program = service->program; + + for (k = 0; k < program->nb_stream_indexes; k++) + if (program->stream_index[k] == i) { + found = 1; break; } @@ -784,6 +782,7 @@ static int mpegts_init(AVFormatContext *s) service->pmt.write_packet = section_write_packet; service->pmt.opaque = s; service->pmt.cc = 15; + service->program = program; } } -- cgit v1.2.3