Browse Source

update: short code offset list

master
Dnomd343 2 years ago
parent
commit
8d0137b90b
  1. 1379
      all_cases/mark.h
  2. 60
      all_cases/short_code.cc

1379
all_cases/mark.h

File diff suppressed because it is too large

60
all_cases/short_code.cc

@ -81,10 +81,10 @@ uint64_t unzip_short_code(uint32_t short_code) {
uint32_t prefix = 0; uint32_t prefix = 0;
for (; prefix < 256; ++prefix) { for (; prefix < 256; ++prefix) {
if (short_code < SHORT_CODE_MARK[head][prefix]) { if (short_code < SHORT_CODE_INDEX[head][prefix]) {
break; break;
} }
short_code -= SHORT_CODE_MARK[head][prefix]; short_code -= SHORT_CODE_INDEX[head][prefix];
} }
std::cout << "prefix: " << prefix << std::endl; std::cout << "prefix: " << prefix << std::endl;
@ -140,20 +140,52 @@ int main() {
// zip short code // zip short code
// valid code -> short code // valid code -> short code
// head -> offset_1
// prefix -> offset_2
// uint64_t code = 0x4FEA13400; uint64_t code = 0x6EC0F8800;
// head_offset = code >> 32;
uint32_t offset[16]; // uint32_t head = code >> 32;
uint32_t sum = 0; // std::cout << "head: " << head << std::endl;
for (int i = 0; i < 16; ++i) { // uint32_t head_offset = ALL_CASES_OFFSET[head];
offset[i] = sum; // std::cout << "head offset: " << head_offset << std::endl;
sum += ALL_CASES_INDEX[i]; //
} // uint32_t prefix = (code >> 24) & 0xFF;
for (int i = 0; i < 16; ++i) { // std::cout << "prefix: " << prefix << std::endl;
std::cout << offset[i] << ", "; // uint32_t prefix_offset = SHORT_CODE_MARK[head][prefix];
// std::cout << "prefix offset: " << prefix_offset << std::endl;
// know real range -> start search at offset
// uint32_t offset[16];
// uint32_t sum = 0;
// for (int i = 0; i < 16; ++i) {
// offset[i] = sum;
// sum += ALL_CASES_INDEX[i];
// }
// for (int i = 0; i < 16; ++i) {
// std::cout << offset[i] << ", ";
// }
uint32_t offset[256];
for (uint32_t head = 0; head < 16; ++head) {
uint32_t sum = 0;
for (int i = 0; i < 256; ++i) {
offset[i] = sum;
sum += SHORT_CODE_INDEX[head][i];
}
std::cout << "{" << std::endl;
for (int i = 0; i < 256; ++i) {
if (i % 8 == 0) {
std::cout << " ";
}
// printf("%7d, ", offset[i]);
printf("%5d, ", SHORT_CODE_INDEX[head][i]);
if (i % 8 == 7) {
std::cout << std::endl;
}
}
std::cout << "}," << std::endl;
} }
return 0; return 0;

Loading…
Cancel
Save