├── .github ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .hgignore ├── .hgtags ├── .readthedocs.yaml ├── COPYING ├── README.markdown ├── SMP ├── .gitattributes ├── .gitignore ├── SMP.patch ├── appveyor.yml ├── libx265.def ├── libx265.vcxproj ├── libx265.vcxproj.filters ├── libx265_files.props ├── libx265_winrt.vcxproj ├── libx265_winrt.vcxproj.filters ├── libx265_with_latest_sdk.bat ├── libx265bit.vcxproj ├── libx265bit.vcxproj.filters ├── libx265bit_winrt.vcxproj ├── libx265bit_winrt.vcxproj.filters ├── readme.txt ├── smp.props ├── smp_winrt.props ├── x265.rc ├── x265.sln ├── x265_config.h ├── x265cli.vcxproj └── x265cli.vcxproj.filters ├── build ├── README.txt ├── aarch64-darwin │ ├── crosscompile.cmake │ └── make-Makefiles.bash ├── aarch64-linux-clang │ └── crosscompile.cmake ├── 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 ├── vc17-x86 │ ├── build-all.bat │ └── make-solutions.bat ├── vc17-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 ├── requirements.txt └── uncrustify │ └── codingstyle.cfg ├── readme.rst ├── source ├── CMakeLists.txt ├── abrEncApp.cpp ├── abrEncApp.h ├── cmake │ ├── CMakeASM_NASMInformation.cmake │ ├── CMakeDetermineASM_NASMCompiler.cmake │ ├── CMakeTestASM_NASMCompiler.cmake │ ├── FindNEON_DOTPROD.cmake │ ├── FindNEON_I8MM.cmake │ ├── FindNasm.cmake │ ├── FindNeon.cmake │ ├── FindNuma.cmake │ ├── FindSVE.cmake │ ├── FindSVE2.cmake │ ├── FindVLD.cmake │ ├── FindVtune.cmake │ ├── Findsvthevc.cmake │ ├── Version.cmake │ ├── clean-generated.cmake │ └── cmake_uninstall.cmake.in ├── common │ ├── CMakeLists.txt │ ├── aarch64 │ │ ├── arm64-utils.cpp │ │ ├── arm64-utils.h │ │ ├── asm-primitives.cpp │ │ ├── asm-sve.S │ │ ├── asm.S │ │ ├── blockcopy8-common.S │ │ ├── blockcopy8-sve.S │ │ ├── blockcopy8.S │ │ ├── dct-prim-sve.cpp │ │ ├── dct-prim.cpp │ │ ├── dct-prim.h │ │ ├── dct.S │ │ ├── filter-neon-dotprod.cpp │ │ ├── filter-neon-dotprod.h │ │ ├── filter-neon-i8mm.cpp │ │ ├── filter-neon-i8mm.h │ │ ├── filter-prim.cpp │ │ ├── filter-prim.h │ │ ├── fun-decls.h │ │ ├── intrapred-prim.cpp │ │ ├── intrapred-prim.h │ │ ├── intrapred.S │ │ ├── loopfilter-prim.cpp │ │ ├── loopfilter-prim.h │ │ ├── mc-a-common.S │ │ ├── mc-a-sve2.S │ │ ├── mc-a.S │ │ ├── mem-neon.h │ │ ├── neon-sve-bridge.h │ │ ├── p2s-common.S │ │ ├── p2s-sve.S │ │ ├── p2s.S │ │ ├── pixel-prim.cpp │ │ ├── pixel-prim.h │ │ ├── pixel-util-common.S │ │ ├── pixel-util-sve.S │ │ ├── pixel-util-sve2.S │ │ ├── pixel-util.S │ │ ├── sad-a.S │ │ ├── sad-neon-dotprod.S │ │ ├── sao-prim-sve.cpp │ │ ├── sao-prim-sve2.cpp │ │ ├── sao-prim.cpp │ │ ├── sao-prim.h │ │ ├── ssd-a-common.S │ │ ├── ssd-a-sve2.S │ │ ├── ssd-a.S │ │ └── ssd-neon-dotprod.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 │ ├── ringmem.cpp │ ├── ringmem.h │ ├── scaler.cpp │ ├── scaler.h │ ├── scalinglist.cpp │ ├── scalinglist.h │ ├── shortyuv.cpp │ ├── shortyuv.h │ ├── slice.cpp │ ├── slice.h │ ├── temporalfilter.cpp │ ├── temporalfilter.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 /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Context 4 | 5 | 6 | ## Expected Behavior 7 | 8 | 9 | ## Actual Behavior 10 | 11 | 12 | ## Steps to Reproduce 13 | 14 | 1. 15 | 2. 16 | 3. 17 | 4. 18 | 19 | ## Your Environment 20 | 21 | * Version Used: 22 | * Operating System and Version: 23 | * Compiler and Version(s): 24 | 25 | ## Possible Fix 26 | 27 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Context 4 | 5 | 6 | ## Current and Suggested Behavior 7 | 8 | 9 | ## Steps to Explain Enhancement 10 | 11 | 1. 12 | 2. 13 | 3. 14 | 4. 15 | 16 | ## Your Test Environment 17 | 18 | * Version Used: 19 | * Operating System and Version(s): 20 | * Compiler and version(s): -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # Build directory 35 | build/ 36 | 37 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.hgtags: -------------------------------------------------------------------------------- 1 | 99fab2ef92be051cd3b3b2d817064cead282b42c 0.1 2 | b3471d9009f5cd487b23c8c61a6bfff8980e54f2 0.2 3 | 3767fbfa970ff4b2dc2e8647db0274168727147e 0.3 4 | 2ba6ec553f218d2b06ad803b87d6ec751fd639f7 0.4 5 | 93707bc4fccdaa89a1f2da11db8808ca912a691c 0.4.1 6 | 69acb3cb777f977f5edde908069ac565915dd366 0.5 7 | b970ffbdd696e3ce45c93b315902eb6366ff085e 0.6 8 | d24e2a8c4326b0cd01bfa6c414c5378481af9018 0.7 9 | 527d03c56d6860dc979ddea1196f7e94d13d3e82 0.8 10 | 82bbd2bf3b49ba086be0f0922f91fe0084896351 0.9 11 | cea97c4d79456842e00ade6be6fd5ec34610e5f8 1.0 12 | ae9609aeebdc3271114168ece003679e9b1dca1b 1.1 13 | d6257335c5370ee54317a0426a12c1f0724b18b9 1.2 14 | c1e4fc0162c14fdb84f5c3bd404fb28cfe10a17f 1.3 15 | 5e604833c5aa605d0b6efbe5234492b5e7d8ac61 1.4 16 | 9f0324125f53a12f766f6ed6f98f16e2f42337f4 1.5 17 | cbeb7d8a4880e4020c4545dd8e498432c3c6cad3 1.6 18 | 8425278def1edf0931dc33fc518e1950063e76b0 1.7 19 | e27327f5da35c5feb660360336fdc94bd0afe719 1.8 20 | 1d3b6e448e01ec40b392ef78b7e55a86249fbe68 1.9 21 | 960c9991d0dcf46559c32e070418d3cbb7e8aa2f 2.0 22 | 981e3bfef16a997bce6f46ce1b15631a0e234747 2.1 23 | be14a7e9755e54f0fd34911c72bdfa66981220bc 2.2 24 | 3037c1448549ca920967831482c653e5892fa8ed 2.3 25 | e7a4dd48293b7956d4a20df257d23904cc78e376 2.4 26 | 64b2d0bf45a52511e57a6b7299160b961ca3d51c 2.5 27 | 0e9ea76945c89962cd46cee6537586e2054b2935 2.6 28 | e41a9bf2bac4a7af2bec2bbadf91e63752d320ef 2.7 29 | a158a3a029663133455268e2a63ae6b0af2df720 2.8 30 | f9681d731f2e56c2ca185cec10daece5939bee07 2.9 31 | bad4e598cac7cdd3df4623c68c91299c620471bd 3.0-rc 32 | bad4e598cac7cdd3df4623c68c91299c620471bd 3.0-rc 33 | 0000000000000000000000000000000000000000 3.0-rc 34 | 1307fd7b2b9984f45179db01432305a416713049 3.0_RC 35 | 72188bd2f03447e71e789a5fd2f10364bb232c2c 3.0 36 | 113518629fa54ffb491dd479e15c1f00dd39d376 3.1_RC1 37 | b4e38ce16d7c4b37a6482dc7ae61fd31071b6ff1 3.1_RC2 38 | 20c9994e8bfbeb9443851b2b3a050cd98c8b147b 3.2_RC1 39 | 353572437201d551381002aebf20d244bd49ef17 3.2 40 | 5ee3593ebd82b4d8957909bbc1b68b99b59ba773 3.3_RC1 41 | 96a10df63c0b778b480330bdf3be8da7db8a5fb1 3.3_RC2 42 | 057215961bc4b51b6260a584ff3d506e6d65cfd6 3.3 43 | ee92f36782800f145970131e01c79955a3ed5c10 3.4_RC1 44 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # Read the Docs configuration file for Sphinx projects 2 | # .readthedocs.yaml 3 | 4 | # Project Information 5 | # Required 6 | version: 2 7 | 8 | build: 9 | os: "ubuntu-20.04" 10 | tools: 11 | python: "3.10" 12 | 13 | # Use a requirements file for pip dependencies 14 | python: 15 | install: 16 | - requirements: doc/requirements.txt 17 | 18 | # Build documentation in the "docs/" directory with Sphinx 19 | sphinx: 20 | builder: html 21 | configuration: doc/reST/conf.py 22 | fail_on_warning: false 23 | 24 | # Optionally build your docs in additional formats such as PDF and ePub 25 | # formats: 26 | # - pdf 27 | # - epub 28 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | ShiftMediaProject x265 2 | ============= 3 | [![Build status](https://ci.appveyor.com/api/projects/status/jnku5ydfyd627au6?svg=true)](https://ci.appveyor.com/project/Sibras/x265) 4 | [![Github All Releases](https://img.shields.io/github/downloads/ShiftMediaProject/x265/total.svg)](https://github.com/ShiftMediaProject/x265/releases) 5 | [![GitHub release](https://img.shields.io/github/release/ShiftMediaProject/x265.svg)](https://github.com/ShiftMediaProject/x265/releases/latest) 6 | [![GitHub issues](https://img.shields.io/github/issues/ShiftMediaProject/x265.svg)](https://github.com/ShiftMediaProject/x265/issues) 7 | [![license](https://img.shields.io/github/license/ShiftMediaProject/x265.svg)](https://github.com/ShiftMediaProject/x265) 8 | [![donate](https://img.shields.io/badge/donate-link-brightgreen.svg)](https://shiftmediaproject.github.io/8-donate/) 9 | ## ShiftMediaProject 10 | 11 | Shift Media Project aims to provide native Windows development libraries for x265 and associated dependencies to support simpler creation and debugging of rich media content directly within Visual Studio. [https://shiftmediaproject.github.io/](https://shiftmediaproject.github.io/) 12 | 13 | ## x265 14 | 15 | x265 is an open-source project and free application library for encoding video streams into the H.265/High Efficiency Video Coding (HEVC) format. [https://x265.org](https://x265.org) 16 | 17 | ## Downloads 18 | 19 | Development libraries are available from the [releases](https://github.com/ShiftMediaProject/x265/releases) page. These libraries are available for each supported Visual Studio version with a different download for each version. Each download contains both static and dynamic libraries to choose from in both 32bit and 64bit versions. 20 | 21 | ## Code 22 | 23 | This repository contains code from the corresponding upstream project with additional modifications to allow it to be compiled with Visual Studio. New custom Visual Studio projects are provided within the 'SMP' sub-directory. Refer to the 'readme' contained within the 'SMP' directory for further details. 24 | 25 | ## Issues 26 | 27 | Any issues related to the ShiftMediaProject specific changes should be sent to the [issues](https://github.com/ShiftMediaProject/x265/issues) page for the repository. Any issues related to the upstream project should be sent upstream directly (see the issues information of the upstream repository for more details). 28 | 29 | ## License 30 | 31 | ShiftMediaProject original code is released under [LGPLv2.1](https://www.gnu.org/licenses/lgpl-2.1.html). All code from the upstream repository remains under its original license (see the license information of the upstream repository for more details). 32 | 33 | ## Copyright 34 | 35 | As this repository includes code from upstream project(s) it includes many copyright owners. ShiftMediaProject makes NO claim of copyright on any upstream code. However, all original ShiftMediaProject authored code is copyright ShiftMediaProject. For a complete copyright list please checkout the source code to examine license headers. Unless expressly stated otherwise all code submitted to the ShiftMediaProject project (in any form) is licensed under [LGPLv2.1](https://www.gnu.org/licenses/lgpl-2.1.html) and copyright is donated to ShiftMediaProject. If you submit code that is not your own work it is your responsibility to place a header stating the copyright. 36 | 37 | ## Contributing 38 | 39 | Patches related to the ShiftMediaProject specific changes should be sent as pull requests to the main repository. Any changes related to the upstream project should be sent upstream directly (see the contributing information of the upstream repository for more details). -------------------------------------------------------------------------------- /SMP/.gitattributes: -------------------------------------------------------------------------------- 1 | *.sln text eol=crlf 2 | *.vcxproj text eol=crlf 3 | *.vcxproj.filters text eol=crlf 4 | *.bat text eol=crlf -------------------------------------------------------------------------------- /SMP/.gitignore: -------------------------------------------------------------------------------- 1 | *.obj 2 | *.lib 3 | *.log 4 | *.tlog 5 | *.pdb 6 | *.ildb 7 | *.pgd 8 | *.pch 9 | *.manifest 10 | *.suo 11 | *.user 12 | *.sdf 13 | *.opensdf 14 | [Oo]bj/ 15 | *.exe 16 | !*.h 17 | !*.c 18 | !*.asm 19 | !*.def 20 | !*.rc 21 | *.sbr 22 | *.iobj 23 | *.ipdb 24 | .vs/ 25 | *.VC.db 26 | *.opendb 27 | *.ilk 28 | [Bb]in/ -------------------------------------------------------------------------------- /SMP/libx265.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | x265_encoder_open_212 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_212 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 | -------------------------------------------------------------------------------- /SMP/libx265_with_latest_sdk.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | SET PROJECT=x265 4 | 5 | @REM Detect the newest available Windows SDK 6 | CALL :GetWindowsSdkVer 7 | 8 | @REM Open the project 9 | %PROJECT%.sln 10 | 11 | EXIT /B 0 12 | 13 | :GetWindowsSdkVer 14 | SET WindowsTargetPlatformVersion= 15 | 16 | IF "%WindowsTargetPlatformVersion%"=="" CALL :GetWin10SdkVer 17 | IF "%WindowsTargetPlatformVersion%"=="" CALL :GetWin81SdkVer 18 | EXIT /B 0 19 | 20 | :GetWin10SdkVer 21 | CALL :GetWin10SdkVerHelper HKLM\SOFTWARE\Wow6432Node > nul 2>&1 22 | IF errorlevel 1 CALL :GetWin10SdkVerHelper HKCU\SOFTWARE\Wow6432Node > nul 2>&1 23 | IF errorlevel 1 CALL :GetWin10SdkVerHelper HKLM\SOFTWARE > nul 2>&1 24 | IF errorlevel 1 CALL :GetWin10SdkVerHelper HKCU\SOFTWARE > nul 2>&1 25 | IF errorlevel 1 EXIT /B 1 26 | EXIT /B 0 27 | 28 | :GetWin10SdkVerHelper 29 | @REM Get Windows 10 SDK installed folder 30 | FOR /F "tokens=1,2*" %%i IN ('reg query "%1\Microsoft\Microsoft SDKs\Windows\v10.0" /v "InstallationFolder"') DO ( 31 | IF "%%i"=="InstallationFolder" ( 32 | SET WindowsSdkDir=%%~k 33 | ) 34 | ) 35 | 36 | @REM get windows 10 sdk version number 37 | SETLOCAL enableDelayedExpansion 38 | IF NOT "%WindowsSdkDir%"=="" FOR /f %%i IN ('dir "%WindowsSdkDir%include\" /b /ad-h /on') DO ( 39 | @REM Skip if Windows.h is not found in %%i\um. This would indicate that only the UCRT MSIs were 40 | @REM installed for this Windows SDK version. 41 | IF EXIST "%WindowsSdkDir%include\%%i\um\Windows.h" ( 42 | SET result=%%i 43 | IF "!result:~0,3!"=="10." ( 44 | SET SDK=!result! 45 | IF "!result!"=="%VSCMD_ARG_WINSDK%" SET findSDK=1 46 | ) 47 | ) 48 | ) 49 | 50 | IF "%findSDK%"=="1" SET SDK=%VSCMD_ARG_WINSDK% 51 | ENDLOCAL & SET WindowsTargetPlatformVersion=%SDK% 52 | IF "%WindowsTargetPlatformVersion%"=="" ( 53 | EXIT /B 1 54 | ) 55 | EXIT /B 0 56 | 57 | :GetWin81SdkVer 58 | SET WindowsTargetPlatformVersion=8.1 59 | EXIT /B 0 60 | -------------------------------------------------------------------------------- /SMP/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | This is a small list of steps in order to build libx265 into a msvc dll and/or lib file. 3 | 4 | The project contains Release and Debug builds for static lib files (Debug/Release) 5 | as well as dynamic shared dll files (DebugDLL/ReleaseDLL). Along with the standard 6 | windows dll/lib configurations mentioned above there are also equivalent variants that 7 | can be used to compile for WinRT/UWP (These configurations have a WinRT suffix). 8 | There are also architecture configurations for either 32bit (x86) or 64bit (x64) compilation. 9 | Choose whichever project configuration meets your requirements. 10 | 11 | The project configurations support being built with various different windows SDK versions. 12 | By default they will use the lowest SDK version that would be available for Visual Studio 13 | version 2013 and up (This is the 8.1 SDK). However a batch file is also included 14 | (lib265_with_latest_sdk.bat) which can be used to auto detect the newest available SDK 15 | installed on the host machine and then open the project using that as the compilation SDK. 16 | 17 | When using the WinRT/UWP project configurations the projects will automatically compile towards 18 | the default application target for the Version of Visual Studio being used: 19 | VS 2013: 8.1 20 | VS 2015: 8.1 21 | VS 2017+: 10.0.10240.0 22 | 23 | 24 | *** Building with NASM *** 25 | 26 | In order to build x265 using msvc you must first download and install NASM. 27 | NASM is required to compile all assembly files. 28 | 29 | 1) Visual Studio NASM integration can be downloaded from https://github.com/ShiftMediaProject/VSNASM/releases/latest 30 | 31 | 2) Once downloaded simply follow the install instructions included in the download. 32 | -------------------------------------------------------------------------------- /SMP/x265.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | VS_VERSION_INFO VERSIONINFO 4 | FILEVERSION 4,0,0,0 5 | PRODUCTVERSION 4,0,0,0 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", "4.0" 21 | VALUE "InternalName", "x265" 22 | VALUE "LegalCopyright", "Multicoreware: GPLv2 or commercial" 23 | VALUE "OriginalFilename", "libx265.dll" 24 | VALUE "ProductName", "x265" 25 | VALUE "ProductVersion", "4.0" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x409, 1200 31 | END 32 | END 33 | -------------------------------------------------------------------------------- /SMP/x265_config.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_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 212 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /build/aarch64-darwin/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_ARM64 1) 7 | set(CMAKE_SYSTEM_NAME Darwin) 8 | set(CMAKE_SYSTEM_PROCESSOR aarch64) 9 | 10 | # specify the cross compiler (giving precedence to user-supplied CC/CXX) 11 | if(NOT DEFINED CMAKE_C_COMPILER) 12 | set(CMAKE_C_COMPILER gcc) 13 | endif() 14 | if(NOT DEFINED CMAKE_CXX_COMPILER) 15 | set(CMAKE_CXX_COMPILER g++) 16 | endif() 17 | 18 | # specify the target environment 19 | SET(CMAKE_FIND_ROOT_PATH /opt/homebrew/bin/) 20 | 21 | -------------------------------------------------------------------------------- /build/aarch64-darwin/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/aarch64-linux-clang/crosscompile.cmake: -------------------------------------------------------------------------------- 1 | # CMake toolchain file for cross compiling x265 for AArch64, using Clang. 2 | 3 | set(CROSS_COMPILE_ARM64 1) 4 | set(CMAKE_SYSTEM_NAME Linux) 5 | set(CMAKE_SYSTEM_PROCESSOR aarch64) 6 | 7 | set(TARGET_TRIPLE aarch64-linux-gnu) 8 | 9 | # specify the cross compiler (giving precedence to user-supplied CC/CXX) 10 | if(NOT DEFINED CMAKE_C_COMPILER) 11 | set(CMAKE_C_COMPILER clang) 12 | endif() 13 | if(NOT DEFINED CMAKE_CXX_COMPILER) 14 | set(CMAKE_CXX_COMPILER clang++) 15 | endif() 16 | 17 | # specify compiler target 18 | set(CMAKE_C_COMPILER_TARGET ${TARGET_TRIPLE}) 19 | set(CMAKE_CXX_COMPILER_TARGET ${TARGET_TRIPLE}) 20 | 21 | # specify assembler target 22 | list(APPEND ASM_FLAGS "--target=${TARGET_TRIPLE}") 23 | 24 | # specify the target environment 25 | SET(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu) 26 | -------------------------------------------------------------------------------- /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_ARM64 1) 7 | set(CMAKE_SYSTEM_NAME Linux) 8 | set(CMAKE_SYSTEM_PROCESSOR aarch64) 9 | 10 | # specify the cross compiler (giving precedence to user-supplied CC/CXX) 11 | if(NOT DEFINED CMAKE_C_COMPILER) 12 | set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc) 13 | endif() 14 | if(NOT DEFINED CMAKE_CXX_COMPILER) 15 | set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++) 16 | endif() 17 | 18 | # specify the target environment 19 | SET(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu) 20 | 21 | -------------------------------------------------------------------------------- /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 -DCMAKE_TOOLCHAIN_FILE="crosscompile.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 <`_ | 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/FindNEON_DOTPROD.cmake: -------------------------------------------------------------------------------- 1 | include(FindPackageHandleStandardArgs) 2 | 3 | # Check if Armv8.4 Neon DotProd is supported by the Arm CPU 4 | if(APPLE) 5 | execute_process(COMMAND sysctl -a 6 | COMMAND grep "hw.optional.arm.FEAT_DotProd: 1" 7 | OUTPUT_VARIABLE has_dot_product 8 | ERROR_QUIET 9 | OUTPUT_STRIP_TRAILING_WHITESPACE) 10 | else() 11 | execute_process(COMMAND cat /proc/cpuinfo 12 | COMMAND grep Features 13 | COMMAND grep asimddp 14 | OUTPUT_VARIABLE has_dot_product 15 | ERROR_QUIET 16 | OUTPUT_STRIP_TRAILING_WHITESPACE) 17 | endif() 18 | 19 | if(has_dot_product) 20 | set(CPU_HAS_NEON_DOTPROD 1) 21 | endif() 22 | -------------------------------------------------------------------------------- /source/cmake/FindNEON_I8MM.cmake: -------------------------------------------------------------------------------- 1 | include(FindPackageHandleStandardArgs) 2 | 3 | # Check if Armv8.6 Neon I8MM is supported by the Arm CPU 4 | if(APPLE) 5 | execute_process(COMMAND sysctl -a 6 | COMMAND grep "hw.optional.arm.FEAT_I8MM: 1" 7 | OUTPUT_VARIABLE has_i8mm 8 | ERROR_QUIET 9 | OUTPUT_STRIP_TRAILING_WHITESPACE) 10 | else() 11 | execute_process(COMMAND cat /proc/cpuinfo 12 | COMMAND grep Features 13 | COMMAND grep i8mm 14 | OUTPUT_VARIABLE has_i8mm 15 | ERROR_QUIET 16 | OUTPUT_STRIP_TRAILING_WHITESPACE) 17 | endif() 18 | 19 | if(has_i8mm) 20 | set(CPU_HAS_NEON_I8MM 1) 21 | endif() 22 | -------------------------------------------------------------------------------- /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 | if(APPLE) 5 | execute_process(COMMAND sysctl -a 6 | COMMAND grep "hw.optional.neon: 1" 7 | OUTPUT_VARIABLE neon_version 8 | ERROR_QUIET 9 | OUTPUT_STRIP_TRAILING_WHITESPACE) 10 | else() 11 | execute_process(COMMAND cat /proc/cpuinfo 12 | COMMAND grep Features 13 | COMMAND grep neon 14 | OUTPUT_VARIABLE neon_version 15 | ERROR_QUIET 16 | OUTPUT_STRIP_TRAILING_WHITESPACE) 17 | endif() 18 | 19 | if(neon_version) 20 | set(CPU_HAS_NEON 1) 21 | endif() 22 | -------------------------------------------------------------------------------- /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/FindSVE.cmake: -------------------------------------------------------------------------------- 1 | include(FindPackageHandleStandardArgs) 2 | 3 | # Check the version of SVE supported by the ARM CPU 4 | if(APPLE) 5 | execute_process(COMMAND sysctl -a 6 | COMMAND grep "hw.optional.sve: 1" 7 | OUTPUT_VARIABLE sve_version 8 | ERROR_QUIET 9 | OUTPUT_STRIP_TRAILING_WHITESPACE) 10 | else() 11 | execute_process(COMMAND cat /proc/cpuinfo 12 | COMMAND grep Features 13 | COMMAND grep -e "sve$" -e "sve[[:space:]]" 14 | OUTPUT_VARIABLE sve_version 15 | ERROR_QUIET 16 | OUTPUT_STRIP_TRAILING_WHITESPACE) 17 | endif() 18 | 19 | if(sve_version) 20 | set(CPU_HAS_SVE 1) 21 | endif() 22 | -------------------------------------------------------------------------------- /source/cmake/FindSVE2.cmake: -------------------------------------------------------------------------------- 1 | include(FindPackageHandleStandardArgs) 2 | 3 | # Check the version of SVE2 supported by the ARM CPU 4 | if(APPLE) 5 | execute_process(COMMAND sysctl -a 6 | COMMAND grep "hw.optional.sve2: 1" 7 | OUTPUT_VARIABLE sve2_version 8 | ERROR_QUIET 9 | OUTPUT_STRIP_TRAILING_WHITESPACE) 10 | else() 11 | execute_process(COMMAND cat /proc/cpuinfo 12 | COMMAND grep Features 13 | COMMAND grep sve2 14 | OUTPUT_VARIABLE sve2_version 15 | ERROR_QUIET 16 | OUTPUT_STRIP_TRAILING_WHITESPACE) 17 | endif() 18 | 19 | if(sve2_version) 20 | set(CPU_HAS_SVE 1) 21 | set(CPU_HAS_SVE2 1) 22 | endif() 23 | -------------------------------------------------------------------------------- /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/arm64-utils.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARM64_UTILS_H__ 2 | #define __ARM64_UTILS_H__ 3 | 4 | #include 5 | 6 | namespace X265_NS 7 | { 8 | void transpose8x8(uint8_t *dst, const uint8_t *src, intptr_t dstride, intptr_t sstride); 9 | void transpose16x16(uint8_t *dst, const uint8_t *src, intptr_t dstride, intptr_t sstride); 10 | void transpose32x32(uint8_t *dst, const uint8_t *src, intptr_t dstride, intptr_t sstride); 11 | void transpose8x8(uint16_t *dst, const uint16_t *src, intptr_t dstride, intptr_t sstride); 12 | void transpose16x16(uint16_t *dst, const uint16_t *src, intptr_t dstride, intptr_t sstride); 13 | void transpose32x32(uint16_t *dst, const uint16_t *src, intptr_t dstride, intptr_t sstride); 14 | } 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /source/common/aarch64/asm-sve.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2022-2023 MulticoreWare, Inc 3 | * 4 | * Authors: David 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 | #include "asm.S" 25 | 26 | .arch armv8-a+sve 27 | 28 | .macro ABS2_SVE a b c 29 | abs \a, \c\()/m, \a 30 | abs \b, \c\()/m, \b 31 | .endm 32 | 33 | .macro ABS8_SVE z0, z1, z2, z3, z4, z5, z6, z7, p0 34 | ABS2_SVE \z0, \z1, p0 35 | ABS2_SVE \z2, \z3, p0 36 | ABS2_SVE \z4, \z5, p0 37 | ABS2_SVE \z6, \z7, p0 38 | .endm 39 | 40 | -------------------------------------------------------------------------------- /source/common/aarch64/blockcopy8-common.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2022-2023 MulticoreWare, Inc 3 | * 4 | * Authors: David 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 | // This file contains the macros written using NEON instruction set 25 | // that are also used by the SVE2 functions 26 | 27 | #include "asm.S" 28 | 29 | .arch armv8-a 30 | 31 | // void cpy1Dto2D_shr(int16_t* dst, const int16_t* src, intptr_t dstStride, int shift) 32 | .macro cpy1Dto2D_shr_start 33 | add x2, x2, x2 34 | dup v0.8h, w3 35 | cmeq v1.8h, v1.8h, v1.8h 36 | sshl v1.8h, v1.8h, v0.8h 37 | sri v1.8h, v1.8h, #1 38 | neg v0.8h, v0.8h 39 | .endm 40 | 41 | .macro cpy2Dto1D_shr_start 42 | add x2, x2, x2 43 | dup v0.8h, w3 44 | cmeq v1.8h, v1.8h, v1.8h 45 | sshl v1.8h, v1.8h, v0.8h 46 | sri v1.8h, v1.8h, #1 47 | neg v0.8h, v0.8h 48 | .endm 49 | 50 | const xtn_xtn2_table, align=4 51 | .byte 0, 2, 4, 6, 8, 10, 12, 14 52 | .byte 16, 18, 20, 22, 24, 26, 28, 30 53 | endconst 54 | 55 | -------------------------------------------------------------------------------- /source/common/aarch64/dct-prim.h: -------------------------------------------------------------------------------- 1 | #ifndef __DCT_PRIM_NEON_H__ 2 | #define __DCT_PRIM_NEON_H__ 3 | 4 | 5 | #include "common.h" 6 | #include "primitives.h" 7 | #include "contexts.h" // costCoeffNxN_c 8 | #include "threading.h" // CLZ 9 | #include 10 | 11 | namespace X265_NS 12 | { 13 | // First two columns of the 4x4 dct transform matrix, duplicated to 4x4 to allow 14 | // processing two lines at once. 15 | const int32_t t8_even[4][4] = 16 | { 17 | { 64, 64, 64, 64 }, 18 | { 83, 36, 83, 36 }, 19 | { 64, -64, 64, -64 }, 20 | { 36, -83, 36, -83 }, 21 | }; 22 | 23 | const uint8_t rev16_tbl[16] = 24 | { 25 | 14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1 26 | }; 27 | 28 | const uint8_t rev32_tbl[16] = 29 | { 30 | 12, 13, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3 31 | }; 32 | 33 | static inline int16x8_t rev16(const int16x8_t a) 34 | { 35 | const uint8x16_t tbl = vld1q_u8(rev16_tbl); 36 | const int8x16_t a_s8 = vreinterpretq_s8_s16(a); 37 | 38 | return vreinterpretq_s16_s8(vqtbx1q_s8(a_s8, a_s8, tbl)); 39 | } 40 | 41 | static inline int32x4_t rev32(const int32x4_t a) 42 | { 43 | const uint8x16_t tbl = vld1q_u8(rev32_tbl); 44 | const int8x16_t a_s8 = vreinterpretq_s8_s32(a); 45 | 46 | return vreinterpretq_s32_s8(vqtbx1q_s8(a_s8, a_s8, tbl)); 47 | } 48 | 49 | // x265 private namespace 50 | void setupDCTPrimitives_neon(EncoderPrimitives &p); 51 | #if defined(HAVE_SVE) && HAVE_SVE_BRIDGE 52 | void setupDCTPrimitives_sve(EncoderPrimitives &p); 53 | #endif 54 | }; 55 | 56 | 57 | 58 | #endif 59 | 60 | -------------------------------------------------------------------------------- /source/common/aarch64/filter-neon-dotprod.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2024 MulticoreWare, Inc 3 | * 4 | * Authors: Hari Limaye 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_COMMON_AARCH64_FILTER_NEON_DOTPROD_H 25 | #define X265_COMMON_AARCH64_FILTER_NEON_DOTPROD_H 26 | 27 | #if defined(HAVE_NEON_DOTPROD) 28 | 29 | #include "primitives.h" 30 | 31 | namespace X265_NS { 32 | void setupFilterPrimitives_neon_dotprod(EncoderPrimitives &p); 33 | } 34 | 35 | #endif // defined(HAVE_NEON_DOTPROD) 36 | 37 | #endif // X265_COMMON_AARCH64_FILTER_NEON_DOTPROD_H 38 | -------------------------------------------------------------------------------- /source/common/aarch64/filter-neon-i8mm.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2024 MulticoreWare, Inc 3 | * 4 | * Authors: Hari Limaye 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_FILTER_NEON_I8MM_H 25 | #define X265_FILTER_NEON_I8MM_H 26 | 27 | #if defined(HAVE_NEON_I8MM) 28 | 29 | #include "primitives.h" 30 | 31 | namespace X265_NS { 32 | void setupFilterPrimitives_neon_i8mm(EncoderPrimitives &p); 33 | } 34 | 35 | #endif // defined(HAVE_NEON_I8MM) 36 | 37 | #endif // X265_FILTER_NEON_I8MM_H 38 | -------------------------------------------------------------------------------- /source/common/aarch64/filter-prim.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILTER_PRIM_ARM64_H__ 2 | #define _FILTER_PRIM_ARM64_H__ 3 | 4 | 5 | #include "common.h" 6 | #include "slicetype.h" // LOWRES_COST_MASK 7 | #include "primitives.h" 8 | #include "x265.h" 9 | 10 | 11 | namespace X265_NS 12 | { 13 | 14 | 15 | void setupFilterPrimitives_neon(EncoderPrimitives &p); 16 | 17 | }; 18 | 19 | 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /source/common/aarch64/intrapred-prim.h: -------------------------------------------------------------------------------- 1 | #ifndef INTRAPRED_PRIM_H__ 2 | 3 | #if defined(__aarch64__) 4 | 5 | namespace X265_NS 6 | { 7 | // x265 private namespace 8 | 9 | void setupIntraPrimitives_neon(EncoderPrimitives &p); 10 | } 11 | 12 | #endif 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /source/common/aarch64/loopfilter-prim.h: -------------------------------------------------------------------------------- 1 | #ifndef _LOOPFILTER_NEON_H__ 2 | #define _LOOPFILTER_NEON_H__ 3 | 4 | #include "common.h" 5 | #include "primitives.h" 6 | 7 | #define PIXEL_MIN 0 8 | 9 | namespace X265_NS 10 | { 11 | void setupLoopFilterPrimitives_neon(EncoderPrimitives &p); 12 | 13 | }; 14 | 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /source/common/aarch64/mc-a-common.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2022-2023 MulticoreWare, Inc 3 | * 4 | * Authors: David 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 | // This file contains the macros written using NEON instruction set 25 | // that are also used by the SVE2 functions 26 | 27 | .arch armv8-a 28 | 29 | #ifdef __APPLE__ 30 | .section __RODATA,__rodata 31 | #else 32 | .section .rodata 33 | #endif 34 | 35 | .macro addAvg_start 36 | lsl x3, x3, #1 37 | lsl x4, x4, #1 38 | mov w11, #0x40 39 | dup v30.16b, w11 40 | .endm 41 | 42 | .macro addavg_1 v0, v1 43 | add \v0\().8h, \v0\().8h, \v1\().8h 44 | saddl v16.4s, \v0\().4h, v30.4h 45 | saddl2 v17.4s, \v0\().8h, v30.8h 46 | shrn \v0\().4h, v16.4s, #7 47 | shrn2 \v0\().8h, v17.4s, #7 48 | .endm 49 | -------------------------------------------------------------------------------- /source/common/aarch64/neon-sve-bridge.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2024 MulticoreWare, Inc 3 | * 4 | * Authors: Hari Limaye 5 | * Jonathan Wright 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_COMMON_AARCH64_NEON_SVE_BRIDGE_H 26 | #define X265_COMMON_AARCH64_NEON_SVE_BRIDGE_H 27 | 28 | #include 29 | 30 | #if defined(HAVE_SVE) && HAVE_SVE_BRIDGE 31 | #include 32 | #include 33 | 34 | /* We can access instructions that are exclusive to the SVE or SVE2 instruction 35 | * sets from a predominantly Neon context by making use of the Neon-SVE bridge 36 | * intrinsics to reinterpret Neon vectors as SVE vectors - with the high part of 37 | * the SVE vector (if it's longer than 128 bits) being "don't care". 38 | * 39 | * While sub-optimal on machines that have SVE vector length > 128-bit - as the 40 | * remainder of the vector is unused - this approach is still beneficial when 41 | * compared to a Neon-only implementation. */ 42 | 43 | static inline int32x4_t x265_vld1sh_s32(const int16_t *ptr) 44 | { 45 | return svget_neonq_s32(svld1sh_s32(svptrue_pat_b32(SV_VL4), ptr)); 46 | } 47 | 48 | static inline int64x2_t x265_sdotq_s16(int64x2_t acc, int16x8_t x, int16x8_t y) 49 | { 50 | return svget_neonq_s64(svdot_s64(svset_neonq_s64(svundef_s64(), acc), 51 | svset_neonq_s16(svundef_s16(), x), 52 | svset_neonq_s16(svundef_s16(), y))); 53 | } 54 | 55 | static inline int8x16_t x265_sve_mask(const int x, const int endX, 56 | const int8x16_t in) 57 | { 58 | // Use predicate to shift "unused lanes" outside of range [-2, 2] 59 | svbool_t svpred = svwhilelt_b8(x, endX); 60 | svint8_t edge_type = svsel_s8(svpred, svset_neonq_s8(svundef_s8(), in), 61 | svdup_n_s8(-3)); 62 | return svget_neonq_s8(edge_type); 63 | } 64 | 65 | #endif // defined(HAVE_SVE) && HAVE_SVE_BRIDGE 66 | 67 | #endif // X265_COMMON_AARCH64_NEON_SVE_BRIDGE_H 68 | -------------------------------------------------------------------------------- /source/common/aarch64/p2s-common.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2022-2023 MulticoreWare, Inc 3 | * 4 | * Authors: David 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 | // This file contains the macros written using NEON instruction set 25 | // that are also used by the SVE2 functions 26 | 27 | .arch armv8-a 28 | 29 | #ifdef __APPLE__ 30 | .section __RODATA,__rodata 31 | #else 32 | .section .rodata 33 | #endif 34 | 35 | .align 4 36 | 37 | #if HIGH_BIT_DEPTH 38 | # if BIT_DEPTH == 10 39 | # define P2S_SHIFT 4 40 | # elif BIT_DEPTH == 12 41 | # define P2S_SHIFT 2 42 | # endif 43 | .macro p2s_start 44 | add x3, x3, x3 45 | add x1, x1, x1 46 | movi v31.8h, #0xe0, lsl #8 47 | .endm 48 | 49 | #else // if !HIGH_BIT_DEPTH 50 | # define P2S_SHIFT 6 51 | .macro p2s_start 52 | add x3, x3, x3 53 | movi v31.8h, #0xe0, lsl #8 54 | .endm 55 | #endif // HIGH_BIT_DEPTH 56 | 57 | .macro p2s_2x2 58 | #if HIGH_BIT_DEPTH 59 | ld1 {v0.s}[0], [x0], x1 60 | ld1 {v0.s}[1], [x0], x1 61 | shl v3.8h, v0.8h, #P2S_SHIFT 62 | #else 63 | ldrh w10, [x0] 64 | add x0, x0, x1 65 | ldrh w11, [x0] 66 | orr w10, w10, w11, lsl #16 67 | add x0, x0, x1 68 | dup v0.4s, w10 69 | ushll v3.8h, v0.8b, #P2S_SHIFT 70 | #endif 71 | add v3.8h, v3.8h, v31.8h 72 | st1 {v3.s}[0], [x2], x3 73 | st1 {v3.s}[1], [x2], x3 74 | .endm 75 | 76 | .macro p2s_6x2 77 | #if HIGH_BIT_DEPTH 78 | ld1 {v0.d}[0], [x0], #8 79 | ld1 {v1.s}[0], [x0], x1 80 | ld1 {v0.d}[1], [x0], #8 81 | ld1 {v1.s}[1], [x0], x1 82 | shl v3.8h, v0.8h, #P2S_SHIFT 83 | shl v4.8h, v1.8h, #P2S_SHIFT 84 | #else 85 | ldr s0, [x0] 86 | ldrh w10, [x0, #4] 87 | add x0, x0, x1 88 | ld1 {v0.s}[1], [x0] 89 | ldrh w11, [x0, #4] 90 | add x0, x0, x1 91 | orr w10, w10, w11, lsl #16 92 | dup v1.4s, w10 93 | ushll v3.8h, v0.8b, #P2S_SHIFT 94 | ushll v4.8h, v1.8b, #P2S_SHIFT 95 | #endif 96 | add v3.8h, v3.8h, v31.8h 97 | add v4.8h, v4.8h, v31.8h 98 | st1 {v3.d}[0], [x2], #8 99 | st1 {v4.s}[0], [x2], x3 100 | st1 {v3.d}[1], [x2], #8 101 | st1 {v4.s}[1], [x2], x3 102 | .endm 103 | -------------------------------------------------------------------------------- /source/common/aarch64/pixel-prim.h: -------------------------------------------------------------------------------- 1 | #ifndef PIXEL_PRIM_NEON_H__ 2 | #define PIXEL_PRIM_NEON_H__ 3 | 4 | #include "common.h" 5 | #include "slicetype.h" // LOWRES_COST_MASK 6 | #include "primitives.h" 7 | #include "x265.h" 8 | 9 | 10 | 11 | namespace X265_NS 12 | { 13 | 14 | 15 | 16 | void setupPixelPrimitives_neon(EncoderPrimitives &p); 17 | 18 | 19 | } 20 | 21 | 22 | #endif 23 | 24 | -------------------------------------------------------------------------------- /source/common/aarch64/pixel-util-common.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2022-2023 MulticoreWare, Inc 3 | * 4 | * Authors: David 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 | // This file contains the macros written using NEON instruction set 25 | // that are also used by the SVE2 functions 26 | 27 | .arch armv8-a 28 | 29 | #ifdef __APPLE__ 30 | .section __RODATA,__rodata 31 | #else 32 | .section .rodata 33 | #endif 34 | 35 | .align 4 36 | 37 | .macro pixel_var_start 38 | movi v0.16b, #0 39 | movi v1.16b, #0 40 | movi v2.16b, #0 41 | movi v3.16b, #0 42 | .endm 43 | 44 | .macro pixel_var_1 v 45 | uaddw v0.8h, v0.8h, \v\().8b 46 | umull v30.8h, \v\().8b, \v\().8b 47 | uaddw2 v1.8h, v1.8h, \v\().16b 48 | umull2 v31.8h, \v\().16b, \v\().16b 49 | uadalp v2.4s, v30.8h 50 | uadalp v3.4s, v31.8h 51 | .endm 52 | 53 | .macro pixel_var_end 54 | uaddlv s0, v0.8h 55 | uaddlv s1, v1.8h 56 | add v2.4s, v2.4s, v3.4s 57 | fadd s0, s0, s1 58 | uaddlv d2, v2.4s 59 | fmov w0, s0 60 | fmov x2, d2 61 | orr x0, x0, x2, lsl #32 62 | .endm 63 | 64 | .macro ssimDist_start 65 | movi v0.16b, #0 66 | movi v1.16b, #0 67 | .endm 68 | 69 | .macro ssimDist_end 70 | uaddlv d0, v0.4s 71 | uaddlv d1, v1.4s 72 | str d0, [x6] 73 | str d1, [x4] 74 | .endm 75 | 76 | .macro normFact_start 77 | movi v0.16b, #0 78 | .endm 79 | 80 | .macro normFact_end 81 | uaddlv d0, v0.4s 82 | str d0, [x3] 83 | .endm 84 | 85 | -------------------------------------------------------------------------------- /source/common/aarch64/sao-prim.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2024 MulticoreWare, Inc 3 | * 4 | * Authors: Hari Limaye 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_COMMON_AARCH64_SAO_PRIM_H 25 | #define X265_COMMON_AARCH64_SAO_PRIM_H 26 | 27 | #include "neon-sve-bridge.h" 28 | #include "primitives.h" 29 | #include 30 | 31 | static inline int8x16_t signOf_neon(const pixel *a, const pixel *b) 32 | { 33 | #if HIGH_BIT_DEPTH 34 | uint16x8_t s0_lo = vld1q_u16(a); 35 | uint16x8_t s0_hi = vld1q_u16(a + 8); 36 | uint16x8_t s1_lo = vld1q_u16(b); 37 | uint16x8_t s1_hi = vld1q_u16(b + 8); 38 | 39 | // signOf(a - b) = -(a > b ? -1 : 0) | (a < b ? -1 : 0) 40 | int16x8_t cmp0_lo = vreinterpretq_s16_u16(vcgtq_u16(s0_lo, s1_lo)); 41 | int16x8_t cmp0_hi = vreinterpretq_s16_u16(vcgtq_u16(s0_hi, s1_hi)); 42 | int16x8_t cmp1_lo = vreinterpretq_s16_u16(vcgtq_u16(s1_lo, s0_lo)); 43 | int16x8_t cmp1_hi = vreinterpretq_s16_u16(vcgtq_u16(s1_hi, s0_hi)); 44 | 45 | int8x16_t cmp0 = vcombine_s8(vmovn_s16(cmp0_lo), vmovn_s16(cmp0_hi)); 46 | int8x16_t cmp1 = vcombine_s8(vmovn_s16(cmp1_lo), vmovn_s16(cmp1_hi)); 47 | #else // HIGH_BIT_DEPTH 48 | uint8x16_t s0 = vld1q_u8(a); 49 | uint8x16_t s1 = vld1q_u8(b); 50 | 51 | // signOf(a - b) = -(a > b ? -1 : 0) | (a < b ? -1 : 0) 52 | int8x16_t cmp0 = vreinterpretq_s8_u8(vcgtq_u8(s0, s1)); 53 | int8x16_t cmp1 = vreinterpretq_s8_u8(vcgtq_u8(s1, s0)); 54 | #endif // HIGH_BIT_DEPTH 55 | return vorrq_s8(vnegq_s8(cmp0), cmp1); 56 | } 57 | 58 | namespace X265_NS { 59 | void setupSaoPrimitives_neon(EncoderPrimitives &p); 60 | 61 | #if defined(HAVE_SVE) && HAVE_SVE_BRIDGE 62 | void setupSaoPrimitives_sve(EncoderPrimitives &p); 63 | #endif 64 | 65 | #if defined(HAVE_SVE2) && HAVE_SVE_BRIDGE 66 | void setupSaoPrimitives_sve2(EncoderPrimitives &p); 67 | #endif 68 | } 69 | 70 | #endif // X265_COMMON_AARCH64_SAO_PRIM_H 71 | -------------------------------------------------------------------------------- /source/common/aarch64/ssd-a-common.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2022-2023 MulticoreWare, Inc 3 | * 4 | * Authors: David 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 | // This file contains the macros written using NEON instruction set 25 | // that are also used by the SVE2 functions 26 | 27 | #include "asm.S" 28 | 29 | .arch armv8-a 30 | 31 | .macro ret_v0_w0 32 | addv s0, v0.4s 33 | fmov w0, s0 34 | ret 35 | .endm 36 | -------------------------------------------------------------------------------- /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 | bool parseMaskingStrength(x265_param* p, const char* value); 42 | 43 | /* this table is kept internal to avoid confusion, since log level indices start at -1 */ 44 | static const char * const logLevelNames[] = { "none", "error", "warning", "info", "debug", "full", 0 }; 45 | 46 | #if EXPORT_C_API 47 | #define PARAM_NS 48 | #else 49 | /* declare param functions within private namespace */ 50 | void x265_param_free(x265_param *); 51 | x265_param* x265_param_alloc(); 52 | void x265_param_default(x265_param *param); 53 | int x265_param_default_preset(x265_param *, const char *preset, const char *tune); 54 | int x265_param_apply_profile(x265_param *, const char *profile); 55 | int x265_param_parse(x265_param *p, const char *name, const char *value); 56 | int x265_scenecut_aware_qp_param_parse(x265_param* p, const char* name, const char* value); 57 | int x265_zone_param_parse(x265_param* p, const char* name, const char* value); 58 | #define PARAM_NS X265_NS 59 | #endif 60 | } 61 | #endif // ifndef X265_PARAM_H 62 | -------------------------------------------------------------------------------- /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 | void pushBackMCSTF(Frame& pic); 53 | #if ENABLE_MULTIVIEW 54 | void pushBackSubDPB(Frame& pic); 55 | #endif 56 | 57 | /** Push picture to beginning of the list */ 58 | void pushFront(Frame& pic); 59 | void pushFrontMCSTF(Frame& pic); 60 | #if ENABLE_MULTIVIEW 61 | Frame* popFrontSubDPB(); 62 | #endif 63 | 64 | /** Pop picture from end of the list */ 65 | Frame* popBack(); 66 | Frame* popBackMCSTF(); 67 | 68 | /** Pop picture from beginning of the list */ 69 | Frame* popFront(); 70 | 71 | /** Find frame with specified POC */ 72 | Frame* getPOC(int poc, int sLayerId = 0); 73 | /* Find next MCSTF frame with specified POC */ 74 | Frame* getPOCMCSTF(int poc); 75 | 76 | /** Get the current Frame from the list **/ 77 | Frame* getCurFrame(int sLayer); 78 | 79 | /** Remove picture from list */ 80 | void remove(Frame& pic); 81 | 82 | /** Remove picture from list */ 83 | Frame* removeFrame(Frame& pic); 84 | /* Remove MCSTF picture from list */ 85 | void removeMCSTF(Frame& pic); 86 | #if ENABLE_MULTIVIEW 87 | /** Remove picture from Sub list */ 88 | void removeSubDPB(Frame& pic); 89 | #endif 90 | 91 | Frame* first() { return m_start; } 92 | 93 | Frame* last() { return m_end; } 94 | 95 | int size() { return m_count; } 96 | 97 | bool empty() const { return !m_count; } 98 | 99 | operator bool() const { return !!m_count; } 100 | }; 101 | } 102 | 103 | #endif // ifndef X265_PICLIST_H 104 | -------------------------------------------------------------------------------- /source/common/ringmem.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2017 MulticoreWare, Inc 3 | * 4 | * Authors: liwei 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_RINGMEM_H 25 | #define X265_RINGMEM_H 26 | 27 | #include "common.h" 28 | #include "threading.h" 29 | 30 | #if _MSC_VER 31 | #define snprintf _snprintf 32 | #define strdup _strdup 33 | #endif 34 | 35 | namespace X265_NS { 36 | 37 | #define MAX_SHR_NAME_LEN 256 38 | 39 | class RingMem { 40 | public: 41 | RingMem(); 42 | ~RingMem(); 43 | 44 | bool skipRead(int32_t cnt); 45 | 46 | bool skipWrite(int32_t cnt); 47 | 48 | ///< initialize 49 | ///< protectRW: if use the semaphore the protect the write and read operation. 50 | bool init(int32_t itemSize, int32_t itemCnt, const char *name, bool protectRW = false); 51 | ///< finalize 52 | void release(); 53 | 54 | typedef void(*fnRWSharedData)(void *dst, void *src, int32_t size); 55 | 56 | ///< data read 57 | bool readNext(void* dst, fnRWSharedData callback); 58 | ///< data write 59 | bool writeData(void *data, fnRWSharedData callback); 60 | 61 | private: 62 | bool m_initialized; 63 | bool m_protectRW; 64 | 65 | int32_t m_itemSize; 66 | int32_t m_itemCnt; 67 | ///< data pool 68 | void *m_dataPool; 69 | typedef struct { 70 | ///< index to write 71 | int32_t m_write; 72 | ///< index to read 73 | int32_t m_read; 74 | 75 | }ShrMemCtrl; 76 | 77 | ShrMemCtrl *m_shrMem; 78 | #ifdef _WIN32 79 | void *m_handle; 80 | #else // _WIN32 81 | char *m_filepath; 82 | #endif // _WIN32 83 | 84 | ///< Semaphores 85 | NamedSemaphore *m_writeSem; 86 | NamedSemaphore *m_readSem; 87 | }; 88 | }; 89 | 90 | #endif // ifndef X265_RINGMEM_H 91 | -------------------------------------------------------------------------------- /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/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 setupIntrinsicPrimitives(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/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/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/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 SUBSAMPLELUMA(cpu) \ 40 | void PFX(frame_subsample_luma_ ## cpu)(const pixel* src0, pixel* dst0, intptr_t src_stride, intptr_t dst_stride, int width, int height); 41 | SUBSAMPLELUMA(mmx2) 42 | SUBSAMPLELUMA(sse2) 43 | SUBSAMPLELUMA(ssse3) 44 | SUBSAMPLELUMA(avx) 45 | SUBSAMPLELUMA(avx2) 46 | SUBSAMPLELUMA(xop) 47 | 48 | #undef SUBSAMPLELUMA 49 | 50 | #define PROPAGATE_COST(cpu) \ 51 | void PFX(mbtree_propagate_cost_ ## cpu)(int* dst, const uint16_t* propagateIn, const int32_t* intraCosts, \ 52 | const uint16_t* interCosts, const int32_t* invQscales, const double* fpsFactor, int len); 53 | 54 | PROPAGATE_COST(sse2) 55 | PROPAGATE_COST(avx) 56 | PROPAGATE_COST(avx2) 57 | 58 | #undef PROPAGATE_COST 59 | 60 | #define FIX8UNPACK(cpu) \ 61 | void PFX(cutree_fix8_unpack_ ## cpu)(double *dst, uint16_t *src, int count); 62 | 63 | FIX8UNPACK(ssse3) 64 | FIX8UNPACK(avx2) 65 | 66 | #undef FIX8UNPACK 67 | 68 | #define FIX8PACK(cpu) \ 69 | void PFX(cutree_fix8_pack_## cpu)(uint16_t *dst, double *src, int count); 70 | 71 | FIX8PACK(ssse3) 72 | FIX8PACK(avx2) 73 | 74 | #undef FIX8PACK 75 | 76 | #endif // ifndef X265_MC_H 77 | -------------------------------------------------------------------------------- /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/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_craNal; 44 | int m_bhasLeadingPicture; 45 | bool m_bRefreshPending; 46 | bool m_bTemporalSublayer; 47 | PicList m_picList; 48 | PicList m_freeList; 49 | FrameData* m_frameDataFreeList; 50 | 51 | DPB(x265_param *param) 52 | { 53 | m_lastIDR = 0; 54 | m_pocCRA = 0; 55 | m_bhasLeadingPicture = param->radl; 56 | if (param->bResetZoneConfig) 57 | { 58 | for (int i = 0; i < param->rc.zonefileCount ; i++) 59 | { 60 | if (param->rc.zones[i].zoneParam->radl) 61 | { 62 | m_bhasLeadingPicture = param->rc.zones[i].zoneParam->radl; 63 | break; 64 | } 65 | } 66 | } 67 | m_bRefreshPending = false; 68 | m_frameDataFreeList = NULL; 69 | m_bOpenGOP = param->bOpenGOP; 70 | m_craNal = param->craNal; 71 | m_bTemporalSublayer = (param->bEnableTemporalSubLayers > 2); 72 | } 73 | 74 | ~DPB(); 75 | 76 | void prepareEncode(Frame*); 77 | 78 | void recycleUnreferenced(); 79 | 80 | protected: 81 | 82 | void computeRPS(int curPoc,int tempId, bool isRAP, RPS * rps, unsigned int maxDecPicBuffer, int sLayerId); 83 | 84 | void applyReferencePictureSet(RPS *rps, int curPoc, int tempId, bool isTSAPicture, int sLayerId); 85 | bool getTemporalLayerNonReferenceFlag(int sLayerId); 86 | void decodingRefreshMarking(int pocCurr, NalUnitType nalUnitType, int sLayerId); 87 | bool isTemporalLayerSwitchingPoint(int curPoc, int tempId, int sLayerId); 88 | bool isStepwiseTemporalLayerSwitchingPoint(RPS *rps, int curPoc, int tempId, int sLayerId); 89 | 90 | NalUnitType getNalUnitType(int curPoc, bool bIsKeyFrame); 91 | }; 92 | } 93 | 94 | #endif // X265_DPB_H 95 | -------------------------------------------------------------------------------- /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 | #if ENABLE_MULTIVIEW || ENABLE_ALPHA 39 | static const int MAX_NAL_UNITS = 32; 40 | #else 41 | static const int MAX_NAL_UNITS = 16; 42 | #endif 43 | 44 | public: 45 | 46 | x265_nal m_nal[MAX_NAL_UNITS]; 47 | uint32_t m_numNal; 48 | 49 | uint8_t* m_buffer; 50 | uint32_t m_occupancy; 51 | uint32_t m_allocSize; 52 | 53 | uint8_t* m_extraBuffer; 54 | uint32_t m_extraOccupancy; 55 | uint32_t m_extraAllocSize; 56 | bool m_annexB; 57 | 58 | NALList(); 59 | ~NALList() { X265_FREE(m_buffer); X265_FREE(m_extraBuffer); } 60 | 61 | void takeContents(NALList& other); 62 | 63 | void serialize(NalUnitType nalUnitType, const Bitstream& bs, int layerId = 0, uint8_t temporalID = 1); 64 | 65 | uint32_t serializeSubstreams(uint32_t* streamSizeBytes, uint32_t streamCount, const Bitstream* streams); 66 | }; 67 | 68 | } 69 | 70 | #endif // ifndef X265_NAL_H 71 | -------------------------------------------------------------------------------- /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, bool alpha, int format) 31 | { 32 | const char * s = strrchr(info.filename, '.'); 33 | 34 | if (bForceY4m || (s && !strcmp(s, ".y4m"))) 35 | return new Y4MInput(info, alpha, format); 36 | else 37 | return new YUVInput(info, alpha, format); 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, bool alpha, int format); 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 alphaAvailable; 59 | 60 | bool threadActive; 61 | 62 | ThreadSafeInteger readCount; 63 | 64 | ThreadSafeInteger writeCount; 65 | char* buf[QUEUE_SIZE]; 66 | FILE *ifs; 67 | bool parseHeader(); 68 | void threadMain(); 69 | 70 | bool populateFrameQueue(); 71 | 72 | public: 73 | 74 | Y4MInput(InputFileInfo& info, bool alpha, int format); 75 | 76 | virtual ~Y4MInput(); 77 | void release(); 78 | bool isEof() const { return ifs && feof(ifs); } 79 | bool isFail() { return !(ifs && !ferror(ifs) && threadActive); } 80 | void startReader(); 81 | bool readPicture(x265_picture&); 82 | 83 | const char *getName() const { return "y4m"; } 84 | 85 | int getWidth() const { return width; } 86 | 87 | int getHeight() const { return height; } 88 | }; 89 | } 90 | 91 | #endif // ifndef X265_Y4M_H 92 | -------------------------------------------------------------------------------- /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 alphaAvailable; 51 | 52 | bool threadActive; 53 | 54 | ThreadSafeInteger readCount; 55 | 56 | ThreadSafeInteger writeCount; 57 | char* buf[QUEUE_SIZE]; 58 | FILE *ifs; 59 | int guessFrameCount(); 60 | void threadMain(); 61 | 62 | bool populateFrameQueue(); 63 | 64 | public: 65 | 66 | YUVInput(InputFileInfo& info, bool alpha, int format); 67 | 68 | virtual ~YUVInput(); 69 | void release(); 70 | bool isEof() const { return ifs && feof(ifs); } 71 | bool isFail() { return !(ifs && !ferror(ifs) && threadActive); } 72 | void startReader(); 73 | 74 | bool readPicture(x265_picture&); 75 | 76 | const char *getName() const { return "yuv"; } 77 | 78 | int getWidth() const { return width; } 79 | 80 | int getHeight() const { return height; } 81 | }; 82 | } 83 | 84 | #endif // ifndef X265_YUV_H 85 | -------------------------------------------------------------------------------- /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, int sourceBitDepth) 34 | { 35 | const char * s = strrchr(fname, '.'); 36 | 37 | if (s && !strcmp(s, ".y4m")) 38 | return new Y4MOutput(fname, width, height, bitdepth, fpsNum, fpsDenom, csp, sourceBitDepth); 39 | else 40 | return new YUVOutput(fname, width, height, bitdepth, csp, sourceBitDepth); 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, int sourceBitDepth); 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 | uint32_t bitDepth; 42 | 43 | int colorSpace; 44 | 45 | uint32_t frameSize; 46 | 47 | int inputDepth; 48 | 49 | std::ofstream ofs; 50 | 51 | std::ofstream::pos_type header; 52 | 53 | char *buf; 54 | 55 | void writeHeader(); 56 | 57 | public: 58 | 59 | Y4MOutput(const char *filename, int width, int height, uint32_t bitdepth, uint32_t fpsNum, uint32_t fpsDenom, int csp, int inputDepth); 60 | 61 | virtual ~Y4MOutput(); 62 | 63 | const char *getName() const { return "y4m"; } 64 | 65 | bool isFail() const { return ofs.fail(); } 66 | 67 | void release() { delete this; } 68 | 69 | bool writePicture(const x265_picture& pic); 70 | }; 71 | } 72 | 73 | #endif // ifndef X265_Y4M_H 74 | -------------------------------------------------------------------------------- /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, int inputdepth) 32 | : width(w) 33 | , height(h) 34 | , depth(d) 35 | , colorSpace(csp) 36 | , frameSize(0) 37 | , inputDepth(inputdepth) 38 | { 39 | ofs.open(filename, ios::binary | ios::out); 40 | buf = new char[width]; 41 | 42 | for (int i = 0; i < x265_cli_csps[colorSpace].planes; i++) 43 | frameSize += (uint32_t)((width >> x265_cli_csps[colorSpace].width[i]) * (height >> x265_cli_csps[colorSpace].height[i])); 44 | } 45 | 46 | YUVOutput::~YUVOutput() 47 | { 48 | ofs.close(); 49 | delete [] buf; 50 | } 51 | 52 | bool YUVOutput::writePicture(const x265_picture& pic) 53 | { 54 | uint64_t fileOffset = pic.poc; 55 | fileOffset *= frameSize; 56 | 57 | X265_CHECK(pic.colorSpace == colorSpace, "invalid chroma subsampling\n"); 58 | X265_CHECK(pic.bitDepth == (int)depth, "invalid bit depth\n"); 59 | 60 | if (inputDepth > 8) 61 | { 62 | if (depth == 8) 63 | { 64 | int shift = pic.bitDepth - 8; 65 | ofs.seekp((std::streamoff)fileOffset); 66 | for (int i = 0; i < x265_cli_csps[colorSpace].planes; i++) 67 | { 68 | uint16_t *src = (uint16_t*)pic.planes[i]; 69 | for (int h = 0; h < height >> x265_cli_csps[colorSpace].height[i]; h++) 70 | { 71 | for (int w = 0; w < width >> x265_cli_csps[colorSpace].width[i]; w++) 72 | buf[w] = (char)(src[w] >> shift); 73 | 74 | ofs.write(buf, width >> x265_cli_csps[colorSpace].width[i]); 75 | src += pic.stride[i] / sizeof(*src); 76 | } 77 | } 78 | } 79 | else 80 | { 81 | ofs.seekp((std::streamoff)(fileOffset * 2)); 82 | for (int i = 0; i < x265_cli_csps[colorSpace].planes; i++) 83 | { 84 | uint16_t *src = (uint16_t*)pic.planes[i]; 85 | for (int h = 0; h < height >> x265_cli_csps[colorSpace].height[i]; h++) 86 | { 87 | ofs.write((const char*)src, (width * 2) >> x265_cli_csps[colorSpace].width[i]); 88 | src += pic.stride[i] / sizeof(*src); 89 | } 90 | } 91 | } 92 | } 93 | else 94 | { 95 | ofs.seekp((std::streamoff)fileOffset); 96 | for (int i = 0; i < x265_cli_csps[colorSpace].planes; i++) 97 | { 98 | char *src = (char*)pic.planes[i]; 99 | for (int h = 0; h < height >> x265_cli_csps[colorSpace].height[i]; h++) 100 | { 101 | ofs.write(src, width >> x265_cli_csps[colorSpace].width[i]); 102 | src += pic.stride[i] / sizeof(*src); 103 | } 104 | } 105 | } 106 | 107 | return true; 108 | } 109 | -------------------------------------------------------------------------------- /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 | int inputDepth; 50 | 51 | char *buf; 52 | 53 | std::ofstream ofs; 54 | 55 | public: 56 | 57 | YUVOutput(const char *filename, int width, int height, uint32_t bitdepth, int csp, int inputDepth); 58 | 59 | virtual ~YUVOutput(); 60 | 61 | const char *getName() const { return "yuv"; } 62 | 63 | bool isFail() const { return ofs.fail(); } 64 | 65 | void release() { delete this; } 66 | 67 | bool writePicture(const x265_picture& pic); 68 | }; 69 | } 70 | 71 | #endif // ifndef X265_YUV_H 72 | -------------------------------------------------------------------------------- /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 | enable_language(ASM) 27 | set(NASM_SRC checkasm-arm.S) 28 | add_custom_command( 29 | OUTPUT checkasm-arm.obj 30 | COMMAND ${CMAKE_CXX_COMPILER} 31 | ARGS ${NASM_FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/checkasm-arm.S -o checkasm-arm.obj 32 | DEPENDS checkasm-arm.S) 33 | endif(ARM OR CROSS_COMPILE_ARM) 34 | 35 | # add PowerPC assembly files 36 | if(POWER) 37 | set(NASM_SRC) 38 | endif(POWER) 39 | 40 | add_executable(TestBench ${NASM_SRC} 41 | testbench.cpp testharness.h 42 | pixelharness.cpp pixelharness.h 43 | mbdstharness.cpp mbdstharness.h 44 | ipfilterharness.cpp ipfilterharness.h 45 | intrapredharness.cpp intrapredharness.h) 46 | 47 | target_link_libraries(TestBench x265-static ${PLATFORM_LIBS}) 48 | if(LINKER_OPTIONS) 49 | if(EXTRA_LIB) 50 | list(APPEND LINKER_OPTIONS "-L..") 51 | endif(EXTRA_LIB) 52 | string(REPLACE ";" " " LINKER_OPTION_STR "${LINKER_OPTIONS}") 53 | set_target_properties(TestBench PROPERTIES LINK_FLAGS "${LINKER_OPTION_STR}") 54 | endif() 55 | -------------------------------------------------------------------------------- /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/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 | # Test FG SEI message addition 27 | # CrowdRun_1920x1080_50_10bit_444.yuv,--preset=ultrafast --weightp --keyint -1 --film-grain "CrowdRun_1920x1080_50_10bit_444.bin" 28 | # DucksAndLegs_1920x1080_60_10bit_422.yuv,--preset=veryfast --min-cu 16 --film-grain "DucksAndLegs_1920x1080_60_10bit_422.bin" 29 | # NebutaFestival_2560x1600_60_10bit_crop.yuv,--preset=superfast --bitrate 10000 --sao --limit-sao --cll --max-cll "1000,400" --film-grain "NebutaFestival_2560x1600_60_10bit_crop.bin" 30 | -------------------------------------------------------------------------------- /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: aa7f602f7 3 | releasetagdistance: 1 4 | releasetag: 3.6 5 | --------------------------------------------------------------------------------