]> www.vanbest.org Git - sasc-ng.git/commitdiff
nagra 0101: map3e without lookup table
authorleslie <unknown>
Thu, 27 Dec 2007 21:15:12 +0000 (22:15 +0100)
committerleslie <unknown>
Thu, 27 Dec 2007 21:15:12 +0000 (22:15 +0100)
systems/nagra/nagra2-0101.c

index e061d1a177951352e55742c650f52132210453df..e4ef894c2a25f1994fcbe7c35f4fef95a5cd44f3 100644 (file)
@@ -122,7 +122,6 @@ class cMap0101 : public cMapCore {
 private:
   static const unsigned char primes[];
   static const unsigned short coef22[][32];
-  static const unsigned short msbtbl3e[];
   unsigned int cycles;
 #ifdef HAS_AUXSRV
   cAuxSrv aux;
@@ -405,26 +404,6 @@ const unsigned short cMap0101::coef22[256][32] = {
   {436,17,16,17,16,17,17,16,27,26,27,26,26,27,26,27,37,38,38,37,38,37,38,38,48,49,48,49,49,48,49,48},
   };
 
-const unsigned short cMap0101::msbtbl3e[] = {
-//      0    1    2    3    4    5    6    7    8    9    a    b    c    d    e    f
-/*0*/   0,  88, 148, 236, 224, 312, 312, 400, 302, 390, 390, 476, 390, 476, 476, 566,
-/*1*/ 378, 466, 466, 554, 466, 554, 554, 642, 466, 554, 554, 642, 554, 642, 642, 730,
-/*2*/ 448, 536, 536, 624, 536, 624, 624, 712, 536, 624, 624, 712, 624, 712, 712, 796,
-/*3*/ 536, 624, 624, 712, 624, 712, 712, 796, 624, 712, 712, 796, 712, 796, 796, 884,
-/*4*/ 524, 612, 612, 700, 612, 700, 700, 790, 612, 700, 700, 790, 700, 790, 790, 878,
-/*5*/ 612, 700, 700, 790, 700, 790, 790, 878, 700, 790, 790, 878, 790, 878, 878, 966,
-/*6*/ 612, 700, 700, 790, 700, 790, 790, 878, 700, 790, 790, 878, 790, 878, 878, 966,
-/*7*/ 700, 790, 790, 878, 790, 878, 878, 966, 790, 878, 878, 966, 878, 966, 966,1054,
-/*8*/ 602, 690, 690, 778, 690, 778, 778, 862, 690, 778, 778, 862, 778, 862, 862, 950,
-/*9*/ 690, 778, 778, 862, 778, 862, 862, 950, 778, 862, 862, 950, 862, 950, 950,1038,
-/*a*/ 690, 778, 778, 862, 778, 862, 862, 950, 778, 862, 862, 950, 862, 950, 950,1038,
-/*b*/ 778, 862, 862, 950, 862, 950, 950,1038, 862, 950, 950,1038, 950,1038,1038,1126,
-/*c*/ 690, 778, 778, 862, 778, 862, 862, 950, 778, 862, 862, 950, 862, 950, 950,1038,
-/*d*/ 778, 862, 862, 950, 862, 950, 950,1038, 862, 950, 950,1038, 950,1038,1038,1126,
-/*e*/ 778, 862, 862, 950, 862, 950, 950,1038, 862, 950, 950,1038, 950,1038,1038,1126,
-/*f*/ 862, 950, 950,1038, 950,1038,1038,1126, 950,1038,1038,1126,1038,1126,1126,1214
-  };
-
 cMap0101::cMap0101(void)
 {
   GenCRC16Table();
@@ -493,9 +472,11 @@ void cMap0101::DoMap(int f, unsigned char *data, int l)
       I.GetLE(data,(l?l:wordsize)<<3);
       BN_mod_exp(B,A,I,D,ctx);
       BN_one(A);
-      int end=(BN_num_bits(I)-1)/8;
-      cycles=3848 + end*650 + msbtbl3e[data[end]] - 13;
-      for(int i=end*8; --i>=0;) if(BN_is_bit_set(I,i)) cycles+=88;
+      int end=BN_num_bits(I);
+      int msb=data[(end-1)/8];
+      cycles=3848 + ((end-1)/8)*650 - 11;
+      for(int i=8; --i>=1;) if(msb&(1<<i)) { cycles+=(i*75)-15; break; }
+      for(int i=end; --i>=0;) if(BN_is_bit_set(I,i)) cycles+=88;
       break;
       }
     case 0x4d: