libheif-1.1.0/ 0000755 0002210 0000144 00000000000 13265634507 010113 5 0000000 0000000 libheif-1.1.0/depcomp 0000755 0002210 0000144 00000056016 13216757744 011425 0000000 0000000 #! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2013-05-30.07; # UTC
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva .
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by 'PROGRAMS ARGS'.
object Object file output by 'PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputting dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to .
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
# Get the directory component of the given path, and save it in the
# global variables '$dir'. Note that this directory component will
# be either empty or ending with a '/' character. This is deliberate.
set_dir_from ()
{
case $1 in
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
*) dir=;;
esac
}
# Get the suffix-stripped basename of the given path, and save it the
# global variable '$base'.
set_base_from ()
{
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
}
# If no dependency file was actually created by the compiler invocation,
# we still have to create a dummy depfile, to avoid errors with the
# Makefile "include basename.Plo" scheme.
make_dummy_depfile ()
{
echo "#dummy" > "$depfile"
}
# Factor out some common post-processing of the generated depfile.
# Requires the auxiliary global variable '$tmpdepfile' to be set.
aix_post_process_depfile ()
{
# If the compiler actually managed to produce a dependency file,
# post-process it.
if test -f "$tmpdepfile"; then
# Each line is of the form 'foo.o: dependency.h'.
# Do two passes, one to just change these to
# $object: dependency.h
# and one to simply output
# dependency.h:
# which is needed to avoid the deleted-header problem.
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
} > "$depfile"
rm -f "$tmpdepfile"
else
make_dummy_depfile
fi
}
# A tabulation character.
tab=' '
# A newline character.
nl='
'
# Character ranges might be problematic outside the C locale.
# These definitions help.
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
lower=abcdefghijklmnopqrstuvwxyz
digits=0123456789
alpha=${upper}${lower}
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Avoid interferences from the environment.
gccflag= dashmflag=
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
cygpath_u="cygpath -u -f -"
if test "$depmode" = msvcmsys; then
# This is just like msvisualcpp but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvisualcpp
fi
if test "$depmode" = msvc7msys; then
# This is just like msvc7 but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvc7
fi
if test "$depmode" = xlc; then
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
gccflag=-qmakedep=gcc,-MF
depmode=gcc
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
## the command line argument order; so add the flags where they
## appear in depend2.am. Note that the slowdown incurred here
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
for arg
do
case $arg in
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
*) set fnord "$@" "$arg" ;;
esac
shift # fnord
shift # $arg
done
"$@"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
## (see the conditional assignment to $gccflag above).
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say). Also, it might not be
## supported by the other compilers which use the 'gcc' depmode.
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The second -e expression handles DOS-style file names with drive
# letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the "deleted header file" problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
## Some versions of gcc put a space before the ':'. On the theory
## that the space means something, we add a space to the output as
## well. hp depmode also adds that space, but also prefixes the VPATH
## to the object. Take care to not repeat it in the output.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like '#:fec' to the end of the
# dependency line.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
| tr "$nl" ' ' >> "$depfile"
echo >> "$depfile"
# The second pass generates a dummy entry for each header file.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile"
;;
xlc)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts '$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.u
tmpdepfile2=$base.u
tmpdepfile3=$dir.libs/$base.u
"$@" -Wc,-M
else
tmpdepfile1=$dir$base.u
tmpdepfile2=$dir$base.u
tmpdepfile3=$dir$base.u
"$@" -M
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
aix_post_process_depfile
;;
tcc)
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
# FIXME: That version still under development at the moment of writing.
# Make that this statement remains true also for stable, released
# versions.
# It will wrap lines (doesn't matter whether long or short) with a
# trailing '\', as in:
#
# foo.o : \
# foo.c \
# foo.h \
#
# It will put a trailing '\' even on the last line, and will use leading
# spaces rather than leading tabs (at least since its commit 0394caf7
# "Emit spaces for -MD").
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
# We have to change lines of the first kind to '$object: \'.
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
# And for each line of the second kind, we have to emit a 'dep.h:'
# dummy dependency, to avoid the deleted-header problem.
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
rm -f "$tmpdepfile"
;;
## The order of this option in the case statement is important, since the
## shell code in configure will try each of these formats in the order
## listed in this file. A plain '-MD' option would be understood by many
## compilers, so we must ensure this comes after the gcc and icc options.
pgcc)
# Portland's C compiler understands '-MD'.
# Will always output deps to 'file.d' where file is the root name of the
# source file under compilation, even if file resides in a subdirectory.
# The object file name does not affect the name of the '.d' file.
# pgcc 10.2 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using '\' :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
set_dir_from "$object"
# Use the source, not the object, to determine the base name, since
# that's sadly what pgcc will do too.
set_base_from "$source"
tmpdepfile=$base.d
# For projects that build the same source file twice into different object
# files, the pgcc approach of using the *source* file root name can cause
# problems in parallel builds. Use a locking strategy to avoid stomping on
# the same $tmpdepfile.
lockdir=$base.d-lock
trap "
echo '$0: caught signal, cleaning up...' >&2
rmdir '$lockdir'
exit 1
" 1 2 13 15
numtries=100
i=$numtries
while test $i -gt 0; do
# mkdir is a portable test-and-set.
if mkdir "$lockdir" 2>/dev/null; then
# This process acquired the lock.
"$@" -MD
stat=$?
# Release the lock.
rmdir "$lockdir"
break
else
# If the lock is being held by a different process, wait
# until the winning process is done or we timeout.
while test -d "$lockdir" && test $i -gt 0; do
sleep 1
i=`expr $i - 1`
done
fi
i=`expr $i - 1`
done
trap - 1 2 13 15
if test $i -le 0; then
echo "$0: failed to acquire lock after $numtries attempts" >&2
echo "$0: check lockdir '$lockdir'" >&2
exit 1
fi
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp2)
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
# compilers, which have integrated preprocessors. The correct option
# to use with these is +Maked; it writes dependencies to a file named
# 'foo.d', which lands next to the object file, wherever that
# happens to be.
# Much of this is similar to the tru64 case; see comments there.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir.libs/$base.d
"$@" -Wc,+Maked
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
"$@" +Maked
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
# Add 'dependent.h:' lines.
sed -ne '2,${
s/^ *//
s/ \\*$//
s/$/:/
p
}' "$tmpdepfile" >> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile" "$tmpdepfile2"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in 'foo.d' instead, so we check for that too.
# Subdirectories are respected.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
# Libtool generates 2 separate objects for the 2 libraries. These
# two compilations output dependencies in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir$base.o.d # libtool 1.5
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
# Same post-processing that is required for AIX mode.
aix_post_process_depfile
;;
msvc7)
if test "$libtool" = yes; then
showIncludes=-Wc,-showIncludes
else
showIncludes=-showIncludes
fi
"$@" $showIncludes > "$tmpdepfile"
stat=$?
grep -v '^Note: including file: ' "$tmpdepfile"
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The first sed program below extracts the file names and escapes
# backslashes for cygpath. The second sed program outputs the file
# name when reading, but also accumulates all include files in the
# hold buffer in order to output them again at the end. This only
# works with sed implementations that can handle large buffers.
sed < "$tmpdepfile" -n '
/^Note: including file: *\(.*\)/ {
s//\1/
s/\\/\\\\/g
p
}' | $cygpath_u | sort -u | sed -n '
s/ /\\ /g
s/\(.*\)/'"$tab"'\1 \\/p
s/.\(.*\) \\/\1:/
H
$ {
s/.*/'"$tab"'/
G
p
}' >> "$depfile"
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
rm -f "$tmpdepfile"
;;
msvc7msys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for ':'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
"$@" $dashmflag |
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this sed invocation
# correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no eat=no
for arg
do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
if test $eat = yes; then
eat=no
continue
fi
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-arch)
eat=yes ;;
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix=`echo "$object" | sed 's/^.*\././'`
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
# makedepend may prepend the VPATH from the source file name to the object.
# No need to regex-escape $object, excess matching of '.' is harmless.
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process the last invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed '1,2d' "$tmpdepfile" \
| tr ' ' "$nl" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E \
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
| sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
IFS=" "
for arg
do
case "$arg" in
-o)
shift
;;
$object)
shift
;;
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E 2>/dev/null |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
echo "$tab" >> "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvcmsys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
libheif-1.1.0/libheif.pc.in 0000644 0002210 0000144 00000000425 13222674722 012363 0000000 0000000 prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libheif
Description: HEIF image codec.
URL: https://github.com/strukturag/libheif
Version: @VERSION@
Requires:
Libs: -lheif -L@libdir@
Libs.private: @LIBS@ -lstdc++
Cflags: -I@includedir@
libheif-1.1.0/src/ 0000755 0002210 0000144 00000000000 13265634507 010702 5 0000000 0000000 libheif-1.1.0/src/heif_hevc.cc 0000644 0002210 0000144 00000017725 13263665765 013075 0000000 0000000 /*
* HEIF codec.
* Copyright (c) 2017 struktur AG, Dirk Farin
*
* This file is part of libheif.
*
* libheif is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* libheif is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with libheif. If not, see .
*/
#include
#include
#include "heif_hevc.h"
#include "bitstream.h"
using namespace heif;
static double read_depth_rep_info_element(BitReader& reader)
{
int sign_flag = reader.get_bits(1);
int exponent = reader.get_bits(7);
int mantissa_len = reader.get_bits(5)+1;
if (mantissa_len<1 || mantissa_len>32) {
// TODO err
}
if (exponent==127) {
// TODO value unspecified
}
int mantissa = reader.get_bits(mantissa_len);
double value;
//printf("sign:%d exponent:%d mantissa_len:%d mantissa:%d\n",sign_flag,exponent,mantissa_len,mantissa);
if (exponent > 0) {
value = pow(2, exponent-31) * (1.0 + mantissa / pow(2,mantissa_len));
}
else {
value = pow(2, -(30+mantissa_len)) * mantissa;
}
if (sign_flag) {
value = -value;
}
return value;
}
static std::shared_ptr read_depth_representation_info(BitReader& reader)
{
auto msg = std::make_shared();
// default values
msg->version = 1;
msg->disparity_reference_view = 0;
msg->depth_nonlinear_representation_model_size = 0;
msg->depth_nonlinear_representation_model = nullptr;
// read header
msg->has_z_near = (uint8_t)reader.get_bits(1);
msg->has_z_far = (uint8_t)reader.get_bits(1);
msg->has_d_min = (uint8_t)reader.get_bits(1);
msg->has_d_max = (uint8_t)reader.get_bits(1);
int rep_type;
if (!reader.get_uvlc(&rep_type)) {
// TODO error
}
// TODO: check rep_type range
msg->depth_representation_type = (enum heif_depth_representation_type)rep_type;
//printf("flags: %d %d %d %d\n",msg->has_z_near,msg->has_z_far,msg->has_d_min,msg->has_d_max);
//printf("type: %d\n",rep_type);
if (msg->has_d_min || msg->has_d_max) {
int ref_view;
if (!reader.get_uvlc(&ref_view)) {
// TODO error
}
msg->disparity_reference_view = ref_view;
//printf("ref_view: %d\n",msg->disparity_reference_view);
}
if (msg->has_z_near) msg->z_near = read_depth_rep_info_element(reader);
if (msg->has_z_far ) msg->z_far = read_depth_rep_info_element(reader);
if (msg->has_d_min ) msg->d_min = read_depth_rep_info_element(reader);
if (msg->has_d_max ) msg->d_max = read_depth_rep_info_element(reader);
/*
printf("z_near: %f\n",msg->z_near);
printf("z_far: %f\n",msg->z_far);
printf("dmin: %f\n",msg->d_min);
printf("dmax: %f\n",msg->d_max);
*/
if (msg->depth_representation_type == heif_depth_representation_type_nonuniform_disparity) {
// TODO: load non-uniform response curve
}
return msg;
}
// aux subtypes: 00 00 00 11 / 00 00 00 0d / 4e 01 / b1 09 / 35 1e 78 c8 01 03 c5 d0 20
Error heif::decode_hevc_aux_sei_messages(const std::vector& data,
std::vector>& msgs)
{
// TODO: we probably do not need a full BitReader just for the array size.
// Read this and the NAL size directly on the array data.
BitReader reader(data.data(), (int)data.size());
uint32_t len = (uint32_t)reader.get_bits(32);
if (len > data.size()-4) {
// ERROR: read past end of data
}
while (reader.get_current_byte_index() < (int)len) {
int currPos = reader.get_current_byte_index();
BitReader sei_reader(data.data() + currPos, (int)data.size()-currPos);
uint32_t nal_size = (uint32_t)sei_reader.get_bits(32);
(void)nal_size;
uint8_t nal_type = (uint8_t)(sei_reader.get_bits(8) >> 1);
sei_reader.skip_bits(8);
// SEI
if (nal_type == 39 ||
nal_type == 40) {
// TODO: loading of multi-byte sei headers
uint8_t payload_id = (uint8_t)(sei_reader.get_bits(8));
uint8_t payload_size = (uint8_t)(sei_reader.get_bits(8));
(void)payload_size;
switch (payload_id) {
case 177: // depth_representation_info
std::shared_ptr sei = read_depth_representation_info(sei_reader);
msgs.push_back(sei);
break;
}
}
break; // TODO: read next SEI
}
return Error::Ok;
}
static std::vector remove_start_code_emulation(const uint8_t* sps, size_t size)
{
std::vector out_data;
for (size_t i=0;i sps_no_emul = remove_start_code_emulation(sps, size);
sps = sps_no_emul.data();
size = sps_no_emul.size();
BitReader reader(sps, (int)size);
// skip NAL header
reader.skip_bits(2*8);
// skip VPS ID
reader.skip_bits(4);
int nMaxSubLayersMinus1 = reader.get_bits(3);
config->temporal_id_nested = (uint8_t)reader.get_bits(1);
// --- profile_tier_level ---
config->general_profile_space = (uint8_t)reader.get_bits(2);
config->general_tier_flag = (uint8_t)reader.get_bits(1);
config->general_profile_idc = (uint8_t)reader.get_bits(5);
config->general_profile_compatibility_flags = reader.get_bits(32);
reader.skip_bits(16); // skip reserved bits
reader.skip_bits(16); // skip reserved bits
reader.skip_bits(16); // skip reserved bits
config->general_level_idc = (uint8_t)reader.get_bits(8);
std::vector layer_profile_present(nMaxSubLayersMinus1);
std::vector layer_level_present(nMaxSubLayersMinus1);
for (int i=0 ; ichroma_format = (uint8_t)value;
if (config->chroma_format==3) {
reader.skip_bits(1);
}
reader.get_uvlc(width);
reader.get_uvlc(height);
bool conformance_window = reader.get_bits(1);
if (conformance_window) {
int left,right,top,bottom;
reader.get_uvlc(&left);
reader.get_uvlc(&right);
reader.get_uvlc(&top);
reader.get_uvlc(&bottom);
//printf("conformance borders: %d %d %d %d\n",left,right,top,bottom);
*width -= 2*(left+right);
*height -= 2*(top+bottom);
}
reader.get_uvlc(&value);
config->bit_depth_luma = (uint8_t)(value + 8);
reader.get_uvlc(&value);
config->bit_depth_chroma = (uint8_t)(value + 8);
// --- init static configuration fields ---
config->configuration_version = 1;
config->min_spatial_segmentation_idc = 0; // TODO: get this value from the VUI, 0 should be safe
config->parallelism_type = 0; // TODO, 0 should be safe
config->avg_frame_rate = 0; // makes no sense for HEIF
config->constant_frame_rate = 0; // makes no sense for HEIF
config->num_temporal_layers = 1; // makes no sense for HEIF
return Error::Ok;
}
libheif-1.1.0/src/encoder-fuzzer.cc 0000644 0002210 0000144 00000011553 13265401054 014065 0000000 0000000 /*
* HEIF codec.
* Copyright (c) 2018 struktur AG, Joachim Bauch
*
* This file is part of libheif.
*
* libheif is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* libheif is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with libheif. If not, see .
*/
#include
#include
#include
#include "heif.h"
static void generate_plane(int width, int height, uint8_t* output, int stride) {
// TODO(fancycode): Fill with random data.
if (width == stride) {
memset(output, 0, width * height);
} else {
for (int y = 0; y < height; y++) {
memset(output, 0, width);
output += stride;
}
}
}
static size_t create_image(const uint8_t* data, size_t size, struct heif_image** image) {
if (size < 2) {
return 0;
}
int width = data[0] + 16;
int height = data[1] + 16;
data += 2;
size -= 2;
// TODO(fancycode): Get colorspace/chroma from fuzzing input.
heif_colorspace colorspace = heif_colorspace_YCbCr;
heif_chroma chroma = heif_chroma_420;
struct heif_error err = heif_image_create(width, height, colorspace, chroma, image);
if (err.code != heif_error_Ok) {
return 0;
}
err = heif_image_add_plane(*image, heif_channel_Y, width, height, 8);
assert(err.code == heif_error_Ok);
err = heif_image_add_plane(*image, heif_channel_Cb, width / 2, height / 2, 8);
assert(err.code == heif_error_Ok);
err = heif_image_add_plane(*image, heif_channel_Cr, width / 2, height / 2, 8);
assert(err.code == heif_error_Ok);
int stride;
uint8_t* plane;
plane = heif_image_get_plane(*image, heif_channel_Y, &stride);
generate_plane(width, height, plane, stride);
plane = heif_image_get_plane(*image, heif_channel_Cb, &stride);
generate_plane(width / 2, height / 2, plane, stride);
plane = heif_image_get_plane(*image, heif_channel_Cr, &stride);
generate_plane(width / 2, height / 2, plane, stride);
return 2;
}
class MemoryWriter {
public:
MemoryWriter() : data_(nullptr), size_(0), capacity_(0) {}
~MemoryWriter() {
free(data_);
}
const uint8_t* data() const { return data_; }
size_t size() const { return size_; }
void write(const void* data, size_t size) {
if (capacity_ - size_ < size) {
size_t new_capacity = capacity_ + size;
uint8_t* new_data = static_cast(malloc(new_capacity));
assert(new_data);
if (data_) {
memcpy(new_data, data_, size_);
free(data_);
}
data_ = new_data;
capacity_ = new_capacity;
}
memcpy(&data_[size_], data, size);
size_ += size;
}
public:
uint8_t* data_;
size_t size_;
size_t capacity_;
};
static struct heif_error writer_write(struct heif_context* ctx, const void* data, size_t size, void* userdata) {
MemoryWriter* writer = static_cast(userdata);
writer->write(data, size);
struct heif_error err{heif_error_Ok, heif_suberror_Unspecified, nullptr};
return err;
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
struct heif_error err;
std::shared_ptr context(heif_context_alloc(),
[] (heif_context* c) { heif_context_free(c); });
assert(context);
static const size_t kMaxEncoders = 5;
const heif_encoder_descriptor* encoder_descriptors[kMaxEncoders];
int count = heif_context_get_encoder_descriptors(context.get(), heif_compression_HEVC, nullptr,
encoder_descriptors, kMaxEncoders);
assert(count > 0);
heif_encoder* encoder;
heif_context_get_encoder(context.get(), encoder_descriptors[0], &encoder);
if (size < 2) {
return 0;
}
int quality = data[0] % 101;;
int lossless = (data[1] > 0x80);
data += 2;
size -= 2;
heif_encoder_set_lossy_quality(encoder, quality);
heif_encoder_set_lossless(encoder, lossless);
struct heif_image* image;
size_t read = create_image(data, size, &image);
assert(read <= size);
if (!read) {
return 0;
}
data += read;
size -= read;
struct heif_image_handle* img;
err = heif_context_encode_image(context.get(), image, encoder, nullptr, &img);
heif_image_release(image);
if (err.code != heif_error_Ok) {
return 0;
}
heif_image_handle_release(img);
MemoryWriter writer;
struct heif_writer w;
w.writer_api_version = 1;
w.write = writer_write;
heif_context_write(context.get(), &w, &writer);
assert(writer.size() > 0);
return 0;
}
libheif-1.1.0/src/heif_plugin_registry.cc 0000644 0002210 0000144 00000005710 13265634335 015354 0000000 0000000 /*
* HEIF codec.
* Copyright (c) 2017 struktur AG, Dirk Farin
*
* This file is part of libheif.
*
* libheif is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* libheif is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with libheif. If not, see .
*/
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
#include
#include
#include "heif_plugin_registry.h"
using namespace heif;
std::set heif::s_decoder_plugins;
struct encoder_descriptor_priority_order
{
bool operator() (const std::unique_ptr& a,
const std::unique_ptr& b) {
return a->plugin->priority > b->plugin->priority; // highest priority first
}
};
std::set,
encoder_descriptor_priority_order> s_encoder_descriptors;
void heif::register_decoder(const heif_decoder_plugin* decoder_plugin)
{
if (decoder_plugin->init_plugin) {
(*decoder_plugin->init_plugin)();
}
s_decoder_plugins.insert(decoder_plugin);
}
void heif::register_encoder(const heif_encoder_plugin* encoder_plugin)
{
if (encoder_plugin->init_plugin) {
(*encoder_plugin->init_plugin)();
}
auto descriptor = std::unique_ptr(new heif_encoder_descriptor);
descriptor->plugin = encoder_plugin;
s_encoder_descriptors.insert(std::move(descriptor));
}
const struct heif_encoder_plugin* heif::get_encoder(enum heif_compression_format type)
{
auto filtered_encoder_descriptors = get_filtered_encoder_descriptors(type, nullptr);
if (filtered_encoder_descriptors.size()>0) {
return filtered_encoder_descriptors[0]->plugin;
}
else {
return nullptr;
}
}
std::vector
heif::get_filtered_encoder_descriptors(enum heif_compression_format format,
const char* name)
{
std::vector filtered_descriptors;
for (const auto& descr : s_encoder_descriptors) {
const struct heif_encoder_plugin* plugin = descr->plugin;
if (plugin->compression_format == format || format==heif_compression_undefined) {
if (name == nullptr || strcmp(name, plugin->id_name)==0) {
filtered_descriptors.push_back(descr.get());
}
}
}
// Note: since our std::set<> is ordered by priority, we do not have to sort our output
return filtered_descriptors;
}
libheif-1.1.0/src/heif-emscripten.h 0000644 0002210 0000144 00000036564 13263665765 014103 0000000 0000000 #ifndef LIBHEIF_BOX_EMSCRIPTEN_H
#define LIBHEIF_BOX_EMSCRIPTEN_H
#include
#include
#include
#include
#include
#include
#include "box.h"
#include "heif_file.h"
namespace heif {
static std::string dump_box_header(BoxHeader* header) {
if (!header) {
return "";
}
Indent indent;
return header->dump(indent);
}
static std::string dump_box(Box* box) {
if (!box) {
return "";
}
Indent indent;
return box->dump(indent);
}
static std::shared_ptr Box_read(BitstreamRange& range) {
std::shared_ptr box;
Error error = Box::read(range, &box);
if (error) {
return nullptr;
}
return box;
}
class EmscriptenBitstreamRange : public BitstreamRange {
public:
explicit EmscriptenBitstreamRange(const std::string& data)
: BitstreamRange(nullptr, 0),
data_(data),
stream_(std::move(data_)) {
construct(&stream_, data.size(), nullptr);
}
bool error() const {
return BitstreamRange::error();
}
private:
std::string data_;
std::basic_istringstream stream_;
};
static Error HeifFile_read_from_memory(HeifFile* file,
const std::string& data) {
if (!file) {
return Error(heif_error_Usage_error,
heif_suberror_Null_pointer_argument);
}
return file->read_from_memory(data.data(), data.size());
}
static emscripten::val HeifFile_get_compressed_image_data(HeifFile* file,
uint16_t ID, const std::string& data) {
emscripten::val result = emscripten::val::object();
if (!file) {
return result;
}
std::vector image_data;
Error err = file->get_compressed_image_data(ID, &image_data);
if (err) {
return emscripten::val(err);
}
result.set("type", file->get_item_type(ID));
result.set("data", std::string(reinterpret_cast(image_data.data()),
image_data.size()));
return result;
}
static std::string heif_get_version() {
return ::heif_get_version();
}
static struct heif_error _heif_context_read_from_memory(
struct heif_context* context, const std::string& data) {
return heif_context_read_from_memory(context, data.data(), data.size(), nullptr);
}
static void strided_copy(void* dest, const void* src, int width, int height,
int stride) {
if (width == stride) {
memcpy(dest, src, width * height);
} else {
const uint8_t* _src = static_cast(src);
uint8_t* _dest = static_cast(dest);
for (int y = 0; y < height; y++, _dest += width, _src += stride) {
memcpy(_dest, _src, stride);
}
}
}
static emscripten::val heif_js_context_get_image_handle(
struct heif_context* context, heif_item_id id) {
emscripten::val result = emscripten::val::object();
if (!context) {
return result;
}
struct heif_image_handle* handle;
struct heif_error err = heif_context_get_image_handle(context, id, &handle);
if (err.code != heif_error_Ok) {
return emscripten::val(err);
}
return emscripten::val(handle);
}
static emscripten::val heif_js_context_get_list_of_top_level_image_IDs(
struct heif_context* context) {
emscripten::val result = emscripten::val::array();
if (!context) {
return result;
}
int count = heif_context_get_number_of_top_level_images(context);
if (count <= 0) {
return result;
}
heif_item_id* ids = (heif_item_id*) malloc(count * sizeof(heif_item_id));
if (!ids) {
Error err = Error(heif_error_Memory_allocation_error,
heif_suberror_Security_limit_exceeded);
return emscripten::val(err);
}
int received = heif_context_get_list_of_top_level_image_IDs(context, ids, count);
if (!received) {
free(ids);
return result;
}
for (int i = 0; i < received; i++) {
result.set(i, ids[i]);
}
free(ids);
return result;
}
static emscripten::val heif_js_decode_image(struct heif_image_handle* handle,
enum heif_colorspace colorspace, enum heif_chroma chroma) {
emscripten::val result = emscripten::val::object();
if (!handle) {
return result;
}
struct heif_image* image;
struct heif_error err = heif_decode_image(handle, &image, colorspace, chroma, nullptr);
if (err.code != heif_error_Ok) {
return emscripten::val(err);
}
result.set("is_primary", heif_image_handle_is_primary_image(handle));
result.set("thumbnails", heif_image_handle_get_number_of_thumbnails(handle));
int width = heif_image_get_width(image, heif_channel_Y);
result.set("width", width);
int height = heif_image_get_height(image, heif_channel_Y);
result.set("height", height);
std::string data;
result.set("chroma", heif_image_get_chroma_format(image));
result.set("colorspace", heif_image_get_colorspace(image));
switch (heif_image_get_colorspace(image)) {
case heif_colorspace_YCbCr:
{
int stride_y;
const uint8_t* plane_y = heif_image_get_plane_readonly(image,
heif_channel_Y, &stride_y);
int stride_u;
const uint8_t* plane_u = heif_image_get_plane_readonly(image,
heif_channel_Cb, &stride_u);
int stride_v;
const uint8_t* plane_v = heif_image_get_plane_readonly(image,
heif_channel_Cr, &stride_v);
data.resize((width * height) + (width * height / 2));
char* dest = const_cast(data.data());
strided_copy(dest, plane_y, width, height, stride_y);
strided_copy(dest + (width * height), plane_u,
width / 2, height / 2, stride_u);
strided_copy(dest + (width * height) + (width * height / 4),
plane_v, width / 2, height / 2, stride_v);
}
break;
case heif_colorspace_RGB:
{
assert(heif_image_get_chroma_format(image) ==
heif_chroma_interleaved_24bit);
int stride_rgb;
const uint8_t* plane_rgb = heif_image_get_plane_readonly(image,
heif_channel_interleaved, &stride_rgb);
data.resize(width * height * 3);
char* dest = const_cast(data.data());
strided_copy(dest, plane_rgb, width * 3, height, stride_rgb);
}
break;
case heif_colorspace_monochrome:
{
assert(heif_image_get_chroma_format(image) ==
heif_chroma_monochrome);
int stride_grey;
const uint8_t* plane_grey = heif_image_get_plane_readonly(image,
heif_channel_Y, &stride_grey);
data.resize(width * height);
char* dest = const_cast(data.data());
strided_copy(dest, plane_grey, width, height, stride_grey);
}
break;
default:
// Should never reach here.
break;
}
result.set("data", std::move(data));
heif_image_release(image);
return result;
}
#define EXPORT_HEIF_FUNCTION(name) \
emscripten::function(#name, &name, emscripten::allow_raw_pointers())
EMSCRIPTEN_BINDINGS(libheif) {
EXPORT_HEIF_FUNCTION(heif_get_version);
EXPORT_HEIF_FUNCTION(heif_get_version_number);
EXPORT_HEIF_FUNCTION(heif_context_alloc);
EXPORT_HEIF_FUNCTION(heif_context_free);
emscripten::function("heif_context_read_from_memory",
&_heif_context_read_from_memory, emscripten::allow_raw_pointers());
EXPORT_HEIF_FUNCTION(heif_context_get_number_of_top_level_images);
emscripten::function("heif_js_context_get_list_of_top_level_image_IDs",
&heif_js_context_get_list_of_top_level_image_IDs, emscripten::allow_raw_pointers());
emscripten::function("heif_js_context_get_image_handle",
&heif_js_context_get_image_handle, emscripten::allow_raw_pointers());
emscripten::function("heif_js_decode_image",
&heif_js_decode_image, emscripten::allow_raw_pointers());
EXPORT_HEIF_FUNCTION(heif_image_handle_release);
emscripten::class_("Error")
.constructor<>()
.class_property("Ok", &Error::Ok)
.property("error_code", &Error::error_code)
.property("sub_error_code", &Error::sub_error_code)
;
emscripten::class_("BitstreamRangeBase")
;
emscripten::class_>("BitstreamRange")
.constructor()
.function("error", &EmscriptenBitstreamRange::error)
;
emscripten::class_("Indent")
.constructor<>()
.function("get_indent", &Indent::get_indent)
;
emscripten::class_("BoxHeader")
.function("get_box_size", &BoxHeader::get_box_size)
.function("get_header_size", &BoxHeader::get_header_size)
.function("get_short_type", &BoxHeader::get_short_type)
.function("get_type_string", &BoxHeader::get_type_string)
.function("dump", &dump_box_header, emscripten::allow_raw_pointers())
;
emscripten::class_>("Box")
.class_function("read", &Box_read, emscripten::allow_raw_pointers())
.function("get_child_box", &Box::get_child_box)
.function("dump", &dump_box, emscripten::allow_raw_pointers())
.smart_ptr>("Box")
;
emscripten::class_("HeifFile")
.constructor<>()
.function("read_from_memory", &HeifFile_read_from_memory,
emscripten::allow_raw_pointers())
.function("get_num_images", &HeifFile::get_num_images)
.function("get_primary_image_ID", &HeifFile::get_primary_image_ID)
.function("get_item_IDs", &HeifFile::get_item_IDs)
.function("get_compressed_image_data", &HeifFile_get_compressed_image_data,
emscripten::allow_raw_pointers())
;
emscripten::enum_("heif_error_code")
.value("heif_error_Ok", heif_error_Ok)
.value("heif_error_Input_does_not_exist", heif_error_Input_does_not_exist)
.value("heif_error_Invalid_input", heif_error_Invalid_input)
.value("heif_error_Unsupported_filetype", heif_error_Unsupported_filetype)
.value("heif_error_Unsupported_feature", heif_error_Unsupported_feature)
.value("heif_error_Usage_error", heif_error_Usage_error)
.value("heif_error_Memory_allocation_error", heif_error_Memory_allocation_error)
.value("heif_error_Decoder_plugin_error", heif_error_Decoder_plugin_error)
.value("heif_error_Encoder_plugin_error", heif_error_Encoder_plugin_error)
;
emscripten::enum_("heif_suberror_code")
.value("heif_suberror_Unspecified", heif_suberror_Unspecified)
.value("heif_suberror_End_of_data", heif_suberror_End_of_data)
.value("heif_suberror_Invalid_box_size", heif_suberror_Invalid_box_size)
.value("heif_suberror_No_ftyp_box", heif_suberror_No_ftyp_box)
.value("heif_suberror_No_idat_box", heif_suberror_No_idat_box)
.value("heif_suberror_No_meta_box", heif_suberror_No_meta_box)
.value("heif_suberror_No_hdlr_box", heif_suberror_No_hdlr_box)
.value("heif_suberror_No_hvcC_box", heif_suberror_No_hvcC_box)
.value("heif_suberror_No_pitm_box", heif_suberror_No_pitm_box)
.value("heif_suberror_No_ipco_box", heif_suberror_No_ipco_box)
.value("heif_suberror_No_ipma_box", heif_suberror_No_ipma_box)
.value("heif_suberror_No_iloc_box", heif_suberror_No_iloc_box)
.value("heif_suberror_No_iinf_box", heif_suberror_No_iinf_box)
.value("heif_suberror_No_iprp_box", heif_suberror_No_iprp_box)
.value("heif_suberror_No_iref_box", heif_suberror_No_iref_box)
.value("heif_suberror_No_pict_handler", heif_suberror_No_pict_handler)
.value("heif_suberror_Ipma_box_references_nonexisting_property",heif_suberror_Ipma_box_references_nonexisting_property)
.value("heif_suberror_No_properties_assigned_to_item",heif_suberror_No_properties_assigned_to_item)
.value("heif_suberror_No_item_data",heif_suberror_No_item_data)
.value("heif_suberror_Invalid_grid_data",heif_suberror_Invalid_grid_data)
.value("heif_suberror_Missing_grid_images",heif_suberror_Missing_grid_images)
.value("heif_suberror_Invalid_clean_aperture",heif_suberror_Invalid_clean_aperture)
.value("heif_suberror_Invalid_overlay_data",heif_suberror_Invalid_overlay_data)
.value("heif_suberror_Overlay_image_outside_of_canvas",heif_suberror_Overlay_image_outside_of_canvas)
.value("heif_suberror_Auxiliary_image_type_unspecified",heif_suberror_Auxiliary_image_type_unspecified)
.value("heif_suberror_No_or_invalid_primary_item",heif_suberror_No_or_invalid_primary_item)
.value("heif_suberror_No_infe_box",heif_suberror_No_infe_box)
.value("heif_suberror_Security_limit_exceeded",heif_suberror_Security_limit_exceeded)
.value("heif_suberror_Nonexisting_item_referenced",heif_suberror_Nonexisting_item_referenced)
.value("heif_suberror_Null_pointer_argument",heif_suberror_Null_pointer_argument)
.value("heif_suberror_Nonexisting_image_channel_referenced",heif_suberror_Nonexisting_image_channel_referenced)
.value("heif_suberror_Unsupported_plugin_version",heif_suberror_Unsupported_plugin_version)
.value("heif_suberror_Unsupported_writer_version",heif_suberror_Unsupported_writer_version)
.value("heif_suberror_Unsupported_parameter",heif_suberror_Unsupported_parameter)
.value("heif_suberror_Invalid_parameter_value",heif_suberror_Invalid_parameter_value)
.value("heif_suberror_Unsupported_codec",heif_suberror_Unsupported_codec)
.value("heif_suberror_Unsupported_image_type",heif_suberror_Unsupported_image_type)
.value("heif_suberror_Unsupported_data_version",heif_suberror_Unsupported_data_version)
.value("heif_suberror_Unsupported_color_conversion",heif_suberror_Unsupported_color_conversion)
.value("heif_suberror_Unsupported_item_construction_method",heif_suberror_Unsupported_item_construction_method)
;
emscripten::enum_("heif_compression_format")
.value("heif_compression_undefined", heif_compression_undefined)
.value("heif_compression_HEVC", heif_compression_HEVC)
.value("heif_compression_AVC", heif_compression_AVC)
.value("heif_compression_JPEG", heif_compression_JPEG)
;
emscripten::enum_("heif_chroma")
.value("heif_chroma_undefined", heif_chroma_undefined)
.value("heif_chroma_monochrome", heif_chroma_monochrome)
.value("heif_chroma_420", heif_chroma_420)
.value("heif_chroma_422", heif_chroma_422)
.value("heif_chroma_444", heif_chroma_444)
.value("heif_chroma_interleaved_RGB", heif_chroma_interleaved_RGB)
.value("heif_chroma_interleaved_RGBA", heif_chroma_interleaved_RGBA)
// Aliases
.value("heif_chroma_interleaved_24bit", heif_chroma_interleaved_24bit)
.value("heif_chroma_interleaved_32bit", heif_chroma_interleaved_32bit)
;
emscripten::enum_("heif_colorspace")
.value("heif_colorspace_undefined", heif_colorspace_undefined)
.value("heif_colorspace_YCbCr", heif_colorspace_YCbCr)
.value("heif_colorspace_RGB", heif_colorspace_RGB)
.value("heif_colorspace_monochrome", heif_colorspace_monochrome)
;
emscripten::enum_("heif_channel")
.value("heif_channel_Y", heif_channel_Y)
.value("heif_channel_Cr", heif_channel_Cr)
.value("heif_channel_Cb", heif_channel_Cb)
.value("heif_channel_R", heif_channel_R)
.value("heif_channel_G", heif_channel_G)
.value("heif_channel_B", heif_channel_B)
.value("heif_channel_Alpha", heif_channel_Alpha)
.value("heif_channel_interleaved", heif_channel_interleaved)
;
emscripten::register_vector("StringVector");
emscripten::register_vector("UInt32Vector");
emscripten::class_("heif_context");
emscripten::class_("heif_image_handle");
emscripten::class_("heif_image");
emscripten::value_object("heif_error")
.field("code", &heif_error::code)
.field("subcode", &heif_error::subcode)
;
}
} // namespace heif
#endif // LIBHEIF_BOX_EMSCRIPTEN_H
libheif-1.1.0/src/box.h 0000644 0002210 0000144 00000045171 13263665765 011603 0000000 0000000 /*
* HEIF codec.
* Copyright (c) 2017 struktur AG, Dirk Farin
*
* This file is part of libheif.
*
* libheif is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* libheif is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with libheif. If not, see .
*/
#ifndef LIBHEIF_BOX_H
#define LIBHEIF_BOX_H
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
#if defined(HAVE_INTTYPES_H)
#include
#endif
#if defined(HAVE_STDDEF_H)
#include
#endif
#include
#include
#include
#include
#include
#include
#include "error.h"
#include "heif.h"
#include "logging.h"
#include "bitstream.h"
#if !defined(__EMSCRIPTEN__) && !defined(_MSC_VER)
// std::array is not supported on some older compilers.
#define HAS_BOOL_ARRAY 1
#endif
namespace heif {
constexpr uint32_t fourcc(const char* string)
{
return ((string[0]<<24) |
(string[1]<<16) |
(string[2]<< 8) |
(string[3]));
}
class Fraction {
public:
Fraction() { }
Fraction(int num,int den) : numerator(num), denominator(den) { }
Fraction operator+(const Fraction&) const;
Fraction operator-(const Fraction&) const;
Fraction operator-(int) const;
Fraction operator/(int) const;
int round_down() const;
int round_up() const;
int round() const;
int numerator, denominator;
};
class BoxHeader {
public:
BoxHeader();
~BoxHeader() { }
constexpr static uint64_t size_until_end_of_file = 0;
uint64_t get_box_size() const { return m_size; }
uint32_t get_header_size() const { return m_header_size; }
uint32_t get_short_type() const { return m_type; }
std::vector get_type() const;
std::string get_type_string() const;
void set_short_type(uint32_t type) { m_type = type; }
Error parse(BitstreamRange& range);
virtual std::string dump(Indent&) const;
// --- full box
Error parse_full_box_header(BitstreamRange& range);
uint8_t get_version() const { return m_version; }
void set_version(uint8_t version) { m_version=version; }
uint32_t get_flags() const { return m_flags; }
void set_flags(uint32_t flags) { m_flags = flags; }
void set_is_full_box(bool flag=true) { m_is_full_box=flag; }
bool is_full_box_header() const { return m_is_full_box; }
// --- writing
size_t reserve_box_header_space(StreamWriter& writer) const;
Error prepend_header(StreamWriter&, size_t box_start) const;
private:
uint64_t m_size = 0;
uint32_t m_header_size = 0;
uint32_t m_type = 0;
std::vector m_uuid_type;
bool m_is_full_box = false;
uint8_t m_version = 0;
uint32_t m_flags = 0;
};
class Box : public BoxHeader {
public:
Box() { }
Box(const BoxHeader& hdr) : BoxHeader(hdr) { }
virtual ~Box() { }
static Error read(BitstreamRange& range, std::shared_ptr* box);
virtual Error write(StreamWriter& writer) const;
// check, which box version is required and set this in the (full) box header
virtual void derive_box_version() { set_version(0); }
void derive_box_version_recursive();
virtual std::string dump(Indent&) const;
std::shared_ptr get_child_box(uint32_t short_type) const;
std::vector> get_child_boxes(uint32_t short_type) const;
const std::vector>& get_all_child_boxes() const { return m_children; }
int append_child_box(std::shared_ptr box) {
m_children.push_back(box);
return (int)m_children.size()-1;
}
protected:
virtual Error parse(BitstreamRange& range);
std::vector> m_children;
const static int READ_CHILDREN_ALL = -1;
Error read_children(BitstreamRange& range, int number = READ_CHILDREN_ALL);
Error write_children(StreamWriter& writer) const;
std::string dump_children(Indent&) const;
};
class Box_ftyp : public Box {
public:
Box_ftyp() { set_short_type(fourcc("ftyp")); set_is_full_box(false); }
Box_ftyp(const BoxHeader& hdr) : Box(hdr) { }
std::string dump(Indent&) const override;
bool has_compatible_brand(uint32_t brand) const;
void set_major_brand(uint32_t major_brand) { m_major_brand=major_brand; }
void set_minor_version(uint32_t minor_version) { m_minor_version=minor_version; }
void clear_compatible_brands() { m_compatible_brands.clear(); }
void add_compatible_brand(uint32_t brand);
Error write(StreamWriter& writer) const override;
protected:
Error parse(BitstreamRange& range) override;
private:
uint32_t m_major_brand;
uint32_t m_minor_version;
std::vector m_compatible_brands;
};
class Box_meta : public Box {
public:
Box_meta() { set_short_type(fourcc("meta")); set_is_full_box(true); }
Box_meta(const BoxHeader& hdr) : Box(hdr) { }
std::string dump(Indent&) const override;
protected:
Error parse(BitstreamRange& range) override;
};
class Box_hdlr : public Box {
public:
Box_hdlr() { set_short_type(fourcc("hdlr")); set_is_full_box(true); }
Box_hdlr(const BoxHeader& hdr) : Box(hdr) { }
std::string dump(Indent&) const override;
uint32_t get_handler_type() const { return m_handler_type; }
void set_handler_type(uint32_t handler) { m_handler_type = handler; }
Error write(StreamWriter& writer) const override;
protected:
Error parse(BitstreamRange& range) override;
private:
uint32_t m_pre_defined = 0;
uint32_t m_handler_type = fourcc("pict");
uint32_t m_reserved[3];
std::string m_name;
};
class Box_pitm : public Box {
public:
Box_pitm() { set_short_type(fourcc("pitm")); set_is_full_box(true); }
Box_pitm(const BoxHeader& hdr) : Box(hdr) { }
std::string dump(Indent&) const override;
heif_item_id get_item_ID() const { return m_item_ID; }
void set_item_ID(heif_item_id id) { m_item_ID = id; }
void derive_box_version() override;
Error write(StreamWriter& writer) const override;
protected:
Error parse(BitstreamRange& range) override;
private:
heif_item_id m_item_ID;
};
class Box_iloc : public Box {
public:
Box_iloc() { set_short_type(fourcc("iloc")); set_is_full_box(true); }
Box_iloc(const BoxHeader& hdr) : Box(hdr) { }
std::string dump(Indent&) const override;
struct Extent {
uint64_t index = 0;
uint64_t offset = 0;
uint64_t length = 0;
std::vector data; // only used when writing data
};
struct Item {
heif_item_id item_ID;
uint8_t construction_method = 0; // >= version 1
uint16_t data_reference_index = 0;
uint64_t base_offset = 0;
std::vector extents;
};
const std::vector- & get_items() const { return m_items; }
Error read_data(const Item& item, std::istream& istr,
const std::shared_ptr&,
std::vector* dest) const;
void set_min_version(uint8_t min_version) { m_user_defined_min_version=min_version; }
// append bitstream data that will be written later (after iloc box)
Error append_data(heif_item_id item_ID,
const std::vector& data,
uint8_t construction_method=0);
// append bitstream data that already has been written (before iloc box)
// Error write_mdat_before_iloc(heif_image_id item_ID,
// std::vector& data)
// reserve data entry that will be written later
// Error reserve_mdat_item(heif_image_id item_ID,
// uint8_t construction_method,
// uint32_t* slot_ID);
// void patch_mdat_slot(uint32_t slot_ID, size_t start, size_t length);
void derive_box_version() override;
Error write(StreamWriter& writer) const override;
Error write_mdat_after_iloc(StreamWriter& writer);
protected:
Error parse(BitstreamRange& range) override;
private:
std::vector
- m_items;
mutable size_t m_iloc_box_start = 0;
uint8_t m_user_defined_min_version = 0;
uint8_t m_offset_size = 0;
uint8_t m_length_size = 0;
uint8_t m_base_offset_size = 0;
uint8_t m_index_size = 0;
void patch_iloc_header(StreamWriter& writer) const;
};
class Box_infe : public Box {
public:
Box_infe() { set_short_type(fourcc("infe")); set_is_full_box(true); }
Box_infe(const BoxHeader& hdr) : Box(hdr) { }
std::string dump(Indent&) const override;
bool is_hidden_item() const { return m_hidden_item; }
void set_hidden_item(bool hidden);
heif_item_id get_item_ID() const { return m_item_ID; }
void set_item_ID(heif_item_id id) { m_item_ID = id; }
std::string get_item_type() const { return m_item_type; }
void set_item_type(std::string type) { m_item_type = type; }
void set_item_name(std::string name) { m_item_name = name; }
void derive_box_version() override;
Error write(StreamWriter& writer) const override;
protected:
Error parse(BitstreamRange& range) override;
private:
heif_item_id m_item_ID;
uint16_t m_item_protection_index;
std::string m_item_type;
std::string m_item_name;
std::string m_content_type;
std::string m_content_encoding;
std::string m_item_uri_type;
// if set, this item should not be part of the presentation (i.e. hidden)
bool m_hidden_item = false;
};
class Box_iinf : public Box {
public:
Box_iinf() { set_short_type(fourcc("iinf")); set_is_full_box(true); }
Box_iinf(const BoxHeader& hdr) : Box(hdr) { }
std::string dump(Indent&) const override;
void derive_box_version() override;
Error write(StreamWriter& writer) const override;
protected:
Error parse(BitstreamRange& range) override;
private:
//std::vector< std::shared_ptr > m_iteminfos;
};
class Box_iprp : public Box {
public:
Box_iprp() { set_short_type(fourcc("iprp")); set_is_full_box(false); }
Box_iprp(const BoxHeader& hdr) : Box(hdr) { }
std::string dump(Indent&) const override;
protected:
Error parse(BitstreamRange& range) override;
};
class Box_ipco : public Box {
public:
Box_ipco() { set_short_type(fourcc("ipco")); set_is_full_box(false); }
Box_ipco(const BoxHeader& hdr) : Box(hdr) { }
struct Property {
bool essential;
std::shared_ptr property;
};
Error get_properties_for_item_ID(heif_item_id itemID,
const std::shared_ptr&,
std::vector& out_properties) const;
std::shared_ptr get_property_for_item_ID(heif_item_id itemID,
const std::shared_ptr&,
uint32_t property_box_type) const;
std::string dump(Indent&) const override;
protected:
Error parse(BitstreamRange& range) override;
};
class Box_ispe : public Box {
public:
Box_ispe() { set_short_type(fourcc("ispe")); set_is_full_box(true); }
Box_ispe(const BoxHeader& hdr) : Box(hdr) { }
uint32_t get_width() const { return m_image_width; }
uint32_t get_height() const { return m_image_height; }
void set_size(uint32_t width, uint32_t height) {
m_image_width = width;
m_image_height = height;
}
std::string dump(Indent&) const override;
Error write(StreamWriter& writer) const override;
protected:
Error parse(BitstreamRange& range) override;
private:
uint32_t m_image_width;
uint32_t m_image_height;
};
class Box_ipma : public Box {
public:
Box_ipma() { set_short_type(fourcc("ipma")); set_is_full_box(true); }
Box_ipma(const BoxHeader& hdr) : Box(hdr) { }
std::string dump(Indent&) const override;
struct PropertyAssociation {
bool essential;
uint16_t property_index;
};
const std::vector* get_properties_for_item_ID(heif_item_id itemID) const;
void add_property_for_item_ID(heif_item_id itemID,
PropertyAssociation assoc);
void derive_box_version() override;
Error write(StreamWriter& writer) const override;
protected:
Error parse(BitstreamRange& range) override;
struct Entry {
heif_item_id item_ID;
std::vector associations;
};
std::vector m_entries;
};
class Box_auxC : public Box {
public:
Box_auxC() { set_short_type(fourcc("auxC")); set_is_full_box(true); }
Box_auxC(const BoxHeader& hdr) : Box(hdr) { }
std::string get_aux_type() const { return m_aux_type; }
void set_aux_type(std::string type) { m_aux_type = type; }
std::vector get_subtypes() const { return m_aux_subtypes; }
std::string dump(Indent&) const override;
protected:
Error parse(BitstreamRange& range) override;
Error write(StreamWriter& writer) const override;
private:
std::string m_aux_type;
std::vector m_aux_subtypes;
};
class Box_irot : public Box {
public:
Box_irot(const BoxHeader& hdr) : Box(hdr) { }
std::string dump(Indent&) const override;
int get_rotation() const { return m_rotation; }
protected:
Error parse(BitstreamRange& range) override;
private:
int m_rotation; // in degrees (CCW)
};
class Box_imir : public Box {
public:
Box_imir(const BoxHeader& hdr) : Box(hdr) { }
enum class MirrorAxis : uint8_t {
Vertical = 0,
Horizontal = 1
};
MirrorAxis get_mirror_axis() const { return m_axis; }
std::string dump(Indent&) const override;
protected:
Error parse(BitstreamRange& range) override;
private:
MirrorAxis m_axis;
};
class Box_clap : public Box {
public:
Box_clap(const BoxHeader& hdr) : Box(hdr) { }
std::string dump(Indent&) const override;
int left_rounded(int image_width) const; // first column
int right_rounded(int image_width) const; // last column that is part of the cropped image
int top_rounded(int image_height) const; // first row
int bottom_rounded(int image_height) const; // last row included in the cropped image
int get_width_rounded() const;
int get_height_rounded() const;
protected:
Error parse(BitstreamRange& range) override;
private:
Fraction m_clean_aperture_width;
Fraction m_clean_aperture_height;
Fraction m_horizontal_offset;
Fraction m_vertical_offset;
};
class Box_iref : public Box {
public:
Box_iref() { set_short_type(fourcc("iref")); set_is_full_box(true); }
Box_iref(const BoxHeader& hdr) : Box(hdr) { }
std::string dump(Indent&) const override;
bool has_references(heif_item_id itemID) const;
uint32_t get_reference_type(heif_item_id itemID) const;
std::vector get_references(heif_item_id itemID) const;
void add_reference(heif_item_id from_id, uint32_t type, std::vector to_ids);
protected:
Error parse(BitstreamRange& range) override;
Error write(StreamWriter& writer) const override;
void derive_box_version() override;
private:
struct Reference {
BoxHeader header;
heif_item_id from_item_ID;
std::vector to_item_ID;
};
std::vector m_references;
};
class Box_hvcC : public Box {
public:
Box_hvcC() { set_short_type(fourcc("hvcC")); set_is_full_box(false); }
Box_hvcC(const BoxHeader& hdr) : Box(hdr) { }
struct configuration {
uint8_t configuration_version;
uint8_t general_profile_space;
bool general_tier_flag;
uint8_t general_profile_idc;
uint32_t general_profile_compatibility_flags;
static const int NUM_CONSTRAINT_INDICATOR_FLAGS = 48;
std::bitset general_constraint_indicator_flags;
uint8_t general_level_idc;
uint16_t min_spatial_segmentation_idc;
uint8_t parallelism_type;
uint8_t chroma_format;
uint8_t bit_depth_luma;
uint8_t bit_depth_chroma;
uint16_t avg_frame_rate;
uint8_t constant_frame_rate;
uint8_t num_temporal_layers;
uint8_t temporal_id_nested;
};
std::string dump(Indent&) const override;
bool get_headers(std::vector* dest) const;
void set_configuration(const configuration& config) { m_configuration=config; }
void append_nal_data(const std::vector& nal);
void append_nal_data(const uint8_t* data, size_t size);
Error write(StreamWriter& writer) const override;
protected:
Error parse(BitstreamRange& range) override;
private:
struct NalArray {
uint8_t m_array_completeness;
uint8_t m_NAL_unit_type;
std::vector< std::vector > m_nal_units;
};
configuration m_configuration;
uint8_t m_length_size = 4; // default: 4 bytes for NAL unit lengths
std::vector m_nal_array;
};
class Box_idat : public Box {
public:
Box_idat(const BoxHeader& hdr) : Box(hdr) { }
std::string dump(Indent&) const override;
Error read_data(std::istream& istr, uint64_t start, uint64_t length,
std::vector& out_data) const;
protected:
Error parse(BitstreamRange& range) override;
std::streampos m_data_start_pos;
};
class Box_grpl : public Box {
public:
Box_grpl(const BoxHeader& hdr) : Box(hdr) { }
std::string dump(Indent&) const override;
protected:
Error parse(BitstreamRange& range) override;
struct EntityGroup {
BoxHeader header;
uint32_t group_id;
std::vector entity_ids;
};
std::vector m_entity_groups;
};
class Box_dinf : public Box {
public:
Box_dinf(const BoxHeader& hdr) : Box(hdr) { }
std::string dump(Indent&) const override;
protected:
Error parse(BitstreamRange& range) override;
};
class Box_dref : public Box {
public:
Box_dref(const BoxHeader& hdr) : Box(hdr) { }
std::string dump(Indent&) const override;
protected:
Error parse(BitstreamRange& range) override;
};
class Box_url : public Box {
public:
Box_url(const BoxHeader& hdr) : Box(hdr) { }
std::string dump(Indent&) const override;
protected:
Error parse(BitstreamRange& range) override;
std::string m_location;
};
}
#endif
libheif-1.1.0/src/heif_decoder_libde265.h 0000644 0002210 0000144 00000001640 13223676463 014771 0000000 0000000 /*
* HEIF codec.
* Copyright (c) 2017 struktur AG, Dirk Farin
*
* This file is part of libheif.
*
* libheif is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* libheif is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with libheif. If not, see .
*/
#ifndef LIBHEIF_HEIF_DECODER_DE265_H
#define LIBHEIF_HEIF_DECODER_DE265_H
const struct heif_decoder_plugin* get_decoder_plugin_libde265();
#endif
libheif-1.1.0/src/error.cc 0000644 0002210 0000144 00000013476 13263665765 012305 0000000 0000000 /*
* HEIF codec.
* Copyright (c) 2017 struktur AG, Dirk Farin
*
* This file is part of libheif.
*
* libheif is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* libheif is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with libheif. If not, see .
*/
#include "error.h"
#include
// static
const char heif::Error::kSuccess[] = "Success";
const char* cUnknownError = "Unknown error";
heif::Error::Error()
: error_code(heif_error_Ok),
sub_error_code(heif_suberror_Unspecified)
{
}
heif::Error::Error(heif_error_code c,
heif_suberror_code sc,
std::string msg)
: error_code(c),
sub_error_code(sc),
message(msg)
{
}
const char* heif::Error::get_error_string(heif_error_code err)
{
switch (err) {
case heif_error_Ok: return "Success";
case heif_error_Input_does_not_exist: return "Input file does not exist";
case heif_error_Invalid_input: return "Invalid input";
case heif_error_Unsupported_filetype: return "Unsupported file-type";
case heif_error_Unsupported_feature: return "Unsupported feature";
case heif_error_Usage_error: return "Usage error";
case heif_error_Memory_allocation_error: return "Memory allocation error";
case heif_error_Decoder_plugin_error: return "Decoder plugin generated an error";
case heif_error_Encoder_plugin_error: return "Encoder plugin generated an error";
}
assert(false);
return "Unknown error";
}
const char* heif::Error::get_error_string(heif_suberror_code err)
{
switch (err) {
case heif_suberror_Unspecified: return "Unspecified";
// --- Invalid_input ---
case heif_suberror_End_of_data: return "Unexpected end of file";
case heif_suberror_Invalid_box_size: return "Invalid box size";
case heif_suberror_Invalid_grid_data: return "Invalid grid data";
case heif_suberror_Missing_grid_images: return "Missing grid images";
case heif_suberror_No_ftyp_box: return "No 'ftyp' box";
case heif_suberror_No_idat_box: return "No 'idat' box";
case heif_suberror_No_meta_box: return "No 'meta' box";
case heif_suberror_No_hdlr_box: return "No 'hdlr' box";
case heif_suberror_No_hvcC_box: return "No 'hvcC' box";
case heif_suberror_No_pitm_box: return "No 'pitm' box";
case heif_suberror_No_ipco_box: return "No 'ipco' box";
case heif_suberror_No_ipma_box: return "No 'ipma' box";
case heif_suberror_No_iloc_box: return "No 'iloc' box";
case heif_suberror_No_iinf_box: return "No 'iinf' box";
case heif_suberror_No_iprp_box: return "No 'iprp' box";
case heif_suberror_No_iref_box: return "No 'iref' box";
case heif_suberror_No_infe_box: return "No 'infe' box";
case heif_suberror_No_pict_handler: return "Not a 'pict' handler";
case heif_suberror_Ipma_box_references_nonexisting_property: return "'ipma' box references a non-existing property";
case heif_suberror_No_properties_assigned_to_item: return "No properties assigned to item";
case heif_suberror_No_item_data: return "Item has no data";
case heif_suberror_Invalid_clean_aperture: return "Invalid clean-aperture specification";
case heif_suberror_Invalid_overlay_data: return "Invalid overlay data";
case heif_suberror_Overlay_image_outside_of_canvas: return "Overlay image outside of canvas area";
case heif_suberror_Auxiliary_image_type_unspecified: return "Type of auxiliary image unspecified";
case heif_suberror_No_or_invalid_primary_item: return "No or invalid primary item";
// --- Memory_allocation_error ---
case heif_suberror_Security_limit_exceeded: return "Security limit exceeded";
// --- Usage_error ---
case heif_suberror_Nonexisting_item_referenced: return "Non-existing item ID referenced";
case heif_suberror_Null_pointer_argument: return "NULL argument received";
case heif_suberror_Nonexisting_image_channel_referenced: return "Non-existing image channel referenced";
case heif_suberror_Unsupported_plugin_version: return "The version of the passed plugin is not supported";
case heif_suberror_Unsupported_writer_version: return "The version of the passed writer is not supported";
case heif_suberror_Unsupported_parameter: return "Unsupported parameter";
case heif_suberror_Invalid_parameter_value: return "Invalid parameter value";
// --- Unsupported_feature ---
case heif_suberror_Unsupported_codec: return "Unsupported codec";
case heif_suberror_Unsupported_image_type: return "Unsupported image type";
case heif_suberror_Unsupported_data_version: return "Unsupported data version";
case heif_suberror_Unsupported_color_conversion: return "Unsupported color conversion";
case heif_suberror_Unsupported_item_construction_method: return "Unsupported item construction method";
// --- Encoder_plugin_error --
}
assert(false);
return cUnknownError;
}
heif_error heif::Error::error_struct(ErrorBuffer* error_buffer) const
{
if (error_buffer) {
if (error_code == heif_error_Ok) {
error_buffer->set_success();
}
else {
std::stringstream sstr;
sstr << get_error_string(error_code) << ": "
<< get_error_string(sub_error_code);
if (!message.empty()) {
sstr << ": " << message;
}
error_buffer->set_error(sstr.str());
}
}
heif_error err;
err.code = error_code;
err.subcode = sub_error_code;
if (error_buffer) {
err.message = error_buffer->get_error();
}
else {
err.message = cUnknownError;
}
return err;
}
libheif-1.1.0/src/heif_file.h 0000644 0002210 0000144 00000010303 13263665765 012712 0000000 0000000 /*
* HEIF codec.
* Copyright (c) 2017 struktur AG, Dirk Farin
*
* This file is part of libheif.
*
* libheif is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* libheif is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with libheif. If not, see .
*/
#ifndef LIBHEIF_HEIF_FILE_H
#define LIBHEIF_HEIF_FILE_H
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
#include "box.h"
#include