1 ///////////////////////////////////////////////////////////////////////////////
3 /// \file raw_encoder.c
4 /// \brief Raw encoder initialization API
6 // Copyright (C) 2007 Lasse Collin
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
18 ///////////////////////////////////////////////////////////////////////////////
20 #include "raw_encoder.h"
21 #include "simple_coder.h"
22 #include "subblock_encoder.h"
23 #include "delta_encoder.h"
24 #include "lzma_encoder.h"
27 static lzma_init_function
28 get_function(lzma_vli id)
31 #ifdef HAVE_FILTER_SUBBLOCK
32 case LZMA_FILTER_SUBBLOCK:
33 return &lzma_subblock_encoder_init;
36 #ifdef HAVE_FILTER_X86
38 return &lzma_simple_x86_encoder_init;
41 #ifdef HAVE_FILTER_POWERPC
42 case LZMA_FILTER_POWERPC:
43 return &lzma_simple_powerpc_encoder_init;
46 #ifdef HAVE_FILTER_IA64
47 case LZMA_FILTER_IA64:
48 return &lzma_simple_ia64_encoder_init;
51 #ifdef HAVE_FILTER_ARM
53 return &lzma_simple_arm_encoder_init;
56 #ifdef HAVE_FILTER_ARMTHUMB
57 case LZMA_FILTER_ARMTHUMB:
58 return &lzma_simple_armthumb_encoder_init;
61 #ifdef HAVE_FILTER_SPARC
62 case LZMA_FILTER_SPARC:
63 return &lzma_simple_sparc_encoder_init;
66 #ifdef HAVE_FILTER_DELTA
67 case LZMA_FILTER_DELTA:
68 return &lzma_delta_encoder_init;
71 #ifdef HAVE_FILTER_LZMA
72 case LZMA_FILTER_LZMA:
73 return &lzma_lzma_encoder_init;
82 lzma_raw_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
83 const lzma_options_filter *options)
85 const lzma_ret ret = lzma_raw_coder_init(next, allocator,
86 options, &get_function, true);
89 lzma_next_coder_end(next, allocator);
95 extern LZMA_API lzma_ret
96 lzma_raw_encoder(lzma_stream *strm, const lzma_options_filter *options)
98 return_if_error(lzma_strm_init(strm));
100 strm->internal->supported_actions[LZMA_RUN] = true;
101 strm->internal->supported_actions[LZMA_SYNC_FLUSH] = true;
102 strm->internal->supported_actions[LZMA_FINISH] = true;
104 const lzma_ret ret = lzma_raw_coder_init(&strm->internal->next,
105 strm->allocator, options, &get_function, true);