diff --git a/src/bmp.imageio/bmpoutput.cpp b/src/bmp.imageio/bmpoutput.cpp index c6e772799c..e60ae820ff 100644 --- a/src/bmp.imageio/bmpoutput.cpp +++ b/src/bmp.imageio/bmpoutput.cpp @@ -27,9 +27,6 @@ class BmpOutput final : public ImageOutput { bool close(void) override; bool write_scanline(int y, int z, TypeDesc format, const void* data, stride_t xstride) override; - bool write_tile(int x, int y, int z, TypeDesc format, const void* data, - stride_t xstride, stride_t ystride, - stride_t zstride) override; private: int64_t m_padded_scanline_size; @@ -38,7 +35,6 @@ class BmpOutput final : public ImageOutput { bmp_pvt::DibInformationHeader m_dib_header; int64_t m_image_start; unsigned int m_dither; - std::vector m_tilebuffer; std::vector m_scratch; std::vector m_buf; // more tmp space for write_scanline @@ -110,11 +106,6 @@ BmpOutput::open(const std::string& name, const ImageSpec& spec, OpenMode mode) m_image_start = iotell(); - // If user asked for tiles -- which this format doesn't support, emulate - // it by buffering the whole image. - if (m_spec.tile_width && m_spec.tile_height) - m_tilebuffer.resize(m_spec.image_bytes()); - return true; } @@ -157,23 +148,6 @@ BmpOutput::write_scanline(int y, int z, TypeDesc format, const void* data, } - -bool -BmpOutput::write_tile(int x, int y, int z, TypeDesc format, const void* data, - stride_t xstride, stride_t ystride, stride_t zstride) -{ - if (!ioproxy_opened()) { - errorfmt("write_tile called but file is not open."); - return false; - } - - // Emulate tiles by buffering the whole image - return copy_tile_to_image_buffer(x, y, z, format, data, xstride, ystride, - zstride, m_tilebuffer.data()); -} - - - bool BmpOutput::close(void) { @@ -182,17 +156,8 @@ BmpOutput::close(void) return true; } - bool ok = true; - if (m_spec.tile_width && m_tilebuffer.size()) { - // Handle tile emulation -- output the buffered pixels - OIIO_DASSERT(m_tilebuffer.size()); - ok &= write_scanlines(m_spec.y, m_spec.y + m_spec.height, 0, - m_spec.format, m_tilebuffer.data()); - std::vector().swap(m_tilebuffer); - } - init(); - return ok; + return true; } diff --git a/src/dpx.imageio/dpxoutput.cpp b/src/dpx.imageio/dpxoutput.cpp index 4db1103a3c..719a38da1a 100644 --- a/src/dpx.imageio/dpxoutput.cpp +++ b/src/dpx.imageio/dpxoutput.cpp @@ -46,9 +46,6 @@ class DPXOutput final : public ImageOutput { bool close() override; bool write_scanline(int y, int z, TypeDesc format, const void* data, stride_t xstride) override; - bool write_tile(int x, int y, int z, TypeDesc format, const void* data, - stride_t xstride, stride_t ystride, - stride_t zstride) override; private: OutStream* m_stream = nullptr; @@ -69,7 +66,6 @@ class DPXOutput final : public ImageOutput { std::vector m_subimage_specs; bool m_write_pending; // subimage buffer needs to be written unsigned int m_dither; - std::vector m_tilebuffer; // Initialize private members to pre-opened state void init(void) @@ -417,11 +413,6 @@ DPXOutput::open(const std::string& name, const ImageSpec& userspec, ? spec0.get_int_attribute("oiio:dither", 0) : 0; - // If user asked for tiles -- which this format doesn't support, emulate - // it by buffering the whole image. - if (spec0.tile_width && spec0.tile_height) - m_tilebuffer.resize(spec0.image_bytes()); - return prep_subimage(m_subimage, true); } @@ -593,16 +584,7 @@ DPXOutput::close() return true; } - bool ok = true; - const ImageSpec& spec_s(m_subimage_specs[m_subimage]); - if (spec_s.tile_width && m_tilebuffer.size()) { - // Handle tile emulation -- output the buffered pixels - ok &= write_scanlines(spec_s.y, spec_s.y + spec_s.height, 0, - spec_s.format, &m_tilebuffer[0]); - std::vector().swap(m_tilebuffer); - } - - ok &= write_buffer(); + bool ok = write_buffer(); m_dpx.Finish(); init(); // Reset to initial state return ok; @@ -644,22 +626,6 @@ DPXOutput::write_scanline(int y, int z, TypeDesc format, const void* data, -bool -DPXOutput::write_tile(int x, int y, int z, TypeDesc format, const void* data, - stride_t xstride, stride_t ystride, stride_t zstride) -{ - if (!is_opened()) { - errorfmt("write_tile called but file is not open."); - return false; - } - - // Emulate tiles by buffering the whole image - return copy_tile_to_image_buffer(x, y, z, format, data, xstride, ystride, - zstride, &m_tilebuffer[0]); -} - - - dpx::Characteristic DPXOutput::get_characteristic_from_string(const std::string& str) { diff --git a/src/hdr.imageio/hdroutput.cpp b/src/hdr.imageio/hdroutput.cpp index 5feb97042a..e682a20079 100644 --- a/src/hdr.imageio/hdroutput.cpp +++ b/src/hdr.imageio/hdroutput.cpp @@ -26,14 +26,10 @@ class HdrOutput final : public ImageOutput { OpenMode mode) override; bool write_scanline(int y, int z, TypeDesc format, const void* data, stride_t xstride) override; - bool write_tile(int x, int y, int z, TypeDesc format, const void* data, - stride_t xstride, stride_t ystride, - stride_t zstride) override; bool close() override; private: std::vector scratch; - std::vector m_tilebuffer; void init(void) { ioproxy_clear(); } @@ -226,11 +222,6 @@ HdrOutput::open(const std::string& name, const ImageSpec& newspec, if (!iowritefmt("-Y {} +X {}\n", m_spec.height, m_spec.width)) return false; - // If user asked for tiles -- which this format doesn't support, emulate - // it by buffering the whole image. - if (m_spec.tile_width && m_spec.tile_height) - m_tilebuffer.resize(m_spec.image_bytes()); - return true; } @@ -246,17 +237,6 @@ HdrOutput::write_scanline(int /*y*/, int /*z*/, TypeDesc format, -bool -HdrOutput::write_tile(int x, int y, int z, TypeDesc format, const void* data, - stride_t xstride, stride_t ystride, stride_t zstride) -{ - // Emulate tiles by buffering the whole image - return copy_tile_to_image_buffer(x, y, z, format, data, xstride, ystride, - zstride, &m_tilebuffer[0]); -} - - - bool HdrOutput::close() { @@ -265,18 +245,9 @@ HdrOutput::close() return true; } - bool ok = true; - if (m_spec.tile_width) { - // We've been emulating tiles; now dump as scanlines. - OIIO_ASSERT(m_tilebuffer.size()); - ok &= write_scanlines(m_spec.y, m_spec.y + m_spec.height, 0, - m_spec.format, &m_tilebuffer[0]); - std::vector().swap(m_tilebuffer); - } - init(); - return ok; + return true; } OIIO_PLUGIN_NAMESPACE_END diff --git a/src/ico.imageio/icooutput.cpp b/src/ico.imageio/icooutput.cpp index 18e5fdb5a3..b6f3eed9de 100644 --- a/src/ico.imageio/icooutput.cpp +++ b/src/ico.imageio/icooutput.cpp @@ -32,9 +32,6 @@ class ICOOutput final : public ImageOutput { bool close() override; bool write_scanline(int y, int z, TypeDesc format, const void* data, stride_t xstride) override; - bool write_tile(int x, int y, int z, TypeDesc format, const void* data, - stride_t xstride, stride_t ystride, - stride_t zstride) override; private: std::string m_filename; ///< Stash the filename @@ -47,7 +44,6 @@ class ICOOutput final : public ImageOutput { int m_and_slb; ///< AND mask scanline length in bytes int m_bpp; ///< Bits per pixel unsigned int m_dither; - std::vector m_tilebuffer; png_structp m_png; ///< PNG read structure pointer png_infop m_info; ///< PNG image info structure pointer @@ -361,11 +357,6 @@ ICOOutput::open(const std::string& name, const ImageSpec& userspec, fseek(m_file, m_offset + sizeof(bmi), SEEK_SET); } - // If user asked for tiles -- which this format doesn't support, emulate - // it by buffering the whole image. - if (m_spec.tile_width && m_spec.tile_height) - m_tilebuffer.resize(m_spec.image_bytes()); - return true; } @@ -392,15 +383,6 @@ ICOOutput::close() return true; } - bool ok = true; - if (m_spec.tile_width) { - // Handle tile emulation -- output the buffered pixels - OIIO_ASSERT(m_tilebuffer.size()); - ok &= write_scanlines(m_spec.y, m_spec.y + m_spec.height, 0, - m_spec.format, &m_tilebuffer[0]); - std::vector().swap(m_tilebuffer); - } - if (m_png) { PNG_pvt::write_end(m_png, m_info); if (m_png || m_info) @@ -411,7 +393,7 @@ ICOOutput::close() fclose(m_file); m_file = NULL; init(); // re-initialize - return ok; + return true; } @@ -516,14 +498,4 @@ ICOOutput::write_scanline(int y, int z, TypeDesc format, const void* data, -bool -ICOOutput::write_tile(int x, int y, int z, TypeDesc format, const void* data, - stride_t xstride, stride_t ystride, stride_t zstride) -{ - // Emulate tiles by buffering the whole image - return copy_tile_to_image_buffer(x, y, z, format, data, xstride, ystride, - zstride, &m_tilebuffer[0]); -} - - OIIO_PLUGIN_NAMESPACE_END diff --git a/src/jpeg.imageio/jpegoutput.cpp b/src/jpeg.imageio/jpegoutput.cpp index f6058deb25..17962a22ed 100644 --- a/src/jpeg.imageio/jpegoutput.cpp +++ b/src/jpeg.imageio/jpegoutput.cpp @@ -40,9 +40,6 @@ class JpgOutput final : public ImageOutput { OpenMode mode = Create) override; bool write_scanline(int y, int z, TypeDesc format, const void* data, stride_t xstride) override; - bool write_tile(int x, int y, int z, TypeDesc format, const void* data, - stride_t xstride, stride_t ystride, - stride_t zstride) override; bool close() override; bool copy_image(ImageInput* in) override; @@ -55,7 +52,7 @@ class JpgOutput final : public ImageOutput { struct jpeg_error_mgr c_jerr; jvirt_barray_ptr* m_copy_coeffs; struct jpeg_decompress_struct* m_copy_decompressor; - std::vector m_tilebuffer; + // m_outbuffer/m_outsize are used for jpeg-to-memory unsigned char* m_outbuffer = nullptr; #if OIIO_JPEG_LIB_VERSION >= 94 @@ -356,11 +353,6 @@ JpgOutput::open(const std::string& name, const ImageSpec& newspec, m_dither = m_spec.get_int_attribute("oiio:dither", 0); - // If user asked for tiles -- which JPEG doesn't support, emulate it by - // buffering the whole image. - if (m_spec.tile_width && m_spec.tile_height) - m_tilebuffer.resize(m_spec.image_bytes()); - return true; } @@ -517,17 +509,6 @@ JpgOutput::write_scanline(int y, int z, TypeDesc format, const void* data, -bool -JpgOutput::write_tile(int x, int y, int z, TypeDesc format, const void* data, - stride_t xstride, stride_t ystride, stride_t zstride) -{ - // Emulate tiles by buffering the whole image - return copy_tile_to_image_buffer(x, y, z, format, data, xstride, ystride, - zstride, &m_tilebuffer[0]); -} - - - bool JpgOutput::close() { @@ -536,16 +517,6 @@ JpgOutput::close() return true; } - bool ok = true; - - if (m_spec.tile_width) { - // We've been emulating tiles; now dump as scanlines. - OIIO_DASSERT(m_tilebuffer.size()); - ok &= write_scanlines(m_spec.y, m_spec.y + m_spec.height, 0, - m_spec.format, &m_tilebuffer[0]); - std::vector().swap(m_tilebuffer); // free it - } - if (m_next_scanline < spec().height && m_copy_coeffs == NULL) { // But if we've only written some scanlines, write the rest to avoid // errors @@ -578,7 +549,7 @@ JpgOutput::close() } init(); - return ok; + return true; } diff --git a/src/png.imageio/pngoutput.cpp b/src/png.imageio/pngoutput.cpp index 00e11947c9..7d06eca25f 100644 --- a/src/png.imageio/pngoutput.cpp +++ b/src/png.imageio/pngoutput.cpp @@ -38,9 +38,6 @@ class PNGOutput final : public ImageOutput { bool write_scanlines(int ybegin, int yend, int z, TypeDesc format, const void* data, stride_t xstride = AutoStride, stride_t ystride = AutoStride) override; - bool write_tile(int x, int y, int z, TypeDesc format, const void* data, - stride_t xstride, stride_t ystride, - stride_t zstride) override; private: std::string m_filename; ///< Stash the filename @@ -55,7 +52,6 @@ class PNGOutput final : public ImageOutput { float m_gamma = 1.0f; ///< Gamma to use for alpha conversion std::vector m_scratch; std::vector m_pngtext; - std::vector m_tilebuffer; bool m_err = false; // Initialize private members to pre-opened state @@ -240,11 +236,6 @@ PNGOutput::open(const std::string& name, const ImageSpec& userspec, m_convert_alpha = m_spec.alpha_channel != -1 && !m_spec.get_int_attribute("oiio:UnassociatedAlpha", 0); - // If user asked for tiles -- which this format doesn't support, emulate - // it by buffering the whole image. - if (m_spec.tile_width && m_spec.tile_height) - m_tilebuffer.resize(m_spec.image_bytes()); - return true; } @@ -258,15 +249,6 @@ PNGOutput::close() return true; } - bool ok = true; - if (m_spec.tile_width) { - // Handle tile emulation -- output the buffered pixels - OIIO_ASSERT(m_tilebuffer.size()); - ok &= write_scanlines(m_spec.y, m_spec.y + m_spec.height, 0, - m_spec.format, &m_tilebuffer[0]); - std::vector().swap(m_tilebuffer); - } - if (m_png) { PNG_pvt::write_end(m_png, m_info); if (m_png || m_info) @@ -276,7 +258,7 @@ PNGOutput::close() } init(); // re-initialize - return ok; + return true; } @@ -457,14 +439,4 @@ PNGOutput::write_scanlines(int ybegin, int yend, int z, TypeDesc format, -bool -PNGOutput::write_tile(int x, int y, int z, TypeDesc format, const void* data, - stride_t xstride, stride_t ystride, stride_t zstride) -{ - // Emulate tiles by buffering the whole image - return copy_tile_to_image_buffer(x, y, z, format, data, xstride, ystride, - zstride, &m_tilebuffer[0]); -} - - OIIO_PLUGIN_NAMESPACE_END diff --git a/src/pnm.imageio/pnmoutput.cpp b/src/pnm.imageio/pnmoutput.cpp index 54596a3afa..1bb94b9677 100644 --- a/src/pnm.imageio/pnmoutput.cpp +++ b/src/pnm.imageio/pnmoutput.cpp @@ -30,9 +30,6 @@ class PNMOutput final : public ImageOutput { bool write_scanlines(int ybegin, int yend, int z, TypeDesc format, const void* data, stride_t xstride = AutoStride, stride_t ystride = AutoStride) override; - bool write_tile(int x, int y, int z, TypeDesc format, const void* data, - stride_t xstride, stride_t ystride, - stride_t zstride) override; private: std::string m_filename; // Stash the filename @@ -42,7 +39,6 @@ class PNMOutput final : public ImageOutput { unsigned int m_dither; std::vector m_scratch; - std::vector m_tilebuffer; void init(void) { ioproxy_clear(); } @@ -310,10 +306,6 @@ PNMOutput::open(const std::string& name, const ImageSpec& userspec, ok &= iowritefmt("{}\n", scale); } } - // If user asked for tiles -- which this format doesn't support, emulate - // it by buffering the whole image. - if (m_spec.tile_width && m_spec.tile_height) - m_tilebuffer.resize(m_spec.image_bytes()); return ok; } @@ -326,17 +318,8 @@ PNMOutput::close() if (!ioproxy_opened()) // already closed return true; - bool ok = true; - if (m_spec.tile_width) { - // Handle tile emulation -- output the buffered pixels - OIIO_DASSERT(m_tilebuffer.size()); - ok &= ImageOutput::write_scanlines(m_spec.y, m_spec.y + m_spec.height, - 0, m_spec.format, &m_tilebuffer[0]); - m_tilebuffer.shrink_to_fit(); - } - init(); - return ok; + return true; } @@ -422,14 +405,4 @@ PNMOutput::write_scanlines(int ybegin, int yend, int z, TypeDesc format, -bool -PNMOutput::write_tile(int x, int y, int z, TypeDesc format, const void* data, - stride_t xstride, stride_t ystride, stride_t zstride) -{ - // Emulate tiles by buffering the whole image - return copy_tile_to_image_buffer(x, y, z, format, data, xstride, ystride, - zstride, &m_tilebuffer[0]); -} - - OIIO_PLUGIN_NAMESPACE_END diff --git a/src/rla.imageio/rlaoutput.cpp b/src/rla.imageio/rlaoutput.cpp index fec2736d51..6afcad128f 100644 --- a/src/rla.imageio/rlaoutput.cpp +++ b/src/rla.imageio/rlaoutput.cpp @@ -35,16 +35,12 @@ class RLAOutput final : public ImageOutput { bool close() override; bool write_scanline(int y, int z, TypeDesc format, const void* data, stride_t xstride) override; - bool write_tile(int x, int y, int z, TypeDesc format, const void* data, - stride_t xstride, stride_t ystride, - stride_t zstride) override; private: std::vector m_scratch; RLAHeader m_rla; ///< Wavefront RLA header std::vector m_sot; ///< Scanline offset table std::vector m_rle; ///< Run record buffer for RLE - std::vector m_tilebuffer; unsigned int m_dither; // Initialize private members to pre-opened state @@ -340,11 +336,6 @@ RLAOutput::open(const std::string& name, const ImageSpec& userspec, m_sot.resize(m_spec.height, (int32_t)0); write(&m_sot[0], m_sot.size()); - // If user asked for tiles -- which this format doesn't support, emulate - // it by buffering the whole image. - if (m_spec.tile_width && m_spec.tile_height) - m_tilebuffer.resize(m_spec.image_bytes()); - return true; } @@ -382,22 +373,13 @@ RLAOutput::close() return true; } - bool ok = true; - if (m_spec.tile_width) { - // Handle tile emulation -- output the buffered pixels - OIIO_DASSERT(m_tilebuffer.size()); - ok &= write_scanlines(m_spec.y, m_spec.y + m_spec.height, 0, - m_spec.format, &m_tilebuffer[0]); - std::vector().swap(m_tilebuffer); - } - // Now that all scanlines have been output, return to write the // correct scanline offset table to file and close the stream. ioseek(sizeof(RLAHeader)); write(m_sot.data(), m_sot.size()); init(); // re-initialize - return ok; + return true; } @@ -545,14 +527,4 @@ RLAOutput::write_scanline(int y, int z, TypeDesc format, const void* data, -bool -RLAOutput::write_tile(int x, int y, int z, TypeDesc format, const void* data, - stride_t xstride, stride_t ystride, stride_t zstride) -{ - // Emulate tiles by buffering the whole image - return copy_tile_to_image_buffer(x, y, z, format, data, xstride, ystride, - zstride, &m_tilebuffer[0]); -} - - OIIO_PLUGIN_NAMESPACE_END diff --git a/src/targa.imageio/targaoutput.cpp b/src/targa.imageio/targaoutput.cpp index b580da9907..ef75e2c0bb 100644 --- a/src/targa.imageio/targaoutput.cpp +++ b/src/targa.imageio/targaoutput.cpp @@ -37,9 +37,6 @@ class TGAOutput final : public ImageOutput { bool close() override; bool write_scanline(int y, int z, TypeDesc format, const void* data, stride_t xstride) override; - bool write_tile(int x, int y, int z, TypeDesc format, const void* data, - stride_t xstride, stride_t ystride, - stride_t zstride) override; bool set_thumbnail(const ImageBuf& thumb) override; private: @@ -50,7 +47,6 @@ class TGAOutput final : public ImageOutput { std::vector m_scratch; int m_idlen; ///< Length of the TGA ID block unsigned int m_dither; - std::vector m_tilebuffer; ImageBuf m_thumb; // Initialize private members to pre-opened state @@ -239,11 +235,6 @@ TGAOutput::open(const std::string& name, const ImageSpec& userspec, } } - // If user asked for tiles -- which this format doesn't support, emulate - // it by buffering the whole image. - if (m_spec.tile_width && m_spec.tile_height) - m_tilebuffer.resize(m_spec.image_bytes()); - return true; } @@ -421,16 +412,7 @@ TGAOutput::close() return true; } - bool ok = true; - if (m_spec.tile_width) { - // Handle tile emulation -- output the buffered pixels - OIIO_ASSERT(m_tilebuffer.size()); - ok &= write_scanlines(m_spec.y, m_spec.y + m_spec.height, 0, - m_spec.format, &m_tilebuffer[0]); - m_tilebuffer.shrink_to_fit(); - } - - ok &= write_tga20_data_fields(); + bool ok = write_tga20_data_fields(); init(); // re-initialize return ok; @@ -681,17 +663,6 @@ TGAOutput::write_scanline(int y, int z, TypeDesc format, const void* data, -bool -TGAOutput::write_tile(int x, int y, int z, TypeDesc format, const void* data, - stride_t xstride, stride_t ystride, stride_t zstride) -{ - // Emulate tiles by buffering the whole image - return copy_tile_to_image_buffer(x, y, z, format, data, xstride, ystride, - zstride, &m_tilebuffer[0]); -} - - - bool TGAOutput::set_thumbnail(const ImageBuf& thumb) { diff --git a/src/zfile.imageio/zfile.cpp b/src/zfile.imageio/zfile.cpp index 65b3f4fc54..d2e326aa4a 100644 --- a/src/zfile.imageio/zfile.cpp +++ b/src/zfile.imageio/zfile.cpp @@ -92,16 +92,12 @@ class ZfileOutput final : public ImageOutput { bool close() override; bool write_scanline(int y, int z, TypeDesc format, const void* data, stride_t xstride) override; - bool write_tile(int x, int y, int z, TypeDesc format, const void* data, - stride_t xstride, stride_t ystride, - stride_t zstride) override; private: std::string m_filename; ///< Stash the filename FILE* m_file; ///< Open image handle for not compressed gzFile m_gz; ///< Handle for compressed files std::vector m_scratch; - std::vector m_tilebuffer; bool opened() const { return m_file || m_gz; } @@ -112,7 +108,6 @@ class ZfileOutput final : public ImageOutput { m_gz = 0; m_filename.clear(); m_scratch.clear(); - m_tilebuffer.clear(); } }; @@ -306,11 +301,6 @@ ZfileOutput::open(const std::string& name, const ImageSpec& userspec, return false; } - // If user asked for tiles -- which this format doesn't support, emulate - // it by buffering the whole image.this form - if (m_spec.tile_width && m_spec.tile_height) - m_tilebuffer.resize(m_spec.image_bytes()); - return true; } @@ -324,15 +314,6 @@ ZfileOutput::close() return true; } - bool ok = true; - if (m_spec.tile_width && m_tilebuffer.size()) { - // We've been emulating tiles; now dump as scanlines. - ok &= write_scanlines(m_spec.y, m_spec.y + m_spec.height, 0, - m_spec.format, m_tilebuffer.data()); - m_tilebuffer.clear(); - m_tilebuffer.shrink_to_fit(); - } - if (m_gz) { gzclose(m_gz); m_gz = 0; @@ -343,7 +324,7 @@ ZfileOutput::close() } init(); // re-initialize - return ok; + return true; } @@ -382,19 +363,4 @@ ZfileOutput::write_scanline(int y, int /*z*/, TypeDesc format, const void* data, -bool -ZfileOutput::write_tile(int x, int y, int z, TypeDesc format, const void* data, - stride_t xstride, stride_t ystride, stride_t zstride) -{ - if (!opened()) { - errorfmt("File not open"); - return false; - } - // Emulate tiles by buffering the whole image - OIIO_ASSERT(m_tilebuffer.data()); - return copy_tile_to_image_buffer(x, y, z, format, data, xstride, ystride, - zstride, m_tilebuffer.data()); -} - - OIIO_PLUGIN_NAMESPACE_END