aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/rangecoder/price_tablegen.c
blob: 68513635933d9d036237ca243f239346d17b0215 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
///////////////////////////////////////////////////////////////////////////////
//
/// \file       price_tablegen.c
/// \brief      Probability price table generator
///
/// Compiling: gcc -std=c99 -o price_tablegen price_tablegen.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 <stddef.h>
#include <inttypes.h>
#include <stdio.h>
#include "range_common.h"
#include "price.h"
#include "price_table_init.c"


int
main(void)
{
	lzma_rc_init();

	printf("/* This file has been automatically generated by "
			"price_tablegen.c. */\n\n"
			"#include \"range_encoder.h\"\n\n"
			"const uint32_t lzma_rc_prices["
			"RC_PRICE_TABLE_SIZE] = {");

	const size_t array_size = sizeof(lzma_rc_prices)
			/ sizeof(lzma_rc_prices[0]);
	for (size_t i = 0; i < array_size; ++i) {
		if (i % 8 == 0)
			printf("\n\t");

		printf("%4" PRIu32, lzma_rc_prices[i]);

		if (i != array_size - 1)
			printf(",");
	}

	printf("\n};\n");

	return 0;
}