@@ -1700,17 +1700,17 @@ OpenEXROutput::write_deep_scanlines(int ybegin, int yend, int /*z*/,
17001700 return false ;
17011701 }
17021702
1703- int nchans = m_spec.nchannels ;
1703+ size_t nchans ( m_spec.nchannels ) ;
17041704 const DeepData* dd = &deepdata;
17051705 std::unique_ptr<DeepData> dd_local; // In case we need a copy
17061706 bool same_chantypes = true ;
1707- for (int c = 0 ; c < nchans; ++c)
1707+ for (size_t c = 0 ; c < nchans; ++c)
17081708 same_chantypes &= (m_spec.channelformat (c) == deepdata.channeltype (c));
17091709 if (!same_chantypes) {
17101710 // If the channel types don't match, we need to make a copy of the
17111711 // DeepData and convert the channels to the spec's channel types.
17121712 std::vector<TypeDesc> chantypes;
1713- if (m_spec.channelformats .size () == size_t ( nchans) )
1713+ if (m_spec.channelformats .size () == nchans)
17141714 chantypes = m_spec.channelformats ;
17151715 else
17161716 chantypes.resize (nchans, m_spec.format );
@@ -1729,15 +1729,15 @@ OpenEXROutput::write_deep_scanlines(int ybegin, int yend, int /*z*/,
17291729 frameBuffer.insertSampleCountSlice (countslice);
17301730 std::vector<void *> pointerbuf;
17311731 dd->get_pointers (pointerbuf);
1732- for (int c = 0 ; c < nchans; ++c) {
1732+ size_t slchans = size_t (m_spec.width ) * nchans;
1733+ size_t xstride = sizeof (void *) * nchans;
1734+ size_t ystride = sizeof (void *) * slchans;
1735+ size_t samplestride = dd->samplesize ();
1736+ for (size_t c = 0 ; c < nchans; ++c) {
17331737 Imf::DeepSlice slice (m_pixeltype[c],
17341738 (char *)(&pointerbuf[c] - m_spec.x * nchans
1735- - ybegin * m_spec.width * nchans),
1736- sizeof (void *)
1737- * nchans, // xstride of pointer array
1738- sizeof (void *) * nchans
1739- * m_spec.width , // ystride of pointer array
1740- dd->samplesize ()); // stride of data sample
1739+ - ybegin * slchans),
1740+ xstride, ystride, samplestride);
17411741 frameBuffer.insert (m_spec.channelnames [c].c_str (), slice);
17421742 }
17431743 m_deep_scanline_output_part->setFrameBuffer (frameBuffer);
@@ -1772,17 +1772,17 @@ OpenEXROutput::write_deep_tiles(int xbegin, int xend, int ybegin, int yend,
17721772 return false ;
17731773 }
17741774
1775- int nchans = m_spec.nchannels ;
1775+ size_t nchans = size_t ( m_spec.nchannels ) ;
17761776 const DeepData* dd = &deepdata;
17771777 std::unique_ptr<DeepData> dd_local; // In case we need a copy
17781778 bool same_chantypes = true ;
1779- for (int c = 0 ; c < nchans; ++c)
1779+ for (size_t c = 0 ; c < nchans; ++c)
17801780 same_chantypes &= (m_spec.channelformat (c) == deepdata.channeltype (c));
17811781 if (!same_chantypes) {
17821782 // If the channel types don't match, we need to make a copy of the
17831783 // DeepData and convert the channels to the spec's channel types.
17841784 std::vector<TypeDesc> chantypes;
1785- if (m_spec.channelformats .size () == size_t ( nchans) )
1785+ if (m_spec.channelformats .size () == nchans)
17861786 chantypes = m_spec.channelformats ;
17871787 else
17881788 chantypes.resize (nchans, m_spec.format );
@@ -1803,15 +1803,15 @@ OpenEXROutput::write_deep_tiles(int xbegin, int xend, int ybegin, int yend,
18031803 frameBuffer.insertSampleCountSlice (countslice);
18041804 std::vector<void *> pointerbuf;
18051805 dd->get_pointers (pointerbuf);
1806- for (int c = 0 ; c < nchans; ++c) {
1806+ size_t slchans = width * nchans;
1807+ size_t xstride = sizeof (void *) * nchans;
1808+ size_t ystride = sizeof (void *) * slchans;
1809+ size_t samplestride = dd->samplesize ();
1810+ for (size_t c = 0 ; c < nchans; ++c) {
18071811 Imf::DeepSlice slice (m_pixeltype[c],
18081812 (char *)(&pointerbuf[c] - xbegin * nchans
1809- - ybegin * width * nchans),
1810- sizeof (void *)
1811- * nchans, // xstride of pointer array
1812- sizeof (void *) * nchans
1813- * width, // ystride of pointer array
1814- dd->samplesize ()); // stride of data sample
1813+ - ybegin * slchans),
1814+ xstride, ystride, samplestride);
18151815 frameBuffer.insert (m_spec.channelnames [c].c_str (), slice);
18161816 }
18171817 m_deep_tiled_output_part->setFrameBuffer (frameBuffer);
0 commit comments