Changeset 161 for libmpc/branches/r2d/libmpcenc/huffsv7.c
- Timestamp:
- 12/18/06 20:52:54 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpc/branches/r2d/libmpcenc/huffsv7.c
r78 r161 20 20 #include "libmpcenc.h" 21 21 22 Huffman_t HuffHdr [10]; // 9 bit 23 Huffman_t HuffSCFI [ 4]; // 3 bit 24 Huffman_t HuffDSCF [16]; // 6 bit 25 Huffman_t HuffQ1 [2] [ 3*3*3]; // 6+ 9 bit 26 Huffman_t HuffQ2 [2] [ 5*5]; // 7+10 bit 27 Huffman_t HuffQ3 [2] [ 7]; // 4+ 5 bit 28 Huffman_t HuffQ4 [2] [ 9]; // 4+ 5 bit 29 Huffman_t HuffQ5 [2] [15]; // 6+ 8 bit 30 Huffman_t HuffQ6 [2] [31]; // 7+13 bit 31 Huffman_t HuffQ7 [2] [63]; // 8+14 bit 32 // 4608 Bytes 33 mpc_uint8_t LUT1_0 [1<< 6]; 34 mpc_uint8_t LUT1_1 [1<< 9]; // 576 Bytes 35 mpc_uint8_t LUT2_0 [1<< 7]; 36 mpc_uint8_t LUT2_1 [1<<10]; // 1152 Bytes 37 mpc_uint8_t LUT3_0 [1<< 4]; 38 mpc_uint8_t LUT3_1 [1<< 5]; // 48 Bytes 39 mpc_uint8_t LUT4_0 [1<< 4]; 40 mpc_uint8_t LUT4_1 [1<< 5]; // 48 Bytes 41 mpc_uint8_t LUT5_0 [1<< 6]; 42 mpc_uint8_t LUT5_1 [1<< 8]; // 320 Bytes 43 mpc_uint8_t LUT6_0 [1<< 7]; 44 mpc_uint8_t LUT6_1 [1<< 7]; // 256 Bytes 45 mpc_uint8_t LUT7_0 [1<< 8]; 46 mpc_uint8_t LUT7_1 [1<< 8]; // 512 Bytes 47 mpc_uint8_t LUTDSCF [1<< 6]; // 64 Bytes = 2976 Bytes 22 const Huffman_t HuffBands [33] = { 23 {1, 1}, {1, 3}, {2, 5}, {2, 6}, {3, 7}, {3, 8}, {4, 8}, {4, 9}, {5, 10}, {6, 11}, {1, 12}, {2, 12}, {3, 12}, {0, 13}, {4, 12}, {5, 12}, {6, 12}, {7, 12}, {8, 12}, {1, 13}, {9, 12}, {10, 12}, {11, 12}, {7, 11}, {8, 11}, {9, 11}, {6, 10}, {7, 10}, {5, 9}, {5, 8}, {3, 6}, {3, 5}, {1, 2} 24 }; 25 26 const Huffman_t HuffRes [2] [17] = { 27 { 28 {1, 1}, {1, 2}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 9}, {1, 10}, {1, 11}, {1, 12}, {1, 13}, {1, 14}, {1, 15}, {0, 16}, {1, 16}, {1, 8}, {1, 3} 29 }, { 30 {1, 2}, {2, 2}, {1, 3}, {1, 5}, {1, 7}, {1, 8}, {1, 10}, {1, 12}, {0, 14}, {1, 14}, {2, 14}, {3, 14}, {1, 11}, {1, 9}, {1, 6}, {1, 4}, {3, 2} 31 } 32 }; 33 34 const Huffman_t HuffSCFI_1 [4] = { 35 {0, 3}, {1, 3}, {1, 1}, {1, 2} 36 }; 37 38 const Huffman_t HuffSCFI_2 [16] = { 39 {1, 6}, {0, 7}, {2, 6}, {3, 6}, {1, 7}, {3, 5}, {4, 5}, {5, 5}, {4, 6}, {6, 5}, {2, 2}, {2, 3}, {5, 6}, {7, 5}, {3, 3}, {3, 2} 40 }; 41 42 const Huffman_t HuffDSCF_1 [64] = { 43 {3, 12}, {4, 12}, {5, 12}, {4, 11}, {5, 11}, {6, 11}, {5, 10}, {6, 10}, {7, 10}, {8, 10}, {9, 10}, {7, 9}, {8, 9}, {9, 9}, {10, 9}, {7, 8}, {8, 8}, {9, 8}, {10, 8}, {7, 7}, {8, 7}, {9, 7}, {10, 7}, {6, 6}, {7, 6}, {5, 5}, {4, 4}, {5, 4}, {6, 5}, {6, 4}, {7, 4}, {10, 10}, {8, 4}, {5, 3}, {6, 3}, {7, 3}, {9, 4}, {7, 5}, {8, 6}, {9, 6}, {11, 7}, {11, 8}, {12, 8}, {13, 8}, {11, 9}, {12, 9}, {13, 9}, {11, 10}, {12, 10}, {13, 10}, {7, 11}, {8, 11}, {9, 11}, {6, 12}, {7, 12}, {3, 13}, {4, 13}, {5, 13}, {0, 14}, {1, 14}, {2, 14}, {3, 14}, {4, 14}, {5, 14} 44 }; 45 46 const Huffman_t HuffDSCF_2 [65] = { 47 {0, 15}, {3, 14}, {4, 14}, {4, 13}, {5, 13}, {6, 13}, {5, 12}, {6, 12}, {7, 12}, {8, 12}, {7, 11}, {8, 11}, {9, 11}, {10, 11}, {7, 10}, {8, 10}, {9, 10}, {10, 10}, {7, 9}, {8, 9}, {9, 9}, {6, 8}, {7, 8}, {5, 7}, {6, 7}, {4, 6}, {3, 5}, {3, 4}, {4, 4}, {3, 3}, {4, 3}, {5, 3}, {6, 3}, {7, 3}, {5, 4}, {4, 5}, {5, 5}, {5, 6}, {7, 7}, {8, 8}, {9, 8}, {10, 9}, {11, 9}, {11, 10}, {12, 10}, {13, 10}, {11, 11}, {12, 11}, {13, 11}, {9, 12}, {10, 12}, {11, 12}, {12, 12}, {7, 13}, {8, 13}, {9, 13}, {5, 14}, {6, 14}, {7, 14}, {1, 15}, {2, 15}, {3, 15}, {4, 15}, {5, 15}, {13, 12} 48 }; 49 50 static const Huffman_t HuffQ1 [19] = { 51 {1, 6}, {1, 4}, {2, 4}, {3, 3}, {4, 3}, {5, 3}, {6, 3}, {7, 3}, {3, 4}, {4, 4}, {5, 4}, {1, 5}, {1, 7}, {1, 8}, {1, 9}, {1, 10}, {1, 11}, {0, 12}, {1, 12} 52 }; 53 54 static const Huffman_t HuffQ2 [2] [5*5*5] = { 55 { 56 {2, 12}, {3, 11}, {15, 10}, {4, 11}, {0, 13}, {5, 11}, {12, 9}, {18, 8}, {13, 9}, {6, 11}, {7, 11}, {19, 8}, {21, 7}, {20, 8}, {8, 11}, {9, 11}, {14, 9}, {21, 8}, {15, 9}, {10, 11}, {3, 12}, {11, 11}, {16, 10}, {12, 11}, {1, 13}, {13, 11}, {16, 9}, {22, 8}, {17, 9}, {14, 11}, {18, 9}, {15, 6}, {16, 6}, {22, 7}, {19, 9}, {23, 8}, {17, 6}, {8, 4}, {18, 6}, {24, 8}, {20, 9}, {19, 6}, {20, 6}, {23, 7}, {21, 9}, {15, 11}, {22, 9}, {25, 8}, {23, 9}, {16, 11}, {17, 10}, {26, 8}, {24, 7}, {27, 8}, {18, 10}, {28, 8}, {21, 6}, {9, 4}, {22, 6}, {29, 8}, {25, 7}, {10, 4}, {7, 3}, {11, 4}, {26, 7}, {30, 8}, {23, 6}, {12, 4}, {24, 6}, {31, 8}, {19, 10}, {32, 8}, {27, 7}, {33, 8}, {20, 10}, {17, 11}, {24, 9}, {34, 8}, {25, 9}, {18, 11}, {26, 9}, {25, 6}, {26, 6}, {27, 6}, {27, 9}, {35, 8}, {28, 6}, {13, 4}, {29, 6}, {36, 8}, {28, 9}, {28, 7}, {30, 6}, {31, 6}, {29, 9}, {19, 11}, {30, 9}, {37, 8}, {31, 9}, {20, 11}, {2, 13}, {21, 11}, {21, 10}, {22, 11}, {4, 12}, {23, 11}, {32, 9}, {38, 8}, {33, 9}, {24, 11}, {22, 10}, {39, 8}, {29, 7}, {40, 8}, {25, 11}, {26, 11}, {34, 9}, {41, 8}, {35, 9}, {27, 11}, {3, 13}, {28, 11}, {23, 10}, {29, 11}, {5, 12} 57 }, { 58 {2, 11}, {3, 10}, {15, 9}, {4, 10}, {0, 12}, {5, 10}, {12, 8}, {13, 8}, {14, 8}, {6, 10}, {7, 10}, {15, 8}, {30, 7}, {16, 8}, {16, 9}, {8, 10}, {17, 8}, {18, 8}, {19, 8}, {9, 10}, {3, 11}, {10, 10}, {17, 9}, {11, 10}, {1, 12}, {12, 10}, {20, 8}, {21, 8}, {22, 8}, {13, 10}, {23, 8}, {18, 6}, {14, 5}, {19, 6}, {24, 8}, {25, 8}, {20, 6}, {15, 5}, {16, 5}, {26, 8}, {27, 8}, {21, 6}, {17, 5}, {22, 6}, {28, 8}, {14, 10}, {29, 8}, {30, 8}, {31, 8}, {15, 10}, {18, 9}, {32, 8}, {31, 7}, {33, 8}, {19, 9}, {34, 8}, {18, 5}, {19, 5}, {20, 5}, {35, 8}, {32, 7}, {21, 5}, {15, 4}, {22, 5}, {33, 7}, {36, 8}, {23, 5}, {24, 5}, {25, 5}, {37, 8}, {20, 9}, {38, 8}, {34, 7}, {39, 8}, {21, 9}, {16, 10}, {40, 8}, {41, 8}, {42, 8}, {17, 10}, {43, 8}, {23, 6}, {26, 5}, {24, 6}, {44, 8}, {45, 8}, {27, 5}, {28, 5}, {25, 6}, {46, 8}, {47, 8}, {26, 6}, {29, 5}, {27, 6}, {48, 8}, {18, 10}, {49, 8}, {50, 8}, {51, 8}, {19, 10}, {2, 12}, {20, 10}, {21, 10}, {22, 10}, {4, 11}, {23, 10}, {52, 8}, {53, 8}, {54, 8}, {24, 10}, {22, 9}, {55, 8}, {35, 7}, {56, 8}, {25, 10}, {26, 10}, {57, 8}, {58, 8}, {59, 8}, {27, 10}, {3, 12}, {28, 10}, {23, 9}, {29, 10}, {5, 11} 59 } 60 }; 61 62 static const Huffman_t HuffQ3 [49] = { 63 {0, 9}, {2, 8}, {5, 7}, {6, 7}, {7, 7}, {3, 8}, {1, 9}, {4, 8}, {9, 6}, {10, 6}, {10, 5}, {11, 6}, {8, 7}, {5, 8}, {9, 7}, {12, 6}, {8, 4}, {9, 4}, {11, 5}, {13, 6}, {10, 7}, {11, 7}, {12, 5}, {10, 4}, {7, 3}, {11, 4}, {13, 5}, {12, 7}, {13, 7}, {14, 6}, {14, 5}, {12, 4}, {13, 4}, {15, 6}, {14, 7}, {6, 8}, {16, 6}, {17, 6}, {15, 5}, {18, 6}, {19, 6}, {7, 8}, {2, 9}, {8, 8}, {15, 7}, {16, 7}, {17, 7}, {9, 8}, {3, 9} 64 }; 65 66 static const Huffman_t HuffQ4 [81] = { 67 {0, 10}, {2, 9}, {5, 8}, {12, 7}, {13, 7}, {6, 8}, {7, 8}, {3, 9}, {1, 10}, {4, 9}, {8, 8}, {14, 7}, {13, 6}, {14, 6}, {15, 6}, {15, 7}, {9, 8}, {5, 9}, {10, 8}, {16, 7}, {16, 6}, {17, 6}, {18, 5}, {18, 6}, {19, 6}, {17, 7}, {11, 8}, {12, 8}, {20, 6}, {21, 6}, {19, 5}, {20, 5}, {21, 5}, {22, 6}, {23, 6}, {13, 8}, {18, 7}, {24, 6}, {22, 5}, {23, 5}, {15, 4}, {24, 5}, {25, 5}, {25, 6}, {19, 7}, {14, 8}, {26, 6}, {27, 6}, {26, 5}, {27, 5}, {28, 5}, {28, 6}, {29, 6}, {15, 8}, {16, 8}, {20, 7}, {30, 6}, {31, 6}, {29, 5}, {32, 6}, {33, 6}, {21, 7}, {17, 8}, {6, 9}, {18, 8}, {22, 7}, {23, 7}, {34, 6}, {35, 6}, {24, 7}, {19, 8}, {7, 9}, {2, 10}, {8, 9}, {20, 8}, {21, 8}, {25, 7}, {22, 8}, {23, 8}, {9, 9}, {3, 10} 68 }; 69 70 static const Huffman_t HuffQ5 [2] [15] = { 71 { 72 {0, 7}, {1, 7}, {2, 6}, {2, 5}, {2, 4}, {2, 3}, {3, 3}, {3, 2}, {4, 3}, {5, 3}, {3, 4}, {3, 5}, {3, 6}, {2, 7}, {3, 7} 73 }, { 74 {0, 6}, {1, 6}, {2, 5}, {2, 4}, {3, 4}, {3, 3}, {4, 3}, {5, 3}, {6, 3}, {7, 3}, {4, 4}, {5, 4}, {3, 5}, {2, 6}, {3, 6} 75 } 76 }; 77 78 static const Huffman_t HuffQ6 [2] [31] = { 79 { 80 {0, 9}, {1, 9}, {2, 9}, {3, 9}, {4, 8}, {5, 8}, {4, 7}, {3, 6}, {4, 6}, {5, 6}, {5, 5}, {6, 5}, {4, 4}, {5, 4}, {4, 3}, {3, 2}, {5, 3}, {6, 4}, {7, 4}, {7, 5}, {6, 6}, {7, 6}, {8, 6}, {9, 6}, {5, 7}, {6, 8}, {7, 8}, {4, 9}, {5, 9}, {6, 9}, {7, 9} 81 }, { 82 {0, 8}, {1, 8}, {2, 7}, {3, 7}, {4, 7}, {4, 6}, {5, 6}, {4, 5}, {5, 5}, {6, 5}, {5, 4}, {6, 4}, {7, 4}, {8, 4}, {9, 4}, {10, 4}, {11, 4}, {12, 4}, {13, 4}, {14, 4}, {15, 4}, {7, 5}, {8, 5}, {9, 5}, {6, 6}, {7, 6}, {5, 7}, {6, 7}, {7, 7}, {2, 8}, {3, 8} 83 } 84 }; 85 86 static const Huffman_t HuffQ7 [2] [63] = { 87 { 88 {0, 10}, {1, 10}, {2, 10}, {8, 9}, {9, 9}, {3, 10}, {4, 10}, {5, 10}, {6, 10}, {7, 10}, {10, 9}, {11, 9}, {12, 9}, {13, 9}, {10, 8}, {11, 8}, {12, 8}, {13, 8}, {14, 8}, {10, 7}, {11, 7}, {12, 7}, {13, 7}, {14, 7}, {10, 6}, {11, 6}, {12, 6}, {8, 5}, {9, 5}, {6, 4}, {4, 3}, {3, 2}, {5, 3}, {7, 4}, {10, 5}, {11, 5}, {13, 6}, {14, 6}, {15, 6}, {15, 7}, {16, 7}, {17, 7}, {18, 7}, {15, 8}, {19, 7}, {16, 8}, {17, 8}, {18, 8}, {19, 8}, {14, 9}, {15, 9}, {16, 9}, {17, 9}, {8, 10}, {9, 10}, {10, 10}, {11, 10}, {12, 10}, {18, 9}, {19, 9}, {13, 10}, {14, 10}, {15, 10} 89 }, { 90 {0, 9}, {1, 9}, {2, 8}, {3, 8}, {4, 8}, {5, 8}, {6, 8}, {7, 8}, {8, 8}, {8, 7}, {9, 7}, {10, 7}, {11, 7}, {12, 7}, {9, 6}, {10, 6}, {11, 6}, {12, 6}, {13, 6}, {14, 6}, {15, 6}, {16, 6}, {12, 5}, {13, 5}, {14, 5}, {15, 5}, {16, 5}, {17, 5}, {18, 5}, {19, 5}, {20, 5}, {21, 5}, {22, 5}, {23, 5}, {24, 5}, {25, 5}, {26, 5}, {27, 5}, {28, 5}, {29, 5}, {30, 5}, {31, 5}, {17, 6}, {18, 6}, {19, 6}, {20, 6}, {21, 6}, {22, 6}, {23, 6}, {13, 7}, {14, 7}, {15, 7}, {16, 7}, {17, 7}, {9, 8}, {10, 8}, {11, 8}, {12, 8}, {13, 8}, {14, 8}, {15, 8}, {2, 9}, {3, 9} 91 } 92 }; 93 94 static const Huffman_t HuffQ8 [2] [127] = { 95 { 96 {3, 11}, {4, 11}, {10, 10}, {11, 10}, {12, 10}, {13, 10}, {14, 10}, {26, 9}, {15, 10}, {27, 9}, {16, 10}, {0, 12}, {1, 12}, {5, 11}, {6, 11}, {7, 11}, {8, 11}, {9, 11}, {10, 11}, {11, 11}, {17, 10}, {12, 11}, {18, 10}, {19, 10}, {20, 10}, {21, 10}, {22, 10}, {23, 10}, {24, 10}, {25, 10}, {28, 9}, {26, 10}, {27, 10}, {28, 10}, {29, 10}, {30, 10}, {29, 9}, {30, 9}, {31, 9}, {32, 9}, {33, 9}, {34, 9}, {35, 9}, {36, 9}, {25, 8}, {37, 9}, {26, 8}, {27, 8}, {28, 8}, {29, 8}, {30, 8}, {31, 8}, {20, 7}, {21, 7}, {22, 7}, {23, 7}, {14, 6}, {15, 6}, {16, 6}, {17, 6}, {11, 5}, {7, 4}, {4, 3}, {3, 2}, {5, 3}, {12, 5}, {13, 5}, {18, 6}, {19, 6}, {20, 6}, {21, 6}, {24, 7}, {25, 7}, {26, 7}, {27, 7}, {32, 8}, {33, 8}, {34, 8}, {35, 8}, {36, 8}, {37, 8}, {38, 8}, {39, 8}, {38, 9}, {39, 9}, {40, 9}, {41, 9}, {42, 9}, {43, 9}, {44, 9}, {45, 9}, {46, 9}, {31, 10}, {32, 10}, {47, 9}, {33, 10}, {34, 10}, {35, 10}, {36, 10}, {37, 10}, {38, 10}, {39, 10}, {40, 10}, {41, 10}, {13, 11}, {14, 11}, {42, 10}, {15, 11}, {16, 11}, {17, 11}, {18, 11}, {2, 12}, {19, 11}, {3, 12}, {4, 12}, {5, 12}, {43, 10}, {44, 10}, {48, 9}, {49, 9}, {45, 10}, {46, 10}, {47, 10}, {48, 10}, {49, 10}, {50, 10}, {51, 10} 97 }, { 98 {0, 9}, {1, 9}, {2, 9}, {3, 9}, {4, 8}, {5, 8}, {6, 8}, {7, 8}, {8, 8}, {9, 8}, {10, 8}, {11, 8}, {12, 8}, {13, 8}, {14, 8}, {15, 8}, {16, 8}, {17, 8}, {18, 8}, {19, 8}, {20, 8}, {21, 8}, {21, 7}, {22, 7}, {23, 7}, {24, 7}, {25, 7}, {26, 7}, {27, 7}, {28, 7}, {29, 7}, {30, 7}, {31, 7}, {32, 7}, {33, 7}, {34, 7}, {35, 7}, {36, 7}, {37, 7}, {38, 7}, {39, 7}, {40, 7}, {41, 7}, {42, 7}, {43, 7}, {44, 7}, {45, 7}, {46, 7}, {47, 7}, {48, 7}, {38, 6}, {39, 6}, {40, 6}, {41, 6}, {42, 6}, {43, 6}, {44, 6}, {45, 6}, {46, 6}, {47, 6}, {48, 6}, {49, 6}, {50, 6}, {51, 6}, {52, 6}, {53, 6}, {54, 6}, {55, 6}, {56, 6}, {57, 6}, {58, 6}, {59, 6}, {60, 6}, {61, 6}, {62, 6}, {49, 7}, {63, 6}, {50, 7}, {51, 7}, {52, 7}, {53, 7}, {54, 7}, {55, 7}, {56, 7}, {57, 7}, {58, 7}, {59, 7}, {60, 7}, {61, 7}, {62, 7}, {63, 7}, {64, 7}, {65, 7}, {66, 7}, {67, 7}, {68, 7}, {69, 7}, {70, 7}, {71, 7}, {72, 7}, {73, 7}, {74, 7}, {75, 7}, {22, 8}, {23, 8}, {24, 8}, {25, 8}, {26, 8}, {27, 8}, {28, 8}, {29, 8}, {30, 8}, {31, 8}, {32, 8}, {33, 8}, {34, 8}, {35, 8}, {36, 8}, {37, 8}, {38, 8}, {39, 8}, {40, 8}, {41, 8}, {4, 9}, {5, 9}, {6, 9}, {7, 9} 99 } 100 }; 101 102 const Huffman_t HuffQ9up [256] = { 103 {1, 10}, {2, 10}, {3, 10}, {4, 10}, {5, 10}, {5, 9}, {6, 9}, {7, 9}, {8, 9}, {9, 9}, {10, 9}, {11, 9}, {12, 9}, {13, 9}, {14, 9}, {15, 9}, {16, 9}, {17, 9}, {18, 9}, {38, 8}, {39, 8}, {19, 9}, {20, 9}, {21, 9}, {22, 9}, {23, 9}, {24, 9}, {25, 9}, {26, 9}, {27, 9}, {28, 9}, {29, 9}, {30, 9}, {31, 9}, {32, 9}, {33, 9}, {34, 9}, {35, 9}, {36, 9}, {37, 9}, {40, 8}, {38, 9}, {41, 8}, {42, 8}, {43, 8}, {44, 8}, {45, 8}, {46, 8}, {47, 8}, {48, 8}, {49, 8}, {50, 8}, {51, 8}, {52, 8}, {53, 8}, {54, 8}, {55, 8}, {56, 8}, {57, 8}, {58, 8}, {59, 8}, {60, 8}, {61, 8}, {62, 8}, {63, 8}, {64, 8}, {65, 8}, {66, 8}, {67, 8}, {68, 8}, {69, 8}, {70, 8}, {71, 8}, {72, 8}, {73, 8}, {74, 8}, {75, 8}, {76, 8}, {77, 8}, {78, 8}, {79, 8}, {80, 8}, {81, 8}, {82, 8}, {83, 8}, {84, 8}, {85, 8}, {86, 8}, {87, 8}, {88, 8}, {89, 8}, {90, 8}, {91, 8}, {92, 8}, {93, 8}, {94, 8}, {95, 8}, {96, 8}, {97, 8}, {98, 8}, {99, 8}, {100, 8}, {101, 8}, {102, 8}, {103, 8}, {104, 8}, {105, 8}, {106, 8}, {86, 7}, {87, 7}, {88, 7}, {89, 7}, {90, 7}, {91, 7}, {92, 7}, {93, 7}, {94, 7}, {95, 7}, {96, 7}, {97, 7}, {98, 7}, {99, 7}, {100, 7}, {101, 7}, {102, 7}, {103, 7}, {104, 7}, {62, 6}, {63, 6}, {105, 7}, {106, 7}, {107, 7}, {108, 7}, {109, 7}, {110, 7}, {111, 7}, {112, 7}, {113, 7}, {114, 7}, {115, 7}, {116, 7}, {117, 7}, {118, 7}, {119, 7}, {120, 7}, {121, 7}, {122, 7}, {107, 8}, {123, 7}, {108, 8}, {109, 8}, {110, 8}, {111, 8}, {112, 8}, {113, 8}, {114, 8}, {115, 8}, {116, 8}, {117, 8}, {118, 8}, {119, 8}, {120, 8}, {121, 8}, {122, 8}, {123, 8}, {124, 8}, {125, 8}, {126, 8}, {127, 8}, {128, 8}, {129, 8}, {130, 8}, {131, 8}, {132, 8}, {133, 8}, {134, 8}, {135, 8}, {136, 8}, {137, 8}, {138, 8}, {139, 8}, {140, 8}, {141, 8}, {142, 8}, {143, 8}, {144, 8}, {145, 8}, {146, 8}, {147, 8}, {148, 8}, {149, 8}, {150, 8}, {151, 8}, {152, 8}, {153, 8}, {154, 8}, {155, 8}, {156, 8}, {157, 8}, {158, 8}, {159, 8}, {160, 8}, {161, 8}, {162, 8}, {163, 8}, {164, 8}, {165, 8}, {166, 8}, {167, 8}, {168, 8}, {169, 8}, {170, 8}, {171, 8}, {39, 9}, {40, 9}, {41, 9}, {42, 9}, {43, 9}, {44, 9}, {45, 9}, {46, 9}, {47, 9}, {48, 9}, {49, 9}, {50, 9}, {51, 9}, {52, 9}, {53, 9}, {54, 9}, {55, 9}, {56, 9}, {57, 9}, {58, 9}, {59, 9}, {60, 9}, {61, 9}, {62, 9}, {63, 9}, {64, 9}, {65, 9}, {66, 9}, {67, 9}, {68, 9}, {69, 9}, {70, 9}, {71, 9}, {72, 9}, {73, 9}, {74, 9}, {75, 9}, {6, 10}, {7, 10}, {8, 10}, {9, 10}, {0, 11}, {1, 11} 104 }; 48 105 49 106 const Huffman_t* HuffQ [2] [8] = { 50 { NULL, HuffQ1[0], HuffQ2[0], HuffQ3[0], HuffQ4[0], HuffQ5[0], HuffQ6[0], HuffQ7[0] },51 { NULL, HuffQ1[1], HuffQ2[1], HuffQ3[1], HuffQ4[1], HuffQ5[1], HuffQ6[1], HuffQ7[1] }107 { HuffQ1, HuffQ2[0], HuffQ3, HuffQ4, HuffQ5[0], HuffQ6[0], HuffQ7[0], HuffQ8[0] }, 108 { HuffQ1, HuffQ2[1], HuffQ3, HuffQ4, HuffQ5[1], HuffQ6[1], HuffQ7[1], HuffQ8[1] } 52 109 }; 53 110 54 #ifdef USE_SV855 Huffman_t HuffN3 [2] [ 7*7]; // 8+ 9 bit56 Huffman_t HuffN8 [2][127]; //13+12 bit57 58 const Huffman_t* HuffN [2] [9] = {59 { NULL, HuffQ1[0], HuffQ2[0], HuffN3[0], HuffQ4[0], HuffQ5[0], HuffQ6[0], HuffQ7[0], HuffN8[0] },60 { NULL, HuffQ1[1], HuffQ2[1], HuffN3[1], HuffQ4[1], HuffQ5[1], HuffQ6[1], HuffQ7[1], HuffN8[1] }61 };62 #endif63 64 static const Huffman_t HuffSCFI_src [4] = {65 { 2, 3 }, { 1, 1 }, { 3, 3 }, { 0, 2 }66 };67 68 static const Huffman_t HuffDSCF_src [16] = {69 { 32, 6 }, { 4, 5 }, { 17, 5 }, { 30, 5 }, { 13, 4 }, { 0, 3 }, { 3, 3 }, { 9, 4 },70 { 5, 3 }, { 2, 3 }, { 14, 4 }, { 3, 4 }, { 31, 5 }, { 5, 5 }, { 33, 6 }, { 12, 4 }71 };72 73 static const Huffman_t HuffHdr_src [10] = {74 { 92, 8 }, { 47, 7 }, { 10, 5 }, { 4, 4 }, { 0, 2 },75 { 1, 1 }, { 3, 3 }, { 22, 6 }, { 187, 9 }, { 186, 9 }76 };77 78 static const Huffman_t HuffQ1_src [2] [3*3*3] = { {79 { 54, 6 }, { 9, 5 }, { 32, 6 }, { 5, 5 }, { 10, 4 }, { 7, 5 }, { 52, 6 }, { 0, 5 }, { 35, 6 },80 { 10, 5 }, { 6, 4 }, { 4, 5 }, { 11, 4 }, { 7, 3 }, { 12, 4 }, { 3, 5 }, { 7, 4 }, { 11, 5 },81 { 34, 6 }, { 1, 5 }, { 53, 6 }, { 6, 5 }, { 9, 4 }, { 2, 5 }, { 33, 6 }, { 8, 5 }, { 55, 6 }82 }, {83 { 103, 8 }, { 62, 7 }, { 225, 9 }, { 55, 7 }, { 3, 4 }, { 52, 7 }, { 101, 8 }, { 60, 7 }, { 227, 9 },84 { 24, 6 }, { 0, 4 }, { 61, 7 }, { 4, 4 }, { 1, 1 }, { 5, 4 }, { 63, 7 }, { 1, 4 }, { 59, 7 },85 { 226, 9 }, { 57, 7 }, { 100, 8 }, { 53, 7 }, { 2, 4 }, { 54, 7 }, { 224, 9 }, { 58, 7 }, { 102, 8 }86 } };87 88 static const Huffman_t HuffQ2_src [2] [5*5] = { {89 { 89, 7 }, { 47, 6 }, { 15, 5 }, { 0, 5 }, { 91, 7 },90 { 4, 5 }, { 6, 4 }, { 13, 4 }, { 4, 4 }, { 5, 5 },91 { 20, 5 }, { 12, 4 }, { 4, 3 }, { 15, 4 }, { 14, 5 },92 { 3, 5 }, { 3, 4 }, { 14, 4 }, { 5, 4 }, { 1, 5 },93 { 90, 7 }, { 2, 5 }, { 21, 5 }, { 46, 6 }, { 88, 7 }94 }, {95 { 921, 10 }, { 113, 7 }, { 51, 6 }, { 231, 8 }, { 922, 10 },96 { 104, 7 }, { 30, 5 }, { 0, 3 }, { 29, 5 }, { 105, 7 },97 { 50, 6 }, { 1, 3 }, { 2, 2 }, { 3, 3 }, { 49, 6 },98 { 107, 7 }, { 27, 5 }, { 2, 3 }, { 31, 5 }, { 112, 7 },99 { 920, 10 }, { 106, 7 }, { 48, 6 }, { 114, 7 }, { 923, 10 }100 } };101 102 #ifdef USE_SV8103 static const Huffman_t HuffN3_src [2] [7*7] = { {104 { 78, 7 }, { 20, 6 }, { 36, 6 }, { 51, 6 }, { 21, 6 }, { 101, 7 }, { 255, 8 },105 { 37, 6 }, { 0, 5 }, { 62, 6 }, { 7, 5 }, { 60, 6 }, { 49, 6 }, { 100, 7 },106 { 30, 6 }, { 53, 6 }, { 8, 5 }, { 14, 5 }, { 5, 5 }, { 54, 6 }, { 26, 6 },107 { 43, 6 }, { 1, 5 }, { 20, 5 }, { 14, 4 }, { 22, 5 }, { 9, 5 }, { 46, 6 },108 { 47, 6 }, { 61, 6 }, { 17, 5 }, { 16, 5 }, { 11, 5 }, { 4, 5 }, { 38, 6 },109 { 6, 6 }, { 52, 6 }, { 6, 5 }, { 12, 5 }, { 2, 5 }, { 55, 6 }, { 27, 6 },110 { 254, 8 }, { 126, 7 }, { 31, 6 }, { 48, 6 }, { 42, 6 }, { 7, 6 }, { 79, 7 }111 }, {112 { 65, 9 }, { 161, 8 }, { 109, 7 }, { 11, 6 }, { 116, 7 }, { 160, 8 }, { 71, 9 },113 { 34, 8 }, { 97, 7 }, { 56, 6 }, { 8, 5 }, { 55, 6 }, { 85, 7 }, { 166, 8 },114 { 84, 7 }, { 52, 6 }, { 3, 4 }, { 11, 4 }, { 5, 4 }, { 59, 6 }, { 86, 7 },115 { 10, 6 }, { 13, 5 }, { 9, 4 }, { 0, 3 }, { 8, 4 }, { 12, 5 }, { 9, 6 },116 { 98, 7 }, { 51, 6 }, { 31, 5 }, { 7, 4 }, { 30, 5 }, { 53, 6 }, { 99, 7 },117 { 162, 8 }, { 108, 7 }, { 50, 6 }, { 9, 5 }, { 57, 6 }, { 82, 7 }, { 163, 8 },118 { 64, 9 }, { 167, 8 }, { 87, 7 }, { 117, 7 }, { 96, 7 }, { 33, 8 }, { 70, 9 }119 } };120 #endif121 122 static const Huffman_t HuffQ3_src [2] [ 7] = { {123 { 12, 4 }, { 4, 3 }, { 0, 2 }, { 1, 2 }, { 7, 3 }, { 5, 3 }, { 13, 4 }124 }, {125 { 4, 5 }, { 3, 4 }, { 2, 2 }, { 3, 2 }, { 1, 2 }, { 0, 3 }, { 5, 5 }126 } };127 128 static const Huffman_t HuffQ4_src [2] [ 9] = { {129 { 5, 4 }, { 0, 3 }, { 4, 3 }, { 6, 3 }, { 7, 3 }, { 5, 3 }, { 3, 3 }, { 1, 3 }, { 4, 4 }130 }, {131 { 9, 5 }, { 12, 4 }, { 3, 3 }, { 0, 2 }, { 2, 2 }, { 7, 3 }, { 13, 4 }, { 5, 4 }, { 8, 5 }132 } };133 134 static const Huffman_t HuffQ5_src [2] [15] = { {135 { 57, 6 }, { 23, 5 }, { 8, 4 }, { 10, 4 }, { 13, 4 }, { 0, 3 }, { 2, 3 }, { 3, 3 },136 { 1, 3 }, { 15, 4 }, { 12, 4 }, { 9, 4 }, { 29, 5 }, { 22, 5 }, { 56, 6 }137 }, {138 { 229, 8 }, { 56, 6 }, { 7, 5 }, { 2, 4 }, { 0, 3 }, { 3, 3 }, { 5, 3 }, { 6, 3 },139 { 4, 3 }, { 2, 3 }, { 15, 4 }, { 29, 5 }, { 6, 5 }, { 115, 7 }, { 228, 8 },140 } };141 142 static const Huffman_t HuffQ6_src [2] [31] = { {143 { 65, 7 }, { 6, 6 }, { 44, 6 }, { 45, 6 }, { 59, 6 }, { 13, 5 }, { 17, 5 }, { 19, 5 },144 { 23, 5 }, { 21, 5 }, { 26, 5 }, { 30, 5 }, { 0, 4 }, { 2, 4 }, { 5, 4 }, { 7, 4 },145 { 3, 4 }, { 4, 4 }, { 31, 5 }, { 28, 5 }, { 25, 5 }, { 27, 5 }, { 24, 5 }, { 20, 5 },146 { 18, 5 }, { 12, 5 }, { 2, 5 }, { 58, 6 }, { 33, 6 }, { 7, 6 }, { 64, 7 },147 }, {148 { 6472, 13 }, { 6474, 13 }, { 808, 10 }, { 405, 9 }, { 203, 8 }, { 102, 7 }, { 49, 6 }, { 9, 5 },149 { 15, 5 }, { 31, 5 }, { 2, 4 }, { 6, 4 }, { 8, 4 }, { 11, 4 }, { 13, 4 }, { 0, 3 },150 { 14, 4 }, { 10, 4 }, { 9, 4 }, { 5, 4 }, { 3, 4 }, { 30, 5 }, { 14, 5 }, { 8, 5 },151 { 48, 6 }, { 103, 7 }, { 201, 8 }, { 200, 8 }, { 1619, 11 }, { 6473, 13 }, { 6475, 13 },152 } };153 154 static const Huffman_t HuffQ7_src [2] [63] = { {155 { 103, 8 }, // 0.3338 01100111156 { 153, 8 }, // 0.3766 10011001157 { 181, 8 }, // 0.4715 10110101158 { 233, 8 }, // 0.5528 11101001159 { 64, 7 }, // 0.6677 1000000160 { 65, 7 }, // 0.7041 1000001161 { 77, 7 }, // 0.7733 1001101162 { 81, 7 }, // 0.8296 1010001163 { 91, 7 }, // 0.9295 1011011164 { 113, 7 }, // 1.0814 1110001165 { 112, 7 }, // 1.0807 1110000166 { 24, 6 }, // 1.2748 011000167 { 29, 6 }, // 1.3390 011101168 { 35, 6 }, // 1.4224 100011169 { 37, 6 }, // 1.5201 100101170 { 41, 6 }, // 1.6642 101001171 { 44, 6 }, // 1.7292 101100172 { 46, 6 }, // 1.8647 101110173 { 51, 6 }, // 2.0473 110011174 { 49, 6 }, // 2.0152 110001175 { 54, 6 }, // 2.1315 110110176 { 55, 6 }, // 2.1358 110111177 { 57, 6 }, // 2.1700 111001178 { 60, 6 }, // 2.2449 111100179 { 0, 5 }, // 2.3063 00000180 { 2, 5 }, // 2.3854 00010181 { 10, 5 }, // 2.5481 01010182 { 5, 5 }, // 2.4867 00101183 { 9, 5 }, // 2.5352 01001184 { 6, 5 }, // 2.5074 00110185 { 13, 5 }, // 2.5745 01101186 { 7, 5 }, // 2.5195 00111187 { 11, 5 }, // 2.5502 01011188 { 15, 5 }, // 2.6251 01111189 { 8, 5 }, // 2.5260 01000190 { 4, 5 }, // 2.4418 00100191 { 3, 5 }, // 2.3983 00011192 { 1, 5 }, // 2.3697 00001193 { 63, 6 }, // 2.3041 111111194 { 62, 6 }, // 2.2656 111110195 { 61, 6 }, // 2.2549 111101196 { 53, 6 }, // 2.1151 110101197 { 59, 6 }, // 2.2042 111011198 { 52, 6 }, // 2.0837 110100199 { 48, 6 }, // 1.9446 110000200 { 47, 6 }, // 1.9189 101111201 { 43, 6 }, // 1.7177 101011202 { 42, 6 }, // 1.7035 101010203 { 39, 6 }, // 1.5287 100111204 { 36, 6 }, // 1.4559 100100205 { 33, 6 }, // 1.4117 100001206 { 28, 6 }, // 1.2776 011100207 { 117, 7 }, // 1.1107 1110101208 { 101, 7 }, // 1.0636 1100101209 { 100, 7 }, // 0.9751 1100100210 { 80, 7 }, // 0.8132 1010000211 { 69, 7 }, // 0.7091 1000101212 { 68, 7 }, // 0.7084 1000100213 { 50, 7 }, // 0.6277 0110010214 { 232, 8 }, // 0.5386 11101000215 { 180, 8 }, // 0.4408 10110100216 { 152, 8 }, // 0.3759 10011000217 { 102, 8 }, // 0.3160 01100110218 }, {219 { 14244, 14 }, // 0.0059 11011110100100220 { 14253, 14 }, // 0.0098 11011110101101221 { 14246, 14 }, // 0.0078 11011110100110222 { 14254, 14 }, // 0.0111 11011110101110223 { 3562, 12 }, // 0.0320 110111101010224 { 752, 10 }, // 0.0920 1011110000225 { 753, 10 }, // 0.1057 1011110001226 { 160, 9 }, // 0.1403 010100000227 { 162, 9 }, // 0.1579 010100010228 { 444, 9 }, // 0.2486 110111100229 { 122, 8 }, // 0.3772 01111010230 { 223, 8 }, // 0.5710 11011111231 { 60, 7 }, // 0.6858 0111100232 { 73, 7 }, // 0.8033 1001001233 { 110, 7 }, // 0.9827 1101110234 { 14, 6 }, // 1.2601 001110235 { 24, 6 }, // 1.3194 011000236 { 25, 6 }, // 1.3938 011001237 { 34, 6 }, // 1.5693 100010238 { 37, 6 }, // 1.7846 100101239 { 54, 6 }, // 2.0078 110110240 { 3, 5 }, // 2.2975 00011241 { 9, 5 }, // 2.5631 01001242 { 11, 5 }, // 2.7021 01011243 { 16, 5 }, // 3.1465 10000244 { 19, 5 }, // 3.4244 10011245 { 21, 5 }, // 3.5921 10101246 { 24, 5 }, // 3.7938 11000247 { 26, 5 }, // 3.9595 11010248 { 29, 5 }, // 4.1546 11101249 { 31, 5 }, // 4.2623 11111250 { 2, 4 }, // 4.5180 0010251 { 0, 4 }, // 4.3151 0000252 { 30, 5 }, // 4.2538 11110253 { 28, 5 }, // 4.1422 11100254 { 25, 5 }, // 3.9145 11001255 { 22, 5 }, // 3.6691 10110256 { 20, 5 }, // 3.4955 10100257 { 14, 5 }, // 2.9155 01110258 { 13, 5 }, // 2.7921 01101259 { 8, 5 }, // 2.5553 01000260 { 6, 5 }, // 2.3093 00110261 { 2, 5 }, // 2.1200 00010262 { 46, 6 }, // 1.8134 101110263 { 35, 6 }, // 1.5824 100011264 { 31, 6 }, // 1.4701 011111265 { 21, 6 }, // 1.3187 010101266 { 15, 6 }, // 1.2776 001111267 { 95, 7 }, // 0.9664 1011111268 { 72, 7 }, // 0.7922 1001000269 { 41, 7 }, // 0.6838 0101001270 { 189, 8 }, // 0.5024 10111101271 { 123, 8 }, // 0.3830 01111011272 { 377, 9 }, // 0.2232 101111001273 { 161, 9 }, // 0.1566 010100001274 { 891, 10 }, // 0.1383 1101111011275 { 327, 10 }, // 0.0900 0101000111276 { 326, 10 }, // 0.0790 0101000110277 { 3560, 12 }, // 0.0254 110111101000278 { 14255, 14 }, // 0.0117 11011110101111279 { 14247, 14 }, // 0.0085 11011110100111280 { 14252, 14 }, // 0.0085 11011110101100281 { 14245, 14 }, // 0.0065 11011110100101282 } };283 284 #ifdef USE_SV8285 static const Huffman_t HuffN8_src [2] [127] = { {286 { 2426, 13 }, { 4943, 13 }, { 787, 12 }, { 2470, 12 }, { 7270, 13 }, { 1764, 12 },287 { 3632, 12 }, { 3633, 12 }, { 2486, 12 }, { 395, 11 }, { 607, 11 }, { 1242, 11 },288 { 108, 10 }, { 300, 10 }, { 199, 10 }, { 440, 10 }, { 442, 10 }, { 616, 10 },289 { 909, 10 }, { 897, 10 }, { 178, 9 }, { 309, 9 }, { 311, 9 }, { 451, 9 },290 { 449, 9 }, { 26, 8 }, { 74, 8 }, { 94, 8 }, { 122, 8 }, { 136, 8 },291 { 12, 7 }, { 29, 7 }, { 28, 7 }, { 36, 7 }, { 39, 7 }, { 46, 7 },292 { 60, 7 }, { 69, 7 }, { 76, 7 }, { 92, 7 }, { 126, 7 }, { 11, 6 },293 { 15, 6 }, { 10, 6 }, { 16, 6 }, { 21, 6 }, { 25, 6 }, { 28, 6 },294 { 32, 6 }, { 31, 6 }, { 37, 6 }, { 47, 6 }, { 43, 6 }, { 35, 6 },295 { 45, 6 }, { 48, 6 }, { 52, 6 }, { 53, 6 }, { 54, 6 }, { 62, 6 },296 { 59, 6 }, { 0, 5 }, { 61, 6 }, { 51, 6 }, { 2, 5 }, { 1, 5 },297 { 60, 6 }, { 57, 6 }, { 58, 6 }, { 55, 6 }, { 50, 6 }, { 49, 6 },298 { 42, 6 }, { 40, 6 }, { 44, 6 }, { 41, 6 }, { 39, 6 }, { 33, 6 },299 { 29, 6 }, { 26, 6 }, { 24, 6 }, { 20, 6 }, { 17, 6 }, { 13, 6 },300 { 8, 6 }, { 9, 6 }, { 127, 7 }, { 93, 7 }, { 73, 7 }, { 72, 7 },301 { 54, 7 }, { 38, 7 }, { 45, 7 }, { 14, 7 }, { 25, 7 }, { 15, 7 },302 { 226, 8 }, { 137, 8 }, { 111, 8 }, { 95, 8 }, { 88, 8 }, { 48, 8 },303 { 455, 9 }, { 450, 9 }, { 246, 9 }, { 247, 9 }, { 179, 9 }, { 55, 9 },304 { 896, 10 }, { 620, 10 }, { 443, 10 }, { 302, 10 }, { 301, 10 }, { 198, 10 },305 { 109, 10 }, { 1234, 11 }, { 883, 11 }, { 392, 11 }, { 394, 11 }, { 3634, 12 },306 { 2487, 12 }, { 786, 12 }, { 1765, 12 }, { 1212, 12 }, { 7271, 13 }, { 2427, 13 },307 { 4942, 13 }308 }, {309 { 3728, 12 }, { 4005, 12 }, { 264, 11 }, { 4004, 12 }, { 4044, 12 }, { 4045, 12 },310 { 4046, 12 }, { 1424, 11 }, { 449, 11 }, { 448, 11 }, { 139, 10 }, { 231, 10 },311 { 133, 10 }, { 719, 10 }, { 641, 10 }, { 676, 10 }, { 225, 10 }, { 677, 10 },312 { 620, 10 }, { 72, 9 }, { 23, 9 }, { 67, 9 }, { 75, 9 }, { 113, 9 },313 { 311, 9 }, { 68, 9 }, { 316, 9 }, { 467, 9 }, { 10, 8 }, { 468, 9 },314 { 35, 8 }, { 27, 8 }, { 358, 9 }, { 32, 8 }, { 26, 8 }, { 501, 9 },315 { 44, 8 }, { 45, 8 }, { 142, 8 }, { 173, 8 }, { 161, 8 }, { 188, 8 },316 { 189, 8 }, { 190, 8 }, { 191, 8 }, { 254, 8 }, { 251, 8 }, { 255, 8 },317 { 19, 7 }, { 26, 7 }, { 70, 7 }, { 76, 7 }, { 87, 7 }, { 85, 7 },318 { 124, 7 }, { 7, 6 }, { 15, 6 }, { 41, 6 }, { 46, 6 }, { 2, 5 },319 { 16, 5 }, { 28, 5 }, { 12, 4 }, { 1, 2 }, { 13, 4 }, { 30, 5 },320 { 18, 5 }, { 0, 5 }, { 45, 6 }, { 34, 6 }, { 12, 6 }, { 3, 6 },321 { 118, 7 }, { 88, 7 }, { 81, 7 }, { 29, 7 }, { 78, 7 }, { 23, 7 },322 { 27, 7 }, { 253, 8 }, { 12, 7 }, { 232, 8 }, { 235, 8 }, { 159, 8 },323 { 238, 8 }, { 172, 8 }, { 168, 8 }, { 143, 8 }, { 154, 8 }, { 40, 8 },324 { 8, 8 }, { 478, 9 }, { 9, 8 }, { 479, 9 }, { 469, 9 }, { 42, 8 },325 { 43, 8 }, { 504, 9 }, { 357, 9 }, { 321, 9 }, { 339, 9 }, { 317, 9 },326 { 114, 9 }, { 82, 9 }, { 83, 9 }, { 73, 9 }, { 74, 9 }, { 1000, 10 },327 { 933, 10 }, { 621, 10 }, { 718, 10 }, { 2003, 11 }, { 713, 10 }, { 2020, 11 },328 { 230, 10 }, { 1865, 11 }, { 44, 10 }, { 138, 10 }, { 1280, 11 }, { 2021, 11 },329 { 3729, 12 }, { 4047, 12 }, { 90, 11 }, { 265, 11 }, { 1281, 11 }, { 1425, 11 },330 { 91, 11 }331 } };332 #endif333 334 /*335 * Fills out the items Code and Length (but not Value) of a Huffman table336 * from a bit packed Huffman table 'src'. Table is not sorted, so this is337 * the table which is suitable for an encoder. Be careful: To get a table338 * usable for a decoder you must use Resort_HuffTable() after this339 * function. It's a little bit dangerous to divide the functionality, maybe340 * there is a more secure and handy solution to this problem.341 */342 343 void Make_HuffTable ( Huffman_t* dst, const Huffman_t* src, mpc_size_t len )344 {345 mpc_size_t i;346 347 for ( i = 0; i < len; i++,src++,dst++ ) {348 dst->Code = src->Code ;349 dst->Length = src->Length;350 }351 }352 353 354 /*355 * Generates a Lookup table for quick Huffman decoding. This table must356 * have a size of a power of 2. Input is the pre-sorted Huffman table,357 * sorted by Resort_HuffTable() and its length, and the length of the358 * lookup table. Output is the Lookup table. It can be used for table based359 * decoding (Huffman_decode_fastest) which fully decodes by means of the360 * LUT. This is only handy for small huffman codes up to 9...10 bit361 * maximum length. For longer codes partial lookup is possible with362 * Huffman_decode_faster() which first estimates possible codes by means363 * of LUT and then searches the exact code like the tableless version364 * Huffman_decode().365 */366 367 void Make_LookupTable ( mpc_uint8_t* LUT,368 mpc_size_t LUT_len,369 const Huffman_t* const Table,370 const mpc_size_t elements )371 {372 mpc_size_t i;373 mpc_size_t idx = elements;374 mpc_uint32_t dval = (mpc_uint32_t)0x80000000L / LUT_len * 2;375 mpc_uint32_t val = dval - 1;376 377 for ( i = 0; i < LUT_len; i++, val += dval ) {378 while ( idx > 0 && val >= Table[idx-1].Code )379 idx--;380 *LUT++ = (mpc_uint8_t)idx;381 }382 383 return;384 }385 386 #define MAKE(d,s) Make_HuffTable ( (d), (s), sizeof(s)/sizeof(*(s)) )387 #define LOOKUP(x,q) Make_LookupTable ( (q), sizeof(q), (x), sizeof(x)/sizeof(*(x)) )388 389 390 void391 Init_Huffman_Encoder_SV7 ( void )392 {393 // Splitting of the 36 Samples394 MAKE ( HuffSCFI, HuffSCFI_src );395 396 // Differential Scalefactors397 MAKE ( HuffDSCF, HuffDSCF_src );398 399 // resolution, differential quantizer indizes400 MAKE ( HuffHdr, HuffHdr_src );401 402 // 3-step quantizer, 3 bundled samples403 MAKE ( HuffQ1[0], HuffQ1_src[0] ); // less shaped, book 0404 MAKE ( HuffQ1[1], HuffQ1_src[1] ); // more shaped, book 1405 406 // 5-step quantizer, 2 bundled samples407 MAKE ( HuffQ2[0], HuffQ2_src[0] ); // less shaped, book 0408 MAKE ( HuffQ2[1], HuffQ2_src[1] ); // more shaped, book 1409 410 // 7-step quantizer, single samples411 MAKE ( HuffQ3[0], HuffQ3_src[0] ); // less shaped, book 0412 MAKE ( HuffQ3[1], HuffQ3_src[1] ); // more shaped, book 1413 414 #ifdef USE_SV8415 // 7-step quantizer, 2 bundled samples416 MAKE ( HuffN3[0], HuffN3_src[0] ); // less shaped, book 0417 MAKE ( HuffN3[1], HuffN3_src[1] ); // more shaped, book 1418 #endif419 420 // 9-step quantizer, single samples421 MAKE ( HuffQ4[0], HuffQ4_src[0] ); // less shaped, book 0422 MAKE ( HuffQ4[1], HuffQ4_src[1] ); // more shaped, book 1423 424 // 15-step quantizer, single samples425 MAKE ( HuffQ5[0], HuffQ5_src[0] ); // less shaped, book 0426 MAKE ( HuffQ5[1], HuffQ5_src[1] ); // more shaped, book 1427 428 // 31-step quantizer, single samples429 MAKE ( HuffQ6[0], HuffQ6_src[0] ); // less shaped, book 0430 MAKE ( HuffQ6[1], HuffQ6_src[1] ); // more shaped, book 1431 432 // 63-step quantizer, single samples433 MAKE ( HuffQ7[0], HuffQ7_src[0] ); // less shaped, book 0434 MAKE ( HuffQ7[1], HuffQ7_src[1] ); // more shaped, book 1435 436 #ifdef USE_SV8437 // 127-step quantizer, single samples438 MAKE ( HuffN8[0], HuffN8_src[0] ); // book 0439 MAKE ( HuffN8[1], HuffN8_src[1] ); // book 1440 #endif441 }442 443 111 /* end of huffsv7.c */
Note: See TracChangeset
for help on using the changeset viewer.