]> icculus.org git repositories - icculus/xz.git/blob - src/liblzma/rangecoder/price_tablegen.c
Fix test_filter_flags to match the new restriction of lc+lp.
[icculus/xz.git] / src / liblzma / rangecoder / price_tablegen.c
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file       price_tablegen.c
4 /// \brief      Probability price table generator
5 ///
6 /// Compiling: gcc -std=c99 -o price_tablegen price_tablegen.c
7 //
8 //  Copyright (C) 2007 Lasse Collin
9 //
10 //  This library is free software; you can redistribute it and/or
11 //  modify it under the terms of the GNU Lesser General Public
12 //  License as published by the Free Software Foundation; either
13 //  version 2.1 of the License, or (at your option) any later version.
14 //
15 //  This library is distributed in the hope that it will be useful,
16 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
17 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 //  Lesser General Public License for more details.
19 //
20 ///////////////////////////////////////////////////////////////////////////////
21
22 #include <stddef.h>
23 #include <inttypes.h>
24 #include <stdio.h>
25 #include "range_common.h"
26 #include "price.h"
27 #include "price_table_init.c"
28
29
30 int
31 main(void)
32 {
33         lzma_rc_init();
34
35         printf("/* This file has been automatically generated by "
36                         "price_tablegen.c. */\n\n"
37                         "#include \"range_encoder.h\"\n\n"
38                         "const uint32_t lzma_rc_prices["
39                         "RC_PRICE_TABLE_SIZE] = {");
40
41         const size_t array_size = sizeof(lzma_rc_prices)
42                         / sizeof(lzma_rc_prices[0]);
43         for (size_t i = 0; i < array_size; ++i) {
44                 if (i % 8 == 0)
45                         printf("\n\t");
46
47                 printf("%4" PRIu32, lzma_rc_prices[i]);
48
49                 if (i != array_size - 1)
50                         printf(",");
51         }
52
53         printf("\n};\n");
54
55         return 0;
56 }