MCPcopy Create free account
hub / github.com/BinomialLLC/basis_universal / EncodeTiledLevel

Function EncodeTiledLevel

encoder/3rdparty/tinyexr.h:8826–8952  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8824}
8825
8826static int EncodeTiledLevel(const EXRImage* level_image, const EXRHeader* exr_header,
8827 const std::vector<tinyexr::ChannelInfo>& channels,
8828 std::vector<std::vector<unsigned char> >& data_list,
8829 size_t start_index, // for data_list
8830 int num_x_tiles, int num_y_tiles,
8831 const std::vector<size_t>& channel_offset_list,
8832 int pixel_data_size,
8833 const void* compression_param, // must be set if zfp compression is enabled
8834 std::string* err) {
8835 int num_tiles = num_x_tiles * num_y_tiles;
8836 if (num_tiles != level_image->num_tiles) {
8837 if (err) {
8838 (*err) += "Invalid number of tiles in argument.\n";
8839 }
8840 return TINYEXR_ERROR_INVALID_ARGUMENT;
8841 }
8842
8843 if ((exr_header->tile_size_x > level_image->width || exr_header->tile_size_y > level_image->height) &&
8844 level_image->level_x == 0 && level_image->level_y == 0) {
8845 if (err) {
8846 (*err) += "Failed to encode tile data.\n";
8847 }
8848 return TINYEXR_ERROR_INVALID_DATA;
8849 }
8850
8851
8852#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0)
8853 std::atomic<bool> invalid_data(false);
8854#else
8855 bool invalid_data(false);
8856#endif
8857
8858#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0)
8859 std::vector<std::thread> workers;
8860 std::atomic<int> tile_count(0);
8861
8862 int num_threads = std::max(1, int(std::thread::hardware_concurrency()));
8863#if (TINYEXR_MAX_THREADS > 0)
8864 num_threads = std::min(num_threads,TINYEXR_MAX_THREADS);
8865#endif
8866 if (num_threads > int(num_tiles)) {
8867 num_threads = int(num_tiles);
8868 }
8869
8870 for (int t = 0; t < num_threads; t++) {
8871 workers.emplace_back(std::thread([&]() {
8872 int i = 0;
8873 while ((i = tile_count++) < num_tiles) {
8874
8875#else
8876 // Use signed int since some OpenMP compiler doesn't allow unsigned type for
8877 // `parallel for`
8878#if TINYEXR_USE_OPENMP
8879#pragma omp parallel for
8880#endif
8881 for (int i = 0; i < num_tiles; i++) {
8882
8883#endif

Callers 1

EncodeChunkFunction · 0.85

Calls 7

EncodePixelDataFunction · 0.85
swap4Function · 0.85
emplace_backMethod · 0.80
maxFunction · 0.70
minFunction · 0.70
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected