OLD | NEW |
1 /** | 1 /** |
2 * \file lzma/base.h | 2 * \file lzma/base.h |
3 * \brief Data types and functions used in many places in liblzma API | 3 * \brief Data types and functions used in many places in liblzma API |
4 */ | 4 */ |
5 | 5 |
6 /* | 6 /* |
7 * Author: Lasse Collin | 7 * Author: Lasse Collin |
8 * | 8 * |
9 * This file has been put into the public domain. | 9 * This file has been put into the public domain. |
10 * You can do whatever you want with this file. | 10 * You can do whatever you want with this file. |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 * network. | 274 * network. |
275 * | 275 * |
276 * Only some filters support LZMA_SYNC_FLUSH. Trying to use | 276 * Only some filters support LZMA_SYNC_FLUSH. Trying to use |
277 * LZMA_SYNC_FLUSH with filters that don't support it will | 277 * LZMA_SYNC_FLUSH with filters that don't support it will |
278 * make lzma_code() return LZMA_OPTIONS_ERROR. For example, | 278 * make lzma_code() return LZMA_OPTIONS_ERROR. For example, |
279 * LZMA1 doesn't support LZMA_SYNC_FLUSH but LZMA2 does. | 279 * LZMA1 doesn't support LZMA_SYNC_FLUSH but LZMA2 does. |
280 * | 280 * |
281 * Using LZMA_SYNC_FLUSH very often can dramatically reduce | 281 * Using LZMA_SYNC_FLUSH very often can dramatically reduce |
282 * the compression ratio. With some filters (for example, | 282 * the compression ratio. With some filters (for example, |
283 * LZMA2), fine-tuning the compression options may help | 283 * LZMA2), fine-tuning the compression options may help |
284 » » * mitigate this problem significantly. | 284 » » * mitigate this problem significantly (for example, |
| 285 » » * match finder with LZMA2). |
285 * | 286 * |
286 * Decoders don't support LZMA_SYNC_FLUSH. | 287 * Decoders don't support LZMA_SYNC_FLUSH. |
287 */ | 288 */ |
288 | 289 |
289 LZMA_FULL_FLUSH = 2, | 290 LZMA_FULL_FLUSH = 2, |
290 /**< | 291 /**< |
291 » » * \brief Make all the input available at output | 292 » » * \brief Finish encoding of the current Block |
292 * | 293 * |
293 » » * Finish encoding of the current Block. All the input | 294 » » * All the input data going to the current Block must have |
294 » » * data going to the current Block must have been given | 295 » » * been given to the encoder (the last bytes can still be |
295 » » * to the encoder (the last bytes can still be pending in | 296 » » * pending in* next_in). Call lzma_code() with LZMA_FULL_FLUSH |
296 » » * next_in). Call lzma_code() with LZMA_FULL_FLUSH until | 297 » » * until it returns LZMA_STREAM_END. Then continue normally |
297 » » * it returns LZMA_STREAM_END. Then continue normally with | 298 » » * with LZMA_RUN or finish the Stream with LZMA_FINISH. |
298 » » * LZMA_RUN or finish the Stream with LZMA_FINISH. | |
299 * | 299 * |
300 * This action is currently supported only by Stream encoder | 300 * This action is currently supported only by Stream encoder |
301 * and easy encoder (which uses Stream encoder). If there is | 301 * and easy encoder (which uses Stream encoder). If there is |
302 * no unfinished Block, no empty Block is created. | 302 * no unfinished Block, no empty Block is created. |
303 */ | 303 */ |
304 | 304 |
305 LZMA_FINISH = 3 | 305 LZMA_FINISH = 3 |
306 /**< | 306 /**< |
307 * \brief Finish the coding operation | 307 * \brief Finish the coding operation |
308 * | 308 * |
309 » » * Finishes the coding operation. All the input data must | 309 » » * All the input data must have been given to the encoder |
310 » » * have been given to the encoder (the last bytes can still | 310 » » * (the last bytes can still be pending in next_in). |
311 » » * be pending in next_in). Call lzma_code() with LZMA_FINISH | 311 » » * Call lzma_code() with LZMA_FINISH until it returns |
312 » » * until it returns LZMA_STREAM_END. Once LZMA_FINISH has | 312 » » * LZMA_STREAM_END. Once LZMA_FINISH has been used, |
313 » » * been used, the amount of input must no longer be changed | 313 » » * the amount of input must no longer be changed by |
314 » » * by the application. | 314 » » * the application. |
315 * | 315 * |
316 * When decoding, using LZMA_FINISH is optional unless the | 316 * When decoding, using LZMA_FINISH is optional unless the |
317 * LZMA_CONCATENATED flag was used when the decoder was | 317 * LZMA_CONCATENATED flag was used when the decoder was |
318 * initialized. When LZMA_CONCATENATED was not used, the only | 318 * initialized. When LZMA_CONCATENATED was not used, the only |
319 * effect of LZMA_FINISH is that the amount of input must not | 319 * effect of LZMA_FINISH is that the amount of input must not |
320 * be changed just like in the encoder. | 320 * be changed just like in the encoder. |
321 */ | 321 */ |
322 } lzma_action; | 322 } lzma_action; |
323 | 323 |
324 | 324 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 lzma_internal *internal; | 471 lzma_internal *internal; |
472 | 472 |
473 /* | 473 /* |
474 * Reserved space to allow possible future extensions without | 474 * Reserved space to allow possible future extensions without |
475 * breaking the ABI. Excluding the initialization of this structure, | 475 * breaking the ABI. Excluding the initialization of this structure, |
476 * you should not touch these, because the names of these variables | 476 * you should not touch these, because the names of these variables |
477 * may change. | 477 * may change. |
478 */ | 478 */ |
479 void *reserved_ptr1; | 479 void *reserved_ptr1; |
480 void *reserved_ptr2; | 480 void *reserved_ptr2; |
| 481 void *reserved_ptr3; |
| 482 void *reserved_ptr4; |
481 uint64_t reserved_int1; | 483 uint64_t reserved_int1; |
482 uint64_t reserved_int2; | 484 uint64_t reserved_int2; |
| 485 size_t reserved_int3; |
| 486 size_t reserved_int4; |
483 lzma_reserved_enum reserved_enum1; | 487 lzma_reserved_enum reserved_enum1; |
484 lzma_reserved_enum reserved_enum2; | 488 lzma_reserved_enum reserved_enum2; |
485 | 489 |
486 } lzma_stream; | 490 } lzma_stream; |
487 | 491 |
488 | 492 |
489 /** | 493 /** |
490 * \brief Initialization for lzma_stream | 494 * \brief Initialization for lzma_stream |
491 * | 495 * |
492 * When you declare an instance of lzma_stream, you can immediately | 496 * When you declare an instance of lzma_stream, you can immediately |
493 * initialize it so that initialization functions know that no memory | 497 * initialize it so that initialization functions know that no memory |
494 * has been allocated yet: | 498 * has been allocated yet: |
495 * | 499 * |
496 * lzma_stream strm = LZMA_STREAM_INIT; | 500 * lzma_stream strm = LZMA_STREAM_INIT; |
497 * | 501 * |
498 * If you need to initialize a dynamically allocated lzma_stream, you can use | 502 * If you need to initialize a dynamically allocated lzma_stream, you can use |
499 * memset(strm_pointer, 0, sizeof(lzma_stream)). Strictly speaking, this | 503 * memset(strm_pointer, 0, sizeof(lzma_stream)). Strictly speaking, this |
500 * violates the C standard since NULL may have different internal | 504 * violates the C standard since NULL may have different internal |
501 * representation than zero, but it should be portable enough in practice. | 505 * representation than zero, but it should be portable enough in practice. |
502 * Anyway, for maximum portability, you can use something like this: | 506 * Anyway, for maximum portability, you can use something like this: |
503 * | 507 * |
504 * lzma_stream tmp = LZMA_STREAM_INIT; | 508 * lzma_stream tmp = LZMA_STREAM_INIT; |
505 * *strm = tmp; | 509 * *strm = tmp; |
506 */ | 510 */ |
507 #define LZMA_STREAM_INIT \ | 511 #define LZMA_STREAM_INIT \ |
508 { NULL, 0, 0, NULL, 0, 0, NULL, NULL, \ | 512 { NULL, 0, 0, NULL, 0, 0, NULL, NULL, \ |
509 » NULL, NULL, 0, 0, LZMA_RESERVED_ENUM, LZMA_RESERVED_ENUM } | 513 » NULL, NULL, NULL, NULL, 0, 0, 0, 0, \ |
| 514 » LZMA_RESERVED_ENUM, LZMA_RESERVED_ENUM } |
510 | 515 |
511 | 516 |
512 /** | 517 /** |
513 * \brief Encode or decode data | 518 * \brief Encode or decode data |
514 * | 519 * |
515 * Once the lzma_stream has been successfully initialized (e.g. with | 520 * Once the lzma_stream has been successfully initialized (e.g. with |
516 * lzma_stream_encoder()), the actual encoding or decoding is done | 521 * lzma_stream_encoder()), the actual encoding or decoding is done |
517 * using this function. The application has to update strm->next_in, | 522 * using this function. The application has to update strm->next_in, |
518 * strm->avail_in, strm->next_out, and strm->avail_out to pass input | 523 * strm->avail_in, strm->next_out, and strm->avail_out to pass input |
519 * to and get output from liblzma. | 524 * to and get output from liblzma. |
(...skipping 27 matching lines...) Expand all Loading... |
547 * This function is currently supported only when *strm has been initialized | 552 * This function is currently supported only when *strm has been initialized |
548 * with a function that takes a memlimit argument. With other functions, you | 553 * with a function that takes a memlimit argument. With other functions, you |
549 * should use e.g. lzma_raw_encoder_memusage() or lzma_raw_decoder_memusage() | 554 * should use e.g. lzma_raw_encoder_memusage() or lzma_raw_decoder_memusage() |
550 * to estimate the memory requirements. | 555 * to estimate the memory requirements. |
551 * | 556 * |
552 * This function is useful e.g. after LZMA_MEMLIMIT_ERROR to find out how big | 557 * This function is useful e.g. after LZMA_MEMLIMIT_ERROR to find out how big |
553 * the memory usage limit should have been to decode the input. Note that | 558 * the memory usage limit should have been to decode the input. Note that |
554 * this may give misleading information if decoding .xz Streams that have | 559 * this may give misleading information if decoding .xz Streams that have |
555 * multiple Blocks, because each Block can have different memory requirements. | 560 * multiple Blocks, because each Block can have different memory requirements. |
556 * | 561 * |
557 * \return Rough estimate of how much memory is currently allocated | 562 * \return How much memory is currently allocated for the filter |
558 * for the filter decoders. If no filter chain is currently | 563 * decoders. If no filter chain is currently allocated, |
559 * allocated, some non-zero value is still returned, which is | 564 * some non-zero value is still returned, which is less than |
560 * less than or equal to what any filter chain would indicate | 565 * or equal to what any filter chain would indicate as its |
561 * as its memory requirement. | 566 * memory requirement. |
562 * | 567 * |
563 * If this function isn't supported by *strm or some other error | 568 * If this function isn't supported by *strm or some other error |
564 * occurs, zero is returned. | 569 * occurs, zero is returned. |
565 */ | 570 */ |
566 extern LZMA_API(uint64_t) lzma_memusage(const lzma_stream *strm) | 571 extern LZMA_API(uint64_t) lzma_memusage(const lzma_stream *strm) |
567 lzma_nothrow lzma_attr_pure; | 572 lzma_nothrow lzma_attr_pure; |
568 | 573 |
569 | 574 |
570 /** | 575 /** |
571 * \brief Get the current memory usage limit | 576 * \brief Get the current memory usage limit |
(...skipping 15 matching lines...) Expand all Loading... |
587 * a function that takes a memlimit argument. | 592 * a function that takes a memlimit argument. |
588 * | 593 * |
589 * \return - LZMA_OK: New memory usage limit successfully set. | 594 * \return - LZMA_OK: New memory usage limit successfully set. |
590 * - LZMA_MEMLIMIT_ERROR: The new limit is too small. | 595 * - LZMA_MEMLIMIT_ERROR: The new limit is too small. |
591 * The limit was not changed. | 596 * The limit was not changed. |
592 * - LZMA_PROG_ERROR: Invalid arguments, e.g. *strm doesn't | 597 * - LZMA_PROG_ERROR: Invalid arguments, e.g. *strm doesn't |
593 * support memory usage limit or memlimit was zero. | 598 * support memory usage limit or memlimit was zero. |
594 */ | 599 */ |
595 extern LZMA_API(lzma_ret) lzma_memlimit_set( | 600 extern LZMA_API(lzma_ret) lzma_memlimit_set( |
596 lzma_stream *strm, uint64_t memlimit) lzma_nothrow; | 601 lzma_stream *strm, uint64_t memlimit) lzma_nothrow; |
OLD | NEW |