]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Optimize mpegts_input_recv_packets()
authorJaroslav Kysela <perex@perex.cz>
Thu, 6 Mar 2014 12:06:20 +0000 (13:06 +0100)
committerAdam Sutton <dev@adamsutton.me.uk>
Fri, 7 Mar 2014 20:35:20 +0000 (20:35 +0000)
src/input/mpegts/mpegts_input.c

index 9c1227f2ecf1c1aded1303aa702a24f70a3a24b8..2c053bd0f5cef5eef0796186fc3b2e57eff78390 100644 (file)
@@ -345,7 +345,10 @@ mpegts_input_recv_packets
 {
   int len = l;
   int i = 0, table_wakeup = 0;
+  int stream = 0;
+  int table = 0;
   mpegts_mux_t *mm = mmi->mmi_mux;
+  mpegts_pid_t *last_mp = NULL;
   assert(mm != NULL);
   assert(name != NULL);
 
@@ -374,25 +377,29 @@ mpegts_input_recv_packets
 
       /* Find PID */
       if ((mp = mpegts_mux_find_pid(mm, pid, 0))) {
-        int stream = 0;
-        int table  = 0;
-
-        /* Stream takes pref. */
-        RB_FOREACH(mps, &mp->mp_subs, mps_link) {
-          if (mps->mps_type & MPS_STREAM)
-            stream = 1;
-          if (mps->mps_type & MPS_TABLE)
-            table  = 1;
-        }
 
-        /* Special case streams */
-        if (pid == 0) table = stream = 1;
-        LIST_FOREACH(s, &mi->mi_transports, s_active_link) {
-          if (((mpegts_service_t*)s)->s_dvb_mux != mmi->mmi_mux) continue;
-               if (pid == s->s_pmt_pid) stream = 1;
-          else if (pid == s->s_pcr_pid) stream = 1;
+       if (mp != last_mp) {
+         last_mp = mp;
+         stream = 0;
+          table = 0;
+
+          /* Stream takes pref. */
+          RB_FOREACH(mps, &mp->mp_subs, mps_link) {
+            if (mps->mps_type & MPS_STREAM)
+              stream = 1;
+            if (mps->mps_type & MPS_TABLE)
+              table  = 1;
+          }
+
+          /* Special case streams */
+          if (pid == 0) table = stream = 1;
+          LIST_FOREACH(s, &mi->mi_transports, s_active_link) {
+            if (((mpegts_service_t*)s)->s_dvb_mux != mmi->mmi_mux) continue;
+                 if (pid == s->s_pmt_pid) stream = 1;
+            else if (pid == s->s_pcr_pid) stream = 1;
+          }
         }
-  
+    
         /* Stream data */
         if (stream) {
           LIST_FOREACH(s, &mi->mi_transports, s_active_link) {