Re: [PATCH]Frontends or51132, or51211 move common code to module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Andrew de Quincey wrote:
On Tuesday 18 April 2006 23:21, Rusty Scott wrote:
So can someone give me a quick decision on what I should do? Should I
put that code into dvb-core.c or make a new dvb_core_math.c?

I would say put it in dvb_core_math.c, but link it into the dvb-core.ko module.



what about dvb_math.c ? But we will need a log function which has a better precision for tuning algorithm. Christoph Pfister volunteered to do one for the stb0899. If we have a common one which is quite precise would be nice.

He sent me a preview, i think it needed a bit more tuning up, he said he got an accuracy of 0.054%


Manu


unsigned char msbtable[256] = {
   0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
   4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
   5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
   5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
   6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
   6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
   6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
   6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
   7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
   7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
   7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
   7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
   7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
   7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
   7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
   7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7};

unsigned short logtable[256] = {
   0x000, 0x00c, 0x017, 0x022, 0x02e, 0x039, 0x044, 0x050,
   0x05b, 0x066, 0x071, 0x07c, 0x087, 0x092, 0x09d, 0x0a8,
   0x0b3, 0x0be, 0x0c9, 0x0d4, 0x0de, 0x0e9, 0x0f4, 0x0fe,
   0x109, 0x113, 0x11e, 0x128, 0x133, 0x13d, 0x147, 0x152,
   0x15c, 0x166, 0x170, 0x17b, 0x185, 0x18f, 0x199, 0x1a3,
   0x1ad, 0x1b7, 0x1c1, 0x1cb, 0x1d5, 0x1de, 0x1e8, 0x1f2,
   0x1fc, 0x205, 0x20f, 0x219, 0x222, 0x22c, 0x236, 0x23f,
   0x249, 0x252, 0x25b, 0x265, 0x26e, 0x277, 0x281, 0x28a,
   0x293, 0x29d, 0x2a6, 0x2af, 0x2b8, 0x2c1, 0x2ca, 0x2d3,
   0x2dc, 0x2e5, 0x2ee, 0x2f7, 0x300, 0x309, 0x312, 0x31b,
   0x323, 0x32c, 0x335, 0x33e, 0x346, 0x34f, 0x358, 0x360,
   0x369, 0x372, 0x37a, 0x383, 0x38b, 0x394, 0x39c, 0x3a5,
   0x3ad, 0x3b5, 0x3be, 0x3c6, 0x3ce, 0x3d7, 0x3df, 0x3e7,
   0x3ef, 0x3f8, 0x400, 0x408, 0x410, 0x418, 0x420, 0x428,
   0x430, 0x438, 0x440, 0x448, 0x450, 0x458, 0x460, 0x468,
   0x470, 0x478, 0x47f, 0x487, 0x48f, 0x497, 0x49f, 0x4a6,
   0x4ae, 0x4b6, 0x4bd, 0x4c5, 0x4cd, 0x4d4, 0x4dc, 0x4e3,
   0x4eb, 0x4f2, 0x4fa, 0x501, 0x509, 0x510, 0x518, 0x51f,
   0x527, 0x52e, 0x535, 0x53d, 0x544, 0x54b, 0x553, 0x55a,
   0x561, 0x568, 0x570, 0x577, 0x57e, 0x585, 0x58c, 0x593,
   0x59b, 0x5a2, 0x5a9, 0x5b0, 0x5b7, 0x5be, 0x5c5, 0x5cc,
   0x5d3, 0x5da, 0x5e1, 0x5e8, 0x5ef, 0x5f5, 0x5fc, 0x603,
   0x60a, 0x611, 0x618, 0x61e, 0x625, 0x62c, 0x633, 0x63a,
   0x640, 0x647, 0x64e, 0x654, 0x65b, 0x662, 0x668, 0x66f,
   0x675, 0x67c, 0x683, 0x689, 0x690, 0x696, 0x69d, 0x6a3,
   0x6aa, 0x6b0, 0x6b7, 0x6bd, 0x6c4, 0x6ca, 0x6d0, 0x6d7,
   0x6dd, 0x6e4, 0x6ea, 0x6f0, 0x6f7, 0x6fd, 0x703, 0x709,
   0x710, 0x716, 0x71c, 0x722, 0x729, 0x72f, 0x735, 0x73b,
   0x741, 0x747, 0x74e, 0x754, 0x75a, 0x760, 0x766, 0x76c,
   0x772, 0x778, 0x77e, 0x784, 0x78a, 0x790, 0x796, 0x79c,
   0x7a2, 0x7a8, 0x7ae, 0x7b4, 0x7ba, 0x7c0, 0x7c6, 0x7cc,
   0x7d1, 0x7d7, 0x7dd, 0x7e3, 0x7e9, 0x7ef, 0x7f4, 0x7fa};

unsigned int intlog2(unsigned int value) {
   unsigned int msb;
   if(value >= (1 << 16)) { // value >= 2^16
       if(value >= (1 << 24)) { // value >= 2^24
           msb = 24 + msbtable[value >> 24];
       } else { // 2^16 <= value < 2^24
           msb = 16 + msbtable[value >> 16];
       }
   } else { // value < 2^16
       if(value >= (1 << 8)) { // 2^8 <= value < 2^16
           msb = 8 + msbtable[value >> 8];
       } else { // value < 2^8
           msb = msbtable[value];
       }
   }

/*    // basic variant
   // now msb is the rounded down log2(value)
   // returns: 000000000000xxxx , where x msb and error < 36.9%
   return msb; */

   // extended variant
// returns: xxxxxyyyyyyyyyyy , where x msb and y approximation and error < 0.01%
   int fract = value << (31 - msb); // msb is now the highest bit in fract
   return (msb << 11)  + logtable[(fract >> 23) & 0xff];
}




_______________________________________________

linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux