├── .gitattributes ├── dav1d ├── dav1d-tmpl-16.c ├── dav1d-tmpl-8.c ├── vcs_version.h ├── include │ ├── vcs_version.h.in │ ├── dav1d │ │ ├── meson.build │ │ └── version.h │ ├── meson.build │ ├── common │ │ ├── frame.h │ │ ├── validate.h │ │ └── intops.h │ └── compat │ │ └── gcc │ │ └── stdatomic.h ├── dav1d.c ├── dav1d-tmpl.inl ├── dav1d-base.inl └── src │ ├── dav1d.rc.in │ ├── decode.h │ ├── obu.h │ ├── qm.h │ ├── dequant_tables.h │ ├── loongarch │ ├── cpu.h │ ├── cpu.c │ ├── refmvs.h │ ├── cdef.h │ ├── loopfilter.h │ └── msac.h │ ├── ppc │ ├── cpu.h │ ├── mc.h │ ├── cpu.c │ ├── loopfilter.h │ ├── looprestoration.h │ ├── cdef.h │ ├── dav1d_types.h │ └── itx.h │ ├── thread_data.h │ ├── riscv │ ├── 64 │ │ ├── cpu.S │ │ └── pal.S │ ├── cpu.h │ ├── cdef.h │ ├── pal.h │ ├── cpu.c │ ├── itx.h │ └── mc.h │ ├── scan.h │ ├── arm │ ├── cpu.h │ ├── loopfilter.h │ ├── asm-offsets.h │ ├── refmvs.h │ ├── arm-arch.h │ └── msac.h │ ├── cdef_apply.h │ ├── pal.h │ ├── warpmv.h │ ├── lr_apply.h │ ├── log.h │ ├── x86 │ ├── cpuid.asm │ ├── cpu.h │ ├── pal.h │ ├── filmgrain_common.asm │ ├── refmvs.h │ └── loopfilter.h │ ├── itx_1d.h │ ├── log.c │ ├── lf_apply.h │ ├── thread_task.h │ ├── ctx.c │ ├── loopfilter.h │ ├── fg_apply.h │ ├── data.h │ ├── cdef.h │ ├── pal.c │ ├── ref.h │ ├── getbits.h │ └── intra_edge.h ├── testdata ├── fox.avif └── camel.heic ├── libde265 ├── libde265.cc ├── extra │ ├── vendorkeep.go │ └── win32cond.h ├── libde265 │ ├── vendorkeep.go │ ├── arm │ │ ├── vendorkeep.go │ │ ├── Makefile.am │ │ ├── arm.h │ │ ├── cpudetect.S │ │ └── neon.S │ ├── x86 │ │ ├── vendorkeep.go │ │ ├── Makefile.am │ │ ├── CMakeLists.txt │ │ ├── sse.h │ │ └── sse-dct.h │ ├── fallback.h │ ├── deblock.h │ ├── de265-version.h │ ├── de265-version.h.in │ ├── scan.h │ ├── sao.h │ ├── md5.h │ ├── alloc_pool.h │ ├── quality.h │ ├── bitstream.h │ ├── visualize.h │ ├── refpic.h │ ├── transform.h │ ├── Makefile.am │ ├── alloc_pool.cc │ ├── Makefile.vc7 │ └── quality.cc ├── README.md ├── include_cgo.go └── libde265-all.inl ├── heif ├── testdata │ ├── park.heic │ └── rotate.heic ├── README.md └── heif_test.go ├── go.mod ├── go.sum ├── .gitignore ├── LICENSE ├── goheif_test.go ├── README.md └── cmd └── heic2jpg └── main.go /.gitattributes: -------------------------------------------------------------------------------- 1 | * linguist-vendored 2 | *.go linguist-vendored=false 3 | -------------------------------------------------------------------------------- /dav1d/dav1d-tmpl-16.c: -------------------------------------------------------------------------------- 1 | #define BITDEPTH 16 2 | #include "dav1d-tmpl.inl" -------------------------------------------------------------------------------- /dav1d/dav1d-tmpl-8.c: -------------------------------------------------------------------------------- 1 | #define BITDEPTH 8 2 | #include "dav1d-tmpl.inl" 3 | -------------------------------------------------------------------------------- /testdata/fox.avif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdeng/goheif/HEAD/testdata/fox.avif -------------------------------------------------------------------------------- /testdata/camel.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdeng/goheif/HEAD/testdata/camel.heic -------------------------------------------------------------------------------- /dav1d/vcs_version.h: -------------------------------------------------------------------------------- 1 | /* auto-generated, do not edit */ 2 | #define DAV1D_VERSION "1.5.2" 3 | -------------------------------------------------------------------------------- /libde265/libde265.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "libde265-all.inl" 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /heif/testdata/park.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdeng/goheif/HEAD/heif/testdata/park.heic -------------------------------------------------------------------------------- /heif/testdata/rotate.heic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdeng/goheif/HEAD/heif/testdata/rotate.heic -------------------------------------------------------------------------------- /dav1d/include/vcs_version.h.in: -------------------------------------------------------------------------------- 1 | /* auto-generated, do not edit */ 2 | #define DAV1D_VERSION "@VCS_TAG@" 3 | -------------------------------------------------------------------------------- /libde265/extra/vendorkeep.go: -------------------------------------------------------------------------------- 1 | //go:build vendorkeep 2 | // +build vendorkeep 3 | 4 | package cgowrapper 5 | -------------------------------------------------------------------------------- /dav1d/dav1d.c: -------------------------------------------------------------------------------- 1 | #include "dav1d-base.inl" 2 | 3 | #if defined(_WIN32) 4 | #include "src/win32/thread.c" 5 | #endif -------------------------------------------------------------------------------- /libde265/libde265/vendorkeep.go: -------------------------------------------------------------------------------- 1 | //go:build vendorkeep 2 | // +build vendorkeep 3 | 4 | package cgowrapper 5 | -------------------------------------------------------------------------------- /libde265/libde265/arm/vendorkeep.go: -------------------------------------------------------------------------------- 1 | //go:build vendorkeep 2 | // +build vendorkeep 3 | 4 | package cgowrapper 5 | -------------------------------------------------------------------------------- /libde265/libde265/x86/vendorkeep.go: -------------------------------------------------------------------------------- 1 | //go:build vendorkeep 2 | // +build vendorkeep 3 | 4 | package cgowrapper 5 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/jdeng/goheif 2 | 3 | go 1.22.3 4 | 5 | require github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd 6 | -------------------------------------------------------------------------------- /heif/README.md: -------------------------------------------------------------------------------- 1 | This directory is copied from https://github.com/go4org/go4/tree/master/media/heif with modifications in `heif.go` and `bmff.go`. 2 | -------------------------------------------------------------------------------- /libde265/README.md: -------------------------------------------------------------------------------- 1 | The `libde265` directory is copied from https://github.com/strukturag/libde265/tree/master/libde265. Encoder code is removed. 2 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd h1:CmH9+J6ZSsIjUK3dcGsnCnO41eRBOnY12zwkn5qVwgc= 2 | github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk= 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | # Test binary, build with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | 14 | .vscode 15 | -------------------------------------------------------------------------------- /dav1d/dav1d-tmpl.inl: -------------------------------------------------------------------------------- 1 | #include "src/cdef_apply_tmpl.c" 2 | #include "src/cdef_tmpl.c" 3 | #include "src/fg_apply_tmpl.c" 4 | #include "src/filmgrain_tmpl.c" 5 | #include "src/ipred_prepare_tmpl.c" 6 | #include "src/ipred_tmpl.c" 7 | #include "src/itx_tmpl.c" 8 | #include "src/lf_apply_tmpl.c" 9 | #include "src/loopfilter_tmpl.c" 10 | #include "src/looprestoration_tmpl.c" 11 | #include "src/lr_apply_tmpl.c" 12 | #include "src/mc_tmpl.c" 13 | #include "src/recon_tmpl.c" 14 | -------------------------------------------------------------------------------- /libde265/libde265/x86/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libde265_x86.la libde265_x86_sse.la 2 | 3 | libde265_x86_la_CXXFLAGS = -I$(top_srcdir)/libde265 $(CFLAG_VISIBILITY) 4 | libde265_x86_la_SOURCES = sse.cc sse.h 5 | libde265_x86_la_LIBADD = libde265_x86_sse.la 6 | 7 | if HAVE_VISIBILITY 8 | libde265_x86_la_CXXFLAGS += -DHAVE_VISIBILITY 9 | endif 10 | 11 | 12 | # SSE4 specific functions 13 | 14 | libde265_x86_sse_la_CXXFLAGS = -msse4.1 -I$(top_srcdir) -I$(top_srcdir)/libde265 $(CFLAG_VISIBILITY) 15 | libde265_x86_sse_la_SOURCES = sse-motion.cc sse-motion.h sse-dct.h sse-dct.cc 16 | 17 | if HAVE_VISIBILITY 18 | libde265_x86_sse_la_CXXFLAGS += -DHAVE_VISIBILITY 19 | endif 20 | 21 | EXTRA_DIST = \ 22 | CMakeLists.txt 23 | -------------------------------------------------------------------------------- /libde265/libde265/x86/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set (x86_sources 2 | sse.cc sse.h 3 | ) 4 | 5 | set (x86_sse_sources 6 | sse-motion.cc sse-motion.h sse-dct.h sse-dct.cc 7 | ) 8 | 9 | add_library(x86 OBJECT ${x86_sources}) 10 | 11 | add_library(x86_sse OBJECT ${x86_sse_sources}) 12 | 13 | set(sse_flags "") 14 | 15 | if(NOT MSVC) 16 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) 17 | set(sse_flags "${sse_flags} -msse4.1") 18 | else(CMAKE_SIZEOF_VOID_P EQUAL 8) 19 | set(sse_flags "${sse_flags} -msse2 -mssse3 -msse4.1") 20 | endif(CMAKE_SIZEOF_VOID_P EQUAL 8) 21 | endif() 22 | 23 | set(X86_OBJECTS $ $ PARENT_SCOPE) 24 | 25 | SET_TARGET_PROPERTIES(x86_sse PROPERTIES COMPILE_FLAGS "${sse_flags}") 26 | -------------------------------------------------------------------------------- /dav1d/dav1d-base.inl: -------------------------------------------------------------------------------- 1 | #include "src/decode.c" 2 | 3 | #include "src/cdf.c" 4 | #include "src/cpu.c" 5 | #include "src/ctx.c" 6 | #include "src/data.c" 7 | #include "src/dequant_tables.c" 8 | #include "src/getbits.c" 9 | #include "src/intra_edge.c" 10 | #include "src/itx_1d.c" 11 | #include "src/lf_mask.c" 12 | #include "src/lib.c" 13 | #include "src/log.c" 14 | #include "src/mem.c" 15 | #include "src/msac.c" 16 | #include "src/obu.c" 17 | #include "src/pal.c" 18 | #include "src/picture.c" 19 | #include "src/qm.c" 20 | #include "src/ref.c" 21 | #include "src/refmvs.c" 22 | 23 | #define init_internal init_internal_scan 24 | #include "src/scan.c" 25 | #undef init_internal 26 | 27 | #include "src/tables.c" 28 | #include "src/thread_task.c" 29 | #include "src/warpmv.c" 30 | 31 | #define transpose wedge_transpose 32 | #include "src/wedge.c" 33 | #undef transpose 34 | 35 | -------------------------------------------------------------------------------- /libde265/include_cgo.go: -------------------------------------------------------------------------------- 1 | //go:build vendorkeep 2 | // +build vendorkeep 3 | 4 | package libde265 5 | 6 | // https://github.com/golang/go/issues/26366 7 | 8 | // This file exists purely to prevent the golang toolchain from stripping 9 | // away the c source directories and files when `go mod vendor` is used 10 | // to populate a `vendor/` directory of a project depending on `goheif`. 11 | // 12 | // How it works: 13 | // - every directory which only includes c/c++ source files receives a 14 | // vendorkeep.go file. 15 | // - every directory we want to preserve is included here as a _ import. 16 | // - every dummy go file is given a build tag to exclude it from the regular 17 | // build. 18 | 19 | import ( 20 | // Prevent go tooling from stripping out the c source files. 21 | _ "github.com/jdeng/goheif/libde265/extra" 22 | _ "github.com/jdeng/goheif/libde265/libde265" 23 | _ "github.com/jdeng/goheif/libde265/libde265/arm" 24 | _ "github.com/jdeng/goheif/libde265/libde265/x86" 25 | ) 26 | -------------------------------------------------------------------------------- /libde265/libde265/arm/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libde265_arm.la 2 | 3 | libde265_arm_la_CXXFLAGS = -I.. $(CFLAG_VISIBILITY) 4 | libde265_arm_la_SOURCES = arm.cc arm.h 5 | libde265_arm_la_LIBADD = 6 | 7 | if HAVE_VISIBILITY 8 | libde265_arm_la_CXXFLAGS += -DHAVE_VISIBILITY 9 | endif 10 | 11 | 12 | if ENABLE_NEON_OPT 13 | # NEON specific functions 14 | 15 | noinst_LTLIBRARIES += libde265_arm_neon.la 16 | libde265_arm_la_LIBADD += libde265_arm_neon.la 17 | libde265_arm_neon_la_CXXFLAGS = -mfpu=neon -I.. $(CFLAG_VISIBILITY) 18 | libde265_arm_neon_la_CCASFLAGS = -mfpu=neon -I.. \ 19 | -DHAVE_NEON \ 20 | -DEXTERN_ASM= \ 21 | -DHAVE_AS_FUNC \ 22 | -DHAVE_SECTION_DATA_REL_RO 23 | 24 | if ENABLE_ARM_THUMB 25 | libde265_arm_neon_la_CCASFLAGS += -DCONFIG_THUMB 26 | endif 27 | 28 | libde265_arm_neon_la_SOURCES = \ 29 | asm.S \ 30 | cpudetect.S \ 31 | hevcdsp_qpel_neon.S \ 32 | neon.S 33 | 34 | if HAVE_VISIBILITY 35 | libde265_arm_neon_la_CXXFLAGS += -DHAVE_VISIBILITY 36 | endif 37 | 38 | endif 39 | -------------------------------------------------------------------------------- /libde265/libde265/x86/sse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 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 | * libde265 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 libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_SSE_H 22 | #define DE265_SSE_H 23 | 24 | #include "acceleration.h" 25 | 26 | void init_acceleration_functions_sse(struct acceleration_functions* accel); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /libde265/libde265/fallback.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 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 | * libde265 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 libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_FALLBACK_H 22 | #define DE265_FALLBACK_H 23 | 24 | #include "acceleration.h" 25 | 26 | void init_acceleration_functions_fallback(struct acceleration_functions* lowlevel); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /libde265/libde265/arm/arm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2015 struktur AG, Joachim Bauch 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 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 | * libde265 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 libde265. If not, see . 19 | */ 20 | 21 | #ifndef LIBDE265_ARM_H 22 | #define LIBDE265_ARM_H 23 | 24 | #include "acceleration.h" 25 | 26 | void init_acceleration_functions_arm(struct acceleration_functions* accel); 27 | 28 | #endif // LIBDE265_ARM_H 29 | -------------------------------------------------------------------------------- /libde265/libde265/deblock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 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 | * libde265 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 libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_DEBLOCK_H 22 | #define DE265_DEBLOCK_H 23 | 24 | #include "libde265/decctx.h" 25 | 26 | void add_deblocking_tasks(image_unit* imgunit); 27 | void apply_deblocking_filter(de265_image* img); //decoder_context* ctx); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /libde265/libde265/arm/cpudetect.S: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2015 struktur AG, Joachim Bauch 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 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 | * libde265 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 libde265. If not, see . 19 | */ 20 | 21 | #include "asm.S" 22 | #include "neon.S" 23 | 24 | // we execute a simple NEON instruction and check if SIGILL is triggered to 25 | // detect if the CPU support NEON code 26 | function libde265_detect_neon, export=1 27 | vand q0, q0, q0 28 | bx lr 29 | endfunc 30 | -------------------------------------------------------------------------------- /dav1d/src/dav1d.rc.in: -------------------------------------------------------------------------------- 1 | #define API_VERSION_NUMBER @API_VERSION_MAJOR@,@API_VERSION_MINOR@,@API_VERSION_REVISION@,0 2 | #define API_VERSION_NUMBER_STR "@API_VERSION_MAJOR@.@API_VERSION_MINOR@.@API_VERSION_REVISION@" 3 | #define PROJECT_VERSION_NUMBER @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_REVISION@,0 4 | #define PROJECT_VERSION_NUMBER_STR "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_REVISION@" 5 | 6 | #include 7 | 8 | 1 VERSIONINFO 9 | FILETYPE VFT_DLL 10 | FILEOS VOS_NT_WINDOWS32 11 | PRODUCTVERSION PROJECT_VERSION_NUMBER 12 | FILEVERSION API_VERSION_NUMBER 13 | BEGIN 14 | BLOCK "StringFileInfo" 15 | BEGIN 16 | BLOCK "040904E4" 17 | BEGIN 18 | VALUE "CompanyName", "VideoLAN" 19 | VALUE "ProductName", "dav1d" 20 | VALUE "ProductVersion", PROJECT_VERSION_NUMBER_STR 21 | VALUE "FileVersion", API_VERSION_NUMBER_STR 22 | VALUE "FileDescription", "dav1d " PROJECT_VERSION_NUMBER_STR " - AV1 decoder" 23 | VALUE "InternalName", "dav1d" 24 | VALUE "OriginalFilename", "libdav1d.dll" 25 | VALUE "LegalCopyright", L"Copyright \251 @COPYRIGHT_YEARS@ VideoLAN and dav1d Authors" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x409, 1252 31 | END 32 | END 33 | -------------------------------------------------------------------------------- /libde265/libde265/de265-version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 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 | * libde265 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 libde265. If not, see . 19 | */ 20 | 21 | /* de265-version.h 22 | * 23 | * This file was generated by autoconf when libde265 was built. 24 | * 25 | * DO NOT EDIT THIS FILE. 26 | */ 27 | #ifndef LIBDE265_VERSION_H 28 | #define LIBDE265_VERSION_H 29 | 30 | /* Numeric representation of the version */ 31 | #define LIBDE265_NUMERIC_VERSION 0x01001500 32 | 33 | /* Version string */ 34 | #define LIBDE265_VERSION "1.0.15" 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /libde265/libde265/de265-version.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 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 | * libde265 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 libde265. If not, see . 19 | */ 20 | 21 | /* de265-version.h 22 | * 23 | * This file was generated by autoconf when libde265 was built. 24 | * 25 | * DO NOT EDIT THIS FILE. 26 | */ 27 | #ifndef LIBDE265_VERSION_H 28 | #define LIBDE265_VERSION_H 29 | 30 | /* Numeric representation of the version */ 31 | #define LIBDE265_NUMERIC_VERSION @NUMERIC_VERSION@ 32 | 33 | /* Version string */ 34 | #define LIBDE265_VERSION "@PACKAGE_VERSION@" 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Jack Deng 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | Note: The directories 'heif' and 'libde265' contain third-party code which is 24 | licensed under their respective licenses (Apache-2.0 and LGPL-3.0) as provided 25 | in those directories. 26 | -------------------------------------------------------------------------------- /libde265/libde265-all.inl: -------------------------------------------------------------------------------- 1 | #if _WIN32 2 | #include "extra/win32cond.c" 3 | #define HAVE___MINGW_ALIGNED_MALLOC 1 4 | #else 5 | #define HAVE_POSIX_MEMALIGN 1 6 | #endif 7 | 8 | //#define HAVE_NEON 1 // disable NEON for ARM as cgo wont compile the .S files 9 | 10 | #include "alloc_pool.cc" 11 | #include "bitstream.cc" 12 | #include "cabac.cc" 13 | #include "configparam.cc" 14 | #include "contextmodel.cc" 15 | #include "de265.cc" 16 | #include "deblock.cc" 17 | #include "decctx.cc" 18 | #include "dpb.cc" 19 | // #include "en265.cc" 20 | #include "fallback-dct.cc" 21 | #include "fallback-motion.cc" 22 | #include "fallback.cc" 23 | #include "image-io.cc" 24 | #include "image.cc" 25 | #include "intrapred.cc" 26 | #include "md5.cc" 27 | #include "motion.cc" 28 | #include "nal-parser.cc" 29 | #include "nal.cc" 30 | #include "pps.cc" 31 | #include "quality.cc" 32 | #include "refpic.cc" 33 | #include "sao.cc" 34 | #include "scan.cc" 35 | #include "sei.cc" 36 | #include "slice.cc" 37 | #include "sps.cc" 38 | #include "threads.cc" 39 | #include "transform.cc" 40 | #include "util.cc" 41 | #include "visualize.cc" 42 | #include "vps.cc" 43 | #include "vui.cc" 44 | 45 | #ifdef HAVE_SSE4_1 46 | #include "x86/sse-dct.cc" 47 | #include "x86/sse-motion.cc" 48 | #include "x86/sse.cc" 49 | #endif 50 | 51 | #ifdef HAVE_ARM 52 | #include "arm/arm.cc" 53 | #endif 54 | 55 | 56 | -------------------------------------------------------------------------------- /libde265/libde265/scan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 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 | * libde265 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 libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_SCAN_H 22 | #define DE265_SCAN_H 23 | 24 | #include 25 | 26 | typedef struct { 27 | uint8_t x,y; 28 | } position; 29 | 30 | typedef struct { 31 | uint8_t subBlock; 32 | uint8_t scanPos; 33 | } scan_position; 34 | 35 | void init_scan_orders(); 36 | 37 | /* scanIdx: 0 - diag, 1 - horiz, 2 - verti 38 | */ 39 | const position* get_scan_order(int log2BlockSize, int scanIdx); 40 | 41 | scan_position get_scan_position(int x,int y, int scanIdx, int log2BlkSize); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /libde265/libde265/sao.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 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 | * libde265 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 libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_SAO_H 22 | #define DE265_SAO_H 23 | 24 | #include "libde265/decctx.h" 25 | 26 | void apply_sample_adaptive_offset(de265_image* img); 27 | 28 | /* requires less memory than the function above */ 29 | void apply_sample_adaptive_offset_sequential(de265_image* img); 30 | 31 | /* saoInputProgress - the CTB progress that SAO will wait for before beginning processing. 32 | Returns 'true' if any tasks have been added. 33 | */ 34 | bool add_sao_tasks(image_unit* imgunit, int saoInputProgress); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /libde265/libde265/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. 3 | * MD5 Message-Digest Algorithm (RFC 1321). 4 | * 5 | * Homepage: 6 | * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5 7 | * 8 | * Author: 9 | * Alexander Peslyak, better known as Solar Designer 10 | * 11 | * This software was written by Alexander Peslyak in 2001. No copyright is 12 | * claimed, and the software is hereby placed in the public domain. 13 | * In case this attempt to disclaim copyright and place the software in the 14 | * public domain is deemed null and void, then the software is 15 | * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the 16 | * general public under the following terms: 17 | * 18 | * Redistribution and use in source and binary forms, with or without 19 | * modification, are permitted. 20 | * 21 | * There's ABSOLUTELY NO WARRANTY, express or implied. 22 | * 23 | * See md5.c for more information. 24 | */ 25 | 26 | #ifdef HAVE_OPENSSL 27 | #include 28 | #elif !defined(_MD5_H) 29 | #define _MD5_H 30 | 31 | /* Any 32-bit or wider unsigned integer data type will do */ 32 | typedef unsigned int MD5_u32plus; 33 | 34 | typedef struct { 35 | MD5_u32plus lo, hi; 36 | MD5_u32plus a, b, c, d; 37 | unsigned char buffer[64]; 38 | MD5_u32plus block[16]; 39 | } MD5_CTX; 40 | 41 | extern void MD5_Init(MD5_CTX *ctx); 42 | extern void MD5_Update(MD5_CTX *ctx, void *data, unsigned long size); 43 | extern void MD5_Final(unsigned char *result, MD5_CTX *ctx); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /libde265/libde265/alloc_pool.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2014 struktur AG, Dirk Farin 4 | * 5 | * Authors: Dirk Farin 6 | * 7 | * This file is part of libde265. 8 | * 9 | * libde265 is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of 12 | * the License, or (at your option) any later version. 13 | * 14 | * libde265 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 Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with libde265. If not, see . 21 | */ 22 | 23 | #ifndef ALLOC_POOL_H 24 | #define ALLOC_POOL_H 25 | 26 | #ifdef HAVE_CONFIG_H 27 | #include "config.h" 28 | #endif 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | 35 | class alloc_pool 36 | { 37 | public: 38 | alloc_pool(size_t objSize, int poolSize=1000, bool grow=true); 39 | ~alloc_pool(); 40 | 41 | void* new_obj(const size_t size); 42 | void delete_obj(void*); 43 | void purge(); 44 | 45 | private: 46 | size_t mObjSize; 47 | int mPoolSize; 48 | bool mGrow; 49 | 50 | std::vector m_memBlocks; 51 | std::vector m_freeList; 52 | 53 | void add_memory_block(); 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /libde265/libde265/x86/sse-dct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013 openHEVC contributors 4 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 5 | * 6 | * This file is part of libde265. 7 | * 8 | * libde265 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 | * libde265 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 libde265. If not, see . 20 | */ 21 | 22 | #ifndef SSE_DCT_H 23 | #define SSE_DCT_H 24 | 25 | #include 26 | #include 27 | 28 | void ff_hevc_transform_skip_8_sse(uint8_t *_dst, const int16_t *coeffs, ptrdiff_t _stride); 29 | void ff_hevc_transform_4x4_luma_add_8_sse4(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride); 30 | void ff_hevc_transform_4x4_add_8_sse4(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride); 31 | void ff_hevc_transform_8x8_add_8_sse4(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride); 32 | void ff_hevc_transform_16x16_add_8_sse4(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride); 33 | void ff_hevc_transform_32x32_add_8_sse4(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /dav1d/src/decode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * Copyright © 2018, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_DECODE_H 29 | #define DAV1D_SRC_DECODE_H 30 | 31 | #include "src/internal.h" 32 | 33 | int dav1d_submit_frame(Dav1dContext *c); 34 | 35 | #endif /* DAV1D_SRC_DECODE_H */ 36 | -------------------------------------------------------------------------------- /dav1d/include/dav1d/meson.build: -------------------------------------------------------------------------------- 1 | # Copyright © 2019, VideoLAN and dav1d authors 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # 7 | # 1. Redistributions of source code must retain the above copyright notice, this 8 | # list of conditions and the following disclaimer. 9 | # 10 | # 2. Redistributions in binary form must reproduce the above copyright notice, 11 | # this list of conditions and the following disclaimer in the documentation 12 | # and/or other materials provided with the distribution. 13 | # 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 18 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | dav1d_api_headers = [ 26 | 'common.h', 27 | 'data.h', 28 | 'dav1d.h', 29 | 'headers.h', 30 | 'picture.h', 31 | 'version.h', 32 | ] 33 | 34 | # install headers 35 | install_headers(dav1d_api_headers, 36 | subdir : 'dav1d') 37 | -------------------------------------------------------------------------------- /dav1d/src/obu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * Copyright © 2018, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_OBU_H 29 | #define DAV1D_SRC_OBU_H 30 | 31 | #include "dav1d/data.h" 32 | #include "src/internal.h" 33 | 34 | ptrdiff_t dav1d_parse_obus(Dav1dContext *c, Dav1dData *in); 35 | 36 | #endif /* DAV1D_SRC_OBU_H */ 37 | -------------------------------------------------------------------------------- /dav1d/src/qm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * Copyright © 2018, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_QM_H 29 | #define DAV1D_SRC_QM_H 30 | 31 | #include "src/levels.h" 32 | 33 | EXTERN const uint8_t *dav1d_qm_tbl[16][2][N_RECT_TX_SIZES]; 34 | 35 | void dav1d_init_qm_tables(void); 36 | 37 | #endif /* DAV1D_SRC_QM_H */ 38 | -------------------------------------------------------------------------------- /dav1d/include/meson.build: -------------------------------------------------------------------------------- 1 | # Copyright © 2018, VideoLAN and dav1d authors 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # 7 | # 1. Redistributions of source code must retain the above copyright notice, this 8 | # list of conditions and the following disclaimer. 9 | # 10 | # 2. Redistributions in binary form must reproduce the above copyright notice, 11 | # this list of conditions and the following disclaimer in the documentation 12 | # and/or other materials provided with the distribution. 13 | # 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 18 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | # Revision file (vcs_version.h) generation 26 | dav1d_git_dir = join_paths(dav1d_src_root, '.git') 27 | rev_target = vcs_tag(command: [ 28 | 'git', '--git-dir', dav1d_git_dir, 'describe', '--long', '--always' 29 | ], 30 | input: 'vcs_version.h.in', 31 | output: 'vcs_version.h' 32 | ) 33 | 34 | subdir('dav1d') 35 | -------------------------------------------------------------------------------- /dav1d/src/dequant_tables.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018-2021, VideoLAN and dav1d authors 3 | * Copyright © 2018, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_DEQUANT_TABLES_H 29 | #define DAV1D_SRC_DEQUANT_TABLES_H 30 | 31 | #include 32 | 33 | #include "src/levels.h" 34 | 35 | EXTERN const uint16_t dav1d_dq_tbl[3][QINDEX_RANGE][2]; 36 | 37 | #endif /* DAV1D_SRC_DEQUANT_TABLES_H */ 38 | -------------------------------------------------------------------------------- /dav1d/src/loongarch/cpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2023, VideoLAN and dav1d authors 3 | * 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 are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef DAV1D_SRC_LOONGARCH_CPU_H 28 | #define DAV1D_SRC_LOONGARCH_CPU_H 29 | 30 | enum CpuFlags { 31 | DAV1D_LOONGARCH_CPU_FLAG_LSX = 1 << 0, 32 | DAV1D_LOONGARCH_CPU_FLAG_LASX = 1 << 1, 33 | }; 34 | 35 | unsigned dav1d_get_cpu_flags_loongarch(void); 36 | 37 | #endif /* DAV1D_SRC_LOONGARCH_CPU_H */ 38 | -------------------------------------------------------------------------------- /dav1d/src/ppc/cpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019, VideoLAN and dav1d authors 3 | * Copyright © 2019, Janne Grunau 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_PPC_CPU_H 29 | #define DAV1D_SRC_PPC_CPU_H 30 | 31 | enum CpuFlags { 32 | DAV1D_PPC_CPU_FLAG_VSX = 1 << 0, 33 | DAV1D_PPC_CPU_FLAG_PWR9 = 1 << 1, 34 | }; 35 | 36 | unsigned dav1d_get_cpu_flags_ppc(void); 37 | 38 | #endif /* DAV1D_SRC_PPC_CPU_H */ 39 | -------------------------------------------------------------------------------- /dav1d/src/thread_data.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * Copyright © 2018, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_THREAD_DATA_H 29 | #define DAV1D_SRC_THREAD_DATA_H 30 | 31 | #include "src/thread.h" 32 | 33 | struct thread_data { 34 | pthread_t thread; 35 | pthread_cond_t cond; 36 | pthread_mutex_t lock; 37 | int inited; 38 | }; 39 | 40 | #endif /* DAV1D_SRC_THREAD_DATA_H */ 41 | -------------------------------------------------------------------------------- /dav1d/src/riscv/cpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2022, VideoLAN and dav1d authors 3 | * Copyright © 2022, Nathan Egge 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_RISCV_CPU_H 29 | #define DAV1D_SRC_RISCV_CPU_H 30 | 31 | enum CpuFlags { 32 | DAV1D_RISCV_CPU_FLAG_V = 1 << 0, 33 | }; 34 | 35 | unsigned dav1d_get_cpu_flags_riscv(void); 36 | 37 | int dav1d_get_vlenb(void); 38 | 39 | #define dav1d_get_vlen() (dav1d_get_vlenb()*8) 40 | 41 | #endif /* DAV1D_SRC_RISCV_CPU_H */ 42 | -------------------------------------------------------------------------------- /libde265/libde265/quality.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 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 | * libde265 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 libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_QUALITY_H 22 | #define DE265_QUALITY_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | LIBDE265_API uint32_t SSD(const uint8_t* img, int imgStride, 30 | const uint8_t* ref, int refStride, 31 | int width, int height); 32 | 33 | LIBDE265_API uint32_t SAD(const uint8_t* img, int imgStride, 34 | const uint8_t* ref, int refStride, 35 | int width, int height); 36 | 37 | LIBDE265_API double MSE(const uint8_t* img, int imgStride, 38 | const uint8_t* ref, int refStride, 39 | int width, int height); 40 | 41 | LIBDE265_API double PSNR(double mse); 42 | 43 | 44 | LIBDE265_API uint32_t compute_distortion_ssd(const de265_image* img1, const de265_image* img2, 45 | int x0, int y0, int log2size, int cIdx); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /dav1d/src/riscv/cdef.h: -------------------------------------------------------------------------------- 1 | #include "src/cpu.h" 2 | #include "src/cdef.h" 3 | 4 | extern void BF(dav1d_cdef_filter_block_4x4, rvv)(pixel *dst, const ptrdiff_t dst_stride, 5 | const pixel (*left)[2], 6 | const pixel *const top, const pixel *const bottom, 7 | const int pri_strength, const int sec_strength, const int dir, 8 | const int damping, const enum CdefEdgeFlags edges HIGHBD_DECL_SUFFIX); 9 | 10 | extern void BF(dav1d_cdef_filter_block_4x8, rvv)(pixel *dst, const ptrdiff_t dst_stride, 11 | const pixel (*left)[2], 12 | const pixel *const top, const pixel *const bottom, 13 | const int pri_strength, const int sec_strength, const int dir, 14 | const int damping, const enum CdefEdgeFlags edges HIGHBD_DECL_SUFFIX); 15 | 16 | extern void BF(dav1d_cdef_filter_block_8x8, rvv)(pixel *dst, const ptrdiff_t dst_stride, 17 | const pixel (*left)[2], 18 | const pixel *const top, const pixel *const bottom, 19 | const int pri_strength, const int sec_strength, const int dir, 20 | const int damping, const enum CdefEdgeFlags edges HIGHBD_DECL_SUFFIX); 21 | 22 | 23 | static ALWAYS_INLINE void cdef_dsp_init_riscv(Dav1dCdefDSPContext *const c) { 24 | const unsigned flags = dav1d_get_cpu_flags(); 25 | if (!(flags & DAV1D_RISCV_CPU_FLAG_V)) return; 26 | 27 | // c->dir = BF(dav1d_cdef_dir, rvv); 28 | c->fb[0] = BF(dav1d_cdef_filter_block_8x8, rvv); 29 | c->fb[1] = BF(dav1d_cdef_filter_block_4x8, rvv); 30 | c->fb[2] = BF(dav1d_cdef_filter_block_4x4, rvv); 31 | } 32 | -------------------------------------------------------------------------------- /dav1d/src/riscv/pal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2023, VideoLAN and dav1d authors 3 | * Copyright © 2024, Bogdan Gligorijevic 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "src/cpu.h" 29 | #include "src/pal.h" 30 | 31 | decl_pal_idx_finish_fn(dav1d_pal_idx_finish_rvv); 32 | 33 | static ALWAYS_INLINE void pal_dsp_init_riscv(Dav1dPalDSPContext *const c) { 34 | const unsigned flags = dav1d_get_cpu_flags(); 35 | 36 | if (!(flags & DAV1D_RISCV_CPU_FLAG_V)) return; 37 | 38 | c->pal_idx_finish = dav1d_pal_idx_finish_rvv; 39 | } 40 | -------------------------------------------------------------------------------- /dav1d/src/scan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018-2021, VideoLAN and dav1d authors 3 | * Copyright © 2018, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_SCAN_H 29 | #define DAV1D_SRC_SCAN_H 30 | 31 | #include 32 | 33 | #include "src/levels.h" 34 | 35 | EXTERN const uint16_t *const dav1d_scans[N_RECT_TX_SIZES]; 36 | EXTERN const uint8_t *const dav1d_last_nonzero_col_from_eob[N_RECT_TX_SIZES]; 37 | 38 | void dav1d_init_last_nonzero_col_from_eob_tables(void); 39 | 40 | #endif /* DAV1D_SRC_SCAN_H */ 41 | -------------------------------------------------------------------------------- /dav1d/src/arm/cpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * Copyright © 2018, Janne Grunau 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_ARM_CPU_H 29 | #define DAV1D_SRC_ARM_CPU_H 30 | 31 | enum CpuFlags { 32 | DAV1D_ARM_CPU_FLAG_NEON = 1 << 0, 33 | DAV1D_ARM_CPU_FLAG_DOTPROD = 1 << 1, 34 | DAV1D_ARM_CPU_FLAG_I8MM = 1 << 2, 35 | DAV1D_ARM_CPU_FLAG_SVE = 1 << 3, 36 | DAV1D_ARM_CPU_FLAG_SVE2 = 1 << 4, 37 | }; 38 | 39 | unsigned dav1d_get_cpu_flags_arm(void); 40 | 41 | #endif /* DAV1D_SRC_ARM_CPU_H */ 42 | -------------------------------------------------------------------------------- /dav1d/src/cdef_apply.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * Copyright © 2018, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_CDEF_APPLY_H 29 | #define DAV1D_SRC_CDEF_APPLY_H 30 | 31 | #include "common/bitdepth.h" 32 | 33 | #include "src/internal.h" 34 | 35 | void bytefn(dav1d_cdef_brow)(Dav1dTaskContext *tc, pixel *const p[3], 36 | const Av1Filter *lflvl, int by_start, int by_end, 37 | int sbrow_start, int sby); 38 | 39 | #endif /* DAV1D_SRC_CDEF_APPLY_H */ 40 | -------------------------------------------------------------------------------- /dav1d/src/pal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2023, VideoLAN and dav1d authors 3 | * Copyright © 2023, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_PAL_H 29 | #define DAV1D_SRC_PAL_H 30 | 31 | #include 32 | 33 | #define decl_pal_idx_finish_fn(name) \ 34 | void (name)(uint8_t *dst, const uint8_t *src, int bw, int bh, int w, int h) 35 | typedef decl_pal_idx_finish_fn(*pal_idx_finish_fn); 36 | 37 | typedef struct Dav1dPalDSPContext { 38 | pal_idx_finish_fn pal_idx_finish; 39 | } Dav1dPalDSPContext; 40 | 41 | void dav1d_pal_dsp_init(Dav1dPalDSPContext *dsp); 42 | 43 | #endif /* DAV1D_SRC_PAL_H */ 44 | -------------------------------------------------------------------------------- /dav1d/src/warpmv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * Copyright © 2018, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_WARPMV_H 29 | #define DAV1D_SRC_WARPMV_H 30 | 31 | #include "src/levels.h" 32 | 33 | int dav1d_get_shear_params(Dav1dWarpedMotionParams *wm); 34 | int dav1d_find_affine_int(const int (*pts)[2][2], int np, int bw4, int bh4, 35 | mv mv, Dav1dWarpedMotionParams *wm, int bx, int by); 36 | void dav1d_set_affine_mv2d(int bw4, int bh4, 37 | mv mv, Dav1dWarpedMotionParams *wm, int bx, int by); 38 | 39 | #endif /* DAV1D_SRC_WARPMV_H */ 40 | -------------------------------------------------------------------------------- /dav1d/src/lr_apply.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * Copyright © 2018, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_LR_APPLY_H 29 | #define DAV1D_SRC_LR_APPLY_H 30 | 31 | #include 32 | #include 33 | 34 | #include "common/bitdepth.h" 35 | 36 | #include "src/internal.h" 37 | 38 | enum LrRestorePlanes { 39 | LR_RESTORE_Y = 1 << 0, 40 | LR_RESTORE_U = 1 << 1, 41 | LR_RESTORE_V = 1 << 2, 42 | }; 43 | 44 | void bytefn(dav1d_lr_sbrow)(Dav1dFrameContext *const f, pixel *const dst[3], 45 | int sby); 46 | 47 | #endif /* DAV1D_SRC_LR_APPLY_H */ 48 | -------------------------------------------------------------------------------- /dav1d/src/log.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * 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 are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef DAV1D_SRC_LOG_H 28 | #define DAV1D_SRC_LOG_H 29 | 30 | #include "config.h" 31 | 32 | #include 33 | 34 | #include "dav1d/dav1d.h" 35 | 36 | #include "common/attributes.h" 37 | 38 | #if CONFIG_LOG 39 | #define dav1d_log dav1d_log 40 | void dav1d_log_default_callback(void *cookie, const char *format, va_list ap); 41 | void dav1d_log(Dav1dContext *c, const char *format, ...) ATTR_FORMAT_PRINTF(2, 3); 42 | #else 43 | #define dav1d_log_default_callback NULL 44 | #define dav1d_log(...) do { } while(0) 45 | #endif 46 | 47 | #endif /* DAV1D_SRC_LOG_H */ 48 | -------------------------------------------------------------------------------- /libde265/libde265/bitstream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 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 | * libde265 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 libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_BITSTREAM_H 22 | #define DE265_BITSTREAM_H 23 | 24 | #ifdef HAVE_CONFIG_H 25 | #include 26 | #endif 27 | 28 | #include 29 | #include 30 | 31 | 32 | #define MAX_UVLC_LEADING_ZEROS 20 33 | #define UVLC_ERROR -99999 34 | 35 | 36 | typedef struct { 37 | uint8_t* data; 38 | int bytes_remaining; 39 | 40 | uint64_t nextbits; // left-aligned bits 41 | int nextbits_cnt; 42 | } bitreader; 43 | 44 | void bitreader_init(bitreader*, unsigned char* buffer, int len); 45 | void bitreader_refill(bitreader*); // refill to at least 56+1 bits 46 | int next_bit(bitreader*); 47 | int next_bit_norefill(bitreader*); 48 | int get_bits(bitreader*, int n); 49 | int get_bits_fast(bitreader*, int n); 50 | int peek_bits(bitreader*, int n); 51 | void skip_bits(bitreader*, int n); 52 | void skip_bits_fast(bitreader*, int n); 53 | void skip_to_byte_boundary(bitreader*); 54 | void prepare_for_CABAC(bitreader*); 55 | int get_uvlc(bitreader*); // may return UVLC_ERROR 56 | int get_svlc(bitreader*); // may return UVLC_ERROR 57 | 58 | bool check_rbsp_trailing_bits(bitreader*); // return true if remaining filler bits are all zero 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /dav1d/include/common/frame.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2021, VideoLAN and dav1d authors 3 | * 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 are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef DAV1D_COMMON_FRAME_H 28 | #define DAV1D_COMMON_FRAME_H 29 | 30 | /* 31 | * Checks whether Dav1dFrameType == INTER || == SWITCH 32 | * Both are defined as odd numbers {1, 3} and therefore have the LSB set. 33 | * See also: AV1 spec 6.8.2 34 | */ 35 | #define IS_INTER_OR_SWITCH(frame_header) \ 36 | ((frame_header)->frame_type & 1) 37 | 38 | /* 39 | * Checks whether Dav1dFrameType == KEY || == INTRA 40 | * See also: AV1 spec 6.8.2 41 | */ 42 | #define IS_KEY_OR_INTRA(frame_header) \ 43 | (!IS_INTER_OR_SWITCH(frame_header)) 44 | 45 | #endif /* DAV1D_COMMON_FRAME_H */ 46 | -------------------------------------------------------------------------------- /dav1d/src/ppc/mc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2024, VideoLAN and dav1d authors 3 | * Copyright © 2024, Luca Barbato 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "src/cpu.h" 29 | #include "src/mc.h" 30 | 31 | decl_blend_fn(BF(dav1d_blend, pwr9)); 32 | decl_blend_dir_fn(BF(dav1d_blend_h, pwr9)); 33 | decl_blend_dir_fn(BF(dav1d_blend_v, pwr9)); 34 | 35 | static ALWAYS_INLINE void mc_dsp_init_ppc(Dav1dMCDSPContext *const c) { 36 | const unsigned flags = dav1d_get_cpu_flags(); 37 | 38 | if (!(flags & DAV1D_PPC_CPU_FLAG_PWR9)) return; 39 | 40 | #if BITDEPTH == 8 41 | c->blend = BF(dav1d_blend, pwr9); 42 | c->blend_h = BF(dav1d_blend_h, pwr9); 43 | c->blend_v = BF(dav1d_blend_v, pwr9); 44 | #endif 45 | 46 | } 47 | -------------------------------------------------------------------------------- /dav1d/include/dav1d/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019-2024, VideoLAN and dav1d authors 3 | * 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 are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef DAV1D_VERSION_H 28 | #define DAV1D_VERSION_H 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | #define DAV1D_API_VERSION_MAJOR 7 35 | #define DAV1D_API_VERSION_MINOR 0 36 | #define DAV1D_API_VERSION_PATCH 0 37 | 38 | /** 39 | * Extract version components from the value returned by 40 | * dav1d_version_int() 41 | */ 42 | #define DAV1D_API_MAJOR(v) (((v) >> 16) & 0xFF) 43 | #define DAV1D_API_MINOR(v) (((v) >> 8) & 0xFF) 44 | #define DAV1D_API_PATCH(v) (((v) >> 0) & 0xFF) 45 | 46 | #ifdef __cplusplus 47 | } /* extern "C" */ 48 | #endif 49 | 50 | #endif /* DAV1D_VERSION_H */ 51 | -------------------------------------------------------------------------------- /dav1d/src/loongarch/cpu.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2023, VideoLAN and dav1d authors 3 | * 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 are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include "config.h" 28 | #include "common/attributes.h" 29 | 30 | #include "src/cpu.h" 31 | #include "src/loongarch/cpu.h" 32 | 33 | #if HAVE_GETAUXVAL 34 | #include 35 | 36 | #define LA_HWCAP_LSX ( 1 << 4 ) 37 | #define LA_HWCAP_LASX ( 1 << 5 ) 38 | #endif 39 | 40 | COLD unsigned dav1d_get_cpu_flags_loongarch(void) { 41 | unsigned flags = dav1d_get_default_cpu_flags(); 42 | #if HAVE_GETAUXVAL 43 | unsigned long hw_cap = dav1d_getauxval(AT_HWCAP); 44 | flags |= (hw_cap & LA_HWCAP_LSX) ? DAV1D_LOONGARCH_CPU_FLAG_LSX : 0; 45 | flags |= (hw_cap & LA_HWCAP_LASX) ? DAV1D_LOONGARCH_CPU_FLAG_LASX : 0; 46 | #endif 47 | 48 | return flags; 49 | } 50 | -------------------------------------------------------------------------------- /dav1d/src/x86/cpuid.asm: -------------------------------------------------------------------------------- 1 | ; Copyright © 2018, VideoLAN and dav1d authors 2 | ; Copyright © 2018, Two Orioles, LLC 3 | ; 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 are met: 7 | ; 8 | ; 1. Redistributions of source code must retain the above copyright notice, this 9 | ; list of conditions and the following disclaimer. 10 | ; 11 | ; 2. Redistributions in binary form must reproduce the above copyright notice, 12 | ; this list of conditions and the following disclaimer in the documentation 13 | ; and/or other materials provided with the distribution. 14 | ; 15 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | ; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | ; ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | %include "config.asm" 27 | %include "ext/x86/x86inc.asm" 28 | 29 | SECTION .text 30 | 31 | cglobal cpu_cpuid, 0, 5, 0, regs, leaf, subleaf 32 | mov r4, regsmp 33 | mov eax, leafm 34 | mov ecx, subleafm 35 | %if ARCH_X86_64 36 | mov r5, rbx 37 | %endif 38 | cpuid 39 | mov [r4+4*0], eax 40 | mov [r4+4*1], ebx 41 | mov [r4+4*2], edx 42 | mov [r4+4*3], ecx 43 | %if ARCH_X86_64 44 | mov rbx, r5 45 | %endif 46 | RET 47 | 48 | cglobal cpu_xgetbv, 0, 0, 0, xcr 49 | movifnidn ecx, xcrm 50 | xgetbv 51 | %if ARCH_X86_64 52 | shl rdx, 32 53 | or rax, rdx 54 | %endif 55 | RET 56 | -------------------------------------------------------------------------------- /dav1d/src/riscv/cpu.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2022, VideoLAN and dav1d authors 3 | * Copyright © 2022, Nathan Egge 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "config.h" 29 | 30 | #include "common/attributes.h" 31 | 32 | #include "src/cpu.h" 33 | #include "src/riscv/cpu.h" 34 | 35 | #if HAVE_GETAUXVAL || HAVE_ELF_AUX_INFO 36 | #include 37 | #define HWCAP_RVV (1 << ('v' - 'a')) 38 | #endif 39 | 40 | int dav1d_has_compliant_rvv(void); 41 | 42 | COLD unsigned dav1d_get_cpu_flags_riscv(void) { 43 | unsigned flags = dav1d_get_default_cpu_flags(); 44 | #if HAVE_GETAUXVAL || HAVE_ELF_AUX_INFO 45 | unsigned long hw_cap = dav1d_getauxval(AT_HWCAP); 46 | flags |= (hw_cap & HWCAP_RVV) && dav1d_has_compliant_rvv() ? DAV1D_RISCV_CPU_FLAG_V : 0; 47 | #endif 48 | 49 | return flags; 50 | } 51 | -------------------------------------------------------------------------------- /dav1d/src/itx_1d.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018-2019, VideoLAN and dav1d authors 3 | * Copyright © 2018-2019, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | #include "src/levels.h" 32 | 33 | #ifndef DAV1D_SRC_ITX_1D_H 34 | #define DAV1D_SRC_ITX_1D_H 35 | 36 | enum Tx1dType { 37 | DCT, 38 | ADST, 39 | IDENTITY, 40 | FLIPADST, 41 | N_TX_1D_TYPES, 42 | }; 43 | 44 | #define decl_itx_1d_fn(name) \ 45 | void (name)(int32_t *c, ptrdiff_t stride, int min, int max) 46 | typedef decl_itx_1d_fn(*itx_1d_fn); 47 | 48 | EXTERN const itx_1d_fn dav1d_tx1d_fns[N_TX_SIZES][N_TX_1D_TYPES]; 49 | EXTERN const uint8_t /* enum Tx1dType */ dav1d_tx1d_types[N_TX_TYPES][2]; 50 | 51 | void dav1d_inv_wht4_1d_c(int32_t *c, ptrdiff_t stride); 52 | 53 | #endif /* DAV1D_SRC_ITX_1D_H */ 54 | -------------------------------------------------------------------------------- /goheif_test.go: -------------------------------------------------------------------------------- 1 | package goheif 2 | 3 | import ( 4 | "bytes" 5 | "image" 6 | "io" 7 | "os" 8 | "testing" 9 | ) 10 | 11 | func TestFormatRegistered(t *testing.T) { 12 | b, err := os.ReadFile("testdata/camel.heic") 13 | if err != nil { 14 | t.Fatal(err) 15 | } 16 | 17 | img, dec, err := image.Decode(bytes.NewReader(b)) 18 | if err != nil { 19 | t.Fatalf("unable to decode heic image: %s", err) 20 | } 21 | 22 | if got, want := dec, "heic"; got != want { 23 | t.Errorf("unexpected decoder: got %s, want %s", got, want) 24 | } 25 | 26 | if w, h := img.Bounds().Dx(), img.Bounds().Dy(); w != 1596 || h != 1064 { 27 | t.Errorf("unexpected decoded image size: got %dx%d, want 1596x1064", w, h) 28 | } 29 | 30 | t.Logf("Successfully decoded HEIC image: %dx%d", img.Bounds().Dx(), img.Bounds().Dy()) 31 | } 32 | 33 | func TestDecodeAVIF(t *testing.T) { 34 | file, err := os.Open("testdata/fox.avif") 35 | if err != nil { 36 | t.Skipf("Test AVIF file not found: %v", err) 37 | } 38 | defer file.Close() 39 | 40 | // Decode using the main goheif package with AV1 support 41 | img, err := Decode(file) 42 | if err != nil { 43 | t.Fatalf("Failed to decode AVIF image: %v", err) 44 | } 45 | 46 | // Check that we got a valid image 47 | if img == nil { 48 | t.Fatal("Decoded image is nil") 49 | } 50 | 51 | bounds := img.Bounds() 52 | if bounds.Dx() <= 0 || bounds.Dy() <= 0 { 53 | t.Fatalf("Invalid image dimensions: %dx%d", bounds.Dx(), bounds.Dy()) 54 | } 55 | 56 | t.Logf("Successfully decoded AVIF image: %dx%d", bounds.Dx(), bounds.Dy()) 57 | } 58 | 59 | func BenchmarkSafeEncoding(b *testing.B) { 60 | benchEncoding(b, true) 61 | } 62 | 63 | func BenchmarkRegularEncoding(b *testing.B) { 64 | benchEncoding(b, false) 65 | } 66 | 67 | func benchEncoding(b *testing.B, safe bool) { 68 | b.Helper() 69 | 70 | currentSetting := SafeEncoding 71 | defer func() { 72 | SafeEncoding = currentSetting 73 | }() 74 | SafeEncoding = safe 75 | 76 | f, err := os.ReadFile("testdata/camel.heic") 77 | if err != nil { 78 | b.Fatal(err) 79 | } 80 | r := bytes.NewReader(f) 81 | 82 | b.ResetTimer() 83 | b.ReportAllocs() 84 | for i := 0; i < b.N; i++ { 85 | Decode(r) 86 | r.Seek(0, io.SeekStart) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /dav1d/src/log.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * 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 are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include "config.h" 28 | 29 | #include 30 | #include 31 | 32 | #include "dav1d/dav1d.h" 33 | 34 | #include "common/validate.h" 35 | 36 | #include "src/internal.h" 37 | #include "src/log.h" 38 | 39 | #if CONFIG_LOG 40 | COLD void dav1d_log_default_callback(void *const cookie, 41 | const char *const format, va_list ap) 42 | { 43 | vfprintf(stderr, format, ap); 44 | } 45 | 46 | COLD void dav1d_log(Dav1dContext *const c, const char *const format, ...) { 47 | assert(c != NULL); 48 | 49 | if (!c->logger.callback) 50 | return; 51 | 52 | va_list ap; 53 | va_start(ap, format); 54 | c->logger.callback(c->logger.cookie, format, ap); 55 | va_end(ap); 56 | } 57 | #endif 58 | -------------------------------------------------------------------------------- /dav1d/src/ppc/cpu.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019, VideoLAN and dav1d authors 3 | * Copyright © 2019, Janne Grunau 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "config.h" 29 | 30 | #include "common/attributes.h" 31 | 32 | #include "src/cpu.h" 33 | #include "src/ppc/cpu.h" 34 | 35 | #define HAVE_AUX ((HAVE_GETAUXVAL || HAVE_ELF_AUX_INFO) && ARCH_PPC64LE) 36 | #if HAVE_AUX 37 | #include 38 | #endif 39 | 40 | COLD unsigned dav1d_get_cpu_flags_ppc(void) { 41 | unsigned flags = dav1d_get_default_cpu_flags(); 42 | #if HAVE_AUX 43 | unsigned long hw_cap = dav1d_getauxval(AT_HWCAP); 44 | unsigned long hw_cap2 = dav1d_getauxval(AT_HWCAP2); 45 | flags |= (hw_cap & PPC_FEATURE_HAS_VSX) ? DAV1D_PPC_CPU_FLAG_VSX : 0; 46 | flags |= (hw_cap2 & PPC_FEATURE2_ARCH_3_00) ? DAV1D_PPC_CPU_FLAG_PWR9 : 0; 47 | #endif 48 | return flags; 49 | } 50 | -------------------------------------------------------------------------------- /libde265/libde265/arm/neon.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Mans Rullgard 3 | * 4 | * This file is part of FFmpeg. 5 | * 6 | * FFmpeg is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * FFmpeg is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with FFmpeg; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | .macro transpose_8x8 r0, r1, r2, r3, r4, r5, r6, r7 22 | vtrn.32 \r0, \r4 23 | vtrn.32 \r1, \r5 24 | vtrn.32 \r2, \r6 25 | vtrn.32 \r3, \r7 26 | vtrn.16 \r0, \r2 27 | vtrn.16 \r1, \r3 28 | vtrn.16 \r4, \r6 29 | vtrn.16 \r5, \r7 30 | vtrn.8 \r0, \r1 31 | vtrn.8 \r2, \r3 32 | vtrn.8 \r4, \r5 33 | vtrn.8 \r6, \r7 34 | .endm 35 | 36 | .macro transpose_4x4 r0, r1, r2, r3 37 | vtrn.16 \r0, \r2 38 | vtrn.16 \r1, \r3 39 | vtrn.8 \r0, \r1 40 | vtrn.8 \r2, \r3 41 | .endm 42 | 43 | .macro swap4 r0, r1, r2, r3, r4, r5, r6, r7 44 | vswp \r0, \r4 45 | vswp \r1, \r5 46 | vswp \r2, \r6 47 | vswp \r3, \r7 48 | .endm 49 | 50 | .macro transpose16_4x4 r0, r1, r2, r3, r4, r5, r6, r7 51 | vtrn.32 \r0, \r2 52 | vtrn.32 \r1, \r3 53 | vtrn.32 \r4, \r6 54 | vtrn.32 \r5, \r7 55 | vtrn.16 \r0, \r1 56 | vtrn.16 \r2, \r3 57 | vtrn.16 \r4, \r5 58 | vtrn.16 \r6, \r7 59 | .endm 60 | -------------------------------------------------------------------------------- /dav1d/src/loongarch/refmvs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2023, VideoLAN and dav1d authors 3 | * Copyright © 2023, Loongson Technology Corporation Limited 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_LOONGARCH_REFMVS_H 29 | #define DAV1D_SRC_LOONGARCH_REFMVS_H 30 | 31 | #include "src/cpu.h" 32 | #include "src/refmvs.h" 33 | 34 | decl_splat_mv_fn(dav1d_splat_mv_lsx); 35 | decl_load_tmvs_fn(dav1d_load_tmvs_lsx); 36 | decl_save_tmvs_fn(dav1d_save_tmvs_lsx); 37 | 38 | static ALWAYS_INLINE void refmvs_dsp_init_loongarch(Dav1dRefmvsDSPContext *const c) { 39 | const unsigned flags = dav1d_get_cpu_flags(); 40 | 41 | if (!(flags & DAV1D_LOONGARCH_CPU_FLAG_LSX)) return; 42 | 43 | c->splat_mv = dav1d_splat_mv_lsx; 44 | c->load_tmvs = dav1d_load_tmvs_lsx; 45 | c->save_tmvs = dav1d_save_tmvs_lsx; 46 | } 47 | 48 | #endif /* DAV1D_SRC_LOONGARCH_REFMVS_H */ 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GoHeif - A go gettable decoder/converter for HEIC/AVIF based on libde265/dav1d 2 | 3 | ## Install 4 | - `heic2jpg` to convert HEIC files to JPG preserving exif 5 | 6 | ``` go get github.com/jdeng/goheif/...``` 7 | 8 | - Tested 9 | - Mac OS X (High Sierra) 10 | - Linux (Ubuntu 16.04 / GCC 5.4) 11 | - Windows 7 64bit with TDM-GCC 32 (GCC 5.1) and golang 1.12 windows/386 12 | 13 | - Code Sample 14 | ``` 15 | func main() { 16 | flag.Parse() 17 | ... 18 | 19 | fin, fout := flag.Arg(0), flag.Arg(1) 20 | fi, err := os.Open(fin) 21 | if err != nil { 22 | log.Fatal(err) 23 | } 24 | defer fi.Close() 25 | 26 | exif, err := goheif.ExtractExif(fi) 27 | if err != nil { 28 | log.Printf("Warning: no EXIF from %s: %v\n", fin, err) 29 | } 30 | 31 | img, err := goheif.Decode(fi) 32 | if err != nil { 33 | log.Fatalf("Failed to parse %s: %v\n", fin, err) 34 | } 35 | 36 | fo, err := os.OpenFile(fout, os.O_RDWR|os.O_CREATE, 0644) 37 | if err != nil { 38 | log.Fatalf("Failed to create output file %s: %v\n", fout, err) 39 | } 40 | defer fo.Close() 41 | 42 | w, _ := newWriterExif(fo, exif) 43 | err = jpeg.Encode(w, img, nil) 44 | if err != nil { 45 | log.Fatalf("Failed to encode %s: %v\n", fout, err) 46 | } 47 | 48 | log.Printf("Convert %s to %s successfully\n", fin, fout) 49 | } 50 | ``` 51 | 52 | ## What is done 53 | 54 | - Changes make to @bradfitz's (https://github.com/bradfitz) golang heif parser 55 | - Some minor bugfixes 56 | - A few new box parsers, noteably 'iref' and 'hvcC' 57 | 58 | - Include libde265's source code (SSE by default enabled) and a simple golang binding 59 | 60 | - Include dav1d's source code and a simple golang binding 61 | 62 | - A Utility `heic2jpg` to illustrate the usage. 63 | 64 | ## License 65 | 66 | - heif and libde265 are in their own licenses 67 | - dav1d is in its own license 68 | - goheif.go, libde265 golang binding and the `heic2jpg` utility are in MIT license 69 | 70 | ## Credits 71 | - heif parser by @bradfitz (https://github.com/go4org/go4/tree/master/media/heif) 72 | - libde265 (https://github.com/strukturag/libde265) 73 | - dav1d (https://code.videolan.org/videolan/dav1d) 74 | - implementation learnt from libheif (https://github.com/strukturag/libheif) 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /dav1d/src/x86/cpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * Copyright © 2018, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_X86_CPU_H 29 | #define DAV1D_SRC_X86_CPU_H 30 | 31 | enum CpuFlags { 32 | DAV1D_X86_CPU_FLAG_SSE2 = 1 << 0, 33 | DAV1D_X86_CPU_FLAG_SSSE3 = 1 << 1, 34 | DAV1D_X86_CPU_FLAG_SSE41 = 1 << 2, 35 | DAV1D_X86_CPU_FLAG_AVX2 = 1 << 3, 36 | DAV1D_X86_CPU_FLAG_AVX512ICL = 1 << 4, /* F/CD/BW/DQ/VL/VNNI/IFMA/VBMI/VBMI2/ 37 | * VPOPCNTDQ/BITALG/GFNI/VAES/VPCLMULQDQ */ 38 | DAV1D_X86_CPU_FLAG_SLOW_GATHER = 1 << 5, /* Flag CPUs where gather instructions are slow enough 39 | * to cause performance regressions. */ 40 | }; 41 | 42 | unsigned dav1d_get_cpu_flags_x86(void); 43 | 44 | #endif /* DAV1D_SRC_X86_CPU_H */ 45 | -------------------------------------------------------------------------------- /dav1d/src/x86/pal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2023, VideoLAN and dav1d authors 3 | * Copyright © 2023, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "src/cpu.h" 29 | 30 | decl_pal_idx_finish_fn(dav1d_pal_idx_finish_ssse3); 31 | decl_pal_idx_finish_fn(dav1d_pal_idx_finish_avx2); 32 | decl_pal_idx_finish_fn(dav1d_pal_idx_finish_avx512icl); 33 | 34 | static ALWAYS_INLINE void pal_dsp_init_x86(Dav1dPalDSPContext *const c) { 35 | const unsigned flags = dav1d_get_cpu_flags(); 36 | 37 | if (!(flags & DAV1D_X86_CPU_FLAG_SSSE3)) return; 38 | 39 | c->pal_idx_finish = dav1d_pal_idx_finish_ssse3; 40 | 41 | #if ARCH_X86_64 42 | if (!(flags & DAV1D_X86_CPU_FLAG_AVX2)) return; 43 | 44 | c->pal_idx_finish = dav1d_pal_idx_finish_avx2; 45 | 46 | if (!(flags & DAV1D_X86_CPU_FLAG_AVX512ICL)) return; 47 | 48 | c->pal_idx_finish = dav1d_pal_idx_finish_avx512icl; 49 | #endif 50 | } 51 | -------------------------------------------------------------------------------- /libde265/extra/win32cond.h: -------------------------------------------------------------------------------- 1 | #ifndef WIN32COND_H 2 | #define WIN32COND_H 3 | 4 | /** 5 | * pthread_cond API for Win32 6 | * 7 | * ACE(TM), TAO(TM), CIAO(TM), DAnCE>(TM), and CoSMIC(TM) (henceforth 8 | * referred to as "DOC software") are copyrighted by Douglas C. Schmidt 9 | * and his research group at Washington University, University of California, 10 | * Irvine, and Vanderbilt University, Copyright (c) 1993-2009, all rights 11 | * reserved. 12 | * 13 | * Since DOC software is open-source, freely available software, you are free 14 | * to use, modify, copy, and distribute--perpetually and irrevocably--the DOC 15 | * software source code and object code produced from the source, as well as 16 | * copy and distribute modified versions of this software. You must, however, 17 | * include this copyright statement along with any code built using DOC 18 | * software that you release. 19 | * 20 | * No copyright statement needs to be provided if you just ship binary 21 | * executables of your software products. 22 | * 23 | * See "Strategies for Implementing POSIX Condition Variables on Win32" at 24 | * http://www.cs.wustl.edu/~schmidt/win32-cv-1.html 25 | */ 26 | 27 | #include 28 | 29 | typedef struct 30 | { 31 | long waiters_count_; 32 | // Number of waiting threads. 33 | 34 | CRITICAL_SECTION waiters_count_lock_; 35 | // Serialize access to . 36 | 37 | HANDLE sema_; 38 | // Semaphore used to queue up threads waiting for the condition to 39 | // become signaled. 40 | 41 | HANDLE waiters_done_; 42 | // An auto-reset event used by the broadcast/signal thread to wait 43 | // for all the waiting thread(s) to wake up and be released from the 44 | // semaphore. 45 | 46 | size_t was_broadcast_; 47 | // Keeps track of whether we were broadcasting or signaling. This 48 | // allows us to optimize the code if we're just signaling. 49 | } win32_cond_t; 50 | 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | 55 | int win32_cond_init(win32_cond_t *cv); 56 | int win32_cond_destroy(win32_cond_t *cv); 57 | int win32_cond_wait(win32_cond_t *cv, HANDLE *external_mutex); 58 | int win32_cond_signal(win32_cond_t *cv); 59 | int win32_cond_broadcast(win32_cond_t *cv); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /dav1d/src/arm/loopfilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * Copyright © 2018, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "src/cpu.h" 29 | #include "src/loopfilter.h" 30 | 31 | decl_loopfilter_sb_fn(BF(dav1d_lpf_h_sb_y, neon)); 32 | decl_loopfilter_sb_fn(BF(dav1d_lpf_v_sb_y, neon)); 33 | decl_loopfilter_sb_fn(BF(dav1d_lpf_h_sb_uv, neon)); 34 | decl_loopfilter_sb_fn(BF(dav1d_lpf_v_sb_uv, neon)); 35 | 36 | static ALWAYS_INLINE void loop_filter_dsp_init_arm(Dav1dLoopFilterDSPContext *const c) { 37 | const unsigned flags = dav1d_get_cpu_flags(); 38 | 39 | if (!(flags & DAV1D_ARM_CPU_FLAG_NEON)) return; 40 | 41 | c->loop_filter_sb[0][0] = BF(dav1d_lpf_h_sb_y, neon); 42 | c->loop_filter_sb[0][1] = BF(dav1d_lpf_v_sb_y, neon); 43 | c->loop_filter_sb[1][0] = BF(dav1d_lpf_h_sb_uv, neon); 44 | c->loop_filter_sb[1][1] = BF(dav1d_lpf_v_sb_uv, neon); 45 | } 46 | -------------------------------------------------------------------------------- /libde265/libde265/visualize.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 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 | * libde265 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 libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_VISUALIZE_H 22 | #define DE265_VISUALIZE_H 23 | 24 | #include "libde265/de265.h" 25 | #include "libde265/image.h" 26 | 27 | 28 | void write_picture_to_file(const de265_image* img, const char* filename); 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | // TODO: these should either move to "sherlock265", or be part of the 35 | // "official" public API 36 | LIBDE265_API void draw_CB_grid(const de265_image* img, uint8_t* dst, int stride, uint32_t value, int pixelSize); 37 | LIBDE265_API void draw_TB_grid(const de265_image* img, uint8_t* dst, int stride, uint32_t value, int pixelSize); 38 | LIBDE265_API void draw_PB_grid(const de265_image* img, uint8_t* dst, int stride, uint32_t value, int pixelSize); 39 | LIBDE265_API void draw_PB_pred_modes(const de265_image* img, uint8_t* dst, int stride, int pixelSize); 40 | LIBDE265_API void draw_intra_pred_modes(const de265_image* img, uint8_t* dst, int stride, uint32_t value, int pixelSize); 41 | LIBDE265_API void draw_QuantPY(const de265_image* img, uint8_t* dst, int stride, int pixelSize); 42 | LIBDE265_API void draw_Motion(const de265_image* img, uint8_t* dst, int stride, int pixelSize); 43 | LIBDE265_API void draw_Slices(const de265_image* img, uint8_t* dst, int stride, int pixelSize); 44 | LIBDE265_API void draw_Tiles(const de265_image* img, uint8_t* dst, int stride, int pixelSize); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /dav1d/src/ppc/loopfilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * Copyright © 2018, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "src/cpu.h" 29 | #include "src/loopfilter.h" 30 | 31 | decl_loopfilter_sb_fn(BF(dav1d_lpf_h_sb_y, pwr9)); 32 | decl_loopfilter_sb_fn(BF(dav1d_lpf_v_sb_y, pwr9)); 33 | decl_loopfilter_sb_fn(BF(dav1d_lpf_h_sb_uv, pwr9)); 34 | decl_loopfilter_sb_fn(BF(dav1d_lpf_v_sb_uv, pwr9)); 35 | 36 | static ALWAYS_INLINE void loop_filter_dsp_init_ppc(Dav1dLoopFilterDSPContext *const c) { 37 | const unsigned flags = dav1d_get_cpu_flags(); 38 | 39 | if (!(flags & DAV1D_PPC_CPU_FLAG_PWR9)) return; 40 | 41 | #if BITDEPTH == 8 42 | c->loop_filter_sb[0][0] = BF(dav1d_lpf_h_sb_y, pwr9); 43 | c->loop_filter_sb[0][1] = BF(dav1d_lpf_v_sb_y, pwr9); 44 | c->loop_filter_sb[1][0] = BF(dav1d_lpf_h_sb_uv, pwr9); 45 | c->loop_filter_sb[1][1] = BF(dav1d_lpf_v_sb_uv, pwr9); 46 | #endif 47 | } 48 | -------------------------------------------------------------------------------- /dav1d/src/x86/filmgrain_common.asm: -------------------------------------------------------------------------------- 1 | ; Copyright © 2019-2022, VideoLAN and dav1d authors 2 | ; Copyright © 2019-2022, Two Orioles, LLC 3 | ; 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 are met: 7 | ; 8 | ; 1. Redistributions of source code must retain the above copyright notice, this 9 | ; list of conditions and the following disclaimer. 10 | ; 11 | ; 2. Redistributions in binary form must reproduce the above copyright notice, 12 | ; this list of conditions and the following disclaimer in the documentation 13 | ; and/or other materials provided with the distribution. 14 | ; 15 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | ; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | ; ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | struc FGData 27 | .seed: resd 1 28 | .num_y_points: resd 1 29 | .y_points: resb 14 * 2 30 | .chroma_scaling_from_luma: resd 1 31 | .num_uv_points: resd 2 32 | .uv_points: resb 2 * 10 * 2 33 | .scaling_shift: resd 1 34 | .ar_coeff_lag: resd 1 35 | .ar_coeffs_y: resb 24 36 | .ar_coeffs_uv: resb 2 * 28 ; includes padding 37 | .ar_coeff_shift: resq 1 38 | .grain_scale_shift: resd 1 39 | .uv_mult: resd 2 40 | .uv_luma_mult: resd 2 41 | .uv_offset: resd 2 42 | .overlap_flag: resd 1 43 | .clip_to_restricted_range: resd 1 44 | endstruc 45 | 46 | cextern gaussian_sequence 47 | -------------------------------------------------------------------------------- /dav1d/src/lf_apply.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * Copyright © 2018, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_LF_APPLY_H 29 | #define DAV1D_SRC_LF_APPLY_H 30 | 31 | #include 32 | 33 | #include "common/bitdepth.h" 34 | 35 | #include "src/internal.h" 36 | #include "src/levels.h" 37 | 38 | void bytefn(dav1d_loopfilter_sbrow_cols)(const Dav1dFrameContext *f, 39 | pixel *const p[3], Av1Filter *lflvl, 40 | int sby, int start_of_tile_row); 41 | void bytefn(dav1d_loopfilter_sbrow_rows)(const Dav1dFrameContext *f, 42 | pixel *const p[3], Av1Filter *lflvl, 43 | int sby); 44 | 45 | void bytefn(dav1d_copy_lpf)(Dav1dFrameContext *const f, 46 | /*const*/ pixel *const src[3], int sby); 47 | 48 | #endif /* DAV1D_SRC_LF_APPLY_H */ 49 | -------------------------------------------------------------------------------- /dav1d/src/ppc/looprestoration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019, VideoLAN and dav1d authors 3 | * Copyright © 2019, Michail Alvanos 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "common/intops.h" 29 | 30 | #include "src/cpu.h" 31 | #include "src/looprestoration.h" 32 | 33 | void dav1d_wiener_filter_vsx(uint8_t *p, const ptrdiff_t stride, 34 | const uint8_t (*const left)[4], 35 | const uint8_t *lpf, 36 | const int w, const int h, 37 | const LooprestorationParams *const params, 38 | const enum LrEdgeFlags edges); 39 | 40 | static ALWAYS_INLINE void loop_restoration_dsp_init_ppc(Dav1dLoopRestorationDSPContext *const c, const int bpc) { 41 | const unsigned flags = dav1d_get_cpu_flags(); 42 | 43 | if (!(flags & DAV1D_PPC_CPU_FLAG_VSX)) return; 44 | 45 | #if BITDEPTH == 8 46 | c->wiener[0] = c->wiener[1] = dav1d_wiener_filter_vsx; 47 | #endif 48 | } 49 | -------------------------------------------------------------------------------- /cmd/heic2jpg/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "image/jpeg" 7 | "io" 8 | "log" 9 | "os" 10 | 11 | "github.com/jdeng/goheif" 12 | ) 13 | 14 | // Skip Writer for exif writing 15 | type writerSkipper struct { 16 | w io.Writer 17 | bytesToSkip int 18 | } 19 | 20 | func (w *writerSkipper) Write(data []byte) (int, error) { 21 | if w.bytesToSkip <= 0 { 22 | return w.w.Write(data) 23 | } 24 | 25 | if dataLen := len(data); dataLen < w.bytesToSkip { 26 | w.bytesToSkip -= dataLen 27 | return dataLen, nil 28 | } 29 | 30 | if n, err := w.w.Write(data[w.bytesToSkip:]); err == nil { 31 | n += w.bytesToSkip 32 | w.bytesToSkip = 0 33 | return n, nil 34 | } else { 35 | return n, err 36 | } 37 | } 38 | 39 | func newWriterExif(w io.Writer, exif []byte) (io.Writer, error) { 40 | writer := &writerSkipper{w, 2} 41 | soi := []byte{0xff, 0xd8} 42 | if _, err := w.Write(soi); err != nil { 43 | return nil, err 44 | } 45 | 46 | if exif != nil { 47 | app1Marker := 0xe1 48 | markerlen := 2 + len(exif) 49 | marker := []byte{0xff, uint8(app1Marker), uint8(markerlen >> 8), uint8(markerlen & 0xff)} 50 | if _, err := w.Write(marker); err != nil { 51 | return nil, err 52 | } 53 | 54 | if _, err := w.Write(exif); err != nil { 55 | return nil, err 56 | } 57 | } 58 | 59 | return writer, nil 60 | } 61 | 62 | func main() { 63 | flag.Parse() 64 | if flag.NArg() != 2 { 65 | fmt.Fprintf(os.Stderr, "usage: heic2jpg \n") 66 | os.Exit(1) 67 | } 68 | 69 | fin, fout := flag.Arg(0), flag.Arg(1) 70 | fi, err := os.Open(fin) 71 | if err != nil { 72 | log.Fatal(err) 73 | } 74 | defer fi.Close() 75 | 76 | exif, err := goheif.ExtractExif(fi) 77 | if err != nil { 78 | log.Printf("Warning: no EXIF from %s: %v\n", fin, err) 79 | } 80 | 81 | img, err := goheif.Decode(fi) 82 | if err != nil { 83 | log.Fatalf("Failed to parse %s: %v\n", fin, err) 84 | } 85 | 86 | fo, err := os.OpenFile(fout, os.O_RDWR|os.O_CREATE, 0644) 87 | if err != nil { 88 | log.Fatalf("Failed to create output file %s: %v\n", fout, err) 89 | } 90 | defer fo.Close() 91 | 92 | w, _ := newWriterExif(fo, exif) 93 | err = jpeg.Encode(w, img, nil) 94 | if err != nil { 95 | log.Fatalf("Failed to encode %s: %v\n", fout, err) 96 | } 97 | 98 | log.Printf("Convert %s to %s successfully\n", fin, fout) 99 | } 100 | -------------------------------------------------------------------------------- /dav1d/src/loongarch/cdef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2024, VideoLAN and dav1d authors 3 | * Copyright © 2024, Loongson Technology Corporation Limited 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_LOONGARCH_CDEF_H 29 | #define DAV1D_SRC_LOONGARCH_CDEF_H 30 | 31 | #include "config.h" 32 | #include "src/cdef.h" 33 | #include "src/cpu.h" 34 | 35 | decl_cdef_dir_fn(BF(dav1d_cdef_find_dir, lsx)); 36 | decl_cdef_fn(BF(dav1d_cdef_filter_block_4x4, lsx)); 37 | decl_cdef_fn(BF(dav1d_cdef_filter_block_4x8, lsx)); 38 | decl_cdef_fn(BF(dav1d_cdef_filter_block_8x8, lsx)); 39 | 40 | static ALWAYS_INLINE void cdef_dsp_init_loongarch(Dav1dCdefDSPContext *const c) { 41 | const unsigned flags = dav1d_get_cpu_flags(); 42 | 43 | if (!(flags & DAV1D_LOONGARCH_CPU_FLAG_LSX)) return; 44 | 45 | #if BITDEPTH == 8 46 | c->dir = BF(dav1d_cdef_find_dir, lsx); 47 | c->fb[0] = BF(dav1d_cdef_filter_block_8x8, lsx); 48 | c->fb[1] = BF(dav1d_cdef_filter_block_4x8, lsx); 49 | c->fb[2] = BF(dav1d_cdef_filter_block_4x4, lsx); 50 | #endif 51 | } 52 | 53 | #endif /* DAV1D_SRC_LOONGARCH_CDEF_H */ 54 | -------------------------------------------------------------------------------- /libde265/libde265/refpic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 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 | * libde265 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 libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_REFPIC_H 22 | #define DE265_REFPIC_H 23 | 24 | #include "libde265/bitstream.h" 25 | 26 | #define MAX_NUM_REF_PICS 16 // maximum defined by standard, may be lower for some Levels 27 | 28 | 29 | class ref_pic_set 30 | { 31 | public: 32 | // Lists of pictures that have to be kept in the decoded picture buffer for future 33 | // reference and that may optionally be used for prediction in the current frame. 34 | // Lists contain the relative POC positions. 35 | int16_t DeltaPocS0[MAX_NUM_REF_PICS]; // sorted in decreasing order (e.g. -1, -2, -4, -7, ...) 36 | int16_t DeltaPocS1[MAX_NUM_REF_PICS]; // sorted in ascending order (e.g. 1, 2, 4, 7) 37 | 38 | // flag for each reference whether this is actually used for prediction in the current frame 39 | uint8_t UsedByCurrPicS0[MAX_NUM_REF_PICS]; 40 | uint8_t UsedByCurrPicS1[MAX_NUM_REF_PICS]; 41 | 42 | uint8_t NumNegativePics; // number of past reference pictures 43 | uint8_t NumPositivePics; // number of future reference pictures 44 | 45 | // --- derived values --- 46 | 47 | void compute_derived_values(); 48 | 49 | uint8_t NumDeltaPocs; // total number of reference pictures (past + future) 50 | 51 | uint8_t NumPocTotalCurr_shortterm_only; /* Total number of reference pictures that may actually 52 | be used for prediction in the current frame. */ 53 | 54 | void reset(); 55 | }; 56 | 57 | 58 | void dump_short_term_ref_pic_set(const ref_pic_set*, FILE* fh); 59 | void dump_compact_short_term_ref_pic_set(const ref_pic_set* set, int range, FILE* fh); 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /dav1d/src/loongarch/loopfilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2023, VideoLAN and dav1d authors 3 | * Copyright © 2023, Loongson Technology Corporation Limited 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_LOONGARCH_LOOPFILTER_H 29 | #define DAV1D_SRC_LOONGARCH_LOOPFILTER_H 30 | 31 | #include "src/cpu.h" 32 | #include "src/loopfilter.h" 33 | 34 | decl_loopfilter_sb_fn(BF(dav1d_lpf_h_sb_y, lsx)); 35 | decl_loopfilter_sb_fn(BF(dav1d_lpf_v_sb_y, lsx)); 36 | decl_loopfilter_sb_fn(BF(dav1d_lpf_h_sb_uv, lsx)); 37 | decl_loopfilter_sb_fn(BF(dav1d_lpf_v_sb_uv, lsx)); 38 | 39 | static ALWAYS_INLINE void loop_filter_dsp_init_loongarch(Dav1dLoopFilterDSPContext *const c) { 40 | const unsigned flags = dav1d_get_cpu_flags(); 41 | 42 | if (!(flags & DAV1D_LOONGARCH_CPU_FLAG_LSX)) return; 43 | 44 | #if BITDEPTH == 8 45 | c->loop_filter_sb[0][0] = BF(dav1d_lpf_h_sb_y, lsx); 46 | c->loop_filter_sb[0][1] = BF(dav1d_lpf_v_sb_y, lsx); 47 | c->loop_filter_sb[1][0] = BF(dav1d_lpf_h_sb_uv, lsx); 48 | c->loop_filter_sb[1][1] = BF(dav1d_lpf_v_sb_uv, lsx); 49 | #endif 50 | } 51 | 52 | #endif /* DAV1D_SRC_LOONGARCH_LOOPFILTER_H */ 53 | -------------------------------------------------------------------------------- /dav1d/src/thread_task.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018-2021, VideoLAN and dav1d authors 3 | * Copyright © 2018, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_THREAD_TASK_H 29 | #define DAV1D_SRC_THREAD_TASK_H 30 | 31 | #include 32 | 33 | #include "src/internal.h" 34 | 35 | #define FRAME_ERROR (UINT_MAX - 1) 36 | #define TILE_ERROR (INT_MAX - 1) 37 | 38 | // these functions assume the task scheduling lock is already taken 39 | int dav1d_task_create_tile_sbrow(Dav1dFrameContext *f, int pass, int cond_signal); 40 | void dav1d_task_frame_init(Dav1dFrameContext *f); 41 | 42 | void dav1d_task_delayed_fg(Dav1dContext *c, Dav1dPicture *out, const Dav1dPicture *in); 43 | 44 | void *dav1d_worker_task(void *data); 45 | 46 | int dav1d_decode_frame_init(Dav1dFrameContext *f); 47 | int dav1d_decode_frame_init_cdf(Dav1dFrameContext *f); 48 | int dav1d_decode_frame_main(Dav1dFrameContext *f); 49 | void dav1d_decode_frame_exit(Dav1dFrameContext *f, int retval); 50 | int dav1d_decode_frame(Dav1dFrameContext *f); 51 | int dav1d_decode_tile_sbrow(Dav1dTaskContext *t); 52 | 53 | #endif /* DAV1D_SRC_THREAD_TASK_H */ 54 | -------------------------------------------------------------------------------- /dav1d/src/ctx.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2024, VideoLAN and dav1d authors 3 | * Copyright © 2024, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "config.h" 29 | 30 | #include 31 | 32 | #include "ctx.h" 33 | 34 | static void memset_w1(void *const ptr, const int value) { 35 | set_ctx1((uint8_t *) ptr, 0, value); 36 | } 37 | 38 | static void memset_w2(void *const ptr, const int value) { 39 | set_ctx2((uint8_t *) ptr, 0, value); 40 | } 41 | 42 | static void memset_w4(void *const ptr, const int value) { 43 | set_ctx4((uint8_t *) ptr, 0, value); 44 | } 45 | 46 | static void memset_w8(void *const ptr, const int value) { 47 | set_ctx8((uint8_t *) ptr, 0, value); 48 | } 49 | 50 | static void memset_w16(void *const ptr, const int value) { 51 | set_ctx16((uint8_t *) ptr, 0, value); 52 | } 53 | 54 | static void memset_w32(void *const ptr, const int value) { 55 | set_ctx32((uint8_t *) ptr, 0, value); 56 | } 57 | 58 | const dav1d_memset_pow2_fn dav1d_memset_pow2[6] = { 59 | memset_w1, 60 | memset_w2, 61 | memset_w4, 62 | memset_w8, 63 | memset_w16, 64 | memset_w32 65 | }; 66 | -------------------------------------------------------------------------------- /dav1d/src/loopfilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * Copyright © 2018, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_LOOPFILTER_H 29 | #define DAV1D_SRC_LOOPFILTER_H 30 | 31 | #include 32 | #include 33 | 34 | #include "common/bitdepth.h" 35 | 36 | #include "src/levels.h" 37 | #include "src/lf_mask.h" 38 | 39 | #define decl_loopfilter_sb_fn(name) \ 40 | void (name)(pixel *dst, ptrdiff_t stride, const uint32_t *mask, \ 41 | const uint8_t (*lvl)[4], ptrdiff_t lvl_stride, \ 42 | const Av1FilterLUT *lut, int w HIGHBD_DECL_SUFFIX) 43 | typedef decl_loopfilter_sb_fn(*loopfilter_sb_fn); 44 | 45 | typedef struct Dav1dLoopFilterDSPContext { 46 | /* 47 | * dimension 1: plane (0=luma, 1=chroma) 48 | * dimension 2: 0=col-edge filter (h), 1=row-edge filter (v) 49 | * 50 | * dst/stride are aligned by 32 51 | */ 52 | loopfilter_sb_fn loop_filter_sb[2][2]; 53 | } Dav1dLoopFilterDSPContext; 54 | 55 | bitfn_decls(void dav1d_loop_filter_dsp_init, Dav1dLoopFilterDSPContext *c); 56 | 57 | #endif /* DAV1D_SRC_LOOPFILTER_H */ 58 | -------------------------------------------------------------------------------- /libde265/libde265/transform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 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 | * libde265 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 libde265. If not, see . 19 | */ 20 | 21 | #ifndef DE265_TRANSFORM_H 22 | #define DE265_TRANSFORM_H 23 | 24 | #include "libde265/de265.h" 25 | #include "libde265/decctx.h" 26 | 27 | extern const int tab8_22[]; 28 | 29 | LIBDE265_INLINE static int table8_22(int qPi) 30 | { 31 | if (qPi<30) return qPi; 32 | if (qPi>=43) return qPi-6; 33 | return tab8_22[qPi-30]; 34 | } 35 | 36 | // (8.6.1) 37 | void decode_quantization_parameters(thread_context* tctx, int xC,int yC, 38 | int xCUBase, int yCUBase); 39 | 40 | // (8.6.2) 41 | void scale_coefficients(thread_context* tctx, 42 | int xT,int yT, // position of TU in frame (chroma adapted) 43 | int x0,int y0, // position of CU in frame (chroma adapted) 44 | int nT, int cIdx, 45 | bool transform_skip_flag, bool intra, int rdpcmMode); 46 | 47 | 48 | void inv_transform(acceleration_functions* acceleration, 49 | uint8_t* dst, int dstStride, int16_t* coeff, 50 | int log2TbSize, int trType); 51 | 52 | void fwd_transform(acceleration_functions* acceleration, 53 | int16_t* coeff, int coeffStride, int log2TbSize, int trType, 54 | const int16_t* src, int srcStride); 55 | 56 | void quant_coefficients(int16_t* out_coeff, 57 | const int16_t* in_coeff, 58 | int log2TrSize, int qp, 59 | bool intra); 60 | 61 | void dequant_coefficients(int16_t* out_coeff, 62 | const int16_t* in_coeff, 63 | int log2TrSize, int qP); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /dav1d/include/common/validate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * Copyright © 2018, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_COMMON_VALIDATE_H 29 | #define DAV1D_COMMON_VALIDATE_H 30 | 31 | #include 32 | #include 33 | 34 | #if defined(NDEBUG) 35 | #define debug_print(...) do {} while (0) 36 | #define debug_abort() do {} while (0) 37 | #else 38 | #define debug_print(...) fprintf(stderr, __VA_ARGS__) 39 | #define debug_abort abort 40 | #endif 41 | 42 | #define validate_input_or_ret_with_msg(x, r, ...) \ 43 | if (!(x)) { \ 44 | debug_print("Input validation check \'%s\' failed in %s!\n", \ 45 | #x, __func__); \ 46 | debug_print(__VA_ARGS__); \ 47 | debug_abort(); \ 48 | return r; \ 49 | } 50 | 51 | #define validate_input_or_ret(x, r) \ 52 | if (!(x)) { \ 53 | debug_print("Input validation check \'%s\' failed in %s!\n", \ 54 | #x, __func__); \ 55 | debug_abort(); \ 56 | return r; \ 57 | } 58 | 59 | #define validate_input(x) validate_input_or_ret(x, ) 60 | 61 | #endif /* DAV1D_COMMON_VALIDATE_H */ 62 | -------------------------------------------------------------------------------- /dav1d/src/riscv/itx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * Copyright © 2023, Nathan Egge 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "src/cpu.h" 29 | #include "src/itx.h" 30 | 31 | #define decl_itx_fns(ext) \ 32 | decl_itx17_fns( 4, 4, ext); \ 33 | decl_itx16_fns( 4, 8, ext); \ 34 | decl_itx16_fns( 4, 16, ext); \ 35 | decl_itx16_fns( 8, 4, ext); \ 36 | decl_itx16_fns( 8, 8, ext); \ 37 | decl_itx16_fns( 8, 16, ext); \ 38 | decl_itx16_fns(16, 4, ext); \ 39 | decl_itx16_fns(16, 8, ext); \ 40 | decl_itx16_fns(16, 16, ext) 41 | 42 | decl_itx_fns(rvv); 43 | 44 | static ALWAYS_INLINE void itx_dsp_init_riscv(Dav1dInvTxfmDSPContext *const c, int const bpc) { 45 | const unsigned flags = dav1d_get_cpu_flags(); 46 | 47 | if (!(flags & DAV1D_RISCV_CPU_FLAG_V)) return; 48 | 49 | #if BITDEPTH == 8 50 | assign_itx17_fn( , 4, 4, rvv); 51 | assign_itx16_fn(R, 4, 8, rvv); 52 | assign_itx16_fn(R, 4, 16, rvv); 53 | assign_itx16_fn(R, 8, 4, rvv); 54 | assign_itx16_fn( , 8, 8, rvv); 55 | assign_itx16_fn(R, 8, 16, rvv); 56 | assign_itx16_fn(R, 16, 4, rvv); 57 | assign_itx16_fn(R, 16, 8, rvv); 58 | assign_itx12_fn( , 16, 16, rvv); 59 | #endif 60 | } 61 | -------------------------------------------------------------------------------- /dav1d/src/riscv/64/cpu.S: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * Copyright © 2024, Nathan Egge 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | *****************************************************************************/ 27 | 28 | #include "src/riscv/asm.S" 29 | 30 | // This function detects non-compliant RVV 0.7.1 hardware which reports support 31 | // for the V extension through HWCAP, by intentionally setting tail and mask 32 | // agnostic vector configurations that were only introduced in RVV 0.9 spec. 33 | // Existing non-compliant (pre RVV 1.0) hardware will set the VILL bit in VTYPE 34 | // (indicating an illegal vector configuration) which is stored in the XLEN-1 35 | // bit position, thus a simple sign check is sufficient for detection. 36 | // This work around is inexpensive and harmless on compliant hardware, but we 37 | // should still consider removing it once all non-compliant RVV 0.7.1 hardware 38 | // is out of service. 39 | function has_compliant_rvv, export=1, ext=v 40 | vsetvli t0, zero, e8, m1, ta, ma 41 | csrr a0, vtype 42 | sgtz a0, a0 43 | ret 44 | endfunc 45 | 46 | function get_vlenb, export=1 47 | csrr a0, vlenb 48 | ret 49 | endfunc 50 | -------------------------------------------------------------------------------- /dav1d/src/arm/asm-offsets.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2021, VideoLAN and dav1d authors 3 | * 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 are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef ARM_ASM_OFFSETS_H 28 | #define ARM_ASM_OFFSETS_H 29 | 30 | #include "config.h" 31 | 32 | #define FGD_SEED 0 33 | #define FGD_AR_COEFF_LAG 92 34 | #define FGD_AR_COEFFS_Y 96 35 | #define FGD_AR_COEFFS_UV 120 36 | #define FGD_AR_COEFF_SHIFT 176 37 | #define FGD_GRAIN_SCALE_SHIFT 184 38 | 39 | #define FGD_SCALING_SHIFT 88 40 | #define FGD_UV_MULT 188 41 | #define FGD_UV_LUMA_MULT 196 42 | #define FGD_UV_OFFSET 204 43 | #define FGD_CLIP_TO_RESTRICTED_RANGE 216 44 | 45 | #if ARCH_AARCH64 46 | #define RMVSF_IW8 16 47 | #define RMVSF_IH8 20 48 | #define RMVSF_MFMV_REF 53 49 | #define RMVSF_MFMV_REF2CUR 56 50 | #define RMVSF_MFMV_REF2REF 59 51 | #define RMVSF_N_MFMVS 80 52 | #define RMVSF_RP_REF 96 53 | #define RMVSF_RP_PROJ 104 54 | #define RMVSF_RP_STRIDE 112 55 | #define RMVSF_N_TILE_THREADS 128 56 | #endif 57 | 58 | #endif /* ARM_ASM_OFFSETS_H */ 59 | -------------------------------------------------------------------------------- /dav1d/include/compat/gcc/stdatomic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * 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 are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef GCCVER_STDATOMIC_H_ 28 | #define GCCVER_STDATOMIC_H_ 29 | 30 | #if !defined(__cplusplus) 31 | 32 | typedef int atomic_int; 33 | typedef unsigned int atomic_uint; 34 | 35 | #define memory_order_relaxed __ATOMIC_RELAXED 36 | #define memory_order_acquire __ATOMIC_ACQUIRE 37 | 38 | #define atomic_init(p_a, v) do { *(p_a) = (v); } while(0) 39 | #define atomic_store(p_a, v) __atomic_store_n(p_a, v, __ATOMIC_SEQ_CST) 40 | #define atomic_load(p_a) __atomic_load_n(p_a, __ATOMIC_SEQ_CST) 41 | #define atomic_load_explicit(p_a, mo) __atomic_load_n(p_a, mo) 42 | #define atomic_fetch_add(p_a, inc) __atomic_fetch_add(p_a, inc, __ATOMIC_SEQ_CST) 43 | #define atomic_fetch_add_explicit(p_a, inc, mo) __atomic_fetch_add(p_a, inc, mo) 44 | #define atomic_fetch_sub(p_a, dec) __atomic_fetch_sub(p_a, dec, __ATOMIC_SEQ_CST) 45 | #define atomic_exchange(p_a, v) __atomic_exchange_n(p_a, v, __ATOMIC_SEQ_CST) 46 | #define atomic_fetch_or(p_a, v) __atomic_fetch_or(p_a, v, __ATOMIC_SEQ_CST) 47 | #define atomic_compare_exchange_strong(p_a, expected, desired) __atomic_compare_exchange_n(p_a, expected, desired, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) 48 | 49 | #endif /* !defined(__cplusplus) */ 50 | 51 | #endif /* GCCVER_STDATOMIC_H_ */ 52 | -------------------------------------------------------------------------------- /libde265/libde265/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = subdir-objects 2 | 3 | lib_LTLIBRARIES = libde265.la 4 | 5 | libde265_ladir = \ 6 | $(includedir)/libde265 7 | 8 | libde265_la_CPPFLAGS = 9 | libde265_la_CFLAGS = \ 10 | $(CFLAG_VISIBILITY) \ 11 | -DLIBDE265_EXPORTS 12 | libde265_la_CXXFLAGS = \ 13 | $(CFLAG_VISIBILITY) \ 14 | -DLIBDE265_EXPORTS \ 15 | -I$(top_srcdir) 16 | 17 | if HAVE_VISIBILITY 18 | libde265_la_CFLAGS += -DHAVE_VISIBILITY 19 | libde265_la_CXXFLAGS += -DHAVE_VISIBILITY 20 | endif 21 | 22 | libde265_la_LDFLAGS = -version-info $(LIBDE265_CURRENT):$(LIBDE265_REVISION):$(LIBDE265_AGE) 23 | 24 | libde265_la_SOURCES = \ 25 | acceleration.h \ 26 | alloc_pool.h \ 27 | alloc_pool.cc \ 28 | bitstream.cc \ 29 | bitstream.h \ 30 | cabac.cc \ 31 | cabac.h \ 32 | configparam.cc \ 33 | configparam.h \ 34 | contextmodel.cc \ 35 | contextmodel.h \ 36 | de265.cc \ 37 | deblock.cc \ 38 | deblock.h \ 39 | decctx.cc \ 40 | decctx.h \ 41 | fallback.cc \ 42 | fallback.h \ 43 | fallback-dct.h \ 44 | fallback-dct.cc \ 45 | fallback-motion.cc \ 46 | fallback-motion.h \ 47 | dpb.cc \ 48 | dpb.h \ 49 | image.cc \ 50 | image.h \ 51 | image-io.h \ 52 | image-io.cc \ 53 | intrapred.cc \ 54 | intrapred.h \ 55 | md5.cc \ 56 | md5.h \ 57 | motion.cc \ 58 | motion.h \ 59 | nal.cc \ 60 | nal.h \ 61 | nal-parser.cc \ 62 | nal-parser.h \ 63 | pps.cc \ 64 | pps.h \ 65 | quality.cc \ 66 | quality.h \ 67 | refpic.cc \ 68 | refpic.h \ 69 | sao.cc \ 70 | sao.h \ 71 | scan.cc \ 72 | scan.h \ 73 | sei.cc \ 74 | sei.h \ 75 | slice.cc \ 76 | slice.h \ 77 | sps.cc \ 78 | sps.h \ 79 | threads.cc \ 80 | threads.h \ 81 | transform.cc \ 82 | transform.h \ 83 | util.cc \ 84 | util.h \ 85 | visualize.cc \ 86 | visualize.h \ 87 | vps.cc \ 88 | vps.h \ 89 | vui.cc \ 90 | vui.h 91 | 92 | SUBDIRS = 93 | libde265_la_LIBADD = 94 | 95 | if ENABLE_ENCODER 96 | libde265_la_SOURCES += en265.h en265.cc 97 | SUBDIRS += encoder 98 | libde265_la_LIBADD += encoder/libde265_encoder.la 99 | endif 100 | 101 | if ENABLE_SSE_OPT 102 | SUBDIRS += x86 103 | libde265_la_LIBADD += x86/libde265_x86.la 104 | endif 105 | 106 | if ENABLE_ARM_OPT 107 | SUBDIRS += arm 108 | libde265_la_LIBADD += arm/libde265_arm.la 109 | endif 110 | 111 | if MINGW 112 | libde265_la_SOURCES += ../extra/win32cond.c ../extra/win32cond.h 113 | libde265_la_LDFLAGS += -no-undefined -static-libgcc -static-libstdc++ 114 | endif 115 | 116 | EXTRA_DIST = Makefile.vc7 \ 117 | CMakeLists.txt 118 | 119 | libde265_la_HEADERS = \ 120 | de265.h \ 121 | de265-version.h 122 | -------------------------------------------------------------------------------- /libde265/libde265/alloc_pool.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2014 struktur AG, Dirk Farin 4 | * 5 | * Authors: Dirk Farin 6 | * 7 | * This file is part of libde265. 8 | * 9 | * libde265 is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of 12 | * the License, or (at your option) any later version. 13 | * 14 | * libde265 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 Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with libde265. If not, see . 21 | */ 22 | 23 | #include "libde265/alloc_pool.h" 24 | #include "libde265/util.h" 25 | #include 26 | #include 27 | 28 | #define DEBUG_MEMORY 1 29 | 30 | 31 | alloc_pool::alloc_pool(size_t objSize, int poolSize, bool grow) 32 | : mObjSize(objSize), 33 | mPoolSize(poolSize), 34 | mGrow(grow) 35 | { 36 | m_freeList.reserve(poolSize); 37 | m_memBlocks.reserve(8); 38 | 39 | add_memory_block(); 40 | } 41 | 42 | 43 | void alloc_pool::add_memory_block() 44 | { 45 | uint8_t* p = new uint8_t[mObjSize * mPoolSize]; 46 | m_memBlocks.push_back(p); 47 | 48 | for (int i=0;iload_tmvs = dav1d_load_tmvs_neon; 56 | #endif 57 | c->save_tmvs = dav1d_save_tmvs_neon; 58 | c->splat_mv = dav1d_splat_mv_neon; 59 | } 60 | -------------------------------------------------------------------------------- /dav1d/src/x86/refmvs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2021, VideoLAN and dav1d authors 3 | * Copyright © 2021, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "src/cpu.h" 29 | #include "src/refmvs.h" 30 | 31 | decl_load_tmvs_fn(dav1d_load_tmvs_sse4); 32 | 33 | decl_save_tmvs_fn(dav1d_save_tmvs_ssse3); 34 | decl_save_tmvs_fn(dav1d_save_tmvs_avx2); 35 | decl_save_tmvs_fn(dav1d_save_tmvs_avx512icl); 36 | 37 | decl_splat_mv_fn(dav1d_splat_mv_sse2); 38 | decl_splat_mv_fn(dav1d_splat_mv_avx2); 39 | decl_splat_mv_fn(dav1d_splat_mv_avx512icl); 40 | 41 | static ALWAYS_INLINE void refmvs_dsp_init_x86(Dav1dRefmvsDSPContext *const c) { 42 | const unsigned flags = dav1d_get_cpu_flags(); 43 | 44 | if (!(flags & DAV1D_X86_CPU_FLAG_SSE2)) return; 45 | 46 | c->splat_mv = dav1d_splat_mv_sse2; 47 | 48 | if (!(flags & DAV1D_X86_CPU_FLAG_SSSE3)) return; 49 | 50 | c->save_tmvs = dav1d_save_tmvs_ssse3; 51 | 52 | if (!(flags & DAV1D_X86_CPU_FLAG_SSE41)) return; 53 | #if ARCH_X86_64 54 | c->load_tmvs = dav1d_load_tmvs_sse4; 55 | 56 | if (!(flags & DAV1D_X86_CPU_FLAG_AVX2)) return; 57 | 58 | c->save_tmvs = dav1d_save_tmvs_avx2; 59 | c->splat_mv = dav1d_splat_mv_avx2; 60 | 61 | if (!(flags & DAV1D_X86_CPU_FLAG_AVX512ICL)) return; 62 | 63 | c->save_tmvs = dav1d_save_tmvs_avx512icl; 64 | c->splat_mv = dav1d_splat_mv_avx512icl; 65 | #endif 66 | } 67 | -------------------------------------------------------------------------------- /dav1d/src/ppc/cdef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019, Luca Barbato 3 | * 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 are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | 29 | #include "common/bitdepth.h" 30 | #include "common/intops.h" 31 | 32 | #include "src/cdef.h" 33 | #include "src/cpu.h" 34 | 35 | #define cdef_vsx_fn(w, h) \ 36 | void dav1d_cdef_filter_##w##x##h##_vsx(pixel *const dst, \ 37 | const ptrdiff_t dst_stride, \ 38 | const pixel (*left)[2], \ 39 | const pixel *const top, \ 40 | const pixel *const bottom, \ 41 | const int pri_strength, \ 42 | const int sec_strength, \ 43 | const int dir, \ 44 | const int damping, \ 45 | const enum CdefEdgeFlags edges) 46 | 47 | cdef_vsx_fn(4, 4); 48 | cdef_vsx_fn(4, 8); 49 | cdef_vsx_fn(8, 8); 50 | 51 | static ALWAYS_INLINE void cdef_dsp_init_ppc(Dav1dCdefDSPContext *const c) { 52 | const unsigned flags = dav1d_get_cpu_flags(); 53 | 54 | if (!(flags & DAV1D_PPC_CPU_FLAG_VSX)) return; 55 | 56 | #if BITDEPTH == 8 57 | c->fb[0] = dav1d_cdef_filter_8x8_vsx; 58 | c->fb[1] = dav1d_cdef_filter_4x8_vsx; 59 | c->fb[2] = dav1d_cdef_filter_4x4_vsx; 60 | #endif 61 | } 62 | -------------------------------------------------------------------------------- /dav1d/src/arm/arm-arch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2024, VideoLAN and dav1d authors 3 | * 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 are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef ARM_ARM_ARCH_H 28 | #define ARM_ARM_ARCH_H 29 | 30 | /* Compatibility header to define __ARM_ARCH with older compilers */ 31 | #ifndef __ARM_ARCH 32 | 33 | #ifdef _M_ARM 34 | #define __ARM_ARCH _M_ARM 35 | 36 | #elif defined(__ARM_ARCH_8A__) || defined(_M_ARM64) 37 | #define __ARM_ARCH 8 38 | 39 | #elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \ 40 | defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || \ 41 | defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) 42 | #define __ARM_ARCH 7 43 | 44 | #elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \ 45 | defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || \ 46 | defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) 47 | #define __ARM_ARCH 6 48 | 49 | #elif defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) || \ 50 | defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) 51 | #define __ARM_ARCH 5 52 | 53 | #elif defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) 54 | #define __ARM_ARCH 4 55 | 56 | #elif defined(__ARM_ARCH_3__) || defined(__ARM_ARCH_3M__) 57 | #define __ARM_ARCH 3 58 | 59 | #elif defined(__ARM_ARCH_2__) 60 | #define __ARM_ARCH 2 61 | 62 | #else 63 | #error Unknown ARM architecture version 64 | #endif 65 | 66 | #endif /* !__ARM_ARCH */ 67 | 68 | #endif /* ARM_ARM_ARCH_H */ 69 | -------------------------------------------------------------------------------- /dav1d/src/data.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018-2021, VideoLAN and dav1d authors 3 | * Copyright © 2018, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_DATA_H 29 | #define DAV1D_SRC_DATA_H 30 | 31 | #include "dav1d/data.h" 32 | 33 | void dav1d_data_ref(Dav1dData *dst, const Dav1dData *src); 34 | 35 | /** 36 | * Copy the source properties to the destination and increase the 37 | * user_data's reference count (if it's not NULL). 38 | */ 39 | void dav1d_data_props_copy(Dav1dDataProps *dst, const Dav1dDataProps *src); 40 | 41 | void dav1d_data_props_set_defaults(Dav1dDataProps *props); 42 | 43 | uint8_t *dav1d_data_create_internal(Dav1dData *buf, size_t sz); 44 | int dav1d_data_wrap_internal(Dav1dData *buf, const uint8_t *ptr, size_t sz, 45 | void (*free_callback)(const uint8_t *data, 46 | void *user_data), 47 | void *user_data); 48 | int dav1d_data_wrap_user_data_internal(Dav1dData *buf, 49 | const uint8_t *user_data, 50 | void (*free_callback)(const uint8_t *user_data, 51 | void *cookie), 52 | void *cookie); 53 | void dav1d_data_unref_internal(Dav1dData *buf); 54 | void dav1d_data_props_unref_internal(Dav1dDataProps *props); 55 | 56 | #endif /* DAV1D_SRC_DATA_H */ 57 | -------------------------------------------------------------------------------- /dav1d/src/ppc/dav1d_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019, VideoLAN and dav1d authors 3 | * Copyright © 2019, Luca Barbato 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_PPC_TYPES_H 29 | #define DAV1D_SRC_PPC_TYPES_H 30 | 31 | #include 32 | #undef pixel 33 | 34 | #define u8x16 vector unsigned char 35 | #define i8x16 vector signed char 36 | #define b8x16 vector bool char 37 | #define u16x8 vector unsigned short 38 | #define i16x8 vector signed short 39 | #define b16x8 vector bool short 40 | #define u32x4 vector unsigned int 41 | #define i32x4 vector signed int 42 | #define b32x4 vector bool int 43 | #define u64x2 vector unsigned long long 44 | #define i64x2 vector signed long long 45 | #define b64x2 vector bool long long 46 | 47 | #define i8h_to_i16(v) ((i16x8) vec_unpackh((i8x16)v)) 48 | #define i8l_to_i16(v) ((i16x8) vec_unpackl((i8x16)v)) 49 | #define u8h_to_i16(v) ((i16x8) vec_mergeh((u8x16) v, vec_splat_u8(0))) 50 | #define u8l_to_i16(v) ((i16x8) vec_mergel((u8x16) v, vec_splat_u8(0))) 51 | #define u8h_to_u16(v) ((u16x8) vec_mergeh((u8x16) v, vec_splat_u8(0))) 52 | #define u8l_to_u16(v) ((u16x8) vec_mergel((u8x16) v, vec_splat_u8(0))) 53 | #define u16h_to_i32(v) ((i32x4) vec_mergeh((u16x8) v, vec_splat_u16(0))) 54 | #define i16h_to_i32(v) ((i32x4) vec_unpackh((i16x8)v)) 55 | #define u16l_to_i32(v) ((i32x4) vec_mergel((u16x8) v, vec_splat_u16(0))) 56 | #define i16l_to_i32(v) ((i32x4) vec_unpackl((i16x8)v)) 57 | 58 | #endif /* DAV1D_SRC_PPC_TYPES_H */ 59 | -------------------------------------------------------------------------------- /dav1d/src/ppc/itx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * Copyright © 2023, Luca Barbato 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "src/cpu.h" 29 | #include "src/itx.h" 30 | 31 | decl_itx17_fns( 4, 4, pwr9); 32 | decl_itx16_fns( 4, 8, pwr9); 33 | decl_itx16_fns( 4, 16, pwr9); 34 | decl_itx16_fns( 8, 4, pwr9); 35 | decl_itx16_fns( 8, 8, pwr9); 36 | decl_itx16_fns( 8, 16, pwr9); 37 | decl_itx2_fns ( 8, 32, pwr9); 38 | decl_itx16_fns(16, 4, pwr9); 39 | decl_itx16_fns(16, 8, pwr9); 40 | decl_itx12_fns(16, 16, pwr9); 41 | decl_itx2_fns (16, 32, pwr9); 42 | decl_itx2_fns (32, 8, pwr9); 43 | decl_itx2_fns (32, 16, pwr9); 44 | decl_itx2_fns (32, 32, pwr9); 45 | 46 | decl_itx_fn(BF(dav1d_inv_txfm_add_dct_dct_16x64, pwr9)); 47 | decl_itx_fn(BF(dav1d_inv_txfm_add_dct_dct_32x64, pwr9)); 48 | decl_itx_fn(BF(dav1d_inv_txfm_add_dct_dct_64x16, pwr9)); 49 | decl_itx_fn(BF(dav1d_inv_txfm_add_dct_dct_64x32, pwr9)); 50 | decl_itx_fn(BF(dav1d_inv_txfm_add_dct_dct_64x64, pwr9)); 51 | 52 | static ALWAYS_INLINE void itx_dsp_init_ppc(Dav1dInvTxfmDSPContext *const c, const int bpc) { 53 | const unsigned flags = dav1d_get_cpu_flags(); 54 | 55 | if (!(flags & DAV1D_PPC_CPU_FLAG_PWR9)) return; 56 | 57 | #if BITDEPTH == 8 58 | assign_itx17_fn( , 4, 4, pwr9); 59 | assign_itx16_fn(R, 4, 8, pwr9); 60 | assign_itx16_fn(R, 8, 4, pwr9); 61 | assign_itx16_fn(, 8, 8, pwr9); 62 | assign_itx16_fn(R, 4, 16, pwr9); 63 | assign_itx16_fn(R, 16, 4, pwr9); 64 | #endif 65 | } 66 | -------------------------------------------------------------------------------- /dav1d/src/riscv/mc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2024, VideoLAN and dav1d authors 3 | * Copyright © 2024, Nathan Egge 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "src/cpu.h" 29 | #include "src/mc.h" 30 | 31 | decl_blend_fn(BF(dav1d_blend, rvv)); 32 | decl_blend_dir_fn(BF(dav1d_blend_h, rvv)); 33 | decl_blend_dir_fn(BF(dav1d_blend_v, rvv)); 34 | 35 | decl_blend_fn(BF(dav1d_blend_vl256, rvv)); 36 | decl_blend_dir_fn(BF(dav1d_blend_h_vl256, rvv)); 37 | decl_blend_dir_fn(BF(dav1d_blend_v_vl256, rvv)); 38 | 39 | decl_avg_fn(BF(dav1d_avg, rvv)); 40 | decl_w_avg_fn(BF(dav1d_w_avg, rvv)); 41 | decl_mask_fn(BF(dav1d_mask, rvv)); 42 | 43 | decl_warp8x8_fn(BF(dav1d_warp_8x8, rvv)); 44 | decl_warp8x8t_fn(BF(dav1d_warp_8x8t, rvv)); 45 | 46 | static ALWAYS_INLINE void mc_dsp_init_riscv(Dav1dMCDSPContext *const c) { 47 | const unsigned flags = dav1d_get_cpu_flags(); 48 | 49 | if (!(flags & DAV1D_RISCV_CPU_FLAG_V)) return; 50 | 51 | c->blend = BF(dav1d_blend, rvv); 52 | c->blend_v = BF(dav1d_blend_v, rvv); 53 | 54 | if (dav1d_get_vlen() >= 256) { 55 | c->blend = BF(dav1d_blend_vl256, rvv); 56 | c->blend_v = BF(dav1d_blend_v_vl256, rvv); 57 | } 58 | 59 | #if BITDEPTH == 8 60 | c->blend_h = BF(dav1d_blend_h, rvv); 61 | 62 | if (dav1d_get_vlen() >= 256) { 63 | c->blend_h = BF(dav1d_blend_h_vl256, rvv); 64 | } 65 | 66 | c->avg = BF(dav1d_avg, rvv); 67 | c->w_avg = BF(dav1d_w_avg, rvv); 68 | c->mask = BF(dav1d_mask, rvv); 69 | 70 | c->warp8x8 = BF(dav1d_warp_8x8, rvv); 71 | c->warp8x8t = BF(dav1d_warp_8x8t, rvv); 72 | #endif 73 | } 74 | -------------------------------------------------------------------------------- /dav1d/src/loongarch/msac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2023, VideoLAN and dav1d authors 3 | * Copyright © 2023, Loongson Technology Corporation Limited 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_LOONGARCH_MSAC_H 29 | #define DAV1D_SRC_LOONGARCH_MSAC_H 30 | 31 | unsigned dav1d_msac_decode_symbol_adapt4_lsx(MsacContext *s, uint16_t *cdf, 32 | size_t n_symbols); 33 | unsigned dav1d_msac_decode_symbol_adapt8_lsx(MsacContext *s, uint16_t *cdf, 34 | size_t n_symbols); 35 | unsigned dav1d_msac_decode_symbol_adapt16_lsx(MsacContext *s, uint16_t *cdf, 36 | size_t n_symbols); 37 | unsigned dav1d_msac_decode_bool_adapt_lsx(MsacContext *s, uint16_t *cdf); 38 | unsigned dav1d_msac_decode_bool_lsx(MsacContext *s, unsigned f); 39 | unsigned dav1d_msac_decode_bool_equi_lsx(MsacContext *s); 40 | unsigned dav1d_msac_decode_hi_tok_lsx(MsacContext *s, uint16_t *cdf); 41 | 42 | #define dav1d_msac_decode_symbol_adapt4 dav1d_msac_decode_symbol_adapt4_lsx 43 | #define dav1d_msac_decode_symbol_adapt8 dav1d_msac_decode_symbol_adapt8_lsx 44 | #define dav1d_msac_decode_symbol_adapt16 dav1d_msac_decode_symbol_adapt16_lsx 45 | #define dav1d_msac_decode_bool_adapt dav1d_msac_decode_bool_adapt_lsx 46 | #define dav1d_msac_decode_bool dav1d_msac_decode_bool_lsx 47 | #define dav1d_msac_decode_bool_equi dav1d_msac_decode_bool_equi_lsx 48 | #define dav1d_msac_decode_hi_tok dav1d_msac_decode_hi_tok_lsx 49 | 50 | #endif /* DAV1D_SRC_LOONGARCH_MSAC_H */ 51 | -------------------------------------------------------------------------------- /libde265/libde265/Makefile.vc7: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Microsoft Visual Studio 2003 3 | # 4 | CFLAGS=/I..\extra /I.. /I. 5 | CC=cl /nologo 6 | LINK=link /nologo /subsystem:console 7 | DEFINES=/DWIN32 /D_WIN32_WINNT=0x0400 /DNDEBUG /DLIBDE265_EXPORTS /D_CRT_SECURE_NO_WARNINGS /DHAVE_SSE4_1 /DHAVE_STDINT_H 8 | 9 | CFLAGS=$(CFLAGS) /MT /Ox /Ob2 /Oi /TP /W4 /GL /EHsc 10 | 11 | # type conversion, possible loss of data 12 | CFLAGS=$(CFLAGS) /wd4244 13 | # unreferenced formal parameter 14 | CFLAGS=$(CFLAGS) /wd4100 15 | # local variable is initialized but not referenced 16 | CFLAGS=$(CFLAGS) /wd4189 17 | # unreferenced local function has been removed 18 | CFLAGS=$(CFLAGS) /wd4505 19 | # padded structures 20 | CFLAGS=$(CFLAGS) /wd4324 21 | # conversion signed/unsigned 22 | CFLAGS=$(CFLAGS) /wd4245 23 | # comparison signed/unsigned 24 | CFLAGS=$(CFLAGS) /wd4018 /wd4389 25 | # possible loss of data with return 26 | CFLAGS=$(CFLAGS) /wd4267 27 | # forcing value to bool (performance warning) 28 | CFLAGS=$(CFLAGS) /wd4800 29 | 30 | CFLAGS=$(CFLAGS) $(DEFINES) 31 | 32 | OBJS=\ 33 | alloc_pool.obj \ 34 | bitstream.obj \ 35 | cabac.obj \ 36 | configparam.obj \ 37 | contextmodel.obj \ 38 | de265.obj \ 39 | deblock.obj \ 40 | decctx.obj \ 41 | dpb.obj \ 42 | en265.obj \ 43 | fallback-dct.obj \ 44 | fallback-motion.obj \ 45 | fallback.obj \ 46 | image.obj \ 47 | image-io.obj \ 48 | intrapred.obj \ 49 | md5.obj \ 50 | motion.obj \ 51 | nal.obj \ 52 | nal-parser.obj \ 53 | pps.obj \ 54 | quality.obj \ 55 | refpic.obj \ 56 | sao.obj \ 57 | scan.obj \ 58 | sei.obj \ 59 | slice.obj \ 60 | sps.obj \ 61 | threads.obj \ 62 | transform.obj \ 63 | util.obj \ 64 | visualize.obj \ 65 | vps.obj \ 66 | vui.obj \ 67 | encoder\encoder-core.obj \ 68 | encoder\encoder-types.obj \ 69 | encoder\encoder-context.obj \ 70 | encoder\encoder-params.obj \ 71 | encoder\encoder-syntax.obj \ 72 | encoder\encoder-intrapred.obj \ 73 | encoder\encoder-motion.obj \ 74 | encoder\encpicbuf.obj \ 75 | encoder\sop.obj \ 76 | encoder\algo\algo.obj \ 77 | encoder\algo\cb-interpartmode.obj \ 78 | encoder\algo\cb-intra-inter.obj \ 79 | encoder\algo\cb-intrapartmode.obj \ 80 | encoder\algo\cb-mergeindex.obj \ 81 | encoder\algo\cb-skip.obj \ 82 | encoder\algo\cb-split.obj \ 83 | encoder\algo\coding-options.obj \ 84 | encoder\algo\ctb-qscale.obj \ 85 | encoder\algo\pb-mv.obj \ 86 | encoder\algo\tb-intrapredmode.obj \ 87 | encoder\algo\tb-rateestim.obj \ 88 | encoder\algo\tb-split.obj \ 89 | encoder\algo\tb-transform.obj \ 90 | x86\sse.obj \ 91 | x86\sse-dct.obj \ 92 | x86\sse-motion.obj \ 93 | ..\extra\win32cond.obj 94 | 95 | all: libde265.dll 96 | 97 | .c.obj: 98 | $(CC) /c $*.c /Fo$*.obj $(CFLAGS) 99 | 100 | .cc.obj: 101 | $(CC) /c $*.cc /Fo$*.obj $(CFLAGS) 102 | 103 | libde265.dll: $(OBJS) 104 | $(LINK) /dll /out:libde265.dll $** 105 | 106 | clean: 107 | del libde265.dll 108 | del $(OBJS) 109 | -------------------------------------------------------------------------------- /dav1d/include/common/intops.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * Copyright © 2018, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_COMMON_INTOPS_H 29 | #define DAV1D_COMMON_INTOPS_H 30 | 31 | #include 32 | 33 | #include "common/attributes.h" 34 | 35 | static inline int imax(const int a, const int b) { 36 | return a > b ? a : b; 37 | } 38 | 39 | static inline int imin(const int a, const int b) { 40 | return a < b ? a : b; 41 | } 42 | 43 | static inline unsigned umax(const unsigned a, const unsigned b) { 44 | return a > b ? a : b; 45 | } 46 | 47 | static inline unsigned umin(const unsigned a, const unsigned b) { 48 | return a < b ? a : b; 49 | } 50 | 51 | static inline int iclip(const int v, const int min, const int max) { 52 | return v < min ? min : v > max ? max : v; 53 | } 54 | 55 | static inline int iclip_u8(const int v) { 56 | return iclip(v, 0, 255); 57 | } 58 | 59 | static inline int apply_sign(const int v, const int s) { 60 | return s < 0 ? -v : v; 61 | } 62 | 63 | static inline int apply_sign64(const int v, const int64_t s) { 64 | return s < 0 ? -v : v; 65 | } 66 | 67 | static inline int ulog2(const unsigned v) { 68 | return 31 ^ clz(v); 69 | } 70 | 71 | static inline int u64log2(const uint64_t v) { 72 | return 63 ^ clzll(v); 73 | } 74 | 75 | static inline unsigned inv_recenter(const unsigned r, const unsigned v) { 76 | if (v > (r << 1)) 77 | return v; 78 | else if ((v & 1) == 0) 79 | return (v >> 1) + r; 80 | else 81 | return r - ((v + 1) >> 1); 82 | } 83 | 84 | #endif /* DAV1D_COMMON_INTOPS_H */ 85 | -------------------------------------------------------------------------------- /dav1d/src/arm/msac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019, VideoLAN and dav1d authors 3 | * Copyright © 2019, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_ARM_MSAC_H 29 | #define DAV1D_SRC_ARM_MSAC_H 30 | 31 | unsigned dav1d_msac_decode_symbol_adapt4_neon(MsacContext *s, uint16_t *cdf, 32 | size_t n_symbols); 33 | unsigned dav1d_msac_decode_symbol_adapt8_neon(MsacContext *s, uint16_t *cdf, 34 | size_t n_symbols); 35 | unsigned dav1d_msac_decode_symbol_adapt16_neon(MsacContext *s, uint16_t *cdf, 36 | size_t n_symbols); 37 | unsigned dav1d_msac_decode_hi_tok_neon(MsacContext *s, uint16_t *cdf); 38 | unsigned dav1d_msac_decode_bool_adapt_neon(MsacContext *s, uint16_t *cdf); 39 | unsigned dav1d_msac_decode_bool_equi_neon(MsacContext *s); 40 | unsigned dav1d_msac_decode_bool_neon(MsacContext *s, unsigned f); 41 | 42 | #if defined(__ARM_NEON) || defined(__APPLE__) || defined(_WIN32) || ARCH_AARCH64 43 | #define dav1d_msac_decode_symbol_adapt4 dav1d_msac_decode_symbol_adapt4_neon 44 | #define dav1d_msac_decode_symbol_adapt8 dav1d_msac_decode_symbol_adapt8_neon 45 | #define dav1d_msac_decode_symbol_adapt16 dav1d_msac_decode_symbol_adapt16_neon 46 | #define dav1d_msac_decode_hi_tok dav1d_msac_decode_hi_tok_neon 47 | #define dav1d_msac_decode_bool_adapt dav1d_msac_decode_bool_adapt_neon 48 | #define dav1d_msac_decode_bool_equi dav1d_msac_decode_bool_equi_neon 49 | #define dav1d_msac_decode_bool dav1d_msac_decode_bool_neon 50 | #endif 51 | 52 | #endif /* DAV1D_SRC_ARM_MSAC_H */ 53 | -------------------------------------------------------------------------------- /dav1d/src/cdef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * Copyright © 2018, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_CDEF_H 29 | #define DAV1D_SRC_CDEF_H 30 | 31 | #include 32 | #include 33 | 34 | #include "common/bitdepth.h" 35 | 36 | enum CdefEdgeFlags { 37 | CDEF_HAVE_LEFT = 1 << 0, 38 | CDEF_HAVE_RIGHT = 1 << 1, 39 | CDEF_HAVE_TOP = 1 << 2, 40 | CDEF_HAVE_BOTTOM = 1 << 3, 41 | }; 42 | 43 | #ifdef BITDEPTH 44 | typedef const pixel (*const_left_pixel_row_2px)[2]; 45 | #else 46 | typedef const void *const_left_pixel_row_2px; 47 | #endif 48 | 49 | // CDEF operates entirely on pre-filter data; if bottom/right edges are 50 | // present (according to $edges), then the pre-filter data is located in 51 | // $dst. However, the edge pixels above $dst may be post-filter, so in 52 | // order to get access to pre-filter top pixels, use $top. 53 | #define decl_cdef_fn(name) \ 54 | void (name)(pixel *dst, ptrdiff_t stride, const_left_pixel_row_2px left, \ 55 | const pixel *top, const pixel *bottom, \ 56 | int pri_strength, int sec_strength, \ 57 | int dir, int damping, enum CdefEdgeFlags edges HIGHBD_DECL_SUFFIX) 58 | typedef decl_cdef_fn(*cdef_fn); 59 | 60 | #define decl_cdef_dir_fn(name) \ 61 | int (name)(const pixel *dst, ptrdiff_t dst_stride, unsigned *var HIGHBD_DECL_SUFFIX) 62 | typedef decl_cdef_dir_fn(*cdef_dir_fn); 63 | 64 | typedef struct Dav1dCdefDSPContext { 65 | cdef_dir_fn dir; 66 | cdef_fn fb[3 /* 444/luma, 422, 420 */]; 67 | } Dav1dCdefDSPContext; 68 | 69 | bitfn_decls(void dav1d_cdef_dsp_init, Dav1dCdefDSPContext *c); 70 | 71 | #endif /* DAV1D_SRC_CDEF_H */ 72 | -------------------------------------------------------------------------------- /dav1d/src/pal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2023, VideoLAN and dav1d authors 3 | * Copyright © 2023, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "config.h" 29 | 30 | #include 31 | 32 | #include "common/attributes.h" 33 | 34 | #include "src/pal.h" 35 | 36 | // fill invisible edges and pack to 4-bit (2 pixels per byte) 37 | static void pal_idx_finish_c(uint8_t *dst, const uint8_t *src, 38 | const int bw, const int bh, 39 | const int w, const int h) 40 | { 41 | assert(bw >= 4 && bw <= 64 && !(bw & (bw - 1))); 42 | assert(bh >= 4 && bh <= 64 && !(bh & (bh - 1))); 43 | assert(w >= 4 && w <= bw && !(w & 3)); 44 | assert(h >= 4 && h <= bh && !(h & 3)); 45 | 46 | const int dst_w = w / 2; 47 | const int dst_bw = bw / 2; 48 | 49 | for (int y = 0; y < h; y++, src += bw, dst += dst_bw) { 50 | for (int x = 0; x < dst_w; x++) 51 | dst[x] = src[x * 2 + 0] | (src[x * 2 + 1] << 4); 52 | if (dst_w < dst_bw) 53 | memset(dst + dst_w, src[w - 1] * 0x11, dst_bw - dst_w); 54 | } 55 | 56 | if (h < bh) { 57 | const uint8_t *const last_row = &dst[-dst_bw]; 58 | for (int y = h; y < bh; y++, dst += dst_bw) 59 | memcpy(dst, last_row, dst_bw); 60 | } 61 | } 62 | 63 | #if HAVE_ASM 64 | #if ARCH_RISCV 65 | #include "riscv/pal.h" 66 | #elif ARCH_X86 67 | #include "x86/pal.h" 68 | #endif 69 | #endif 70 | 71 | COLD void dav1d_pal_dsp_init(Dav1dPalDSPContext *const c) { 72 | c->pal_idx_finish = pal_idx_finish_c; 73 | 74 | #if HAVE_ASM 75 | #if ARCH_RISCV 76 | pal_dsp_init_riscv(c); 77 | #elif ARCH_X86 78 | pal_dsp_init_x86(c); 79 | #endif 80 | #endif 81 | } 82 | -------------------------------------------------------------------------------- /heif/heif_test.go: -------------------------------------------------------------------------------- 1 | package heif 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "os" 7 | "testing" 8 | 9 | "github.com/rwcarlsen/goexif/exif" 10 | "github.com/rwcarlsen/goexif/tiff" 11 | ) 12 | 13 | func TestAll(t *testing.T) { 14 | f, err := os.Open("testdata/park.heic") 15 | if err != nil { 16 | t.Fatal(err) 17 | } 18 | defer f.Close() 19 | h := Open(f) 20 | 21 | // meta 22 | _, err = h.getMeta() 23 | if err != nil { 24 | t.Fatalf("getMeta: %v", err) 25 | } 26 | 27 | it, err := h.PrimaryItem() 28 | if err != nil { 29 | t.Fatalf("PrimaryItem: %v", err) 30 | } 31 | if want := uint32(49); it.ID != want { 32 | t.Errorf("PrimaryIem ID = %v; want %v", it.ID, want) 33 | } 34 | if it.Location == nil { 35 | t.Errorf("Item.Location is nil") 36 | } 37 | if it.Info == nil { 38 | t.Errorf("Item.Info is nil") 39 | } 40 | if len(it.Properties) == 0 { 41 | t.Errorf("Item.Properties is empty") 42 | } 43 | for _, prop := range it.Properties { 44 | t.Logf(" property: %q, %#v", prop.Type(), prop) 45 | } 46 | if w, h, ok := it.SpatialExtents(); !ok || w == 0 || h == 0 { 47 | t.Errorf("no spatial extents found") 48 | } else { 49 | t.Logf("dimensions: %v x %v", w, h) 50 | } 51 | 52 | // exif 53 | exbuf, err := h.EXIF() 54 | if err != nil { 55 | t.Errorf("EXIF: %v", err) 56 | } else { 57 | const magic = "Exif\x00\x00" 58 | if !bytes.HasPrefix(exbuf, []byte(magic)) { 59 | t.Errorf("Exif buffer doesn't start with %q: got %q", magic, exbuf) 60 | } 61 | x, err := exif.Decode(bytes.NewReader(exbuf)) 62 | if err != nil { 63 | t.Fatalf("EXIF decode: %v", err) 64 | } 65 | got := map[string]string{} 66 | if err := x.Walk(walkFunc(func(name exif.FieldName, tag *tiff.Tag) error { 67 | got[fmt.Sprint(name)] = fmt.Sprint(tag) 68 | return nil 69 | })); err != nil { 70 | t.Fatalf("EXIF walk: %v", err) 71 | } 72 | if g, w := len(got), 56; g < w { 73 | t.Errorf("saw %v EXIF tags; want at least %v", g, w) 74 | } 75 | if g, w := got["GPSLongitude"], `["122/1","21/1","3776/100"]`; g != w { 76 | t.Errorf("GPSLongitude = %#q; want %#q", g, w) 77 | } 78 | 79 | } 80 | } 81 | 82 | func TestRotations(t *testing.T) { 83 | f, err := os.Open("testdata/rotate.heic") 84 | if err != nil { 85 | t.Fatal(err) 86 | } 87 | defer f.Close() 88 | h := Open(f) 89 | it, err := h.PrimaryItem() 90 | if err != nil { 91 | t.Fatalf("PrimaryItem: %v", err) 92 | } 93 | if r := it.Rotations(); r != 3 { 94 | t.Errorf("Rotations = %v; want %v", r, 3) 95 | } 96 | sw, sh, ok := it.SpatialExtents() 97 | if !ok { 98 | t.Fatalf("expected spatial extents") 99 | } 100 | vw, vh, ok := it.VisualDimensions() 101 | if !ok { 102 | t.Fatalf("expected visual dimensions") 103 | } 104 | if vw != sh || vh != sw { 105 | t.Errorf("visual dimensions = %v, %v; want %v, %v", vw, vh, sh, sw) 106 | } 107 | } 108 | 109 | type walkFunc func(exif.FieldName, *tiff.Tag) error 110 | 111 | func (f walkFunc) Walk(name exif.FieldName, tag *tiff.Tag) error { 112 | return f(name, tag) 113 | } 114 | -------------------------------------------------------------------------------- /dav1d/src/ref.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * Copyright © 2018, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_REF_H 29 | #define DAV1D_SRC_REF_H 30 | 31 | #include "dav1d/dav1d.h" 32 | 33 | #include "src/mem.h" 34 | #include "src/thread.h" 35 | 36 | #include 37 | #include 38 | 39 | struct Dav1dRef { 40 | void *data; 41 | const void *const_data; 42 | atomic_int ref_cnt; 43 | int free_ref; 44 | void (*free_callback)(const uint8_t *data, void *user_data); 45 | void *user_data; 46 | }; 47 | 48 | #if !TRACK_HEAP_ALLOCATIONS 49 | #define dav1d_ref_create(type, size) dav1d_ref_create(size) 50 | #endif 51 | 52 | Dav1dRef *dav1d_ref_create(enum AllocationType type, size_t size); 53 | Dav1dRef *dav1d_ref_create_using_pool(Dav1dMemPool *pool, size_t size); 54 | void dav1d_ref_dec(Dav1dRef **ref); 55 | 56 | static inline Dav1dRef *dav1d_ref_init(Dav1dRef *const ref, const void *const ptr, 57 | void (*const free_callback)(const uint8_t *data, void *user_data), 58 | void *const user_data, const int free_ref) 59 | { 60 | ref->data = NULL; 61 | ref->const_data = ptr; 62 | atomic_init(&ref->ref_cnt, 1); 63 | ref->free_ref = free_ref; 64 | ref->free_callback = free_callback; 65 | ref->user_data = user_data; 66 | return ref; 67 | } 68 | 69 | static inline void dav1d_ref_inc(Dav1dRef *const ref) { 70 | atomic_fetch_add_explicit(&ref->ref_cnt, 1, memory_order_relaxed); 71 | } 72 | 73 | static inline int dav1d_ref_is_writable(Dav1dRef *const ref) { 74 | return atomic_load(&ref->ref_cnt) == 1 && ref->data; 75 | } 76 | 77 | #endif /* DAV1D_SRC_REF_H */ 78 | -------------------------------------------------------------------------------- /dav1d/src/getbits.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * Copyright © 2018, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_GETBITS_H 29 | #define DAV1D_SRC_GETBITS_H 30 | 31 | #include 32 | #include 33 | 34 | typedef struct GetBits { 35 | uint64_t state; 36 | int bits_left, error; 37 | const uint8_t *ptr, *ptr_start, *ptr_end; 38 | } GetBits; 39 | 40 | void dav1d_init_get_bits(GetBits *c, const uint8_t *data, size_t sz); 41 | unsigned dav1d_get_bit(GetBits *c); 42 | unsigned dav1d_get_bits(GetBits *c, int n); 43 | int dav1d_get_sbits(GetBits *c, int n); 44 | unsigned dav1d_get_uleb128(GetBits *c); 45 | 46 | // Output in range 0..max-1 47 | unsigned dav1d_get_uniform(GetBits *c, unsigned max); 48 | unsigned dav1d_get_vlc(GetBits *c); 49 | int dav1d_get_bits_subexp(GetBits *c, int ref, unsigned n); 50 | 51 | // Discard bits from the buffer until we're next byte-aligned. 52 | static inline void dav1d_bytealign_get_bits(GetBits *c) { 53 | // bits_left is never more than 7, because it is only incremented 54 | // by refill(), called by dav1d_get_bits and that never reads more 55 | // than 7 bits more than it needs. 56 | // 57 | // If this wasn't true, we would need to work out how many bits to 58 | // discard (bits_left % 8), subtract that from bits_left and then 59 | // shift state right by that amount. 60 | assert(c->bits_left <= 7); 61 | 62 | c->bits_left = 0; 63 | c->state = 0; 64 | } 65 | 66 | // Return the current bit position relative to the start of the buffer. 67 | static inline unsigned dav1d_get_bits_pos(const GetBits *c) { 68 | return (unsigned) (c->ptr - c->ptr_start) * 8 - c->bits_left; 69 | } 70 | 71 | #endif /* DAV1D_SRC_GETBITS_H */ 72 | -------------------------------------------------------------------------------- /dav1d/src/riscv/64/pal.S: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright © 2018, VideoLAN and dav1d authors 3 | * Copyright © 2024, Bogdan Gligorijevic 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | *****************************************************************************/ 27 | 28 | #include "src/riscv/asm.S" 29 | 30 | function pal_idx_finish_rvv, export=1, ext="v,zba,zbb" 31 | csrw vxrm, zero 32 | srl t0, a2, 1 33 | sub a2, a2, a4 34 | srl t1, a4, 1 35 | mv t2, a5 36 | 37 | csrr t6, vlenb 38 | li t4, -3 39 | ctz a6, t0 40 | ctz t6, t6 41 | li a7, 16 42 | sub a6, a6, t6 43 | li t6, 1<<4+1 44 | 45 | // a6 is never > 3 for VLEN >=128 46 | // that would've required stripmining with a6 set to 3 47 | max a6, a6, t4 48 | li t5, 2 49 | andi a6, a6, 7 50 | addi t4, a1, 1 51 | ori a6, a6, 0xc0 52 | 53 | 1: 54 | sub t3, t0, t1 55 | vsetvl zero, t1, a6 56 | vlse8.v v0, (a1), t5 57 | sh1add a1, t1, a1 58 | vlse8.v v8, (t4), t5 59 | sh1add t4, t1, t4 60 | vmacc.vx v0, a7, v8 61 | vse8.v v0, (a0) 62 | add a0, a0, t1 63 | ble t3, zero, 4f 64 | 65 | lbu a4, -1(a1) 66 | mul a4, a4, t6 67 | vsetvl zero, t3, a6 68 | vmv.v.x v0, a4 69 | vse8.v v0, (a0) 70 | add a0, a0, t3 71 | 4: 72 | addi t2, t2, -1 73 | add a1, a1, a2 74 | add t4, t4, a2 75 | bnez t2, 1b 76 | 77 | sub t1, a3, a5 78 | 79 | sub t2, a0, t0 80 | ble t1, zero, 7f 81 | 82 | vsetvl zero, t0, a6 83 | vle8.v v0, (t2) 84 | add t2, a0, t0 85 | 5: 86 | addi t1, t1, -2 87 | vse8.v v0, (a0) 88 | vse8.v v0, (t2) 89 | sh1add a0, t0, a0 90 | sh1add t2, t0, t2 91 | 92 | bnez t1, 5b 93 | 7: 94 | ret 95 | endfunc 96 | -------------------------------------------------------------------------------- /libde265/libde265/quality.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * H.265 video codec. 3 | * Copyright (c) 2013-2014 struktur AG, Dirk Farin 4 | * 5 | * This file is part of libde265. 6 | * 7 | * libde265 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 | * libde265 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 libde265. If not, see . 19 | */ 20 | 21 | #include "quality.h" 22 | #include 23 | 24 | 25 | uint32_t SSD(const uint8_t* img, int imgStride, 26 | const uint8_t* ref, int refStride, 27 | int width, int height) 28 | { 29 | uint32_t sum=0; 30 | 31 | const uint8_t* iPtr = img; 32 | const uint8_t* rPtr = ref; 33 | 34 | for (int y=0;yget_image_plane_at_pos(cIdx,x0,y0), img1->get_image_stride(cIdx), 109 | img2->get_image_plane_at_pos(cIdx,x0,y0), img2->get_image_stride(cIdx), 110 | 1<loop_filter_sb[0][0] = BF(dav1d_lpf_h_sb_y, ssse3); 47 | c->loop_filter_sb[0][1] = BF(dav1d_lpf_v_sb_y, ssse3); 48 | c->loop_filter_sb[1][0] = BF(dav1d_lpf_h_sb_uv, ssse3); 49 | c->loop_filter_sb[1][1] = BF(dav1d_lpf_v_sb_uv, ssse3); 50 | 51 | #if ARCH_X86_64 52 | if (!(flags & DAV1D_X86_CPU_FLAG_AVX2)) return; 53 | 54 | c->loop_filter_sb[0][0] = BF(dav1d_lpf_h_sb_y, avx2); 55 | c->loop_filter_sb[0][1] = BF(dav1d_lpf_v_sb_y, avx2); 56 | c->loop_filter_sb[1][0] = BF(dav1d_lpf_h_sb_uv, avx2); 57 | c->loop_filter_sb[1][1] = BF(dav1d_lpf_v_sb_uv, avx2); 58 | 59 | if (!(flags & DAV1D_X86_CPU_FLAG_AVX512ICL)) return; 60 | 61 | c->loop_filter_sb[0][1] = BF(dav1d_lpf_v_sb_y, avx512icl); 62 | c->loop_filter_sb[1][1] = BF(dav1d_lpf_v_sb_uv, avx512icl); 63 | 64 | if (!(flags & DAV1D_X86_CPU_FLAG_SLOW_GATHER)) { 65 | c->loop_filter_sb[0][0] = BF(dav1d_lpf_h_sb_y, avx512icl); 66 | c->loop_filter_sb[1][0] = BF(dav1d_lpf_h_sb_uv, avx512icl); 67 | } 68 | #endif 69 | } 70 | -------------------------------------------------------------------------------- /dav1d/src/intra_edge.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018-2023, VideoLAN and dav1d authors 3 | * Copyright © 2018-2023, Two Orioles, LLC 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DAV1D_SRC_INTRA_EDGE_H 29 | #define DAV1D_SRC_INTRA_EDGE_H 30 | 31 | #include 32 | 33 | enum EdgeFlags { 34 | EDGE_I444_TOP_HAS_RIGHT = 1 << 0, 35 | EDGE_I422_TOP_HAS_RIGHT = 1 << 1, 36 | EDGE_I420_TOP_HAS_RIGHT = 1 << 2, 37 | EDGE_I444_LEFT_HAS_BOTTOM = 1 << 3, 38 | EDGE_I422_LEFT_HAS_BOTTOM = 1 << 4, 39 | EDGE_I420_LEFT_HAS_BOTTOM = 1 << 5, 40 | EDGE_ALL_TOP_HAS_RIGHT = EDGE_I444_TOP_HAS_RIGHT | 41 | EDGE_I422_TOP_HAS_RIGHT | 42 | EDGE_I420_TOP_HAS_RIGHT, 43 | EDGE_ALL_LEFT_HAS_BOTTOM = EDGE_I444_LEFT_HAS_BOTTOM | 44 | EDGE_I422_LEFT_HAS_BOTTOM | 45 | EDGE_I420_LEFT_HAS_BOTTOM, 46 | EDGE_ALL_TR_AND_BL = EDGE_ALL_TOP_HAS_RIGHT | 47 | EDGE_ALL_LEFT_HAS_BOTTOM, 48 | }; 49 | 50 | #define INTRA_EDGE_SPLIT(n, i) \ 51 | ((const EdgeNode*)((uintptr_t)(n) + ((const EdgeBranch*)(n))->split_offset[i])) 52 | 53 | typedef struct EdgeNode { 54 | uint8_t /* enum EdgeFlags */ o, h[2], v[2]; 55 | } EdgeNode; 56 | 57 | typedef struct EdgeTip { 58 | EdgeNode node; 59 | uint8_t /* enum EdgeFlags */ split[3]; 60 | } EdgeTip; 61 | 62 | typedef struct EdgeBranch { 63 | EdgeNode node; 64 | uint8_t /* enum EdgeFlags */ h4, v4; 65 | uint16_t split_offset[4]; /* relative to the address of this node */ 66 | } EdgeBranch; 67 | 68 | /* Tree to keep track of which edges are available. */ 69 | EXTERN const EdgeNode *dav1d_intra_edge_tree[2 /* BL_128X128, BL_64X64 */]; 70 | 71 | void dav1d_init_intra_edge_tree(void); 72 | 73 | #endif /* DAV1D_SRC_INTRA_EDGE_H */ 74 | --------------------------------------------------------------------------------