From 98a2db88c4f4d95728bc8af7494ccf5cd798edc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Novomesk=C3=BD?= <52529860+novomesk@users.noreply.github.com> Date: Fri, 26 Feb 2021 17:32:17 +0100 Subject: Add HEIF format to kimageformats project (#5261) --- projects/kimageformats/Dockerfile | 6 ++++-- projects/kimageformats/build.sh | 21 ++++++++++++++++++++- projects/kimageformats/kimgio_fuzzer.cc | 3 ++- 3 files changed, 26 insertions(+), 4 deletions(-) (limited to 'projects/kimageformats') diff --git a/projects/kimageformats/Dockerfile b/projects/kimageformats/Dockerfile index e3e04567c..4acc31c91 100644 --- a/projects/kimageformats/Dockerfile +++ b/projects/kimageformats/Dockerfile @@ -22,8 +22,10 @@ RUN git clone --depth 1 https://invent.kde.org/frameworks/extra-cmake-modules.gi RUN git clone --depth 1 --branch=5.15 git://code.qt.io/qt/qtbase.git RUN git clone --depth 1 https://invent.kde.org/frameworks/karchive.git RUN git clone --depth 1 https://invent.kde.org/frameworks/kimageformats.git -RUN git clone --depth 1 -b v2.0.1 https://aomedia.googlesource.com/aom -RUN git clone --depth 1 -b v0.8.4 https://github.com/AOMediaCodec/libavif.git +RUN git clone --depth 1 -b v2.0.2 https://aomedia.googlesource.com/aom +RUN git clone --depth 1 -b v0.9.0 https://github.com/AOMediaCodec/libavif.git +RUN git clone --depth 1 https://github.com/strukturag/libde265.git +RUN git clone --depth 1 https://github.com/strukturag/libheif.git COPY build.sh $SRC COPY kimgio_fuzzer.cc $SRC WORKDIR kimageformats diff --git a/projects/kimageformats/build.sh b/projects/kimageformats/build.sh index 3cec92133..0ffa60bbb 100644 --- a/projects/kimageformats/build.sh +++ b/projects/kimageformats/build.sh @@ -56,6 +56,7 @@ cd build.libavif extra_libaom_flags='-DAOM_MAX_ALLOCABLE_MEMORY=536870912 -DDO_RANGE_CHECK_CLAMP=1' cmake -DBUILD_SHARED_LIBS=0 -DENABLE_DOCS=0 -DENABLE_EXAMPLES=0 -DENABLE_TESTDATA=0 -DENABLE_TESTS=0 -DENABLE_TOOLS=0 -DCONFIG_PIC=1 -DAOM_TARGET_CPU=generic -DCONFIG_SIZE_LIMIT=1 -DDECODE_HEIGHT_LIMIT=12288 -DDECODE_WIDTH_LIMIT=12288 -DAOM_EXTRA_C_FLAGS="${extra_libaom_flags}" -DAOM_EXTRA_CXX_FLAGS="${extra_libaom_flags}" .. make -j$(nproc) +make install -j$(nproc) cd $SRC ln -s "$SRC/aom" "$SRC/libavif/ext/" @@ -65,10 +66,28 @@ cd build CFLAGS="$CFLAGS -fPIC" cmake -DBUILD_SHARED_LIBS=OFF -DAVIF_ENABLE_WERROR=OFF -DAVIF_CODEC_AOM=ON -DAVIF_LOCAL_AOM=ON .. make -j$(nproc) +cd $SRC +cd libde265 +cmake -DBUILD_SHARED_LIBS=OFF -DDISABLE_SSE=ON . +make -j$(nproc) +make install -j$(nproc) + +cd $SRC +cd libheif +#Reduce max width and height to avoid allocating too much memory +sed -i "s/static const int MAX_IMAGE_WIDTH = 32768;/static const int MAX_IMAGE_WIDTH = 8192;/g" libheif/heif_limits.h +sed -i "s/static const int MAX_IMAGE_HEIGHT = 32768;/static const int MAX_IMAGE_HEIGHT = 8192;/g" libheif/heif_limits.h +mkdir build +cd build +cmake -DBUILD_SHARED_LIBS=OFF -DWITH_AOM=ON -DWITH_DAV1D=OFF -DWITH_EXAMPLES=OFF -DWITH_LIBDE265=ON -DWITH_RAV1E=OFF -DWITH_X265=OFF .. +make -j$(nproc) +make install -j$(nproc) + cd $SRC cd kimageformats HANDLER_TYPES="ANIHandler ani QAVIFHandler avif + HEIFHandler heif KraHandler kra OraHandler ora PCXHandler pcx @@ -84,7 +103,7 @@ echo "$HANDLER_TYPES" | while read class format; do fuzz_target_name=kimgio_${format}_fuzzer $SRC/qtbase/bin/moc $SRC/kimageformats/src/imageformats/$format.cpp -o $format.moc - $CXX $CXXFLAGS -fPIC -DHANDLER=$class -std=c++14 $SRC/kimgio_fuzzer.cc $SRC/kimageformats/src/imageformats/$format.cpp -o $OUT/$fuzz_target_name -I $SRC/qtbase/include/QtCore/ -I $SRC/qtbase/include/ -I $SRC/qtbase/include//QtGui -I $SRC/kimageformats/src/imageformats/ -I $SRC/karchive/src/ -I $SRC/qtbase/mkspecs/linux-clang-libc++/ -I $SRC/libavif/include/ -I . -L $SRC/qtbase/lib $SRC/libavif/build/libavif.a $SRC/aom/build.libavif/libaom.a -lQt5Gui -lQt5Core -lqtlibpng -lqtharfbuzz -lm -lqtpcre2 -ldl -lpthread $LIB_FUZZING_ENGINE /usr/local/lib/libzip.a /usr/local/lib/libz.a -lKF5Archive /usr/local/lib/libz.a + $CXX $CXXFLAGS -fPIC -DHANDLER=$class -std=c++14 $SRC/kimgio_fuzzer.cc $SRC/kimageformats/src/imageformats/$format.cpp -o $OUT/$fuzz_target_name -I $SRC/qtbase/include/QtCore/ -I $SRC/qtbase/include/ -I $SRC/qtbase/include//QtGui -I $SRC/kimageformats/src/imageformats/ -I $SRC/karchive/src/ -I $SRC/qtbase/mkspecs/linux-clang-libc++/ -I $SRC/libavif/include/ -I . -L $SRC/qtbase/lib $SRC/libavif/build/libavif.a /usr/local/lib/libheif.a /usr/local/lib/liblibde265.a $SRC/aom/build.libavif/libaom.a -lQt5Gui -lQt5Core -lqtlibpng -lqtharfbuzz -lm -lqtpcre2 -ldl -lpthread $LIB_FUZZING_ENGINE /usr/local/lib/libzip.a /usr/local/lib/libz.a -lKF5Archive /usr/local/lib/libz.a find . -name "*.${format}" | zip -q $OUT/${fuzz_target_name}_seed_corpus.zip -@ ) diff --git a/projects/kimageformats/kimgio_fuzzer.cc b/projects/kimageformats/kimgio_fuzzer.cc index c37bb2216..5fe9cc6b5 100644 --- a/projects/kimageformats/kimgio_fuzzer.cc +++ b/projects/kimageformats/kimgio_fuzzer.cc @@ -20,7 +20,7 @@ Usage: python infra/helper.py build_image kimageformats python infra/helper.py build_fuzzers --sanitizer undefined|address|memory kimageformats - python infra/helper.py run_fuzzer kimageformats kimgio_[ani|avif|kra|ora|pcx|pic|psd|ras|rgb|tga|xcf]_fuzzer + python infra/helper.py run_fuzzer kimageformats kimgio_[ani|avif|heif|kra|ora|pcx|pic|psd|ras|rgb|tga|xcf]_fuzzer */ @@ -30,6 +30,7 @@ #include "ani_p.h" #include "avif_p.h" +#include "heif_p.h" #include "kra.h" #include "ora.h" #include "pcx_p.h" -- cgit v1.2.3