[FFmpeg-cvslog] avformat/mpegtsenc: Keep track of the program for each service

Michael Niedermayer git at videolan.org
Thu Mar 24 12:44:01 CET 2016


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Wed Mar 23 02:52:03 2016 +0100| [50d017a28171177b89c367194ec8d02f963e7e9e] | committer: Michael Niedermayer

avformat/mpegtsenc: Keep track of the program for each service

Simplifies code

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavformat/mpegtsenc.c |   17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 68f9867..3e4e418 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;
         }
     }
 



More information about the ffmpeg-cvslog mailing list