Rizin
unix-like reverse engineering framework and cli tools
|
.xz Block handling More...
Go to the source code of this file.
Classes | |
struct | lzma_block |
Options for the Block and Block Header encoders and decoders. More... | |
Macros | |
#define | LZMA_BLOCK_HEADER_SIZE_MIN 8 |
#define | LZMA_BLOCK_HEADER_SIZE_MAX 1024 |
#define | lzma_block_header_size_decode(b) (((uint32_t)(b) + 1) * 4) |
Decode the Block Header Size field. More... | |
Functions | |
LZMA_API (lzma_ret) lzma_block_header_size(lzma_block *block) lzma_nothrow lzma_attr_warn_unused_result | |
Calculate Block Header Size. More... | |
LZMA_API (lzma_vli) lzma_block_unpadded_size(const lzma_block *block) lzma_nothrow lzma_attr_pure | |
Calculate Unpadded Size. More... | |
LZMA_API (size_t) lzma_block_buffer_bound(size_t uncompressed_size) lzma_nothrow | |
Calculate maximum output size for single-call Block encoding. More... | |
.xz Block handling
Definition in file block.h.
Decode the Block Header Size field.
To decode Block Header using lzma_block_header_decode(), the size of the Block Header has to be known and stored into lzma_block.header_size. The size can be calculated from the first byte of a Block using this macro. Note that if the first byte is 0x00, it indicates beginning of Index; use this macro only when the byte is not 0x00.
There is no encoding macro, because Block Header encoder is enough for that.
LZMA_API | ( | lzma_ret | ) |
Calculate Block Header Size.
Single-call .xz Block decoder.
Single-call uncompressed .xz Block encoder.
Single-call .xz Block encoder.
Initialize .xz Block decoder.
Initialize .xz Block encoder.
Validate and set Compressed Size according to Unpadded Size.
Decode Block Header.
Encode Block Header.
Calculate the minimum size needed for the Block Header field using the settings specified in the lzma_block structure. Note that it is OK to increase the calculated header_size value as long as it is a multiple of four and doesn't exceed LZMA_BLOCK_HEADER_SIZE_MAX. Increasing header_size just means that lzma_block_header_encode() will add Header Padding.
The caller must have calculated the size of the Block Header already with lzma_block_header_size(). If a value larger than the one calculated by lzma_block_header_size() is used, the Block Header will be padded to the specified size.
out | Beginning of the output buffer. This must be at least block->header_size bytes. |
block | Block options to be encoded. |
block->version should (usually) be set to the highest value supported by the application. If the application sets block->version to a value higher than supported by the current liblzma version, this function will downgrade block->version to the highest value supported by it. Thus one should check the value of block->version after calling this function if block->version was set to a non-zero value and the application doesn't otherwise know that the liblzma version being used is new enough to support the specified block->version.
The size of the Block Header must have already been decoded with lzma_block_header_size_decode() macro and stored to block->header_size.
The integrity check type from Stream Header must have been stored to block->check.
block->filters must have been allocated, but they don't need to be initialized (possible existing filter options are not freed).
block | Destination for Block options. |
allocator | lzma_allocator for custom allocator functions. Set to NULL to use malloc() (and also free() if an error occurs). |
in | Beginning of the input buffer. This must be at least block->header_size bytes. |
Block Header stores Compressed Size, but Index has Unpadded Size. If the application has already parsed the Index and is now decoding Blocks, it can calculate Compressed Size from Unpadded Size. This function does exactly that with error checking:
Valid actions for lzma_code() are LZMA_RUN, LZMA_SYNC_FLUSH (only if the filter chain supports it), and LZMA_FINISH.
Valid actions for lzma_code() are LZMA_RUN and LZMA_FINISH. Using LZMA_FINISH is not required. It is supported only for convenience.
In contrast to the multi-call encoder initialized with lzma_block_encoder(), this function encodes also the Block Header. This is required to make it possible to write appropriate Block Header also in case the data isn't compressible, and different filter chain has to be used to encode the data in uncompressed form using uncompressed chunks of the LZMA2 filter.
When the data isn't compressible, header_size, compressed_size, and uncompressed_size are set just like when the data was compressible, but it is possible that header_size is too small to hold the filter chain specified in block->filters, because that isn't necessarily the filter chain that was actually used to encode the data. lzma_block_unpadded_size() still works normally, because it doesn't read the filters array.
block | Block options: block->version, block->check, and block->filters must have been initialized. |
allocator | lzma_allocator for custom allocator functions. Set to NULL to use malloc() and free(). |
in | Beginning of the input buffer |
in_size | Size of the input buffer |
out | Beginning of the output buffer |
out_pos | The next byte will be written to out[*out_pos]. *out_pos is updated only if encoding succeeds. |
out_size | Size of the out buffer; the first byte into which no data is written to is out[out_size]. |
This is like lzma_block_buffer_encode() except this doesn't try to compress the data and instead encodes the data using LZMA2 uncompressed chunks. The required output buffer size can be determined with lzma_block_buffer_bound().
Since the data won't be compressed, this function ignores block->filters. This function doesn't take lzma_allocator because this function doesn't allocate any memory from the heap.
This is single-call equivalent of lzma_block_decoder(), and requires that the caller has already decoded Block Header and checked its memory usage.
block | Block options just like with lzma_block_decoder(). |
allocator | lzma_allocator for custom allocator functions. Set to NULL to use malloc() and free(). |
in | Beginning of the input buffer |
in_pos | The next byte will be read from in[*in_pos]. *in_pos is updated only if decoding succeeds. |
in_size | Size of the input buffer; the first byte that won't be read is in[in_size]. |
out | Beginning of the output buffer |
out_pos | The next byte will be written to out[*out_pos]. *out_pos is updated only if encoding succeeds. |
out_size | Size of the out buffer; the first byte into which no data is written to is out[out_size]. |
LZMA_API | ( | uint64_t | ) | const |
Calculate Unpadded Size.
Calculate the total encoded size of a Block.
The Index field stores Unpadded Size and Uncompressed Size. The latter can be taken directly from the lzma_block structure after coding a Block, but Unpadded Size needs to be calculated from Block Header Size, Compressed Size, and size of the Check field. This is where this function is needed.
This is equivalent to lzma_block_unpadded_size() except that the returned value includes the size of the Block Padding field.
Calculate Unpadded Size.
Get the memory usage of decoder filter chain.
Calculate CRC64 using the polynomial from the ECMA-182 standard.
This function is used similarly to lzma_crc32(). See its documentation.
Definition at line 131 of file block_util.c.
LZMA_API | ( | size_t | ) |
Calculate maximum output size for single-call Block encoding.
This is equivalent to lzma_stream_buffer_bound() but for .xz Blocks. See the documentation of lzma_stream_buffer_bound().
Definition at line 73 of file block_buffer_encoder.c.
References lzma_block_buffer_bound64(), SIZE_MAX, and uncompressed_size.
uint64_t const lzma_allocator * allocator |
Definition at line 377 of file block.h.
Referenced by alone_decode(), alone_decoder_end(), alone_encode(), alone_encoder_end(), alone_encoder_init(), arm_coder_init(), armthumb_coder_init(), auto_decode(), auto_decoder_end(), auto_decoder_init(), block_buffer_encode(), block_decode(), block_decoder_end(), block_encode(), block_encode_normal(), block_encoder_end(), block_encoder_init(), block_encoder_update(), copy_or_code(), delta_coder_end(), delta_decode(), delta_encode(), delta_encoder_update(), fill_window(), free_properties(), get_thread(), ia64_coder_init(), index_decode(), index_decoder_end(), index_decoder_init(), index_decoder_reset(), index_dup_stream(), index_encoder_end(), index_init_plain(), index_stream_end(), index_stream_init(), index_tree_end(), index_tree_node_end(), initialize_new_thread(), lz_decode(), lz_decoder_end(), lz_encode(), lz_encoder_end(), lz_encoder_init(), lz_encoder_prepare(), lz_encoder_update(), lzma2_decoder_end(), lzma2_decoder_init(), lzma2_encoder_end(), lzma2_encoder_init(), lzma_alone_decoder_init(), LZMA_API(), lzma_attribute(), lzma_block_decoder_init(), lzma_block_encoder_init(), lzma_decoder_init(), lzma_delta_coder_init(), lzma_delta_decoder_init(), lzma_delta_encoder_init(), lzma_delta_props_decode(), lzma_encoder_init(), lzma_free(), lzma_index_encoder_init(), lzma_lz_decoder_init(), lzma_lz_encoder_init(), lzma_lzma2_decoder_init(), lzma_lzma2_encoder_init(), lzma_lzma_decoder_create(), lzma_lzma_decoder_init(), lzma_lzma_encoder_create(), lzma_lzma_encoder_init(), lzma_lzma_props_decode(), lzma_next_end(), lzma_next_filter_init(), lzma_next_filter_update(), lzma_outq_end(), lzma_outq_init(), lzma_raw_coder_init(), lzma_raw_decoder_init(), lzma_raw_encoder_init(), lzma_simple_arm_decoder_init(), lzma_simple_arm_encoder_init(), lzma_simple_armthumb_decoder_init(), lzma_simple_armthumb_encoder_init(), lzma_simple_coder_init(), lzma_simple_ia64_decoder_init(), lzma_simple_ia64_encoder_init(), lzma_simple_powerpc_decoder_init(), lzma_simple_powerpc_encoder_init(), lzma_simple_props_decode(), lzma_simple_sparc_decoder_init(), lzma_simple_sparc_encoder_init(), lzma_simple_x86_decoder_init(), lzma_simple_x86_encoder_init(), lzma_stream_decoder_init(), powerpc_coder_init(), simple_code(), simple_coder_end(), simple_coder_update(), sparc_coder_init(), stream_decode(), stream_decoder_end(), stream_decoder_reset(), stream_encode(), stream_encode_in(), stream_encode_mt(), stream_encoder_end(), stream_encoder_init(), stream_encoder_mt_end(), stream_encoder_mt_init(), stream_encoder_update(), threads_end(), and x86_coder_init().
const lzma_allocator const uint8_t * in |
Definition at line 527 of file block.h.
Referenced by _zip_crypto_aes_encrypt_block(), _zip_pkware_decrypt(), _zip_pkware_encrypt(), addpoint(), agraph_follow_innodes(), agraph_get_title(), agraph_print_edges(), alone_decode(), alone_encode(), amd29k_instr_decode(), anop32(), anop_esil(), apply_FP(), apply_IP(), gzifstream::attach(), gzfilebuf::attach(), auto_decode(), base64decode(), base64encode(), bclose(), bget4(), bin_pe_init_sections(), blast(), bload(), block_buffer_encode(), block_decode(), block_encode(), block_encode_normal(), block_encode_uncompressed(), bopen(), bskip(), coder_loop(), copy_and_encode(), copy_or_code(), cr16_analysis_4bit_opcode(), cr16_decode_command(), cr16_decode_i_r(), createdb(), decode_buffer(), decode_known(), decode_unknown(), decoder_loop(), decoder_loop_ret(), decryptaes(), def(), deflate_index_build(), deflate_index_extract(), delta_decode(), delta_encode(), dict_write(), encode(), encryptaes(), fill_window(), fn(), fullSpeedBench(), get_edge_number(), gzcopy(), gzhead(), gzheader(), gzip_normalize(), gztack(), handle_redirection(), handle_redirection_proc(), i2u16(), i2ut16(), index_decode(), inf(), inflate(), inflate_fast(), inflateSync(), instrGet(), is_cpu(), libdemangle_handler_rust(), load(), local_b64_decode(), local_b64_encode(), local_LZ4_compress_default_large(), local_LZ4_compress_default_small(), local_LZ4_compress_destSize(), local_LZ4_compress_fast0(), local_LZ4_compress_fast1(), local_LZ4_compress_fast17(), local_LZ4_compress_fast2(), local_LZ4_compress_fast_continue0(), local_LZ4_compress_fast_extState0(), local_LZ4_compress_forceDict(), local_LZ4_compress_HC(), local_LZ4_compress_HC_continue(), local_LZ4_compress_HC_extStateHC(), local_LZ4_decompress_fast(), local_LZ4_decompress_fast_usingDict_prefix(), local_LZ4_decompress_fast_usingExtDict(), local_LZ4_decompress_safe_forceExtDict(), local_LZ4_decompress_safe_partial(), local_LZ4_decompress_safe_usingDict(), local_LZ4_decompress_safe_withPrefix64k(), local_LZ4_saveDict(), local_LZ4_saveDictHC(), local_LZ4F_compressFrame(), local_LZ4F_decompress(), lz_decode(), lz_encode(), lzh_init(), lzma2_decode(), LZMA_API(), lzma_bufcpy(), lzma_decode(), main(), MD5Transform(), msp430_decode_command(), noned_init(), oids_od_bfind(), op_at_phys(), gzfilebuf::open(), gzifstream::open(), gzfilebuf::open_mode(), optimise_sboxes(), parseOpcode(), partcompress(), propeller_decode_command(), rc_read_init(), read4(), readin(), readmore(), replace_seq(), rip(), run_old_command(), rz_base64_decode(), rz_base64_decode_dyn(), rz_base64_encode(), rz_base91_decode(), rz_base91_encode(), rz_cmd(), rz_cons_grep_line(), rz_cons_grepbuf(), rz_cons_newline(), rz_des_permute_key_inv(), rz_file_gzslurp(), rz_hex_bin2str(), rz_hex_bin2strdup(), rz_hex_bin_truncate(), rz_hex_str2bin(), rz_hex_str2binmask(), rz_hex_ut2st_str(), rz_main_rzpipe(), rz_parse_assemble(), rz_parse_filter_dup(), rz_str_bits64(), rz_str_utf16_to_utf8(), rzp_open_spawn(), sdb_decode(), serpent_decrypt(), serpent_encrypt(), serpent_keyschedule(), gzfilebuf::showmanyc(), simple_code(), skip(), spp_file(), spp_io(), stream_decode(), stream_encode(), stream_encode_in(), stream_encode_mt(), stream_flags_decode(), tar(), test(), tokenize(), gzfilebuf::underflow(), utf16be_to_utf8_impl(), uv_thread_create_ex(), v850_decode_command(), xap_op(), and zpull().
const lzma_allocator const uint8_t size_t * in_pos |
Definition at line 579 of file block.h.
Referenced by alone_decode(), alone_encode(), auto_decode(), block_decode(), block_encode(), block_encode_normal(), block_encode_uncompressed(), copy_or_code(), decode_buffer(), decompress_empty(), delta_decode(), delta_encode(), dict_write(), fill_window(), index_decode(), lz_decode(), lz_encode(), lzma2_decode(), LZMA_API(), lzma_bufcpy(), lzma_decode(), message_progress_update(), progress_flush(), progress_percentage(), progress_pos(), progress_remaining(), rc_read_init(), simple_code(), stream_decode(), stream_encode(), stream_encode_in(), stream_encode_mt(), and worker_encode().
Definition at line 527 of file block.h.
Referenced by alone_decode(), alone_encode(), auto_decode(), block_buffer_encode(), block_decode(), block_encode(), block_encode_normal(), block_encode_uncompressed(), coder_loop(), coder_run(), copy_or_code(), decode_buffer(), decoder_loop(), decoder_loop_ret(), delta_decode(), delta_encode(), dict_write(), fill_window(), index_decode(), lz_decode(), lz_encode(), lzma2_decode(), LZMA_API(), lzma_bufcpy(), lzma_decode(), main(), message_progress_start(), rc_read_init(), simple_code(), stream_decode(), stream_encode(), stream_encode_in(), stream_encode_mt(), and worker_encode().
uint8_t * out |
Definition at line 528 of file block.h.
Referenced by __apply_filter_cmd(), __handle_cmd_str_cache(), __open(), __rap_reg_profile(), __read(), __search_db(), __show_status_input(), __system(), __write(), _zip_crypto_aes_encrypt_block(), _zip_pkware_decrypt(), _zip_pkware_encrypt(), addpoint(), alone_decode(), alone_encode(), annotated_hexdump(), apply_FP(), apply_IP(), apprentice_compile(), apprentice_load(), asm_test_failed_both_ways(), assemble(), gzofstream::attach(), gzfilebuf::attach(), auto_decode(), autocomplete_process_path(), autocomplete_sdb(), autocompleteFilename(), base64decode(), base64encode(), block_buffer_encode(), block_decode(), block_encode(), block_encode_normal(), block_encode_uncompressed(), cabd_sys_read_block(), cmd_analysis_esil(), cmd_get_desc_best(), coder_loop(), consume_limits_r(), consume_locals_r(), consume_s7_r(), consume_str_r(), consume_u1_r(), consume_u32_r(), consume_u7_r(), convert_relocs(), copy_and_encode(), copy_or_code(), core_cmd_pipe(), create_output_name(), dcpu16_assemble(), dcpu16_disasm(), decode_buffer(), decryptaes(), def(), DEFINE_HANDLE_TS_FCN_AND_SYMBOL(), deflate_index_extract(), delta_decode(), delta_encode(), dem_str_ndup(), do_fputs(), do_handle_substitution_cmd(), ds_print_meta_infos(), emit_get_ar(), emit_get_var(), encode(), encode_tuple(), encryptaes(), esil_poke_n(), file_vprintf(), find_e_opts(), find_include(), format_reg_value(), from_ebcdic(), fullSpeedBench(), get_lines(), getarg(), getstr(), gzcopy(), gzinit(), gzip_normalize(), gztack(), handle_cmd_substitution_arg(), handle_redirection(), handle_redirection_proc(), i8080_op(), ihex_write(), index_decode(), index_encode(), inf(), inflate(), inflate_fast(), inflateBack(), inflateBack9(), inflateSync(), insert_offset(), instrPrint(), interact_fix_asm(), interact_fix_cmd(), lh5801_print_insn(), libdemangle_handler_msvc(), libdemangle_handler_rust(), libdemangle_handler_swift(), local_b64_decode(), local_b64_encode(), local_LZ4_compress_default_large(), local_LZ4_compress_default_small(), local_LZ4_compress_destSize(), local_LZ4_compress_fast0(), local_LZ4_compress_fast1(), local_LZ4_compress_fast17(), local_LZ4_compress_fast2(), local_LZ4_compress_fast_continue0(), local_LZ4_compress_fast_extState0(), local_LZ4_compress_forceDict(), local_LZ4_compress_HC(), local_LZ4_compress_HC_continue(), local_LZ4_compress_HC_extStateHC(), local_LZ4_decompress_fast(), local_LZ4_decompress_fast_usingDict_prefix(), local_LZ4_decompress_fast_usingExtDict(), local_LZ4_decompress_safe_forceExtDict(), local_LZ4_decompress_safe_partial(), local_LZ4_decompress_safe_usingDict(), local_LZ4_decompress_safe_withPrefix64k(), local_LZ4_saveDict(), local_LZ4_saveDictHC(), local_LZ4F_compressFrame(), local_LZ4F_decompress(), lz_decode(), lz_encode(), lzh_init(), lzma2_encode(), LZMA_API(), lzma_bufcpy(), lzma_decode(), lzma_delta_props_encode(), lzma_encode(), lzma_lzma2_props_encode(), lzma_lzma_encode(), lzma_outq_read(), lzma_simple_props_encode(), main(), mf_read(), mips_assemble(), mnem_acall(), mnem_add(), mnem_addc(), mnem_ajmp(), mnem_anl(), mnem_cjne(), mnem_clr(), mnem_cpl(), mnem_da(), mnem_dec(), mnem_div(), mnem_djnz(), mnem_inc(), mnem_jb(), mnem_jbc(), mnem_jc(), mnem_jmp(), mnem_jnb(), mnem_jnc(), mnem_jnz(), mnem_jz(), mnem_lcall(), mnem_ljmp(), mnem_mov(), mnem_mov_c(), mnem_movc(), mnem_movx(), mnem_mul(), mnem_nop(), mnem_orl(), mnem_pop(), mnem_push(), mnem_ret(), mnem_reti(), mnem_rl(), mnem_rlc(), mnem_rr(), mnem_rrc(), mnem_setb(), mnem_sjmp(), mnem_subb(), mnem_swap(), mnem_xch(), mnem_xchd(), mnem_xrl(), mpcf_re_range(), noned_init(), num_callback(), oabd_decompress(), oabd_decompress_incremental(), op_at_phys(), gzfilebuf::open(), gzofstream::open(), gzfilebuf::open_mode(), optimise_sboxes(), out_printf(), gzfilebuf::overflow(), parse_hexadecimal(), parseHeap(), parseOpcode(), poll_cb(), print_result_diff(), printCol(), procfs_pid_slurp(), put4(), PUT_CALLBACK(), rax(), rc_encode(), rc_shift_low(), read_ptr_pa(), read_ptr_va(), relative_address(), replace_seq(), rip(), rop_classify_arithmetic(), rop_classify_arithmetic_const(), rop_classify_constant(), rop_classify_mov(), rop_classify_nops(), rop_kuery(), run_rz_test(), rz_analysis_class_unique_attr_id_raw(), rz_analysis_cond_to_string(), rz_analysis_reflines_str(), rz_analysis_value_to_string(), rz_asm_rasm_assemble(), rz_base64_decode(), rz_base64_encode(), rz_base91_decode(), rz_base91_encode(), rz_bin_addr2text(), rz_cf_value_data_new(), rz_cmd(), rz_cmd_alias(), rz_cmd_debug_process_profile_edit_handler(), rz_cmd_help(), rz_cmd_kuery(), rz_cmd_print(), rz_cons_grep_line(), rz_cons_grepbuf(), rz_cons_pal_parse(), rz_core_analysis_il_vm_status(), rz_core_bin_method_flags_str(), rz_core_cmd_foreach(), rz_core_cmd_pipe_old(), rz_core_cmd_subst_i(), rz_core_kuery_print(), rz_core_meta_editor(), rz_core_meta_string_add(), rz_core_rtr_http_run(), rz_core_run_script(), rz_core_visual_analysis_refresh(), rz_core_visual_analysis_refresh_column(), rz_core_yank_hexpair(), rz_des_permute_key_inv(), rz_diff_myers_distance(), rz_egg_mkvar(), rz_egg_raw(), rz_egg_raw_prepend(), rz_file_gzslurp(), rz_hex_bin2str(), rz_hex_bin2strdup(), rz_hex_from_c(), rz_hex_from_c_array(), rz_hex_from_c_str(), rz_hex_from_js(), rz_hex_from_py(), rz_hex_from_py_array(), rz_hex_from_py_str(), rz_hex_no_code(), rz_hex_str2bin(), rz_hex_str2binmask(), rz_hex_ut2st_str(), rz_main_rzpipe(), rz_num_to_bits(), rz_num_to_trits(), rz_parse_filter_dup(), rz_print_colorize_asm_str(), rz_reg_get_bvalue(), rz_socket_http_response(), rz_str_ansi_filter(), rz_str_binstr2bin(), rz_str_bits_from_string(), rz_str_escape_(), rz_str_ndup(), rz_str_scale(), rz_str_word_get0set(), rz_subprocess_drain(), rz_subprocess_output_free(), rz_syscmd_join(), rz_test_asm_test_output_free(), rz_test_check_asm_test(), rz_test_check_cmd_test(), rz_test_check_fuzz_test(), rz_test_check_json_test(), rz_test_run_asm_test(), rz_test_run_cmd_test(), rz_test_run_test(), rzp_open_spawn(), sdb_aslice(), sdb_decode(), sdb_encode(), sdb_fmt_tostr(), sdb_query(), sdb_querys(), serpent_decrypt(), serpent_encrypt(), serpent_keyschedule(), simple_code(), single_a_arg_instr(), single_byte_instr(), singlearg_bit(), singlearg_direct(), singlearg_immediate(), singlearg_register(), singlearg_reladdr(), spc700_disas(), spp_eval(), spp_eval_str(), spp_file(), spp_io(), spp_proc_eval(), spp_run(), stream_decode(), stream_encode(), stream_encode_mt(), stream_flags_encode(), subprocess_runner(), system_common_handler(), TAG_CALLBACK(), tokenize(), usage(), uv__fs_copyfile(), uv__fs_sendfile_emul(), uv__get_cpu_speed(), uv__set_process_title(), uv_cpu_info(), uv_exepath(), uv_pipe_connect(), uv_process_tty_read_raw_req(), UV_UNUSED(), valPrint(), walk_namespace(), and winkd_walk_vadtree().
Definition at line 528 of file block.h.
Referenced by alone_decode(), alone_encode(), auto_decode(), block_buffer_encode(), block_decode(), block_encode(), block_encode_normal(), block_encode_uncompressed(), copy_or_code(), decode_buffer(), decompress_empty(), delta_decode(), delta_encode(), encode(), index_encode(), lz_decode(), lz_encode(), lzma2_encode(), LZMA_API(), lzma_bufcpy(), lzma_encode(), lzma_lzma_encode(), lzma_outq_read(), mf_read(), progress_pos(), rc_encode(), rc_shift_low(), simple_code(), stream_decode(), stream_encode(), and stream_encode_mt().