mirror of
https://github.com/rupertwh/bmplib.git
synced 2026-07-08 18:06:05 +00:00
auto-generation: small fixes
* found one last error in huffman makeup codes * use smaller types (short/char) to reduce table size * small fixes, formatting
This commit is contained in:
@@ -189,7 +189,7 @@ static struct Huffcode huff_makeup_white[] = { { 64, "11011" },
|
||||
{ 1984, "000000010010" },
|
||||
{ 2048, "000000010011" },
|
||||
{ 2112, "000000010100" },
|
||||
{ 2170, "000000010101" },
|
||||
{ 2176, "000000010101" },
|
||||
{ 2240, "000000010110" },
|
||||
{ 2304, "000000010111" },
|
||||
{ 2368, "000000011100" },
|
||||
@@ -231,7 +231,7 @@ static struct Huffcode huff_makeup_black[] = { { 64, "0000001111" },
|
||||
{ 1984, "000000010010" },
|
||||
{ 2048, "000000010011" },
|
||||
{ 2112, "000000010100" },
|
||||
{ 2170, "000000010101" },
|
||||
{ 2176, "000000010101" },
|
||||
{ 2240, "000000010110" },
|
||||
{ 2304, "000000010111" },
|
||||
{ 2368, "000000011100" },
|
||||
|
||||
@@ -71,35 +71,43 @@ int main(int argc, char *argv[])
|
||||
s_buildtree();
|
||||
|
||||
fprintf(file, "/* bmplib - %s\n"
|
||||
" *\n"
|
||||
" * Copyright (c) 2024, Rupert Weber.\n"
|
||||
" *\n"
|
||||
" * This file is part of bmplib.\n"
|
||||
" * bmplib is free software: you can redistribute it and/or modify\n"
|
||||
" * it under the terms of the GNU Lesser General Public License as\n"
|
||||
" * published by the Free Software Foundation, either version 3 of\n"
|
||||
" * the License, or (at your option) any later version.\n"
|
||||
" *\n"
|
||||
" * This program is distributed in the hope that it will be useful,\n"
|
||||
" * but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
||||
" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
||||
" * GNU Lesser General Public License for more details.\n"
|
||||
" *\n"
|
||||
" * You should have received a copy of the GNU Lesser General Public\n"
|
||||
" * License along with this library.\n"
|
||||
" * If not, see <https://www.gnu.org/licenses/>\n"
|
||||
" */\n\n"
|
||||
"/* This file is auto-generated by %s */\n\n\n",
|
||||
" *\n"
|
||||
" * Copyright (c) 2024, Rupert Weber.\n"
|
||||
" *\n"
|
||||
" * This file is part of bmplib.\n"
|
||||
" * bmplib is free software: you can redistribute it and/or modify\n"
|
||||
" * it under the terms of the GNU Lesser General Public License as\n"
|
||||
" * published by the Free Software Foundation, either version 3 of\n"
|
||||
" * the License, or (at your option) any later version.\n"
|
||||
" *\n"
|
||||
" * This program is distributed in the hope that it will be useful,\n"
|
||||
" * but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
||||
" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
||||
" * GNU Lesser General Public License for more details.\n"
|
||||
" *\n"
|
||||
" * You should have received a copy of the GNU Lesser General Public\n"
|
||||
" * License along with this library.\n"
|
||||
" * If not, see <https://www.gnu.org/licenses/>\n"
|
||||
" */\n\n"
|
||||
"/* This file is auto-generated by %s */\n\n\n",
|
||||
src_name, this_name);
|
||||
|
||||
fprintf(file, "static int blackroot = %d;\n", black_tree);
|
||||
fprintf(file, "static int whiteroot = %d;\n\n\n", white_tree);
|
||||
fprintf(file, "static struct Node nodebuffer[] = {\n");
|
||||
fputs("struct Node {\n"
|
||||
"\tsigned short l;\n"
|
||||
"\tsigned short r;\n"
|
||||
"\tshort value;\n"
|
||||
"\tchar terminal;\n"
|
||||
"\tchar makeup;\n"
|
||||
"};\n\n", file);
|
||||
|
||||
fprintf(file, "static const int blackroot = %d;\n", black_tree);
|
||||
fprintf(file, "static const int whiteroot = %d;\n\n\n", white_tree);
|
||||
fprintf(file, "static const struct Node nodebuffer[] = {\n");
|
||||
for (i = 0; i < ARR_SIZE(nodebuffer); i++) {
|
||||
fprintf(file, "\t{ %3d, %3d, %4d, %d, %d },\n",
|
||||
n[i].l, n[i].r, n[i].value, n[i].terminal, n[i].makeup);
|
||||
}
|
||||
fprintf(file, "};\n");
|
||||
fputs("};\n", file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,28 +53,28 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
fprintf(file, "/* bmplib - %s\n"
|
||||
" *\n"
|
||||
" * Copyright (c) 2024, Rupert Weber.\n"
|
||||
" *\n"
|
||||
" * This file is part of bmplib.\n"
|
||||
" * bmplib is free software: you can redistribute it and/or modify\n"
|
||||
" * it under the terms of the GNU Lesser General Public License as\n"
|
||||
" * published by the Free Software Foundation, either version 3 of\n"
|
||||
" * the License, or (at your option) any later version.\n"
|
||||
" *\n"
|
||||
" * This program is distributed in the hope that it will be useful,\n"
|
||||
" * but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
||||
" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
||||
" * GNU Lesser General Public License for more details.\n"
|
||||
" *\n"
|
||||
" * You should have received a copy of the GNU Lesser General Public\n"
|
||||
" * License along with this library.\n"
|
||||
" * If not, see <https://www.gnu.org/licenses/>\n"
|
||||
" */\n\n"
|
||||
"/* This file is auto-generated by %s */\n\n\n",
|
||||
" *\n"
|
||||
" * Copyright (c) 2024, Rupert Weber.\n"
|
||||
" *\n"
|
||||
" * This file is part of bmplib.\n"
|
||||
" * bmplib is free software: you can redistribute it and/or modify\n"
|
||||
" * it under the terms of the GNU Lesser General Public License as\n"
|
||||
" * published by the Free Software Foundation, either version 3 of\n"
|
||||
" * the License, or (at your option) any later version.\n"
|
||||
" *\n"
|
||||
" * This program is distributed in the hope that it will be useful,\n"
|
||||
" * but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
||||
" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
||||
" * GNU Lesser General Public License for more details.\n"
|
||||
" *\n"
|
||||
" * You should have received a copy of the GNU Lesser General Public\n"
|
||||
" * License along with this library.\n"
|
||||
" * If not, see <https://www.gnu.org/licenses/>\n"
|
||||
" */\n\n"
|
||||
"/* This file is auto-generated by %s */\n\n\n",
|
||||
src_name, this_name);
|
||||
|
||||
fprintf(file, "static const int reversebits[] = {\n\t");
|
||||
fprintf(file, "static const unsigned char reversebits[] = {\n\t");
|
||||
for (int i = 0; i < 256; i++) {
|
||||
reversed = reverse(i, 8);
|
||||
fprintf(file, "0x%02x, ", reversed);
|
||||
|
||||
11
huffman.c
11
huffman.c
@@ -31,18 +31,9 @@
|
||||
#include "bmp-common.h"
|
||||
#include "reversebits.h"
|
||||
#include "huffman.h"
|
||||
#include "huffman-codes.h"
|
||||
|
||||
|
||||
struct Node {
|
||||
int l;
|
||||
int r;
|
||||
int value;
|
||||
int terminal;
|
||||
int makeup;
|
||||
};
|
||||
|
||||
#include "huffman-codes.h" /* auto-generated by huffman-gen-codes.c */
|
||||
|
||||
|
||||
static int s_findnode(uint32_t bits, int nbits, int black, int *found);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user