aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/rangecoder/price_table_gen.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-01-15 07:40:21 +0200
committerLasse Collin <lasse.collin@tukaani.org>2008-01-15 07:40:21 +0200
commitd13d693155c176fc9e9ad5c50d48ccba27c2d9c6 (patch)
treeb688e0baaca289c39c329bae9fafb97f3b68682b /src/liblzma/rangecoder/price_table_gen.c
parentRemove RC_BUFFER_SIZE from lzma_encoder_private.h (diff)
downloadxz-d13d693155c176fc9e9ad5c50d48ccba27c2d9c6.tar.xz
Added precomputed range coder probability price table.
Diffstat (limited to 'src/liblzma/rangecoder/price_table_gen.c')
-rw-r--r--src/liblzma/rangecoder/price_table_gen.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/liblzma/rangecoder/price_table_gen.c b/src/liblzma/rangecoder/price_table_gen.c
new file mode 100644
index 00000000..04703e4f
--- /dev/null
+++ b/src/liblzma/rangecoder/price_table_gen.c
@@ -0,0 +1,55 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+/// \file price_table_gen.c
+/// \brief Probability price table generator
+///
+/// Compiling: gcc -std=c99 -o price_table_gen price_table_gen.c
+//
+// Copyright (C) 2007 Lasse Collin
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#include <sys/types.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include "range_common.h"
+#include "price_table_init.c"
+
+
+int
+main(void)
+{
+ lzma_rc_init();
+
+ printf("/* This file has been automatically generated by "
+ "price_table_gen.c. */\n\n"
+ "#include \"range_encoder.h\"\n\n"
+ "const uint32_t lzma_rc_prob_prices["
+ "BIT_MODEL_TOTAL >> MOVE_REDUCING_BITS] = {");
+
+ const size_t array_size = sizeof(lzma_rc_prob_prices)
+ / sizeof(lzma_rc_prob_prices[0]);
+ for (size_t i = 0; i < array_size; ++i) {
+ if (i % 8 == 0)
+ printf("\n\t");
+
+ printf("% 4" PRIu32, lzma_rc_prob_prices[i]);
+
+ if (i != array_size - 1)
+ printf(",");
+ }
+
+ printf("\n};\n");
+
+ return 0;
+}