VirtualBox

source: vbox/trunk/src/libs/liblzma-5.4.1/common/index.h@ 107044

Last change on this file since 107044 was 98730, checked in by vboxsync, 21 months ago

libs/liblzma-5.4.1: Export to OSE, bugref:10254

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.5 KB
Line 
1///////////////////////////////////////////////////////////////////////////////
2//
3/// \file index.h
4/// \brief Handling of Index
5/// \note This header file does not include common.h or lzma.h because
6/// this file is needed by both liblzma internally and by the
7/// tests. Including common.h will include and define many things
8/// the tests do not need and prevents issues with header file
9/// include order. This way, if lzma.h or common.h are not
10/// included before this file it will break on every OS instead
11/// of causing more subtle errors.
12//
13// Author: Lasse Collin
14//
15// This file has been put into the public domain.
16// You can do whatever you want with this file.
17//
18///////////////////////////////////////////////////////////////////////////////
19
20#ifndef LZMA_INDEX_H
21#define LZMA_INDEX_H
22
23
24/// Minimum Unpadded Size
25#define UNPADDED_SIZE_MIN LZMA_VLI_C(5)
26
27/// Maximum Unpadded Size
28#define UNPADDED_SIZE_MAX (LZMA_VLI_MAX & ~LZMA_VLI_C(3))
29
30/// Index Indicator based on xz specification
31#define INDEX_INDICATOR 0
32
33
34/// Get the size of the Index Padding field. This is needed by Index encoder
35/// and decoder, but applications should have no use for this.
36extern uint32_t lzma_index_padding_size(const lzma_index *i);
37
38
39/// Set for how many Records to allocate memory the next time
40/// lzma_index_append() needs to allocate space for a new Record.
41/// This is used only by the Index decoder.
42extern void lzma_index_prealloc(lzma_index *i, lzma_vli records);
43
44
45/// Round the variable-length integer to the next multiple of four.
46static inline lzma_vli
47vli_ceil4(lzma_vli vli)
48{
49 assert(vli <= LZMA_VLI_MAX);
50 return (vli + 3) & ~LZMA_VLI_C(3);
51}
52
53
54/// Calculate the size of the Index field excluding Index Padding
55static inline lzma_vli
56index_size_unpadded(lzma_vli count, lzma_vli index_list_size)
57{
58 // Index Indicator + Number of Records + List of Records + CRC32
59 return 1 + lzma_vli_size(count) + index_list_size + 4;
60}
61
62
63/// Calculate the size of the Index field including Index Padding
64static inline lzma_vli
65index_size(lzma_vli count, lzma_vli index_list_size)
66{
67 return vli_ceil4(index_size_unpadded(count, index_list_size));
68}
69
70
71/// Calculate the total size of the Stream
72static inline lzma_vli
73index_stream_size(lzma_vli blocks_size,
74 lzma_vli count, lzma_vli index_list_size)
75{
76 return LZMA_STREAM_HEADER_SIZE + blocks_size
77 + index_size(count, index_list_size)
78 + LZMA_STREAM_HEADER_SIZE;
79}
80
81#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette