@@ -104,7 +104,7 @@ extern "C" {
104
104
#endif
105
105
106
106
// Use miniz or not to decode ZIP format pixel. Linking with zlib
107
- // required if this flas is 0 and TINYEXR_USE_STB_ZLIB is 0.
107
+ // required if this flag is 0 and TINYEXR_USE_STB_ZLIB is 0.
108
108
#ifndef TINYEXR_USE_MINIZ
109
109
#define TINYEXR_USE_MINIZ (1 )
110
110
#endif
@@ -114,7 +114,7 @@ extern "C" {
114
114
#define TINYEXR_USE_STB_ZLIB (0 )
115
115
#endif
116
116
117
- // Disable PIZ comporession when applying cpplint.
117
+ // Disable PIZ compression when applying cpplint.
118
118
#ifndef TINYEXR_USE_PIZ
119
119
#define TINYEXR_USE_PIZ (1 )
120
120
#endif
@@ -185,11 +185,11 @@ typedef struct TEXRVersion {
185
185
int version; // this must be 2
186
186
// tile format image;
187
187
// not zero for only a single-part "normal" tiled file (according to spec.)
188
- int tiled;
188
+ int tiled;
189
189
int long_name; // long name attribute
190
190
// deep image(EXR 2.0);
191
191
// for a multi-part file, indicates that at least one part is of type deep* (according to spec.)
192
- int non_image;
192
+ int non_image;
193
193
int multipart; // multi-part(EXR 2.0)
194
194
} EXRVersion;
195
195
@@ -1507,7 +1507,7 @@ static int rleCompress(int inLength, const char in[], signed char out[]) {
1507
1507
1508
1508
//
1509
1509
// Uncompress an array of bytes compressed with rleCompress().
1510
- // Returns the length of the oncompressed data, or 0 if the
1510
+ // Returns the length of the uncompressed data, or 0 if the
1511
1511
// length of the uncompressed data would be more than maxLength.
1512
1512
//
1513
1513
@@ -3670,7 +3670,7 @@ static bool DecodePixelData(/* out */ unsigned char **out_images,
3670
3670
}
3671
3671
}
3672
3672
#else
3673
- assert (0 && " PIZ is enabled in this build" );
3673
+ assert (0 && " PIZ is disabled in this build" );
3674
3674
return false ;
3675
3675
#endif
3676
3676
@@ -4063,7 +4063,7 @@ static bool DecodePixelData(/* out */ unsigned char **out_images,
4063
4063
for (int u = 0 ; u < width; u++) {
4064
4064
tinyexr::FP16 hf;
4065
4065
4066
- // address may not be aliged . use byte-wise copy for safety.#76
4066
+ // address may not be aligned . use byte-wise copy for safety.#76
4067
4067
// hf.u = line_ptr[u];
4068
4068
tinyexr::cpy2 (&(hf.u ), line_ptr + u);
4069
4069
@@ -4120,7 +4120,7 @@ static bool DecodePixelData(/* out */ unsigned char **out_images,
4120
4120
4121
4121
if (reinterpret_cast <const unsigned char *>(line_ptr + width) >
4122
4122
(data_ptr + data_len)) {
4123
- // Corrupsed data
4123
+ // Corrupted data
4124
4124
return false ;
4125
4125
}
4126
4126
@@ -4269,8 +4269,8 @@ static unsigned char **AllocateImage(int num_channels,
4269
4269
if (success) {
4270
4270
(*success) = true ;
4271
4271
}
4272
- }
4273
-
4272
+ }
4273
+
4274
4274
return images;
4275
4275
}
4276
4276
@@ -4773,8 +4773,8 @@ static bool ConvertHeader(EXRHeader *exr_header, const HeaderInfo &info, std::st
4773
4773
struct OffsetData {
4774
4774
OffsetData () : num_x_levels(0 ), num_y_levels(0 ) {}
4775
4775
std::vector<std::vector<std::vector <tinyexr::tinyexr_uint64> > > offsets;
4776
- int num_x_levels;
4777
- int num_y_levels;
4776
+ int num_x_levels;
4777
+ int num_y_levels;
4778
4778
};
4779
4779
4780
4780
static int LevelIndex (int lx, int ly, int tile_level_mode, int num_x_levels) {
@@ -4834,7 +4834,7 @@ static int DecodeTiledLevel(EXRImage* exr_image, const EXRHeader* exr_header,
4834
4834
#else
4835
4835
unsigned error_flag (EF_SUCCESS);
4836
4836
#endif
4837
-
4837
+
4838
4838
// Although the spec says : "...the data window is subdivided into an array of smaller rectangles...",
4839
4839
// the IlmImf library allows the dimensions of the tile to be larger (or equal) than the dimensions of the data window.
4840
4840
#if 0
@@ -4878,7 +4878,7 @@ static int DecodeTiledLevel(EXRImage* exr_image, const EXRHeader* exr_header,
4878
4878
exr_header->tile_size_y , &alloc_success);
4879
4879
4880
4880
if (!alloc_success) {
4881
- error_flag |= EF_INVALID_DATA;
4881
+ error_flag |= EF_INVALID_DATA;
4882
4882
continue ;
4883
4883
}
4884
4884
@@ -4890,7 +4890,7 @@ static int DecodeTiledLevel(EXRImage* exr_image, const EXRHeader* exr_header,
4890
4890
tinyexr::tinyexr_uint64 offset = offset_data.offsets [size_t (level_index)][size_t (y_tile)][size_t (x_tile)];
4891
4891
if (offset + sizeof (int ) * 5 > size) {
4892
4892
// Insufficient data size.
4893
- error_flag |= EF_INSUFFICIENT_DATA;
4893
+ error_flag |= EF_INSUFFICIENT_DATA;
4894
4894
continue ;
4895
4895
}
4896
4896
@@ -4956,7 +4956,7 @@ static int DecodeTiledLevel(EXRImage* exr_image, const EXRHeader* exr_header,
4956
4956
exr_image->tiles [tile_idx].level_y = tile_coordinates[3 ];
4957
4957
4958
4958
#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0)
4959
- }
4959
+ }
4960
4960
}));
4961
4961
} // num_thread loop
4962
4962
@@ -6069,8 +6069,8 @@ int LoadEXRWithLayer(float **out_rgba, int *width, int *height,
6069
6069
6070
6070
if (channels.size () < 1 ) {
6071
6071
if (layername == NULL ) {
6072
- tinyexr::SetErrorMessage (" Layer Not Foound . Seems EXR contains channels with layer(e.g. `diffuse.R`). if you are using LoadEXR(), please try LoadEXRWithLayer(). LoadEXR() cannot load EXR having channels with layer." , err);
6073
-
6072
+ tinyexr::SetErrorMessage (" Layer Not Found . Seems EXR contains channels with layer(e.g. `diffuse.R`). if you are using LoadEXR(), please try LoadEXRWithLayer(). LoadEXR() cannot load EXR having channels with layer." , err);
6073
+
6074
6074
} else {
6075
6075
tinyexr::SetErrorMessage (" Layer Not Found" , err);
6076
6076
}
@@ -6106,22 +6106,22 @@ int LoadEXRWithLayer(float **out_rgba, int *width, int *height,
6106
6106
for (int it = 0 ; it < exr_image.num_tiles ; it++) {
6107
6107
for (int j = 0 ; j < exr_header.tile_size_y ; j++) {
6108
6108
for (int i = 0 ; i < exr_header.tile_size_x ; i++) {
6109
- const int ii = exr_image.tiles [it].offset_x *
6110
- static_cast <int >(exr_header.tile_size_x ) +
6111
- i;
6112
- const int jj = exr_image.tiles [it].offset_y *
6113
- static_cast <int >(exr_header.tile_size_y ) +
6114
- j;
6115
- const int idx = ii + jj * static_cast <int >(exr_image.width );
6109
+ const size_t ii = exr_image.tiles [it].offset_x *
6110
+ static_cast <size_t >(exr_header.tile_size_x ) +
6111
+ i;
6112
+ const size_t jj = exr_image.tiles [it].offset_y *
6113
+ static_cast <size_t >(exr_header.tile_size_y ) +
6114
+ j;
6115
+ const size_t idx = ii + jj * static_cast <size_t >(exr_image.width );
6116
6116
6117
6117
// out of region check.
6118
- if (ii >= exr_image.width ) {
6118
+ if (ii >= static_cast < size_t >( exr_image.width ) ) {
6119
6119
continue ;
6120
6120
}
6121
- if (jj >= exr_image.height ) {
6121
+ if (jj >= static_cast < size_t >( exr_image.height ) ) {
6122
6122
continue ;
6123
6123
}
6124
- const int srcIdx = i + j * exr_header.tile_size_x ;
6124
+ const size_t srcIdx = i + j * exr_header.tile_size_x ;
6125
6125
unsigned char **src = exr_image.tiles [it].images ;
6126
6126
(*out_rgba)[4 * idx + 0 ] =
6127
6127
reinterpret_cast <float **>(src)[chIdx][srcIdx];
@@ -6135,7 +6135,9 @@ int LoadEXRWithLayer(float **out_rgba, int *width, int *height,
6135
6135
}
6136
6136
}
6137
6137
} else {
6138
- for (int i = 0 ; i < exr_image.width * exr_image.height ; i++) {
6138
+ const size_t pixel_size = static_cast <size_t >(exr_image.width ) *
6139
+ static_cast <size_t >(exr_image.height );
6140
+ for (size_t i = 0 ; i < pixel_size; i++) {
6139
6141
const float val =
6140
6142
reinterpret_cast <float **>(exr_image.images )[chIdx][i];
6141
6143
(*out_rgba)[4 * i + 0 ] = val;
@@ -6176,20 +6178,20 @@ int LoadEXRWithLayer(float **out_rgba, int *width, int *height,
6176
6178
for (int it = 0 ; it < exr_image.num_tiles ; it++) {
6177
6179
for (int j = 0 ; j < exr_header.tile_size_y ; j++) {
6178
6180
for (int i = 0 ; i < exr_header.tile_size_x ; i++) {
6179
- const int ii =
6181
+ const size_t ii =
6180
6182
exr_image.tiles [it].offset_x * exr_header.tile_size_x + i;
6181
- const int jj =
6183
+ const size_t jj =
6182
6184
exr_image.tiles [it].offset_y * exr_header.tile_size_y + j;
6183
- const int idx = ii + jj * exr_image.width ;
6185
+ const size_t idx = ii + jj * exr_image.width ;
6184
6186
6185
6187
// out of region check.
6186
- if (ii >= exr_image.width ) {
6188
+ if (ii >= static_cast < size_t >( exr_image.width ) ) {
6187
6189
continue ;
6188
6190
}
6189
- if (jj >= exr_image.height ) {
6191
+ if (jj >= static_cast < size_t >( exr_image.height ) ) {
6190
6192
continue ;
6191
6193
}
6192
- const int srcIdx = i + j * exr_header.tile_size_x ;
6194
+ const size_t srcIdx = i + j * exr_header.tile_size_x ;
6193
6195
unsigned char **src = exr_image.tiles [it].images ;
6194
6196
(*out_rgba)[4 * idx + 0 ] =
6195
6197
reinterpret_cast <float **>(src)[idxR][srcIdx];
@@ -6207,7 +6209,9 @@ int LoadEXRWithLayer(float **out_rgba, int *width, int *height,
6207
6209
}
6208
6210
}
6209
6211
} else {
6210
- for (int i = 0 ; i < exr_image.width * exr_image.height ; i++) {
6212
+ const size_t pixel_size = static_cast <size_t >(exr_image.width ) *
6213
+ static_cast <size_t >(exr_image.height );
6214
+ for (size_t i = 0 ; i < pixel_size; i++) {
6211
6215
(*out_rgba)[4 * i + 0 ] =
6212
6216
reinterpret_cast <float **>(exr_image.images )[idxR][i];
6213
6217
(*out_rgba)[4 * i + 1 ] =
@@ -6384,20 +6388,20 @@ int LoadEXRFromMemory(float **out_rgba, int *width, int *height,
6384
6388
for (int it = 0 ; it < exr_image.num_tiles ; it++) {
6385
6389
for (int j = 0 ; j < exr_header.tile_size_y ; j++) {
6386
6390
for (int i = 0 ; i < exr_header.tile_size_x ; i++) {
6387
- const int ii =
6391
+ const size_t ii =
6388
6392
exr_image.tiles [it].offset_x * exr_header.tile_size_x + i;
6389
- const int jj =
6393
+ const size_t jj =
6390
6394
exr_image.tiles [it].offset_y * exr_header.tile_size_y + j;
6391
- const int idx = ii + jj * exr_image.width ;
6395
+ const size_t idx = ii + jj * exr_image.width ;
6392
6396
6393
6397
// out of region check.
6394
- if (ii >= exr_image.width ) {
6398
+ if (ii >= static_cast < size_t >( exr_image.width ) ) {
6395
6399
continue ;
6396
6400
}
6397
- if (jj >= exr_image.height ) {
6401
+ if (jj >= static_cast < size_t >( exr_image.height ) ) {
6398
6402
continue ;
6399
6403
}
6400
- const int srcIdx = i + j * exr_header.tile_size_x ;
6404
+ const size_t srcIdx = i + j * exr_header.tile_size_x ;
6401
6405
unsigned char **src = exr_image.tiles [it].images ;
6402
6406
(*out_rgba)[4 * idx + 0 ] =
6403
6407
reinterpret_cast <float **>(src)[0 ][srcIdx];
@@ -6411,7 +6415,9 @@ int LoadEXRFromMemory(float **out_rgba, int *width, int *height,
6411
6415
}
6412
6416
}
6413
6417
} else {
6414
- for (int i = 0 ; i < exr_image.width * exr_image.height ; i++) {
6418
+ const size_t pixel_size = static_cast <size_t >(exr_image.width ) *
6419
+ static_cast <size_t >(exr_image.height );
6420
+ for (size_t i = 0 ; i < pixel_size; i++) {
6415
6421
const float val = reinterpret_cast <float **>(exr_image.images )[0 ][i];
6416
6422
(*out_rgba)[4 * i + 0 ] = val;
6417
6423
(*out_rgba)[4 * i + 1 ] = val;
@@ -6450,20 +6456,20 @@ int LoadEXRFromMemory(float **out_rgba, int *width, int *height,
6450
6456
for (int it = 0 ; it < exr_image.num_tiles ; it++) {
6451
6457
for (int j = 0 ; j < exr_header.tile_size_y ; j++)
6452
6458
for (int i = 0 ; i < exr_header.tile_size_x ; i++) {
6453
- const int ii =
6459
+ const size_t ii =
6454
6460
exr_image.tiles [it].offset_x * exr_header.tile_size_x + i;
6455
- const int jj =
6461
+ const size_t jj =
6456
6462
exr_image.tiles [it].offset_y * exr_header.tile_size_y + j;
6457
- const int idx = ii + jj * exr_image.width ;
6463
+ const size_t idx = ii + jj * exr_image.width ;
6458
6464
6459
6465
// out of region check.
6460
- if (ii >= exr_image.width ) {
6466
+ if (ii >= static_cast < size_t >( exr_image.width ) ) {
6461
6467
continue ;
6462
6468
}
6463
- if (jj >= exr_image.height ) {
6469
+ if (jj >= static_cast < size_t >( exr_image.height ) ) {
6464
6470
continue ;
6465
6471
}
6466
- const int srcIdx = i + j * exr_header.tile_size_x ;
6472
+ const size_t srcIdx = i + j * exr_header.tile_size_x ;
6467
6473
unsigned char **src = exr_image.tiles [it].images ;
6468
6474
(*out_rgba)[4 * idx + 0 ] =
6469
6475
reinterpret_cast <float **>(src)[idxR][srcIdx];
@@ -6480,7 +6486,9 @@ int LoadEXRFromMemory(float **out_rgba, int *width, int *height,
6480
6486
}
6481
6487
}
6482
6488
} else {
6483
- for (int i = 0 ; i < exr_image.width * exr_image.height ; i++) {
6489
+ const size_t pixel_size = static_cast <size_t >(exr_image.width ) *
6490
+ static_cast <size_t >(exr_image.height );
6491
+ for (size_t i = 0 ; i < pixel_size; i++) {
6484
6492
(*out_rgba)[4 * i + 0 ] =
6485
6493
reinterpret_cast <float **>(exr_image.images )[idxR][i];
6486
6494
(*out_rgba)[4 * i + 1 ] =
@@ -6593,7 +6601,7 @@ namespace tinyexr
6593
6601
6594
6602
// out_data must be allocated initially with the block-header size
6595
6603
// of the current image(-part) type
6596
- static bool EncodePixelData (/* out */ std::vector<unsigned char >& out_data,
6604
+ static bool EncodePixelData (/* out */ std::vector<unsigned char >& out_data,
6597
6605
const unsigned char * const * images,
6598
6606
int compression_type,
6599
6607
int /* line_order*/ ,
@@ -6894,13 +6902,13 @@ static int EncodeTiledLevel(const EXRImage* level_image, const EXRHeader* exr_he
6894
6902
int y_tile = i / num_x_tiles;
6895
6903
6896
6904
EXRTile& tile = level_image->tiles [tile_idx];
6897
-
6905
+
6898
6906
const unsigned char * const * images =
6899
6907
static_cast <const unsigned char * const *>(tile.images );
6900
6908
6901
6909
data_list[data_idx].resize (5 *sizeof (int ));
6902
6910
size_t data_header_size = data_list[data_idx].size ();
6903
- bool ret = EncodePixelData (data_list[data_idx],
6911
+ bool ret = EncodePixelData (data_list[data_idx],
6904
6912
images,
6905
6913
exr_header->compression_type ,
6906
6914
0 , // increasing y
@@ -6946,7 +6954,7 @@ static int EncodeTiledLevel(const EXRImage* level_image, const EXRHeader* exr_he
6946
6954
6947
6955
if (invalid_data) {
6948
6956
if (err) {
6949
- (*err) += " Failed to encode tile data.\n " ;
6957
+ (*err) += " Failed to encode tile data.\n " ;
6950
6958
}
6951
6959
return TINYEXR_ERROR_INVALID_DATA;
6952
6960
}
@@ -7117,7 +7125,7 @@ static int EncodeChunk(const EXRImage* exr_image, const EXRHeader* exr_header,
7117
7125
data_list[i].resize (2 *sizeof (int ));
7118
7126
size_t data_header_size = data_list[i].size ();
7119
7127
7120
- bool ret = EncodePixelData (data_list[i],
7128
+ bool ret = EncodePixelData (data_list[i],
7121
7129
images,
7122
7130
exr_header->compression_type ,
7123
7131
0 , // increasing y
@@ -7133,7 +7141,7 @@ static int EncodeChunk(const EXRImage* exr_image, const EXRHeader* exr_header,
7133
7141
compression_param);
7134
7142
if (!ret) {
7135
7143
invalid_data = true ;
7136
- continue ; // "break" cannot be used with OpenMP
7144
+ continue ; // "break" cannot be used with OpenMP
7137
7145
}
7138
7146
assert (data_list[i].size () > data_header_size);
7139
7147
int data_len = static_cast <int >(data_list[i].size () - data_header_size);
@@ -8311,7 +8319,7 @@ int ParseEXRMultipartHeaderFromMemory(EXRHeader ***exr_headers,
8311
8319
(*exr_headers) =
8312
8320
static_cast <EXRHeader **>(malloc (sizeof (EXRHeader *) * infos.size ()));
8313
8321
8314
-
8322
+
8315
8323
int retcode = TINYEXR_SUCCESS;
8316
8324
8317
8325
for (size_t i = 0 ; i < infos.size (); i++) {
@@ -8588,7 +8596,7 @@ int LoadEXRMultipartImageFromMemory(EXRImage *exr_images,
8588
8596
return TINYEXR_ERROR_INVALID_DATA;
8589
8597
}
8590
8598
offset_data.offsets [l][dy][dx] = offset + 4 ; // +4 to skip 'part number'
8591
- marker += sizeof (tinyexr::tinyexr_uint64); // = 8
8599
+ marker += sizeof (tinyexr::tinyexr_uint64); // = 8
8592
8600
}
8593
8601
}
8594
8602
}
@@ -8599,7 +8607,7 @@ int LoadEXRMultipartImageFromMemory(EXRImage *exr_images,
8599
8607
for (size_t i = 0 ; i < static_cast <size_t >(num_parts); i++) {
8600
8608
tinyexr::OffsetData &offset_data = chunk_offset_table_list[i];
8601
8609
8602
- // First check 'part number' is identitical to 'i'
8610
+ // First check 'part number' is identical to 'i'
8603
8611
for (unsigned int l = 0 ; l < offset_data.offsets .size (); ++l)
8604
8612
for (unsigned int dy = 0 ; dy < offset_data.offsets [l].size (); ++dy)
8605
8613
for (unsigned int dx = 0 ; dx < offset_data.offsets [l][dy].size (); ++dx) {
@@ -8971,7 +8979,7 @@ int SaveEXR(const float *data, int width, int height, int components,
8971
8979
}
8972
8980
8973
8981
#ifdef __clang__
8974
- // zero-as-null-ppinter -constant
8982
+ // zero-as-null-pointer -constant
8975
8983
#pragma clang diagnostic pop
8976
8984
#endif
8977
8985
0 commit comments