├── source ├── common │ ├── mc.c │ ├── mc.h │ ├── common.c │ ├── common.h │ ├── cudata.c │ ├── cudata.h │ ├── frame.c │ ├── intra.c │ ├── osdep.h │ ├── avs2_defs.h │ ├── avs2tab.h │ ├── cg_scan.c │ ├── defines.h │ ├── predict.h │ ├── transform.c │ ├── block_info.c │ ├── primitives.h │ ├── vec │ │ ├── intrinsic.h │ │ ├── intrinsic_alf.c │ │ ├── intrinsic_dct.c │ │ ├── intrinsic_idct.c │ │ ├── intrinsic_dct_avx.c │ │ ├── intrinsic_idct_avx2.c │ │ ├── intrinsic_inter_pred.c │ │ ├── intrinsic_intra-pred.c │ │ ├── intrinsic_deblock_avx2.c │ │ ├── intrinsic_inter_pred_avx2.c │ │ ├── intrinsic_intra-filledge.c │ │ ├── intrinsic_intra-pred_avx2.c │ │ ├── intrinsic_cg_scan_avx.c │ │ ├── intrinsic_pixel.c │ │ ├── intrinsic_quant.c │ │ └── intrinsic_cg_scan.c │ ├── transform.h │ ├── block_info.h │ ├── x86 │ │ ├── quant8.h │ │ ├── dct8.h │ │ ├── mc.h │ │ ├── cpu-a.asm │ │ ├── pixel.h │ │ └── const-a.asm │ ├── threadpool.h │ ├── common_arm.h │ ├── primitives.c │ ├── frame.h │ ├── filter.h │ ├── intra.h │ ├── basic_types.h │ ├── win32thread.h │ ├── common_arm.c │ ├── nal.h │ ├── cpu.h │ └── pixel.h ├── encoder │ ├── aec.c │ ├── aec.h │ ├── alf.c │ ├── me.c │ ├── rdo.c │ ├── rps.c │ ├── sao.c │ ├── rdoq.c │ ├── slice.c │ ├── slice.h │ ├── xavs2.c │ ├── aec_ctx.c │ ├── aec_rdo.c │ ├── aec_vrdo.c │ ├── encoder.c │ ├── md_inter.c │ ├── md_intra.c │ ├── presets.c │ ├── parameters.c │ ├── pre_encode.c │ ├── xavs2_api.c │ ├── aec_fastrdo.c │ ├── rdoq.h │ ├── presets.h │ ├── alf.h │ ├── sao.h │ ├── header.h │ ├── yuv_writer.c │ ├── rdo.h │ ├── tdrdo.h │ ├── wquant.h │ ├── ratecontrol.h │ ├── rps.h │ ├── xlist.h │ ├── encoder.h │ ├── me.h │ ├── wrapper.c │ └── xlist.c ├── compat │ ├── msvc │ │ └── stdint.h │ └── getopt │ │ └── getopt.h └── configw.h ├── .github └── ISSUE_TEMPLATE │ ├── ----.md │ ├── feature_request.md │ └── bug_report.md ├── .travis.yml ├── .gitignore ├── appveyor.yml ├── config ├── seq-template.cfg └── encoder_ai.cfg ├── .gitattributes ├── README.zh.md ├── version.sh └── README.md /source/common/mc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/mc.c -------------------------------------------------------------------------------- /source/common/mc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/mc.h -------------------------------------------------------------------------------- /source/encoder/aec.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/encoder/aec.c -------------------------------------------------------------------------------- /source/encoder/aec.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/encoder/aec.h -------------------------------------------------------------------------------- /source/encoder/alf.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/encoder/alf.c -------------------------------------------------------------------------------- /source/encoder/me.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/encoder/me.c -------------------------------------------------------------------------------- /source/encoder/rdo.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/encoder/rdo.c -------------------------------------------------------------------------------- /source/encoder/rps.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/encoder/rps.c -------------------------------------------------------------------------------- /source/encoder/sao.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/encoder/sao.c -------------------------------------------------------------------------------- /source/common/common.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/common.c -------------------------------------------------------------------------------- /source/common/common.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/common.h -------------------------------------------------------------------------------- /source/common/cudata.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/cudata.c -------------------------------------------------------------------------------- /source/common/cudata.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/cudata.h -------------------------------------------------------------------------------- /source/common/frame.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/frame.c -------------------------------------------------------------------------------- /source/common/intra.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/intra.c -------------------------------------------------------------------------------- /source/common/osdep.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/osdep.h -------------------------------------------------------------------------------- /source/encoder/rdoq.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/encoder/rdoq.c -------------------------------------------------------------------------------- /source/encoder/slice.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/encoder/slice.c -------------------------------------------------------------------------------- /source/encoder/slice.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/encoder/slice.h -------------------------------------------------------------------------------- /source/encoder/xavs2.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/encoder/xavs2.c -------------------------------------------------------------------------------- /source/common/avs2_defs.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/avs2_defs.h -------------------------------------------------------------------------------- /source/common/avs2tab.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/avs2tab.h -------------------------------------------------------------------------------- /source/common/cg_scan.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/cg_scan.c -------------------------------------------------------------------------------- /source/common/defines.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/defines.h -------------------------------------------------------------------------------- /source/common/predict.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/predict.h -------------------------------------------------------------------------------- /source/common/transform.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/transform.c -------------------------------------------------------------------------------- /source/encoder/aec_ctx.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/encoder/aec_ctx.c -------------------------------------------------------------------------------- /source/encoder/aec_rdo.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/encoder/aec_rdo.c -------------------------------------------------------------------------------- /source/encoder/aec_vrdo.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/encoder/aec_vrdo.c -------------------------------------------------------------------------------- /source/encoder/encoder.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/encoder/encoder.c -------------------------------------------------------------------------------- /source/encoder/md_inter.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/encoder/md_inter.c -------------------------------------------------------------------------------- /source/encoder/md_intra.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/encoder/md_intra.c -------------------------------------------------------------------------------- /source/encoder/presets.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/encoder/presets.c -------------------------------------------------------------------------------- /source/common/block_info.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/block_info.c -------------------------------------------------------------------------------- /source/common/primitives.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/primitives.h -------------------------------------------------------------------------------- /source/encoder/parameters.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/encoder/parameters.c -------------------------------------------------------------------------------- /source/encoder/pre_encode.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/encoder/pre_encode.c -------------------------------------------------------------------------------- /source/encoder/xavs2_api.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/encoder/xavs2_api.c -------------------------------------------------------------------------------- /source/common/vec/intrinsic.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/vec/intrinsic.h -------------------------------------------------------------------------------- /source/encoder/aec_fastrdo.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/encoder/aec_fastrdo.c -------------------------------------------------------------------------------- /source/common/vec/intrinsic_alf.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/vec/intrinsic_alf.c -------------------------------------------------------------------------------- /source/common/vec/intrinsic_dct.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/vec/intrinsic_dct.c -------------------------------------------------------------------------------- /source/common/vec/intrinsic_idct.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/vec/intrinsic_idct.c -------------------------------------------------------------------------------- /source/common/vec/intrinsic_dct_avx.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/vec/intrinsic_dct_avx.c -------------------------------------------------------------------------------- /source/common/vec/intrinsic_idct_avx2.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/vec/intrinsic_idct_avx2.c -------------------------------------------------------------------------------- /source/common/vec/intrinsic_inter_pred.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/vec/intrinsic_inter_pred.c -------------------------------------------------------------------------------- /source/common/vec/intrinsic_intra-pred.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/vec/intrinsic_intra-pred.c -------------------------------------------------------------------------------- /source/common/vec/intrinsic_deblock_avx2.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/vec/intrinsic_deblock_avx2.c -------------------------------------------------------------------------------- /source/common/vec/intrinsic_inter_pred_avx2.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/vec/intrinsic_inter_pred_avx2.c -------------------------------------------------------------------------------- /source/common/vec/intrinsic_intra-filledge.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/vec/intrinsic_intra-filledge.c -------------------------------------------------------------------------------- /source/common/vec/intrinsic_intra-pred_avx2.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/xavs2/HEAD/source/common/vec/intrinsic_intra-pred_avx2.c -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/----.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 问题咨询 3 | about: 使用问题/安全问题/其他问题 4 | 5 | --- 6 | 7 | 请发送邮件至: sswang@pku.edu.cn 8 | 或在应用内“高级设置” - “建议反馈” 填写表单 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project / 功能请求 4 | 5 | --- 6 | 7 | 请详细填写以下四项关键元素 8 | 9 | ## 功能描述 10 | 11 | ## 功能带来的效应 12 | 13 | ## 缺少此功能的影响 14 | 15 | ## 实现的思路与方式 16 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | dist: xenial 3 | 4 | install: 5 | - wget https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.gz -O nasm-2.14.02.tar.gz 6 | - tar -xvf nasm-2.14.02.tar.gz 7 | - pushd nasm-2.14.02 && ./configure --prefix=/usr && make && sudo make install && popd 8 | 9 | jobs: 10 | include: 11 | # General Linux build job 12 | - name: Build 13 | script: 14 | - cd build/linux 15 | - ./configure 16 | - make -j 17 | 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | Release/ 3 | x64_Debug/ 4 | x64_Release/ 5 | test/ 6 | build/linux/xavs2* 7 | My*/ 8 | *.user 9 | *.suo 10 | *.ncb 11 | *.aps 12 | *.pdb 13 | *.ipdb 14 | *.res 15 | *.dat 16 | *.manifest 17 | *.map 18 | *.dep 19 | *.idb 20 | *.ilk 21 | *.htm 22 | *.exp 23 | *.lib 24 | *.obj 25 | *.iobj 26 | *.dll* 27 | *.exe 28 | *.avs 29 | *.mkv 30 | *.mp4 31 | *.y4m 32 | *.yuv 33 | *.log 34 | *.bak 35 | *.o 36 | *.a 37 | *.so 38 | *.cd 39 | *.sdf 40 | *.opensdf 41 | *.depend 42 | version.h 43 | *.pc 44 | *.mak 45 | *.so.* 46 | config.h 47 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | image: Visual Studio 2015 2 | configuration: Release 3 | 4 | platform: 5 | - x64 6 | 7 | install: 8 | - appveyor DownloadFile https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/win64/nasm-2.14.02-win64.zip -FileName nasm.zip 9 | - ps: Expand-Archive -Path nasm.zip -DestinationPath build/vs2013 -Force:$true 10 | - ps: Move-Item build/vs2013/nasm-2.14.02/nasm.exe build/vs2013 11 | 12 | build: 13 | project: build\vs2013\xavs2.sln 14 | 15 | artifacts: 16 | - path: build\bin\x64_Release\*.* 17 | name: $(APPVEYOR_PROJECT_NAME) 18 | -------------------------------------------------------------------------------- /source/compat/msvc/stdint.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef _MSC_VER 4 | #error "Use this header only with Microsoft Visual C++ compilers!" 5 | #endif 6 | 7 | #include // for intptr_t 8 | #if !defined(UINT64_MAX) 9 | #include 10 | #define UINT64_MAX _UI64_MAX 11 | #endif 12 | 13 | /* a minimal set of C99 types for use with MSVC (VC9) */ 14 | 15 | typedef signed char int8_t; 16 | typedef short int int16_t; 17 | typedef int int32_t; 18 | typedef __int64 int64_t; 19 | 20 | typedef unsigned char uint8_t; 21 | typedef unsigned short int uint16_t; 22 | typedef unsigned int uint32_t; 23 | typedef unsigned __int64 uint64_t; 24 | 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report of bug / 如果你认为你发现了一项代码问题 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | 9 | A clear and concise description of what the bug is. 10 | 11 | 请详细的描述这个bug的细节 12 | 13 | **To Reproduce** 14 | 15 | Steps to reproduce the behavior (including the commond line parameters) 16 | 17 | 请详细描述重现这个bug的步骤(运行的命令行参数、输入的文件) 18 | 19 | 20 | **Expected behavior** 21 | 22 | A clear and concise description of what you expected to happen. 23 | 24 | 你认为这个功能本应如何工作 25 | 26 | **Screenshots** 27 | 28 | If applicable, add screenshots to help explain your problem. 29 | 30 | 如果有可能,请提供截图 31 | 32 | **Desktop (please complete the following information):** 33 | - OS: [e.g. Windows10, Ubuntu 18.04] 34 | - Compiler [e.g. Visual Studio 2013, GCC 5.6.0] 35 | - yasm [e.g. 1.2.0, 1.3.0-luofl] 36 | 37 | 你的操作系统(包括版本)、编译器(GCC/G++, VS)、汇编器yasm(版本号)。 38 | 39 | 40 | **Additional context** 41 | 42 | Add any other context about the problem here, i.e. video sequences and bitstreams. 43 | 44 | 额外的材料,例如输入的视频序列、码流文件等。 45 | -------------------------------------------------------------------------------- /config/seq-template.cfg: -------------------------------------------------------------------------------- 1 | ########################################################################################## 2 | # Input File Configuration 3 | # Suggested parameters: encoder_*.cfg -f seq.cfg 4 | # **Do not modify this file.** 5 | # You can copy this file and rename as you like 6 | ########################################################################################## 7 | InputFile = "E:\Seq\BasketballPass_416x240_50.yuv" # Input sequence, YUV 4:2:0 8 | FramesToBeEncoded = 30 # Number of frames to be coded 9 | SourceWidth = 416 # Image width in Pels 10 | SourceHeight = 240 # Image height in Pels 11 | fps = 50.0 # framerate, AVS2 supported: 23.976(24000/1001), 24.0, 25.0(default), 29.97(30000/1001), 30.0, 50.0, 59.94(60000/1001), 60.0 12 | ChromaFormat = 1 # chroma format, 1=4:2:0 (default, the only supported format for the standard), 0=4:0:0, 2=4:2:2 13 | InputSampleBitDepth = 8 # Source bit depth (8 bit or 10 bit for all components) 14 | SampleBitDepth = 8 # Internal coding bit depth (8 bit or 10 bit for all components) 15 | ReconFile = "test_rec.yuv" 16 | OutputFile = "test.avs" 17 | -------------------------------------------------------------------------------- /source/encoder/rdoq.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rdoq.h 3 | * 4 | * Description of this file: 5 | * RDOQ functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | #ifndef XAVS2_RDOQ_H 38 | #define XAVS2_RDOQ_H 39 | 40 | #define rdoq_block FPFX(rdoq_block) 41 | int rdoq_block(xavs2_t *h, aec_t *p_aec, cu_t *p_cu, coeff_t *cur_blk, int bsx, int bsy, int i_tu_level, int qp, int b_luma, int intra_mode); 42 | 43 | #endif // XAVS2_RDOQ_H 44 | -------------------------------------------------------------------------------- /source/encoder/presets.h: -------------------------------------------------------------------------------- 1 | /* 2 | * presets.h 3 | * 4 | * Description of this file: 5 | * parse preset level functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | 38 | #ifndef XAVS2_PRESETS_H 39 | #define XAVS2_PRESETS_H 40 | 41 | #define parse_preset_level FPFX(parse_preset_level) 42 | void parse_preset_level(xavs2_param_t *p_param, int i_preset_level); 43 | #define encoder_set_fast_algorithms FPFX(encoder_set_fast_algorithms) 44 | void encoder_set_fast_algorithms(xavs2_t *h); 45 | #define decide_ultimate_paramters FPFX(decide_ultimate_paramters) 46 | void decide_ultimate_paramters(xavs2_param_t *p_param); 47 | 48 | #endif // XAVS2_PRESET_LEVELS_H 49 | -------------------------------------------------------------------------------- /source/common/transform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * transform.h 3 | * 4 | * Description of this file: 5 | * transform functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | #ifndef XAVS2_TRANSFORM_H 38 | #define XAVS2_TRANSFORM_H 39 | 40 | /** 41 | * =========================================================================== 42 | * type defines 43 | * =========================================================================== 44 | */ 45 | 46 | /** 47 | * =========================================================================== 48 | * function declares 49 | * =========================================================================== 50 | */ 51 | 52 | #endif // XAVS2_TRANSFORM_H 53 | -------------------------------------------------------------------------------- /source/common/block_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * block_info.h 3 | * 4 | * Description of this file: 5 | * Block Infomation functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | 38 | #ifndef XAVS2_BLOCK_INFO_H 39 | #define XAVS2_BLOCK_INFO_H 40 | 41 | #define get_neighbor_cbp_y FPFX(get_neighbor_cbp_y) 42 | int get_neighbor_cbp_y(xavs2_t *h, cu_info_t *p_cur, int slice_idx_cur_cu, int x_4x4, int y_4x4); 43 | #define set_available_tables FPFX(set_available_tables) 44 | void set_available_tables(xavs2_t *h); 45 | #define check_neighbor_cu_avail FPFX(check_neighbor_cu_avail) 46 | void check_neighbor_cu_avail(xavs2_t *h, cu_t *p_cu, int scu_x, int scu_y, int scu_xy); 47 | 48 | #endif // XAVS2_BLOCK_INFO_H 49 | -------------------------------------------------------------------------------- /source/common/x86/quant8.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * quant8.h: x86 quantization functions 3 | ***************************************************************************** 4 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 5 | * Copyright (C) 2018~ VCL, NELVT, Peking University 6 | * 7 | * Authors: Falei LUO 8 | * Jiaqi Zhang 9 | * 10 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 11 | * Homepage2: https://github.com/pkuvcl/xavs2 12 | * Homepage3: https://gitee.com/pkuvcl/xavs2 13 | * 14 | * This program is free software; you can redistribute it and/or modify 15 | * it under the terms of the GNU General Public License as published by 16 | * the Free Software Foundation; either version 2 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * This program is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | * GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License 25 | * along with this program; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 27 | * 28 | * This program is also available under a commercial proprietary license. 29 | * For more information, contact us at sswang @ pku.edu.cn. 30 | *****************************************************************************/ 31 | 32 | #ifndef XAVS2_QUANT8_H 33 | #define XAVS2_QUANT8_H 34 | 35 | int FPFX(quant_sse4)(coeff_t *coef, const int i_coef, const int scale, const int shift, const int add); 36 | 37 | int FPFX(quant_avx2)(coeff_t *coef, const int i_coef, const int scale, const int shift, const int add); 38 | 39 | void FPFX(dequant_sse4)(coeff_t *coef, const int i_coef, const int scale, const int shift); 40 | 41 | void FPFX(dequant_avx2)(coeff_t *coef, const int i_coef, const int scale, const int shift); 42 | 43 | #endif // ifndef XAVS2_QUANT8_H 44 | -------------------------------------------------------------------------------- /source/encoder/alf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * alf.h 3 | * 4 | * Description of this file: 5 | * ALF functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | #ifndef XAVS2_ALF_H 38 | #define XAVS2_ALF_H 39 | 40 | #define alf_get_buffer_size FPFX(alf_get_buffer_size) 41 | int alf_get_buffer_size(const xavs2_param_t *param); 42 | 43 | #define alf_init_buffer FPFX(alf_init_buffer) 44 | void alf_init_buffer(xavs2_t *h, uint8_t *mem_base); 45 | 46 | #define alf_filter_one_frame FPFX(alf_filter_one_frame) 47 | void alf_filter_one_frame(xavs2_t *h); 48 | 49 | #define alf_get_statistics_lcu FPFX(alf_get_statistics_lcu) 50 | void alf_get_statistics_lcu(xavs2_t *h, int lcu_x, int lcu_y, 51 | xavs2_frame_t *p_org, xavs2_frame_t *p_rec); 52 | 53 | #endif // XAVS2_ALF_H 54 | -------------------------------------------------------------------------------- /source/common/threadpool.h: -------------------------------------------------------------------------------- 1 | /* 2 | * threadpool.h 3 | * 4 | * Description of this file: 5 | * thread pooling functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | #ifndef XAVS2_THREADPOOL_H 38 | #define XAVS2_THREADPOOL_H 39 | 40 | typedef struct xavs2_threadpool_t xavs2_threadpool_t; 41 | 42 | #define xavs2_threadpool_init FPFX(threadpool_init) 43 | int xavs2_threadpool_init (xavs2_threadpool_t **p_pool, int threads, 44 | xavs2_tfunc_t init_func, void *init_arg); 45 | #define xavs2_threadpool_run FPFX(threadpool_run) 46 | void xavs2_threadpool_run (xavs2_threadpool_t *pool, void *(*func)(void *), void *arg, int wait_sign); 47 | #define xavs2_threadpool_wait FPFX(threadpool_wait) 48 | void *xavs2_threadpool_wait (xavs2_threadpool_t *pool, void *arg); 49 | #define xavs2_threadpool_delete FPFX(threadpool_delete) 50 | void xavs2_threadpool_delete(xavs2_threadpool_t *pool); 51 | 52 | #endif // XAVS2_THREADPOOL_H 53 | -------------------------------------------------------------------------------- /source/encoder/sao.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sao.h 3 | * 4 | * Description of this file: 5 | * SAO functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | 38 | #ifndef XAVS2_SAO_H 39 | #define XAVS2_SAO_H 40 | 41 | #define write_saoparam_one_lcu FPFX(write_saoparam_one_lcu) 42 | void write_saoparam_one_lcu(xavs2_t *h, aec_t *p_aec, int lcu_x, int lcu_y, bool_t *slice_sao_on, SAOBlkParam *saoBlkParam); 43 | #define sao_slice_onoff_decision FPFX(sao_slice_onoff_decision) 44 | void sao_slice_onoff_decision(xavs2_t *h, bool_t *slice_sao_on); 45 | 46 | /* decide sao parameters directly after one lcu reconstruction */ 47 | #define sao_get_lcu_param_after_deblock FPFX(sao_get_lcu_param_after_deblock) 48 | void sao_get_lcu_param_after_deblock(xavs2_t *h, aec_t *p_aec, int i_lcu_x, int i_lcu_y); 49 | 50 | /* conduct SAO filtering after one lcu row coding */ 51 | #define sao_filter_lcu FPFX(sao_filter_lcu) 52 | void sao_filter_lcu(xavs2_t *h, SAOBlkParam blk_param[NUM_SAO_COMPONENTS], int lcu_x, int lcu_y); 53 | #endif // XAVS2_SAO_H 54 | -------------------------------------------------------------------------------- /source/encoder/header.h: -------------------------------------------------------------------------------- 1 | /* 2 | * header.h 3 | * 4 | * Description of this file: 5 | * Header writing functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | 38 | #ifndef XAVS2_HEADER_H 39 | #define XAVS2_HEADER_H 40 | 41 | #define xavs2_sequence_write FPFX(sequence_write) 42 | int xavs2_sequence_write(xavs2_t *h, bs_t *p_bs); 43 | #define xavs2_user_data_write FPFX(user_data_write) 44 | int xavs2_user_data_write(bs_t *p_bs); 45 | #define xavs2_intra_picture_header_write FPFX(intra_picture_header_write) 46 | int xavs2_intra_picture_header_write(xavs2_t *h, bs_t *p_bs); 47 | #define xavs2_inter_picture_header_write FPFX(inter_picture_header_write) 48 | int xavs2_inter_picture_header_write(xavs2_t *h, bs_t *p_bs); 49 | #define xavs2_picture_header_alf_write FPFX(picture_header_alf_write) 50 | void xavs2_picture_header_alf_write(xavs2_t *h, ALFParam *alfPictureParam, bs_t *p_bs); 51 | #define xavs2_slice_header_write FPFX(slice_header_write) 52 | int xavs2_slice_header_write(xavs2_t *h, slice_t *p_slice); 53 | 54 | #endif // XAVS2_HEADER_H 55 | -------------------------------------------------------------------------------- /source/encoder/yuv_writer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * yuv_writer.c 3 | * 4 | * Description of this file: 5 | * YUV Writing functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | 38 | #include "common.h" 39 | #include "wrapper.h" 40 | #include "encoder.h" 41 | 42 | /* --------------------------------------------------------------------------- 43 | */ 44 | void dump_yuv_out(xavs2_t *h, FILE *fp, xavs2_frame_t *frame, int img_w, int img_h) 45 | { 46 | int j; 47 | 48 | if (fp != NULL) { 49 | UNUSED_PARAMETER(h); 50 | for (j = 0; j < img_h; j++) { 51 | fwrite(frame->planes[0] + j * frame->i_stride[0], img_w, 1, fp); 52 | } 53 | 54 | if (frame->i_plane == 3) { 55 | for (j = 0; j < (img_h >> 1); j++) { 56 | fwrite(frame->planes[1] + j * frame->i_stride[1], img_w >> 1, 1, fp); 57 | } 58 | 59 | for (j = 0; j < (img_h >> 1); j++) { 60 | fwrite(frame->planes[2] + j * frame->i_stride[2], img_w >> 1, 1, fp); 61 | } 62 | } 63 | 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /source/encoder/rdo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rdo.h 3 | * 4 | * Description of this file: 5 | * RDO functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | #ifndef XAVS2_RDO_H 38 | #define XAVS2_RDO_H 39 | 40 | #define xavs2_init_valid_mode_table FPFX(init_valid_mode_table) 41 | void xavs2_init_valid_mode_table(xavs2_t *h); 42 | 43 | #define compress_ctu_inter FPFX(compress_ctu_inter) 44 | rdcost_t compress_ctu_inter (xavs2_t *h, aec_t *p_aec, cu_t *p_cu, int i_level, int i_min_level, int i_max_level, rdcost_t cost_limit); 45 | #define compress_ctu_intra_topdown FPFX(compress_ctu_intra_topdown) 46 | rdcost_t compress_ctu_intra_topdown(xavs2_t *h, aec_t *p_aec, cu_t *p_cu, int i_level, int i_min_level, int i_max_level, rdcost_t cost_limit); 47 | #define compress_ctu_intra_downtop FPFX(compress_ctu_intra_downtop) 48 | rdcost_t compress_ctu_intra_downtop(xavs2_t *h, aec_t *p_aec, cu_t *p_cu, int i_level, int i_min_level, int i_max_level, rdcost_t cost_limit); 49 | 50 | typedef rdcost_t(*lcu_analyse_t)(xavs2_t *h, aec_t *p_aec, cu_t *p_cu, int i_level, int i_min_level, int i_max_level, rdcost_t cost_limit); 51 | 52 | #endif // XAVS2_RDO_H 53 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | #common settings that generally should always be used with your language specific settings 2 | 3 | # Auto detect text files and perform LF normalization 4 | # http://davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/ 5 | * text=auto 6 | 7 | # 8 | # The above will handle all files NOT found below 9 | # 10 | 11 | # Scripts 12 | *.bat text eol=crlf 13 | *.cmd text eol=crlf 14 | *.ps1 text eol=crlf 15 | *.sh text eol=lf 16 | 17 | # Documents 18 | *.doc diff=astextplain 19 | *.DOC diff=astextplain 20 | *.docx diff=astextplain 21 | *.DOCX diff=astextplain 22 | *.dot diff=astextplain 23 | *.DOT diff=astextplain 24 | *.ppt diff=astextplain 25 | *.PPT diff=astextplain 26 | *.pptx diff=astextplain 27 | *.PPTX diff=astextplain 28 | *.pdf diff=astextplain 29 | *.PDF diff=astextplain 30 | *.rtf diff=astextplain 31 | *.RTF diff=astextplain 32 | *.md text 33 | *.adoc text 34 | *.textile text 35 | *.mustache text 36 | *.csv text 37 | *.tab text 38 | *.tsv text 39 | *.sql text 40 | 41 | # Graphics 42 | *.png binary 43 | *.jpg binary 44 | *.jpeg binary 45 | *.gif binary 46 | *.tif binary 47 | *.tiff binary 48 | *.ico binary 49 | # SVG treated as an asset (binary) by default. If you want to treat it as text, 50 | # comment-out the following line and uncomment the line after. 51 | *.svg binary 52 | #*.svg text 53 | *.eps binary 54 | 55 | #sources 56 | *.c text eol=crlf 57 | *.cc text eol=crlf 58 | *.cxx text eol=crlf 59 | *.cpp text eol=crlf 60 | *.c++ text eol=crlf 61 | *.hpp text eol=crlf 62 | *.h text eol=crlf 63 | *.h++ text eol=crlf 64 | *.hh text eol=crlf 65 | *.asm text eol=crlf 66 | *.S text eol=crlf 67 | *.cfg text eol=crlf 68 | *.txt text eol=lf 69 | 70 | # QT Project files 71 | *.pro text eol=lf 72 | 73 | # Compiled Object files 74 | *.slo binary 75 | *.lo binary 76 | *.o binary 77 | *.obj binary 78 | 79 | # Precompiled Headers 80 | *.gch binary 81 | *.pch binary 82 | 83 | # Compiled Dynamic libraries 84 | *.so binary 85 | *.dylib binary 86 | *.dll binary 87 | 88 | # Compiled Static libraries 89 | *.lai binary 90 | *.la binary 91 | *.a binary 92 | *.lib binary 93 | 94 | # Executables 95 | *.exe binary 96 | *.out binary 97 | *.app binary 98 | 99 | # Custom for Visual Studio 100 | *.sln text eol=crlf 101 | *.csproj text eol=crlf 102 | *.vbproj text eol=crlf 103 | *.fsproj text eol=crlf 104 | *.dbproj text eol=crlf 105 | 106 | *.vcproj text eol=crlf 107 | *.vcxproj text eol=crlf 108 | *.sln text eol=crlf 109 | *.vcxitems text eol=crlf 110 | *.props text eol=crlf 111 | *.filters text eol=crlf 112 | -------------------------------------------------------------------------------- /source/encoder/tdrdo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tdrdo.h 3 | * 4 | * Description of this file: 5 | * TDRDO functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | 38 | #ifndef XAVS2_TDRDO_H 39 | #define XAVS2_TDRDO_H 40 | 41 | 42 | /** 43 | * =========================================================================== 44 | * function declares 45 | * =========================================================================== 46 | */ 47 | #define tdrdo_get_buffer_size FPFX(tdrdo_get_buffer_size) 48 | int tdrdo_get_buffer_size(xavs2_param_t *param); 49 | #define tdrdo_init FPFX(tdrdo_init) 50 | int tdrdo_init(td_rdo_t *td_rdo, xavs2_param_t *param); 51 | #define tdrdo_destroy FPFX(tdrdo_destroy) 52 | void tdrdo_destroy(td_rdo_t *td_rdo); 53 | 54 | #define tdrdo_frame_start FPFX(tdrdo_frame_start) 55 | void tdrdo_frame_start(xavs2_t *h); 56 | #define tdrdo_frame_done FPFX(tdrdo_frame_done) 57 | void tdrdo_frame_done(xavs2_t *h); 58 | #define tdrdo_lcu_adjust_lambda FPFX(tdrdo_lcu_adjust_lambda) 59 | void tdrdo_lcu_adjust_lambda(xavs2_t *h, rdcost_t *new_lambda); 60 | #define tdrdo_lcu_update FPFX(tdrdo_lcu_update) 61 | void tdrdo_lcu_update(xavs2_t *h); 62 | 63 | #endif // XAVS2_TDRDO_H 64 | -------------------------------------------------------------------------------- /source/common/common_arm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * common_arm.h 3 | * 4 | * Description of this file: 5 | * common tables definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | #ifndef COMMON_ARM_H_ 38 | #define COMMON_ARM_H_ 39 | 40 | #ifdef __ARM_ARCH_7A__ 41 | 42 | enum ARM_MC_PART { 43 | /*mc_copy idx*/ 44 | ARM_PART_2x4, ARM_PART_2x8, 45 | ARM_PART_4x2, ARM_PART_6x8, 46 | ARM_PART_8x2, ARM_PART_8x6 47 | }; 48 | 49 | enum ARM_PLANE_COPY_PART { 50 | /*plane_copy idx*/ 51 | ARM_PLANE_COPY_W88, ARM_PLANE_COPY_W160, 52 | ARM_PLANE_COPY_W176, ARM_PLANE_COPY_W320, 53 | ARM_PLANE_COPY_W352, ARM_PLANE_COPY_W360, 54 | ARM_PLANE_COPY_W512, ARM_PLANE_COPY_W640, 55 | ARM_PLANE_COPY_W704, ARM_PLANE_COPY_W720, 56 | ARM_PLANE_COPY_W960, ARM_PLANE_COPY_W1024, 57 | ARM_PLANE_COPY_W1280, ARM_PLANE_COPY_W1920 58 | }; 59 | extern const unsigned char g_arm_partition_map_tab[]; 60 | //Wxh= 2x4, 2x8, 6x8, 8x6 61 | #define ARM_MC_PART_INDEX(w, h) g_arm_partition_map_tab[(w + 1) * h] 62 | #define ARM_PLANE_COPY_INDEX(w) g_arm_partition_map_tab[(((w + 8) >> 4) - 5) >> 1] 63 | 64 | extern short dct4x4_const_table[64]; 65 | #endif /* __ARM_ARCH_7A__ */ 66 | 67 | #endif /* COMMON_ARM_H_ */ 68 | -------------------------------------------------------------------------------- /source/encoder/wquant.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wquant.h 3 | * 4 | * Description of this file: 5 | * Weighted Quant functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | 38 | #ifndef XAVS2_WQUANT_H 39 | #define XAVS2_WQUANT_H 40 | 41 | #if ENABLE_WQUANT 42 | 43 | #define PARAM_NUM 6 44 | #define WQ_MODEL_NUM 3 45 | #define SCENE_MODE_NUM 4 46 | 47 | #define UNDETAILED 0 48 | #define DETAILED 1 49 | 50 | #define WQ_MODE_F 0 51 | #define WQ_MODE_U 1 52 | #define WQ_MODE_D 2 53 | 54 | #define FRAME_WQ_DEFAULT 0 55 | #define USER_DEF_UNDETAILED 1 56 | #define USER_DEF_DETAILED 2 57 | 58 | 59 | /** 60 | * =========================================================================== 61 | * interface function declares 62 | * =========================================================================== 63 | */ 64 | 65 | #define xavs2_wq_init_seq_quant_param FPFX(wq_init_seq_quant_param) 66 | void xavs2_wq_init_seq_quant_param(xavs2_t *h); 67 | #define xavs2_wq_init_pic_quant_param FPFX(wq_init_pic_quant_param) 68 | void xavs2_wq_init_pic_quant_param(xavs2_t *h); 69 | #define xavs2_wq_update_pic_matrix FPFX(wq_update_pic_matrix) 70 | void xavs2_wq_update_pic_matrix(xavs2_t *h); 71 | 72 | extern const short tab_wq_param_default[2][6]; 73 | 74 | #endif 75 | 76 | #endif // XAVS2_WQUANT_H 77 | -------------------------------------------------------------------------------- /source/encoder/ratecontrol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ratecontrol.h 3 | * 4 | * Description of this file: 5 | * Ratecontrol functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | 38 | #ifndef XAVS2_RATECONTRAL_H 39 | #define XAVS2_RATECONTRAL_H 40 | 41 | #define xavs2_rc_get_buffer_size FPFX(rc_get_buffer_size) 42 | int xavs2_rc_get_buffer_size(xavs2_param_t *h); 43 | #define xavs2_rc_init FPFX(rc_init) 44 | int xavs2_rc_init(ratectrl_t *rc, xavs2_param_t *param); 45 | 46 | #define xavs2_rc_get_base_qp FPFX(rc_get_base_qp) 47 | int xavs2_rc_get_base_qp(xavs2_t *h); 48 | 49 | #define xavs2_rc_get_frame_qp FPFX(rc_get_frame_qp) 50 | int xavs2_rc_get_frame_qp(xavs2_t *h, int frm_idx, int frm_type, int force_qp); 51 | #define xavs2_rc_update_after_frame_coded FPFX(rc_update_after_frame_coded) 52 | void xavs2_rc_update_after_frame_coded(xavs2_t *h, int frm_bits, int frm_qp, int frm_type, int frm_idx); 53 | 54 | 55 | #if ENABLE_RATE_CONTROL_CU 56 | #define xavs2_rc_get_lcu_qp FPFX(rc_get_lcu_qp) 57 | int xavs2_rc_get_lcu_qp(xavs2_t *h, int frm_idx, int qp); 58 | 59 | #define xavs2_rc_update_after_lcu_coded FPFX(rc_update_after_lcu_coded) 60 | void xavs2_rc_update_after_lcu_coded(xavs2_t *h, int frm_idx, int qp); 61 | #endif // ENABLE_RATE_CONTROL_CU 62 | 63 | #define xavs2_rc_destroy FPFX(rc_destroy) 64 | void xavs2_rc_destroy(ratectrl_t *rc); 65 | 66 | #endif // XAVS2_RATECONTRAL_H 67 | -------------------------------------------------------------------------------- /source/encoder/rps.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rps.h 3 | * 4 | * Description of this file: 5 | * RPS functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | #ifndef XAVS2_RPS_H 38 | #define XAVS2_RPS_H 39 | 40 | // (1 - LDP, 2 - RA, 3 - RAP, 4 - AI) 41 | enum xavs2e_rps_cfg_e { 42 | XAVS2_RPS_CFG_LDP = 1, 43 | XAVS2_RPS_CFG_RA = 2, 44 | XAVS2_RPS_CFG_RAP = 3, 45 | XAVS2_RPS_CFG_AI = 4 46 | }; 47 | 48 | #define frame_buffer_get_free_frame_ipb FPFX(frame_buffer_get_free_frame_ipb) 49 | xavs2_frame_t *frame_buffer_get_free_frame_ipb(xavs2_handler_t *h_mgr); 50 | #define frame_buffer_update_remove_frames FPFX(frame_buffer_update_remove_frames) 51 | void frame_buffer_update_remove_frames(xavs2_frame_buffer_t *frm_buf, xavs2_frame_t *cur_frm); 52 | #define frame_buffer_remove_frames FPFX(frame_buffer_remove_frames) 53 | void frame_buffer_remove_frames(xavs2_frame_buffer_t *frm_buf); 54 | 55 | #define rps_build FPFX(rps_build) 56 | int rps_build(const xavs2_t *h, xavs2_frame_buffer_t *frm_buf, 57 | xavs2_frame_t *cur_frm, 58 | xavs2_rps_t *p_rps, xavs2_frame_t *frefs[XAVS2_MAX_REFS]); 59 | 60 | #define find_fdec_and_build_rps FPFX(find_fdec_and_build_rps) 61 | xavs2_frame_t *find_fdec_and_build_rps(xavs2_t *h, xavs2_frame_buffer_t *frm_buf, 62 | xavs2_frame_t *cur_frm, 63 | xavs2_frame_t *frefs[XAVS2_MAX_REFS]); 64 | 65 | 66 | #define rps_check_config FPFX(rps_check_config) 67 | int rps_check_config(xavs2_param_t *param); 68 | 69 | #define rps_set_picture_reorder_delay FPFX(rps_set_picture_reorder_delay) 70 | void rps_set_picture_reorder_delay(xavs2_t *h); 71 | 72 | #endif // XAVS2_RPS_H 73 | -------------------------------------------------------------------------------- /source/common/primitives.c: -------------------------------------------------------------------------------- 1 | /* 2 | * primitives.c 3 | * 4 | * Description of this file: 5 | * function handles initialize functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | #include "common.h" 38 | #include "primitives.h" 39 | #include "cpu.h" 40 | #include "intra.h" 41 | #include "mc.h" 42 | #include "transform.h" 43 | #include "filter.h" 44 | #include "sao.h" 45 | 46 | /* --------------------------------------------------------------------------- 47 | * global function handle 48 | */ 49 | intrinsic_func_t g_funcs; 50 | 51 | /* --------------------------------------------------------------------------- 52 | */ 53 | void xavs2_init_all_primitives(xavs2_param_t* param, intrinsic_func_t *p_funcs) 54 | { 55 | uint32_t cpuid = p_funcs->cpuid; 56 | 57 | if (param != NULL) { 58 | if (param->sample_bit_depth != g_bit_depth) { 59 | xavs2_log(NULL, XAVS2_LOG_ERROR, "init primitives error: only %d bit-depth is supported\n", g_bit_depth); 60 | } 61 | } 62 | 63 | /* init memory operation function handlers */ 64 | xavs2_mem_oper_init (cpuid, p_funcs); 65 | 66 | /* init function handles */ 67 | xavs2_intra_pred_init(cpuid, p_funcs); 68 | xavs2_mc_init (cpuid, p_funcs); 69 | xavs2_pixel_init (cpuid, &p_funcs->pixf); 70 | xavs2_deblock_init (cpuid, p_funcs); 71 | xavs2_dct_init (cpuid, &p_funcs->dctf); 72 | xavs2_quant_init (cpuid, &p_funcs->dctf); 73 | xavs2_cg_scan_init (cpuid, p_funcs); 74 | xavs2_mad_init (cpuid, p_funcs->pixf.madf); 75 | 76 | xavs2_sao_init (cpuid, p_funcs); 77 | xavs2_alf_init (cpuid, p_funcs); 78 | 79 | xavs2_rdo_init (cpuid, p_funcs); 80 | } 81 | -------------------------------------------------------------------------------- /README.zh.md: -------------------------------------------------------------------------------- 1 | # xavs2 2 | 3 | 遵循 `AVS2-P2/IEEE1857.4` 视频编码标准的编码器. 4 | 5 | 对应的解码器 **davs2** 可在 [Github][4] 或 [Gitee (mirror in China)][5] 上找到. 6 | 7 | [![GitHub tag](https://img.shields.io/github/tag/pkuvcl/xavs2.svg?style=plastic)]() 8 | [![GitHub issues](https://img.shields.io/github/issues/pkuvcl/xavs2.svg)](https://github.com/pkuvcl/xavs2/issues) 9 | [![GitHub forks](https://img.shields.io/github/forks/pkuvcl/xavs2.svg)](https://github.com/pkuvcl/xavs2/network) 10 | [![GitHub stars](https://img.shields.io/github/stars/pkuvcl/xavs2.svg)](https://github.com/pkuvcl/xavs2/stargazers) 11 | [![Travis Build Status](https://travis-ci.org/pkuvcl/xavs2.svg?branch=master)](https://travis-ci.org/pkuvcl/xavs2) 12 | [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/qysemawbynvhiktf?svg=true)](https://ci.appveyor.com/project/luofalei/xavs2/build/artifacts) 13 | 14 | ## 编译方法 15 | ### Windows 16 | 17 | 可使用`VS2013`打开解决方案`./build/win32/xavs2.sln`进行编译, 也可以使用更新的vs版本打开上述解决方案. 18 | 打开解决方案后, 将工程`xavs2`设置为启动项, 进行编译即可. 19 | 20 | #### 注意 21 | 1. 首次编译本项目时, 需要安装一个 `shell 执行器`, 比如 `git-for-windows` 中的 `bash`, 22 | 需要将该 `bash` 所在的目录添加到系统环境变量 `PATH` 中. 23 | 如上所述, 如果您以默认配置安装了`git-for-windows`, 24 | 那么将 `C:\Program Files\Git\bin` 添加到环境变量中即可. 25 | 2. 需将 `nasm.exe`放入到 `build/vs2013`目录, `nasm`版本号需为`2.13`或更新. 26 | 对于`windows`平台,可下载如下压缩包中,解压得到`nasm.exe`. 27 | https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/win64/nasm-2.14.02-win64.zip 28 | 29 | ### Linux 30 | 31 | 对于linux系统, 依次执行如下命令即可完成编译: 32 | ``` 33 | $ cd build/linux 34 | $ ./configure 35 | $ make 36 | ``` 37 | 38 | ## 运行和测试 39 | ``` 40 | ./xavs2 [-f encoder.cfg [-f seq.cfg]] [-p ParameterName=value] [--ParameterName=value] 41 | ``` 42 | 43 | ### 使用配置文件进行参数设置 44 | ``` 45 | ./xavs2 -f encoder.cfg -f seq4K.cfg -p InputFile=input.yuv -p FramesToBeEncoded=500 \ 46 | -p preset=0 -p recon=. -p initial_qp=32 -p OutputFile=test.avs 47 | ``` 48 | 49 | ### 不使用配置文件 50 | ``` 51 | ./xavs2 -p InputFile=input.yuv --FramesToBeEncoded=500 --fps=50 \ 52 | --SourceWidth=3840 --SourceHeight=2160 --InputSampleBitDepth=8 --SampleBitDepth=8 \ 53 | --thread_frames=1 --thread_rows=1 --preset=0 \ 54 | --recon=. --initial_qp=32 --OutputFile=test.avs 55 | ``` 56 | 57 | ## Issue & Pull Request 58 | 59 | 欢迎提交 issue,请写清楚遇到问题的环境与运行参数,包括操作系统环境、编译器环境等,重现的流程, 60 | 如果可能提供原始输入YUV/码流文件,请尽量提供以方便更快地重现结果。 61 | 62 | [反馈问题的 issue 请按照模板格式填写][6]。 63 | 64 | 如果有开发能力,建议在本地调试出错的代码,并[提供相应修正的 Pull Request][7]。 65 | 66 | ### 已知问题与工作清单 67 | 68 | - 高比特精度(10-bit)支持与其SIMD指令优化. 69 | 70 | - 码率控制. 71 | 72 | - 场景切换检测与自适应帧类型选择. 73 | 74 | - ARM平台的NEON指令优化. 75 | 76 | - 等等. 77 | 78 | ## 主页链接 79 | 80 | [北京大学-视频编码算法研究室(PKU-VCL)][1] 81 | 82 | `AVS2-P2/IEEE1857.4` 编码器: [xavs2 (Github)][2], [xavs2 (mirror in China)][3] 83 | 84 | `AVS2-P2/IEEE1857.4` 解码器: [davs2 (Github)][4], [davs2 (mirror in China)][5] 85 | 86 | [1]: http://vcl.idm.pku.edu.cn/ "PKU-VCL" 87 | [2]: https://github.com/pkuvcl/xavs2 "xavs2 github repository" 88 | [3]: https://gitee.com/pkuvcl/xavs2 "xavs2 gitee repository" 89 | [4]: https://github.com/pkuvcl/davs2 "davs2 decoder@github" 90 | [5]: https://gitee.com/pkuvcl/davs2 "davs2 decoder@gitee" 91 | [6]: https://github.com/pkuvcl/xavs2/issues "report issues" 92 | [7]: https://github.com/pkuvcl/xavs2/pulls "pull request" 93 | -------------------------------------------------------------------------------- /source/common/frame.h: -------------------------------------------------------------------------------- 1 | /* 2 | * frame.h 3 | * 4 | * Description of this file: 5 | * Frame handling functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | #ifndef XAVS2_FRAME_H 38 | #define XAVS2_FRAME_H 39 | 40 | 41 | /** 42 | * =========================================================================== 43 | * function declares 44 | * =========================================================================== 45 | */ 46 | 47 | #define xavs2_frame_new FPFX(frame_new) 48 | xavs2_frame_t *xavs2_frame_new(xavs2_t *h, uint8_t **mem_base, int alloc_type); 49 | #define xavs2_frame_delete FPFX(frame_delete) 50 | void xavs2_frame_delete(xavs2_handler_t *h_mgr, xavs2_frame_t *frame); 51 | 52 | #define xavs2_frame_buffer_size FPFX(frame_buffer_size) 53 | size_t xavs2_frame_buffer_size(const xavs2_param_t *param, int alloc_type); 54 | #define xavs2_frame_destroy_objects FPFX(frame_destroy_objects) 55 | void xavs2_frame_destroy_objects(xavs2_handler_t *h_mgr, xavs2_frame_t *frame); 56 | 57 | #define xavs2_frame_copy_planes FPFX(frame_copy_planes) 58 | void xavs2_frame_copy_planes(xavs2_t *h, xavs2_frame_t *dst, xavs2_frame_t *src); 59 | 60 | #define xavs2_frame_expand_border_frame FPFX(frame_expand_border_frame) 61 | void plane_expand_border(pel_t *p_pix, int i_stride, int i_width, int i_height, 62 | int i_padh, int i_padv, int b_pad_top, int b_pad_bottom); 63 | void xavs2_frame_expand_border_frame(xavs2_t *h, xavs2_frame_t *frame); 64 | #define xavs2_frame_expand_border_lcurow FPFX(frame_expand_border_lcurow) 65 | void xavs2_frame_expand_border_lcurow(xavs2_t *h, xavs2_frame_t *frame, int i_lcu_y); 66 | 67 | #define xavs2_frame_expand_border_mod8 FPFX(frame_expand_border_mod8) 68 | void xavs2_frame_expand_border_mod8(xavs2_t *h, xavs2_frame_t *frame); 69 | 70 | #endif /* XAVS2_FRAME_H */ 71 | -------------------------------------------------------------------------------- /source/common/x86/dct8.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2017 MulticoreWare, Inc 3 | * 4 | * Authors: Nabajit Deka 5 | ;* Min Chen 6 | * Jiaqi Zhang 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at license @ x265.com. 24 | *****************************************************************************/ 25 | 26 | 27 | #ifndef XAVS2_I386_DCT8_H 28 | #define XAVS2_I386_DCT8_H 29 | 30 | #define xavs2_dct_4x4_sse2 FPFX(dct_4x4_sse2) 31 | void xavs2_dct_4x4_sse2 (const coeff_t *src, coeff_t *dst, int i_src); 32 | #define xavs2_dct_4x4_avx2 FPFX(dct_4x4_avx2) 33 | void xavs2_dct_4x4_avx2 (const coeff_t *src, coeff_t *dst, int i_src); 34 | #define xavs2_dct_8x8_sse2 FPFX(dct_8x8_sse2) 35 | void xavs2_dct_8x8_sse2 (const coeff_t *src, coeff_t *dst, int i_src); 36 | #define xavs2_dct_8x8_sse4 FPFX(dct_8x8_sse4) 37 | void xavs2_dct_8x8_sse4 (const coeff_t *src, coeff_t *dst, int i_src); 38 | #if ARCH_X86_64 39 | #define xavs2_dct_8x8_avx2 FPFX(dct_8x8_avx2) 40 | void xavs2_dct_8x8_avx2 (const coeff_t *src, coeff_t *dst, int i_src); 41 | #define xavs2_dct_16x16_avx2 FPFX(dct_16x16_avx2) 42 | void xavs2_dct_16x16_avx2 (const coeff_t *src, coeff_t *dst, int i_src); 43 | #define xavs2_dct_32x32_avx2 FPFX(dct_32x32_avx2) 44 | void xavs2_dct_32x32_avx2 (const coeff_t *src, coeff_t *dst, int i_src); 45 | #endif 46 | 47 | #define xavs2_idct_4x4_sse2 FPFX(idct_4x4_sse2) 48 | void xavs2_idct_4x4_sse2 (const coeff_t *src, coeff_t *dst, int i_dst); 49 | #define xavs2_idct_8x8_ssse3 FPFX(idct_8x8_ssse3) 50 | void xavs2_idct_8x8_ssse3 (const coeff_t *src, coeff_t *dst, int i_dst); 51 | #if ARCH_X86_64 52 | #define xavs2_idct_4x4_avx2 FPFX(idct_4x4_avx2) 53 | void xavs2_idct_4x4_avx2 (const coeff_t *src, coeff_t *dst, int i_dst); 54 | #define xavs2_idct_8x8_sse2 FPFX(idct_8x8_sse2) 55 | void xavs2_idct_8x8_sse2 (const coeff_t *src, coeff_t *dst, int i_dst); 56 | #define xavs2_idct_8x8_avx2 FPFX(idct_8x8_avx2) 57 | void xavs2_idct_8x8_avx2 (const coeff_t *src, coeff_t *dst, int i_dst); 58 | #define xavs2_idct_16x16_avx2 FPFX(idct_16x16_avx2) 59 | void xavs2_idct_16x16_avx2(const coeff_t *src, coeff_t *dst, int i_dst); 60 | #define xavs2_idct_32x32_avx2 FPFX(idct_32x32_avx2) 61 | void xavs2_idct_32x32_avx2(const coeff_t *src, coeff_t *dst, int i_dst); 62 | #endif 63 | 64 | #endif // ifndef XAVS2_I386_DCT8_H 65 | -------------------------------------------------------------------------------- /source/configw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * configw.h 3 | * 4 | * Description of this file: 5 | * compiling configuration for windows platform 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | #ifndef XAVS2_CONFIGW_H 38 | #define XAVS2_CONFIGW_H 39 | 40 | #if defined(__ICL) || defined(_MSC_VER) 41 | 42 | /* arch */ 43 | #define ARCH_X86 1 44 | #define ARCH_PPC 0 45 | #define ARCH_ARM 0 46 | #define ARCH_UltraSPARC 0 47 | 48 | /* system */ 49 | #define SYS_WINDOWS 1 50 | #define SYS_LINUX 0 51 | #define SYS_MACOSX 0 52 | #define SYS_BEOS 0 53 | #define SYS_FREEBSD 0 54 | #define SYS_OPENBSD 0 55 | 56 | /* cpu */ 57 | #ifndef __SSE__ 58 | #define __SSE__ 59 | #endif 60 | #define HAVE_MMX 1 /* X86 */ 61 | #define HAVE_ALTIVEC 0 /* ALTIVEC */ 62 | #define HAVE_ALTIVEC_H 0 63 | #define HAVE_ARMV6 0 64 | #define HAVE_ARMV6T2 0 65 | 66 | /* thread */ 67 | #define HAVE_THREAD 1 68 | #define HAVE_WIN32THREAD 1 69 | #define HAVE_PTHREAD 0 70 | #define HAVE_BEOSTHREAD 0 71 | #define HAVE_POSIXTHREAD 0 72 | #define PTW32_STATIC_LIB 0 73 | 74 | /* interlace support */ 75 | #define HAVE_INTERLACED 1 76 | 77 | /* malloc */ 78 | #define HAVE_MALLOC_H 0 79 | 80 | /* big-endian */ 81 | #define WORDS_BIGENDIAN 0 82 | 83 | /* others */ 84 | #define HAVE_STDINT_H 1 85 | #define HAVE_VECTOREXT 0 86 | #define HAVE_LOG2F 0 87 | #define HAVE_SWSCALE 0 88 | #define HAVE_LAVF 0 89 | #define HAVE_FFMS 0 90 | #define HAVE_GPAC 0 91 | #define HAVE_GF_MALLOC 0 92 | #define HAVE_AVS 0 93 | 94 | #endif 95 | #endif // XAVS2_CONFIGW_H 96 | -------------------------------------------------------------------------------- /source/common/filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * filter.h 3 | * 4 | * Description of this file: 5 | * Filter functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | 38 | #ifndef XAVS2_IN_LOOP_FILTERS_H 39 | #define XAVS2_IN_LOOP_FILTERS_H 40 | 41 | /** 42 | * =========================================================================== 43 | * global/local variables 44 | * =========================================================================== 45 | */ 46 | 47 | static const int tab_saoclip[NUM_SAO_OFFSET][3] = { 48 | // EO 49 | { -1, 6, 7 }, // low bound, upper bound, threshold 50 | { 0, 1, 1 }, 51 | { 0, 0, 0 }, 52 | { -1, 0, 1 }, 53 | { -6, 1, 7 }, 54 | { -7, 7, 7 } // BO 55 | }; 56 | /* --------------------------------------------------------------------------- 57 | * lcu neighbor 58 | */ 59 | enum lcu_neighbor_e { 60 | SAO_T = 0, /* top */ 61 | SAO_D = 1, /* down */ 62 | SAO_L = 2, /* left */ 63 | SAO_R = 3, /* right */ 64 | SAO_TL = 4, /* top-left */ 65 | SAO_TR = 5, /* top-right */ 66 | SAO_DL = 6, /* down-left */ 67 | SAO_DR = 7 /* down-right */ 68 | }; 69 | 70 | typedef struct sao_region_t { 71 | int pix_x[NUM_SAO_COMPONENTS]; /* start pixel position in x */ 72 | int pix_y[NUM_SAO_COMPONENTS]; /* start pixel position in y */ 73 | int width[NUM_SAO_COMPONENTS]; /* */ 74 | int height[NUM_SAO_COMPONENTS]; /* */ 75 | 76 | /* availabilities of neighboring blocks */ 77 | int8_t b_left; 78 | int8_t b_top_left; 79 | int8_t b_top; 80 | int8_t b_top_right; 81 | int8_t b_right; 82 | int8_t b_right_down; 83 | int8_t b_down; 84 | int8_t b_down_left; 85 | } sao_region_t; 86 | 87 | #define xavs2_lcu_deblock FPFX(lcu_deblock) 88 | void xavs2_lcu_deblock(xavs2_t *h, xavs2_frame_t *frm); 89 | 90 | #endif // XAVS2_IN_LOOP_FILTERS_H 91 | -------------------------------------------------------------------------------- /source/encoder/xlist.h: -------------------------------------------------------------------------------- 1 | /* 2 | * xlist.h 3 | * 4 | * Description of this file: 5 | * list structure with multi-thread support of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | #ifndef XAVS2_XLIST_H 38 | #define XAVS2_XLIST_H 39 | 40 | 41 | /** 42 | * =========================================================================== 43 | * type defines 44 | * =========================================================================== 45 | */ 46 | 47 | /* --------------------------------------------------------------------------- 48 | * node 49 | */ 50 | typedef struct node_t node_t; 51 | struct node_t { 52 | node_t *next; /* pointer to next node */ 53 | }; 54 | 55 | /* --------------------------------------------------------------------------- 56 | * xlist_t 57 | */ 58 | typedef struct xlist_t { 59 | node_t *p_list_head; /* pointer to head of node list */ 60 | node_t *p_list_tail; /* pointer to tail of node list */ 61 | xavs2_thread_cond_t list_cond; /* list condition variable */ 62 | xavs2_thread_mutex_t list_mutex; /* list mutex lock */ 63 | int i_node_num; /* node number in the list */ 64 | } xlist_t; 65 | 66 | 67 | /** 68 | * =========================================================================== 69 | * interface function declares 70 | * =========================================================================== 71 | */ 72 | 73 | /* --------------------------------------------------------------------------- 74 | * xlist 75 | */ 76 | #define xl_init FPFX(xl_init) 77 | int xl_init(xlist_t *const xlist); 78 | #define xl_destroy FPFX(xl_destroy) 79 | void xl_destroy(xlist_t *const xlist); 80 | #define xl_append FPFX(xl_append) 81 | void xl_append(xlist_t *const xlist, void *node); 82 | #define xl_remove_head FPFX(xl_remove_head) 83 | void *xl_remove_head(xlist_t *const xlist, const int wait); 84 | 85 | #endif // XAVS2_XLIST_H 86 | -------------------------------------------------------------------------------- /source/common/x86/mc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2013-2017 MulticoreWare, Inc 3 | * 4 | * Authors: Steve Borho 5 | * Jiaqi Zhang 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 20 | * 21 | * This program is also available under a commercial proprietary license. 22 | * For more information, contact us at license @ x265.com. 23 | *****************************************************************************/ 24 | 25 | #ifndef XAVS2_I386_MC_H 26 | #define XAVS2_I386_MC_H 27 | 28 | #define xavs2_plane_copy_core_mmx2 FPFX(plane_copy_core_mmx2) 29 | void xavs2_plane_copy_core_mmx2(pel_t *dst, intptr_t i_dst, pel_t *src, intptr_t i_src, int w, int h); 30 | #define xavs2_plane_copy_deinterleave_mmx FPFX(plane_copy_deinterleave_mmx) 31 | void xavs2_plane_copy_deinterleave_mmx(pel_t *dstu, intptr_t i_dstu, pel_t *dstv, intptr_t i_dstv, pel_t *src, intptr_t i_src, int w, int h); 32 | 33 | #define xavs2_memcpy_aligned_mmx FPFX(memcpy_aligned_mmx) 34 | void *xavs2_memcpy_aligned_mmx(void *dst, const void *src, size_t n); 35 | #define xavs2_memcpy_aligned_sse FPFX(memcpy_aligned_sse) 36 | void *xavs2_memcpy_aligned_sse(void *dst, const void *src, size_t n); 37 | 38 | #define xavs2_fast_memcpy_mmx FPFX(fast_memcpy_mmx) 39 | void *xavs2_fast_memcpy_mmx (void *dst, const void *src, size_t n); 40 | 41 | #define xavs2_fast_memset_mmx FPFX(fast_memset_mmx) 42 | void *xavs2_fast_memset_mmx (void *dst, int val, size_t n); 43 | 44 | #define xavs2_memzero_aligned_mmx FPFX(memzero_aligned_mmx) 45 | void *xavs2_memzero_aligned_mmx(void *dst, size_t n); 46 | #define xavs2_memzero_aligned_sse FPFX(memzero_aligned_sse) 47 | void *xavs2_memzero_aligned_sse(void *dst, size_t n); 48 | #define xavs2_memzero_aligned_avx FPFX(memzero_aligned_avx) 49 | void *xavs2_memzero_aligned_avx(void *dst, size_t n); 50 | 51 | #define xavs2_fast_memzero_mmx FPFX(fast_memzero_mmx) 52 | void *xavs2_fast_memzero_mmx (void *dst, size_t n); 53 | 54 | #define xavs2_lowres_filter_core_mmx2 FPFX(lowres_filter_core_mmx2) 55 | void xavs2_lowres_filter_core_mmx2 (pel_t *src, int i_src, pel_t *dst, int i_dst, int width, int height); 56 | #define xavs2_lowres_filter_core_sse2 FPFX(lowres_filter_core_sse2) 57 | void xavs2_lowres_filter_core_sse2 (pel_t *src, int i_src, pel_t *dst, int i_dst, int width, int height); 58 | #define xavs2_lowres_filter_core_ssse3 FPFX(lowres_filter_core_ssse3) 59 | void xavs2_lowres_filter_core_ssse3(pel_t *src, int i_src, pel_t *dst, int i_dst, int width, int height); 60 | #define xavs2_lowres_filter_core_avx FPFX(lowres_filter_core_avx) 61 | void xavs2_lowres_filter_core_avx (pel_t *src, int i_src, pel_t *dst, int i_dst, int width, int height); 62 | 63 | #endif // XAVS2_I386_MC_H 64 | -------------------------------------------------------------------------------- /source/encoder/encoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * encoder.h 3 | * 4 | * Description of this file: 5 | * Encoder functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | #ifndef XAVS2_ENCODER_H 38 | #define XAVS2_ENCODER_H 39 | 40 | /** 41 | * =========================================================================== 42 | * interface function defines (pre-encode processing) 43 | * =========================================================================== 44 | */ 45 | 46 | int send_frame_to_enc_queue(xavs2_handler_t *h_mgr, xavs2_frame_t *frm); 47 | 48 | void xavs2e_get_frame_lambda(xavs2_t *h, xavs2_frame_t *cur_frm, int i_qp); 49 | 50 | /** 51 | * =========================================================================== 52 | * interface function defines (encode processing) 53 | * =========================================================================== 54 | */ 55 | 56 | int encoder_check_parameters(xavs2_param_t *param); 57 | 58 | xavs2_t *encoder_open (xavs2_param_t *param, xavs2_handler_t *h_mgr); 59 | int encoder_encode(xavs2_handler_t *h_mgr, xavs2_frame_t *frame); 60 | void encoder_close (xavs2_handler_t *h_mgr); 61 | 62 | int encoder_contexts_init(xavs2_t *h, xavs2_handler_t *h_mgr); 63 | void dump_yuv_out(xavs2_t *h, FILE *fp, xavs2_frame_t *frame, int img_w, int img_h); 64 | void encoder_fetch_one_encoded_frame(xavs2_handler_t *h_mgr, xavs2_outpacket_t *packet, int is_flush); 65 | 66 | void xavs2_reconfigure_encoder(xavs2_t *h); 67 | 68 | #if XAVS2_STAT 69 | /** 70 | * =========================================================================== 71 | * interface function defines (encode report) 72 | * =========================================================================== 73 | */ 74 | void encoder_show_head_info(xavs2_param_t *param); 75 | void encoder_show_frame_info_tab(xavs2_t *h, xavs2_handler_t *mgr); 76 | 77 | void encoder_cal_psnr(xavs2_t *h, double *psnr_y, double *psnr_u, double *psnr_v); 78 | void encoder_cal_ssim(xavs2_t *h, double *ssim_y, double *ssim_u, double *ssim_v); 79 | 80 | void encoder_report_one_frame(xavs2_t *h, outputframe_t *frame); 81 | 82 | void encoder_report_stat_info(xavs2_t *h); 83 | #endif 84 | 85 | #endif // XAVS2_ENCODER_H 86 | -------------------------------------------------------------------------------- /version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # ============================================================================ 4 | # File: 5 | # version.sh 6 | # - get version of repository and generate the file version.h 7 | # Author: 8 | # Falei LUO 9 | # ============================================================================ 10 | 11 | # setting API version 12 | api="$(grep '#define XAVS2_BUILD' < source/xavs2.h | sed 's/^.* \([1-9][0-9]*\).*$/\1/')" 13 | VER_R=0 14 | VER_SHA='not-in-git-tree' 15 | 16 | # get version of remote origin/master and local HEAD 17 | if [ -d .git ] && command -v git >/dev/null 2>&1 ; then 18 | VER_R=`git rev-list --count origin/master` 19 | VER_SHA=`git rev-parse HEAD | cut -c -16` 20 | fi 21 | 22 | # generate version numbers 23 | VER_MAJOR=`echo $(($api / 10))` 24 | VER_MINOR=`echo $(($api % 10))` 25 | 26 | # date and time information 27 | BUILD_TIME=`date "+%Y-%m-%d %H:%M:%S"` 28 | 29 | # generate the file version.h 30 | echo "// ===========================================================================" > version.h 31 | echo "// version.h" >> version.h 32 | echo "// - collection of version numbers" >> version.h 33 | echo "//" >> version.h 34 | echo "// Author: Falei LUO " >> version.h 35 | echo "//" >> version.h 36 | echo "// ===========================================================================" >> version.h 37 | echo "" >> version.h 38 | echo "#ifndef XAVS2_VERSION_H" >> version.h 39 | echo "#define XAVS2_VERSION_H" >> version.h 40 | echo "" >> version.h 41 | echo "// version number" >> version.h 42 | echo "#define VER_MAJOR $VER_MAJOR // major version number" >> version.h 43 | echo "#define VER_MINOR $VER_MINOR // minor version number" >> version.h 44 | echo "#define VER_BUILD $VER_R // build number" >> version.h 45 | echo "#define VER_SHA_STR \"$VER_SHA\" // commit id" >> version.h 46 | echo "" >> version.h 47 | echo "// stringify" >> version.h 48 | echo "#define _TOSTR(x) #x // stringify x" >> version.h 49 | echo "#define TOSTR(x) _TOSTR(x) // stringify x, perform macro expansion" >> version.h 50 | echo "" >> version.h 51 | echo "// define XVERSION string" >> version.h 52 | echo "#define XVERSION VER_MAJOR, VER_MINOR, VER_BUILD" >> version.h 53 | echo "#define XVERSION_STR TOSTR(VER_MAJOR) \".\" TOSTR(VER_MINOR) \".\" TOSTR(VER_BUILD) \" \" VER_SHA_STR" >> version.h 54 | echo "#define XBUILD_TIME \"$BUILD_TIME\"" >> version.h 55 | echo "" >> version.h 56 | echo "#endif // __VERSION_H__" >> version.h 57 | 58 | mv version.h source/version.h 59 | 60 | # show version informations 61 | echo "#define XAVS2_VERSION $api" 62 | echo "#define XAVS2_POINTVER \"$VER_MAJOR.$VER_MINOR.$VER_R\"" 63 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # xavs2 2 | 3 | **xavs2** is an open-source encoder of `AVS2-P2/IEEE1857.4` video coding standard. 4 | 5 | A decoder, **davs2**, can be found at [Github][4] or [Gitee (mirror in China)][5]. 6 | 7 | [![GitHub tag](https://img.shields.io/github/tag/pkuvcl/xavs2.svg?style=plastic)]() 8 | [![GitHub issues](https://img.shields.io/github/issues/pkuvcl/xavs2.svg)](https://github.com/pkuvcl/xavs2/issues) 9 | [![GitHub forks](https://img.shields.io/github/forks/pkuvcl/xavs2.svg)](https://github.com/pkuvcl/xavs2/network) 10 | [![GitHub stars](https://img.shields.io/github/stars/pkuvcl/xavs2.svg)](https://github.com/pkuvcl/xavs2/stargazers) 11 | [![Travis Build Status](https://travis-ci.org/pkuvcl/xavs2.svg?branch=master)](https://travis-ci.org/pkuvcl/xavs2) 12 | [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/qysemawbynvhiktf?svg=true)](https://ci.appveyor.com/project/luofalei/xavs2/build/artifacts) 13 | 14 | ## Build it 15 | ### Windows 16 | Use `VS2013` or later version of visual studio to open the solution file `./build/vs2013/xavs2.sln`, 17 | then set the `xavs2` as the start project and build it. 18 | 19 | #### Notes 20 | 1. A `shell executor`, i.e. the bash in git for windows, is needed and should be found in `PATH` variable. 21 | For example, the path `C:\Program Files\Git\bin` can be added if git-for-windows is installed. 22 | 2. `nasm.exe` with version `2.13` (or later version) is needed and should be put into the `build/vs2013` directory. 23 | For windows platform, you can downloaded the packege and unpack the zip file to get `nasm.exe`: 24 | https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/win64/nasm-2.14.02-win64.zip 25 | 26 | 27 | ### Linux 28 | ``` 29 | $ cd build/linux 30 | $ ./configure 31 | $ make 32 | ``` 33 | 34 | ## Try it 35 | ``` 36 | ./xavs2 [-f encoder.cfg [-f seq.cfg]] [-p ParameterName=value] [--ParameterName=value] 37 | ``` 38 | 39 | ### Encode with configuration files 40 | ``` 41 | ./xavs2 -f encoder.cfg -f seq4K.cfg -p InputFile=input.yuv -p FramesToBeEncoded=500 \ 42 | -p preset=0 -p recon=. -p initial_qp=32 -p OutputFile=test.avs 43 | ``` 44 | 45 | ### Enocde without configuraton files 46 | ``` 47 | ./xavs2 -p InputFile=input.yuv --FramesToBeEncoded=500 --fps=50 \ 48 | --SourceWidth=3840 --SourceHeight=2160 --InputSampleBitDepth=8 --SampleBitDepth=8 \ 49 | --thread_frames=1 --thread_rows=1 --preset=0 \ 50 | --recon=. --initial_qp=32 --OutputFile=test.avs 51 | ``` 52 | 53 | ## How to Report Bugs and Provide Feedback 54 | 55 | Use the ["Issues" tab on Github][6]. 56 | 57 | ## How to Contribute 58 | 59 | We welcome community contributions to this project. Thank you for your time! By contributing to the project, you agree to the license and copyright terms therein and to the release of your contribution under these terms. 60 | 61 | If you have some bugs or features fixed, and would like to share with the public, please [make a Pull Request][7]. 62 | 63 | ### Contribution process 64 | 65 | - Validate that your changes do not break a build 66 | 67 | - Perform smoke tests and ensure they pass 68 | 69 | - Submit a pull request for review to the maintainer 70 | 71 | ### Known workitems or bugs 72 | 73 | - high bit-depth (i.e. 10-bit) support and SIMD optimization. 74 | 75 | - Rate-control in CBR, VBR. 76 | 77 | - Adaptive scene change detection and frame type decision. 78 | 79 | - NEON support for ARM platform. 80 | 81 | - and so on. 82 | 83 | ## Homepages 84 | 85 | [PKU-VCL][1] 86 | 87 | `AVS2-P2/IEEE1857.4` Encoder: [xavs2 (Github)][2], [xavs2 (mirror in China)][3] 88 | 89 | `AVS2-P2/IEEE1857.4` Decoder: [davs2 (Github)][4], [davs2 (mirror in China)][5] 90 | 91 | [1]: http://vcl.idm.pku.edu.cn/ "PKU-VCL" 92 | [2]: https://github.com/pkuvcl/xavs2 "xavs2 github repository" 93 | [3]: https://gitee.com/pkuvcl/xavs2 "xavs2 gitee repository" 94 | [4]: https://github.com/pkuvcl/davs2 "davs2 decoder@github" 95 | [5]: https://gitee.com/pkuvcl/davs2 "davs2 decoder@gitee" 96 | [6]: https://github.com/pkuvcl/xavs2/issues "report issues" 97 | [7]: https://github.com/pkuvcl/xavs2/pulls "pull request" 98 | -------------------------------------------------------------------------------- /source/common/intra.h: -------------------------------------------------------------------------------- 1 | /* 2 | * intra.h 3 | * 4 | * Description of this file: 5 | * Intra prediction functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | #ifndef XAVS2_INTRA_H 38 | #define XAVS2_INTRA_H 39 | 40 | typedef struct intra_candidate_t intra_candidate_t; 41 | 42 | #define xavs2_intra_get_cu_neighbors FPFX(intra_get_cu_neighbors) 43 | uint32_t xavs2_intra_get_cu_neighbors(xavs2_t *h, cu_t *p_cu, int img_x, int img_y, int cu_size); 44 | 45 | #define xavs2_intra_fill_ref_samples_luma FPFX(intra_fill_ref_samples_luma) 46 | void xavs2_intra_fill_ref_samples_luma(xavs2_t *h, cu_t *p_cu, int img_x, int img_y, 47 | int block_x, int block_y, int bsx, int bsy); 48 | 49 | #define rdo_get_pred_intra_luma FPFX(rdo_get_pred_intra_luma) 50 | int rdo_get_pred_intra_luma(xavs2_t *h, cu_t *p_cu, intra_candidate_t *p_candidates, 51 | pel_t *p_fenc, int mpm[], int blockidx, 52 | int block_x, int block_y, int block_w, int block_h); 53 | 54 | #define rdo_get_pred_intra_luma_rmd FPFX(rdo_get_pred_intra_luma_rmd) 55 | int rdo_get_pred_intra_luma_rmd(xavs2_t *h, cu_t *p_cu, intra_candidate_t *p_candidates, 56 | pel_t *p_fenc, int mpm[], int blockidx, 57 | int block_x, int block_y, int block_w, int block_h); 58 | 59 | #define rdo_get_pred_intra_luma_cuda FPFX(rdo_get_pred_intra_luma_cuda) 60 | int rdo_get_pred_intra_luma_cuda(xavs2_t *h, cu_t *p_cu, intra_candidate_t *p_candidates, 61 | pel_t *p_fenc, int mpm[], int blockidx, 62 | int block_x, int block_y, int block_w, int block_h); 63 | 64 | #define rdo_get_pred_intra_luma_2nd_pass FPFX(rdo_get_pred_intra_luma_2nd_pass) 65 | int rdo_get_pred_intra_luma_2nd_pass(xavs2_t *h, cu_t *p_cu, intra_candidate_t *p_candidates, 66 | pel_t *p_fenc, int mpm[], int blockidx, 67 | int block_x, int block_y, int block_w, int block_h); 68 | 69 | #define rdo_get_pred_intra_chroma FPFX(rdo_get_pred_intra_chroma) 70 | int rdo_get_pred_intra_chroma(xavs2_t *h, cu_t *p_cu, int i_level, int pix_y_c, int pix_x_c, 71 | intra_candidate_t *p_candidate_list); 72 | 73 | #define rdo_get_pred_intra_chroma_fast FPFX(rdo_get_pred_intra_chroma_fast) 74 | int rdo_get_pred_intra_chroma_fast(xavs2_t *h, cu_t *p_cu, int i_level, int pix_y_c, int pix_x_c, 75 | intra_candidate_t *p_candidate_list); 76 | 77 | #endif // XAVS2_INTRA_H 78 | -------------------------------------------------------------------------------- /source/common/basic_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * basic_types.h 3 | * 4 | * Description of this file: 5 | * basic types definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | 38 | #ifndef XAVS2_BASIC_TYPES_H 39 | #define XAVS2_BASIC_TYPES_H 40 | 41 | #include 42 | #include "defines.h" 43 | #include "osdep.h" 44 | 45 | /* 46 | * =========================================================================== 47 | * basic types 48 | * =========================================================================== 49 | */ 50 | typedef uint8_t pel_t; /* type for pixel */ 51 | typedef int16_t itr_t; /* intra prediction temp */ 52 | typedef uint16_t sum_t; 53 | typedef uint32_t sum2_t; 54 | typedef uint32_t pixel4; 55 | typedef int32_t ssum2_t; /* Signed sum */ 56 | typedef int32_t dist_t; 57 | 58 | typedef int8_t bool_t; /* Bool type, true or false */ 59 | typedef int16_t mct_t; /* motion compensation temp */ 60 | typedef int16_t coeff_t; /* type for transform coefficient */ 61 | typedef int32_t cmp_dist_t; /* distortion type */ 62 | typedef double rdcost_t; /* type for RDcost calculation, can also be int64_t */ 63 | 64 | /* 65 | * =========================================================================== 66 | * structure types 67 | * =========================================================================== 68 | */ 69 | typedef struct xavs2_handler_t xavs2_handler_t; /* top handler of the encoder */ 70 | typedef struct xavs2_log_t xavs2_log_t; /* log module */ 71 | typedef struct xavs2_t xavs2_t; /* main encoder context for one thread */ 72 | typedef struct xavs2_frame_t xavs2_frame_t; 73 | typedef struct xavs2_frame_buffer_t xavs2_frame_buffer_t; 74 | typedef struct ratectrl_t ratectrl_t; 75 | typedef struct cu_size_ctrl_t cu_size_ctrl_t; 76 | typedef struct td_rdo_t td_rdo_t; 77 | typedef struct aec_t aec_t; 78 | typedef struct cu_t cu_t; 79 | typedef union mv_t mv_t; 80 | typedef struct cu_info_t cu_info_t; 81 | 82 | typedef struct outputframe_t outputframe_t; 83 | 84 | 85 | /* --------------------------------------------------------------------------- 86 | * SAOStatData 87 | */ 88 | typedef struct SAOBlkParam { 89 | int mergeIdx; // 0: merge_left, 1: merge_up, 2 not merge (new parameter) 90 | int typeIdc; // OFF(-1), EO_0, EO_90, EO_135, EO_45, BO 91 | int startBand; // BO: starting band index 92 | int deltaBand; // BO: third starting band distance 93 | int offset[MAX_NUM_SAO_CLASSES]; 94 | } SAOBlkParam; 95 | 96 | 97 | #endif // XAVS2_BASIC_TYPES_H 98 | -------------------------------------------------------------------------------- /source/common/vec/intrinsic_cg_scan_avx.c: -------------------------------------------------------------------------------- 1 | /* 2 | * intrinsic_cg_scan_avx.c 3 | * 4 | * Description of this file: 5 | * AVX2 assembly functions of CG-Scanning module of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * Jiaqi ZHANG 14 | * etc. 15 | * 16 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 17 | * Homepage2: https://github.com/pkuvcl/xavs2 18 | * Homepage3: https://gitee.com/pkuvcl/xavs2 19 | * 20 | * This program is free software; you can redistribute it and/or modify 21 | * it under the terms of the GNU General Public License as published by 22 | * the Free Software Foundation; either version 2 of the License, or 23 | * (at your option) any later version. 24 | * 25 | * This program is distributed in the hope that it will be useful, 26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 | * GNU General Public License for more details. 29 | * 30 | * You should have received a copy of the GNU General Public License 31 | * along with this program; if not, write to the Free Software 32 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 33 | * 34 | * This program is also available under a commercial proprietary license. 35 | * For more information, contact us at sswang @ pku.edu.cn. 36 | */ 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | #include "../common.h" 45 | #include "intrinsic.h" 46 | 47 | #if ARCH_X86_64 48 | /* --------------------------------------------------------------------------- 49 | */ 50 | void coeff_scan4_xy_avx(coeff_t *dst, uint64_t r1, uint64_t r2, uint64_t r3, uint64_t r4) 51 | { 52 | __m256i order1; 53 | __m256i m_in; 54 | int16_t int1, int2; 55 | 56 | order1 = _mm256_setr_epi16(0x0100, 0x0302, 0x0908, 0x0F0E, 0x0B0A, 0x0504, 0x0706, 0x0D0C, 57 | 0x0302, 0x0908, 0x0B0A, 0x0504, 0x0100, 0x0706, 0x0D0C, 0x0F0E); 58 | 59 | m_in = _mm256_setr_epi64x(r1, r2, r3, r4); // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 60 | 61 | int1 = _mm256_extract_epi16(m_in, 7); 62 | int2 = _mm256_extract_epi16(m_in, 8); 63 | 64 | _mm256_insert_epi16(m_in, int2, 7); //0 1 2 3 4 5 6 8 65 | _mm256_insert_epi16(m_in, int1, 8); //7 9 10 11 12 13 14 15 66 | 67 | //0 1 2 3 4 5 6 8 --------> 0 1 4 8 5 2 3 6 68 | //7 9 10 11 12 13 14 15 --------> 9 12 13 10 7 11 14 15 69 | m_in = _mm256_shuffle_epi8(m_in, order1); 70 | 71 | _mm256_storeu_si256((__m256i*)dst, m_in); 72 | } 73 | 74 | /* --------------------------------------------------------------------------- 75 | */ 76 | void coeff_scan4_yx_avx(coeff_t *dst, uint64_t r1, uint64_t r2, uint64_t r3, uint64_t r4) 77 | { 78 | __m256i order1; 79 | __m256i m_in; 80 | int32_t int1, int2; 81 | 82 | order1 = _mm256_setr_epi16(0x0100, 0x0908, 0x0302, 0x0504, 0x0B0A, 0x0D0C, 0x0706, 0x0F0E, 83 | 0x0100, 0x0908, 0x0302, 0x0504, 0x0B0A, 0x0D0C, 0x0706, 0x0F0E); 84 | 85 | m_in = _mm256_setr_epi64x(r1, r2, r3, r4); // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 86 | 87 | int1 = _mm256_extract_epi32(m_in, 3); 88 | int2 = _mm256_extract_epi32(m_in, 4); 89 | 90 | _mm256_insert_epi32(m_in, int2, 3); //0 1 2 3 4 5 8 9 91 | _mm256_insert_epi32(m_in, int1, 4); //6 7 10 11 12 13 14 15 92 | 93 | int1 = _mm256_extract_epi16(m_in, 3); 94 | int2 = _mm256_extract_epi16(m_in, 12); 95 | 96 | _mm256_insert_epi16(m_in, (int16_t)int2, 3); //0 1 2 12 4 5 8 9 97 | _mm256_insert_epi16(m_in, (int16_t)int1, 12); //6 7 10 11 3 13 14 15 98 | 99 | //0 1 2 12 4 5 8 9 --------> 0 4 1 2 5 8 12 9 100 | //6 7 10 11 3 13 14 15 --------> 6 3 7 10 13 14 11 15 101 | m_in= _mm256_shuffle_epi8(m_in, order1); 102 | 103 | _mm256_storeu_si256((__m256i*)dst, m_in); 104 | } 105 | #endif // ARCH_X86_64 106 | -------------------------------------------------------------------------------- /source/common/vec/intrinsic_pixel.c: -------------------------------------------------------------------------------- 1 | /* 2 | * intrinsic_pixel.c 3 | * 4 | * Description of this file: 5 | * SSE assembly functions of Pixel-Processing module of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | #include "../basic_types.h" 38 | #include "intrinsic.h" 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | 46 | void xavs2_pixel_average_sse128(pel_t *dst, int i_dst, pel_t *src1, int i_src1, pel_t *src2, int i_src2, int width, int height) 47 | { 48 | int i, j; 49 | __m128i S1, S2, D; 50 | 51 | if (width & 15) { 52 | __m128i mask = _mm_load_si128((const __m128i*)intrinsic_mask[(width & 15) - 1]); 53 | 54 | for (i = 0; i < height; i++) { 55 | for (j = 0; j < width - 15; j += 16) { 56 | S1 = _mm_loadu_si128((const __m128i*)(src1 + j)); 57 | S2 = _mm_loadu_si128((const __m128i*)(src2 + j)); 58 | D = _mm_avg_epu8(S1, S2); 59 | _mm_storeu_si128((__m128i*)(dst + j), D); 60 | } 61 | 62 | S1 = _mm_loadu_si128((const __m128i*)(src1 + j)); 63 | S2 = _mm_loadu_si128((const __m128i*)(src2 + j)); 64 | D = _mm_avg_epu8(S1, S2); 65 | _mm_maskmoveu_si128(D, mask, (char*)&dst[j]); 66 | 67 | src1 += i_src1; 68 | src2 += i_src2; 69 | dst += i_dst; 70 | } 71 | } else { 72 | for (i = 0; i < height; i++) { 73 | for (j = 0; j < width; j += 16) { 74 | S1 = _mm_loadu_si128((const __m128i*)(src1 + j)); 75 | S2 = _mm_loadu_si128((const __m128i*)(src2 + j)); 76 | D = _mm_avg_epu8(S1, S2); 77 | _mm_storeu_si128((__m128i*)(dst + j), D); 78 | } 79 | src1 += i_src1; 80 | src2 += i_src2; 81 | dst += i_dst; 82 | } 83 | } 84 | 85 | } 86 | 87 | /* --------------------------------------------------------------------------- 88 | */ 89 | void *xavs2_memzero_aligned_c_sse2(void *dst, size_t n) 90 | { 91 | __m128i *p_dst = (__m128i *)dst; 92 | __m128i m0 = _mm_setzero_si128(); 93 | int i = (int)(n >> 4); 94 | 95 | for (; i != 0; i--) { 96 | _mm_store_si128(p_dst, m0); 97 | p_dst++; 98 | } 99 | 100 | return dst; 101 | } 102 | 103 | /* --------------------------------------------------------------------------- 104 | */ 105 | void xavs2_mem_repeat_i_c_sse2(void *dst, int val, size_t count) 106 | { 107 | __m128i *p_dst = (__m128i *)dst; 108 | __m128i m0 = _mm_set1_epi32(val); 109 | int i = (int)((count + 3) >> 2); 110 | 111 | for (; i != 0; i--) { 112 | _mm_store_si128(p_dst, m0); 113 | p_dst++; 114 | } 115 | } 116 | 117 | /* --------------------------------------------------------------------------- 118 | */ 119 | void *xavs2_memcpy_aligned_c_sse2(void *dst, const void *src, size_t n) 120 | { 121 | __m128i *p_dst = (__m128i *)dst; 122 | const __m128i *p_src = (const __m128i *)src; 123 | int i = (int)(n >> 4); 124 | 125 | for (; i != 0; i--) { 126 | _mm_store_si128(p_dst, _mm_load_si128(p_src)); 127 | p_src++; 128 | p_dst++; 129 | } 130 | 131 | return dst; 132 | } 133 | 134 | -------------------------------------------------------------------------------- /source/common/win32thread.h: -------------------------------------------------------------------------------- 1 | /* 2 | * win32thread.h 3 | * 4 | * Description of this file: 5 | * windows threading of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | #ifndef XAVS2_WIN32THREAD_H 38 | #define XAVS2_WIN32THREAD_H 39 | 40 | #define WIN32_LEAN_AND_MEAN 41 | #include 42 | /* the following macro is used within xavs2 encoder */ 43 | #undef ERROR 44 | 45 | typedef struct { 46 | void *handle; 47 | void *(*func)(void *arg); 48 | void *arg; 49 | void *ret; 50 | } xavs2_thread_t; 51 | #define xavs2_thread_attr_t int 52 | 53 | /* the conditional variable api for windows 6.0+ uses critical sections and not mutexes */ 54 | typedef CRITICAL_SECTION xavs2_thread_mutex_t; 55 | #define XAVS2_PTHREAD_MUTEX_INITIALIZER {0} 56 | #define xavs2_thread_mutexattr_t int 57 | #define pthread_exit(a) 58 | 59 | /* This is the CONDITIONAL_VARIABLE typedef for using Window's native conditional variables on kernels 6.0+. 60 | * MinGW does not currently have this typedef. */ 61 | typedef struct { 62 | xavs2_thread_mutex_t mtx_broadcast; 63 | xavs2_thread_mutex_t mtx_waiter_count; 64 | int waiter_count; 65 | HANDLE semaphore; 66 | HANDLE waiters_done; 67 | int is_broadcast; 68 | } xavs2_win32_cond_t, xavs2_thread_cond_t; 69 | 70 | #define xavs2_thread_condattr_t int 71 | 72 | #define xavs2_thread_create FPFX(thread_create) 73 | int xavs2_thread_create(xavs2_thread_t *thread, const xavs2_thread_attr_t *attr, 74 | void *(*start_routine)(void *), void *arg); 75 | #define xavs2_thread_join FPFX(thread_join) 76 | int xavs2_thread_join(xavs2_thread_t thread, void **value_ptr); 77 | 78 | #define xavs2_thread_mutex_init FPFX(thread_mutex_init) 79 | int xavs2_thread_mutex_init(xavs2_thread_mutex_t *mutex, const xavs2_thread_mutexattr_t *attr); 80 | #define xavs2_thread_mutex_destroy FPFX(thread_mutex_destroy) 81 | int xavs2_thread_mutex_destroy(xavs2_thread_mutex_t *mutex); 82 | #define xavs2_thread_mutex_lock FPFX(thread_mutex_lock) 83 | int xavs2_thread_mutex_lock(xavs2_thread_mutex_t *mutex); 84 | #define xavs2_thread_mutex_unlock FPFX(thread_mutex_unlock) 85 | int xavs2_thread_mutex_unlock(xavs2_thread_mutex_t *mutex); 86 | 87 | #define xavs2_thread_cond_init FPFX(thread_cond_init) 88 | int xavs2_thread_cond_init(xavs2_thread_cond_t *cond, const xavs2_thread_condattr_t *attr); 89 | #define xavs2_thread_cond_destroy FPFX(thread_cond_destroy) 90 | int xavs2_thread_cond_destroy(xavs2_thread_cond_t *cond); 91 | #define xavs2_thread_cond_broadcast FPFX(thread_cond_broadcast) 92 | int xavs2_thread_cond_broadcast(xavs2_thread_cond_t *cond); 93 | #define xavs2_thread_cond_wait FPFX(thread_cond_wait) 94 | int xavs2_thread_cond_wait(xavs2_thread_cond_t *cond, xavs2_thread_mutex_t *mutex); 95 | #define xavs2_thread_cond_signal FPFX(thread_cond_signal) 96 | int xavs2_thread_cond_signal(xavs2_thread_cond_t *cond); 97 | 98 | #define xavs2_thread_attr_init(a) 0 99 | #define xavs2_thread_attr_destroy(a) 0 100 | 101 | #define xavs2_win32_threading_init FPFX(win32_threading_init) 102 | int xavs2_win32_threading_init(void); 103 | #define xavs2_win32_threading_destroy FPFX(win32_threading_destroy) 104 | void xavs2_win32_threading_destroy(void); 105 | 106 | #define xavs2_thread_num_processors_np FPFX(thread_num_processors_np) 107 | int xavs2_thread_num_processors_np(void); 108 | 109 | #endif // XAVS2_WIN32THREAD_H 110 | -------------------------------------------------------------------------------- /source/encoder/me.h: -------------------------------------------------------------------------------- 1 | /* 2 | * me.h 3 | * 4 | * Description of this file: 5 | * ME functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | 38 | #ifndef XAVS2_ME_H 39 | #define XAVS2_ME_H 40 | 41 | 42 | /** 43 | * =========================================================================== 44 | * macros 45 | * =========================================================================== 46 | */ 47 | 48 | #define pack16to32_mask(x,y) (((x) << 16)|((y) & 0xFFFF)) 49 | #define pack16to32_mask2(mx,my) (((mx) << 16) | ((my) & 0x7FFF)) 50 | #define CHECK_MV_RANGE(mx,my) (!(((pack16to32_mask2(mx,my) + mv_min) | (mv_max - pack16to32_mask2(mx,my))) & 0x80004000)) 51 | #define CHECK_MV_RANGE_X4(x0,y0,x1,y1,x2,y2,x3,y3) (!(( \ 52 | (pack16to32_mask2(x0, y0) + mv_min) | (mv_max - pack16to32_mask2(x0, y0)) | \ 53 | (pack16to32_mask2(x1, y1) + mv_min) | (mv_max - pack16to32_mask2(x1, y1)) | \ 54 | (pack16to32_mask2(x2, y2) + mv_min) | (mv_max - pack16to32_mask2(x2, y2)) | \ 55 | (pack16to32_mask2(x3, y3) + mv_min) | (mv_max - pack16to32_mask2(x3, y3)) \ 56 | ) & 0x80004000)) 57 | 58 | /* --------------------------------------------------------------------------- 59 | * conversion */ 60 | #define IPEL(mv) (((mv) + 2) >> 2) /* convert fractional pixel MV to integer pixel with rounding */ 61 | #define FPEL(mv) ((mv) << 2) /* convert integer pixel MV to fractional pixel */ 62 | 63 | /* --------------------------------------------------------------------------- 64 | */ 65 | #define COPY1_IF_LT(x, y) \ 66 | if ((y) < (x)) {\ 67 | (x) = (y);\ 68 | } 69 | 70 | #define COPY2_IF_LT(x, y, a, b) \ 71 | if ((y) < (x)) {\ 72 | (x) = (y);\ 73 | (a) = (b);\ 74 | } 75 | 76 | #define COPY3_IF_LT(x, y, a, b, c, d) \ 77 | if ((y) < (x)) {\ 78 | (x) = (y);\ 79 | (a) = (b);\ 80 | (c) = (d);\ 81 | } 82 | 83 | #define COPY4_IF_LT(x, y, a, b, c, d, e, f) \ 84 | if ((y) < (x)) {\ 85 | (x) = (y);\ 86 | (a) = (b);\ 87 | (c) = (d);\ 88 | (e) = (f);\ 89 | } 90 | 91 | #define COPY5_IF_LT(x, y, a, b, c, d, e, f, g, h) \ 92 | if ((y) < (x)) {\ 93 | (x) = (y);\ 94 | (a) = (b);\ 95 | (c) = (d);\ 96 | (e) = (f);\ 97 | (g) = (h);\ 98 | } 99 | 100 | /* --------------------------------------------------------------------------- 101 | * MV cost */ 102 | #define MV_COST_IPEL(mx,my) (WEIGHTED_COST(lambda, p_cost_mvx[(mx) << 2] + p_cost_mvy[(my) << 2])) 103 | #define MV_COST_FPEL(mx,my) (WEIGHTED_COST(lambda, p_cost_mvx[mx] + p_cost_mvy[my])) 104 | #define MV_COST_FPEL_BID(mx,my) (WEIGHTED_COST(lambda, p_cost_bix[mx] + p_cost_biy[my])) 105 | 106 | 107 | /** 108 | * =========================================================================== 109 | * function declares 110 | * =========================================================================== 111 | */ 112 | 113 | #define xavs2_me_get_buf_size FPFX(me_get_buf_size) 114 | int xavs2_me_get_buf_size(const xavs2_param_t *param); 115 | #define xavs2_me_init FPFX(me_init) 116 | void xavs2_me_init(xavs2_t *h, uint8_t **mem_base); 117 | #define xavs2_me_init_umh_threshold FPFX(me_init_umh_threshold) 118 | void xavs2_me_init_umh_threshold(xavs2_t *h, double *bsize, int i_qp); 119 | 120 | #define xavs2_me_search FPFX(me_search) 121 | dist_t xavs2_me_search(xavs2_t *h, xavs2_me_t *p_me, int16_t(*mvc)[2], int i_mvc); 122 | 123 | #define xavs2_me_search_sym FPFX(me_search_sym) 124 | dist_t xavs2_me_search_sym(xavs2_t *h, xavs2_me_t *p_me, pel_t *buf_pixel_temp, mv_t *mv); 125 | #define xavs2_me_search_bid FPFX(me_search_bid) 126 | dist_t xavs2_me_search_bid(xavs2_t *h, xavs2_me_t *p_me, pel_t *buf_pixel_temp, mv_t *fwd_mv, mv_t *bwd_mv, cu_parallel_t *p_enc); 127 | 128 | #endif // XAVS2_ME_H 129 | -------------------------------------------------------------------------------- /source/common/common_arm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * common_arm.c 3 | * 4 | * Description of this file: 5 | * common tables definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | #ifdef __ARM_ARCH_7A__ 38 | 39 | #include "common_arm.h" 40 | #include "common.h" 41 | 42 | //ARM_PART_4x2=10, ARM_PART_2x4 = 12, ARM_PART_8x2= 18, ARM_PART_2x8=24,ARM_PART_8x6=54,ARM_PART_6x8=56 43 | const unsigned char g_arm_partition_map_tab[] = 44 | { 45 | ARM_PLANE_COPY_W88, 255, ARM_PLANE_COPY_W160, ARM_PLANE_COPY_W176, 255, 255, 255, ARM_PLANE_COPY_W320, ARM_PLANE_COPY_W352, ARM_PLANE_COPY_W360, ARM_PART_4x2, 255, ARM_PART_2x4, ARM_PLANE_COPY_W512, 255, 255, 46 | 255, ARM_PLANE_COPY_W640, ARM_PART_8x2, ARM_PLANE_COPY_W704, ARM_PLANE_COPY_W720, 255, 255, 255, ARM_PART_2x8, 255, 255, ARM_PLANE_COPY_W960, 255, ARM_PLANE_COPY_W1024, 255, 255, 47 | 255, 255, 255, 255, 255, ARM_PLANE_COPY_W1280, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 48 | 255, 255, 255, 255, 255, 255, ARM_PART_8x6, 255, ARM_PART_6x8, ARM_PLANE_COPY_W1920, 255, 255, 255, 255, 255, 255 49 | }; 50 | 51 | 52 | /* 53 | g_T4[0][0] * g_T4[0][0], g_T4[0][0] * g_T4[1][0], g_T4[0][0] * g_T4[2][0], g_T4[0][0] * g_T4[3][0], 54 | g_T4[0][0] * g_T4[0][1], g_T4[0][0] * g_T4[1][1], g_T4[0][0] * g_T4[2][1], g_T4[0][0] * g_T4[3][1], 55 | g_T4[0][1] * g_T4[0][0], g_T4[0][1] * g_T4[1][0], g_T4[0][1] * g_T4[2][0], g_T4[0][1] * g_T4[3][0], 56 | g_T4[0][1] * g_T4[0][1], g_T4[0][1] * g_T4[1][1], g_T4[0][1] * g_T4[2][1], g_T4[0][1] * g_T4[3][1], 57 | 58 | g_T4[1][0] * g_T4[0][0], g_T4[1][0] * g_T4[1][0], g_T4[1][0] * g_T4[2][0], g_T4[1][0] * g_T4[3][0], 59 | g_T4[1][0] * g_T4[0][1], g_T4[1][0] * g_T4[1][1], g_T4[1][0] * g_T4[2][1], g_T4[1][0] * g_T4[3][1], 60 | g_T4[1][1] * g_T4[0][0], g_T4[1][1] * g_T4[1][0], g_T4[1][1] * g_T4[2][0], g_T4[1][1] * g_T4[3][0], 61 | g_T4[1][1] * g_T4[0][1], g_T4[1][1] * g_T4[1][1], g_T4[1][1] * g_T4[2][1], g_T4[1][1] * g_T4[3][1], 62 | 63 | g_T4[2][0] * g_T4[0][0], g_T4[2][0] * g_T4[1][0], g_T4[2][0] * g_T4[2][0], g_T4[2][0] * g_T4[3][0], 64 | g_T4[2][0] * g_T4[0][1], g_T4[2][0] * g_T4[1][1], g_T4[2][0] * g_T4[2][1], g_T4[2][0] * g_T4[3][1], 65 | g_T4[2][1] * g_T4[0][0], g_T4[2][1] * g_T4[1][0], g_T4[2][1] * g_T4[2][0], g_T4[2][1] * g_T4[3][0], 66 | g_T4[2][1] * g_T4[0][1], g_T4[2][1] * g_T4[1][1], g_T4[2][1] * g_T4[2][1], g_T4[2][1] * g_T4[3][1], 67 | 68 | g_T4[3][0] * g_T4[0][0], g_T4[3][0] * g_T4[1][0], g_T4[3][0] * g_T4[2][0], g_T4[3][0] * g_T4[3][0], 69 | g_T4[3][0] * g_T4[0][1], g_T4[3][0] * g_T4[1][1], g_T4[3][0] * g_T4[2][1], g_T4[3][0] * g_T4[3][1], 70 | g_T4[3][1] * g_T4[0][0], g_T4[3][1] * g_T4[1][0], g_T4[3][1] * g_T4[2][0], g_T4[3][1] * g_T4[3][0], 71 | g_T4[3][1] * g_T4[0][1], g_T4[3][1] * g_T4[1][1], g_T4[3][1] * g_T4[2][1], g_T4[3][1] * g_T4[3][1] 72 | */ 73 | 74 | ALIGN32(short dct4x4_const_table[64]) = { 75 | 32 * 32, 32 * 42, 32 * 32, 32 * 17, 76 | 32 * 32, 32 * 17, 32 * (-32), 32 * (-42), 77 | 32 * 32, 32 * 42, 32 * 32, 32 * 17, 78 | 32 * 32, 32 * 17, 32 * (-32), 32 * (-42), 79 | 80 | 42 * 32, 42 * 42, 42 * 32, 42 * 17, 81 | 42 * 32, 42 * 17, 42 * (-32), 42 * (-42), 82 | 17 * 32, 17 * 42, 17 * 32, 17 * 17, 83 | 17 * 32, 17 * 17, 17 * (-32), 17 * (-42), 84 | 85 | 32 * 32, 32 * 42, 32 * 32, 32 * 17, 86 | 32 * 32, 32 * 17, 32 * (-32), 32 * (-42), 87 | (-32) * 32, (-32) * 42, (-32) * 32, (-32) * 17, 88 | (-32) * 32, (-32) * 17, (-32) * (-32), (-32) * (-42), 89 | 90 | 17 * 32, 17 * 42, 17 * 32, 17 * 17, 91 | 17 * 32, 17 * 17, 17 * (-32), 17 * (-42), 92 | (-42) * 32, (-42) * 42, (-42) * 32, (-42) * 17, 93 | (-42) * 32, (-42) * 17, (-42) * (-32), (-42) * (-42) 94 | }; 95 | ALIGN32(short g_dct_temp_buf[1024]) = {0}; 96 | #endif //__ARM_ARCH_7A__ 97 | -------------------------------------------------------------------------------- /source/common/nal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * nal.h 3 | * 4 | * Description of this file: 5 | * NAL functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | 38 | #ifndef XAVS2_NAL_H 39 | #define XAVS2_NAL_H 40 | 41 | #include "bitstream.h" 42 | 43 | /** 44 | * =========================================================================== 45 | * nal function defines 46 | * =========================================================================== 47 | */ 48 | 49 | /* --------------------------------------------------------------------------- 50 | */ 51 | static ALWAYS_INLINE void nal_start(xavs2_t *h, int i_type, int i_ref_idc) 52 | { 53 | nal_t *nal = &h->p_nal[h->i_nal]; 54 | 55 | nal->i_ref_idc = i_ref_idc; 56 | nal->i_type = i_type; 57 | nal->i_payload = 0; 58 | nal->p_payload = &h->p_bs_buf_header[xavs2_bs_pos(&h->header_bs) >> 3]; 59 | } 60 | 61 | /* --------------------------------------------------------------------------- 62 | */ 63 | static ALWAYS_INLINE void nal_end(xavs2_t *h) 64 | { 65 | nal_t *nal = &h->p_nal[h->i_nal]; 66 | uint8_t *end = &h->p_bs_buf_header[xavs2_bs_pos(&h->header_bs) >> 3]; 67 | 68 | nal->i_payload = (int)(end - nal->p_payload); 69 | h->i_nal++; 70 | } 71 | 72 | /* --------------------------------------------------------------------------- 73 | */ 74 | static ALWAYS_INLINE void 75 | nal_merge_slice(xavs2_t *h, uint8_t *p_bs_buffer, int i_bs_len, int i_type, int i_ref_idc) 76 | { 77 | nal_t *nal = &h->p_nal[h->i_nal]; 78 | 79 | assert(i_bs_len > 8); 80 | 81 | // update the current nal 82 | nal->i_ref_idc = i_ref_idc; 83 | nal->i_type = i_type; 84 | nal->i_payload = i_bs_len; 85 | nal->p_payload = p_bs_buffer; 86 | 87 | // next nal 88 | h->i_nal++; 89 | } 90 | 91 | /* --------------------------------------------------------------------------- 92 | */ 93 | static INLINE 94 | uint8_t *nal_escape_c(uint8_t *dst, uint8_t *src, uint8_t *end) 95 | { 96 | int left_bits = 8; 97 | uint8_t tmp = 0; 98 | 99 | /* check pseudo start code */ 100 | while (src < end) { 101 | tmp |= (uint8_t)(*src >> (8 - left_bits)); 102 | if (tmp <= 0x03 && !dst[-2] && !dst[-1]) { 103 | *dst++ = 0x02; /* insert '10' */ 104 | tmp <<= 6; 105 | if (left_bits >= 2) { 106 | tmp |= (uint8_t)((*src++) << (left_bits - 2)); 107 | left_bits = left_bits - 2; 108 | } else { 109 | tmp |= (uint8_t)((*src) >> (2 - left_bits)); 110 | *dst++ = tmp; 111 | tmp = (uint8_t)((*src++) << (6 + left_bits)); 112 | left_bits = 6 + left_bits; 113 | } 114 | continue; 115 | } 116 | *dst++ = tmp; 117 | tmp = (uint8_t)((*src++) << left_bits); 118 | } 119 | 120 | /* rest bits */ 121 | if (left_bits != 8 && tmp != 0) { 122 | *dst++ = tmp; 123 | } 124 | 125 | return dst; 126 | } 127 | 128 | /* --------------------------------------------------------------------------- 129 | */ 130 | static INLINE 131 | intptr_t encoder_encapsulate_nals(xavs2_t *h, xavs2_frame_t *frm, int start) 132 | { 133 | uint8_t *nal_buffer; 134 | int previous_nal_size = 0; 135 | int nal_size = 0; 136 | int i; 137 | 138 | for (i = 0; i < start; i++) { 139 | previous_nal_size += h->p_nal[i].i_payload; 140 | } 141 | 142 | for (i = start; i < h->i_nal; i++) { 143 | nal_size += h->p_nal[i].i_payload; 144 | } 145 | 146 | /* NOTE: frame->i_bs_buf is big enough, no need to reallocate memory */ 147 | // assert(previous_nal_size + nal_size <= frame->i_bs_buf); 148 | 149 | /* copy new nals */ 150 | nal_buffer = frm->p_bs_buf + previous_nal_size; 151 | nal_size = h->i_nal; /* number of all nals */ 152 | for (i = start; i < nal_size; i++) { 153 | nal_t *nal = &h->p_nal[i]; 154 | memcpy(nal_buffer, nal->p_payload, nal->i_payload); 155 | nal_buffer += nal->i_payload; 156 | } 157 | 158 | return nal_buffer - (frm->p_bs_buf + previous_nal_size); 159 | } 160 | 161 | 162 | #endif // XAVS2_NAL_H 163 | -------------------------------------------------------------------------------- /source/common/cpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cpu.h 3 | * 4 | * Description of this file: 5 | * CPU-Processing functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | 38 | 39 | #ifndef XAVS2_CPU_H 40 | #define XAVS2_CPU_H 41 | 42 | /** 43 | * =========================================================================== 44 | * const defines 45 | * =========================================================================== 46 | */ 47 | /* CPU flags */ 48 | 49 | /* x86 */ 50 | #define XAVS2_CPU_CMOV 0x0000001 51 | #define XAVS2_CPU_MMX 0x0000002 52 | #define XAVS2_CPU_MMX2 0x0000004 /* MMX2 aka MMXEXT aka ISSE */ 53 | #define XAVS2_CPU_MMXEXT XAVS2_CPU_MMX2 54 | #define XAVS2_CPU_SSE 0x0000008 55 | #define XAVS2_CPU_SSE2 0x0000010 56 | #define XAVS2_CPU_SSE3 0x0000020 57 | #define XAVS2_CPU_SSSE3 0x0000040 58 | #define XAVS2_CPU_SSE4 0x0000080 /* SSE4.1 */ 59 | #define XAVS2_CPU_SSE42 0x0000100 /* SSE4.2 */ 60 | #define XAVS2_CPU_LZCNT 0x0000200 /* Phenom support for "leading zero count" instruction. */ 61 | #define XAVS2_CPU_AVX 0x0000400 /* AVX support: requires OS support even if YMM registers aren't used. */ 62 | #define XAVS2_CPU_XOP 0x0000800 /* AMD XOP */ 63 | #define XAVS2_CPU_FMA4 0x0001000 /* AMD FMA4 */ 64 | #define XAVS2_CPU_AVX2 0x0002000 /* AVX2 */ 65 | #define XAVS2_CPU_FMA3 0x0004000 /* Intel FMA3 */ 66 | #define XAVS2_CPU_BMI1 0x0008000 /* BMI1 */ 67 | #define XAVS2_CPU_BMI2 0x0010000 /* BMI2 */ 68 | /* x86 modifiers */ 69 | #define XAVS2_CPU_CACHELINE_32 0x0020000 /* avoid memory loads that span the border between two cachelines */ 70 | #define XAVS2_CPU_CACHELINE_64 0x0040000 /* 32/64 is the size of a cacheline in bytes */ 71 | #define XAVS2_CPU_SSE2_IS_SLOW 0x0080000 /* avoid most SSE2 functions on Athlon64 */ 72 | #define XAVS2_CPU_SSE2_IS_FAST 0x0100000 /* a few functions are only faster on Core2 and Phenom */ 73 | #define XAVS2_CPU_SLOW_SHUFFLE 0x0200000 /* The Conroe has a slow shuffle unit (relative to overall SSE performance) */ 74 | #define XAVS2_CPU_STACK_MOD4 0x0400000 /* if stack is only mod4 and not mod16 */ 75 | #define XAVS2_CPU_SLOW_CTZ 0x0800000 /* BSR/BSF x86 instructions are really slow on some CPUs */ 76 | #define XAVS2_CPU_SLOW_ATOM 0x1000000 /* The Atom is terrible: slow SSE unaligned loads, slow 77 | * SIMD multiplies, slow SIMD variable shifts, slow pshufb, 78 | * cacheline split penalties -- gather everything here that 79 | * isn't shared by other CPUs to avoid making half a dozen 80 | * new SLOW flags. */ 81 | #define XAVS2_CPU_SLOW_PSHUFB 0x2000000 /* such as on the Intel Atom */ 82 | #define XAVS2_CPU_SLOW_PALIGNR 0x4000000 /* such as on the AMD Bobcat */ 83 | 84 | /* ARM */ 85 | #define XAVS2_CPU_ARMV6 0x0000001 86 | #define XAVS2_CPU_NEON 0x0000002 /* ARM NEON */ 87 | #define XAVS2_CPU_FAST_NEON_MRC 0x0000004 /* Transfer from NEON to ARM register is fast (Cortex-A9) */ 88 | 89 | 90 | /** 91 | * =========================================================================== 92 | * declarations 93 | * =========================================================================== 94 | */ 95 | #define xavs2_cpu_detect FPFX(cpu_detect) 96 | uint32_t xavs2_cpu_detect(void); 97 | #define xavs2_cpu_num_processors FPFX(cpu_num_processors) 98 | int xavs2_cpu_num_processors(void); 99 | #define xavs2_cpu_emms FPFX(cpu_emms) 100 | void xavs2_cpu_emms(void); 101 | #define xavs2_cpu_sfence FPFX(cpu_sfence) 102 | void xavs2_cpu_sfence(void); 103 | #define xavs2_get_simd_capabilities FPFX(get_simd_capabilities) 104 | char *xavs2_get_simd_capabilities(char *buf, int cpuid); 105 | 106 | #if HAVE_MMX 107 | #define xavs2_cpu_cpuid_test FPFX(cpu_cpuid_test) 108 | int xavs2_cpu_cpuid_test(void); 109 | #define xavs2_cpu_cpuid FPFX(cpu_cpuid) 110 | uint32_t xavs2_cpu_cpuid(uint32_t op, uint32_t * eax, uint32_t * ebx, uint32_t * ecx, uint32_t * edx); 111 | #define xavs2_cpu_xgetbv FPFX(cpu_xgetbv) 112 | void xavs2_cpu_xgetbv(uint32_t op, uint32_t *eax, uint32_t *edx); 113 | #define xavs2_emms() xavs2_cpu_emms() 114 | #else 115 | #define xavs2_emms() 116 | #endif 117 | 118 | #endif // XAVS2_CPU_H 119 | -------------------------------------------------------------------------------- /source/encoder/wrapper.c: -------------------------------------------------------------------------------- 1 | /* 2 | * wrapper.c 3 | * 4 | * Description of this file: 5 | * encoder wrapper functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | #include "common.h" 38 | #include "wrapper.h" 39 | #include "frame.h" 40 | #include "encoder.h" 41 | #include "rps.h" 42 | 43 | /* --------------------------------------------------------------------------- 44 | */ 45 | void frame_buffer_init(xavs2_handler_t *h_mgr, uint8_t **mem_base, xavs2_frame_buffer_t *frm_buf, 46 | int num_frm, int frm_type) 47 | { 48 | int i; 49 | 50 | memset(frm_buf, 0, sizeof(xavs2_frame_buffer_t)); 51 | 52 | frm_buf->COI = 0; 53 | frm_buf->COI_IDR = 0; 54 | frm_buf->POC_IDR = 0; 55 | frm_buf->num_frames = num_frm; 56 | frm_buf->i_frame_b = 0; 57 | frm_buf->ip_pic_idx = 0; 58 | 59 | if (mem_base == NULL) { 60 | for (i = 0; i < num_frm; i++) { 61 | frm_buf->frames[i] = xavs2_frame_new(h_mgr->p_coder, NULL, frm_type); 62 | } 63 | } else { 64 | uint8_t *mem_ptr = *mem_base; 65 | for (i = 0; i < num_frm; i++) { 66 | frm_buf->frames[i] = xavs2_frame_new(h_mgr->p_coder, &mem_ptr, frm_type); 67 | ALIGN_POINTER(mem_ptr); 68 | } 69 | *mem_base = mem_ptr; 70 | } 71 | } 72 | 73 | /* --------------------------------------------------------------------------- 74 | * destroy frame buffer 75 | */ 76 | void frame_buffer_destroy(xavs2_handler_t *h_mgr, xavs2_frame_buffer_t *frm_buf) 77 | { 78 | int i; 79 | 80 | for (i = 0; i < frm_buf->num_frames; i++) { 81 | xavs2_frame_delete(h_mgr, frm_buf->frames[i]); 82 | frm_buf->frames[i] = NULL; 83 | } 84 | } 85 | 86 | /* --------------------------------------------------------------------------- 87 | * update frame buffer information 88 | */ 89 | void frame_buffer_update(xavs2_t *h, xavs2_frame_buffer_t *frm_buf, xavs2_frame_t *frm) 90 | { 91 | /* update the task manager */ 92 | if (h->param->intra_period_max != 0 && frm->i_frm_type == XAVS2_TYPE_I) { 93 | frm_buf->COI_IDR = frm->i_frm_coi; 94 | frm_buf->POC_IDR = frm->i_frame; 95 | } 96 | 97 | if (frm->i_frm_type == XAVS2_TYPE_B) { 98 | frm_buf->i_frame_b++; /* encoded B-picture index */ 99 | } else { 100 | frm_buf->i_frame_b = 0; /* reset */ 101 | frm_buf->ip_pic_idx++; /* encoded I/P/F-picture index */ 102 | } 103 | } 104 | 105 | 106 | /** 107 | * --------------------------------------------------------------------------- 108 | * Function : destroy all lists used by the AVS video encoder 109 | * Parameters : 110 | * [in ] : h_mgr - pointer of struct xavs2_handler_t, the AVS encoder 111 | * [out] : none 112 | * Return : none 113 | * --------------------------------------------------------------------------- 114 | */ 115 | void destroy_all_lists(xavs2_handler_t *h_mgr) 116 | { 117 | int i; 118 | 119 | assert(h_mgr != NULL); 120 | 121 | xl_destroy(&h_mgr->list_frames_output); 122 | xl_destroy(&h_mgr->list_frames_ready); 123 | xl_destroy(&h_mgr->list_frames_free); 124 | 125 | for (i = 0; i < XAVS2_INPUT_NUM; i++) { 126 | xavs2_frame_destroy_objects(h_mgr, h_mgr->ipb.frames[i]); 127 | } 128 | } 129 | 130 | /** 131 | * --------------------------------------------------------------------------- 132 | * Function : proceeding of wrapper thread 133 | * Parameters : 134 | * [in ] : h_mgr - pointer to xavs2_handler_t 135 | * [out] : none 136 | * Return : none 137 | * --------------------------------------------------------------------------- 138 | */ 139 | void *proc_wrapper_thread(void *args) 140 | { 141 | xavs2_handler_t *h_mgr = (xavs2_handler_t *)args; 142 | xlist_t *list_in = &h_mgr->list_frames_ready; 143 | xlist_t *list_idle = &h_mgr->list_frames_free; 144 | 145 | for (;;) { 146 | /* fetch one node from input list */ 147 | xavs2_frame_t *frame = (xavs2_frame_t *)xl_remove_head(list_in, 1); 148 | int state = frame->i_state; 149 | if (state == XAVS2_EXIT_THREAD) { 150 | xl_append(list_idle, frame); 151 | break; /* exit this thread */ 152 | } 153 | 154 | /* encoding... */ 155 | if (encoder_encode(h_mgr, frame) < 0) { 156 | xavs2_log(NULL, XAVS2_LOG_ERROR, "encode frame fail\n"); 157 | break; /* exit on error */ 158 | } 159 | 160 | /* throw it into idle list */ 161 | if (state == XAVS2_FLUSH) { 162 | xl_append(list_idle, frame); 163 | } 164 | } 165 | 166 | return NULL; 167 | } 168 | -------------------------------------------------------------------------------- /source/encoder/xlist.c: -------------------------------------------------------------------------------- 1 | /* 2 | * xlist.c 3 | * 4 | * Description of this file: 5 | * list structure with multi-thread support of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | #include "common.h" 38 | #include "xlist.h" 39 | 40 | #if !defined(_MSC_VER) 41 | #include 42 | #include 43 | #endif 44 | 45 | /** 46 | * =========================================================================== 47 | * xlist 48 | * =========================================================================== 49 | */ 50 | 51 | /** 52 | * --------------------------------------------------------------------------- 53 | * Function : initialize a list 54 | * Parameters : 55 | * [in ] : xlist - pointer to the node list 56 | * [out] : none 57 | * Return : zero for success, otherwise failed 58 | * Remarks : also create 2 synchronous objects, but without any node 59 | * --------------------------------------------------------------------------- 60 | */ 61 | int xl_init(xlist_t *const xlist) 62 | { 63 | if (xlist == NULL) { 64 | return -1; 65 | } 66 | 67 | /* set list empty */ 68 | xlist->p_list_head = NULL; 69 | xlist->p_list_tail = NULL; 70 | 71 | /* set node number */ 72 | xlist->i_node_num = 0; 73 | 74 | /* create lock and conditions */ 75 | if (xavs2_thread_mutex_init(&xlist->list_mutex, NULL) < 0 || 76 | xavs2_thread_cond_init(&xlist->list_cond, NULL) < 0) { 77 | xavs2_log(NULL, XAVS2_LOG_ERROR, "Failed to init lock for xl_init()"); 78 | return -1; 79 | } 80 | 81 | return 0; 82 | } 83 | 84 | /** 85 | * --------------------------------------------------------------------------- 86 | * Function : destroy a list 87 | * Parameters : 88 | * [in ] : xlist - the list, pointer to struct xlist_t 89 | * [out] : none 90 | * Return : none 91 | * --------------------------------------------------------------------------- 92 | */ 93 | void xl_destroy(xlist_t *const xlist) 94 | { 95 | if (xlist == NULL) { 96 | return; 97 | } 98 | 99 | /* destroy lock and conditions */ 100 | xavs2_thread_mutex_destroy(&xlist->list_mutex); 101 | xavs2_thread_cond_destroy(&xlist->list_cond); 102 | 103 | /* clear */ 104 | memset(xlist, 0, sizeof(xlist_t)); 105 | } 106 | 107 | /** 108 | * --------------------------------------------------------------------------- 109 | * Function : append data to the tail of a list 110 | * Parameters : 111 | * [in ] : xlist - the node list, pointer to struct xlist 112 | * : data - the data to append 113 | * [out] : none 114 | * Return : none 115 | * --------------------------------------------------------------------------- 116 | */ 117 | void xl_append(xlist_t *const xlist, void *node) 118 | { 119 | node_t *new_node = (node_t *)node; 120 | 121 | if (xlist == NULL || new_node == NULL) { 122 | return; /* error */ 123 | } 124 | 125 | new_node->next = NULL; /* set NULL */ 126 | 127 | xavs2_thread_mutex_lock(&xlist->list_mutex); /* lock */ 128 | 129 | /* append this node */ 130 | if (xlist->p_list_tail != NULL) { 131 | /* append this node at tail */ 132 | xlist->p_list_tail->next = new_node; 133 | } else { 134 | xlist->p_list_head = new_node; 135 | } 136 | 137 | xlist->p_list_tail = new_node; /* point to the tail node */ 138 | xlist->i_node_num++; /* increase the node number */ 139 | 140 | xavs2_thread_mutex_unlock(&xlist->list_mutex); /* unlock */ 141 | 142 | /* all is done, notify one waiting thread to work */ 143 | xavs2_thread_cond_signal(&xlist->list_cond); 144 | } 145 | 146 | /** 147 | * --------------------------------------------------------------------------- 148 | * Function : remove one node from the list's head position 149 | * Parameters : 150 | * [in ] : xlist - the node list, pointer to struct xlist_t 151 | * : wait - wait the semaphore? 152 | * [out] : none 153 | * Return : node pointer for success, or NULL for failure 154 | * --------------------------------------------------------------------------- 155 | */ 156 | void *xl_remove_head(xlist_t *const xlist, const int wait) 157 | { 158 | node_t *node = NULL; 159 | 160 | if (xlist == NULL) { 161 | return NULL; /* error */ 162 | } 163 | 164 | xavs2_thread_mutex_lock(&xlist->list_mutex); 165 | 166 | while (wait && !xlist->i_node_num) { 167 | xavs2_thread_cond_wait(&xlist->list_cond, &xlist->list_mutex); 168 | } 169 | 170 | /* remove the header node */ 171 | if (xlist->i_node_num > 0) { 172 | node = xlist->p_list_head; /* point to the header node */ 173 | 174 | /* modify the list */ 175 | xlist->p_list_head = node->next; 176 | 177 | if (xlist->p_list_head == NULL) { 178 | /* there are no any node in this list, reset the tail pointer */ 179 | xlist->p_list_tail = NULL; 180 | } 181 | 182 | xlist->i_node_num--; /* decrease the number */ 183 | } 184 | 185 | xavs2_thread_mutex_unlock(&xlist->list_mutex); 186 | 187 | return node; 188 | } 189 | -------------------------------------------------------------------------------- /source/common/x86/cpu-a.asm: -------------------------------------------------------------------------------- 1 | ;***************************************************************************** 2 | ;* cpu-a.asm: x86 cpu utilities 3 | ;***************************************************************************** 4 | ;* Copyright (C) 2003-2013 x264 project 5 | ;* Copyright (C) 2013-2017 MulticoreWare, Inc 6 | ;* Copyright (C) 2018~ VCL, NELVT, Peking University 7 | ;* 8 | ;* Authors: Laurent Aimar 9 | ;* Loren Merritt 10 | ;* Fiona Glaser 11 | ;* Jiaqi Zhang 12 | ;* 13 | ;* This program is free software; you can redistribute it and/or modify 14 | ;* it under the terms of the GNU General Public License as published by 15 | ;* the Free Software Foundation; either version 2 of the License, or 16 | ;* (at your option) any later version. 17 | ;* 18 | ;* This program is distributed in the hope that it will be useful, 19 | ;* but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | ;* GNU General Public License for more details. 22 | ;* 23 | ;* You should have received a copy of the GNU General Public License 24 | ;* along with this program; if not, write to the Free Software 25 | ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 26 | ;* 27 | ;* This program is also available under a commercial proprietary license. 28 | ;* For more information, contact us at license @ x265.com. 29 | ;***************************************************************************** 30 | 31 | 32 | %include "x86inc.asm" 33 | 34 | SECTION .text 35 | 36 | ;----------------------------------------------------------------------------- 37 | ; void cpu_cpuid( int op, int *eax, int *ebx, int *ecx, int *edx ) 38 | ;----------------------------------------------------------------------------- 39 | cglobal cpu_cpuid, 5,7 40 | push rbx 41 | push r4 42 | push r3 43 | push r2 44 | push r1 45 | mov eax, r0d 46 | xor ecx, ecx 47 | cpuid 48 | pop r4 49 | mov [r4], eax 50 | pop r4 51 | mov [r4], ebx 52 | pop r4 53 | mov [r4], ecx 54 | pop r4 55 | mov [r4], edx 56 | pop rbx 57 | RET 58 | 59 | ;----------------------------------------------------------------------------- 60 | ; void cpu_xgetbv( int op, int *eax, int *edx ) 61 | ;----------------------------------------------------------------------------- 62 | cglobal cpu_xgetbv, 3,7 63 | push r2 64 | push r1 65 | mov ecx, r0d 66 | xgetbv 67 | pop r4 68 | mov [r4], eax 69 | pop r4 70 | mov [r4], edx 71 | RET 72 | 73 | ;----------------------------------------------------------------------------- 74 | ; void cpuid_get_serial_number( int op, int *eax, int *ebx, int *ecx, int *edx ) 75 | ; 2017-06-18 luofl 76 | ;----------------------------------------------------------------------------- 77 | cglobal cpuid_get_serial_number, 5,7 78 | push rbx 79 | push r4 80 | push r3 81 | push r2 82 | push r1 83 | ; first 64 bits 84 | mov eax, 00h 85 | xor edx, edx 86 | cpuid 87 | pop r4 88 | mov [r4], edx 89 | pop r4 90 | mov [r4], eax 91 | ; second 64 bits 92 | mov eax, 01h 93 | xor ecx, ecx 94 | xor edx, edx 95 | cpuid 96 | pop r4 97 | mov [r4], edx 98 | pop r4 99 | mov [r4], eax 100 | 101 | pop rbx 102 | RET 103 | 104 | %if ARCH_X86_64 105 | 106 | ;----------------------------------------------------------------------------- 107 | ; void stack_align( void (*func)(void*), void *arg ); 108 | ;----------------------------------------------------------------------------- 109 | cglobal stack_align 110 | push rbp 111 | mov rbp, rsp 112 | %if WIN64 113 | sub rsp, 32 ; shadow space 114 | %endif 115 | and rsp, ~31 116 | mov rax, r0 117 | mov r0, r1 118 | mov r1, r2 119 | mov r2, r3 120 | call rax 121 | leave 122 | ret 123 | 124 | %else 125 | 126 | ;----------------------------------------------------------------------------- 127 | ; int cpu_cpuid_test( void ) 128 | ; return 0 if unsupported 129 | ;----------------------------------------------------------------------------- 130 | cglobal cpu_cpuid_test 131 | pushfd 132 | push ebx 133 | push ebp 134 | push esi 135 | push edi 136 | pushfd 137 | pop eax 138 | mov ebx, eax 139 | xor eax, 0x200000 140 | push eax 141 | popfd 142 | pushfd 143 | pop eax 144 | xor eax, ebx 145 | pop edi 146 | pop esi 147 | pop ebp 148 | pop ebx 149 | popfd 150 | ret 151 | 152 | cglobal stack_align 153 | push ebp 154 | mov ebp, esp 155 | sub esp, 12 156 | and esp, ~31 157 | mov ecx, [ebp+8] 158 | mov edx, [ebp+12] 159 | mov [esp], edx 160 | mov edx, [ebp+16] 161 | mov [esp+4], edx 162 | mov edx, [ebp+20] 163 | mov [esp+8], edx 164 | call ecx 165 | leave 166 | ret 167 | 168 | %endif 169 | 170 | ;----------------------------------------------------------------------------- 171 | ; void cpu_emms( void ) 172 | ;----------------------------------------------------------------------------- 173 | cglobal cpu_emms 174 | emms 175 | ret 176 | 177 | ;----------------------------------------------------------------------------- 178 | ; void cpu_sfence( void ) 179 | ;----------------------------------------------------------------------------- 180 | cglobal cpu_sfence 181 | sfence 182 | ret 183 | 184 | %if 0 ; REMOVED 185 | cextern intel_cpu_indicator_init 186 | 187 | ;----------------------------------------------------------------------------- 188 | ; void safe_intel_cpu_indicator_init( void ); 189 | ;----------------------------------------------------------------------------- 190 | cglobal safe_intel_cpu_indicator_init 191 | push r0 192 | push r1 193 | push r2 194 | push r3 195 | push r4 196 | push r5 197 | push r6 198 | %if ARCH_X86_64 199 | push r7 200 | push r8 201 | push r9 202 | push r10 203 | push r11 204 | push r12 205 | push r13 206 | push r14 207 | %endif 208 | push rbp 209 | mov rbp, rsp 210 | %if WIN64 211 | sub rsp, 32 ; shadow space 212 | %endif 213 | and rsp, ~31 214 | call intel_cpu_indicator_init 215 | leave 216 | %if ARCH_X86_64 217 | pop r14 218 | pop r13 219 | pop r12 220 | pop r11 221 | pop r10 222 | pop r9 223 | pop r8 224 | pop r7 225 | %endif 226 | pop r6 227 | pop r5 228 | pop r4 229 | pop r3 230 | pop r2 231 | pop r1 232 | pop r0 233 | ret 234 | 235 | %endif ; if 0 -------------------------------------------------------------------------------- /source/common/vec/intrinsic_quant.c: -------------------------------------------------------------------------------- 1 | /* 2 | * intrinsic_quant.c 3 | * 4 | * Description of this file: 5 | * SSE assembly functions of QUANT module of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | #include "../basic_types.h" 38 | #include "intrinsic.h" 39 | 40 | 41 | #include 42 | #include 43 | #include // SSE 44 | #include // SSE3 45 | #include // SSSE3 46 | #include 47 | 48 | int quant_c_sse128(coeff_t *coef, const int i_coef, const int scale, const int shift, const int add) 49 | { 50 | __m128i mScale, mAdd; 51 | __m128i data0, data1; 52 | __m128i T0, T1; 53 | __m128i mZero, mCount; 54 | int i; 55 | 56 | mScale = _mm_set1_epi32(scale); 57 | mAdd = _mm_set1_epi32(add); 58 | mZero = _mm_setzero_si128(); 59 | mCount = _mm_setzero_si128(); 60 | 61 | for (i = 0; i < i_coef; i += 16) { 62 | data0 = _mm_cvtepi16_epi32(_mm_loadl_epi64((__m128i *)(coef + i))); 63 | data1 = _mm_cvtepi16_epi32(_mm_loadl_epi64((__m128i *)(coef + i + 4))); 64 | 65 | T0 = _mm_abs_epi32(data0); 66 | T1 = _mm_abs_epi32(data1); 67 | 68 | T0 = _mm_mullo_epi32(T0, mScale); 69 | T1 = _mm_mullo_epi32(T1, mScale); 70 | 71 | T0 = _mm_add_epi32(T0, mAdd); 72 | T1 = _mm_add_epi32(T1, mAdd); 73 | 74 | T0 = _mm_srai_epi32(T0, shift); 75 | T1 = _mm_srai_epi32(T1, shift); 76 | 77 | T0 = _mm_sign_epi32(T0, data0); 78 | T1 = _mm_sign_epi32(T1, data1); 79 | 80 | T0 = _mm_packs_epi32(T0, T1); 81 | 82 | _mm_store_si128((__m128i *)(coef + i), T0); 83 | mCount = _mm_sub_epi16(mCount, _mm_cmpeq_epi16(T0, mZero)); 84 | 85 | data0 = _mm_cvtepi16_epi32(_mm_loadl_epi64((__m128i *)(coef + i + 8))); 86 | data1 = _mm_cvtepi16_epi32(_mm_loadl_epi64((__m128i *)(coef + i + 12))); 87 | 88 | T0 = _mm_abs_epi32(data0); 89 | T1 = _mm_abs_epi32(data1); 90 | 91 | T0 = _mm_mullo_epi32(T0, mScale); 92 | T1 = _mm_mullo_epi32(T1, mScale); 93 | 94 | T0 = _mm_add_epi32(T0, mAdd); 95 | T1 = _mm_add_epi32(T1, mAdd); 96 | 97 | T0 = _mm_srai_epi32(T0, shift); 98 | T1 = _mm_srai_epi32(T1, shift); 99 | 100 | T0 = _mm_sign_epi32(T0, data0); 101 | T1 = _mm_sign_epi32(T1, data1); 102 | 103 | T0 = _mm_packs_epi32(T0, T1); 104 | 105 | _mm_store_si128((__m128i *)(coef + i + 8), T0); 106 | mCount = _mm_sub_epi16(mCount, _mm_cmpeq_epi16(T0, mZero)); 107 | } 108 | mCount = _mm_packus_epi16(mCount, mCount); 109 | mCount = _mm_sad_epu8(mCount, mZero); // get the total number of 0 110 | 111 | return i_coef - _mm_extract_epi16(mCount, 0); 112 | } 113 | 114 | void dequant_c_sse128(coeff_t *coef, const int i_coef, const int scale, const int shift, const int add) 115 | { 116 | __m128i mScale, mAdd; 117 | __m128i data0, data1; 118 | int i; 119 | 120 | mScale = _mm_set1_epi32(scale); 121 | mAdd = _mm_set1_epi32(add); 122 | 123 | for (i = 0; i < i_coef; i += 16) { 124 | data0 = _mm_cvtepi16_epi32(_mm_loadl_epi64((__m128i *)(coef + i))); 125 | data1 = _mm_cvtepi16_epi32(_mm_loadl_epi64((__m128i *)(coef + i + 4))); 126 | 127 | data0 = _mm_mullo_epi32(data0, mScale); 128 | data1 = _mm_mullo_epi32(data1, mScale); 129 | 130 | data0 = _mm_add_epi32(data0, mAdd); 131 | data1 = _mm_add_epi32(data1, mAdd); 132 | 133 | data0 = _mm_srai_epi32(data0, shift); 134 | data1 = _mm_srai_epi32(data1, shift); 135 | 136 | _mm_store_si128((__m128i *)(coef + i), _mm_packs_epi32(data0, data1)); 137 | 138 | data0 = _mm_cvtepi16_epi32(_mm_loadl_epi64((__m128i *)(coef + i + 8))); 139 | data1 = _mm_cvtepi16_epi32(_mm_loadl_epi64((__m128i *)(coef + i + 12))); 140 | 141 | data0 = _mm_mullo_epi32(data0, mScale); 142 | data1 = _mm_mullo_epi32(data1, mScale); 143 | 144 | data0 = _mm_add_epi32(data0, mAdd); 145 | data1 = _mm_add_epi32(data1, mAdd); 146 | 147 | data0 = _mm_srai_epi32(data0, shift); 148 | data1 = _mm_srai_epi32(data1, shift); 149 | 150 | _mm_store_si128((__m128i *)(coef + i + 8), _mm_packs_epi32(data0, data1)); 151 | } 152 | } 153 | 154 | void abs_coeff_sse128(coeff_t *dst, const coeff_t *src, const int i_coef) 155 | { 156 | int i; 157 | 158 | for (i = 0; i < i_coef; i += 16) { 159 | _mm_store_si128((__m128i *)(dst + i), _mm_abs_epi16(_mm_load_si128((__m128i *)(src + i)))); 160 | _mm_store_si128((__m128i *)(dst + i + 8), _mm_abs_epi16(_mm_load_si128((__m128i *)(src + i + 8)))); 161 | } 162 | } 163 | 164 | int add_sign_sse128(coeff_t *dst, const coeff_t *abs_val, const int i_coef) 165 | { 166 | __m128i mDst, mAbs; 167 | __m128i mZero, mCount; 168 | int i; 169 | 170 | mZero = _mm_setzero_si128(); 171 | mCount = _mm_setzero_si128(); 172 | 173 | for (i = 0; i < i_coef; i += 16) { 174 | mDst = _mm_load_si128((__m128i *)(dst + i)); 175 | mAbs = _mm_load_si128((__m128i *)(abs_val + i)); 176 | mDst = _mm_sign_epi16(mAbs, mDst); 177 | _mm_store_si128((__m128i *)(dst + i), mDst); 178 | mCount = _mm_sub_epi16(mCount, _mm_cmpeq_epi16(mAbs, mZero)); 179 | 180 | mDst = _mm_load_si128((__m128i *)(dst + i + 8)); 181 | mAbs = _mm_load_si128((__m128i *)(abs_val + i + 8)); 182 | mDst = _mm_sign_epi16(mAbs, mDst); 183 | _mm_store_si128((__m128i *)(dst + i + 8), mDst); 184 | mCount = _mm_sub_epi16(mCount, _mm_cmpeq_epi16(mAbs, mZero)); 185 | } 186 | mCount = _mm_packus_epi16(mCount, mCount); 187 | mCount = _mm_sad_epu8(mCount, mZero); 188 | 189 | return i_coef - _mm_extract_epi16(mCount, 0); 190 | } 191 | -------------------------------------------------------------------------------- /source/compat/getopt/getopt.h: -------------------------------------------------------------------------------- 1 | /* Declarations for getopt. 2 | Copyright (C) 1989-1994, 1996-1999, 2001 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _GETOPT_H 21 | 22 | #ifndef __need_getopt 23 | # define _GETOPT_H 1 24 | #endif 25 | 26 | #include 27 | 28 | /* If __GNU_LIBRARY__ is not already defined, either we are being used 29 | standalone, or this is the first header included in the source file. 30 | If we are being used with glibc, we need to include , but 31 | that does not exist if we are standalone. So: if __GNU_LIBRARY__ is 32 | not defined, include , which will pull in for us 33 | if it's from glibc. (Why ctype.h? It's guaranteed to exist and it 34 | doesn't flood the namespace with stuff the way some other headers do.) */ 35 | #if !defined __GNU_LIBRARY__ 36 | # include 37 | #endif 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /* For communication from `getopt' to the caller. 44 | When `getopt' finds an option that takes an argument, 45 | the argument value is returned here. 46 | Also, when `ordering' is RETURN_IN_ORDER, 47 | each non-option ARGV-element is returned here. */ 48 | 49 | extern char *optarg; 50 | 51 | /* Index in ARGV of the next element to be scanned. 52 | This is used for communication to and from the caller 53 | and for communication between successive calls to `getopt'. 54 | 55 | On entry to `getopt', zero means this is the first call; initialize. 56 | 57 | When `getopt' returns -1, this is the index of the first of the 58 | non-option elements that the caller should itself scan. 59 | 60 | Otherwise, `optind' communicates from one call to the next 61 | how much of ARGV has been scanned so far. */ 62 | 63 | extern int optind; 64 | 65 | /* Callers store zero here to inhibit the error message `getopt' prints 66 | for unrecognized options. */ 67 | 68 | extern int opterr; 69 | 70 | /* Set to an option character which was unrecognized. */ 71 | 72 | extern int optopt; 73 | 74 | #ifndef __need_getopt 75 | /* Describe the long-named options requested by the application. 76 | The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector 77 | of `struct option' terminated by an element containing a name which is 78 | zero. 79 | 80 | The field `has_arg' is: 81 | no_argument (or 0) if the option does not take an argument, 82 | required_argument (or 1) if the option requires an argument, 83 | optional_argument (or 2) if the option takes an optional argument. 84 | 85 | If the field `flag' is not NULL, it points to a variable that is set 86 | to the value given in the field `val' when the option is found, but 87 | left unchanged if the option is not found. 88 | 89 | To have a long-named option do something other than set an `int' to 90 | a compiled-in constant, such as set a value from `optarg', set the 91 | option's `flag' field to zero and its `val' field to a nonzero 92 | value (the equivalent single-letter option character, if there is 93 | one). For long options that have a zero `flag' field, `getopt' 94 | returns the contents of the `val' field. */ 95 | 96 | struct option { 97 | # if (defined __STDC__ && __STDC__) || defined __cplusplus 98 | const char *name; 99 | # else 100 | char *name; 101 | # endif 102 | /* has_arg can't be an enum because some compilers complain about 103 | type mismatches in all the code that assumes it is an int. */ 104 | int has_arg; 105 | int32_t *flag; 106 | int val; 107 | }; 108 | 109 | /* Names for the values of the `has_arg' field of `struct option'. */ 110 | 111 | # define no_argument 0 112 | # define required_argument 1 113 | # define optional_argument 2 114 | #endif /* need getopt */ 115 | 116 | 117 | /* Get definitions and prototypes for functions to process the 118 | arguments in ARGV (ARGC of them, minus the program name) for 119 | options given in OPTS. 120 | 121 | Return the option character from OPTS just read. Return -1 when 122 | there are no more options. For unrecognized options, or options 123 | missing arguments, `optopt' is set to the option letter, and '?' is 124 | returned. 125 | 126 | The OPTS string is a list of characters which are recognized option 127 | letters, optionally followed by colons, specifying that that letter 128 | takes an argument, to be placed in `optarg'. 129 | 130 | If a letter in OPTS is followed by two colons, its argument is 131 | optional. This behavior is specific to the GNU `getopt'. 132 | 133 | The argument `--' causes premature termination of argument 134 | scanning, explicitly telling `getopt' that there are no more 135 | options. 136 | 137 | If OPTS begins with `--', then non-option arguments are treated as 138 | arguments to the option '\0'. This behavior is specific to the GNU 139 | `getopt'. */ 140 | 141 | #if (defined __STDC__ && __STDC__) || defined __cplusplus 142 | # ifdef __GNU_LIBRARY__ 143 | /* Many other libraries have conflicting prototypes for getopt, with 144 | differences in the consts, in stdlib.h. To avoid compilation 145 | errors, only prototype getopt for the GNU C library. */ 146 | extern int getopt(int __argc, char *const *__argv, const char *__shortopts); 147 | # else /* not __GNU_LIBRARY__ */ 148 | extern int getopt(); 149 | # endif /* __GNU_LIBRARY__ */ 150 | 151 | # ifndef __need_getopt 152 | extern int getopt_long(int __argc, char *const *__argv, const char *__shortopts, 153 | const struct option *__longopts, int32_t *__longind); 154 | extern int getopt_long_only(int __argc, char *const *__argv, 155 | const char *__shortopts, 156 | const struct option *__longopts, int32_t *__longind); 157 | 158 | /* Internal only. Users should not call this directly. */ 159 | extern int _getopt_internal(int __argc, char *const *__argv, 160 | const char *__shortopts, 161 | const struct option *__longopts, int32_t *__longind, 162 | int __long_only); 163 | # endif 164 | #else /* not __STDC__ */ 165 | extern int getopt(); 166 | # ifndef __need_getopt 167 | extern int getopt_long(); 168 | extern int getopt_long_only(); 169 | 170 | extern int _getopt_internal(); 171 | # endif 172 | #endif /* __STDC__ */ 173 | 174 | #ifdef __cplusplus 175 | } 176 | #endif 177 | 178 | /* Make sure we later can get all the definitions and declarations. */ 179 | #undef __need_getopt 180 | 181 | #endif /* getopt.h */ 182 | -------------------------------------------------------------------------------- /source/common/x86/pixel.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * pixel.h: x86 pixel metrics 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2013 x264 project 5 | * Copyright (C) 2013-2017 MulticoreWare, Inc 6 | * 7 | * Authors: Laurent Aimar 8 | * Loren Merritt 9 | * Fiona Glaser 10 | ;* Min Chen 11 | * Jiaqi Zhang 12 | * 13 | * This program is free software; you can redistribute it and/or modify 14 | * it under the terms of the GNU General Public License as published by 15 | * the Free Software Foundation; either version 2 of the License, or 16 | * (at your option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | * GNU General Public License for more details. 22 | * 23 | * You should have received a copy of the GNU General Public License 24 | * along with this program; if not, write to the Free Software 25 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 26 | * 27 | * This program is also available under a commercial proprietary license. 28 | * For more information, contact us at license @ x265.com. 29 | *****************************************************************************/ 30 | 31 | #ifndef XAVS2_X86_PIXEL_H 32 | #define XAVS2_X86_PIXEL_H 33 | 34 | 35 | /** 36 | * =========================================================================== 37 | * function declares 38 | * =========================================================================== 39 | */ 40 | 41 | #define FUNCDEF_TU(ret, name, cpu, ...) \ 42 | ret FPFX(name ## _4x4_ ## cpu(__VA_ARGS__));\ 43 | ret FPFX(name ## _8x8_ ## cpu(__VA_ARGS__));\ 44 | ret FPFX(name ## _16x16_ ## cpu(__VA_ARGS__));\ 45 | ret FPFX(name ## _32x32_ ## cpu(__VA_ARGS__));\ 46 | ret FPFX(name ## _64x64_ ## cpu(__VA_ARGS__)) 47 | 48 | #define FUNCDEF_TU_S(ret, name, cpu, ...) \ 49 | ret FPFX(name ## _4_ ## cpu(__VA_ARGS__));\ 50 | ret FPFX(name ## _8_ ## cpu(__VA_ARGS__));\ 51 | ret FPFX(name ## _16_ ## cpu(__VA_ARGS__));\ 52 | ret FPFX(name ## _32_ ## cpu(__VA_ARGS__));\ 53 | ret FPFX(name ## _64_ ## cpu(__VA_ARGS__)) 54 | 55 | #define FUNCDEF_PU(ret, name, cpu, ...) \ 56 | ret FPFX(name ## _4x4_ ## cpu)(__VA_ARGS__);\ 57 | ret FPFX(name ## _8x8_ ## cpu)(__VA_ARGS__);\ 58 | ret FPFX(name ## _16x16_ ## cpu)(__VA_ARGS__);\ 59 | ret FPFX(name ## _32x32_ ## cpu)(__VA_ARGS__);\ 60 | ret FPFX(name ## _64x64_ ## cpu)(__VA_ARGS__);\ 61 | ret FPFX(name ## _8x4_ ## cpu)(__VA_ARGS__);\ 62 | ret FPFX(name ## _4x8_ ## cpu)(__VA_ARGS__);\ 63 | ret FPFX(name ## _16x8_ ## cpu)(__VA_ARGS__);\ 64 | ret FPFX(name ## _8x16_ ## cpu)(__VA_ARGS__);\ 65 | ret FPFX(name ## _16x32_ ## cpu)(__VA_ARGS__);\ 66 | ret FPFX(name ## _32x16_ ## cpu)(__VA_ARGS__);\ 67 | ret FPFX(name ## _64x32_ ## cpu)(__VA_ARGS__);\ 68 | ret FPFX(name ## _32x64_ ## cpu)(__VA_ARGS__);\ 69 | ret FPFX(name ## _16x12_ ## cpu)(__VA_ARGS__);\ 70 | ret FPFX(name ## _12x16_ ## cpu)(__VA_ARGS__);\ 71 | ret FPFX(name ## _16x4_ ## cpu)(__VA_ARGS__);\ 72 | ret FPFX(name ## _4x16_ ## cpu)(__VA_ARGS__);\ 73 | ret FPFX(name ## _32x24_ ## cpu)(__VA_ARGS__);\ 74 | ret FPFX(name ## _24x32_ ## cpu)(__VA_ARGS__);\ 75 | ret FPFX(name ## _32x8_ ## cpu)(__VA_ARGS__);\ 76 | ret FPFX(name ## _8x32_ ## cpu)(__VA_ARGS__);\ 77 | ret FPFX(name ## _64x48_ ## cpu)(__VA_ARGS__);\ 78 | ret FPFX(name ## _48x64_ ## cpu)(__VA_ARGS__);\ 79 | ret FPFX(name ## _64x16_ ## cpu)(__VA_ARGS__);\ 80 | ret FPFX(name ## _16x64_ ## cpu)(__VA_ARGS__) 81 | 82 | #define FUNCDEF_CHROMA_PU(ret, name, cpu, ...) \ 83 | FUNCDEF_PU(ret, name, cpu, __VA_ARGS__);\ 84 | ret FPFX(name ## _4x2_ ## cpu)(__VA_ARGS__);\ 85 | ret FPFX(name ## _2x4_ ## cpu)(__VA_ARGS__);\ 86 | ret FPFX(name ## _8x2_ ## cpu)(__VA_ARGS__);\ 87 | ret FPFX(name ## _2x8_ ## cpu)(__VA_ARGS__);\ 88 | ret FPFX(name ## _8x6_ ## cpu)(__VA_ARGS__);\ 89 | ret FPFX(name ## _6x8_ ## cpu)(__VA_ARGS__);\ 90 | ret FPFX(name ## _8x12_ ## cpu)(__VA_ARGS__);\ 91 | ret FPFX(name ## _12x8_ ## cpu)(__VA_ARGS__);\ 92 | ret FPFX(name ## _6x16_ ## cpu)(__VA_ARGS__);\ 93 | ret FPFX(name ## _16x6_ ## cpu)(__VA_ARGS__);\ 94 | ret FPFX(name ## _2x16_ ## cpu)(__VA_ARGS__);\ 95 | ret FPFX(name ## _16x2_ ## cpu)(__VA_ARGS__);\ 96 | ret FPFX(name ## _4x12_ ## cpu)(__VA_ARGS__);\ 97 | ret FPFX(name ## _12x4_ ## cpu)(__VA_ARGS__);\ 98 | ret FPFX(name ## _32x12_ ## cpu)(__VA_ARGS__);\ 99 | ret FPFX(name ## _12x32_ ## cpu)(__VA_ARGS__);\ 100 | ret FPFX(name ## _32x4_ ## cpu)(__VA_ARGS__);\ 101 | ret FPFX(name ## _4x32_ ## cpu)(__VA_ARGS__);\ 102 | ret FPFX(name ## _32x48_ ## cpu)(__VA_ARGS__);\ 103 | ret FPFX(name ## _48x32_ ## cpu)(__VA_ARGS__);\ 104 | ret FPFX(name ## _16x24_ ## cpu)(__VA_ARGS__);\ 105 | ret FPFX(name ## _24x16_ ## cpu)(__VA_ARGS__);\ 106 | ret FPFX(name ## _8x64_ ## cpu)(__VA_ARGS__);\ 107 | ret FPFX(name ## _64x8_ ## cpu)(__VA_ARGS__);\ 108 | ret FPFX(name ## _64x24_ ## cpu)(__VA_ARGS__);\ 109 | ret FPFX(name ## _24x64_ ## cpu)(__VA_ARGS__); 110 | 111 | #define DECL_PIXELS(cpu) \ 112 | FUNCDEF_PU(int, pixel_ssd, cpu, const pel_t*, intptr_t, const pel_t*, intptr_t);\ 113 | FUNCDEF_PU(int, pixel_sa8d, cpu, const pel_t*, intptr_t, const pel_t*, intptr_t);\ 114 | FUNCDEF_PU(void, pixel_sad_x3, cpu, const pel_t*, const pel_t*, const pel_t*, const pel_t*, intptr_t, int32_t*);\ 115 | FUNCDEF_PU(void, pixel_sad_x4, cpu, const pel_t*, const pel_t*, const pel_t*, const pel_t*, const pel_t*, intptr_t, int32_t*);\ 116 | FUNCDEF_PU(void, pixel_avg, cpu, pel_t* dst, intptr_t dstride, const pel_t* src0, intptr_t sstride0, const pel_t* src1, intptr_t sstride1, int);\ 117 | FUNCDEF_PU(void, pixel_add_ps, cpu, pel_t* a, intptr_t dstride, const pel_t* b0, const coeff_t* b1, intptr_t sstride0, intptr_t sstride1);\ 118 | FUNCDEF_PU(void, pixel_sub_ps, cpu, coeff_t* a, intptr_t dstride, const pel_t* b0, const pel_t* b1, intptr_t sstride0, intptr_t sstride1);\ 119 | FUNCDEF_PU(int, pixel_satd, cpu, const pel_t*, intptr_t, const pel_t*, intptr_t);\ 120 | FUNCDEF_PU(int, pixel_sad, cpu, const pel_t*, intptr_t, const pel_t*, intptr_t);\ 121 | FUNCDEF_PU(int, pixel_ssd_ss, cpu, const int16_t*, intptr_t, const int16_t*, intptr_t);\ 122 | FUNCDEF_PU(void, addAvg, cpu, const int16_t*, const int16_t*, pel_t*, intptr_t, intptr_t, intptr_t);\ 123 | FUNCDEF_PU(int, pixel_ssd_s, cpu, const int16_t*, intptr_t);\ 124 | FUNCDEF_TU_S(int, pixel_ssd_s, cpu, const int16_t*, intptr_t);\ 125 | FUNCDEF_TU(uint64_t, pixel_var, cpu, const pel_t*, intptr_t);\ 126 | FUNCDEF_TU(int, psyCost_pp, cpu, const pel_t* source, intptr_t sstride, const pel_t* recon, intptr_t rstride);\ 127 | FUNCDEF_TU(int, psyCost_ss, cpu, const int16_t* source, intptr_t sstride, const int16_t* recon, intptr_t rstride) 128 | 129 | DECL_PIXELS(mmx); 130 | DECL_PIXELS(mmx2); 131 | DECL_PIXELS(sse2); 132 | DECL_PIXELS(sse3); 133 | DECL_PIXELS(sse4); 134 | DECL_PIXELS(ssse3); 135 | DECL_PIXELS(avx); 136 | DECL_PIXELS(xop); 137 | DECL_PIXELS(avx2); 138 | 139 | #undef DECL_PIXELS 140 | 141 | #endif // XAVS2_X86_PIXEL_H 142 | -------------------------------------------------------------------------------- /source/common/vec/intrinsic_cg_scan.c: -------------------------------------------------------------------------------- 1 | /* 2 | * intrinsic_cg_scan.c 3 | * 4 | * Description of this file: 5 | * SSE assembly functions of CG-Scanning module of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * Jiaqi ZHANG 14 | * etc. 15 | * 16 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 17 | * Homepage2: https://github.com/pkuvcl/xavs2 18 | * Homepage3: https://gitee.com/pkuvcl/xavs2 19 | * 20 | * This program is free software; you can redistribute it and/or modify 21 | * it under the terms of the GNU General Public License as published by 22 | * the Free Software Foundation; either version 2 of the License, or 23 | * (at your option) any later version. 24 | * 25 | * This program is distributed in the hope that it will be useful, 26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 | * GNU General Public License for more details. 29 | * 30 | * You should have received a copy of the GNU General Public License 31 | * along with this program; if not, write to the Free Software 32 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 33 | * 34 | * This program is also available under a commercial proprietary license. 35 | * For more information, contact us at sswang @ pku.edu.cn. 36 | */ 37 | 38 | #include "../common.h" 39 | #include "intrinsic.h" 40 | 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | 47 | /* --------------------------------------------------------------------------- 48 | */ 49 | void coeff_scan_4x4_xy_sse128(coeff_t *dst, const coeff_t *src, int i_src_shift) 50 | { 51 | __m128i row0, row1, row2, row3; 52 | __m128i dst1, dst2; 53 | __m128i order1, order2; 54 | int int1, int2; 55 | 56 | order1 = _mm_setr_epi16(0x0100, 0x0302, 0x0908, 0x0F0E, 0x0B0A, 0x0504, 0x0706, 0x0D0C); 57 | order2 = _mm_setr_epi16(0x0302, 0x0908, 0x0B0A, 0x0504, 0x0100, 0x0706, 0x0D0C, 0x0F0E); 58 | 59 | row0 = _mm_loadl_epi64((const __m128i*)&src[0 << i_src_shift]); 60 | row1 = _mm_loadl_epi64((const __m128i*)&src[(int64_t)(1 << i_src_shift)]); 61 | row2 = _mm_loadl_epi64((const __m128i*)&src[2 << i_src_shift]); 62 | row3 = _mm_loadl_epi64((const __m128i*)&src[3 << i_src_shift]); 63 | 64 | dst1 = _mm_unpacklo_epi64(row0, row1); //0 1 2 3 4 5 6 7 65 | dst2 = _mm_unpacklo_epi64(row2, row3); //8 9 10 11 12 13 14 15 66 | 67 | int1 = _mm_extract_epi16(dst1, 7); 68 | int2 = _mm_extract_epi16(dst2, 0); 69 | 70 | dst1 = _mm_insert_epi16(dst1, int2, 7); //0 1 2 3 4 5 6 8 71 | dst2 = _mm_insert_epi16(dst2, int1, 0); //7 9 10 11 12 13 14 15 72 | 73 | //0 1 2 3 4 5 6 8 -------> 0 1 4 8 5 2 3 6 74 | dst1 = _mm_shuffle_epi8(dst1, order1); 75 | //0 1 2 3 4 5 6 7 76 | //7 9 10 11 12 13 14 15 --------> 9 12 13 10 7 11 14 15 77 | dst2 = _mm_shuffle_epi8(dst2, order2); 78 | 79 | _mm_store_si128((__m128i*)(dst + 0), dst1); 80 | _mm_store_si128((__m128i*)(dst + 8), dst2); 81 | } 82 | 83 | /* --------------------------------------------------------------------------- 84 | */ 85 | void coeff_scan_4x4_yx_sse128(coeff_t *dst, const coeff_t *src, int i_src_shift) 86 | { 87 | __m128i row0, row1, row2, row3; 88 | __m128i dst1, dst2; 89 | __m128i order1, order2; 90 | int int1, int2; 91 | 92 | order1 = _mm_setr_epi16(0x0100, 0x0908, 0x0302, 0x0504, 0x0B0A, 0x0D0C, 0x0706, 0x0F0E); 93 | order2 = _mm_setr_epi16(0x0100, 0x0908, 0x0302, 0x0504, 0x0B0A, 0x0D0C, 0x0706, 0x0F0E); 94 | 95 | row0 = _mm_loadl_epi64((const __m128i*)&src[0 << i_src_shift]); // 0 1 2 3 96 | row1 = _mm_loadl_epi64((const __m128i*)&src[(int64_t)1 << i_src_shift]); // 4 5 6 7 97 | row2 = _mm_loadl_epi64((const __m128i*)&src[2 << i_src_shift]); // 8 9 10 11 98 | row3 = _mm_loadl_epi64((const __m128i*)&src[3 << i_src_shift]); //12 13 14 15 99 | 100 | dst1 = _mm_unpacklo_epi64(row0, row1); //0 1 2 3 4 5 6 7 101 | dst2 = _mm_unpacklo_epi64(row2, row3); //8 9 10 11 12 13 14 15 102 | 103 | int1 = _mm_extract_epi32(dst1, 3); 104 | int2 = _mm_extract_epi32(dst2, 0); 105 | 106 | dst1 = _mm_insert_epi32(dst1, int2, 3); //0 1 2 3 4 5 8 9 107 | dst2 = _mm_insert_epi32(dst2, int1, 0); //6 7 10 11 12 13 14 15 108 | 109 | int1 = _mm_extract_epi16(dst1, 3); 110 | int2 = _mm_extract_epi16(dst2, 4); 111 | 112 | dst1 = _mm_insert_epi16(dst1, int2, 3); //0 1 2 12 4 5 8 9 113 | dst2 = _mm_insert_epi16(dst2, int1, 4); //6 7 10 11 3 13 14 15 114 | 115 | //0 1 2 3 4 5 6 7 116 | //0 1 2 12 4 5 8 9 -------> 0 4 1 2 5 8 12 9 117 | dst1 = _mm_shuffle_epi8(dst1, order1); 118 | //0 1 2 3 4 5 6 7 119 | //6 7 10 11 3 13 14 15 --------> 6 3 7 10 13 14 11 15 120 | dst2 = _mm_shuffle_epi8(dst2, order2); 121 | 122 | _mm_store_si128((__m128i*)(dst + 0), dst1); 123 | _mm_store_si128((__m128i*)(dst + 8), dst2); 124 | } 125 | 126 | #if ARCH_X86_64 127 | /* --------------------------------------------------------------------------- 128 | */ 129 | void coeff_scan4_xy_sse128(coeff_t *dst, uint64_t r1, uint64_t r2, uint64_t r3, uint64_t r4) 130 | { 131 | __m128i dst1, dst2; 132 | __m128i order1, order2; 133 | int int1, int2; 134 | 135 | order1 = _mm_setr_epi16(0x0100, 0x0302, 0x0908, 0x0F0E, 0x0B0A, 0x0504, 0x0706, 0x0D0C); 136 | order2 = _mm_setr_epi16(0x0302, 0x0908, 0x0B0A, 0x0504, 0x0100, 0x0706, 0x0D0C, 0x0F0E); 137 | 138 | dst1 = _mm_set_epi64x((int64_t)r2, (int64_t)r1); //0 1 2 3 4 5 6 7 139 | dst2 = _mm_set_epi64x((int64_t)r4, (int64_t)r3); //8 9 10 11 12 13 14 15 140 | 141 | int1 = _mm_extract_epi16(dst1, 7); 142 | int2 = _mm_extract_epi16(dst2, 0); 143 | 144 | dst1 = _mm_insert_epi16(dst1, int2, 7); //0 1 2 3 4 5 6 8 145 | dst2 = _mm_insert_epi16(dst2, int1, 0); //7 9 10 11 12 13 14 15 146 | 147 | //0 1 2 3 4 5 6 8 -------> 0 1 4 8 5 2 3 6 148 | dst1 = _mm_shuffle_epi8(dst1, order1); 149 | //0 1 2 3 4 5 6 7 150 | //7 9 10 11 12 13 14 15 --------> 9 12 13 10 7 11 14 15 151 | dst2 = _mm_shuffle_epi8(dst2, order2); 152 | 153 | _mm_store_si128((__m128i*)(dst + 0), dst1); 154 | _mm_store_si128((__m128i*)(dst + 8), dst2); 155 | } 156 | 157 | /* --------------------------------------------------------------------------- 158 | */ 159 | void coeff_scan4_yx_sse128(coeff_t *dst, uint64_t r1, uint64_t r2, uint64_t r3, uint64_t r4) 160 | { 161 | __m128i dst1, dst2; 162 | __m128i order1, order2; 163 | int int1, int2; 164 | 165 | order1 = _mm_setr_epi16(0x0100, 0x0908, 0x0302, 0x0504, 0x0B0A, 0x0D0C, 0x0706, 0x0F0E); 166 | order2 = _mm_setr_epi16(0x0100, 0x0908, 0x0302, 0x0504, 0x0B0A, 0x0D0C, 0x0706, 0x0F0E); 167 | 168 | dst1 = _mm_set_epi64x((int64_t)r2, (int64_t)r1); //0 1 2 3 4 5 6 7 169 | dst2 = _mm_set_epi64x((int64_t)r4, (int64_t)r3); //8 9 10 11 12 13 14 15 170 | 171 | int1 = _mm_extract_epi32(dst1, 3); 172 | int2 = _mm_extract_epi32(dst2, 0); 173 | 174 | dst1 = _mm_insert_epi32(dst1, int2, 3); //0 1 2 3 4 5 8 9 175 | dst2 = _mm_insert_epi32(dst2, int1, 0); //6 7 10 11 12 13 14 15 176 | 177 | int1 = _mm_extract_epi16(dst1, 3); 178 | int2 = _mm_extract_epi16(dst2, 4); 179 | 180 | dst1 = _mm_insert_epi16(dst1, int2, 3); //0 1 2 12 4 5 8 9 181 | dst2 = _mm_insert_epi16(dst2, int1, 4); //6 7 10 11 3 13 14 15 182 | 183 | //0 1 2 3 4 5 6 7 184 | //0 1 2 12 4 5 8 9 -------> 0 4 1 2 5 8 12 9 185 | dst1 = _mm_shuffle_epi8(dst1, order1); 186 | //0 1 2 3 4 5 6 7 187 | //6 7 10 11 3 13 14 15 --------> 6 3 7 10 13 14 11 15 188 | dst2 = _mm_shuffle_epi8(dst2, order2); 189 | 190 | _mm_store_si128((__m128i*)(dst + 0), dst1); 191 | _mm_store_si128((__m128i*)(dst + 8), dst2); 192 | } 193 | #endif // ARCH_X86_64 194 | -------------------------------------------------------------------------------- /config/encoder_ai.cfg: -------------------------------------------------------------------------------- 1 | # New Input File Format is as follows 2 | # = # Comment 3 | # See configfile.h for a list of supported ParameterNames 4 | 5 | ########################################################################################## 6 | # Files 7 | ########################################################################################## 8 | InputFile = "E:\Seq\BasketballPass_416x240_50.yuv" # Input sequence, YUV 4:2:0 9 | FramesToBeEncoded = 30 # Number of frames to be coded 10 | SourceWidth = 416 # Image width in Pels 11 | SourceHeight = 240 # Image height in Pels 12 | fps = 50.0 # framerate, AVS2 supported: 23.976(24000/1001), 24.0, 25.0(default), 29.97(30000/1001), 30.0, 50.0, 59.94(60000/1001), 60.0 13 | ChromaFormat = 1 # chroma format, 1=4:2:0 (default, the only supported format for the standard), 0=4:0:0, 2=4:2:2 14 | InputSampleBitDepth = 8 # Source bit depth (8 bit or 10 bit for all components) 15 | SampleBitDepth = 8 # Internal coding bit depth (8 bit or 10 bit for all components) 16 | ReconFile = "test_rec.yuv" 17 | OutputFile = "test.avs" 18 | 19 | ########################################################################################## 20 | # Maximum Size 21 | ########################################################################################## 22 | MaxSizeInBit = 6 # Maximum CU size 23 | 24 | ########################################################################################## 25 | # Encoder Control 26 | ########################################################################################## 27 | ProfileID = 32 # Profile ID (18: MAIN PICTURE profile, 32: MAIN profile, 34: MAIN10 profile) 28 | LevelID = 66 # Level ID (16: 2.0; 32: 4.0; 34: 4.2; 64: 6.0; 66: 6.2) 29 | IntraPeriodMin = 1 # min Period of I-Frames (0=only first) 30 | IntraPeriodMax = 1 # max Period of I-Frames (0=only first) 31 | UseHadamard = 1 # Hadamard transform (0=not used, 1=used) 32 | 33 | ########################################################################################## 34 | # RD Optimization 35 | ########################################################################################## 36 | RdoLevel = 3 # RD-optimized mode decision (0:off, 1: only for best partition mode of one CU, 2: only for best 2 partition modes; 3: All partition modes) 37 | 38 | ########################################################################################## 39 | # Coding Tools 40 | ########################################################################################## 41 | NSQT = 0 # 42 | SDIP = 1 # 43 | SECTEnable = 1 # (0: Not use Secondary Transform, 1:Use Secondary Transform) 44 | 45 | ########################################################################################## 46 | # Loop filter parameters 47 | ########################################################################################## 48 | CrossSliceLoopFilter = 1 # Enable Cross Slice Boundary Filter (0=Disable, 1=Enable) 49 | 50 | LoopFilterDisable = 0 # Disable loop filter in picture header (0=Filter, 1=No Filter) 51 | LoopFilterParameter = 0 # Send loop filter parameter (0= No parameter, 1= Send Parameter) 52 | LoopFilterAlphaOffset = 0 # Aplha offset in loop filter 53 | LoopFilterBetaOffset = 0 # Beta offset in loop filter 54 | 55 | SAOEnable = 1 # Enable SAO (1=SAO on, 0=SAO OFF) 56 | ALFEnable = 1 # Enable ALF (1=ALF on, 0=ALF OFF) 57 | ALF_LowLatencyEncodingEnable = 0 # Enable Low Latency ALF (1=Low Latency ALF, 0=High Efficiency ALF) 58 | 59 | ########################################################################################## 60 | # Reference Picture Manage 61 | ########################################################################################## 62 | NumberBFrames = 0 # Number of B frames inserted (0=not used) 63 | gop_size = 1 # sub GOP size (negative numbers indicating an employ of default settings, which will invliadate the following settings.) 64 | # POC QPoffset #ref_pics_active ref_pic reference pictures predict deltaRPS num_ref_be_removed ref_be_removed 65 | Frame1: 1 0 0 0 0 1 1 66 | 67 | ######################################################################################## 68 | # Frequency Weighting Quantization 69 | ######################################################################################## 70 | WQEnable = 0 # Frequency Weighting Quantization (0=disable,1=enable) 71 | # SeqWQM = 0 # (0:default, 1:user define) 72 | # SeqWQFile = "seq_wq_matrix.txt" 73 | # 74 | # PicWQEnable = 0 # Frame level Frequency Weighting Quantization (0=disable,1=enable) 75 | # WQParam = 0 # Weighting Quantization Parameter(0=Default, 1=UnDetailed, 2=Detailed) 76 | # PicWQDataIndex = 1 # Picture level WQ data index (0:refer to seq_header, 77 | # # 1:derived by WQ parameter, 78 | # # 2:load from pic_header) 79 | # PicWQFile = "pic_wq_matrix.txt" 80 | # WQModel = 1 # Frequency Weighting Quantization Model (0-2) 81 | # WeightParamDetailed = "[128,98,106,116,116,128]" # User defined Parameters-Detailed 82 | # WeightParamUnDetailed = "[135,143,143,160,160,213]" # User defined Parameters-UnDetailed 83 | # 84 | # ChromaDeltaQPDisable = 1 # 1: Chroma Delta QP disable; 0: Chroma Delta QP enable 85 | # ChromaDeltaU = 0 # Chroma component U delta QP 86 | # ChromaDeltaV = 0 # Chroma component V delta QP 87 | 88 | ###################Encoder Optimization Tools############################################# 89 | ######################################################################################## 90 | #RDOQ 91 | ######################################################################################## 92 | RdoqLevel = 2 # (0: off, 1: cu level, only for best partition mode, 2: all mode) 93 | LambdaFactor = 75 # 94 | LambdaFactorP = 120 # 95 | LambdaFactorB = 100 # 96 | 97 | ########################################################################################## 98 | #RATECONTROL 99 | ########################################################################################## 100 | RateControl = 0 # 0: CQP, 1: CBR (frame level), 2: CBR (SCU level), 3: VBR 101 | TargetBitRate = 1000000 # (target bit-rate, in bps) 102 | initial_qp = 34 # initial qp for first frame (0-63) 103 | 104 | # ---------------------------------------------------------------------------- 105 | # preset level 106 | # ---------------------------------------------------------------------------- 107 | preset_level = 8 # preset level for the tradeoff between speed and performance, ordered from fastest to slowest (default 5) 108 | 109 | # ---------------------------------------------------------------------------- 110 | # slices 111 | # ---------------------------------------------------------------------------- 112 | slice_num = 1 # number of slices per frame 113 | 114 | # ---------------------------------------------------------------------------- 115 | # parallel 116 | # ---------------------------------------------------------------------------- 117 | thread_frames = 1 # number of parallel threads for frames ( 0: auto ) 118 | thread_rows = 1 # number of parallel threads for rows ( 0: auto ) 119 | 120 | # ---------------------------------------------------------------------------- 121 | # log level 122 | # ---------------------------------------------------------------------------- 123 | log_level = 3 # log level: -1: none, 0: error, 1: warning, 2: info, 3: debug 124 | -------------------------------------------------------------------------------- /source/common/pixel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pixel.h 3 | * 4 | * Description of this file: 5 | * Pixel processing functions definition of the xavs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * xavs2 - video encoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * Homepage1: http://vcl.idm.pku.edu.cn/xavs2 16 | * Homepage2: https://github.com/pkuvcl/xavs2 17 | * Homepage3: https://gitee.com/pkuvcl/xavs2 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2 of the License, or 22 | * (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 32 | * 33 | * This program is also available under a commercial proprietary license. 34 | * For more information, contact us at sswang @ pku.edu.cn. 35 | */ 36 | 37 | #ifndef XAVS2_PIXEL_H 38 | #define XAVS2_PIXEL_H 39 | 40 | 41 | /** 42 | * =========================================================================== 43 | * type defines 44 | * =========================================================================== 45 | */ 46 | 47 | /* --------------------------------------------------------------------------- 48 | * Luma PU partition 49 | */ 50 | enum LumaPU { 51 | /* square (the first 5 PUs match the block sizes) */ 52 | LUMA_4x4, LUMA_8x8, LUMA_16x16, LUMA_32x32, LUMA_64x64, 53 | /* rectangular */ 54 | LUMA_8x4, LUMA_4x8, 55 | LUMA_16x8, LUMA_8x16, 56 | LUMA_32x16, LUMA_16x32, 57 | LUMA_64x32, LUMA_32x64, 58 | /* asymmetrical (0.75, 0.25) */ 59 | LUMA_16x12, LUMA_12x16, LUMA_16x4, LUMA_4x16, 60 | LUMA_32x24, LUMA_24x32, LUMA_32x8, LUMA_8x32, 61 | LUMA_64x48, LUMA_48x64, LUMA_64x16, LUMA_16x64, 62 | /* number */ 63 | NUM_PU_SIZES, /* total number of PU sizes */ 64 | LUMA_INVALID = 255 65 | }; 66 | 67 | /* --------------------------------------------------------------------------- 68 | * Luma CU sizes, can be indexed using log2n(width)-2 69 | */ 70 | enum LumaCU { 71 | BLOCK_4x4, 72 | BLOCK_8x8, 73 | BLOCK_16x16, 74 | BLOCK_32x32, 75 | BLOCK_64x64, 76 | NUM_CU_SIZES /* total number of CU sizes */ 77 | }; 78 | 79 | /* --------------------------------------------------------------------------- 80 | * TU sizes 81 | */ 82 | enum TransUnit { 83 | /* square */ 84 | TU_4x4, TU_8x8, TU_16x16, TU_32x32, TU_64x64, 85 | /* asymmetrical */ 86 | TU_16x4, TU_4x16, 87 | TU_32x8, TU_8x32, 88 | TU_64x16, TU_16x64, 89 | /* number */ 90 | NUM_TU_SIZES /* total number of TU sizes */ 91 | }; 92 | 93 | /* --------------------------------------------------------------------------- 94 | * Chroma (only for 4:2:0) partition sizes. 95 | * These enum are only a convenience for indexing into the chroma primitive 96 | * arrays when instantiating macros or templates. The chroma function tables 97 | * should always be indexed by a LumaPU enum when used. 98 | */ 99 | enum ChromaPU { 100 | /* square */ 101 | CHROMA_2x2, CHROMA_4x4, CHROMA_8x8, CHROMA_16x16, CHROMA_32x32, 102 | /* rectangular */ 103 | CHROMA_4x2, CHROMA_2x4, 104 | CHROMA_8x4, CHROMA_4x8, 105 | CHROMA_16x8, CHROMA_8x16, 106 | CHROMA_32x16, CHROMA_16x32, 107 | /* asymmetrical (0.75, 0.25) */ 108 | CHROMA_8x6, CHROMA_6x8, CHROMA_8x2, CHROMA_2x8, 109 | CHROMA_16x12, CHROMA_12x16, CHROMA_16x4, CHROMA_4x16, 110 | CHROMA_32x24, CHROMA_24x32, CHROMA_32x8, CHROMA_8x32, 111 | }; 112 | 113 | /* --------------------------------------------------------------------------- 114 | */ 115 | enum ChromaCU { 116 | BLOCK_C_2x2, 117 | BLOCK_C_4x4, 118 | BLOCK_C_8x8, 119 | BLOCK_C_16x16, 120 | BLOCK_C_32x32 121 | }; 122 | 123 | 124 | typedef cmp_dist_t(*pixel_cmp_t)(const pel_t *pix1, intptr_t i_pix1, const pel_t *pix2, intptr_t i_pix2); 125 | typedef dist_t(*pixel_ssd_t)(const pel_t *pix1, intptr_t i_pix1, const pel_t *pix2, intptr_t i_pix2); 126 | typedef dist_t(*pixel_ssd2_t)(const pel_t *pix1, intptr_t i_pix1, const pel_t *pix2, intptr_t i_pix2, int width, int height); 127 | typedef void(*pixel_cmp_x3_t)(const pel_t *fenc, const pel_t *pix0, const pel_t *pix1, const pel_t *pix2, intptr_t i_stride, int scores[3]); 128 | typedef void(*pixel_cmp_x4_t)(const pel_t *fenc, const pel_t *pix0, const pel_t *pix1, const pel_t *pix2, const pel_t *pix3, intptr_t i_stride, int scores[4]); 129 | 130 | typedef void(*copy_pp_t)(pel_t* dst, intptr_t dstStride, const pel_t* src, intptr_t srcStride); // dst is aligned 131 | typedef void(*copy_sp_t)(pel_t* dst, intptr_t dstStride, const coeff_t* src, intptr_t srcStride); 132 | typedef void(*copy_ps_t)(coeff_t* dst, intptr_t dstStride, const pel_t* src, intptr_t srcStride); 133 | typedef void(*copy_ss_t)(coeff_t* dst, intptr_t dstStride, const coeff_t* src, intptr_t srcStride); 134 | 135 | typedef void(*pixel_sub_ps_t)(coeff_t* dst, intptr_t dstride, const pel_t* src0, const pel_t* src1, intptr_t sstride0, intptr_t sstride1); 136 | typedef void(*pixel_add_ps_t)(pel_t* a, intptr_t dstride, const pel_t* b0, const coeff_t* b1, intptr_t sstride0, intptr_t sstride1); 137 | typedef void(*pixel_avg_pp_t)(pel_t* dst, intptr_t dstride, const pel_t* src0, intptr_t sstride0, const pel_t* src1, intptr_t sstride1, int weight); 138 | 139 | typedef int(*mad_funcs_t)(pel_t *p_src, int i_src, int cu_size); 140 | 141 | typedef struct { 142 | 143 | pixel_cmp_t sad [NUM_PU_SIZES]; 144 | pixel_cmp_t satd [NUM_PU_SIZES]; 145 | pixel_cmp_t sa8d [NUM_PU_SIZES]; 146 | pixel_ssd_t ssd [NUM_PU_SIZES]; 147 | pixel_cmp_x3_t sad_x3 [NUM_PU_SIZES]; 148 | pixel_cmp_x4_t sad_x4 [NUM_PU_SIZES]; 149 | 150 | pixel_sub_ps_t sub_ps [NUM_PU_SIZES]; 151 | pixel_add_ps_t add_ps [NUM_PU_SIZES]; 152 | copy_sp_t copy_sp[NUM_PU_SIZES]; 153 | copy_ps_t copy_ps[NUM_PU_SIZES]; 154 | copy_ss_t copy_ss[NUM_PU_SIZES]; 155 | copy_pp_t copy_pp[NUM_PU_SIZES]; 156 | pixel_avg_pp_t avg [NUM_PU_SIZES]; 157 | 158 | pixel_cmp_t *intra_cmp; /* either satd or sad for intra mode prediction */ 159 | pixel_cmp_t *fpel_cmp; /* either satd or sad for fractional pixel comparison in ME */ 160 | 161 | mad_funcs_t madf[CTU_DEPTH]; 162 | 163 | pixel_ssd2_t ssd_block; 164 | /* block average */ 165 | void (*average)(pel_t *dst, int i_dst, pel_t *src1, int i_src1, pel_t *src2, int i_src2, int width, int height); 166 | } pixel_funcs_t; 167 | 168 | 169 | /** 170 | * =========================================================================== 171 | * global variables 172 | * =========================================================================== 173 | */ 174 | 175 | /* get partition index for the given size */ 176 | #define g_partition_map_tab FPFX(g_partition_map_tab) 177 | extern const uint8_t g_partition_map_tab[]; 178 | #define PART_INDEX(w, h) (g_partition_map_tab[((((w) >> 2) - 1) << 4) + ((h) >> 2) - 1]) 179 | 180 | 181 | /** 182 | * =========================================================================== 183 | * function declares 184 | * =========================================================================== 185 | */ 186 | 187 | #define xavs2_pixel_init FPFX(pixel_init) 188 | void xavs2_pixel_init(uint32_t cpu, pixel_funcs_t* pixf); 189 | 190 | #define xavs2_pixel_ssd_wxh FPFX(xpixel_ssd_wxh) 191 | uint64_t xavs2_pixel_ssd_wxh(pixel_funcs_t *pf, 192 | pel_t *p_pix1, intptr_t i_pix1, 193 | pel_t *p_pix2, intptr_t i_pix2, 194 | int i_width, int i_height, 195 | int inout_shift); 196 | 197 | 198 | #define xavs2_mad_init FPFX(mad_init) 199 | void xavs2_mad_init(uint32_t cpu, mad_funcs_t *madf); 200 | 201 | #endif // XAVS2_PIXEL_H 202 | -------------------------------------------------------------------------------- /source/common/x86/const-a.asm: -------------------------------------------------------------------------------- 1 | ;***************************************************************************** 2 | ;* const-a.asm: x86 global constants 3 | ;***************************************************************************** 4 | ;* Copyright (C) 2003-2013 x264 project 5 | ;* Copyright (C) 2013-2017 MulticoreWare, Inc 6 | ;* Copyright (C) 2018~ VCL, NELVT, Peking University 7 | ;* 8 | ;* Authors: Loren Merritt 9 | ;* Fiona Glaser 10 | ;* Min Chen 11 | ;* Praveen Kumar Tiwari 12 | ;* Jiaqi Zhang 13 | ;* 14 | ;* This program is free software; you can redistribute it and/or modify 15 | ;* it under the terms of the GNU General Public License as published by 16 | ;* the Free Software Foundation; either version 2 of the License, or 17 | ;* (at your option) any later version. 18 | ;* 19 | ;* This program is distributed in the hope that it will be useful, 20 | ;* but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | ;* GNU General Public License for more details. 23 | ;* 24 | ;* You should have received a copy of the GNU General Public License 25 | ;* along with this program; if not, write to the Free Software 26 | ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 27 | ;* 28 | ;* This program is also available under a commercial proprietary license. 29 | ;* For more information, contact us at license @ x265.com. 30 | ;***************************************************************************** 31 | 32 | %include "x86inc.asm" 33 | 34 | SECTION_RODATA 32 35 | 36 | ;; 8-bit constants 37 | 38 | const pb_0, times 32 db 0 39 | const pb_1, times 32 db 1 40 | const pb_2, times 32 db 2 41 | const pb_3, times 32 db 3 42 | const pb_4, times 32 db 4 43 | const pb_8, times 32 db 8 44 | const pb_15, times 32 db 15 45 | const pb_16, times 32 db 16 46 | const pb_31, times 32 db 31 47 | const pb_32, times 32 db 32 48 | const pb_64, times 32 db 64 49 | const pb_124, times 32 db 124 50 | const pb_128, times 32 db 128 51 | const pb_a1, times 16 db 0xa1 52 | 53 | const pb_01, times 8 db 0, 1 54 | const pb_0123, times 4 db 0, 1 55 | times 4 db 2, 3 56 | const hsub_mul, times 16 db 1, -1 57 | const pw_swap, times 2 db 6, 7, 4, 5, 2, 3, 0, 1 58 | const pb_unpackbd1, times 2 db 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3 59 | const pb_unpackbd2, times 2 db 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7 60 | const pb_unpackwq1, times 1 db 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 2, 3, 2, 3, 2, 3 61 | const pb_unpackwq2, times 1 db 4, 5, 4, 5, 4, 5, 4, 5, 6, 7, 6, 7, 6, 7, 6, 7 62 | const pb_shuf8x8c, times 1 db 0, 0, 0, 0, 2, 2, 2, 2, 4, 4, 4, 4, 6, 6, 6, 6 63 | const pb_movemask, times 16 db 0x00 64 | times 16 db 0xFF 65 | 66 | const pb_movemask_32, times 32 db 0x00 67 | times 32 db 0xFF 68 | times 32 db 0x00 69 | 70 | const pb_0000000000000F0F, times 2 db 0xff, 0x00 71 | times 12 db 0x00 72 | const pb_000000000000000F, db 0xff 73 | times 15 db 0x00 74 | const pb_shuf_off4, times 2 db 0, 4, 1, 5, 2, 6, 3, 7 75 | const pw_shuf_off4, times 1 db 0, 1, 8, 9, 2, 3, 10, 11, 4, 5, 12, 13, 6, 7, 14, 15 76 | 77 | ;; 16-bit constants 78 | 79 | const pw_n1, times 16 dw -1 80 | const pw_1, times 16 dw 1 81 | const pw_2, times 16 dw 2 82 | const pw_3, times 16 dw 3 83 | const pw_7, times 16 dw 7 84 | const pw_m2, times 8 dw -2 85 | const pw_4, times 8 dw 4 86 | const pw_8, times 8 dw 8 87 | const pw_16, times 16 dw 16 88 | const pw_15, times 16 dw 15 89 | const pw_31, times 16 dw 31 90 | const pw_32, times 16 dw 32 91 | const pw_64, times 8 dw 64 92 | const pw_128, times 16 dw 128 93 | const pw_256, times 16 dw 256 94 | const pw_257, times 16 dw 257 95 | const pw_512, times 16 dw 512 96 | const pw_1023, times 16 dw 1023 97 | const pw_1024, times 16 dw 1024 98 | const pw_2048, times 16 dw 2048 99 | const pw_4096, times 16 dw 4096 100 | const pw_8192, times 8 dw 8192 101 | const pw_00ff, times 16 dw 0x00ff 102 | const pw_ff00, times 8 dw 0xff00 103 | const pw_2000, times 16 dw 0x2000 104 | const pw_8000, times 8 dw 0x8000 105 | const pw_3fff, times 16 dw 0x3fff 106 | const pw_32_0, times 4 dw 32, 107 | times 4 dw 0 108 | const pw_pixel_max, times 16 dw ((1 << BIT_DEPTH)-1) 109 | 110 | const pw_0_7, times 2 dw 0, 1, 2, 3, 4, 5, 6, 7 111 | const pw_ppppmmmm, times 1 dw 1, 1, 1, 1, -1, -1, -1, -1 112 | const pw_ppmmppmm, times 1 dw 1, 1, -1, -1, 1, 1, -1, -1 113 | const pw_pmpmpmpm, times 16 dw 1, -1, 1, -1, 1, -1, 1, -1 114 | const pw_pmmpzzzz, times 1 dw 1, -1, -1, 1, 0, 0, 0, 0 115 | const multi_2Row, times 1 dw 1, 2, 3, 4, 1, 2, 3, 4 116 | const multiH, times 1 dw 9, 10, 11, 12, 13, 14, 15, 16 117 | const multiH3, times 1 dw 25, 26, 27, 28, 29, 30, 31, 32 118 | const multiL, times 1 dw 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 119 | const multiH2, times 1 dw 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 120 | const pw_planar16_mul, times 1 dw 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 121 | const pw_planar32_mul, times 1 dw 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16 122 | const pw_FFFFFFFFFFFFFFF0, dw 0x00 123 | times 7 dw 0xff 124 | const hmul_16p, times 16 db 1 125 | times 8 db 1, -1 126 | const pw_exp2_0_15, dw 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 127 | const pw_1_ffff, times 4 dw 1 128 | times 4 dw 0xFFFF 129 | 130 | 131 | ;; 32-bit constants 132 | 133 | const pd_0, times 8 dd 0 134 | const pd_1, times 8 dd 1 135 | const pd_2, times 8 dd 2 136 | const pd_3, times 8 dd 3 137 | const pd_4, times 4 dd 4 138 | const pd_8, times 4 dd 8 139 | const pd_11, times 4 dd 11 140 | const pd_12, times 4 dd 12 141 | const pd_15, times 8 dd 15 142 | const pd_16, times 8 dd 16 143 | const pd_31, times 8 dd 31 144 | const pd_32, times 8 dd 32 145 | const pd_64, times 4 dd 64 146 | const pd_128, times 4 dd 128 147 | const pd_256, times 4 dd 256 148 | const pd_512, times 4 dd 512 149 | const pd_1024, times 4 dd 1024 150 | const pd_2048, times 4 dd 2048 151 | const pd_ffff, times 4 dd 0xffff 152 | const pd_32767, times 4 dd 32767 153 | const pd_n32768, times 4 dd 0xffff8000 154 | const pd_524416, times 4 dd 524416 155 | const pd_n32768, times 8 dd 0xffff8000 156 | const pd_n131072, times 4 dd 0xfffe0000 157 | const pd_0000ffff, times 8 dd 0x0000FFFF 158 | const pd_planar16_mul0, times 1 dd 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 159 | const pd_planar16_mul1, times 1 dd 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 160 | const pd_planar32_mul1, times 1 dd 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16 161 | const pd_planar32_mul2, times 1 dd 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 162 | const pd_planar16_mul2, times 1 dd 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 163 | const trans8_shuf, times 1 dd 0, 4, 1, 5, 2, 6, 3, 7 164 | 165 | ;; 64-bit constants 166 | 167 | const pq_1, times 1 dq 1 168 | --------------------------------------------------------------------------------