#define READ_BMP_SIZE 14
typedef struct {
+ mm_util_img_codec_type type;
unsigned char *signature;
unsigned int len;
unsigned int offset;
static unsigned char gIfegWBMPHeader[] = { 0x00, 0x00 };
static const image_signature_t signature_info[] = {
- { gIfegJPEGHeader, 2, 0},
- { gIfegPNGHeader, 8, 0},
- { gIfegGIFHeader, 3, 0},
- { gIfegBMPHeader, 2, 0},
- { gIfegWBMPHeader, 2, 0}
+ { IMG_CODEC_JPEG, gIfegJPEGHeader, 2, 0},
+ { IMG_CODEC_PNG, gIfegPNGHeader, 8, 0},
+ { IMG_CODEC_GIF, gIfegGIFHeader, 3, 0},
+ { IMG_CODEC_BMP, gIfegBMPHeader, 2, 0},
+ { IMG_CODEC_WBMP, gIfegWBMPHeader, 2, 0}
};
+static const unsigned int signature_info_num = sizeof(signature_info) / sizeof(image_signature_t);
static unsigned int __ReadBE16bitsToUINT(const unsigned char *pBuffer)
{
long file_size = 0;
unsigned char data[MINIMUM_HEADER_BYTES] = {0, };
size_t file_read = 0;
- unsigned int _type = 0, _width = 0, _height = 0;
+ unsigned int idx = 0, _width = 0, _height = 0;
+ mm_util_img_codec_type _type = IMG_CODEC_UNKNOWN_TYPE;
mm_util_retvm_if(!path, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid path");
file_size -= MINIMUM_HEADER_BYTES;
// get codec type using signature
- for (_type = 0; _type < IMG_CODEC_UNKNOWN_TYPE; _type++) {
- if (memcmp(data + signature_info[_type].offset, signature_info[_type].signature, signature_info[_type].len) == 0) {
+ for (idx = 0; idx < signature_info_num; idx++) {
+ if (memcmp(data + signature_info[idx].offset, signature_info[idx].signature, signature_info[idx].len) == 0) {
+ _type = signature_info[idx].type;
mm_util_debug("type = %u", _type);
break;
}