From 60082d68d455adccf830410e93b538d991b95fb9 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 6 Mar 2014 13:06:20 +0100 Subject: [PATCH] Optimize mpegts_input_recv_packets() --- src/input/mpegts/mpegts_input.c | 39 +++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/input/mpegts/mpegts_input.c b/src/input/mpegts/mpegts_input.c index 9c1227f2..2c053bd0 100644 --- a/src/input/mpegts/mpegts_input.c +++ b/src/input/mpegts/mpegts_input.c @@ -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; - } + if (mp != last_mp) { + last_mp = mp; + stream = 0; + table = 0; - /* 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 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) {