├── .github ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .gitlab-ci.yml ├── AUTHORS ├── COPYING ├── Makefile ├── README.markdown ├── SMP ├── .gitattributes ├── .gitignore ├── appveyor.yml ├── common │ └── oclobj.h ├── config.h ├── libx264.vcxproj ├── libx264.vcxproj.filters ├── libx264_files.props ├── libx264_winrt.vcxproj ├── libx264_winrt.vcxproj.filters ├── libx264bit.vcxproj ├── libx264bit.vcxproj.filters ├── libx264bit_winrt.vcxproj ├── libx264bit_winrt.vcxproj.filters ├── readme.txt ├── smp.props ├── smp_winrt.props ├── x264.sln ├── x264_config.h ├── x264_with_latest_sdk.bat ├── x264cli.vcxproj └── x264cli.vcxproj.filters ├── autocomplete.c ├── common ├── aarch64 │ ├── asm-offsets.c │ ├── asm-offsets.h │ ├── asm.S │ ├── bitstream-a.S │ ├── bitstream.h │ ├── cabac-a.S │ ├── dct-a-common.S │ ├── dct-a-sve.S │ ├── dct-a-sve2.S │ ├── dct-a.S │ ├── dct.h │ ├── deblock-a-common.S │ ├── deblock-a-sve.S │ ├── deblock-a.S │ ├── deblock.h │ ├── mc-a-common.S │ ├── mc-a-sve.S │ ├── mc-a.S │ ├── mc-c.c │ ├── mc.h │ ├── pixel-a-common.S │ ├── pixel-a-sve.S │ ├── pixel-a.S │ ├── pixel.h │ ├── predict-a.S │ ├── predict-c.c │ ├── predict.h │ ├── quant-a.S │ └── quant.h ├── arm │ ├── asm.S │ ├── bitstream-a.S │ ├── bitstream.h │ ├── cpu-a.S │ ├── dct-a.S │ ├── dct.h │ ├── deblock-a.S │ ├── deblock.h │ ├── mc-a.S │ ├── mc-c.c │ ├── mc.h │ ├── pixel-a.S │ ├── pixel.h │ ├── predict-a.S │ ├── predict-c.c │ ├── predict.h │ ├── quant-a.S │ └── quant.h ├── base.c ├── base.h ├── bitstream.c ├── bitstream.h ├── cabac.c ├── cabac.h ├── common.c ├── common.h ├── cpu.c ├── cpu.h ├── dct.c ├── dct.h ├── deblock.c ├── frame.c ├── frame.h ├── loongarch │ ├── dct-a.S │ ├── dct.h │ ├── deblock-a.S │ ├── deblock.h │ ├── loongson_asm.S │ ├── loongson_util.S │ ├── mc-a.S │ ├── mc-c.c │ ├── mc.h │ ├── pixel-a.S │ ├── pixel-c.c │ ├── pixel.h │ ├── predict-a.S │ ├── predict-c.c │ ├── predict.h │ ├── quant-a.S │ ├── quant.h │ └── sad-a.S ├── macroblock.c ├── macroblock.h ├── mc.c ├── mc.h ├── mips │ ├── dct-c.c │ ├── dct.h │ ├── deblock-c.c │ ├── deblock.h │ ├── macros.h │ ├── mc-c.c │ ├── mc.h │ ├── pixel-c.c │ ├── pixel.h │ ├── predict-c.c │ ├── predict.h │ ├── quant-c.c │ └── quant.h ├── mvpred.c ├── opencl.c ├── opencl.h ├── opencl │ ├── bidir.cl │ ├── downscale.cl │ ├── intra.cl │ ├── motionsearch.cl │ ├── subpel.cl │ ├── weightp.cl │ └── x264-cl.h ├── osdep.c ├── osdep.h ├── pixel.c ├── pixel.h ├── ppc │ ├── dct.c │ ├── dct.h │ ├── deblock.c │ ├── deblock.h │ ├── mc.c │ ├── mc.h │ ├── pixel.c │ ├── pixel.h │ ├── ppccommon.h │ ├── predict.c │ ├── predict.h │ ├── quant.c │ └── quant.h ├── predict.c ├── predict.h ├── quant.c ├── quant.h ├── rectangle.c ├── rectangle.h ├── set.c ├── set.h ├── tables.c ├── tables.h ├── threadpool.c ├── threadpool.h ├── vlc.c ├── win32thread.c ├── win32thread.h └── x86 │ ├── bitstream-a.asm │ ├── bitstream.h │ ├── cabac-a.asm │ ├── const-a.asm │ ├── cpu-a.asm │ ├── dct-32.asm │ ├── dct-64.asm │ ├── dct-a.asm │ ├── dct.h │ ├── deblock-a.asm │ ├── deblock.h │ ├── mc-a.asm │ ├── mc-a2.asm │ ├── mc-c.c │ ├── mc.h │ ├── pixel-32.asm │ ├── pixel-a.asm │ ├── pixel.h │ ├── predict-a.asm │ ├── predict-c.c │ ├── predict.h │ ├── quant-a.asm │ ├── quant.h │ ├── sad-a.asm │ ├── sad16-a.asm │ ├── trellis-64.asm │ ├── util.h │ ├── x86inc.asm │ └── x86util.asm ├── config.guess ├── config.sub ├── configure ├── doc ├── ratecontrol.txt ├── regression_test.txt ├── standards.txt ├── threads.txt └── vui.txt ├── encoder ├── analyse.c ├── analyse.h ├── api.c ├── cabac.c ├── cavlc.c ├── encoder.c ├── lookahead.c ├── macroblock.c ├── macroblock.h ├── me.c ├── me.h ├── ratecontrol.c ├── ratecontrol.h ├── rdo.c ├── set.c ├── set.h ├── slicetype-cl.c ├── slicetype-cl.h └── slicetype.c ├── example.c ├── extras ├── avisynth_c.h ├── cl.h ├── cl_platform.h ├── getopt.c ├── getopt.h ├── intel_dispatcher.h ├── inttypes.h └── stdint.h ├── filters ├── filters.c ├── filters.h └── video │ ├── cache.c │ ├── crop.c │ ├── depth.c │ ├── fix_vfr_pts.c │ ├── internal.c │ ├── internal.h │ ├── resize.c │ ├── select_every.c │ ├── source.c │ ├── video.c │ └── video.h ├── input ├── avs.c ├── ffms.c ├── input.c ├── input.h ├── lavf.c ├── raw.c ├── thread.c ├── timecode.c └── y4m.c ├── output ├── flv.c ├── flv_bytestream.c ├── flv_bytestream.h ├── matroska.c ├── matroska_ebml.c ├── matroska_ebml.h ├── mp4.c ├── mp4_lsmash.c ├── output.h └── raw.c ├── tools ├── bash-autocomplete.sh ├── checkasm-a.asm ├── checkasm-aarch64.S ├── checkasm-arm.S ├── checkasm-loongarch.S ├── checkasm.c ├── cltostr.sh ├── countquant_x264.pl ├── digress │ ├── __init__.py │ ├── cli.py │ ├── comparers.py │ ├── constants.py │ ├── errors.py │ ├── scm │ │ ├── __init__.py │ │ ├── dummy.py │ │ └── git.py │ └── testing.py ├── gas-preprocessor.pl ├── msvsdepend.sh ├── q_matrix_jvt.cfg └── test_x264.py ├── version.sh ├── x264.c ├── x264.h ├── x264cli.h ├── x264dll.c ├── x264res.manifest └── x264res.rc /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | This project provides additional functionality beyond what is provided by the project that it is based off. 4 | Ensure that any issues/pull requests submitted to this project are only for functionality that was provided by 5 | this project. Any issues/pull requests that are based off of the upstream project should be directed directly to them. 6 | 7 | When contributing a pull-request to this repository, please first discuss the change you wish to make via issue 8 | with the owners of this repository before making a change. Ensure that the change is only related to functionality 9 | provided by this project only. 10 | 11 | Please note we have a code of conduct, please follow it in all your interactions with the project. 12 | 13 | ## Submitting Changes 14 | 15 | Changes are excepted by submitting a pull request directly to the projects Github page. 16 | When creating the pull request the provided template should be used to ensure all required information is provided. 17 | 18 | ## Code of Conduct 19 | 20 | ### Our Pledge 21 | 22 | In the interest of fostering an open and welcoming environment, we as 23 | contributors and maintainers pledge to making participation in our project and 24 | our community a harassment-free experience for everyone, regardless of age, body 25 | size, disability, ethnicity, gender identity and expression, level of experience, 26 | nationality, personal appearance, race, religion, or sexual identity and 27 | orientation. 28 | 29 | ### Our Standards 30 | 31 | Examples of behavior that contributes to creating a positive environment 32 | include: 33 | 34 | * Using welcoming and inclusive language 35 | * Being respectful of differing viewpoints and experiences 36 | * Gracefully accepting constructive criticism 37 | * Focusing on what is best for the community 38 | * Showing empathy towards other community members 39 | 40 | Examples of unacceptable behavior by participants include: 41 | 42 | * The use of sexualized language or imagery and unwelcome sexual attention or 43 | advances 44 | * Trolling, insulting/derogatory comments, and personal or political attacks 45 | * Public or private harassment 46 | * Publishing others' private information, such as a physical or electronic 47 | address, without explicit permission 48 | * Other conduct which could reasonably be considered inappropriate in a 49 | professional setting 50 | 51 | ### Our Responsibilities 52 | 53 | Project maintainers are responsible for clarifying the standards of acceptable 54 | behavior and are expected to take appropriate and fair corrective action in 55 | response to any instances of unacceptable behavior. 56 | 57 | Project maintainers have the right and responsibility to remove, edit, or 58 | reject comments, commits, code, wiki edits, issues, and other contributions 59 | that are not aligned to this Code of Conduct, or to ban temporarily or 60 | permanently any contributor for other behaviors that they deem inappropriate, 61 | threatening, offensive, or harmful. 62 | 63 | ### Scope 64 | 65 | This Code of Conduct applies both within project spaces and in public spaces 66 | when an individual is representing the project or its community. Examples of 67 | representing a project or community include using an official project e-mail 68 | address, posting via an official social media account, or acting as an appointed 69 | representative at an online or offline event. Representation of a project may be 70 | further defined and clarified by project maintainers. 71 | 72 | ### Enforcement 73 | 74 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 75 | reported by contacting the project team. All 76 | complaints will be reviewed and investigated and will result in a response that 77 | is deemed necessary and appropriate to the circumstances. The project team is 78 | obligated to maintain confidentiality with regard to the reporter of an incident. 79 | Further details of specific enforcement policies may be posted separately. 80 | 81 | Project maintainers who do not follow or enforce the Code of Conduct in good 82 | faith may face temporary or permanent repercussions as determined by other 83 | members of the project's leadership. 84 | 85 | ### Attribution 86 | 87 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 88 | available at [http://contributor-covenant.org/version/1/4][version] 89 | 90 | [homepage]: http://contributor-covenant.org 91 | [version]: http://contributor-covenant.org/version/1/4/ -------------------------------------------------------------------------------- /.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 | *~ 2 | *.a 3 | *.diff 4 | *.orig 5 | *.rej 6 | *.dll* 7 | *.exe 8 | *.def 9 | *.lib 10 | *.pdb 11 | *.mo 12 | *.o 13 | *.patch 14 | *.pc 15 | *.pot 16 | *.so* 17 | *.dylib 18 | .*.swp 19 | .depend 20 | .DS_Store 21 | TAGS 22 | config.h 23 | config.mak 24 | config.log 25 | x264_config.h 26 | x264 27 | checkasm 28 | 29 | *.264 30 | *.h264 31 | *.2pass 32 | *.ffindex 33 | *.avs 34 | *.mkv 35 | *.flv 36 | *.mp4 37 | *.y4m 38 | *.yuv 39 | *.log 40 | *.mbtree 41 | *.temp 42 | *.pyc 43 | *.pgd 44 | *.pgc 45 | 46 | .digress_x264 47 | dataDec.txt 48 | log.dec 49 | common/oclobj.h 50 | x264_lookahead.clbin 51 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # Contributors to x264 2 | # 3 | # The format of this file was inspired by the Linux kernel CREDITS file. 4 | # Authors are listed alphabetically. 5 | # 6 | # The fields are: name (N), email (E), web-address (W), CVS account login (C), 7 | # PGP key ID and fingerprint (P), description (D), and snail-mail address (S). 8 | 9 | N: Alex Izvorski 10 | E: aizvorski AT gmail DOT com 11 | D: x86 asm (sse2) 12 | 13 | N: Alex Wright 14 | E: alexw0885 AT gmail DOT com 15 | D: Motion estimation (subpel and mixed refs) 16 | D: B-RDO 17 | 18 | N: bobololo 19 | D: Avisynth input 20 | D: MP4 muxing 21 | 22 | N: Christian Heine 23 | E: sennindemokrit AT gmx DOT net 24 | D: x86 asm 25 | 26 | N: David Wolstencroft 27 | D: Altivec optimizations 28 | 29 | N: Eric Petit 30 | E: eric.petit AT lapsus DOT org 31 | C: titer 32 | D: Altivec asm 33 | D: BeOS and MacOS X ports. 34 | S: France 35 | 36 | N: Fiona Glaser 37 | E: fiona AT x264 DOT com 38 | D: Maintainer 39 | D: All areas of encoder analysis and algorithms 40 | D: Motion estimation, rate control, macroblock & frame decisions, RDO, etc 41 | D: x86 asm 42 | S: USA 43 | 44 | N: Gabriel Bouvigne 45 | E: bouvigne AT mp3-tech DOT org 46 | D: 2pass VBV 47 | 48 | N: Guillaume Poirier 49 | E: gpoirier CHEZ mplayerhq POINT hu 50 | D: Altivec optimizations 51 | S: Brittany, France 52 | 53 | N: Henrik Gramner 54 | E: henrik AT gramner DOT com 55 | D: 4:2:2 chroma subsampling, x86 asm, Windows improvements, bugfixes 56 | S: Sweden 57 | 58 | N: Laurent Aimar 59 | E: fenrir AT videolan DOT org 60 | C: fenrir 61 | D: Initial import, former maintainer 62 | D: x86 asm (mmx/mmx2) 63 | S: France 64 | 65 | N: Loren Merritt 66 | E: pengvado AT akuvian DOT org 67 | C: pengvado 68 | D: Maintainer 69 | D: All areas of encoder analysis and algorithms 70 | D: Motion estimation, rate control, macroblock & frame decisions, RDO, etc 71 | D: Multithreading 72 | D: x86 asm 73 | S: USA 74 | 75 | N: Mans Rullgard 76 | E: mru AT mansr DOT com 77 | C: mru 78 | D: Rate control 79 | S: Southampton, UK 80 | 81 | N: Michael Niedermayer 82 | E: michaelni AT gmx DOT at 83 | D: Rate control 84 | 85 | N: Mike Matsnev 86 | E: mike AT po DOT cs DOT msu DOT su 87 | D: Matroska muxing 88 | 89 | N: Min Chen 90 | E: chenm001 AT 163 DOT com 91 | C: chenm001 92 | D: Win32/VC 6.0 port 93 | D: gcc asm to nasm conversion 94 | S: China 95 | 96 | N: Radek Czyz 97 | E: radoslaw AT syskin DOT cjb DOT net 98 | D: Cached motion compensation 99 | 100 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | ShiftMediaProject x264 2 | ============= 3 | [![Build status](https://ci.appveyor.com/api/projects/status/21frbu7w0l6ul59t?svg=true)](https://ci.appveyor.com/project/Sibras/x264) 4 | [![Github All Releases](https://img.shields.io/github/downloads/ShiftMediaProject/x264/total.svg)](https://github.com/ShiftMediaProject/x264/releases) 5 | [![GitHub release](https://img.shields.io/github/release/ShiftMediaProject/x264.svg)](https://github.com/ShiftMediaProject/x264/releases/latest) 6 | [![GitHub issues](https://img.shields.io/github/issues/ShiftMediaProject/x264.svg)](https://github.com/ShiftMediaProject/x264/issues) 7 | [![license](https://img.shields.io/github/license/ShiftMediaProject/x264.svg)](https://github.com/ShiftMediaProject/x264) 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 x264 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 | ## x264 14 | 15 | A free software library and application for encoding video streams into the H.264/MPEG-4 AVC format. [https://www.videolan.org/developers/x264.html](https://www.videolan.org/developers/x264.html) 16 | 17 | ## Downloads 18 | 19 | Development libraries are available from the [releases](https://github.com/ShiftMediaProject/x264/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/x264/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/config.h: -------------------------------------------------------------------------------- 1 | #define HAVE_MMX 1 2 | #if defined(_M_X64) 3 | # define ARCH_X86_64 1 4 | # define ARCH_X86_32 0 5 | # define ARCH_X86 0 6 | # define STACK_ALIGNMENT 16 7 | #else 8 | # define ARCH_X86_64 0 9 | # define ARCH_X86_32 1 10 | # define ARCH_X86 1 11 | # define STACK_ALIGNMENT 4 12 | #endif 13 | #define SYS_WINDOWS 1 14 | #define HAVE_WIN32THREAD 1 15 | #define HAVE_THREAD 1 16 | #define HAVE_LOG2F 1 17 | #define HAVE_AVS 1 18 | #define USE_AVXSYNTH 0 19 | #define HAVE_VECTOREXT 0 20 | #define fseek _fseeki64 21 | #define ftell _ftelli64 22 | #define HAVE_GPL 1 23 | #define HAVE_INTERLACED 1 24 | #if (BIT_DEPTH==8) && (!defined(WINAPI_FAMILY) || (WINAPI_FAMILY!=WINAPI_FAMILY_PC_APP && WINAPI_FAMILY!=WINAPI_FAMILY_PHONE_APP)) 25 | # define HAVE_OPENCL 1 26 | #else 27 | # define HAVE_OPENCL 0 28 | #endif 29 | #define HAVE_MALLOC_H 0 30 | #define HAVE_ALTIVEC 0 31 | #define HAVE_ALTIVEC_H 0 32 | #define HAVE_ARMV6 0 33 | #define HAVE_ARMV6T2 0 34 | #define HAVE_NEON 0 35 | #define HAVE_BEOSTHREAD 0 36 | #define HAVE_POSIXTHREAD 0 37 | #define HAVE_SWSCALE 0 38 | #define HAVE_LAVF 0 39 | #define HAVE_FFMS 0 40 | #define HAVE_GPAC 0 41 | #define HAVE_CPU_COUNT 0 42 | #define HAVE_THP 0 43 | #define HAVE_LSMASH 0 44 | #if defined(__INTEL_COMPILER) 45 | # define HAVE_X86_INLINE_ASM 1 46 | #else 47 | # define HAVE_X86_INLINE_ASM 0 48 | #endif 49 | #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_PC_APP || WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP) 50 | #define HAVE_WINRT 1 51 | #else 52 | #define HAVE_WINRT 0 53 | #endif 54 | #define HAVE_BITDEPTH8 1 55 | #define HAVE_BITDEPTH10 1 -------------------------------------------------------------------------------- /SMP/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | This is a small list of steps in order to build libx264 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 | (lib264_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 x264 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/x264_config.h: -------------------------------------------------------------------------------- 1 | #define X264_BIT_DEPTH 8 2 | #define X264_GPL 1 3 | #define X264_INTERLACED 1 4 | #define X264_CHROMA_FORMAT 0 5 | #define X264_REV 3194 6 | #define X264_REV_DIFF 0 7 | #define X264_VERSION " r3194" 8 | #define X264_POINTVER "0.164.3194" 9 | -------------------------------------------------------------------------------- /SMP/x264_with_latest_sdk.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | SET PROJECT=x264 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 | -------------------------------------------------------------------------------- /common/aarch64/asm-offsets.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * asm-offsets.c: check asm offsets for aarch64 3 | ***************************************************************************** 4 | * Copyright (C) 2014-2024 x264 project 5 | * 6 | * Authors: Janne Grunau 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #include "common/common.h" 27 | #include "asm-offsets.h" 28 | 29 | #define STATIC_ASSERT(name, x) int assert_##name[2 * !!(x) - 1] 30 | 31 | #define X264_CHECK_OFFSET(s, m, o) struct check_##s##_##m \ 32 | { \ 33 | STATIC_ASSERT(offset_##m, offsetof(s, m) == o); \ 34 | } 35 | 36 | #define X264_CHECK_REL_OFFSET(s, a, type, b) struct check_##s##_##a##_##b \ 37 | { \ 38 | STATIC_ASSERT(rel_offset_##a##_##b, offsetof(s, a) + sizeof(type) == offsetof(s, b)); \ 39 | } 40 | 41 | 42 | X264_CHECK_OFFSET(x264_cabac_t, i_low, CABAC_I_LOW); 43 | X264_CHECK_OFFSET(x264_cabac_t, i_range, CABAC_I_RANGE); 44 | X264_CHECK_OFFSET(x264_cabac_t, i_queue, CABAC_I_QUEUE); 45 | X264_CHECK_OFFSET(x264_cabac_t, i_bytes_outstanding, CABAC_I_BYTES_OUTSTANDING); 46 | X264_CHECK_OFFSET(x264_cabac_t, p_start, CABAC_P_START); 47 | X264_CHECK_OFFSET(x264_cabac_t, p, CABAC_P); 48 | X264_CHECK_OFFSET(x264_cabac_t, p_end, CABAC_P_END); 49 | X264_CHECK_OFFSET(x264_cabac_t, f8_bits_encoded, CABAC_F8_BITS_ENCODED); 50 | X264_CHECK_OFFSET(x264_cabac_t, state, CABAC_STATE); 51 | 52 | // the aarch64 asm makes following additional assumptions about the x264_cabac_t 53 | // memory layout 54 | 55 | X264_CHECK_REL_OFFSET(x264_cabac_t, i_low, int, i_range); 56 | X264_CHECK_REL_OFFSET(x264_cabac_t, i_queue, int, i_bytes_outstanding); 57 | -------------------------------------------------------------------------------- /common/aarch64/asm-offsets.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * asm-offsets.h: asm offsets for aarch64 3 | ***************************************************************************** 4 | * Copyright (C) 2014-2024 x264 project 5 | * 6 | * Authors: Janne Grunau 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_AARCH64_ASM_OFFSETS_H 27 | #define X264_AARCH64_ASM_OFFSETS_H 28 | 29 | #define CABAC_I_LOW 0x00 30 | #define CABAC_I_RANGE 0x04 31 | #define CABAC_I_QUEUE 0x08 32 | #define CABAC_I_BYTES_OUTSTANDING 0x0c 33 | #define CABAC_P_START 0x10 34 | #define CABAC_P 0x18 35 | #define CABAC_P_END 0x20 36 | #define CABAC_F8_BITS_ENCODED 0x30 37 | #define CABAC_STATE 0x34 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /common/aarch64/bitstream-a.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * bitstream-a.S: aarch64 bitstream functions 3 | ***************************************************************************** 4 | * Copyright (C) 2014-2024 x264 project 5 | * 6 | * Authors: Janne Grunau 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #include "asm.S" 27 | 28 | function nal_escape_neon, export=1 29 | movi v0.16b, #0xff 30 | movi v4.16b, #4 31 | mov w3, #3 32 | subs x6, x1, x2 33 | cbz x6, 99f 34 | 0: 35 | cmn x6, #15 36 | b.lt 16f 37 | mov x1, x2 38 | b 100f 39 | 16: 40 | ld1 {v1.16b}, [x1], #16 41 | ext v2.16b, v0.16b, v1.16b, #14 42 | ext v3.16b, v0.16b, v1.16b, #15 43 | cmhi v7.16b, v4.16b, v1.16b 44 | cmeq v5.16b, v2.16b, #0 45 | cmeq v6.16b, v3.16b, #0 46 | and v5.16b, v5.16b, v7.16b 47 | and v5.16b, v5.16b, v6.16b 48 | shrn v7.8b, v5.8h, #4 49 | mov x7, v7.d[0] 50 | cbz x7, 16f 51 | mov x6, #-16 52 | 100: 53 | umov w5, v0.b[14] 54 | umov w4, v0.b[15] 55 | orr w5, w4, w5, lsl #8 56 | 101: 57 | ldrb w4, [x1, x6] 58 | orr w9, w4, w5, lsl #16 59 | cmp w9, #3 60 | b.hi 102f 61 | strb w3, [x0], #1 62 | orr w5, w3, w5, lsl #8 63 | 102: 64 | adds x6, x6, #1 65 | strb w4, [x0], #1 66 | orr w5, w4, w5, lsl #8 67 | b.lt 101b 68 | subs x6, x1, x2 69 | lsr w9, w5, #8 70 | mov v0.b[14], w9 71 | mov v0.b[15], w5 72 | b.lt 0b 73 | 74 | ret 75 | 16: 76 | subs x6, x1, x2 77 | st1 {v1.16b}, [x0], #16 78 | mov v0.16b, v1.16b 79 | b.lt 0b 80 | 99: 81 | ret 82 | endfunc 83 | -------------------------------------------------------------------------------- /common/aarch64/bitstream.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * bitstream.h: aarch64 bitstream functions 3 | ***************************************************************************** 4 | * Copyright (C) 2017-2024 x264 project 5 | * 6 | * Authors: Anton Mitrofanov 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_AARCH64_BITSTREAM_H 27 | #define X264_AARCH64_BITSTREAM_H 28 | 29 | #define x264_nal_escape_neon x264_template(nal_escape_neon) 30 | uint8_t *x264_nal_escape_neon( uint8_t *dst, uint8_t *src, uint8_t *end ); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /common/aarch64/dct-a-common.S: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * dct-a-common.S: aarch64 transform and zigzag 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2024 x264 project 5 | * 6 | * Authors: David Conrad 7 | * Janne Grunau 8 | * David Chen 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 licensing@x264.com. 26 | *****************************************************************************/ 27 | 28 | // This file contains the NEON macros that are intended to be used by 29 | // the SVE/SVE2 functions as well 30 | 31 | .macro DCT_1D v0 v1 v2 v3 v4 v5 v6 v7 32 | SUMSUB_AB \v1, \v6, \v5, \v6 33 | SUMSUB_AB \v3, \v7, \v4, \v7 34 | add \v0, \v3, \v1 35 | add \v4, \v7, \v7 36 | add \v5, \v6, \v6 37 | sub \v2, \v3, \v1 38 | add \v1, \v4, \v6 39 | sub \v3, \v7, \v5 40 | .endm 41 | -------------------------------------------------------------------------------- /common/aarch64/dct-a-sve.S: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * dct-a-sve.S: aarch64 transform and zigzag 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2024 x264 project 5 | * 6 | * Authors: David 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #include "asm.S" 27 | #include "dct-a-common.S" 28 | 29 | .arch armv8-a+sve 30 | 31 | function sub4x4_dct_sve, export=1 32 | mov x3, #FENC_STRIDE 33 | mov x4, #FDEC_STRIDE 34 | ptrue p0.h, vl4 35 | ld1b {z0.h}, p0/z, [x1] 36 | add x1, x1, x3 37 | ld1b {z1.h}, p0/z, [x2] 38 | add x2, x2, x4 39 | ld1b {z2.h}, p0/z, [x1] 40 | add x1, x1, x3 41 | sub v16.4h, v0.4h, v1.4h 42 | ld1b {z3.h}, p0/z, [x2] 43 | add x2, x2, x4 44 | ld1b {z4.h}, p0/z, [x1] 45 | add x1, x1, x3 46 | sub v17.4h, v2.4h, v3.4h 47 | ld1b {z5.h}, p0/z, [x2] 48 | add x2, x2, x4 49 | ld1b {z6.h}, p0/z, [x1] 50 | sub v18.4h, v4.4h, v5.4h 51 | ld1b {z7.h}, p0/z, [x2] 52 | sub v19.4h, v6.4h, v7.4h 53 | 54 | DCT_1D v0.4h, v1.4h, v2.4h, v3.4h, v16.4h, v17.4h, v18.4h, v19.4h 55 | transpose4x4.h v0, v1, v2, v3, v4, v5, v6, v7 56 | DCT_1D v4.4h, v5.4h, v6.4h, v7.4h, v0.4h, v1.4h, v2.4h, v3.4h 57 | st1 {v4.4h,v5.4h,v6.4h,v7.4h}, [x0] 58 | ret 59 | endfunc 60 | 61 | function zigzag_interleave_8x8_cavlc_sve, export=1 62 | mov z31.s, #1 63 | ptrue p2.s, vl2 64 | ld4 {v0.8h,v1.8h,v2.8h,v3.8h}, [x1], #64 65 | ld4 {v4.8h,v5.8h,v6.8h,v7.8h}, [x1], #64 66 | umax v16.8h, v0.8h, v4.8h 67 | umax v17.8h, v1.8h, v5.8h 68 | umax v18.8h, v2.8h, v6.8h 69 | umax v19.8h, v3.8h, v7.8h 70 | st1 {v0.8h}, [x0], #16 71 | st1 {v4.8h}, [x0], #16 72 | umaxp v16.8h, v16.8h, v17.8h 73 | umaxp v18.8h, v18.8h, v19.8h 74 | st1 {v1.8h}, [x0], #16 75 | st1 {v5.8h}, [x0], #16 76 | umaxp v16.8h, v16.8h, v18.8h 77 | st1 {v2.8h}, [x0], #16 78 | st1 {v6.8h}, [x0], #16 79 | cmhs v16.4s, v16.4s, v31.4s 80 | st1 {v3.8h}, [x0], #16 81 | and v16.16b, v16.16b, v31.16b 82 | st1 {v7.8h}, [x0], #16 83 | st1b {z16.s}, p2, [x2] 84 | add x2, x2, #8 85 | mov v16.d[0], v16.d[1] 86 | st1b {z16.s}, p2, [x2] 87 | ret 88 | endfunc 89 | -------------------------------------------------------------------------------- /common/aarch64/dct-a-sve2.S: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * dct-a-sve2.S: aarch64 transform and zigzag 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2024 x264 project 5 | * 6 | * Authors: David 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #include "asm.S" 27 | #include "dct-a-common.S" 28 | 29 | .arch armv8-a+sve+sve2 30 | 31 | function add4x4_idct_sve2, export=1 32 | mov x2, #FDEC_STRIDE 33 | mov x11, x0 34 | ptrue p0.h, vl8 35 | ptrue p1.h, vl4 36 | ld1 {v0.8h, v1.8h}, [x1] 37 | 38 | SUMSUB_AB v4.8h, v5.8h, v0.8h, v1.8h 39 | 40 | sshr v7.8h, v0.8h, #1 41 | sshr v6.8h, v1.8h, #1 42 | sub v7.8h, v7.8h, v1.8h 43 | add v6.8h, v6.8h, v0.8h 44 | mov v7.d[0], v7.d[1] 45 | mov v6.d[0], v6.d[1] 46 | ld1b {z28.h}, p0/z, [x11] 47 | add x11, x11, x2 48 | SUMSUB_AB v0.8h, v2.8h, v4.8h, v6.8h 49 | SUMSUB_AB v1.8h, v3.8h, v5.8h, v7.8h 50 | 51 | transpose4x4.h v0, v1, v3, v2, v16, v17, v18, v19 52 | 53 | SUMSUB_AB v4.4h, v5.4h, v0.4h, v3.4h 54 | 55 | sshr v7.4h, v1.4h, #1 56 | sshr v6.4h, v2.4h, #1 57 | sub v7.4h, v7.4h, v2.4h 58 | add v6.4h, v6.4h, v1.4h 59 | ld1b {z29.h}, p0/z, [x11] 60 | add x11, x11, x2 61 | SUMSUB_AB v0.4h, v2.4h, v4.4h, v6.4h 62 | SUMSUB_AB v1.4h, v3.4h, v5.4h, v7.4h 63 | 64 | srshr z0.h, p1/m, z0.h, #6 65 | srshr z1.h, p1/m, z1.h, #6 66 | ld1b {z31.h}, p0/z, [x11] 67 | add x11, x11, x2 68 | srshr z2.h, p1/m, z2.h, #6 69 | srshr z3.h, p1/m, z3.h, #6 70 | ld1b {z30.h}, p0/z, [x11] 71 | 72 | add v0.8h, v0.8h, v28.8h 73 | add v1.8h, v1.8h, v29.8h 74 | add v2.8h, v2.8h, v30.8h 75 | add v3.8h, v3.8h, v31.8h 76 | sqxtunb z0.b, z0.h 77 | sqxtunb z1.b, z1.h 78 | sqxtunb z2.b, z2.h 79 | sqxtunb z3.b, z3.h 80 | 81 | st1b {z0.h}, p1, [x0] 82 | add x0, x0, x2 83 | st1b {z1.h}, p1, [x0] 84 | add x0, x0, x2 85 | st1b {z3.h}, p1, [x0] 86 | add x0, x0, x2 87 | st1b {z2.h}, p1, [x0] 88 | ret 89 | endfunc 90 | -------------------------------------------------------------------------------- /common/aarch64/deblock-a-common.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * deblock-a-common.S: aarch64 deblocking 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2024 x264 project 5 | * 6 | * Authors: Mans Rullgard 7 | * Janne Grunau 8 | * David Chen 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 licensing@x264.com. 26 | *****************************************************************************/ 27 | 28 | // This file contains the NEON macros that are intended to be used by 29 | // the SVE/SVE2 functions as well 30 | 31 | .macro h264_loop_filter_start 32 | cmp w2, #0 33 | ldr w6, [x4] 34 | ccmp w3, #0, #0, ne 35 | mov v24.s[0], w6 36 | and w8, w6, w6, lsl #16 37 | b.eq 1f 38 | ands w8, w8, w8, lsl #8 39 | b.ge 2f 40 | 1: 41 | ret 42 | 2: 43 | .endm 44 | -------------------------------------------------------------------------------- /common/aarch64/deblock-a-sve.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * deblock-a-sve.S: aarch64 deblocking 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2024 x264 project 5 | * 6 | * Authors: David 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #include "asm.S" 27 | #include "deblock-a-common.S" 28 | 29 | .arch armv8-a+sve 30 | 31 | .macro h264_loop_filter_chroma_sve 32 | ptrue p0.b, vl16 33 | 34 | dup v22.16b, w2 // alpha 35 | uxtl v24.8h, v24.8b 36 | uabd v26.16b, v16.16b, v0.16b // abs(p0 - q0) 37 | uxtl v4.8h, v0.8b 38 | uxtl2 v5.8h, v0.16b 39 | uabd v28.16b, v18.16b, v16.16b // abs(p1 - p0) 40 | usubw v4.8h, v4.8h, v16.8b 41 | usubw2 v5.8h, v5.8h, v16.16b 42 | sli v24.8h, v24.8h, #8 43 | shl v4.8h, v4.8h, #2 44 | shl v5.8h, v5.8h, #2 45 | uabd v30.16b, v2.16b, v0.16b // abs(q1 - q0) 46 | uxtl v24.4s, v24.4h 47 | uaddw v4.8h, v4.8h, v18.8b 48 | uaddw2 v5.8h, v5.8h, v18.16b 49 | 50 | cmphi p1.b, p0/z, z22.b, z26.b 51 | usubw v4.8h, v4.8h, v2.8b 52 | usubw2 v5.8h, v5.8h, v2.16b 53 | sli v24.4s, v24.4s, #16 54 | dup v22.16b, w3 // beta 55 | rshrn v4.8b, v4.8h, #3 56 | rshrn2 v4.16b, v5.8h, #3 57 | cmphi p2.b, p0/z, z22.b, z28.b 58 | cmphi p3.b, p0/z, z22.b, z30.b 59 | smin v4.16b, v4.16b, v24.16b 60 | neg v25.16b, v24.16b 61 | and p1.b, p0/z, p1.b, p2.b 62 | smax v4.16b, v4.16b, v25.16b 63 | and p1.b, p0/z, p1.b, p3.b 64 | uxtl v22.8h, v0.8b 65 | uxtl2 v23.8h, v0.16b 66 | 67 | uxtl v28.8h, v16.8b 68 | uxtl2 v29.8h, v16.16b 69 | saddw v28.8h, v28.8h, v4.8b 70 | saddw2 v29.8h, v29.8h, v4.16b 71 | ssubw v22.8h, v22.8h, v4.8b 72 | ssubw2 v23.8h, v23.8h, v4.16b 73 | sqxtun v16.8b, v28.8h 74 | sqxtun v0.8b, v22.8h 75 | sqxtun2 v16.16b, v29.8h 76 | sqxtun2 v0.16b, v23.8h 77 | .endm 78 | 79 | function deblock_v_chroma_sve, export=1 80 | h264_loop_filter_start 81 | 82 | sub x0, x0, x1, lsl #1 83 | // No performance improvement if sve load is used. So, continue using 84 | // NEON load here 85 | ld1 {v18.16b}, [x0], x1 86 | ld1 {v16.16b}, [x0], x1 87 | ld1 {v0.16b}, [x0], x1 88 | ld1 {v2.16b}, [x0] 89 | 90 | h264_loop_filter_chroma_sve 91 | 92 | sub x0, x0, x1, lsl #1 93 | st1b {z16.b}, p1, [x0] 94 | add x0, x0, x1 95 | st1b {z0.b}, p1, [x0] 96 | 97 | ret 98 | endfunc 99 | -------------------------------------------------------------------------------- /common/aarch64/deblock.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * deblock.h: aarch64 deblocking 3 | ***************************************************************************** 4 | * Copyright (C) 2017-2024 x264 project 5 | * 6 | * Authors: Anton Mitrofanov 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_AARCH64_DEBLOCK_H 27 | #define X264_AARCH64_DEBLOCK_H 28 | 29 | #define x264_deblock_v_luma_neon x264_template(deblock_v_luma_neon) 30 | void x264_deblock_v_luma_neon ( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 31 | #define x264_deblock_h_luma_neon x264_template(deblock_h_luma_neon) 32 | void x264_deblock_h_luma_neon ( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 33 | #define x264_deblock_v_chroma_neon x264_template(deblock_v_chroma_neon) 34 | void x264_deblock_v_chroma_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 35 | #define x264_deblock_h_chroma_neon x264_template(deblock_h_chroma_neon) 36 | void x264_deblock_h_chroma_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 37 | #define x264_deblock_strength_neon x264_template(deblock_strength_neon) 38 | void x264_deblock_strength_neon( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE], 39 | int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4], 40 | int mvy_limit, int bframe ); 41 | #define x264_deblock_h_chroma_422_neon x264_template(deblock_h_chroma_422_neon) 42 | void x264_deblock_h_chroma_422_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 43 | #define x264_deblock_h_chroma_mbaff_neon x264_template(deblock_h_chroma_mbaff_neon) 44 | void x264_deblock_h_chroma_mbaff_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 45 | #define x264_deblock_h_chroma_intra_mbaff_neon x264_template(deblock_h_chroma_intra_mbaff_neon) 46 | void x264_deblock_h_chroma_intra_mbaff_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 47 | #define x264_deblock_h_chroma_intra_neon x264_template(deblock_h_chroma_intra_neon) 48 | void x264_deblock_h_chroma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 49 | #define x264_deblock_h_chroma_422_intra_neon x264_template(deblock_h_chroma_422_intra_neon) 50 | void x264_deblock_h_chroma_422_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 51 | #define x264_deblock_v_chroma_intra_neon x264_template(deblock_v_chroma_intra_neon) 52 | void x264_deblock_v_chroma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 53 | #define x264_deblock_h_luma_intra_neon x264_template(deblock_h_luma_intra_neon) 54 | void x264_deblock_h_luma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 55 | #define x264_deblock_v_luma_intra_neon x264_template(deblock_v_luma_intra_neon) 56 | void x264_deblock_v_luma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 57 | 58 | #define x264_deblock_v_chroma_sve x264_template(deblock_v_chroma_sve) 59 | void x264_deblock_v_chroma_sve( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /common/aarch64/mc-a-common.S: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * mc-a-common.S: aarch64 motion compensation 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2024 x264 project 5 | * 6 | * Authors: David Conrad 7 | * Janne Grunau 8 | * Mans Rullgard 9 | * Stefan Groenroos 10 | * David Chen 11 | * 12 | * This program is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with this program; if not, write to the Free Software 24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 25 | * 26 | * This program is also available under a commercial proprietary license. 27 | * For more information, contact us at licensing@x264.com. 28 | *****************************************************************************/ 29 | 30 | // This file contains the NEON macros and functions that are intended to be used by 31 | // the SVE/SVE2 functions as well 32 | 33 | #if BIT_DEPTH == 8 34 | 35 | // 0 < weight < 64 36 | .macro load_weights_add_add 37 | mov w6, w6 38 | .endm 39 | 40 | // weight > 64 41 | .macro load_weights_add_sub 42 | neg w7, w7 43 | .endm 44 | 45 | // weight < 0 46 | .macro load_weights_sub_add 47 | neg w6, w6 48 | .endm 49 | 50 | function pixel_avg_w4_neon 51 | 1: subs w9, w9, #2 52 | ld1 {v0.s}[0], [x2], x3 53 | ld1 {v2.s}[0], [x4], x5 54 | urhadd v0.8b, v0.8b, v2.8b 55 | ld1 {v1.s}[0], [x2], x3 56 | ld1 {v3.s}[0], [x4], x5 57 | urhadd v1.8b, v1.8b, v3.8b 58 | st1 {v0.s}[0], [x0], x1 59 | st1 {v1.s}[0], [x0], x1 60 | b.gt 1b 61 | ret 62 | endfunc 63 | 64 | #else // BIT_DEPTH == 10 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /common/aarch64/mc-a-sve.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * mc-a-sve.S: aarch64 motion compensation 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2024 x264 project 5 | * 6 | * Authors: David 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #include "asm.S" 27 | #include "mc-a-common.S" 28 | 29 | .arch armv8-a+sve 30 | 31 | #if BIT_DEPTH == 8 32 | 33 | // void pixel_avg( uint8_t *dst, intptr_t dst_stride, 34 | // uint8_t *src1, intptr_t src1_stride, 35 | // uint8_t *src2, intptr_t src2_stride, int weight ); 36 | .macro AVGH_SVE w h 37 | function pixel_avg_\w\()x\h\()_sve, export=1 38 | mov w10, #64 39 | cmp w6, #32 40 | mov w9, #\h 41 | b.eq pixel_avg_w\w\()_neon 42 | subs w7, w10, w6 43 | b.lt pixel_avg_weight_w\w\()_add_sub_sve // weight > 64 44 | cmp w6, #0 45 | b.ge pixel_avg_weight_w\w\()_add_add_sve 46 | b pixel_avg_weight_w\w\()_sub_add_sve // weight < 0 47 | endfunc 48 | .endm 49 | 50 | AVGH_SVE 4, 2 51 | AVGH_SVE 4, 4 52 | AVGH_SVE 4, 8 53 | AVGH_SVE 4, 16 54 | 55 | // 0 < weight < 64 56 | .macro weight_add_add_sve dst, s1, s2, h= 57 | mul \dst, \s1, v30.8h 58 | mla \dst, \s2, v31.8h 59 | .endm 60 | 61 | // weight > 64 62 | .macro weight_add_sub_sve dst, s1, s2, h= 63 | mul \dst, \s1, v30.8h 64 | mls \dst, \s2, v31.8h 65 | .endm 66 | 67 | // weight < 0 68 | .macro weight_sub_add_sve dst, s1, s2, h= 69 | mul \dst, \s2, v31.8h 70 | mls \dst, \s1, v30.8h 71 | .endm 72 | 73 | .macro AVG_WEIGHT_SVE ext 74 | function pixel_avg_weight_w4_\ext\()_sve 75 | load_weights_\ext 76 | ptrue p0.b, vl8 77 | dup v30.8h, w6 78 | dup v31.8h, w7 79 | 1: // height loop 80 | subs w9, w9, #2 81 | ld1b {z0.h}, p0/z, [x2] 82 | add x2, x2, x3 83 | ld1b {z1.h}, p0/z, [x4] 84 | add x4, x4, x5 85 | weight_\ext\()_sve v4.8h, v0.8h, v1.8h 86 | ld1b {z2.h}, p0/z, [x2] 87 | add x2, x2, x3 88 | ld1b {z3.h}, p0/z, [x4] 89 | add x4, x4, x5 90 | 91 | sqrshrun v0.8b, v4.8h, #6 92 | weight_\ext\()_sve v5.8h, v2.8h, v3.8h 93 | st1 {v0.s}[0], [x0], x1 94 | sqrshrun v1.8b, v5.8h, #6 95 | st1 {v1.s}[0], [x0], x1 96 | b.gt 1b 97 | ret 98 | endfunc 99 | .endm 100 | 101 | AVG_WEIGHT_SVE add_add 102 | AVG_WEIGHT_SVE add_sub 103 | AVG_WEIGHT_SVE sub_add 104 | 105 | #else // BIT_DEPTH == 10 106 | 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /common/aarch64/mc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * mc.h: aarch64 motion compensation 3 | ***************************************************************************** 4 | * Copyright (C) 2014-2024 x264 project 5 | * 6 | * Authors: Janne Grunau 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_AARCH64_MC_H 27 | #define X264_AARCH64_MC_H 28 | 29 | #define x264_mc_init_aarch64 x264_template(mc_init_aarch64) 30 | void x264_mc_init_aarch64( uint32_t cpu, x264_mc_functions_t *pf ); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /common/aarch64/pixel-a-common.S: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * pixel-a-common.S: aarch64 pixel metrics 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2024 x264 project 5 | * 6 | * Authors: David Conrad 7 | * Janne Grunau 8 | * David Chen 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 licensing@x264.com. 26 | *****************************************************************************/ 27 | 28 | // This file contains the NEON macros and constants that are intended to be used by 29 | // the SVE/SVE2 functions as well 30 | 31 | const mask_ac_4_8 32 | .short 0, -1, -1, -1, 0, -1, -1, -1 33 | .short 0, -1, -1, -1, -1, -1, -1, -1 34 | endconst 35 | 36 | .macro SUMSUB_ABCD s1, d1, s2, d2, a, b, c, d 37 | SUMSUB_AB \s1, \d1, \a, \b 38 | SUMSUB_AB \s2, \d2, \c, \d 39 | .endm 40 | 41 | .macro HADAMARD4_V r1, r2, r3, r4, t1, t2, t3, t4 42 | SUMSUB_ABCD \t1, \t2, \t3, \t4, \r1, \r2, \r3, \r4 43 | SUMSUB_ABCD \r1, \r3, \r2, \r4, \t1, \t3, \t2, \t4 44 | .endm 45 | -------------------------------------------------------------------------------- /common/arm/bitstream-a.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * bitstream-a.S: arm bitstream functions 3 | ***************************************************************************** 4 | * Copyright (C) 2014-2024 x264 project 5 | * 6 | * Authors: Janne Grunau 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #include "asm.S" 27 | 28 | function nal_escape_neon 29 | push {r4-r5,lr} 30 | vmov.u8 q0, #0xff 31 | vmov.u8 q8, #4 32 | mov r3, #3 33 | subs lr, r1, r2 34 | beq 99f 35 | 0: 36 | cmn lr, #15 37 | blt 16f 38 | mov r1, r2 39 | b 100f 40 | 16: 41 | vld1.8 {q1}, [r1]! 42 | vext.8 q2, q0, q1, #14 43 | vext.8 q3, q0, q1, #15 44 | vcgt.u8 q11, q8, q1 45 | vceq.u8 q9, q2, #0 46 | vceq.u8 q10, q3, #0 47 | vand q9, q9, q11 48 | vand q9, q9, q10 49 | vshrn.u16 d22, q9, #4 50 | vmov ip, lr, d22 51 | orrs ip, ip, lr 52 | beq 16f 53 | mov lr, #-16 54 | 100: 55 | vmov.u8 r5, d1[6] 56 | vmov.u8 r4, d1[7] 57 | orr r5, r4, r5, lsl #8 58 | 101: 59 | ldrb r4, [r1, lr] 60 | orr ip, r4, r5, lsl #16 61 | cmp ip, #3 62 | bhi 102f 63 | strb r3, [r0], #1 64 | orr r5, r3, r5, lsl #8 65 | 102: 66 | adds lr, lr, #1 67 | strb r4, [r0], #1 68 | orr r5, r4, r5, lsl #8 69 | blt 101b 70 | subs lr, r1, r2 71 | lsr ip, r5, #8 72 | vmov.u8 d1[6], ip 73 | vmov.u8 d1[7], r5 74 | blt 0b 75 | 76 | pop {r4-r5,pc} 77 | 16: 78 | subs lr, r1, r2 79 | vst1.8 {q1}, [r0]! 80 | vmov q0, q1 81 | blt 0b 82 | 99: 83 | pop {r4-r5,pc} 84 | endfunc 85 | -------------------------------------------------------------------------------- /common/arm/bitstream.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * bitstream.h: arm bitstream functions 3 | ***************************************************************************** 4 | * Copyright (C) 2017-2024 x264 project 5 | * 6 | * Authors: Anton Mitrofanov 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_ARM_BITSTREAM_H 27 | #define X264_ARM_BITSTREAM_H 28 | 29 | #define x264_nal_escape_neon x264_template(nal_escape_neon) 30 | uint8_t *x264_nal_escape_neon( uint8_t *dst, uint8_t *src, uint8_t *end ); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /common/arm/cpu-a.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * cpu-a.S: arm cpu detection 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2024 x264 project 5 | * 6 | * Authors: David Conrad 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #include "asm.S" 27 | 28 | .align 2 29 | 30 | // done in gas because .fpu neon overrides the refusal to assemble 31 | // instructions the selected -march/-mcpu doesn't support 32 | function cpu_neon_test 33 | vadd.i16 q0, q0, q0 34 | bx lr 35 | endfunc 36 | 37 | // return: 0 on success 38 | // 1 if counters were already enabled 39 | // 9 if lo-res counters were already enabled 40 | function cpu_enable_armv7_counter, export=0 41 | mrc p15, 0, r2, c9, c12, 0 // read PMNC 42 | ands r0, r2, #1 43 | andne r0, r2, #9 44 | 45 | orr r2, r2, #1 // enable counters 46 | bic r2, r2, #8 // full resolution 47 | mcreq p15, 0, r2, c9, c12, 0 // write PMNC 48 | mov r2, #1 << 31 // enable cycle counter 49 | mcr p15, 0, r2, c9, c12, 1 // write CNTENS 50 | bx lr 51 | endfunc 52 | 53 | function cpu_disable_armv7_counter, export=0 54 | mrc p15, 0, r0, c9, c12, 0 // read PMNC 55 | bic r0, r0, #1 // disable counters 56 | mcr p15, 0, r0, c9, c12, 0 // write PMNC 57 | bx lr 58 | endfunc 59 | 60 | 61 | .macro READ_TIME r 62 | mrc p15, 0, \r, c9, c13, 0 63 | .endm 64 | 65 | // return: 0 if transfers neon -> arm transfers take more than 10 cycles 66 | // nonzero otherwise 67 | function cpu_fast_neon_mrc_test 68 | // check for user access to performance counters 69 | mrc p15, 0, r0, c9, c14, 0 70 | cmp r0, #0 71 | bxeq lr 72 | 73 | push {r4-r6,lr} 74 | bl cpu_enable_armv7_counter 75 | ands r1, r0, #8 76 | mov r3, #0 77 | mov ip, #4 78 | mov r6, #4 79 | moveq r5, #1 80 | movne r5, #64 81 | 82 | average_loop: 83 | mov r4, r5 84 | READ_TIME r1 85 | 1: subs r4, r4, #1 86 | .rept 8 87 | vmov.u32 lr, d0[0] 88 | add lr, lr, lr 89 | .endr 90 | bgt 1b 91 | READ_TIME r2 92 | 93 | subs r6, r6, #1 94 | sub r2, r2, r1 95 | cmpgt r2, #30 << 3 // assume context switch if it took over 30 cycles 96 | addle r3, r3, r2 97 | subsle ip, ip, #1 98 | bgt average_loop 99 | 100 | // disable counters if we enabled them 101 | ands r0, r0, #1 102 | bleq cpu_disable_armv7_counter 103 | 104 | lsr r0, r3, #5 105 | cmp r0, #10 106 | movgt r0, #0 107 | pop {r4-r6,pc} 108 | endfunc 109 | -------------------------------------------------------------------------------- /common/arm/dct.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * dct.h: arm transform and zigzag 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2024 x264 project 5 | * 6 | * Authors: David Conrad 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_ARM_DCT_H 27 | #define X264_ARM_DCT_H 28 | 29 | #define x264_dct4x4dc_neon x264_template(dct4x4dc_neon) 30 | void x264_dct4x4dc_neon( int16_t d[16] ); 31 | #define x264_idct4x4dc_neon x264_template(idct4x4dc_neon) 32 | void x264_idct4x4dc_neon( int16_t d[16] ); 33 | 34 | #define x264_sub4x4_dct_neon x264_template(sub4x4_dct_neon) 35 | void x264_sub4x4_dct_neon( int16_t dct[16], uint8_t *pix1, uint8_t *pix2 ); 36 | #define x264_sub8x8_dct_neon x264_template(sub8x8_dct_neon) 37 | void x264_sub8x8_dct_neon( int16_t dct[4][16], uint8_t *pix1, uint8_t *pix2 ); 38 | #define x264_sub16x16_dct_neon x264_template(sub16x16_dct_neon) 39 | void x264_sub16x16_dct_neon( int16_t dct[16][16], uint8_t *pix1, uint8_t *pix2 ); 40 | 41 | #define x264_add4x4_idct_neon x264_template(add4x4_idct_neon) 42 | void x264_add4x4_idct_neon( uint8_t *p_dst, int16_t dct[16] ); 43 | #define x264_add8x8_idct_neon x264_template(add8x8_idct_neon) 44 | void x264_add8x8_idct_neon( uint8_t *p_dst, int16_t dct[4][16] ); 45 | #define x264_add16x16_idct_neon x264_template(add16x16_idct_neon) 46 | void x264_add16x16_idct_neon( uint8_t *p_dst, int16_t dct[16][16] ); 47 | 48 | #define x264_add8x8_idct_dc_neon x264_template(add8x8_idct_dc_neon) 49 | void x264_add8x8_idct_dc_neon( uint8_t *p_dst, int16_t dct[4] ); 50 | #define x264_add16x16_idct_dc_neon x264_template(add16x16_idct_dc_neon) 51 | void x264_add16x16_idct_dc_neon( uint8_t *p_dst, int16_t dct[16] ); 52 | #define x264_sub8x8_dct_dc_neon x264_template(sub8x8_dct_dc_neon) 53 | void x264_sub8x8_dct_dc_neon( int16_t dct[4], uint8_t *pix1, uint8_t *pix2 ); 54 | #define x264_sub8x16_dct_dc_neon x264_template(sub8x16_dct_dc_neon) 55 | void x264_sub8x16_dct_dc_neon( int16_t dct[8], uint8_t *pix1, uint8_t *pix2 ); 56 | 57 | #define x264_sub8x8_dct8_neon x264_template(sub8x8_dct8_neon) 58 | void x264_sub8x8_dct8_neon( int16_t dct[64], uint8_t *pix1, uint8_t *pix2 ); 59 | #define x264_sub16x16_dct8_neon x264_template(sub16x16_dct8_neon) 60 | void x264_sub16x16_dct8_neon( int16_t dct[4][64], uint8_t *pix1, uint8_t *pix2 ); 61 | 62 | #define x264_add8x8_idct8_neon x264_template(add8x8_idct8_neon) 63 | void x264_add8x8_idct8_neon( uint8_t *p_dst, int16_t dct[64] ); 64 | #define x264_add16x16_idct8_neon x264_template(add16x16_idct8_neon) 65 | void x264_add16x16_idct8_neon( uint8_t *p_dst, int16_t dct[4][64] ); 66 | 67 | #define x264_zigzag_scan_4x4_frame_neon x264_template(zigzag_scan_4x4_frame_neon) 68 | void x264_zigzag_scan_4x4_frame_neon( int16_t level[16], int16_t dct[16] ); 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /common/arm/deblock.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * deblock.h: arm deblocking 3 | ***************************************************************************** 4 | * Copyright (C) 2017-2024 x264 project 5 | * 6 | * Authors: Anton Mitrofanov 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_ARM_DEBLOCK_H 27 | #define X264_ARM_DEBLOCK_H 28 | 29 | #define x264_deblock_v_luma_neon x264_template(deblock_v_luma_neon) 30 | void x264_deblock_v_luma_neon ( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 31 | #define x264_deblock_h_luma_neon x264_template(deblock_h_luma_neon) 32 | void x264_deblock_h_luma_neon ( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 33 | #define x264_deblock_v_chroma_neon x264_template(deblock_v_chroma_neon) 34 | void x264_deblock_v_chroma_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 35 | #define x264_deblock_h_chroma_neon x264_template(deblock_h_chroma_neon) 36 | void x264_deblock_h_chroma_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 37 | #define x264_deblock_strength_neon x264_template(deblock_strength_neon) 38 | void x264_deblock_strength_neon( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE], 39 | int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4], 40 | int mvy_limit, int bframe ); 41 | #define x264_deblock_h_chroma_422_neon x264_template(deblock_h_chroma_422_neon) 42 | void x264_deblock_h_chroma_422_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 43 | #define x264_deblock_h_chroma_mbaff_neon x264_template(deblock_h_chroma_mbaff_neon) 44 | void x264_deblock_h_chroma_mbaff_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 45 | #define x264_deblock_h_chroma_intra_mbaff_neon x264_template(deblock_h_chroma_intra_mbaff_neon) 46 | void x264_deblock_h_chroma_intra_mbaff_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 47 | #define x264_deblock_h_chroma_intra_neon x264_template(deblock_h_chroma_intra_neon) 48 | void x264_deblock_h_chroma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 49 | #define x264_deblock_h_chroma_422_intra_neon x264_template(deblock_h_chroma_422_intra_neon) 50 | void x264_deblock_h_chroma_422_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 51 | #define x264_deblock_v_chroma_intra_neon x264_template(deblock_v_chroma_intra_neon) 52 | void x264_deblock_v_chroma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 53 | #define x264_deblock_h_luma_intra_neon x264_template(deblock_h_luma_intra_neon) 54 | void x264_deblock_h_luma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 55 | #define x264_deblock_v_luma_intra_neon x264_template(deblock_v_luma_intra_neon) 56 | void x264_deblock_v_luma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /common/arm/mc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * mc.h: arm motion compensation 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2024 x264 project 5 | * 6 | * Authors: David Conrad 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_ARM_MC_H 27 | #define X264_ARM_MC_H 28 | 29 | #define x264_mc_init_arm x264_template(mc_init_arm) 30 | void x264_mc_init_arm( uint32_t cpu, x264_mc_functions_t *pf ); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /common/arm/quant.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * quant.h: arm quantization and level-run 3 | ***************************************************************************** 4 | * Copyright (C) 2005-2024 x264 project 5 | * 6 | * Authors: David Conrad 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_ARM_QUANT_H 27 | #define X264_ARM_QUANT_H 28 | 29 | #define x264_quant_2x2_dc_armv6 x264_template(quant_2x2_dc_armv6) 30 | int x264_quant_2x2_dc_armv6( int16_t dct[4], int mf, int bias ); 31 | 32 | #define x264_quant_2x2_dc_neon x264_template(quant_2x2_dc_neon) 33 | int x264_quant_2x2_dc_neon( int16_t dct[4], int mf, int bias ); 34 | #define x264_quant_4x4_dc_neon x264_template(quant_4x4_dc_neon) 35 | int x264_quant_4x4_dc_neon( int16_t dct[16], int mf, int bias ); 36 | #define x264_quant_4x4_neon x264_template(quant_4x4_neon) 37 | int x264_quant_4x4_neon( int16_t dct[16], uint16_t mf[16], uint16_t bias[16] ); 38 | #define x264_quant_4x4x4_neon x264_template(quant_4x4x4_neon) 39 | int x264_quant_4x4x4_neon( int16_t dct[4][16], uint16_t mf[16], uint16_t bias[16] ); 40 | #define x264_quant_8x8_neon x264_template(quant_8x8_neon) 41 | int x264_quant_8x8_neon( int16_t dct[64], uint16_t mf[64], uint16_t bias[64] ); 42 | 43 | #define x264_dequant_4x4_dc_neon x264_template(dequant_4x4_dc_neon) 44 | void x264_dequant_4x4_dc_neon( int16_t dct[16], int dequant_mf[6][16], int i_qp ); 45 | #define x264_dequant_4x4_neon x264_template(dequant_4x4_neon) 46 | void x264_dequant_4x4_neon( int16_t dct[16], int dequant_mf[6][16], int i_qp ); 47 | #define x264_dequant_8x8_neon x264_template(dequant_8x8_neon) 48 | void x264_dequant_8x8_neon( int16_t dct[64], int dequant_mf[6][64], int i_qp ); 49 | 50 | #define x264_decimate_score15_neon x264_template(decimate_score15_neon) 51 | int x264_decimate_score15_neon( int16_t * ); 52 | #define x264_decimate_score16_neon x264_template(decimate_score16_neon) 53 | int x264_decimate_score16_neon( int16_t * ); 54 | #define x264_decimate_score64_neon x264_template(decimate_score64_neon) 55 | int x264_decimate_score64_neon( int16_t * ); 56 | 57 | #define x264_coeff_last4_arm x264_template(coeff_last4_arm) 58 | int x264_coeff_last4_arm( int16_t * ); 59 | #define x264_coeff_last8_arm x264_template(coeff_last8_arm) 60 | int x264_coeff_last8_arm( int16_t * ); 61 | #define x264_coeff_last15_neon x264_template(coeff_last15_neon) 62 | int x264_coeff_last15_neon( int16_t * ); 63 | #define x264_coeff_last16_neon x264_template(coeff_last16_neon) 64 | int x264_coeff_last16_neon( int16_t * ); 65 | #define x264_coeff_last64_neon x264_template(coeff_last64_neon) 66 | int x264_coeff_last64_neon( int16_t * ); 67 | 68 | #define x264_denoise_dct_neon x264_template(denoise_dct_neon) 69 | void x264_denoise_dct_neon( dctcoef *, uint32_t *, udctcoef *, int ); 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /common/common.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * common.c: misc common functions 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2024 x264 project 5 | * 6 | * Authors: Loren Merritt 7 | * Laurent Aimar 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 licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #include "common.h" 28 | 29 | /**************************************************************************** 30 | * x264_log: 31 | ****************************************************************************/ 32 | void x264_log( x264_t *h, int i_level, const char *psz_fmt, ... ) 33 | { 34 | if( !h || i_level <= h->param.i_log_level ) 35 | { 36 | va_list arg; 37 | va_start( arg, psz_fmt ); 38 | if( !h ) 39 | x264_log_default( NULL, i_level, psz_fmt, arg ); 40 | else 41 | h->param.pf_log( h->param.p_log_private, i_level, psz_fmt, arg ); 42 | va_end( arg ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /common/cpu.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * cpu.h: cpu detection 3 | ***************************************************************************** 4 | * Copyright (C) 2004-2024 x264 project 5 | * 6 | * Authors: Loren Merritt 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_CPU_H 27 | #define X264_CPU_H 28 | 29 | X264_API uint32_t x264_cpu_detect( void ); 30 | X264_API int x264_cpu_num_processors( void ); 31 | void x264_cpu_emms( void ); 32 | void x264_cpu_sfence( void ); 33 | #if HAVE_MMX 34 | /* There is no way to forbid the compiler from using float instructions 35 | * before the emms so miscompilation could theoretically occur in the 36 | * unlikely event that the compiler reorders emms and float instructions. */ 37 | #if HAVE_X86_INLINE_ASM 38 | /* Clobbering memory makes the compiler less likely to reorder code. */ 39 | #define x264_emms() asm volatile( "emms":::"memory","st","st(1)","st(2)", \ 40 | "st(3)","st(4)","st(5)","st(6)","st(7)" ) 41 | #else 42 | #define x264_emms() x264_cpu_emms() 43 | #endif 44 | #else 45 | #define x264_emms() 46 | #endif 47 | #define x264_sfence x264_cpu_sfence 48 | 49 | typedef struct 50 | { 51 | const char *name; 52 | uint32_t flags; 53 | } x264_cpu_name_t; 54 | X264_API extern const x264_cpu_name_t x264_cpu_names[]; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /common/dct.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * dct.h: transform and zigzag 3 | ***************************************************************************** 4 | * Copyright (C) 2004-2024 x264 project 5 | * 6 | * Authors: Loren Merritt 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_DCT_H 27 | #define X264_DCT_H 28 | 29 | typedef struct 30 | { 31 | // pix1 stride = FENC_STRIDE 32 | // pix2 stride = FDEC_STRIDE 33 | // p_dst stride = FDEC_STRIDE 34 | void (*sub4x4_dct) ( dctcoef dct[16], pixel *pix1, pixel *pix2 ); 35 | void (*add4x4_idct)( pixel *p_dst, dctcoef dct[16] ); 36 | 37 | void (*sub8x8_dct) ( dctcoef dct[4][16], pixel *pix1, pixel *pix2 ); 38 | void (*sub8x8_dct_dc) ( dctcoef dct[4], pixel *pix1, pixel *pix2 ); 39 | void (*add8x8_idct) ( pixel *p_dst, dctcoef dct[4][16] ); 40 | void (*add8x8_idct_dc)( pixel *p_dst, dctcoef dct[4] ); 41 | 42 | void (*sub8x16_dct_dc)( dctcoef dct[8], pixel *pix1, pixel *pix2 ); 43 | 44 | void (*sub16x16_dct) ( dctcoef dct[16][16], pixel *pix1, pixel *pix2 ); 45 | void (*add16x16_idct) ( pixel *p_dst, dctcoef dct[16][16] ); 46 | void (*add16x16_idct_dc)( pixel *p_dst, dctcoef dct[16] ); 47 | 48 | void (*sub8x8_dct8) ( dctcoef dct[64], pixel *pix1, pixel *pix2 ); 49 | void (*add8x8_idct8)( pixel *p_dst, dctcoef dct[64] ); 50 | 51 | void (*sub16x16_dct8) ( dctcoef dct[4][64], pixel *pix1, pixel *pix2 ); 52 | void (*add16x16_idct8)( pixel *p_dst, dctcoef dct[4][64] ); 53 | 54 | void (*dct4x4dc) ( dctcoef d[16] ); 55 | void (*idct4x4dc)( dctcoef d[16] ); 56 | 57 | void (*dct2x4dc)( dctcoef dct[8], dctcoef dct4x4[8][16] ); 58 | 59 | } x264_dct_function_t; 60 | 61 | typedef struct 62 | { 63 | void (*scan_8x8)( dctcoef level[64], dctcoef dct[64] ); 64 | void (*scan_4x4)( dctcoef level[16], dctcoef dct[16] ); 65 | int (*sub_8x8) ( dctcoef level[64], const pixel *p_src, pixel *p_dst ); 66 | int (*sub_4x4) ( dctcoef level[16], const pixel *p_src, pixel *p_dst ); 67 | int (*sub_4x4ac)( dctcoef level[16], const pixel *p_src, pixel *p_dst, dctcoef *dc ); 68 | void (*interleave_8x8_cavlc)( dctcoef *dst, dctcoef *src, uint8_t *nnz ); 69 | 70 | } x264_zigzag_function_t; 71 | 72 | #define x264_dct_init x264_template(dct_init) 73 | void x264_dct_init( uint32_t cpu, x264_dct_function_t *dctf ); 74 | #define x264_zigzag_init x264_template(zigzag_init) 75 | void x264_zigzag_init( uint32_t cpu, x264_zigzag_function_t *pf_progressive, x264_zigzag_function_t *pf_interlaced ); 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /common/loongarch/deblock.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * deblock.h: loongarch deblock 3 | ***************************************************************************** 4 | * Copyright (C) 2023-2024 x264 project 5 | * 6 | * Authors: Hao 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_LOONGARCH_DEBLOCK_H 27 | #define X264_LOONGARCH_DEBLOCK_H 28 | 29 | #if !HIGH_BIT_DEPTH 30 | #define x264_deblock_v_luma_lasx x264_template(deblock_v_luma_lasx) 31 | void x264_deblock_v_luma_lasx( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 32 | #define x264_deblock_h_luma_lasx x264_template(deblock_h_luma_lasx) 33 | void x264_deblock_h_luma_lasx( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 34 | 35 | #define x264_deblock_v_luma_intra_lsx x264_template(deblock_v_luma_intra_lsx) 36 | void x264_deblock_v_luma_intra_lsx( uint8_t *pix, intptr_t stride, int alpha, int beta ); 37 | #define x264_deblock_h_luma_intra_lsx x264_template(deblock_h_luma_intra_lsx) 38 | void x264_deblock_h_luma_intra_lsx( uint8_t *pix, intptr_t stride, int alpha, int beta ); 39 | 40 | #define x264_deblock_v_luma_intra_lasx x264_template(deblock_v_luma_intra_lasx) 41 | void x264_deblock_v_luma_intra_lasx( uint8_t *pix, intptr_t stride, int alpha, int beta ); 42 | #define x264_deblock_h_luma_intra_lasx x264_template(deblock_h_luma_intra_lasx) 43 | void x264_deblock_h_luma_intra_lasx( uint8_t *pix, intptr_t stride, int alpha, int beta ); 44 | #define x264_deblock_strength_lsx x264_template(deblock_strength_lsx) 45 | void x264_deblock_strength_lsx( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE], 46 | int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4], 47 | int mvy_limit, int bframe ); 48 | #define x264_deblock_strength_lasx x264_template(deblock_strength_lasx) 49 | void x264_deblock_strength_lasx( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE], 50 | int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4], 51 | int mvy_limit, int bframe ); 52 | #endif 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /common/loongarch/loongson_util.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * loongson_util.S: loongson utility macros 3 | ***************************************************************************** 4 | * Copyright (C) 2023-2024 x264 project 5 | * 6 | * Authors: Shiyou Yin 7 | * Xiwei Gu 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 licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #define GLUE(a, b) a ## b 28 | #define JOIN(a, b) GLUE(a, b) 29 | 30 | /* Set prefix as needed. */ 31 | #define ASM_REF JOIN(JOIN(x264_, BIT_DEPTH), _) 32 | 33 | #define FENC_STRIDE 16 34 | #define FDEC_STRIDE 32 35 | 36 | .macro function_x264 name, align=DEFAULT_ALIGN 37 | .macro endfunc_x264 38 | jirl $r0, $r1, 0x0 39 | .size ASM_REF\name, . - ASM_REF\name 40 | .purgem endfunc_x264 41 | .endm 42 | .text ; 43 | .align \align ; 44 | .globl ASM_REF\name ; 45 | .type ASM_REF\name, @function ; 46 | ASM_REF\name: ; 47 | .endm 48 | -------------------------------------------------------------------------------- /common/mips/dct.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * dct.h: msa transform and zigzag 3 | ***************************************************************************** 4 | * Copyright (C) 2015-2024 x264 project 5 | * 6 | * Authors: Rishikesh More 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_MIPS_DCT_H 27 | #define X264_MIPS_DCT_H 28 | 29 | #define x264_dct4x4dc_msa x264_template(dct4x4dc_msa) 30 | void x264_dct4x4dc_msa( int16_t d[16] ); 31 | #define x264_idct4x4dc_msa x264_template(idct4x4dc_msa) 32 | void x264_idct4x4dc_msa( int16_t d[16] ); 33 | #define x264_add4x4_idct_msa x264_template(add4x4_idct_msa) 34 | void x264_add4x4_idct_msa( uint8_t *p_dst, int16_t pi_dct[16] ); 35 | #define x264_add8x8_idct_msa x264_template(add8x8_idct_msa) 36 | void x264_add8x8_idct_msa( uint8_t *p_dst, int16_t pi_dct[4][16] ); 37 | #define x264_add16x16_idct_msa x264_template(add16x16_idct_msa) 38 | void x264_add16x16_idct_msa( uint8_t *p_dst, int16_t pi_dct[16][16] ); 39 | #define x264_add8x8_idct8_msa x264_template(add8x8_idct8_msa) 40 | void x264_add8x8_idct8_msa( uint8_t *p_dst, int16_t pi_dct[64] ); 41 | #define x264_add16x16_idct8_msa x264_template(add16x16_idct8_msa) 42 | void x264_add16x16_idct8_msa( uint8_t *p_dst, int16_t pi_dct[4][64] ); 43 | #define x264_add8x8_idct_dc_msa x264_template(add8x8_idct_dc_msa) 44 | void x264_add8x8_idct_dc_msa( uint8_t *p_dst, int16_t pi_dct[4] ); 45 | #define x264_add16x16_idct_dc_msa x264_template(add16x16_idct_dc_msa) 46 | void x264_add16x16_idct_dc_msa( uint8_t *p_dst, int16_t pi_dct[16] ); 47 | #define x264_sub4x4_dct_msa x264_template(sub4x4_dct_msa) 48 | void x264_sub4x4_dct_msa( int16_t p_dst[16], uint8_t *p_src, uint8_t *p_ref ); 49 | #define x264_sub8x8_dct_msa x264_template(sub8x8_dct_msa) 50 | void x264_sub8x8_dct_msa( int16_t p_dst[4][16], uint8_t *p_src, 51 | uint8_t *p_ref ); 52 | #define x264_sub16x16_dct_msa x264_template(sub16x16_dct_msa) 53 | void x264_sub16x16_dct_msa( int16_t p_dst[16][16], uint8_t *p_src, 54 | uint8_t *p_ref ); 55 | #define x264_sub8x8_dct_dc_msa x264_template(sub8x8_dct_dc_msa) 56 | void x264_sub8x8_dct_dc_msa( int16_t pi_dct[4], uint8_t *p_pix1, 57 | uint8_t *p_pix2 ); 58 | #define x264_sub8x16_dct_dc_msa x264_template(sub8x16_dct_dc_msa) 59 | void x264_sub8x16_dct_dc_msa( int16_t pi_dct[8], uint8_t *p_pix1, 60 | uint8_t *p_pix2 ); 61 | #define x264_zigzag_scan_4x4_frame_msa x264_template(zigzag_scan_4x4_frame_msa) 62 | void x264_zigzag_scan_4x4_frame_msa( int16_t pi_level[16], int16_t pi_dct[16] ); 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /common/mips/deblock.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * deblock.h: msa deblocking 3 | ***************************************************************************** 4 | * Copyright (C) 2017-2024 x264 project 5 | * 6 | * Authors: Anton Mitrofanov 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_MIPS_DEBLOCK_H 27 | #define X264_MIPS_DEBLOCK_H 28 | 29 | #if !HIGH_BIT_DEPTH 30 | #define x264_deblock_v_luma_msa x264_template(deblock_v_luma_msa) 31 | void x264_deblock_v_luma_msa( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 32 | #define x264_deblock_h_luma_msa x264_template(deblock_h_luma_msa) 33 | void x264_deblock_h_luma_msa( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 34 | #define x264_deblock_v_chroma_msa x264_template(deblock_v_chroma_msa) 35 | void x264_deblock_v_chroma_msa( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 36 | #define x264_deblock_h_chroma_msa x264_template(deblock_h_chroma_msa) 37 | void x264_deblock_h_chroma_msa( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 38 | #define x264_deblock_v_luma_intra_msa x264_template(deblock_v_luma_intra_msa) 39 | void x264_deblock_v_luma_intra_msa( uint8_t *pix, intptr_t stride, int alpha, int beta ); 40 | #define x264_deblock_h_luma_intra_msa x264_template(deblock_h_luma_intra_msa) 41 | void x264_deblock_h_luma_intra_msa( uint8_t *pix, intptr_t stride, int alpha, int beta ); 42 | #define x264_deblock_v_chroma_intra_msa x264_template(deblock_v_chroma_intra_msa) 43 | void x264_deblock_v_chroma_intra_msa( uint8_t *pix, intptr_t stride, int alpha, int beta ); 44 | #define x264_deblock_h_chroma_intra_msa x264_template(deblock_h_chroma_intra_msa) 45 | void x264_deblock_h_chroma_intra_msa( uint8_t *pix, intptr_t stride, int alpha, int beta ); 46 | #define x264_deblock_strength_msa x264_template(deblock_strength_msa) 47 | void x264_deblock_strength_msa( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE], 48 | int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4], int mvy_limit, 49 | int bframe ); 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /common/mips/mc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * mc.h: msa motion compensation 3 | ***************************************************************************** 4 | * Copyright (C) 2015-2024 x264 project 5 | * 6 | * Authors: Neha Rana 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_MIPS_MC_H 27 | #define X264_MIPS_MC_H 28 | 29 | #define x264_mc_init_mips x264_template(mc_init_mips) 30 | void x264_mc_init_mips( uint32_t cpu, x264_mc_functions_t *pf ); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /common/mips/predict.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * predict.h: msa intra prediction 3 | ***************************************************************************** 4 | * Copyright (C) 2015-2024 x264 project 5 | * 6 | * Authors: Rishikesh More 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_MIPS_PREDICT_H 27 | #define X264_MIPS_PREDICT_H 28 | 29 | #define x264_intra_predict_dc_16x16_msa x264_template(intra_predict_dc_16x16_msa) 30 | void x264_intra_predict_dc_16x16_msa( uint8_t *p_src ); 31 | #define x264_intra_predict_dc_left_16x16_msa x264_template(intra_predict_dc_left_16x16_msa) 32 | void x264_intra_predict_dc_left_16x16_msa( uint8_t *p_src ); 33 | #define x264_intra_predict_dc_top_16x16_msa x264_template(intra_predict_dc_top_16x16_msa) 34 | void x264_intra_predict_dc_top_16x16_msa( uint8_t *p_src ); 35 | #define x264_intra_predict_dc_128_16x16_msa x264_template(intra_predict_dc_128_16x16_msa) 36 | void x264_intra_predict_dc_128_16x16_msa( uint8_t *p_src ); 37 | #define x264_intra_predict_hor_16x16_msa x264_template(intra_predict_hor_16x16_msa) 38 | void x264_intra_predict_hor_16x16_msa( uint8_t *p_src ); 39 | #define x264_intra_predict_vert_16x16_msa x264_template(intra_predict_vert_16x16_msa) 40 | void x264_intra_predict_vert_16x16_msa( uint8_t *p_src ); 41 | #define x264_intra_predict_plane_16x16_msa x264_template(intra_predict_plane_16x16_msa) 42 | void x264_intra_predict_plane_16x16_msa( uint8_t *p_src ); 43 | #define x264_intra_predict_dc_4blk_8x8_msa x264_template(intra_predict_dc_4blk_8x8_msa) 44 | void x264_intra_predict_dc_4blk_8x8_msa( uint8_t *p_src ); 45 | #define x264_intra_predict_hor_8x8_msa x264_template(intra_predict_hor_8x8_msa) 46 | void x264_intra_predict_hor_8x8_msa( uint8_t *p_src ); 47 | #define x264_intra_predict_vert_8x8_msa x264_template(intra_predict_vert_8x8_msa) 48 | void x264_intra_predict_vert_8x8_msa( uint8_t *p_src ); 49 | #define x264_intra_predict_plane_8x8_msa x264_template(intra_predict_plane_8x8_msa) 50 | void x264_intra_predict_plane_8x8_msa( uint8_t *p_src ); 51 | #define x264_intra_predict_ddl_8x8_msa x264_template(intra_predict_ddl_8x8_msa) 52 | void x264_intra_predict_ddl_8x8_msa( uint8_t *p_src, uint8_t pu_xyz[36] ); 53 | #define x264_intra_predict_dc_8x8_msa x264_template(intra_predict_dc_8x8_msa) 54 | void x264_intra_predict_dc_8x8_msa( uint8_t *p_src, uint8_t pu_xyz[36] ); 55 | #define x264_intra_predict_h_8x8_msa x264_template(intra_predict_h_8x8_msa) 56 | void x264_intra_predict_h_8x8_msa( uint8_t *p_src, uint8_t pu_xyz[36] ); 57 | #define x264_intra_predict_v_8x8_msa x264_template(intra_predict_v_8x8_msa) 58 | void x264_intra_predict_v_8x8_msa( uint8_t *p_src, uint8_t pu_xyz[36] ); 59 | #define x264_intra_predict_dc_4x4_msa x264_template(intra_predict_dc_4x4_msa) 60 | void x264_intra_predict_dc_4x4_msa( uint8_t *p_src ); 61 | #define x264_intra_predict_hor_4x4_msa x264_template(intra_predict_hor_4x4_msa) 62 | void x264_intra_predict_hor_4x4_msa( uint8_t *p_src ); 63 | #define x264_intra_predict_vert_4x4_msa x264_template(intra_predict_vert_4x4_msa) 64 | void x264_intra_predict_vert_4x4_msa( uint8_t *p_src ); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /common/mips/quant.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * quant.h: msa quantization and level-run 3 | ***************************************************************************** 4 | * Copyright (C) 2015-2024 x264 project 5 | * 6 | * Authors: Rishikesh More 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_MIPS_QUANT_H 27 | #define X264_MIPS_QUANT_H 28 | 29 | #define x264_dequant_4x4_msa x264_template(dequant_4x4_msa) 30 | void x264_dequant_4x4_msa( int16_t *p_dct, int32_t pi_dequant_mf[6][16], 31 | int32_t i_qp ); 32 | #define x264_dequant_8x8_msa x264_template(dequant_8x8_msa) 33 | void x264_dequant_8x8_msa( int16_t *p_dct, int32_t pi_dequant_mf[6][64], 34 | int32_t i_qp ); 35 | #define x264_dequant_4x4_dc_msa x264_template(dequant_4x4_dc_msa) 36 | void x264_dequant_4x4_dc_msa( int16_t *p_dct, int32_t pi_dequant_mf[6][16], 37 | int32_t i_qp ); 38 | #define x264_quant_4x4_msa x264_template(quant_4x4_msa) 39 | int32_t x264_quant_4x4_msa( int16_t *p_dct, uint16_t *p_mf, uint16_t *p_bias ); 40 | #define x264_quant_4x4x4_msa x264_template(quant_4x4x4_msa) 41 | int32_t x264_quant_4x4x4_msa( int16_t p_dct[4][16], 42 | uint16_t pu_mf[16], uint16_t pu_bias[16] ); 43 | #define x264_quant_8x8_msa x264_template(quant_8x8_msa) 44 | int32_t x264_quant_8x8_msa( int16_t *p_dct, uint16_t *p_mf, uint16_t *p_bias ); 45 | #define x264_quant_4x4_dc_msa x264_template(quant_4x4_dc_msa) 46 | int32_t x264_quant_4x4_dc_msa( int16_t *p_dct, int32_t i_mf, int32_t i_bias ); 47 | #define x264_coeff_last64_msa x264_template(coeff_last64_msa) 48 | int32_t x264_coeff_last64_msa( int16_t *p_src ); 49 | #define x264_coeff_last16_msa x264_template(coeff_last16_msa) 50 | int32_t x264_coeff_last16_msa( int16_t *p_src ); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /common/opencl/weightp.cl: -------------------------------------------------------------------------------- 1 | /* Weightp filter a downscaled image into a temporary output buffer. 2 | * This kernel is launched once for each scale. 3 | * 4 | * Launch dimensions: width x height (in pixels) 5 | */ 6 | kernel void weightp_scaled_images( read_only image2d_t in_plane, 7 | write_only image2d_t out_plane, 8 | uint offset, 9 | uint scale, 10 | uint denom ) 11 | { 12 | int gx = get_global_id( 0 ); 13 | int gy = get_global_id( 1 ); 14 | uint4 input_val; 15 | uint4 output_val; 16 | 17 | input_val = read_imageui( in_plane, sampler, (int2)(gx, gy)); 18 | output_val = (uint4)(offset) + ( ( ((uint4)(scale)) * input_val ) >> ((uint4)(denom)) ); 19 | write_imageui( out_plane, (int2)(gx, gy), output_val ); 20 | } 21 | 22 | /* Weightp filter for the half-pel interpolated image 23 | * 24 | * Launch dimensions: width x height (in pixels) 25 | */ 26 | kernel void weightp_hpel( read_only image2d_t in_plane, 27 | write_only image2d_t out_plane, 28 | uint offset, 29 | uint scale, 30 | uint denom ) 31 | { 32 | int gx = get_global_id( 0 ); 33 | int gy = get_global_id( 1 ); 34 | uint input_val; 35 | uint output_val; 36 | 37 | input_val = read_imageui( in_plane, sampler, (int2)(gx, gy)).s0; 38 | //Unpack 39 | uint4 temp; 40 | temp.s0 = input_val & 0x00ff; temp.s1 = (input_val >> 8) & 0x00ff; 41 | temp.s2 = (input_val >> 16) & 0x00ff; temp.s3 = (input_val >> 24) & 0x00ff; 42 | 43 | temp = (uint4)(offset) + ( ( ((uint4)(scale)) * temp ) >> ((uint4)(denom)) ); 44 | 45 | //Pack 46 | output_val = temp.s0 | (temp.s1 << 8) | (temp.s2 << 16) | (temp.s3 << 24); 47 | write_imageui( out_plane, (int2)(gx, gy), output_val ); 48 | } 49 | -------------------------------------------------------------------------------- /common/opencl/x264-cl.h: -------------------------------------------------------------------------------- 1 | #pragma OPENCL EXTENSION cl_khr_local_int32_extended_atomics : enable 2 | 3 | constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST; 4 | 5 | /* 7.18.1.1 Exact-width integer types */ 6 | typedef signed char int8_t; 7 | typedef unsigned char uint8_t; 8 | typedef short int16_t; 9 | typedef unsigned short uint16_t; 10 | typedef int int32_t; 11 | typedef unsigned uint32_t; 12 | 13 | typedef uint8_t pixel; 14 | typedef uint16_t sum_t; 15 | typedef uint32_t sum2_t; 16 | 17 | #define LOWRES_COST_MASK ((1<<14)-1) 18 | #define LOWRES_COST_SHIFT 14 19 | #define COST_MAX (1<<28) 20 | 21 | #define PIXEL_MAX 255 22 | #define BITS_PER_SUM (8 * sizeof(sum_t)) 23 | 24 | /* Constants for offsets into frame statistics buffer */ 25 | #define COST_EST 0 26 | #define COST_EST_AQ 1 27 | #define INTRA_MBS 2 28 | 29 | #define COPY2_IF_LT( x, y, a, b )\ 30 | if( (y) < (x) )\ 31 | {\ 32 | (x) = (y);\ 33 | (a) = (b);\ 34 | } 35 | 36 | constant int2 dia_offs[4] = 37 | { 38 | {0, -1}, {-1, 0}, {1, 0}, {0, 1}, 39 | }; 40 | 41 | inline pixel x264_clip_pixel( int x ) 42 | { 43 | return (pixel) clamp( x, (int) 0, (int) PIXEL_MAX ); 44 | } 45 | 46 | inline int2 x264_median_mv( short2 a, short2 b, short2 c ) 47 | { 48 | short2 t1 = min(a, b); 49 | short2 t2 = min(max(a, b), c); 50 | return convert_int2(max(t1, t2)); 51 | } 52 | 53 | inline sum2_t abs2( sum2_t a ) 54 | { 55 | sum2_t s = ((a >> (BITS_PER_SUM - 1)) & (((sum2_t)1 << BITS_PER_SUM) + 1)) * ((sum_t)-1); 56 | return (a + s) ^ s; 57 | } 58 | 59 | #define HADAMARD4( d0, d1, d2, d3, s0, s1, s2, s3 ) {\ 60 | sum2_t t0 = s0 + s1;\ 61 | sum2_t t1 = s0 - s1;\ 62 | sum2_t t2 = s2 + s3;\ 63 | sum2_t t3 = s2 - s3;\ 64 | d0 = t0 + t2;\ 65 | d2 = t0 - t2;\ 66 | d1 = t1 + t3;\ 67 | d3 = t1 - t3;\ 68 | } 69 | 70 | #define HADAMARD4V( d0, d1, d2, d3, s0, s1, s2, s3 ) {\ 71 | int2 t0 = s0 + s1;\ 72 | int2 t1 = s0 - s1;\ 73 | int2 t2 = s2 + s3;\ 74 | int2 t3 = s2 - s3;\ 75 | d0 = t0 + t2;\ 76 | d2 = t0 - t2;\ 77 | d1 = t1 + t3;\ 78 | d3 = t1 - t3;\ 79 | } 80 | 81 | #define SATD_C_8x4_Q( name, q1, q2 )\ 82 | int name( q1 pixel *pix1, int i_pix1, q2 pixel *pix2, int i_pix2 )\ 83 | {\ 84 | sum2_t tmp[4][4];\ 85 | sum2_t a0, a1, a2, a3;\ 86 | sum2_t sum = 0;\ 87 | for( int i = 0; i < 4; i++, pix1 += i_pix1, pix2 += i_pix2 )\ 88 | {\ 89 | a0 = (pix1[0] - pix2[0]) + ((sum2_t)(pix1[4] - pix2[4]) << BITS_PER_SUM);\ 90 | a1 = (pix1[1] - pix2[1]) + ((sum2_t)(pix1[5] - pix2[5]) << BITS_PER_SUM);\ 91 | a2 = (pix1[2] - pix2[2]) + ((sum2_t)(pix1[6] - pix2[6]) << BITS_PER_SUM);\ 92 | a3 = (pix1[3] - pix2[3]) + ((sum2_t)(pix1[7] - pix2[7]) << BITS_PER_SUM);\ 93 | HADAMARD4( tmp[i][0], tmp[i][1], tmp[i][2], tmp[i][3], a0, a1, a2, a3 );\ 94 | }\ 95 | for( int i = 0; i < 4; i++ )\ 96 | {\ 97 | HADAMARD4( a0, a1, a2, a3, tmp[0][i], tmp[1][i], tmp[2][i], tmp[3][i] );\ 98 | sum += abs2( a0 ) + abs2( a1 ) + abs2( a2 ) + abs2( a3 );\ 99 | }\ 100 | return (((sum_t)sum) + (sum>>BITS_PER_SUM)) >> 1;\ 101 | } 102 | 103 | /* 104 | * Utility function to perform a parallel sum reduction of an array of integers 105 | */ 106 | int parallel_sum( int value, int x, volatile local int *array ) 107 | { 108 | array[x] = value; 109 | barrier( CLK_LOCAL_MEM_FENCE ); 110 | 111 | int dim = get_local_size( 0 ); 112 | 113 | while( dim > 1 ) 114 | { 115 | dim >>= 1; 116 | 117 | if( x < dim ) 118 | array[x] += array[x + dim]; 119 | 120 | if( dim > 32 ) 121 | barrier( CLK_LOCAL_MEM_FENCE ); 122 | } 123 | 124 | return array[0]; 125 | } 126 | 127 | int mv_cost( uint2 mvd ) 128 | { 129 | float2 mvdf = (float2)(mvd.x, mvd.y) + 1.0f; 130 | float2 cost = round( log2(mvdf) * 2.0f + 0.718f + (float2)(!!mvd.x, !!mvd.y) ); 131 | return (int) (cost.x + cost.y); 132 | } 133 | -------------------------------------------------------------------------------- /common/osdep.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * osdep.c: platform-specific code 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2024 x264 project 5 | * 6 | * Authors: Steven Walters 7 | * Laurent Aimar 8 | * Henrik Gramner 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 licensing@x264.com. 26 | *****************************************************************************/ 27 | 28 | #include "osdep.h" 29 | 30 | #if SYS_WINDOWS 31 | #include 32 | #include 33 | #else 34 | #include 35 | #endif 36 | #include 37 | 38 | #if PTW32_STATIC_LIB 39 | /* this is a global in pthread-win32 to indicate if it has been initialized or not */ 40 | extern int ptw32_processInitialized; 41 | #endif 42 | 43 | int64_t x264_mdate( void ) 44 | { 45 | #if SYS_WINDOWS 46 | struct timeb tb; 47 | ftime( &tb ); 48 | return ((int64_t)tb.time * 1000 + (int64_t)tb.millitm) * 1000; 49 | #elif HAVE_CLOCK_GETTIME 50 | struct timespec ts; 51 | clock_gettime( CLOCK_MONOTONIC, &ts ); 52 | return (int64_t)ts.tv_sec * 1000000 + (int64_t)ts.tv_nsec / 1000; 53 | #else 54 | struct timeval tv_date; 55 | gettimeofday( &tv_date, NULL ); 56 | return (int64_t)tv_date.tv_sec * 1000000 + (int64_t)tv_date.tv_usec; 57 | #endif 58 | } 59 | 60 | #if HAVE_WIN32THREAD || PTW32_STATIC_LIB 61 | /* state of the threading library being initialized */ 62 | static volatile LONG threading_is_init = 0; 63 | 64 | static void threading_destroy( void ) 65 | { 66 | #if PTW32_STATIC_LIB 67 | pthread_win32_thread_detach_np(); 68 | pthread_win32_process_detach_np(); 69 | #else 70 | x264_win32_threading_destroy(); 71 | #endif 72 | } 73 | 74 | static int threading_init( void ) 75 | { 76 | #if PTW32_STATIC_LIB 77 | /* if static pthread-win32 is already initialized, then do nothing */ 78 | if( ptw32_processInitialized ) 79 | return 0; 80 | if( !pthread_win32_process_attach_np() ) 81 | return -1; 82 | #else 83 | if( x264_win32_threading_init() ) 84 | return -1; 85 | #endif 86 | /* register cleanup to run at process termination */ 87 | atexit( threading_destroy ); 88 | return 0; 89 | } 90 | 91 | int x264_threading_init( void ) 92 | { 93 | LONG state; 94 | while( (state = InterlockedCompareExchange( &threading_is_init, -1, 0 )) != 0 ) 95 | { 96 | /* if already init, then do nothing */ 97 | if( state > 0 ) 98 | return 0; 99 | } 100 | if( threading_init() < 0 ) 101 | { 102 | InterlockedExchange( &threading_is_init, 0 ); 103 | return -1; 104 | } 105 | InterlockedExchange( &threading_is_init, 1 ); 106 | return 0; 107 | } 108 | #endif 109 | -------------------------------------------------------------------------------- /common/ppc/dct.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * dct.h: ppc transform and zigzag 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2024 x264 project 5 | * 6 | * Authors: Eric Petit 7 | * Guillaume Poirier 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 licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef X264_PPC_DCT_H 28 | #define X264_PPC_DCT_H 29 | 30 | #define x264_sub4x4_dct_altivec x264_template(sub4x4_dct_altivec) 31 | void x264_sub4x4_dct_altivec( int16_t dct[16], uint8_t *pix1, uint8_t *pix2 ); 32 | #define x264_sub8x8_dct_altivec x264_template(sub8x8_dct_altivec) 33 | void x264_sub8x8_dct_altivec( int16_t dct[4][16], uint8_t *pix1, uint8_t *pix2 ); 34 | #define x264_sub16x16_dct_altivec x264_template(sub16x16_dct_altivec) 35 | void x264_sub16x16_dct_altivec( int16_t dct[16][16], uint8_t *pix1, uint8_t *pix2 ); 36 | 37 | #define x264_add8x8_idct_dc_altivec x264_template(add8x8_idct_dc_altivec) 38 | void x264_add8x8_idct_dc_altivec( uint8_t *p_dst, int16_t dct[4] ); 39 | #define x264_add16x16_idct_dc_altivec x264_template(add16x16_idct_dc_altivec) 40 | void x264_add16x16_idct_dc_altivec( uint8_t *p_dst, int16_t dct[16] ); 41 | 42 | #define x264_add4x4_idct_altivec x264_template(add4x4_idct_altivec) 43 | void x264_add4x4_idct_altivec( uint8_t *p_dst, int16_t dct[16] ); 44 | #define x264_add8x8_idct_altivec x264_template(add8x8_idct_altivec) 45 | void x264_add8x8_idct_altivec( uint8_t *p_dst, int16_t dct[4][16] ); 46 | #define x264_add16x16_idct_altivec x264_template(add16x16_idct_altivec) 47 | void x264_add16x16_idct_altivec( uint8_t *p_dst, int16_t dct[16][16] ); 48 | 49 | #define x264_sub8x8_dct_dc_altivec x264_template(sub8x8_dct_dc_altivec) 50 | void x264_sub8x8_dct_dc_altivec( int16_t dct[4], uint8_t *pix1, uint8_t *pix2 ); 51 | #define x264_sub8x8_dct8_altivec x264_template(sub8x8_dct8_altivec) 52 | void x264_sub8x8_dct8_altivec( int16_t dct[64], uint8_t *pix1, uint8_t *pix2 ); 53 | #define x264_sub16x16_dct8_altivec x264_template(sub16x16_dct8_altivec) 54 | void x264_sub16x16_dct8_altivec( int16_t dct[4][64], uint8_t *pix1, uint8_t *pix2 ); 55 | 56 | #define x264_add8x8_idct8_altivec x264_template(add8x8_idct8_altivec) 57 | void x264_add8x8_idct8_altivec( uint8_t *dst, int16_t dct[64] ); 58 | #define x264_add16x16_idct8_altivec x264_template(add16x16_idct8_altivec) 59 | void x264_add16x16_idct8_altivec( uint8_t *dst, int16_t dct[4][64] ); 60 | 61 | #define x264_zigzag_scan_4x4_frame_altivec x264_template(zigzag_scan_4x4_frame_altivec) 62 | void x264_zigzag_scan_4x4_frame_altivec( int16_t level[16], int16_t dct[16] ); 63 | #define x264_zigzag_scan_4x4_field_altivec x264_template(zigzag_scan_4x4_field_altivec) 64 | void x264_zigzag_scan_4x4_field_altivec( int16_t level[16], int16_t dct[16] ); 65 | #define x264_zigzag_scan_8x8_frame_altivec x264_template(zigzag_scan_8x8_frame_altivec) 66 | void x264_zigzag_scan_8x8_frame_altivec( int16_t level[64], int16_t dct[64] ); 67 | #define x264_zigzag_interleave_8x8_cavlc_altivec x264_template(zigzag_interleave_8x8_cavlc_altivec) 68 | void x264_zigzag_interleave_8x8_cavlc_altivec( int16_t *dst, int16_t *src, uint8_t *nnz ); 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /common/ppc/deblock.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * deblock.h: ppc deblocking 3 | ***************************************************************************** 4 | * Copyright (C) 2017-2024 x264 project 5 | * 6 | * Authors: Anton Mitrofanov 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_PPC_DEBLOCK_H 27 | #define X264_PPC_DEBLOCK_H 28 | 29 | #define x264_deblock_v_luma_altivec x264_template(deblock_v_luma_altivec) 30 | void x264_deblock_v_luma_altivec( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 31 | #define x264_deblock_h_luma_altivec x264_template(deblock_h_luma_altivec) 32 | void x264_deblock_h_luma_altivec( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /common/ppc/mc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * mc.h: ppc motion compensation 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2024 x264 project 5 | * 6 | * Authors: Eric Petit 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_PPC_MC_H 27 | #define X264_PPC_MC_H 28 | 29 | #define x264_mc_init_altivec x264_template(mc_init_altivec) 30 | void x264_mc_init_altivec( x264_mc_functions_t *pf ); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /common/ppc/pixel.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * pixel.h: ppc pixel metrics 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2024 x264 project 5 | * 6 | * Authors: Eric Petit 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_PPC_PIXEL_H 27 | #define X264_PPC_PIXEL_H 28 | 29 | #define x264_pixel_init_altivec x264_template(pixel_init_altivec) 30 | void x264_pixel_init_altivec( x264_pixel_function_t *pixf ); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /common/ppc/predict.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * predict.h: ppc intra prediction 3 | ***************************************************************************** 4 | * Copyright (C) 2007-2024 x264 project 5 | * 6 | * Authors: Guillaume Poirier 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_PPC_PREDICT_H 27 | #define X264_PPC_PREDICT_H 28 | 29 | #define x264_predict_16x16_init_altivec x264_template(predict_16x16_init_altivec) 30 | void x264_predict_16x16_init_altivec( x264_predict_t pf[7] ); 31 | #define x264_predict_8x8c_init_altivec x264_template(predict_8x8c_init_altivec) 32 | void x264_predict_8x8c_init_altivec( x264_predict_t pf[7] ); 33 | 34 | #endif /* X264_PPC_PREDICT_H */ 35 | -------------------------------------------------------------------------------- /common/ppc/quant.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * quant.h: ppc quantization 3 | ***************************************************************************** 4 | * Copyright (C) 2007-2024 x264 project 5 | * 6 | * Authors: Guillaume Poirier 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_PPC_QUANT_H 27 | #define X264_PPC_QUANT_H 28 | 29 | #define x264_quant_4x4x4_altivec x264_template(quant_4x4x4_altivec) 30 | int x264_quant_4x4x4_altivec( int16_t dct[4][16], uint16_t mf[16], uint16_t bias[16] ); 31 | #define x264_quant_4x4_altivec x264_template(quant_4x4_altivec) 32 | int x264_quant_4x4_altivec( int16_t dct[16], uint16_t mf[16], uint16_t bias[16] ); 33 | #define x264_quant_8x8_altivec x264_template(quant_8x8_altivec) 34 | int x264_quant_8x8_altivec( int16_t dct[64], uint16_t mf[64], uint16_t bias[64] ); 35 | 36 | #define x264_quant_4x4_dc_altivec x264_template(quant_4x4_dc_altivec) 37 | int x264_quant_4x4_dc_altivec( int16_t dct[16], int mf, int bias ); 38 | #define x264_quant_2x2_dc_altivec x264_template(quant_2x2_dc_altivec) 39 | int x264_quant_2x2_dc_altivec( int16_t dct[4], int mf, int bias ); 40 | 41 | #define x264_dequant_4x4_altivec x264_template(dequant_4x4_altivec) 42 | void x264_dequant_4x4_altivec( int16_t dct[16], int dequant_mf[6][16], int i_qp ); 43 | #define x264_dequant_8x8_altivec x264_template(dequant_8x8_altivec) 44 | void x264_dequant_8x8_altivec( int16_t dct[64], int dequant_mf[6][64], int i_qp ); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /common/quant.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * quant.h: quantization and level-run 3 | ***************************************************************************** 4 | * Copyright (C) 2005-2024 x264 project 5 | * 6 | * Authors: Loren Merritt 7 | * Fiona Glaser 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 licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef X264_QUANT_H 28 | #define X264_QUANT_H 29 | 30 | typedef struct 31 | { 32 | int (*quant_8x8) ( dctcoef dct[64], udctcoef mf[64], udctcoef bias[64] ); 33 | int (*quant_4x4) ( dctcoef dct[16], udctcoef mf[16], udctcoef bias[16] ); 34 | int (*quant_4x4x4)( dctcoef dct[4][16], udctcoef mf[16], udctcoef bias[16] ); 35 | int (*quant_4x4_dc)( dctcoef dct[16], int mf, int bias ); 36 | int (*quant_2x2_dc)( dctcoef dct[4], int mf, int bias ); 37 | 38 | void (*dequant_8x8)( dctcoef dct[64], int dequant_mf[6][64], int i_qp ); 39 | void (*dequant_4x4)( dctcoef dct[16], int dequant_mf[6][16], int i_qp ); 40 | void (*dequant_4x4_dc)( dctcoef dct[16], int dequant_mf[6][16], int i_qp ); 41 | 42 | void (*idct_dequant_2x4_dc)( dctcoef dct[8], dctcoef dct4x4[8][16], int dequant_mf[6][16], int i_qp ); 43 | void (*idct_dequant_2x4_dconly)( dctcoef dct[8], int dequant_mf[6][16], int i_qp ); 44 | 45 | int (*optimize_chroma_2x2_dc)( dctcoef dct[4], int dequant_mf ); 46 | int (*optimize_chroma_2x4_dc)( dctcoef dct[8], int dequant_mf ); 47 | 48 | void (*denoise_dct)( dctcoef *dct, uint32_t *sum, udctcoef *offset, int size ); 49 | 50 | int (*decimate_score15)( dctcoef *dct ); 51 | int (*decimate_score16)( dctcoef *dct ); 52 | int (*decimate_score64)( dctcoef *dct ); 53 | int (*coeff_last[14])( dctcoef *dct ); 54 | int (*coeff_last4)( dctcoef *dct ); 55 | int (*coeff_last8)( dctcoef *dct ); 56 | int (*coeff_level_run[13])( dctcoef *dct, x264_run_level_t *runlevel ); 57 | int (*coeff_level_run4)( dctcoef *dct, x264_run_level_t *runlevel ); 58 | int (*coeff_level_run8)( dctcoef *dct, x264_run_level_t *runlevel ); 59 | 60 | #define TRELLIS_PARAMS const int *unquant_mf, const uint8_t *zigzag, int lambda2,\ 61 | int last_nnz, dctcoef *coefs, dctcoef *quant_coefs, dctcoef *dct,\ 62 | uint8_t *cabac_state_sig, uint8_t *cabac_state_last,\ 63 | uint64_t level_state0, uint16_t level_state1 64 | int (*trellis_cabac_4x4)( TRELLIS_PARAMS, int b_ac ); 65 | int (*trellis_cabac_8x8)( TRELLIS_PARAMS, int b_interlaced ); 66 | int (*trellis_cabac_4x4_psy)( TRELLIS_PARAMS, int b_ac, dctcoef *fenc_dct, int psy_trellis ); 67 | int (*trellis_cabac_8x8_psy)( TRELLIS_PARAMS, int b_interlaced, dctcoef *fenc_dct, int psy_trellis ); 68 | int (*trellis_cabac_dc)( TRELLIS_PARAMS, int num_coefs ); 69 | int (*trellis_cabac_chroma_422_dc)( TRELLIS_PARAMS ); 70 | } x264_quant_function_t; 71 | 72 | #define x264_quant_init x264_template(quant_init) 73 | void x264_quant_init( x264_t *h, uint32_t cpu, x264_quant_function_t *pf ); 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /common/rectangle.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * rectangle.c: rectangle filling 3 | ***************************************************************************** 4 | * Copyright (C) 2010-2024 x264 project 5 | * 6 | * Authors: Fiona Glaser 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #include "common.h" 27 | 28 | #define CACHE_FUNC(name,size,width,height)\ 29 | static void macroblock_cache_##name##_##width##_##height( void *target, uint32_t val )\ 30 | {\ 31 | x264_macroblock_cache_rect( target, width*size, height, size, val );\ 32 | } 33 | 34 | #define CACHE_FUNCS(name,size)\ 35 | CACHE_FUNC(name,size,4,4)\ 36 | CACHE_FUNC(name,size,2,4)\ 37 | CACHE_FUNC(name,size,4,2)\ 38 | CACHE_FUNC(name,size,2,2)\ 39 | CACHE_FUNC(name,size,2,1)\ 40 | CACHE_FUNC(name,size,1,2)\ 41 | CACHE_FUNC(name,size,1,1)\ 42 | void (*x264_cache_##name##_func_table[10])(void *, uint32_t) =\ 43 | {\ 44 | macroblock_cache_##name##_1_1,\ 45 | macroblock_cache_##name##_2_1,\ 46 | macroblock_cache_##name##_1_2,\ 47 | macroblock_cache_##name##_2_2,\ 48 | NULL,\ 49 | macroblock_cache_##name##_4_2,\ 50 | NULL,\ 51 | macroblock_cache_##name##_2_4,\ 52 | NULL,\ 53 | macroblock_cache_##name##_4_4\ 54 | };\ 55 | 56 | CACHE_FUNCS(mv, 4) 57 | CACHE_FUNCS(mvd, 2) 58 | CACHE_FUNCS(ref, 1) 59 | -------------------------------------------------------------------------------- /common/threadpool.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * threadpool.h: thread pooling 3 | ***************************************************************************** 4 | * Copyright (C) 2010-2024 x264 project 5 | * 6 | * Authors: Steven Walters 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_THREADPOOL_H 27 | #define X264_THREADPOOL_H 28 | 29 | typedef struct x264_threadpool_t x264_threadpool_t; 30 | 31 | #if HAVE_THREAD 32 | #define x264_threadpool_init x264_template(threadpool_init) 33 | X264_API int x264_threadpool_init( x264_threadpool_t **p_pool, int threads ); 34 | #define x264_threadpool_run x264_template(threadpool_run) 35 | X264_API void x264_threadpool_run( x264_threadpool_t *pool, void *(*func)(void *), void *arg ); 36 | #define x264_threadpool_wait x264_template(threadpool_wait) 37 | X264_API void *x264_threadpool_wait( x264_threadpool_t *pool, void *arg ); 38 | #define x264_threadpool_delete x264_template(threadpool_delete) 39 | X264_API void x264_threadpool_delete( x264_threadpool_t *pool ); 40 | #else 41 | #define x264_threadpool_init(p,t) -1 42 | #define x264_threadpool_run(p,f,a) 43 | #define x264_threadpool_wait(p,a) NULL 44 | #define x264_threadpool_delete(p) 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /common/vlc.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * vlc.c : vlc tables 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2024 x264 project 5 | * 6 | * Authors: Laurent Aimar 7 | * Fiona Glaser 8 | * Henrik Gramner 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 licensing@x264.com. 26 | *****************************************************************************/ 27 | 28 | #include "common.h" 29 | 30 | vlc_large_t x264_level_token[7][LEVEL_TABLE_SIZE]; 31 | uint32_t x264_run_before[1<<16]; 32 | 33 | void x264_cavlc_init( x264_t *h ) 34 | { 35 | for( int i_suffix = 0; i_suffix < 7; i_suffix++ ) 36 | for( int16_t level = -LEVEL_TABLE_SIZE/2; level < LEVEL_TABLE_SIZE/2; level++ ) 37 | { 38 | int mask = level >> 15; 39 | int abs_level = (level^mask)-mask; 40 | int i_level_code = abs_level ? abs_level*2-mask-2 : 0; 41 | int i_next = i_suffix; 42 | vlc_large_t *vlc = &x264_level_token[i_suffix][level+LEVEL_TABLE_SIZE/2]; 43 | 44 | if( ( i_level_code >> i_suffix ) < 14 ) 45 | { 46 | vlc->i_size = (i_level_code >> i_suffix) + 1 + i_suffix; 47 | vlc->i_bits = (1<i_size = 19; 52 | vlc->i_bits = (1<<4) + (i_level_code - 14); 53 | } 54 | else if( i_suffix > 0 && ( i_level_code >> i_suffix ) == 14 ) 55 | { 56 | vlc->i_size = 15 + i_suffix; 57 | vlc->i_bits = (1<i_size = 28; 65 | vlc->i_bits = (1<<12) + i_level_code; 66 | } 67 | if( i_next == 0 ) 68 | i_next++; 69 | if( abs_level > (3 << (i_next-1)) && i_next < 6 ) 70 | i_next++; 71 | vlc->i_next = i_next; 72 | } 73 | 74 | x264_run_before[0] = 0; 75 | x264_run_before[1] = 0; 76 | for( uint32_t i = 2; i < (1<<16); i++ ) 77 | { 78 | x264_run_level_t runlevel; 79 | ALIGNED_ARRAY_16( dctcoef, dct, [16] ); 80 | int size = 0; 81 | int bits = 0; 82 | for( int j = 0; j < 16; j++ ) 83 | dct[j] = i&(1<quantf.coeff_level_run[DCT_LUMA_4x4]( dct, &runlevel ); 85 | int zeros = runlevel.last + 1 - total; 86 | uint32_t mask = i << (x264_clz( i ) + 1); 87 | for( int j = 0; j < total-1 && zeros > 0; j++ ) 88 | { 89 | int idx = X264_MIN(zeros, 7) - 1; 90 | int run = x264_clz( mask ); 91 | int len = x264_run_before_init[idx][run].i_size; 92 | size += len; 93 | bits <<= len; 94 | bits |= x264_run_before_init[idx][run].i_bits; 95 | zeros -= run; 96 | mask <<= run + 1; 97 | } 98 | x264_run_before[i] = (bits << 5) + size; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /common/win32thread.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * win32thread.h: windows threading 3 | ***************************************************************************** 4 | * Copyright (C) 2010-2024 x264 project 5 | * 6 | * Authors: Steven Walters 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_WIN32THREAD_H 27 | #define X264_WIN32THREAD_H 28 | 29 | #include 30 | /* the following macro is used within x264 */ 31 | #undef ERROR 32 | 33 | typedef struct 34 | { 35 | void *handle; 36 | void *(*func)( void* arg ); 37 | void *arg; 38 | void **p_ret; 39 | void *ret; 40 | } x264_pthread_t; 41 | #define x264_pthread_attr_t int 42 | 43 | /* the conditional variable api for windows 6.0+ uses critical sections and not mutexes */ 44 | typedef CRITICAL_SECTION x264_pthread_mutex_t; 45 | #define X264_PTHREAD_MUTEX_INITIALIZER {0} 46 | #define x264_pthread_mutexattr_t int 47 | 48 | #if HAVE_WINRT 49 | typedef CONDITION_VARIABLE x264_pthread_cond_t; 50 | #else 51 | typedef struct 52 | { 53 | void *Ptr; 54 | } x264_pthread_cond_t; 55 | #endif 56 | #define x264_pthread_condattr_t int 57 | 58 | int x264_pthread_create( x264_pthread_t *thread, const x264_pthread_attr_t *attr, 59 | void *(*start_routine)( void* ), void *arg ); 60 | int x264_pthread_join( x264_pthread_t thread, void **value_ptr ); 61 | 62 | int x264_pthread_mutex_init( x264_pthread_mutex_t *mutex, const x264_pthread_mutexattr_t *attr ); 63 | int x264_pthread_mutex_destroy( x264_pthread_mutex_t *mutex ); 64 | int x264_pthread_mutex_lock( x264_pthread_mutex_t *mutex ); 65 | int x264_pthread_mutex_unlock( x264_pthread_mutex_t *mutex ); 66 | 67 | int x264_pthread_cond_init( x264_pthread_cond_t *cond, const x264_pthread_condattr_t *attr ); 68 | int x264_pthread_cond_destroy( x264_pthread_cond_t *cond ); 69 | int x264_pthread_cond_broadcast( x264_pthread_cond_t *cond ); 70 | int x264_pthread_cond_wait( x264_pthread_cond_t *cond, x264_pthread_mutex_t *mutex ); 71 | int x264_pthread_cond_signal( x264_pthread_cond_t *cond ); 72 | 73 | #define x264_pthread_attr_init(a) 0 74 | #define x264_pthread_attr_destroy(a) 0 75 | 76 | int x264_win32_threading_init( void ); 77 | void x264_win32_threading_destroy( void ); 78 | 79 | int x264_pthread_num_processors_np( void ); 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /common/x86/const-a.asm: -------------------------------------------------------------------------------- 1 | ;***************************************************************************** 2 | ;* const-a.asm: x86 global constants 3 | ;***************************************************************************** 4 | ;* Copyright (C) 2010-2024 x264 project 5 | ;* 6 | ;* Authors: Loren Merritt 7 | ;* Fiona Glaser 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 licensing@x264.com. 25 | ;***************************************************************************** 26 | 27 | %include "x86inc.asm" 28 | 29 | SECTION_RODATA 32 30 | 31 | const pb_1, times 32 db 1 32 | const hsub_mul, times 16 db 1, -1 33 | const pw_1, times 16 dw 1 34 | const pw_16, times 16 dw 16 35 | const pw_32, times 16 dw 32 36 | const pw_512, times 16 dw 512 37 | const pw_00ff, times 16 dw 0x00ff 38 | const pw_pixel_max,times 16 dw ((1 << BIT_DEPTH)-1) 39 | const pw_0to15, dw 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 40 | const pd_1, times 8 dd 1 41 | const pd_0123, dd 0,1,2,3 42 | const pd_4567, dd 4,5,6,7 43 | const deinterleave_shufd, dd 0,4,1,5,2,6,3,7 44 | const pb_unpackbd1, times 2 db 0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3 45 | const pb_unpackbd2, times 2 db 4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7 46 | 47 | const pb_01, times 8 db 0,1 48 | const pb_0, times 16 db 0 49 | const pb_a1, times 16 db 0xa1 50 | const pb_3, times 16 db 3 51 | const pb_shuf8x8c, db 0,0,0,0,2,2,2,2,4,4,4,4,6,6,6,6 52 | 53 | const pw_2, times 8 dw 2 54 | const pw_m2, times 8 dw -2 55 | const pw_4, times 8 dw 4 56 | const pw_8, times 8 dw 8 57 | const pw_64, times 8 dw 64 58 | const pw_256, times 8 dw 256 59 | const pw_32_0, times 4 dw 32 60 | times 4 dw 0 61 | const pw_8000, times 8 dw 0x8000 62 | const pw_3fff, times 8 dw 0x3fff 63 | const pw_ppppmmmm, dw 1,1,1,1,-1,-1,-1,-1 64 | const pw_ppmmppmm, dw 1,1,-1,-1,1,1,-1,-1 65 | const pw_pmpmpmpm, dw 1,-1,1,-1,1,-1,1,-1 66 | const pw_pmmpzzzz, dw 1,-1,-1,1,0,0,0,0 67 | 68 | const pd_8, times 4 dd 8 69 | const pd_32, times 4 dd 32 70 | const pd_1024, times 4 dd 1024 71 | const pd_ffff, times 4 dd 0xffff 72 | const pw_ff00, times 8 dw 0xff00 73 | 74 | const popcnt_table 75 | %assign x 0 76 | %rep 256 77 | ; population count 78 | db ((x>>0)&1)+((x>>1)&1)+((x>>2)&1)+((x>>3)&1)+((x>>4)&1)+((x>>5)&1)+((x>>6)&1)+((x>>7)&1) 79 | %assign x x+1 80 | %endrep 81 | 82 | const sw_64, dd 64 83 | -------------------------------------------------------------------------------- /common/x86/cpu-a.asm: -------------------------------------------------------------------------------- 1 | ;***************************************************************************** 2 | ;* cpu-a.asm: x86 cpu utilities 3 | ;***************************************************************************** 4 | ;* Copyright (C) 2003-2024 x264 project 5 | ;* 6 | ;* Authors: Laurent Aimar 7 | ;* Loren Merritt 8 | ;* Fiona Glaser 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 licensing@x264.com. 26 | ;***************************************************************************** 27 | 28 | %include "x86inc.asm" 29 | 30 | SECTION .text 31 | 32 | ;----------------------------------------------------------------------------- 33 | ; void cpu_cpuid( int op, int *eax, int *ebx, int *ecx, int *edx ) 34 | ;----------------------------------------------------------------------------- 35 | cglobal cpu_cpuid, 5,7 36 | push rbx 37 | push r4 38 | push r3 39 | push r2 40 | push r1 41 | mov eax, r0d 42 | xor ecx, ecx 43 | cpuid 44 | pop r4 45 | mov [r4], eax 46 | pop r4 47 | mov [r4], ebx 48 | pop r4 49 | mov [r4], ecx 50 | pop r4 51 | mov [r4], edx 52 | pop rbx 53 | RET 54 | 55 | ;----------------------------------------------------------------------------- 56 | ; uint64_t cpu_xgetbv( int xcr ) 57 | ;----------------------------------------------------------------------------- 58 | cglobal cpu_xgetbv 59 | movifnidn ecx, r0m 60 | xgetbv 61 | %if ARCH_X86_64 62 | shl rdx, 32 63 | or rax, rdx 64 | %endif 65 | ret 66 | 67 | ;----------------------------------------------------------------------------- 68 | ; void cpu_emms( void ) 69 | ;----------------------------------------------------------------------------- 70 | cglobal cpu_emms 71 | emms 72 | ret 73 | 74 | ;----------------------------------------------------------------------------- 75 | ; void cpu_sfence( void ) 76 | ;----------------------------------------------------------------------------- 77 | cglobal cpu_sfence 78 | sfence 79 | ret 80 | 81 | %if ARCH_X86_64 == 0 82 | ;----------------------------------------------------------------------------- 83 | ; int cpu_cpuid_test( void ) 84 | ; return 0 if unsupported 85 | ;----------------------------------------------------------------------------- 86 | cglobal cpu_cpuid_test 87 | pushfd 88 | push ebx 89 | push ebp 90 | push esi 91 | push edi 92 | pushfd 93 | pop eax 94 | mov ebx, eax 95 | xor eax, 0x200000 96 | push eax 97 | popfd 98 | pushfd 99 | pop eax 100 | xor eax, ebx 101 | pop edi 102 | pop esi 103 | pop ebp 104 | pop ebx 105 | popfd 106 | ret 107 | %endif 108 | -------------------------------------------------------------------------------- /common/x86/mc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * mc.h: x86 motion compensation 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2024 x264 project 5 | * 6 | * Authors: Loren Merritt 7 | * Laurent Aimar 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 licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef X264_X86_MC_H 28 | #define X264_X86_MC_H 29 | 30 | #define x264_mc_init_mmx x264_template(mc_init_mmx) 31 | void x264_mc_init_mmx( uint32_t cpu, x264_mc_functions_t *pf ); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /doc/regression_test.txt: -------------------------------------------------------------------------------- 1 | Here is one test method which checks that the encoder's 2 | view of decoded pictures in the same as the decoder's view. 3 | This ensures that there is no distortion besides what is 4 | inherently caused by compression. 5 | 6 | # Install and compile x264 : 7 | git clone git://git.videolan.org/x264.git x264 8 | cd x264 9 | ./configure 10 | make 11 | cd .. 12 | 13 | # Install and compile JM reference decoder : 14 | wget http://iphome.hhi.de/suehring/tml/download/jm17.2.zip 15 | unzip jm17.2.zip 16 | cd JM 17 | sh unixprep.sh 18 | cd ldecod 19 | make 20 | cd ../.. 21 | 22 | ./x264/x264 input.yuv --dump-yuv fdec.yuv -o output.h264 23 | ./JM/bin/ldecod.exe -i output.h264 -o ref.yuv 24 | diff ref.yuv fdec.yuv 25 | -------------------------------------------------------------------------------- /doc/standards.txt: -------------------------------------------------------------------------------- 1 | x264 is written in C. The particular variant of C is: intersection of C99 and gcc>=3.4. 2 | checkasm is written in gcc, with no attempt at compatibility with anything else. 3 | 4 | We make the following additional assumptions which are true of real systems but not guaranteed by C99: 5 | * Two's complement. 6 | * Signed right-shifts are sign-extended. 7 | * int is 32-bit or larger. 8 | 9 | x86-specific assumptions: 10 | * The stack is 16-byte aligned. We align it on entry to libx264 and on entry to any thread, but the compiler must preserve alignment after that. 11 | * We call emms before any float operation and before returning from libx264, not after each mmx operation. So bad things could happen if the compiler inserts float operations where they aren't expected. 12 | -------------------------------------------------------------------------------- /encoder/analyse.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * analyse.h: macroblock analysis 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2024 x264 project 5 | * 6 | * Authors: Laurent Aimar 7 | * Loren Merritt 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 licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef X264_ENCODER_ANALYSE_H 28 | #define X264_ENCODER_ANALYSE_H 29 | 30 | #define x264_analyse_init_costs x264_template(analyse_init_costs) 31 | int x264_analyse_init_costs( x264_t *h ); 32 | #define x264_analyse_free_costs x264_template(analyse_free_costs) 33 | void x264_analyse_free_costs( x264_t *h ); 34 | #define x264_analyse_weight_frame x264_template(analyse_weight_frame) 35 | void x264_analyse_weight_frame( x264_t *h, int end ); 36 | #define x264_macroblock_analyse x264_template(macroblock_analyse) 37 | void x264_macroblock_analyse( x264_t *h ); 38 | #define x264_slicetype_decide x264_template(slicetype_decide) 39 | void x264_slicetype_decide( x264_t *h ); 40 | 41 | #define x264_slicetype_analyse x264_template(slicetype_analyse) 42 | void x264_slicetype_analyse( x264_t *h, int intra_minigop ); 43 | 44 | #define x264_lookahead_init x264_template(lookahead_init) 45 | int x264_lookahead_init( x264_t *h, int i_slicetype_length ); 46 | #define x264_lookahead_is_empty x264_template(lookahead_is_empty) 47 | int x264_lookahead_is_empty( x264_t *h ); 48 | #define x264_lookahead_put_frame x264_template(lookahead_put_frame) 49 | void x264_lookahead_put_frame( x264_t *h, x264_frame_t *frame ); 50 | #define x264_lookahead_get_frames x264_template(lookahead_get_frames) 51 | void x264_lookahead_get_frames( x264_t *h ); 52 | #define x264_lookahead_delete x264_template(lookahead_delete) 53 | void x264_lookahead_delete( x264_t *h ); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /encoder/me.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * me.h: motion estimation 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2024 x264 project 5 | * 6 | * Authors: Loren Merritt 7 | * Laurent Aimar 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 licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef X264_ENCODER_ME_H 28 | #define X264_ENCODER_ME_H 29 | 30 | #define COST_MAX (1<<28) 31 | #define COST_MAX64 (1ULL<<60) 32 | 33 | typedef struct 34 | { 35 | /* aligning the first member is a gcc hack to force the struct to be aligned, 36 | * as well as force sizeof(struct) to be a multiple of the alignment. */ 37 | /* input */ 38 | ALIGNED_64( int i_pixel ); /* PIXEL_WxH */ 39 | uint16_t *p_cost_mv; /* lambda * nbits for each possible mv */ 40 | int i_ref_cost; 41 | int i_ref; 42 | const x264_weight_t *weight; 43 | 44 | pixel *p_fref[12]; 45 | pixel *p_fref_w; 46 | pixel *p_fenc[3]; 47 | uint16_t *integral; 48 | int i_stride[3]; 49 | 50 | ALIGNED_4( int16_t mvp[2] ); 51 | 52 | /* output */ 53 | int cost_mv; /* lambda * nbits for the chosen mv */ 54 | int cost; /* satd + lambda * nbits */ 55 | ALIGNED_8( int16_t mv[2] ); 56 | } ALIGNED_64( x264_me_t ); 57 | 58 | #define x264_me_search_ref x264_template(me_search_ref) 59 | void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc, int *p_fullpel_thresh ); 60 | #define x264_me_search( h, m, mvc, i_mvc )\ 61 | x264_me_search_ref( h, m, mvc, i_mvc, NULL ) 62 | 63 | #define x264_me_refine_qpel x264_template(me_refine_qpel) 64 | void x264_me_refine_qpel( x264_t *h, x264_me_t *m ); 65 | #define x264_me_refine_qpel_refdupe x264_template(me_refine_qpel_refdupe) 66 | void x264_me_refine_qpel_refdupe( x264_t *h, x264_me_t *m, int *p_halfpel_thresh ); 67 | #define x264_me_refine_qpel_rd x264_template(me_refine_qpel_rd) 68 | void x264_me_refine_qpel_rd( x264_t *h, x264_me_t *m, int i_lambda2, int i4, int i_list ); 69 | #define x264_me_refine_bidir_rd x264_template(me_refine_bidir_rd) 70 | void x264_me_refine_bidir_rd( x264_t *h, x264_me_t *m0, x264_me_t *m1, int i_weight, int i8, int i_lambda2 ); 71 | #define x264_me_refine_bidir_satd x264_template(me_refine_bidir_satd) 72 | void x264_me_refine_bidir_satd( x264_t *h, x264_me_t *m0, x264_me_t *m1, int i_weight ); 73 | #define x264_rd_cost_part x264_template(rd_cost_part) 74 | uint64_t x264_rd_cost_part( x264_t *h, int i_lambda2, int i8, int i_pixel ); 75 | 76 | #define COPY1_IF_LT(x,y)\ 77 | if( (y) < (x) )\ 78 | (x) = (y); 79 | 80 | #define COPY2_IF_LT(x,y,a,b)\ 81 | if( (y) < (x) )\ 82 | {\ 83 | (x) = (y);\ 84 | (a) = (b);\ 85 | } 86 | 87 | #define COPY3_IF_LT(x,y,a,b,c,d)\ 88 | if( (y) < (x) )\ 89 | {\ 90 | (x) = (y);\ 91 | (a) = (b);\ 92 | (c) = (d);\ 93 | } 94 | 95 | #define COPY4_IF_LT(x,y,a,b,c,d,e,f)\ 96 | if( (y) < (x) )\ 97 | {\ 98 | (x) = (y);\ 99 | (a) = (b);\ 100 | (c) = (d);\ 101 | (e) = (f);\ 102 | } 103 | 104 | #define COPY2_IF_GT(x,y,a,b)\ 105 | if( (y) > (x) )\ 106 | {\ 107 | (x) = (y);\ 108 | (a) = (b);\ 109 | } 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /encoder/set.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * set.h: header writing 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2024 x264 project 5 | * 6 | * Authors: Laurent Aimar 7 | * Loren Merritt 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 licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef X264_ENCODER_SET_H 28 | #define X264_ENCODER_SET_H 29 | 30 | #define x264_sps_init x264_template(sps_init) 31 | void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param ); 32 | #define x264_sps_init_reconfigurable x264_template(sps_init_reconfigurable) 33 | void x264_sps_init_reconfigurable( x264_sps_t *sps, x264_param_t *param ); 34 | #define x264_sps_init_scaling_list x264_template(sps_init_scaling_list) 35 | void x264_sps_init_scaling_list( x264_sps_t *sps, x264_param_t *param ); 36 | #define x264_sps_write x264_template(sps_write) 37 | void x264_sps_write( bs_t *s, x264_sps_t *sps ); 38 | #define x264_pps_init x264_template(pps_init) 39 | void x264_pps_init( x264_pps_t *pps, int i_id, x264_param_t *param, x264_sps_t *sps ); 40 | #define x264_pps_write x264_template(pps_write) 41 | void x264_pps_write( bs_t *s, x264_sps_t *sps, x264_pps_t *pps ); 42 | #define x264_sei_recovery_point_write x264_template(sei_recovery_point_write) 43 | void x264_sei_recovery_point_write( x264_t *h, bs_t *s, int recovery_frame_cnt ); 44 | #define x264_sei_version_write x264_template(sei_version_write) 45 | int x264_sei_version_write( x264_t *h, bs_t *s ); 46 | #define x264_validate_levels x264_template(validate_levels) 47 | int x264_validate_levels( x264_t *h, int verbose ); 48 | #define x264_sei_buffering_period_write x264_template(sei_buffering_period_write) 49 | void x264_sei_buffering_period_write( x264_t *h, bs_t *s ); 50 | #define x264_sei_pic_timing_write x264_template(sei_pic_timing_write) 51 | void x264_sei_pic_timing_write( x264_t *h, bs_t *s ); 52 | #define x264_sei_dec_ref_pic_marking_write x264_template(sei_dec_ref_pic_marking_write) 53 | void x264_sei_dec_ref_pic_marking_write( x264_t *h, bs_t *s ); 54 | #define x264_sei_frame_packing_write x264_template(sei_frame_packing_write) 55 | void x264_sei_frame_packing_write( x264_t *h, bs_t *s ); 56 | #define x264_sei_mastering_display_write x264_template(sei_mastering_display_write) 57 | void x264_sei_mastering_display_write( x264_t *h, bs_t *s ); 58 | #define x264_sei_content_light_level_write x264_template(sei_content_light_level_write) 59 | void x264_sei_content_light_level_write( x264_t *h, bs_t *s ); 60 | #define x264_sei_alternative_transfer_write x264_template(sei_alternative_transfer_write) 61 | void x264_sei_alternative_transfer_write( x264_t *h, bs_t *s ); 62 | #define x264_sei_avcintra_umid_write x264_template(sei_avcintra_umid_write) 63 | int x264_sei_avcintra_umid_write( x264_t *h, bs_t *s ); 64 | #define x264_sei_avcintra_vanc_write x264_template(sei_avcintra_vanc_write) 65 | int x264_sei_avcintra_vanc_write( x264_t *h, bs_t *s, int len ); 66 | #define x264_sei_write x264_template(sei_write) 67 | void x264_sei_write( bs_t *s, uint8_t *payload, int payload_size, int payload_type ); 68 | #define x264_filler_write x264_template(filler_write) 69 | void x264_filler_write( x264_t *h, bs_t *s, int filler ); 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /encoder/slicetype-cl.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * slicetype-cl.h: OpenCL slicetype decision code (lowres lookahead) 3 | ***************************************************************************** 4 | * Copyright (C) 2017-2024 x264 project 5 | * 6 | * Authors: Anton Mitrofanov 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_ENCODER_SLICETYPE_CL_H 27 | #define X264_ENCODER_SLICETYPE_CL_H 28 | 29 | #define x264_opencl_lowres_init x264_template(opencl_lowres_init) 30 | int x264_opencl_lowres_init( x264_t *h, x264_frame_t *fenc, int lambda ); 31 | #define x264_opencl_motionsearch x264_template(opencl_motionsearch) 32 | int x264_opencl_motionsearch( x264_t *h, x264_frame_t **frames, int b, int ref, int b_islist1, int lambda, const x264_weight_t *w ); 33 | #define x264_opencl_finalize_cost x264_template(opencl_finalize_cost) 34 | int x264_opencl_finalize_cost( x264_t *h, int lambda, x264_frame_t **frames, int p0, int p1, int b, int dist_scale_factor ); 35 | #define x264_opencl_precalculate_frame_cost x264_template(opencl_precalculate_frame_cost) 36 | int x264_opencl_precalculate_frame_cost( x264_t *h, x264_frame_t **frames, int lambda, int p0, int p1, int b ); 37 | #define x264_opencl_flush x264_template(opencl_flush) 38 | void x264_opencl_flush( x264_t *h ); 39 | #define x264_opencl_slicetype_prep x264_template(opencl_slicetype_prep) 40 | void x264_opencl_slicetype_prep( x264_t *h, x264_frame_t **frames, int num_frames, int lambda ); 41 | #define x264_opencl_slicetype_end x264_template(opencl_slicetype_end) 42 | void x264_opencl_slicetype_end( x264_t *h ); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /extras/intel_dispatcher.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * intel_dispatcher.h: intel compiler cpu dispatcher override 3 | ***************************************************************************** 4 | * Copyright (C) 2014-2024 x264 project 5 | * 6 | * Authors: Anton Mitrofanov 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_INTEL_DISPATCHER_H 27 | #define X264_INTEL_DISPATCHER_H 28 | 29 | /* Feature flags using _FEATURE_* defines from immintrin.h */ 30 | extern unsigned long long __intel_cpu_feature_indicator; 31 | extern unsigned long long __intel_cpu_feature_indicator_x; 32 | 33 | /* CPU vendor independent version of dispatcher */ 34 | void __intel_cpu_features_init_x( void ); 35 | 36 | static void x264_intel_dispatcher_override( void ) 37 | { 38 | if( __intel_cpu_feature_indicator & ~1ULL ) 39 | return; 40 | __intel_cpu_feature_indicator = 0; 41 | __intel_cpu_feature_indicator_x = 0; 42 | __intel_cpu_features_init_x(); 43 | __intel_cpu_feature_indicator = __intel_cpu_feature_indicator_x; 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /filters/filters.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * filters.h: common filter functions 3 | ***************************************************************************** 4 | * Copyright (C) 2010-2024 x264 project 5 | * 6 | * Authors: Diogo Franco 7 | * Steven Walters 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 licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef X264_FILTERS_H 28 | #define X264_FILTERS_H 29 | 30 | #include "x264cli.h" 31 | #include "filters/video/video.h" 32 | 33 | char **x264_split_options( const char *opt_str, const char * const *options ); 34 | char *x264_get_option( const char *name, char **split_options ); 35 | int x264_otob( const char *str, int def ); // option to bool 36 | double x264_otof( const char *str, double def ); // option to float/double 37 | int x264_otoi( const char *str, int def ); // option to int 38 | char *x264_otos( char *str, char *def ); // option to string 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /filters/video/internal.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * internal.c: video filter utilities 3 | ***************************************************************************** 4 | * Copyright (C) 2010-2024 x264 project 5 | * 6 | * Authors: Steven Walters 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #include "internal.h" 27 | 28 | #define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, "x264", __VA_ARGS__ ) 29 | 30 | void x264_cli_plane_copy( uint8_t *dst, int i_dst, uint8_t *src, int i_src, int w, int h ) 31 | { 32 | while( h-- ) 33 | { 34 | memcpy( dst, src, w ); 35 | dst += i_dst; 36 | src += i_src; 37 | } 38 | } 39 | 40 | int x264_cli_pic_copy( cli_pic_t *out, cli_pic_t *in ) 41 | { 42 | int csp = in->img.csp & X264_CSP_MASK; 43 | FAIL_IF_ERROR( x264_cli_csp_is_invalid( in->img.csp ), "invalid colorspace arg %d\n", in->img.csp ); 44 | FAIL_IF_ERROR( in->img.csp != out->img.csp || in->img.height != out->img.height 45 | || in->img.width != out->img.width, "incompatible frame properties\n" ); 46 | /* copy data */ 47 | out->duration = in->duration; 48 | out->pts = in->pts; 49 | out->opaque = in->opaque; 50 | 51 | for( int i = 0; i < out->img.planes; i++ ) 52 | { 53 | int height = in->img.height * x264_cli_csps[csp].height[i]; 54 | int width = in->img.width * x264_cli_csps[csp].width[i]; 55 | width *= x264_cli_csp_depth_factor( in->img.csp ); 56 | x264_cli_plane_copy( out->img.plane[i], out->img.stride[i], in->img.plane[i], 57 | in->img.stride[i], width, height ); 58 | } 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /filters/video/internal.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * internal.h: video filter utilities 3 | ***************************************************************************** 4 | * Copyright (C) 2010-2024 x264 project 5 | * 6 | * Authors: Steven Walters 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_FILTER_VIDEO_INTERNAL_H 27 | #define X264_FILTER_VIDEO_INTERNAL_H 28 | 29 | #include "video.h" 30 | 31 | void x264_cli_plane_copy( uint8_t *dst, int i_dst, uint8_t *src, int i_src, int w, int h ); 32 | int x264_cli_pic_copy( cli_pic_t *out, cli_pic_t *in ); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /filters/video/source.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * source.c: source video filter 3 | ***************************************************************************** 4 | * Copyright (C) 2010-2024 x264 project 5 | * 6 | * Authors: Steven Walters 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #include "video.h" 27 | 28 | /* This filter converts the demuxer API into the filtering API for video frames. 29 | * Backseeking is prohibited here as not all demuxers are capable of doing so. */ 30 | 31 | typedef struct 32 | { 33 | cli_pic_t pic; 34 | hnd_t hin; 35 | int cur_frame; 36 | } source_hnd_t; 37 | 38 | cli_vid_filter_t source_filter; 39 | 40 | static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, x264_param_t *param, char *opt_string ) 41 | { 42 | source_hnd_t *h = calloc( 1, sizeof(source_hnd_t) ); 43 | if( !h ) 44 | return -1; 45 | h->cur_frame = -1; 46 | 47 | if( cli_input.picture_alloc( &h->pic, *handle, info->csp, info->width, info->height ) ) 48 | return -1; 49 | 50 | h->hin = *handle; 51 | *handle = h; 52 | *filter = source_filter; 53 | 54 | return 0; 55 | } 56 | 57 | static int get_frame( hnd_t handle, cli_pic_t *output, int frame ) 58 | { 59 | source_hnd_t *h = handle; 60 | /* do not allow requesting of frames from before the current position */ 61 | if( frame <= h->cur_frame || cli_input.read_frame( &h->pic, h->hin, frame ) ) 62 | return -1; 63 | h->cur_frame = frame; 64 | *output = h->pic; 65 | return 0; 66 | } 67 | 68 | static int release_frame( hnd_t handle, cli_pic_t *pic, int frame ) 69 | { 70 | source_hnd_t *h = handle; 71 | if( cli_input.release_frame && cli_input.release_frame( &h->pic, h->hin ) ) 72 | return -1; 73 | return 0; 74 | } 75 | 76 | static void free_filter( hnd_t handle ) 77 | { 78 | source_hnd_t *h = handle; 79 | cli_input.picture_clean( &h->pic, h->hin ); 80 | cli_input.close_file( h->hin ); 81 | free( h ); 82 | } 83 | 84 | cli_vid_filter_t source_filter = { "source", NULL, init, get_frame, release_frame, free_filter, NULL }; 85 | -------------------------------------------------------------------------------- /filters/video/video.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * video.c: video filters 3 | ***************************************************************************** 4 | * Copyright (C) 2010-2024 x264 project 5 | * 6 | * Authors: Steven Walters 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #include "video.h" 27 | 28 | static cli_vid_filter_t *first_filter = NULL; 29 | 30 | static void register_vid_filter( cli_vid_filter_t *new_filter ) 31 | { 32 | cli_vid_filter_t *filter_i = first_filter; 33 | while( filter_i->next ) 34 | filter_i = filter_i->next; 35 | filter_i->next = new_filter; 36 | new_filter->next = NULL; 37 | } 38 | 39 | #define REGISTER_VFILTER(name)\ 40 | {\ 41 | extern cli_vid_filter_t name##_filter;\ 42 | register_vid_filter( &name##_filter );\ 43 | } 44 | 45 | void x264_register_vid_filters( void ) 46 | { 47 | extern cli_vid_filter_t source_filter; 48 | first_filter = &source_filter; 49 | #if HAVE_BITDEPTH8 50 | REGISTER_VFILTER( cache_8 ); 51 | REGISTER_VFILTER( depth_8 ); 52 | #endif 53 | #if HAVE_BITDEPTH10 54 | REGISTER_VFILTER( cache_10 ); 55 | REGISTER_VFILTER( depth_10 ); 56 | #endif 57 | REGISTER_VFILTER( crop ); 58 | REGISTER_VFILTER( fix_vfr_pts ); 59 | REGISTER_VFILTER( resize ); 60 | REGISTER_VFILTER( select_every ); 61 | #if HAVE_GPL 62 | #endif 63 | } 64 | 65 | int x264_init_vid_filter( const char *name, hnd_t *handle, cli_vid_filter_t *filter, 66 | video_info_t *info, x264_param_t *param, char *opt_string ) 67 | { 68 | cli_vid_filter_t *filter_i = first_filter; 69 | while( filter_i && strcasecmp( name, filter_i->name ) ) 70 | filter_i = filter_i->next; 71 | FAIL_IF_ERR( !filter_i, "x264", "invalid filter `%s'\n", name ); 72 | if( filter_i->init( handle, filter, info, param, opt_string ) ) 73 | return -1; 74 | 75 | return 0; 76 | } 77 | 78 | void x264_vid_filter_help( int longhelp ) 79 | { 80 | for( cli_vid_filter_t *filter_i = first_filter; filter_i; filter_i = filter_i->next ) 81 | if( filter_i->help ) 82 | filter_i->help( longhelp ); 83 | } 84 | -------------------------------------------------------------------------------- /filters/video/video.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * video.h: video filters 3 | ***************************************************************************** 4 | * Copyright (C) 2010-2024 x264 project 5 | * 6 | * Authors: Steven Walters 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_FILTER_VIDEO_H 27 | #define X264_FILTER_VIDEO_H 28 | 29 | #include "input/input.h" 30 | #include "filters/filters.h" 31 | 32 | typedef struct cli_vid_filter_t cli_vid_filter_t; 33 | 34 | struct cli_vid_filter_t 35 | { 36 | /* name of the filter */ 37 | const char *name; 38 | /* help: a short message on what the filter does and how to use it. 39 | * this should only be implemented by filters directly accessible by the user */ 40 | void (*help)( int longhelp ); 41 | /* init: initializes the filter given the input clip properties and parameter to adjust them as necessary 42 | * with the given options provided by the user. 43 | * returns 0 on success, nonzero on error. */ 44 | int (*init)( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, x264_param_t *param, char *opt_string ); 45 | /* get_frame: given the storage for the output frame and desired frame number, generate the frame accordingly. 46 | * the image data returned by get_frame should be treated as const and not be altered. 47 | * returns 0 on success, nonzero on error. */ 48 | int (*get_frame)( hnd_t handle, cli_pic_t *output, int frame ); 49 | /* release_frame: frame is done being used and is signaled for cleanup. 50 | * returns 0 on succeess, nonzero on error. */ 51 | int (*release_frame)( hnd_t handle, cli_pic_t *pic, int frame ); 52 | /* free: run filter cleanup procedures. */ 53 | void (*free)( hnd_t handle ); 54 | /* next registered filter, unused by filters themselves */ 55 | cli_vid_filter_t *next; 56 | }; 57 | 58 | void x264_register_vid_filters( void ); 59 | void x264_vid_filter_help( int longhelp ); 60 | int x264_init_vid_filter( const char *name, hnd_t *handle, cli_vid_filter_t *filter, 61 | video_info_t *info, x264_param_t *param, char *opt_string ); 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /output/matroska_ebml.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * matroska_ebml.h: matroska muxer utilities 3 | ***************************************************************************** 4 | * Copyright (C) 2005-2024 x264 project 5 | * 6 | * Authors: Mike Matsnev 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_MATROSKA_EBML_H 27 | #define X264_MATROSKA_EBML_H 28 | 29 | /* Matroska display size units from the spec */ 30 | #define DS_PIXELS 0 31 | #define DS_CM 1 32 | #define DS_INCHES 2 33 | #define DS_ASPECT_RATIO 3 34 | 35 | typedef struct mk_writer mk_writer; 36 | 37 | mk_writer *mk_create_writer( const char *filename ); 38 | 39 | int mk_write_header( mk_writer *w, const char *writing_app, 40 | const char *codec_id, 41 | const void *codec_private, unsigned codec_private_size, 42 | int64_t default_frame_duration, 43 | int64_t timescale, 44 | unsigned width, unsigned height, 45 | unsigned d_width, unsigned d_height, int display_size_units, int stereo_mode ); 46 | 47 | int mk_start_frame( mk_writer *w ); 48 | int mk_add_frame_data( mk_writer *w, const void *data, unsigned size ); 49 | int mk_set_frame_flags( mk_writer *w, int64_t timestamp, int keyframe, int skippable ); 50 | int mk_close( mk_writer *w, int64_t last_delta ); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /output/output.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * output.h: x264 file output modules 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2024 x264 project 5 | * 6 | * Authors: Laurent Aimar 7 | * Loren Merritt 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 licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef X264_OUTPUT_H 28 | #define X264_OUTPUT_H 29 | 30 | #include "x264cli.h" 31 | 32 | typedef struct 33 | { 34 | int use_dts_compress; 35 | } cli_output_opt_t; 36 | 37 | typedef struct 38 | { 39 | int (*open_file)( char *psz_filename, hnd_t *p_handle, cli_output_opt_t *opt ); 40 | int (*set_param)( hnd_t handle, x264_param_t *p_param ); 41 | int (*write_headers)( hnd_t handle, x264_nal_t *p_nal ); 42 | int (*write_frame)( hnd_t handle, uint8_t *p_nal, int i_size, x264_picture_t *p_picture ); 43 | int (*close_file)( hnd_t handle, int64_t largest_pts, int64_t second_largest_pts ); 44 | } cli_output_t; 45 | 46 | extern const cli_output_t raw_output; 47 | extern const cli_output_t mkv_output; 48 | extern const cli_output_t mp4_output; 49 | extern const cli_output_t flv_output; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /output/raw.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * raw.c: raw muxer 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2024 x264 project 5 | * 6 | * Authors: Laurent Aimar 7 | * Loren Merritt 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 licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #include "output.h" 28 | 29 | static int open_file( char *psz_filename, hnd_t *p_handle, cli_output_opt_t *opt ) 30 | { 31 | if( !strcmp( psz_filename, "-" ) ) 32 | *p_handle = stdout; 33 | else if( !(*p_handle = x264_fopen( psz_filename, "w+b" )) ) 34 | return -1; 35 | 36 | return 0; 37 | } 38 | 39 | static int set_param( hnd_t handle, x264_param_t *p_param ) 40 | { 41 | return 0; 42 | } 43 | 44 | static int write_headers( hnd_t handle, x264_nal_t *p_nal ) 45 | { 46 | int size = p_nal[0].i_payload + p_nal[1].i_payload + p_nal[2].i_payload; 47 | 48 | if( fwrite( p_nal[0].p_payload, size, 1, (FILE*)handle ) ) 49 | return size; 50 | return -1; 51 | } 52 | 53 | static int write_frame( hnd_t handle, uint8_t *p_nalu, int i_size, x264_picture_t *p_picture ) 54 | { 55 | if( fwrite( p_nalu, i_size, 1, (FILE*)handle ) ) 56 | return i_size; 57 | return -1; 58 | } 59 | 60 | static int close_file( hnd_t handle, int64_t largest_pts, int64_t second_largest_pts ) 61 | { 62 | if( !handle || handle == stdout ) 63 | return 0; 64 | 65 | return fclose( (FILE*)handle ); 66 | } 67 | 68 | const cli_output_t raw_output = { open_file, set_param, write_headers, write_frame, close_file }; 69 | 70 | -------------------------------------------------------------------------------- /tools/bash-autocomplete.sh: -------------------------------------------------------------------------------- 1 | _x264() 2 | { 3 | local path args cur prev 4 | 5 | path="${COMP_LINE%%[[:blank:]]*}" 6 | args="${COMP_LINE:${#path}:$((COMP_POINT-${#path}))}" 7 | cur="${args##*[[:blank:]=]}" 8 | prev="$(sed 's/[[:blank:]=]*$//; s/^.*[[:blank:]]//' <<< "${args%%"$cur"}")" 9 | 10 | # Expand ~ 11 | printf -v path '%q' "$path" && eval path="${path/#'\~'/'~'}" 12 | 13 | COMPREPLY=($("$path" --autocomplete "$prev" "$cur")) && compopt +o default 14 | } 2>/dev/null 15 | complete -o default -F _x264 x264 16 | -------------------------------------------------------------------------------- /tools/checkasm-arm.S: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * checkasm-arm.S: assembly check tool 3 | ***************************************************************************** 4 | * Copyright (C) 2015-2024 x264 project 5 | * 6 | * Authors: Martin Storsjo 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #include "../common/arm/asm.S" 27 | 28 | const register_init, align=4 29 | .quad 0x21f86d66c8ca00ce 30 | .quad 0x75b6ba21077c48ad 31 | .quad 0xed56bb2dcb3c7736 32 | .quad 0x8bda43d3fd1a7e06 33 | .quad 0xb64a9c9e5d318408 34 | .quad 0xdf9a54b303f1d3a3 35 | .quad 0x4a75479abd64e097 36 | .quad 0x249214109d5d1c88 37 | endconst 38 | 39 | const error_message 40 | .asciz "failed to preserve register" 41 | endconst 42 | 43 | .text 44 | 45 | @ max number of args used by any x264 asm function. 46 | #define MAX_ARGS 15 47 | 48 | #define ARG_STACK 4*(MAX_ARGS - 4) 49 | 50 | @ align the used stack space to 8 to preserve the stack alignment 51 | #define ARG_STACK_A (((ARG_STACK + pushed + 7) & ~7) - pushed) 52 | 53 | .macro clobbercheck variant 54 | .equ pushed, 4*10 55 | function checkasm_call_\variant 56 | push {r4-r11, lr} 57 | .ifc \variant, neon 58 | vpush {q4-q7} 59 | .equ pushed, pushed + 16*4 60 | .endif 61 | 62 | movrel r12, register_init 63 | .ifc \variant, neon 64 | vldm r12, {q4-q7} 65 | .endif 66 | ldm r12, {r4-r11} 67 | 68 | push {r1} 69 | 70 | sub sp, sp, #ARG_STACK_A 71 | .equ pos, 0 72 | .rept MAX_ARGS-4 73 | ldr r12, [sp, #ARG_STACK_A + pushed + 8 + pos] 74 | str r12, [sp, #pos] 75 | .equ pos, pos + 4 76 | .endr 77 | 78 | mov r12, r0 79 | mov r0, r2 80 | mov r1, r3 81 | ldrd r2, r3, [sp, #ARG_STACK_A + pushed] 82 | blx r12 83 | add sp, sp, #ARG_STACK_A 84 | pop {r2} 85 | 86 | push {r0, r1} 87 | movrel r12, register_init 88 | .ifc \variant, neon 89 | vldm r12, {q0-q3} 90 | veor q0, q0, q4 91 | veor q1, q1, q5 92 | veor q2, q2, q6 93 | veor q3, q3, q7 94 | vorr q0, q0, q1 95 | vorr q0, q0, q2 96 | vorr q0, q0, q3 97 | vorr d0, d0, d1 98 | vrev64.32 d1, d0 99 | vorr d0, d0, d1 100 | vmov.32 r3, d0[0] 101 | .else 102 | mov r3, #0 103 | .endif 104 | 105 | .macro check_reg reg1, reg2= 106 | ldrd r0, r1, [r12], #8 107 | eor r0, r0, \reg1 108 | orr r3, r3, r0 109 | .ifnb \reg2 110 | eor r1, r1, \reg2 111 | orr r3, r3, r1 112 | .endif 113 | .endm 114 | check_reg r4, r5 115 | check_reg r6, r7 116 | @ r9 is a volatile register in the ios ABI 117 | #if SYS_MACOSX 118 | check_reg r8 119 | #else 120 | check_reg r8, r9 121 | #endif 122 | check_reg r10, r11 123 | .purgem check_reg 124 | 125 | cmp r3, #0 126 | beq 0f 127 | 128 | mov r12, #0 129 | str r12, [r2] 130 | movrel r0, error_message 131 | blx EXT(puts) 132 | 0: 133 | pop {r0, r1} 134 | .ifc \variant, neon 135 | vpop {q4-q7} 136 | .endif 137 | pop {r4-r11, pc} 138 | endfunc 139 | .endm 140 | 141 | clobbercheck neon 142 | clobbercheck noneon 143 | -------------------------------------------------------------------------------- /tools/cltostr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Convert standard input to a C char array, write to a file, then create an 4 | # MD5 sum of that file and append said MD5 sum as char array to the file. 5 | 6 | [ -n "$1" ] || exit 1 7 | 8 | # Filter out whitespace, empty lines, and comments. 9 | sanitize() { 10 | sed 's/^[[:space:]]*//; /^$/d; /^\/\//d' 11 | } 12 | 13 | # Convert stdin to a \0-terminated char array. 14 | dump() { 15 | echo "static const char $1[] = {" 16 | od -v -A n -t x1 | sed 's/[[:space:]]*\([[:alnum:]]\{2\}\)/0x\1, /g' 17 | echo '0x00 };' 18 | } 19 | 20 | # Print MD5 hash w/o newline character to not embed the character in the array. 21 | hash() { 22 | # md5sum is not standard, so try different platform-specific alternatives. 23 | { md5sum "$1" || md5 -q "$1" || digest -a md5 "$1"; } 2>/dev/null | 24 | cut -b -32 | tr -d '\n\r' 25 | } 26 | 27 | trap 'rm -f "$1.temp"' EXIT 28 | 29 | sanitize | tee "$1.temp" | 30 | dump 'x264_opencl_source' > "$1" 31 | 32 | hash "$1.temp" | 33 | dump 'x264_opencl_source_hash' >> "$1" 34 | -------------------------------------------------------------------------------- /tools/countquant_x264.pl: -------------------------------------------------------------------------------- 1 | #!/bin/env perl 2 | # countquant_x264.pl: displays statistics from x264 multipass logfiles 3 | # by Loren Merritt, 2005-4-5 4 | 5 | @size{I,P,B} = 6 | @n{I,P,B} = (0)x3; 7 | 8 | sub proc_file { 9 | my $fh = shift; 10 | while(<$fh>) { 11 | /type:(.) q:(\d+\.\d+) tex:(\d+) mv:(\d+) misc:(\d+)/ or next; 12 | $type = uc $1; 13 | $n{$type} ++; 14 | $q[int($2+.5)] ++; 15 | $avgq += $2; 16 | $avgq{$type} += $2; 17 | my $bytes = ($3+$4+$5)/8; 18 | $size{$type} += $bytes; 19 | } 20 | $size = $size{I} + $size{P} + $size{B}; 21 | $n = $n{I} + $n{P} + $n{B}; 22 | $n or die "unrecognized input\n"; 23 | } 24 | 25 | if(@ARGV) { 26 | foreach(@ARGV) { 27 | open $fh, "<", $_ or die "can't open '$_': $!"; 28 | proc_file($fh); 29 | } 30 | } else { 31 | proc_file(STDIN); 32 | } 33 | 34 | for(0..51) { 35 | $q[$_] or next; 36 | printf "q%2d: %6d %4.1f%%\n", $_, $q[$_], 100*$q[$_]/$n; 37 | } 38 | print "\n"; 39 | $digits = int(log($n+1)/log(10))+2; 40 | printf "All: %${digits}d %s avgQP:%5.2f avgBytes:%5d\n", 41 | $n, $n==$n{I}?" ":"", $avgq/$n, $size/$n; 42 | foreach(qw(I P B S)) { 43 | $n{$_} or next; 44 | printf "%s: %${digits}d (%4.1f%%) avgQP:%5.2f avgBytes:%5d\n", 45 | $_, $n{$_}, 100*$n{$_}/$n, $avgq{$_}/$n{$_}, $size{$_}/$n{$_}; 46 | } 47 | print "\n"; 48 | printf "total size: $size B = %.2f KiB = %.2f MiB\n", 49 | $size/2**10, $size/2**20; 50 | print "bitrate: ", join("\n = ", 51 | map sprintf("%.2f kbps @ %s fps", $_*$size*8/1000/$n, $_), 52 | 23.976, 25, 29.97), "\n"; 53 | -------------------------------------------------------------------------------- /tools/digress/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Automated regression/unit testing suite. 3 | """ 4 | 5 | __version__ = '0.2' 6 | 7 | def digress(fixture): 8 | """ 9 | Command-line helper for Digress. 10 | """ 11 | from digress.cli import Dispatcher 12 | Dispatcher(fixture).dispatch() 13 | -------------------------------------------------------------------------------- /tools/digress/comparers.py: -------------------------------------------------------------------------------- 1 | """ 2 | Digress comparers. 3 | """ 4 | 5 | from digress.errors import ComparisonError 6 | 7 | import os 8 | from itertools import imap, izip 9 | 10 | def compare_direct(value_a, value_b): 11 | if value_a != value_b: 12 | raise ComparisonError("%s is not %s" % (value_a, value_b)) 13 | 14 | def compare_pass(value_a, value_b): 15 | """ 16 | Always true, as long as the test is passed. 17 | """ 18 | 19 | def compare_tolerance(tolerance): 20 | def _compare_tolerance(value_a, value_b): 21 | if abs(value_a - value_b) > tolerance: 22 | raise ComparisonError("%s is not %s (tolerance: %s)" % ( 23 | value_a, 24 | value_b, 25 | tolerance 26 | )) 27 | return _compare_tolerance 28 | 29 | def compare_files(file_a, file_b): 30 | size_a = os.path.getsize(file_a) 31 | size_b = os.path.getsize(file_b) 32 | 33 | print file_a, file_b 34 | 35 | if size_a != size_b: 36 | raise ComparisonError("%s is not the same size as %s" % ( 37 | file_a, 38 | file_b 39 | )) 40 | 41 | BUFFER_SIZE = 8196 42 | 43 | offset = 0 44 | 45 | with open(file_a) as f_a: 46 | with open(file_b) as f_b: 47 | for chunk_a, chunk_b in izip( 48 | imap( 49 | lambda i: f_a.read(BUFFER_SIZE), 50 | xrange(size_a // BUFFER_SIZE + 1) 51 | ), 52 | imap( 53 | lambda i: f_b.read(BUFFER_SIZE), 54 | xrange(size_b // BUFFER_SIZE + 1) 55 | ) 56 | ): 57 | chunk_size = len(chunk_a) 58 | 59 | if chunk_a != chunk_b: 60 | for i in xrange(chunk_size): 61 | if chunk_a[i] != chunk_b[i]: 62 | raise ComparisonError("%s differs from %s at offset %d" % ( 63 | file_a, 64 | file_b, 65 | offset + i 66 | )) 67 | 68 | offset += chunk_size 69 | -------------------------------------------------------------------------------- /tools/digress/constants.py: -------------------------------------------------------------------------------- 1 | """ 2 | All of Digress's constants. 3 | """ 4 | 5 | TEST_PASS = 0 6 | TEST_FAIL = 1 7 | TEST_DISABLED = 2 8 | TEST_SKIPPED = 3 9 | 10 | CASE_PASS = 0 11 | CASE_FAIL = 1 12 | 13 | FIXTURE_PASS = 0 14 | FIXTURE_FAIL = 1 15 | -------------------------------------------------------------------------------- /tools/digress/errors.py: -------------------------------------------------------------------------------- 1 | """ 2 | Digress errors. 3 | """ 4 | 5 | class DigressError(Exception): 6 | """ 7 | Digress error base class. 8 | """ 9 | 10 | class NoSuchTestError(DigressError): 11 | """ 12 | Raised when no such test exists. 13 | """ 14 | 15 | class DisabledTestError(DigressError): 16 | """ 17 | Test is disabled. 18 | """ 19 | 20 | class SkippedTestError(DigressError): 21 | """ 22 | Test is marked as skipped. 23 | """ 24 | 25 | class DisabledCaseError(DigressError): 26 | """ 27 | Case is marked as disabled. 28 | """ 29 | 30 | class SkippedCaseError(DigressError): 31 | """ 32 | Case is marked as skipped. 33 | """ 34 | 35 | class FailedTestError(DigressError): 36 | """ 37 | Test failed. 38 | """ 39 | 40 | class ComparisonError(DigressError): 41 | """ 42 | Comparison failed. 43 | """ 44 | 45 | class IncomparableError(DigressError): 46 | """ 47 | Values cannot be compared. 48 | """ 49 | 50 | class AlreadyRunError(DigressError): 51 | """ 52 | Test/case has already been run. 53 | """ 54 | 55 | class SCMError(DigressError): 56 | """ 57 | Error occurred in SCM. 58 | """ 59 | def __init__(self, message): 60 | self.message = message.replace("\n", " ") 61 | 62 | def __str__(self): 63 | return self.message 64 | -------------------------------------------------------------------------------- /tools/digress/scm/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Source control backends for Digress. 3 | """ 4 | -------------------------------------------------------------------------------- /tools/digress/scm/dummy.py: -------------------------------------------------------------------------------- 1 | """ 2 | Dummy SCM backend for Digress. 3 | """ 4 | 5 | from random import random 6 | 7 | def checkout(revision): 8 | """ 9 | Checkout a revision. 10 | """ 11 | pass 12 | 13 | def current_rev(): 14 | """ 15 | Get the current revision 16 | """ 17 | return str(random()) 18 | 19 | def revisions(rev_a, rev_b): 20 | """ 21 | Get a list of revisions from one to another. 22 | """ 23 | pass 24 | 25 | def stash(): 26 | """ 27 | Stash the repository. 28 | """ 29 | pass 30 | 31 | def unstash(): 32 | """ 33 | Unstash the repository. 34 | """ 35 | pass 36 | 37 | def bisect(command, revision): 38 | """ 39 | Perform a bisection. 40 | """ 41 | raise NotImplementedError("dummy SCM backend does not support bisection") 42 | -------------------------------------------------------------------------------- /tools/digress/scm/git.py: -------------------------------------------------------------------------------- 1 | """ 2 | Git SCM backend for Digress. 3 | """ 4 | 5 | from subprocess import Popen, PIPE, STDOUT 6 | import re 7 | 8 | from digress.errors import SCMError 9 | 10 | GIT_BRANCH_EXPR = re.compile("[*] (.*)") 11 | 12 | def checkout(revision): 13 | """ 14 | Checkout a revision from git. 15 | """ 16 | proc = Popen([ 17 | "git", 18 | "checkout", 19 | "-f", 20 | revision 21 | ], stdout=PIPE, stderr=STDOUT) 22 | 23 | output = proc.communicate()[0].strip() 24 | if proc.returncode != 0: 25 | raise SCMError("checkout error: %s" % output) 26 | 27 | def rev_parse(ref): 28 | proc = Popen([ 29 | "git", 30 | "rev-parse", 31 | ref 32 | ], stdout=PIPE, stderr=STDOUT) 33 | 34 | output = proc.communicate()[0].strip() 35 | if proc.returncode != 0: 36 | raise SCMError("rev-parse error: %s" % output) 37 | return output 38 | 39 | def current_rev(): 40 | """ 41 | Get the current revision. 42 | """ 43 | return rev_parse("HEAD") 44 | 45 | def current_branch(): 46 | """ 47 | Get the current branch. 48 | """ 49 | proc = Popen([ 50 | "git", 51 | "branch", 52 | "--no-color" 53 | ], stdout=PIPE, stderr=STDOUT) 54 | 55 | output = proc.communicate()[0].strip() 56 | if proc.returncode != 0: 57 | raise SCMError("branch error: %s" % output) 58 | branch_name = GIT_BRANCH_EXPR.findall(output)[0] 59 | return branch_name != "(no branch)" and branch_name or None 60 | 61 | def revisions(rev_a, rev_b): 62 | """ 63 | Get a list of revisions from one to another. 64 | """ 65 | proc = Popen([ 66 | "git", 67 | "log", 68 | "--format=%H", ("%s...%s" % (rev_a, rev_b)) 69 | ], stdout=PIPE, stderr=STDOUT) 70 | 71 | output = proc.communicate()[0].strip() 72 | if proc.returncode != 0: 73 | raise SCMError("log error: %s" % output) 74 | return output.split("\n") 75 | 76 | def stash(): 77 | """ 78 | Stash the repository. 79 | """ 80 | proc = Popen([ 81 | "git", 82 | "stash", 83 | "save", 84 | "--keep-index" 85 | ], stdout=PIPE, stderr=STDOUT) 86 | 87 | output = proc.communicate()[0].strip() 88 | if proc.returncode != 0: 89 | raise SCMError("stash error: %s" % output) 90 | 91 | def unstash(): 92 | """ 93 | Unstash the repository. 94 | """ 95 | proc = Popen(["git", "stash", "pop"], stdout=PIPE, stderr=STDOUT) 96 | proc.communicate() 97 | 98 | def bisect(*args): 99 | """ 100 | Perform a bisection. 101 | """ 102 | proc = Popen((["git", "bisect"] + list(args)), stdout=PIPE, stderr=STDOUT) 103 | output = proc.communicate()[0] 104 | if proc.returncode != 0: 105 | raise SCMError("bisect error: %s" % output) 106 | return output 107 | 108 | def dirty(): 109 | """ 110 | Check if the working tree is dirty. 111 | """ 112 | proc = Popen(["git", "status"], stdout=PIPE, stderr=STDOUT) 113 | output = proc.communicate()[0].strip() 114 | if proc.returncode != 0: 115 | raise SCMError("status error: %s" % output) 116 | if "modified:" in output: 117 | return True 118 | else: 119 | return False 120 | -------------------------------------------------------------------------------- /tools/msvsdepend.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Output a Makefile rule describing the dependencies of a given source file. 4 | # Expected arguments are $(CC) $(CFLAGS) $(SRC) $(OBJ) 5 | 6 | set -f 7 | 8 | [ -n "$1" ] && [ -n "$3" ] && [ -n "$4" ] || exit 1 9 | 10 | # Add flags to only perform syntax checking and output a list of included files 11 | # Discard all output other than included files 12 | # Convert '\' directory separators to '/' 13 | # Remove system includes (hack: check for "/Program Files" string in path) 14 | # Add the source file itself as a dependency 15 | deps="$($1 $2 -nologo -showIncludes -W0 -Zs "$3" 2>&1 | 16 | grep '^Note: including file:' | 17 | sed 's/^Note: including file:[[:space:]]*\(.*\)$/\1/; s/\\/\//g' | 18 | sed '/\/[Pp]rogram [Ff]iles/d') 19 | $3" 20 | 21 | # Convert Windows paths to Unix paths if possible 22 | if command -v cygpath >/dev/null 2>&1 ; then 23 | IFS=' 24 | ' 25 | deps="$(cygpath -u -- $deps)" 26 | elif grep -q 'Microsoft' /proc/sys/kernel/osrelease 2>/dev/null ; then 27 | # Running under WSL. We don't have access to cygpath but since the Windows 28 | # file system resides under "/mnt//" we can simply replace 29 | # "C:" with "/mnt/c". This command uses a GNU extension to sed but that's 30 | # available on WSL so we don't need to limit ourselves by what POSIX says. 31 | deps="$(printf '%s' "$deps" | sed 's/^\([a-zA-Z]\):/\/mnt\/\L\1/')" 32 | fi 33 | 34 | # Escape characters as required to create valid Makefile file names 35 | escape() { 36 | sed 's/ /\\ /g; s/#/\\#/g; s/\$/\$\$/g' 37 | } 38 | 39 | # Remove prefixes that are equal to the working directory 40 | # Sort and remove duplicate entries 41 | # Escape and collapse the dependencies into one line 42 | deps="$(printf '%s' "$deps" | 43 | sed "s/^$(pwd | sed 's/\//\\\//g')\///; s/^\.\///" | 44 | sort | uniq | 45 | escape | tr -s '\n\r' ' ' | sed 's/^ *\(.*\) $/\1/')" 46 | 47 | # Escape the target file name as well 48 | target="$(printf '%s' "$4" | escape)" 49 | 50 | printf '%s: %s\n' "$target" "$deps" 51 | -------------------------------------------------------------------------------- /tools/q_matrix_jvt.cfg: -------------------------------------------------------------------------------- 1 | # This an example configuration file for initializing the quantization matrix. 2 | # Altogether 6 matrices for 4x4 blocks and 2 matrix for 8x8 blocks. 3 | # The values range from 1 to 255. 4 | # If first value of matrix is equal to 0, default values ("JVT") will be used 5 | # for that matrix. 6 | # If a matrix is completely omitted, it will be filled with 16s. 7 | # 8 | # Note: JM expects CHROMAU and CHROMAV to be specified separately, whereas 9 | # x264 forces them to use the same matrix. If U and V are specified to have 10 | # different matrices, only the first is used. 11 | #################################################################################### 12 | 13 | INTRA4X4_LUMA = 14 | 6,13,20,28, 15 | 13,20,28,32, 16 | 20,28,32,37, 17 | 28,32,37,42 18 | 19 | INTRA4X4_CHROMAU = 20 | 6,13,20,28, 21 | 13,20,28,32, 22 | 20,28,32,37, 23 | 28,32,37,42 24 | 25 | INTRA4X4_CHROMAV = 26 | 6,13,20,28, 27 | 13,20,28,32, 28 | 20,28,32,37, 29 | 28,32,37,42 30 | 31 | INTER4X4_LUMA = 32 | 10,14,20,24, 33 | 14,20,24,27, 34 | 20,24,27,30, 35 | 24,27,30,34 36 | 37 | INTER4X4_CHROMAU = 38 | 10,14,20,24, 39 | 14,20,24,27, 40 | 20,24,27,30, 41 | 24,27,30,34 42 | 43 | INTER4X4_CHROMAV = 44 | 10,14,20,24, 45 | 14,20,24,27, 46 | 20,24,27,30, 47 | 24,27,30,34 48 | 49 | INTRA8X8_LUMA = 50 | 6,10,13,16,18,23,25,27, 51 | 10,11,16,18,23,25,27,29, 52 | 13,16,18,23,25,27,29,31, 53 | 16,18,23,25,27,29,31,33, 54 | 18,23,25,27,29,31,33,36, 55 | 23,25,27,29,31,33,36,38, 56 | 25,27,29,31,33,36,38,40, 57 | 27,29,31,33,36,38,40,42 58 | 59 | INTER8X8_LUMA = 60 | 9,13,15,17,19,21,22,24, 61 | 13,13,17,19,21,22,24,25, 62 | 15,17,19,21,22,24,25,27, 63 | 17,19,21,22,24,25,27,28, 64 | 19,21,22,24,25,27,28,30, 65 | 21,22,24,25,27,28,30,32, 66 | 22,24,25,27,28,30,32,33, 67 | 24,25,27,28,30,32,33,35 68 | 69 | -------------------------------------------------------------------------------- /version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd "$(dirname "$0")" >/dev/null && [ -f x264.h ] || exit 1 4 | 5 | api="$(grep '#define X264_BUILD' < x264.h | sed 's/^.* \([1-9][0-9]*\).*$/\1/')" 6 | ver="x" 7 | version="" 8 | 9 | if [ -d .git ] && command -v git >/dev/null 2>&1 ; then 10 | localver="$(($(git rev-list HEAD | wc -l)))" 11 | if [ "$localver" -gt 1 ] ; then 12 | ver_diff="$(($(git rev-list origin/master..HEAD | wc -l)))" 13 | ver="$((localver-ver_diff))" 14 | echo "#define X264_REV $ver" 15 | echo "#define X264_REV_DIFF $ver_diff" 16 | if [ "$ver_diff" -ne 0 ] ; then 17 | ver="$ver+$ver_diff" 18 | fi 19 | if git status | grep -q "modified:" ; then 20 | ver="${ver}M" 21 | fi 22 | ver="$ver $(git rev-list -n 1 HEAD | cut -c 1-7)" 23 | version=" r$ver" 24 | fi 25 | fi 26 | 27 | echo "#define X264_VERSION \"$version\"" 28 | echo "#define X264_POINTVER \"0.$api.$ver\"" 29 | -------------------------------------------------------------------------------- /x264cli.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * x264cli.h: x264cli common 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2024 x264 project 5 | * 6 | * Authors: Laurent Aimar 7 | * Loren Merritt 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 licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef X264_CLI_H 28 | #define X264_CLI_H 29 | 30 | #include "common/base.h" 31 | 32 | /* In microseconds */ 33 | #define UPDATE_INTERVAL 250000 34 | 35 | #define MAX_RESOLUTION 16384 36 | 37 | typedef void *hnd_t; 38 | 39 | extern const char * const x264_avcintra_class_names[]; 40 | extern const char * const x264_cqm_names[]; 41 | extern const char * const x264_log_level_names[]; 42 | extern const char * const x264_partition_names[]; 43 | extern const char * const x264_pulldown_names[]; 44 | extern const char * const x264_range_names[]; 45 | extern const char * const x264_output_csp_names[]; 46 | extern const char * const x264_valid_profile_names[]; 47 | extern const char * const x264_demuxer_names[]; 48 | extern const char * const x264_muxer_names[]; 49 | 50 | static inline uint64_t gcd( uint64_t a, uint64_t b ) 51 | { 52 | while( 1 ) 53 | { 54 | int64_t c = a % b; 55 | if( !c ) 56 | return b; 57 | a = b; 58 | b = c; 59 | } 60 | } 61 | 62 | static inline uint64_t lcm( uint64_t a, uint64_t b ) 63 | { 64 | return ( a / gcd( a, b ) ) * b; 65 | } 66 | 67 | static inline char *get_filename_extension( char *filename ) 68 | { 69 | char *ext = filename + strlen( filename ); 70 | while( *ext != '.' && ext > filename ) 71 | ext--; 72 | ext += *ext == '.'; 73 | return ext; 74 | } 75 | 76 | void x264_cli_log( const char *name, int i_level, const char *fmt, ... ); 77 | void x264_cli_printf( int i_level, const char *fmt, ... ); 78 | int x264_cli_autocomplete( const char *prev, const char *cur ); 79 | 80 | #ifdef _WIN32 81 | void x264_cli_set_console_title( const char *title ); 82 | int x264_ansi_filename( const char *filename, char *ansi_filename, int size, int create_file ); 83 | #else 84 | #define x264_cli_set_console_title( title ) 85 | #endif 86 | 87 | #define RETURN_IF_ERR( cond, name, ret, ... )\ 88 | do\ 89 | {\ 90 | if( cond )\ 91 | {\ 92 | x264_cli_log( name, X264_LOG_ERROR, __VA_ARGS__ );\ 93 | return ret;\ 94 | }\ 95 | } while( 0 ) 96 | 97 | #define FAIL_IF_ERR( cond, name, ... ) RETURN_IF_ERR( cond, name, -1, __VA_ARGS__ ) 98 | 99 | typedef enum 100 | { 101 | RANGE_AUTO = -1, 102 | RANGE_TV, 103 | RANGE_PC 104 | } range_enum; 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /x264dll.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * x264dll: x264 DLLMain for win32 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2024 x264 project 5 | * 6 | * Authors: Anton Mitrofanov 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #include "common/base.h" 27 | #include 28 | 29 | /* Callback for our DLL so we can initialize pthread */ 30 | BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) 31 | { 32 | #if PTW32_STATIC_LIB 33 | switch( fdwReason ) 34 | { 35 | case DLL_PROCESS_ATTACH: 36 | pthread_win32_process_attach_np(); 37 | 38 | case DLL_THREAD_ATTACH: 39 | pthread_win32_thread_attach_np(); 40 | break; 41 | 42 | case DLL_THREAD_DETACH: 43 | pthread_win32_thread_detach_np(); 44 | break; 45 | 46 | case DLL_PROCESS_DETACH: 47 | pthread_win32_thread_detach_np(); 48 | pthread_win32_process_detach_np(); 49 | break; 50 | } 51 | #endif 52 | 53 | return TRUE; 54 | } 55 | -------------------------------------------------------------------------------- /x264res.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | true 7 | UTF-8 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /x264res.rc: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * x264res.rc: windows resource file 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2024 x264 project 5 | * 6 | * Authors: Henrik Gramner 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 licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #include 27 | #include 28 | #include "x264.h" 29 | 30 | #ifndef X264_REV 31 | #define X264_REV 0 32 | #define X264_REV_DIFF 0 33 | #endif 34 | 35 | #define str(s) #s 36 | #define xstr(s) str(s) 37 | 38 | #ifndef DLL 39 | 1 RT_MANIFEST "x264res.manifest" 40 | #endif 41 | 42 | VS_VERSION_INFO VERSIONINFO 43 | FILEVERSION 0, X264_BUILD, X264_REV, X264_REV_DIFF 44 | PRODUCTVERSION 0, X264_BUILD, X264_REV, X264_REV_DIFF 45 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 46 | #ifdef DEBUG 47 | FILEFLAGS VS_FF_DEBUG 48 | #else 49 | FILEFLAGS 0 50 | #endif 51 | FILEOS VOS_NT_WINDOWS32 /* Identical for x86-64 */ 52 | #ifdef DLL 53 | FILETYPE VFT_DLL 54 | #else 55 | FILETYPE VFT_APP 56 | #endif 57 | FILESUBTYPE VFT2_UNKNOWN 58 | BEGIN 59 | BLOCK "StringFileInfo" 60 | BEGIN 61 | BLOCK "040904B0" 62 | BEGIN 63 | VALUE "CompanyName", "x264 project" 64 | #ifdef DLL 65 | VALUE "FileDescription", "H.264 (MPEG-4 AVC) encoder library" 66 | #else 67 | VALUE "FileDescription", "H.264 (MPEG-4 AVC) encoder" 68 | #endif 69 | VALUE "FileVersion", X264_POINTVER 70 | VALUE "InternalName", "x264" 71 | VALUE "LegalCopyright", "Copyright (C) 2003-2024 x264 project" 72 | #ifdef DLL 73 | VALUE "OriginalFilename", "libx264-" xstr(X264_BUILD) ".dll" 74 | #else 75 | VALUE "OriginalFilename", "x264.exe" 76 | #endif 77 | VALUE "ProductName", "x264" 78 | VALUE "ProductVersion", X264_POINTVER 79 | END 80 | END 81 | 82 | BLOCK "VarFileInfo" 83 | BEGIN 84 | VALUE "Translation", 0x0409, 0x04B0 /* U.S. English (Unicode) */ 85 | END 86 | END 87 | --------------------------------------------------------------------------------