[FFmpeg-cvslog] mpegts: clear avprograms only for removed programs

Michael Niedermayer git at videolan.org
Sun Mar 10 09:56:10 CET 2013


ffmpeg | branch: release/1.2 | Michael Niedermayer <michaelni at gmx.at> | Mon Feb  4 23:41:53 2013 +0100| [0ec869527c13fce6755bc6f6b07cb50138936449] | committer: Carl Eugen Hoyos

mpegts: clear avprograms only for removed programs

Fixes Ticket2186

Requested-by: carl
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit 806a66fd08a395486e763fb10588c5fd02e8d54e)

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

 libavformat/mpegts.c |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 8b92bc4..32aa51f 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -208,9 +208,6 @@ static void clear_program(MpegTSContext *ts, unsigned int programid)
 
 static void clear_programs(MpegTSContext *ts)
 {
-    int i;
-    for(i=0; i<ts->nb_prg; i++)
-        clear_avprogram(ts, ts->prg[i].id);
     av_freep(&ts->prg);
     ts->nb_prg=0;
 }
@@ -1636,6 +1633,17 @@ static void pat_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
             add_pid_to_pmt(ts, sid, pmt_pid);
         }
     }
+
+    if (sid < 0) {
+        int i,j;
+        for (j=0; j<ts->stream->nb_programs; j++) {
+            for (i=0; i<ts->nb_prg; i++)
+                if (ts->prg[i].id == ts->stream->programs[j]->id)
+                    break;
+            if (i==ts->nb_prg)
+                clear_avprogram(ts, ts->stream->programs[j]->id);
+        }
+    }
 }
 
 static void sdt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len)



More information about the ffmpeg-cvslog mailing list