mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[kandinsky] Make sure the image compressor can actually compress
This commit is contained in:
committed by
LeaNumworks
parent
f1198d3c76
commit
0489842997
@@ -13,6 +13,7 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
#include "../../ion/src/external/lz4/lz4hc.h"
|
||||
|
||||
#define ERROR_IF(cond, message) if (cond) { printf(message); return -1; };
|
||||
@@ -148,7 +149,7 @@ void generateHeaderFromImage(FILE * file, const char * guardian, const char * va
|
||||
|
||||
void generateImplementationFromImage(FILE * file, const char * header, const char * variable, uint32_t width, uint32_t height, png_bytep * pixelsRowPointers) {
|
||||
|
||||
int sizeOfPixelBuffer = width*height*sizeof(uint16_t);
|
||||
int sizeOfPixelBuffer = width * height * sizeof(uint16_t);
|
||||
uint16_t * pixelBuffer = (uint16_t *)malloc(sizeOfPixelBuffer);
|
||||
|
||||
for (int j=0; j<height; j++) {
|
||||
@@ -171,15 +172,18 @@ void generateImplementationFromImage(FILE * file, const char * header, const cha
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t * compressedPixelBuffer = malloc(sizeOfPixelBuffer);
|
||||
int maxSizeOfCompressedPixelBuffer = LZ4_compressBound(sizeOfPixelBuffer);
|
||||
uint8_t * compressedPixelBuffer = malloc(maxSizeOfCompressedPixelBuffer);
|
||||
int sizeOfCompressedPixelBuffer = LZ4_compress_HC(
|
||||
pixelBuffer,
|
||||
compressedPixelBuffer,
|
||||
sizeOfPixelBuffer,
|
||||
sizeOfCompressedPixelBuffer,
|
||||
maxSizeOfCompressedPixelBuffer,
|
||||
LZ4HC_CLEVEL_MAX
|
||||
);
|
||||
|
||||
assert(sizeOfCompressedPixelBuffer != 0);
|
||||
|
||||
fprintf(file, "// This file is auto-generated by Inliner. Do not edit manually.\n");
|
||||
fprintf(file, "#include \"%s.h\"\n\n", header);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user