MCPcopy Create free account
hub / github.com/cinder/Cinder / EncodeTiledLevel

Function EncodeTiledLevel

include/tinyexr/tinyexr.h:7313–7439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7311}
7312
7313static int EncodeTiledLevel(const EXRImage* level_image, const EXRHeader* exr_header,
7314 const std::vector<tinyexr::ChannelInfo>& channels,
7315 std::vector<std::vector<unsigned char> >& data_list,
7316 size_t start_index, // for data_list
7317 int num_x_tiles, int num_y_tiles,
7318 const std::vector<size_t>& channel_offset_list,
7319 int pixel_data_size,
7320 const void* compression_param, // must be set if zfp compression is enabled
7321 std::string* err) {
7322 int num_tiles = num_x_tiles * num_y_tiles;
7323 if (num_tiles != level_image->num_tiles) {
7324 if (err) {
7325 (*err) += "Invalid number of tiles in argument.\n";
7326 }
7327 return TINYEXR_ERROR_INVALID_ARGUMENT;
7328 }
7329
7330 if ((exr_header->tile_size_x > level_image->width || exr_header->tile_size_y > level_image->height) &&
7331 level_image->level_x == 0 && level_image->level_y == 0) {
7332 if (err) {
7333 (*err) += "Failed to encode tile data.\n";
7334 }
7335 return TINYEXR_ERROR_INVALID_DATA;
7336 }
7337
7338
7339#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0)
7340 std::atomic<bool> invalid_data(false);
7341#else
7342 bool invalid_data(false);
7343#endif
7344
7345#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0)
7346 std::vector<std::thread> workers;
7347 std::atomic<int> tile_count(0);
7348
7349 int num_threads = std::max(1, int(std::thread::hardware_concurrency()));
7350#if (TINYEXR_MAX_THREADS > 0)
7351 num_threads = std::min(num_threads,TINYEXR_MAX_THREADS);
7352#endif
7353 if (num_threads > int(num_tiles)) {
7354 num_threads = int(num_tiles);
7355 }
7356
7357 for (int t = 0; t < num_threads; t++) {
7358 workers.emplace_back(std::thread([&]() {
7359 int i = 0;
7360 while ((i = tile_count++) < num_tiles) {
7361
7362#else
7363 // Use signed int since some OpenMP compiler doesn't allow unsigned type for
7364 // `parallel for`
7365#if TINYEXR_USE_OPENMP
7366#pragma omp parallel for
7367#endif
7368 for (int i = 0; i < num_tiles; i++) {
7369
7370#endif

Callers 1

EncodeChunkFunction · 0.85

Calls 8

threadClass · 0.85
EncodePixelDataFunction · 0.85
swap4Function · 0.85
maxFunction · 0.50
minFunction · 0.50
resizeMethod · 0.45
sizeMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected