diff --git a/hpvm/test/hpvm-cava/src/cam_pipe_utility.c b/hpvm/test/hpvm-cava/src/cam_pipe_utility.c index 864f02d5b28f2c4738279cf66cba5f4312c2a3de..4ef58c3bcb3f68d23818e3be8d529824bd70c539 100644 --- a/hpvm/test/hpvm-cava/src/cam_pipe_utility.c +++ b/hpvm/test/hpvm-cava/src/cam_pipe_utility.c @@ -5,29 +5,33 @@ #include "cam_pipe_utility.h" //#include "pipe_stages.h" -uint8_t *read_image_from_binary(char *file_path, int *row_size, int *col_size) { +uint8_t *read_image_from_binary(char *file_path, size_t *row_size, + size_t *col_size) { uint8_t *image; FILE *fp = fopen(file_path, "r"); int chan_size; - if (fread(row_size, sizeof(int), 1, fp) != 1) + int row_size_tmp, col_size_tmp; + if (fread(&row_size_tmp, sizeof(int), 1, fp) != 1) assert("Failed to read row size from binary file!"); - if (fread(col_size, sizeof(int), 1, fp) != 1) + if (fread(&col_size_tmp, sizeof(int), 1, fp) != 1) assert("Failed to read col size from binary file!"); if (fread(&chan_size, sizeof(int), 1, fp) != 1) assert("Failed to read row size from binary file!"); assert(chan_size == CHAN_SIZE && "Channel size read from the binary file " "doesn't equal to the default value!\n"); - int size = *row_size * *col_size * CHAN_SIZE; + size_t size = (size_t)row_size_tmp * col_size_tmp * CHAN_SIZE; image = malloc_aligned(sizeof(uint8_t) * size); if (fread(image, sizeof(uint8_t), size, fp) != size) assert("Failed to read the image from binary file!"); fclose(fp); + *row_size = (size_t)row_size_tmp; + *col_size = (size_t)col_size_tmp; return image; } -void write_image_to_binary(char *file_path, uint8_t *image, int row_size, - int col_size) { +void write_image_to_binary(char *file_path, uint8_t *image, size_t row_size, + size_t col_size) { FILE *fp = fopen(file_path, "w"); int shape[3] = {row_size, col_size, CHAN_SIZE}; diff --git a/hpvm/test/hpvm-cava/src/cam_pipe_utility.h b/hpvm/test/hpvm-cava/src/cam_pipe_utility.h index b61b7cc9b52aa59522f93661895fca960b947f17..a7ba68372aa44a74de588605904fd165a7b98d72 100644 --- a/hpvm/test/hpvm-cava/src/cam_pipe_utility.h +++ b/hpvm/test/hpvm-cava/src/cam_pipe_utility.h @@ -4,9 +4,10 @@ #include "pipe_stages.h" #include "utility.h" -uint8_t *read_image_from_binary(char *file_path, int *row_size, int *col_size); -void write_image_to_binary(char *file_path, uint8_t *image, int row_size, - int col_size); +uint8_t *read_image_from_binary(char *file_path, size_t *row_size, + size_t *col_size); +void write_image_to_binary(char *file_path, uint8_t *image, size_t row_size, + size_t col_size); float *transpose_mat(float *inmat, int width, int height); void convert_hwc_to_chw(uint8_t *input, int row_size, int col_size, uint8_t **result);