2008-08-28 21:53:15 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
/// \file simple_encoder.c
|
|
|
|
/// \brief Properties encoder for simple filters
|
|
|
|
//
|
2009-04-13 10:27:40 +02:00
|
|
|
// Author: Lasse Collin
|
2008-08-28 21:53:15 +02:00
|
|
|
//
|
2009-04-13 10:27:40 +02:00
|
|
|
// This file has been put into the public domain.
|
|
|
|
// You can do whatever you want with this file.
|
2008-08-28 21:53:15 +02:00
|
|
|
//
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "simple_encoder.h"
|
|
|
|
|
|
|
|
|
|
|
|
extern lzma_ret
|
|
|
|
lzma_simple_props_size(uint32_t *size, const void *options)
|
|
|
|
{
|
2008-12-31 15:29:39 +01:00
|
|
|
const lzma_options_bcj *const opt = options;
|
2008-08-28 21:53:15 +02:00
|
|
|
*size = (opt == NULL || opt->start_offset == 0) ? 0 : 4;
|
|
|
|
return LZMA_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
extern lzma_ret
|
|
|
|
lzma_simple_props_encode(const void *options, uint8_t *out)
|
|
|
|
{
|
2008-12-31 15:29:39 +01:00
|
|
|
const lzma_options_bcj *const opt = options;
|
2008-08-28 21:53:15 +02:00
|
|
|
|
|
|
|
// The default start offset is zero, so we don't need to store any
|
|
|
|
// options unless the start offset is non-zero.
|
|
|
|
if (opt == NULL || opt->start_offset == 0)
|
|
|
|
return LZMA_OK;
|
|
|
|
|
2019-12-31 21:41:45 +01:00
|
|
|
write32le(out, opt->start_offset);
|
2008-08-28 21:53:15 +02:00
|
|
|
|
|
|
|
return LZMA_OK;
|
|
|
|
}
|