summaryrefslogtreecommitdiff
path: root/utility
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2011-02-17 14:30:14 -0800
committerBill Richardson <wfrichar@chromium.org>2011-02-17 14:30:14 -0800
commita7209ee2de570a1404e6df247df4a68c72d16245 (patch)
tree42a8807d37c4bcda4f94c7959c3394a22904472b /utility
parentf456e83dfd12310f146fdbedde5888a6e6293c9b (diff)
downloadvboot-a7209ee2de570a1404e6df247df4a68c72d16245.tar.gz
Allow yaml file to specify default compression for images
BUG=chromium-os:11490 TEST=manual cd src/platform/vboot_reference make make runbmptests Change-Id: Ia887fc1aa1de873c6da6c04995bc0a9ad6b364aa Review URL: http://codereview.chromium.org/6541001
Diffstat (limited to 'utility')
-rw-r--r--utility/bmpblk_util.c13
-rw-r--r--utility/bmpblk_utility.cc20
-rw-r--r--utility/include/bmpblk_utility.h1
3 files changed, 33 insertions, 1 deletions
diff --git a/utility/bmpblk_util.c b/utility/bmpblk_util.c
index f2b0adc8..5c94d8e9 100644
--- a/utility/bmpblk_util.c
+++ b/utility/bmpblk_util.c
@@ -264,11 +264,22 @@ int dump_bmpblock(const char *infile, int show_as_yaml,
// Write out yaml
fprintf(yfp, "bmpblock: %d.%d\n", hdr->major_version, hdr->minor_version);
- fprintf(yfp, "images:\n");
offset = sizeof(BmpBlockHeader) +
(sizeof(ScreenLayout) *
hdr->number_of_localizations *
hdr->number_of_screenlayouts);
+ // FIXME(chromium-os:12134): The bmbblock structure allows each image to be
+ // compressed differently, but we haven't provided a way for the yaml file to
+ // specify that. Additionally, we allow the yaml file to specify a default
+ // compression scheme for all images, but only if that line appears in the
+ // yaml file before any images. Accordingly, we'll just check the first image
+ // to see if it has any compression, and if it does, we'll write that out as
+ // the default. When this bug is fixed, we should just write each image's
+ // compression setting separately.
+ img = (ImageInfo *)(ptr + offset);
+ if (img->compression)
+ fprintf(yfp, "compression: %d\n", img->compression);
+ fprintf(yfp, "images:\n");
for(i=0; i<hdr->number_of_imageinfos; i++) {
img = (ImageInfo *)(ptr + offset);
sprintf(image_name, "img_%08x.bmp", offset);
diff --git a/utility/bmpblk_utility.cc b/utility/bmpblk_utility.cc
index 8605dde0..078a5ceb 100644
--- a/utility/bmpblk_utility.cc
+++ b/utility/bmpblk_utility.cc
@@ -139,6 +139,8 @@ void BmpBlockUtil::parse_first_layer(yaml_parser_t *parser) {
keyword = (char*)event.data.scalar.value;
if (keyword == "bmpblock") {
parse_bmpblock(parser);
+ } else if (keyword == "compression") {
+ parse_compression(parser);
} else if (keyword == "images") {
parse_images(parser);
} else if (keyword == "screens") {
@@ -174,6 +176,24 @@ void BmpBlockUtil::parse_bmpblock(yaml_parser_t *parser) {
yaml_event_delete(&event);
}
+void BmpBlockUtil::parse_compression(yaml_parser_t *parser) {
+ yaml_event_t event;
+ yaml_parser_parse(parser, &event);
+ if (event.type != YAML_SCALAR_EVENT) {
+ error("Syntax error in parsing bmpblock.\n");
+ }
+ char *comp_str = (char *)event.data.scalar.value;
+ char *e = 0;
+ uint32_t comp = (uint32_t)strtoul(comp_str, &e, 0);
+ if (!*comp_str || (e && *e) || comp >= MAX_COMPRESS) {
+ error("Invalid compression specified in config file\n");
+ }
+ if (!set_compression_) {
+ compression_ = comp;
+ }
+ yaml_event_delete(&event);
+}
+
void BmpBlockUtil::parse_images(yaml_parser_t *parser) {
yaml_event_t event;
string image_name, image_filename;
diff --git a/utility/include/bmpblk_utility.h b/utility/include/bmpblk_utility.h
index 53f135d7..9c708ba3 100644
--- a/utility/include/bmpblk_utility.h
+++ b/utility/include/bmpblk_utility.h
@@ -93,6 +93,7 @@ class BmpBlockUtil {
void parse_config(yaml_parser_t *parser);
void parse_first_layer(yaml_parser_t *parser);
void parse_bmpblock(yaml_parser_t *parser);
+ void parse_compression(yaml_parser_t *parser);
void parse_images(yaml_parser_t *parser);
void parse_layout(yaml_parser_t *parser, ScreenConfig &screen);
void parse_screens(yaml_parser_t *parser);