├── tools ├── digress │ ├── scm │ │ ├── __init__.py │ │ ├── dummy.py │ │ └── git.py │ ├── constants.py │ ├── __init__.py │ ├── errors.py │ └── comparers.py ├── bash-autocomplete.sh ├── cltostr.sh ├── countquant_x264.pl ├── q_matrix_jvt.cfg ├── msvsdepend.sh └── checkasm-arm.S ├── audio ├── audio.h ├── audio.c ├── encoders.h └── encoders │ └── enc_raw.c ├── .gitignore ├── x264res.manifest ├── doc ├── regression_test.txt └── standards.txt ├── COPYING.qtaacenc ├── filters ├── video │ ├── x86 │ │ └── yadif_filter_line.h │ ├── internal.h │ ├── yadif_filter_line.h │ ├── subtitles.h │ ├── internal.c │ ├── vflip.c │ ├── source.c │ ├── video.h │ └── video.c ├── audio │ ├── audio_filters.c │ └── internal.h └── filters.h ├── common ├── ppc │ ├── mc.h │ ├── pixel.h │ ├── predict.h │ ├── deblock.h │ ├── quant.h │ └── dct.h ├── arm │ ├── mc.h │ ├── bitstream.h │ ├── bitstream-a.S │ ├── quant.h │ ├── dct.h │ ├── deblock.h │ ├── cpu-a.S │ └── predict-c.c ├── mips │ ├── mc.h │ ├── quant.h │ ├── deblock.h │ ├── dct.h │ └── predict.h ├── aarch64 │ ├── mc.h │ ├── bitstream.h │ ├── asm-offsets.h │ ├── asm-offsets.c │ ├── bitstream-a.S │ ├── deblock.h │ └── quant.h ├── x86 │ ├── mc.h │ ├── const-a.asm │ ├── cpu-a.asm │ └── bitstream-a.asm ├── opencl │ ├── weightp.cl │ └── x264-cl.h ├── threadpool.h ├── rectangle.c ├── cpu.h ├── common.c ├── win32thread.h ├── dct.h ├── osdep.c ├── quant.h ├── vlc.c └── tables.h ├── version.sh ├── extras └── intel_dispatcher.h ├── x264dll.c ├── AUTHORS ├── encoder ├── slicetype-cl.h ├── analyse.h ├── set.h └── me.h ├── output ├── output.h ├── raw.c └── matroska_ebml.h ├── x264res.rc └── x264cli.h /tools/digress/scm/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Source control backends for Digress. 3 | """ 4 | -------------------------------------------------------------------------------- /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/__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 | -------------------------------------------------------------------------------- /audio/audio.h: -------------------------------------------------------------------------------- 1 | #ifndef AUDIO_AUDIO_H_ 2 | #define AUDIO_AUDIO_H_ 3 | 4 | #include 5 | #include "x264cli.h" 6 | #include "filters/audio/audio_filters.h" 7 | 8 | enum AudioTrack 9 | { 10 | TRACK_ANY = -1, 11 | TRACK_NONE = -2 12 | }; 13 | 14 | hnd_t x264_audio_open_from_file( char *preferred_filter_name, char *path, int trackno ); 15 | 16 | #endif /* AUDIO_AUDIO_H_ */ 17 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /x264res.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | true 7 | UTF-8 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /audio/audio.c: -------------------------------------------------------------------------------- 1 | #include "filters/audio/internal.h" 2 | 3 | #include 4 | 5 | hnd_t x264_audio_open_from_file( char *preferred_filter_name, char *path, int trackno ) 6 | { 7 | char *source_name = preferred_filter_name ? preferred_filter_name : "lavf"; 8 | audio_filter_t *source = x264_af_get_filter( source_name ); 9 | 10 | if( !source ) 11 | { 12 | x264_cli_log( "audio", X264_LOG_ERROR, "no decoder / demuxer avilable!\n" ); 13 | return NULL; 14 | } 15 | hnd_t h = NULL; 16 | size_t init_arg_size = strlen( path ) + 10; 17 | char *init_arg = malloc( init_arg_size ); 18 | assert( snprintf( init_arg, init_arg_size, "%s,%d", path, trackno ) < init_arg_size ); 19 | if( source->init( &h, init_arg ) < 0 || !h ) 20 | { 21 | x264_cli_log( "audio", X264_LOG_ERROR, "error initializing source filter!\n" ); 22 | return NULL; 23 | } 24 | free( init_arg ); 25 | return h; 26 | } 27 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /COPYING.qtaacenc: -------------------------------------------------------------------------------- 1 | This software contains the following software: 2 | 3 | ------------------------------------------------------------------- 4 | 5 | Copyright (c) 2010-2011 tmkk 6 | 7 | Permission is hereby granted, free of charge, to any person 8 | obtaining a copy of this software and associated documentation 9 | files (the "Software"), to deal in the Software without 10 | restriction, including without limitation the rights to use, 11 | copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following 14 | conditions: 15 | 16 | The above copyright notice and this permission notice shall be 17 | included in all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 21 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 23 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 24 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 25 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 26 | OTHER DEALINGS IN THE SOFTWARE. 27 | 28 | ------------------------------------------------------------------- 29 | -------------------------------------------------------------------------------- /filters/video/x86/yadif_filter_line.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * yadif_filter_line.c: yadif (yet another deinterlacing filter) 3 | ***************************************************************************** 4 | * Copyright (C) 2006 Michael Niedermayer 5 | * Avisynth port (C) 2007 Alexander G. Balakhnin aka Fizick http://avisynth.org.ru 6 | * x264 port (C) 2013 James Darnley 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 | 23 | void filter_line_mmx2( struct yadif_context *yctx ); 24 | void filter_line_sse2( struct yadif_context *yctx ); 25 | void filter_line_ssse3( struct yadif_context *yctx ); 26 | -------------------------------------------------------------------------------- /common/ppc/mc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * mc.h: ppc motion compensation 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2021 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/arm/mc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * mc.h: arm motion compensation 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2021 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/mips/mc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * mc.h: msa motion compensation 3 | ***************************************************************************** 4 | * Copyright (C) 2015-2021 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/ppc/pixel.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * pixel.h: ppc pixel metrics 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2021 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/aarch64/mc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * mc.h: aarch64 motion compensation 3 | ***************************************************************************** 4 | * Copyright (C) 2014-2021 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/arm/bitstream.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * bitstream.h: arm bitstream functions 3 | ***************************************************************************** 4 | * Copyright (C) 2017-2021 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/x86/mc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * mc.h: x86 motion compensation 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2021 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 | -------------------------------------------------------------------------------- /common/aarch64/bitstream.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * bitstream.h: aarch64 bitstream functions 3 | ***************************************************************************** 4 | * Copyright (C) 2017-2021 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /filters/video/internal.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * internal.h: video filter utilities 3 | ***************************************************************************** 4 | * Copyright (C) 2010-2021 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 | -------------------------------------------------------------------------------- /common/ppc/predict.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * predict.h: ppc intra prediction 3 | ***************************************************************************** 4 | * Copyright (C) 2007-2021 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 | -------------------------------------------------------------------------------- /filters/video/yadif_filter_line.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * yadif_filter_line.h: yadif (yet another deinterlacing filter) 3 | ***************************************************************************** 4 | * Copyright (C) 2006 Michael Niedermayer 5 | * Avisynth port (C) 2007 Alexander G. Balakhnin aka Fizick http://avisynth.org.ru 6 | * x264 port (C) 2013 James Darnley 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 | 23 | #include 24 | 25 | struct yadif_context { 26 | uint8_t *output; 27 | const uint8_t *previous; 28 | const uint8_t *current; 29 | const uint8_t *next; 30 | int mode; 31 | int width; 32 | int stride; 33 | int parity; 34 | }; 35 | 36 | typedef void (*filter_line_func)( struct yadif_context *yctx ); 37 | 38 | filter_line_func get_filter_func( unsigned int cpu, int high_depth ); 39 | -------------------------------------------------------------------------------- /common/ppc/deblock.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * deblock.h: ppc deblocking 3 | ***************************************************************************** 4 | * Copyright (C) 2017-2021 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 | -------------------------------------------------------------------------------- /filters/audio/audio_filters.c: -------------------------------------------------------------------------------- 1 | #include "filters/audio/internal.h" 2 | 3 | #include 4 | 5 | audio_info_t *x264_af_get_info( hnd_t handle ) 6 | { 7 | return &((audio_hnd_t*)handle)->info; 8 | } 9 | 10 | audio_filter_t *x264_af_get_filter( char *name ) 11 | { 12 | #if HAVE_AUDIO 13 | #define CHECK( filter ) \ 14 | extern audio_filter_t audio_filter_##filter; \ 15 | if ( !strcmp( name, audio_filter_##filter.name ) ) \ 16 | return &audio_filter_##filter 17 | #if HAVE_LAVF 18 | CHECK( lavf ); 19 | #endif 20 | #if HAVE_AVS 21 | CHECK( avs ); 22 | #endif 23 | #undef CHECKFLT 24 | #undef CHECK 25 | #endif /* HAVE_AUDIO */ 26 | return NULL; 27 | } 28 | 29 | audio_packet_t *x264_af_get_samples( hnd_t handle, int64_t first_sample, int64_t last_sample ) 30 | { 31 | audio_hnd_t *h = handle; 32 | audio_packet_t *out = h->self->get_samples( h, first_sample, last_sample ); 33 | if( out ) 34 | { 35 | out->owner = h; 36 | return out; 37 | } 38 | return 0; 39 | } 40 | 41 | void x264_af_free_packet( audio_packet_t *pkt ) 42 | { 43 | if( !pkt ) 44 | return; 45 | audio_hnd_t *owner = pkt->owner; 46 | if( owner ) 47 | owner->self->free_packet( owner, pkt ); 48 | else 49 | { 50 | if( pkt->priv ) 51 | free( pkt->priv ); 52 | if( pkt->data ) 53 | free( pkt->data ); 54 | if( pkt->samples && pkt->channels ) 55 | x264_af_free_buffer( pkt->samples, pkt->channels ); 56 | free( pkt ); 57 | } 58 | } 59 | 60 | void x264_af_close( hnd_t chain ) 61 | { 62 | audio_hnd_t *h = chain; 63 | if( h->prev ) 64 | x264_af_close( h->prev ); 65 | h->self->close( h ); 66 | } 67 | -------------------------------------------------------------------------------- /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 | #!/usr/bin/env bash 2 | [ -n "$1" ] && cd $1 3 | git rev-list HEAD | sort > config.git-hash 4 | LOCAL_VER=`wc -l config.git-hash | awk '{print $1}'` 5 | GIT_HEAD=`git branch --list | grep "*" | awk '{print $2}'` 6 | BIT_DEPTH=`grep "X264_BIT_DEPTH" < x264_config.h | awk '{print $3}'` 7 | if [ $BIT_DEPTH == "0" ] ; then 8 | BIT_DEPTH="(8 & 10)" 9 | fi 10 | CHROMA_FORMATS=`grep "X264_CHROMA_FORMAT" < x264_config.h | awk '{print $3}'` 11 | if [ $CHROMA_FORMATS == "0" ] ; then 12 | CHROMA_FORMATS="all" 13 | elif [ $CHROMA_FORMATS == "X264_CSP_I420" ] ; then 14 | CHROMA_FORMATS="4:2:0" 15 | elif [ $CHROMA_FORMATS == "X264_CSP_I422" ] ; then 16 | CHROMA_FORMATS="4:2:2" 17 | elif [ $CHROMA_FORMATS == "X264_CSP_I444" ] ; then 18 | CHROMA_FORMATS="4:4:4" 19 | fi 20 | BUILD_ARCH=`grep "SYS_ARCH=" < config.mak | awk -F= '{print $2}'` 21 | if [ $LOCAL_VER \> 1 ] ; then 22 | PLAIN_VER=`git rev-list origin/master | sort | join config.git-hash - | wc -l | awk '{print $1}'` 23 | echo "#define X264_REV $PLAIN_VER" 24 | if [ $PLAIN_VER == $LOCAL_VER ] ; then 25 | VER=$PLAIN_VER 26 | else 27 | VER_DIFF=$(($LOCAL_VER-$PLAIN_VER)) 28 | VER="$PLAIN_VER+$VER_DIFF" 29 | fi 30 | echo "#define X264_REV_DIFF $VER_DIFF" 31 | if git status | grep -q "modified:" ; then 32 | VER="${VER}M" 33 | fi 34 | VER="$VER $(git rev-list HEAD -n 1 | cut -c 1-7) $GIT_HEAD [${BIT_DEPTH}-bit@${CHROMA_FORMATS} ${BUILD_ARCH}]" 35 | echo "#define X264_VERSION \" r$VER\"" 36 | else 37 | echo "#define X264_VERSION \"\"" 38 | VER="x [${BIT_DEPTH}-bit@${CHROMA_FORMATS} ${BUILD_ARCH}]" 39 | fi 40 | rm -f config.git-hash 41 | API=`grep '#define X264_BUILD' < "$(dirname "$0")"/x264.h | sed -e 's/.* \([1-9][0-9]*\).*/\1/'` 42 | echo "#define X264_POINTVER \"0.$API.$VER\"" 43 | -------------------------------------------------------------------------------- /common/aarch64/asm-offsets.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * asm-offsets.h: asm offsets for aarch64 3 | ***************************************************************************** 4 | * Copyright (C) 2014-2021 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 | -------------------------------------------------------------------------------- /filters/video/subtitles.h: -------------------------------------------------------------------------------- 1 | enum { 2 | CSRI_F_RGBA = 0, 3 | CSRI_F_ARGB, 4 | CSRI_F_BGRA, 5 | CSRI_F_ABGR, 6 | 7 | CSRI_F_RGB_ = 0x100, 8 | CSRI_F__RGB, 9 | CSRI_F_BGR_, /**< Windows "RGB32" */ 10 | CSRI_F__BGR, 11 | 12 | CSRI_F_RGB = 0x200, 13 | CSRI_F_BGR, /**< Windows "RGB24" */ 14 | 15 | CSRI_F_AYUV = 0x1000, 16 | CSRI_F_YUVA, 17 | CSRI_F_YVUA, 18 | 19 | CSRI_F_YUY2 = 0x1100, 20 | 21 | CSRI_F_YV12A = 0x2011, /**< planar YUV 2x2 + alpha plane */ 22 | CSRI_F_YV12 = 0x2111, /**< planar YUV 2x2 */ 23 | CSRI_F_NV12, 24 | CSRI_F_NV21 25 | }; 26 | 27 | typedef struct { 28 | unsigned pixfmt; 29 | unsigned width; 30 | unsigned height; 31 | } csri_fmt; 32 | 33 | typedef struct { 34 | unsigned pixfmt; 35 | unsigned char *planes[4]; 36 | ptrdiff_t strides[4]; 37 | } csri_frame; 38 | 39 | typedef struct { 40 | const char *name; 41 | const char *specific; 42 | const char *longname; 43 | const char *author; 44 | const char *copyright; 45 | } csri_info; 46 | 47 | typedef union { 48 | int32_t lval; 49 | double dval; 50 | const char *utf8val; 51 | void *otherval; 52 | } csri_vardata; 53 | 54 | typedef struct { 55 | const char *name; 56 | csri_vardata data; 57 | struct csri_openflag *next; 58 | } csri_openflag; 59 | 60 | typedef void* (*csri_open_file_t)(void *renderer, const char *filename, csri_openflag *flags); 61 | typedef int (*csri_add_file_t)(void *inst, const char *filename, csri_openflag *flags); 62 | typedef void (*csri_close_t)(void *inst); 63 | typedef int (*csri_request_fmt_t)(void *inst, const csri_fmt *fmt); 64 | typedef void (*csri_render_t)(void *inst, csri_frame *frame, double time); 65 | 66 | extern csri_render_t csri_render; 67 | #define subtitles_render_frame csri_render 68 | extern csri_close_t csri_close; 69 | #define subtitles_close csri_close 70 | 71 | void* subtitles_new_renderer(const csri_fmt *fmt, uint32_t sarw, uint32_t sarh); 72 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /filters/filters.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * filters.h: common filter functions 3 | ***************************************************************************** 4 | * Copyright (C) 2010-2021 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /extras/intel_dispatcher.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * intel_dispatcher.h: intel compiler cpu dispatcher override 3 | ***************************************************************************** 4 | * Copyright (C) 2014-2021 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 | -------------------------------------------------------------------------------- /x264dll.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * x264dll: x264 DLLMain for win32 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2021 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /common/threadpool.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * threadpool.h: thread pooling 3 | ***************************************************************************** 4 | * Copyright (C) 2010-2021 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/rectangle.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * rectangle.c: rectangle filling 3 | ***************************************************************************** 4 | * Copyright (C) 2010-2021 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/cpu.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * cpu.h: cpu detection 3 | ***************************************************************************** 4 | * Copyright (C) 2004-2021 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/ppc/quant.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * quant.h: ppc quantization 3 | ***************************************************************************** 4 | * Copyright (C) 2007-2021 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /encoder/slicetype-cl.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * slicetype-cl.h: OpenCL slicetype decision code (lowres lookahead) 3 | ***************************************************************************** 4 | * Copyright (C) 2017-2021 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 | -------------------------------------------------------------------------------- /output/output.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * output.h: x264 file output modules 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2021 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 | double display_width; 35 | double display_height; 36 | int use_dts_compress; 37 | int no_sar; 38 | int no_remux; 39 | int fragments; 40 | int mux_mov; 41 | int mux_3gp; 42 | int mux_3g2; 43 | char *chapter; 44 | int add_bom; 45 | char *language; 46 | uint32_t priming; 47 | int no_progress; 48 | int x264_bit_depth; 49 | } cli_output_opt_t; 50 | 51 | typedef struct 52 | { 53 | int (*open_file)( char *psz_filename, hnd_t *p_handle, cli_output_opt_t *opt, hnd_t audio_filters, char *audio_encoder, char *audio_parameters ); 54 | int (*set_param)( hnd_t handle, x264_param_t *p_param ); 55 | int (*write_headers)( hnd_t handle, x264_nal_t *p_nal ); 56 | int (*write_frame)( hnd_t handle, uint8_t *p_nal, int i_size, x264_picture_t *p_picture ); 57 | int (*close_file)( hnd_t handle, int64_t largest_pts, int64_t second_largest_pts ); 58 | } cli_output_t; 59 | 60 | extern const cli_output_t raw_output; 61 | extern const cli_output_t mkv_output; 62 | extern const cli_output_t mp4_output; 63 | extern const cli_output_t flv_output; 64 | extern const cli_output_t avi_output; 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /filters/video/internal.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * internal.c: video filter utilities 3 | ***************************************************************************** 4 | * Copyright (C) 2010-2021 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 | -------------------------------------------------------------------------------- /common/aarch64/asm-offsets.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * asm-offsets.c: check asm offsets for aarch64 3 | ***************************************************************************** 4 | * Copyright (C) 2014-2021 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 | -------------------------------------------------------------------------------- /encoder/analyse.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * analyse.h: macroblock analysis 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2021 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 | -------------------------------------------------------------------------------- /output/raw.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * raw.c: raw muxer 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2021 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, hnd_t audio_filters, char *audio_enc, char *audio_params ) 30 | { 31 | FAIL_IF_ERR( audio_enc && ( strcmp( audio_enc, "none" ) && strcmp( audio_enc, "auto" ) ), "raw", 32 | "audio is not supported on this muxer\n" ); 33 | 34 | if( !strcmp( psz_filename, "-" ) ) 35 | *p_handle = stdout; 36 | else if( !(*p_handle = x264_fopen( psz_filename, "w+b" )) ) 37 | return -1; 38 | 39 | return 0; 40 | } 41 | 42 | static int set_param( hnd_t handle, x264_param_t *p_param ) 43 | { 44 | return 0; 45 | } 46 | 47 | static int write_headers( hnd_t handle, x264_nal_t *p_nal ) 48 | { 49 | int size = p_nal[0].i_payload + p_nal[1].i_payload + p_nal[2].i_payload; 50 | 51 | if( fwrite( p_nal[0].p_payload, size, 1, (FILE*)handle ) ) 52 | return size; 53 | return -1; 54 | } 55 | 56 | static int write_frame( hnd_t handle, uint8_t *p_nalu, int i_size, x264_picture_t *p_picture ) 57 | { 58 | if( fwrite( p_nalu, i_size, 1, (FILE*)handle ) ) 59 | return i_size; 60 | return -1; 61 | } 62 | 63 | static int close_file( hnd_t handle, int64_t largest_pts, int64_t second_largest_pts ) 64 | { 65 | if( !handle || handle == stdout ) 66 | return 0; 67 | 68 | return fclose( (FILE*)handle ); 69 | } 70 | 71 | const cli_output_t raw_output = { open_file, set_param, write_headers, write_frame, close_file }; 72 | 73 | -------------------------------------------------------------------------------- /common/mips/quant.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * quant.h: msa quantization and level-run 3 | ***************************************************************************** 4 | * Copyright (C) 2015-2021 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 | -------------------------------------------------------------------------------- /filters/video/vflip.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * crop.c: vertical flip video filter 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2014 x264 project 5 | * 6 | * Authors: James Darnley 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 | #include "video.h" 28 | #define NAME "vflip" 29 | #define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, NAME, __VA_ARGS__ ) 30 | 31 | cli_vid_filter_t vflip_filter; 32 | 33 | typedef struct 34 | { 35 | hnd_t prev_handle; 36 | cli_vid_filter_t prev_filter; 37 | } vflip_handle; 38 | 39 | static void help( int longhelp ) 40 | { 41 | printf( " "NAME" vertically flips the frame\n" ); 42 | } 43 | 44 | static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, x264_param_t *param, char *opt_string ) 45 | { 46 | vflip_handle *h = calloc( 1, sizeof(vflip_handle) ); 47 | if( !h ) 48 | return -1; 49 | 50 | info->csp ^= X264_CSP_VFLIP; 51 | 52 | h->prev_filter = *filter; 53 | h->prev_handle = *handle; 54 | *handle = h; 55 | *filter = vflip_filter; 56 | 57 | return 0; 58 | } 59 | 60 | static int get_frame( hnd_t handle, cli_pic_t *output, int frame ) 61 | { 62 | vflip_handle *h = handle; 63 | return h->prev_filter.get_frame( h->prev_handle, output, frame ); 64 | } 65 | 66 | static int release_frame( hnd_t handle, cli_pic_t *pic, int frame ) 67 | { 68 | vflip_handle *h = handle; 69 | return h->prev_filter.release_frame( h->prev_handle, pic, frame ); 70 | } 71 | 72 | static void free_filter( hnd_t handle ) 73 | { 74 | vflip_handle *h = handle; 75 | h->prev_filter.free( h->prev_handle ); 76 | free( h ); 77 | } 78 | 79 | cli_vid_filter_t vflip_filter = { NAME, help, init, get_frame, release_frame, free_filter, NULL }; 80 | -------------------------------------------------------------------------------- /common/arm/bitstream-a.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * bitstream-a.S: arm bitstream functions 3 | ***************************************************************************** 4 | * Copyright (C) 2014-2021 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/aarch64/bitstream-a.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * bitstream-a.S: aarch64 bitstream functions 3 | ***************************************************************************** 4 | * Copyright (C) 2014-2021 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 | -------------------------------------------------------------------------------- /audio/encoders.h: -------------------------------------------------------------------------------- 1 | #ifndef AUDIO_ENCODERS_H_ 2 | #define AUDIO_ENCODERS_H_ 3 | 4 | #include "audio/audio.h" 5 | #include "filters/audio/audio_filters.h" 6 | 7 | typedef struct audio_encoder_t 8 | { 9 | hnd_t (*init)( hnd_t filter_chain, const char *opts ); 10 | audio_info_t *(*get_info)( hnd_t handle ); 11 | audio_packet_t *(*get_next_packet)( hnd_t handle ); 12 | void (*skip_samples)( hnd_t handle, uint64_t samplecount ); 13 | audio_packet_t *(*finish)( hnd_t handle ); 14 | void (*free_packet)( hnd_t handle, audio_packet_t *samples ); 15 | void (*close)( hnd_t handle ); 16 | void (*show_help)( const char * const encoder_name ); 17 | int (*is_valid_encoder)( const char * const encoder_name, void **priv ); 18 | } audio_encoder_t; 19 | 20 | #if HAVE_AUDIO 21 | extern const audio_encoder_t audio_encoder_raw; 22 | #if HAVE_LAVF 23 | extern const audio_encoder_t audio_encoder_lavc; 24 | #endif 25 | #if HAVE_LAME 26 | extern const audio_encoder_t audio_encoder_lame; 27 | #endif 28 | #if HAVE_QT_AAC 29 | extern const audio_encoder_t audio_encoder_qtaac; 30 | #endif 31 | #if HAVE_FAAC 32 | extern const audio_encoder_t audio_encoder_faac; 33 | #endif 34 | #if HAVE_AMRWB_3GPP 35 | extern const audio_encoder_t audio_encoder_amrwb_3gpp; 36 | #endif 37 | 38 | #endif /* HAVE_AUDIO */ 39 | 40 | #define AUDIO_CODEC_COMMON_OPTIONS "codec", "is_vbr", "bitrate", "quality" 41 | 42 | enum audio_encoder_query 43 | { 44 | QUERY_CODEC = 0, 45 | QUERY_ENCODER = 1, 46 | }; 47 | 48 | #define MAX_ARGS 256 49 | 50 | /* the first available encoder on allowed_list is the prefered encoder if encoder is "auto" 51 | * allowed_list = NULL means any valid encoder is allowed 52 | * The 'none' case isn't handled by this function (will return NULL like with any other invalid encoder) 53 | * If the user wants 'none' to be a default, it must be tested outside of this function 54 | * If the user wants to allow any encoder, the default case must be tested outside of this function */ 55 | const audio_encoder_t *x264_select_audio_encoder( const char *name, char* allowed_list[], const char **used_enc ); 56 | const audio_encoder_t *x264_audio_encoder_by_name( const char *name, int mode, const char **used_enc ); 57 | hnd_t x264_audio_encoder_open( const audio_encoder_t *encoder, hnd_t filter_chain, const char *opts ); 58 | hnd_t x264_audio_copy_open( hnd_t handle ); 59 | 60 | const char *x264_audio_encoder_codec_name( hnd_t encoder ); 61 | audio_info_t *x264_audio_encoder_info( hnd_t encoder ); 62 | void x264_audio_encoder_skip_samples( hnd_t encoder, uint64_t samplecount ); 63 | audio_packet_t *x264_audio_encode_frame( hnd_t encoder ); 64 | audio_packet_t *x264_audio_encoder_finish( hnd_t encoder ); 65 | void x264_audio_free_frame( hnd_t encoder, audio_packet_t *frame ); 66 | 67 | void x264_audio_encoder_close( hnd_t encoder ); 68 | void x264_audio_encoder_show_help( int longhelp ); 69 | void x264_audio_encoder_list_codecs( int longhelp ); 70 | void x264_audio_encoder_list_encoders( int longhelp ); 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /x264res.rc: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * x264res.rc: windows resource file 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2021 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-2021 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 | -------------------------------------------------------------------------------- /filters/video/source.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * source.c: source video filter 3 | ***************************************************************************** 4 | * Copyright (C) 2010-2021 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 | -------------------------------------------------------------------------------- /common/mips/deblock.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * deblock.h: msa deblocking 3 | ***************************************************************************** 4 | * Copyright (C) 2017-2021 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 | -------------------------------------------------------------------------------- /filters/video/video.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * video.h: video filters 3 | ***************************************************************************** 4 | * Copyright (C) 2010-2021 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 | -------------------------------------------------------------------------------- /common/common.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * common.c: misc common functions 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2021 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 | if( h && h->param.psz_log_file && i_level <= h->param.i_log_file_level ) 46 | { 47 | va_list arg; 48 | va_start( arg, psz_fmt ); 49 | x264_log_file( h->param.psz_log_file, i_level, psz_fmt, arg ); 50 | va_end( arg ); 51 | } 52 | } 53 | 54 | void x264_log_file( char *p_file_name, int i_level, const char *psz_fmt, va_list arg ) 55 | { 56 | char *psz_prefix; 57 | switch( i_level ) 58 | { 59 | case X264_LOG_ERROR: 60 | psz_prefix = "error"; 61 | break; 62 | case X264_LOG_WARNING: 63 | psz_prefix = "warning"; 64 | break; 65 | case X264_LOG_INFO: 66 | psz_prefix = "info"; 67 | break; 68 | case X264_LOG_DEBUG: 69 | psz_prefix = "debug"; 70 | break; 71 | default: 72 | psz_prefix = "unknown"; 73 | break; 74 | } 75 | FILE *p_log_file = x264_fopen( p_file_name, "ab" ); 76 | if( p_log_file ) 77 | { 78 | fprintf( p_log_file, "x264 [%s]: ", psz_prefix ); 79 | x264_vfprintf( p_log_file, psz_fmt, arg ); 80 | fclose( p_log_file ); 81 | } 82 | } 83 | 84 | -------------------------------------------------------------------------------- /filters/audio/internal.h: -------------------------------------------------------------------------------- 1 | #ifndef FILTERS_AUDIO_INTERNAL_H_ 2 | #define FILTERS_AUDIO_INTERNAL_H_ 3 | 4 | #include "filters/audio/audio_filters.h" 5 | 6 | #define AUDIO_FILTER_COMMON \ 7 | const audio_filter_t *self; \ 8 | audio_info_t info; \ 9 | struct audio_hnd_t *prev; 10 | 11 | #define INIT_FILTER_STRUCT(filterstruct, structname) \ 12 | structname *h; \ 13 | do \ 14 | { \ 15 | h = calloc( 1, sizeof( structname ) ); \ 16 | if( !h ) \ 17 | goto fail; \ 18 | h->self = &filterstruct; \ 19 | h->prev = *handle; \ 20 | if( h->prev ) \ 21 | h->info = h->prev->info; \ 22 | *handle = h; \ 23 | } while( 0 ) 24 | 25 | #define IS_LPCM_CODEC_ID( id ) ((id) >= 0x10000 && (id) < 0x11000) 26 | 27 | // Generic audio handle (used to access fields from AUDIO_FILTER_COMMON) 28 | typedef struct audio_hnd_t 29 | { 30 | AUDIO_FILTER_COMMON 31 | } audio_hnd_t; 32 | 33 | #define AF_LOG( handle, level, ... ) x264_cli_log( ((audio_hnd_t*)handle)->self->name, (level), __VA_ARGS__ ) 34 | 35 | #define AF_LOG_ERR( handle, ... ) AF_LOG( (handle), X264_LOG_ERROR , __VA_ARGS__ ) 36 | #define AF_LOG_WARN( handle, ... ) AF_LOG( (handle), X264_LOG_WARNING, __VA_ARGS__ ) 37 | 38 | enum SampleFmt { 39 | SMPFMT_NONE = -1, 40 | SMPFMT_U8, 41 | SMPFMT_S16, 42 | SMPFMT_S32, 43 | SMPFMT_FLT, 44 | SMPFMT_DBL, 45 | 46 | SMPFMT_U8P, 47 | SMPFMT_S16P, 48 | SMPFMT_S32P, 49 | SMPFMT_FLTP, 50 | SMPFMT_DBLP 51 | }; 52 | 53 | float **x264_af_get_buffer ( unsigned channels, unsigned samplecount ); 54 | int x264_af_resize_buffer( float **buffer, unsigned channels, unsigned samplecount ); 55 | int x264_af_resize_fill_buffer( float **buffer, unsigned out_samplecount, unsigned channels, unsigned in_samplecount, float value ); 56 | void x264_af_free_buffer ( float **buffer, unsigned channels ); 57 | float **x264_af_dup_buffer ( float **buffer, unsigned channels, unsigned samplecount ); 58 | int x264_af_cat_buffer ( float **buf, unsigned bufsamples, float **in, unsigned insamples, unsigned channels ); 59 | 60 | float **x264_af_deinterleave ( float *samples, unsigned channels, unsigned samplecount ); 61 | float *x264_af_interleave ( float **in, unsigned channels, unsigned samplecount ); 62 | 63 | float **x264_af_deinterleave2( uint8_t *samples, enum SampleFmt fmt, unsigned channels, unsigned samplecount ); 64 | uint8_t *x264_af_interleave2 ( enum SampleFmt outfmt, float **in, unsigned channels, unsigned samplecount ); 65 | uint8_t *x264_af_convert ( enum SampleFmt outfmt, uint8_t *in, enum SampleFmt fmt, unsigned channels, unsigned samplecount ); 66 | 67 | uint8_t *x264_af_interleave3 ( enum SampleFmt outfmt, float **in, unsigned channels, unsigned samplecount, int *map ); 68 | 69 | #endif /* FILTERS_AUDIO_INTERNAL_H_ */ 70 | -------------------------------------------------------------------------------- /common/win32thread.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * win32thread.h: windows threading 3 | ***************************************************************************** 4 | * Copyright (C) 2010-2021 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-2021 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /filters/video/video.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * video.c: video filters 3 | ***************************************************************************** 4 | * Copyright (C) 2010-2021 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 | #define REGISTER_GPL_VFILTER( name ) \ 46 | if( HAVE_GPL ) REGISTER_VFILTER( name ) 47 | 48 | void x264_register_vid_filters( void ) 49 | { 50 | extern cli_vid_filter_t source_filter; 51 | first_filter = &source_filter; 52 | #if HAVE_BITDEPTH8 53 | REGISTER_VFILTER( cache_8 ); 54 | REGISTER_VFILTER( depth_8 ); 55 | #endif 56 | #if HAVE_BITDEPTH10 57 | REGISTER_VFILTER( cache_10 ); 58 | REGISTER_VFILTER( depth_10 ); 59 | #endif 60 | REGISTER_VFILTER( fix_vfr_pts ); 61 | REGISTER_VFILTER( hqdn3d ); 62 | REGISTER_VFILTER( crop ); 63 | REGISTER_VFILTER( pad ); 64 | REGISTER_VFILTER( resize ); 65 | REGISTER_VFILTER( select_every ); 66 | REGISTER_VFILTER( vflip ); 67 | REGISTER_GPL_VFILTER( yadif ); 68 | 69 | #ifdef _WIN32 70 | REGISTER_VFILTER( subtitles ); 71 | #endif 72 | } 73 | 74 | int x264_init_vid_filter( const char *name, hnd_t *handle, cli_vid_filter_t *filter, 75 | video_info_t *info, x264_param_t *param, char *opt_string ) 76 | { 77 | cli_vid_filter_t *filter_i = first_filter; 78 | while( filter_i && strcasecmp( name, filter_i->name ) ) 79 | filter_i = filter_i->next; 80 | FAIL_IF_ERR( !filter_i, "x264", "invalid filter `%s'\n", name ); 81 | if( filter_i->init( handle, filter, info, param, opt_string ) ) 82 | return -1; 83 | 84 | return 0; 85 | } 86 | 87 | void x264_vid_filter_help( int longhelp ) 88 | { 89 | for( cli_vid_filter_t *filter_i = first_filter; filter_i; filter_i = filter_i->next ) 90 | if( filter_i->help ) 91 | filter_i->help( longhelp ); 92 | } 93 | -------------------------------------------------------------------------------- /common/dct.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * dct.h: transform and zigzag 3 | ***************************************************************************** 4 | * Copyright (C) 2004-2021 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/mips/dct.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * dct.h: msa transform and zigzag 3 | ***************************************************************************** 4 | * Copyright (C) 2015-2021 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 | -------------------------------------------------------------------------------- /audio/encoders/enc_raw.c: -------------------------------------------------------------------------------- 1 | #include "audio/encoders.h" 2 | #include "filters/audio/internal.h" 3 | 4 | #include 5 | 6 | typedef struct enc_raw_t 7 | { 8 | audio_info_t info; 9 | int finishing; 10 | hnd_t filter_chain; 11 | int64_t last_sample; 12 | } enc_raw_t; 13 | 14 | static hnd_t init( hnd_t filter_chain, const char *opts ) 15 | { 16 | assert( filter_chain ); 17 | enc_raw_t *h = calloc( 1, sizeof( enc_raw_t ) ); 18 | audio_hnd_t *chain = h->filter_chain = filter_chain; 19 | h->info = chain->info; 20 | 21 | h->info.codec_name = "raw"; 22 | h->info.extradata = NULL; 23 | h->info.extradata_size = 0; 24 | h->info.framelen = h->info.framelen ? h->info.framelen : 1; 25 | h->info.depth = 16; 26 | h->info.chansize = h->info.depth / 8; 27 | h->info.samplesize = h->info.chansize * h->info.channels; 28 | h->info.framesize = h->info.framelen * h->info.samplesize; 29 | h->info.timebase = (timebase_t) { 1, h->info.samplerate }; 30 | 31 | x264_cli_log( "audio", X264_LOG_INFO, "opened raw encoder (%dbits, %dch, %dhz)\n", 32 | h->info.chansize * 8, h->info.channels, h->info.samplerate ); 33 | return h; 34 | } 35 | 36 | static audio_info_t *get_info( hnd_t handle ) 37 | { 38 | assert( handle ); 39 | enc_raw_t *h = handle; 40 | 41 | return &h->info; 42 | } 43 | 44 | static audio_packet_t *get_next_packet( hnd_t handle ) 45 | { 46 | enc_raw_t *h = handle; 47 | if( h->finishing ) 48 | return NULL; 49 | 50 | audio_packet_t *smp = x264_af_get_samples( h->filter_chain, h->last_sample, h->last_sample + h->info.framelen ); 51 | if( !smp ) 52 | return NULL; 53 | 54 | audio_packet_t *out = calloc( 1, sizeof( audio_packet_t ) ); 55 | memcpy( out, smp, sizeof( audio_packet_t ) ); 56 | out->info = h->info; 57 | out->samples = NULL; 58 | out->samplecount = smp->samplecount; 59 | out->data = x264_af_interleave2( SMPFMT_S16, smp->samples, smp->channels, smp->samplecount ); 60 | out->size = smp->samplecount * h->info.samplesize; 61 | out->dts = h->last_sample; 62 | out->info.last_delta = smp->samplecount; 63 | h->last_sample += smp->samplecount; 64 | x264_af_free_packet( smp ); 65 | 66 | return out; 67 | } 68 | 69 | static void skip_samples( hnd_t handle, uint64_t samplecount ) 70 | { 71 | ((enc_raw_t*)handle)->last_sample += samplecount; 72 | } 73 | 74 | static audio_packet_t *finish( hnd_t handle ) 75 | { 76 | ((enc_raw_t*)handle)->finishing = 1; 77 | return NULL; 78 | } 79 | 80 | static void free_packet( hnd_t handle, audio_packet_t *packet ) 81 | { 82 | x264_af_free_packet( packet ); 83 | } 84 | 85 | static void raw_close( hnd_t handle ) 86 | { 87 | free( handle ); 88 | } 89 | 90 | static void raw_help( const char * const codec_name ) 91 | { 92 | printf( " * raw encoder help\n" ); 93 | printf( " Directly pass the decoded PCM samples (in native endian) to muxer.\n" ); 94 | printf( " All audio options except for --acodec and --audiofile are ignored.\n" ); 95 | printf( "\n" ); 96 | } 97 | 98 | const audio_encoder_t audio_encoder_raw = 99 | { 100 | .init = init, 101 | .get_info = get_info, 102 | .get_next_packet = get_next_packet, 103 | .skip_samples = skip_samples, 104 | .finish = finish, 105 | .free_packet = free_packet, 106 | .close = raw_close, 107 | .show_help = raw_help, 108 | .is_valid_encoder = NULL 109 | }; 110 | -------------------------------------------------------------------------------- /common/x86/cpu-a.asm: -------------------------------------------------------------------------------- 1 | ;***************************************************************************** 2 | ;* cpu-a.asm: x86 cpu utilities 3 | ;***************************************************************************** 4 | ;* Copyright (C) 2003-2021 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/arm/quant.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * quant.h: arm quantization and level-run 3 | ***************************************************************************** 4 | * Copyright (C) 2005-2021 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/osdep.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * osdep.c: platform-specific code 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2021 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/arm/dct.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * dct.h: arm transform and zigzag 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2021 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 | -------------------------------------------------------------------------------- /x264cli.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * x264cli.h: x264cli common 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2021 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_log_file( char *p_file_name, int i_level, const char *psz_fmt, va_list arg ); 78 | void x264_cli_printf( int i_level, const char *fmt, ... ); 79 | int x264_cli_autocomplete( const char *prev, const char *cur ); 80 | 81 | #ifdef _WIN32 82 | void x264_cli_set_console_title( const char *title ); 83 | int x264_ansi_filename( const char *filename, char *ansi_filename, int size, int create_file ); 84 | #else 85 | #define x264_cli_set_console_title( title ) 86 | #endif 87 | 88 | #define RETURN_IF_ERR( cond, name, ret, ... )\ 89 | do\ 90 | {\ 91 | if( cond )\ 92 | {\ 93 | x264_cli_log( name, X264_LOG_ERROR, __VA_ARGS__ );\ 94 | return ret;\ 95 | }\ 96 | } while( 0 ) 97 | 98 | #define FAIL_IF_ERR( cond, name, ... ) RETURN_IF_ERR( cond, name, -1, __VA_ARGS__ ) 99 | 100 | typedef enum 101 | { 102 | RANGE_AUTO = -1, 103 | RANGE_TV, 104 | RANGE_PC 105 | } range_enum; 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /common/arm/deblock.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * deblock.h: arm deblocking 3 | ***************************************************************************** 4 | * Copyright (C) 2017-2021 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/aarch64/deblock.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * deblock.h: aarch64 deblocking 3 | ***************************************************************************** 4 | * Copyright (C) 2017-2021 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 | #endif 59 | -------------------------------------------------------------------------------- /common/quant.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * quant.h: quantization and level-run 3 | ***************************************************************************** 4 | * Copyright (C) 2005-2021 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/arm/cpu-a.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * cpu-a.S: arm cpu detection 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2021 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/mips/predict.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * predict.h: msa intra prediction 3 | ***************************************************************************** 4 | * Copyright (C) 2015-2021 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/ppc/dct.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * dct.h: ppc transform and zigzag 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2021 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/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 | -------------------------------------------------------------------------------- /encoder/set.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * set.h: header writing 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2021 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/me.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * me.h: motion estimation 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2021 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 | -------------------------------------------------------------------------------- /common/vlc.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * vlc.c : vlc tables 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2021 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 | -------------------------------------------------------------------------------- /tools/checkasm-arm.S: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * checkasm-arm.S: assembly check tool 3 | ***************************************************************************** 4 | * Copyright (C) 2015-2021 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 | -------------------------------------------------------------------------------- /output/matroska_ebml.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * matroska_ebml.h: matroska muxer utilities 3 | ***************************************************************************** 4 | * Copyright (C) 2005-2021 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 | #define MK_MAX_TRACKS 4 36 | 37 | typedef enum { 38 | MK_TRACK_VIDEO = 1, 39 | MK_TRACK_AUDIO = 2 40 | } mk_track_type; 41 | 42 | typedef enum { 43 | MK_LACING_NONE = 0, 44 | MK_LACING_XIPH = 1, 45 | MK_LACING_FIXED = 2, 46 | MK_LACING_EBML = 3 47 | } mk_lacing_type; 48 | 49 | typedef struct { 50 | unsigned width; 51 | unsigned height; 52 | unsigned display_width; 53 | unsigned display_height; 54 | int display_size_units; 55 | int stereo_mode; 56 | } mk_video_info_t; 57 | 58 | typedef struct { 59 | unsigned channels; 60 | unsigned samplerate; 61 | unsigned output_samplerate; 62 | unsigned bit_depth; 63 | } mk_audio_info_t; 64 | 65 | typedef union { 66 | mk_video_info_t v; 67 | mk_audio_info_t a; 68 | } mk_track_info_t; 69 | 70 | typedef struct { 71 | mk_track_type type; 72 | mk_lacing_type lacing; 73 | unsigned id; 74 | const char *codec_id; 75 | void *codec_private; 76 | unsigned codec_private_size; 77 | int64_t default_frame_duration; 78 | mk_track_info_t info; 79 | } mk_track_t; 80 | 81 | typedef struct mk_writer mk_writer; 82 | 83 | mk_writer *mk_create_writer( const char *filename ); 84 | 85 | int mk_write_header( mk_writer *w, const char *writing_app, int64_t timescale, 86 | mk_track_t *tracks, int track_count ); 87 | int mk_start_frame( mk_writer *w ); 88 | int mk_end_frame( mk_writer *w, uint32_t track_id ); 89 | int mk_add_frame_data( mk_writer *w, const void *data, unsigned size ); 90 | int mk_set_frame_flags( mk_writer *w, int64_t timestamp, int keyframe, int skippable, uint32_t track_id ); 91 | int mk_close( mk_writer *w, int64_t *last_delta ); 92 | 93 | /* Supported (or may be supported in the future) audio codecs in x264's matroska muxer. */ 94 | /* We do not care about A_MS/ACM (avi compatible) type codecs. */ 95 | /* For reference, see http://haali.su/mkv/codecs.pdf */ 96 | #if HAVE_AUDIO 97 | #define MK_AUDIO_TAG_AAC "A_AAC" 98 | #define MK_AUDIO_TAG_AC3 "A_AC3" 99 | #define MK_AUDIO_TAG_EAC3 "A_EAC3" 100 | #define MK_AUDIO_TAG_DTS "A_DTS" 101 | #define MK_AUDIO_TAG_FLAC "A_FLAC" 102 | #define MK_AUDIO_TAG_MP1 "A_MPEG/L1" 103 | #define MK_AUDIO_TAG_MP2 "A_MPEG/L2" 104 | #define MK_AUDIO_TAG_MP3 "A_MPEG/L3" 105 | #define MK_AUDIO_TAG_PCM_FLOAT "A_PCM/FLOAT/IEEE" 106 | #define MK_AUDIO_TAG_PCM_LE "A_PCM/INT/LIT" 107 | #define MK_AUDIO_TAG_PCM_BE "A_PCM/INT/BIG" /* Do we need this? */ 108 | #define MK_AUDIO_TAG_MLP "A_MLP" 109 | #define MK_AUDIO_TAG_TRUEHD "A_TRUEHD" 110 | #define MK_AUDIO_TAG_TTA "A_TTA1" 111 | #define MK_AUDIO_TAG_VORBIS "A_VORBIS" 112 | #endif /* HAVE_AUDIO */ 113 | 114 | #endif /* X264_MATROSKA_EBML_H */ 115 | -------------------------------------------------------------------------------- /common/aarch64/quant.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * quant.h: arm quantization and level-run 3 | ***************************************************************************** 4 | * Copyright (C) 2005-2021 x264 project 5 | * 6 | * Authors: David Conrad 7 | * Janne Grunau 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_AARCH64_QUANT_H 28 | #define X264_AARCH64_QUANT_H 29 | 30 | #define x264_quant_2x2_dc_aarch64 x264_template(quant_2x2_dc_aarch64) 31 | int x264_quant_2x2_dc_aarch64( int16_t dct[4], int mf, int bias ); 32 | 33 | #define x264_quant_2x2_dc_neon x264_template(quant_2x2_dc_neon) 34 | int x264_quant_2x2_dc_neon( int16_t dct[4], int mf, int bias ); 35 | #define x264_quant_4x4_dc_neon x264_template(quant_4x4_dc_neon) 36 | int x264_quant_4x4_dc_neon( int16_t dct[16], int mf, int bias ); 37 | #define x264_quant_4x4_neon x264_template(quant_4x4_neon) 38 | int x264_quant_4x4_neon( int16_t dct[16], uint16_t mf[16], uint16_t bias[16] ); 39 | #define x264_quant_4x4x4_neon x264_template(quant_4x4x4_neon) 40 | int x264_quant_4x4x4_neon( int16_t dct[4][16], uint16_t mf[16], uint16_t bias[16] ); 41 | #define x264_quant_8x8_neon x264_template(quant_8x8_neon) 42 | int x264_quant_8x8_neon( int16_t dct[64], uint16_t mf[64], uint16_t bias[64] ); 43 | 44 | #define x264_dequant_4x4_dc_neon x264_template(dequant_4x4_dc_neon) 45 | void x264_dequant_4x4_dc_neon( int16_t dct[16], int dequant_mf[6][16], int i_qp ); 46 | #define x264_dequant_4x4_neon x264_template(dequant_4x4_neon) 47 | void x264_dequant_4x4_neon( int16_t dct[16], int dequant_mf[6][16], int i_qp ); 48 | #define x264_dequant_8x8_neon x264_template(dequant_8x8_neon) 49 | void x264_dequant_8x8_neon( int16_t dct[64], int dequant_mf[6][64], int i_qp ); 50 | 51 | #define x264_decimate_score15_neon x264_template(decimate_score15_neon) 52 | int x264_decimate_score15_neon( int16_t * ); 53 | #define x264_decimate_score16_neon x264_template(decimate_score16_neon) 54 | int x264_decimate_score16_neon( int16_t * ); 55 | #define x264_decimate_score64_neon x264_template(decimate_score64_neon) 56 | int x264_decimate_score64_neon( int16_t * ); 57 | 58 | #define x264_coeff_last4_aarch64 x264_template(coeff_last4_aarch64) 59 | int x264_coeff_last4_aarch64( int16_t * ); 60 | #define x264_coeff_last8_aarch64 x264_template(coeff_last8_aarch64) 61 | int x264_coeff_last8_aarch64( int16_t * ); 62 | #define x264_coeff_last15_neon x264_template(coeff_last15_neon) 63 | int x264_coeff_last15_neon( int16_t * ); 64 | #define x264_coeff_last16_neon x264_template(coeff_last16_neon) 65 | int x264_coeff_last16_neon( int16_t * ); 66 | #define x264_coeff_last64_neon x264_template(coeff_last64_neon) 67 | int x264_coeff_last64_neon( int16_t * ); 68 | 69 | #define x264_coeff_level_run4_aarch64 x264_template(coeff_level_run4_aarch64) 70 | int x264_coeff_level_run4_aarch64( int16_t *, x264_run_level_t * ); 71 | #define x264_coeff_level_run8_neon x264_template(coeff_level_run8_neon) 72 | int x264_coeff_level_run8_neon( int16_t *, x264_run_level_t * ); 73 | #define x264_coeff_level_run15_neon x264_template(coeff_level_run15_neon) 74 | int x264_coeff_level_run15_neon( int16_t *, x264_run_level_t * ); 75 | #define x264_coeff_level_run16_neon x264_template(coeff_level_run16_neon) 76 | int x264_coeff_level_run16_neon( int16_t *, x264_run_level_t * ); 77 | 78 | #define x264_denoise_dct_neon x264_template(denoise_dct_neon) 79 | void x264_denoise_dct_neon( dctcoef *, uint32_t *, udctcoef *, int ); 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /common/arm/predict-c.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * predict.c: arm intra prediction 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2021 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 "common/common.h" 27 | #include "predict.h" 28 | #include "pixel.h" 29 | 30 | void x264_predict_4x4_init_arm( uint32_t cpu, x264_predict_t pf[12] ) 31 | { 32 | if( !(cpu&X264_CPU_ARMV6) ) 33 | return; 34 | 35 | #if !HIGH_BIT_DEPTH 36 | pf[I_PRED_4x4_H] = x264_predict_4x4_h_armv6; 37 | pf[I_PRED_4x4_V] = x264_predict_4x4_v_armv6; 38 | pf[I_PRED_4x4_DC] = x264_predict_4x4_dc_armv6; 39 | pf[I_PRED_4x4_DDR] = x264_predict_4x4_ddr_armv6; 40 | 41 | if( !(cpu&X264_CPU_NEON) ) 42 | return; 43 | 44 | pf[I_PRED_4x4_DC_TOP] = x264_predict_4x4_dc_top_neon; 45 | pf[I_PRED_4x4_DDL] = x264_predict_4x4_ddl_neon; 46 | #endif // !HIGH_BIT_DEPTH 47 | } 48 | 49 | void x264_predict_8x8c_init_arm( uint32_t cpu, x264_predict_t pf[7] ) 50 | { 51 | if( !(cpu&X264_CPU_NEON) ) 52 | return; 53 | 54 | #if !HIGH_BIT_DEPTH 55 | pf[I_PRED_CHROMA_DC] = x264_predict_8x8c_dc_neon; 56 | pf[I_PRED_CHROMA_DC_TOP] = x264_predict_8x8c_dc_top_neon; 57 | pf[I_PRED_CHROMA_DC_LEFT] = x264_predict_8x8c_dc_left_neon; 58 | pf[I_PRED_CHROMA_H] = x264_predict_8x8c_h_neon; 59 | pf[I_PRED_CHROMA_V] = x264_predict_8x8c_v_neon; 60 | pf[I_PRED_CHROMA_P] = x264_predict_8x8c_p_neon; 61 | #endif // !HIGH_BIT_DEPTH 62 | } 63 | 64 | void x264_predict_8x16c_init_arm( uint32_t cpu, x264_predict_t pf[7] ) 65 | { 66 | if( !(cpu&X264_CPU_NEON) ) 67 | return; 68 | 69 | #if !HIGH_BIT_DEPTH 70 | /* The other functions weren't faster than C (gcc 4.7.3) on Cortex A8 and A9. */ 71 | pf[I_PRED_CHROMA_DC_TOP] = x264_predict_8x16c_dc_top_neon; 72 | pf[I_PRED_CHROMA_H] = x264_predict_8x16c_h_neon; 73 | pf[I_PRED_CHROMA_P] = x264_predict_8x16c_p_neon; 74 | #endif // !HIGH_BIT_DEPTH 75 | } 76 | 77 | void x264_predict_8x8_init_arm( uint32_t cpu, x264_predict8x8_t pf[12], x264_predict_8x8_filter_t *predict_filter ) 78 | { 79 | if( !(cpu&X264_CPU_NEON) ) 80 | return; 81 | 82 | #if !HIGH_BIT_DEPTH 83 | pf[I_PRED_8x8_DDL] = x264_predict_8x8_ddl_neon; 84 | pf[I_PRED_8x8_DDR] = x264_predict_8x8_ddr_neon; 85 | pf[I_PRED_8x8_VL] = x264_predict_8x8_vl_neon; 86 | pf[I_PRED_8x8_VR] = x264_predict_8x8_vr_neon; 87 | pf[I_PRED_8x8_DC] = x264_predict_8x8_dc_neon; 88 | pf[I_PRED_8x8_H] = x264_predict_8x8_h_neon; 89 | pf[I_PRED_8x8_HD] = x264_predict_8x8_hd_neon; 90 | pf[I_PRED_8x8_HU] = x264_predict_8x8_hu_neon; 91 | pf[I_PRED_8x8_V] = x264_predict_8x8_v_neon; 92 | #endif // !HIGH_BIT_DEPTH 93 | } 94 | 95 | void x264_predict_16x16_init_arm( uint32_t cpu, x264_predict_t pf[7] ) 96 | { 97 | if( !(cpu&X264_CPU_NEON) ) 98 | return; 99 | 100 | #if !HIGH_BIT_DEPTH 101 | pf[I_PRED_16x16_DC ] = x264_predict_16x16_dc_neon; 102 | pf[I_PRED_16x16_DC_TOP] = x264_predict_16x16_dc_top_neon; 103 | pf[I_PRED_16x16_DC_LEFT]= x264_predict_16x16_dc_left_neon; 104 | pf[I_PRED_16x16_H ] = x264_predict_16x16_h_neon; 105 | pf[I_PRED_16x16_V ] = x264_predict_16x16_v_neon; 106 | pf[I_PRED_16x16_P ] = x264_predict_16x16_p_neon; 107 | #endif // !HIGH_BIT_DEPTH 108 | } 109 | -------------------------------------------------------------------------------- /common/x86/bitstream-a.asm: -------------------------------------------------------------------------------- 1 | ;***************************************************************************** 2 | ;* bitstream-a.asm: x86 bitstream functions 3 | ;***************************************************************************** 4 | ;* Copyright (C) 2010-2021 x264 project 5 | ;* 6 | ;* Authors: Fiona Glaser 7 | ;* Henrik Gramner 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 | %include "x86util.asm" 29 | 30 | SECTION .text 31 | 32 | ;----------------------------------------------------------------------------- 33 | ; uint8_t *x264_nal_escape( uint8_t *dst, uint8_t *src, uint8_t *end ) 34 | ;----------------------------------------------------------------------------- 35 | %macro NAL_LOOP 2 36 | %%escape: 37 | ; Detect false positive to avoid unnecessary escape loop 38 | xor r3d, r3d 39 | cmp byte [r0+r1-1], 0 40 | setnz r3b 41 | xor k3, k4 42 | jnz .escape 43 | jmp %%continue 44 | ALIGN 16 45 | %1: 46 | mova [r0+r1+mmsize], m1 47 | pcmpeqb m1, m0 48 | mova [r0+r1], m2 49 | pcmpeqb m2, m0 50 | pmovmskb r3d, m1 51 | %2 m1, [r1+r2+3*mmsize] 52 | pmovmskb r4d, m2 53 | %2 m2, [r1+r2+2*mmsize] 54 | shl k3, mmsize 55 | or k3, k4 56 | lea k4, [2*r3+1] 57 | and k4, k3 58 | jnz %%escape 59 | %%continue: 60 | add r1, 2*mmsize 61 | jl %1 62 | %endmacro 63 | 64 | %macro NAL_ESCAPE 0 65 | %if mmsize == 32 66 | %xdefine k3 r3 67 | %xdefine k4 r4 68 | %else 69 | %xdefine k3 r3d 70 | %xdefine k4 r4d 71 | %endif 72 | 73 | cglobal nal_escape, 3,5 74 | movzx r3d, byte [r1] 75 | sub r1, r2 ; r1 = offset of current src pointer from end of src 76 | pxor m0, m0 77 | mov [r0], r3b 78 | sub r0, r1 ; r0 = projected end of dst, assuming no more escapes 79 | or r3d, 0xffffff00 ; ignore data before src 80 | 81 | ; Start off by jumping into the escape loop in case there's an escape at the start. 82 | ; And do a few more in scalar until dst is aligned. 83 | jmp .escape_loop 84 | 85 | %if mmsize == 16 86 | NAL_LOOP .loop_aligned, mova 87 | jmp .ret 88 | %endif 89 | NAL_LOOP .loop_unaligned, movu 90 | .ret: 91 | movifnidn rax, r0 92 | RET 93 | 94 | .escape: 95 | ; Skip bytes that are known to be valid 96 | and k4, k3 97 | tzcnt k4, k4 98 | xor r3d, r3d ; the last two bytes are known to be zero 99 | add r1, r4 100 | .escape_loop: 101 | inc r1 102 | jge .ret 103 | movzx r4d, byte [r1+r2] 104 | shl r3d, 8 105 | or r3d, r4d 106 | test r3d, 0xfffffc ; if the last two bytes are 0 and the current byte is <=3 107 | jz .add_escape_byte 108 | .escaped: 109 | lea r4d, [r0+r1] 110 | mov [r0+r1], r3b 111 | test r4d, mmsize-1 ; Do SIMD when dst is aligned 112 | jnz .escape_loop 113 | movu m1, [r1+r2+mmsize] 114 | movu m2, [r1+r2] 115 | %if mmsize == 16 116 | lea r4d, [r1+r2] 117 | test r4d, mmsize-1 118 | jz .loop_aligned 119 | %endif 120 | jmp .loop_unaligned 121 | 122 | .add_escape_byte: 123 | mov byte [r0+r1], 3 124 | inc r0 125 | or r3d, 0x0300 126 | jmp .escaped 127 | %endmacro 128 | 129 | INIT_MMX mmx2 130 | NAL_ESCAPE 131 | INIT_XMM sse2 132 | NAL_ESCAPE 133 | %if ARCH_X86_64 134 | INIT_YMM avx2 135 | NAL_ESCAPE 136 | %endif 137 | -------------------------------------------------------------------------------- /common/tables.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * tables.h: const tables 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2021 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_TABLES_H 28 | #define X264_TABLES_H 29 | 30 | typedef struct 31 | { 32 | uint8_t i_bits; 33 | uint8_t i_size; 34 | } vlc_t; 35 | 36 | X264_API extern const x264_level_t x264_levels[]; 37 | 38 | extern const uint8_t x264_exp2_lut[64]; 39 | extern const float x264_log2_lut[128]; 40 | extern const float x264_log2_lz_lut[32]; 41 | 42 | #define QP_MAX_MAX (51+6*2+18) 43 | extern const uint16_t x264_lambda_tab[QP_MAX_MAX+1]; 44 | extern const int x264_lambda2_tab[QP_MAX_MAX+1]; 45 | extern const int x264_trellis_lambda2_tab[2][QP_MAX_MAX+1]; 46 | #define MAX_CHROMA_LAMBDA_OFFSET 36 47 | extern const uint16_t x264_chroma_lambda2_offset_tab[MAX_CHROMA_LAMBDA_OFFSET+1]; 48 | 49 | extern const uint8_t x264_hpel_ref0[16]; 50 | extern const uint8_t x264_hpel_ref1[16]; 51 | 52 | extern const uint8_t x264_cqm_jvt4i[16]; 53 | extern const uint8_t x264_cqm_jvt4p[16]; 54 | extern const uint8_t x264_cqm_jvt8i[64]; 55 | extern const uint8_t x264_cqm_jvt8p[64]; 56 | extern const uint8_t x264_cqm_flat16[64]; 57 | extern const uint8_t * const x264_cqm_jvt[8]; 58 | extern const uint8_t x264_cqm_avci50_4ic[16]; 59 | extern const uint8_t x264_cqm_avci50_p_8iy[64]; 60 | extern const uint8_t x264_cqm_avci50_1080i_8iy[64]; 61 | extern const uint8_t x264_cqm_avci100_720p_4ic[16]; 62 | extern const uint8_t x264_cqm_avci100_720p_8iy[64]; 63 | extern const uint8_t x264_cqm_avci100_1080_4ic[16]; 64 | extern const uint8_t x264_cqm_avci100_1080i_8iy[64]; 65 | extern const uint8_t x264_cqm_avci100_1080p_8iy[64]; 66 | extern const uint8_t x264_cqm_avci300_2160p_4iy[16]; 67 | extern const uint8_t x264_cqm_avci300_2160p_4ic[16]; 68 | extern const uint8_t x264_cqm_avci300_2160p_8iy[64]; 69 | 70 | extern const uint8_t x264_decimate_table4[16]; 71 | extern const uint8_t x264_decimate_table8[64]; 72 | 73 | extern const uint32_t x264_dct4_weight_tab[16]; 74 | extern const uint32_t x264_dct8_weight_tab[64]; 75 | extern const uint32_t x264_dct4_weight2_tab[16]; 76 | extern const uint32_t x264_dct8_weight2_tab[64]; 77 | 78 | extern const int8_t x264_cabac_context_init_I[1024][2]; 79 | extern const int8_t x264_cabac_context_init_PB[3][1024][2]; 80 | extern const uint8_t x264_cabac_range_lps[64][4]; 81 | extern const uint8_t x264_cabac_transition[128][2]; 82 | extern const uint8_t x264_cabac_renorm_shift[64]; 83 | extern const uint16_t x264_cabac_entropy[128]; 84 | 85 | extern const uint8_t x264_significant_coeff_flag_offset_8x8[2][64]; 86 | extern const uint8_t x264_last_coeff_flag_offset_8x8[63]; 87 | extern const uint8_t x264_coeff_flag_offset_chroma_422_dc[7]; 88 | extern const uint16_t x264_significant_coeff_flag_offset[2][16]; 89 | extern const uint16_t x264_last_coeff_flag_offset[2][16]; 90 | extern const uint16_t x264_coeff_abs_level_m1_offset[16]; 91 | extern const uint8_t x264_count_cat_m1[14]; 92 | 93 | extern const vlc_t x264_coeff0_token[6]; 94 | extern const vlc_t x264_coeff_token[6][16][4]; 95 | extern const vlc_t x264_total_zeros[15][16]; 96 | extern const vlc_t x264_total_zeros_2x2_dc[3][4]; 97 | extern const vlc_t x264_total_zeros_2x4_dc[7][8]; 98 | extern const vlc_t x264_run_before_init[7][16]; 99 | 100 | extern uint8_t x264_zero[1024]; 101 | 102 | #endif 103 | --------------------------------------------------------------------------------