]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
tvhcsa: optimization for DVBCSA code
authorJaroslav Kysela <perex@perex.cz>
Sun, 3 Dec 2017 11:38:50 +0000 (12:38 +0100)
committerJaroslav Kysela <perex@perex.cz>
Sun, 3 Dec 2017 11:38:50 +0000 (12:38 +0100)
src/descrambler/tvhcsa.c

index 297c10a9fb243426cd93865c5bc39da5d0244b0a..dc55ac402d56122bae6228b5e8f54e45de1028df 100644 (file)
@@ -125,7 +125,6 @@ tvhcsa_csa_cbc_descramble
 
 #if ENABLE_DVBCSA
   uint8_t *pkt;
-  int xc0;
   int ev_od;
   int len;
   int offset;
@@ -138,39 +137,32 @@ tvhcsa_csa_cbc_descramble
    csa->csa_fill++;
 
    do { // handle this packet
-     xc0 = pkt[3] & 0xc0;
-     if(xc0 == 0x00) { // clear
+     if((pkt[3] & 0x80) == 0) // clear or reserved (0x40)
        break;
-     }
-     if(xc0 == 0x40) { // reserved
-       break;
-     }
-     if(xc0 == 0x80 || xc0 == 0xc0) { // encrypted
-       ev_od = (xc0 & 0x40) >> 6; // 0 even, 1 odd
-       pkt[3] &= 0x3f;  // consider it decrypted now
-       if(pkt[3] & 0x20) { // incomplete packet
-         offset = 4 + pkt[4] + 1;
-         len = 188 - offset;
-         n = len >> 3;
-         // FIXME: //residue = len - (n << 3);
-         if(n == 0) { // decrypted==encrypted!
-           break; // this doesn't need more processing
-         }
-       } else {
-         len = 184;
-         offset = 4;
-         // FIXME: //n = 23;
-         // FIXME: //residue = 0;
-       }
-       if(ev_od == 0) {
-         csa->csa_tsbbatch_even[csa->csa_fill_even].data = pkt + offset;
-         csa->csa_tsbbatch_even[csa->csa_fill_even].len = len;
-         csa->csa_fill_even++;
-       } else {
-         csa->csa_tsbbatch_odd[csa->csa_fill_odd].data = pkt + offset;
-         csa->csa_tsbbatch_odd[csa->csa_fill_odd].len = len;
-         csa->csa_fill_odd++;
+     ev_od = pkt[3] & 0x40;
+     pkt[3] &= 0x3f;  // consider it decrypted now
+     if(pkt[3] & 0x20) { // incomplete packet
+       offset = 4 + pkt[4] + 1;
+       len = 188 - offset;
+       n = len >> 3;
+       // FIXME: //residue = len - (n << 3);
+       if(n == 0) { // decrypted==encrypted!
+         break; // this doesn't need more processing
        }
+     } else {
+       len = 184;
+       offset = 4;
+       // FIXME: //n = 23;
+       // FIXME: //residue = 0;
+     }
+     if(ev_od == 0) {
+       csa->csa_tsbbatch_even[csa->csa_fill_even].data = pkt + offset;
+       csa->csa_tsbbatch_even[csa->csa_fill_even].len = len;
+       csa->csa_fill_even++;
+     } else {
+       csa->csa_tsbbatch_odd[csa->csa_fill_odd].data = pkt + offset;
+       csa->csa_tsbbatch_odd[csa->csa_fill_odd].len = len;
+       csa->csa_fill_odd++;
      }
    } while(0);