diff --git a/src/iconvert/iconvert.cpp b/src/iconvert/iconvert.cpp index 51f75a7e52..d98a2dfd49 100644 --- a/src/iconvert/iconvert.cpp +++ b/src/iconvert/iconvert.cpp @@ -375,8 +375,7 @@ convert_file(const std::string& in_filename, const std::string& out_filename) bool ok = true; bool mip_to_subimage_warning = false; - for (int subimage = 0; ok && in->seek_subimage(subimage, 0, inspec); - ++subimage) { + for (int subimage = 0; ok && in->seek_subimage(subimage, 0); ++subimage) { if (subimage > 0 && !out->supports("multiimage")) { print(stderr, "iconvert WARNING: {} does not support multiple subimages.\n" @@ -388,6 +387,7 @@ convert_file(const std::string& in_filename, const std::string& out_filename) int miplevel = 0; do { // Copy the spec, with possible change in format + inspec = in->spec(subimage, miplevel); ImageSpec outspec = inspec; bool nocopy = adjust_spec(in.get(), out.get(), inspec, outspec); if (miplevel > 0) { @@ -473,7 +473,7 @@ convert_file(const std::string& in_filename, const std::string& out_filename) } ++miplevel; - } while (ok && in->seek_subimage(subimage, miplevel, inspec)); + } while (ok && in->seek_subimage(subimage, miplevel)); } out->close(); diff --git a/src/igrep/igrep.cpp b/src/igrep/igrep.cpp index 4dddda897b..8182e60915 100644 --- a/src/igrep/igrep.cpp +++ b/src/igrep/igrep.cpp @@ -62,7 +62,6 @@ grep_file(const std::string& filename, std::regex& re, std::cerr << geterror() << "\n"; return false; } - ImageSpec spec = in->spec(); if (file_match) { bool match = false; @@ -83,6 +82,7 @@ grep_file(const std::string& filename, std::regex& re, do { if (!all_subimages && subimage > 0) break; + ImageSpec spec = in->spec(subimage); for (auto&& p : spec.extra_attribs) { TypeDesc t = p.type(); if (t.elementtype() == TypeDesc::STRING) { @@ -108,7 +108,7 @@ grep_file(const std::string& filename, std::regex& re, } } } - } while (in->seek_subimage(++subimage, 0, spec)); + } while (in->seek_subimage(++subimage, 0)); if (invert_match) { found = !found; diff --git a/src/iinfo/iinfo.cpp b/src/iinfo/iinfo.cpp index 86295e3c9b..6a051902f0 100644 --- a/src/iinfo/iinfo.cpp +++ b/src/iinfo/iinfo.cpp @@ -243,8 +243,9 @@ static void print_info_subimage(int current_subimage, int max_subimages, ImageSpec& spec, ImageInput* input, const std::string& filename) { - if (!input->seek_subimage(current_subimage, 0, spec)) + if (!input->seek_subimage(current_subimage, 0)) return; + spec = input->spec(current_subimage); if (!metamatch.empty() && !std::regex_search( @@ -274,9 +275,9 @@ print_info_subimage(int current_subimage, int max_subimages, ImageSpec& spec, print("\n"); } // Count MIP levels - ImageSpec mipspec; - while (input->seek_subimage(current_subimage, nmip, mipspec)) { + while (input->seek_subimage(current_subimage, nmip)) { if (printres) { + ImageSpec mipspec = input->spec_dimensions(current_subimage, nmip); if (nmip == 1) print(" MIP-map levels: {}x{}", spec.width, spec.height); print(" {}x{}", mipspec.width, mipspec.height); @@ -291,8 +292,7 @@ print_info_subimage(int current_subimage, int max_subimages, ImageSpec& spec, if (filenameprefix) print("{} : ", filename); // Before sha-1, be sure to point back to the highest-res MIP level - ImageSpec tmpspec; - input->seek_subimage(current_subimage, 0, tmpspec); + input->seek_subimage(current_subimage, 0); print_sha1(input, current_subimage, 0); } @@ -302,8 +302,7 @@ print_info_subimage(int current_subimage, int max_subimages, ImageSpec& spec, if (compute_stats && (metamatch.empty() || std::regex_search("stats", field_re))) { for (int m = 0; m < nmip; ++m) { - ImageSpec mipspec; - input->seek_subimage(current_subimage, m, mipspec); + ImageSpec mipspec = input->spec_dimensions(current_subimage, m); if (filenameprefix) print("{} : ", filename); if (nmip > 1 && (subimages || m == 0)) { @@ -314,7 +313,7 @@ print_info_subimage(int current_subimage, int max_subimages, ImageSpec& spec, } } - if (!input->seek_subimage(current_subimage, 0, spec)) + if (!input->seek_subimage(current_subimage, 0)) return; } @@ -334,23 +333,24 @@ print_info(const std::string& filename, size_t namefieldlength, std::vector num_of_miplevels; { int nmip = 1; - while (input->seek_subimage(input->current_subimage(), nmip, spec)) { + while (input->seek_subimage(input->current_subimage(), nmip)) { ++nmip; any_mipmapping = true; } num_of_miplevels.push_back(nmip); } - while (input->seek_subimage(num_of_subimages, 0, spec)) { + while (input->seek_subimage(num_of_subimages, 0)) { // maybe we should do this more gently? ++num_of_subimages; int nmip = 1; - while (input->seek_subimage(input->current_subimage(), nmip, spec)) { + while (input->seek_subimage(input->current_subimage(), nmip)) { ++nmip; any_mipmapping = true; } num_of_miplevels.push_back(nmip); } - input->seek_subimage(0, 0, spec); // re-seek to the first + // input->seek_subimage(0, 0); // re-seek to the first + spec = input->spec(0, 0); if (metamatch.empty() || std::regex_search("resolution, width, height, depth, channels", @@ -388,7 +388,7 @@ print_info(const std::string& filename, size_t namefieldlength, // info about num of subimages and their resolutions print(" {} subimages: ", num_of_subimages); for (int i = 0; i < num_of_subimages; ++i) { - input->seek_subimage(i, 0, spec); + spec = input->spec(i, 0); int bits = spec.get_int_attribute("oiio:BitsPerSample", spec.format.size() * 8); if (i) diff --git a/src/include/OpenImageIO/imageio.h b/src/include/OpenImageIO/imageio.h index 32846f5652..0a02f751c0 100644 --- a/src/include/OpenImageIO/imageio.h +++ b/src/include/OpenImageIO/imageio.h @@ -66,11 +66,6 @@ typedef bool (*ProgressCallback)(void *opaque_data, float portion_done); -// Deprecated typedefs. Just use ParamValue and ParamValueList directly. -typedef ParamValue ImageIOParameter; -typedef ParamValueList ImageIOParameterList; - - // Forward declaration of IOProxy namespace Filesystem { class IOProxy; @@ -952,18 +947,24 @@ class OIIO_API ImageInput { ioproxy, plugin_searchpath); } - // DEPRECATED(2.2): back compatible version + /// @} + +#if OIIO_DISABLE_DEPRECATED < OIIO_MAKE_VERSION(2,2,0) && OIIO_VERSION_LESS(2,7,0) \ + && !defined(OIIO_DOXYGEN) && !defined(OIIO_INTERNAL) + OIIO_DEPRECATED("Use the modern form of create instead (2.2)") static unique_ptr create (const std::string& filename, bool do_open, const ImageSpec *config, - string_view plugin_searchpath); - // DEPRECATED(2.1) This method should no longer be used, it is redundant. + string_view plugin_searchpath) { + return create(filename, do_open, config, nullptr, plugin_searchpath); + } + OIIO_DEPRECATED("Use the modern form of create instead (2.1)") static unique_ptr create (const std::string& filename, - const std::string& plugin_searchpath); - - /// @} - - // DEPRECATED(2.1) - static void destroy (ImageInput *x); + const std::string& plugin_searchpath) { + return create(filename, false, nullptr, nullptr, plugin_searchpath); + } + OIIO_DEPRECATED("destroy is no longer needed (2.1)") + static void destroy (ImageInput *x) { delete x; } +#endif protected: ImageInput (); @@ -1190,21 +1191,29 @@ class OIIO_API ImageInput { return subimage == current_subimage() && miplevel == current_miplevel(); } +#if OIIO_DISABLE_DEPRECATED < OIIO_MAKE_VERSION(2,0,0) && !defined(OIIO_DOXYGEN) // Old version for backwards-compatibility: pass reference to newspec. // Some day this will be deprecated. + OIIO_DEPRECATED("Prefer the version that doesn't take an ImageSpec argument (2.0)") bool seek_subimage (int subimage, int miplevel, ImageSpec &newspec) { bool ok = seek_subimage (subimage, miplevel); if (ok) newspec = spec(); return ok; } +#endif - // DEPRECATED(2.1) +#if OIIO_DISABLE_DEPRECATED < OIIO_MAKE_VERSION(2,1,0) && !defined(OIIO_DOXYGEN) // Seek to the given subimage -- backwards-compatible call that // doesn't worry about MIP-map levels at all. + OIIO_DEPRECATED("Prefer the version that takes a mipmap argument (2.1)") bool seek_subimage (int subimage, ImageSpec &newspec) { - return seek_subimage (subimage, 0 /* miplevel */, newspec); + bool ok = seek_subimage (subimage, 0 /* miplevel */); + if (ok) + newspec = spec(subimage); + return ok; } +#endif /// @{ /// @name Reading pixels @@ -1317,7 +1326,8 @@ class OIIO_API ImageInput { stride_t xstride=AutoStride, stride_t ystride=AutoStride); -#ifndef OIIO_DOXYGEN +#if OIIO_DISABLE_DEPRECATED < OIIO_MAKE_VERSION(2,0,0) \ + && !defined(OIIO_DOXYGEN) && !defined(OIIO_INTERNAL) // DEPRECATED versions of read_scanlines (pre-1.9 OIIO). These will // eventually be removed. Try to replace these calls with ones to the // new variety of read_scanlines that takes an explicit subimage and @@ -1326,13 +1336,21 @@ class OIIO_API ImageInput { bool read_scanlines (int ybegin, int yend, int z, TypeDesc format, void *data, stride_t xstride=AutoStride, - stride_t ystride=AutoStride); + stride_t ystride=AutoStride) { + lock_guard lock(*this); + return read_scanlines(current_subimage(), current_miplevel(), ybegin, yend, + z, 0, m_spec.nchannels, format, data, xstride, ystride); + } OIIO_DEPRECATED("replace with version that takes subimage & miplevel parameters (2.0)") bool read_scanlines (int ybegin, int yend, int z, int chbegin, int chend, TypeDesc format, void *data, stride_t xstride=AutoStride, - stride_t ystride=AutoStride); + stride_t ystride=AutoStride) { + lock_guard lock(*this); + return read_scanlines(current_subimage(), current_miplevel(), ybegin, yend, + z, chbegin, chend, format, data, xstride, ystride); + } #endif /// Read the tile whose upper-left origin is (x,y,z) into `data[]`, @@ -1424,7 +1442,7 @@ class OIIO_API ImageInput { stride_t xstride=AutoStride, stride_t ystride=AutoStride, stride_t zstride=AutoStride); -#ifndef OIIO_DOXYGEN +#if OIIO_DISABLE_DEPRECATED < OIIO_MAKE_VERSION(2,0,0) && !defined(OIIO_DOXYGEN) // DEPRECATED versions of read_tiles (pre-1.9 OIIO). These will // eventually be removed. Try to replace these calls with ones to the // new variety of read_tiles that takes an explicit subimage and @@ -1485,7 +1503,7 @@ class OIIO_API ImageInput { ProgressCallback progress_callback=NULL, void *progress_callback_data=NULL); -#ifndef OIIO_DOXYGEN +#if OIIO_DISABLE_DEPRECATED < OIIO_MAKE_VERSION(2,0,0) && !defined(OIIO_DOXYGEN) // DEPRECATED versions of read_image (pre-1.9 OIIO). These will // eventually be removed. Try to replace these calls with ones to the // new variety of read_image that takes an explicit subimage and @@ -1680,13 +1698,23 @@ class OIIO_API ImageInput { /// thread that called whichever API function encountered an error. std::string geterror(bool clear = true) const; + /// Error reporting for the plugin implementation: call this with + /// std::format-like arguments. It is not necessary to have the error + /// message contain a trailing newline. + template + void errorfmt(const char* fmt, const Args&... args) const { + append_error(Strutil::fmt::format (fmt, args...)); + } + +#if OIIO_DISABLE_DEPRECATED < OIIO_MAKE_VERSION(2, 6, 3) && \ + !defined(OIIO_INTERNAL) && !defined(OIIO_DOXYGEN) /// Error reporting for the plugin implementation: call this with /// Strutil::format-like arguments. It is not necessary to have the /// error message contain a trailing newline. /// Use with caution! Some day this will change to be fmt-like rather /// than printf-like. template - OIIO_FORMAT_DEPRECATED + OIIO_DEPRECATED("use errorfmt instead, with std::format-like arguments (3.0)") void error(const char* fmt, const Args&... args) const { append_error(Strutil::format (fmt, args...)); } @@ -1695,27 +1723,20 @@ class OIIO_API ImageInput { /// printf-like arguments. It is not necessary to have the error message /// contain a trailing newline. template - OIIO_FORMAT_DEPRECATED + OIIO_DEPRECATED("use errorfmt instead, with std::format-like arguments (3.0)") void errorf(const char* fmt, const Args&... args) const { append_error(Strutil::sprintf (fmt, args...)); } - /// Error reporting for the plugin implementation: call this with - /// std::format-like arguments. It is not necessary to have the error - /// message contain a trailing newline. - template - void errorfmt(const char* fmt, const Args&... args) const { - append_error(Strutil::fmt::format (fmt, args...)); - } - // Error reporting for the plugin implementation: call this with // std::format-like arguments. It is not necessary to have the // error message contain a trailing newline. template - OIIO_DEPRECATED("use `errorfmt` instead") + OIIO_DEPRECATED("use `errorfmt` instead (2.3)") void fmterror(const char* fmt, const Args&... args) const { append_error(Strutil::fmt::format (fmt, args...)); } +#endif /// Set the threading policy for this ImageInput, controlling the /// maximum amount of parallelizing thread "fan-out" that might occur @@ -1862,10 +1883,6 @@ class OIIO_API ImageInput { std::unique_ptr m_impl; void append_error(string_view message) const; // add to error message - // Deprecated: - OIIO_DEPRECATED("Deprecated") - static unique_ptr create (const std::string& filename, bool do_open, - const std::string& plugin_searchpath); }; @@ -1924,14 +1941,19 @@ class OIIO_API ImageOutput { Strutil::utf16_to_utf8(plugin_searchpath)); } - // DEPRECATED(2.2) - static unique_ptr create (const std::string &filename, - const std::string &plugin_searchpath); - /// @} - // @deprecated - static void destroy (ImageOutput *x); +#if OIIO_DISABLE_DEPRECATED < OIIO_MAKE_VERSION(2,2,0) \ + && !defined(OIIO_DOXYGEN) && !defined(OIIO_INTERNAL) + OIIO_DEPRECATED("Obsolete version (2.2)") + static unique_ptr create (const std::string &filename, + const std::string &plugin_searchpath) { + return create(filename, nullptr, plugin_searchpath); + } + + OIIO_DEPRECATED("destroy is no longer needed") + static void destroy (ImageOutput *x) { delete x; } +#endif protected: ImageOutput (); @@ -2476,13 +2498,23 @@ class OIIO_API ImageOutput { /// thread that called whichever API function encountered an error. std::string geterror(bool clear = true) const; + /// Error reporting for the plugin implementation: call this with + /// std::format-like arguments. It is not necessary to have the error + /// message contain a trailing newline. + template + void errorfmt(const char* fmt, const Args&... args) const { + append_error(Strutil::fmt::format (fmt, args...)); + } + +#if OIIO_DISABLE_DEPRECATED < OIIO_MAKE_VERSION(2, 6, 3) && \ + !defined(OIIO_INTERNAL) && !defined(OIIO_DOXYGEN) /// Error reporting for the plugin implementation: call this with /// `Strutil::format`-like arguments. It is not necessary to have the /// error message contain a trailing newline. /// Use with caution! Some day this will change to be fmt-like rather /// than printf-like. template - OIIO_FORMAT_DEPRECATED + OIIO_DEPRECATED("use errorfmt instead, with std::format-like arguments (3.0)") void error(const char* fmt, const Args&... args) const { append_error(Strutil::format (fmt, args...)); } @@ -2491,27 +2523,20 @@ class OIIO_API ImageOutput { /// printf-like arguments. It is not necessary to have the error message /// contain a trailing newline. template - OIIO_FORMAT_DEPRECATED + OIIO_DEPRECATED("use errorfmt instead, with std::format-like arguments (3.0)") void errorf(const char* fmt, const Args&... args) const { append_error(Strutil::sprintf (fmt, args...)); } - /// Error reporting for the plugin implementation: call this with - /// std::format-like arguments. It is not necessary to have the error - /// message contain a trailing newline. - template - void errorfmt(const char* fmt, const Args&... args) const { - append_error(Strutil::fmt::format (fmt, args...)); - } - // Error reporting for the plugin implementation: call this with // std::format-like arguments. It is not necessary to have the error // message contain a trailing newline. template - OIIO_DEPRECATED("use `errorfmt` instead") + OIIO_DEPRECATED("use `errorfmt` instead (2.3)") void fmterror(const char* fmt, const Args&... args) const { append_error(Strutil::fmt::format (fmt, args...)); } +#endif /// Set the threading policy for this ImageOutput, controlling the /// maximum amount of parallelizing thread "fan-out" that might occur @@ -3237,12 +3262,6 @@ get_extension_map() OIIO_API bool convert_pixel_values (TypeDesc src_type, const void *src, TypeDesc dst_type, void *dst, int n = 1); -/// DEPRECATED(2.1): old name -inline bool convert_types (TypeDesc src_type, const void *src, - TypeDesc dst_type, void *dst, int n = 1) { - return convert_pixel_values (src_type, src, dst_type, dst, n); -} - /// Helper routine for data conversion: Convert an image of nchannels x /// width x height x depth from src to dst. The src and dst may have @@ -3260,18 +3279,6 @@ OIIO_API bool convert_image (int nchannels, int width, int height, int depth, void *dst, TypeDesc dst_type, stride_t dst_xstride, stride_t dst_ystride, stride_t dst_zstride); -/// DEPRECATED(2.0) -- the alpha_channel, z_channel were never used -inline bool convert_image(int nchannels, int width, int height, int depth, - const void *src, TypeDesc src_type, - stride_t src_xstride, stride_t src_ystride, stride_t src_zstride, - void *dst, TypeDesc dst_type, - stride_t dst_xstride, stride_t dst_ystride, stride_t dst_zstride, - int /*alpha_channel*/, int /*z_channel*/ = -1) -{ - return convert_image(nchannels, width, height, depth, src, src_type, - src_xstride, src_ystride, src_zstride, dst, dst_type, - dst_xstride, dst_ystride, dst_zstride); -} /// A version of convert_image that will break up big jobs into multiple @@ -3284,19 +3291,7 @@ OIIO_API bool parallel_convert_image ( void *dst, TypeDesc dst_type, stride_t dst_xstride, stride_t dst_ystride, stride_t dst_zstride, int nthreads=0); -/// DEPRECATED(2.0) -- the alpha_channel, z_channel were never used -inline bool parallel_convert_image( - int nchannels, int width, int height, int depth, - const void *src, TypeDesc src_type, - stride_t src_xstride, stride_t src_ystride, stride_t src_zstride, - void *dst, TypeDesc dst_type, - stride_t dst_xstride, stride_t dst_ystride, stride_t dst_zstride, - int /*alpha_channel*/, int /*z_channel*/, int nthreads=0) -{ - return parallel_convert_image (nchannels, width, height, depth, - src, src_type, src_xstride, src_ystride, src_zstride, - dst, dst_type, dst_xstride, dst_ystride, dst_zstride, nthreads); -} + /// Add random [-ditheramplitude,ditheramplitude] dither to the color channels /// of the image. Dither will not be added to the alpha or z channel. The @@ -3368,18 +3363,80 @@ void debugfmt (const char* fmt, Args&&... args) Strutil::debug(fmt, std::forward(args)...); } + + +// to force correct linkage on some systems +OIIO_API void _ImageIO_force_link (); + + +////////////////////////////////////////////////////////////////////////// +// DEPRECATED things +// +// These are all hidden from ocumentation and internal use, and should trigger +// deprecation warnings if used externally. They will most likely be removed +// entirely before the final release of OIIO 3.0. +// +#if !defined(OIIO_INTERNAL) && !defined(OIIO_DOXYGEN) + +#if OIIO_DISABLE_DEPRECATED < OIIO_MAKE_VERSION(1,9,0) && !defined(OIIO_INTERNAL) +// Deprecated typedefs. Just use ParamValue and ParamValueList directly. +OIIO_DEPRECATED("Use ParamValue instead") typedef ParamValue ImageIOParameter; +OIIO_DEPRECATED("Use ParamValueList instead") typedef ParamValueList ImageIOParameterList; +#endif + +#if OIIO_DISABLE_DEPRECATED < OIIO_MAKE_VERSION(2, 0, 0) +// DEPRECATED(2.0) -- the alpha_channel, z_channel were never used +OIIO_DEPRECATED("Deprecated version (2.0)") +inline bool convert_image(int nchannels, int width, int height, int depth, + const void *src, TypeDesc src_type, + stride_t src_xstride, stride_t src_ystride, stride_t src_zstride, + void *dst, TypeDesc dst_type, + stride_t dst_xstride, stride_t dst_ystride, stride_t dst_zstride, + int /*alpha_channel*/, int /*z_channel*/ = -1) +{ + return convert_image(nchannels, width, height, depth, src, src_type, + src_xstride, src_ystride, src_zstride, dst, dst_type, + dst_xstride, dst_ystride, dst_zstride); +} + +// DEPRECATED(2.0) -- the alpha_channel, z_channel were never used +OIIO_DEPRECATED("Deprecated version (2.0)") +inline bool parallel_convert_image( + int nchannels, int width, int height, int depth, + const void *src, TypeDesc src_type, + stride_t src_xstride, stride_t src_ystride, stride_t src_zstride, + void *dst, TypeDesc dst_type, + stride_t dst_xstride, stride_t dst_ystride, stride_t dst_zstride, + int /*alpha_channel*/, int /*z_channel*/, int nthreads=0) +{ + return parallel_convert_image (nchannels, width, height, depth, + src, src_type, src_xstride, src_ystride, src_zstride, + dst, dst_type, dst_xstride, dst_ystride, dst_zstride, nthreads); +} +#endif + +#if OIIO_DISABLE_DEPRECATED < OIIO_MAKE_VERSION(2, 1, 0) +// DEPRECATED(2.1): old name +OIIO_DEPRECATED("use convert_pixel_values instead (2.1)") +inline bool convert_types (TypeDesc src_type, const void *src, + TypeDesc dst_type, void *dst, int n = 1) { + return convert_pixel_values (src_type, src, dst_type, dst, n); +} +#endif + +#if OIIO_DISABLE_DEPRECATED < OIIO_MAKE_VERSION(2, 6, 3) // (Unfortunate old synonym) template OIIO_DEPRECATED("use `debugfmt` instead") -void fmtdebug (const char* fmt, const Args&... args) +inline void fmtdebug (const char* fmt, const Args&... args) { debug (Strutil::fmt::format(fmt, args...)); } /// debug output with printf conventions. template -OIIO_FORMAT_DEPRECATED -void debugf (const char* fmt, const Args&... args) +OIIO_DEPRECATED("use `debugfmt` instead, with std::format-like arguments (3.0)") +inline void debugf (const char* fmt, const Args&... args) { debug (Strutil::sprintf(fmt, args...)); } @@ -3387,15 +3444,16 @@ void debugf (const char* fmt, const Args&... args) /// debug output with the same conventions as Strutil::format. Beware, this /// will change one day! template -OIIO_FORMAT_DEPRECATED -void debug (const char* fmt, const T1& v1, const Args&... args) +OIIO_DEPRECATED("use `debugfmt` instead, with std::format-like arguments (3.0)") +inline void debug (const char* fmt, const T1& v1, const Args&... args) { debug (Strutil::format(fmt, v1, args...)); } +#endif - -// to force correct linkage on some systems -OIIO_API void _ImageIO_force_link (); +#endif +// +////////////////////////////////////////////////////////////////////////// OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/oiioversion.h.in b/src/include/OpenImageIO/oiioversion.h.in index 58f0483007..696ca787db 100644 --- a/src/include/OpenImageIO/oiioversion.h.in +++ b/src/include/OpenImageIO/oiioversion.h.in @@ -167,8 +167,10 @@ namespace @PROJ_NAME@ = @PROJ_NAMESPACE_V@; /// Version 24 Added a PIMPL pointers to ImageInput and ImageOutput and /// removed some unnecessary fields that were exposed. /// Version 25 added the thumbnail retrieval and set. (OIIO 2.3) +/// Version 26 deprecated the old stateful ImageInput::read_* methods. +/// (OIIO 2.6.3/3.0) -#define OIIO_PLUGIN_VERSION 25 +#define OIIO_PLUGIN_VERSION 26 #define OIIO_PLUGIN_NAMESPACE_BEGIN OIIO_NAMESPACE_BEGIN #define OIIO_PLUGIN_NAMESPACE_END OIIO_NAMESPACE_END diff --git a/src/libOpenImageIO/imagebufalgo_opencv.cpp b/src/libOpenImageIO/imagebufalgo_opencv.cpp index 20d76c03f8..81ad615407 100644 --- a/src/libOpenImageIO/imagebufalgo_opencv.cpp +++ b/src/libOpenImageIO/imagebufalgo_opencv.cpp @@ -269,7 +269,7 @@ ImageBufAlgo::from_OpenCV(const cv::Mat& mat, TypeDesc convert, ROI roi, parallel_convert_image(spec.nchannels, spec.width, spec.height, 1, mat.ptr(), srcformat, pixelsize, linestep, 0, dst.pixeladdr(roi.xbegin, roi.ybegin), dstformat, - spec.pixel_bytes(), spec.scanline_bytes(), 0, -1, -1, + spec.pixel_bytes(), spec.scanline_bytes(), 0, nthreads); // OpenCV uses BGR ordering diff --git a/src/libOpenImageIO/imageinput.cpp b/src/libOpenImageIO/imageinput.cpp index f6f25377eb..0a03219c6a 100644 --- a/src/libOpenImageIO/imageinput.cpp +++ b/src/libOpenImageIO/imageinput.cpp @@ -253,8 +253,8 @@ ImageInput::read_scanline(int y, int z, TypeDesc format, void* data, return false; if (m_spec.channelformats.empty()) { // No per-channel formats -- do the conversion in one shot - ok = contiguous ? convert_types(m_spec.format, buf, format, data, - scanline_values) + ok = contiguous ? convert_pixel_values(m_spec.format, buf, format, data, + scanline_values) : convert_image(m_spec.nchannels, m_spec.width, 1, 1, buf, m_spec.format, AutoStride, AutoStride, AutoStride, data, format, @@ -282,30 +282,6 @@ ImageInput::read_scanline(int y, int z, TypeDesc format, void* data, -bool -ImageInput::read_scanlines(int ybegin, int yend, int z, TypeDesc format, - void* data, stride_t xstride, stride_t ystride) -{ - lock_guard lock(*this); - return read_scanlines(current_subimage(), current_miplevel(), ybegin, yend, - z, 0, m_spec.nchannels, format, data, xstride, - ystride); -} - - - -bool -ImageInput::read_scanlines(int ybegin, int yend, int z, int chbegin, int chend, - TypeDesc format, void* data, stride_t xstride, - stride_t ystride) -{ - lock_guard lock(*this); - return read_scanlines(current_subimage(), current_miplevel(), ybegin, yend, - z, chbegin, chend, format, data, xstride, ystride); -} - - - bool ImageInput::read_scanlines(int subimage, int miplevel, int ybegin, int yend, int z, int chbegin, int chend, TypeDesc format, @@ -385,8 +361,8 @@ ImageInput::read_scanlines(int subimage, int miplevel, int ybegin, int yend, if (spec.channelformats.empty()) { // No per-channel formats -- do the conversion in one shot if (contiguous) { - ok = convert_types(spec.format, &buf[0], format, data, - chunkvalues); + ok = convert_pixel_values(spec.format, &buf[0], format, data, + chunkvalues); } else { ok = parallel_convert_image(nchans, spec.width, nscanlines, 1, &buf[0], spec.format, AutoStride, @@ -542,8 +518,8 @@ ImageInput::read_tile(int x, int y, int z, TypeDesc format, void* data, return false; if (m_spec.channelformats.empty()) { // No per-channel formats -- do the conversion in one shot - ok = contiguous ? convert_types(m_spec.format, &buf[0], format, data, - tile_values) + ok = contiguous ? convert_pixel_values(m_spec.format, &buf[0], format, + data, tile_values) : convert_image(m_spec.nchannels, m_spec.tile_width, m_spec.tile_height, m_spec.tile_depth, &buf[0], m_spec.format, AutoStride, @@ -903,9 +879,14 @@ ImageInput::read_image(TypeDesc format, void* data, stride_t xstride, ProgressCallback progress_callback, void* progress_callback_data) { - return read_image(current_subimage(), current_miplevel(), 0, -1, format, - data, xstride, ystride, zstride, progress_callback, - progress_callback_data); + int subimage, miplevel; + { + lock_guard lock(*this); + subimage = current_subimage(); + miplevel = current_miplevel(); + } + return read_image(subimage, miplevel, 0, -1, format, data, xstride, ystride, + zstride, progress_callback, progress_callback_data); } diff --git a/src/libOpenImageIO/imageioplugin.cpp b/src/libOpenImageIO/imageioplugin.cpp index d2a0210fff..a6b5356b07 100644 --- a/src/libOpenImageIO/imageioplugin.cpp +++ b/src/libOpenImageIO/imageioplugin.cpp @@ -593,54 +593,6 @@ ImageOutput::create(string_view filename, Filesystem::IOProxy* ioproxy, -// DEPRECATED(2.2) -std::unique_ptr -ImageOutput::create(const std::string& filename, - const std::string& plugin_searchpath) -{ - return create(filename, nullptr, plugin_searchpath); -} - - - -void -ImageOutput::destroy(ImageOutput* x) -{ - delete x; -} - - - -// DEPRECATED(2.1) -std::unique_ptr -ImageInput::create(const std::string& filename, - const std::string& plugin_searchpath) -{ - return create(filename, false, nullptr, plugin_searchpath); -} - - - -// DEPRECATED(2.1) -std::unique_ptr -ImageInput::create(const std::string& filename, bool do_open, - const std::string& plugin_searchpath) -{ - return create(filename, do_open, nullptr, plugin_searchpath); -} - - - -// DEPRECATED(2.2) -std::unique_ptr -ImageInput::create(const std::string& filename, bool do_open, - const ImageSpec* config, string_view plugin_searchpath) -{ - return create(filename, do_open, config, nullptr, plugin_searchpath); -} - - - std::unique_ptr ImageInput::create(string_view filename, bool do_open, const ImageSpec* config, Filesystem::IOProxy* ioproxy, string_view plugin_searchpath) @@ -838,12 +790,4 @@ ImageInput::create(string_view filename, bool do_open, const ImageSpec* config, } - -void -ImageInput::destroy(ImageInput* x) -{ - delete x; -} - - OIIO_NAMESPACE_END diff --git a/src/libtexture/imagecache.cpp b/src/libtexture/imagecache.cpp index dbc71d1044..f6d9b360e9 100644 --- a/src/libtexture/imagecache.cpp +++ b/src/libtexture/imagecache.cpp @@ -505,7 +505,7 @@ ImageCacheFile::open(ImageCachePerThreadInfo* thread_info) fmt = OIIO::Filesystem::extension(fmt, false); else fmt = m_filename.string(); - inp = ImageInput::create(fmt, false, &configspec, + inp = ImageInput::create(fmt, false, &configspec, nullptr, m_imagecache.plugin_searchpath()); } if (!inp) { @@ -564,7 +564,8 @@ ImageCacheFile::open(ImageCachePerThreadInfo* thread_info) int max_mip_res = imagecache().max_mip_res(); int nmip = 0; do { - tempspec = nativespec; + nativespec = inp->spec(nsubimages, nmip); + tempspec = nativespec; if (nmip == 0) { // Things to do on MIP level 0, i.e. once per subimage si.init(*this, tempspec, imagecache().forcefloat()); @@ -623,7 +624,7 @@ ImageCacheFile::open(ImageCachePerThreadInfo* thread_info) LevelInfo levelinfo(tempspec, nativespec); si.levels.push_back(levelinfo); ++nmip; - } while (inp->seek_subimage(nsubimages, nmip, nativespec)); + } while (inp->seek_subimage(nsubimages, nmip)); // Special work for non-MIPmapped images -- but only if "automip" // is on, it's a non-mipmapped image, and it doesn't have a @@ -691,7 +692,7 @@ ImageCacheFile::open(ImageCachePerThreadInfo* thread_info) si.minwh[m] = std::min(si.spec(m).width, si.spec(m).height); si.minwh[nmip] = 0; // One past the end, set to 0 ++nsubimages; - } while (inp->seek_subimage(nsubimages, 0, nativespec)); + } while (inp->seek_subimage(nsubimages, 0)); OIIO_DASSERT((size_t)nsubimages == m_subimages.size()); m_total_imagesize_ondisk = imagesize_t(Filesystem::file_size(m_filename)); @@ -3302,14 +3303,15 @@ ImageCacheImpl::get_pixels(ImageCacheFile* file, // Special case for a contiguous span within one tile int spanend = std::min(tx + spec.tile_width, xend); stride_t span = spanend - x; - convert_types(cachetype, data, format, xptr, - result_nchans * span); + convert_pixel_values(cachetype, data, format, xptr, + result_nchans * span); x += (span - 1); xptr += xstride * (span - 1); // no need to increment data, since next read will // be from a different tile } else { - convert_types(cachetype, data, format, xptr, result_nchans); + convert_pixel_values(cachetype, data, format, xptr, + result_nchans); data += cache_stride; } } diff --git a/src/libtexture/texturesys.cpp b/src/libtexture/texturesys.cpp index 578e3947e7..0cc8792348 100644 --- a/src/libtexture/texturesys.cpp +++ b/src/libtexture/texturesys.cpp @@ -884,11 +884,13 @@ TextureSystemImpl::get_texels(TextureHandle* texture_handle_, const char* data; if (tile && (data = (const char*)tile->data(x, y, z, chbegin))) { - convert_types(texfile->datatype(subimage), data, format, - result, actualchannels); + convert_pixel_values(texfile->datatype(subimage), data, + format, result, actualchannels); for (int c = actualchannels; c < nchannels; ++c) - convert_types(TypeDesc::FLOAT, &options.fill, format, - (char*)result + c * formatchannelsize, 1); + convert_pixel_values(TypeFloat, &options.fill, format, + (char*)result + + c * formatchannelsize, + 1); } else { memset(result, 0, formatpixelsize); } diff --git a/src/null.imageio/nullimageio.cpp b/src/null.imageio/nullimageio.cpp index 9f43e244d6..0454a0483d 100644 --- a/src/null.imageio/nullimageio.cpp +++ b/src/null.imageio/nullimageio.cpp @@ -320,8 +320,8 @@ NullInput::open(const std::string& name, ImageSpec& newspec, // Convert float to the native type fvalue.resize(m_topspec.nchannels, 0.0f); m_value.resize(m_topspec.pixel_bytes()); - convert_types(TypeFloat, fvalue.data(), m_topspec.format, - m_value.data(), m_topspec.nchannels); + convert_pixel_values(TypeFloat, fvalue.data(), m_topspec.format, + m_value.data(), m_topspec.nchannels); } bool ok = seek_subimage(0, 0); diff --git a/src/oiiotool/printinfo.cpp b/src/oiiotool/printinfo.cpp index c12ab1656c..3d5ddef48d 100644 --- a/src/oiiotool/printinfo.cpp +++ b/src/oiiotool/printinfo.cpp @@ -331,10 +331,10 @@ print_info_subimage(std::ostream& out, Oiiotool& ot, int current_subimage, mipdesc += format(" {}x{}", mipspec->width, mipspec->height); } } else if (input) { - ImageSpec mipspec; - for (int m = 1; input->seek_subimage(current_subimage, m, mipspec); - ++m) + for (int m = 1; input->seek_subimage(current_subimage, m); ++m) { + ImageSpec mipspec = input->spec_dimensions(current_subimage, m); mipdesc += format(" {}x{}", mipspec.width, mipspec.height); + } } lines.insert(lines.begin() + 1, mipdesc); } @@ -398,7 +398,7 @@ print_info_subimage(std::ostream& out, Oiiotool& ot, int current_subimage, if (img) spec = *img->nativespec(i); if (input) - input->seek_subimage(i, 0, spec); + spec = input->spec(i, 0); int bits = spec.get_int_attribute("oiio:BitsPerSample", spec.format.size() * 8); if (i) @@ -446,8 +446,6 @@ print_info_subimage(std::ostream& out, Oiiotool& ot, int current_subimage, out << ser; if (input && opt.dumpdata) { - ImageSpec tmp; - input->seek_subimage(current_subimage, 0, tmp); dump_data(out, input, opt, current_subimage); } @@ -456,7 +454,7 @@ print_info_subimage(std::ostream& out, Oiiotool& ot, int current_subimage, for (int m = 0; m < nmip; ++m) { ImageSpec mipspec; if (input) - input->seek_subimage(current_subimage, m, mipspec); + mipspec = input->spec(current_subimage, m); else if (img) mipspec = *img->spec(current_subimage, m); if (opt.filenameprefix) diff --git a/src/python/py_imageinput.cpp b/src/python/py_imageinput.cpp index ddc8d06796..795a8ea69b 100644 --- a/src/python/py_imageinput.cpp +++ b/src/python/py_imageinput.cpp @@ -176,7 +176,8 @@ declare_imageinput(py::module& m) "create", [](const std::string& filename, const std::string& searchpath) -> py::object { - auto in = ImageInput::create(filename, searchpath); + auto in = ImageInput::create(filename, false, nullptr, nullptr, + searchpath); return in ? py::cast(in.release()) : py::none(); }, "filename"_a, "plugin_searchpath"_a = "") diff --git a/src/python/py_imageoutput.cpp b/src/python/py_imageoutput.cpp index 25eac32f64..9a33abc19d 100644 --- a/src/python/py_imageoutput.cpp +++ b/src/python/py_imageoutput.cpp @@ -198,7 +198,7 @@ declare_imageoutput(py::module& m) "create", [](const std::string& filename, const std::string& searchpath) -> py::object { - auto out(ImageOutput::create(filename, searchpath)); + auto out(ImageOutput::create(filename, nullptr, searchpath)); return out ? py::cast(out.release()) : py::none(); }, "filename"_a, "plugin_searchpath"_a = "") diff --git a/testsuite/iinfo/ref/out-fmt6.txt b/testsuite/iinfo/ref/out-fmt6.txt index 97ef517847..2ee140f242 100644 --- a/testsuite/iinfo/ref/out-fmt6.txt +++ b/testsuite/iinfo/ref/out-fmt6.txt @@ -312,7 +312,7 @@ uint8_t foo[2][2][3] = /* (1, 1): */ { 64, 128, 191 /* (0.2509804, 0.5019608, 0.7490196) */ } }, }; Reading tmp.tif - + 39754B9B5BF224DA2869627680D5853D787E794F 0 0 diff --git a/testsuite/iinfo/ref/out.txt b/testsuite/iinfo/ref/out.txt index f29a286c8c..adc549a06a 100644 --- a/testsuite/iinfo/ref/out.txt +++ b/testsuite/iinfo/ref/out.txt @@ -312,7 +312,7 @@ uint8_t foo[2][2][3] = /* (1, 1): */ { 64, 128, 191 /* (0.2509804, 0.5019608, 0.7490196) */ } }, }; Reading tmp.tif - + 39754B9B5BF224DA2869627680D5853D787E794F 0 0 diff --git a/testsuite/python-imagespec/ref/out-python3.txt b/testsuite/python-imagespec/ref/out-python3.txt index c7c3e03326..bb671e9666 100644 --- a/testsuite/python-imagespec/ref/out-python3.txt +++ b/testsuite/python-imagespec/ref/out-python3.txt @@ -125,7 +125,7 @@ extra_attribs size is 10 99.5 seralize(xml): - + 1 2 3 diff --git a/testsuite/python-imagespec/ref/out.txt b/testsuite/python-imagespec/ref/out.txt index 67152b40bb..59c89e2199 100644 --- a/testsuite/python-imagespec/ref/out.txt +++ b/testsuite/python-imagespec/ref/out.txt @@ -125,7 +125,7 @@ extra_attribs size is 10 99.5 seralize(xml): - + 1 2 3