@@ -1693,17 +1693,17 @@ OpenEXROutput::write_deep_scanlines(int ybegin, int yend, int /*z*/,
1693
1693
return false ;
1694
1694
}
1695
1695
1696
- int nchans = m_spec.nchannels ;
1696
+ size_t nchans ( m_spec.nchannels ) ;
1697
1697
const DeepData* dd = &deepdata;
1698
1698
std::unique_ptr<DeepData> dd_local; // In case we need a copy
1699
1699
bool same_chantypes = true ;
1700
- for (int c = 0 ; c < nchans; ++c)
1700
+ for (size_t c = 0 ; c < nchans; ++c)
1701
1701
same_chantypes &= (m_spec.channelformat (c) == deepdata.channeltype (c));
1702
1702
if (!same_chantypes) {
1703
1703
// If the channel types don't match, we need to make a copy of the
1704
1704
// DeepData and convert the channels to the spec's channel types.
1705
1705
std::vector<TypeDesc> chantypes;
1706
- if (m_spec.channelformats .size () == size_t ( nchans) )
1706
+ if (m_spec.channelformats .size () == nchans)
1707
1707
chantypes = m_spec.channelformats ;
1708
1708
else
1709
1709
chantypes.resize (nchans, m_spec.format );
@@ -1722,15 +1722,15 @@ OpenEXROutput::write_deep_scanlines(int ybegin, int yend, int /*z*/,
1722
1722
frameBuffer.insertSampleCountSlice (countslice);
1723
1723
std::vector<void *> pointerbuf;
1724
1724
dd->get_pointers (pointerbuf);
1725
- for (int c = 0 ; c < nchans; ++c) {
1725
+ size_t slchans = size_t (m_spec.width ) * nchans;
1726
+ size_t xstride = sizeof (void *) * nchans;
1727
+ size_t ystride = sizeof (void *) * slchans;
1728
+ size_t samplestride = dd->samplesize ();
1729
+ for (size_t c = 0 ; c < nchans; ++c) {
1726
1730
Imf::DeepSlice slice (m_pixeltype[c],
1727
1731
(char *)(&pointerbuf[c] - m_spec.x * nchans
1728
- - ybegin * m_spec.width * nchans),
1729
- sizeof (void *)
1730
- * nchans, // xstride of pointer array
1731
- sizeof (void *) * nchans
1732
- * m_spec.width , // ystride of pointer array
1733
- dd->samplesize ()); // stride of data sample
1732
+ - ybegin * slchans),
1733
+ xstride, ystride, samplestride);
1734
1734
frameBuffer.insert (m_spec.channelnames [c].c_str (), slice);
1735
1735
}
1736
1736
m_deep_scanline_output_part->setFrameBuffer (frameBuffer);
@@ -1765,17 +1765,17 @@ OpenEXROutput::write_deep_tiles(int xbegin, int xend, int ybegin, int yend,
1765
1765
return false ;
1766
1766
}
1767
1767
1768
- int nchans = m_spec.nchannels ;
1768
+ size_t nchans = size_t ( m_spec.nchannels ) ;
1769
1769
const DeepData* dd = &deepdata;
1770
1770
std::unique_ptr<DeepData> dd_local; // In case we need a copy
1771
1771
bool same_chantypes = true ;
1772
- for (int c = 0 ; c < nchans; ++c)
1772
+ for (size_t c = 0 ; c < nchans; ++c)
1773
1773
same_chantypes &= (m_spec.channelformat (c) == deepdata.channeltype (c));
1774
1774
if (!same_chantypes) {
1775
1775
// If the channel types don't match, we need to make a copy of the
1776
1776
// DeepData and convert the channels to the spec's channel types.
1777
1777
std::vector<TypeDesc> chantypes;
1778
- if (m_spec.channelformats .size () == size_t ( nchans) )
1778
+ if (m_spec.channelformats .size () == nchans)
1779
1779
chantypes = m_spec.channelformats ;
1780
1780
else
1781
1781
chantypes.resize (nchans, m_spec.format );
@@ -1796,15 +1796,15 @@ OpenEXROutput::write_deep_tiles(int xbegin, int xend, int ybegin, int yend,
1796
1796
frameBuffer.insertSampleCountSlice (countslice);
1797
1797
std::vector<void *> pointerbuf;
1798
1798
dd->get_pointers (pointerbuf);
1799
- for (int c = 0 ; c < nchans; ++c) {
1799
+ size_t slchans = width * nchans;
1800
+ size_t xstride = sizeof (void *) * nchans;
1801
+ size_t ystride = sizeof (void *) * slchans;
1802
+ size_t samplestride = dd->samplesize ();
1803
+ for (size_t c = 0 ; c < nchans; ++c) {
1800
1804
Imf::DeepSlice slice (m_pixeltype[c],
1801
1805
(char *)(&pointerbuf[c] - xbegin * nchans
1802
- - ybegin * width * nchans),
1803
- sizeof (void *)
1804
- * nchans, // xstride of pointer array
1805
- sizeof (void *) * nchans
1806
- * width, // ystride of pointer array
1807
- dd->samplesize ()); // stride of data sample
1806
+ - ybegin * slchans),
1807
+ xstride, ystride, samplestride);
1808
1808
frameBuffer.insert (m_spec.channelnames [c].c_str (), slice);
1809
1809
}
1810
1810
m_deep_tiled_output_part->setFrameBuffer (frameBuffer);
0 commit comments