Browse code

avformat/mpegts: Factorize version checking code out

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2015/04/30 05:24:09
Showing 1 changed files
... ...
@@ -580,6 +580,16 @@ typedef struct SectionHeader {
580 580
     uint8_t last_sec_num;
581 581
 } SectionHeader;
582 582
 
583
+static int skip_identical(const SectionHeader *h, MpegTSSectionFilter *tssf)
584
+{
585
+    if (h->version == tssf->last_ver)
586
+        return 1;
587
+
588
+    tssf->last_ver = h->version;
589
+
590
+    return 0;
591
+}
592
+
583 593
 static inline int get8(const uint8_t **pp, const uint8_t *p_end)
584 594
 {
585 595
     const uint8_t *p;
... ...
@@ -1469,9 +1479,8 @@ static void m4sl_cb(MpegTSFilter *filter, const uint8_t *section,
1469 1469
         return;
1470 1470
     if (h.tid != M4OD_TID)
1471 1471
         return;
1472
-    if (h.version == tssf->last_ver)
1472
+    if (skip_identical(&h, tssf))
1473 1473
         return;
1474
-    tssf->last_ver = h.version;
1475 1474
 
1476 1475
     mp4_read_od(s, p, (unsigned) (p_end - p), mp4_descr, &mp4_descr_count,
1477 1476
                 MAX_MP4_DESCR_COUNT);
... ...
@@ -1816,9 +1825,8 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
1816 1816
     p = section;
1817 1817
     if (parse_section_header(h, &p, p_end) < 0)
1818 1818
         return;
1819
-    if (h->version == tssf->last_ver)
1819
+    if (skip_identical(h, tssf))
1820 1820
         return;
1821
-    tssf->last_ver = h->version;
1822 1821
 
1823 1822
     av_log(ts->stream, AV_LOG_TRACE, "sid=0x%x sec_num=%d/%d version=%d\n",
1824 1823
             h->id, h->sec_num, h->last_sec_num, h->version);
... ...
@@ -1986,9 +1994,8 @@ static void pat_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
1986 1986
     if (ts->skip_changes)
1987 1987
         return;
1988 1988
 
1989
-    if (h->version == tssf->last_ver)
1989
+    if (skip_identical(h, tssf))
1990 1990
         return;
1991
-    tssf->last_ver = h->version;
1992 1991
     ts->stream->ts_id = h->id;
1993 1992
 
1994 1993
     clear_programs(ts);
... ...
@@ -2061,9 +2068,8 @@ static void sdt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
2061 2061
         return;
2062 2062
     if (ts->skip_changes)
2063 2063
         return;
2064
-    if (h->version == tssf->last_ver)
2064
+    if (skip_identical(h, tssf))
2065 2065
         return;
2066
-    tssf->last_ver = h->version;
2067 2066
 
2068 2067
     onid = get16(&p, p_end);
2069 2068
     if (onid < 0)