| Index: utility/bmpblk_utility.cc
|
| diff --git a/utility/bmpblk_utility.cc b/utility/bmpblk_utility.cc
|
| index 9f912d0b0a0b6ae1af239a0e6438013551ddbf77..fd8c8f6899f17ab48723b645748218ac17ea782e 100644
|
| --- a/utility/bmpblk_utility.cc
|
| +++ b/utility/bmpblk_utility.cc
|
| @@ -10,6 +10,7 @@
|
| #include <assert.h>
|
| #include <errno.h>
|
| #include <getopt.h>
|
| +#include <lzma.h>
|
| #include <stdarg.h>
|
| #include <stdio.h>
|
| #include <stdlib.h>
|
| @@ -326,6 +327,37 @@ void BmpBlockUtil::load_all_image_files() {
|
| free(tmpbuf);
|
| }
|
| break;
|
| + case COMPRESS_LZMA:
|
| + {
|
| + // Calculate the worst case of buffer size.
|
| + uint32_t tmpsize = lzma_stream_buffer_bound(content.size());
|
| + uint8_t *tmpbuf = (uint8_t *)malloc(tmpsize);
|
| + lzma_stream stream = LZMA_STREAM_INIT;
|
| + lzma_ret result;
|
| +
|
| + result = lzma_easy_encoder(&stream, 9, LZMA_CHECK_NONE);
|
| + if (result != LZMA_OK) {
|
| + error("Unable to initialize easy encoder (error: %d)!\n", result);
|
| + }
|
| +
|
| + stream.next_in = (uint8_t *)content.data();
|
| + stream.avail_in = content.size();
|
| + do {
|
| + stream.next_out = tmpbuf;
|
| + stream.avail_out = tmpsize;
|
| + result = lzma_code(&stream, LZMA_FINISH);
|
| + if (result != LZMA_OK && result != LZMA_STREAM_END) {
|
| + error("Unable to encode data (error: %d)!\n", result);
|
| + }
|
| + } while (result == LZMA_OK);
|
| + it->second.data.compression = compression_;
|
| + it->second.compressed_content.assign((const char *)tmpbuf,
|
| + tmpsize - stream.avail_out);
|
| + it->second.data.compressed_size = tmpsize - stream.avail_out;
|
| + lzma_end(&stream);
|
| + free(tmpbuf);
|
| + }
|
| + break;
|
| default:
|
| error("Unsupported compression method attempted.\n");
|
| }
|
| @@ -535,7 +567,7 @@ static void usagehelp_exit(const char *prog_name) {
|
| " -z NUM = compression algorithm to use\n"
|
| " 0 = none\n"
|
| " 1 = EFIv1\n"
|
| - " 2 = TBD\n"
|
| + " 2 = LZMA\n"
|
| "\n", prog_name);
|
| printf(
|
| "To display the contents of a BMPBLOCK:\n"
|
|
|