Separated validator and pixeldata finder
This commit is contained in:
parent
987a708303
commit
8c64bbfc26
@ -5,19 +5,14 @@
|
|||||||
#include "ciff_tools.h"
|
#include "ciff_tools.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
uint8_t parse_ciff_from_mem(const uint8_t* data, uint64_t data_len, uint64_t* width, uint64_t* height, uint64_t* pixel_data_starts) {
|
uint8_t validate_ciff(const uint8_t* data, uint64_t data_len) {
|
||||||
/**
|
|
||||||
* Igazából, ezek többnyire csak változatos ellenőrzések
|
|
||||||
* A függvény validálja a CIFF fájl tartalmát, majd ha ez sikeres volt, akkor megmondja
|
|
||||||
* - A kép dimenzióit
|
|
||||||
* - Hogy hol kezdődik a pixel információ a képben
|
|
||||||
* Az, hogy a kép információt kimásolja-e, az a programozóra van bízva.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Read out the static part of the header (If we have at least header bytes)
|
// Read out the static part of the header (If we have at least header bytes)
|
||||||
if (data_len < sizeof(ciff_static_header_t)) {
|
if (data_len < sizeof(ciff_static_header_t)) {
|
||||||
return CIFF_PARSE_HEADER_TOO_SHORT;
|
return CIFF_PARSE_HEADER_TOO_SHORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is just a pointer with different type information
|
||||||
ciff_static_header_t* header_info = (struct ciff_static_header_t*)data;
|
ciff_static_header_t* header_info = (struct ciff_static_header_t*)data;
|
||||||
|
|
||||||
// Do some preflight checks
|
// Do some preflight checks
|
||||||
@ -64,6 +59,21 @@ uint8_t parse_ciff_from_mem(const uint8_t* data, uint64_t data_len, uint64_t* wi
|
|||||||
return CIFF_PARSE_UNKNOWN_ERROR;
|
return CIFF_PARSE_UNKNOWN_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return CIFF_PARSE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t get_pixel_data_from_ciff(const uint8_t* data, uint64_t data_len, uint64_t* width, uint64_t* height, uint64_t* pixel_data_starts) {
|
||||||
|
/**
|
||||||
|
* Ez csak visszad egy pointert, hogy honnan kezdődik a pixel data, miután validálta a képet
|
||||||
|
*/
|
||||||
|
|
||||||
|
uint8_t validate_result = validate_ciff(data, data_len);
|
||||||
|
if (validate_result != CIFF_PARSE_SUCCESS) {
|
||||||
|
return validate_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
ciff_static_header_t* header_info = (struct ciff_static_header_t*)data; // This is just a pointer with different type information
|
||||||
|
|
||||||
// Set return data
|
// Set return data
|
||||||
*width = header_info->width;
|
*width = header_info->width;
|
||||||
*height = header_info->height;
|
*height = header_info->height;
|
||||||
|
@ -22,7 +22,7 @@ typedef struct __attribute__ ((packed)) ciff_static_header_t {
|
|||||||
uint64_t height;
|
uint64_t height;
|
||||||
} ciff_static_header_t;
|
} ciff_static_header_t;
|
||||||
|
|
||||||
|
uint8_t validate_ciff(const uint8_t* data, uint64_t data_len);
|
||||||
uint8_t parse_ciff_from_mem(const uint8_t* data, uint64_t data_len, uint64_t* width, uint64_t* height, uint64_t* pixel_data_starts);
|
uint8_t get_pixel_data_from_ciff(const uint8_t* data, uint64_t data_len, uint64_t* width, uint64_t* height, uint64_t* pixel_data_starts);
|
||||||
|
|
||||||
#endif //CAFF_PREVIEWER_CIFF_TOOLS_H
|
#endif //CAFF_PREVIEWER_CIFF_TOOLS_H
|
||||||
|
Loading…
Reference in New Issue
Block a user