1207753Smm///////////////////////////////////////////////////////////////////////////////
2207753Smm//
3207753Smm/// \file       simple_encoder.c
4207753Smm/// \brief      Properties encoder for simple filters
5207753Smm//
6207753Smm//  Author:     Lasse Collin
7207753Smm//
8207753Smm//  This file has been put into the public domain.
9207753Smm//  You can do whatever you want with this file.
10207753Smm//
11207753Smm///////////////////////////////////////////////////////////////////////////////
12207753Smm
13207753Smm#include "simple_encoder.h"
14207753Smm
15207753Smm
16207753Smmextern lzma_ret
17207753Smmlzma_simple_props_size(uint32_t *size, const void *options)
18207753Smm{
19207753Smm	const lzma_options_bcj *const opt = options;
20207753Smm	*size = (opt == NULL || opt->start_offset == 0) ? 0 : 4;
21207753Smm	return LZMA_OK;
22207753Smm}
23207753Smm
24207753Smm
25207753Smmextern lzma_ret
26207753Smmlzma_simple_props_encode(const void *options, uint8_t *out)
27207753Smm{
28207753Smm	const lzma_options_bcj *const opt = options;
29207753Smm
30207753Smm	// The default start offset is zero, so we don't need to store any
31207753Smm	// options unless the start offset is non-zero.
32207753Smm	if (opt == NULL || opt->start_offset == 0)
33207753Smm		return LZMA_OK;
34207753Smm
35207753Smm	unaligned_write32le(out, opt->start_offset);
36207753Smm
37207753Smm	return LZMA_OK;
38207753Smm}
39