/src/xz/src/liblzma/simple/simple_encoder.c
Line | Count | Source |
1 | | // SPDX-License-Identifier: 0BSD |
2 | | |
3 | | /////////////////////////////////////////////////////////////////////////////// |
4 | | // |
5 | | /// \file simple_encoder.c |
6 | | /// \brief Properties encoder for simple filters |
7 | | // |
8 | | // Author: Lasse Collin |
9 | | // |
10 | | /////////////////////////////////////////////////////////////////////////////// |
11 | | |
12 | | #include "simple_encoder.h" |
13 | | |
14 | | |
15 | | extern lzma_ret |
16 | | lzma_simple_props_size(uint32_t *size, const void *options) |
17 | 0 | { |
18 | 0 | const lzma_options_bcj *const opt = options; |
19 | 0 | *size = (opt == NULL || opt->start_offset == 0) ? 0 : 4; |
20 | 0 | return LZMA_OK; |
21 | 0 | } |
22 | | |
23 | | |
24 | | extern lzma_ret |
25 | | lzma_simple_props_encode(const void *options, uint8_t *out) |
26 | 0 | { |
27 | 0 | const lzma_options_bcj *const opt = options; |
28 | | |
29 | | // The default start offset is zero, so we don't need to store any |
30 | | // options unless the start offset is non-zero. |
31 | 0 | if (opt == NULL || opt->start_offset == 0) |
32 | 0 | return LZMA_OK; |
33 | | |
34 | 0 | write32le(out, opt->start_offset); |
35 | |
|
36 | 0 | return LZMA_OK; |
37 | 0 | } |