MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenImageIO / alloc

Method alloc

src/libOpenImageIO/imageio.cpp:750–774  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

748
749
750void
751DeepData::alloc ()
752{
753 // Calculate the total size we need, align each channel to 4 byte boundary
754 size_t totalsamples = 0, totalbytes = 0;
755 for (int i = 0; i < npixels; ++i) {
756 int s = nsamples[i];
757 totalsamples += s;
758 for (int c = 0; c < nchannels; ++c)
759 totalbytes += round_to_multiple (channeltypes[c].size() * s, 4);
760 }
761
762 // Set all the data pointers to the right offsets within the
763 // data block. Leave the pointes NULL for pixels with no samples.
764 data.resize (totalbytes);
765 char *p = &data[0];
766 for (int i = 0; i < npixels; ++i) {
767 if (nsamples[i]) {
768 for (int c = 0; c < nchannels; ++c) {
769 pointers[i*nchannels+c] = p;
770 p += round_to_multiple (channeltypes[c].size()*nsamples[i], 4);
771 }
772 }
773 }
774}
775
776
777

Callers 6

write_mipmapFunction · 0.45
channelsMethod · 0.45
IBAprepMethod · 0.45
make_kernelMethod · 0.45

Calls 3

round_to_multipleFunction · 0.85
resizeMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected