xref: /dflybsd-src/contrib/xz/src/liblzma/simple/simple_encoder.c (revision b5feb3da7c498482b19d14ac6f2b1901005f7d94)
12940b44dSPeter Avalos ///////////////////////////////////////////////////////////////////////////////
22940b44dSPeter Avalos //
32940b44dSPeter Avalos /// \file       simple_encoder.c
42940b44dSPeter Avalos /// \brief      Properties encoder for simple filters
52940b44dSPeter Avalos //
62940b44dSPeter Avalos //  Author:     Lasse Collin
72940b44dSPeter Avalos //
82940b44dSPeter Avalos //  This file has been put into the public domain.
92940b44dSPeter Avalos //  You can do whatever you want with this file.
102940b44dSPeter Avalos //
112940b44dSPeter Avalos ///////////////////////////////////////////////////////////////////////////////
122940b44dSPeter Avalos 
132940b44dSPeter Avalos #include "simple_encoder.h"
142940b44dSPeter Avalos 
152940b44dSPeter Avalos 
162940b44dSPeter Avalos extern lzma_ret
lzma_simple_props_size(uint32_t * size,const void * options)172940b44dSPeter Avalos lzma_simple_props_size(uint32_t *size, const void *options)
182940b44dSPeter Avalos {
192940b44dSPeter Avalos 	const lzma_options_bcj *const opt = options;
202940b44dSPeter Avalos 	*size = (opt == NULL || opt->start_offset == 0) ? 0 : 4;
212940b44dSPeter Avalos 	return LZMA_OK;
222940b44dSPeter Avalos }
232940b44dSPeter Avalos 
242940b44dSPeter Avalos 
252940b44dSPeter Avalos extern lzma_ret
lzma_simple_props_encode(const void * options,uint8_t * out)262940b44dSPeter Avalos lzma_simple_props_encode(const void *options, uint8_t *out)
272940b44dSPeter Avalos {
282940b44dSPeter Avalos 	const lzma_options_bcj *const opt = options;
292940b44dSPeter Avalos 
302940b44dSPeter Avalos 	// The default start offset is zero, so we don't need to store any
312940b44dSPeter Avalos 	// options unless the start offset is non-zero.
322940b44dSPeter Avalos 	if (opt == NULL || opt->start_offset == 0)
332940b44dSPeter Avalos 		return LZMA_OK;
342940b44dSPeter Avalos 
35*e151908bSDaniel Fojt 	write32le(out, opt->start_offset);
362940b44dSPeter Avalos 
372940b44dSPeter Avalos 	return LZMA_OK;
382940b44dSPeter Avalos }
39