Branch Coverage

bmp.c
Criterion Covered Total %
branch 282 370 76.2


line true false branch
84 13 12 if (im->type == i_direct_type) {
91 12 0 pal_size = i_colorcount(im);
92 4 8 if (pal_size <= 2) {
95 4 4 else if (pal_size <= 16) {
127 1 103 if (!read_packed(ig, "CCVvvVVV!V!vvVVVVVV", &b_magic, &m_magic, &filesize,
135 103 0 if (b_magic != 'B' || m_magic != 'M' || infohead_size != INFOHEAD_SIZE
103 0 if (b_magic != 'B' || m_magic != 'M' || infohead_size != INFOHEAD_SIZE
103 0 if (b_magic != 'B' || m_magic != 'M' || infohead_size != INFOHEAD_SIZE
136 1 102 || planes != 1) {
148 8 94 if (!i_int_check_image_file_limits(xsize, abs((int)ysize), 3, sizeof(i_sample_t))) {
181 58 35 if (im) {
183 58 0 if (xres && !yres)
0 58 if (xres && !yres)
185 58 0 else if (yres && !xres)
0 58 else if (yres && !xres)
187 58 0 if (xres) {
232 145505 125192 while (*format) {
233 144162 1343 p = va_arg(ap, i_packed_t *);
237 207 145298 if (shrieking) ++format;
241 0 414 if (i_io_read(ig, buf, 2) != 2)
244 0 414 if (shrieking)
251 1 1136 if (i_io_read(ig, buf, 4) != 4)
254 206 930 if (shrieking)
261 3 25074 if (i_io_read(ig, buf, 1) != 1)
267 0 0 if (i_io_read(ig, buf, 1) != 1)
273 3 118874 if (i_io_read(ig, buf, 3) != 3)
311 2390 525 while (*format) {
312 2117 273 i = va_arg(ap, i_upacked_t);
318 0 84 if (i_io_write(ig, buf, 2) == -1)
327 0 231 if (i_io_write(ig, buf, 4) == -1)
334 7 2068 if (i_io_write(ig, buf, 1) == -1)
373 25 0 if (im->xsize > SIGNMAX32 || im->ysize > SIGNMAX32) {
0 25 if (im->xsize > SIGNMAX32 || im->ysize > SIGNMAX32) {
380 25 0 if (!i_tags_get_int(&im->tags, "i_aspect_only", 0,&aspect_only))
382 12 13 if (!got_xres) {
383 12 0 if (!got_yres)
389 0 13 if (!got_yres)
392 25 0 if (xres <= 0 || yres <= 0)
0 25 if (xres <= 0 || yres <= 0)
394 0 25 if (aspect_only) {
397 0 0 if (xres < yres) {
410 12 13 if (im->type == i_palette_type) {
411 12 0 colors_used = i_colorcount(im);
415 4 21 if (!write_packed(ig, "CCVvvVVVVvvVVVVVV", 'B', 'M',
427 9 12 if (im->type == i_palette_type) {
431 507 6 for (i = 0; i < colors_used; ++i) {
432 507 0 i_getcolors(im, i, &c, 1);
433 507 0 if (im->channels >= 3) {
434 3 504 if (!write_packed(ig, "CCCC", (i_upacked_t)(c.channel[2]),
443 0 0 if (!write_packed(ig, "CCCC", v, v, v, 0)) {
478 2 2 if (!write_bmphead(ig, im, 1, line_size * im->ysize))
483 0 2 if (unpacked_size < im->xsize) {
495 151 1 for (y = im->ysize-1; y >= 0; --y) {
496 151 0 i_gpal(im, 0, im->xsize, y, line);
500 22520 151 for (x = 0; x < im->xsize; ++x) {
501 6962 15558 if (line[x])
503 2702 19818 if ((mask >>= 1) == 0) {
509 151 0 if (mask != 0x80) {
512 1 150 if (i_io_write(ig, packed, line_size) < 0) {
522 0 1 if (i_io_close(ig))
550 2 2 if (!write_bmphead(ig, im, 4, line_size * im->ysize))
555 0 2 if (unpacked_size < im->xsize) {
567 151 1 for (y = im->ysize-1; y >= 0; --y) {
568 151 0 i_gpal(im, 0, im->xsize, y, line);
570 11260 151 for (x = 0; x < im->xsize; x += 2) {
573 1 150 if (i_io_write(ig, packed, line_size) < 0) {
583 0 1 if (i_io_close(ig))
609 2 2 if (!write_bmphead(ig, im, 8, line_size * im->ysize))
614 0 2 if (unpacked_size < im->xsize) {
621 151 1 for (y = im->ysize-1; y >= 0; --y) {
622 151 0 i_gpal(im, 0, im->xsize, y, line);
623 1 150 if (i_io_write(ig, line, line_size) < 0) {
631 0 1 if (i_io_close(ig))
658 0 13 if (line_size / 3 != im->xsize) {
665 1 12 if (!write_bmphead(ig, im, 24, line_size * im->ysize))
669 1533 11 for (y = im->ysize-1; y >= 0; --y) {
673 238132 1533 for (x = 0; x < im->xsize; ++x) {
679 1 1532 if (i_io_write(ig, samples, line_size) < 0) {
687 1 10 if (i_io_close(ig))
709 6218 56 for (i = 0; i < count; ++i) {
710 3 6215 if (!read_packed(ig, "CCCC", &b, &g, &r, &x)) {
717 6215 0 if (i_addcolors(im, &c, 1) < 0) {
0 6215 if (i_addcolors(im, &c, 1) < 0) {
748 1 15 if (compression != BI_RGB) {
753 0 15 if ((i_img_dim)((i_img_dim_u)xsize + 8) < xsize) { /* if there was overflow */
764 14 1 if (ysize > 0) {
777 0 15 if (!clr_used)
779 15 0 if (clr_used < 0 || clr_used > 2) {
1 14 if (clr_used < 0 || clr_used > 2) {
785 1 13 if (offbits < base_offset) {
791 0 13 if (!im)
793 1 12 if (!read_bmp_pal(ig, im, clr_used)) {
798 2 10 if (offbits > base_offset) {
802 7 1 while (base_offset < offbits) {
803 1 6 if (i_io_read(ig, &buffer, 1) != 1) {
816 328 8 while (y != lasty) {
817 3 325 if (i_io_read(ig, packed, line_size) != line_size) {
820 1 2 if (allow_incomplete) {
834 26000 325 for (x = 0; x < xsize; ++x) {
837 3050 22950 if (!bit) {
842 325 0 i_ppal(im, 0, xsize, y, line);
881 24 2 if (ysize > 0) {
894 0 26 if (!clr_used)
897 24 2 if (clr_used > 16 || clr_used < 0) {
0 24 if (clr_used > 16 || clr_used < 0) {
903 1 23 if (offbits < base_offset) {
909 0 23 if (!im) /* error should have been pushed already */
911 1 22 if (!read_bmp_pal(ig, im, clr_used)) {
916 2 20 if (offbits > base_offset) {
920 7 1 while (base_offset < offbits) {
921 1 6 if (i_io_read(ig, &buffer, 1) != 1) {
930 21 0 if (line_size < 260)
936 11 10 if (compression == BI_RGB) {
938 323 8 while (y != lasty) {
939 3 320 if (i_io_read(ig, packed, line_size) != line_size) {
942 1 2 if (allow_incomplete) {
955 12950 320 for (x = 0; x < xsize; x+=2) {
960 320 0 i_ppal(im, 0, xsize, y, line);
966 9 1 else if (compression == BI_RLE4) {
975 2 3586 if (i_io_read(ig, packed, 2) != 2) {
978 1 1 if (allow_incomplete) {
989 2726 860 else if (packed[0]) {
991 1 2725 if (x + count > xlimit) {
1002 40426 2725 for (i = 0; i < count; i += 2)
1004 40426 2725 for (i = 1; i < count; i += 2)
1006 2725 0 i_ppal(im, x, x+count, y, line);
1021 0 0 if (i_io_read(ig, packed, 2) != 2) {
1024 0 0 if (allow_incomplete) {
1041 1 294 if (x + count > xlimit) {
1053 2 292 if (i_io_read(ig, packed, read_size) != read_size) {
1056 1 1 if (allow_incomplete) {
1067 864 292 for (i = 0; i < size; ++i) {
1070 864 0 i_ppal(im, x, x+2, y, line);
1109 0 25 if (line_size < xsize) { /* if it overflowed (unlikely, but check) */
1114 23 2 if (ysize > 0) {
1127 0 25 if (!clr_used)
1129 24 1 if (clr_used > 256 || clr_used < 0) {
0 24 if (clr_used > 256 || clr_used < 0) {
1135 1 23 if (offbits < base_offset) {
1141 0 23 if (!im)
1143 1 22 if (!read_bmp_pal(ig, im, clr_used)) {
1148 2 20 if (offbits > base_offset) {
1152 7 1 while (base_offset < offbits) {
1153 1 6 if (i_io_read(ig, &buffer, 1) != 1) {
1163 11 10 if (compression == BI_RGB) {
1165 320 8 while (y != lasty) {
1166 3 317 if (i_io_read(ig, line, line_size) != line_size) {
1168 1 2 if (allow_incomplete) {
1179 317 0 i_ppal(im, 0, xsize, y, line);
1184 9 1 else if (compression == BI_RLE8) {
1193 2 3608 if (i_io_read(ig, packed, 2) != 2) {
1195 1 1 if (allow_incomplete) {
1206 2296 1312 if (packed[0]) {
1207 1 2295 if (x + packed[0] > xsize) {
1215 2295 0 i_ppal(im, x, x+packed[0], y, line);
1229 0 0 if (i_io_read(ig, packed, 2) != 2) {
1231 0 0 if (allow_incomplete) {
1248 1 768 if (x + count > xsize) {
1257 2 766 if (i_io_read(ig, line, read_size) != read_size) {
1259 1 1 if (allow_incomplete) {
1270 766 0 i_ppal(im, x, x+count, y, line);
1360 25 1 if (ysize > 0) {
1373 25 1 if (compression == BI_RGB) {
1378 0 25 for (i = 0; i < clr_used; ++clr_used) {
1380 0 0 if (i_io_read(ig, buf, 4) != 4) {
1387 0 1 else if (compression == BI_BITFIELDS) {
1392 0 0 for (i = 0; i < 3; ++i) {
1394 0 0 if (!read_packed(ig, "V", &rmask)) {
1398 0 0 if (rmask == 0) {
1406 0 0 while (!(bits & 1)) {
1412 0 0 while (bits & 1) {
1427 1 24 if (offbits < base_offset) {
1432 2 22 if (offbits > base_offset) {
1436 7 1 while (base_offset < offbits) {
1437 1 6 if (i_io_read(ig, &buffer, 1) != 1) {
1446 0 23 if (!im)
1454 0 23 if (bytes / sizeof(i_color) != xsize) {
1460 1076 20 while (y != lasty) {
1462 118877 1073 for (x = 0; x < xsize; ++x) {
1464 3 118874 if (!read_packed(ig, unpack_code, &pixel)) {
1466 1 2 if (allow_incomplete) {
1477 356622 118874 for (i = 0; i < 3; ++i) {
1480 0 356622 if (bits < 8) {
1483 356622 0 else if (bits) {
1491 750 323 if (extras)