| 748 | |
| 749 | |
| 750 | void |
| 751 | DeepData::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 |
no test coverage detected