Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HEIF support #2160

Merged
merged 1 commit into from
Jan 24, 2019
Merged
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
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Release 2.1 (?? 2019) -- compared to 2.0
New minimum dependencies:

Major new features and improvements:
* Support for HEIC/HEIF images. HEIC is the still-image sibling of HEVC
(a.k.a. H.265), and compresses to about half the size of JPEG but with
higher visual quality. (2.1.0)

Public API changes:
* Python: define `__version__` for the module. #2096 (2.1.0/2.0.4)
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ set (USE_EXTERNAL_PUGIXML OFF CACHE BOOL
"Use an externally built shared library version of the pugixml library")
set (PUGIXML_HOME "" CACHE STRING "Hint about where to find external PugiXML library")
option (USE_DICOM "Use DICOM if DCMTK is found" ON)
option (USE_HEIF "Support HEIC/HEIF files, if libheif is found)" ON)
set (TEX_BATCH_SIZE "" CACHE STRING "Force TextureSystem SIMD batch size (e.g. 16)")
set (SOVERSION ${OIIO_VERSION_MAJOR}.${OIIO_VERSION_MINOR}
CACHE STRING "Set the SO version in the SO name of the output library")
Expand Down Expand Up @@ -370,6 +371,10 @@ oiio_add_tests (fits
IMAGEDIR fits-images
URL http://www.cv.nrao.edu/fits/data/tests/)

oiio_add_tests (heif
FOUNDVAR LIBHEIF_FOUND
URL https://github.com/nokiatech/heif/tree/gh-pages/content)

oiio_add_tests (webp
FOUNDVAR WEBP_FOUND
IMAGEDIR oiio-images/webp
Expand Down
2 changes: 2 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ NEW or CHANGED MINIMUM dependencies since the last major release are **bold**.
* If you want support for converting to and from OpenCV data structures,
or for capturing images from a camera:
* OpenCV 2.x, 3.x, or 4.x
* If you want support for HEIF/HEIC images:
* libheic >= 1.3 (older versions may work, we haven't tested)


Building OpenImageIO on Linux or OS X
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ OpenImageIO consists of:
including TIFF, JPEG/JFIF, OpenEXR, PNG, HDR/RGBE, ICO, BMP, Targa,
JPEG-2000, RMan Zfile, FITS, DDS, Softimage PIC, PNM, DPX, Cineon,
IFF, Field3D, OpenVDB, Ptex, Photoshop PSD, Wavefront RLA, SGI, WebP,
GIF, DICOM, many "RAW" digital camera formats, and a variety of movie
formats (readable as individual frames). More are being developed
GIF, DICOM, HEIC/HEIF, many "RAW" digital camera formats, and a variety of
movie formats (readable as individual frames). More are being developed
all the time.

* Several command line image tools based on these classes, including
Expand Down
3 changes: 2 additions & 1 deletion site/spi/Makefile-bits-arnold
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ ifeq (${SP_OS}, rhel7)
-DHDF5_LIBRARIES=/usr/lib64/libhdf5.so \
-DNuke_ROOT=/net/apps/rhel7/foundry/nuke${NUKE_VERSION} \
-DLIBRAW_INCLUDEDIR_HINT=/usr/include/libraw-0.18.11 \
-DLIBRAW_LIBDIR_HINT=/usr/lib64/libraw-0.18.11
-DLIBRAW_LIBDIR_HINT=/usr/lib64/libraw-0.18.11 \
-DLIBHEIF_PATH=/shots/spi/home/lib/arnold/rhel7/libheif-1.3.2

# Special sauce for Python 3.6
ifeq (${PYTHON_VERSION},3.6)
Expand Down
3 changes: 2 additions & 1 deletion site/spi/Makefile-bits-spcomp2
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ ifeq (${SP_OS}, rhel7)
-DHDF5_LIBRARIES=/usr/lib64/libhdf5.so \
-DNuke_ROOT=/net/apps/rhel7/foundry/nuke${NUKE_VERSION} \
-DLIBRAW_INCLUDEDIR_HINT=/usr/include/libraw-0.18.11 \
-DLIBRAW_LIBDIR_HINT=/usr/lib64/libraw-0.18.11
-DLIBRAW_LIBDIR_HINT=/usr/lib64/libraw-0.18.11 \
-DLIBHEIF_PATH=/shots/spi/home/lib/arnold/rhel7/libheif-1.3.2

# Special sauce for Python 3.6
ifeq (${PYTHON_VERSION},3.6)
Expand Down
1 change: 1 addition & 0 deletions src/build-scripts/install_homebrew_deps.bash
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ brew install opencv
brew install tbb
brew install openvdb
brew install pybind11
brew install libheif
if [ "$LINKSTATIC" == "1" ] ; then
brew install little-cms2 tinyxml szip
brew install homebrew/dupes/bzip2
Expand Down
10 changes: 10 additions & 0 deletions src/cmake/externalpackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ if (NOT VERBOSE)
set (HDF5_FIND_QUIETLY true)
set (IlmBase_FIND_QUIETLY true)
set (JPEG_FIND_QUIETLY true)
set (LIBHEIF_FIND_QUIETLY true)
set (LibRaw_FIND_QUIETLY true)
set (Nuke_FIND_QUIETLY true)
set (OpenColorIO_FIND_QUIETLY true)
Expand Down Expand Up @@ -518,6 +519,15 @@ endif()
###########################################################################


###########################################################################
# HEIF
if (USE_HEIF)
find_package (Libheif 1.3)
endif()
# end HEIF setup
###########################################################################


###########################################################################
# pybind11

Expand Down
56 changes: 56 additions & 0 deletions src/cmake/modules/FindLibheif.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Module to find LIBHEIF
#
# This module will first look into the directories defined by the variables:
# - LIBHEIF_PATH, LIBHEIF_INCLUDE_PATH, LIBHEIF_LIBRARY_PATH
#
# This module defines the following variables:
#
# LIBHEIF_FOUND True if LIBHEIF was found.
# LIBHEIF_INCLUDES Where to find LIBHEIF headers
# LIBHEIF_LIBRARIES List of libraries to link against when using LIBHEIF
# LIBHEIF_VERSION Version of LIBHEIF (e.g., 3.6.2)

include (FindPackageHandleStandardArgs)
include (FindPackageMessage)

find_path (LIBHEIF_INCLUDE_DIR
libheif/heif_version.h
PATHS
${LIBHEIF_INCLUDE_PATH}
${LIBHEIF_PATH}/include/
DOC "The directory where libheif headers reside")

find_library (LIBHEIF_LIBRARY heif
PATHS ${LIBHEIF_PATH}/lib ${LIBHEIF_LIBRARY_PATH})

message (STATUS "LIBHEIF_INCLUDE_DIR = ${LIBHEIF_INCLUDE_DIR}")
if (LIBHEIF_INCLUDE_DIR)
file(STRINGS "${LIBHEIF_INCLUDE_DIR}/libheif/heif_version.h" TMP REGEX "^#define LIBHEIF_VERSION[ \t].*$")
string(REGEX MATCHALL "[0-9.]+" LIBHEIF_VERSION ${TMP})
endif ()

if (LIBHEIF_INCLUDE_DIR AND LIBHEIF_LIBRARY)
set(LIBHEIF_FOUND TRUE)
set(LIBHEIF_INCLUDES "${LIBHEIF_INCLUDE_DIR}")
set(LIBHEIF_LIBRARIES "${LIBHEIF_LIBRARY}")
if (NOT LIBHEIF_FIND_QUIETLY)
message(STATUS "Found libheif ${LIBHEIF_VERSION} library ${LIBHEIF_LIBRARIES}")
message(STATUS "Found libheif includes ${LIBHEIF_INCLUDES}")
endif ()
else()
set(LIBHEIF_FOUND FALSE)
message(STATUS "libheif not found. Specify LIBHEIF_PATH to locate it")
endif()

include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (LIBHEIF
REQUIRED_VARS LIBHEIF_INCLUDE_DIR
LIBHEIF_LIBRARIES
VERSION_VAR LIBHEIF_VERSION
)

mark_as_advanced (
LIBHEIF_INCLUDE_DIR
LIBHEIF_LIBRARIES
LIBHEIF_VERSION
)
34 changes: 34 additions & 0 deletions src/doc/builtinplugins.tex
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,40 @@ \section{HDR/RGBE}
RGBE header (if it's gamma corrected).
\end{tabular}

\vspace{.25in}


\section{HEIF/HEIC}
\label{sec:bundledplugins:heif}
\index{HEIF} \endex{HEIC}

HEIF is a container format for images compressed with the HEIC compression
standard (same compression as HEVC/H.265). It is used commonly for iPhone
camera pictures, but it is not Apple-specific and will probably become more
popualar on other platforms in coming years. HEIF files usually use the file
extension {\cf .HEIC}.

HEIC compression is lossy, but is higher visual quality than JPEG while
taking only half the file size. Currently, OIIO's HEIF reader supports
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the end of this sentence?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, yes. Will fix.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

reading files as RGB or RGBA, uint8 pixel values. Multi-image files are
currently supported for reading, but not yet writing. All pixel data is
uint8, though we hope to add support for HDR (more than 8 bits) in the
future.

\subsubsection*{Configuration settings for HEIF output}

When opening an HEIF \ImageOutput, the following special metadata tokens
control aspects of the writing itself:

\vspace{.125in}
\noindent\begin{tabular}{p{1.5in}|p{0.5in}|p{3.25in}}
\ImageSpec Attribute & Type & HEIF header data or explanation \\
\hline
\qkw{Compression} & string & If supplied, must be \qkw{heic}, but may
optionally have a quality value appended, like \qkw{heic:90}.
Quality can be 1-100, with 100 meaning lossless. The default is 75. \\[2ex]
\end{tabular}


\vspace{.25in}

Expand Down
3 changes: 3 additions & 0 deletions src/doc/oiiointro.tex
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ \section{Acknowledgments}
\item {\cf OpenVDB} \copyright\ 2012-2018 DreamWorks Animation LLC,
Mozilla Public License 2.0.
\item {\cf Thread Building Blocks} \copyright\ Intel. Apache 2.0 license.
\item {\cf libheif} \copyright 2017-2018 Struktur AG (LGPL). \\
\url{https://github.com/strukturag/libheif}

\end{itemize}


Expand Down
8 changes: 8 additions & 0 deletions src/heif.imageio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
if (USE_HEIF AND LIBHEIF_FOUND)
add_oiio_plugin (heifinput.cpp heifoutput.cpp
INCLUDE_DIRS ${LIBHEIF_INCLUDES}
LINK_LIBRARIES ${LIBHEIF_LIBRARIES}
DEFINITIONS "-DUSE_HEIF=1")
else ()
message (WARNING "heif plugin will not be built")
endif ()
Loading