comparison tools/libgfx.c @ 2063:bd109c0a7b88

Improve IFF probing.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 05 Dec 2018 12:54:28 +0200
parents 02fa60b27af5
children 3617ef01c1de
comparison
equal deleted inserted replaced
2062:f11fad2dc3b5 2063:bd109c0a7b88
1505 1505
1506 1506
1507 static int fmtProbeIFF(const Uint8 *buf, const size_t len) 1507 static int fmtProbeIFF(const Uint8 *buf, const size_t len)
1508 { 1508 {
1509 if (len > 32 && 1509 if (len > 32 &&
1510 buf[ 0] == 'F' && buf[ 1] == 'O' && 1510 DM_BE32_TO_NATIVE(*(Uint32 *) (buf + 0)) == IFF_ID_FORM && (
1511 buf[ 2] == 'R' && buf[ 3] == 'M' && ( 1511 DM_BE32_TO_NATIVE(*(Uint32 *) (buf + 8)) == IFF_ID_ILBM ||
1512 (buf[ 8] == 'I' && buf[ 9] == 'L' && buf[10] == 'B' && buf[11] == 'M') || 1512 DM_BE32_TO_NATIVE(*(Uint32 *) (buf + 8)) == IFF_ID_PBM ||
1513 (buf[ 8] == 'P' && buf[ 9] == 'B' && buf[10] == 'M' && buf[11] == 0x20) 1513 DM_BE32_TO_NATIVE(*(Uint32 *) (buf + 8)) == IFF_ID_ACBM))
1514 )) 1514 {
1515 { 1515 if (DM_BE32_TO_NATIVE(*(Uint32 *) (buf + 12)) == IFF_ID_BMHD)
1516 if (buf[12] == 'B' && buf[13] == 'M' &&
1517 buf[14] == 'H' && buf[15] == 'D')
1518 return DM_PROBE_SCORE_MAX; 1516 return DM_PROBE_SCORE_MAX;
1519 else 1517 else
1520 return DM_PROBE_SCORE_GOOD; 1518 return DM_PROBE_SCORE_GOOD;
1521 } 1519 }
1522 1520