├── .clang-tidy ├── .github ├── FUNDING.yml ├── dependabot.yml └── workflows │ ├── build.yml │ ├── cifuzz.yml │ ├── clang.yml │ ├── coverity.yml │ ├── diagram.yml │ ├── emscripten.yml │ ├── fuzzer.yml │ ├── go.yml │ ├── lint.yml │ ├── mingw.yml │ ├── osx.yml │ └── test.yml ├── .gitignore ├── CMakeLists.txt ├── COPYING ├── CPPLINT.cfg ├── Makefile.am ├── README.md ├── appveyor.yml ├── autogen.sh ├── build-emscripten.sh ├── cmake └── modules │ ├── FindAOM.cmake │ ├── FindDAV1D.cmake │ ├── FindLIBDE265.cmake │ ├── FindRAV1E.cmake │ ├── FindSvtEnc.cmake │ ├── FindX265.cmake │ └── LibFindMacros.cmake ├── configure.ac ├── examples ├── CMakeLists.txt ├── COPYING ├── Makefile.am ├── benchmark.cc ├── benchmark.h ├── demo.html ├── encoder.cc ├── encoder.h ├── encoder_jpeg.cc ├── encoder_jpeg.h ├── encoder_png.cc ├── encoder_png.h ├── encoder_y4m.cc ├── encoder_y4m.h ├── example.avif ├── example.heic ├── heif-convert.1 ├── heif-enc.1 ├── heif-info.1 ├── heif-test.go ├── heif-thumbnailer.1 ├── heif_convert.cc ├── heif_enc.cc ├── heif_info.cc ├── heif_test.cc ├── heif_thumbnailer.cc └── test_c_api.c ├── extra ├── Makefile.am ├── getopt.c ├── getopt.h └── getopt_long.c ├── fuzzing ├── Makefile.am ├── corpus │ ├── clap-overflow-divide-zero.heic │ ├── clusterfuzz-testcase-minimized-color-conversion-fuzzer-6275694804467712 │ ├── clusterfuzz-testcase-minimized-file-fuzzer-4616081830051840.heic │ ├── clusterfuzz-testcase-minimized-file-fuzzer-5120279175102464.heic │ ├── clusterfuzz-testcase-minimized-file-fuzzer-5643900194127872.heic │ ├── clusterfuzz-testcase-minimized-file-fuzzer-5651556035198976.heic │ ├── clusterfuzz-testcase-minimized-file-fuzzer-5662360964956160.heic │ ├── clusterfuzz-testcase-minimized-file-fuzzer-5671864958976000.heic │ ├── clusterfuzz-testcase-minimized-file-fuzzer-5686319331672064.heic │ ├── clusterfuzz-testcase-minimized-file-fuzzer-5718632116518912.heic │ ├── clusterfuzz-testcase-minimized-file-fuzzer-5720856641142784.heic │ ├── clusterfuzz-testcase-minimized-file-fuzzer-5724458239655936.heic │ ├── clusterfuzz-testcase-minimized-file-fuzzer-5732616832024576.heic │ ├── clusterfuzz-testcase-minimized-file-fuzzer-5752063708495872.heic │ ├── clusterfuzz-testcase-minimized-file-fuzzer-5757633845264384.heic │ ├── clusterfuzz-testcase-minimized-file-fuzzer-6045213633282048.heic │ ├── colors-no-alpha-thumbnail.heic │ ├── colors-no-alpha.heic │ ├── colors-with-alpha-thumbnail.heic │ ├── colors-with-alpha.heic │ ├── github_138.heic │ ├── github_15.heic │ ├── github_20.heic │ ├── github_367_1.heic │ ├── github_367_2.heic │ ├── github_44.heic │ ├── github_45.heic │ ├── github_46_1.heic │ ├── github_46_2.heic │ ├── github_47.heic │ ├── github_48.heic │ ├── github_49.heic │ ├── github_50.heic │ ├── hbo_heif_context.h_126_1.heic │ └── uaf_heif_context.h_117_1.heic └── dictionary.txt ├── gdk-pixbuf ├── CMakeLists.txt ├── Makefile.am └── pixbufloader-heif.c ├── gnome ├── CMakeLists.txt ├── Makefile.am ├── avif.xml ├── heif.thumbnailer └── heif.xml ├── go ├── Makefile.am └── heif │ ├── heif.go │ └── heif_test.go ├── libheif.pc.in ├── libheif ├── CMakeLists.txt ├── Makefile.am ├── bitstream.cc ├── bitstream.h ├── box.cc ├── box.h ├── box_fuzzer.cc ├── color_conversion_fuzzer.cc ├── encoder_fuzzer.cc ├── error.cc ├── error.h ├── exif.cc ├── exif.h ├── file_fuzzer.cc ├── heif.cc ├── heif.h ├── heif_api_structs.h ├── heif_avif.cc ├── heif_avif.h ├── heif_colorconversion.cc ├── heif_colorconversion.h ├── heif_context.cc ├── heif_context.h ├── heif_cxx.h ├── heif_emscripten.h ├── heif_file.cc ├── heif_file.h ├── heif_hevc.cc ├── heif_hevc.h ├── heif_image.cc ├── heif_image.h ├── heif_init.cc ├── heif_init.h ├── heif_limits.h ├── heif_plugin.cc ├── heif_plugin.h ├── heif_plugin_registry.cc ├── heif_plugin_registry.h ├── heif_version.h.in ├── logging.h ├── metadata_compression.cc ├── metadata_compression.h ├── nclx.cc ├── nclx.h └── plugins │ ├── CMakeLists.txt │ ├── heif_decoder_aom.cc │ ├── heif_decoder_aom.h │ ├── heif_decoder_dav1d.cc │ ├── heif_decoder_dav1d.h │ ├── heif_decoder_libde265.cc │ ├── heif_decoder_libde265.h │ ├── heif_encoder_aom.cc │ ├── heif_encoder_aom.h │ ├── heif_encoder_rav1e.cc │ ├── heif_encoder_rav1e.h │ ├── heif_encoder_svt.cc │ ├── heif_encoder_svt.h │ ├── heif_encoder_x265.cc │ └── heif_encoder_x265.h ├── logos └── sponsors │ └── shopify.svg ├── m4 ├── ac_c_cxx_compile_flags.m4 ├── ax_cxx_compile_stdcxx_11.m4 └── visibility.m4 ├── post.js ├── pre.js ├── scripts ├── Makefile.am ├── check-emscripten-enums.sh ├── check-go-enums.sh ├── check-gofmt.sh ├── check-licenses.sh ├── configure-fuzzer.sh ├── cpplint.py ├── install-ci-linux.sh ├── install-ci-osx.sh ├── install-clang.sh ├── install-emscripten.sh ├── pre-commit.hook ├── prepare-ci.sh ├── run-ci.sh └── test-javascript.js ├── tests ├── Makefile.am ├── catch.hpp ├── conversion.cc ├── encode.cc ├── main.cc └── test-race.go └── third-party ├── aom.cmd ├── dav1d.cmd ├── rav1e.cmd └── svt.cmd /.clang-tidy: -------------------------------------------------------------------------------- 1 | --- 2 | Checks: > 3 | -clang-analyzer-security.insecureAPI.strcat, 4 | -clang-analyzer-security.insecureAPI.strcpy, 5 | modernize-shrink-to-fit, 6 | modernize-use-default-member-init, 7 | modernize-use-equals-default, 8 | modernize-use-equals-delete, 9 | modernize-use-override, 10 | performance-* 11 | HeaderFilterRegex: .* 12 | WarningsAsErrors: '*' 13 | ... 14 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [farindk] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | strategy: 12 | matrix: 13 | env: 14 | - { NAME: "nothing" } 15 | - { NAME: "cmake", WITH_GRAPHICS: 1, WITH_X265: 1, WITH_AOM: 1, WITH_DAV1D: 1, WITH_RAV1E: 1, WITH_LIBDE265: 1, CMAKE: 1 } 16 | - { NAME: "tarball", WITH_GRAPHICS: 1, WITH_X265: 1, WITH_AOM: 1, WITH_DAV1D: 1, WITH_RAV1E: 1, WITH_LIBDE265: 1, TARBALL: 1 } 17 | - { NAME: "graphics", WITH_GRAPHICS: 1 } 18 | - { NAME: "x265", WITH_X265: 1 } 19 | - { NAME: "x265 / graphics", WITH_GRAPHICS: 1, WITH_X265: 1 } 20 | - { NAME: "libde265 (1) / graphics", WITH_GRAPHICS: 1, WITH_LIBDE265: 1 } 21 | - { NAME: "libde265 (2) / graphics", WITH_GRAPHICS: 1, WITH_LIBDE265: 2 } 22 | - { NAME: "libde265 (1) / x265 / graphics", WITH_GRAPHICS: 1, WITH_X265: 1, WITH_LIBDE265: 1 } 23 | - { NAME: "libde265 (2) / x265 / graphics", WITH_GRAPHICS: 1, WITH_X265: 1, WITH_LIBDE265: 2 } 24 | - { NAME: "libde265 (1) / x265 / aom / graphics", WITH_GRAPHICS: 1, WITH_X265: 1, WITH_AOM: 1, WITH_LIBDE265: 1 } 25 | - { NAME: "libde265 (1) / x265 / dav1d / graphics", WITH_GRAPHICS: 1, WITH_X265: 1, WITH_DAV1D: 1, WITH_LIBDE265: 1 } 26 | - { NAME: "libde265 (1) / x265 / aom / rav1e / graphics", WITH_GRAPHICS: 1, WITH_X265: 1, WITH_AOM: 1, WITH_RAV1E: 1, WITH_LIBDE265: 1 } 27 | env: ${{ matrix.env }} 28 | runs-on: ubuntu-latest 29 | steps: 30 | - uses: actions/checkout@v3 31 | 32 | - name: Install dependencies 33 | run: | 34 | ./scripts/install-ci-linux.sh 35 | 36 | - name: Prepare CI 37 | run: | 38 | ./scripts/prepare-ci.sh 39 | 40 | - name: Run tests 41 | run: | 42 | ./scripts/run-ci.sh 43 | -------------------------------------------------------------------------------- /.github/workflows/cifuzz.yml: -------------------------------------------------------------------------------- 1 | name: CIFuzz 2 | on: [pull_request] 3 | jobs: 4 | Fuzzing: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - name: Build Fuzzers 8 | id: build 9 | uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master 10 | with: 11 | oss-fuzz-project-name: 'libheif' 12 | dry-run: false 13 | - name: Run Fuzzers 14 | uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master 15 | with: 16 | oss-fuzz-project-name: 'libheif' 17 | fuzz-seconds: 600 18 | dry-run: false 19 | - name: Upload Crash 20 | uses: actions/upload-artifact@v3 21 | if: failure() && steps.build.outcome == 'success' 22 | with: 23 | name: artifacts 24 | path: ./out/artifacts 25 | -------------------------------------------------------------------------------- /.github/workflows/clang.yml: -------------------------------------------------------------------------------- 1 | name: clang 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | strategy: 12 | matrix: 13 | env: 14 | - { NAME: "nothing" } 15 | - { NAME: "libde265 (1) / x265 / aom / graphics", WITH_GRAPHICS: 1, WITH_X265: 1, WITH_AOM: 1, WITH_LIBDE265: 1 } 16 | - { NAME: "libde265 (2) / x265 / aom / graphics", WITH_GRAPHICS: 1, WITH_X265: 1, WITH_AOM: 1, WITH_LIBDE265: 2 } 17 | env: ${{ matrix.env }} 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: actions/checkout@v3 21 | 22 | - name: Install dependencies 23 | run: | 24 | ./scripts/install-ci-linux.sh 25 | sudo apt install clang 26 | 27 | - name: Prepare CI 28 | env: 29 | CC: clang 30 | CXX: clang++ 31 | run: | 32 | ./scripts/prepare-ci.sh 33 | 34 | - name: Run tests 35 | env: 36 | CC: clang 37 | CXX: clang++ 38 | run: | 39 | ./scripts/run-ci.sh 40 | 41 | tidy: 42 | env: 43 | WITH_GRAPHICS: 1 44 | WITH_X265: 1 45 | WITH_AOM: 1 46 | WITH_DAV1D: 1 47 | WITH_RAV1E: 1 48 | WITH_LIBDE265: 1 49 | CMAKE: 1 50 | CLANG_TIDY: 1 51 | runs-on: ubuntu-20.04 52 | steps: 53 | - uses: actions/checkout@v3 54 | 55 | - name: Install dependencies 56 | run: | 57 | ./scripts/install-ci-linux.sh 58 | sudo apt install clang-tidy-12 59 | 60 | - name: Prepare CI 61 | run: | 62 | ./scripts/prepare-ci.sh 63 | 64 | - name: Run tests 65 | run: | 66 | ./scripts/run-ci.sh 67 | 68 | - name: Run clang-tidy 69 | run: | 70 | run-clang-tidy-12 -checks=-clang-diagnostic-tautological-compare,-clang-diagnostic-tautological-constant-out-of-range-compare -j$(nproc) 71 | -------------------------------------------------------------------------------- /.github/workflows/coverity.yml: -------------------------------------------------------------------------------- 1 | name: coverity 2 | 3 | on: 4 | push: 5 | branches: [ coverity ] 6 | 7 | jobs: 8 | scan: 9 | runs-on: ubuntu-latest 10 | env: 11 | TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} 12 | WITH_AOM: 1 13 | WITH_GRAPHICS: 1 14 | WITH_LIBDE265: 1 15 | WITH_X265: 1 16 | steps: 17 | - uses: actions/checkout@v3 18 | 19 | - name: Cache Coverity build tool 20 | uses: actions/cache@v3 21 | with: 22 | path: | 23 | coverity_tool.tar.gz 24 | key: ${{ runner.os }} 25 | 26 | - name: Download Coverity build tool 27 | run: | 28 | wget -c -N https://scan.coverity.com/download/linux64 --post-data "token=$TOKEN&project=strukturag%2Flibheif" -O coverity_tool.tar.gz 29 | mkdir coverity_tool 30 | tar xzf coverity_tool.tar.gz --strip 1 -C coverity_tool 31 | 32 | - name: Install dependencies 33 | run: | 34 | ./scripts/install-ci-linux.sh 35 | 36 | - name: Prepare CI 37 | run: | 38 | ./scripts/prepare-ci.sh 39 | 40 | - name: Build with Coverity build tool 41 | run: | 42 | export PATH=`pwd`/coverity_tool/bin:$PATH 43 | cov-build --dir cov-int make 44 | 45 | - name: Submit build result to Coverity Scan 46 | run: | 47 | tar czvf libheif.tar.gz cov-int 48 | curl --form token=$TOKEN \ 49 | --form email=opensource@struktur.de \ 50 | --form file=@libheif.tar.gz \ 51 | --form version="Commit $GITHUB_SHA" \ 52 | --form description="Build submitted via CI" \ 53 | https://scan.coverity.com/builds?project=strukturag%2Flibheif 54 | -------------------------------------------------------------------------------- /.github/workflows/diagram.yml: -------------------------------------------------------------------------------- 1 | name: Create diagram 2 | on: 3 | workflow_dispatch: {} 4 | push: 5 | branches: 6 | - main 7 | jobs: 8 | get_data: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Checkout code 12 | uses: actions/checkout@v3 13 | - name: Update diagram 14 | uses: githubocto/repo-visualizer@main 15 | with: 16 | excluded_paths: "ignore,.github" 17 | -------------------------------------------------------------------------------- /.github/workflows/emscripten.yml: -------------------------------------------------------------------------------- 1 | name: emscripten 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | emscripten: 11 | env: 12 | EMSCRIPTEN_VERSION: 1.37.26 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v3 16 | 17 | - name: Install emscripten 18 | run: | 19 | ./scripts/install-ci-linux.sh 20 | 21 | - name: Prepare CI 22 | run: | 23 | ./scripts/prepare-ci.sh 24 | 25 | - name: Run tests 26 | run: | 27 | ./scripts/run-ci.sh 28 | -------------------------------------------------------------------------------- /.github/workflows/fuzzer.yml: -------------------------------------------------------------------------------- 1 | name: fuzzer 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | fuzzer: 11 | env: 12 | WITH_AOM: 1 13 | WITH_GRAPHICS: 1 14 | WITH_LIBDE265: 2 15 | WITH_X265: 1 16 | FUZZER: 1 17 | runs-on: ubuntu-18.04 18 | steps: 19 | - uses: actions/checkout@v3 20 | 21 | - name: Install dependencies 22 | run: | 23 | ./scripts/install-ci-linux.sh 24 | 25 | - name: Prepare CI 26 | run: | 27 | ./scripts/prepare-ci.sh 28 | 29 | - name: Run tests 30 | run: | 31 | ./scripts/run-ci.sh 32 | -------------------------------------------------------------------------------- /.github/workflows/go.yml: -------------------------------------------------------------------------------- 1 | name: go 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | libde265: 11 | strategy: 12 | matrix: 13 | libde265-version: 14 | - "1" 15 | - "2" 16 | env: 17 | WITH_LIBDE265: ${{ matrix.libde265-version }} 18 | WITH_X265: 1 19 | WITH_GRAPHICS: 1 20 | GO: 1 21 | runs-on: ubuntu-latest 22 | steps: 23 | - uses: actions/checkout@v3 24 | 25 | - uses: actions/setup-go@v3 26 | with: 27 | go-version: "1.10" 28 | 29 | - name: Install dependencies 30 | run: | 31 | ./scripts/install-ci-linux.sh 32 | 33 | - name: Prepare CI 34 | run: | 35 | ./scripts/prepare-ci.sh 36 | 37 | - name: Run tests 38 | run: | 39 | ./scripts/run-ci.sh 40 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: lint 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | cpplint: 11 | env: 12 | CPPLINT: 1 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v3 16 | 17 | - name: Install dependencies 18 | run: | 19 | ./scripts/install-ci-linux.sh 20 | 21 | - name: Prepare CI 22 | run: | 23 | ./scripts/prepare-ci.sh 24 | 25 | - name: Check format 26 | run: | 27 | ./scripts/run-ci.sh 28 | 29 | licenses: 30 | env: 31 | CHECK_LICENSES: 1 32 | runs-on: ubuntu-latest 33 | steps: 34 | - uses: actions/checkout@v3 35 | 36 | - name: Install dependencies 37 | run: | 38 | ./scripts/install-ci-linux.sh 39 | 40 | - name: Prepare CI 41 | run: | 42 | ./scripts/prepare-ci.sh 43 | 44 | - name: Check licenses 45 | run: | 46 | ./scripts/run-ci.sh 47 | -------------------------------------------------------------------------------- /.github/workflows/mingw.yml: -------------------------------------------------------------------------------- 1 | name: mingw 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | mingw: 11 | strategy: 12 | matrix: 13 | env: 14 | - { MINGW: 32 } 15 | - { MINGW: 64 } 16 | env: ${{ matrix.env }} 17 | runs-on: ubuntu-20.04 18 | steps: 19 | - uses: actions/checkout@v3 20 | 21 | - name: Install dependencies 22 | run: | 23 | ./scripts/install-ci-linux.sh 24 | 25 | - name: Prepare CI 26 | run: | 27 | ./scripts/prepare-ci.sh 28 | 29 | - name: Run tests 30 | run: | 31 | ./scripts/run-ci.sh 32 | -------------------------------------------------------------------------------- /.github/workflows/osx.yml: -------------------------------------------------------------------------------- 1 | name: osx 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | strategy: 12 | matrix: 13 | env: 14 | - { NAME: "nothing" } 15 | - { NAME: "cmake", WITH_GRAPHICS: 1, WITH_X265: 1, WITH_AOM: 1, WITH_LIBDE265: 1, CMAKE: 1 } 16 | - { NAME: "libde265 (1) / x265 / graphics", WITH_GRAPHICS: 1, WITH_X265: 1, WITH_LIBDE265: 1 } 17 | - { NAME: "libde265 (2) / x265 / graphics", WITH_GRAPHICS: 1, WITH_X265: 1, WITH_LIBDE265: 2 } 18 | env: ${{ matrix.env }} 19 | runs-on: macos-10.15 20 | steps: 21 | - uses: actions/checkout@v3 22 | 23 | - name: Install dependencies 24 | run: | 25 | ./scripts/install-ci-osx.sh 26 | 27 | - name: Prepare CI 28 | run: | 29 | ./scripts/prepare-ci.sh 30 | 31 | - name: Run tests 32 | run: | 33 | ./scripts/run-ci.sh 34 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | test: 11 | env: 12 | TESTS: 1 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v3 16 | 17 | - name: Install dependencies 18 | run: | 19 | ./scripts/install-ci-linux.sh 20 | 21 | - name: Prepare CI 22 | run: | 23 | ./scripts/prepare-ci.sh 24 | 25 | - name: Run tests 26 | run: | 27 | ./scripts/run-ci.sh 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.la 2 | *.lo 3 | *.o 4 | *.pc 5 | m4/lt*.m4 6 | libheif/*.a 7 | 8 | .deps 9 | .libs 10 | aclocal.m4 11 | autom4te.cache/ 12 | compile 13 | config.* 14 | configure 15 | depcomp 16 | examples/heif-convert 17 | examples/heif-enc 18 | examples/heif-info 19 | examples/heif-test 20 | examples/heif-test-go 21 | examples/heif-thumbnailer 22 | examples/src 23 | examples/test-c-api 24 | go/go 25 | go/src 26 | install-sh 27 | libtool 28 | libheif.js 29 | libheif.js.map 30 | libheif.min.js 31 | ltmain.sh 32 | Makefile 33 | Makefile.in 34 | m4/libtool.m4 35 | missing 36 | out.bin 37 | libheif/*-fuzzer 38 | libheif/heif_version.h 39 | stamp-h1 40 | tests/test-race 41 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.0) 2 | 3 | project(libheif LANGUAGES C CXX VERSION 1.14.0.0) 4 | 5 | # https://cmake.org/cmake/help/v3.1/policy/CMP0054.html 6 | cmake_policy(VERSION 3.0...3.22) 7 | include(GNUInstallDirs) 8 | 9 | # The version number. 10 | set (PACKAGE_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) 11 | 12 | # Check for unistd.h 13 | 14 | include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake) 15 | 16 | CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H) 17 | 18 | if (HAVE_UNISTD_H) 19 | add_definitions(-DHAVE_UNISTD_H) 20 | endif() 21 | 22 | 23 | if(NOT MSVC) 24 | add_definitions(-Wall) 25 | add_definitions(-Werror) 26 | add_definitions(-Wsign-compare) 27 | add_definitions(-Wconversion) 28 | add_definitions(-Wno-sign-conversion) 29 | add_definitions(-Wno-error=conversion) 30 | add_definitions(-Wno-error=unused-parameter) 31 | add_definitions(-Wno-error=deprecated-declarations) 32 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") 33 | add_definitions(-Wno-error=tautological-compare) 34 | add_definitions(-Wno-error=tautological-constant-out-of-range-compare) 35 | endif () 36 | endif() 37 | 38 | set(CMAKE_CXX_STANDARD 11) 39 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 40 | set(CMAKE_CXX_EXTENSIONS OFF) 41 | 42 | set(CMAKE_CXX_VISIBILITY_PRESET hidden) 43 | set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) 44 | 45 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) 46 | 47 | # Create the compile command database for clang by default 48 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) 49 | 50 | option(BUILD_SHARED_LIBS "Build shared libraries" ON) 51 | 52 | include(CheckCXXCompilerFlag) 53 | CHECK_CXX_COMPILER_FLAG(-Wno-error=potentially-evaluated-expression has_potentially_evaluated_expression) 54 | if (has_potentially_evaluated_expression) 55 | add_definitions(-Wno-error=potentially-evaluated-expression) 56 | endif() 57 | 58 | LIST (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules") 59 | 60 | option(ENABLE_PLUGIN_LOADING "Support loading of plugins" ON) 61 | set(PLUGIN_DIRECTORY "/usr/local/lib/libheif" CACHE STRING "Plugin install directory") 62 | 63 | macro(plugin_option variableName packageName displayName displayType defaultPlugin) 64 | option(WITH_${variableName} "Build ${displayName} ${displayType}" ON) 65 | option(WITH_${variableName}_PLUGIN "Build ${displayName} as a plugin" ${defaultPlugin}) 66 | if (WITH_${variableName}) 67 | find_package(${packageName}) 68 | endif () 69 | 70 | if (${variableName}_FOUND AND WITH_${variableName}_PLUGIN) 71 | set(msg "found (plugin)") 72 | elseif (${variableName}_FOUND) 73 | set(msg "found (built-in)") 74 | elseif (WITH_${variableName}) 75 | set(msg "not found") 76 | else() 77 | set(msg "disabled") 78 | endif () 79 | 80 | message("${displayName} (${displayType}): ${msg}") 81 | unset(msg) 82 | endmacro() 83 | 84 | plugin_option(LIBDE265 LIBDE265 "libde265" "HEIC decoder" OFF) 85 | plugin_option(X265 X265 "x265" "HEIC encoder" OFF) 86 | plugin_option(DAV1D DAV1D "Dav1d" "AVIF decoder" OFF) 87 | plugin_option(AOM_ENCODER AOM "aom" "AVIF encoder" OFF) 88 | plugin_option(AOM_DECODER AOM "aom" "AVIF decoder" OFF) 89 | plugin_option(SvtEnc SvtEnc "Svt-av1" "AVIF encoder" ON) 90 | plugin_option(RAV1E RAV1E "Rav1e" "AVIF encoder" ON) 91 | 92 | 93 | # --- Create libheif pkgconfig file 94 | 95 | set(prefix ${CMAKE_INSTALL_PREFIX}) 96 | set(exec_prefix ${CMAKE_INSTALL_PREFIX}) 97 | set(libdir ${CMAKE_INSTALL_FULL_LIBDIR}) 98 | set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}) 99 | if (LIBDE265_FOUND) 100 | list(APPEND REQUIRES_PRIVATE "libde265") 101 | set(have_libde265 yes) 102 | else() 103 | set(have_libde265 no) 104 | endif() 105 | if (X265_FOUND) 106 | list(APPEND REQUIRES_PRIVATE "x265") 107 | set(have_x265 yes) 108 | else() 109 | set(have_x265 no) 110 | endif() 111 | if (AOM_DECODER_FOUND OR AOM_ENCODER_FOUND) 112 | list(APPEND REQUIRES_PRIVATE "aom") 113 | endif() 114 | if (DAV1D_FOUND) 115 | list(APPEND REQUIRES_PRIVATE "dav1d") 116 | endif() 117 | if (RAV1E_FOUND) 118 | list(APPEND REQUIRES_PRIVATE "rav1e") 119 | endif() 120 | if (SvtEnc_FOUND) 121 | list(APPEND REQUIRES_PRIVATE "SvtEnc") 122 | endif() 123 | if (AOM_DECODER_FOUND OR DAV1D_FOUND) 124 | set(have_avif_decoder yes) 125 | else() 126 | set(have_avif_decoder no) 127 | endif() 128 | if (AOM_ENCODER_FOUND OR RAV1E_FOUND) 129 | set(have_avif_encoder yes) 130 | else() 131 | set(have_avif_encoder no) 132 | endif() 133 | list(JOIN REQUIRES_PRIVATE " " REQUIRES_PRIVATE) 134 | set(VERSION ${PROJECT_VERSION}) 135 | 136 | configure_file(libheif.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libheif.pc @ONLY) 137 | 138 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libheif.pc 139 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) 140 | 141 | # --- 142 | 143 | option(WITH_EXAMPLES "Build examples" ON) 144 | 145 | option(WITH_DEFLATE_HEADER_COMPRESSION OFF) 146 | 147 | if(WITH_EXAMPLES) 148 | add_subdirectory (examples) 149 | endif() 150 | add_subdirectory (libheif) 151 | add_subdirectory (gdk-pixbuf) 152 | add_subdirectory (gnome) 153 | 154 | 155 | # --- packaging (source code) 156 | 157 | set(CPACK_VERBATIM_VARIABLES YES) 158 | set(CPACK_SOURCE_IGNORE_FILES 159 | /.git/ 160 | /.github/ 161 | /.gitignore$ 162 | /build/ 163 | /cmake-build.*/ 164 | /.deps/ 165 | /.idea/ 166 | /.clang-tidy 167 | ~$ 168 | /third-party/.*/ # only exclude the sub-directories, but keep the *.cmd files 169 | /Testing/ 170 | /logos/ 171 | /Makefile$ 172 | /libtool$ 173 | /libheif.pc$ 174 | /config.h$ 175 | stamp-h1$ 176 | ) 177 | include(CPack) 178 | -------------------------------------------------------------------------------- /CPPLINT.cfg: -------------------------------------------------------------------------------- 1 | set noparent 2 | filter=-,+build/include_what_you_use 3 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ACLOCAL_AMFLAGS = -I m4 2 | 3 | SUBDIRS = \ 4 | libheif \ 5 | examples \ 6 | extra \ 7 | fuzzing \ 8 | gdk-pixbuf \ 9 | gnome \ 10 | go \ 11 | scripts \ 12 | tests 13 | 14 | pkgconfigdir = $(libdir)/pkgconfig 15 | pkgconfig_DATA = libheif.pc 16 | 17 | EXTRA_DIST = \ 18 | .github/workflows/*.yml \ 19 | appveyor.yml \ 20 | autogen.sh \ 21 | CMakeLists.txt \ 22 | CPPLINT.cfg \ 23 | README.md \ 24 | pre.js \ 25 | post.js \ 26 | build-emscripten.sh \ 27 | cmake/modules/*.cmake 28 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # stats available at 2 | # https://ci.appveyor.com/project/strukturag/libheif 3 | image: Visual Studio 2019 4 | configuration: Release 5 | cache: c:\tools\vcpkg\installed\ 6 | 7 | matrix: 8 | allow_failures: 9 | - arch: arm64 # libde265 currently doesn't support arm64 on vcpkg 10 | 11 | environment: 12 | matrix: 13 | - arch: x64 14 | - arch: arm64 15 | 16 | install: 17 | - vcpkg install libde265:%arch%-windows 18 | - vcpkg install x265:%arch%-windows 19 | - vcpkg install dav1d:%arch%-windows 20 | - cd c:\tools\vcpkg 21 | - vcpkg integrate install 22 | - cd %APPVEYOR_BUILD_FOLDER% 23 | 24 | before_build: 25 | - mkdir build 26 | - cd build 27 | - cmake .. -A %arch% -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake 28 | 29 | build: 30 | verbosity: normal 31 | 32 | artifacts: 33 | - path: build 34 | - path: build\**\Release\*.exe 35 | - path: build\**\Release\*.dll 36 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eu 3 | # 4 | # HEIF codec. 5 | # Copyright (c) 2017 struktur AG, Joachim Bauch 6 | # 7 | # This file is part of libheif. 8 | # 9 | # libheif is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # libheif is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with libheif. If not, see . 21 | # 22 | ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 23 | 24 | if [ -d "$ROOT/.git/hooks" ]; then 25 | echo "Installing pre-commit hook ..." 26 | ln -sf "$ROOT/scripts/pre-commit.hook" "$ROOT/.git/hooks/pre-commit" 27 | fi 28 | 29 | if [ -x "`which autoreconf 2>/dev/null`" ] ; then 30 | exec autoreconf -ivf 31 | fi 32 | 33 | LIBTOOLIZE=libtoolize 34 | SYSNAME=`uname` 35 | if [ "x$SYSNAME" = "xDarwin" ] ; then 36 | LIBTOOLIZE=glibtoolize 37 | fi 38 | aclocal -I m4 && \ 39 | autoheader && \ 40 | $LIBTOOLIZE && \ 41 | autoconf && \ 42 | automake --add-missing --force-missing --copy 43 | -------------------------------------------------------------------------------- /build-emscripten.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 | 5 | CORES=$(nproc --all) 6 | echo "Build using ${CORES} CPU cores" 7 | 8 | LIBDE265_VERSION=1.0.8 9 | [ -s "libde265-${LIBDE265_VERSION}.tar.gz" ] || curl \ 10 | -L \ 11 | -o libde265-${LIBDE265_VERSION}.tar.gz \ 12 | https://github.com/strukturag/libde265/releases/download/v${LIBDE265_VERSION}/libde265-${LIBDE265_VERSION}.tar.gz 13 | if [ ! -s "libde265-${LIBDE265_VERSION}/libde265/.libs/libde265.so" ]; then 14 | tar xf libde265-${LIBDE265_VERSION}.tar.gz 15 | cd libde265-${LIBDE265_VERSION} 16 | [ -x configure ] || ./autogen.sh 17 | emconfigure ./configure --disable-sse --disable-dec265 --disable-sherlock265 18 | emmake make -j${CORES} 19 | cd .. 20 | fi 21 | 22 | CONFIGURE_ARGS="--disable-multithreading --disable-go" 23 | 24 | emconfigure ./configure $CONFIGURE_ARGS \ 25 | PKG_CONFIG_PATH="${DIR}/libde265-${LIBDE265_VERSION}" \ 26 | libde265_CFLAGS="-I${DIR}/libde265-${LIBDE265_VERSION}" \ 27 | libde265_LIBS="-L${DIR}/libde265-${LIBDE265_VERSION}/libde265/.libs" 28 | if [ ! -e "Makefile" ]; then 29 | # Most likely the first run of "emscripten" which will generate the 30 | # config file and terminate. Run "emconfigure" again. 31 | emconfigure ./configure $CONFIGURE_ARGS \ 32 | PKG_CONFIG_PATH="${DIR}/libde265-${LIBDE265_VERSION}" \ 33 | libde265_CFLAGS="-I${DIR}/libde265-${LIBDE265_VERSION}" \ 34 | libde265_LIBS="-L${DIR}/libde265-${LIBDE265_VERSION}/libde265/.libs" 35 | fi 36 | emmake make -j${CORES} 37 | 38 | export TOTAL_MEMORY=16777216 39 | 40 | echo "Running Emscripten..." 41 | emcc libheif/.libs/libheif.so \ 42 | --bind \ 43 | -s NO_EXIT_RUNTIME=1 \ 44 | -s TOTAL_MEMORY=${TOTAL_MEMORY} \ 45 | -s ALLOW_MEMORY_GROWTH=1 \ 46 | -s ASSERTIONS=0 \ 47 | -s INVOKE_RUN=0 \ 48 | -s DOUBLE_MODE=0 \ 49 | -s PRECISE_F32=0 \ 50 | -s PRECISE_I64_MATH=0 \ 51 | -s DISABLE_EXCEPTION_CATCHING=1 \ 52 | -s USE_CLOSURE_COMPILER=0 \ 53 | -s LEGACY_VM_SUPPORT=1 \ 54 | --memory-init-file 0 \ 55 | -O3 \ 56 | -std=c++11 \ 57 | -L${DIR}/libde265-${LIBDE265_VERSION}/libde265/.libs \ 58 | -lde265 \ 59 | --pre-js pre.js \ 60 | --post-js post.js \ 61 | -o libheif.js 62 | -------------------------------------------------------------------------------- /cmake/modules/FindAOM.cmake: -------------------------------------------------------------------------------- 1 | include(LibFindMacros) 2 | 3 | libfind_pkg_check_modules(AOM_PKGCONF aom) 4 | 5 | find_path(AOM_INCLUDE_DIR 6 | NAMES aom/aom_decoder.h aom/aom_encoder.h 7 | HINTS ${AOM_PKGCONF_INCLUDE_DIRS} ${AOM_PKGCONF_INCLUDEDIR} 8 | PATH_SUFFIXES AOM 9 | ) 10 | 11 | find_library(AOM_LIBRARY 12 | NAMES libaom aom 13 | HINTS ${AOM_PKGCONF_LIBRARY_DIRS} ${AOM_PKGCONF_LIBDIR} 14 | ) 15 | 16 | if(EXISTS "${AOM_INCLUDE_DIR}/aom/aom_decoder.h") 17 | set(AOM_DECODER_FOUND YES) 18 | else() 19 | set(AOM_DECODER_FOUND NO) 20 | endif() 21 | 22 | if(EXISTS "${AOM_INCLUDE_DIR}/aom/aom_encoder.h") 23 | set(AOM_ENCODER_FOUND YES) 24 | else() 25 | set(AOM_ENCODER_FOUND NO) 26 | endif() 27 | 28 | set(AOM_PROCESS_LIBS AOM_LIBRARY) 29 | set(AOM_PROCESS_INCLUDES AOM_INCLUDE_DIR) 30 | libfind_process(AOM) 31 | 32 | include(FindPackageHandleStandardArgs) 33 | find_package_handle_standard_args(AOM 34 | REQUIRED_VARS 35 | AOM_INCLUDE_DIR 36 | AOM_LIBRARIES 37 | ) 38 | -------------------------------------------------------------------------------- /cmake/modules/FindDAV1D.cmake: -------------------------------------------------------------------------------- 1 | include(LibFindMacros) 2 | libfind_pkg_check_modules(DAV1D_PKGCONF dav1d) 3 | 4 | find_path(DAV1D_INCLUDE_DIR 5 | NAMES dav1d/dav1d.h 6 | HINTS ${DAV1D_PKGCONF_INCLUDE_DIRS} ${DAV1D_PKGCONF_INCLUDEDIR} 7 | PATH_SUFFIXES DAV1D 8 | ) 9 | 10 | find_library(DAV1D_LIBRARY 11 | NAMES libdav1d dav1d 12 | HINTS ${DAV1D_PKGCONF_LIBRARY_DIRS} ${DAV1D_PKGCONF_LIBDIR} 13 | ) 14 | 15 | set(DAV1D_PROCESS_LIBS DAV1D_LIBRARY) 16 | set(DAV1D_PROCESS_INCLUDES DAV1D_INCLUDE_DIR) 17 | libfind_process(DAV1D) 18 | 19 | include(FindPackageHandleStandardArgs) 20 | find_package_handle_standard_args(DAV1D 21 | REQUIRED_VARS 22 | DAV1D_INCLUDE_DIR 23 | DAV1D_LIBRARIES 24 | ) 25 | -------------------------------------------------------------------------------- /cmake/modules/FindLIBDE265.cmake: -------------------------------------------------------------------------------- 1 | include(LibFindMacros) 2 | libfind_pkg_check_modules(LIBDE265_PKGCONF libde265) 3 | 4 | find_path(LIBDE265_INCLUDE_DIR 5 | NAMES libde265/de265.h 6 | HINTS ${LIBDE265_PKGCONF_INCLUDE_DIRS} ${LIBDE265_PKGCONF_INCLUDEDIR} 7 | PATH_SUFFIXES DE265 8 | ) 9 | 10 | find_library(LIBDE265_LIBRARY 11 | NAMES libde265 de265 12 | HINTS ${LIBDE265_PKGCONF_LIBRARY_DIRS} ${LIBDE265_PKGCONF_LIBDIR} 13 | ) 14 | 15 | set(LIBDE265_PROCESS_LIBS ${LIBDE265_LIBRARY}) 16 | set(LIBDE265_PROCESS_INCLUDES ${LIBDE265_INCLUDE_DIR}) 17 | libfind_process(LIBDE265) 18 | 19 | if(LIBDE265_INCLUDE_DIR) 20 | set(libde265_config_file "${LIBDE265_INCLUDE_DIR}/libde265/de265-version.h") 21 | if(EXISTS ${libde265_config_file}) 22 | file(STRINGS 23 | ${libde265_config_file} 24 | TMP 25 | REGEX "#define LIBDE265_VERSION .*$") 26 | string(REGEX REPLACE "#define LIBDE265_VERSION" "" TMP ${TMP}) 27 | string(REGEX MATCHALL "[0-9.]+" LIBDE265_VERSION ${TMP}) 28 | endif() 29 | endif() 30 | 31 | include(FindPackageHandleStandardArgs) 32 | find_package_handle_standard_args(LIBDE265 33 | REQUIRED_VARS 34 | LIBDE265_INCLUDE_DIRS 35 | LIBDE265_LIBRARIES 36 | VERSION_VAR 37 | LIBDE265_VERSION 38 | ) 39 | -------------------------------------------------------------------------------- /cmake/modules/FindRAV1E.cmake: -------------------------------------------------------------------------------- 1 | include(LibFindMacros) 2 | libfind_pkg_check_modules(RAV1E_PKGCONF rav1e) 3 | 4 | find_path(RAV1E_INCLUDE_DIR 5 | NAMES rav1e.h 6 | HINTS ${RAV1E_PKGCONF_INCLUDE_DIRS} ${RAV1E_PKGCONF_INCLUDEDIR} 7 | PATH_SUFFIXES RAV1E 8 | ) 9 | 10 | find_library(RAV1E_LIBRARY 11 | NAMES librav1e rav1e rav1e.dll 12 | HINTS ${RAV1E_PKGCONF_LIBRARY_DIRS} ${RAV1E_PKGCONF_LIBDIR} 13 | ) 14 | 15 | set(RAV1E_PROCESS_LIBS RAV1E_LIBRARY) 16 | set(RAV1E_PROCESS_INCLUDES RAV1E_INCLUDE_DIR) 17 | libfind_process(RAV1E) 18 | 19 | include(FindPackageHandleStandardArgs) 20 | find_package_handle_standard_args(RAV1E 21 | REQUIRED_VARS 22 | RAV1E_INCLUDE_DIR 23 | RAV1E_LIBRARIES 24 | ) 25 | -------------------------------------------------------------------------------- /cmake/modules/FindSvtEnc.cmake: -------------------------------------------------------------------------------- 1 | include(LibFindMacros) 2 | libfind_pkg_check_modules(SvtEnc_PKGCONF SvtAv1Enc) 3 | 4 | find_path(SvtEnc_INCLUDE_DIR 5 | NAMES svt-av1/EbSvtAv1Enc.h 6 | HINTS ${SvtEnc_PKGCONF_INCLUDE_DIRS} ${SvtEnc_PKGCONF_INCLUDEDIR} 7 | PATH_SUFFIXES SvtEnc 8 | ) 9 | 10 | find_library(SvtEnc_LIBRARY 11 | NAMES SvtAv1Enc libSvtAv1Enc 12 | HINTS ${SvtEnc_PKGCONF_LIBRARY_DIRS} ${SvtEnc_PKGCONF_LIBDIR} 13 | ) 14 | 15 | set(SvtEnc_PROCESS_LIBS SvtEnc_LIBRARY) 16 | set(SvtEnc_PROCESS_INCLUDES SvtEnc_INCLUDE_DIR) 17 | libfind_process(SvtEnc) 18 | 19 | include(FindPackageHandleStandardArgs) 20 | find_package_handle_standard_args(SvtEnc 21 | REQUIRED_VARS 22 | SvtEnc_INCLUDE_DIR 23 | SvtEnc_LIBRARIES 24 | ) 25 | -------------------------------------------------------------------------------- /cmake/modules/FindX265.cmake: -------------------------------------------------------------------------------- 1 | include(LibFindMacros) 2 | libfind_pkg_check_modules(X265_PKGCONF x265) 3 | 4 | find_path(X265_INCLUDE_DIR 5 | NAMES x265.h 6 | HINTS ${X265_PKGCONF_INCLUDE_DIRS} ${X265_PKGCONF_INCLUDEDIR} 7 | PATH_SUFFIXES X265 8 | ) 9 | 10 | find_library(X265_LIBRARY 11 | NAMES libx265 x265 12 | HINTS ${X265_PKGCONF_LIBRARY_DIRS} ${X265_PKGCONF_LIBDIR} 13 | ) 14 | 15 | set(X265_PROCESS_LIBS X265_LIBRARY) 16 | set(X265_PROCESS_INCLUDES X265_INCLUDE_DIR) 17 | libfind_process(X265) 18 | 19 | if(X265_INCLUDE_DIR) 20 | set(x265_config_file "${X265_INCLUDE_DIR}/x265_config.h") 21 | if(EXISTS ${x265_config_file}) 22 | file(STRINGS 23 | ${x265_config_file} 24 | TMP 25 | REGEX "#define X265_BUILD .*$") 26 | string(REGEX REPLACE "#define X265_BUILD" "" TMP ${TMP}) 27 | string(REGEX MATCHALL "[0-9.]+" X265_BUILD ${TMP}) 28 | endif() 29 | endif() 30 | 31 | include(FindPackageHandleStandardArgs) 32 | find_package_handle_standard_args(X265 33 | REQUIRED_VARS 34 | X265_INCLUDE_DIR 35 | X265_LIBRARIES 36 | VERSION_VAR 37 | X265_BUILD 38 | ) 39 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Needed to find libheif/heif_version.h while compiling the library 2 | include_directories(${libheif_BINARY_DIR} ${libheif_SOURCE_DIR}) 3 | 4 | set (heif_convert_sources 5 | encoder.cc 6 | encoder.h 7 | encoder_y4m.cc 8 | encoder_y4m.h 9 | heif_convert.cc 10 | ../libheif/exif.cc 11 | ../libheif/exif.cc 12 | ) 13 | 14 | set (additional_link_directories) 15 | set (additional_libraries) 16 | set (additional_includes) 17 | 18 | include (${CMAKE_ROOT}/Modules/FindJPEG.cmake) 19 | 20 | if(JPEG_FOUND) 21 | add_definitions(-DHAVE_LIBJPEG=1) 22 | include_directories(SYSTEM ${JPEG_INCLUDE_DIR}) 23 | 24 | include (${CMAKE_ROOT}/Modules/CheckCXXSourceCompiles.cmake) 25 | 26 | set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARIES}) 27 | 28 | # while the docs say JPEG_INCLUDE_DIRS, my FindJPEG.cmake script returns it in JPEG_INCLUDE_DIR 29 | set(CMAKE_REQUIRED_INCLUDES ${JPEG_INCLUDE_DIRS} ${JPEG_INCLUDE_DIR}) 30 | 31 | check_cxx_source_compiles(" 32 | #include 33 | #include 34 | #include 35 | 36 | int main() { 37 | jpeg_write_icc_profile(NULL, NULL, 0); 38 | return 0; 39 | } 40 | " HAVE_JPEG_WRITE_ICC_PROFILE) 41 | if(HAVE_JPEG_WRITE_ICC_PROFILE) 42 | add_definitions(-DHAVE_JPEG_WRITE_ICC_PROFILE=1) 43 | endif() 44 | 45 | set (heif_convert_sources 46 | ${heif_convert_sources} 47 | encoder_jpeg.cc 48 | encoder_jpeg.h 49 | ) 50 | set (additional_libraries 51 | ${additional_libraries} 52 | ${JPEG_LIBRARIES} 53 | ) 54 | set (additional_includes 55 | ${additional_includes} 56 | ${JPEG_INCLUDE_DIRS} 57 | ${JPEG_INCLUDE_DIR} 58 | ) 59 | endif() 60 | 61 | if(UNIX OR MINGW) 62 | include (${CMAKE_ROOT}/Modules/FindPkgConfig.cmake) 63 | pkg_check_modules (LIBPNG libpng) 64 | if(LIBPNG_FOUND) 65 | add_definitions(-DHAVE_LIBPNG=1) 66 | set (heif_convert_sources 67 | ${heif_convert_sources} 68 | encoder_png.cc 69 | encoder_png.h 70 | benchmark.h benchmark.cc) 71 | set (additional_link_directories 72 | ${additional_link_directories} 73 | ${LIBPNG_LIBRARY_DIRS} 74 | ) 75 | set (additional_libraries 76 | ${additional_libraries} 77 | ${LIBPNG_LINK_LIBRARIES} ${LIBPNG_LIBRARIES} 78 | ) 79 | set (additional_includes 80 | ${additional_includes} 81 | ${LIBPNG_INCLUDE_DIRS} 82 | ) 83 | endif() 84 | endif() 85 | 86 | set (heif_info_sources 87 | heif_info.cc 88 | ) 89 | 90 | set (heif_enc_sources 91 | heif_enc.cc 92 | ../libheif/exif.cc 93 | ../libheif/exif.cc 94 | benchmark.h 95 | benchmark.cc 96 | ) 97 | 98 | set (heif_test_sources 99 | heif_test.cc 100 | ) 101 | 102 | if(MSVC) 103 | set (getopt_sources 104 | ../extra/getopt.c 105 | ../extra/getopt.h 106 | ../extra/getopt_long.c 107 | ) 108 | include_directories ("../extra") 109 | endif() 110 | 111 | add_executable (heif-convert ${heif_convert_sources} ${getopt_sources}) 112 | target_link_directories (heif-convert PRIVATE ${additional_link_directories}) 113 | target_link_libraries (heif-convert heif ${additional_libraries}) 114 | target_include_directories(heif-convert PRIVATE ${additional_includes}) 115 | install(TARGETS heif-convert RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 116 | install(FILES heif-convert.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) 117 | 118 | add_executable (heif-info ${heif_info_sources} ${getopt_sources}) 119 | target_link_libraries (heif-info heif) 120 | install(TARGETS heif-info RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 121 | install(FILES heif-info.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) 122 | 123 | add_executable (heif-enc ${heif_enc_sources} ${getopt_sources}) 124 | target_link_directories (heif-enc PRIVATE ${additional_link_directories}) 125 | target_link_libraries (heif-enc heif ${additional_libraries}) 126 | target_include_directories(heif-enc PRIVATE ${additional_includes}) 127 | install(TARGETS heif-enc RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 128 | install(FILES heif-enc.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) 129 | 130 | add_executable (heif-test ${heif_test_sources} ${getopt_sources}) 131 | target_link_libraries (heif-test heif) 132 | 133 | 134 | if(LIBPNG_FOUND) 135 | set (heif_thumbnailer_sources 136 | encoder.cc 137 | encoder.h 138 | heif_thumbnailer.cc 139 | encoder_png.cc 140 | encoder_png.h 141 | ../libheif/exif.h 142 | ../libheif/exif.cc 143 | ) 144 | 145 | add_executable (heif-thumbnailer ${heif_thumbnailer_sources}) 146 | target_link_directories (heif-thumbnailer PRIVATE ${LIBPNG_LIBRARY_DIRS}) 147 | target_link_libraries (heif-thumbnailer heif ${LIBPNG_LINK_LIBRARIES} ${LIBPNG_LIBRARIES}) 148 | target_include_directories(heif-thumbnailer PRIVATE ${LIBPNG_INCLUDE_DIRS}) 149 | install(TARGETS heif-thumbnailer RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 150 | install(FILES heif-thumbnailer.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) 151 | endif() 152 | -------------------------------------------------------------------------------- /examples/COPYING: -------------------------------------------------------------------------------- 1 | 2 | MIT License 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | -------------------------------------------------------------------------------- /examples/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = subdir-objects 2 | 3 | examples = \ 4 | heif-convert \ 5 | heif-enc \ 6 | heif-info 7 | 8 | examples_noinst = \ 9 | heif-test \ 10 | test-c-api 11 | 12 | dist_man_MANS = 13 | 14 | heif_convert_DEPENDENCIES = ../libheif/libheif.la 15 | heif_convert_CXXFLAGS = -I$(top_srcdir) -I$(top_builddir)/. 16 | heif_convert_LDFLAGS = 17 | heif_convert_LDADD = ../libheif/libheif.la 18 | heif_convert_SOURCES = encoder.cc encoder.h heif_convert.cc encoder_y4m.cc encoder_y4m.h ../libheif/exif.h ../libheif/exif.cc 19 | dist_man_MANS += heif-convert.1 20 | 21 | 22 | if HAVE_LIBPNG 23 | examples += heif-thumbnailer 24 | heif_thumbnailer_DEPENDENCIES = ../libheif/libheif.la 25 | heif_thumbnailer_CXXFLAGS = -I$(top_srcdir) -I$(top_builddir) $(libpng_CFLAGS) 26 | heif_thumbnailer_LDFLAGS = $(libpng_LIBS) 27 | heif_thumbnailer_LDADD = ../libheif/libheif.la 28 | heif_thumbnailer_SOURCES = encoder.cc encoder.h heif_thumbnailer.cc encoder_png.cc encoder_png.h ../libheif/exif.h ../libheif/exif.cc 29 | dist_man_MANS += heif-thumbnailer.1 30 | endif 31 | 32 | if HAVE_LIBJPEG 33 | heif_convert_CXXFLAGS += $(libjpeg_CFLAGS) 34 | heif_convert_LDADD += $(libjpeg_LIBS) 35 | heif_convert_SOURCES += encoder_jpeg.cc encoder_jpeg.h 36 | endif 37 | 38 | if HAVE_LIBPNG 39 | heif_convert_CXXFLAGS += $(libpng_CFLAGS) 40 | heif_convert_LDADD += $(libpng_LIBS) 41 | heif_convert_SOURCES += encoder_png.cc encoder_png.h 42 | endif 43 | 44 | heif_info_DEPENDENCIES = ../libheif/libheif.la 45 | heif_info_CXXFLAGS = -I$(top_srcdir) -I$(top_builddir) 46 | heif_info_LDFLAGS = 47 | heif_info_LDADD = ../libheif/libheif.la 48 | heif_info_SOURCES = heif_info.cc 49 | dist_man_MANS += heif-info.1 50 | 51 | heif_enc_DEPENDENCIES = ../libheif/libheif.la 52 | heif_enc_CXXFLAGS = -I$(top_srcdir) -I$(top_builddir) 53 | heif_enc_LDFLAGS = 54 | heif_enc_LDADD = ../libheif/libheif.la 55 | heif_enc_SOURCES = heif_enc.cc benchmark.cc benchmark.h ../libheif/exif.h ../libheif/exif.cc 56 | dist_man_MANS += heif-enc.1 57 | 58 | if HAVE_LIBJPEG 59 | heif_enc_CXXFLAGS += $(libjpeg_CFLAGS) 60 | heif_enc_LDADD += $(libjpeg_LIBS) 61 | endif 62 | 63 | if HAVE_LIBPNG 64 | heif_enc_CXXFLAGS += $(libpng_CFLAGS) 65 | heif_enc_LDADD += $(libpng_LIBS) 66 | endif 67 | 68 | heif_test_DEPENDENCIES = ../libheif/libheif.la 69 | heif_test_CXXFLAGS = -I$(top_srcdir) -I$(top_builddir) 70 | heif_test_LDFLAGS = 71 | heif_test_LDADD = ../libheif/libheif.la 72 | heif_test_SOURCES = heif_test.cc 73 | 74 | test_c_api_DEPENDENCIES = ../libheif/libheif.la 75 | test_c_api_CFLAGS = -I$(top_srcdir) -I$(top_builddir) 76 | test_c_api_LDFLAGS = 77 | test_c_api_LDADD = ../libheif/libheif.la 78 | test_c_api_SOURCES = test_c_api.c 79 | 80 | EXTRA_DIST = \ 81 | CMakeLists.txt \ 82 | COPYING \ 83 | demo.html \ 84 | example.avif \ 85 | example.heic 86 | 87 | if HAVE_GO 88 | examples_noinst += \ 89 | heif-test-go 90 | 91 | heif_test_go_SOURCES = heif-test.go 92 | 93 | gopath: 94 | mkdir -p ${CURDIR}/src/github.com/strukturag/libheif 95 | ln -sf ${CURDIR}/../go ${CURDIR}/src/github.com/strukturag/libheif/ 96 | 97 | heif-test-go: gopath $(top_builddir)/libheif/libheif.la $(top_builddir)/libheif.pc heif-test.go 98 | GOPATH=${CURDIR} PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:$(abs_top_builddir):$(abs_top_builddir)/libde265/dist/lib/pkgconfig/ CGO_CFLAGS="-I$(abs_top_builddir)" CGO_LDFLAGS="-L$(abs_top_builddir)/libheif/.libs" LD_LIBRARY_PATH=$(abs_top_builddir)/libheif/.libs $(GO) build -o heif-test-go ${heif_test_go_SOURCES} 99 | 100 | format-go: ${heif_test_go_SOURCES} 101 | $(GO) fmt ${heif_test_go_SOURCES} 102 | else 103 | format-go: 104 | echo ""go" not present in "${PATH}", skipping formatting" 105 | endif 106 | 107 | if WITH_EXAMPLES 108 | bin_PROGRAMS = $(examples) 109 | noinst_PROGRAMS = $(examples_noinst) 110 | endif 111 | 112 | format-local: format-go 113 | -------------------------------------------------------------------------------- /examples/benchmark.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2022 Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | #include "benchmark.h" 22 | #include "libheif/heif.h" 23 | #include 24 | 25 | 26 | double compute_psnr(heif_image* original_image, const std::string& encoded_file) 27 | { 28 | double psnr = 0.0; 29 | 30 | // read encoded image 31 | 32 | struct heif_context* ctx = nullptr; 33 | struct heif_image_handle* handle = nullptr; 34 | struct heif_image* image = nullptr; 35 | heif_error err{}; 36 | 37 | int orig_stride = 0; 38 | const uint8_t* orig_p = nullptr; 39 | int compressed_stride = 0; 40 | const uint8_t* compressed_p = nullptr; 41 | 42 | int w = 0, h = 0; 43 | double mse = 0.0; 44 | 45 | 46 | if (heif_image_get_colorspace(original_image) != heif_colorspace_YCbCr && 47 | heif_image_get_colorspace(original_image) != heif_colorspace_monochrome) { 48 | fprintf(stderr, "Benchmark can only be computed on YCbCr or monochrome images\n"); 49 | goto cleanup; 50 | } 51 | 52 | 53 | ctx = heif_context_alloc(); 54 | 55 | err = heif_context_read_from_file(ctx, encoded_file.c_str(), nullptr); 56 | if (err.code) { 57 | fprintf(stderr, "Error reading encoded file: %s\n", err.message); 58 | goto cleanup; 59 | } 60 | 61 | err = heif_context_get_primary_image_handle(ctx, &handle); 62 | if (err.code) { 63 | fprintf(stderr, "Error getting primary image handle: %s\n", err.message); 64 | goto cleanup; 65 | } 66 | 67 | err = heif_decode_image(handle, &image, 68 | heif_image_get_colorspace(original_image), 69 | heif_image_get_chroma_format(original_image), 70 | nullptr); 71 | if (err.code) { 72 | fprintf(stderr, "Error decoding image: %s\n", err.message); 73 | goto cleanup; 74 | } 75 | 76 | w = heif_image_get_width(original_image, heif_channel_Y); 77 | h = heif_image_get_height(original_image, heif_channel_Y); 78 | 79 | orig_p = heif_image_get_plane_readonly(original_image, heif_channel_Y, &orig_stride); 80 | compressed_p = heif_image_get_plane_readonly(image, heif_channel_Y, &compressed_stride); 81 | 82 | for (int y = 0; y < h; y++) { 83 | for (int x = 0; x < w; x++) { 84 | int d = orig_p[y * orig_stride + x] - compressed_p[y * compressed_stride + x]; 85 | mse += d * d; 86 | } 87 | } 88 | 89 | mse /= w * h; 90 | 91 | psnr = 10 * log10(255.0 * 255.0 / mse); 92 | 93 | cleanup: 94 | heif_image_release(image); 95 | heif_image_handle_release(handle); 96 | heif_context_free(ctx); 97 | 98 | return psnr; 99 | } 100 | -------------------------------------------------------------------------------- /examples/benchmark.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2022 Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | 22 | #ifndef LIBHEIF_BENCHMARK_H 23 | #define LIBHEIF_BENCHMARK_H 24 | 25 | #include 26 | #include 27 | 28 | struct heif_image; 29 | 30 | double compute_psnr(heif_image* original_image, const std::string& encoded_file); 31 | 32 | #endif //LIBHEIF_BENCHMARK_H 33 | -------------------------------------------------------------------------------- /examples/encoder.cc: -------------------------------------------------------------------------------- 1 | /* 2 | libheif example application "convert". 3 | This file is part of convert, an example application using libheif. 4 | 5 | MIT License 6 | 7 | Copyright (c) 2018 struktur AG, Joachim Bauch 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in all 17 | copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | SOFTWARE. 26 | */ 27 | #if defined(HAVE_CONFIG_H) 28 | #include "config.h" 29 | #endif 30 | 31 | #include 32 | #include 33 | 34 | #include "encoder.h" 35 | 36 | static const char kMetadataTypeExif[] = "Exif"; 37 | 38 | // static 39 | bool Encoder::HasExifMetaData(const struct heif_image_handle* handle) 40 | { 41 | 42 | heif_item_id metadata_id; 43 | int count = heif_image_handle_get_list_of_metadata_block_IDs(handle, kMetadataTypeExif, 44 | &metadata_id, 1); 45 | return count > 0; 46 | } 47 | 48 | // static 49 | uint8_t* Encoder::GetExifMetaData(const struct heif_image_handle* handle, size_t* size) 50 | { 51 | heif_item_id metadata_id; 52 | int count = heif_image_handle_get_list_of_metadata_block_IDs(handle, kMetadataTypeExif, 53 | &metadata_id, 1); 54 | 55 | for (int i = 0; i < count; i++) { 56 | size_t datasize = heif_image_handle_get_metadata_size(handle, metadata_id); 57 | uint8_t* data = static_cast(malloc(datasize)); 58 | if (!data) { 59 | continue; 60 | } 61 | 62 | heif_error error = heif_image_handle_get_metadata(handle, metadata_id, data); 63 | if (error.code != heif_error_Ok) { 64 | free(data); 65 | continue; 66 | } 67 | 68 | *size = datasize; 69 | return data; 70 | } 71 | 72 | return nullptr; 73 | } 74 | 75 | 76 | std::vector Encoder::get_xmp_metadata(const struct heif_image_handle* handle) 77 | { 78 | std::vector xmp; 79 | 80 | heif_item_id metadata_ids[16]; 81 | int count = heif_image_handle_get_list_of_metadata_block_IDs(handle, nullptr, metadata_ids, 16); 82 | 83 | for (int i = 0; i < count; i++) { 84 | if (strcmp(heif_image_handle_get_metadata_type(handle, metadata_ids[i]), "mime") == 0 && 85 | strcmp(heif_image_handle_get_metadata_content_type(handle, metadata_ids[i]), "application/rdf+xml") == 0) { 86 | 87 | size_t datasize = heif_image_handle_get_metadata_size(handle, metadata_ids[i]); 88 | xmp.resize(datasize); 89 | 90 | heif_error error = heif_image_handle_get_metadata(handle, metadata_ids[i], xmp.data()); 91 | if (error.code != heif_error_Ok) { 92 | // TODO: return error 93 | return {}; 94 | } 95 | 96 | return xmp; 97 | } 98 | } 99 | 100 | return {}; 101 | } 102 | -------------------------------------------------------------------------------- /examples/encoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | libheif example application "convert". 3 | 4 | MIT License 5 | 6 | Copyright (c) 2017 struktur AG, Joachim Bauch 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | #ifndef EXAMPLE_ENCODER_H 27 | #define EXAMPLE_ENCODER_H 28 | 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | 36 | class Encoder 37 | { 38 | public: 39 | virtual ~Encoder() = default; 40 | 41 | virtual heif_colorspace colorspace(bool has_alpha) const = 0; 42 | 43 | virtual heif_chroma chroma(bool has_alpha, int bit_depth) const = 0; 44 | 45 | virtual void UpdateDecodingOptions(const struct heif_image_handle* handle, 46 | struct heif_decoding_options* options) const 47 | { 48 | // Override if necessary. 49 | } 50 | 51 | virtual bool Encode(const struct heif_image_handle* handle, 52 | const struct heif_image* image, const std::string& filename) = 0; 53 | 54 | protected: 55 | static bool HasExifMetaData(const struct heif_image_handle* handle); 56 | 57 | static uint8_t* GetExifMetaData(const struct heif_image_handle* handle, size_t* size); 58 | 59 | static std::vector get_xmp_metadata(const struct heif_image_handle* handle); 60 | }; 61 | 62 | #endif // EXAMPLE_ENCODER_H 63 | -------------------------------------------------------------------------------- /examples/encoder_jpeg.h: -------------------------------------------------------------------------------- 1 | /* 2 | libheif example application "convert". 3 | 4 | MIT License 5 | 6 | Copyright (c) 2017 struktur AG, Joachim Bauch 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | #ifndef EXAMPLE_ENCODER_JPEG_H 27 | #define EXAMPLE_ENCODER_JPEG_H 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #include 34 | 35 | #include 36 | 37 | #include "encoder.h" 38 | 39 | class JpegEncoder : public Encoder 40 | { 41 | public: 42 | JpegEncoder(int quality); 43 | 44 | heif_colorspace colorspace(bool has_alpha) const override 45 | { 46 | return heif_colorspace_YCbCr; 47 | } 48 | 49 | heif_chroma chroma(bool has_alpha, int bit_depth) const override 50 | { 51 | return heif_chroma_420; 52 | } 53 | 54 | void UpdateDecodingOptions(const struct heif_image_handle* handle, 55 | struct heif_decoding_options* options) const override; 56 | 57 | bool Encode(const struct heif_image_handle* handle, 58 | const struct heif_image* image, const std::string& filename) override; 59 | 60 | private: 61 | static const int kDefaultQuality = 90; 62 | 63 | struct ErrorHandler 64 | { 65 | struct jpeg_error_mgr pub; /* "public" fields */ 66 | jmp_buf setjmp_buffer; /* for return to caller */ 67 | }; 68 | 69 | static void OnJpegError(j_common_ptr cinfo); 70 | 71 | int quality_; 72 | }; 73 | 74 | #endif // EXAMPLE_ENCODER_JPEG_H 75 | -------------------------------------------------------------------------------- /examples/encoder_png.h: -------------------------------------------------------------------------------- 1 | /* 2 | libheif example application "convert". 3 | 4 | MIT License 5 | 6 | Copyright (c) 2017 struktur AG, Joachim Bauch 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | #ifndef EXAMPLE_ENCODER_PNG_H 27 | #define EXAMPLE_ENCODER_PNG_H 28 | 29 | #include 30 | 31 | #include "encoder.h" 32 | 33 | class PngEncoder : public Encoder 34 | { 35 | public: 36 | PngEncoder(); 37 | 38 | heif_colorspace colorspace(bool has_alpha) const override 39 | { 40 | return heif_colorspace_RGB; 41 | } 42 | 43 | heif_chroma chroma(bool has_alpha, int bit_depth) const override 44 | { 45 | if (bit_depth == 8) { 46 | if (has_alpha) 47 | return heif_chroma_interleaved_RGBA; 48 | else 49 | return heif_chroma_interleaved_RGB; 50 | } 51 | else { 52 | if (has_alpha) 53 | return heif_chroma_interleaved_RRGGBBAA_BE; 54 | else 55 | return heif_chroma_interleaved_RRGGBB_BE; 56 | } 57 | } 58 | 59 | bool Encode(const struct heif_image_handle* handle, 60 | const struct heif_image* image, const std::string& filename) override; 61 | 62 | private: 63 | }; 64 | 65 | #endif // EXAMPLE_ENCODER_PNG_H 66 | -------------------------------------------------------------------------------- /examples/encoder_y4m.cc: -------------------------------------------------------------------------------- 1 | /* 2 | libheif example application "convert". 3 | 4 | MIT License 5 | 6 | Copyright (c) 2019 struktur AG, Dirk Farin 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | #include "encoder_y4m.h" 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | 33 | Y4MEncoder::Y4MEncoder() = default; 34 | 35 | 36 | void Y4MEncoder::UpdateDecodingOptions(const struct heif_image_handle* handle, 37 | struct heif_decoding_options* options) const 38 | { 39 | } 40 | 41 | 42 | bool Y4MEncoder::Encode(const struct heif_image_handle* handle, 43 | const struct heif_image* image, 44 | const std::string& filename) 45 | { 46 | FILE* fp = fopen(filename.c_str(), "wb"); 47 | if (!fp) { 48 | fprintf(stderr, "Can't open %s: %s\n", filename.c_str(), strerror(errno)); 49 | return false; 50 | } 51 | 52 | int y_stride, cb_stride, cr_stride; 53 | const uint8_t* yp = heif_image_get_plane_readonly(image, heif_channel_Y, &y_stride); 54 | const uint8_t* cbp = heif_image_get_plane_readonly(image, heif_channel_Cb, &cb_stride); 55 | const uint8_t* crp = heif_image_get_plane_readonly(image, heif_channel_Cr, &cr_stride); 56 | 57 | assert(y_stride > 0); 58 | assert(cb_stride > 0); 59 | assert(cr_stride > 0); 60 | 61 | int yw = heif_image_get_width(image, heif_channel_Y); 62 | int yh = heif_image_get_height(image, heif_channel_Y); 63 | int cw = heif_image_get_width(image, heif_channel_Cb); 64 | int ch = heif_image_get_height(image, heif_channel_Cb); 65 | 66 | fprintf(fp, "YUV4MPEG2 W%d H%d F30:1\nFRAME\n", yw, yh); 67 | 68 | for (int y = 0; y < yh; y++) { 69 | fwrite(yp + y * y_stride, 1, yw, fp); 70 | } 71 | 72 | for (int y = 0; y < ch; y++) { 73 | fwrite(cbp + y * cb_stride, 1, cw, fp); 74 | } 75 | 76 | for (int y = 0; y < ch; y++) { 77 | fwrite(crp + y * cr_stride, 1, cw, fp); 78 | } 79 | 80 | fclose(fp); 81 | 82 | return true; 83 | } 84 | -------------------------------------------------------------------------------- /examples/encoder_y4m.h: -------------------------------------------------------------------------------- 1 | /* 2 | libheif example application "convert". 3 | 4 | MIT License 5 | 6 | Copyright (c) 2019 struktur AG, Dirk Farin 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | #ifndef EXAMPLE_ENCODER_Y4M_H 27 | #define EXAMPLE_ENCODER_Y4M_H 28 | 29 | #include 30 | 31 | #include "encoder.h" 32 | 33 | class Y4MEncoder : public Encoder 34 | { 35 | public: 36 | Y4MEncoder(); 37 | 38 | heif_colorspace colorspace(bool has_alpha) const override 39 | { 40 | return heif_colorspace_YCbCr; 41 | } 42 | 43 | heif_chroma chroma(bool has_alpha, int bit_depth) const override 44 | { 45 | return heif_chroma_420; 46 | } 47 | 48 | void UpdateDecodingOptions(const struct heif_image_handle* handle, 49 | struct heif_decoding_options* options) const override; 50 | 51 | bool Encode(const struct heif_image_handle* handle, 52 | const struct heif_image* image, const std::string& filename) override; 53 | 54 | private: 55 | }; 56 | 57 | #endif // EXAMPLE_ENCODER_Y4M_H 58 | -------------------------------------------------------------------------------- /examples/example.avif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/examples/example.avif -------------------------------------------------------------------------------- /examples/example.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/examples/example.heic -------------------------------------------------------------------------------- /examples/heif-convert.1: -------------------------------------------------------------------------------- 1 | .TH HEIF-THUMBNAILER 1 2 | .SH NAME 3 | heif-convert \- convert HEIC/HEIF image 4 | .SH SYNOPSIS 5 | .B heif-convert 6 | [\fB\-q\fR \fIQUALITY\fR] 7 | .IR filename 8 | .IR output[.jpg|.png|.y4m] 9 | .SH DESCRIPTION 10 | .B heif-convert 11 | Convert HEIC/HEIF image to a different image format. 12 | .SH OPTIONS 13 | .TP 14 | .BR \-q\fR\ \fIQUALITY\fR 15 | Defines quality level between 0 and 100 for the generated output file. 16 | .SH EXIT STATUS 17 | .PP 18 | \fB0\fR 19 | .RS 4 20 | Success 21 | .RE 22 | .PP 23 | \fB1\fR 24 | .RS 4 25 | Failure (syntax or usage error; error while loading, converting or writing image). 26 | .RE 27 | .SH NOTES 28 | The available output formats depend on the libraries that were available at 29 | compile time. Supported are JPEG, PNG and Y4M, the file type is determined based 30 | on the extension of the output file. 31 | .SH BUGS 32 | Please reports bugs or issues at https://github.com/strukturag/libheif 33 | .SH AUTHORS 34 | Joachim Bauch, struktur AG 35 | .br 36 | Dirk Farin, struktur AG 37 | .SH COPYRIGHT 38 | Copyright \[co] 2017 struktur AG 39 | -------------------------------------------------------------------------------- /examples/heif-enc.1: -------------------------------------------------------------------------------- 1 | .TH HEIF-ENC 1 2 | .SH NAME 3 | heif-enc \- convert image to HEIC/HEIF 4 | .SH SYNOPSIS 5 | .B heif-enc 6 | [\fB\-h\fR|\fB--help\fR] 7 | [\fB\-q\fR \fIQUALITY\fR|\fB--quality\fR \fIQUALITY\fR] 8 | [\fB\-L\fR|\fB--lossless\fR] 9 | [\fB\-t\fR \fISIZE\fR|\fB--thumb\fR \fISIZE\fR] 10 | [\fB--no-alpha\fR] 11 | [\fB--no-thumb-alpha\fR] 12 | [\fB\-o\fR \fIFILENAME\fR|\fB--output\fR \fIFILENAME\fR] 13 | [\fB\-v\fR|\fB--verbose\fR] 14 | [\fB\-P\fR|\fB--params\fR] 15 | [\fB\-b\fR \fIDEPTH\fR] 16 | [\fB\-p\fR \fINAME\fR\fB=\fR\fIVALUE\fR] 17 | .IR filename[.jpg|.png|.y4m] 18 | .SH DESCRIPTION 19 | .B heif-enc 20 | Convert image to HEIC/HEIF. 21 | .SH OPTIONS 22 | .TP 23 | .BR \-q\fR\ \fIQUALITY\fR ", " \-\-quality\fR\ \fIQUALITY\fR 24 | Defines quality level between 0 and 100 for the generated output file. 25 | .TP 26 | .BR \-L ", "\-\-lossless\fR 27 | Generate lossless output (\fB-q\fR has no effect) 28 | .TP 29 | .BR \-t\fR\ \fISIZE\fR ", " \-\-thumb\fR\ \fISIZE\fR 30 | Generate thumbnail with maximum size \fISIZE\fR pixels (default: off). 31 | .TP 32 | .BR \-\-no-alpha\fR 33 | Do not save alpha channel. 34 | .TP 35 | .BR \-\-no-thumb-alpha\fR 36 | Do not save alpha channel in thumbnail image. 37 | .TP 38 | .BR \-o\fR\ \fIFILENAME\fR ", " \-\-output\fR\ \fIFILENAME\fR 39 | Output filename (optional). 40 | .TP 41 | .BR \-v ", "\-\-verbose\fR 42 | Enable logging output (more \fB\-v\fR will increase logging level). 43 | .TP 44 | .BR \-P ", "\-\-params\fR 45 | Show all encoder parameters. 46 | .TP 47 | .BR \-b\fR\ \fIDEPTH\fR 48 | Bit-depth of generated HEIF file when using 16-bit PNG input (default: 10 bit). 49 | .TP 50 | .BR \-p\fR\ \fINAME\fR\fB=\fR\fIVALUE\fR 51 | Set additional encoder parameters. See \fBNOTES\fR below. 52 | .SH EXIT STATUS 53 | .PP 54 | \fB0\fR 55 | .RS 4 56 | Success 57 | .RE 58 | .PP 59 | \fB1\fR 60 | .RS 4 61 | Failure (syntax or usage error; error while loading, converting or writing image). 62 | .RE 63 | .SH NOTES 64 | The available input formats depend on the libraries that were available at 65 | compile time. Supported are JPEG, PNG and Y4M, the file type is determined based 66 | on the extension of the input file. 67 | 68 | When specifying multiple source images, they will all be saved into the same 69 | HEIF file. 70 | 71 | When using the x265 encoder, you may pass it any of its parameters by 72 | prefixing the parameter name with \fBx265:\fR. 73 | Hence, to set the \fBctu\fR parameter, you will have to set \fBx265:ctu\fR 74 | in libheif (e.g.: \fB-p x265:ctu=64\fR). 75 | 76 | Note that there is no checking for valid parameters when using the prefix. 77 | .SH BUGS 78 | Please reports bugs or issues at https://github.com/strukturag/libheif 79 | .SH AUTHORS 80 | Dirk Farin, struktur AG 81 | .SH COPYRIGHT 82 | Copyright \[co] 2017 struktur AG 83 | -------------------------------------------------------------------------------- /examples/heif-info.1: -------------------------------------------------------------------------------- 1 | .TH HEIF-INFO 1 2 | .SH NAME 3 | heif-info \- show information on HEIC/HEIF file 4 | .SH SYNOPSIS 5 | .B heif-info 6 | [\fB\-d\fR|\fB--dump-boxes\fR] 7 | [\fB\-h\fR|\fB--help\fR] 8 | .IR filename 9 | .SH DESCRIPTION 10 | .B heif-info 11 | Show information on HEIC/HEIF file. 12 | .SH OPTIONS 13 | .TP 14 | .BR \-d ", " \-\-dump-boxes\fR 15 | Show a low-level dump of all MP4 file boxes. 16 | .TP 17 | .BR \-help ", " \-\-help\fR 18 | Show help. 19 | .SH EXIT STATUS 20 | .PP 21 | \fB0\fR 22 | .RS 4 23 | Success 24 | .RE 25 | .PP 26 | \fB1\fR 27 | .RS 4 28 | Failure (syntax or usage error; error while loading image). 29 | .RE 30 | .SH BUGS 31 | Please reports bugs or issues at https://github.com/strukturag/libheif 32 | .SH AUTHORS 33 | Dirk Farin, struktur AG 34 | .SH COPYRIGHT 35 | Copyright \[co] 2017 struktur AG 36 | -------------------------------------------------------------------------------- /examples/heif-test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Simple GO interface test program 3 | 4 | MIT License 5 | 6 | Copyright (c) 2018 struktur AG, Dirk Farin 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | 27 | package main 28 | 29 | import ( 30 | "bytes" 31 | "fmt" 32 | "image" 33 | _ "image/jpeg" 34 | "image/png" 35 | "io/ioutil" 36 | "os" 37 | "path/filepath" 38 | 39 | "github.com/strukturag/libheif/go/heif" 40 | ) 41 | 42 | // ================================================== 43 | // TEST 44 | // ================================================== 45 | 46 | func savePNG(img image.Image, filename string) { 47 | var out bytes.Buffer 48 | if err := png.Encode(&out, img); err != nil { 49 | fmt.Printf("Could not encode image as PNG: %s\n", err) 50 | } else { 51 | if err := ioutil.WriteFile(filename, out.Bytes(), 0644); err != nil { 52 | fmt.Printf("Could not save PNG image as %s: %s\n", filename, err) 53 | } else { 54 | fmt.Printf("Written to %s\n", filename) 55 | } 56 | } 57 | } 58 | 59 | func testHeifHighlevel(filename string) { 60 | fmt.Printf("Performing highlevel conversion of %s\n", filename) 61 | file, err := os.Open(filename) 62 | if err != nil { 63 | fmt.Printf("Could not read file %s: %s\n", filename, err) 64 | return 65 | } 66 | defer file.Close() 67 | 68 | img, magic, err := image.Decode(file) 69 | if err != nil { 70 | fmt.Printf("Could not decode image: %s\n", err) 71 | return 72 | } 73 | 74 | fmt.Printf("Decoded image of type %s: %s\n", magic, img.Bounds()) 75 | 76 | ext := filepath.Ext(filename) 77 | outFilename := filename[0:len(filename)-len(ext)] + "_highlevel.png" 78 | savePNG(img, outFilename) 79 | } 80 | 81 | func testHeifLowlevel(filename string) { 82 | fmt.Printf("Performing lowlevel conversion of %s\n", filename) 83 | c, err := heif.NewContext() 84 | if err != nil { 85 | fmt.Printf("Could not create context: %s\n", err) 86 | return 87 | } 88 | 89 | if err := c.ReadFromFile(filename); err != nil { 90 | fmt.Printf("Could not read file %s: %s\n", filename, err) 91 | return 92 | } 93 | 94 | nImages := c.GetNumberOfTopLevelImages() 95 | fmt.Printf("Number of top level images: %v\n", nImages) 96 | 97 | ids := c.GetListOfTopLevelImageIDs() 98 | fmt.Printf("List of top level image IDs: %#v\n", ids) 99 | 100 | if pID, err := c.GetPrimaryImageID(); err != nil { 101 | fmt.Printf("Could not get primary image id: %s\n", err) 102 | } else { 103 | fmt.Printf("Primary image: %v\n", pID) 104 | } 105 | 106 | handle, err := c.GetPrimaryImageHandle() 107 | if err != nil { 108 | fmt.Printf("Could not get primary image: %s\n", err) 109 | return 110 | } 111 | 112 | fmt.Printf("Image size: %v × %v\n", handle.GetWidth(), handle.GetHeight()) 113 | 114 | img, err := handle.DecodeImage(heif.ColorspaceUndefined, heif.ChromaUndefined, nil) 115 | if err != nil { 116 | fmt.Printf("Could not decode image: %s\n", err) 117 | } else if i, err := img.GetImage(); err != nil { 118 | fmt.Printf("Could not get image: %s\n", err) 119 | } else { 120 | fmt.Printf("Rectangle: %v\n", i.Bounds()) 121 | 122 | ext := filepath.Ext(filename) 123 | outFilename := filename[0:len(filename)-len(ext)] + "_lowlevel.png" 124 | savePNG(i, outFilename) 125 | } 126 | } 127 | 128 | func testHeifEncode(filename string) { 129 | file, err := os.Open(filename) 130 | if err != nil { 131 | fmt.Printf("failed to open file %v\n", file) 132 | return 133 | } 134 | defer file.Close() 135 | 136 | i, _, err := image.Decode(file) 137 | if err != nil { 138 | fmt.Printf("failed to decode image: %v\n", err) 139 | return 140 | } 141 | 142 | const quality = 100 143 | ctx, err := heif.EncodeFromImage(i, heif.CompressionHEVC, quality, heif.LosslessModeEnabled, heif.LoggingLevelFull) 144 | if err != nil { 145 | fmt.Printf("failed to heif encode image: %v\n", err) 146 | return 147 | } 148 | 149 | ext := filepath.Ext(filename) 150 | out := filename[0:len(filename)-len(ext)] + "_encoded.heif" 151 | if err := ctx.WriteToFile(out); err != nil { 152 | fmt.Printf("failed to write to file: %v\n", err) 153 | return 154 | } 155 | fmt.Printf("Written to %s\n", out) 156 | } 157 | 158 | func main() { 159 | fmt.Printf("libheif version: %v\n", heif.GetVersion()) 160 | if len(os.Args) < 2 { 161 | fmt.Printf("USAGE: %s \n", os.Args[0]) 162 | return 163 | } 164 | 165 | filename := os.Args[1] 166 | testHeifLowlevel(filename) 167 | fmt.Println() 168 | testHeifHighlevel(filename) 169 | fmt.Println() 170 | testHeifEncode(filename) 171 | fmt.Println("Done.") 172 | } 173 | -------------------------------------------------------------------------------- /examples/heif-thumbnailer.1: -------------------------------------------------------------------------------- 1 | .TH HEIF-THUMBNAILER 1 2 | .SH NAME 3 | heif-thumbnailer \- create thumbnails from HEIC/HEIF files 4 | .SH SYNOPSIS 5 | .B heif-thumbnailer 6 | [\fB\-s\fR \fISIZE\fR] 7 | .IR filename 8 | .IR output 9 | .SH DESCRIPTION 10 | .B heif-thumbnailer 11 | Create thumbnail images from HEIC/HEIF files that can be used for example by Nautilus. 12 | .SH OPTIONS 13 | .TP 14 | .BR \-s\fR\ \fISIZE\fR 15 | Defines the maximum width and height of the thumbnail to generate. 16 | Default is 512 pixel. 17 | .SH EXIT STATUS 18 | .PP 19 | \fB0\fR 20 | .RS 4 21 | Success 22 | .RE 23 | .PP 24 | \fB1\fR 25 | .RS 4 26 | Failure (syntax or usage error; error while loading, converting or writing image). 27 | .RE 28 | .SH BUGS 29 | Please reports bugs or issues at https://github.com/strukturag/libheif 30 | .SH AUTHORS 31 | Dirk Farin, struktur AG 32 | .SH COPYRIGHT 33 | Copyright \[co] 2018 struktur AG 34 | -------------------------------------------------------------------------------- /examples/heif_test.cc: -------------------------------------------------------------------------------- 1 | /* 2 | libheif example application "heif-test". 3 | 4 | MIT License 5 | 6 | Copyright (c) 2017 struktur AG, Dirk Farin 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | #if defined(HAVE_CONFIG_H) 27 | #include "config.h" 28 | #endif 29 | 30 | #include 31 | #include 32 | 33 | #if defined(HAVE_UNISTD_H) 34 | 35 | #include 36 | 37 | #else 38 | #define STDOUT_FILENO 1 39 | #endif 40 | 41 | #include 42 | 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | 50 | static struct option long_options[] = { 51 | //{"write-raw", required_argument, 0, 'w' }, 52 | //{"output", required_argument, 0, 'o' }, 53 | {(char* const) "decode-img", required_argument, 0, 'd'}, 54 | {(char* const) "metadata", required_argument, 0, 'm'}, 55 | {0, 0, 0, 0} 56 | }; 57 | 58 | void show_help(const char* argv0) 59 | { 60 | fprintf(stderr, " heif-test libheif version: %s\n", heif_get_version()); 61 | fprintf(stderr, "------------------------------------\n"); 62 | fprintf(stderr, "usage: heif-test [options] image.heic\n"); 63 | fprintf(stderr, "\n"); 64 | fprintf(stderr, "options:\n"); 65 | fprintf(stderr, " -d, --decode-img ID decode image and output raw pixel data of all planes\n"); 66 | fprintf(stderr, " -m, --metadata ID output metadata\n"); 67 | fprintf(stderr, " -h, --help show help\n"); 68 | } 69 | 70 | 71 | std::pair parse_id_pair(const std::string& s) 72 | { 73 | std::string::size_type p = s.find_first_of(':'); 74 | if (p == std::string::npos) { 75 | fprintf(stderr, "id pair has to be in this format: 'ID:ID'\n"); 76 | exit(1); 77 | } 78 | 79 | std::pair pair; 80 | pair.first = atoi(s.substr(0, p).c_str()); 81 | pair.second = atoi(s.substr(p + 1).c_str()); 82 | return pair; 83 | } 84 | 85 | 86 | int main(int argc, char** argv) 87 | { 88 | std::vector image_IDs; 89 | std::vector> metadata_IDs; // first: image, second: metadata 90 | 91 | while (true) { 92 | int option_index = 0; 93 | int c = getopt_long(argc, argv, "d:m:h", long_options, &option_index); 94 | if (c == -1) 95 | break; 96 | 97 | switch (c) { 98 | case 'd': 99 | image_IDs.push_back(atoi(optarg)); 100 | break; 101 | case 'm': 102 | metadata_IDs.push_back(parse_id_pair(optarg)); 103 | break; 104 | case 'h': 105 | show_help(argv[0]); 106 | return 0; 107 | } 108 | } 109 | 110 | if (optind != argc - 1) { 111 | show_help(argv[0]); 112 | return 0; 113 | } 114 | 115 | 116 | const char* input_filename = argv[optind]; 117 | 118 | // ============================================================================== 119 | 120 | try { 121 | heif::Context ctx; 122 | ctx.read_from_file(input_filename); 123 | 124 | 125 | // --- dump images 126 | 127 | for (auto id : image_IDs) { 128 | heif::ImageHandle handle = ctx.get_image_handle(id); 129 | 130 | heif::Image img = handle.decode_image(heif_colorspace_undefined, heif_chroma_undefined); 131 | 132 | std::vector channel_candidates{ 133 | heif_channel_Y, 134 | heif_channel_Cb, 135 | heif_channel_Cr, 136 | heif_channel_R, 137 | heif_channel_G, 138 | heif_channel_B, 139 | heif_channel_Alpha, 140 | heif_channel_interleaved 141 | }; 142 | 143 | for (heif_channel channel : channel_candidates) { 144 | if (img.has_channel(channel)) { 145 | int width = img.get_width(channel); 146 | int height = img.get_height(channel); 147 | int bytes = (img.get_bits_per_pixel(channel) + 7) / 8; 148 | 149 | int stride; 150 | const uint8_t* p = img.get_plane(channel, &stride); 151 | for (int y = 0; y < height; y++) { 152 | fwrite(p + y * stride, width, bytes, stdout); 153 | } 154 | } 155 | } 156 | } 157 | 158 | 159 | // --- dump metadata 160 | 161 | for (auto idpair : metadata_IDs) { 162 | heif::ImageHandle handle = ctx.get_image_handle(idpair.first); 163 | std::vector data = handle.get_metadata(idpair.second); 164 | fwrite(data.data(), data.size(), 1, stdout); 165 | } 166 | } 167 | catch (const heif::Error& err) { 168 | std::cerr << err.get_message() << "\n"; 169 | } 170 | 171 | return 0; 172 | } 173 | -------------------------------------------------------------------------------- /examples/test_c_api.c: -------------------------------------------------------------------------------- 1 | /* 2 | Very simple test whether the header file compiler with a plain C compiler 3 | This file is part of libheif. It performs test calculations for CI checks. 4 | 5 | MIT License 6 | 7 | Copyright (c) 2018 struktur AG, Dirk Farin 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in all 17 | copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | SOFTWARE. 26 | */ 27 | 28 | 29 | #include "libheif/heif.h" 30 | #include "libheif/heif_version.h" 31 | #include "libheif/heif_plugin.h" 32 | 33 | int main() 34 | { 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /extra/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = \ 2 | getopt.c \ 3 | getopt.h \ 4 | getopt_long.c 5 | -------------------------------------------------------------------------------- /extra/getopt.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: getopt.c,v 1.16 1999/12/02 13:15:56 kleink Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1987, 1993, 1994 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. All advertising materials mentioning features or use of this software 16 | * must display the following acknowledgement: 17 | * This product includes software developed by the University of 18 | * California, Berkeley and its contributors. 19 | * 4. Neither the name of the University nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | */ 35 | 36 | #if 0 37 | static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95"; 38 | #endif 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #define __P(x) x 46 | #define _DIAGASSERT(x) assert(x) 47 | 48 | #ifdef __weak_alias 49 | __weak_alias(getopt,_getopt); 50 | #endif 51 | 52 | #ifdef __cplusplus 53 | extern "C" { 54 | #endif 55 | 56 | int opterr = 1, /* if error message should be printed */ 57 | optind = 1, /* index into parent argv vector */ 58 | optopt, /* character checked for validity */ 59 | optreset; /* reset getopt */ 60 | char *optarg; /* argument associated with option */ 61 | 62 | static char * _progname __P((char *)); 63 | int getopt_internal __P((int, char * const *, const char *)); 64 | 65 | static char * 66 | _progname(char * nargv0) 67 | { 68 | char * tmp; 69 | 70 | _DIAGASSERT(nargv0 != NULL); 71 | 72 | tmp = strrchr(nargv0, '/'); 73 | if (tmp) 74 | tmp++; 75 | else 76 | tmp = nargv0; 77 | return(tmp); 78 | } 79 | 80 | #define BADCH (int)'?' 81 | #define BADARG (int)':' 82 | #define EMSG "" 83 | 84 | /* 85 | * getopt -- 86 | * Parse argc/argv argument vector. 87 | */ 88 | int 89 | getopt(int nargc, char * nargv[], const char *ostr) 90 | { 91 | static char *__progname = 0; 92 | static char *place = EMSG; /* option letter processing */ 93 | const char *oli; /* option letter list index */ 94 | __progname = __progname?__progname:_progname(*nargv); 95 | 96 | _DIAGASSERT(nargv != NULL); 97 | _DIAGASSERT(ostr != NULL); 98 | 99 | if (optreset || !*place) { /* update scanning pointer */ 100 | optreset = 0; 101 | if (optind >= nargc || *(place = nargv[optind]) != '-') { 102 | place = EMSG; 103 | return (-1); 104 | } 105 | if (place[1] && *++place == '-' /* found "--" */ 106 | && place[1] == '\0') { 107 | ++optind; 108 | place = EMSG; 109 | return (-1); 110 | } 111 | } /* option letter okay? */ 112 | if ((optopt = (int)*place++) == (int)':' || 113 | !(oli = strchr(ostr, optopt))) { 114 | /* 115 | * if the user didn't specify '-' as an option, 116 | * assume it means -1. 117 | */ 118 | if (optopt == (int)'-') 119 | return (-1); 120 | if (!*place) 121 | ++optind; 122 | if (opterr && *ostr != ':') 123 | (void)fprintf(stderr, 124 | "%s: illegal option -- %c\n", __progname, optopt); 125 | return (BADCH); 126 | } 127 | if (*++oli != ':') { /* don't need argument */ 128 | optarg = NULL; 129 | if (!*place) 130 | ++optind; 131 | } 132 | else { /* need an argument */ 133 | if (*place) /* no white space */ 134 | optarg = place; 135 | else if (nargc <= ++optind) { /* no arg */ 136 | place = EMSG; 137 | if (*ostr == ':') 138 | return (BADARG); 139 | if (opterr) 140 | (void)fprintf(stderr, 141 | "%s: option requires an argument -- %c\n", 142 | __progname, optopt); 143 | return (BADCH); 144 | } 145 | else /* white space */ 146 | optarg = nargv[optind]; 147 | place = EMSG; 148 | ++optind; 149 | } 150 | return (optopt); /* dump back option letter */ 151 | } 152 | 153 | #ifdef __cplusplus 154 | } 155 | #endif 156 | -------------------------------------------------------------------------------- /extra/getopt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1987, 1993, 1994, 1996 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | */ 33 | #ifndef __GETOPT_H__ 34 | #define __GETOPT_H__ 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | extern int opterr; /* if error message should be printed */ 41 | extern int optind; /* index into parent argv vector */ 42 | extern int optopt; /* character checked for validity */ 43 | extern int optreset; /* reset getopt */ 44 | extern char *optarg; /* argument associated with option */ 45 | 46 | struct option 47 | { 48 | const char *name; 49 | int has_arg; 50 | int *flag; 51 | int val; 52 | }; 53 | 54 | #define no_argument 0 55 | #define required_argument 1 56 | #define optional_argument 2 57 | 58 | int getopt(int, char**, char*); 59 | int getopt_long(int, char**, char*, struct option*, int*); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif /* __GETOPT_H__ */ 66 | -------------------------------------------------------------------------------- /fuzzing/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = \ 2 | corpus/*.heic \ 3 | dictionary.txt 4 | -------------------------------------------------------------------------------- /fuzzing/corpus/clap-overflow-divide-zero.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/clap-overflow-divide-zero.heic -------------------------------------------------------------------------------- /fuzzing/corpus/clusterfuzz-testcase-minimized-color-conversion-fuzzer-6275694804467712: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/clusterfuzz-testcase-minimized-color-conversion-fuzzer-6275694804467712 -------------------------------------------------------------------------------- /fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-4616081830051840.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-4616081830051840.heic -------------------------------------------------------------------------------- /fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5120279175102464.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5120279175102464.heic -------------------------------------------------------------------------------- /fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5643900194127872.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5643900194127872.heic -------------------------------------------------------------------------------- /fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5651556035198976.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5651556035198976.heic -------------------------------------------------------------------------------- /fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5662360964956160.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5662360964956160.heic -------------------------------------------------------------------------------- /fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5671864958976000.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5671864958976000.heic -------------------------------------------------------------------------------- /fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5686319331672064.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5686319331672064.heic -------------------------------------------------------------------------------- /fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5718632116518912.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5718632116518912.heic -------------------------------------------------------------------------------- /fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5720856641142784.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5720856641142784.heic -------------------------------------------------------------------------------- /fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5724458239655936.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5724458239655936.heic -------------------------------------------------------------------------------- /fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5732616832024576.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5732616832024576.heic -------------------------------------------------------------------------------- /fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5752063708495872.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5752063708495872.heic -------------------------------------------------------------------------------- /fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5757633845264384.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-5757633845264384.heic -------------------------------------------------------------------------------- /fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-6045213633282048.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/clusterfuzz-testcase-minimized-file-fuzzer-6045213633282048.heic -------------------------------------------------------------------------------- /fuzzing/corpus/colors-no-alpha-thumbnail.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/colors-no-alpha-thumbnail.heic -------------------------------------------------------------------------------- /fuzzing/corpus/colors-no-alpha.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/colors-no-alpha.heic -------------------------------------------------------------------------------- /fuzzing/corpus/colors-with-alpha-thumbnail.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/colors-with-alpha-thumbnail.heic -------------------------------------------------------------------------------- /fuzzing/corpus/colors-with-alpha.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/colors-with-alpha.heic -------------------------------------------------------------------------------- /fuzzing/corpus/github_138.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/github_138.heic -------------------------------------------------------------------------------- /fuzzing/corpus/github_15.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/github_15.heic -------------------------------------------------------------------------------- /fuzzing/corpus/github_20.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/github_20.heic -------------------------------------------------------------------------------- /fuzzing/corpus/github_367_1.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/github_367_1.heic -------------------------------------------------------------------------------- /fuzzing/corpus/github_367_2.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/github_367_2.heic -------------------------------------------------------------------------------- /fuzzing/corpus/github_44.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/github_44.heic -------------------------------------------------------------------------------- /fuzzing/corpus/github_45.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/github_45.heic -------------------------------------------------------------------------------- /fuzzing/corpus/github_46_1.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/github_46_1.heic -------------------------------------------------------------------------------- /fuzzing/corpus/github_46_2.heic: -------------------------------------------------------------------------------- 1 | iprpiprp -------------------------------------------------------------------------------- /fuzzing/corpus/github_47.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/github_47.heic -------------------------------------------------------------------------------- /fuzzing/corpus/github_48.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/github_48.heic -------------------------------------------------------------------------------- /fuzzing/corpus/github_49.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/github_49.heic -------------------------------------------------------------------------------- /fuzzing/corpus/github_50.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/github_50.heic -------------------------------------------------------------------------------- /fuzzing/corpus/hbo_heif_context.h_126_1.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/hbo_heif_context.h_126_1.heic -------------------------------------------------------------------------------- /fuzzing/corpus/uaf_heif_context.h_117_1.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pphh77/libheif-Windowsbinary/2275b1035575d47fe3f614bb20f8f28a85e27edb/fuzzing/corpus/uaf_heif_context.h_117_1.heic -------------------------------------------------------------------------------- /fuzzing/dictionary.txt: -------------------------------------------------------------------------------- 1 | "auxC" 2 | "auxl" 3 | "av1C" 4 | "avif" 5 | "cdsc" 6 | "clap" 7 | "colr" 8 | "dimg" 9 | "dinf" 10 | "dref" 11 | "ftyp" 12 | "grpl" 13 | "hdlr" 14 | "heic" 15 | "heix" 16 | "hevc" 17 | "hevx" 18 | "heim" 19 | "heis" 20 | "hevm" 21 | "hevs" 22 | "hvcC" 23 | "idat" 24 | "iinf" 25 | "iloc" 26 | "imir" 27 | "infe" 28 | "ipco" 29 | "ipma" 30 | "iprp" 31 | "iref" 32 | "irot" 33 | "ispe" 34 | "mdat" 35 | "meta" 36 | "mif1" 37 | "mime" 38 | "msf1" 39 | "nclx" 40 | "pict" 41 | "pitm" 42 | "pixi" 43 | "prof" 44 | "rICC" 45 | "thmb" 46 | "uri " 47 | "url " 48 | "uuid" 49 | -------------------------------------------------------------------------------- /gdk-pixbuf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(UNIX) 2 | find_package(PkgConfig) 3 | find_package(Threads) 4 | pkg_check_modules(GDKPIXBUF2 gdk-pixbuf-2.0) 5 | 6 | if(GDKPIXBUF2_FOUND) 7 | execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} gdk-pixbuf-2.0 --variable gdk_pixbuf_moduledir --define-variable=prefix=${CMAKE_INSTALL_PREFIX} OUTPUT_VARIABLE GDKPIXBUF2_MODULE_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) 8 | 9 | add_library(pixbufloader-heif MODULE pixbufloader-heif.c) 10 | 11 | target_include_directories(pixbufloader-heif 12 | PRIVATE 13 | ${GDKPIXBUF2_INCLUDE_DIRS} 14 | ${libheif_BINARY_DIR} 15 | ${libheif_SOURCE_DIR}) 16 | target_link_libraries(pixbufloader-heif PUBLIC ${GDKPIXBUF2_LIBRARIES} heif) 17 | 18 | install(TARGETS pixbufloader-heif LIBRARY DESTINATION ${GDKPIXBUF2_MODULE_DIR}) 19 | endif() 20 | endif() 21 | -------------------------------------------------------------------------------- /gdk-pixbuf/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = subdir-objects 2 | 3 | gdk_pixbuf_module_LTLIBRARIES = 4 | 5 | if HAVE_GDKPIXBUF2 6 | gdk_pixbuf_module_LTLIBRARIES += libpixbufloader-heif.la 7 | libpixbufloader_heif_la_DEPENDENCIES = ../libheif/libheif.la 8 | libpixbufloader_heif_la_CFLAGS = -I$(top_srcdir) -I$(top_builddir) $(gdkpixbuf_CFLAGS) 9 | libpixbufloader_heif_la_LIBADD = ../libheif/libheif.la $(gdkpixbuf_LIBS) 10 | libpixbufloader_heif_la_LDFLAGS = -avoid-version -module 11 | libpixbufloader_heif_la_SOURCES = pixbufloader-heif.c 12 | endif 13 | 14 | EXTRA_DIST = CMakeLists.txt 15 | -------------------------------------------------------------------------------- /gnome/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | install(FILES heif.thumbnailer DESTINATION ${CMAKE_INSTALL_DATADIR}/thumbnailers) 2 | install(FILES avif.xml heif.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/mime/packages) 3 | -------------------------------------------------------------------------------- /gnome/Makefile.am: -------------------------------------------------------------------------------- 1 | thumbnailer_dir = $(datadir)/thumbnailers 2 | thumbnailer__DATA = heif.thumbnailer 3 | 4 | mime_dir = $(datadir)/mime/packages 5 | mime__DATA = heif.xml avif.xml 6 | 7 | EXTRA_DIST = \ 8 | CMakeLists.txt \ 9 | heif.thumbnailer \ 10 | heif.xml \ 11 | avif.xml 12 | -------------------------------------------------------------------------------- /gnome/avif.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AVIF image 5 | AVIF-Bild 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /gnome/heif.thumbnailer: -------------------------------------------------------------------------------- 1 | [Thumbnailer Entry] 2 | TryExec=heif-thumbnailer 3 | Exec=heif-thumbnailer -s %s %i %o 4 | MimeType=image/heif;image/avif; 5 | -------------------------------------------------------------------------------- /gnome/heif.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | HEIF image 5 | HEIF-Bild 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /go/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = \ 2 | heif/heif.go \ 3 | heif/heif_test.go 4 | 5 | gopath: 6 | ln -sf ${CURDIR} ${CURDIR}/src 7 | 8 | if HAVE_GO 9 | test-go: gopath $(top_builddir)/libheif/libheif.la $(top_builddir)/libheif.pc 10 | GOPATH=${CURDIR} PKG_CONFIG_PATH=$(abs_top_builddir):$(abs_top_builddir)/libde265/dist/lib/pkgconfig/ CGO_CFLAGS="-I$(abs_top_builddir)" CGO_LDFLAGS="-L$(abs_top_builddir)/libheif/.libs" LD_LIBRARY_PATH=$(abs_top_builddir)/libheif/.libs $(GO) test -v heif 11 | 12 | format-go: gopath 13 | GOPATH=${CURDIR} $(GO) fmt heif 14 | else 15 | test-go: 16 | echo ""go" not present in "${PATH}", skipping tests" 17 | 18 | format-go: 19 | echo ""go" not present in "${PATH}", skipping formatting" 20 | endif 21 | 22 | test-local: test-go 23 | 24 | format-local: format-go 25 | -------------------------------------------------------------------------------- /libheif.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | builtin_h265_decoder=@have_libde265@ 6 | builtin_h265_encoder=@have_x265@ 7 | builtin_avif_decoder=@have_avif_decoder@ 8 | builtin_avif_encoder=@have_avif_encoder@ 9 | 10 | Name: libheif 11 | Description: HEIF image codec. 12 | URL: https://github.com/strukturag/libheif 13 | Version: @VERSION@ 14 | Requires: 15 | Requires.private: @REQUIRES_PRIVATE@ 16 | Libs: -L@libdir@ -lheif 17 | Libs.private: @LIBS@ -lstdc++ 18 | Cflags: -I@includedir@ 19 | -------------------------------------------------------------------------------- /libheif/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(CMakePackageConfigHelpers) 2 | 3 | configure_file(heif_version.h.in ${CMAKE_CURRENT_BINARY_DIR}/heif_version.h) 4 | 5 | set(libheif_headers 6 | heif.h 7 | heif_cxx.h 8 | heif_plugin.h 9 | ${CMAKE_CURRENT_BINARY_DIR}/heif_version.h) 10 | 11 | add_library(heif 12 | bitstream.cc 13 | box.cc 14 | error.cc 15 | heif.cc 16 | heif_context.cc 17 | heif_file.cc 18 | heif_image.cc 19 | heif_hevc.cc 20 | heif_avif.cc 21 | heif_colorconversion.cc 22 | heif_plugin_registry.cc 23 | heif_plugin.cc 24 | nclx.cc 25 | bitstream.h 26 | box.h 27 | error.h 28 | heif_api_structs.h 29 | heif_context.h 30 | heif_file.h 31 | heif_image.h 32 | heif_hevc.h 33 | heif_avif.h 34 | heif_colorconversion.h 35 | heif_plugin_registry.h 36 | heif_limits.h 37 | heif_init.cc heif_init.h 38 | nclx.h 39 | logging.h 40 | metadata_compression.cc 41 | metadata_compression.h 42 | ${libheif_headers} 43 | ) 44 | 45 | # Needed to find libheif/heif_version.h while compiling the library 46 | target_include_directories(heif PRIVATE ${libheif_BINARY_DIR} ${libheif_SOURCE_DIR}) 47 | 48 | # Propagate include/libheif to consume the headers from other projects 49 | target_include_directories(heif 50 | PUBLIC 51 | $ 52 | $ 53 | $) 54 | 55 | set_target_properties(heif 56 | PROPERTIES 57 | VERSION ${PROJECT_VERSION} 58 | SOVERSION ${PROJECT_VERSION_MAJOR}) 59 | 60 | target_compile_definitions(heif 61 | PUBLIC 62 | LIBHEIF_EXPORTS 63 | HAVE_VISIBILITY) 64 | 65 | add_subdirectory(plugins) 66 | 67 | if (ENABLE_PLUGIN_LOADING AND UNIX) 68 | target_compile_definitions(heif PRIVATE ENABLE_PLUGIN_LOADING=1) 69 | target_link_libraries(heif PRIVATE dl) 70 | endif() 71 | 72 | if (WITH_DEFLATE_HEADER_COMPRESSION) 73 | find_library(z-lib z) 74 | target_link_libraries(heif PRIVATE ${z-lib}) 75 | target_compile_definitions(heif PRIVATE WITH_DEFLATE_HEADER_COMPRESSION=1) 76 | endif () 77 | 78 | write_basic_package_version_file(${PROJECT_NAME}-config-version.cmake COMPATIBILITY ExactVersion) 79 | 80 | install(TARGETS heif EXPORT ${PROJECT_NAME}-config 81 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 82 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 83 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 84 | ) 85 | 86 | install(FILES ${libheif_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) 87 | 88 | install(EXPORT ${PROJECT_NAME}-config DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") 89 | 90 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake DESTINATION 91 | "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") 92 | -------------------------------------------------------------------------------- /libheif/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = subdir-objects 2 | 3 | bin_PROGRAMS = 4 | lib_LTLIBRARIES = 5 | 6 | lib_LTLIBRARIES += libheif.la 7 | 8 | libheif_ladir = \ 9 | $(includedir)/libheif 10 | 11 | ADDITIONAL_LIBS = 12 | if HAVE_AOM 13 | ADDITIONAL_LIBS += $(aom_LIBS) 14 | endif 15 | 16 | if HAVE_LIBDE265 17 | ADDITIONAL_LIBS += $(libde265_LIBS) 18 | endif 19 | 20 | if HAVE_X265 21 | ADDITIONAL_LIBS += $(x265_LIBS) 22 | endif 23 | 24 | if HAVE_RAV1E 25 | ADDITIONAL_LIBS += $(rav1e_LIBS) 26 | endif 27 | 28 | if HAVE_DAV1D 29 | ADDITIONAL_LIBS += $(dav1d_LIBS) 30 | endif 31 | 32 | if HAVE_SvtEnc 33 | ADDITIONAL_LIBS += $(svt_LIBS) 34 | endif 35 | 36 | libheif_la_CPPFLAGS = 37 | libheif_la_CFLAGS = \ 38 | $(CFLAG_VISIBILITY) \ 39 | -DLIBHEIF_EXPORTS 40 | libheif_la_CXXFLAGS = \ 41 | $(CFLAG_VISIBILITY) \ 42 | $(aom_CFLAGS) \ 43 | $(libde265_CFLAGS) \ 44 | $(x265_CFLAGS) \ 45 | $(dav1d_CFLAGS) \ 46 | $(rav1e_CFLAGS) \ 47 | $(svt_CFLAGS) \ 48 | -DLIBHEIF_EXPORTS -I$(top_srcdir) 49 | libheif_la_LIBADD = $(ADDITIONAL_LIBS) 50 | 51 | libheif_la_LDFLAGS = -version-info $(LIBHEIF_CURRENT):$(LIBHEIF_REVISION):$(LIBHEIF_AGE) 52 | if MINGW 53 | libheif_la_LDFLAGS += -no-undefined 54 | endif 55 | 56 | libheif_la_SOURCES = \ 57 | bitstream.h \ 58 | bitstream.cc \ 59 | box.h \ 60 | box.cc \ 61 | error.h \ 62 | error.cc \ 63 | heif_api_structs.h \ 64 | heif_file.h \ 65 | heif_file.cc \ 66 | heif_image.h \ 67 | heif_image.cc \ 68 | heif_limits.h \ 69 | heif.h \ 70 | heif.cc \ 71 | heif_context.h \ 72 | heif_context.cc \ 73 | heif_hevc.h \ 74 | heif_hevc.cc \ 75 | heif_init.h \ 76 | heif_init.cc \ 77 | heif_avif.h \ 78 | heif_avif.cc \ 79 | heif_plugin_registry.h \ 80 | heif_plugin_registry.cc \ 81 | heif_plugin.h \ 82 | heif_plugin.cc \ 83 | heif_colorconversion.h \ 84 | heif_colorconversion.cc \ 85 | logging.h \ 86 | metadata_compression.h \ 87 | metadata_compression.cc \ 88 | nclx.cc \ 89 | nclx.h 90 | 91 | if HAVE_AOM_DECODER 92 | libheif_la_SOURCES += \ 93 | plugins/heif_decoder_aom.cc \ 94 | plugins/heif_decoder_aom.h 95 | endif 96 | 97 | if HAVE_AOM_ENCODER 98 | libheif_la_SOURCES += \ 99 | plugins/heif_encoder_aom.cc \ 100 | plugins/heif_encoder_aom.h 101 | endif 102 | 103 | if HAVE_LIBDE265 104 | libheif_la_SOURCES += \ 105 | plugins/heif_decoder_libde265.cc \ 106 | plugins/heif_decoder_libde265.h 107 | endif 108 | 109 | if HAVE_RAV1E 110 | libheif_la_SOURCES += \ 111 | plugins/heif_encoder_rav1e.cc \ 112 | plugins/heif_encoder_rav1e.h 113 | endif 114 | 115 | if HAVE_DAV1D 116 | libheif_la_SOURCES += \ 117 | plugins/heif_decoder_dav1d.cc \ 118 | plugins/heif_decoder_dav1d.h 119 | endif 120 | 121 | if HAVE_SvtEnc 122 | libheif_la_SOURCES += \ 123 | plugins/heif_encoder_svt.cc \ 124 | plugins/heif_encoder_svt.h 125 | endif 126 | 127 | 128 | if HAVE_X265 129 | libheif_la_SOURCES += \ 130 | plugins/heif_encoder_x265.cc \ 131 | plugins/heif_encoder_x265.h 132 | endif 133 | 134 | libheif_la_HEADERS = \ 135 | heif.h \ 136 | heif_plugin.h \ 137 | heif_version.h \ 138 | heif_cxx.h 139 | 140 | noinst_HEADERS = \ 141 | heif_emscripten.h 142 | 143 | if HAVE_VISIBILITY 144 | libheif_la_CFLAGS += -DHAVE_VISIBILITY 145 | libheif_la_CXXFLAGS += -DHAVE_VISIBILITY 146 | endif 147 | 148 | if ENABLE_LIBFUZZER 149 | bin_PROGRAMS += box-fuzzer \ 150 | color-conversion-fuzzer 151 | if HAVE_LIBDE265 152 | bin_PROGRAMS += file-fuzzer 153 | endif 154 | if HAVE_X265 155 | bin_PROGRAMS += encoder-fuzzer 156 | endif 157 | else 158 | noinst_LIBRARIES = libfuzzers.a 159 | libfuzzers_a_SOURCES = \ 160 | box_fuzzer.cc \ 161 | color_conversion_fuzzer.cc \ 162 | encoder_fuzzer.cc \ 163 | file_fuzzer.cc 164 | endif 165 | 166 | box_fuzzer_DEPENDENCIES = 167 | box_fuzzer_CXXFLAGS = $(libde265_CFLAGS) 168 | box_fuzzer_LDFLAGS = $(FUZZING_ENGINE) 169 | box_fuzzer_LDADD = $(ADDITIONAL_LIBS) 170 | box_fuzzer_SOURCES = $(libheif_la_SOURCES) box_fuzzer.cc 171 | 172 | color_conversion_fuzzer_DEPENDENCIES = 173 | color_conversion_fuzzer_CXXFLAGS = $(libde265_CFLAGS) 174 | color_conversion_fuzzer_LDFLAGS = $(FUZZING_ENGINE) 175 | color_conversion_fuzzer_LDADD = $(ADDITIONAL_LIBS) 176 | color_conversion_fuzzer_SOURCES = $(libheif_la_SOURCES) color_conversion_fuzzer.cc 177 | 178 | encoder_fuzzer_DEPENDENCIES = 179 | encoder_fuzzer_CXXFLAGS = $(libde265_CFLAGS) 180 | encoder_fuzzer_LDFLAGS = $(FUZZING_ENGINE) 181 | encoder_fuzzer_LDADD = $(ADDITIONAL_LIBS) 182 | encoder_fuzzer_SOURCES = $(libheif_la_SOURCES) encoder_fuzzer.cc 183 | 184 | file_fuzzer_DEPENDENCIES = 185 | file_fuzzer_CXXFLAGS = $(libde265_CFLAGS) 186 | file_fuzzer_LDFLAGS = $(FUZZING_ENGINE) 187 | file_fuzzer_LDADD = $(ADDITIONAL_LIBS) 188 | file_fuzzer_SOURCES = $(libheif_la_SOURCES) file_fuzzer.cc 189 | 190 | EXTRA_DIST = \ 191 | CMakeLists.txt \ 192 | plugins/CMakeLists.txt 193 | -------------------------------------------------------------------------------- /libheif/box_fuzzer.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2017 struktur AG, Joachim Bauch 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | #include 22 | 23 | #include "box.h" 24 | #include "bitstream.h" 25 | #include "logging.h" 26 | 27 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) 28 | { 29 | auto reader = std::make_shared(data, size, false); 30 | 31 | heif::BitstreamRange range(reader, size); 32 | for (;;) { 33 | std::shared_ptr box; 34 | heif::Error error = heif::Box::read(range, &box); 35 | if (error != heif::Error::Ok || range.error()) { 36 | break; 37 | } 38 | 39 | box->get_type(); 40 | box->get_type_string(); 41 | heif::Indent indent; 42 | box->dump(indent); 43 | } 44 | 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /libheif/error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2017 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | #ifndef LIBHEIF_ERROR_H 22 | #define LIBHEIF_ERROR_H 23 | 24 | #if defined(HAVE_CONFIG_H) 25 | #include "config.h" 26 | #endif 27 | 28 | #include 29 | #include 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | 40 | #include "heif.h" 41 | 42 | 43 | static constexpr char kSuccess[] = "Success"; 44 | 45 | 46 | namespace heif { 47 | 48 | class ErrorBuffer 49 | { 50 | public: 51 | ErrorBuffer() = default; 52 | 53 | void set_success() 54 | { 55 | m_error_message = c_success; 56 | } 57 | 58 | void set_error(const std::string& err) 59 | { 60 | m_buffer = err; 61 | m_error_message = m_buffer.c_str(); 62 | } 63 | 64 | const char* get_error() const 65 | { 66 | return m_error_message; 67 | } 68 | 69 | private: 70 | constexpr static const char* c_success = "Success"; 71 | std::string m_buffer; 72 | const char* m_error_message = c_success; 73 | }; 74 | 75 | 76 | class Error 77 | { 78 | public: 79 | enum heif_error_code error_code = heif_error_Ok; 80 | enum heif_suberror_code sub_error_code = heif_suberror_Unspecified; 81 | std::string message; 82 | 83 | Error(); 84 | 85 | Error(heif_error_code c, 86 | heif_suberror_code sc = heif_suberror_Unspecified, 87 | const std::string& msg = ""); 88 | 89 | static Error Ok; 90 | 91 | static const char kSuccess[]; 92 | 93 | bool operator==(const Error& other) const 94 | { return error_code == other.error_code; } 95 | 96 | bool operator!=(const Error& other) const 97 | { return !(*this == other); } 98 | 99 | operator bool() const 100 | { return error_code != heif_error_Ok; } 101 | 102 | static const char* get_error_string(heif_error_code err); 103 | 104 | static const char* get_error_string(heif_suberror_code err); 105 | 106 | heif_error error_struct(ErrorBuffer* error_buffer) const; 107 | }; 108 | 109 | 110 | inline std::ostream& operator<<(std::ostream& ostr, const Error& err) 111 | { 112 | ostr << err.error_code << "/" << err.sub_error_code; 113 | return ostr; 114 | } 115 | } 116 | 117 | #endif 118 | -------------------------------------------------------------------------------- /libheif/exif.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2022 Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | #include 22 | #include "exif.h" 23 | 24 | #define EXIF_TYPE_SHORT 3 25 | #define DEFAULT_EXIF_ORIENTATION 1 26 | #define EXIF_TAG_ORIENTATION 0x112 27 | 28 | 29 | static int32_t read32(const uint8_t* data, int size, int pos, bool littleEndian) 30 | { 31 | if (pos + 4 > size) { 32 | return -1; 33 | } 34 | 35 | const uint8_t* p = data + pos; 36 | 37 | if (littleEndian) { 38 | return (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]; 39 | } 40 | else { 41 | return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; 42 | } 43 | } 44 | 45 | 46 | static int32_t read16(const uint8_t* data, int size, int pos, bool littleEndian) 47 | { 48 | if (pos + 2 > size) { 49 | return -1; 50 | } 51 | 52 | const uint8_t* p = data + pos; 53 | 54 | if (littleEndian) { 55 | return (p[1] << 8) | p[0]; 56 | } 57 | else { 58 | return (p[0] << 8) | p[1]; 59 | } 60 | } 61 | 62 | 63 | static void write16(uint8_t* data, int size, int pos, uint16_t value, bool littleEndian) 64 | { 65 | if (pos + 2 > size) { 66 | return; 67 | } 68 | 69 | uint8_t* p = data + pos; 70 | 71 | if (littleEndian) { 72 | p[0] = (uint8_t) (value & 0xFF); 73 | p[1] = (uint8_t) (value >> 8); 74 | } 75 | else { 76 | p[0] = (uint8_t) (value >> 8); 77 | p[1] = (uint8_t) (value & 0xFF); 78 | } 79 | } 80 | 81 | 82 | static int find_exif_tag(const uint8_t* exif, int size, uint16_t query_tag, bool* out_littleEndian) 83 | { 84 | if (size < 4) { 85 | return -1; 86 | } 87 | 88 | if ((exif[0] != 'I' && exif[0] != 'M') || 89 | (exif[1] != 'I' && exif[1] != 'M')) { 90 | return -1; 91 | } 92 | 93 | bool littleEndian = (exif[0] == 'I'); 94 | 95 | assert(out_littleEndian); 96 | *out_littleEndian = littleEndian; 97 | 98 | int offset = read32(exif, size, 4, littleEndian); 99 | if (offset < 0) { 100 | return -1; 101 | } 102 | 103 | int cnt = read16(exif, size, offset, littleEndian); 104 | if (cnt < 1) { 105 | return -1; 106 | } 107 | 108 | for (int i = 0; i < cnt; i++) { 109 | int tag = read16(exif, size, offset + 2 + i * 12, littleEndian); 110 | if (tag == query_tag) { 111 | return offset + 2 + i * 12; 112 | } 113 | } 114 | 115 | // TODO: do we have to also scan the next IFD table ? 116 | 117 | return -1; 118 | } 119 | 120 | 121 | void modify_exif_tag_if_it_exists(uint8_t* exif, int size, uint16_t modify_tag, uint16_t modify_value) 122 | { 123 | bool little_endian; 124 | int pos = find_exif_tag(exif, size, modify_tag, &little_endian); 125 | if (pos < 0) { 126 | return; 127 | } 128 | 129 | int type = read16(exif, size, pos + 2, little_endian); 130 | int count = read32(exif, size, pos + 4, little_endian); 131 | 132 | if (type == EXIF_TYPE_SHORT && count == 1) { 133 | write16(exif, size, pos + 8, modify_value, little_endian); 134 | } 135 | } 136 | 137 | 138 | void modify_exif_orientation_tag_if_it_exists(uint8_t* exifData, int size, uint16_t orientation) 139 | { 140 | modify_exif_tag_if_it_exists(exifData, size, EXIF_TAG_ORIENTATION, orientation); 141 | } 142 | 143 | 144 | int read_exif_orientation_tag(const uint8_t* exif, int size) 145 | { 146 | bool little_endian; 147 | int pos = find_exif_tag(exif, size, EXIF_TAG_ORIENTATION, &little_endian); 148 | if (pos < 0) { 149 | return DEFAULT_EXIF_ORIENTATION; 150 | } 151 | 152 | int type = read16(exif, size, pos + 2, little_endian); 153 | int count = read32(exif, size, pos + 4, little_endian); 154 | 155 | if (type == EXIF_TYPE_SHORT && count == 1) { 156 | return read16(exif, size, pos + 8, little_endian); 157 | } 158 | 159 | return DEFAULT_EXIF_ORIENTATION; 160 | } -------------------------------------------------------------------------------- /libheif/exif.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2022 Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | #ifndef LIBHEIF_EXIF_H 22 | #define LIBHEIF_EXIF_H 23 | 24 | #include 25 | #include 26 | 27 | int read_exif_orientation_tag(const uint8_t* exif, int size); 28 | 29 | void modify_exif_orientation_tag_if_it_exists(uint8_t* exifData, int size, uint16_t orientation); 30 | 31 | #endif //LIBHEIF_EXIF_H 32 | -------------------------------------------------------------------------------- /libheif/heif_api_structs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2017 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | #ifndef HEIF_API_STRUCTS_H 22 | #define HEIF_API_STRUCTS_H 23 | 24 | #include "heif_image.h" 25 | #include "heif_context.h" 26 | 27 | #include 28 | 29 | struct heif_image_handle 30 | { 31 | std::shared_ptr image; 32 | 33 | // store reference to keep the context alive while we are using the handle (issue #147) 34 | std::shared_ptr context; 35 | }; 36 | 37 | 38 | struct heif_image 39 | { 40 | std::shared_ptr image; 41 | }; 42 | 43 | 44 | struct heif_context 45 | { 46 | std::shared_ptr context; 47 | }; 48 | 49 | 50 | struct heif_encoder 51 | { 52 | heif_encoder(const struct heif_encoder_plugin* plugin); 53 | 54 | ~heif_encoder(); 55 | 56 | struct heif_error alloc(); 57 | 58 | void release(); 59 | 60 | 61 | const struct heif_encoder_plugin* plugin; 62 | void* encoder = nullptr; 63 | }; 64 | 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /libheif/heif_avif.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2017 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | #ifndef HEIF_AVIF_H 22 | #define HEIF_AVIF_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include "heif.h" 29 | #include "box.h" 30 | #include "error.h" 31 | 32 | 33 | namespace heif { 34 | 35 | class HeifPixelImage; 36 | 37 | Error fill_av1C_configuration(Box_av1C::configuration* inout_config, const std::shared_ptr& image); 38 | 39 | bool fill_av1C_configuration_from_stream(Box_av1C::configuration* out_config, const uint8_t* data, int dataSize); 40 | 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /libheif/heif_colorconversion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2017 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | 22 | #include "heif_image.h" 23 | #include 24 | #include 25 | 26 | 27 | namespace heif { 28 | 29 | struct ColorState 30 | { 31 | heif_colorspace colorspace = heif_colorspace_undefined; 32 | heif_chroma chroma = heif_chroma_undefined; 33 | bool has_alpha = false; 34 | int bits_per_pixel = 8; 35 | std::shared_ptr nclx_profile; 36 | 37 | ColorState() = default; 38 | 39 | ColorState(heif_colorspace colorspace, heif_chroma chroma, bool has_alpha, int bits_per_pixel) 40 | : colorspace(colorspace), chroma(chroma), has_alpha(has_alpha), bits_per_pixel(bits_per_pixel) 41 | {} 42 | 43 | bool operator==(const ColorState&) const; 44 | }; 45 | 46 | 47 | enum class ColorConversionCriterion 48 | { 49 | Speed, 50 | Quality, 51 | Memory, 52 | Balanced 53 | }; 54 | 55 | 56 | struct ColorConversionCosts 57 | { 58 | ColorConversionCosts() = default; 59 | 60 | ColorConversionCosts(float _speed, float _quality, float _memory) 61 | { 62 | speed = _speed; 63 | quality = _quality; 64 | memory = _memory; 65 | } 66 | 67 | float speed = 0; 68 | float quality = 0; 69 | float memory = 0; 70 | 71 | ColorConversionCosts operator+(const ColorConversionCosts& b) const 72 | { 73 | return {speed + b.speed, 74 | quality + b.quality, 75 | memory + b.memory}; 76 | } 77 | 78 | float total(ColorConversionCriterion) const 79 | { 80 | return speed * 0.3f + quality * 0.6f + memory * 0.1f; 81 | } 82 | }; 83 | 84 | 85 | struct ColorConversionOptions 86 | { 87 | ColorConversionCriterion criterion = ColorConversionCriterion::Balanced; 88 | }; 89 | 90 | 91 | struct ColorStateWithCost 92 | { 93 | ColorState color_state; 94 | ColorConversionCosts costs; 95 | }; 96 | 97 | 98 | class ColorConversionOperation 99 | { 100 | public: 101 | virtual ~ColorConversionOperation() = default; 102 | 103 | // We specify the target state to control the conversion into a direction that is most 104 | // suitable for reaching the target state. That allows one conversion operation to 105 | // provide a range of conversion options. 106 | // Also returns the cost for this conversion. 107 | virtual std::vector 108 | state_after_conversion(const ColorState& input_state, 109 | const ColorState& target_state, 110 | const ColorConversionOptions& options = ColorConversionOptions()) = 0; 111 | 112 | virtual std::shared_ptr 113 | convert_colorspace(const std::shared_ptr& input, 114 | const ColorState& target_state, 115 | const ColorConversionOptions& options = ColorConversionOptions()) = 0; 116 | }; 117 | 118 | 119 | class ColorConversionPipeline 120 | { 121 | public: 122 | bool construct_pipeline(const ColorState& input_state, 123 | const ColorState& target_state, 124 | const ColorConversionOptions& options = ColorConversionOptions()); 125 | 126 | std::shared_ptr 127 | convert_image(const std::shared_ptr& input); 128 | 129 | void debug_dump_pipeline() const; 130 | 131 | private: 132 | std::vector> m_operations; 133 | ColorState m_target_state; 134 | ColorConversionOptions m_options; 135 | }; 136 | 137 | 138 | std::shared_ptr convert_colorspace(const std::shared_ptr& input, 139 | heif_colorspace colorspace, 140 | heif_chroma chroma, 141 | const std::shared_ptr& target_profile, 142 | int output_bpp = 0); 143 | } 144 | -------------------------------------------------------------------------------- /libheif/heif_hevc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2017 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | #ifndef HEIF_HEVC_H 22 | #define HEIF_HEVC_H 23 | 24 | #include "heif.h" 25 | #include "box.h" 26 | #include "error.h" 27 | 28 | #include 29 | #include 30 | 31 | 32 | namespace heif { 33 | 34 | class SEIMessage 35 | { 36 | public: 37 | virtual ~SEIMessage() = default; 38 | }; 39 | 40 | 41 | class SEIMessage_depth_representation_info : public SEIMessage, 42 | public heif_depth_representation_info 43 | { 44 | public: 45 | }; 46 | 47 | 48 | Error decode_hevc_aux_sei_messages(const std::vector& data, 49 | std::vector>& msgs); 50 | 51 | 52 | Error parse_sps_for_hvcC_configuration(const uint8_t* sps, size_t size, 53 | Box_hvcC::configuration* inout_config, 54 | int* width, int* height); 55 | 56 | } 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /libheif/heif_init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2022 Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | 22 | #ifndef LIBHEIF_HEIF_INIT_H 23 | #define LIBHEIF_HEIF_INIT_H 24 | 25 | namespace heif { 26 | // TODO: later, we might defer the default plugin initialization to when they are actually used for the first time. 27 | // That would prevent them from being initialized every time at program start, even when the application software uses heif_init() later on. 28 | 29 | // void implicit_plugin_registration(); 30 | } 31 | 32 | #endif //LIBHEIF_HEIF_INIT_H 33 | -------------------------------------------------------------------------------- /libheif/heif_limits.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2018 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | #ifndef LIBHEIF_HEIF_LIMITS_H 21 | #define LIBHEIF_HEIF_LIMITS_H 22 | 23 | #if defined(HAVE_CONFIG_H) 24 | #include "config.h" 25 | #endif 26 | 27 | #include 28 | #include 29 | 30 | static const size_t MAX_CHILDREN_PER_BOX = 20000; 31 | static const int MAX_ILOC_ITEMS = 20000; 32 | static const int MAX_ILOC_EXTENTS_PER_ITEM = 32; 33 | static const int MAX_MEMORY_BLOCK_SIZE = 512 * 1024 * 1024; // 512 MB 34 | 35 | // Artificial limit to avoid allocating too much memory. 36 | // 32768^2 = 1.5 GB as YUV-4:2:0 or 4 GB as RGB32 37 | static const int MAX_IMAGE_WIDTH = 32768; 38 | static const int MAX_IMAGE_HEIGHT = 32768; 39 | 40 | // Maximum nesting level of boxes in input files. 41 | // We put a limit on this to avoid unlimited stack usage by malicious input files. 42 | static const int MAX_BOX_NESTING_LEVEL = 20; 43 | 44 | static const int MAX_BOX_SIZE = 0x7FFFFFFF; // 2 GB 45 | static const int64_t MAX_LARGE_BOX_SIZE = 0x0FFFFFFFFFFFFFFF; 46 | static const int64_t MAX_FILE_POS = 0x007FFFFFFFFFFFFFLL; // maximum file position 47 | static const int MAX_FRACTION_VALUE = 0x10000; 48 | 49 | #endif // LIBHEIF_HEIF_LIMITS_H 50 | -------------------------------------------------------------------------------- /libheif/heif_plugin.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2017 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | #include "heif.h" 22 | #include "heif_plugin.h" // needed to avoid 'unresolved symbols' on Visual Studio compiler 23 | 24 | struct heif_error heif_error_ok = {heif_error_Ok, heif_suberror_Unspecified, "Success"}; 25 | 26 | struct heif_error heif_error_unsupported_parameter = {heif_error_Usage_error, 27 | heif_suberror_Unsupported_parameter, 28 | "Unsupported encoder parameter"}; 29 | 30 | struct heif_error heif_error_invalid_parameter_value = {heif_error_Usage_error, 31 | heif_suberror_Invalid_parameter_value, 32 | "Invalid parameter value"}; 33 | 34 | 35 | -------------------------------------------------------------------------------- /libheif/heif_plugin_registry.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2017 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | #if defined(HAVE_CONFIG_H) 22 | #include "config.h" 23 | #endif 24 | 25 | #include 26 | #include 27 | 28 | #include "heif_plugin_registry.h" 29 | 30 | #if HAVE_LIBDE265 31 | #include "libheif/plugins/heif_decoder_libde265.h" 32 | #endif 33 | 34 | #if HAVE_X265 35 | #include "libheif/plugins/heif_encoder_x265.h" 36 | #endif 37 | 38 | #if HAVE_AOM_ENCODER 39 | #include "libheif/plugins/heif_encoder_aom.h" 40 | #endif 41 | 42 | #if HAVE_AOM_DECODER 43 | #include "libheif/plugins/heif_decoder_aom.h" 44 | #endif 45 | 46 | #if HAVE_RAV1E 47 | #include "libheif/plugins/heif_encoder_rav1e.h" 48 | #endif 49 | 50 | #if HAVE_DAV1D 51 | #include "libheif/plugins/heif_decoder_dav1d.h" 52 | #endif 53 | 54 | #if HAVE_SvtEnc 55 | #include "libheif/plugins/heif_encoder_svt.h" 56 | #endif 57 | 58 | 59 | using namespace heif; 60 | 61 | 62 | std::set heif::s_decoder_plugins; 63 | 64 | std::multiset, 65 | encoder_descriptor_priority_order> heif::s_encoder_descriptors; 66 | 67 | // Note: we cannot move this to 'heif_init' because we have to make sure that this is initialized 68 | // AFTER the two global std::set above. 69 | static class Register_Default_Plugins 70 | { 71 | public: 72 | Register_Default_Plugins() 73 | { 74 | register_default_plugins(); 75 | } 76 | } dummy; 77 | 78 | 79 | void heif::register_default_plugins() 80 | { 81 | #if HAVE_LIBDE265 82 | heif::register_decoder(get_decoder_plugin_libde265()); 83 | #endif 84 | 85 | #if HAVE_X265 86 | heif::register_encoder(get_encoder_plugin_x265()); 87 | #endif 88 | 89 | #if HAVE_AOM_ENCODER 90 | heif::register_encoder(get_encoder_plugin_aom()); 91 | #endif 92 | 93 | #if HAVE_AOM_DECODER 94 | heif::register_decoder(get_decoder_plugin_aom()); 95 | #endif 96 | 97 | #if HAVE_RAV1E 98 | heif::register_encoder(get_encoder_plugin_rav1e()); 99 | #endif 100 | 101 | #if HAVE_DAV1D 102 | heif::register_decoder(get_decoder_plugin_dav1d()); 103 | #endif 104 | 105 | #if HAVE_SvtEnc 106 | heif::register_encoder(get_encoder_plugin_svt()); 107 | #endif 108 | } 109 | 110 | 111 | void heif::register_decoder(const heif_decoder_plugin* decoder_plugin) 112 | { 113 | if (decoder_plugin->init_plugin) { 114 | (*decoder_plugin->init_plugin)(); 115 | } 116 | 117 | s_decoder_plugins.insert(decoder_plugin); 118 | } 119 | 120 | 121 | const struct heif_decoder_plugin* heif::get_decoder(enum heif_compression_format type) 122 | { 123 | int highest_priority = 0; 124 | const struct heif_decoder_plugin* best_plugin = nullptr; 125 | 126 | for (const auto* plugin : s_decoder_plugins) { 127 | int priority = plugin->does_support_format(type); 128 | if (priority > highest_priority) { 129 | highest_priority = priority; 130 | best_plugin = plugin; 131 | } 132 | } 133 | 134 | return best_plugin; 135 | } 136 | 137 | void heif::register_encoder(const heif_encoder_plugin* encoder_plugin) 138 | { 139 | if (encoder_plugin->init_plugin) { 140 | (*encoder_plugin->init_plugin)(); 141 | } 142 | 143 | auto descriptor = std::unique_ptr(new heif_encoder_descriptor); 144 | descriptor->plugin = encoder_plugin; 145 | 146 | s_encoder_descriptors.insert(std::move(descriptor)); 147 | } 148 | 149 | 150 | const struct heif_encoder_plugin* heif::get_encoder(enum heif_compression_format type) 151 | { 152 | auto filtered_encoder_descriptors = get_filtered_encoder_descriptors(type, nullptr); 153 | if (filtered_encoder_descriptors.size() > 0) { 154 | return filtered_encoder_descriptors[0]->plugin; 155 | } 156 | else { 157 | return nullptr; 158 | } 159 | } 160 | 161 | 162 | std::vector 163 | heif::get_filtered_encoder_descriptors(enum heif_compression_format format, 164 | const char* name) 165 | { 166 | std::vector filtered_descriptors; 167 | 168 | for (const auto& descr : s_encoder_descriptors) { 169 | const struct heif_encoder_plugin* plugin = descr->plugin; 170 | 171 | if (plugin->compression_format == format || format == heif_compression_undefined) { 172 | if (name == nullptr || strcmp(name, plugin->id_name) == 0) { 173 | filtered_descriptors.push_back(descr.get()); 174 | } 175 | } 176 | } 177 | 178 | 179 | // Note: since our std::set<> is ordered by priority, we do not have to sort our output 180 | 181 | return filtered_descriptors; 182 | } 183 | -------------------------------------------------------------------------------- /libheif/heif_plugin_registry.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2017 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | #ifndef LIBHEIF_HEIF_PLUGIN_REGISTRY_H 22 | #define LIBHEIF_HEIF_PLUGIN_REGISTRY_H 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "error.h" 31 | 32 | #include "heif.h" 33 | #include "heif_plugin.h" 34 | 35 | 36 | struct heif_encoder_descriptor 37 | { 38 | const struct heif_encoder_plugin* plugin; 39 | 40 | const char* get_name() const 41 | { return plugin->get_plugin_name(); } 42 | 43 | enum heif_compression_format get_compression_format() const 44 | { return plugin->compression_format; } 45 | }; 46 | 47 | 48 | namespace heif { 49 | struct encoder_descriptor_priority_order 50 | { 51 | bool operator()(const std::unique_ptr& a, 52 | const std::unique_ptr& b) const 53 | { 54 | return a->plugin->priority > b->plugin->priority; // highest priority first 55 | } 56 | }; 57 | 58 | 59 | extern std::set s_decoder_plugins; 60 | 61 | extern std::multiset, 62 | encoder_descriptor_priority_order> s_encoder_descriptors; 63 | 64 | void register_default_plugins(); 65 | 66 | void register_decoder(const heif_decoder_plugin* decoder_plugin); 67 | 68 | void register_encoder(const heif_encoder_plugin* encoder_plugin); 69 | 70 | const struct heif_decoder_plugin* get_decoder(enum heif_compression_format type); 71 | 72 | const struct heif_encoder_plugin* get_encoder(enum heif_compression_format type); 73 | 74 | std::vector 75 | get_filtered_encoder_descriptors(enum heif_compression_format, 76 | const char* name); 77 | } 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /libheif/heif_version.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2017 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | /* heif_version.h 22 | * 23 | * This file was generated by autoconf when libheif was built. 24 | * 25 | * DO NOT EDIT THIS FILE. 26 | */ 27 | #ifndef LIBHEIF_HEIF_VERSION_H 28 | #define LIBHEIF_HEIF_VERSION_H 29 | 30 | /* Numeric representation of the version */ 31 | #define LIBHEIF_NUMERIC_VERSION ((@PROJECT_VERSION_MAJOR@<<24) | (@PROJECT_VERSION_MINOR@<<16) | (@PROJECT_VERSION_PATCH@<<8) | @PROJECT_VERSION_TWEAK@) 32 | 33 | /* Version string */ 34 | #define LIBHEIF_VERSION "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@" 35 | 36 | #define LIBHEIF_PLUGIN_DIRECTORY "@PLUGIN_DIRECTORY@" 37 | 38 | #endif // LIBHEIF_HEIF_VERSION_H 39 | -------------------------------------------------------------------------------- /libheif/logging.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2017 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | #ifndef LIBHEIF_LOGGING_H 22 | #define LIBHEIF_LOGGING_H 23 | 24 | #if defined(HAVE_CONFIG_H) 25 | #include "config.h" 26 | #endif 27 | 28 | #include 29 | #include 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | 38 | namespace heif { 39 | 40 | class Indent 41 | { 42 | public: 43 | Indent() = default; 44 | 45 | int get_indent() const 46 | { return m_indent; } 47 | 48 | void operator++(int) 49 | { m_indent++; } 50 | 51 | void operator--(int) 52 | { 53 | m_indent--; 54 | if (m_indent < 0) m_indent = 0; 55 | } 56 | 57 | private: 58 | int m_indent = 0; 59 | }; 60 | 61 | 62 | inline std::ostream& operator<<(std::ostream& ostr, const Indent& indent) 63 | { 64 | for (int i = 0; i < indent.get_indent(); i++) { 65 | ostr << "| "; 66 | } 67 | 68 | return ostr; 69 | } 70 | } 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /libheif/metadata_compression.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2022 Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | 22 | #include "metadata_compression.h" 23 | 24 | 25 | #if WITH_DEFLATE_HEADER_COMPRESSION 26 | #include 27 | #include 28 | 29 | std::vector deflate(const uint8_t* input, int size) 30 | { 31 | std::vector output; 32 | 33 | // initialize compressor 34 | 35 | const int outBufferSize = 8192; 36 | uint8_t dst[outBufferSize]; 37 | 38 | z_stream strm; 39 | memset(&strm, 0, sizeof(z_stream)); 40 | 41 | strm.avail_in = size; 42 | strm.next_in = (Bytef*)input; 43 | 44 | strm.avail_out = outBufferSize; 45 | strm.next_out = (Bytef*) dst; 46 | 47 | strm.zalloc = Z_NULL; 48 | strm.zfree = Z_NULL; 49 | strm.opaque = Z_NULL; 50 | 51 | int err = deflateInit(&strm, Z_DEFAULT_COMPRESSION); 52 | if (err != Z_OK) { 53 | return {}; // TODO: return error 54 | } 55 | 56 | do { 57 | strm.next_out = dst; 58 | strm.avail_out = outBufferSize; 59 | 60 | err = deflate(&strm, Z_FINISH); 61 | if (err == Z_BUF_ERROR || err == Z_OK) { 62 | // this is the usual case when we run out of buffer space 63 | // -> do nothing 64 | } 65 | else if (err == Z_STREAM_ERROR) { 66 | return {}; // TODO: return error 67 | } 68 | 69 | 70 | // append decoded data to output 71 | 72 | output.insert(output.end(), dst, dst + outBufferSize - strm.avail_out); 73 | } while (err != Z_STREAM_END); 74 | 75 | deflateEnd(&strm); 76 | 77 | return output; 78 | } 79 | 80 | 81 | std::vector inflate(const std::vector& compressed_input) 82 | { 83 | std::vector output; 84 | 85 | // decompress data with zlib 86 | 87 | const int outBufferSize = 8192; 88 | uint8_t dst[outBufferSize]; 89 | 90 | z_stream strm; 91 | memset(&strm, 0, sizeof(z_stream)); 92 | 93 | strm.avail_in = (int)compressed_input.size(); 94 | strm.next_in = (Bytef*) compressed_input.data(); 95 | 96 | strm.avail_out = outBufferSize; 97 | strm.next_out = (Bytef*) dst; 98 | 99 | strm.zalloc = Z_NULL; 100 | strm.zfree = Z_NULL; 101 | strm.opaque = Z_NULL; 102 | 103 | int err = -1; 104 | 105 | err = inflateInit(&strm); 106 | if (err != Z_OK) { 107 | // TODO: return error 108 | return {}; 109 | } 110 | 111 | do { 112 | strm.next_out = dst; 113 | strm.avail_out = outBufferSize; 114 | 115 | err = inflate(&strm, Z_FINISH); 116 | if (err == Z_BUF_ERROR || err == Z_OK) { 117 | // this is the usual case when we run out of buffer space 118 | // -> do nothing 119 | } 120 | else if (err == Z_NEED_DICT || err == Z_DATA_ERROR || err == Z_STREAM_ERROR) { 121 | // TODO: return error 122 | return {}; 123 | } 124 | 125 | 126 | // append decoded data to output 127 | 128 | output.insert(output.end(), dst, dst + outBufferSize - strm.avail_out); 129 | } while (err != Z_STREAM_END); 130 | 131 | 132 | inflateEnd(&strm); 133 | 134 | return output; 135 | } 136 | #endif 137 | -------------------------------------------------------------------------------- /libheif/metadata_compression.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2022 Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | #ifndef LIBHEIF_METADATA_COMPRESSION_H 21 | #define LIBHEIF_METADATA_COMPRESSION_H 22 | 23 | #include 24 | #include 25 | 26 | #if WITH_DEFLATE_HEADER_COMPRESSION 27 | std::vector deflate(const uint8_t* input, int size); 28 | 29 | std::vector inflate(const std::vector&); 30 | #endif 31 | 32 | #endif //LIBHEIF_METADATA_COMPRESSION_H 33 | -------------------------------------------------------------------------------- /libheif/nclx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2020 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | #ifndef LIBHEIF_NCLX_H 22 | #define LIBHEIF_NCLX_H 23 | 24 | #include 25 | 26 | namespace heif { 27 | 28 | struct primaries 29 | { 30 | primaries() = default; 31 | 32 | primaries(float gx, float gy, float bx, float by, float rx, float ry, float wx, float wy); 33 | 34 | bool defined = false; 35 | 36 | float greenX=0, greenY=0; 37 | float blueX=0, blueY=0; 38 | float redX=0, redY=0; 39 | float whiteX=0, whiteY=0; 40 | }; 41 | 42 | primaries get_colour_primaries(uint16_t primaries_idx); 43 | 44 | 45 | struct Kr_Kb 46 | { 47 | float Kr = 0, Kb = 0; 48 | }; 49 | 50 | Kr_Kb get_Kr_Kb(uint16_t matrix_coefficients_idx, uint16_t primaries_idx); 51 | 52 | struct YCbCr_to_RGB_coefficients 53 | { 54 | bool defined = false; 55 | 56 | float r_cr = 0; 57 | float g_cb = 0; 58 | float g_cr = 0; 59 | float b_cb = 0; 60 | 61 | static YCbCr_to_RGB_coefficients defaults(); 62 | }; 63 | 64 | YCbCr_to_RGB_coefficients get_YCbCr_to_RGB_coefficients(uint16_t matrix_coefficients_idx, uint16_t primaries_idx); 65 | 66 | struct RGB_to_YCbCr_coefficients 67 | { 68 | bool defined = false; 69 | 70 | float c[3][3] = {{0,0,0},{0,0,0},{0,0,0}}; // e.g. y = c[0][0]*r + c[0][1]*g + c[0][2]*b 71 | 72 | static RGB_to_YCbCr_coefficients defaults(); 73 | }; 74 | 75 | RGB_to_YCbCr_coefficients get_RGB_to_YCbCr_coefficients(uint16_t matrix_coefficients_idx, uint16_t primaries_idx); 76 | 77 | // uint16_t get_transfer_characteristics() const {return m_transfer_characteristics;} 78 | // uint16_t get_matrix_coefficients() const {return m_matrix_coefficients;} 79 | // bool get_full_range_flag() const {return m_full_range_flag;} 80 | } 81 | 82 | 83 | #endif //LIBHEIF_NCLX_H 84 | -------------------------------------------------------------------------------- /libheif/plugins/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | macro(plugin_compilation name varName optionName defineName) 3 | if (${varName}_FOUND) 4 | if (NOT "${${varName}_LIBRARY_DIRS}" STREQUAL "") 5 | set(${varName}_LINKDIR "-L${${varName}_LIBRARY_DIRS}") 6 | endif () 7 | 8 | if (WITH_${optionName}_PLUGIN) 9 | add_library(heif-${name} 10 | MODULE ${${optionName}_sources} ${${optionName}_extra_plugin_sources} 11 | ../heif_plugin.cc 12 | ) 13 | set_target_properties(heif-${name} 14 | PROPERTIES 15 | VERSION ${PROJECT_VERSION} 16 | SOVERSION ${PROJECT_VERSION_MAJOR}) 17 | target_compile_definitions(heif-${name} 18 | PUBLIC 19 | LIBHEIF_EXPORTS 20 | HAVE_VISIBILITY) 21 | target_compile_definitions(heif-${name} PRIVATE PLUGIN_${defineName}=1) 22 | target_include_directories(heif-${name} PRIVATE ${PROJECT_SOURCE_DIR} ${libheif_BINARY_DIR} ${libheif_SOURCE_DIR} ${${varName}_INCLUDE_DIR}) 23 | target_link_libraries(heif-${name} PRIVATE ${${varName}_LIBRARIES} ${${varName}_LINKDIR}) 24 | 25 | install(TARGETS heif-${name} 26 | LIBRARY DESTINATION ${PLUGIN_DIRECTORY} 27 | ) 28 | else () 29 | target_sources(heif PRIVATE ${${optionName}_sources}) 30 | target_compile_definitions(heif PRIVATE HAVE_${defineName}=1) 31 | target_include_directories(heif PRIVATE ${${varName}_INCLUDE_DIR}) 32 | target_link_libraries(heif PRIVATE ${${varName}_LIBRARIES} ${${varName}_LINKDIR}) 33 | endif () 34 | 35 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${varName}_CFLAGS}") 36 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${varName}_CFLAGS}") 37 | endif () 38 | endmacro() 39 | 40 | 41 | set(X265_sources heif_encoder_x265.h heif_encoder_x265.cc) 42 | set(X265_extra_plugin_sources) 43 | plugin_compilation(x265 X265 X265 X265) 44 | 45 | set(LIBDE265_sources heif_decoder_libde265.cc heif_decoder_libde265.h) 46 | set(LIBDE265_extra_plugin_sources ../heif_image.cc ../error.cc) 47 | plugin_compilation(libde265 LIBDE265 LIBDE265 LIBDE265) 48 | 49 | set(DAV1D_sources heif_decoder_dav1d.cc heif_decoder_dav1d.h) 50 | set(DAV1D_extra_plugin_sources) 51 | plugin_compilation(dav1d DAV1D DAV1D DAV1D) 52 | 53 | set(AOM_DECODER_sources heif_decoder_aom.cc heif_decoder_aom.h) 54 | set(AOM_DECODER_extra_plugin_sources) 55 | plugin_compilation(aomdec AOM AOM_DECODER AOM_DECODER) 56 | 57 | set(AOM_ENCODER_sources heif_encoder_aom.cc heif_encoder_aom.h) 58 | set(AOM_ENCODER_extra_plugin_sources ../heif_avif.cc ../error.cc) 59 | plugin_compilation(aomenc AOM AOM_ENCODER AOM_ENCODER) 60 | 61 | set(SvtEnc_sources heif_encoder_svt.cc heif_encoder_svt.h) 62 | set(SvtEnc_extra_plugin_sources) 63 | plugin_compilation(svtenc SvtEnc SvtEnc SvtEnc) 64 | 65 | set(RAV1E_sources heif_encoder_rav1e.cc heif_encoder_rav1e.h) 66 | set(RAV1E_extra_plugin_sources ../box.cc ../error.cc) 67 | plugin_compilation(rav1e RAV1E RAV1E RAV1E) 68 | -------------------------------------------------------------------------------- /libheif/plugins/heif_decoder_aom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2017 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | #ifndef LIBHEIF_HEIF_DECODER_AOM_H 22 | #define LIBHEIF_HEIF_DECODER_AOM_H 23 | 24 | const struct heif_decoder_plugin* get_decoder_plugin_aom(); 25 | 26 | #if PLUGIN_AOM_DECODER 27 | extern "C" { 28 | __attribute__((unused)) LIBHEIF_API extern heif_plugin_info plugin_info; 29 | } 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /libheif/plugins/heif_decoder_dav1d.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2017 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | #ifndef LIBHEIF_HEIF_DECODER_DAV1D_H 22 | #define LIBHEIF_HEIF_DECODER_DAV1D_H 23 | 24 | const struct heif_decoder_plugin* get_decoder_plugin_dav1d(); 25 | 26 | #if PLUGIN_DAV1D 27 | extern "C" { 28 | __attribute__((unused)) LIBHEIF_API extern heif_plugin_info plugin_info; 29 | } 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /libheif/plugins/heif_decoder_libde265.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2017 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | #ifndef LIBHEIF_HEIF_DECODER_DE265_H 22 | #define LIBHEIF_HEIF_DECODER_DE265_H 23 | 24 | const struct heif_decoder_plugin* get_decoder_plugin_libde265(); 25 | 26 | #if PLUGIN_LIBDE265 27 | extern "C" { 28 | __attribute__((unused)) LIBHEIF_API extern heif_plugin_info plugin_info; 29 | } 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /libheif/plugins/heif_encoder_aom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2017 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | #ifndef LIBHEIF_HEIF_ENCODER_AOM_H 22 | #define LIBHEIF_HEIF_ENCODER_AOM_H 23 | 24 | 25 | const struct heif_encoder_plugin* get_encoder_plugin_aom(); 26 | 27 | #if PLUGIN_AOM_ENCODER 28 | extern "C" { 29 | __attribute__((unused)) LIBHEIF_API extern heif_plugin_info plugin_info; 30 | } 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /libheif/plugins/heif_encoder_rav1e.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2017 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | #ifndef LIBHEIF_HEIF_ENCODER_RAV1E_H 22 | #define LIBHEIF_HEIF_ENCODER_RAV1E_H 23 | 24 | 25 | const struct heif_encoder_plugin* get_encoder_plugin_rav1e(); 26 | 27 | #if PLUGIN_RAV1E 28 | extern "C" { 29 | __attribute__((unused)) LIBHEIF_API extern heif_plugin_info plugin_info; 30 | } 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /libheif/plugins/heif_encoder_svt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2022, Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | #ifndef LIBHEIF_HEIF_ENCODER_SVT_H 22 | #define LIBHEIF_HEIF_ENCODER_SVT_H 23 | 24 | 25 | const struct heif_encoder_plugin* get_encoder_plugin_svt(); 26 | 27 | #if PLUGIN_SvtEnc 28 | extern "C" { 29 | __attribute__((unused)) LIBHEIF_API extern heif_plugin_info plugin_info; 30 | } 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /libheif/plugins/heif_encoder_x265.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HEIF codec. 3 | * Copyright (c) 2017 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libheif. 6 | * 7 | * libheif is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * libheif is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with libheif. If not, see . 19 | */ 20 | 21 | #ifndef LIBHEIF_HEIF_ENCODER_X265_H 22 | #define LIBHEIF_HEIF_ENCODER_X265_H 23 | 24 | 25 | /* Image sizes in HEVC: since HEVC does not allow for odd image dimensions when 26 | using chroma 4:2:0, our strategy is as follows. 27 | 28 | - Images with odd dimensions are extended with an extra row/column which 29 | contains a copy of the border. 30 | - The HEVC image size generated by x265 is rounded up to the CTU size (?) 31 | and the conformance window has to be respected. 32 | - We add an additional crop transform to remove the extra row/column. 33 | */ 34 | 35 | 36 | const struct heif_encoder_plugin* get_encoder_plugin_x265(); 37 | 38 | #if PLUGIN_X265 39 | extern "C" { 40 | __attribute__((unused)) LIBHEIF_API extern heif_plugin_info plugin_info; 41 | } 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /logos/sponsors/shopify.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 10 | 11 | 18 | 19 | 21 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /m4/ac_c_cxx_compile_flags.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([AC_C_CXX_COMPILE_FLAGS],[ 2 | NEW_CFLAGS="$CFLAGS" 3 | NEW_CXXFLAGS="$CXXFLAGS" 4 | for ac_flag in $1 5 | do 6 | AC_MSG_CHECKING(whether compiler supports $ac_flag) 7 | CXXFLAGS="$NEW_CXXFLAGS $ac_flag" 8 | AC_LANG(C++) 9 | AC_TRY_COMPILE(,[ 10 | ; 11 | ],[ 12 | 13 | NEW_CFLAGS="$NEW_CFLAGS $ac_flag" 14 | NEW_CXXFLAGS="$NEW_CXXFLAGS $ac_flag" 15 | 16 | AC_MSG_RESULT(yes) 17 | ],AC_MSG_RESULT(no)) 18 | done 19 | 20 | CFLAGS=$NEW_CFLAGS 21 | CXXFLAGS=$NEW_CXXFLAGS 22 | ]) 23 | -------------------------------------------------------------------------------- /m4/ax_cxx_compile_stdcxx_11.m4: -------------------------------------------------------------------------------- 1 | # ============================================================================ 2 | # http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html 3 | # ============================================================================ 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # Check for baseline language coverage in the compiler for the C++11 12 | # standard; if necessary, add switches to CXXFLAGS to enable support. 13 | # 14 | # The first argument, if specified, indicates whether you insist on an 15 | # extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. 16 | # -std=c++11). If neither is specified, you get whatever works, with 17 | # preference for an extended mode. 18 | # 19 | # The second argument, if specified 'mandatory' or if left unspecified, 20 | # indicates that baseline C++11 support is required and that the macro 21 | # should error out if no mode with that support is found. If specified 22 | # 'optional', then configuration proceeds regardless, after defining 23 | # HAVE_CXX11 if and only if a supporting mode is found. 24 | # 25 | # LICENSE 26 | # 27 | # Copyright (c) 2008 Benjamin Kosnik 28 | # Copyright (c) 2012 Zack Weinberg 29 | # Copyright (c) 2013 Roy Stogner 30 | # Copyright (c) 2014 Alexey Sokolov 31 | # 32 | # Copying and distribution of this file, with or without modification, are 33 | # permitted in any medium without royalty provided the copyright notice 34 | # and this notice are preserved. This file is offered as-is, without any 35 | # warranty. 36 | 37 | #serial 4 38 | 39 | m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [[ 40 | template 41 | struct check 42 | { 43 | static_assert(sizeof(int) <= sizeof(T), "not big enough"); 44 | }; 45 | 46 | struct Base { 47 | virtual void f() {} 48 | }; 49 | struct Child : public Base { 50 | virtual void f() {} // DiFa: override {} # override not supported in gcc 4.6 51 | }; 52 | 53 | typedef check> right_angle_brackets; 54 | 55 | int a; 56 | decltype(a) b; 57 | 58 | typedef check check_type; 59 | check_type c; 60 | check_type&& cr = static_cast(c); 61 | 62 | auto d = a; 63 | auto l = [](){}; 64 | ]]) 65 | 66 | AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl 67 | m4_if([$1], [], [], 68 | [$1], [ext], [], 69 | [$1], [noext], [], 70 | [m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl 71 | m4_if([$2], [], [ax_cxx_compile_cxx11_required=true], 72 | [$2], [mandatory], [ax_cxx_compile_cxx11_required=true], 73 | [$2], [optional], [ax_cxx_compile_cxx11_required=false], 74 | [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])]) 75 | AC_LANG_PUSH([C++])dnl 76 | ac_success=no 77 | AC_CACHE_CHECK(whether $CXX supports C++11 features by default, 78 | ax_cv_cxx_compile_cxx11, 79 | [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], 80 | [ax_cv_cxx_compile_cxx11=yes], 81 | [ax_cv_cxx_compile_cxx11=no])]) 82 | if test x$ax_cv_cxx_compile_cxx11 = xyes; then 83 | ac_success=yes 84 | fi 85 | 86 | m4_if([$1], [noext], [], [dnl 87 | if test x$ac_success = xno; then 88 | for switch in -std=gnu++11 -std=gnu++0x; do 89 | cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch]) 90 | AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch, 91 | $cachevar, 92 | [ac_save_CXXFLAGS="$CXXFLAGS" 93 | CXXFLAGS="$CXXFLAGS $switch" 94 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], 95 | [eval $cachevar=yes], 96 | [eval $cachevar=no]) 97 | CXXFLAGS="$ac_save_CXXFLAGS"]) 98 | if eval test x\$$cachevar = xyes; then 99 | CXXFLAGS="$CXXFLAGS $switch" 100 | ac_success=yes 101 | break 102 | fi 103 | done 104 | fi]) 105 | 106 | m4_if([$1], [ext], [], [dnl 107 | if test x$ac_success = xno; then 108 | for switch in -std=c++11 -std=c++0x; do 109 | cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch]) 110 | AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch, 111 | $cachevar, 112 | [ac_save_CXXFLAGS="$CXXFLAGS" 113 | CXXFLAGS="$CXXFLAGS $switch" 114 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], 115 | [eval $cachevar=yes], 116 | [eval $cachevar=no]) 117 | CXXFLAGS="$ac_save_CXXFLAGS"]) 118 | if eval test x\$$cachevar = xyes; then 119 | CXXFLAGS="$CXXFLAGS $switch" 120 | ac_success=yes 121 | break 122 | fi 123 | done 124 | fi]) 125 | AC_LANG_POP([C++]) 126 | if test x$ax_cxx_compile_cxx11_required = xtrue; then 127 | if test x$ac_success = xno; then 128 | AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.]) 129 | fi 130 | else 131 | if test x$ac_success = xno; then 132 | HAVE_CXX11=0 133 | AC_MSG_NOTICE([No compiler with C++11 support was found]) 134 | else 135 | HAVE_CXX11=1 136 | AC_DEFINE(HAVE_CXX11,1, 137 | [define if the compiler supports basic C++11 syntax]) 138 | fi 139 | 140 | AC_SUBST(HAVE_CXX11) 141 | fi 142 | ]) 143 | -------------------------------------------------------------------------------- /m4/visibility.m4: -------------------------------------------------------------------------------- 1 | # visibility.m4 serial 1 (gettext-0.15) 2 | dnl Copyright (C) 2005 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Bruno Haible. 8 | 9 | dnl Tests whether the compiler supports the command-line option 10 | dnl -fvisibility=hidden and the function and variable attributes 11 | dnl __attribute__((__visibility__("hidden"))) and 12 | dnl __attribute__((__visibility__("default"))). 13 | dnl Does *not* test for __visibility__("protected") - which has tricky 14 | dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on 15 | dnl MacOS X. 16 | dnl Does *not* test for __visibility__("internal") - which has processor 17 | dnl dependent semantics. 18 | dnl Does *not* test for #pragma GCC visibility push(hidden) - which is 19 | dnl "really only recommended for legacy code". 20 | dnl Set the variable CFLAG_VISIBILITY. 21 | dnl Defines and sets the variable HAVE_VISIBILITY. 22 | 23 | AC_DEFUN([gl_VISIBILITY], 24 | [ 25 | AC_REQUIRE([AC_PROG_CC]) 26 | CFLAG_VISIBILITY= 27 | HAVE_VISIBILITY=0 28 | if test -n "$GCC"; then 29 | AC_MSG_CHECKING([for simple visibility declarations]) 30 | AC_CACHE_VAL(gl_cv_cc_visibility, [ 31 | gl_save_CFLAGS="$CFLAGS" 32 | CFLAGS="$CFLAGS -fvisibility=hidden" 33 | AC_TRY_COMPILE( 34 | [extern __attribute__((__visibility__("hidden"))) int hiddenvar; 35 | extern __attribute__((__visibility__("default"))) int exportedvar; 36 | extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); 37 | extern __attribute__((__visibility__("default"))) int exportedfunc (void);], 38 | [], 39 | gl_cv_cc_visibility=yes, 40 | gl_cv_cc_visibility=no) 41 | CFLAGS="$gl_save_CFLAGS"]) 42 | AC_MSG_RESULT([$gl_cv_cc_visibility]) 43 | if test $gl_cv_cc_visibility = yes; then 44 | CFLAG_VISIBILITY="-fvisibility=hidden" 45 | HAVE_VISIBILITY=1 46 | fi 47 | fi 48 | AC_SUBST([CFLAG_VISIBILITY]) 49 | AC_SUBST([HAVE_VISIBILITY]) 50 | AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY], 51 | [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.]) 52 | ]) 53 | -------------------------------------------------------------------------------- /pre.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @preserve libheif.js HEIF decoder 3 | * (c)2017 struktur AG, http://www.struktur.de, opensource@struktur.de 4 | * 5 | * This file is part of libheif 6 | * https://github.com/strukturag/libheif 7 | * 8 | * libheif is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as 10 | * published by the Free Software Foundation, either version 3 of 11 | * the License, or (at your option) any later version. 12 | * 13 | * libheif is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with libheif. If not, see . 20 | */ 21 | (function() { 22 | var Module = { 23 | print: function(text) { 24 | text = Array.prototype.slice.call(arguments).join(' '); 25 | console.log(text); 26 | }, 27 | printErr: function(text) { 28 | text = Array.prototype.slice.call(arguments).join(' '); 29 | console.error(text); 30 | }, 31 | canvas: {}, 32 | noInitialRun: true 33 | }; 34 | -------------------------------------------------------------------------------- /scripts/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = \ 2 | pre-commit.hook \ 3 | check-emscripten-enums.sh \ 4 | check-go-enums.sh \ 5 | check-gofmt.sh \ 6 | check-licenses.sh \ 7 | install-clang.sh \ 8 | install-ci-linux.sh \ 9 | install-ci-osx.sh \ 10 | install-emscripten.sh \ 11 | prepare-ci.sh \ 12 | run-ci.sh \ 13 | cpplint.py \ 14 | test-javascript.js 15 | -------------------------------------------------------------------------------- /scripts/check-emscripten-enums.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | # 4 | # HEIF codec. 5 | # Copyright (c) 2018 struktur AG, Joachim Bauch 6 | # 7 | # This file is part of libheif. 8 | # 9 | # libheif is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # libheif is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with libheif. If not, see . 21 | # 22 | 23 | DEFINE_TYPES=" 24 | heif_error_ 25 | heif_suberror_ 26 | heif_compression_ 27 | heif_chroma_ 28 | heif_colorspace_ 29 | heif_channel_ 30 | " 31 | 32 | API_DEFINES="" 33 | for type in $DEFINE_TYPES; do 34 | DEFINES=$(grep "^[ \t]*$type" libheif/heif.h | sed 's|[[:space:]]*\([^ \t=]*\)[[:space:]]*=.*|\1|g') 35 | if [ -z "$API_DEFINES" ]; then 36 | API_DEFINES="$DEFINES" 37 | else 38 | API_DEFINES="$API_DEFINES 39 | $DEFINES" 40 | fi 41 | ALIASES=$(grep "^[ \t]*#define $type" libheif/heif.h | sed 's|[[:space:]]*#define \([^ \t]*\)[[:space:]]*.*|\1|g') 42 | if [ ! -z "$ALIASES" ]; then 43 | API_DEFINES="$API_DEFINES 44 | $ALIASES" 45 | fi 46 | done 47 | API_DEFINES=$(echo "$API_DEFINES" | sort) 48 | 49 | EMSCRIPTEN_DEFINES="" 50 | for type in $DEFINE_TYPES; do 51 | DEFINES=$(grep "\.value(\"$type" libheif/heif_emscripten.h | sed 's|[^\"]*\"\(.*\)\".*|\1|g') 52 | if [ -z "$EMSCRIPTEN_DEFINES" ]; then 53 | EMSCRIPTEN_DEFINES="$DEFINES" 54 | else 55 | EMSCRIPTEN_DEFINES="$EMSCRIPTEN_DEFINES 56 | $DEFINES" 57 | fi 58 | done 59 | EMSCRIPTEN_DEFINES=$(echo "$EMSCRIPTEN_DEFINES" | sort) 60 | 61 | set +e 62 | CHANGES=$(diff -u <(echo "$API_DEFINES") <(echo "$EMSCRIPTEN_DEFINES")) 63 | set -e 64 | if [ -z "$CHANGES" ]; then 65 | echo "All defines from heif.h are present in heif_emscripten.h" 66 | exit 0 67 | fi 68 | 69 | echo "Differences found between enum defines in heif.h and heif_emscripten.h." 70 | echo "Lines prefixed with '+' are only in heif_emscripten.h, resulting in" 71 | echo "compile errors. Lines prefixed with '-' are missing in heif_emscripten.h" 72 | echo 73 | echo "$CHANGES" 74 | exit 1 75 | -------------------------------------------------------------------------------- /scripts/check-go-enums.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | # 4 | # HEIF codec. 5 | # Copyright (c) 2018 struktur AG, Joachim Bauch 6 | # 7 | # This file is part of libheif. 8 | # 9 | # libheif is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # libheif is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with libheif. If not, see . 21 | # 22 | 23 | DEFINE_TYPES=" 24 | heif_error_ 25 | heif_suberror_ 26 | heif_compression_ 27 | heif_chroma_ 28 | heif_colorspace_ 29 | heif_channel_ 30 | " 31 | 32 | API_DEFINES="" 33 | for type in $DEFINE_TYPES; do 34 | DEFINES=$(grep "^[ \t]*$type" libheif/heif.h | sed 's|[[:space:]]*\([^ \t=]*\)[[:space:]]*=.*|\1|g') 35 | if [ -z "$API_DEFINES" ]; then 36 | API_DEFINES="$DEFINES" 37 | else 38 | API_DEFINES="$API_DEFINES 39 | $DEFINES" 40 | fi 41 | ALIASES=$(grep "^[ \t]*#define $type" libheif/heif.h | sed 's|[[:space:]]*#define \([^ \t]*\)[[:space:]]*.*|\1|g') 42 | if [ ! -z "$ALIASES" ]; then 43 | API_DEFINES="$API_DEFINES 44 | $ALIASES" 45 | fi 46 | done 47 | API_DEFINES=$(echo "$API_DEFINES" | sort) 48 | 49 | GO_DEFINES="" 50 | for type in $DEFINE_TYPES; do 51 | DEFINES=$(grep " = C\.$type" go/heif/heif.go | sed 's|.* = C\.\([a-zA-Z0-9_]*\).*|\1|g') 52 | if [ -z "$GO_DEFINES" ]; then 53 | GO_DEFINES="$DEFINES" 54 | else 55 | GO_DEFINES="$GO_DEFINES 56 | $DEFINES" 57 | fi 58 | done 59 | GO_DEFINES=$(echo "$GO_DEFINES" | sort) 60 | 61 | set +e 62 | CHANGES=$(diff -u <(echo "$API_DEFINES") <(echo "$GO_DEFINES")) 63 | set -e 64 | if [ -z "$CHANGES" ]; then 65 | echo "All defines from heif.h are present in go/heif/heif.go" 66 | exit 0 67 | fi 68 | 69 | echo "Differences found between enum defines in heif.h and go/heif/heif.go." 70 | echo "Lines prefixed with '+' are only in go/heif/heif.go, resulting in" 71 | echo "compile errors. Lines prefixed with '-' are missing in go/heif/heif.go" 72 | echo 73 | echo "$CHANGES" 74 | exit 1 75 | -------------------------------------------------------------------------------- /scripts/check-gofmt.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eufo pipefail 3 | # 4 | # HEIF codec. 5 | # Copyright (c) 2018 struktur AG, Leon Klingele 6 | # 7 | # This file is part of libheif. 8 | # 9 | # libheif is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # libheif is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with libheif. If not, see . 21 | # 22 | 23 | realpath() { python -c "import os,sys; print(os.path.realpath(sys.argv[1]))" "$1"; } 24 | 25 | DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)" 26 | 27 | FILES=$(find "$DIR"/.. -name *.go) 28 | result=0 29 | for filename in $FILES; do 30 | filename=$(realpath "${filename}") 31 | newfile=`mktemp /tmp/fmt.XXXXXX` || exit 1 32 | gofmt "${filename}" > "${newfile}" 2>> /dev/null 33 | set +e 34 | diff -u -p "${filename}" --label "${filename}" --label "${filename} (formatted)" "${newfile}" 35 | r=$? 36 | set -e 37 | rm "${newfile}" 38 | if [ $r != 0 ] ; then 39 | result=1 40 | else 41 | echo "Done processing ${filename}" 42 | fi 43 | done 44 | 45 | if [ $result != 0 ] ; then 46 | echo 47 | echo "Please fix the formatting errors above." >& 2 48 | exit 1 49 | fi 50 | -------------------------------------------------------------------------------- /scripts/check-licenses.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eu 3 | # 4 | # HEIF codec. 5 | # Copyright (c) 2018 struktur AG, Joachim Bauch 6 | # 7 | # This file is part of libheif. 8 | # 9 | # libheif is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # libheif is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with libheif. If not, see . 21 | # 22 | 23 | echo "Checking licenses..." 24 | CHECK_RESULT=`/usr/bin/licensecheck --recursive --ignore 'emscripten|libde265|README\.md|post\.js|/.git/|clusterfuzz-testcase-.*' .` 25 | 26 | FOUND= 27 | while read -r line; do 28 | if ( echo $line | grep -q "GENERATED FILE" ); then 29 | # We don't care about generated files 30 | echo "OK: $line" 31 | continue 32 | fi 33 | 34 | if ( echo "$line" | grep -q "UNKNOWN" ); then 35 | FILENAME=`echo "$line" | awk '{split($0,a,":");print a[1]}'` 36 | echo "ERROR: $line" >& 2 37 | FOUND=1 38 | continue 39 | fi 40 | 41 | echo "OK: $line" 42 | done <<< "${CHECK_RESULT}" 43 | 44 | if [ ! -z ${FOUND} ]; then 45 | echo "ERROR: Found files without licenses" >& 2 46 | exit 1 47 | fi 48 | -------------------------------------------------------------------------------- /scripts/configure-fuzzer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # HEIF codec. 4 | # Copyright (c) 2018 struktur AG, Joachim Bauch 5 | # 6 | # This file is part of libheif. 7 | # 8 | # libheif is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 3 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # libheif is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with libheif. If not, see . 20 | # 21 | 22 | FUZZER_FLAGS="-fsanitize=fuzzer-no-link,address,shift,integer -fno-sanitize-recover=shift,integer" # ,undefined 23 | export CFLAGS="$CFLAGS $FUZZER_FLAGS" 24 | export CXXFLAGS="$CXXFLAGS $FUZZER_FLAGS" 25 | export CXX=clang-7 26 | export CC=clang-7 27 | 28 | CONFIGURE_ARGS="$CONFIGURE_ARGS --disable-go" 29 | CONFIGURE_ARGS="$CONFIGURE_ARGS --enable-libfuzzer=-fsanitize=fuzzer" 30 | exec ./configure $CONFIGURE_ARGS 31 | 32 | export TSAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-7 33 | export MSAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-7 34 | export ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-7 35 | -------------------------------------------------------------------------------- /scripts/install-ci-osx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | # 4 | # HEIF codec. 5 | # Copyright (c) 2018 struktur AG, Joachim Bauch 6 | # 7 | # This file is part of libheif. 8 | # 9 | # libheif is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # libheif is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with libheif. If not, see . 21 | # 22 | 23 | INSTALL_PACKAGES="\ 24 | autoconf \ 25 | automake \ 26 | pkg-config \ 27 | " 28 | REMOVE_PACKAGES= 29 | 30 | if [ ! -z "$WITH_AOM" ]; then 31 | INSTALL_PACKAGES="$INSTALL_PACKAGES \ 32 | aom \ 33 | " 34 | fi 35 | 36 | if [ ! -z "$WITH_LIBDE265" ]; then 37 | INSTALL_PACKAGES="$INSTALL_PACKAGES \ 38 | libde265 \ 39 | " 40 | fi 41 | 42 | if [ ! -z "$WITH_X265" ]; then 43 | INSTALL_PACKAGES="$INSTALL_PACKAGES \ 44 | x265 \ 45 | " 46 | fi 47 | 48 | if [ -z "$WITH_GRAPHICS" ] && [ -z "$CHECK_LICENSES" ] && [ -z "$CPPLINT" ]; then 49 | REMOVE_PACKAGES="$REMOVE_PACKAGES \ 50 | libjpeg \ 51 | libpng \ 52 | " 53 | fi 54 | 55 | if [ ! -z "$WITH_GRAPHICS" ]; then 56 | INSTALL_PACKAGES="$INSTALL_PACKAGES \ 57 | libjpeg \ 58 | libpng \ 59 | " 60 | fi 61 | 62 | if [ ! -z "$REMOVE_PACKAGES" ] || [ ! -z "$INSTALL_PACKAGES" ]; then 63 | # Need to update homebrew before installing / removing packages to make sure 64 | # the correct version of ruby is used. 65 | brew update 66 | fi 67 | 68 | if [ ! -z "$REMOVE_PACKAGES" ]; then 69 | echo "Removing packages $REMOVE_PACKAGES ..." 70 | for package in $REMOVE_PACKAGES; do 71 | brew list $package &>/dev/null && brew uninstall --ignore-dependencies $package 72 | done 73 | fi 74 | 75 | if [ ! -z "$INSTALL_PACKAGES" ]; then 76 | echo "Installing packages $INSTALL_PACKAGES ..." 77 | for package in $INSTALL_PACKAGES; do 78 | brew list $package &>/dev/null || brew install $package 79 | done 80 | fi 81 | -------------------------------------------------------------------------------- /scripts/install-clang.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | # 4 | # HEIF codec. 5 | # Copyright (c) 2018 struktur AG, Joachim Bauch 6 | # 7 | # This file is part of libheif. 8 | # 9 | # libheif is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # libheif is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with libheif. If not, see . 21 | # 22 | 23 | # Use script from https://chromium.googlesource.com/chromium/src/tools/clang/ 24 | # to download prebuilt version of clang. This commit defines which version of 25 | # the script should be used (and thus defines the version of clang). 26 | COMMIT_HASH=f30572cab0ed7d31dc5547e709670ac9d252c6c0 27 | 28 | DEST=$1 29 | 30 | if [ -z "${DEST}" ]; then 31 | echo "USAGE: $0 " 32 | exit 1 33 | fi 34 | 35 | url="https://chromium.googlesource.com/chromium/src/tools/clang/+/${COMMIT_HASH}/scripts/update.py?format=TEXT" 36 | 37 | tmpdir=$(mktemp -d) 38 | echo "Using ${tmpdir} as temporary folder" 39 | 40 | script_folder=${tmpdir}/tools/clang/scripts 41 | mkdir -p "${script_folder}" 42 | echo "Downloading from ${url} ..." 43 | curl -o "${script_folder}/update.py.b64" ${url} 44 | 45 | echo "Decoding base64 ..." 46 | base64 --decode "${script_folder}/update.py.b64" > "${script_folder}/update.py" 47 | 48 | echo "Running ${script_folder}/update.py ..." 49 | python "${script_folder}/update.py" 50 | 51 | echo "Copying to ${DEST} ..." 52 | mkdir -p "$DEST" 53 | cp -rf "${tmpdir}/third_party/llvm-build/Release+Asserts/"* "${DEST}" 54 | 55 | echo "Cleaning up ..." 56 | rm -rf "${tmpdir}" 57 | -------------------------------------------------------------------------------- /scripts/install-emscripten.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | VERSION=$1 5 | TARGET=$2 6 | 7 | if [ -z "$VERSION" ] || [ -z "$TARGET" ]; then 8 | echo "USAGE: $0 " 9 | exit 1 10 | fi 11 | 12 | LIBSTDC_BASE=http://de.archive.ubuntu.com/ubuntu/pool/main/g/gcc-5 13 | EMSDK_DOWNLOAD=https://github.com/emscripten-core/emsdk.git 14 | 15 | CODENAME=$(/usr/bin/lsb_release --codename --short) 16 | if [ "$CODENAME" = "trusty" ] && [ ! -e "/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21" ]; then 17 | CONTENTS=$(curl --location $LIBSTDC_BASE) 18 | LIBSTDC_VERSION=$(echo $CONTENTS | sed 's|.*libstdc++6_\([^_]*\)_amd64\.deb.*|\1|g') 19 | TMPDIR=$(mktemp --directory) 20 | echo "Installing libstdc++6 $LIBSTDC_VERSION to fix Emscripten ..." 21 | echo "Extracting in $TMPDIR ..." 22 | curl "${LIBSTDC_BASE}/libstdc++6_${LIBSTDC_VERSION}_amd64.deb" > "$TMPDIR/libstdc++6_${LIBSTDC_VERSION}_amd64.deb" 23 | dpkg -x "$TMPDIR/libstdc++6_${LIBSTDC_VERSION}_amd64.deb" "$TMPDIR" 24 | sudo mv "$TMPDIR/usr/lib/x86_64-linux-gnu/"libstdc++* /usr/lib/x86_64-linux-gnu 25 | rm -rf "$TMPDIR" 26 | fi 27 | 28 | cd "$TARGET" 29 | if [ ! -d emsdk ]; then 30 | echo "Cloning SDK base system ..." 31 | git clone --verbose --recursive "$EMSDK_DOWNLOAD" emsdk 32 | fi 33 | 34 | cd emsdk 35 | echo "Updating SDK ..." 36 | git pull --verbose 37 | 38 | echo "Installing SDK version ${VERSION} ..." 39 | ./emsdk install sdk-fastcomp-${VERSION}-64bit 40 | 41 | echo "Activating SDK version ${VERSION} ..." 42 | ./emsdk activate sdk-fastcomp-${VERSION}-64bit 43 | -------------------------------------------------------------------------------- /scripts/pre-commit.hook: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | # 4 | # HEIF codec. 5 | # Copyright (c) 2018 struktur AG, Joachim Bauch 6 | # 7 | # This file is part of libheif. 8 | # 9 | # libheif is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # libheif is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with libheif. If not, see . 21 | # 22 | ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 23 | 24 | # Assume running from ".git/hooks" folder. 25 | CPPLINT="$ROOT/../../scripts/cpplint.py" 26 | if [ ! -x "$CPPLINT" ]; then 27 | # Running from "scripts" folder. 28 | CPPLINT="$ROOT/cpplint.py" 29 | fi 30 | 31 | PYTHON=$(which python || true) 32 | if [ -z "$PYTHON" ]; then 33 | PYTHON=$(which python3 || true) 34 | fi 35 | 36 | # Run cpplint against changed C/C++ files and check if all enums from the API 37 | # are also updated in the Emscripten/Go files. 38 | check_c_enums= 39 | check_go_enums= 40 | logged_python= 41 | for file in `git diff-index --cached --name-only HEAD --diff-filter=ACMR| grep -E "\.cc$|\.h$|\.c$"` ; do 42 | if [ -z "$PYTHON" ]; then 43 | if [ -z "$logged_python" ]; then 44 | echo "WARNING: Could not find valid Python interpreter to run cpplint, skipping checks..." 45 | logged_python=1 46 | fi 47 | else 48 | "$PYTHON" "$CPPLINT" "$file" 49 | fi 50 | if [ "$file" = "libheif/heif.h" ] ; then 51 | check_c_enums=1 52 | check_go_enums=1 53 | fi 54 | if [ "$file" = "libheif/heif_emscripten.h" ] ; then 55 | check_c_enums=1 56 | fi 57 | done 58 | 59 | if [ "$check_c_enums" = "1" ]; then 60 | CHECK_EMSCRIPTEN="$ROOT/../../scripts/check-emscripten-enums.sh" 61 | if [ ! -x "$CHECK_EMSCRIPTEN" ]; then 62 | # Running from "scripts" folder. 63 | CHECK_EMSCRIPTEN="$ROOT/check-emscripten-enums.sh" 64 | fi 65 | "$CHECK_EMSCRIPTEN" 66 | fi 67 | 68 | # Check format of Go files 69 | for file in `git diff-index --cached --name-only HEAD --diff-filter=ACMR| grep "\.go$"` ; do 70 | # nf is the temporary checkout. This makes sure we check against the 71 | # revision in the index (and not the checked out version). 72 | nf=`git checkout-index --temp ${file} | cut -f 1` 73 | newfile=`mktemp /tmp/${nf}.XXXXXX` || exit 1 74 | gofmt ${nf} > "${newfile}" 2>> /dev/null 75 | set +e 76 | diff -u -p --label "$file" "${nf}" --label "$file (formatted)" "${newfile}" 77 | r=$? 78 | set -e 79 | rm "${newfile}" 80 | rm "${nf}" 81 | if [ $r != 0 ] ; then 82 | echo "=================================================================================================" 83 | echo " Code format error in: $file " 84 | echo " " 85 | echo " Please fix before committing. Don't forget to run git add before trying to commit again. " 86 | echo " If the whole file is to be committed, this should work (run from the top-level directory): " 87 | echo " " 88 | echo " go fmt $file; git add $file; git commit" 89 | echo " " 90 | echo "=================================================================================================" 91 | exit 1 92 | fi 93 | if [ "$file" = "go/heif/heif.go" ] ; then 94 | check_go_enums=1 95 | fi 96 | done 97 | 98 | if [ "$check_go_enums" = "1" ]; then 99 | CHECK_GO="$ROOT/../../scripts/check-go-enums.sh" 100 | if [ ! -x "$CHECK_GO" ]; then 101 | # Running from "scripts" folder. 102 | CHECK_GO="$ROOT/check-go-enums.sh" 103 | fi 104 | "$CHECK_GO" 105 | fi 106 | -------------------------------------------------------------------------------- /scripts/prepare-ci.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | # 4 | # HEIF codec. 5 | # Copyright (c) 2018 struktur AG, Joachim Bauch 6 | # 7 | # This file is part of libheif. 8 | # 9 | # libheif is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # libheif is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with libheif. If not, see . 21 | # 22 | 23 | ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" 24 | 25 | BUILD_ROOT=$ROOT/.. 26 | 27 | PKG_CONFIG_PATH= 28 | if [ "$WITH_LIBDE265" = "2" ]; then 29 | PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$BUILD_ROOT/libde265/dist/lib/pkgconfig/" 30 | fi 31 | 32 | if [ "$WITH_RAV1E" = "1" ]; then 33 | PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$BUILD_ROOT/third-party/rav1e/dist/lib/pkgconfig/" 34 | fi 35 | 36 | if [ "$WITH_DAV1D" = "1" ]; then 37 | PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$BUILD_ROOT/third-party/dav1d/dist/lib/x86_64-linux-gnu/pkgconfig/" 38 | fi 39 | if [ ! -z "$PKG_CONFIG_PATH" ]; then 40 | export PKG_CONFIG_PATH="$PKG_CONFIG_PATH" 41 | fi 42 | 43 | CONFIGURE_HOST= 44 | if [ "$MINGW" == "32" ]; then 45 | CONFIGURE_HOST=i686-w64-mingw32 46 | elif [ "$MINGW" == "64" ]; then 47 | CONFIGURE_HOST=x86_64-w64-mingw32 48 | fi 49 | 50 | if [ -z "$CHECK_LICENSES" ] && [ -z "$CPPLINT" ] && [ -z "$CMAKE" ]; then 51 | ./autogen.sh 52 | CONFIGURE_ARGS= 53 | if [ -z "$CONFIGURE_HOST" ]; then 54 | if [ ! -z "$FUZZER" ]; then 55 | export CC="$BUILD_ROOT/clang/bin/clang" 56 | export CXX="$BUILD_ROOT/clang/bin/clang++" 57 | FUZZER_FLAGS="-fsanitize=fuzzer-no-link,address,shift,integer -fno-sanitize-recover=shift,integer" 58 | export CFLAGS="$CFLAGS -g -O0 $FUZZER_FLAGS" 59 | export CXXFLAGS="$CXXFLAGS -g -O0 $FUZZER_FLAGS" 60 | CONFIGURE_ARGS="$CONFIGURE_ARGS --enable-libfuzzer=-fsanitize=fuzzer" 61 | fi 62 | else 63 | # Make sure the correct compiler will be used. 64 | unset CC 65 | unset CXX 66 | CONFIGURE_ARGS="$CONFIGURE_ARGS --host=$CONFIGURE_HOST" 67 | fi 68 | if [ ! -z "$GO" ]; then 69 | CONFIGURE_ARGS="$CONFIGURE_ARGS --prefix=$BUILD_ROOT/dist --disable-gdk-pixbuf" 70 | else 71 | CONFIGURE_ARGS="$CONFIGURE_ARGS --disable-go" 72 | fi 73 | if [ ! -z "$TESTS" ]; then 74 | CONFIGURE_ARGS="$CONFIGURE_ARGS --enable-tests" 75 | fi 76 | if [ "$WITH_RAV1E" = "1" ]; then 77 | CONFIGURE_ARGS="$CONFIGURE_ARGS --enable-local-rav1e" 78 | fi 79 | ./configure $CONFIGURE_ARGS 80 | fi 81 | -------------------------------------------------------------------------------- /scripts/test-javascript.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @preserve libheif.js HEIF decoder 3 | * (c)2017 struktur AG, http://www.struktur.de, opensource@struktur.de 4 | * 5 | * This file is part of libheif 6 | * https://github.com/strukturag/libheif 7 | * 8 | * libheif is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as 10 | * published by the Free Software Foundation, either version 3 of 11 | * the License, or (at your option) any later version. 12 | * 13 | * libheif is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with libheif. If not, see . 20 | */ 21 | (function() { 22 | 23 | console.log("Running libheif JavaScript tests ..."); 24 | 25 | var libheif = require('../libheif.js'); 26 | console.log("Loaded libheif.js", libheif.heif_get_version()); 27 | 28 | // Ensure that no "undefined" properties are exported. 29 | var key; 30 | var missing = []; 31 | for (key in libheif) { 32 | if (!libheif.hasOwnProperty(key)) { 33 | continue; 34 | } 35 | if (typeof(libheif[key]) === "undefined") { 36 | missing.push(key); 37 | } 38 | } 39 | if (missing.length) { 40 | throw new Error("The following properties are not defined: " + missing); 41 | } 42 | 43 | // Decode the example file and make sure at least one image is returned. 44 | var fs = require('fs'); 45 | fs.readFile('examples/example.heic', function(err, data) { 46 | if (err) { 47 | throw err; 48 | } 49 | 50 | var decoder = new libheif.HeifDecoder(); 51 | var image_data = decoder.decode(data); 52 | console.log("Loaded images:", image_data.length); 53 | if (!image_data.length) { 54 | throw new Error("Should have loaded images"); 55 | } 56 | }); 57 | 58 | })(); 59 | -------------------------------------------------------------------------------- /tests/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_PROGRAMS = 2 | 3 | if HAVE_TESTS 4 | noinst_PROGRAMS += \ 5 | heif-unit-tests 6 | 7 | heif_unit_tests_DEPENDENCIES = ../libheif/libheif.la 8 | heif_unit_tests_CXXFLAGS = -I$(top_srcdir) -I$(top_builddir)/. 9 | heif_unit_tests_LDFLAGS = 10 | heif_unit_tests_LDADD = ../libheif/libheif.la 11 | heif_unit_tests_SOURCES = main.cc encode.cc catch.hpp conversion.cc 12 | 13 | test-local: heif-unit-tests 14 | ./heif-unit-tests 15 | 16 | endif 17 | 18 | if HAVE_GO 19 | noinst_PROGRAMS += \ 20 | test-race 21 | 22 | test_race_SOURCES = test-race.go 23 | 24 | gopath: 25 | mkdir -p ${CURDIR}/src/github.com/strukturag/libheif 26 | ln -sf ${CURDIR}/../go ${CURDIR}/src/github.com/strukturag/libheif/ 27 | 28 | test-race: gopath $(top_builddir)/libheif/libheif.la $(top_builddir)/libheif.pc test-race.go 29 | GOPATH=${CURDIR} PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:$(abs_top_builddir):$(abs_top_builddir)/libde265/dist/lib/pkgconfig/ CGO_CFLAGS="-I$(abs_top_builddir)" CGO_LDFLAGS="-L$(abs_top_builddir)/libheif/.libs" LD_LIBRARY_PATH=$(abs_top_builddir)/libheif/.libs $(GO) build -o test-race ${test_race_SOURCES} 30 | 31 | format-go: ${test_race_SOURCES} 32 | $(GO) fmt ${test_race_SOURCES} 33 | else 34 | format-go: 35 | echo ""go" not present in "${PATH}", skipping formatting" 36 | endif 37 | 38 | format-local: format-go 39 | -------------------------------------------------------------------------------- /tests/encode.cc: -------------------------------------------------------------------------------- 1 | /* 2 | libheif unit tests 3 | 4 | MIT License 5 | 6 | Copyright (c) 2019 struktur AG, Dirk Farin 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | 27 | #include "catch.hpp" 28 | #include "libheif/heif.h" 29 | 30 | 31 | struct heif_image* createImage_RRGGBB_BE() { 32 | struct heif_image* image; 33 | struct heif_error err; 34 | err = heif_image_create(256,256, 35 | heif_colorspace_RGB, 36 | heif_chroma_interleaved_RRGGBB_BE, 37 | &image); 38 | if (err.code) { 39 | return nullptr; 40 | } 41 | 42 | err = heif_image_add_plane(image, 43 | heif_channel_interleaved, 44 | 256,256, 10); 45 | if (err.code) { 46 | heif_image_release(image); 47 | return nullptr; 48 | } 49 | 50 | return image; 51 | } 52 | 53 | 54 | struct heif_error encode_image(struct heif_image* img) { 55 | struct heif_context* ctx = heif_context_alloc(); 56 | 57 | struct heif_encoder* enc; 58 | struct heif_error err { heif_error_Ok }; 59 | 60 | err = heif_context_get_encoder_for_format(ctx, 61 | heif_compression_HEVC, 62 | &enc); 63 | if (err.code) { 64 | heif_context_free(ctx); 65 | return err; 66 | } 67 | 68 | 69 | struct heif_image_handle* hdl; 70 | err = heif_context_encode_image(ctx, 71 | img, 72 | enc, 73 | nullptr, 74 | &hdl); 75 | if (err.code) { 76 | heif_encoder_release(enc); 77 | heif_context_free(ctx); 78 | return err; 79 | } 80 | 81 | return err; 82 | } 83 | 84 | 85 | #if 0 86 | TEST_CASE( "Create images", "[heif_image]" ) { 87 | auto img = createImage_RRGGBB_BE(); 88 | REQUIRE( img != nullptr ); 89 | 90 | heif_image_release(img); 91 | } 92 | 93 | 94 | 95 | TEST_CASE( "Encode HDR", "[heif_encoder]" ) { 96 | auto img = createImage_RRGGBB_BE(); 97 | REQUIRE( img != nullptr ); 98 | 99 | REQUIRE( encode_image(img).code == heif_error_Ok ); 100 | 101 | heif_image_release(img); 102 | } 103 | #endif 104 | -------------------------------------------------------------------------------- /tests/main.cc: -------------------------------------------------------------------------------- 1 | /* 2 | libheif unit tests 3 | 4 | MIT License 5 | 6 | Copyright (c) 2019 struktur AG, Dirk Farin 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | 27 | #define CATCH_CONFIG_MAIN 28 | #include "catch.hpp" 29 | -------------------------------------------------------------------------------- /tests/test-race.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Go race detector 3 | * 4 | * MIT License 5 | * 6 | * Copyright (c) 2019 struktur AG, Joachim Bauch 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | * 26 | * Based on an example by "Hans Duedal" (hans.duedal@gmail.com) to reproduce 27 | * https://github.com/strukturag/libheif/issues/147 28 | * 29 | */ 30 | package main 31 | 32 | import ( 33 | "fmt" 34 | "image" 35 | "io/ioutil" 36 | "os" 37 | "sync" 38 | 39 | "github.com/strukturag/libheif/go/heif" 40 | ) 41 | 42 | func decodeImage(data []byte) (image.Image, int, int, error) { 43 | ctx, err := heif.NewContext() 44 | if err != nil { 45 | return nil, 0, 0, err 46 | } 47 | err = ctx.ReadFromMemory(data) 48 | if err != nil { 49 | return nil, 0, 0, err 50 | } 51 | imgh, err := ctx.GetPrimaryImageHandle() 52 | if err != nil { 53 | return nil, 0, 0, err 54 | } 55 | 56 | width := imgh.GetWidth() 57 | height := imgh.GetHeight() 58 | 59 | img, err := imgh.DecodeImage(heif.ColorspaceUndefined, heif.ChromaUndefined, nil) 60 | if err != nil { 61 | return nil, 0, 0, err 62 | } 63 | 64 | img, err = img.ScaleImage(width/2, height/2) 65 | if err != nil { 66 | return nil, 0, 0, err 67 | } 68 | 69 | goimg, err := img.GetImage() 70 | if err != nil { 71 | return nil, 0, 0, err 72 | } 73 | 74 | return goimg, width / 2, height / 2, nil 75 | } 76 | 77 | func main() { 78 | if len(os.Args) != 2 { 79 | fmt.Printf("USAGE: %s \n", os.Args[0]) 80 | os.Exit(1) 81 | } 82 | 83 | filename := os.Args[1] 84 | imgbytes, err := ioutil.ReadFile(filename) 85 | if err != nil { 86 | panic(err) 87 | } 88 | 89 | count := 100 90 | 91 | var ready sync.WaitGroup 92 | var done sync.WaitGroup 93 | 94 | fmt.Printf("Decoding in %d goroutines ...", count) 95 | ready.Add(count) 96 | done.Add(count) 97 | for i := 0; i < count; i++ { 98 | go func() { 99 | defer done.Done() 100 | ready.Done() 101 | ready.Wait() 102 | _, _, _, err := decodeImage(imgbytes) 103 | if err != nil { 104 | panic(err) 105 | } 106 | }() 107 | } 108 | done.Wait() 109 | fmt.Println("ok") 110 | } 111 | -------------------------------------------------------------------------------- /third-party/aom.cmd: -------------------------------------------------------------------------------- 1 | : # This install script was originally taken from libavif but might have been modified. 2 | 3 | : # If you want to enable the AOM encoder, please check that the WITH_AOM CMake variable is set correctly. 4 | : # You will also have to set the PKG_CONFIG_PATH to "third-party/aom/dist/lib/pkgconfig" so that the local AOM library is found. 5 | 6 | : # The odd choice of comment style in this file is to try to share this script between *nix and win32. 7 | 8 | : # cmake and ninja must be in your PATH. 9 | 10 | : # If you're running this on Windows, be sure you've already run this (from your VC2019 install dir): 11 | : # "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat" 12 | 13 | git clone -b v3.5.0 --depth 1 https://aomedia.googlesource.com/aom 14 | 15 | cd aom 16 | 17 | cmake -S . -B build.libavif -G Ninja -DCMAKE_INSTALL_PREFIX="$(pwd)/dist" -DCMAKE_BUILD_TYPE=Release -DENABLE_DOCS=0 -DENABLE_EXAMPLES=0 -DENABLE_TESTDATA=0 -DENABLE_TESTS=0 -DENABLE_TOOLS=0 18 | ninja -C build.libavif 19 | ninja -C build.libavif install 20 | cd .. 21 | -------------------------------------------------------------------------------- /third-party/dav1d.cmd: -------------------------------------------------------------------------------- 1 | : # This install script was originally taken from libavif but might have been modified. 2 | 3 | : # If you want to enable the DAV1D decoder, please check that the WITH_DAV1D CMake variable is set correctly. 4 | : # You will also have to set the PKG_CONFIG_PATH to "third-party/dav1d/dist/lib/x86_64-linux-gnu/pkgconfig" so that the local DAV1D library is found. 5 | 6 | : # The odd choice of comment style in this file is to try to share this script between *nix and win32. 7 | 8 | : # meson and ninja must be in your PATH. 9 | 10 | : # If you're running this on Windows, be sure you've already run this (from your VC2019 install dir): 11 | : # "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat" 12 | 13 | git clone -b 1.0.0 --depth 1 https://code.videolan.org/videolan/dav1d.git 14 | 15 | cd dav1d 16 | 17 | : # macOS might require: -Dc_args=-fno-stack-check 18 | : # Build with asan: -Db_sanitize=address 19 | : # Build with ubsan: -Db_sanitize=undefined 20 | meson build --default-library=static --buildtype release --prefix "$(pwd)/dist" $@ 21 | ninja -C build 22 | ninja -C build install 23 | cd .. 24 | -------------------------------------------------------------------------------- /third-party/rav1e.cmd: -------------------------------------------------------------------------------- 1 | : # This install script was originally taken from libavif but might have been modified. 2 | 3 | : # If you want to enable the RAV1E encoder, please check that the WITH_RAV1E CMake variable is set correctly. 4 | : # You will also have to set the PKG_CONFIG_PATH to "third-party/rav1e/dist/lib/pkgconfig" so that the local RAV1E library is found. 5 | 6 | : # The odd choice of comment style in this file is to try to share this script between *nix and win32. 7 | 8 | : # cargo must be in your PATH. (use rustup or brew to install) 9 | 10 | : # If you're running this on Windows targeting Rust's windows-msvc, be sure you've already run this (from your VC2017 install dir): 11 | : # "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvars64.bat" 12 | : # 13 | : # Also, the error that "The target windows-msvc is not supported yet" can safely be ignored provided that rav1e/target/release 14 | : # contains rav1e.h and rav1e.lib. 15 | 16 | git clone -b 0.5 --depth 1 https://github.com/xiph/rav1e.git 17 | 18 | cd rav1e 19 | cargo install cargo-c 20 | cargo cinstall --crt-static --release --prefix="$(pwd)/dist" --library-type=staticlib 21 | cd .. 22 | -------------------------------------------------------------------------------- /third-party/svt.cmd: -------------------------------------------------------------------------------- 1 | : # This install script was originally taken from libavif but might have been modified. 2 | 3 | : # cmake and ninja must be in your PATH for compiling. 4 | 5 | : # If you want to enable the SVT-AV1 encoder, please check that the WITH_SvtEnc and WITH_SvtEnc_BUILTIN CMake variables are set correctly. 6 | : # You will also have to set the PKG_CONFIG_PATH to "third-party/SVT-AV1/Build/linux/Release" so that the local SVT-AV1 library is found. 7 | 8 | git clone -b v1.2.1 --depth 1 https://gitlab.com/AOMediaCodec/SVT-AV1.git 9 | 10 | cd SVT-AV1 11 | cd Build/linux 12 | 13 | ./build.sh release static no-dec no-apps 14 | cd ../.. 15 | mkdir -p include/svt-av1 16 | cp Source/API/*.h include/svt-av1 17 | 18 | cd .. 19 | --------------------------------------------------------------------------------