Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 1 addition & 36 deletions src/bmp.imageio/bmpoutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<unsigned char> m_tilebuffer;
std::vector<unsigned char> m_scratch;
std::vector<unsigned char> m_buf; // more tmp space for write_scanline

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)
{
Expand All @@ -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<unsigned char>().swap(m_tilebuffer);
}

init();
return ok;
return true;
}


Expand Down
36 changes: 1 addition & 35 deletions src/dpx.imageio/dpxoutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -69,7 +66,6 @@ class DPXOutput final : public ImageOutput {
std::vector<ImageSpec> m_subimage_specs;
bool m_write_pending; // subimage buffer needs to be written
unsigned int m_dither;
std::vector<unsigned char> m_tilebuffer;

// Initialize private members to pre-opened state
void init(void)
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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<unsigned char>().swap(m_tilebuffer);
}

ok &= write_buffer();
bool ok = write_buffer();
m_dpx.Finish();
init(); // Reset to initial state
return ok;
Expand Down Expand Up @@ -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)
{
Expand Down
31 changes: 1 addition & 30 deletions src/hdr.imageio/hdroutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned char> scratch;
std::vector<unsigned char> m_tilebuffer;

void init(void) { ioproxy_clear(); }

Expand Down Expand Up @@ -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;
}

Expand All @@ -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()
{
Expand All @@ -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<unsigned char>().swap(m_tilebuffer);
}

init();

return ok;
return true;
}

OIIO_PLUGIN_NAMESPACE_END
30 changes: 1 addition & 29 deletions src/ico.imageio/icooutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<unsigned char> m_tilebuffer;

png_structp m_png; ///< PNG read structure pointer
png_infop m_info; ///< PNG image info structure pointer
Expand Down Expand Up @@ -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;
}

Expand All @@ -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<unsigned char>().swap(m_tilebuffer);
}

if (m_png) {
PNG_pvt::write_end(m_png, m_info);
if (m_png || m_info)
Expand All @@ -411,7 +393,7 @@ ICOOutput::close()
fclose(m_file);
m_file = NULL;
init(); // re-initialize
return ok;
return true;
}


Expand Down Expand Up @@ -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
33 changes: 2 additions & 31 deletions src/jpeg.imageio/jpegoutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<unsigned char> m_tilebuffer;

// m_outbuffer/m_outsize are used for jpeg-to-memory
unsigned char* m_outbuffer = nullptr;
#if OIIO_JPEG_LIB_VERSION >= 94
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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()
{
Expand All @@ -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<unsigned char>().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
Expand Down Expand Up @@ -578,7 +549,7 @@ JpgOutput::close()
}

init();
return ok;
return true;
}


Expand Down
Loading