├── .hgignore ├── COPYING ├── build ├── README.txt ├── aarch64-linux │ ├── crosscompile.cmake │ └── make-Makefiles.bash ├── arm-linux │ ├── crosscompile.cmake │ └── make-Makefiles.bash ├── linux │ ├── make-Makefiles.bash │ └── multilib.sh ├── msys-cl │ ├── make-Makefiles-64bit.sh │ └── make-Makefiles.sh ├── msys │ ├── make-Makefiles.sh │ ├── make-x86_64-w64-mingw32-Makefiles.sh │ ├── multilib.sh │ └── toolchain-x86_64-w64-mingw32.cmake ├── vc10-x86 │ ├── build-all.bat │ └── make-solutions.bat ├── vc10-x86_64 │ ├── build-all.bat │ ├── make-solutions.bat │ └── multilib.bat ├── vc11-x86 │ ├── build-all.bat │ └── make-solutions.bat ├── vc11-x86_64 │ ├── build-all.bat │ ├── make-solutions.bat │ └── multilib.bat ├── vc12-x86 │ ├── build-all.bat │ └── make-solutions.bat ├── vc12-x86_64 │ ├── build-all.bat │ ├── make-solutions.bat │ └── multilib.bat ├── vc15-x86 │ ├── build-all.bat │ └── make-solutions.bat ├── vc15-x86_64 │ ├── build-all.bat │ ├── make-solutions.bat │ └── multilib.bat ├── vc9-x86 │ ├── build-all.bat │ └── make-solutions.bat ├── vc9-x86_64 │ ├── build-all.bat │ ├── make-solutions.bat │ └── multilib.bat └── xcode │ └── make-project.sh ├── doc ├── intra │ ├── intra-16x16.txt │ ├── intra-32x32.txt │ ├── intra-4x4.txt │ └── intra-8x8.txt ├── reST │ ├── Makefile │ ├── api.rst │ ├── cli.rst │ ├── conf.py │ ├── index.rst │ ├── introduction.rst │ ├── lossless.rst │ ├── presets.rst │ ├── releasenotes.rst │ ├── svthevc.rst │ ├── threading.rst │ └── x265.rst └── uncrustify │ └── codingstyle.cfg ├── readme.rst ├── source ├── CMakeLists.txt ├── abrEncApp.cpp ├── abrEncApp.h ├── cmake │ ├── CMakeASM_NASMInformation.cmake │ ├── CMakeDetermineASM_NASMCompiler.cmake │ ├── CMakeTestASM_NASMCompiler.cmake │ ├── FindNasm.cmake │ ├── FindNeon.cmake │ ├── FindNuma.cmake │ ├── FindVLD.cmake │ ├── FindVtune.cmake │ ├── Findsvthevc.cmake │ ├── Version.cmake │ ├── clean-generated.cmake │ └── cmake_uninstall.cmake.in ├── common │ ├── CMakeLists.txt │ ├── aarch64 │ │ ├── asm-primitives.cpp │ │ ├── asm.S │ │ ├── ipfilter8.S │ │ ├── ipfilter8.h │ │ ├── mc-a.S │ │ ├── pixel-util.S │ │ ├── pixel-util.h │ │ ├── pixel.h │ │ └── sad-a.S │ ├── arm │ │ ├── asm-primitives.cpp │ │ ├── asm.S │ │ ├── blockcopy8.S │ │ ├── blockcopy8.h │ │ ├── cpu-a.S │ │ ├── dct-a.S │ │ ├── dct8.h │ │ ├── intrapred.h │ │ ├── ipfilter8.S │ │ ├── ipfilter8.h │ │ ├── loopfilter.h │ │ ├── mc-a.S │ │ ├── mc.h │ │ ├── pixel-util.S │ │ ├── pixel-util.h │ │ ├── pixel.h │ │ ├── sad-a.S │ │ └── ssd-a.S │ ├── bitstream.cpp │ ├── bitstream.h │ ├── common.cpp │ ├── common.h │ ├── constants.cpp │ ├── constants.h │ ├── contexts.h │ ├── cpu.cpp │ ├── cpu.h │ ├── cudata.cpp │ ├── cudata.h │ ├── dct.cpp │ ├── deblock.cpp │ ├── deblock.h │ ├── frame.cpp │ ├── frame.h │ ├── framedata.cpp │ ├── framedata.h │ ├── intrapred.cpp │ ├── ipfilter.cpp │ ├── loopfilter.cpp │ ├── lowpassdct.cpp │ ├── lowres.cpp │ ├── lowres.h │ ├── md5.cpp │ ├── md5.h │ ├── mv.h │ ├── param.cpp │ ├── param.h │ ├── piclist.cpp │ ├── piclist.h │ ├── picyuv.cpp │ ├── picyuv.h │ ├── pixel.cpp │ ├── ppc │ │ ├── dct_altivec.cpp │ │ ├── intrapred_altivec.cpp │ │ ├── ipfilter_altivec.cpp │ │ ├── pixel_altivec.cpp │ │ └── ppccommon.h │ ├── predict.cpp │ ├── predict.h │ ├── primitives.cpp │ ├── primitives.h │ ├── quant.cpp │ ├── quant.h │ ├── scaler.cpp │ ├── scaler.h │ ├── scalinglist.cpp │ ├── scalinglist.h │ ├── shortyuv.cpp │ ├── shortyuv.h │ ├── slice.cpp │ ├── slice.h │ ├── threading.cpp │ ├── threading.h │ ├── threadpool.cpp │ ├── threadpool.h │ ├── vec │ │ ├── dct-sse3.cpp │ │ ├── dct-sse41.cpp │ │ ├── dct-ssse3.cpp │ │ └── vec-primitives.cpp │ ├── version.cpp │ ├── wavefront.cpp │ ├── wavefront.h │ ├── winxp.cpp │ ├── winxp.h │ ├── x86 │ │ ├── README.txt │ │ ├── asm-primitives.cpp │ │ ├── blockcopy8.asm │ │ ├── blockcopy8.h │ │ ├── const-a.asm │ │ ├── cpu-a.asm │ │ ├── dct8.asm │ │ ├── dct8.h │ │ ├── h-ipfilter16.asm │ │ ├── h-ipfilter8.asm │ │ ├── h4-ipfilter16.asm │ │ ├── intrapred.h │ │ ├── intrapred16.asm │ │ ├── intrapred8.asm │ │ ├── intrapred8_allangs.asm │ │ ├── ipfilter16.asm │ │ ├── ipfilter8.asm │ │ ├── ipfilter8.h │ │ ├── loopfilter.asm │ │ ├── loopfilter.h │ │ ├── mc-a.asm │ │ ├── mc-a2.asm │ │ ├── mc.h │ │ ├── pixel-32.asm │ │ ├── pixel-a.asm │ │ ├── pixel-util.h │ │ ├── pixel-util8.asm │ │ ├── pixel.h │ │ ├── pixeladd8.asm │ │ ├── sad-a.asm │ │ ├── sad16-a.asm │ │ ├── seaintegral.asm │ │ ├── seaintegral.h │ │ ├── ssd-a.asm │ │ ├── v4-ipfilter16.asm │ │ ├── v4-ipfilter8.asm │ │ ├── x86inc.asm │ │ └── x86util.asm │ ├── yuv.cpp │ └── yuv.h ├── compat │ ├── getopt │ │ ├── LGPL.txt │ │ ├── getopt.c │ │ └── getopt.h │ └── msvc │ │ └── stdint.h ├── dynamicHDR10 │ ├── BasicStructures.h │ ├── CMakeLists.txt │ ├── JsonHelper.cpp │ ├── JsonHelper.h │ ├── LICENSE.txt │ ├── SeiMetadataDictionary.cpp │ ├── SeiMetadataDictionary.h │ ├── api.cpp │ ├── hdr10plus.h │ ├── json11 │ │ ├── LICENSE.txt │ │ ├── json11.cpp │ │ └── json11.h │ ├── metadataFromJson.cpp │ └── metadataFromJson.h ├── encoder │ ├── CMakeLists.txt │ ├── analysis.cpp │ ├── analysis.h │ ├── api.cpp │ ├── bitcost.cpp │ ├── bitcost.h │ ├── dpb.cpp │ ├── dpb.h │ ├── encoder.cpp │ ├── encoder.h │ ├── entropy.cpp │ ├── entropy.h │ ├── frameencoder.cpp │ ├── frameencoder.h │ ├── framefilter.cpp │ ├── framefilter.h │ ├── level.cpp │ ├── level.h │ ├── motion.cpp │ ├── motion.h │ ├── nal.cpp │ ├── nal.h │ ├── ratecontrol.cpp │ ├── ratecontrol.h │ ├── rdcost.h │ ├── reference.cpp │ ├── reference.h │ ├── sao.cpp │ ├── sao.h │ ├── search.cpp │ ├── search.h │ ├── sei.cpp │ ├── sei.h │ ├── slicetype.cpp │ ├── slicetype.h │ ├── svt.h │ └── weightPrediction.cpp ├── input │ ├── input.cpp │ ├── input.h │ ├── y4m.cpp │ ├── y4m.h │ ├── yuv.cpp │ └── yuv.h ├── output │ ├── output.cpp │ ├── output.h │ ├── raw.cpp │ ├── raw.h │ ├── reconplay.cpp │ ├── reconplay.h │ ├── y4m.cpp │ ├── y4m.h │ ├── yuv.cpp │ └── yuv.h ├── profile │ ├── CMakeLists.txt │ ├── PPA │ │ ├── CMakeLists.txt │ │ ├── ppa.cpp │ │ ├── ppa.h │ │ └── ppaApi.h │ ├── cpuEvents.h │ └── vtune │ │ ├── CMakeLists.txt │ │ ├── vtune.cpp │ │ └── vtune.h ├── test │ ├── CMakeLists.txt │ ├── checkasm-a.asm │ ├── checkasm-arm.S │ ├── intrapredharness.cpp │ ├── intrapredharness.h │ ├── ipfilterharness.cpp │ ├── ipfilterharness.h │ ├── mbdstharness.cpp │ ├── mbdstharness.h │ ├── pixelharness.cpp │ ├── pixelharness.h │ ├── rate-control-tests.txt │ ├── regression-tests.txt │ ├── save-load-tests.txt │ ├── smoke-tests.txt │ ├── testbench.cpp │ └── testharness.h ├── x265.cpp ├── x265.def.in ├── x265.h ├── x265.pc.in ├── x265.rc.in ├── x265_config.h.in ├── x265cli.cpp └── x265cli.h └── x265Version.txt /.hgignore: -------------------------------------------------------------------------------- 1 | syntax: glob 2 | doc/uncrustify/uncrustify.exe 3 | build/ 4 | **.rej 5 | **.orig 6 | **.hevc 7 | **.yuv 8 | **.y4m 9 | **.out 10 | **.swp 11 | .DS_Store 12 | -------------------------------------------------------------------------------- /build/README.txt: -------------------------------------------------------------------------------- 1 | = Mandatory Prerequisites = 2 | 3 | * GCC, MSVC (9, 10, 11, 12), Xcode or Intel C/C++ 4 | * CMake 2.8.8 or later http://www.cmake.org 5 | * On linux, ccmake is helpful, usually a package named cmake-curses-gui 6 | 7 | Note: MSVC12 requires cmake 2.8.11 or later 8 | 9 | 10 | = Optional Prerequisites = 11 | 12 | 1. To compile assembly primitives (performance) 13 | a) If you are using release 2.6 or older, download and install Yasm 1.2.0 or later, 14 | 15 | For Windows, download the latest yasm executable 16 | http://yasm.tortall.net/Download.html and copy the EXE into 17 | C:\Windows or somewhere else in your %PATH% that a 32-bit app (cmake) 18 | can find it. If it is not in the path, you must manually tell cmake 19 | where to find it. Note: you do not need the vsyasm packages, x265 20 | does not use them. You only need the yasm executable itself. 21 | 22 | On Linux, the packaged yasm may be older than 1.2, in which case 23 | so you will need get the latest source and build it yourself. 24 | 25 | Once YASM is properly installed, run cmake to regenerate projects. If you 26 | do not see the below line in the cmake output, YASM is not in the PATH. 27 | 28 | -- Found Yasm 1.3.0 to build assembly primitives 29 | 30 | Now build the encoder and run x265 -V: 31 | 32 | x265 [info]: using cpu capabilities: MMX, SSE2, ... 33 | 34 | If cpu capabilities line says 'none!', then the encoder was built 35 | without yasm. 36 | 37 | b) If you are building from the default branch after release 2.6, download and install nasm 2.13 or newer 38 | 39 | For windows and linux, you can download the nasm installer from http://www.nasm.us/pub/nasm/releasebuilds/?C=M;O=D. 40 | Make sure that it is in your PATH environment variable (%PATH% in windows, and $PATH in linux) so that cmake 41 | can find it. 42 | 43 | Once NASM is properly installed, run cmake to regenerate projects. If you 44 | do not see the below line in the cmake output, NASM is not in the PATH. 45 | 46 | -- Found Nasm 2.13 to build assembly primitives 47 | 48 | Now build the encoder and run x265 -V: 49 | 50 | x265 [info]: using cpu capabilities: MMX, SSE2, ... 51 | 52 | If cpu capabilities line says 'none!', then the encoder was built 53 | without nasm and will be considerably slower for performance. 54 | 55 | 2. VisualLeakDetector (Windows Only) 56 | 57 | Download from https://vld.codeplex.com/releases and install. May need 58 | to re-login in order for it to be in your %PATH%. Cmake will find it 59 | and enable leak detection in debug builds without any additional work. 60 | 61 | If VisualLeakDetector is not installed, cmake will complain a bit, but 62 | it is completely harmless. 63 | 64 | 65 | = Build Instructions Linux = 66 | 67 | 1. Use cmake to generate Makefiles: cmake ../source 68 | 2. Build x265: make 69 | 70 | Or use our shell script which runs cmake then opens the curses GUI to 71 | configure build options 72 | 73 | 1. cd build/linux ; ./make-Makefiles.bash 74 | 2. make 75 | 76 | 77 | = Build Instructions Windows = 78 | 79 | We recommend you use one of the make-solutions.bat files in the appropriate 80 | build/ sub-folder for your preferred compiler. They will open the cmake-gui 81 | to configure build options, click configure until no more red options remain, 82 | then click generate and exit. There should now be an x265.sln file in the 83 | same folder, open this in Visual Studio and build it. 84 | 85 | = Version number considerations = 86 | 87 | Note that cmake will update X265_VERSION each time cmake runs, if you are 88 | building out of a Mercurial source repository. If you are building out of 89 | a release source package, the version will not change. If Mercurial is not 90 | found, the version will be "unknown". 91 | -------------------------------------------------------------------------------- /build/aarch64-linux/crosscompile.cmake: -------------------------------------------------------------------------------- 1 | # CMake toolchain file for cross compiling x265 for aarch64 2 | # This feature is only supported as experimental. Use with caution. 3 | # Please report bugs on bitbucket 4 | # Run cmake with: cmake -DCMAKE_TOOLCHAIN_FILE=crosscompile.cmake -G "Unix Makefiles" ../../source && ccmake ../../source 5 | 6 | set(CROSS_COMPILE_ARM 1) 7 | set(CMAKE_SYSTEM_NAME Linux) 8 | set(CMAKE_SYSTEM_PROCESSOR aarch64) 9 | 10 | # specify the cross compiler 11 | set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc) 12 | set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++) 13 | 14 | # specify the target environment 15 | SET(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu) 16 | -------------------------------------------------------------------------------- /build/aarch64-linux/make-Makefiles.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Run this from within a bash shell 3 | 4 | cmake -DCMAKE_TOOLCHAIN_FILE="crosscompile.cmake" -G "Unix Makefiles" ../../source && ccmake ../../source 5 | -------------------------------------------------------------------------------- /build/arm-linux/crosscompile.cmake: -------------------------------------------------------------------------------- 1 | # CMake toolchain file for cross compiling x265 for ARM arch 2 | # This feature is only supported as experimental. Use with caution. 3 | # Please report bugs on bitbucket 4 | # Run cmake with: cmake -DCMAKE_TOOLCHAIN_FILE=crosscompile.cmake -G "Unix Makefiles" ../../source && ccmake ../../source 5 | 6 | set(CROSS_COMPILE_ARM 1) 7 | set(CMAKE_SYSTEM_NAME Linux) 8 | set(CMAKE_SYSTEM_PROCESSOR armv6l) 9 | 10 | # specify the cross compiler 11 | set(CMAKE_C_COMPILER arm-linux-gnueabi-gcc) 12 | set(CMAKE_CXX_COMPILER arm-linux-gnueabi-g++) 13 | 14 | # specify the target environment 15 | SET(CMAKE_FIND_ROOT_PATH /usr/arm-linux-gnueabi) 16 | -------------------------------------------------------------------------------- /build/arm-linux/make-Makefiles.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Run this from within a bash shell 3 | 4 | cmake -G "Unix Makefiles" ../../source && ccmake ../../source 5 | -------------------------------------------------------------------------------- /build/linux/make-Makefiles.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Run this from within a bash shell 3 | cmake -G "Unix Makefiles" ../../source && ccmake ../../source 4 | -------------------------------------------------------------------------------- /build/linux/multilib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | mkdir -p 8bit 10bit 12bit 4 | 5 | cd 12bit 6 | cmake ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN12=ON 7 | make ${MAKEFLAGS} 8 | 9 | cd ../10bit 10 | cmake ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF 11 | make ${MAKEFLAGS} 12 | 13 | cd ../8bit 14 | ln -sf ../10bit/libx265.a libx265_main10.a 15 | ln -sf ../12bit/libx265.a libx265_main12.a 16 | cmake ../../../source -DEXTRA_LIB="x265_main10.a;x265_main12.a" -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=ON -DLINKED_12BIT=ON 17 | make ${MAKEFLAGS} 18 | 19 | # rename the 8bit library, then combine all three into libx265.a 20 | mv libx265.a libx265_main.a 21 | 22 | uname=`uname` 23 | if [ "$uname" = "Linux" ] 24 | then 25 | 26 | # On Linux, we use GNU ar to combine the static libraries together 27 | ar -M </dev/null 40 | 41 | fi 42 | -------------------------------------------------------------------------------- /build/msys-cl/make-Makefiles-64bit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This is to generate visual studio builds with required environment variables set in this shell, useful for ffmpeg integration 3 | # Run this from within an MSYS bash shell 4 | 5 | target_processor='amd64' 6 | path=$(which cl) 7 | 8 | if cl; then 9 | echo 10 | else 11 | echo "please launch 'visual studio command prompt' and run '..\vcvarsall.bat amd64'" 12 | echo "and then launch msys bash shell from there" 13 | exit 1 14 | fi 15 | 16 | if [[ $path == *$target_processor* ]]; then 17 | echo 18 | else 19 | echo "64 bit target not set, please launch 'visual studio command prompt' and run '..\vcvarsall.bat amd64 | x86_amd64 | amd64_x86'" 20 | exit 1 21 | fi 22 | 23 | cmake -G "NMake Makefiles" -DCMAKE_CXX_FLAGS="-DWIN32 -D_WINDOWS -W4 -GR -EHsc" -DCMAKE_C_FLAGS="-DWIN32 -D_WINDOWS -W4" ../../source 24 | if [ -e Makefile ] 25 | then 26 | nmake 27 | fi -------------------------------------------------------------------------------- /build/msys-cl/make-Makefiles.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This is to generate visual studio builds with required environment variables set in this shell, useful for ffmpeg integration 3 | # Run this from within an MSYS bash shell 4 | 5 | if cl; then 6 | echo 7 | else 8 | echo "please launch msys from 'visual studio command prompt'" 9 | exit 1 10 | fi 11 | 12 | cmake -G "NMake Makefiles" -DCMAKE_CXX_FLAGS="-DWIN32 -D_WINDOWS -W4 -GR -EHsc" -DCMAKE_C_FLAGS="-DWIN32 -D_WINDOWS -W4" ../../source 13 | 14 | if [ -e Makefile ] 15 | then 16 | nmake 17 | fi -------------------------------------------------------------------------------- /build/msys/make-Makefiles.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Run this from within an MSYS bash shell 3 | cmake -G "MSYS Makefiles" ../../source && cmake-gui ../../source 4 | -------------------------------------------------------------------------------- /build/msys/make-x86_64-w64-mingw32-Makefiles.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This will generate a cross-compile environment, compiling an x86_64 4 | # Win64 target from a 32bit MinGW32 host environment. If your MinGW 5 | # install is 64bit, you can use the native compiler batch file: 6 | # make-Makefiles.sh 7 | 8 | cmake -G "MSYS Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain-x86_64-w64-mingw32.cmake ../../source && cmake-gui ../../source 9 | -------------------------------------------------------------------------------- /build/msys/multilib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | mkdir -p 8bit 10bit 12bit 4 | 5 | cd 12bit 6 | cmake -G "MSYS Makefiles" ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN12=ON 7 | make ${MAKEFLAGS} 8 | cp libx265.a ../8bit/libx265_main12.a 9 | 10 | cd ../10bit 11 | cmake -G "MSYS Makefiles" ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF 12 | make ${MAKEFLAGS} 13 | cp libx265.a ../8bit/libx265_main10.a 14 | 15 | cd ../8bit 16 | cmake -G "MSYS Makefiles" ../../../source -DEXTRA_LIB="x265_main10.a;x265_main12.a" -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=ON -DLINKED_12BIT=ON 17 | make ${MAKEFLAGS} 18 | 19 | # rename the 8bit library, then combine all three into libx265.a using GNU ar 20 | mv libx265.a libx265_main.a 21 | 22 | ar -M <' where is one of" 20 | @echo " html to make standalone HTML files" 21 | @echo " pickle to make pickle files" 22 | @echo " json to make JSON files" 23 | @echo " htmlhelp to make HTML files and a HTML help project" 24 | @echo " qthelp to make HTML files and a qthelp project" 25 | @echo " qhc to make QHC file" 26 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 27 | @echo " man to make manpages" 28 | @echo " changes to make an overview over all changed/added/deprecated items" 29 | @echo " linkcheck to check all external links for integrity" 30 | 31 | clean: 32 | -rm -rf build/* 33 | 34 | distclean: clean 35 | -rmdir build/ 36 | 37 | html: 38 | mkdir -p build/html build/doctrees 39 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html 40 | @echo 41 | @echo "Build finished. The HTML pages are in build/html." 42 | 43 | zip: html 44 | (cd build ; zip TortoiseHg.html.zip -r html) 45 | 46 | pickle: 47 | mkdir -p build/pickle build/doctrees 48 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle 49 | @echo 50 | @echo "Build finished; now you can process the pickle files." 51 | 52 | web: pickle 53 | 54 | json: 55 | mkdir -p build/json build/doctrees 56 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) build/json 57 | @echo 58 | @echo "Build finished; now you can process the JSON files." 59 | 60 | htmlhelp: 61 | mkdir -p build/htmlhelp build/doctrees 62 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp 63 | @echo 64 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 65 | ".hhp project file in build/htmlhelp." 66 | 67 | qthelp: 68 | mkdir -p build/qthelp build/doctrees 69 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) build/qthelp 70 | @echo 71 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 72 | ".qhcp project file in build/qthelp, like this:" 73 | @echo "# qcollectiongenerator build/qthelp/foo.qhcp" 74 | @echo "To view the help file:" 75 | @echo "# assistant -collectionFile build/qthelp/foo.qhc" 76 | 77 | qhc: qthelp 78 | $(QCOLLECTIONGENERATOR) build/qthelp/TortoiseHg.qhcp 79 | @echo "Build finished. To view the help file:" 80 | @echo "# assistant -collectionFile build/qthelp/TortoiseHg.qhc" 81 | 82 | latex: 83 | mkdir -p build/latex build/doctrees 84 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex 85 | @echo 86 | @echo "Build finished; the LaTeX files are in build/latex." 87 | @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ 88 | "run these through (pdf)latex." 89 | 90 | man: 91 | mkdir -p build/man build/doctrees 92 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) build/man 93 | @echo 94 | @echo "Build finished; the manpages are in build/man." 95 | @echo "Run \`man -l build/man/x265.1' or \`man -l build/man/libx265.3'" \ 96 | "to view them." 97 | 98 | changes: 99 | mkdir -p build/changes build/doctrees 100 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes 101 | @echo 102 | @echo "The overview file is in build/changes." 103 | 104 | linkcheck: 105 | mkdir -p build/linkcheck build/doctrees 106 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck 107 | @echo 108 | @echo "Link check complete; look for any errors in the above output " \ 109 | "or in build/linkcheck/output.txt." 110 | -------------------------------------------------------------------------------- /doc/reST/cli.rst: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/videolan/x265/419182243fb2e2dfbe91dfc45a51778cf704f849/doc/reST/cli.rst -------------------------------------------------------------------------------- /doc/reST/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # -- General configuration ----------------------------------------------------- 4 | 5 | source_suffix = '.rst' 6 | 7 | # Name of the master file 8 | master_doc = 'index' 9 | 10 | # General information about the project. 11 | project = u'x265' 12 | 13 | # This is the Copyright Information that will appear on the bottom of the document 14 | copyright = u'2014 MulticoreWare Inc' 15 | 16 | # -- Options for HTML output --------------------------------------------------- 17 | html_theme = "default" 18 | 19 | # One entry per manual page. List of tuples 20 | # (source start file, name, description, authors, manual section). 21 | man_pages = [ 22 | ('index', 'libx265', 'Full x265 Documentation', 23 | ['MulticoreWare Inc'], 3), 24 | ('x265', 'x265', 'x265 CLI Documentation', 25 | ['MulticoreWare Inc'], 1) 26 | ] 27 | -------------------------------------------------------------------------------- /doc/reST/index.rst: -------------------------------------------------------------------------------- 1 | x265 Documentation 2 | ====================== 3 | .. toctree:: 4 | :maxdepth: 2 5 | 6 | introduction 7 | cli 8 | api 9 | threading 10 | presets 11 | lossless 12 | svthevc 13 | releasenotes 14 | -------------------------------------------------------------------------------- /doc/reST/x265.rst: -------------------------------------------------------------------------------- 1 | x265 CLI Documentation 2 | ###################### 3 | 4 | 5 | SYNOPSIS 6 | ======== 7 | 8 | **x265** [options] infile [-o] outfile 9 | 10 | Bit depth: 8 11 | 12 | 13 | **x265-10bit** [options] infile [-o] outfile 14 | 15 | Bit depth: 10 16 | 17 | 18 | infile can be YUV or Y4M 19 | 20 | outfile is raw HEVC bitstream 21 | 22 | 23 | DESCRIPTION 24 | =========== 25 | 26 | .. toctree:: 27 | :maxdepth: 2 28 | 29 | introduction 30 | 31 | 32 | OPTIONS 33 | ======= 34 | 35 | .. toctree:: 36 | :maxdepth: 2 37 | 38 | cli 39 | presets 40 | lossless 41 | 42 | 43 | SEE ALSO 44 | ======== 45 | 46 | **libx265**\(3) 47 | 48 | Online documentation: http://x265.readthedocs.org/en/default/cli.html 49 | 50 | -------------------------------------------------------------------------------- /readme.rst: -------------------------------------------------------------------------------- 1 | ================= 2 | x265 HEVC Encoder 3 | ================= 4 | 5 | | **Read:** | Online `documentation `_ | Developer `wiki `_ 6 | | **Download:** | `releases `_ 7 | | **Interact:** | #x265 on freenode.irc.net | `x265-devel@videolan.org `_ | `Report an issue `_ 8 | 9 | `x265 `_ is an open 10 | source HEVC encoder. See the developer wiki for instructions for 11 | downloading and building the source. 12 | 13 | x265 is free to use under the `GNU GPL `_ 14 | and is also available under a commercial `license `_ 15 | -------------------------------------------------------------------------------- /source/cmake/CMakeASM_NASMInformation.cmake: -------------------------------------------------------------------------------- 1 | set(ASM_DIALECT "_NASM") 2 | set(CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS asm) 3 | 4 | if(X64) 5 | list(APPEND ASM_FLAGS -DARCH_X86_64=1 -I ${CMAKE_CURRENT_SOURCE_DIR}/../common/x86/) 6 | if(ENABLE_PIC) 7 | list(APPEND ASM_FLAGS -DPIC) 8 | endif() 9 | if(APPLE) 10 | set(ARGS -f macho64 -DPREFIX) 11 | elseif(UNIX AND NOT CYGWIN) 12 | set(ARGS -f elf64) 13 | else() 14 | set(ARGS -f win64) 15 | endif() 16 | else() 17 | list(APPEND ASM_FLAGS -DARCH_X86_64=0 -I ${CMAKE_CURRENT_SOURCE_DIR}/../common/x86/) 18 | if(APPLE) 19 | set(ARGS -f macho32 -DPREFIX) 20 | elseif(UNIX AND NOT CYGWIN) 21 | set(ARGS -f elf32) 22 | else() 23 | set(ARGS -f win32 -DPREFIX) 24 | endif() 25 | endif() 26 | 27 | if(GCC) 28 | list(APPEND ASM_FLAGS -DHAVE_ALIGNED_STACK=1) 29 | else() 30 | list(APPEND ASM_FLAGS -DHAVE_ALIGNED_STACK=0) 31 | endif() 32 | 33 | if(HIGH_BIT_DEPTH) 34 | if(MAIN12) 35 | list(APPEND ASM_FLAGS -DHIGH_BIT_DEPTH=1 -DBIT_DEPTH=12 -DX265_NS=${X265_NS}) 36 | else() 37 | list(APPEND ASM_FLAGS -DHIGH_BIT_DEPTH=1 -DBIT_DEPTH=10 -DX265_NS=${X265_NS}) 38 | endif() 39 | else() 40 | list(APPEND ASM_FLAGS -DHIGH_BIT_DEPTH=0 -DBIT_DEPTH=8 -DX265_NS=${X265_NS}) 41 | endif() 42 | 43 | list(APPEND ASM_FLAGS "${CMAKE_ASM_NASM_FLAGS}") 44 | 45 | if(CMAKE_BUILD_TYPE MATCHES Release) 46 | list(APPEND ASM_FLAGS "${CMAKE_ASM_NASM_FLAGS_RELEASE}") 47 | elseif(CMAKE_BUILD_TYPE MATCHES Debug) 48 | list(APPEND ASM_FLAGS "${CMAKE_ASM_NASM_FLAGS_DEBUG}") 49 | elseif(CMAKE_BUILD_TYPE MATCHES MinSizeRel) 50 | list(APPEND ASM_FLAGS "${CMAKE_ASM_NASM_FLAGS_MINSIZEREL}") 51 | elseif(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo) 52 | list(APPEND ASM_FLAGS "${CMAKE_ASM_NASM_FLAGS_RELWITHDEBINFO}") 53 | endif() 54 | 55 | set(NASM_FLAGS ${ARGS} ${ASM_FLAGS} PARENT_SCOPE) 56 | string(REPLACE ";" " " CMAKE_ASM_NASM_COMPILER_ARG1 "${ARGS}") 57 | 58 | # This section exists to override the one in CMakeASMInformation.cmake 59 | # (the default Information file). This removes the 60 | # thing so that your C compiler flags that have been set via 61 | # set_target_properties don't get passed to nasm and confuse it. 62 | if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT) 63 | string(REPLACE ";" " " STR_ASM_FLAGS "${ASM_FLAGS}") 64 | set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT " ${STR_ASM_FLAGS} -o ") 65 | endif() 66 | 67 | include(CMakeASMInformation) 68 | set(ASM_DIALECT) 69 | -------------------------------------------------------------------------------- /source/cmake/CMakeDetermineASM_NASMCompiler.cmake: -------------------------------------------------------------------------------- 1 | set(ASM_DIALECT "_NASM") 2 | set(CMAKE_ASM${ASM_DIALECT}_COMPILER ${NASM_EXECUTABLE}) 3 | set(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT ${_CMAKE_TOOLCHAIN_PREFIX}nasm) 4 | include(CMakeDetermineASMCompiler) 5 | set(ASM_DIALECT) 6 | -------------------------------------------------------------------------------- /source/cmake/CMakeTestASM_NASMCompiler.cmake: -------------------------------------------------------------------------------- 1 | set(ASM_DIALECT "_NASM") 2 | include(CMakeTestASMCompiler) 3 | set(ASM_DIALECT) 4 | -------------------------------------------------------------------------------- /source/cmake/FindNasm.cmake: -------------------------------------------------------------------------------- 1 | include(FindPackageHandleStandardArgs) 2 | 3 | # Simple path search with YASM_ROOT environment variable override 4 | find_program(NASM_EXECUTABLE 5 | NAMES nasm nasm-2.13.0-win32 nasm-2.13.0-win64 nasm nasm-2.13.0-win32 nasm-2.13.0-win64 6 | HINTS $ENV{NASM_ROOT} ${NASM_ROOT} 7 | PATH_SUFFIXES bin 8 | ) 9 | 10 | if(NASM_EXECUTABLE) 11 | execute_process(COMMAND ${NASM_EXECUTABLE} -version 12 | OUTPUT_VARIABLE nasm_version 13 | ERROR_QUIET 14 | OUTPUT_STRIP_TRAILING_WHITESPACE 15 | ) 16 | if(nasm_version MATCHES "^NASM version ([0-9\\.]*)") 17 | set(NASM_VERSION_STRING "${CMAKE_MATCH_1}") 18 | endif() 19 | unset(nasm_version) 20 | endif() 21 | 22 | # Provide standardized success/failure messages 23 | find_package_handle_standard_args(nasm 24 | REQUIRED_VARS NASM_EXECUTABLE 25 | VERSION_VAR NASM_VERSION_STRING) 26 | -------------------------------------------------------------------------------- /source/cmake/FindNeon.cmake: -------------------------------------------------------------------------------- 1 | include(FindPackageHandleStandardArgs) 2 | 3 | # Check the version of neon supported by the ARM CPU 4 | execute_process(COMMAND cat /proc/cpuinfo | grep Features | grep neon 5 | OUTPUT_VARIABLE neon_version 6 | ERROR_QUIET 7 | OUTPUT_STRIP_TRAILING_WHITESPACE) 8 | if(neon_version) 9 | set(CPU_HAS_NEON 1) 10 | endif() 11 | -------------------------------------------------------------------------------- /source/cmake/FindNuma.cmake: -------------------------------------------------------------------------------- 1 | # Module for locating libnuma 2 | # 3 | # Read-only variables: 4 | # NUMA_FOUND 5 | # Indicates that the library has been found. 6 | # 7 | # NUMA_INCLUDE_DIR 8 | # Points to the libnuma include directory. 9 | # 10 | # NUMA_LIBRARY_DIR 11 | # Points to the directory that contains the libraries. 12 | # The content of this variable can be passed to link_directories. 13 | # 14 | # NUMA_LIBRARY 15 | # Points to the libnuma that can be passed to target_link_libararies. 16 | # 17 | # Copyright (c) 2013-2020 MulticoreWare, Inc 18 | 19 | include(FindPackageHandleStandardArgs) 20 | 21 | find_path(NUMA_ROOT_DIR 22 | NAMES include/numa.h 23 | PATHS ENV NUMA_ROOT 24 | DOC "NUMA root directory") 25 | 26 | find_path(NUMA_INCLUDE_DIR 27 | NAMES numa.h 28 | HINTS ${NUMA_ROOT_DIR} 29 | PATH_SUFFIXES include 30 | DOC "NUMA include directory") 31 | 32 | find_library(NUMA_LIBRARY 33 | NAMES numa 34 | HINTS ${NUMA_ROOT_DIR} 35 | DOC "NUMA library") 36 | 37 | if (NUMA_LIBRARY) 38 | get_filename_component(NUMA_LIBRARY_DIR ${NUMA_LIBRARY} PATH) 39 | endif() 40 | 41 | mark_as_advanced(NUMA_INCLUDE_DIR NUMA_LIBRARY_DIR NUMA_LIBRARY) 42 | 43 | find_package_handle_standard_args(NUMA REQUIRED_VARS NUMA_ROOT_DIR NUMA_INCLUDE_DIR NUMA_LIBRARY) 44 | -------------------------------------------------------------------------------- /source/cmake/FindVtune.cmake: -------------------------------------------------------------------------------- 1 | # Module for locating Vtune 2 | # 3 | # Read-only variables 4 | # VTUNE_FOUND: Indicates that the library has been found 5 | # VTUNE_INCLUDE_DIR: Points to the vtunes include dir 6 | # VTUNE_LIBRARY_DIR: Points to the directory with libraries 7 | # 8 | # Copyright (c) 2013-2020 MulticoreWare, Inc 9 | 10 | include(FindPackageHandleStandardArgs) 11 | 12 | find_path(VTUNE_DIR 13 | if(UNIX) 14 | NAMES amplxe-vars.sh 15 | else() 16 | NAMES amplxe-vars.bat 17 | endif(UNIX) 18 | HINTS $ENV{VTUNE_AMPLIFIER_XE_2017_DIR} $ENV{VTUNE_AMPLIFIER_XE_2016_DIR} $ENV{VTUNE_AMPLIFIER_XE_2015_DIR} 19 | DOC "Vtune root directory") 20 | 21 | set (VTUNE_INCLUDE_DIR ${VTUNE_DIR}/include) 22 | set (VTUNE_LIBRARY_DIR ${VTUNE_DIR}/lib64) 23 | 24 | mark_as_advanced(VTUNE_DIR) 25 | find_package_handle_standard_args(VTUNE REQUIRED_VARS VTUNE_DIR VTUNE_INCLUDE_DIR VTUNE_LIBRARY_DIR) 26 | -------------------------------------------------------------------------------- /source/cmake/Findsvthevc.cmake: -------------------------------------------------------------------------------- 1 | # Module for locating SVT-HEVC Library 2 | # 3 | # SVT_HEVC_INCLUDE_DIR 4 | # Points to the SVT-HEVC include directory. 5 | # 6 | # SVT_HEVC_LIBRARY 7 | # Points to the SVT-HEVC library 8 | # Copyright (c) 2013-2018 MulticoreWare, Inc 9 | 10 | include(FindPackageHandleStandardArgs) 11 | 12 | if(UNIX) 13 | SET(CMAKE_FIND_LIBRARY_SUFFIXES ".so") 14 | else() 15 | SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib") 16 | endif() 17 | 18 | set(SVT_VERSION_MAJOR_REQUIRED 1) 19 | set(SVT_VERSION_MINOR_REQUIRED 4) 20 | set(SVT_VERSION_PATCHLEVEL_REQUIRED 1) 21 | 22 | find_path(SVT_HEVC_INCLUDE_DIR 23 | NAMES EbApiVersion.h EbErrorCodes.h 24 | HINTS $ENV{SVT_HEVC_INCLUDE_DIR} 25 | PATHS ENV 26 | DOC "SVT-HEVC include directory") 27 | 28 | if(SVT_HEVC_INCLUDE_DIR) 29 | if(EXISTS "${SVT_HEVC_INCLUDE_DIR}/EbApiVersion.h") 30 | file(READ "${SVT_HEVC_INCLUDE_DIR}/EbApiVersion.h" version) 31 | 32 | string(REGEX MATCH "SVT_VERSION_MAJOR \\(([0-9]*)\\)" _ ${version}) 33 | set(SVT_VERSION_MAJOR ${CMAKE_MATCH_1}) 34 | 35 | string(REGEX MATCH "SVT_VERSION_MINOR \\(([0-9]*)\\)" _ ${version}) 36 | set(SVT_VERSION_MINOR ${CMAKE_MATCH_1}) 37 | 38 | string(REGEX MATCH "SVT_VERSION_PATCHLEVEL \\(([0-9]*)\\)" _ ${version}) 39 | set(SVT_VERSION_PATCHLEVEL ${CMAKE_MATCH_1}) 40 | 41 | if(NOT ${SVT_VERSION_MAJOR} EQUAL "1" OR NOT ${SVT_VERSION_MINOR} EQUAL "4" OR NOT ${SVT_VERSION_PATCHLEVEL} EQUAL "1") 42 | message (SEND_ERROR "-- Found SVT-HEVC Lib Version: ${SVT_VERSION_MAJOR}.${SVT_VERSION_MINOR}.${SVT_VERSION_PATCHLEVEL} which doesn't match the required version: ${SVT_VERSION_MAJOR_REQUIRED}.${SVT_VERSION_MINOR_REQUIRED}.${SVT_VERSION_PATCHLEVEL_REQUIRED}; Aborting configure ") 43 | else() 44 | message(STATUS "-- Found SVT-HEVC Lib Version: ${SVT_VERSION_MAJOR}.${SVT_VERSION_MINOR}.${SVT_VERSION_PATCHLEVEL}") 45 | endif() 46 | else() 47 | message (SEND_ERROR "-- Required version of SVT-HEVC Lib: ${SVT_VERSION_MAJOR_REQUIRED}.${SVT_VERSION_MINOR_REQUIRED}.${SVT_VERSION_PATCHLEVEL_REQUIRED}; Aborting configure ") 48 | endif() 49 | endif() 50 | 51 | find_library(SVT_HEVC_LIBRARY 52 | if(UNIX) 53 | NAMES SvtHevcEnc 54 | else() 55 | NAMES SvtHevcEnc 56 | endif() 57 | HINTS $ENV{SVT_HEVC_LIBRARY_DIR} 58 | PATHS ENV 59 | DOC "SVT-HEVC library") 60 | 61 | 62 | mark_as_advanced(SVT_HEVC_LIBRARY SVT_HEVC_INCLUDE_DIR SVT_HEVC_LIBRARY_DIR) 63 | find_package_handle_standard_args(SVTHEVC REQUIRED_VARS SVT_HEVC_LIBRARY SVT_HEVC_INCLUDE_DIR) 64 | -------------------------------------------------------------------------------- /source/cmake/clean-generated.cmake: -------------------------------------------------------------------------------- 1 | set(generated "${CMAKE_CURRENT_BINARY_DIR}/x265.rc" 2 | "${CMAKE_CURRENT_BINARY_DIR}/x265.pc" 3 | "${CMAKE_CURRENT_BINARY_DIR}/x265.def" 4 | "${CMAKE_CURRENT_BINARY_DIR}/x265_config.h") 5 | 6 | foreach(file ${generated}) 7 | if(EXISTS ${file}) 8 | file(REMOVE ${file}) 9 | endif() 10 | endforeach(file) 11 | -------------------------------------------------------------------------------- /source/cmake/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 2 | message(FATAL_ERROR "Cannot find install manifest: '@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt'") 3 | endif() 4 | 5 | file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 6 | string(REGEX REPLACE "\n" ";" files "${files}") 7 | foreach(file ${files}) 8 | message(STATUS "Uninstalling $ENV{DESTDIR}${file}") 9 | if(EXISTS "$ENV{DESTDIR}${file}" OR IS_SYMLINK "$ENV{DESTDIR}${file}") 10 | exec_program("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 11 | OUTPUT_VARIABLE rm_out 12 | RETURN_VALUE rm_retval) 13 | if(NOT "${rm_retval}" STREQUAL 0) 14 | message(FATAL_ERROR "Problem when removing '$ENV{DESTDIR}${file}'") 15 | endif(NOT "${rm_retval}" STREQUAL 0) 16 | else() 17 | message(STATUS "File '$ENV{DESTDIR}${file}' does not exist.") 18 | endif() 19 | endforeach(file) 20 | 21 | if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt") 22 | file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt") 23 | endif() 24 | -------------------------------------------------------------------------------- /source/common/aarch64/asm.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2020 MulticoreWare, Inc 3 | * 4 | * Authors: Hongbin Liu 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | .arch armv8-a 25 | 26 | #ifdef PREFIX 27 | #define EXTERN_ASM _ 28 | #else 29 | #define EXTERN_ASM 30 | #endif 31 | 32 | #ifdef __ELF__ 33 | #define ELF 34 | #else 35 | #define ELF @ 36 | #endif 37 | 38 | #define HAVE_AS_FUNC 1 39 | 40 | #if HAVE_AS_FUNC 41 | #define FUNC 42 | #else 43 | #define FUNC @ 44 | #endif 45 | 46 | .macro function name, export=1 47 | .macro endfunc 48 | ELF .size \name, . - \name 49 | FUNC .endfunc 50 | .purgem endfunc 51 | .endm 52 | .align 2 53 | .if \export == 1 54 | .global EXTERN_ASM\name 55 | ELF .hidden EXTERN_ASM\name 56 | ELF .type EXTERN_ASM\name, %function 57 | FUNC .func EXTERN_ASM\name 58 | EXTERN_ASM\name: 59 | .else 60 | ELF .hidden \name 61 | ELF .type \name, %function 62 | FUNC .func \name 63 | \name: 64 | .endif 65 | .endm 66 | 67 | 68 | #define FENC_STRIDE 64 69 | #define FDEC_STRIDE 32 70 | -------------------------------------------------------------------------------- /source/common/aarch64/mc-a.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2020 MulticoreWare, Inc 3 | * 4 | * Authors: Hongbin Liu 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #include "asm.S" 25 | 26 | .section .rodata 27 | 28 | .align 4 29 | 30 | .text 31 | 32 | .macro pixel_avg_pp_4xN_neon h 33 | function x265_pixel_avg_pp_4x\h\()_neon 34 | .rept \h 35 | ld1 {v0.s}[0], [x2], x3 36 | ld1 {v1.s}[0], [x4], x5 37 | urhadd v2.8b, v0.8b, v1.8b 38 | st1 {v2.s}[0], [x0], x1 39 | .endr 40 | ret 41 | endfunc 42 | .endm 43 | 44 | pixel_avg_pp_4xN_neon 4 45 | pixel_avg_pp_4xN_neon 8 46 | pixel_avg_pp_4xN_neon 16 47 | 48 | .macro pixel_avg_pp_8xN_neon h 49 | function x265_pixel_avg_pp_8x\h\()_neon 50 | .rept \h 51 | ld1 {v0.8b}, [x2], x3 52 | ld1 {v1.8b}, [x4], x5 53 | urhadd v2.8b, v0.8b, v1.8b 54 | st1 {v2.8b}, [x0], x1 55 | .endr 56 | ret 57 | endfunc 58 | .endm 59 | 60 | pixel_avg_pp_8xN_neon 4 61 | pixel_avg_pp_8xN_neon 8 62 | pixel_avg_pp_8xN_neon 16 63 | pixel_avg_pp_8xN_neon 32 64 | -------------------------------------------------------------------------------- /source/common/aarch64/pixel-util.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2020 MulticoreWare, Inc 3 | * 4 | * Authors: Yimeng Su 5 | * Hongbin Liu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program 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 General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 20 | * 21 | * This program is also available under a commercial proprietary license. 22 | * For more information, contact us at license @ x265.com. 23 | *****************************************************************************/ 24 | 25 | #ifndef X265_PIXEL_UTIL_AARCH64_H 26 | #define X265_PIXEL_UTIL_AARCH64_H 27 | 28 | int x265_pixel_satd_4x4_neon(const pixel* pix1, intptr_t stride_pix1, const pixel* pix2, intptr_t stride_pix2); 29 | int x265_pixel_satd_4x8_neon(const pixel* pix1, intptr_t stride_pix1, const pixel* pix2, intptr_t stride_pix2); 30 | int x265_pixel_satd_4x16_neon(const pixel* pix1, intptr_t stride_pix1, const pixel* pix2, intptr_t stride_pix2); 31 | int x265_pixel_satd_4x32_neon(const pixel* pix1, intptr_t stride_pix1, const pixel* pix2, intptr_t stride_pix2); 32 | int x265_pixel_satd_8x4_neon(const pixel* pix1, intptr_t stride_pix1, const pixel* pix2, intptr_t stride_pix2); 33 | int x265_pixel_satd_8x8_neon(const pixel* pix1, intptr_t stride_pix1, const pixel* pix2, intptr_t stride_pix2); 34 | int x265_pixel_satd_12x16_neon(const pixel* pix1, intptr_t stride_pix1, const pixel* pix2, intptr_t stride_pix2); 35 | int x265_pixel_satd_12x32_neon(const pixel* pix1, intptr_t stride_pix1, const pixel* pix2, intptr_t stride_pix2); 36 | 37 | uint32_t x265_quant_neon(const int16_t* coef, const int32_t* quantCoeff, int32_t* deltaU, int16_t* qCoef, int qBits, int add, int numCoeff); 38 | int PFX(psyCost_4x4_neon)(const pixel* source, intptr_t sstride, const pixel* recon, intptr_t rstride); 39 | 40 | #endif // ifndef X265_PIXEL_UTIL_AARCH64_H 41 | -------------------------------------------------------------------------------- /source/common/aarch64/sad-a.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2020 MulticoreWare, Inc 3 | * 4 | * Authors: Hongbin Liu 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #include "asm.S" 25 | 26 | .section .rodata 27 | 28 | .align 4 29 | 30 | .text 31 | 32 | .macro SAD_X_START_8 x 33 | ld1 {v0.8b}, [x0], x9 34 | .if \x == 3 35 | ld1 {v1.8b}, [x1], x4 36 | ld1 {v2.8b}, [x2], x4 37 | ld1 {v3.8b}, [x3], x4 38 | .elseif \x == 4 39 | ld1 {v1.8b}, [x1], x5 40 | ld1 {v2.8b}, [x2], x5 41 | ld1 {v3.8b}, [x3], x5 42 | ld1 {v4.8b}, [x4], x5 43 | .endif 44 | uabdl v16.8h, v0.8b, v1.8b 45 | uabdl v17.8h, v0.8b, v2.8b 46 | uabdl v18.8h, v0.8b, v3.8b 47 | .if \x == 4 48 | uabdl v19.8h, v0.8b, v4.8b 49 | .endif 50 | .endm 51 | 52 | .macro SAD_X_8 x 53 | ld1 {v0.8b}, [x0], x9 54 | .if \x == 3 55 | ld1 {v1.8b}, [x1], x4 56 | ld1 {v2.8b}, [x2], x4 57 | ld1 {v3.8b}, [x3], x4 58 | .elseif \x == 4 59 | ld1 {v1.8b}, [x1], x5 60 | ld1 {v2.8b}, [x2], x5 61 | ld1 {v3.8b}, [x3], x5 62 | ld1 {v4.8b}, [x4], x5 63 | .endif 64 | uabal v16.8h, v0.8b, v1.8b 65 | uabal v17.8h, v0.8b, v2.8b 66 | uabal v18.8h, v0.8b, v3.8b 67 | .if \x == 4 68 | uabal v19.8h, v0.8b, v4.8b 69 | .endif 70 | .endm 71 | 72 | .macro SAD_X_8xN x, h 73 | function x265_sad_x\x\()_8x\h\()_neon 74 | mov x9, #FENC_STRIDE 75 | SAD_X_START_8 \x 76 | .rept \h - 1 77 | SAD_X_8 \x 78 | .endr 79 | uaddlv s0, v16.8h 80 | uaddlv s1, v17.8h 81 | uaddlv s2, v18.8h 82 | .if \x == 4 83 | uaddlv s3, v19.8h 84 | .endif 85 | 86 | .if \x == 3 87 | stp s0, s1, [x5] 88 | str s2, [x5, #8] 89 | .elseif \x == 4 90 | stp s0, s1, [x6] 91 | stp s2, s3, [x6, #8] 92 | .endif 93 | ret 94 | endfunc 95 | .endm 96 | 97 | SAD_X_8xN 3 4 98 | SAD_X_8xN 3 8 99 | SAD_X_8xN 3 16 100 | SAD_X_8xN 3 32 101 | 102 | SAD_X_8xN 4 4 103 | SAD_X_8xN 4 8 104 | SAD_X_8xN 4 16 105 | SAD_X_8xN 4 32 106 | -------------------------------------------------------------------------------- /source/common/arm/cpu-a.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * cpu-a.S: arm cpu detection 3 | ***************************************************************************** 4 | * Copyright (C) 2013-2020 MulticoreWare, Inc 5 | * 6 | * Authors: David Conrad 7 | * Dnyaneshwar Gorade 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 22 | * 23 | * This program is also available under a commercial proprietary license. 24 | * For more information, contact us at license @ x265.com. 25 | *****************************************************************************/ 26 | 27 | #include "asm.S" 28 | 29 | .align 2 30 | 31 | // done in gas because .fpu neon overrides the refusal to assemble 32 | // instructions the selected -march/-mcpu doesn't support 33 | function x265_cpu_neon_test 34 | vadd.i16 q0, q0, q0 35 | bx lr 36 | endfunc 37 | 38 | // return: 0 on success 39 | // 1 if counters were already enabled 40 | // 9 if lo-res counters were already enabled 41 | function x265_cpu_enable_armv7_counter, export=0 42 | mrc p15, 0, r2, c9, c12, 0 // read PMNC 43 | ands r0, r2, #1 44 | andne r0, r2, #9 45 | 46 | orr r2, r2, #1 // enable counters 47 | bic r2, r2, #8 // full resolution 48 | mcreq p15, 0, r2, c9, c12, 0 // write PMNC 49 | mov r2, #1 << 31 // enable cycle counter 50 | mcr p15, 0, r2, c9, c12, 1 // write CNTENS 51 | bx lr 52 | endfunc 53 | 54 | function x265_cpu_disable_armv7_counter, export=0 55 | mrc p15, 0, r0, c9, c12, 0 // read PMNC 56 | bic r0, r0, #1 // disable counters 57 | mcr p15, 0, r0, c9, c12, 0 // write PMNC 58 | bx lr 59 | endfunc 60 | 61 | 62 | .macro READ_TIME r 63 | mrc p15, 0, \r, c9, c13, 0 64 | .endm 65 | 66 | // return: 0 if transfers neon -> arm transfers take more than 10 cycles 67 | // nonzero otherwise 68 | function x265_cpu_fast_neon_mrc_test 69 | // check for user access to performance counters 70 | mrc p15, 0, r0, c9, c14, 0 71 | cmp r0, #0 72 | bxeq lr 73 | 74 | push {r4-r6,lr} 75 | bl x265_cpu_enable_armv7_counter 76 | ands r1, r0, #8 77 | mov r3, #0 78 | mov ip, #4 79 | mov r6, #4 80 | moveq r5, #1 81 | movne r5, #64 82 | 83 | average_loop: 84 | mov r4, r5 85 | READ_TIME r1 86 | 1: subs r4, r4, #1 87 | .rept 8 88 | vmov.u32 lr, d0[0] 89 | add lr, lr, lr 90 | .endr 91 | bgt 1b 92 | READ_TIME r2 93 | 94 | subs r6, r6, #1 95 | sub r2, r2, r1 96 | cmpgt r2, #30 << 3 // assume context switch if it took over 30 cycles 97 | addle r3, r3, r2 98 | subsle ip, ip, #1 99 | bgt average_loop 100 | 101 | // disable counters if we enabled them 102 | ands r0, r0, #1 103 | bleq x265_cpu_disable_armv7_counter 104 | 105 | lsr r0, r3, #5 106 | cmp r0, #10 107 | movgt r0, #0 108 | pop {r4-r6,pc} 109 | endfunc 110 | -------------------------------------------------------------------------------- /source/common/arm/dct8.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Min Chen 5 | * Dnyaneshwar Gorade 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program 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 General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 20 | * 21 | * This program is also available under a commercial proprietary license. 22 | * For more information, contact us at license @ x265.com. 23 | *****************************************************************************/ 24 | 25 | #ifndef X265_DCT8_ARM_H 26 | #define X265_DCT8_ARM_H 27 | 28 | void PFX(dct_4x4_neon)(const int16_t* src, int16_t* dst, intptr_t srcStride); 29 | void PFX(dct_8x8_neon)(const int16_t* src, int16_t* dst, intptr_t srcStride); 30 | void PFX(dct_16x16_neon)(const int16_t* src, int16_t* dst, intptr_t srcStride); 31 | 32 | #endif // ifndef X265_DCT8_ARM_H 33 | -------------------------------------------------------------------------------- /source/common/arm/intrapred.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * intrapred.h: Intra Prediction metrics 3 | ***************************************************************************** 4 | * Copyright (C) 2013-2020 MulticoreWare, Inc 5 | * 6 | * Authors: Min Chen 7 | * Praveen Kumar Tiwari 8 | * Dnyaneshwar Gorade 9 | * 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 23 | * 24 | * This program is also available under a commercial proprietary license. 25 | * For more information, contact us at license @ x265.com. 26 | *****************************************************************************/ 27 | 28 | #ifndef X265_INTRAPRED_ARM_H 29 | #define X265_INTRAPRED_ARM_H 30 | 31 | #endif // ifndef X265_INTRAPRED_ARM_H 32 | -------------------------------------------------------------------------------- /source/common/arm/loopfilter.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Dnyaneshwar Gorade 5 | * Praveen Kumar Tiwari 6 | ;* Min Chen 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at license @ x265.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X265_LOOPFILTER_ARM_H 27 | #define X265_LOOPFILTER_ARM_H 28 | 29 | #endif // ifndef X265_LOOPFILTER_ARM_H 30 | -------------------------------------------------------------------------------- /source/common/arm/mc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #ifndef X265_MC_ARM_H 25 | #define X265_MC_ARM_H 26 | 27 | #endif // ifndef X265_MC_ARM_H 28 | -------------------------------------------------------------------------------- /source/common/bitstream.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "bitstream.h" 3 | #include "threading.h" 4 | 5 | using namespace X265_NS; 6 | 7 | #if defined(_MSC_VER) 8 | #pragma warning(disable: 4244) 9 | #endif 10 | 11 | #define MIN_FIFO_SIZE 1000 12 | 13 | Bitstream::Bitstream() 14 | { 15 | m_fifo = X265_MALLOC(uint8_t, MIN_FIFO_SIZE); 16 | m_byteAlloc = MIN_FIFO_SIZE; 17 | resetBits(); 18 | } 19 | 20 | void Bitstream::push_back(uint8_t val) 21 | { 22 | if (!m_fifo) 23 | return; 24 | 25 | if (m_byteOccupancy >= m_byteAlloc) 26 | { 27 | /** reallocate buffer with doubled size */ 28 | uint8_t *temp = X265_MALLOC(uint8_t, m_byteAlloc * 2); 29 | if (temp) 30 | { 31 | memcpy(temp, m_fifo, m_byteOccupancy); 32 | X265_FREE(m_fifo); 33 | m_fifo = temp; 34 | m_byteAlloc *= 2; 35 | } 36 | else 37 | { 38 | x265_log(NULL, X265_LOG_ERROR, "Unable to realloc bitstream buffer"); 39 | return; 40 | } 41 | } 42 | m_fifo[m_byteOccupancy++] = val; 43 | } 44 | 45 | void Bitstream::write(uint32_t val, uint32_t numBits) 46 | { 47 | X265_CHECK(numBits <= 32, "numBits out of range\n"); 48 | X265_CHECK(numBits == 32 || ((val & (~0u << numBits)) == 0), "numBits & val out of range\n"); 49 | 50 | uint32_t totalPartialBits = m_partialByteBits + numBits; 51 | uint32_t nextPartialBits = totalPartialBits & 7; 52 | uint8_t nextHeldByte = val << (8 - nextPartialBits); 53 | uint32_t writeBytes = totalPartialBits >> 3; 54 | 55 | if (writeBytes) 56 | { 57 | /* topword aligns m_partialByte with the msb of val */ 58 | uint32_t topword = (numBits - nextPartialBits) & ~7; 59 | #if USING_FTRAPV 60 | uint32_t write_bits = (topword < 32 ? m_partialByte << topword : 0) | (val >> nextPartialBits); 61 | #else 62 | uint32_t write_bits = (m_partialByte << topword) | (val >> nextPartialBits); 63 | #endif 64 | 65 | switch (writeBytes) 66 | { 67 | case 4: push_back(write_bits >> 24); // fall-through 68 | case 3: push_back(write_bits >> 16); // fall-through 69 | case 2: push_back(write_bits >> 8); // fall-through 70 | case 1: push_back(write_bits); 71 | } 72 | 73 | m_partialByte = nextHeldByte; 74 | m_partialByteBits = nextPartialBits; 75 | } 76 | else 77 | { 78 | m_partialByte |= nextHeldByte; 79 | m_partialByteBits = nextPartialBits; 80 | } 81 | } 82 | 83 | void Bitstream::writeByte(uint32_t val) 84 | { 85 | // Only CABAC will call writeByte, the fifo must be byte aligned 86 | X265_CHECK(!m_partialByteBits, "expecting m_partialByteBits = 0\n"); 87 | 88 | push_back(val); 89 | } 90 | 91 | void Bitstream::writeAlignOne() 92 | { 93 | uint32_t numBits = (8 - m_partialByteBits) & 0x7; 94 | 95 | write((1 << numBits) - 1, numBits); 96 | } 97 | 98 | void Bitstream::writeAlignZero() 99 | { 100 | if (m_partialByteBits) 101 | { 102 | push_back(m_partialByte); 103 | m_partialByte = 0; 104 | m_partialByteBits = 0; 105 | } 106 | } 107 | 108 | void Bitstream::writeByteAlignment() 109 | { 110 | write(1, 1); 111 | writeAlignZero(); 112 | } 113 | 114 | void SyntaxElementWriter::writeUvlc(uint32_t code) 115 | { 116 | ++code; 117 | 118 | X265_CHECK(code, "writing -1 code, will cause infinite loop\n"); 119 | 120 | unsigned long idx; 121 | CLZ(idx, code); 122 | uint32_t length = (uint32_t)idx * 2 + 1; 123 | 124 | // Take care of cases where length > 32 125 | m_bitIf->write(0, length >> 1); 126 | m_bitIf->write(code, (length + 1) >> 1); 127 | } 128 | -------------------------------------------------------------------------------- /source/common/cpu.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Loren Merritt 5 | * Steve Borho 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program 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 General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 20 | * 21 | * This program is also available under a commercial proprietary license. 22 | * For more information, contact us at license @ x265.com. 23 | *****************************************************************************/ 24 | 25 | #ifndef X265_CPU_H 26 | #define X265_CPU_H 27 | 28 | #include "common.h" 29 | /* All assembly functions are prefixed with X265_NS (macro expanded) */ 30 | #define PFX3(prefix, name) prefix ## _ ## name 31 | #define PFX2(prefix, name) PFX3(prefix, name) 32 | #define PFX(name) PFX2(X265_NS, name) 33 | 34 | // from cpu-a.asm, if ASM primitives are compiled, else primitives.cpp 35 | extern "C" void PFX(cpu_emms)(void); 36 | extern "C" void PFX(safe_intel_cpu_indicator_init)(void); 37 | 38 | #if _MSC_VER && _WIN64 39 | #define x265_emms() PFX(cpu_emms)() 40 | #elif _MSC_VER 41 | #include 42 | #define x265_emms() _mm_empty() 43 | #elif __GNUC__ 44 | // Cannot use _mm_empty() directly without compiling all the source with 45 | // a fixed CPU arch, which we would like to avoid at the moment 46 | #define x265_emms() PFX(cpu_emms)() 47 | #else 48 | #define x265_emms() PFX(cpu_emms)() 49 | #endif 50 | 51 | namespace X265_NS { 52 | uint32_t cpu_detect(bool); 53 | bool detect512(); 54 | 55 | struct cpu_name_t 56 | { 57 | char name[16]; 58 | uint32_t flags; 59 | }; 60 | 61 | extern const cpu_name_t cpu_names[]; 62 | } 63 | 64 | #endif // ifndef X265_CPU_H 65 | -------------------------------------------------------------------------------- /source/common/deblock.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Author: Gopu Govindaswamy 5 | * Min Chen 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program 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 General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 20 | * 21 | * This program is also available under a commercial proprietary license. 22 | * For more information, contact us at license @ x265.com. 23 | *****************************************************************************/ 24 | 25 | #ifndef X265_DEBLOCK_H 26 | #define X265_DEBLOCK_H 27 | 28 | #include "common.h" 29 | 30 | namespace X265_NS { 31 | // private namespace 32 | 33 | class CUData; 34 | struct CUGeom; 35 | 36 | class Deblock 37 | { 38 | public: 39 | enum { EDGE_VER, EDGE_HOR }; 40 | 41 | static void deblockCTU(const CUData* ctu, const CUGeom& cuGeom, int32_t dir); 42 | 43 | protected: 44 | 45 | // CU-level deblocking function 46 | static void deblockCU(const CUData* cu, const CUGeom& cuGeom, const int32_t dir, uint8_t blockStrength[]); 47 | 48 | // set filtering functions 49 | static void setEdgefilterTU(const CUData* cu, uint32_t absPartIdx, uint32_t tuDepth, int32_t dir, uint8_t blockStrength[]); 50 | static void setEdgefilterPU(const CUData* cu, uint32_t absPartIdx, int32_t dir, uint8_t blockStrength[], uint32_t numUnits); 51 | static void setEdgefilterMultiple(uint32_t absPartIdx, int32_t dir, int32_t edgeIdx, uint8_t value, uint8_t blockStrength[], uint32_t numUnits); 52 | 53 | // get filtering functions 54 | static uint8_t getBoundaryStrength(const CUData* cuQ, int32_t dir, uint32_t partQ, const uint8_t blockStrength[]); 55 | 56 | // filter luma/chroma functions 57 | static void edgeFilterLuma(const CUData* cuQ, uint32_t absPartIdx, uint32_t depth, int32_t dir, int32_t edge, const uint8_t blockStrength[]); 58 | static void edgeFilterChroma(const CUData* cuQ, uint32_t absPartIdx, uint32_t depth, int32_t dir, int32_t edge, const uint8_t blockStrength[]); 59 | 60 | static const uint8_t s_tcTable[54]; 61 | static const uint8_t s_betaTable[52]; 62 | }; 63 | } 64 | #endif // ifndef X265_DEBLOCK_H 65 | -------------------------------------------------------------------------------- /source/common/md5.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * md5.h: Calculate MD5 3 | ***************************************************************************** 4 | * Copyright (C) 2013-2020 MulticoreWare, Inc 5 | * 6 | * Authors: Min Chen 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; 11 | * 12 | * This program 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 General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 20 | * 21 | * This program is also available under a commercial proprietary license. 22 | * For more information, contact us at chenm003@163.com. 23 | *****************************************************************************/ 24 | 25 | #ifndef X265_MD5_H 26 | #define X265_MD5_H 27 | 28 | #include "common.h" 29 | 30 | namespace X265_NS { 31 | //private x265 namespace 32 | 33 | typedef struct MD5Context 34 | { 35 | uint32_t buf[4]; 36 | uint32_t bits[2]; 37 | unsigned char in[64]; 38 | } MD5Context; 39 | 40 | void MD5Init(MD5Context *context); 41 | void MD5Update(MD5Context *context, unsigned char *buf, uint32_t len); 42 | void MD5Final(MD5Context *ctx, uint8_t *digest); 43 | 44 | class MD5 45 | { 46 | public: 47 | 48 | /** 49 | * initialize digest state 50 | */ 51 | MD5() 52 | { 53 | MD5Init(&m_state); 54 | } 55 | 56 | /** 57 | * compute digest over buf of length len. 58 | * multiple calls may extend the digest over more data. 59 | */ 60 | void update(unsigned char *buf, unsigned len) 61 | { 62 | MD5Update(&m_state, buf, len); 63 | } 64 | 65 | /** 66 | * flush any outstanding MD5 data, write the digest into digest. 67 | */ 68 | void finalize(unsigned char digest[16]) 69 | { 70 | MD5Final(&m_state, digest); 71 | } 72 | 73 | private: 74 | 75 | MD5Context m_state; 76 | }; 77 | } 78 | 79 | #endif // ifndef X265_MD5_H 80 | -------------------------------------------------------------------------------- /source/common/param.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Deepthi Nandakumar 5 | * Praveen Kumar Tiwari 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program 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 General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 20 | * 21 | * This program is also available under a commercial proprietary license. 22 | * For more information, contact us at license @ x265.com. 23 | *****************************************************************************/ 24 | 25 | #ifndef X265_PARAM_H 26 | #define X265_PARAM_H 27 | 28 | namespace X265_NS { 29 | 30 | int x265_check_params(x265_param *param); 31 | void x265_print_params(x265_param *param); 32 | void x265_param_apply_fastfirstpass(x265_param *p); 33 | char* x265_param2string(x265_param *param, int padx, int pady); 34 | int x265_atoi(const char *str, bool& bError); 35 | double x265_atof(const char *str, bool& bError); 36 | int parseCpuName(const char *value, bool& bError, bool bEnableavx512); 37 | void setParamAspectRatio(x265_param *p, int width, int height); 38 | void getParamAspectRatio(x265_param *p, int& width, int& height); 39 | bool parseLambdaFile(x265_param *param); 40 | void x265_copy_params(x265_param* dst, x265_param* src); 41 | 42 | /* this table is kept internal to avoid confusion, since log level indices start at -1 */ 43 | static const char * const logLevelNames[] = { "none", "error", "warning", "info", "debug", "full", 0 }; 44 | 45 | #if EXPORT_C_API 46 | #define PARAM_NS 47 | #else 48 | /* declare param functions within private namespace */ 49 | void x265_param_free(x265_param *); 50 | x265_param* x265_param_alloc(); 51 | void x265_param_default(x265_param *param); 52 | int x265_param_default_preset(x265_param *, const char *preset, const char *tune); 53 | int x265_param_apply_profile(x265_param *, const char *profile); 54 | int x265_param_parse(x265_param *p, const char *name, const char *value); 55 | int x265_zone_param_parse(x265_param* p, const char* name, const char* value); 56 | #define PARAM_NS X265_NS 57 | #endif 58 | } 59 | #endif // ifndef X265_PARAM_H 60 | -------------------------------------------------------------------------------- /source/common/piclist.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Gopu Govindaswamy 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #ifndef X265_PICLIST_H 25 | #define X265_PICLIST_H 26 | 27 | #include "common.h" 28 | 29 | namespace X265_NS { 30 | 31 | class Frame; 32 | 33 | class PicList 34 | { 35 | protected: 36 | 37 | Frame* m_start; 38 | Frame* m_end; 39 | int m_count; 40 | 41 | public: 42 | 43 | PicList() 44 | { 45 | m_start = NULL; 46 | m_end = NULL; 47 | m_count = 0; 48 | } 49 | 50 | /** Push picture to end of the list */ 51 | void pushBack(Frame& pic); 52 | 53 | /** Push picture to beginning of the list */ 54 | void pushFront(Frame& pic); 55 | 56 | /** Pop picture from end of the list */ 57 | Frame* popBack(); 58 | 59 | /** Pop picture from beginning of the list */ 60 | Frame* popFront(); 61 | 62 | /** Find frame with specified POC */ 63 | Frame* getPOC(int poc); 64 | 65 | /** Get the current Frame from the list **/ 66 | Frame* getCurFrame(void); 67 | 68 | /** Remove picture from list */ 69 | void remove(Frame& pic); 70 | 71 | Frame* first() { return m_start; } 72 | 73 | Frame* last() { return m_end; } 74 | 75 | int size() { return m_count; } 76 | 77 | bool empty() const { return !m_count; } 78 | 79 | operator bool() const { return !!m_count; } 80 | }; 81 | } 82 | 83 | #endif // ifndef X265_PICLIST_H 84 | -------------------------------------------------------------------------------- /source/common/ppc/ppccommon.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Min Chen 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #ifndef X265_PPCCOMMON_H 25 | #define X265_PPCCOMMON_H 26 | 27 | 28 | #if HAVE_ALTIVEC 29 | #include 30 | 31 | #define vec_u8_t vector unsigned char 32 | #define vec_s8_t vector signed char 33 | #define vec_u16_t vector unsigned short 34 | #define vec_s16_t vector signed short 35 | #define vec_u32_t vector unsigned int 36 | #define vec_s32_t vector signed int 37 | 38 | //copy from x264 39 | #define LOAD_ZERO const vec_u8_t zerov = vec_splat_u8( 0 ) 40 | 41 | #define zero_u8v (vec_u8_t) zerov 42 | #define zero_s8v (vec_s8_t) zerov 43 | #define zero_u16v (vec_u16_t) zerov 44 | #define zero_s16v (vec_s16_t) zerov 45 | #define zero_u32v (vec_u32_t) zerov 46 | #define zero_s32v (vec_s32_t) zerov 47 | 48 | /*********************************************************************** 49 | * 8 <-> 16 bits conversions 50 | **********************************************************************/ 51 | #ifdef WORDS_BIGENDIAN 52 | #define vec_u8_to_u16_h(v) (vec_u16_t) vec_mergeh( zero_u8v, (vec_u8_t) v ) 53 | #define vec_u8_to_u16_l(v) (vec_u16_t) vec_mergel( zero_u8v, (vec_u8_t) v ) 54 | #define vec_u8_to_s16_h(v) (vec_s16_t) vec_mergeh( zero_u8v, (vec_u8_t) v ) 55 | #define vec_u8_to_s16_l(v) (vec_s16_t) vec_mergel( zero_u8v, (vec_u8_t) v ) 56 | #else 57 | #define vec_u8_to_u16_h(v) (vec_u16_t) vec_mergeh( (vec_u8_t) v, zero_u8v ) 58 | #define vec_u8_to_u16_l(v) (vec_u16_t) vec_mergel( (vec_u8_t) v, zero_u8v ) 59 | #define vec_u8_to_s16_h(v) (vec_s16_t) vec_mergeh( (vec_u8_t) v, zero_u8v ) 60 | #define vec_u8_to_s16_l(v) (vec_s16_t) vec_mergel( (vec_u8_t) v, zero_u8v ) 61 | #endif 62 | 63 | #define vec_u8_to_u16(v) vec_u8_to_u16_h(v) 64 | #define vec_u8_to_s16(v) vec_u8_to_s16_h(v) 65 | 66 | #ifdef WORDS_BIGENDIAN 67 | #define vec_u16_to_u32_h(v) (vec_u32_t) vec_mergeh( zero_u16v, (vec_u16_t) v ) 68 | #define vec_u16_to_u32_l(v) (vec_u32_t) vec_mergel( zero_u16v, (vec_u16_t) v ) 69 | #define vec_u16_to_s32_h(v) (vec_s32_t) vec_mergeh( zero_u16v, (vec_u16_t) v ) 70 | #define vec_u16_to_s32_l(v) (vec_s32_t) vec_mergel( zero_u16v, (vec_u16_t) v ) 71 | #else 72 | #define vec_u16_to_u32_h(v) (vec_u32_t) vec_mergeh( (vec_u16_t) v, zero_u16v ) 73 | #define vec_u16_to_u32_l(v) (vec_u32_t) vec_mergel( (vec_u16_t) v, zero_u16v ) 74 | #define vec_u16_to_s32_h(v) (vec_s32_t) vec_mergeh( (vec_u16_t) v, zero_u16v ) 75 | #define vec_u16_to_s32_l(v) (vec_s32_t) vec_mergel( (vec_u16_t) v, zero_u16v ) 76 | #endif 77 | 78 | #define vec_u16_to_u32(v) vec_u16_to_u32_h(v) 79 | #define vec_u16_to_s32(v) vec_u16_to_s32_h(v) 80 | 81 | #define vec_u32_to_u16(v) vec_pack( v, zero_u32v ) 82 | #define vec_s32_to_u16(v) vec_packsu( v, zero_s32v ) 83 | 84 | #define BITS_PER_SUM (8 * sizeof(sum_t)) 85 | 86 | #endif /* HAVE_ALTIVEC */ 87 | 88 | #endif /* X265_PPCCOMMON_H */ 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /source/common/scalinglist.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #ifndef X265_SCALINGLIST_H 25 | #define X265_SCALINGLIST_H 26 | 27 | #include "common.h" 28 | 29 | namespace X265_NS { 30 | // private namespace 31 | 32 | class ScalingList 33 | { 34 | public: 35 | 36 | enum { NUM_SIZES = 4 }; // 4x4, 8x8, 16x16, 32x32 37 | enum { NUM_LISTS = 6 }; // number of quantization matrix lists (YUV * inter/intra) 38 | enum { NUM_REM = 6 }; // number of remainders of QP/6 39 | enum { MAX_MATRIX_COEF_NUM = 64 }; // max coefficient number per quantization matrix 40 | enum { MAX_MATRIX_SIZE_NUM = 8 }; // max size number for quantization matrix 41 | 42 | static const int s_numCoefPerSize[NUM_SIZES]; 43 | static const int32_t s_invQuantScales[NUM_REM]; 44 | static const int32_t s_quantScales[NUM_REM]; 45 | static const char MatrixType[4][6][20]; 46 | static const char MatrixType_DC[4][12][22]; 47 | 48 | int32_t m_scalingListDC[NUM_SIZES][NUM_LISTS]; // the DC value of the matrix coefficient for 16x16 49 | int32_t* m_scalingListCoef[NUM_SIZES][NUM_LISTS]; // quantization matrix 50 | 51 | int32_t* m_quantCoef[NUM_SIZES][NUM_LISTS][NUM_REM]; // array of quantization matrix coefficient 4x4 52 | int32_t* m_dequantCoef[NUM_SIZES][NUM_LISTS][NUM_REM]; // array of dequantization matrix coefficient 4x4 53 | 54 | bool m_bEnabled; 55 | bool m_bDataPresent; // non-default scaling lists must be signaled 56 | 57 | ScalingList(); 58 | ~ScalingList(); 59 | 60 | bool init(); 61 | void setDefaultScalingList(); 62 | bool parseScalingList(const char* filename); 63 | void setupQuantMatrices(int internalCsp); 64 | 65 | /* used during SPS coding */ 66 | int checkPredMode(int sizeId, int listId) const; 67 | 68 | protected: 69 | 70 | static const int SCALING_LIST_DC = 16; // default DC value 71 | 72 | const int32_t* getScalingListDefaultAddress(int sizeId, int listId) const; 73 | void processDefaultMarix(int sizeId, int listId); 74 | bool checkDefaultScalingList() const; 75 | 76 | void processScalingListEnc(int32_t *coeff, int32_t *quantcoeff, int32_t quantScales, int height, int width, int ratio, int stride, int32_t dc); 77 | void processScalingListDec(int32_t *coeff, int32_t *dequantcoeff, int32_t invQuantScales, int height, int width, int ratio, int stride, int32_t dc); 78 | }; 79 | 80 | } 81 | 82 | #endif // ifndef X265_SCALINGLIST_H 83 | -------------------------------------------------------------------------------- /source/common/shortyuv.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * x265: ShortYUV class for short sized YUV-style frames 3 | ***************************************************************************** 4 | * Copyright (C) 2013-2020 MulticoreWare, Inc 5 | * 6 | * Authors: Deepthi Nandakumar 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at license @ x265.com 24 | *****************************************************************************/ 25 | 26 | #ifndef X265_SHORTYUV_H 27 | #define X265_SHORTYUV_H 28 | 29 | #include "common.h" 30 | 31 | namespace X265_NS { 32 | // private namespace 33 | 34 | class Yuv; 35 | 36 | /* A ShortYuv instance holds int16_ts for a square CU (64x64 down to 8x8) for all three planes, 37 | * these are typically used to hold residual or coefficients */ 38 | class ShortYuv 39 | { 40 | public: 41 | 42 | int16_t* m_buf[3]; 43 | 44 | uint32_t m_size; 45 | uint32_t m_csize; 46 | 47 | int m_csp; 48 | int m_hChromaShift; 49 | int m_vChromaShift; 50 | 51 | ShortYuv(); 52 | 53 | bool create(uint32_t size, int csp); 54 | void destroy(); 55 | void clear(); 56 | 57 | int16_t* getLumaAddr(uint32_t absPartIdx) { return m_buf[0] + getAddrOffset(absPartIdx, m_size); } 58 | int16_t* getCbAddr(uint32_t absPartIdx) { return m_buf[1] + getChromaAddrOffset(absPartIdx); } 59 | int16_t* getCrAddr(uint32_t absPartIdx) { return m_buf[2] + getChromaAddrOffset(absPartIdx); } 60 | int16_t* getChromaAddr(uint32_t chromaId, uint32_t partUnitIdx) { return m_buf[chromaId] + getChromaAddrOffset(partUnitIdx); } 61 | 62 | const int16_t* getLumaAddr(uint32_t absPartIdx) const { return m_buf[0] + getAddrOffset(absPartIdx, m_size); } 63 | const int16_t* getCbAddr(uint32_t absPartIdx) const { return m_buf[1] + getChromaAddrOffset(absPartIdx); } 64 | const int16_t* getCrAddr(uint32_t absPartIdx) const { return m_buf[2] + getChromaAddrOffset(absPartIdx); } 65 | const int16_t* getChromaAddr(uint32_t chromaId, uint32_t partUnitIdx) const { return m_buf[chromaId] + getChromaAddrOffset(partUnitIdx); } 66 | 67 | void subtract(const Yuv& srcYuv0, const Yuv& srcYuv1, uint32_t log2Size, int picCsp); 68 | 69 | void copyPartToPartLuma(ShortYuv& dstYuv, uint32_t absPartIdx, uint32_t log2Size) const; 70 | void copyPartToPartChroma(ShortYuv& dstYuv, uint32_t absPartIdx, uint32_t log2SizeL) const; 71 | 72 | void copyPartToPartLuma(Yuv& dstYuv, uint32_t absPartIdx, uint32_t log2Size) const; 73 | void copyPartToPartChroma(Yuv& dstYuv, uint32_t absPartIdx, uint32_t log2SizeL) const; 74 | 75 | int getChromaAddrOffset(uint32_t idx) const 76 | { 77 | int blkX = g_zscanToPelX[idx] >> m_hChromaShift; 78 | int blkY = g_zscanToPelY[idx] >> m_vChromaShift; 79 | 80 | return blkX + blkY * m_csize; 81 | } 82 | 83 | static int getAddrOffset(uint32_t idx, uint32_t width) 84 | { 85 | int blkX = g_zscanToPelX[idx]; 86 | int blkY = g_zscanToPelY[idx]; 87 | 88 | return blkX + blkY * width; 89 | } 90 | }; 91 | } 92 | 93 | #endif // ifndef X265_SHORTYUV_H 94 | -------------------------------------------------------------------------------- /source/common/vec/vec-primitives.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #include "primitives.h" 25 | #include "x265.h" 26 | 27 | /* The #if logic here must match the file lists in CMakeLists.txt */ 28 | #if X265_ARCH_X86 29 | #if defined(__INTEL_COMPILER) 30 | #define HAVE_SSE3 31 | #define HAVE_SSSE3 32 | #define HAVE_SSE4 33 | #define HAVE_AVX2 34 | #elif defined(__GNUC__) 35 | #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) 36 | #if __clang__ || GCC_VERSION >= 40300 /* gcc_version >= gcc-4.3.0 */ 37 | #define HAVE_SSE3 38 | #define HAVE_SSSE3 39 | #define HAVE_SSE4 40 | #endif 41 | #if __clang__ || GCC_VERSION >= 40700 /* gcc_version >= gcc-4.7.0 */ 42 | #define HAVE_AVX2 43 | #endif 44 | #elif defined(_MSC_VER) 45 | #define HAVE_SSE3 46 | #define HAVE_SSSE3 47 | #define HAVE_SSE4 48 | #if _MSC_VER >= 1700 // VC11 49 | #define HAVE_AVX2 50 | #endif 51 | #endif // compiler checks 52 | #endif // if X265_ARCH_X86 53 | 54 | namespace X265_NS { 55 | // private x265 namespace 56 | 57 | void setupIntrinsicDCT_sse3(EncoderPrimitives&); 58 | void setupIntrinsicDCT_ssse3(EncoderPrimitives&); 59 | void setupIntrinsicDCT_sse41(EncoderPrimitives&); 60 | 61 | /* Use primitives for the best available vector architecture */ 62 | void setupInstrinsicPrimitives(EncoderPrimitives &p, int cpuMask) 63 | { 64 | #ifdef HAVE_SSE3 65 | if (cpuMask & X265_CPU_SSE3) 66 | { 67 | setupIntrinsicDCT_sse3(p); 68 | } 69 | #endif 70 | #ifdef HAVE_SSSE3 71 | if (cpuMask & X265_CPU_SSSE3) 72 | { 73 | setupIntrinsicDCT_ssse3(p); 74 | } 75 | #endif 76 | #ifdef HAVE_SSE4 77 | if (cpuMask & X265_CPU_SSE4) 78 | { 79 | setupIntrinsicDCT_sse41(p); 80 | } 81 | #endif 82 | (void)p; 83 | (void)cpuMask; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /source/common/version.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * Min Chen 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program 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 General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 20 | * 21 | * This program is also available under a commercial proprietary license. 22 | * For more information, contact us at license @ x265.com. 23 | *****************************************************************************/ 24 | 25 | #include "x265.h" 26 | #include "common.h" 27 | #include "primitives.h" 28 | 29 | #define XSTR(x) STR(x) 30 | #define STR(x) #x 31 | 32 | #if defined(__clang__) 33 | #define COMPILEDBY "[clang " XSTR(__clang_major__) "." XSTR(__clang_minor__) "." XSTR(__clang_patchlevel__) "]" 34 | #ifdef __IA64__ 35 | #define ONARCH "[on 64-bit] " 36 | #else 37 | #define ONARCH "[on 32-bit] " 38 | #endif 39 | #endif 40 | 41 | #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__) 42 | #define COMPILEDBY "[GCC " XSTR(__GNUC__) "." XSTR(__GNUC_MINOR__) "." XSTR(__GNUC_PATCHLEVEL__) "]" 43 | #ifdef __IA64__ 44 | #define ONARCH "[on 64-bit] " 45 | #else 46 | #define ONARCH "[on 32-bit] " 47 | #endif 48 | #endif 49 | 50 | #ifdef __INTEL_COMPILER 51 | #define COMPILEDBY "[ICC " XSTR(__INTEL_COMPILER) "]" 52 | #elif _MSC_VER 53 | #define COMPILEDBY "[MSVC " XSTR(_MSC_VER) "]" 54 | #endif 55 | 56 | #ifndef COMPILEDBY 57 | #define COMPILEDBY "[Unk-CXX]" 58 | #endif 59 | 60 | #ifdef _WIN32 61 | #define ONOS "[Windows]" 62 | #elif __linux 63 | #define ONOS "[Linux]" 64 | #elif __OpenBSD__ 65 | #define ONOS "[OpenBSD]" 66 | #elif __CYGWIN__ 67 | #define ONOS "[Cygwin]" 68 | #elif __APPLE__ 69 | #define ONOS "[Mac OS X]" 70 | #else 71 | #define ONOS "[Unk-OS]" 72 | #endif 73 | 74 | #if X86_64 75 | #define BITS "[64 bit]" 76 | #else 77 | #define BITS "[32 bit]" 78 | #endif 79 | 80 | #if defined(ENABLE_ASSEMBLY) || HAVE_ALTIVEC 81 | #define ASM "" 82 | #else 83 | #define ASM "[noasm]" 84 | #endif 85 | 86 | #if NO_ATOMICS 87 | #define ATOMICS "[no-atomics]" 88 | #else 89 | #define ATOMICS "" 90 | #endif 91 | 92 | #if CHECKED_BUILD 93 | #define CHECKED "[CHECKED] " 94 | #else 95 | #define CHECKED " " 96 | #endif 97 | 98 | #if X265_DEPTH == 12 99 | 100 | #define BITDEPTH "12bit" 101 | const int PFX(max_bit_depth) = 12; 102 | 103 | #elif X265_DEPTH == 10 104 | 105 | #define BITDEPTH "10bit" 106 | const int PFX(max_bit_depth) = 10; 107 | 108 | #elif X265_DEPTH == 8 109 | 110 | #define BITDEPTH "8bit" 111 | const int PFX(max_bit_depth) = 8; 112 | 113 | #endif 114 | 115 | #if LINKED_8BIT 116 | #define ADD8 "+8bit" 117 | #else 118 | #define ADD8 "" 119 | #endif 120 | #if LINKED_10BIT 121 | #define ADD10 "+10bit" 122 | #else 123 | #define ADD10 "" 124 | #endif 125 | #if LINKED_12BIT 126 | #define ADD12 "+12bit" 127 | #else 128 | #define ADD12 "" 129 | #endif 130 | 131 | const char* PFX(version_str) = XSTR(X265_VERSION); 132 | const char* PFX(build_info_str) = ONOS COMPILEDBY BITS ASM ATOMICS CHECKED BITDEPTH ADD8 ADD10 ADD12; 133 | -------------------------------------------------------------------------------- /source/common/wavefront.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * Min Chen 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program 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 General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 20 | * 21 | * This program is also available under a commercial proprietary license. 22 | * For more information, contact us at license @ x265.com 23 | *****************************************************************************/ 24 | 25 | #ifndef X265_WAVEFRONT_H 26 | #define X265_WAVEFRONT_H 27 | 28 | #include "common.h" 29 | #include "threadpool.h" 30 | 31 | namespace X265_NS { 32 | // x265 private namespace 33 | 34 | // Generic wave-front scheduler, manages busy-state of CU rows as a priority 35 | // queue (higher CU rows have priority over lower rows) 36 | // 37 | // Derived classes must implement ProcessRow(). 38 | class WaveFront : public JobProvider 39 | { 40 | private: 41 | 42 | // bitmaps of rows queued for processing, uses atomic intrinsics 43 | 44 | // Dependencies are categorized as internal and external. Internal dependencies 45 | // are caused by neighbor block availability. External dependencies are generally 46 | // reference frame reconstructed pixels being available. 47 | uint32_t volatile *m_internalDependencyBitmap; 48 | uint32_t volatile *m_externalDependencyBitmap; 49 | 50 | // number of words in the bitmap 51 | int m_numWords; 52 | 53 | int m_numRows; 54 | 55 | protected: 56 | uint32_t *m_row_to_idx; 57 | uint32_t *m_idx_to_row; 58 | 59 | public: 60 | 61 | WaveFront() 62 | : m_internalDependencyBitmap(NULL) 63 | , m_externalDependencyBitmap(NULL) 64 | {} 65 | 66 | virtual ~WaveFront(); 67 | 68 | // If returns false, the frame must be encoded in series. 69 | bool init(int numRows); 70 | 71 | // Enqueue a row to be processed (mark its internal dependencies as resolved). 72 | // A worker thread will later call processRow(row). 73 | // This provider must be enqueued in the pool before enqueuing a row 74 | void enqueueRow(int row); 75 | 76 | // Mark a row as no longer having internal dependencies resolved. Returns 77 | // true if bit clear was successful, false otherwise. 78 | bool dequeueRow(int row); 79 | 80 | // Mark the row's external dependencies as being resolved 81 | void enableRow(int row); 82 | 83 | // Mark all row external dependencies as being resolved. Some wavefront 84 | // implementations (lookahead, for instance) have no recon pixel dependencies. 85 | void enableAllRows(); 86 | 87 | // Mark all rows as having external dependencies which must be 88 | // resolved before each row may proceed. 89 | void clearEnabledRowMask(); 90 | 91 | // WaveFront's implementation of JobProvider::findJob. Consults 92 | // m_queuedBitmap and calls ProcessRow(row) for lowest numbered queued row 93 | // processes available rows and returns when no work remains 94 | void findJob(int threadId); 95 | 96 | // Start or resume encode processing of this row, must be implemented by 97 | // derived classes. 98 | virtual void processRow(int row, int threadId) = 0; 99 | }; 100 | } // end namespace X265_NS 101 | 102 | #endif // ifndef X265_WAVEFRONT_H 103 | -------------------------------------------------------------------------------- /source/common/winxp.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com 22 | *****************************************************************************/ 23 | 24 | #ifndef X265_WINXP_H 25 | #define X265_WINXP_H 26 | 27 | #if defined(_WIN32) && (_WIN32_WINNT < 0x0600) // _WIN32_WINNT_VISTA 28 | 29 | #ifdef _MSC_VER 30 | #include // _InterlockedCompareExchange64 31 | #endif 32 | 33 | namespace X265_NS { 34 | /* non-native condition variable */ 35 | typedef struct 36 | { 37 | CRITICAL_SECTION broadcastMutex; 38 | CRITICAL_SECTION waiterCountMutex; 39 | HANDLE semaphore; 40 | HANDLE waitersDone; 41 | volatile int waiterCount; 42 | volatile int bIsBroadcast; 43 | } ConditionVariable; 44 | 45 | int WINAPI cond_init(ConditionVariable *cond); 46 | void WINAPI cond_broadcast(ConditionVariable *cond); 47 | void WINAPI cond_signal(ConditionVariable *cond); 48 | BOOL WINAPI cond_wait(ConditionVariable *cond, CRITICAL_SECTION *mutex, DWORD wait); 49 | void cond_destroy(ConditionVariable *cond); 50 | 51 | /* map missing API symbols to our structure and functions */ 52 | #define CONDITION_VARIABLE X265_NS::ConditionVariable 53 | #define InitializeConditionVariable X265_NS::cond_init 54 | #define SleepConditionVariableCS X265_NS::cond_wait 55 | #define WakeConditionVariable X265_NS::cond_signal 56 | #define WakeAllConditionVariable X265_NS::cond_broadcast 57 | #define XP_CONDITION_VAR_FREE X265_NS::cond_destroy 58 | 59 | } // namespace X265_NS 60 | 61 | #else // if defined(_WIN32) && (_WIN32_WINNT < 0x0600) 62 | 63 | #define XP_CONDITION_VAR_FREE(x) 64 | 65 | #endif // _WIN32_WINNT <= _WIN32_WINNT_WINXP 66 | 67 | #endif // ifndef X265_WINXP_H 68 | -------------------------------------------------------------------------------- /source/common/x86/README.txt: -------------------------------------------------------------------------------- 1 | The ASM source here is directly pulled from the x264 project with two 2 | changes: 3 | 4 | 1 - FENC_STRIDE must be increased to 64 in x86util.asm because of HEVC's 5 | larger CU sizes 6 | 2 - Because of #1, we must rebrand the functions with x265_ prefixes in 7 | x86inc.asm (private_prefix) and pixel-a.asm (mangle(x265_pixel_ssd)) 8 | 3 - We have modified the MMX SSD primitives to use EMMS before returning 9 | 4 - We have added some new SATD block sizes for SSE3 10 | 11 | Current assembly is based on x264 revision: 12 | configure: Support cygwin64 13 | Diogo Franco (Kovensky) 14 | 2013-07-23 22:17:44 -0300 15 | -------------------------------------------------------------------------------- /source/common/x86/dct8.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Nabajit Deka 5 | ;* Min Chen 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program 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 General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 20 | * 21 | * This program is also available under a commercial proprietary license. 22 | * For more information, contact us at license @ x265.com. 23 | *****************************************************************************/ 24 | 25 | #ifndef X265_DCT8_H 26 | #define X265_DCT8_H 27 | 28 | FUNCDEF_TU_S2(void, dct, sse2, const int16_t* src, int16_t* dst, intptr_t srcStride); 29 | FUNCDEF_TU_S2(void, dct, ssse3, const int16_t* src, int16_t* dst, intptr_t srcStride); 30 | FUNCDEF_TU_S2(void, dct, sse4, const int16_t* src, int16_t* dst, intptr_t srcStride); 31 | FUNCDEF_TU_S2(void, dct, avx2, const int16_t* src, int16_t* dst, intptr_t srcStride); 32 | 33 | FUNCDEF_TU_S2(void, idct, sse2, const int16_t* src, int16_t* dst, intptr_t dstStride); 34 | FUNCDEF_TU_S2(void, idct, ssse3, const int16_t* src, int16_t* dst, intptr_t dstStride); 35 | FUNCDEF_TU_S2(void, idct, sse4, const int16_t* src, int16_t* dst, intptr_t dstStride); 36 | FUNCDEF_TU_S2(void, idct, avx2, const int16_t* src, int16_t* dst, intptr_t dstStride); 37 | FUNCDEF_TU_S2(void, nonPsyRdoQuant, avx512, int16_t *m_resiDctCoeff, int64_t *costUncoded, int64_t *totalUncodedCost, int64_t *totalRdCost, uint32_t blkPos); 38 | FUNCDEF_TU_S2(void, psyRdoQuant, avx512, int16_t* m_resiDctCoeff, int16_t* m_fencDctCoeff, int64_t* costUncoded, int64_t* totalUncodedCost, int64_t* totalRdCost, int64_t *psyScale, uint32_t blkPos); 39 | FUNCDEF_TU_S2(void, nonPsyRdoQuant, avx2, int16_t *m_resiDctCoeff, int64_t *costUncoded, int64_t *totalUncodedCost, int64_t *totalRdCost, uint32_t blkPos); 40 | FUNCDEF_TU_S2(void, psyRdoQuant_1p, avx2, int16_t* m_resiDctCoeff, int64_t* costUncoded, int64_t* totalUncodedCost, int64_t* totalRdCost, uint32_t blkPos); 41 | FUNCDEF_TU_S2(void, psyRdoQuant_2p, avx2, int16_t* m_resiDctCoeff, int16_t* m_fencDctCoeff, int64_t* costUncoded, int64_t* totalUncodedCost, int64_t* totalRdCost, int64_t *psyScale, uint32_t blkPos); 42 | 43 | void PFX(dst4_ssse3)(const int16_t* src, int16_t* dst, intptr_t srcStride); 44 | void PFX(dst4_sse2)(const int16_t* src, int16_t* dst, intptr_t srcStride); 45 | void PFX(idst4_sse2)(const int16_t* src, int16_t* dst, intptr_t srcStride); 46 | void PFX(dst4_avx2)(const int16_t* src, int16_t* dst, intptr_t srcStride); 47 | void PFX(idst4_avx2)(const int16_t* src, int16_t* dst, intptr_t srcStride); 48 | void PFX(denoise_dct_sse4)(int16_t* dct, uint32_t* sum, const uint16_t* offset, int size); 49 | void PFX(denoise_dct_avx2)(int16_t* dct, uint32_t* sum, const uint16_t* offset, int size); 50 | void PFX(denoise_dct_avx512)(int16_t* dct, uint32_t* sum, const uint16_t* offset, int size); 51 | void PFX(dct8_avx512)(const int16_t* src, int16_t* dst, intptr_t srcStride); 52 | void PFX(idct8_avx512)(const int16_t* src, int16_t* dst, intptr_t dstStride); 53 | void PFX(idct16_avx512)(const int16_t* src, int16_t* dst, intptr_t dstStride); 54 | void PFX(idct32_avx512)(const int16_t* src, int16_t* dst, intptr_t dstStride); 55 | void PFX(dct32_avx512)(const int16_t* src, int16_t* dst, intptr_t srcStride); 56 | void PFX(dct16_avx512)(const int16_t* src, int16_t* dst, intptr_t srcStride); 57 | #endif // ifndef X265_DCT8_H 58 | -------------------------------------------------------------------------------- /source/common/x86/ipfilter8.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #ifndef X265_IPFILTER8_H 25 | #define X265_IPFILTER8_H 26 | 27 | #define SETUP_FUNC_DEF(cpu) \ 28 | FUNCDEF_PU(void, interp_8tap_horiz_pp, cpu, const pixel* src, intptr_t srcStride, pixel* dst, intptr_t dstStride, int coeffIdx); \ 29 | FUNCDEF_PU(void, interp_8tap_horiz_ps, cpu, const pixel* src, intptr_t srcStride, int16_t* dst, intptr_t dstStride, int coeffIdx, int isRowExt); \ 30 | FUNCDEF_PU(void, interp_8tap_vert_pp, cpu, const pixel* src, intptr_t srcStride, pixel* dst, intptr_t dstStride, int coeffIdx); \ 31 | FUNCDEF_PU(void, interp_8tap_vert_ps, cpu, const pixel* src, intptr_t srcStride, int16_t* dst, intptr_t dstStride, int coeffIdx); \ 32 | FUNCDEF_PU(void, interp_8tap_vert_sp, cpu, const int16_t* src, intptr_t srcStride, pixel* dst, intptr_t dstStride, int coeffIdx); \ 33 | FUNCDEF_PU(void, interp_8tap_vert_ss, cpu, const int16_t* src, intptr_t srcStride, int16_t* dst, intptr_t dstStride, int coeffIdx); \ 34 | FUNCDEF_PU(void, interp_8tap_hv_pp, cpu, const pixel* src, intptr_t srcStride, pixel* dst, intptr_t dstStride, int idxX, int idxY); \ 35 | FUNCDEF_CHROMA_PU(void, filterPixelToShort, cpu, const pixel* src, intptr_t srcStride, int16_t* dst, intptr_t dstStride); \ 36 | FUNCDEF_CHROMA_PU(void, filterPixelToShort_aligned, cpu, const pixel* src, intptr_t srcStride, int16_t* dst, intptr_t dstStride); \ 37 | FUNCDEF_CHROMA_PU(void, interp_4tap_horiz_pp, cpu, const pixel* src, intptr_t srcStride, pixel* dst, intptr_t dstStride, int coeffIdx); \ 38 | FUNCDEF_CHROMA_PU(void, interp_4tap_horiz_ps, cpu, const pixel* src, intptr_t srcStride, int16_t* dst, intptr_t dstStride, int coeffIdx, int isRowExt); \ 39 | FUNCDEF_CHROMA_PU(void, interp_4tap_vert_pp, cpu, const pixel* src, intptr_t srcStride, pixel* dst, intptr_t dstStride, int coeffIdx); \ 40 | FUNCDEF_CHROMA_PU(void, interp_4tap_vert_ps, cpu, const pixel* src, intptr_t srcStride, int16_t* dst, intptr_t dstStride, int coeffIdx); \ 41 | FUNCDEF_CHROMA_PU(void, interp_4tap_vert_sp, cpu, const int16_t* src, intptr_t srcStride, pixel* dst, intptr_t dstStride, int coeffIdx); \ 42 | FUNCDEF_CHROMA_PU(void, interp_4tap_vert_ss, cpu, const int16_t* src, intptr_t srcStride, int16_t* dst, intptr_t dstStride, int coeffIdx) 43 | 44 | SETUP_FUNC_DEF(sse2); 45 | SETUP_FUNC_DEF(ssse3); 46 | SETUP_FUNC_DEF(sse3); 47 | SETUP_FUNC_DEF(sse4); 48 | SETUP_FUNC_DEF(avx2); 49 | SETUP_FUNC_DEF(avx512); 50 | 51 | #endif // ifndef X265_IPFILTER8_H 52 | -------------------------------------------------------------------------------- /source/common/x86/loopfilter.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Dnyaneshwar Gorade 5 | * Praveen Kumar Tiwari 6 | ;* Min Chen 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at license @ x265.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X265_LOOPFILTER_H 27 | #define X265_LOOPFILTER_H 28 | 29 | #define DECL_SAO(cpu) \ 30 | void PFX(saoCuOrgE0_ ## cpu)(pixel * rec, int8_t * offsetEo, int endX, int8_t* signLeft, intptr_t stride); \ 31 | void PFX(saoCuOrgE1_ ## cpu)(pixel* rec, int8_t* upBuff1, int8_t* offsetEo, intptr_t stride, int width); \ 32 | void PFX(saoCuOrgE1_2Rows_ ## cpu)(pixel* rec, int8_t* upBuff1, int8_t* offsetEo, intptr_t stride, int width); \ 33 | void PFX(saoCuOrgE2_ ## cpu)(pixel* rec, int8_t* pBufft, int8_t* pBuff1, int8_t* offsetEo, int lcuWidth, intptr_t stride); \ 34 | void PFX(saoCuOrgE2_ ## cpu)(pixel* rec, int8_t* pBufft, int8_t* pBuff1, int8_t* offsetEo, int lcuWidth, intptr_t stride); \ 35 | void PFX(saoCuOrgE2_32_ ## cpu)(pixel* rec, int8_t* pBufft, int8_t* pBuff1, int8_t* offsetEo, int lcuWidth, intptr_t stride); \ 36 | void PFX(saoCuOrgE3_ ## cpu)(pixel *rec, int8_t *upBuff1, int8_t *m_offsetEo, intptr_t stride, int startX, int endX); \ 37 | void PFX(saoCuOrgE3_32_ ## cpu)(pixel *rec, int8_t *upBuff1, int8_t *m_offsetEo, intptr_t stride, int startX, int endX); \ 38 | void PFX(saoCuOrgB0_ ## cpu)(pixel* rec, const int8_t* offsetBo, int ctuWidth, int ctuHeight, intptr_t stride); \ 39 | void PFX(saoCuStatsBO_ ## cpu)(const int16_t *diff, const pixel *rec, intptr_t stride, int endX, int endY, int32_t *stats, int32_t *count); \ 40 | void PFX(saoCuStatsE0_ ## cpu)(const int16_t *diff, const pixel *rec, intptr_t stride, int endX, int endY, int32_t *stats, int32_t *count); \ 41 | void PFX(saoCuStatsE1_ ## cpu)(const int16_t *diff, const pixel *rec, intptr_t stride, int8_t *upBuff1, int endX, int endY, int32_t *stats, int32_t *count); \ 42 | void PFX(saoCuStatsE2_ ## cpu)(const int16_t *diff, const pixel *rec, intptr_t stride, int8_t *upBuff1, int8_t *upBufft, int endX, int endY, int32_t *stats, int32_t *count); \ 43 | void PFX(saoCuStatsE3_ ## cpu)(const int16_t *diff, const pixel *rec, intptr_t stride, int8_t *upBuff1, int endX, int endY, int32_t *stats, int32_t *count); \ 44 | void PFX(calSign_ ## cpu)(int8_t *dst, const pixel *src1, const pixel *src2, const int endX); 45 | 46 | DECL_SAO(sse4); 47 | DECL_SAO(avx2); 48 | 49 | void PFX(pelFilterLumaStrong_V_sse4)(pixel* src, intptr_t srcStep, intptr_t offset, int32_t tcP, int32_t tcQ); 50 | void PFX(pelFilterLumaStrong_H_sse4)(pixel* src, intptr_t srcStep, intptr_t offset, int32_t tcP, int32_t tcQ); 51 | void PFX(pelFilterChroma_V_sse4)(pixel* src, intptr_t srcStep, intptr_t offset, int32_t tc, int32_t maskP, int32_t maskQ); 52 | void PFX(pelFilterChroma_H_sse4)(pixel* src, intptr_t srcStep, intptr_t offset, int32_t tc, int32_t maskP, int32_t maskQ); 53 | 54 | #endif // ifndef X265_LOOPFILTER_H 55 | -------------------------------------------------------------------------------- /source/common/x86/mc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #ifndef X265_MC_H 25 | #define X265_MC_H 26 | 27 | #define LOWRES(cpu) \ 28 | void PFX(frame_init_lowres_core_ ## cpu)(const pixel* src0, pixel* dst0, pixel* dsth, pixel* dstv, pixel* dstc, \ 29 | intptr_t src_stride, intptr_t dst_stride, int width, int height); 30 | LOWRES(mmx2) 31 | LOWRES(sse2) 32 | LOWRES(ssse3) 33 | LOWRES(avx) 34 | LOWRES(avx2) 35 | LOWRES(xop) 36 | 37 | #undef LOWRES 38 | 39 | #define PROPAGATE_COST(cpu) \ 40 | void PFX(mbtree_propagate_cost_ ## cpu)(int* dst, const uint16_t* propagateIn, const int32_t* intraCosts, \ 41 | const uint16_t* interCosts, const int32_t* invQscales, const double* fpsFactor, int len); 42 | 43 | PROPAGATE_COST(sse2) 44 | PROPAGATE_COST(avx) 45 | PROPAGATE_COST(avx2) 46 | 47 | #undef PROPAGATE_COST 48 | 49 | #define FIX8UNPACK(cpu) \ 50 | void PFX(cutree_fix8_unpack_ ## cpu)(double *dst, uint16_t *src, int count); 51 | 52 | FIX8UNPACK(ssse3) 53 | FIX8UNPACK(avx2) 54 | 55 | #undef FIX8UNPACK 56 | 57 | #define FIX8PACK(cpu) \ 58 | void PFX(cutree_fix8_pack_## cpu)(uint16_t *dst, double *src, int count); 59 | 60 | FIX8PACK(ssse3) 61 | FIX8PACK(avx2) 62 | 63 | #undef FIX8PACK 64 | 65 | #endif // ifndef X265_MC_H 66 | -------------------------------------------------------------------------------- /source/common/x86/seaintegral.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Vignesh V Menon 5 | * Jayashri Murugan 6 | * Praveen Tiwari 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at license @ x265.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X265_SEAINTEGRAL_H 27 | #define X265_SEAINTEGRAL_H 28 | 29 | void PFX(integral4v_avx2)(uint32_t *sum, intptr_t stride); 30 | void PFX(integral8v_avx2)(uint32_t *sum, intptr_t stride); 31 | void PFX(integral12v_avx2)(uint32_t *sum, intptr_t stride); 32 | void PFX(integral16v_avx2)(uint32_t *sum, intptr_t stride); 33 | void PFX(integral24v_avx2)(uint32_t *sum, intptr_t stride); 34 | void PFX(integral32v_avx2)(uint32_t *sum, intptr_t stride); 35 | void PFX(integral4h_avx2)(uint32_t *sum, pixel *pix, intptr_t stride); 36 | void PFX(integral8h_avx2)(uint32_t *sum, pixel *pix, intptr_t stride); 37 | void PFX(integral12h_avx2)(uint32_t *sum, pixel *pix, intptr_t stride); 38 | void PFX(integral16h_avx2)(uint32_t *sum, pixel *pix, intptr_t stride); 39 | void PFX(integral24h_avx2)(uint32_t *sum, pixel *pix, intptr_t stride); 40 | void PFX(integral32h_avx2)(uint32_t *sum, pixel *pix, intptr_t stride); 41 | 42 | #endif //X265_SEAINTEGRAL_H 43 | -------------------------------------------------------------------------------- /source/compat/msvc/stdint.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef _MSC_VER 4 | #error "Use this header only with Microsoft Visual C++ compilers!" 5 | #endif 6 | 7 | #include // for intptr_t 8 | #if !defined(UINT64_MAX) 9 | #include 10 | #define UINT64_MAX _UI64_MAX 11 | #define INT64_MAX _I64_MAX 12 | #define INT16_MAX _I16_MAX 13 | #endif 14 | 15 | /* a minimal set of C99 types for use with MSVC (VC9) */ 16 | 17 | typedef signed char int8_t; 18 | typedef short int int16_t; 19 | typedef int int32_t; 20 | typedef __int64 int64_t; 21 | 22 | typedef unsigned char uint8_t; 23 | typedef unsigned short int uint16_t; 24 | typedef unsigned int uint32_t; 25 | typedef unsigned __int64 uint64_t; 26 | 27 | -------------------------------------------------------------------------------- /source/dynamicHDR10/BasicStructures.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Bhavna Hariharan 5 | * Kavitha Sampath 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program 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 General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 20 | * 21 | * This program is also available under a commercial proprietary license. 22 | * For more information, contact us at license @ x265.com. 23 | **/ 24 | 25 | #ifndef BASICSTRUCTURES_H 26 | #define BASICSTRUCTURES_H 27 | 28 | #include 29 | 30 | 31 | struct LuminanceParameters 32 | { 33 | float averageLuminance = 0.0; 34 | float maxRLuminance = 0.0; 35 | float maxGLuminance = 0.0; 36 | float maxBLuminance = 0.0; 37 | int order = 0; 38 | std::vector percentiles; 39 | }; 40 | 41 | struct BezierCurveData 42 | { 43 | int order = 0; 44 | int sPx = 0; 45 | int sPy = 0; 46 | std::vector coeff; 47 | }; 48 | 49 | struct PercentileLuminance{ 50 | 51 | float averageLuminance = 0.0; 52 | float maxRLuminance = 0.0; 53 | float maxGLuminance = 0.0; 54 | float maxBLuminance = 0.0; 55 | int order = 0; 56 | std::vector percentiles; 57 | }; 58 | 59 | #endif // BASICSTRUCTURES_H 60 | -------------------------------------------------------------------------------- /source/dynamicHDR10/JsonHelper.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Bhavna Hariharan 5 | * Kavitha Sampath 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program 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 General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 20 | * 21 | * This program is also available under a commercial proprietary license. 22 | * For more information, contact us at license @ x265.com. 23 | **/ 24 | 25 | #ifndef JSON_H 26 | #define JSON_H 27 | #include 28 | #include 29 | #include "json11/json11.h" 30 | 31 | using std::string; 32 | using namespace json11; 33 | typedef Json::object JsonObject; 34 | typedef Json::array JsonArray; 35 | 36 | class JsonHelper 37 | { 38 | public: 39 | static JsonObject readJson(string path); 40 | static JsonArray readJsonArray(const string &path); 41 | static string dump(JsonArray json); 42 | static string dump(JsonObject json, int extraTab = 0); 43 | 44 | static bool writeJson(JsonObject json , string path); 45 | static bool writeJson(JsonArray json, string path); 46 | static JsonObject add(string key, string value, JsonObject &json); 47 | private: 48 | static void printTabs(string &out, int tabCounter); 49 | JsonObject mJson; 50 | static bool validatePathExtension(string &path); 51 | }; 52 | 53 | #endif // JSON_H 54 | -------------------------------------------------------------------------------- /source/dynamicHDR10/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2013-2020 MulticoreWare, Inc 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; either version 2 of the License, or 6 | (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 16 | 17 | This program is also available under a commercial proprietary license. 18 | For more information, contact us at license @ x265.com. 19 | -------------------------------------------------------------------------------- /source/dynamicHDR10/SeiMetadataDictionary.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Bhavna Hariharan 5 | * Kavitha Sampath 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program 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 General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 20 | * 21 | * This program is also available under a commercial proprietary license. 22 | * For more information, contact us at license @ x265.com. 23 | **/ 24 | 25 | #ifndef SEIMETADATADICTIONARY_H 26 | #define SEIMETADATADICTIONARY_H 27 | 28 | #include "SeiMetadataDictionary.h" 29 | 30 | #include 31 | 32 | namespace SeiMetadataDictionary 33 | { 34 | 35 | class JsonDataKeys 36 | { 37 | public: 38 | static const std::string LocalParameters; 39 | static const std::string TargetDisplayLuminance; 40 | static const std::string NumberOfWindows; 41 | }; 42 | 43 | //Bezier Curve Data 44 | class BezierCurveNames 45 | { 46 | public: 47 | static const std::string TagName; 48 | static const std::string NumberOfAnchors; 49 | static const std::string KneePointX; 50 | static const std::string KneePointY; 51 | static const std::string AnchorsTag; 52 | static const std::string Anchors[14]; 53 | }; 54 | //Ellipse Selection Data 55 | class EllipseSelectionNames 56 | { 57 | public: 58 | static const std::string WindowUpperLeftCornerX; 59 | static const std::string WindowUpperLeftCornerY; 60 | static const std::string WindowLowerRightCornerX; 61 | static const std::string WindowLowerRightCornerY; 62 | static const std::string WindowData; 63 | }; 64 | //Ellipse Data 65 | class EllipseNames 66 | { 67 | public: 68 | static const std::string TagName; 69 | static const std::string RotationAngle; 70 | static const std::string CenterOfEllipseX; 71 | static const std::string CenterOfEllipseY; 72 | static const std::string OverlapProcessOption; 73 | static const std::string SemiMajorAxisExternalEllipse; 74 | static const std::string SemiMinorAxisExternalEllipse; 75 | static const std::string SemiMajorAxisInternalEllipse; 76 | }; 77 | //Percentile Luminance 78 | class PercentileNames 79 | { 80 | public: 81 | static const std::string TagName; 82 | static const std::string NumberOfPercentiles; 83 | static const std::string DistributionIndex; 84 | static const std::string DistributionValues; 85 | static const std::string PercentilePercentageValue[15]; 86 | static const std::string PercentileLuminanceValue[15]; 87 | }; 88 | //Luminance Parameters 89 | class LuminanceNames 90 | { 91 | public: 92 | static const std::string TagName; 93 | static const std::string LlcTagName; 94 | static const std::string AverageRGB; 95 | static const std::string MaxSCL; 96 | static const std::string MaxSCL0; 97 | static const std::string MaxSCL1; 98 | static const std::string MaxSCL2; 99 | }; 100 | } 101 | 102 | #endif // SEIMETADATADICTIONARY_H 103 | -------------------------------------------------------------------------------- /source/dynamicHDR10/api.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Bhavna Hariharan 5 | * Kavitha Sampath 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program 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 General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 20 | * 21 | * This program is also available under a commercial proprietary license. 22 | * For more information, contact us at license @ x265.com. 23 | **/ 24 | 25 | #include "hdr10plus.h" 26 | #include "metadataFromJson.h" 27 | 28 | bool hdr10plus_json_to_frame_cim(const char* path, uint32_t frameNumber, uint8_t *&cim) 29 | { 30 | metadataFromJson meta; 31 | return meta.frameMetadataFromJson(path, 32 | frameNumber, 33 | cim); 34 | } 35 | 36 | int hdr10plus_json_to_movie_cim(const char* path, uint8_t **&cim) 37 | { 38 | metadataFromJson meta; 39 | return meta.movieMetadataFromJson(path, cim); 40 | } 41 | 42 | bool hdr10plus_json_to_frame_eif(const char* path, uint32_t frameNumber, uint8_t *&eif) 43 | { 44 | metadataFromJson meta; 45 | return meta.extendedInfoFrameMetadataFromJson(path, 46 | frameNumber, 47 | eif); 48 | } 49 | 50 | int hdr10plus_json_to_movie_eif(const char* path, uint8_t **&eif) 51 | { 52 | metadataFromJson meta; 53 | return meta.movieExtendedInfoFrameMetadataFromJson(path, eif); 54 | } 55 | 56 | 57 | void hdr10plus_clear_movie(uint8_t **&metadata, const int numberOfFrames) 58 | { 59 | if(metadata) 60 | { 61 | metadataFromJson meta; 62 | meta.clear(metadata, numberOfFrames); 63 | } 64 | } 65 | 66 | static const hdr10plus_api libapi = 67 | { 68 | &hdr10plus_json_to_frame_cim, 69 | &hdr10plus_json_to_movie_cim, 70 | &hdr10plus_json_to_frame_eif, 71 | &hdr10plus_json_to_movie_eif, 72 | &hdr10plus_clear_movie, 73 | }; 74 | 75 | const hdr10plus_api* hdr10plus_api_get() 76 | { 77 | return &libapi; 78 | } 79 | -------------------------------------------------------------------------------- /source/dynamicHDR10/json11/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Dropbox, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /source/encoder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # vim: syntax=cmake 2 | 3 | if(GCC) 4 | add_definitions(-Wno-uninitialized) 5 | if(CC_HAS_NO_STRICT_OVERFLOW) 6 | # GCC 4.9.2 gives warnings we know we can ignore in this file 7 | set_source_files_properties(slicetype.cpp PROPERTIES COMPILE_FLAGS -Wno-strict-overflow) 8 | endif(CC_HAS_NO_STRICT_OVERFLOW) 9 | endif() 10 | if(MSVC) 11 | add_definitions(/wd4701) # potentially uninitialized local variable 'foo' used 12 | endif() 13 | 14 | if(EXTRA_LIB) 15 | if(LINKED_8BIT) 16 | list(APPEND APIFLAGS "-DLINKED_8BIT=1") 17 | endif(LINKED_8BIT) 18 | if(LINKED_10BIT) 19 | list(APPEND APIFLAGS "-DLINKED_10BIT=1") 20 | endif(LINKED_10BIT) 21 | if(LINKED_12BIT) 22 | list(APPEND APIFLAGS "-DLINKED_12BIT=1") 23 | endif(LINKED_12BIT) 24 | string(REPLACE ";" " " APIFLAGSTR "${APIFLAGS}") 25 | set_source_files_properties(api.cpp PROPERTIES COMPILE_FLAGS ${APIFLAGSTR}) 26 | endif(EXTRA_LIB) 27 | 28 | add_library(encoder OBJECT ../x265.h 29 | analysis.cpp analysis.h 30 | search.cpp search.h 31 | bitcost.cpp bitcost.h rdcost.h 32 | motion.cpp motion.h 33 | slicetype.cpp slicetype.h 34 | frameencoder.cpp frameencoder.h 35 | framefilter.cpp framefilter.h 36 | level.cpp level.h 37 | nal.cpp nal.h 38 | sei.cpp sei.h 39 | sao.cpp sao.h 40 | entropy.cpp entropy.h 41 | dpb.cpp dpb.h 42 | ratecontrol.cpp ratecontrol.h 43 | reference.cpp reference.h 44 | encoder.cpp encoder.h 45 | api.cpp 46 | weightPrediction.cpp svt.h) 47 | -------------------------------------------------------------------------------- /source/encoder/bitcost.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #ifndef X265_BITCOST_H 25 | #define X265_BITCOST_H 26 | 27 | #include "common.h" 28 | #include "threading.h" 29 | #include "mv.h" 30 | 31 | namespace X265_NS { 32 | // private x265 namespace 33 | 34 | class BitCost 35 | { 36 | public: 37 | 38 | BitCost() : m_cost_mvx(0), m_cost_mvy(0), m_cost(0), m_mvp(0) {} 39 | 40 | void setQP(unsigned int qp); 41 | 42 | void setMVP(const MV& mvp) { m_mvp = mvp; m_cost_mvx = m_cost - mvp.x; m_cost_mvy = m_cost - mvp.y; } 43 | 44 | // return bit cost of motion vector difference, multiplied by lambda 45 | inline uint16_t mvcost(const MV& mv) const { return m_cost_mvx[mv.x] + m_cost_mvy[mv.y]; } 46 | 47 | // return bit cost of motion vector difference, without lambda 48 | inline uint32_t bitcost(const MV& mv) const 49 | { 50 | return (uint32_t)(s_bitsizes[mv.x - m_mvp.x] + 51 | s_bitsizes[mv.y - m_mvp.y] + 0.5f); 52 | } 53 | 54 | static inline uint32_t bitcost(const MV& mv, const MV& mvp) 55 | { 56 | return (uint32_t)(s_bitsizes[mv.x - mvp.x] + 57 | s_bitsizes[mv.y - mvp.y] + 0.5f); 58 | } 59 | 60 | static void destroy(); 61 | 62 | protected: 63 | 64 | uint16_t *m_cost_mvx; 65 | 66 | uint16_t *m_cost_mvy; 67 | 68 | uint16_t *m_cost; 69 | 70 | uint16_t *m_fpelMvCosts[4]; 71 | 72 | MV m_mvp; 73 | 74 | BitCost& operator =(const BitCost&); 75 | 76 | private: 77 | 78 | /* default log2_max_mv_length_horizontal and log2_max_mv_length_horizontal 79 | * are 15, specified in quarter-pel luma sample units. making the maximum 80 | * signaled ful-pel motion distance 4096, max qpel is 32768 */ 81 | enum { BC_MAX_MV = (1 << 15) }; 82 | 83 | enum { BC_MAX_QP = 82 }; 84 | 85 | static float *s_bitsizes; 86 | 87 | static uint16_t *s_costs[BC_MAX_QP]; 88 | 89 | static uint16_t *s_fpelMvCosts[BC_MAX_QP][4]; 90 | 91 | static Lock s_costCalcLock; 92 | 93 | static void CalculateLogs(); 94 | }; 95 | } 96 | 97 | #endif // ifndef X265_BITCOST_H 98 | -------------------------------------------------------------------------------- /source/encoder/dpb.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #ifndef X265_DPB_H 25 | #define X265_DPB_H 26 | 27 | #include "piclist.h" 28 | 29 | namespace X265_NS { 30 | // private namespace for x265 31 | 32 | class Frame; 33 | class FrameData; 34 | class Slice; 35 | 36 | class DPB 37 | { 38 | public: 39 | 40 | int m_lastIDR; 41 | int m_pocCRA; 42 | int m_bOpenGOP; 43 | int m_bhasLeadingPicture; 44 | bool m_bRefreshPending; 45 | bool m_bTemporalSublayer; 46 | PicList m_picList; 47 | PicList m_freeList; 48 | FrameData* m_frameDataFreeList; 49 | 50 | DPB(x265_param *param) 51 | { 52 | m_lastIDR = 0; 53 | m_pocCRA = 0; 54 | m_bhasLeadingPicture = param->radl; 55 | if (param->bResetZoneConfig) 56 | { 57 | for (int i = 0; i < param->rc.zonefileCount ; i++) 58 | { 59 | if (param->rc.zones[i].zoneParam->radl) 60 | { 61 | m_bhasLeadingPicture = param->rc.zones[i].zoneParam->radl; 62 | break; 63 | } 64 | } 65 | } 66 | m_bRefreshPending = false; 67 | m_frameDataFreeList = NULL; 68 | m_bOpenGOP = param->bOpenGOP; 69 | m_bTemporalSublayer = !!param->bEnableTemporalSubLayers; 70 | } 71 | 72 | ~DPB(); 73 | 74 | void prepareEncode(Frame*); 75 | 76 | void recycleUnreferenced(); 77 | 78 | protected: 79 | 80 | void computeRPS(int curPoc, bool isRAP, RPS * rps, unsigned int maxDecPicBuffer); 81 | 82 | void applyReferencePictureSet(RPS *rps, int curPoc); 83 | void decodingRefreshMarking(int pocCurr, NalUnitType nalUnitType); 84 | 85 | NalUnitType getNalUnitType(int curPoc, bool bIsKeyFrame); 86 | }; 87 | } 88 | 89 | #endif // X265_DPB_H 90 | -------------------------------------------------------------------------------- /source/encoder/level.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #ifndef X265_LEVEL_H 25 | #define X265_LEVEL_H 1 26 | 27 | #include "common.h" 28 | #include "x265.h" 29 | 30 | namespace X265_NS { 31 | // encoder private namespace 32 | 33 | struct VPS; 34 | void determineLevel(const x265_param ¶m, VPS& vps); 35 | bool enforceLevel(x265_param& param, VPS& vps); 36 | 37 | } 38 | 39 | #endif // ifndef X265_LEVEL_H 40 | -------------------------------------------------------------------------------- /source/encoder/nal.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #ifndef X265_NAL_H 25 | #define X265_NAL_H 26 | 27 | #include "common.h" 28 | #include "x265.h" 29 | 30 | namespace X265_NS { 31 | // private namespace 32 | 33 | class Bitstream; 34 | 35 | class NALList 36 | { 37 | public: 38 | static const int MAX_NAL_UNITS = 16; 39 | 40 | public: 41 | 42 | x265_nal m_nal[MAX_NAL_UNITS]; 43 | uint32_t m_numNal; 44 | 45 | uint8_t* m_buffer; 46 | uint32_t m_occupancy; 47 | uint32_t m_allocSize; 48 | 49 | uint8_t* m_extraBuffer; 50 | uint32_t m_extraOccupancy; 51 | uint32_t m_extraAllocSize; 52 | bool m_annexB; 53 | 54 | NALList(); 55 | ~NALList() { X265_FREE(m_buffer); X265_FREE(m_extraBuffer); } 56 | 57 | void takeContents(NALList& other); 58 | 59 | void serialize(NalUnitType nalUnitType, const Bitstream& bs); 60 | 61 | uint32_t serializeSubstreams(uint32_t* streamSizeBytes, uint32_t streamCount, const Bitstream* streams); 62 | }; 63 | 64 | } 65 | 66 | #endif // ifndef X265_NAL_H 67 | -------------------------------------------------------------------------------- /source/encoder/reference.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * Min Chen 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program 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 General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 20 | * 21 | * This program is also available under a commercial proprietary license. 22 | * For more information, contact us at license @ x265.com. 23 | *****************************************************************************/ 24 | 25 | #ifndef X265_REFERENCE_H 26 | #define X265_REFERENCE_H 27 | 28 | #include "primitives.h" 29 | #include "picyuv.h" 30 | #include "lowres.h" 31 | #include "mv.h" 32 | 33 | namespace X265_NS { 34 | // private x265 namespace 35 | 36 | struct WeightParam; 37 | 38 | class MotionReference : public ReferencePlanes 39 | { 40 | public: 41 | 42 | MotionReference(); 43 | ~MotionReference(); 44 | int init(PicYuv*, WeightParam* wp, const x265_param& p); 45 | void applyWeight(uint32_t finishedRows, uint32_t maxNumRows, uint32_t maxNumRowsInSlice, uint32_t sliceId); 46 | 47 | pixel* weightBuffer[3]; 48 | int numInterpPlanes; 49 | uint32_t* numSliceWeightedRows; 50 | 51 | protected: 52 | 53 | MotionReference& operator =(const MotionReference&); 54 | }; 55 | } 56 | 57 | #endif // ifndef X265_REFERENCE_H 58 | -------------------------------------------------------------------------------- /source/encoder/svt.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2018 MulticoreWare, Inc 3 | * 4 | * Authors: Radhakrishnan 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | 25 | #ifndef SVT_H 26 | #define SVT_H 27 | 28 | #ifdef SVT_HEVC 29 | 30 | #include "EbApi.h" 31 | #include "EbErrorCodes.h" 32 | 33 | namespace X265_NS { 34 | 35 | #define INPUT_SIZE_576p_TH 0x90000 // 0.58 Million 36 | #define INPUT_SIZE_1080i_TH 0xB71B0 // 0.75 Million 37 | #define INPUT_SIZE_1080p_TH 0x1AB3F0 // 1.75 Million 38 | #define INPUT_SIZE_4K_TH 0x29F630 // 2.75 Million 39 | 40 | #define EB_OUTPUTSTREAMBUFFERSIZE_MACRO(ResolutionSize) ((ResolutionSize) < (INPUT_SIZE_1080i_TH) ? 0x1E8480 : (ResolutionSize) < (INPUT_SIZE_1080p_TH) ? 0x2DC6C0 : (ResolutionSize) < (INPUT_SIZE_4K_TH) ? 0x2DC6C0 : 0x2DC6C0) 41 | 42 | void svt_param_default(x265_param* param); 43 | int svt_set_preset(x265_param* param, const char* preset); 44 | int svt_param_parse(x265_param* param, const char* name, const char* value); 45 | void svt_initialise_app_context(x265_encoder *enc); 46 | int svt_initialise_input_buffer(x265_encoder *enc); 47 | } 48 | 49 | #endif // ifdef SVT_HEVC 50 | 51 | #endif // ifndef SVT_H 52 | -------------------------------------------------------------------------------- /source/input/input.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #include "input.h" 25 | #include "yuv.h" 26 | #include "y4m.h" 27 | 28 | using namespace X265_NS; 29 | 30 | InputFile* InputFile::open(InputFileInfo& info, bool bForceY4m) 31 | { 32 | const char * s = strrchr(info.filename, '.'); 33 | 34 | if (bForceY4m || (s && !strcmp(s, ".y4m"))) 35 | return new Y4MInput(info); 36 | else 37 | return new YUVInput(info); 38 | } 39 | -------------------------------------------------------------------------------- /source/input/input.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #ifndef X265_INPUT_H 25 | #define X265_INPUT_H 26 | 27 | #define MIN_FRAME_WIDTH 64 28 | #define MAX_FRAME_WIDTH 8192 29 | #define MIN_FRAME_HEIGHT 64 30 | #define MAX_FRAME_HEIGHT 4320 31 | #define MIN_FRAME_RATE 1 32 | #define MAX_FRAME_RATE 300 33 | 34 | #include "common.h" 35 | 36 | namespace X265_NS { 37 | // private x265 namespace 38 | 39 | struct InputFileInfo 40 | { 41 | /* possibly user-supplied, possibly read from file header */ 42 | int width; 43 | int height; 44 | int csp; 45 | int depth; 46 | int fpsNum; 47 | int fpsDenom; 48 | int sarWidth; 49 | int sarHeight; 50 | int frameCount; 51 | int timebaseNum; 52 | int timebaseDenom; 53 | 54 | /* user supplied */ 55 | int skipFrames; 56 | const char *filename; 57 | }; 58 | 59 | class InputFile 60 | { 61 | protected: 62 | 63 | virtual ~InputFile() {} 64 | 65 | public: 66 | 67 | InputFile() {} 68 | 69 | static InputFile* open(InputFileInfo& info, bool bForceY4m); 70 | 71 | virtual void startReader() = 0; 72 | 73 | virtual void release() = 0; 74 | 75 | virtual bool readPicture(x265_picture& pic) = 0; 76 | 77 | virtual bool isEof() const = 0; 78 | 79 | virtual bool isFail() = 0; 80 | 81 | virtual const char *getName() const = 0; 82 | 83 | virtual int getWidth() const = 0; 84 | 85 | virtual int getHeight() const = 0; 86 | }; 87 | } 88 | 89 | #endif // ifndef X265_INPUT_H 90 | -------------------------------------------------------------------------------- /source/input/y4m.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #ifndef X265_Y4M_H 25 | #define X265_Y4M_H 26 | 27 | #include "input.h" 28 | #include "threading.h" 29 | #include 30 | 31 | #define QUEUE_SIZE 5 32 | 33 | namespace X265_NS { 34 | // x265 private namespace 35 | 36 | class Y4MInput : public InputFile, public Thread 37 | { 38 | protected: 39 | 40 | uint32_t rateNum; 41 | 42 | uint32_t rateDenom; 43 | 44 | uint32_t sarWidth; 45 | 46 | uint32_t sarHeight; 47 | 48 | size_t framesize; 49 | 50 | int depth; 51 | 52 | int width; 53 | 54 | int height; 55 | 56 | int colorSpace; 57 | 58 | bool threadActive; 59 | 60 | ThreadSafeInteger readCount; 61 | 62 | ThreadSafeInteger writeCount; 63 | char* buf[QUEUE_SIZE]; 64 | FILE *ifs; 65 | bool parseHeader(); 66 | void threadMain(); 67 | 68 | bool populateFrameQueue(); 69 | 70 | public: 71 | 72 | Y4MInput(InputFileInfo& info); 73 | 74 | virtual ~Y4MInput(); 75 | void release(); 76 | bool isEof() const { return ifs && feof(ifs); } 77 | bool isFail() { return !(ifs && !ferror(ifs) && threadActive); } 78 | void startReader(); 79 | bool readPicture(x265_picture&); 80 | 81 | const char *getName() const { return "y4m"; } 82 | 83 | int getWidth() const { return width; } 84 | 85 | int getHeight() const { return height; } 86 | }; 87 | } 88 | 89 | #endif // ifndef X265_Y4M_H 90 | -------------------------------------------------------------------------------- /source/input/yuv.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #ifndef X265_YUV_H 25 | #define X265_YUV_H 26 | 27 | #include "input.h" 28 | #include "threading.h" 29 | #include 30 | 31 | #define QUEUE_SIZE 5 32 | 33 | namespace X265_NS { 34 | // private x265 namespace 35 | 36 | class YUVInput : public InputFile, public Thread 37 | { 38 | protected: 39 | 40 | int width; 41 | 42 | int height; 43 | 44 | int colorSpace; //< source Color Space Parameter 45 | 46 | uint32_t depth; 47 | 48 | uint32_t framesize; 49 | 50 | bool threadActive; 51 | 52 | ThreadSafeInteger readCount; 53 | 54 | ThreadSafeInteger writeCount; 55 | char* buf[QUEUE_SIZE]; 56 | FILE *ifs; 57 | int guessFrameCount(); 58 | void threadMain(); 59 | 60 | bool populateFrameQueue(); 61 | 62 | public: 63 | 64 | YUVInput(InputFileInfo& info); 65 | 66 | virtual ~YUVInput(); 67 | void release(); 68 | bool isEof() const { return ifs && feof(ifs); } 69 | bool isFail() { return !(ifs && !ferror(ifs) && threadActive); } 70 | void startReader(); 71 | 72 | bool readPicture(x265_picture&); 73 | 74 | const char *getName() const { return "yuv"; } 75 | 76 | int getWidth() const { return width; } 77 | 78 | int getHeight() const { return height; } 79 | }; 80 | } 81 | 82 | #endif // ifndef X265_YUV_H 83 | -------------------------------------------------------------------------------- /source/output/output.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * Xinyue Lu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program 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 General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 20 | * 21 | * This program is also available under a commercial proprietary license. 22 | * For more information, contact us at license @ x265.com. 23 | *****************************************************************************/ 24 | 25 | #include "output.h" 26 | #include "yuv.h" 27 | #include "y4m.h" 28 | 29 | #include "raw.h" 30 | 31 | using namespace X265_NS; 32 | 33 | ReconFile* ReconFile::open(const char *fname, int width, int height, uint32_t bitdepth, uint32_t fpsNum, uint32_t fpsDenom, int csp) 34 | { 35 | const char * s = strrchr(fname, '.'); 36 | 37 | if (s && !strcmp(s, ".y4m")) 38 | return new Y4MOutput(fname, width, height, fpsNum, fpsDenom, csp); 39 | else 40 | return new YUVOutput(fname, width, height, bitdepth, csp); 41 | } 42 | 43 | OutputFile* OutputFile::open(const char *fname, InputFileInfo& inputInfo) 44 | { 45 | return new RAWOutput(fname, inputInfo); 46 | } 47 | -------------------------------------------------------------------------------- /source/output/output.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * Xinyue Lu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program 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 General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 20 | * 21 | * This program is also available under a commercial proprietary license. 22 | * For more information, contact us at license @ x265.com. 23 | *****************************************************************************/ 24 | 25 | #ifndef X265_OUTPUT_H 26 | #define X265_OUTPUT_H 27 | 28 | #include "x265.h" 29 | #include "input/input.h" 30 | 31 | namespace X265_NS { 32 | // private x265 namespace 33 | 34 | class ReconFile 35 | { 36 | protected: 37 | 38 | virtual ~ReconFile() {} 39 | 40 | public: 41 | 42 | ReconFile() {} 43 | 44 | static ReconFile* open(const char *fname, int width, int height, uint32_t bitdepth, 45 | uint32_t fpsNum, uint32_t fpsDenom, int csp); 46 | 47 | virtual bool isFail() const = 0; 48 | 49 | virtual void release() = 0; 50 | 51 | virtual bool writePicture(const x265_picture& pic) = 0; 52 | 53 | virtual const char *getName() const = 0; 54 | }; 55 | 56 | class OutputFile 57 | { 58 | protected: 59 | 60 | virtual ~OutputFile() {} 61 | 62 | public: 63 | 64 | OutputFile() {} 65 | 66 | static OutputFile* open(const char* fname, InputFileInfo& inputInfo); 67 | 68 | virtual bool isFail() const = 0; 69 | 70 | virtual bool needPTS() const = 0; 71 | 72 | virtual void release() = 0; 73 | 74 | virtual const char* getName() const = 0; 75 | 76 | virtual void setParam(x265_param* param) = 0; 77 | 78 | virtual int writeHeaders(const x265_nal* nal, uint32_t nalcount) = 0; 79 | 80 | virtual int writeFrame(const x265_nal* nal, uint32_t nalcount, x265_picture& pic) = 0; 81 | 82 | virtual void closeFile(int64_t largest_pts, int64_t second_largest_pts) = 0; 83 | }; 84 | } 85 | 86 | #endif // ifndef X265_OUTPUT_H 87 | -------------------------------------------------------------------------------- /source/output/raw.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * Xinyue Lu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program 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 General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 20 | * 21 | * This program is also available under a commercial proprietary license. 22 | * For more information, contact us at license @ x265.com. 23 | *****************************************************************************/ 24 | #include "raw.h" 25 | #if _WIN32 26 | #include 27 | #include 28 | #if defined(_MSC_VER) 29 | #pragma warning(disable: 4996) // POSIX setmode and fileno deprecated 30 | #endif 31 | #endif 32 | 33 | using namespace X265_NS; 34 | using namespace std; 35 | RAWOutput::RAWOutput(const char* fname, InputFileInfo&) 36 | { 37 | b_fail = false; 38 | if (!strcmp(fname, "-")) 39 | { 40 | ofs = stdout; 41 | #if _WIN32 42 | setmode(fileno(stdout), O_BINARY); 43 | #endif 44 | return; 45 | } 46 | ofs = x265_fopen(fname, "wb"); 47 | if (!ofs || ferror(ofs)) 48 | b_fail = true; 49 | } 50 | 51 | void RAWOutput::setParam(x265_param* param) 52 | { 53 | param->bAnnexB = true; 54 | } 55 | 56 | int RAWOutput::writeHeaders(const x265_nal* nal, uint32_t nalcount) 57 | { 58 | uint32_t bytes = 0; 59 | 60 | for (uint32_t i = 0; i < nalcount; i++) 61 | { 62 | fwrite((const void*)nal->payload, 1, nal->sizeBytes, ofs); 63 | bytes += nal->sizeBytes; 64 | nal++; 65 | } 66 | 67 | return bytes; 68 | } 69 | 70 | int RAWOutput::writeFrame(const x265_nal* nal, uint32_t nalcount, x265_picture&) 71 | { 72 | uint32_t bytes = 0; 73 | 74 | for (uint32_t i = 0; i < nalcount; i++) 75 | { 76 | fwrite((const void*)nal->payload, 1, nal->sizeBytes, ofs); 77 | bytes += nal->sizeBytes; 78 | nal++; 79 | } 80 | 81 | return bytes; 82 | } 83 | 84 | void RAWOutput::closeFile(int64_t, int64_t) 85 | { 86 | if (ofs != stdout) 87 | fclose(ofs); 88 | } 89 | -------------------------------------------------------------------------------- /source/output/raw.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * Xinyue Lu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program 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 General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 20 | * 21 | * This program is also available under a commercial proprietary license. 22 | * For more information, contact us at license @ x265.com. 23 | *****************************************************************************/ 24 | 25 | #ifndef X265_HEVC_RAW_H 26 | #define X265_HEVC_RAW_H 27 | 28 | #include "output.h" 29 | #include "common.h" 30 | #include 31 | #include 32 | 33 | namespace X265_NS { 34 | class RAWOutput : public OutputFile 35 | { 36 | protected: 37 | 38 | FILE* ofs; 39 | 40 | bool b_fail; 41 | 42 | public: 43 | 44 | RAWOutput(const char* fname, InputFileInfo&); 45 | 46 | bool isFail() const { return b_fail; } 47 | 48 | bool needPTS() const { return false; } 49 | 50 | void release() { delete this; } 51 | 52 | const char* getName() const { return "raw"; } 53 | 54 | void setParam(x265_param* param); 55 | 56 | int writeHeaders(const x265_nal* nal, uint32_t nalcount); 57 | 58 | int writeFrame(const x265_nal* nal, uint32_t nalcount, x265_picture&); 59 | 60 | void closeFile(int64_t largest_pts, int64_t second_largest_pts); 61 | }; 62 | } 63 | 64 | #endif // ifndef X265_HEVC_RAW_H 65 | -------------------------------------------------------------------------------- /source/output/reconplay.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Peixuan Zhang 5 | * Chunli Zhang 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program 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 General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 20 | * 21 | * This program is also available under a commercial proprietary license. 22 | * For more information, contact us at license @ x265.com. 23 | *****************************************************************************/ 24 | 25 | #ifndef X265_RECONPLAY_H 26 | #define X265_RECONPLAY_H 27 | 28 | #include "x265.h" 29 | #include "threading.h" 30 | #include 31 | 32 | namespace X265_NS { 33 | // private x265 namespace 34 | 35 | class ReconPlay : public Thread 36 | { 37 | public: 38 | 39 | ReconPlay(const char* commandLine, x265_param& param); 40 | 41 | virtual ~ReconPlay(); 42 | 43 | bool writePicture(const x265_picture& pic); 44 | 45 | static bool pipeValid; 46 | 47 | protected: 48 | 49 | enum { RECON_BUF_SIZE = 40 }; 50 | 51 | FILE* outputPipe; /* The output pipe for player */ 52 | size_t frameSize; /* size of one frame in pixels */ 53 | bool threadActive; /* worker thread is active */ 54 | int width; /* width of frame */ 55 | int height; /* height of frame */ 56 | int colorSpace; /* color space of frame */ 57 | 58 | int poc[RECON_BUF_SIZE]; 59 | pixel* frameData[RECON_BUF_SIZE]; 60 | 61 | /* Note that the class uses read and write counters to signal that reads and 62 | * writes have occurred in the ring buffer, but writes into the buffer 63 | * happen in decode order and the reader must check that the POC it next 64 | * needs to send to the pipe is in fact present. The counters are used to 65 | * prevent the writer from getting too far ahead of the reader */ 66 | ThreadSafeInteger readCount; 67 | ThreadSafeInteger writeCount; 68 | 69 | void threadMain(); 70 | bool outputFrame(); 71 | }; 72 | } 73 | 74 | #endif // ifndef X265_RECONPLAY_H 75 | -------------------------------------------------------------------------------- /source/output/y4m.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #ifndef X265_Y4M_H 25 | #define X265_Y4M_H 26 | 27 | #include "output.h" 28 | #include 29 | 30 | namespace X265_NS { 31 | // private x265 namespace 32 | 33 | class Y4MOutput : public ReconFile 34 | { 35 | protected: 36 | 37 | int width; 38 | 39 | int height; 40 | 41 | int colorSpace; 42 | 43 | uint32_t frameSize; 44 | 45 | std::ofstream ofs; 46 | 47 | std::ofstream::pos_type header; 48 | 49 | char *buf; 50 | 51 | void writeHeader(); 52 | 53 | public: 54 | 55 | Y4MOutput(const char *filename, int width, int height, uint32_t fpsNum, uint32_t fpsDenom, int csp); 56 | 57 | virtual ~Y4MOutput(); 58 | 59 | const char *getName() const { return "y4m"; } 60 | 61 | bool isFail() const { return ofs.fail(); } 62 | 63 | void release() { delete this; } 64 | 65 | bool writePicture(const x265_picture& pic); 66 | }; 67 | } 68 | 69 | #endif // ifndef X265_Y4M_H 70 | -------------------------------------------------------------------------------- /source/output/yuv.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #include "common.h" 25 | #include "output.h" 26 | #include "yuv.h" 27 | 28 | using namespace X265_NS; 29 | using namespace std; 30 | 31 | YUVOutput::YUVOutput(const char *filename, int w, int h, uint32_t d, int csp) 32 | : width(w) 33 | , height(h) 34 | , depth(d) 35 | , colorSpace(csp) 36 | , frameSize(0) 37 | { 38 | ofs.open(filename, ios::binary | ios::out); 39 | buf = new char[width]; 40 | 41 | for (int i = 0; i < x265_cli_csps[colorSpace].planes; i++) 42 | frameSize += (uint32_t)((width >> x265_cli_csps[colorSpace].width[i]) * (height >> x265_cli_csps[colorSpace].height[i])); 43 | } 44 | 45 | YUVOutput::~YUVOutput() 46 | { 47 | ofs.close(); 48 | delete [] buf; 49 | } 50 | 51 | bool YUVOutput::writePicture(const x265_picture& pic) 52 | { 53 | uint64_t fileOffset = pic.poc; 54 | fileOffset *= frameSize; 55 | 56 | X265_CHECK(pic.colorSpace == colorSpace, "invalid chroma subsampling\n"); 57 | X265_CHECK(pic.bitDepth == (int)depth, "invalid bit depth\n"); 58 | 59 | #if HIGH_BIT_DEPTH 60 | if (depth == 8) 61 | { 62 | int shift = pic.bitDepth - 8; 63 | ofs.seekp((std::streamoff)fileOffset); 64 | for (int i = 0; i < x265_cli_csps[colorSpace].planes; i++) 65 | { 66 | uint16_t *src = (uint16_t*)pic.planes[i]; 67 | for (int h = 0; h < height >> x265_cli_csps[colorSpace].height[i]; h++) 68 | { 69 | for (int w = 0; w < width >> x265_cli_csps[colorSpace].width[i]; w++) 70 | buf[w] = (char)(src[w] >> shift); 71 | 72 | ofs.write(buf, width >> x265_cli_csps[colorSpace].width[i]); 73 | src += pic.stride[i] / sizeof(*src); 74 | } 75 | } 76 | } 77 | else 78 | { 79 | ofs.seekp((std::streamoff)(fileOffset * 2)); 80 | for (int i = 0; i < x265_cli_csps[colorSpace].planes; i++) 81 | { 82 | uint16_t *src = (uint16_t*)pic.planes[i]; 83 | for (int h = 0; h < height >> x265_cli_csps[colorSpace].height[i]; h++) 84 | { 85 | ofs.write((const char*)src, (width * 2) >> x265_cli_csps[colorSpace].width[i]); 86 | src += pic.stride[i] / sizeof(*src); 87 | } 88 | } 89 | } 90 | #else // if HIGH_BIT_DEPTH 91 | ofs.seekp((std::streamoff)fileOffset); 92 | for (int i = 0; i < x265_cli_csps[colorSpace].planes; i++) 93 | { 94 | char *src = (char*)pic.planes[i]; 95 | for (int h = 0; h < height >> x265_cli_csps[colorSpace].height[i]; h++) 96 | { 97 | ofs.write(src, width >> x265_cli_csps[colorSpace].width[i]); 98 | src += pic.stride[i] / sizeof(*src); 99 | } 100 | } 101 | 102 | #endif // if HIGH_BIT_DEPTH 103 | 104 | return true; 105 | } 106 | -------------------------------------------------------------------------------- /source/output/yuv.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #ifndef X265_YUV_H 25 | #define X265_YUV_H 26 | 27 | #include "output.h" 28 | #include "common.h" 29 | 30 | #include 31 | 32 | namespace X265_NS { 33 | // private x265 namespace 34 | 35 | class YUVOutput : public ReconFile 36 | { 37 | protected: 38 | 39 | int width; 40 | 41 | int height; 42 | 43 | uint32_t depth; 44 | 45 | int colorSpace; 46 | 47 | uint32_t frameSize; 48 | 49 | char *buf; 50 | 51 | std::ofstream ofs; 52 | 53 | public: 54 | 55 | YUVOutput(const char *filename, int width, int height, uint32_t bitdepth, int csp); 56 | 57 | virtual ~YUVOutput(); 58 | 59 | const char *getName() const { return "yuv"; } 60 | 61 | bool isFail() const { return ofs.fail(); } 62 | 63 | void release() { delete this; } 64 | 65 | bool writePicture(const x265_picture& pic); 66 | }; 67 | } 68 | 69 | #endif // ifndef X265_YUV_H 70 | -------------------------------------------------------------------------------- /source/profile/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # vim: syntax=cmake 2 | 3 | option(ENABLE_PPA "Enable PPA profiling instrumentation" OFF) 4 | if(ENABLE_PPA) 5 | add_definitions(-DENABLE_PPA) 6 | add_subdirectory(PPA) 7 | list(APPEND PLATFORM_LIBS PPA) 8 | if(UNIX) 9 | list(APPEND PLATFORM_LIBS dl) 10 | endif(UNIX) 11 | endif(ENABLE_PPA) 12 | 13 | option(ENABLE_VTUNE "Enable Vtune profiling instrumentation" OFF) 14 | if(ENABLE_VTUNE) 15 | add_definitions(-DENABLE_VTUNE) 16 | add_subdirectory(vtune) 17 | list(APPEND PLATFORM_LIBS vtune) 18 | include_directories($ENV{VTUNE_AMPLIFIER_XE_2015_DIR}/include) 19 | link_directories($ENV{VTUNE_AMPLIFIER_XE_2015_DIR}/lib64) 20 | if(WIN32) 21 | list(APPEND PLATFORM_LIBS libittnotify.lib) 22 | else() 23 | list(APPEND PLATFORM_LIBS libittnotify.a dl) 24 | endif() 25 | endif(ENABLE_VTUNE) 26 | -------------------------------------------------------------------------------- /source/profile/PPA/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(PPA ppa.h ppaApi.h ppa.cpp ../cpuEvents.h) 2 | -------------------------------------------------------------------------------- /source/profile/PPA/ppa.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #ifndef PPA_H 25 | #define PPA_H 26 | 27 | /* declare enum list of users CPU events */ 28 | #define CPU_EVENT(x) x, 29 | enum PPACpuEventEnum 30 | { 31 | #include "../cpuEvents.h" 32 | PPACpuGroupNums 33 | }; 34 | #undef CPU_EVENT 35 | 36 | #include "ppaApi.h" 37 | 38 | void initializePPA(); 39 | 40 | #define PPA_INIT() initializePPA() 41 | #define PPAScopeEvent(e) ppa::ProfileScope ppaScope_(e) 42 | 43 | #endif /* PPA_H */ 44 | -------------------------------------------------------------------------------- /source/profile/PPA/ppaApi.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #ifndef _PPA_API_H_ 25 | #define _PPA_API_H_ 26 | 27 | namespace ppa { 28 | // PPA private namespace 29 | 30 | typedef unsigned short EventID; 31 | typedef unsigned char GroupID; 32 | 33 | class Base 34 | { 35 | public: 36 | 37 | virtual ~Base() {} 38 | 39 | virtual bool isEventFiltered(EventID eventId) const = 0; 40 | virtual bool configEventById(EventID eventId, bool filtered) const = 0; 41 | virtual int configGroupById(GroupID groupId, bool filtered) const = 0; 42 | virtual void configAllEvents(bool filtered) const = 0; 43 | virtual EventID registerEventByName(const char *pEventName) = 0; 44 | virtual GroupID registerGroupByName(const char *pGroupName) = 0; 45 | virtual EventID registerEventInGroup(const char *pEventName, GroupID groupId) = 0; 46 | virtual void triggerStartEvent(EventID eventId) = 0; 47 | virtual void triggerEndEvent(EventID eventId) = 0; 48 | virtual void triggerTidEvent(EventID eventId, unsigned int data) = 0; 49 | virtual void triggerDebugEvent(EventID eventId, unsigned int data0, unsigned int data1) = 0; 50 | 51 | virtual EventID getEventId(int index) const = 0; 52 | 53 | protected: 54 | 55 | virtual void init(const char **pNames, int eventCount) = 0; 56 | }; 57 | 58 | extern ppa::Base *ppabase; 59 | 60 | struct ProfileScope 61 | { 62 | ppa::EventID id; 63 | 64 | ProfileScope(int e) { if (ppabase) { id = ppabase->getEventId(e); ppabase->triggerStartEvent(id); } else id = 0; } 65 | ~ProfileScope() { if (ppabase) ppabase->triggerEndEvent(id); } 66 | }; 67 | 68 | } 69 | 70 | #endif //_PPA_API_H_ 71 | -------------------------------------------------------------------------------- /source/profile/cpuEvents.h: -------------------------------------------------------------------------------- 1 | CPU_EVENT(frameRead) 2 | CPU_EVENT(bitstreamWrite) 3 | CPU_EVENT(frameThread) 4 | CPU_EVENT(encodeCTU) 5 | CPU_EVENT(filterCTURow) 6 | CPU_EVENT(slicetypeDecideEV) 7 | CPU_EVENT(prelookahead) 8 | CPU_EVENT(estCostSingle) 9 | CPU_EVENT(estCostCoop) 10 | CPU_EVENT(pmode) 11 | CPU_EVENT(pme) 12 | -------------------------------------------------------------------------------- /source/profile/vtune/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${VTUNE_INCLUDE_DIR}) 2 | add_library(vtune vtune.h vtune.cpp ../cpuEvents.h) 3 | -------------------------------------------------------------------------------- /source/profile/vtune/vtune.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #include "vtune.h" 25 | #include 26 | 27 | namespace { 28 | 29 | #define CPU_EVENT(x) #x, 30 | const char *stringNames[] = 31 | { 32 | #include "../cpuEvents.h" 33 | }; 34 | #undef CPU_EVENT 35 | 36 | } 37 | 38 | namespace X265_NS { 39 | 40 | __itt_domain* domain; 41 | __itt_string_handle* taskHandle[NUM_VTUNE_TASKS]; 42 | 43 | void vtuneInit() 44 | { 45 | domain = __itt_domain_create("x265"); 46 | size_t length = sizeof(stringNames) / sizeof(const char *); 47 | for (size_t i = 0; i < length; i++) 48 | taskHandle[i] = __itt_string_handle_create(stringNames[i]); 49 | } 50 | 51 | void vtuneSetThreadName(const char *name, int id) 52 | { 53 | char threadname[128]; 54 | sprintf(threadname, "%s %d", name, id); 55 | __itt_thread_set_name(threadname); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /source/profile/vtune/vtune.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #ifndef VTUNE_H 25 | #define VTUNE_H 26 | 27 | #include "ittnotify.h" 28 | 29 | namespace X265_NS { 30 | 31 | #define CPU_EVENT(x) x, 32 | enum VTuneTasksEnum 33 | { 34 | #include "../cpuEvents.h" 35 | NUM_VTUNE_TASKS 36 | }; 37 | #undef CPU_EVENT 38 | 39 | extern __itt_domain* domain; 40 | extern __itt_string_handle* taskHandle[NUM_VTUNE_TASKS]; 41 | 42 | struct VTuneScopeEvent 43 | { 44 | VTuneScopeEvent(int e) { __itt_task_begin(domain, __itt_null, __itt_null, taskHandle[e]); } 45 | ~VTuneScopeEvent() { __itt_task_end(domain); } 46 | }; 47 | 48 | void vtuneInit(); 49 | void vtuneSetThreadName(const char *name, int id); 50 | 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /source/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # vim: syntax=cmake 2 | 3 | check_symbol_exists(__rdtsc "intrin.h" HAVE_RDTSC) 4 | if(HAVE_RDTSC) 5 | add_definitions(-DHAVE_RDTSC=1) 6 | endif() 7 | 8 | # add X86 assembly files 9 | if(X86) 10 | enable_language(ASM_NASM) 11 | 12 | if(MSVC_IDE) 13 | set(NASM_SRC checkasm-a.obj) 14 | add_custom_command( 15 | OUTPUT checkasm-a.obj 16 | COMMAND ${NASM_EXECUTABLE} 17 | ARGS ${NASM_FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/checkasm-a.asm -o checkasm-a.obj 18 | DEPENDS checkasm-a.asm) 19 | else() 20 | set(NASM_SRC checkasm-a.asm) 21 | endif() 22 | endif(X86) 23 | 24 | # add ARM assembly files 25 | if(ARM OR CROSS_COMPILE_ARM) 26 | if(NOT ARM64) 27 | enable_language(ASM) 28 | set(NASM_SRC checkasm-arm.S) 29 | add_custom_command( 30 | OUTPUT checkasm-arm.obj 31 | COMMAND ${CMAKE_CXX_COMPILER} 32 | ARGS ${NASM_FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/checkasm-arm.S -o checkasm-arm.obj 33 | DEPENDS checkasm-arm.S) 34 | endif() 35 | endif(ARM OR CROSS_COMPILE_ARM) 36 | 37 | # add PowerPC assembly files 38 | if(POWER) 39 | set(NASM_SRC) 40 | endif(POWER) 41 | 42 | add_executable(TestBench ${NASM_SRC} 43 | testbench.cpp testharness.h 44 | pixelharness.cpp pixelharness.h 45 | mbdstharness.cpp mbdstharness.h 46 | ipfilterharness.cpp ipfilterharness.h 47 | intrapredharness.cpp intrapredharness.h) 48 | 49 | target_link_libraries(TestBench x265-static ${PLATFORM_LIBS}) 50 | if(LINKER_OPTIONS) 51 | if(EXTRA_LIB) 52 | list(APPEND LINKER_OPTIONS "-L..") 53 | endif(EXTRA_LIB) 54 | string(REPLACE ";" " " LINKER_OPTION_STR "${LINKER_OPTIONS}") 55 | set_target_properties(TestBench PROPERTIES LINK_FLAGS "${LINKER_OPTION_STR}") 56 | endif() 57 | -------------------------------------------------------------------------------- /source/test/checkasm-arm.S: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * checkasm-arm.S: assembly check tool 3 | ***************************************************************************** 4 | * Copyright (C) 2013-2020 MulticoreWare, Inc 5 | * 6 | * Authors: Martin Storsjo 7 | * Dnyaneshwar Gorade 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 22 | * 23 | * This program is also available under a commercial proprietary license. 24 | * For more information, contact us at license @ x265.com. 25 | *****************************************************************************/ 26 | 27 | #include "../common/arm/asm.S" 28 | 29 | .section .rodata 30 | .align 4 31 | register_init: 32 | .quad 0x21f86d66c8ca00ce 33 | .quad 0x75b6ba21077c48ad 34 | .quad 0xed56bb2dcb3c7736 35 | .quad 0x8bda43d3fd1a7e06 36 | .quad 0xb64a9c9e5d318408 37 | .quad 0xdf9a54b303f1d3a3 38 | .quad 0x4a75479abd64e097 39 | .quad 0x249214109d5d1c88 40 | 41 | error_message: 42 | .asciz "failed to preserve register" 43 | 44 | .text 45 | 46 | @ max number of args used by any x265 asm function. 47 | #define MAX_ARGS 15 48 | 49 | #define ARG_STACK 4*(MAX_ARGS - 2) 50 | 51 | .macro clobbercheck variant 52 | .equ pushed, 4*10 53 | function x265_checkasm_call_\variant 54 | push {r4-r11, lr} 55 | .ifc \variant, neon 56 | vpush {q4-q7} 57 | .equ pushed, pushed + 16*4 58 | .endif 59 | 60 | movrel r12, register_init 61 | .ifc \variant, neon 62 | vldm r12, {q4-q7} 63 | .endif 64 | ldm r12, {r4-r11} 65 | 66 | push {r1} 67 | 68 | sub sp, sp, #ARG_STACK 69 | .equ pos, 0 70 | .rept MAX_ARGS-2 71 | ldr r12, [sp, #ARG_STACK + pushed + 8 + pos] 72 | str r12, [sp, #pos] 73 | .equ pos, pos + 4 74 | .endr 75 | 76 | mov r12, r0 77 | mov r0, r2 78 | mov r1, r3 79 | ldrd r2, r3, [sp, #ARG_STACK + pushed] 80 | blx r12 81 | add sp, sp, #ARG_STACK 82 | pop {r2} 83 | 84 | push {r0, r1} 85 | movrel r12, register_init 86 | .ifc \variant, neon 87 | vldm r12, {q0-q3} 88 | veor q0, q0, q4 89 | veor q1, q1, q5 90 | veor q2, q2, q6 91 | veor q3, q3, q7 92 | vorr q0, q0, q1 93 | vorr q0, q0, q2 94 | vorr q0, q0, q3 95 | vorr d0, d0, d1 96 | vrev64.32 d1, d0 97 | vorr d0, d0, d1 98 | vmov.32 r3, d0[0] 99 | .else 100 | mov r3, #0 101 | .endif 102 | 103 | .macro check_reg reg1, reg2 104 | ldrd r0, r1, [r12], #8 105 | eor r0, r0, \reg1 106 | eor r1, r1, \reg2 107 | orr r3, r3, r0 108 | orr r3, r3, r1 109 | .endm 110 | check_reg r4, r5 111 | check_reg r6, r7 112 | check_reg r8, r9 113 | check_reg r10, r11 114 | .purgem check_reg 115 | 116 | cmp r3, #0 117 | beq 0f 118 | 119 | mov r12, #0 120 | str r12, [r2] 121 | movrel r0, error_message 122 | bl puts 123 | 0: 124 | pop {r0, r1} 125 | .ifc \variant, neon 126 | vpop {q4-q7} 127 | .endif 128 | pop {r4-r11, pc} 129 | endfunc 130 | .endm 131 | 132 | clobbercheck neon 133 | clobbercheck noneon 134 | -------------------------------------------------------------------------------- /source/test/intrapredharness.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Min Chen 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #ifndef _INTRAPREDHARNESS_H_1 25 | #define _INTRAPREDHARNESS_H_1 1 26 | 27 | #include "testharness.h" 28 | #include "primitives.h" 29 | 30 | class IntraPredHarness : public TestHarness 31 | { 32 | protected: 33 | 34 | enum { INPUT_SIZE = 4 * 65 * 65 * 100 }; 35 | enum { OUTPUT_SIZE = 64 * FENC_STRIDE }; 36 | enum { OUTPUT_SIZE_33 = 33 * OUTPUT_SIZE }; 37 | enum { TEST_CASES = 3 }; 38 | enum { INCR = 32 }; 39 | enum { STRIDE = 64 }; 40 | enum { ITERS = 100 }; 41 | enum { MAX_HEIGHT = 64 }; 42 | enum { PAD_ROWS = 64 }; 43 | enum { BUFFSIZE = STRIDE * (MAX_HEIGHT + PAD_ROWS) + INCR * ITERS }; 44 | 45 | pixel pixel_test_buff[TEST_CASES][BUFFSIZE]; 46 | ALIGN_VAR_16(pixel, pixel_buff[INPUT_SIZE]); 47 | pixel pixel_out_c[OUTPUT_SIZE]; 48 | pixel pixel_out_vec[OUTPUT_SIZE]; 49 | pixel pixel_out_33_c[OUTPUT_SIZE_33]; 50 | pixel pixel_out_33_vec[OUTPUT_SIZE_33]; 51 | 52 | bool check_dc_primitive(intra_pred_t ref, intra_pred_t opt, int width); 53 | bool check_planar_primitive(intra_pred_t ref, intra_pred_t opt, int width); 54 | bool check_angular_primitive(const intra_pred_t ref[], const intra_pred_t opt[], int size); 55 | bool check_allangs_primitive(const intra_allangs_t ref, const intra_allangs_t opt, int size); 56 | bool check_intra_filter_primitive(const intra_filter_t ref, const intra_filter_t opt); 57 | 58 | public: 59 | 60 | IntraPredHarness(); 61 | 62 | const char *getName() const { return "intrapred"; } 63 | 64 | bool testCorrectness(const EncoderPrimitives& ref, const EncoderPrimitives& opt); 65 | 66 | void measureSpeed(const EncoderPrimitives& ref, const EncoderPrimitives& opt); 67 | }; 68 | 69 | #endif // ifndef _INTRAPREDHARNESS_H_1 70 | -------------------------------------------------------------------------------- /source/test/ipfilterharness.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Deepthi Devaki , 5 | * Rajesh Paulraj 6 | * Praveen Kumar Tiwari 7 | * Min Chen 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 22 | * 23 | * This program is also available under a commercial proprietary license. 24 | * For more information, contact us at license @ x265.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef _IPFILTERHARNESS_H_1 28 | #define _IPFILTERHARNESS_H_1 1 29 | 30 | #include "testharness.h" 31 | #include "primitives.h" 32 | 33 | class IPFilterHarness : public TestHarness 34 | { 35 | protected: 36 | 37 | // Assuming max_height = max_width = max_srcStride = max_dstStride = 100 38 | enum { TEST_BUF_SIZE = 200 * 200 }; 39 | enum { ITERS = 100 }; 40 | enum { TEST_CASES = 3 }; 41 | enum { SMAX = 1 << 12 }; 42 | enum { SMIN = (unsigned)-1 << 12 }; 43 | ALIGN_VAR_64(pixel, pixel_buff[TEST_BUF_SIZE]); 44 | ALIGN_VAR_64(int16_t, short_buff[TEST_BUF_SIZE]); 45 | ALIGN_VAR_64(int16_t, IPF_vec_output_s[TEST_BUF_SIZE]); 46 | ALIGN_VAR_64(int16_t, IPF_C_output_s[TEST_BUF_SIZE]); 47 | ALIGN_VAR_64(pixel, IPF_vec_output_p[TEST_BUF_SIZE]); 48 | ALIGN_VAR_64(pixel, IPF_C_output_p[TEST_BUF_SIZE]); 49 | 50 | ALIGN_VAR_64(pixel, pixel_test_buff[TEST_CASES][TEST_BUF_SIZE]); 51 | ALIGN_VAR_64(int16_t, short_test_buff[TEST_CASES][TEST_BUF_SIZE]); 52 | 53 | bool check_IPFilterChroma_primitive(filter_pp_t ref, filter_pp_t opt); 54 | bool check_IPFilterChroma_ps_primitive(filter_ps_t ref, filter_ps_t opt); 55 | bool check_IPFilterChroma_hps_primitive(filter_hps_t ref, filter_hps_t opt); 56 | bool check_IPFilterChroma_sp_primitive(filter_sp_t ref, filter_sp_t opt); 57 | bool check_IPFilterChroma_ss_primitive(filter_ss_t ref, filter_ss_t opt); 58 | bool check_IPFilterLuma_primitive(filter_pp_t ref, filter_pp_t opt); 59 | bool check_IPFilterLuma_ps_primitive(filter_ps_t ref, filter_ps_t opt); 60 | bool check_IPFilterLuma_hps_primitive(filter_hps_t ref, filter_hps_t opt); 61 | bool check_IPFilterLuma_sp_primitive(filter_sp_t ref, filter_sp_t opt); 62 | bool check_IPFilterLuma_ss_primitive(filter_ss_t ref, filter_ss_t opt); 63 | bool check_IPFilterLumaHV_primitive(filter_hv_pp_t ref, filter_hv_pp_t opt); 64 | bool check_IPFilterLumaP2S_primitive(filter_p2s_t ref, filter_p2s_t opt); 65 | bool check_IPFilterLumaP2S_aligned_primitive(filter_p2s_t ref, filter_p2s_t opt); 66 | bool check_IPFilterChromaP2S_primitive(filter_p2s_t ref, filter_p2s_t opt); 67 | bool check_IPFilterChromaP2S_aligned_primitive(filter_p2s_t ref, filter_p2s_t opt); 68 | 69 | public: 70 | 71 | IPFilterHarness(); 72 | 73 | const char *getName() const { return "interp"; } 74 | 75 | bool testCorrectness(const EncoderPrimitives& ref, const EncoderPrimitives& opt); 76 | 77 | void measureSpeed(const EncoderPrimitives& ref, const EncoderPrimitives& opt); 78 | }; 79 | 80 | #endif // ifndef _FILTERHARNESS_H_1 81 | -------------------------------------------------------------------------------- /source/test/mbdstharness.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * Min Chen 6 | * Praveen Kumar Tiwari 7 | * Nabajit Deka 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 22 | * 23 | * This program is also available under a commercial proprietary license. 24 | * For more information, contact us at license @ x265.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef _MBDSTHARNESS_H_1 28 | #define _MBDSTHARNESS_H_1 1 29 | 30 | #include "testharness.h" 31 | #include "primitives.h" 32 | 33 | class MBDstHarness : public TestHarness 34 | { 35 | protected: 36 | 37 | enum { ITERS = 128 }; 38 | enum { INCR = 16 }; 39 | enum { MAX_TU_SIZE = 32 * 32 }; 40 | enum { TEST_BUF_SIZE = MAX_TU_SIZE + ITERS * INCR }; 41 | enum { TEST_CASES = 3 }; 42 | 43 | ALIGN_VAR_32(int16_t, mbuf1[TEST_BUF_SIZE]); 44 | int16_t mbufdct[TEST_BUF_SIZE]; 45 | int mbufidct[TEST_BUF_SIZE]; 46 | 47 | int16_t mshortbuf2[MAX_TU_SIZE]; 48 | int16_t mshortbuf3[MAX_TU_SIZE]; 49 | 50 | int mintbuf1[MAX_TU_SIZE]; 51 | int mintbuf2[MAX_TU_SIZE]; 52 | int mintbuf3[MAX_TU_SIZE]; 53 | int mintbuf4[MAX_TU_SIZE]; 54 | int16_t short_test_buff[TEST_CASES][TEST_BUF_SIZE]; 55 | int16_t short_test_buff1[TEST_CASES][TEST_BUF_SIZE]; 56 | int int_test_buff[TEST_CASES][TEST_BUF_SIZE]; 57 | int int_idct_test_buff[TEST_CASES][TEST_BUF_SIZE]; 58 | uint32_t mubuf1[MAX_TU_SIZE]; 59 | uint32_t mubuf2[MAX_TU_SIZE]; 60 | uint16_t mushortbuf1[MAX_TU_SIZE]; 61 | 62 | int16_t short_denoise_test_buff1[TEST_CASES][TEST_BUF_SIZE]; 63 | int16_t short_denoise_test_buff2[TEST_CASES][TEST_BUF_SIZE]; 64 | bool check_dequant_primitive(dequant_scaling_t ref, dequant_scaling_t opt); 65 | bool check_dequant_primitive(dequant_normal_t ref, dequant_normal_t opt); 66 | bool check_nonPsyRdoQuant_primitive(nonPsyRdoQuant_t ref, nonPsyRdoQuant_t opt); 67 | bool check_psyRdoQuant_primitive(psyRdoQuant_t ref, psyRdoQuant_t opt); 68 | bool check_quant_primitive(quant_t ref, quant_t opt); 69 | bool check_nquant_primitive(nquant_t ref, nquant_t opt); 70 | bool check_dct_primitive(dct_t ref, dct_t opt, intptr_t width); 71 | bool check_idct_primitive(idct_t ref, idct_t opt, intptr_t width); 72 | bool check_count_nonzero_primitive(count_nonzero_t ref, count_nonzero_t opt); 73 | bool check_denoise_dct_primitive(denoiseDct_t ref, denoiseDct_t opt); 74 | bool check_psyRdoQuant_primitive_avx2(psyRdoQuant_t1 ref, psyRdoQuant_t1 opt); 75 | 76 | public: 77 | 78 | MBDstHarness(); 79 | 80 | const char *getName() const { return "transforms"; } 81 | 82 | bool testCorrectness(const EncoderPrimitives& ref, const EncoderPrimitives& opt); 83 | 84 | void measureSpeed(const EncoderPrimitives& ref, const EncoderPrimitives& opt); 85 | }; 86 | 87 | #endif // ifndef _MBDSTHARNESS_H_1 88 | -------------------------------------------------------------------------------- /source/test/smoke-tests.txt: -------------------------------------------------------------------------------- 1 | # List of command lines to be run by smoke tests, see https://bitbucket.org/sborho/test-harness 2 | 3 | # consider VBV tests a failure if new bitrate is more than 5% different 4 | # from the old bitrate 5 | # vbv-tolerance = 0.05 6 | big_buck_bunny_360p24.y4m,--preset=superfast --bitrate 400 --vbv-bufsize 600 --vbv-maxrate 400 --hrd --aud --repeat-headers 7 | big_buck_bunny_360p24.y4m,--preset=medium --bitrate 1000 -F4 --cu-lossless --scaling-list default 8 | big_buck_bunny_360p24.y4m,--preset=slower --no-weightp --qg-size 16 9 | washdc_422_ntsc.y4m,--preset=faster --no-strong-intra-smoothing --keyint 1 --qg-size 16 10 | washdc_422_ntsc.y4m,--preset=medium --qp 40 --nr-inter 400 -F4 11 | washdc_422_ntsc.y4m,--preset=veryslow --pmode --tskip --rdoq-level 0 12 | old_town_cross_444_720p50.y4m,--preset=ultrafast --weightp --keyint -1 13 | old_town_cross_444_720p50.y4m,--preset=fast --keyint 20 --min-cu-size 16 14 | old_town_cross_444_720p50.y4m,--preset=slow --sao-non-deblock --pmode --qg-size 32 15 | RaceHorses_416x240_30_10bit.yuv,--preset=veryfast --max-tu-size 8 16 | RaceHorses_416x240_30_10bit.yuv,--preset=slower --bitrate 500 -F4 --rdoq-level 1 17 | CrowdRun_1920x1080_50_10bit_444.yuv,--preset=ultrafast --constrained-intra --min-keyint 5 --keyint 10 18 | CrowdRun_1920x1080_50_10bit_444.yuv,--preset=medium --max-tu-size 16 --tu-inter-depth 2 --limit-tu 3 19 | DucksAndLegs_1920x1080_60_10bit_422.yuv,--preset=veryfast --min-cu 16 20 | DucksAndLegs_1920x1080_60_10bit_422.yuv,--preset=fast --weightb --interlace bff 21 | DucksAndLegs_1920x1080_60_10bit_422.yuv,--preset=veryslow --limit-ref 1 --limit-mode --tskip --limit-tu 1 22 | CrowdRun_1920x1080_50_10bit_444.yuv,--preset=superfast --bitrate 7000 --sao --limit-sao 23 | # Main12 intraCost overflow bug test 24 | 720p50_parkrun_ter.y4m,--preset medium 25 | 720p50_parkrun_ter.y4m,--preset=fast --hevc-aq --no-cutree 26 | -------------------------------------------------------------------------------- /source/x265.def.in: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | x265_encoder_open_${X265_BUILD} 3 | x265_param_default 4 | x265_param_default_preset 5 | x265_param_parse 6 | x265_param_alloc 7 | x265_param_free 8 | x265_picture_init 9 | x265_picture_alloc 10 | x265_picture_free 11 | x265_param_apply_profile 12 | x265_max_bit_depth 13 | x265_version_str 14 | x265_build_info_str 15 | x265_encoder_headers 16 | x265_encoder_parameters 17 | x265_encoder_reconfig 18 | x265_encoder_encode 19 | x265_encoder_get_stats 20 | x265_encoder_log 21 | x265_encoder_close 22 | x265_cleanup 23 | x265_api_get_${X265_BUILD} 24 | x265_api_query 25 | x265_encoder_intra_refresh 26 | x265_encoder_ctu_info 27 | x265_get_slicetype_poc_and_scenecut 28 | x265_get_ref_frame_list 29 | x265_csvlog_open 30 | x265_csvlog_frame 31 | x265_csvlog_encode 32 | x265_dither_image 33 | x265_set_analysis_data 34 | -------------------------------------------------------------------------------- /source/x265.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/@LIB_INSTALL_DIR@ 4 | includedir=${prefix}/include 5 | 6 | Name: @CMAKE_PROJECT_NAME@ 7 | Description: H.265/HEVC video encoder 8 | Version: @X265_LATEST_TAG@ 9 | Libs: -L${libdir} -lx265 10 | Libs.private: @PRIVATE_LIBS@ 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /source/x265.rc.in: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | VS_VERSION_INFO VERSIONINFO 4 | FILEVERSION @X265_VERSION_MAJOR@,@X265_VERSION_MINOR@,@X265_BRANCH_ID@,@X265_TAG_DISTANCE@ 5 | PRODUCTVERSION @X265_VERSION_MAJOR@,@X265_VERSION_MINOR@,@X265_BRANCH_ID@,@X265_TAG_DISTANCE@ 6 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 7 | FILEOS VOS_NT_WINDOWS32 8 | #ifdef OPENOBEX_EXPORTS 9 | FILETYPE VFT_DLL 10 | #else 11 | FILETYPE VFT_STATIC_LIB 12 | #endif 13 | FILESUBTYPE VFT2_UNKNOWN 14 | BEGIN 15 | BLOCK "StringFileInfo" 16 | BEGIN 17 | BLOCK "04090000" 18 | BEGIN 19 | VALUE "FileDescription", "HEVC video encoder" 20 | VALUE "FileVersion", "@X265_VERSION@" 21 | VALUE "InternalName", "x265" 22 | VALUE "LegalCopyright", "Multicoreware: GPLv2 or commercial" 23 | VALUE "OriginalFilename", "libx265.dll" 24 | VALUE "ProductName", "x265" 25 | VALUE "ProductVersion", "@X265_VERSION@" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x409, 1200 31 | END 32 | END 33 | -------------------------------------------------------------------------------- /source/x265_config.h.in: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2020 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program 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 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | * 20 | * This program is also available under a commercial proprietary license. 21 | * For more information, contact us at license @ x265.com. 22 | *****************************************************************************/ 23 | 24 | #ifndef X265_CONFIG_H 25 | #define X265_CONFIG_H 26 | 27 | /* Defines generated at build time */ 28 | 29 | /* Incremented each time public API is changed, X265_BUILD is used as 30 | * the shared library SONAME on platforms which support it. It also 31 | * prevents linking against a different version of the static lib */ 32 | #define X265_BUILD ${X265_BUILD} 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /x265Version.txt: -------------------------------------------------------------------------------- 1 | #Attribute: Values 2 | repositorychangeset: 5163c32d7 3 | releasetagcommitid: a4f320054 4 | releasetagdistance: 28 5 | releasetag: 3.4 6 | --------------------------------------------------------------------------------