diff options
author | Jens Arnold <amiconn@rockbox.org> | 2006-11-20 00:55:09 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2006-11-20 00:55:09 +0000 |
commit | 0b2ac4b427a3013c0e4f20560e78c0216ed4d803 (patch) | |
tree | c87341aa1fa725d01b906a2fa087dc65b69d1f83 /apps | |
parent | 848e0b5a16826cbc729dc0b24d0d1acef58a1304 (diff) | |
download | rockbox-0b2ac4b427a3013c0e4f20560e78c0216ed4d803.tar.gz rockbox-0b2ac4b427a3013c0e4f20560e78c0216ed4d803.zip |
BMP loader: Using shifts for division by powers of 2 saves a bit on code size.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11559 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/recorder/bmp.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/apps/recorder/bmp.c b/apps/recorder/bmp.c index 96b915f840..b33c0a329d 100644 --- a/apps/recorder/bmp.c +++ b/apps/recorder/bmp.c | |||
@@ -223,7 +223,7 @@ int read_bmp_file(char* filename, | |||
223 | } | 223 | } |
224 | 224 | ||
225 | depth = readshort(&bmph.bit_count); | 225 | depth = readshort(&bmph.bit_count); |
226 | padded_width = ((width * depth + 31) / 8) & ~3; /* 4-byte boundary aligned */ | 226 | padded_width = ((width * depth + 31) >> 3) & ~3; /* 4-byte boundary aligned */ |
227 | 227 | ||
228 | #if (LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) | 228 | #if (LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) |
229 | if (format == FORMAT_ANY) { | 229 | if (format == FORMAT_ANY) { |
@@ -244,7 +244,7 @@ int read_bmp_file(char* filename, | |||
244 | if (remote) { | 244 | if (remote) { |
245 | #if (LCD_REMOTE_DEPTH == 2) && (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED) | 245 | #if (LCD_REMOTE_DEPTH == 2) && (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED) |
246 | dst_width = width; | 246 | dst_width = width; |
247 | dst_height = (height + 7) / 8; | 247 | dst_height = (height + 7) >> 3; |
248 | #endif /* LCD_REMOTE_DEPTH / LCD_REMOTE_PIXELFORMAT */ | 248 | #endif /* LCD_REMOTE_DEPTH / LCD_REMOTE_PIXELFORMAT */ |
249 | totalsize = dst_width * dst_height * sizeof(fb_remote_data); | 249 | totalsize = dst_width * dst_height * sizeof(fb_remote_data); |
250 | } else | 250 | } else |
@@ -253,9 +253,9 @@ int read_bmp_file(char* filename, | |||
253 | #if LCD_DEPTH == 2 | 253 | #if LCD_DEPTH == 2 |
254 | #if LCD_PIXELFORMAT == VERTICAL_PACKING | 254 | #if LCD_PIXELFORMAT == VERTICAL_PACKING |
255 | dst_width = width; | 255 | dst_width = width; |
256 | dst_height = (height + 3) / 4; | 256 | dst_height = (height + 3) >> 2; |
257 | #else /* LCD_PIXELFORMAT == HORIZONTAL_PACKING */ | 257 | #else /* LCD_PIXELFORMAT == HORIZONTAL_PACKING */ |
258 | dst_width = (width + 3) / 4; | 258 | dst_width = (width + 3) >> 2; |
259 | dst_height = height; | 259 | dst_height = height; |
260 | #endif /* LCD_PIXELFORMAT */ | 260 | #endif /* LCD_PIXELFORMAT */ |
261 | #elif LCD_DEPTH == 16 | 261 | #elif LCD_DEPTH == 16 |
@@ -268,7 +268,7 @@ int read_bmp_file(char* filename, | |||
268 | #endif /* (LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) */ | 268 | #endif /* (LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) */ |
269 | { | 269 | { |
270 | dst_width = width; | 270 | dst_width = width; |
271 | dst_height = (height + 7) / 8; | 271 | dst_height = (height + 7) >> 3; |
272 | totalsize = dst_width * dst_height; | 272 | totalsize = dst_width * dst_height; |
273 | } | 273 | } |
274 | 274 | ||
@@ -364,7 +364,7 @@ int read_bmp_file(char* filename, | |||
364 | case 1: | 364 | case 1: |
365 | q0.raw = palette[0]; | 365 | q0.raw = palette[0]; |
366 | q1.raw = palette[1]; | 366 | q1.raw = palette[1]; |
367 | p = (unsigned char*)bmpbuf + (width + 7) / 8; | 367 | p = (unsigned char*)bmpbuf + ((width + 7) >> 3); |
368 | mask = 0x80 >> ((width + 7) & 7); | 368 | mask = 0x80 >> ((width + 7) & 7); |
369 | while (p > (unsigned char*)bmpbuf) { | 369 | while (p > (unsigned char*)bmpbuf) { |
370 | data = *(--p); | 370 | data = *(--p); |
@@ -377,7 +377,7 @@ int read_bmp_file(char* filename, | |||
377 | case 4: | 377 | case 4: |
378 | if (width & 1) | 378 | if (width & 1) |
379 | rp++; | 379 | rp++; |
380 | p = (unsigned char*)bmpbuf + (width + 1) / 2; | 380 | p = (unsigned char*)bmpbuf + ((width + 1) >> 1); |
381 | while (p > (unsigned char*)bmpbuf) { | 381 | while (p > (unsigned char*)bmpbuf) { |
382 | data = *(--p); | 382 | data = *(--p); |
383 | *(--rp) = palette[data & 0x0f]; | 383 | *(--rp) = palette[data & 0x0f]; |
@@ -460,7 +460,7 @@ int read_bmp_file(char* filename, | |||
460 | if (remote) { | 460 | if (remote) { |
461 | #if (LCD_REMOTE_DEPTH == 2) && (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED) | 461 | #if (LCD_REMOTE_DEPTH == 2) && (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED) |
462 | fb_remote_data *dest = (fb_remote_data *)bitmap | 462 | fb_remote_data *dest = (fb_remote_data *)bitmap |
463 | + dst_width * (row / 8); | 463 | + dst_width * (row >> 3); |
464 | int shift = row & 7; | 464 | int shift = row & 7; |
465 | int delta = 127; | 465 | int delta = 127; |
466 | unsigned bright; | 466 | unsigned bright; |
@@ -479,7 +479,7 @@ int read_bmp_file(char* filename, | |||
479 | #if LCD_DEPTH == 2 | 479 | #if LCD_DEPTH == 2 |
480 | #if LCD_PIXELFORMAT == VERTICAL_PACKING | 480 | #if LCD_PIXELFORMAT == VERTICAL_PACKING |
481 | /* iriver H1x0 */ | 481 | /* iriver H1x0 */ |
482 | fb_data *dest = (fb_data *)bitmap + dst_width * (row / 4); | 482 | fb_data *dest = (fb_data *)bitmap + dst_width * (row >> 2); |
483 | int shift = 2 * (row & 3); | 483 | int shift = 2 * (row & 3); |
484 | int delta = 127; | 484 | int delta = 127; |
485 | unsigned bright; | 485 | unsigned bright; |
@@ -535,7 +535,7 @@ int read_bmp_file(char* filename, | |||
535 | } else | 535 | } else |
536 | #endif /* (LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) */ | 536 | #endif /* (LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) */ |
537 | { | 537 | { |
538 | p = bitmap + dst_width * (row / 8); | 538 | p = bitmap + dst_width * (row >> 3); |
539 | mask = 1 << (row & 7); | 539 | mask = 1 << (row & 7); |
540 | 540 | ||
541 | for (col = 0; col < width; col++, p++) | 541 | for (col = 0; col < width; col++, p++) |