├── .gitattributes ├── .github └── ISSUE_TEMPLATE │ ├── ----.md │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── .travis.yml ├── COPYING ├── README.md ├── README.zh.md ├── appveyor.yml ├── build ├── linux │ ├── Makefile │ ├── config.guess │ ├── config.sub │ └── configure └── vs2013 │ ├── DAVS2.sln │ ├── davs2.vcxproj │ ├── davs2.vcxproj.filters │ ├── libdavs2.vcxproj │ ├── libdavs2.vcxproj.filters │ ├── libdavs2_asm.vcxproj │ ├── libdavs2_asm.vcxproj.filters │ ├── libdavs2_intrin_avx.vcxproj │ ├── libdavs2_intrin_avx.vcxproj.filters │ ├── libdavs2_intrin_sse.vcxproj │ ├── libdavs2_intrin_sse.vcxproj.filters │ ├── nasm.props │ ├── nasm.targets │ └── nasm.xml ├── source ├── common │ ├── aec.cc │ ├── aec.h │ ├── alf.cc │ ├── alf.h │ ├── bitstream.cc │ ├── bitstream.h │ ├── block_info.cc │ ├── block_info.h │ ├── common.cc │ ├── common.h │ ├── cpu.cc │ ├── cpu.h │ ├── cu.cc │ ├── cu.h │ ├── davs2.cc │ ├── deblock.cc │ ├── deblock.h │ ├── decoder.cc │ ├── decoder.h │ ├── defines.h │ ├── frame.cc │ ├── frame.h │ ├── header.cc │ ├── header.h │ ├── intra.cc │ ├── intra.h │ ├── mc.cc │ ├── mc.h │ ├── memory.cc │ ├── osdep.h │ ├── pixel.cc │ ├── predict.cc │ ├── predict.h │ ├── primitives.cc │ ├── primitives.h │ ├── quant.cc │ ├── quant.h │ ├── sao.cc │ ├── sao.h │ ├── scantab.h │ ├── threadpool.cc │ ├── threadpool.h │ ├── transform.cc │ ├── transform.h │ ├── vec │ │ ├── intrinsic.cc │ │ ├── intrinsic.h │ │ ├── intrinsic_alf.cc │ │ ├── intrinsic_deblock.cc │ │ ├── intrinsic_deblock_avx2.cc │ │ ├── intrinsic_idct.cc │ │ ├── intrinsic_idct_avx2.cc │ │ ├── intrinsic_inter_pred.cc │ │ ├── intrinsic_inter_pred_avx2.cc │ │ ├── intrinsic_intra-filledge.cc │ │ ├── intrinsic_intra-pred.cc │ │ ├── intrinsic_intra-pred_avx2.cc │ │ ├── intrinsic_pixel.cc │ │ ├── intrinsic_pixel_avx.cc │ │ ├── intrinsic_sao.cc │ │ └── intrinsic_sao_avx2.cc │ ├── vlc.h │ ├── win32thread.cc │ ├── win32thread.h │ └── x86 │ │ ├── blockcopy8.asm │ │ ├── const-a.asm │ │ ├── cpu-a.asm │ │ ├── dct8.asm │ │ ├── dct8.h │ │ ├── ipfilter8.asm │ │ ├── ipfilter8.h │ │ ├── mc-a2.asm │ │ ├── pixeladd8.asm │ │ ├── quant8.asm │ │ ├── x86inc.asm │ │ └── x86util.asm ├── configw.h ├── davs2.h └── test │ ├── getopt │ ├── getopt.c │ └── getopt.h │ ├── inputstream.h │ ├── md5.h │ ├── parse_args.h │ ├── psnr.h │ ├── test.c │ └── utils.h └── version.sh /.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 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/----.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 问题咨询 3 | about: 使用问题/安全问题/其他问题 4 | 5 | --- 6 | 7 | 请发送邮件至: sswang@pku.edu.cn 8 | 或在应用内“高级设置” - “建议反馈” 填写表单 9 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | Release/ 3 | x64_Debug/ 4 | x64_Release/ 5 | build/linux/cavs2dec* 6 | build/linux/davs2* 7 | My*/ 8 | *.user 9 | *.suo 10 | *.ncb 11 | *.aps 12 | *.pdb 13 | *.res 14 | *.dat 15 | *.manifest 16 | *.map 17 | *.dep 18 | *.idb 19 | *.ilk 20 | *.htm 21 | *.exp 22 | *.lib 23 | *.obj 24 | *.dll* 25 | *.exe 26 | *.avs 27 | *.mkv 28 | *.mp4 29 | *.y4m 30 | *.yuv 31 | *.log 32 | *.bak 33 | *.o 34 | *.a 35 | *.so 36 | *.cd 37 | *.sdf 38 | *.opensdf 39 | *.depend 40 | *.pc 41 | *.mak 42 | *.so.* 43 | *.dec 44 | *.txt 45 | config.h 46 | *.iobj 47 | *.ipdb 48 | version.h 49 | 50 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # davs2 2 | **davs2** is an open-source decoder of `AVS2-P2/IEEE1857.4` video coding standard. 3 | 4 | An encoder, **xavs2**, can be found at [Github][2] or [Gitee (mirror in China)][3]. 5 | 6 | [![GitHub tag](https://img.shields.io/github/tag/pkuvcl/davs2.svg?style=plastic)]() 7 | [![GitHub issues](https://img.shields.io/github/issues/pkuvcl/davs2.svg)](https://github.com/pkuvcl/davs2/issues) 8 | [![GitHub forks](https://img.shields.io/github/forks/pkuvcl/davs2.svg)](https://github.com/pkuvcl/davs2/network) 9 | [![GitHub stars](https://img.shields.io/github/stars/pkuvcl/davs2.svg)](https://github.com/pkuvcl/davs2/stargazers) 10 | 11 | Linux(Ubuntu-16.04):[![Travis Build Status](https://travis-ci.org/pkuvcl/davs2.svg?branch=master)](https://travis-ci.org/pkuvcl/davs2) 12 | Windows(VS2013):[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/pq0b5mnc6mig6ryp?svg=true)](https://ci.appveyor.com/project/luofalei/davs2/build/artifacts) 13 | 14 | Stargazers over time 15 | [![Stargazers over time](https://starcharts.herokuapp.com/pkuvcl/davs2.svg)](https://starcharts.herokuapp.com/pkuvcl/davs2) 16 | 17 | ## Compile it 18 | ### Windows 19 | Use VS2013 or latest version of visual studio open the `./build/vs2013/davs2.sln` solution 20 | and set the `davs2` as the start project. 21 | 22 | #### Notes 23 | 1. A `shell executor`, i.e. the bash in git for windows, is needed and should be found in `PATH` variable. 24 | For example, the path `C:\Program Files\Git\bin` can be added if git-for-windows is installed. 25 | 2. `nasm.exe` with version `2.13` (or later version) is needed and should be put into the `PATH` directory. 26 | For windows platform, you can downloaded the packege and unpack the zip file to get `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 | $ cd build/linux 32 | $ ./configure 33 | $ make 34 | ``` 35 | 36 | ## Try it 37 | 38 | Decode AVS2 stream `test.avs` with `1` thread and output to a *YUV file* named `dec.yuv`. 39 | ``` 40 | ./davs2 -i test.avs -t 1 -o dec.yuv 41 | ``` 42 | 43 | Decode AVS2 stream `test.avs` and display the decoding result via *ffplay*. 44 | ``` 45 | ./davs2 -i test.avs -t 1 -o stdout | ffplay -i - 46 | ``` 47 | 48 | ### Parameter Instructions 49 | | Parameter | Alias | Result | 50 | | :--------: | :---------: | :--------------: | 51 | | --input=test.avs | -i test.avs | Setting the input bitstream file | 52 | | --output=dec.yuv | -o dec.yuv | Setting the output YUV file | 53 | | --psnr=rec.yuv | -r rec.yuv | Setting the reference reconstruction YUV file | 54 | | --threads=N | -t N | Setting the threads for decoding (default: 1) | 55 | | --md5=M | -m M | Reference MD5, used to check whether the output YUV is right | 56 | | --verbose | -v | Enable decoding status every frame (Default: Enabled) | 57 | | --help | -h | Showing this instruction | 58 | 59 | ## Issue and Pull Request 60 | 61 | [Issues should be reported here][6]。 62 | 63 | If you have some bugs fixed or features implemented, and would like to share with the public, please [make a Pull Request][7]. 64 | 65 | ## Homepages 66 | 67 | [PKU-VCL][1] 68 | 69 | `AVS2-P2/IEEE1857.4` Encoder: [xavs2 (Github)][2], [xavs2 (mirror in China)][3] 70 | 71 | `AVS2-P2/IEEE1857.4` Decoder: [davs2 (Github)][4], [davs2 (mirror in China)][5] 72 | 73 | [1]: http://vcl.idm.pku.edu.cn/ "PKU-VCL" 74 | [2]: https://github.com/pkuvcl/xavs2 "xavs2 github repository" 75 | [3]: https://gitee.com/pkuvcl/xavs2 "xavs2 gitee repository" 76 | [4]: https://github.com/pkuvcl/davs2 "davs2 decoder@github" 77 | [5]: https://gitee.com/pkuvcl/davs2 "davs2 decoder@gitee" 78 | [6]: https://github.com/pkuvcl/davs2/issues "report issues" 79 | [7]: https://github.com/pkuvcl/davs2/pulls "pull request" 80 | -------------------------------------------------------------------------------- /README.zh.md: -------------------------------------------------------------------------------- 1 | # davs2 2 | 3 | 遵循 `AVS2-P2/IEEE1857.4` 视频编码标准的解码器. 4 | 5 | 对应的编码器 **xavs2** 可在 [Github][2] 或 [Gitee (mirror in China)][3] 上找到. 6 | 7 | [![GitHub tag](https://img.shields.io/github/tag/pkuvcl/davs2.svg?style=plastic)]() 8 | [![GitHub issues](https://img.shields.io/github/issues/pkuvcl/davs2.svg)](https://github.com/pkuvcl/davs2/issues) 9 | [![GitHub forks](https://img.shields.io/github/forks/pkuvcl/davs2.svg)](https://github.com/pkuvcl/davs2/network) 10 | [![GitHub stars](https://img.shields.io/github/stars/pkuvcl/davs2.svg)](https://github.com/pkuvcl/davs2/stargazers) 11 | 12 | Linux(Ubuntu-16.04):[![Travis Build Status](https://travis-ci.org/pkuvcl/davs2.svg?branch=master)](https://travis-ci.org/pkuvcl/davs2) 13 | Windows(VS2013):[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/pq0b5mnc6mig6ryp?svg=true)](https://ci.appveyor.com/project/luofalei/davs2/build/artifacts) 14 | 15 | [![Stargazers over time](https://starcharts.herokuapp.com/pkuvcl/davs2.svg)](https://starcharts.herokuapp.com/pkuvcl/davs2) 16 | 17 | ## 编译方法 18 | ### Windows 19 | 20 | 可使用`VS2013`打开解决方案`./build/win32/DAVS2.sln`进行编译, 也可以使用更新的vs版本打开上述解决方案. 21 | 打开解决方案后, 将工程`davs2`设置为启动项, 进行编译即可. 22 | 23 | #### 注意 24 | 1. 首次编译本项目时, 需要安装一个 `shell 执行器`, 比如 `git-for-windows` 中的 `bash`, 25 | 需要将该 `bash` 所在的目录添加到系统环境变量 `PATH` 中. 26 | 如上所述, 如果您以默认配置安装了`git-for-windows`, 27 | 那么将 `C:\Program Files\Git\bin` 添加到环境变量中即可. 28 | 2. 需将 `nasm.exe`放入到系统 `PATH` 目录, `nasm`版本号需为`2.13`或更新. 29 | 对于`windows`平台,可下载如下压缩包中,解压得到`nasm.exe`. 30 | https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/win64/nasm-2.14.02-win64.zip 31 | 32 | ### Linux 33 | 34 | 对于linux系统, 依次执行如下命令即可完成编译: 35 | ``` 36 | $ cd build/linux 37 | $ ./configure 38 | $ make 39 | ``` 40 | 41 | ## 运行和测试 42 | 43 | 使用`1`个线程解码AVS2码流文件`test.avs`并将结果输出成YUV文件`dec.yuv`: 44 | ``` 45 | ./davs2 -i test.avs -t 1 -o dec.yuv 46 | ``` 47 | 48 | 解码AVS2码流文件`test.avs`并用ffplay播放显示: 49 | ``` 50 | ./davs2 -i test.avs -t 1 -o stdout | ffplay -i - 51 | ``` 52 | 53 | ### 参数说明 54 | | 参数 | 等价形式 | 意义 | 55 | | :--------: | :---------: | :--------------: | 56 | | --input=test.avs | -i test.avs | 设置输入码流文件路径 | 57 | | --output=dec.yuv | -o dec.yuv | 设置输出解码YUV文件路径 | 58 | | --psnr=rec.yuv | -r rec.yuv | 设置参考用YUV文件路径, 用于计算PSNR以确定是否匹配 | 59 | | --threads=N | -t N | 设置解码线程数 (默认值: 1) | 60 | | --md5=M | -m M | 设置参考MD5值, 用于验证输出的重构YUV是否匹配 | 61 | | --verbose | -v | 设置每帧是否输出 (默认: 开启) | 62 | | --help | -h | 显示此输出命令 | 63 | 64 | ## Issue & Pull Request 65 | 66 | 欢迎提交 issue,请写清楚遇到问题的环境与运行参数,包括操作系统环境、编译器环境等。 67 | 如果可能提供原始输入`YUV/码流文件`,请尽量提供以方便更快地重现结果。 68 | 69 | [反馈问题的 issue 请按照模板格式填写][6]。 70 | 71 | 如果有开发能力,建议在本地调试出错的代码,并[提供相应修正的 Pull Request][7]。 72 | 73 | ## 主页链接 74 | 75 | [北京大学-视频编码算法研究室(PKU-VCL)][1] 76 | 77 | `AVS2-P2/IEEE1857.4` Encoder: [xavs2 (Github)][2], [xavs2 (mirror in China)][3] 78 | 79 | `AVS2-P2/IEEE1857.4` Decoder: [davs2 (Github)][4], [davs2 (mirror in China)][5] 80 | 81 | [1]: http://vcl.idm.pku.edu.cn/ "PKU-VCL" 82 | [2]: https://github.com/pkuvcl/xavs2 "xavs2 github repository" 83 | [3]: https://gitee.com/pkuvcl/xavs2 "xavs2 gitee repository" 84 | [4]: https://github.com/pkuvcl/davs2 "davs2 decoder@github" 85 | [5]: https://gitee.com/pkuvcl/davs2 "davs2 decoder@gitee" 86 | [6]: https://github.com/pkuvcl/davs2/issues "report issues" 87 | [7]: https://github.com/pkuvcl/davs2/pulls "pull request" 88 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | image: Visual Studio 2015 2 | configuration: Release 3 | 4 | platform: 5 | - x64 6 | 7 | install: 8 | - git submodule update --init 9 | - appveyor DownloadFile https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/win64/nasm-2.14.02-win64.zip -FileName nasm.zip 10 | - ps: Expand-Archive -Path nasm.zip -DestinationPath build/vs2013 -Force:$true 11 | - set PATH=%PATH%;%APPVEYOR_BUILD_FOLDER%/build/vs2013/nasm-2.14.02 12 | 13 | build: 14 | project: build\vs2013\DAVS2.sln 15 | 16 | artifacts: 17 | - path: build\bin\x64_Release\*.* 18 | name: $(APPVEYOR_PROJECT_NAME) 19 | -------------------------------------------------------------------------------- /build/vs2013/DAVS2.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.40629.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "davs2", "davs2.vcxproj", "{852EFB9B-4E73-4E80-AA57-711ADCB132AE}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {34C0840A-BDE6-446B-B0DF-A8281A42825B} = {34C0840A-BDE6-446B-B0DF-A8281A42825B} 9 | EndProjectSection 10 | EndProject 11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libdavs2", "libdavs2.vcxproj", "{34C0840A-BDE6-446B-B0DF-A8281A42825B}" 12 | ProjectSection(ProjectDependencies) = postProject 13 | {A9B37E3C-A8C7-4E24-BC2D-AB4D0804DAC1} = {A9B37E3C-A8C7-4E24-BC2D-AB4D0804DAC1} 14 | {558555B9-A7B2-42D6-A298-BB5CC248541F} = {558555B9-A7B2-42D6-A298-BB5CC248541F} 15 | {2E7A6EE4-927F-470A-A012-3B29EDB87906} = {2E7A6EE4-927F-470A-A012-3B29EDB87906} 16 | EndProjectSection 17 | EndProject 18 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libdavs2_asm", "libdavs2_asm.vcxproj", "{A9B37E3C-A8C7-4E24-BC2D-AB4D0804DAC1}" 19 | EndProject 20 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libdavs2_intrin_avx", "libdavs2_intrin_avx.vcxproj", "{558555B9-A7B2-42D6-A298-BB5CC248541F}" 21 | EndProject 22 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libdavs2_intrin_sse", "libdavs2_intrin_sse.vcxproj", "{2E7A6EE4-927F-470A-A012-3B29EDB87906}" 23 | EndProject 24 | Global 25 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 26 | Debug|Win32 = Debug|Win32 27 | Debug|x64 = Debug|x64 28 | Release|Win32 = Release|Win32 29 | Release|x64 = Release|x64 30 | EndGlobalSection 31 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 32 | {852EFB9B-4E73-4E80-AA57-711ADCB132AE}.Debug|Win32.ActiveCfg = Debug|Win32 33 | {852EFB9B-4E73-4E80-AA57-711ADCB132AE}.Debug|Win32.Build.0 = Debug|Win32 34 | {852EFB9B-4E73-4E80-AA57-711ADCB132AE}.Debug|x64.ActiveCfg = Debug|x64 35 | {852EFB9B-4E73-4E80-AA57-711ADCB132AE}.Debug|x64.Build.0 = Debug|x64 36 | {852EFB9B-4E73-4E80-AA57-711ADCB132AE}.Release|Win32.ActiveCfg = Release|Win32 37 | {852EFB9B-4E73-4E80-AA57-711ADCB132AE}.Release|Win32.Build.0 = Release|Win32 38 | {852EFB9B-4E73-4E80-AA57-711ADCB132AE}.Release|x64.ActiveCfg = Release|x64 39 | {852EFB9B-4E73-4E80-AA57-711ADCB132AE}.Release|x64.Build.0 = Release|x64 40 | {34C0840A-BDE6-446B-B0DF-A8281A42825B}.Debug|Win32.ActiveCfg = Debug|Win32 41 | {34C0840A-BDE6-446B-B0DF-A8281A42825B}.Debug|Win32.Build.0 = Debug|Win32 42 | {34C0840A-BDE6-446B-B0DF-A8281A42825B}.Debug|x64.ActiveCfg = Debug|x64 43 | {34C0840A-BDE6-446B-B0DF-A8281A42825B}.Debug|x64.Build.0 = Debug|x64 44 | {34C0840A-BDE6-446B-B0DF-A8281A42825B}.Release|Win32.ActiveCfg = Release|Win32 45 | {34C0840A-BDE6-446B-B0DF-A8281A42825B}.Release|Win32.Build.0 = Release|Win32 46 | {34C0840A-BDE6-446B-B0DF-A8281A42825B}.Release|x64.ActiveCfg = Release|x64 47 | {34C0840A-BDE6-446B-B0DF-A8281A42825B}.Release|x64.Build.0 = Release|x64 48 | {A9B37E3C-A8C7-4E24-BC2D-AB4D0804DAC1}.Debug|Win32.ActiveCfg = Debug|Win32 49 | {A9B37E3C-A8C7-4E24-BC2D-AB4D0804DAC1}.Debug|Win32.Build.0 = Debug|Win32 50 | {A9B37E3C-A8C7-4E24-BC2D-AB4D0804DAC1}.Debug|x64.ActiveCfg = Debug|x64 51 | {A9B37E3C-A8C7-4E24-BC2D-AB4D0804DAC1}.Debug|x64.Build.0 = Debug|x64 52 | {A9B37E3C-A8C7-4E24-BC2D-AB4D0804DAC1}.Release|Win32.ActiveCfg = Release|Win32 53 | {A9B37E3C-A8C7-4E24-BC2D-AB4D0804DAC1}.Release|Win32.Build.0 = Release|Win32 54 | {A9B37E3C-A8C7-4E24-BC2D-AB4D0804DAC1}.Release|x64.ActiveCfg = Release|x64 55 | {A9B37E3C-A8C7-4E24-BC2D-AB4D0804DAC1}.Release|x64.Build.0 = Release|x64 56 | {558555B9-A7B2-42D6-A298-BB5CC248541F}.Debug|Win32.ActiveCfg = Debug|Win32 57 | {558555B9-A7B2-42D6-A298-BB5CC248541F}.Debug|Win32.Build.0 = Debug|Win32 58 | {558555B9-A7B2-42D6-A298-BB5CC248541F}.Debug|x64.ActiveCfg = Debug|x64 59 | {558555B9-A7B2-42D6-A298-BB5CC248541F}.Debug|x64.Build.0 = Debug|x64 60 | {558555B9-A7B2-42D6-A298-BB5CC248541F}.Release|Win32.ActiveCfg = Release|Win32 61 | {558555B9-A7B2-42D6-A298-BB5CC248541F}.Release|Win32.Build.0 = Release|Win32 62 | {558555B9-A7B2-42D6-A298-BB5CC248541F}.Release|x64.ActiveCfg = Release|x64 63 | {558555B9-A7B2-42D6-A298-BB5CC248541F}.Release|x64.Build.0 = Release|x64 64 | {2E7A6EE4-927F-470A-A012-3B29EDB87906}.Debug|Win32.ActiveCfg = Debug|Win32 65 | {2E7A6EE4-927F-470A-A012-3B29EDB87906}.Debug|Win32.Build.0 = Debug|Win32 66 | {2E7A6EE4-927F-470A-A012-3B29EDB87906}.Debug|x64.ActiveCfg = Debug|x64 67 | {2E7A6EE4-927F-470A-A012-3B29EDB87906}.Debug|x64.Build.0 = Debug|x64 68 | {2E7A6EE4-927F-470A-A012-3B29EDB87906}.Release|Win32.ActiveCfg = Release|Win32 69 | {2E7A6EE4-927F-470A-A012-3B29EDB87906}.Release|Win32.Build.0 = Release|Win32 70 | {2E7A6EE4-927F-470A-A012-3B29EDB87906}.Release|x64.ActiveCfg = Release|x64 71 | {2E7A6EE4-927F-470A-A012-3B29EDB87906}.Release|x64.Build.0 = Release|x64 72 | EndGlobalSection 73 | GlobalSection(SolutionProperties) = preSolution 74 | HideSolutionNode = FALSE 75 | EndGlobalSection 76 | EndGlobal 77 | -------------------------------------------------------------------------------- /build/vs2013/davs2.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 6 | h;hh;hpp;hxx;hm;inl;inc;xsd 7 | 8 | 9 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 10 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 11 | 12 | 13 | 14 | 15 | inc 16 | 17 | 18 | inc 19 | 20 | 21 | inc 22 | 23 | 24 | inc 25 | 26 | 27 | inc 28 | 29 | 30 | inc 31 | 32 | 33 | inc 34 | 35 | 36 | 37 | 38 | src 39 | 40 | 41 | src 42 | 43 | 44 | -------------------------------------------------------------------------------- /build/vs2013/libdavs2.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 6 | h;hh;hpp;hxx;hm;inl;inc;xsd 7 | 8 | 9 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 10 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | src 20 | 21 | 22 | src 23 | 24 | 25 | src 26 | 27 | 28 | src 29 | 30 | 31 | src 32 | 33 | 34 | src 35 | 36 | 37 | src 38 | 39 | 40 | src 41 | 42 | 43 | src 44 | 45 | 46 | src 47 | 48 | 49 | src 50 | 51 | 52 | src 53 | 54 | 55 | src 56 | 57 | 58 | src 59 | 60 | 61 | src 62 | 63 | 64 | src 65 | 66 | 67 | src 68 | 69 | 70 | src 71 | 72 | 73 | src 74 | 75 | 76 | src 77 | 78 | 79 | src 80 | 81 | 82 | src 83 | 84 | 85 | src 86 | 87 | 88 | 89 | 90 | inc 91 | 92 | 93 | inc 94 | 95 | 96 | inc 97 | 98 | 99 | inc 100 | 101 | 102 | inc 103 | 104 | 105 | inc 106 | 107 | 108 | inc 109 | 110 | 111 | inc 112 | 113 | 114 | inc 115 | 116 | 117 | inc 118 | 119 | 120 | inc 121 | 122 | 123 | inc 124 | 125 | 126 | inc 127 | 128 | 129 | inc 130 | 131 | 132 | inc 133 | 134 | 135 | inc 136 | 137 | 138 | inc 139 | 140 | 141 | inc 142 | 143 | 144 | inc 145 | 146 | 147 | inc 148 | 149 | 150 | inc 151 | 152 | 153 | inc 154 | 155 | 156 | inc 157 | 158 | 159 | inc 160 | 161 | 162 | inc 163 | 164 | 165 | inc 166 | 167 | 168 | inc 169 | 170 | 171 | 172 | 173 | inc 174 | 175 | 176 | -------------------------------------------------------------------------------- /build/vs2013/libdavs2_asm.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | asm-x86 12 | 13 | 14 | asm-x86 15 | 16 | 17 | 18 | 19 | asm-x86 20 | 21 | 22 | asm-x86 23 | 24 | 25 | asm-x86 26 | 27 | 28 | asm-x86 29 | 30 | 31 | asm-x86 32 | 33 | 34 | asm-x86 35 | 36 | 37 | asm-x86 38 | 39 | 40 | asm-x86 41 | 42 | 43 | -------------------------------------------------------------------------------- /build/vs2013/libdavs2_intrin_avx.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | {558555B9-A7B2-42D6-A298-BB5CC248541F} 34 | Win32Proj 35 | asmopt 36 | 37 | 38 | 39 | StaticLibrary 40 | true 41 | $(DefaultPlatformToolset) 42 | MultiByte 43 | 44 | 45 | StaticLibrary 46 | true 47 | $(DefaultPlatformToolset) 48 | MultiByte 49 | 50 | 51 | StaticLibrary 52 | false 53 | $(DefaultPlatformToolset) 54 | true 55 | MultiByte 56 | 57 | 58 | StaticLibrary 59 | false 60 | $(DefaultPlatformToolset) 61 | true 62 | MultiByte 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | $(SolutionDir)..\bin\$(Platform)_$(Configuration)\ 80 | $(SolutionDir)$(Platform)_$(Configuration)\$(ProjectName)\ 81 | 82 | 83 | $(SolutionDir)..\bin\$(Platform)_$(Configuration)\ 84 | $(SolutionDir)$(Platform)_$(Configuration)\$(ProjectName)\ 85 | 86 | 87 | $(SolutionDir)..\bin\$(Platform)_$(Configuration)\ 88 | $(SolutionDir)$(Platform)_$(Configuration)\$(ProjectName)\ 89 | 90 | 91 | $(SolutionDir)..\bin\$(Platform)_$(Configuration)\ 92 | $(SolutionDir)$(Platform)_$(Configuration)\$(ProjectName)\ 93 | 94 | 95 | 96 | 97 | 98 | Level4 99 | Disabled 100 | HIGH_BIT_DEPTH=0;BIT_DEPTH=8;WIN32;ARCH_X86_64=0;_DEBUG;_LIB;%(PreprocessorDefinitions) 101 | ..\..\;..\..\source;..\..\pthread 102 | ProgramDatabase 103 | MultiThreadedDebug 104 | 105 | 106 | 107 | AdvancedVectorExtensions2 108 | 109 | 110 | Windows 111 | true 112 | 113 | 114 | 115 | 116 | 117 | 118 | Level4 119 | Disabled 120 | HIGH_BIT_DEPTH=0;BIT_DEPTH=8;WIN32;ARCH_X86_64=1;_DEBUG;_LIB;%(PreprocessorDefinitions) 121 | ..\..\;..\..\source;..\..\pthread;$(CUDA_PATH)\include;$(AMD_APPSDK_PATH)\include;$(INTEL_OPENCL_SDK)\include; 122 | MultiThreadedDebug 123 | 124 | 125 | 126 | AdvancedVectorExtensions2 127 | 128 | 129 | Windows 130 | true 131 | 132 | 133 | 134 | 135 | Level4 136 | 137 | 138 | MaxSpeed 139 | true 140 | true 141 | HIGH_BIT_DEPTH=0;BIT_DEPTH=8;WIN32;ARCH_X86_64=0;NDEBUG;_LIB;%(PreprocessorDefinitions) 142 | ..\..\;..\..\source;..\..\pthread 143 | Speed 144 | MultiThreaded 145 | 146 | 147 | 148 | AdvancedVectorExtensions2 149 | 150 | 151 | Windows 152 | true 153 | true 154 | true 155 | 156 | 157 | 158 | 159 | Level4 160 | 161 | 162 | MaxSpeed 163 | true 164 | true 165 | HIGH_BIT_DEPTH=0;BIT_DEPTH=8;WIN32;ARCH_X86_64=1;NDEBUG;_LIB;%(PreprocessorDefinitions) 166 | ..\..\;..\..\source;..\..\pthread;$(CUDA_PATH)\include;$(AMD_APPSDK_PATH)\include;$(INTEL_OPENCL_SDK)\include; 167 | Speed 168 | MultiThreaded 169 | 170 | 171 | 172 | AdvancedVectorExtensions 173 | 174 | 175 | Windows 176 | true 177 | true 178 | true 179 | 180 | 181 | 182 | -------------------------------------------------------------------------------- /build/vs2013/libdavs2_intrin_avx.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | vec 12 | 13 | 14 | vec 15 | 16 | 17 | vec 18 | 19 | 20 | vec 21 | 22 | 23 | vec 24 | 25 | 26 | vec 27 | 28 | 29 | 30 | 31 | vec 32 | 33 | 34 | -------------------------------------------------------------------------------- /build/vs2013/libdavs2_intrin_sse.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | {2E7A6EE4-927F-470A-A012-3B29EDB87906} 38 | Win32Proj 39 | asmopt 40 | 41 | 42 | 43 | StaticLibrary 44 | true 45 | $(DefaultPlatformToolset) 46 | MultiByte 47 | 48 | 49 | StaticLibrary 50 | true 51 | $(DefaultPlatformToolset) 52 | MultiByte 53 | 54 | 55 | StaticLibrary 56 | false 57 | $(DefaultPlatformToolset) 58 | true 59 | MultiByte 60 | 61 | 62 | StaticLibrary 63 | false 64 | $(DefaultPlatformToolset) 65 | true 66 | MultiByte 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | $(SolutionDir)..\bin\$(Platform)_$(Configuration)\ 84 | $(SolutionDir)$(Platform)_$(Configuration)\$(ProjectName)\ 85 | 86 | 87 | $(SolutionDir)..\bin\$(Platform)_$(Configuration)\ 88 | $(SolutionDir)$(Platform)_$(Configuration)\$(ProjectName)\ 89 | 90 | 91 | $(SolutionDir)..\bin\$(Platform)_$(Configuration)\ 92 | $(SolutionDir)$(Platform)_$(Configuration)\$(ProjectName)\ 93 | 94 | 95 | $(SolutionDir)..\bin\$(Platform)_$(Configuration)\ 96 | $(SolutionDir)$(Platform)_$(Configuration)\$(ProjectName)\ 97 | 98 | 99 | 100 | 101 | 102 | Level4 103 | Disabled 104 | HIGH_BIT_DEPTH=0;BIT_DEPTH=8;WIN32;ARCH_X86_64=0;_DEBUG;_LIB;%(PreprocessorDefinitions) 105 | ..\..\;..\..\source;..\..\pthread 106 | ProgramDatabase 107 | MultiThreadedDebug 108 | 109 | 4752; 110 | 111 | 112 | Windows 113 | true 114 | 115 | 116 | 117 | 118 | 119 | 120 | Level4 121 | Disabled 122 | HIGH_BIT_DEPTH=0;BIT_DEPTH=8;WIN32;ARCH_X86_64=1;_DEBUG;_LIB;%(PreprocessorDefinitions) 123 | ..\..\;..\..\source;..\..\pthread;$(CUDA_PATH)\include;$(AMD_APPSDK_PATH)\include;$(INTEL_OPENCL_SDK)\include; 124 | MultiThreadedDebug 125 | 126 | 4752; 127 | 128 | 129 | Windows 130 | true 131 | 132 | 133 | 134 | 135 | Level4 136 | 137 | 138 | MaxSpeed 139 | true 140 | true 141 | HIGH_BIT_DEPTH=0;BIT_DEPTH=8;WIN32;ARCH_X86_64=0;NDEBUG;_LIB;%(PreprocessorDefinitions) 142 | ..\..\;..\..\source;..\..\pthread 143 | Speed 144 | MultiThreaded 145 | 146 | 4752; 147 | 148 | 149 | Windows 150 | true 151 | true 152 | true 153 | 154 | 155 | 156 | 157 | Level4 158 | 159 | 160 | MaxSpeed 161 | true 162 | true 163 | HIGH_BIT_DEPTH=0;BIT_DEPTH=8;WIN32;ARCH_X86_64=1;NDEBUG;_LIB;%(PreprocessorDefinitions) 164 | ..\..\;..\..\source;..\..\pthread;$(CUDA_PATH)\include;$(AMD_APPSDK_PATH)\include;$(INTEL_OPENCL_SDK)\include; 165 | Speed 166 | MultiThreaded 167 | 168 | 4752; 169 | 170 | 171 | Windows 172 | true 173 | true 174 | true 175 | 176 | 177 | 178 | -------------------------------------------------------------------------------- /build/vs2013/libdavs2_intrin_sse.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | vec 12 | 13 | 14 | vec 15 | 16 | 17 | vec 18 | 19 | 20 | vec 21 | 22 | 23 | vec 24 | 25 | 26 | vec 27 | 28 | 29 | vec 30 | 31 | 32 | vec 33 | 34 | 35 | vec 36 | 37 | 38 | vec 39 | 40 | 41 | 42 | 43 | vec 44 | 45 | 46 | -------------------------------------------------------------------------------- /build/vs2013/nasm.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | Midl 6 | CustomBuild 7 | 8 | 9 | $(VCInstallDir) 10 | 11 | 12 | 13 | $(IntDir)%(FileName).obj 14 | nasm.exe -Xvc -f win32 [AllOptions] [AdditionalOptions] "%(FullPath)" 15 | nasm.exe -Xvc -f win64 [AllOptions] [AdditionalOptions] "%(FullPath)" 16 | echo NASM not supported on this platform 17 | exit 1 18 | %(Identity) 19 | 20 | 21 | -------------------------------------------------------------------------------- /build/vs2013/nasm.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | _NASM 8 | 9 | 10 | 11 | 12 | $(ComputeLinkInputsTargets); 13 | ComputeNASMOutput; 14 | 15 | 16 | $(ComputeLibInputsTargets); 17 | ComputeNASMOutput; 18 | 19 | 20 | 24 | $(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml 25 | 26 | 34 | 35 | 36 | 37 | 38 | 39 | @(NASM, '|') 40 | 41 | 42 | 46 | 50 | 65 | 66 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /build/vs2013/nasm.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 12 | 13 | 14 | 16 | 17 | General 18 | 19 | 20 | 22 | 23 | Preprocessing Options 24 | 25 | 26 | 28 | 29 | Assembler Options 30 | 31 | 32 | 35 | 36 | Command Line 37 | 38 | 39 | 40 | 44 | 45 | 49 | 50 | 51 | 58 | 65 | 72 | 79 | 86 | 93 | 100 | 107 | 114 | 119 | 124 | 125 | Execute Before 126 | 127 | 128 | Specifies the targets for the build customization to run before. 129 | 130 | 131 | 134 | 135 | 136 | 140 | 141 | 142 | 147 | 148 | Execute After 149 | 150 | 151 | Specifies the targets for the build customization to run after. 152 | 153 | 154 | 157 | 158 | 159 | 163 | 164 | 165 | 170 | 175 | 179 | 180 | Additional Options 181 | 182 | 183 | Additional Options 184 | 185 | 186 | 187 | 190 | 193 | 197 | 198 | -------------------------------------------------------------------------------- /source/common/aec.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/aec.cc -------------------------------------------------------------------------------- /source/common/aec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * aec.h 3 | * 4 | * Description of this file: 5 | * AEC functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - 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 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #ifndef DAVS2_AEC_H 34 | #define DAVS2_AEC_H 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /* --------------------------------------------------------------------------- 41 | * global variables */ 42 | #define saoclip FPFX(saoclip) 43 | extern const int saoclip[NUM_SAO_OFFSET][3]; 44 | #define tab_intra_mode_scan_type FPFX(tab_intra_mode_scan_type) 45 | extern const int tab_intra_mode_scan_type[NUM_INTRA_MODE]; 46 | 47 | /* --------------------------------------------------------------------------- 48 | * aec basic operations */ 49 | #define aec_init_contexts FPFX(aec_init_contexts) 50 | void aec_init_contexts (aec_t *p_aec); 51 | #define aec_new_slice FPFX(aec_new_slice) 52 | void aec_new_slice (davs2_t *h); 53 | 54 | #define aec_start_decoding FPFX(aec_start_decoding) 55 | int aec_start_decoding (aec_t *p_aec, uint8_t *p_start, int i_byte_pos, int i_bytes); 56 | #define aec_bits_read FPFX(aec_bits_read) 57 | int aec_bits_read (aec_t *p_aec); 58 | #define aec_startcode_follows FPFX(aec_startcode_follows) 59 | int aec_startcode_follows (aec_t *p_aec, int eos_bit); 60 | 61 | /* --------------------------------------------------------------------------- 62 | * ctu structure information */ 63 | #define aec_read_split_flag FPFX(aec_read_split_flag) 64 | int aec_read_split_flag (aec_t *p_aec, int i_level); 65 | 66 | /* --------------------------------------------------------------------------- 67 | * cu type information */ 68 | #define aec_read_cu_type FPFX(aec_read_cu_type) 69 | int aec_read_cu_type (aec_t *p_aec, cu_t *p_cu, int img_type, int b_amp, int b_mhp, int b_wsm, int num_references); 70 | #define aec_read_cu_type_sframe FPFX(aec_read_cu_type_sframe) 71 | int aec_read_cu_type_sframe(aec_t *p_aec); 72 | #define aec_read_intra_cu_type FPFX(aec_read_intra_cu_type) 73 | int aec_read_intra_cu_type (aec_t *p_aec, cu_t *p_cu, int b_sdip, davs2_t *h); 74 | 75 | /* --------------------------------------------------------------------------- 76 | * inter prediction information */ 77 | #define aec_read_dmh_mode FPFX(aec_read_dmh_mode) 78 | int aec_read_dmh_mode (aec_t *p_aec, int i_cu_level); 79 | #define aec_read_mvds FPFX(aec_read_mvds) 80 | void aec_read_mvds (aec_t *p_aec, mv_t *p_mvd); 81 | #define aec_read_inter_pred_dir FPFX(aec_read_inter_pred_dir) 82 | void aec_read_inter_pred_dir(aec_t * p_aec, cu_t *p_cu, davs2_t *h); 83 | 84 | /* --------------------------------------------------------------------------- 85 | * intra prediction information */ 86 | #define aec_read_intra_pmode FPFX(aec_read_intra_pmode) 87 | int aec_read_intra_pmode (aec_t *p_aec); 88 | #define aec_read_intra_pmode_c FPFX(aec_read_intra_pmode_c) 89 | int aec_read_intra_pmode_c (aec_t *p_aec, davs2_t *h, int luma_mode); 90 | 91 | /* --------------------------------------------------------------------------- 92 | * transform unit (residual) information */ 93 | #define cu_read_cbp FPFX(cu_read_cbp) 94 | int cu_read_cbp (davs2_t *h, aec_t *p_aec, cu_t *p_cu, int scu_x, int scu_y); 95 | #define cu_get_block_coeffs FPFX(cu_get_block_coeffs) 96 | int8_t cu_get_block_coeffs (aec_t *p_aec, runlevel_t *runlevel, 97 | cu_t *p_cu, coeff_t *p_res, int w_tr, int h_tr, 98 | int i_tu_level, int b_luma, 99 | int intra_pred_class, int b_swap_xy, 100 | int scale, int shift, int wq_size_id); 101 | 102 | /* --------------------------------------------------------------------------- 103 | * loop filter information */ 104 | #define aec_read_sao_mergeflag FPFX(aec_read_sao_mergeflag) 105 | int aec_read_sao_mergeflag (aec_t *p_aec, int mergeleft_avail, int mergeup_avail); 106 | #define aec_read_sao_mode FPFX(aec_read_sao_mode) 107 | int aec_read_sao_mode (aec_t *p_aec); 108 | #define aec_read_sao_offsets FPFX(aec_read_sao_offsets) 109 | void aec_read_sao_offsets (aec_t *p_aec, sao_param_t *p_sao_param, int *offset); 110 | #define aec_read_sao_type FPFX(aec_read_sao_type) 111 | int aec_read_sao_type (aec_t *p_aec, sao_param_t *p_sao_param); 112 | 113 | #define aec_read_alf_lcu_ctrl FPFX(aec_read_alf_lcu_ctrl) 114 | int aec_read_alf_lcu_ctrl (aec_t *p_aec); 115 | 116 | #ifndef AEC_RETURN_ON_ERROR 117 | #define AEC_RETURN_ON_ERROR(ret_code) \ 118 | if (p_aec->b_bit_error) {\ 119 | p_aec->b_bit_error = FALSE; /* reset error flag */\ 120 | /* davs2_log(h, DAVS2_LOG_ERROR, "aec decoding error."); */\ 121 | return (ret_code);\ 122 | } 123 | #endif 124 | 125 | #ifdef __cplusplus 126 | } 127 | #endif 128 | #endif // DAVS2_AEC_H 129 | -------------------------------------------------------------------------------- /source/common/alf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * alf.h 3 | * 4 | * Description of this file: 5 | * ALF functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - 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 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #ifndef DAVS2_ALF_H 34 | #define DAVS2_ALF_H 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | #define alf_get_buffer_size FPFX(alf_get_buffer_size) 40 | size_t alf_get_buffer_size(davs2_t *h); 41 | #define alf_init_buffer FPFX(alf_init_buffer) 42 | void alf_init_buffer (davs2_t *h); 43 | 44 | #define alf_lcurow FPFX(alf_lcurow) 45 | void alf_lcurow(davs2_t *h, alf_param_t *p_alf_param, davs2_frame_t *p_tmp_frm, davs2_frame_t *p_dec_frm, int i_lcu_y); 46 | 47 | #define alf_read_param FPFX(alf_read_param) 48 | void alf_read_param(davs2_t *h, davs2_bs_t *bs); 49 | 50 | #define davs2_alf_init FPFX(alf_init) 51 | void davs2_alf_init(uint32_t cpuid, ao_funcs_t *fh); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | #endif // DAVS2_ALF_H 57 | -------------------------------------------------------------------------------- /source/common/bitstream.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * bitstream.cc 3 | * 4 | * Description of this file: 5 | * Bitstream functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - 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 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #include "common.h" 34 | #include "aec.h" 35 | #include "bitstream.h" 36 | 37 | 38 | /* --------------------------------------------------------------------------- 39 | * start code (in 32-bit) 40 | */ 41 | #define SEQENCE_START_CODE 0xB0010000 42 | #define I_FRAME_START_CODE 0xB3010000 43 | #define PB_FRAME_START_CODE 0xB6010000 44 | 45 | 46 | /** 47 | * =========================================================================== 48 | * function defines 49 | * =========================================================================== 50 | */ 51 | 52 | /* --------------------------------------------------------------------------- 53 | */ 54 | void bs_init(davs2_bs_t *bs, uint8_t *p_data, int i_data) 55 | { 56 | bs->p_stream = p_data; 57 | bs->i_stream = i_data; 58 | bs->i_bit_pos = 0; 59 | } 60 | 61 | /* --------------------------------------------------------------------------- 62 | * align position in bitstream */ 63 | void bs_align(davs2_bs_t *bs) 64 | { 65 | bs->i_bit_pos = ((bs->i_bit_pos + 7) >> 3) << 3; 66 | } 67 | 68 | /* --------------------------------------------------------------------------- 69 | */ 70 | int bs_left_bytes(davs2_bs_t *bs) 71 | { 72 | return (bs->i_stream - (bs->i_bit_pos >> 3)); 73 | } 74 | 75 | /* --------------------------------------------------------------------------- 76 | * Function : try to find slice header in next forward bytes 77 | * Parameters : 78 | * [in ] : bs_data - pointer to the bit-stream data buffer 79 | * Return : TRUE for slice header, otherwise FALSE 80 | * --------------------------------------------------------------------------- 81 | */ 82 | int found_slice_header(davs2_bs_t *bs) 83 | { 84 | int num_bytes = 4; 85 | 86 | for (; num_bytes; num_bytes--) { 87 | uint8_t *data = bs->p_stream + ((bs->i_bit_pos + 7) >> 3); 88 | uint32_t code = *(uint32_t *)data; 89 | if ((code & 0x00FFFFFF) == 0x00010000 && ((code >> 24) <= SC_SLICE_CODE_MAX)) { 90 | return 1; 91 | } 92 | bs->i_bit_pos += 8; 93 | } 94 | 95 | return 0; 96 | } 97 | 98 | /* --------------------------------------------------------------------------- 99 | */ 100 | int bs_get_start_code(davs2_bs_t *bs) 101 | { 102 | uint8_t *p_data = bs->p_stream + ((bs->i_bit_pos + 7) >> 3); 103 | int i_left_bytes = bs_left_bytes(bs); 104 | int i_used_bytes = 0; 105 | 106 | /* find the start code '00 00 01 xx' */ 107 | while (i_left_bytes >= 4 && (*(uint32_t *)p_data & 0x00FFFFFF) != 0x00010000) { 108 | p_data++; 109 | i_left_bytes--; 110 | i_used_bytes++; 111 | } 112 | 113 | if (i_left_bytes >= 4) { 114 | bs->i_bit_pos += (i_used_bytes << 3); 115 | return p_data[3]; 116 | } else { 117 | return -1; 118 | } 119 | } 120 | 121 | /* --------------------------------------------------------------------------- 122 | * Function : check bitstream & dispose the pseudo start code 123 | * Parameters : 124 | * [in] : dst - pointer to dst byte buffer 125 | * [in/out] : src - pointer to source byte buffer 126 | * [in/out] : i_src - byte number of src 127 | * Return : byte number of dst 128 | * --------------------------------------------------------------------------- 129 | */ 130 | int bs_dispose_pseudo_code(uint8_t *dst, uint8_t *src, int i_src) 131 | { 132 | static const int BITMASK[] = { 0x00, 0x00, 0xc0, 0x00, 0xf0, 0x00, 0xfc, 0x00 }; 133 | int b_found_start_code = 0; 134 | int leading_zeros = 0; 135 | int last_bit_count = 0; 136 | int curr_bit_count = 0; 137 | int b_dispose = 0; 138 | int i_pos = 0; 139 | int i_dst = 0; 140 | uint8_t last_byte = 0; 141 | uint8_t curr_byte = 0; 142 | 143 | /* checking... */ 144 | while (i_pos < i_src) { 145 | curr_byte = src[i_pos++]; 146 | curr_bit_count = 8; 147 | switch (curr_byte) { 148 | case 0: 149 | if (b_found_start_code) { 150 | b_dispose = 1; /* start code of first slice: [00 00 01 00] */ 151 | b_found_start_code = 0; 152 | } 153 | leading_zeros++; 154 | break; 155 | case 1: 156 | if (leading_zeros >= 2) { 157 | /* find start code: [00 00 01] */ 158 | b_found_start_code = 1; 159 | if (last_bit_count) { 160 | /* terminate the fixing work before new start code */ 161 | last_bit_count = 0; 162 | dst[i_dst++] = 0; /* insert the dispose byte */ 163 | } 164 | } 165 | leading_zeros = 0; 166 | break; 167 | case 2: 168 | if (b_dispose && leading_zeros == 2) { 169 | /* dispose the pseudo code, two bits */ 170 | curr_bit_count = 6; 171 | } 172 | leading_zeros = 0; 173 | break; 174 | default: 175 | if (b_found_start_code) { 176 | if (curr_byte == SC_SEQUENCE_HEADER || curr_byte == SC_USER_DATA || curr_byte == SC_EXTENSION) { 177 | b_dispose = 0; 178 | } else { 179 | b_dispose = 1; 180 | } 181 | b_found_start_code = 0; 182 | } 183 | leading_zeros = 0; 184 | break; 185 | } 186 | 187 | if (curr_bit_count == 8) { 188 | if (last_bit_count == 0) { 189 | dst[i_dst++] = curr_byte; 190 | } else { 191 | dst[i_dst++] = ((last_byte & BITMASK[last_bit_count]) | ((curr_byte & BITMASK[8 - last_bit_count]) >> last_bit_count)); 192 | last_byte = (curr_byte << (8 - last_bit_count)) & BITMASK[last_bit_count]; 193 | } 194 | } else { 195 | if (last_bit_count == 0) { 196 | last_byte = curr_byte; 197 | last_bit_count = curr_bit_count; 198 | } else { 199 | dst[i_dst++] = ((last_byte & BITMASK[last_bit_count]) | ((curr_byte & BITMASK[8 - last_bit_count]) >> last_bit_count)); 200 | last_byte = (curr_byte << (8 - last_bit_count)) & BITMASK[last_bit_count - 2]; 201 | last_bit_count = last_bit_count - 2; 202 | } 203 | } 204 | } 205 | 206 | if (last_bit_count != 0 && last_byte != 0) { 207 | dst[i_dst++] = last_byte; 208 | } 209 | 210 | return i_dst; 211 | } 212 | 213 | // --------------------------------------------------------------------------- 214 | // find the first start code in byte stream 215 | // return the byte address if found, or NULL on failure 216 | const uint8_t * 217 | find_start_code(const uint8_t *data, int len) 218 | { 219 | while (len >= 4 && (*(uint32_t *)data & 0x00FFFFFF) != 0x00010000) { 220 | data++; 221 | len--; 222 | } 223 | 224 | return len >= 4 ? data : NULL; 225 | } 226 | 227 | // --------------------------------------------------------------------------- 228 | // find the first picture or sequence start code in byte stream 229 | int32_t 230 | find_pic_start_code(uint8_t prevbyte3, uint8_t prevbyte2, uint8_t prevbyte1, const uint8_t *data, int32_t len) 231 | { 232 | #define ISPIC(x) ((x) == 0xB0 || (x) == 0xB1 || (x) == 0xB3 || (x) == 0xB6 || (x) == 0xB7) 233 | 234 | const uint8_t *p = NULL; 235 | const uint8_t *data0 = data; 236 | const int32_t len0 = len; 237 | 238 | /* check start code: 00 00 01 xx */ 239 | if (/*..*/ len >= 1 && (prevbyte3 == 0) && (prevbyte2 == 0) && (prevbyte1 == 1)) { 240 | if (ISPIC(data[0])) { 241 | return -3; // found start code (position: -3) 242 | } 243 | } else if (len >= 2 && (prevbyte2 == 0) && (prevbyte1 == 0) && (data[0] == 1)) { 244 | if (ISPIC(data[1])) { 245 | return -2; // found start code (position: -2) 246 | } 247 | } else if (len >= 3 && (prevbyte1 == 0) && (data[0] == 0) && (data[1] == 1)) { 248 | if (ISPIC(data[2])) { 249 | return -1; // found start code (position: -1) 250 | } 251 | } 252 | 253 | /* check start code: 00 00 01 xx, ONLY in data buffer */ 254 | while (((p = (uint8_t *)find_start_code(data, len)) != NULL) && !ISPIC(p[3])) { 255 | len -= (int32_t)(p - data + 4); 256 | data = p + 4; 257 | } 258 | 259 | return (int32_t)(p != NULL ? p - data0 : len0 + 1); 260 | 261 | #undef ISPIC 262 | } 263 | -------------------------------------------------------------------------------- /source/common/bitstream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * bitstream.h 3 | * 4 | * Description of this file: 5 | * Bitstream functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - 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 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #ifndef DAVS2_BITSTREAM_H 34 | #define DAVS2_BITSTREAM_H 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | #include "common.h" 40 | 41 | #define bs_init FPFX(bs_init) 42 | void bs_init(davs2_bs_t *bs, uint8_t *p_data, int i_data); 43 | #define bs_align FPFX(bs_align) 44 | void bs_align(davs2_bs_t *bs); 45 | #define bs_left_bytes FPFX(bs_left_bytes) 46 | int bs_left_bytes(davs2_bs_t *bs); 47 | #define found_slice_header FPFX(found_slice_header) 48 | int found_slice_header(davs2_bs_t *bs); 49 | #define bs_get_start_code FPFX(bs_get_start_code) 50 | int bs_get_start_code(davs2_bs_t *bs); 51 | #define bs_dispose_pseudo_code FPFX(bs_dispose_pseudo_code) 52 | int bs_dispose_pseudo_code(uint8_t *dst, uint8_t *src, int i_src); 53 | #define find_start_code FPFX(find_start_code) 54 | const uint8_t * find_start_code(const uint8_t *data, int len); 55 | #define find_pic_start_code FPFX(find_pic_start_code) 56 | int32_t find_pic_start_code(uint8_t prevbyte3, uint8_t prevbyte2, uint8_t prevbyte1, const uint8_t *data, int32_t len); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | #endif // DAVS2_BITSTREAM_H 62 | -------------------------------------------------------------------------------- /source/common/block_info.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/block_info.cc -------------------------------------------------------------------------------- /source/common/block_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * block_info.h 3 | * 4 | * Description of this file: 5 | * Block Infomation functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - 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 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #ifndef DAVS2_BLOCK_INFO_H 34 | #define DAVS2_BLOCK_INFO_H 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | #define get_neighbor_cbp_y FPFX(get_neighbor_cbp_y) 40 | int get_neighbor_cbp_y(davs2_t *h, int xN, int yN, int scu_x, int scu_y, cu_t *p_cu); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | #endif // DAVS2_BLOCK_INFO_H 46 | -------------------------------------------------------------------------------- /source/common/common.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/common.cc -------------------------------------------------------------------------------- /source/common/common.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/common.h -------------------------------------------------------------------------------- /source/common/cpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cpu.h 3 | * 4 | * Description of this file: 5 | * CPU-Processing functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - 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 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | 34 | #ifndef DAVS2_CPU_H 35 | #define DAVS2_CPU_H 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | 41 | #define davs2_cpu_detect FPFX(cpu_detect) 42 | uint32_t davs2_cpu_detect(void); 43 | #define davs2_cpu_num_processors FPFX(cpu_num_processors) 44 | int davs2_cpu_num_processors(void); 45 | #define avs_cpu_emms FPFX(avs_cpu_emms) 46 | void avs_cpu_emms(void); 47 | #define avs_cpu_mask_misalign_sse FPFX(avs_cpu_mask_misalign_sse) 48 | void avs_cpu_mask_misalign_sse(void); 49 | #define avs_cpu_sfence FPFX(avs_cpu_sfence) 50 | void avs_cpu_sfence(void); 51 | 52 | #define davs2_get_simd_capabilities FPFX(get_simd_capabilities) 53 | char *davs2_get_simd_capabilities(char *buf, uint32_t cpuid); 54 | 55 | #if HAVE_MMX 56 | #define davs2_cpu_cpuid FPFX(cpu_cpuid) 57 | uint32_t davs2_cpu_cpuid(uint32_t op, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx); 58 | #define davs2_cpu_xgetbv FPFX(cpu_xgetbv) 59 | void davs2_cpu_xgetbv(uint32_t op, uint32_t *eax, uint32_t *edx); 60 | #define avs_emms() avs_cpu_emms() 61 | #else 62 | #define avs_emms() 63 | #endif 64 | 65 | #define avs_sfence avs_cpu_sfence 66 | 67 | /* kluge: 68 | * gcc can't give variables any greater alignment than the stack frame has. 69 | * We need 16 byte alignment for SSE2, so here we make sure that the stack is 70 | * aligned to 16 bytes. 71 | * gcc 4.2 introduced __attribute__((force_align_arg_pointer)) to fix this 72 | * problem, but I don't want to require such a new version. 73 | * This applies only to x86_32, since other architectures that need alignment 74 | * also have ABIs that ensure aligned stack. */ 75 | #if ARCH_X86 && HAVE_MMX 76 | //int xavs_stack_align(void(*func) (xavs_t *), xavs_t * arg); 77 | //#define avs_stack_align(func,arg) avs_stack_align((void (*)(xavs_t*))func,arg) 78 | #else 79 | #define avs_stack_align(func,...) func(__VA_ARGS__) 80 | #endif 81 | 82 | #define avs_cpu_restore FPFX(avs_cpu_restore) 83 | void avs_cpu_restore(uint32_t cpuid); 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | #endif // DAVS2_CPU_H 89 | -------------------------------------------------------------------------------- /source/common/cu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cu.h 3 | * 4 | * Description of this file: 5 | * CU Processing functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - 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 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #ifndef DAVS2_CU_H 34 | #define DAVS2_CU_H 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /* --------------------------------------------------------------------------- 40 | * init LCU decoding 41 | * \input param 42 | * h : decoder handler 43 | * i_lcu_x : LCU position index 44 | * i_lcu_y : LCU position index 45 | */ 46 | #define decode_lcu_init FPFX(decode_lcu_init) 47 | void decode_lcu_init (davs2_t *h, int i_lcu_x, int i_lcu_y); 48 | 49 | #define rowrec_lcu_init FPFX(rowrec_lcu_init) 50 | void rowrec_lcu_init (davs2_t *h, davs2_row_rec_t *row_rec, int i_lcu_x, int i_lcu_y); 51 | 52 | /* --------------------------------------------------------------------------- 53 | * process LCU entropy decoding (recursively) 54 | * \input param 55 | * h : decoder handler 56 | * i_level : log2(CU size) 57 | * pix_x : pixel position of the decoding CU in the frame in Luma component 58 | * pix_y : pixel position of the decoding CU in the frame in Luma component 59 | */ 60 | #define decode_lcu_parse FPFX(decode_lcu_parse) 61 | int decode_lcu_parse(davs2_t *h, int i_level, int pix_x, int pix_y); 62 | 63 | /* --------------------------------------------------------------------------- 64 | * process LCU reconstruction (recursively) 65 | * \input param 66 | * h : decoder handler 67 | * i_level : log2(CU size) 68 | * pix_x : pixel position of the decoding CU in the frame in Luma component 69 | * pix_y : pixel position of the decoding CU in the frame in Luma component 70 | */ 71 | #define decode_lcu_recon FPFX(decode_lcu_recon) 72 | int decode_lcu_recon(davs2_t *h, davs2_row_rec_t *row_rec, int i_level, int pix_x, int pix_y); 73 | 74 | #define decoder_wait_lcu_row FPFX(decoder_wait_lcu_row) 75 | void decoder_wait_lcu_row(davs2_t *h, davs2_frame_t *frame, int max_y_in_pic); 76 | #define decoder_wait_row FPFX(decoder_wait_row) 77 | void decoder_wait_row(davs2_t *h, davs2_frame_t *frame, int max_y_in_pic); 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | #endif // DAVS2_CU_H 83 | -------------------------------------------------------------------------------- /source/common/davs2.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/davs2.cc -------------------------------------------------------------------------------- /source/common/deblock.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/deblock.cc -------------------------------------------------------------------------------- /source/common/deblock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * deblock.h 3 | * 4 | * Description of this file: 5 | * Deblock functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - 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 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #ifndef DAVS2_DEBLOCK_H 34 | #define DAVS2_DEBLOCK_H 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | #define davs2_deblock_init FPFX(deblock_init) 40 | void davs2_deblock_init(uint32_t cpuid, ao_funcs_t* fh); 41 | #define davs2_lcu_deblock FPFX(lcu_deblock) 42 | void davs2_lcu_deblock(davs2_t *h, davs2_frame_t *frm, int i_lcu_x, int i_lcu_y); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | #endif // DAVS2_DEBLOCK_H 48 | -------------------------------------------------------------------------------- /source/common/decoder.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/decoder.cc -------------------------------------------------------------------------------- /source/common/decoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * decoder.h 3 | * 4 | * Description of this file: 5 | * Decoder functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - 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 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #ifndef DAVS2_DECODER_H 34 | #define DAVS2_DECODER_H 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | #include "common.h" 40 | 41 | #define decoder_open FPFX(decoder_decoder_open) 42 | davs2_t *decoder_open(davs2_mgr_t *mgr, davs2_t *h, int idx_decoder); 43 | #define decoder_decode_picture_data FPFX(decoder_decode_picture_data) 44 | void *decoder_decode_picture_data(void *arg1, int arg2); 45 | #define decoder_close FPFX(decoder_decoder_close) 46 | void decoder_close(davs2_t *h); 47 | #define create_freepictures FPFX(create_freepictures) 48 | int create_freepictures(davs2_mgr_t *mgr, int w, int h, int size); 49 | #define destroy_freepictures FPFX(destroy_freepictures) 50 | void destroy_freepictures(davs2_mgr_t *mgr); 51 | #define decoder_alloc_extra_buffer FPFX(decoder_alloc_extra_buffer) 52 | int decoder_alloc_extra_buffer(davs2_t *h); 53 | #define decoder_free_extra_buffer FPFX(decoder_free_extra_buffer) 54 | void decoder_free_extra_buffer(davs2_t *h); 55 | #define davs2_write_a_frame FPFX(write_a_frame) 56 | void davs2_write_a_frame(davs2_picture_t *pic, davs2_frame_t *frame); 57 | 58 | #define task_get_references FPFX(task_get_references) 59 | int task_get_references(davs2_t *h, int64_t pts, int64_t dts); 60 | 61 | #define task_unload_packet FPFX(task_unload_packet) 62 | void task_unload_packet(davs2_t *h, es_unit_t *es_unit); 63 | #define decoder_get_output FPFX(decoder_get_output) 64 | int decoder_get_output(davs2_mgr_t *mgr, davs2_seq_info_t *headerset, davs2_picture_t *out_frame, int is_flush); 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | #endif // DAVS2_DECODER_H 70 | -------------------------------------------------------------------------------- /source/common/frame.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/frame.cc -------------------------------------------------------------------------------- /source/common/frame.h: -------------------------------------------------------------------------------- 1 | /* 2 | * frame.h 3 | * 4 | * Description of this file: 5 | * Frame handling functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - 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 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #ifndef DAVS2_FRAME_H 34 | #define DAVS2_FRAME_H 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * =========================================================================== 41 | * function declares 42 | * =========================================================================== 43 | */ 44 | #define davs2_frame_get_size FPFX(frame_get_size) 45 | size_t davs2_frame_get_size(int width, int height, int chroma_format, int b_extra); 46 | #define davs2_frame_new FPFX(frame_new) 47 | davs2_frame_t *davs2_frame_new(int width, int height, int chroma_format, uint8_t **mem_base, int b_extra); 48 | 49 | #define davs2_frame_destroy FPFX(frame_destroy) 50 | void davs2_frame_destroy(davs2_frame_t *frame); 51 | 52 | #define davs2_frame_copy_planes FPFX(frame_copy_planes) 53 | void davs2_frame_copy_planes(davs2_frame_t *p_dst, davs2_frame_t *p_src); 54 | #define davs2_frame_copy_properties FPFX(frame_copy_properties) 55 | void davs2_frame_copy_properties(davs2_frame_t *p_dst, davs2_frame_t *p_src); 56 | #define davs2_frame_copy_lcu FPFX(frame_copy_lcu) 57 | void davs2_frame_copy_lcu(davs2_t *h, davs2_frame_t *p_dst, davs2_frame_t *p_src, int i_lcu_x, int i_lcu_y, int pix_offset, int padding_size); 58 | #define davs2_frame_copy_lcurow FPFX(frame_copy_lcurow) 59 | void davs2_frame_copy_lcurow(davs2_t *h, davs2_frame_t *p_dst, davs2_frame_t *p_src, int i_lcu_y, int pix_offset, int padding_size); 60 | 61 | #define davs2_frame_expand_border FPFX(frame_expand_border) 62 | void davs2_frame_expand_border(davs2_frame_t *frame); 63 | 64 | #define pad_line_lcu FPFX(pad_line_lcu) 65 | void pad_line_lcu(davs2_t *h, int lcu_y); 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | #endif /* DAVS2_FRAME_H */ 71 | -------------------------------------------------------------------------------- /source/common/header.h: -------------------------------------------------------------------------------- 1 | /* 2 | * header.h 3 | * 4 | * Description of this file: 5 | * Header functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - 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 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #ifndef DAVS2_HEADER_H 34 | #define DAVS2_HEADER_H 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | #define parse_slice_header FPFX(parse_slice_header) 40 | void parse_slice_header(davs2_t *h, davs2_bs_t *bs); 41 | #define parse_header FPFX(parse_header) 42 | int parse_header(davs2_t *h, davs2_bs_t *p_bs); 43 | 44 | #define release_one_frame FPFX(release_one_frame) 45 | void release_one_frame(davs2_frame_t *frame); 46 | #define task_release_frames FPFX(task_release_frames) 47 | void task_release_frames(davs2_t *h); 48 | 49 | #define alloc_picture FPFX(alloc_picture) 50 | davs2_outpic_t *alloc_picture(int w, int h); 51 | #define free_picture FPFX(free_picture) 52 | void free_picture(davs2_outpic_t *pic); 53 | 54 | #define destroy_dpb FPFX(destroy_dpb) 55 | void destroy_dpb(davs2_mgr_t *mgr); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | #endif // DAVS2_HEADER_H 61 | -------------------------------------------------------------------------------- /source/common/intra.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/intra.cc -------------------------------------------------------------------------------- /source/common/intra.h: -------------------------------------------------------------------------------- 1 | /* 2 | * intra.h 3 | * 4 | * Description of this file: 5 | * Intra prediction functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - 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 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #ifndef DAVS2_INTRA_H 34 | #define DAVS2_INTRA_H 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /* --------------------------------------------------------------------------- 40 | */ 41 | static ALWAYS_INLINE 42 | void intra_pred(pel_t *src, pel_t *dst, int i_dst, int dir_mode, int bsy, int bsx, int i_avail) 43 | { 44 | if (dir_mode != DC_PRED) { 45 | gf_davs2.intraf[dir_mode](src, dst, i_dst, dir_mode, bsx, bsy); 46 | } else { 47 | int b_top = !!IS_NEIGHBOR_AVAIL(i_avail, MD_I_TOP); 48 | int b_left = !!IS_NEIGHBOR_AVAIL(i_avail, MD_I_LEFT); 49 | int mode_ex = ((b_top << 8) + b_left); 50 | 51 | gf_davs2.intraf[dir_mode](src, dst, i_dst, mode_ex, bsx, bsy); 52 | } 53 | } 54 | 55 | #define davs2_intra_pred_init FPFX(intra_pred_init) 56 | void davs2_intra_pred_init(uint32_t cpuid, ao_funcs_t *pf); 57 | #define davs2_get_intra_pred FPFX(get_intra_pred) 58 | void davs2_get_intra_pred(davs2_row_rec_t *row_rec, cu_t *p_cu, int predmode, int ctu_x, int ctu_y, int bsx, int bsy); 59 | #define davs2_get_intra_pred_chroma FPFX(get_intra_pred_chroma) 60 | void davs2_get_intra_pred_chroma(davs2_row_rec_t *h, cu_t *p_cu, int ctu_c_x, int ctu_c_y); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | #endif // DAVS2_INTRA_H 66 | -------------------------------------------------------------------------------- /source/common/mc.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/mc.cc -------------------------------------------------------------------------------- /source/common/mc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mc.h 3 | * 4 | * Description of this file: 5 | * MC functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - 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 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #ifndef DAVS2_MC_H 34 | #define DAVS2_MC_H 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | #define mc_luma FPFX(mc_luma) 40 | void mc_luma (davs2_t *h, pel_t *dst, int i_dst, int posx, int posy, int width, int height, pel_t *p_fref, int i_fref); 41 | #define mc_chroma FPFX(mc_chroma) 42 | void mc_chroma(davs2_t *h, pel_t *dst, int i_dst, int posx, int posy, int width, int height, pel_t *p_fref, int i_fref); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | #endif // DAVS2_MC_H 48 | -------------------------------------------------------------------------------- /source/common/memory.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * memory.cc 3 | * 4 | * Description of this file: 5 | * Memory functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - 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 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #include "common.h" 34 | #include "primitives.h" 35 | 36 | #if HAVE_MMX 37 | #include "vec/intrinsic.h" 38 | #endif 39 | 40 | /* --------------------------------------------------------------------------- 41 | */ 42 | void *memzero_aligned_c(void *dst, size_t n) 43 | { 44 | return memset(dst, 0, n); 45 | } 46 | 47 | /* --------------------------------------------------------------------------- 48 | */ 49 | void davs2_memory_init(uint32_t cpuid, ao_funcs_t* pf) 50 | { 51 | /* memory copy */ 52 | pf->fast_memcpy = memcpy; 53 | pf->fast_memset = memset; 54 | pf->memcpy_aligned = memcpy; 55 | pf->fast_memzero = memzero_aligned_c; 56 | pf->memzero_aligned = memzero_aligned_c; 57 | 58 | /* init asm function handles */ 59 | #if HAVE_MMX 60 | if (cpuid & DAVS2_CPU_MMX) { 61 | pf->fast_memcpy = davs2_fast_memcpy_mmx; 62 | pf->memcpy_aligned = davs2_memcpy_aligned_mmx; 63 | pf->fast_memset = davs2_fast_memset_mmx; 64 | pf->fast_memzero = davs2_fast_memzero_mmx; 65 | pf->memzero_aligned = davs2_fast_memzero_mmx; 66 | } 67 | 68 | if (cpuid & DAVS2_CPU_SSE) { 69 | // pf->memcpy_aligned = davs2_memcpy_aligned_sse; 70 | // pf->memzero_aligned = davs2_memzero_aligned_sse; 71 | } 72 | 73 | if (cpuid & DAVS2_CPU_SSE2) { 74 | pf->memzero_aligned = davs2_memzero_aligned_c_sse2; 75 | // gf_davs2.memcpy_aligned = davs2_memcpy_aligned_c_sse2; 76 | } 77 | 78 | if (cpuid & DAVS2_CPU_AVX2) { 79 | pf->memzero_aligned = davs2_memzero_aligned_c_avx; 80 | } 81 | #endif // HAVE_MMX 82 | } 83 | -------------------------------------------------------------------------------- /source/common/osdep.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/osdep.h -------------------------------------------------------------------------------- /source/common/predict.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/predict.cc -------------------------------------------------------------------------------- /source/common/predict.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/predict.h -------------------------------------------------------------------------------- /source/common/primitives.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * primitives.cc 3 | * 4 | * Description of this file: 5 | * function handles initialize functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - 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 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | 34 | #include "common.h" 35 | #include "primitives.h" 36 | #include "cpu.h" 37 | #include "intra.h" 38 | #include "mc.h" 39 | #include "transform.h" 40 | #include "quant.h" 41 | #include "deblock.h" 42 | #include "sao.h" 43 | #include "alf.h" 44 | 45 | /* --------------------------------------------------------------------------- 46 | */ 47 | ao_funcs_t gf_davs2 = {0}; 48 | 49 | /* --------------------------------------------------------------------------- 50 | */ 51 | void init_all_primitives(uint32_t cpuid) 52 | { 53 | if (gf_davs2.initial_count != 0) { 54 | // already initialed 55 | gf_davs2.initial_count++; 56 | return; 57 | } 58 | 59 | gf_davs2.initial_count = 1; 60 | gf_davs2.cpuid = cpuid; 61 | 62 | /* init function handles */ 63 | davs2_memory_init (cpuid, &gf_davs2); 64 | davs2_intra_pred_init(cpuid, &gf_davs2); 65 | davs2_pixel_init (cpuid, &gf_davs2); 66 | davs2_mc_init (cpuid, &gf_davs2); 67 | davs2_quant_init (cpuid, &gf_davs2); 68 | davs2_dct_init (cpuid, &gf_davs2); 69 | davs2_deblock_init (cpuid, &gf_davs2); 70 | davs2_sao_init (cpuid, &gf_davs2); 71 | davs2_alf_init (cpuid, &gf_davs2); 72 | 73 | } 74 | -------------------------------------------------------------------------------- /source/common/primitives.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/primitives.h -------------------------------------------------------------------------------- /source/common/quant.h: -------------------------------------------------------------------------------- 1 | /* 2 | * quant.h 3 | * 4 | * Description of this file: 5 | * Quant functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - 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 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #ifndef DAVS2_QUANT_H 34 | #define DAVS2_QUANT_H 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | #define QP_SCALE_CR FPFX(QP_SCALE_CR) 40 | extern const uint8_t QP_SCALE_CR[]; 41 | #define IQ_SHIFT FPFX(IQ_SHIFT) 42 | extern const int16_t IQ_SHIFT[]; 43 | #define IQ_TAB FPFX(IQ_TAB) 44 | extern const uint16_t IQ_TAB[]; 45 | #define wq_param_default FPFX(wq_param_default) 46 | extern const int16_t wq_param_default[2][6]; 47 | 48 | 49 | /** 50 | * --------------------------------------------------------------------------- 51 | * Weight Quant 52 | * - Adaptive Frequency Weighting Quantization, include: 53 | * a). Frequency weighting model, quantization 54 | * b). Picture level user-defined frequency weighting 55 | * c). LCU level adaptive frequency weighting mode decision 56 | * According to adopted proposals: m1878, m2148, m2331 57 | * --------------------------------------------------------------------------- 58 | */ 59 | #define PARAM_NUM 6 60 | #define WQ_MODEL_NUM 3 61 | 62 | #define UNDETAILED 0 63 | #define DETAILED 1 64 | 65 | #define WQ_MODE_F 0 66 | #define WQ_MODE_U 1 67 | #define WQ_MODE_D 2 68 | 69 | #define wq_get_default_matrix FPFX(wq_get_default_matrix) 70 | const int *wq_get_default_matrix(int sizeId); 71 | 72 | #define wq_init_frame_quant_param FPFX(wq_init_frame_quant_param) 73 | void wq_init_frame_quant_param(davs2_t *h); 74 | #define wq_update_frame_matrix FPFX(wq_update_frame_matrix) 75 | void wq_update_frame_matrix(davs2_t *h); 76 | 77 | 78 | /* dequant */ 79 | #define dequant_coeffs FPFX(dequant_coeffs) 80 | void dequant_coeffs(davs2_t *h, coeff_t *p_coeff, int bsx, int bsy, int scale, int shift, int WQMSizeId); 81 | #define davs2_quant_init FPFX(quant_init) 82 | void davs2_quant_init(uint32_t cpuid, ao_funcs_t *fh); 83 | 84 | 85 | /* --------------------------------------------------------------------------- 86 | * get qp in chroma component 87 | */ 88 | static ALWAYS_INLINE 89 | int cu_get_chroma_qp(davs2_t * h, int luma_qp, int uv) 90 | { 91 | int qp = luma_qp + (uv == 0 ? h->chroma_quant_param_delta_u : h->chroma_quant_param_delta_v); 92 | 93 | #if HIGH_BIT_DEPTH 94 | const int bit_depth_offset = ((h->sample_bit_depth - 8) << 3); 95 | qp -= bit_depth_offset; 96 | qp = qp < 0 ? qp : QP_SCALE_CR[qp]; 97 | qp = DAVS2_CLIP3(0, 63 + bit_depth_offset, qp + bit_depth_offset); 98 | 99 | #else 100 | qp = QP_SCALE_CR[DAVS2_CLIP3(0, 63, qp)]; 101 | #endif 102 | 103 | return qp; 104 | } 105 | 106 | 107 | 108 | /* --------------------------------------------------------------------------- 109 | * get quant parameters 110 | */ 111 | static ALWAYS_INLINE 112 | void cu_get_quant_params(davs2_t * h, int qp, int bit_size, 113 | int *shift, int *scale) 114 | { 115 | *shift = IQ_SHIFT[qp] + (h->sample_bit_depth + 1) + bit_size - LIMIT_BIT; 116 | *scale = IQ_TAB[qp]; 117 | } 118 | 119 | 120 | #ifdef __cplusplus 121 | } 122 | #endif 123 | #endif // DAVS2_QUANT_H 124 | -------------------------------------------------------------------------------- /source/common/sao.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/sao.cc -------------------------------------------------------------------------------- /source/common/sao.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sao.h 3 | * 4 | * Description of this file: 5 | * SAO functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - 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 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #ifndef DAVS2_SAO_H 34 | #define DAVS2_SAO_H 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | #define sao_read_lcu_param FPFX(sao_read_lcu_param) 40 | void sao_read_lcu_param(davs2_t *h, int lcu_xy, bool_t *slice_sao_on, sao_t *sao_param); 41 | 42 | #define sao_lcu FPFX(sao_lcu) 43 | void sao_lcu(davs2_t *h, davs2_frame_t *p_tmp_frm, davs2_frame_t *p_dec_frm, int i_lcu_x, int i_lcu_y); 44 | #define sao_lcurow FPFX(sao_lcurow) 45 | void sao_lcurow(davs2_t *h, davs2_frame_t *p_tmp_frm, davs2_frame_t *p_dec_frm, int i_lcu_y); 46 | 47 | #define davs2_sao_init FPFX(sao_init) 48 | void davs2_sao_init(uint32_t cpuid, ao_funcs_t *fh); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | #endif // DAVS2_SAO_H 54 | -------------------------------------------------------------------------------- /source/common/scantab.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/scantab.h -------------------------------------------------------------------------------- /source/common/threadpool.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/threadpool.cc -------------------------------------------------------------------------------- /source/common/threadpool.h: -------------------------------------------------------------------------------- 1 | /* 2 | * threadpool.h 3 | * 4 | * Description of this file: 5 | * thread pooling functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - 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 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #ifndef DAVS2_THREADPOOL_H 34 | #define DAVS2_THREADPOOL_H 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | typedef struct davs2_threadpool_t davs2_threadpool_t; 40 | typedef void *(*davs2_threadpool_func_t)(void *arg1, int arg2); 41 | 42 | #define davs2_threadpool_init FPFX(threadpool_init) 43 | int davs2_threadpool_init (davs2_threadpool_t **p_pool, int threads, 44 | davs2_threadpool_func_t init_func, void *init_arg1, int init_arg2); 45 | #define davs2_threadpool_run FPFX(threadpool_run) 46 | void davs2_threadpool_run (davs2_threadpool_t *pool, davs2_threadpool_func_t func, void *arg1, int arg2, int wait_sign); 47 | #define davs2_threadpool_is_free FPFX(threadpool_is_free) 48 | int davs2_threadpool_is_free(davs2_threadpool_t *pool); 49 | #define davs2_threadpool_wait FPFX(threadpool_wait) 50 | void *davs2_threadpool_wait (davs2_threadpool_t *pool, void *arg1, int arg2); 51 | #define davs2_threadpool_delete FPFX(threadpool_delete) 52 | void davs2_threadpool_delete(davs2_threadpool_t *pool); 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | #endif // __STARAVS_THREADPOOL_H 58 | -------------------------------------------------------------------------------- /source/common/transform.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/transform.cc -------------------------------------------------------------------------------- /source/common/transform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * transform.h 3 | * 4 | * Description of this file: 5 | * Transform functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - 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 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #ifndef DAVS2_TRANSFORM_H 34 | #define DAVS2_TRANSFORM_H 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | #define davs2_dct_init FPFX(dct_init) 40 | void davs2_dct_init(uint32_t cpuid, ao_funcs_t *fh); 41 | 42 | #define davs2_get_recons FPFX(get_recons) 43 | void davs2_get_recons(davs2_row_rec_t *row_rec, cu_t *p_cu, int blockidx, cb_t *p_tu, int ctu_x, int ctu_y); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | #endif // DAVS2_TRANSFORM_H 49 | -------------------------------------------------------------------------------- /source/common/vec/intrinsic.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/vec/intrinsic.h -------------------------------------------------------------------------------- /source/common/vec/intrinsic_alf.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/vec/intrinsic_alf.cc -------------------------------------------------------------------------------- /source/common/vec/intrinsic_deblock_avx2.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/vec/intrinsic_deblock_avx2.cc -------------------------------------------------------------------------------- /source/common/vec/intrinsic_idct.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/vec/intrinsic_idct.cc -------------------------------------------------------------------------------- /source/common/vec/intrinsic_idct_avx2.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/vec/intrinsic_idct_avx2.cc -------------------------------------------------------------------------------- /source/common/vec/intrinsic_inter_pred.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/vec/intrinsic_inter_pred.cc -------------------------------------------------------------------------------- /source/common/vec/intrinsic_inter_pred_avx2.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/vec/intrinsic_inter_pred_avx2.cc -------------------------------------------------------------------------------- /source/common/vec/intrinsic_intra-filledge.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/vec/intrinsic_intra-filledge.cc -------------------------------------------------------------------------------- /source/common/vec/intrinsic_intra-pred.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/vec/intrinsic_intra-pred.cc -------------------------------------------------------------------------------- /source/common/vec/intrinsic_intra-pred_avx2.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/vec/intrinsic_intra-pred_avx2.cc -------------------------------------------------------------------------------- /source/common/vec/intrinsic_pixel.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * intrinsic_pixel.cc 3 | * 4 | * Description of this file: 5 | * SSE assembly functions of Pixel-Processing module of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - video decoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #include "../common.h" 34 | #include "intrinsic.h" 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | 42 | 43 | void avs_pixel_average_sse128(pel_t *dst, int i_dst, const pel_t *src0, int i_src0, const pel_t *src1, int i_src1, int width, int height) 44 | { 45 | #if HIGH_BIT_DEPTH 46 | int j; 47 | __m128i D; 48 | 49 | if (width & 7) { 50 | __m128i mask = _mm_load_si128((const __m128i *)intrinsic_mask_10bit[(width & 7) - 1]); 51 | 52 | while (height--) { 53 | for (j = 0; j < width - 7; j += 8) { 54 | D = _mm_avg_epu16(_mm_loadu_si128((const __m128i *)(src0 + j)), _mm_loadu_si128((const __m128i *)(src1 + j))); 55 | _mm_storeu_si128((__m128i *)(dst + j), D); 56 | } 57 | 58 | D = _mm_avg_epu16(_mm_loadu_si128((const __m128i *)(src0 + j)), _mm_loadu_si128((const __m128i *)(src1 + j))); 59 | _mm_maskmoveu_si128(D, mask, (char *)&dst[j]); 60 | 61 | src0 += i_src0; 62 | src1 += i_src1; 63 | dst += i_dst; 64 | } 65 | } else { 66 | while (height--) { 67 | for (j = 0; j < width; j += 8) { 68 | D = _mm_avg_epu16(_mm_loadu_si128((const __m128i *)(src0 + j)), _mm_loadu_si128((const __m128i *)(src1 + j))); 69 | _mm_storeu_si128((__m128i *)(dst + j), D); 70 | } 71 | src0 += i_src0; 72 | src1 += i_src1; 73 | dst += i_dst; 74 | } 75 | } 76 | #else 77 | int i, j; 78 | __m128i S1, S2, D; 79 | 80 | if (width & 15) { 81 | __m128i mask = _mm_load_si128((const __m128i*)intrinsic_mask[(width & 15) - 1]); 82 | 83 | for (i = 0; i < height; i++) { 84 | for (j = 0; j < width - 15; j += 16) { 85 | S1 = _mm_loadu_si128((const __m128i*)(src0 + j)); 86 | S2 = _mm_loadu_si128((const __m128i*)(src1 + j)); 87 | D = _mm_avg_epu8(S1, S2); 88 | _mm_storeu_si128((__m128i*)(dst + j), D); 89 | } 90 | 91 | S1 = _mm_loadu_si128((const __m128i*)(src0 + j)); 92 | S2 = _mm_loadu_si128((const __m128i*)(src1 + j)); 93 | D = _mm_avg_epu8(S1, S2); 94 | _mm_maskmoveu_si128(D, mask, (char*)(dst + j)); 95 | 96 | src0 += i_src0; 97 | src1 += i_src1; 98 | dst += i_dst; 99 | } 100 | } else { 101 | for (i = 0; i < height; i++) { 102 | for (j = 0; j < width; j += 16) { 103 | S1 = _mm_loadu_si128((const __m128i*)(src0 + j)); 104 | S2 = _mm_loadu_si128((const __m128i*)(src1 + j)); 105 | D = _mm_avg_epu8(S1, S2); 106 | _mm_storeu_si128((__m128i*)(dst + j), D); 107 | } 108 | src0 += i_src0; 109 | src1 += i_src1; 110 | dst += i_dst; 111 | } 112 | } 113 | #endif 114 | } 115 | 116 | /* --------------------------------------------------------------------------- 117 | */ 118 | void *davs2_memzero_aligned_c_sse2(void *dst, size_t n) 119 | { 120 | __m128i *p_dst = (__m128i *)dst; 121 | __m128i m0 = _mm_setzero_si128(); 122 | int i = (int)(n >> 4); 123 | 124 | for (; i != 0; i--) { 125 | _mm_store_si128(p_dst, m0); 126 | p_dst++; 127 | } 128 | 129 | return dst; 130 | } 131 | 132 | /* --------------------------------------------------------------------------- 133 | */ 134 | void *davs2_memcpy_aligned_c_sse2(void *dst, const void *src, size_t n) 135 | { 136 | __m128i *p_dst = (__m128i *)dst; 137 | const __m128i *p_src = (const __m128i *)src; 138 | int i = (int)(n >> 4); 139 | 140 | for (; i != 0; i--) { 141 | _mm_store_si128(p_dst, _mm_load_si128(p_src)); 142 | p_src++; 143 | p_dst++; 144 | } 145 | 146 | return dst; 147 | } 148 | 149 | /* --------------------------------------------------------------------------- 150 | */ 151 | void plane_copy_c_sse2(pel_t *dst, intptr_t i_dst, pel_t *src, intptr_t i_src, int w, int h) 152 | { 153 | const int n128 = (w * sizeof(pel_t)) >> 4; 154 | int n_left = (w * sizeof(pel_t)) - (n128 << 4); 155 | 156 | if (n_left) { 157 | int n_offset = (n128 << 4); 158 | while (h--) { 159 | const __m128i *p_src = (const __m128i *)src; 160 | __m128i *p_dst = (__m128i *)dst; 161 | int n = n128; 162 | for (; n != 0; n--) { 163 | _mm_storeu_si128(p_dst, _mm_loadu_si128(p_src)); 164 | p_dst++; 165 | p_src++; 166 | } 167 | memcpy((uint8_t *)(dst) + n_offset, (uint8_t *)(src) + n_offset, n_left); 168 | dst += i_dst; 169 | src += i_src; 170 | } 171 | } else { 172 | while (h--) { 173 | const __m128i *p_src = (const __m128i *)src; 174 | __m128i *p_dst = (__m128i *)dst; 175 | int n = n128; 176 | for (; n != 0; n--) { 177 | _mm_storeu_si128(p_dst, _mm_loadu_si128(p_src)); 178 | p_dst++; 179 | p_src++; 180 | } 181 | dst += i_dst; 182 | src += i_src; 183 | } 184 | } 185 | } 186 | -------------------------------------------------------------------------------- /source/common/vec/intrinsic_sao.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/vec/intrinsic_sao.cc -------------------------------------------------------------------------------- /source/common/vec/intrinsic_sao_avx2.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/common/vec/intrinsic_sao_avx2.cc -------------------------------------------------------------------------------- /source/common/vlc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * vlc.h 3 | * 4 | * Description of this file: 5 | * VLC functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - 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 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #ifndef DAVS2_VLC_H 34 | #define DAVS2_VLC_H 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /* --------------------------------------------------------------------------- 40 | * reads bits from the bitstream buffer 41 | * Input: 42 | * p_buf - containing VLC-coded data bits 43 | * i_bit_pos - bit offset from start of partition 44 | * i_buf - total bytes in bitstream 45 | * i_bits - number of bits to read 46 | * return 0 for success, otherwise failure 47 | */ 48 | static INLINE 49 | int read_bits(uint8_t *p_buf, int i_buf, int i_bit_pos, int *p_info, int i_bits) 50 | { 51 | int byte_offset = i_bit_pos >> 3; // byte from start of buffer 52 | int bit_offset = 7 - (i_bit_pos & 7); // bit from start of byte 53 | int inf = 0; 54 | 55 | while (i_bits--) { 56 | inf <<= 1; 57 | inf |= (p_buf[byte_offset] & (1 << bit_offset)) >> bit_offset; 58 | 59 | bit_offset--; 60 | if (bit_offset < 0) { 61 | byte_offset++; 62 | bit_offset += 8; 63 | 64 | if (byte_offset > i_buf) { 65 | return -1; /* error */ 66 | } 67 | } 68 | } 69 | *p_info = inf; 70 | 71 | return 0; 72 | } 73 | 74 | /* --------------------------------------------------------------------------- 75 | * RETURN: the length of symbol, or -1 on error 76 | */ 77 | static INLINE 78 | int get_vlc_symbol(uint8_t *p_buf, int i_bit_pos, int *info, int i_buf) 79 | { 80 | int byte_offset = i_bit_pos >> 3; // byte from start of buffer 81 | int bit_offset = 7 - (i_bit_pos & 7); // bit from start of byte 82 | int bit_counter = 1; 83 | int len = 1; 84 | int ctr_bit; // control bit for current bit position 85 | int info_bit; 86 | int inf; 87 | 88 | ctr_bit = (p_buf[byte_offset] & (1 << bit_offset)); // set up control bit 89 | while (ctr_bit == 0) { 90 | // find leading 1 bit 91 | len++; 92 | bit_offset -= 1; 93 | bit_counter++; 94 | 95 | if (bit_offset < 0) { 96 | // finish with current byte ? 97 | bit_offset = bit_offset + 8; 98 | byte_offset++; 99 | } 100 | 101 | ctr_bit = (p_buf[byte_offset] & (1 << bit_offset)); // set up control bit 102 | } 103 | 104 | // make info-word 105 | inf = 0; // shortest possible code is 1, then info is always 0 106 | for (info_bit = 0; (info_bit < (len - 1)); info_bit++) { 107 | bit_counter++; 108 | bit_offset--; 109 | 110 | if (bit_offset < 0) { 111 | // finished with current byte ? 112 | bit_offset = bit_offset + 8; 113 | byte_offset++; 114 | } 115 | 116 | if (byte_offset > i_buf) { 117 | return -1; /* error */ 118 | } 119 | 120 | inf = (inf << 1); 121 | if (p_buf[byte_offset] & (0x01 << (bit_offset))) { 122 | inf |= 1; 123 | } 124 | } 125 | *info = inf; 126 | 127 | // return absolute offset in bit from start of frame 128 | return bit_counter; 129 | } 130 | 131 | /* --------------------------------------------------------------------------- 132 | * reads an u(v) syntax element (FLC codeword) from UVLC-partition 133 | * RETURN: the value of the coded syntax element, or -1 on error 134 | */ 135 | static INLINE 136 | int vlc_u_v(davs2_bs_t *bs, int i_bits 137 | #if AVS2_TRACE 138 | , char *tracestring 139 | #endif 140 | ) 141 | { 142 | int ret_val = 0; 143 | 144 | if (read_bits(bs->p_stream, bs->i_stream, bs->i_bit_pos, &ret_val, i_bits) == 0) { 145 | bs->i_bit_pos += i_bits; /* move bitstream pointer */ 146 | 147 | #if AVS2_TRACE 148 | avs2_trace_string(tracestring, ret_val, i_bits); 149 | #endif 150 | 151 | return ret_val; 152 | } 153 | 154 | return -1; 155 | } 156 | 157 | /* --------------------------------------------------------------------------- 158 | * reads an ue(v) syntax element 159 | * RETURN: the value of the coded syntax element, or -1 on error 160 | */ 161 | static INLINE 162 | int vlc_ue_v(davs2_bs_t *bs 163 | #if AVS2_TRACE 164 | , char *tracestring 165 | #endif 166 | ) 167 | { 168 | int len, info; 169 | int ret_val; 170 | 171 | len = get_vlc_symbol(bs->p_stream, bs->i_bit_pos, &info, bs->i_stream); 172 | if (len == -1) { 173 | return -1; /* error */ 174 | } 175 | 176 | bs->i_bit_pos += len; 177 | 178 | // cal: pow(2, (len / 2)) + info - 1; 179 | ret_val = (1 << (len >> 1)) + info - 1; 180 | 181 | #if AVS2_TRACE 182 | avs2_trace_string2(tracestring, ret_val + 1, ret_val, len); 183 | #endif 184 | 185 | return ret_val; 186 | } 187 | 188 | /* --------------------------------------------------------------------------- 189 | * reads an se(v) syntax element 190 | * RETURN: the value of the coded syntax element, or -1 on error 191 | */ 192 | static INLINE 193 | int vlc_se_v(davs2_bs_t *bs 194 | #if AVS2_TRACE 195 | , char *tracestring 196 | #endif 197 | ) 198 | { 199 | int len, info; 200 | int ret_val; 201 | int n; 202 | 203 | len = get_vlc_symbol(bs->p_stream, bs->i_bit_pos, &info, bs->i_stream); 204 | if (len == -1) { 205 | return -1; /* error */ 206 | } 207 | 208 | bs->i_bit_pos += len; 209 | 210 | // cal: (int)pow(2, (len / 2)) + info - 1; 211 | n = (1 << (len >> 1)) + info - 1; 212 | ret_val = (n + 1) >> 1; 213 | if ((n & 1) == 0) { /* lsb is signed bit */ 214 | ret_val = -ret_val; 215 | } 216 | 217 | #if AVS2_TRACE 218 | avs2_trace_string2(tracestring, n + 1, ret_val, len); 219 | #endif 220 | 221 | return ret_val; 222 | } 223 | 224 | 225 | #if AVS2_TRACE 226 | #define u_flag(bs, tracestring) (bool_t)vlc_u_v(bs, 1, tracestring) 227 | #define u_v(bs, i_bits, tracestring) vlc_u_v(bs, i_bits, tracestring) 228 | #define ue_v(bs, tracestring) vlc_ue_v(bs, tracestring) 229 | #define se_v(bs, tracestring) vlc_se_v(bs, tracestring) 230 | #else 231 | #define u_flag(bs, tracestring) (bool_t)vlc_u_v(bs, 1) 232 | #define u_v(bs, i_bits, tracestring) vlc_u_v(bs, i_bits) 233 | #define ue_v(bs, tracestring) vlc_ue_v(bs) 234 | #define se_v(bs, tracestring) vlc_se_v(bs) 235 | #endif 236 | 237 | #ifdef __cplusplus 238 | } 239 | #endif 240 | #endif // DAVS2_VLC_H 241 | -------------------------------------------------------------------------------- /source/common/win32thread.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * win32thread.h: windows threading 3 | ***************************************************************************** 4 | * Copyright (C) 2010-2017 x264 project 5 | * 6 | * Authors: Steven Walters 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | /* 27 | * changes of this file: 28 | * modified for davs2 library 29 | * 30 | * -------------------------------------------------------------------------- 31 | * 32 | * davs2 - video decoder of AVS2/IEEE1857.4 video coding standard 33 | * Copyright (C) 2018~ VCL, NELVT, Peking University 34 | * 35 | * Authors: Falei LUO 36 | * etc. 37 | */ 38 | 39 | #ifndef DAVS2_WIN32THREAD_H 40 | #define DAVS2_WIN32THREAD_H 41 | 42 | #define WIN32_LEAN_AND_MEAN 43 | #include 44 | /* the following macro is used within xavs2 encoder */ 45 | #undef ERROR 46 | 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | 51 | typedef struct { 52 | void *handle; 53 | void *(*func)(void *arg); 54 | void *arg; 55 | void *ret; 56 | } davs2_thread_t; 57 | #define davs2_thread_attr_t int 58 | 59 | /* the conditional variable api for windows 6.0+ uses critical sections and not mutexes */ 60 | typedef CRITICAL_SECTION davs2_thread_mutex_t; 61 | #define DAVS2_THREAD_MUTEX_INITIALIZER {0} 62 | #define davs2_thread_mutexattr_t int 63 | #define pthread_exit(a) 64 | /* This is the CONDITIONAL_VARIABLE typedef for using Window's native conditional variables on kernels 6.0+. 65 | * MinGW does not currently have this typedef. */ 66 | typedef struct { 67 | void *ptr; 68 | } davs2_thread_cond_t; 69 | #define davs2_thread_condattr_t int 70 | 71 | #define davs2_thread_create FPFX(thread_create) 72 | int davs2_thread_create(davs2_thread_t *thread, const davs2_thread_attr_t *attr, 73 | void *(*start_routine)(void *), void *arg); 74 | #define davs2_thread_join FPFX(thread_join) 75 | int davs2_thread_join(davs2_thread_t thread, void **value_ptr); 76 | 77 | #define davs2_thread_mutex_init FPFX(thread_mutex_init) 78 | int davs2_thread_mutex_init(davs2_thread_mutex_t *mutex, const davs2_thread_mutexattr_t *attr); 79 | #define davs2_thread_mutex_destroy FPFX(thread_mutex_destroy) 80 | int davs2_thread_mutex_destroy(davs2_thread_mutex_t *mutex); 81 | #define davs2_thread_mutex_lock FPFX(thread_mutex_lock) 82 | int davs2_thread_mutex_lock(davs2_thread_mutex_t *mutex); 83 | #define davs2_thread_mutex_unlock FPFX(thread_mutex_unlock) 84 | int davs2_thread_mutex_unlock(davs2_thread_mutex_t *mutex); 85 | 86 | #define davs2_thread_cond_init FPFX(thread_cond_init) 87 | int davs2_thread_cond_init(davs2_thread_cond_t *cond, const davs2_thread_condattr_t *attr); 88 | #define davs2_thread_cond_destroy FPFX(thread_cond_destroy) 89 | int davs2_thread_cond_destroy(davs2_thread_cond_t *cond); 90 | #define davs2_thread_cond_broadcast FPFX(thread_cond_broadcast) 91 | int davs2_thread_cond_broadcast(davs2_thread_cond_t *cond); 92 | #define davs2_thread_cond_wait FPFX(thread_cond_wait) 93 | int davs2_thread_cond_wait(davs2_thread_cond_t *cond, davs2_thread_mutex_t *mutex); 94 | #define davs2_thread_cond_signal FPFX(thread_cond_signal) 95 | int davs2_thread_cond_signal(davs2_thread_cond_t *cond); 96 | 97 | #define davs2_thread_attr_init(a) 0 98 | #define davs2_thread_attr_destroy(a) 0 99 | 100 | #define davs2_win32_threading_init FPFX(win32_threading_init) 101 | int davs2_win32_threading_init(void); 102 | #define davs2_win32_threading_destroy FPFX(win32_threading_destroy) 103 | void davs2_win32_threading_destroy(void); 104 | 105 | #define davs2_thread_num_processors_np FPFX(thread_num_processors_np) 106 | int davs2_thread_num_processors_np(void); 107 | 108 | #ifdef __cplusplus 109 | } 110 | #endif 111 | #endif // DAVS2_WIN32THREAD_H 112 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 DAVS2_I386_DCT8_H 28 | #define DAVS2_I386_DCT8_H 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | void FPFX(idct_4x4_sse2 )(const coeff_t *src, coeff_t *dst, int i_dst); 34 | void FPFX(idct_8x8_ssse3)(const coeff_t *src, coeff_t *dst, int i_dst); 35 | #if ARCH_X86_64 36 | void FPFX(idct_4x4_avx2 )(const coeff_t *src, coeff_t *dst, int i_dst); 37 | void FPFX(idct_8x8_sse2 )(const coeff_t *src, coeff_t *dst, int i_dst); 38 | void FPFX(idct_8x8_avx2 )(const coeff_t *src, coeff_t *dst, int i_dst); 39 | void FPFX(idct_16x16_avx2)(const coeff_t *src, coeff_t *dst, int i_dst); 40 | void FPFX(idct_32x32_avx2)(const coeff_t *src, coeff_t *dst, int i_dst); 41 | #endif 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | #endif // ifndef DAVS2_I386_DCT8_H 47 | -------------------------------------------------------------------------------- /source/common/x86/ipfilter8.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 DAVS2_IPFILTER8_H 26 | #define DAVS2_IPFILTER8_H 27 | 28 | #include "../vec/intrinsic.h" 29 | 30 | #if defined(__cplusplus) 31 | extern "C" { 32 | #endif /* __cplusplus */ 33 | 34 | #define SETUP_FUNC_DEF(cpu) \ 35 | FUNCDEF_PU(void, interp_8tap_horiz_pp, cpu, const pel_t* src, intptr_t srcStride, pel_t* dst, intptr_t dstStride, int coeffIdx); \ 36 | FUNCDEF_PU(void, interp_8tap_horiz_ps, cpu, const pel_t* src, intptr_t srcStride, int16_t* dst, intptr_t dstStride, int coeffIdx, int isRowExt); \ 37 | FUNCDEF_PU(void, interp_8tap_vert_pp, cpu, const pel_t* src, intptr_t srcStride, pel_t* dst, intptr_t dstStride, int coeffIdx); \ 38 | FUNCDEF_PU(void, interp_8tap_vert_ps, cpu, const pel_t* src, intptr_t srcStride, int16_t* dst, intptr_t dstStride, int coeffIdx); \ 39 | FUNCDEF_PU(void, interp_8tap_vert_sp, cpu, const int16_t* src, intptr_t srcStride, pel_t* dst, intptr_t dstStride, int coeffIdx); \ 40 | FUNCDEF_PU(void, interp_8tap_vert_ss, cpu, const int16_t* src, intptr_t srcStride, int16_t* dst, intptr_t dstStride, int coeffIdx); \ 41 | FUNCDEF_PU(void, interp_8tap_hv_pp, cpu, const pel_t* src, intptr_t srcStride, pel_t* dst, intptr_t dstStride, int idxX, int idxY) 42 | 43 | SETUP_FUNC_DEF(sse2); 44 | SETUP_FUNC_DEF(ssse3); 45 | SETUP_FUNC_DEF(sse3); 46 | SETUP_FUNC_DEF(sse4); 47 | SETUP_FUNC_DEF(avx2); 48 | 49 | #if defined(__cplusplus) 50 | } 51 | #endif /* __cplusplus */ 52 | #endif // ifndef DAVS2_IPFILTER8_H 53 | -------------------------------------------------------------------------------- /source/common/x86/quant8.asm: -------------------------------------------------------------------------------- 1 | ;***************************************************************************** 2 | ;* quant8.asm: 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 | %include "x86inc.asm" 33 | %include "x86util.asm" 34 | 35 | 36 | SECTION .text 37 | 38 | ; ---------------------------------------------------------------------------- 39 | ; void dequant(coeff_t *coef, const int i_coef, const int scale, const int shift); 40 | ; ---------------------------------------------------------------------------- 41 | 42 | ; ---------------------------------------------------------------------------- 43 | ; dequant_sse4 44 | INIT_XMM sse4 45 | cglobal dequant, 2,2,7 46 | ;{ 47 | mov r3, r3mp ; r3 <-- shift 48 | movq m4, r2mp ; m4[0] = scale 49 | movq m6, r3 ; m6[0] = shift 50 | dec r3 ; r3d <-- shift - 1 51 | xor r2, r2 ; r2 <-- 0 52 | shr r1, 4 ; r1 = i_coef/16 53 | bts r2, r3 ; r2 <-- add = 1 < (shift - 1) 54 | movq m5, r2 ; m5[0] = add 55 | pshufd m4, m4, 0 ; m4[3210] = scale 56 | pshufd m5, m5, 0 ; m5[3210] = add 57 | ; 58 | .loop: ; 59 | pmovsxwd m0, [r0 ] ; load 4 coeff 60 | pmovsxwd m1, [r0 + 8] ; 61 | pmovsxwd m2, [r0 + 16] ; 62 | pmovsxwd m3, [r0 + 24] ; 63 | ; 64 | pmulld m0, m4 ; coef[i] * scale 65 | pmulld m1, m4 ; 66 | pmulld m2, m4 ; 67 | pmulld m3, m4 ; 68 | paddd m0, m5 ; coef[i] * scale + add 69 | paddd m1, m5 ; 70 | paddd m2, m5 ; 71 | paddd m3, m5 ; 72 | psrad m0, m6 ; (coef[i] * scale + add) >> shift 73 | psrad m1, m6 ; 74 | psrad m2, m6 ; 75 | psrad m3, m6 ; 76 | ; 77 | packssdw m0, m1 ; pack to 8 coeff 78 | packssdw m2, m3 ; 79 | ; 80 | mova [r0 ], m0 ; store 81 | mova [r0+16], m2 ; 82 | add r0, 32 ; 83 | dec r1 ; 84 | jnz .loop ; 85 | ; 86 | RET ; return 87 | ;} 88 | -------------------------------------------------------------------------------- /source/configw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * configw.h 3 | * 4 | * Description of this file: 5 | * header file for MS/Intel compiler on windows platform of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - video decoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #ifndef DAVS2_CONFIGW_H 34 | #define DAVS2_CONFIGW_H 35 | 36 | #if defined(__ICL) || defined(_MSC_VER) 37 | 38 | /* arch */ 39 | #define ARCH_X86 1 40 | #define ARCH_PPC 0 41 | #define ARCH_ARM 0 42 | #define ARCH_UltraSPARC 0 43 | 44 | /* system */ 45 | #define SYS_WINDOWS 1 46 | #define SYS_LINUX 0 47 | #define SYS_MACOSX 0 48 | #define SYS_BEOS 0 49 | #define SYS_FREEBSD 0 50 | #define SYS_OPENBSD 0 51 | 52 | /* cpu */ 53 | #ifndef __SSE__ 54 | #define __SSE__ 55 | #endif 56 | #define HAVE_MMX 1 /* X86 */ 57 | #define HAVE_ALTIVEC 0 /* ALTIVEC */ 58 | #define HAVE_ALTIVEC_H 0 59 | #define HAVE_NEON 0 /* ARM */ 60 | #define HAVE_ARMV6 0 61 | #define HAVE_ARMV6T2 0 62 | 63 | /* thread */ 64 | #define HAVE_THREAD 1 65 | #define HAVE_WIN32THREAD 1 66 | #define HAVE_PTHREAD 0 67 | #define HAVE_BEOSTHREAD 0 68 | #define HAVE_POSIXTHREAD 0 69 | #define PTW32_STATIC_LIB 0 70 | 71 | /* interlace support */ 72 | #define HAVE_INTERLACED 1 73 | 74 | /* malloc */ 75 | #define HAVE_MALLOC_H 0 76 | 77 | /* big-endian */ 78 | #define WORDS_BIGENDIAN 0 79 | 80 | /* others */ 81 | #define HAVE_STDINT_H 1 82 | #define HAVE_VECTOREXT 0 83 | #define HAVE_LOG2F 0 84 | #define HAVE_SWSCALE 0 85 | #define HAVE_LAVF 0 86 | #define HAVE_FFMS 0 87 | #define HAVE_GPAC 0 88 | #define HAVE_GF_MALLOC 0 89 | #define HAVE_AVS 0 90 | 91 | #endif 92 | #endif // DAVS2_CONFIGW_H 93 | -------------------------------------------------------------------------------- /source/test/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/test/inputstream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * inputstream.h 3 | * 4 | * Description of this file: 5 | * Inputstream Processing functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - video decoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #ifndef DAVS2_CHECKFRAME_H 34 | #define DAVS2_CHECKFRAME_H 35 | 36 | #include "utils.h" 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | /* --------------------------------------------------------------------------- 45 | */ 46 | #define ISPIC(x) ((x) == 0xB3 || (x) == 0xB6) 47 | #define ISUNIT(x) ((x) == 0xB0 || (x) == 0xB1 || (x) == 0xB7 || ISPIC(x)) 48 | 49 | /* --------------------------------------------------------------------------- 50 | */ 51 | static __inline 52 | const uint8_t * 53 | find_start_code(const uint8_t *data, int len) 54 | { 55 | while (len >= 4 && (*(int *)data & 0x00FFFFFF) != 0x00010000) { 56 | ++data; 57 | --len; 58 | } 59 | 60 | return len >= 4 ? data : 0; 61 | } 62 | 63 | /* --------------------------------------------------------------------------- 64 | */ 65 | static int 66 | check_frame(const uint8_t *data, int len) 67 | { 68 | const uint8_t *p; 69 | const uint8_t *data0 = data; 70 | const int len0 = len; 71 | 72 | while (((p = (uint8_t *)find_start_code(data, len)) != 0) && !ISUNIT(p[3])) { 73 | len -= (int)(p - data + 4); 74 | data = p + 4; 75 | } 76 | 77 | return (int)(p ? p - data0 : len0 + 1); 78 | } 79 | 80 | /* --------------------------------------------------------------------------- 81 | */ 82 | static int 83 | find_one_frame(uint8_t * data, int len, int *start, int *end) 84 | { 85 | if ((*start = check_frame(data, len)) > len) { 86 | return -1; 87 | } 88 | 89 | if ((*end = check_frame(data + *start + 4, len - *start - 4)) <= len) { 90 | *end += *start + 4; 91 | } 92 | 93 | return 0; 94 | } 95 | 96 | /* --------------------------------------------------------------------------- 97 | */ 98 | static int 99 | count_frames(uint8_t *data, int size) 100 | { 101 | int count = 0; 102 | int start, end; 103 | 104 | for (;;) { 105 | if (find_one_frame(data, size, &start, &end) < 0) { 106 | break; 107 | } 108 | 109 | if (ISPIC(data[start + 3])) { 110 | count++; 111 | } 112 | 113 | data += end; 114 | size -= end; 115 | } 116 | 117 | return count; 118 | } 119 | 120 | 121 | /* --------------------------------------------------------------------------- 122 | */ 123 | static int 124 | read_input_file(davs2_input_param_t *p_param, uint8_t **data, int *size, int *frames, float errrate) 125 | { 126 | /* get size of input file */ 127 | fseek(p_param->g_infile, 0, SEEK_END); 128 | *size = ftell(p_param->g_infile); 129 | fseek(p_param->g_infile, 0, SEEK_SET); 130 | 131 | /* memory for stream buffer */ 132 | if ((*data = (uint8_t *)calloc(*size + 1024, sizeof(uint8_t))) == NULL) { 133 | show_message(CONSOLE_RED, "failed to alloc memory for input file.\n"); 134 | return -1; 135 | } 136 | 137 | /* read stream data */ 138 | if (fread(*data, *size, 1, p_param->g_infile) < 1) { 139 | show_message(CONSOLE_RED, "failed to read input file.\n"); 140 | free(*data); 141 | *data = NULL; 142 | return -1; 143 | } 144 | 145 | if (errrate != 0) { 146 | show_message(CONSOLE_WHITE, "noise interfering is enabled:\n"); 147 | } 148 | 149 | /* get total frames */ 150 | *frames = count_frames(*data, *size); 151 | 152 | return 0; 153 | } 154 | 155 | #endif /// DAVS2_CHECKFRAME_H 156 | -------------------------------------------------------------------------------- /source/test/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * md5.h 3 | * 4 | * Description of this file: 5 | * MD5 calculate function of davs2. 6 | * 7 | */ 8 | 9 | /* The copyright in this software is being made available under the BSD 10 | * License, included below. This software may be subject to other third party 11 | * and contributor rights, including patent rights, and no such rights are 12 | * granted under this license. 13 | * 14 | * Copyright (c) 2002-2016, Audio Video coding Standard Workgroup of China 15 | * All rights reserved. 16 | * 17 | * Redistribution and use in source and binary forms, with or without 18 | * modification, are permitted provided that the following conditions are met: 19 | * 20 | * * Redistributions of source code must retain the above copyright notice, 21 | * this list of conditions and the following disclaimer. 22 | * * Redistributions in binary form must reproduce the above copyright notice, 23 | * this list of conditions and the following disclaimer in the documentation 24 | * and/or other materials provided with the distribution. 25 | * * Neither the name of Audio Video coding Standard Workgroup of China 26 | * nor the names of its contributors maybe used to endorse or promote products 27 | * derived from this software without 28 | * specific prior written permission. 29 | * 30 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 31 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 32 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 33 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 34 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 35 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 36 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 37 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 38 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 39 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 40 | * THE POSSIBILITY OF SUCH DAMAGE. 41 | */ 42 | 43 | /* 44 | * -------------------------------------------------------------------------- 45 | * 46 | * davs2 - video decoder of AVS2/IEEE1857.4 video coding standard 47 | * Copyright (C) 2018~ VCL, NELVT, Peking University 48 | * 49 | * Authors: Falei LUO 50 | * Huiwen REN 51 | * etc. 52 | * 53 | */ 54 | 55 | #ifndef DAVS2_MD5_H 56 | #define DAVS2_MD5_H 57 | 58 | #include 59 | #include 60 | #include 61 | 62 | #define F(x, y, z) (((x) & (y)) | ((~x) & (z))) 63 | #define G(x, y, z) (((x) & (z)) | ((y) & (~z))) 64 | #define H(x, y, z) ((x) ^ (y) ^ (z)) 65 | #define I(x, y, z) ((y) ^ ((x) | (~z))) 66 | 67 | #define RL(x, y) (((x) << (y)) | ((x) >> (32 - (y)))) 68 | 69 | #define PP(x) (x<<24)|((x<<8)&0xff0000)|((x>>8)&0xff00)|(x>>24) 70 | 71 | #define FF(a, b, c, d, x, s, ac) a = b + (RL((a + F(b,c,d) + x + ac),s)) 72 | #define GG(a, b, c, d, x, s, ac) a = b + (RL((a + G(b,c,d) + x + ac),s)) 73 | #define HH(a, b, c, d, x, s, ac) a = b + (RL((a + H(b,c,d) + x + ac),s)) 74 | #define II(a, b, c, d, x, s, ac) a = b + (RL((a + I(b,c,d) + x + ac),s)) 75 | 76 | void md5(unsigned int *pA, unsigned int *pB, unsigned int *pC, unsigned int *pD, unsigned int x[16]) 77 | { 78 | unsigned int a, b, c, d; 79 | a = *pA; 80 | b = *pB; 81 | c = *pC; 82 | d = *pD; 83 | /**//* Round 1 */ 84 | FF(a, b, c, d, x[ 0], 7, 0xd76aa478); /**/ /* 1 */ 85 | FF(d, a, b, c, x[ 1], 12, 0xe8c7b756); /**/ /* 2 */ 86 | FF(c, d, a, b, x[ 2], 17, 0x242070db); /**/ /* 3 */ 87 | FF(b, c, d, a, x[ 3], 22, 0xc1bdceee); /**/ /* 4 */ 88 | FF(a, b, c, d, x[ 4], 7, 0xf57c0faf); /**/ /* 5 */ 89 | FF(d, a, b, c, x[ 5], 12, 0x4787c62a); /**/ /* 6 */ 90 | FF(c, d, a, b, x[ 6], 17, 0xa8304613); /**/ /* 7 */ 91 | FF(b, c, d, a, x[ 7], 22, 0xfd469501); /**/ /* 8 */ 92 | FF(a, b, c, d, x[ 8], 7, 0x698098d8); /**/ /* 9 */ 93 | FF(d, a, b, c, x[ 9], 12, 0x8b44f7af); /**/ /* 10 */ 94 | FF(c, d, a, b, x[10], 17, 0xffff5bb1); /**/ /* 11 */ 95 | FF(b, c, d, a, x[11], 22, 0x895cd7be); /**/ /* 12 */ 96 | FF(a, b, c, d, x[12], 7, 0x6b901122); /**/ /* 13 */ 97 | FF(d, a, b, c, x[13], 12, 0xfd987193); /**/ /* 14 */ 98 | FF(c, d, a, b, x[14], 17, 0xa679438e); /**/ /* 15 */ 99 | FF(b, c, d, a, x[15], 22, 0x49b40821); /**/ /* 16 */ 100 | 101 | /**//* Round 2 */ 102 | GG(a, b, c, d, x[ 1], 5, 0xf61e2562); /**/ /* 17 */ 103 | GG(d, a, b, c, x[ 6], 9, 0xc040b340); /**/ /* 18 */ 104 | GG(c, d, a, b, x[11], 14, 0x265e5a51); /**/ /* 19 */ 105 | GG(b, c, d, a, x[ 0], 20, 0xe9b6c7aa); /**/ /* 20 */ 106 | GG(a, b, c, d, x[ 5], 5, 0xd62f105d); /**/ /* 21 */ 107 | GG(d, a, b, c, x[10], 9, 0x02441453); /**/ /* 22 */ 108 | GG(c, d, a, b, x[15], 14, 0xd8a1e681); /**/ /* 23 */ 109 | GG(b, c, d, a, x[ 4], 20, 0xe7d3fbc8); /**/ /* 24 */ 110 | GG(a, b, c, d, x[ 9], 5, 0x21e1cde6); /**/ /* 25 */ 111 | GG(d, a, b, c, x[14], 9, 0xc33707d6); /**/ /* 26 */ 112 | GG(c, d, a, b, x[ 3], 14, 0xf4d50d87); /**/ /* 27 */ 113 | GG(b, c, d, a, x[ 8], 20, 0x455a14ed); /**/ /* 28 */ 114 | GG(a, b, c, d, x[13], 5, 0xa9e3e905); /**/ /* 29 */ 115 | GG(d, a, b, c, x[ 2], 9, 0xfcefa3f8); /**/ /* 30 */ 116 | GG(c, d, a, b, x[ 7], 14, 0x676f02d9); /**/ /* 31 */ 117 | GG(b, c, d, a, x[12], 20, 0x8d2a4c8a); /**/ /* 32 */ 118 | 119 | /**//* Round 3 */ 120 | HH(a, b, c, d, x[ 5], 4, 0xfffa3942); /**/ /* 33 */ 121 | HH(d, a, b, c, x[ 8], 11, 0x8771f681); /**/ /* 34 */ 122 | HH(c, d, a, b, x[11], 16, 0x6d9d6122); /**/ /* 35 */ 123 | HH(b, c, d, a, x[14], 23, 0xfde5380c); /**/ /* 36 */ 124 | HH(a, b, c, d, x[ 1], 4, 0xa4beea44); /**/ /* 37 */ 125 | HH(d, a, b, c, x[ 4], 11, 0x4bdecfa9); /**/ /* 38 */ 126 | HH(c, d, a, b, x[ 7], 16, 0xf6bb4b60); /**/ /* 39 */ 127 | HH(b, c, d, a, x[10], 23, 0xbebfbc70); /**/ /* 40 */ 128 | HH(a, b, c, d, x[13], 4, 0x289b7ec6); /**/ /* 41 */ 129 | HH(d, a, b, c, x[ 0], 11, 0xeaa127fa); /**/ /* 42 */ 130 | HH(c, d, a, b, x[ 3], 16, 0xd4ef3085); /**/ /* 43 */ 131 | HH(b, c, d, a, x[ 6], 23, 0x04881d05); /**/ /* 44 */ 132 | HH(a, b, c, d, x[ 9], 4, 0xd9d4d039); /**/ /* 45 */ 133 | HH(d, a, b, c, x[12], 11, 0xe6db99e5); /**/ /* 46 */ 134 | HH(c, d, a, b, x[15], 16, 0x1fa27cf8); /**/ /* 47 */ 135 | HH(b, c, d, a, x[ 2], 23, 0xc4ac5665); /**/ /* 48 */ 136 | 137 | /**//* Round 4 */ 138 | II(a, b, c, d, x[ 0], 6, 0xf4292244); /**/ /* 49 */ 139 | II(d, a, b, c, x[ 7], 10, 0x432aff97); /**/ /* 50 */ 140 | II(c, d, a, b, x[14], 15, 0xab9423a7); /**/ /* 51 */ 141 | II(b, c, d, a, x[ 5], 21, 0xfc93a039); /**/ /* 52 */ 142 | II(a, b, c, d, x[12], 6, 0x655b59c3); /**/ /* 53 */ 143 | II(d, a, b, c, x[ 3], 10, 0x8f0ccc92); /**/ /* 54 */ 144 | II(c, d, a, b, x[10], 15, 0xffeff47d); /**/ /* 55 */ 145 | II(b, c, d, a, x[ 1], 21, 0x85845dd1); /**/ /* 56 */ 146 | II(a, b, c, d, x[ 8], 6, 0x6fa87e4f); /**/ /* 57 */ 147 | II(d, a, b, c, x[15], 10, 0xfe2ce6e0); /**/ /* 58 */ 148 | II(c, d, a, b, x[ 6], 15, 0xa3014314); /**/ /* 59 */ 149 | II(b, c, d, a, x[13], 21, 0x4e0811a1); /**/ /* 60 */ 150 | II(a, b, c, d, x[ 4], 6, 0xf7537e82); /**/ /* 61 */ 151 | II(d, a, b, c, x[11], 10, 0xbd3af235); /**/ /* 62 */ 152 | II(c, d, a, b, x[ 2], 15, 0x2ad7d2bb); /**/ /* 63 */ 153 | II(b, c, d, a, x[ 9], 21, 0xeb86d391); /**/ /* 64 */ 154 | 155 | *pA += a; 156 | *pB += b; 157 | *pC += c; 158 | *pD += d; 159 | 160 | } 161 | 162 | long long FileMD5(const char *filename, unsigned int md5value[4]) 163 | { 164 | FILE *p_infile = NULL; 165 | 166 | int i; 167 | unsigned int flen[2]; 168 | long long len; 169 | unsigned int A, B, C, D; 170 | unsigned int x[16]; 171 | memset(md5value, 0, 4 * sizeof(unsigned int)); 172 | 173 | if (filename == NULL) { 174 | return 0; 175 | } 176 | 177 | if (strlen(filename) > 0 && (p_infile = fopen(filename, "rb")) == NULL) { 178 | show_message(CONSOLE_RED, "Input file %s does not exist", filename); 179 | return 0; 180 | } 181 | 182 | fseek(p_infile, 0, SEEK_END); 183 | len = ftell(p_infile); 184 | fseek(p_infile, 0, SEEK_SET); 185 | 186 | if (len == -1) { 187 | show_message(CONSOLE_RED, "Input file %s is too large to calculate md5!\n", filename); 188 | fclose(p_infile); 189 | return 0; 190 | } 191 | 192 | A = 0x67452301, B = 0xefcdab89, C = 0x98badcfe, D = 0x10325476; 193 | flen[1] = (unsigned int)(len / 0x20000000); 194 | flen[0] = (unsigned int)((len % 0x20000000) * 8); 195 | 196 | memset(x, 0, 64); 197 | int read_size = fread(&x, 4, 16, p_infile); 198 | if(read_size!=16){ 199 | if(!feof(p_infile) && ferror(p_infile)){ 200 | show_message(CONSOLE_RED, "Reading file error!\n", filename); 201 | clearerr(p_infile); 202 | } 203 | } 204 | 205 | for (i = 0; i < len / 64; i++) { 206 | md5(&A, &B, &C, &D, x); 207 | memset(x, 0, 64); 208 | int ReadSize=fread(&x, 4, 16, p_infile); 209 | if(ReadSize!=16){ 210 | if(!feof(p_infile) && ferror(p_infile)){ 211 | show_message(CONSOLE_RED, "Reading file error!\n", filename); 212 | clearerr(p_infile); 213 | } 214 | } 215 | } 216 | ((char *)x)[len % 64] = 128; 217 | if (len % 64 > 55) { 218 | md5(&A, &B, &C, &D, x); 219 | memset(x, 0, 64); 220 | } 221 | memcpy(x + 14, flen, 8); 222 | md5(&A, &B, &C, &D, x); 223 | 224 | fclose(p_infile); 225 | 226 | md5value[0] = PP(A); 227 | md5value[1] = PP(B); 228 | md5value[2] = PP(C); 229 | md5value[3] = PP(D); 230 | return len; 231 | } 232 | 233 | #endif // DAVS2_MD5_H 234 | -------------------------------------------------------------------------------- /source/test/parse_args.h: -------------------------------------------------------------------------------- 1 | /* 2 | * parse_args.h 3 | * 4 | * Description of this file: 5 | * Argument Parsing functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - video decoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #ifndef DAVS2_GETOPT_H 34 | #define DAVS2_GETOPT_H 35 | 36 | #include 37 | #include 38 | #include 39 | #if _WIN32 40 | #include 41 | #include 42 | #endif 43 | #include "utils.h" 44 | 45 | typedef struct davs2_input_param_t { 46 | const char *s_infile; 47 | const char *s_outfile; 48 | const char *s_recfile; 49 | const char *s_md5; 50 | 51 | int g_verbose; 52 | int g_psnr; 53 | int g_threads; 54 | int b_y4m; // Y4M or YUV 55 | 56 | FILE *g_infile; 57 | FILE *g_recfile; 58 | FILE *g_outfile; 59 | } davs2_input_param_t; 60 | 61 | #if defined(__ICL) || defined(_MSC_VER) 62 | #define strcasecmp _stricmp 63 | #endif 64 | 65 | /* 包含附加参数的,在字母后面需要加上冒号 */ 66 | static const char *optString = "i:o:r:m:t:vh?"; 67 | 68 | static const struct option longOpts[] = { 69 | {"input", required_argument, NULL, 'i'}, 70 | {"output", required_argument, NULL, 'o'}, 71 | {"psnr", required_argument, NULL, 'r'}, 72 | {"md5", required_argument, NULL, 'm'}, 73 | {"threads", required_argument, NULL, 't'}, 74 | {"verbose", no_argument, NULL, 'v'}, 75 | {"help", no_argument, NULL, 'h'}, 76 | {NULL, no_argument, NULL, 0} 77 | }; 78 | 79 | 80 | /* --------------------------------------------------------------------------- 81 | */ 82 | static void display_usage(void) 83 | { 84 | /* 运行参数说明 */ 85 | const char * usage = "usage: davs2 -i avs2file -o outputfile [-r recfile] [-t threads] [-v]"; 86 | 87 | show_message(CONSOLE_RED, "davs2 parameters\n %s\n", usage); 88 | show_message(CONSOLE_RED, "+------------------+-------------+-------------------------------------------+\n"); 89 | show_message(CONSOLE_RED, "| Parameter | Alias | Settings |\n"); 90 | show_message(CONSOLE_RED, "+------------------+-------------+-------------------------------------------+\n"); 91 | show_message(CONSOLE_RED, "| --input=test.avs | -i test.avs | input bitstream file path |\n"); 92 | show_message(CONSOLE_RED, "| --output=dec.yuv | -o dec.yuv | output YUV/Y4M file path |\n"); 93 | show_message(CONSOLE_RED, "| --psnr=rec.yuv | -r rec.yuv | reference reconstruction YUV file |\n"); 94 | show_message(CONSOLE_RED, "| --threads=N | -t N | threads for decoding (default: 1) |\n"); 95 | show_message(CONSOLE_RED, "| --md5=M | -m M | Reference MD5 of decoded YUV |\n"); 96 | show_message(CONSOLE_RED, "| --verbose | -v | Enable decoding status every frame |\n"); 97 | show_message(CONSOLE_RED, "| --help | -h | Showing this instruction |\n"); 98 | show_message(CONSOLE_RED, "+------------------+-------------+-------------------------------------------+\n"); 99 | } 100 | 101 | 102 | /* --------------------------------------------------------------------------- 103 | */ 104 | static int parse_args(davs2_input_param_t *p_param, int argc, char **argv) 105 | { 106 | char title[1024] = {0}; 107 | int i; 108 | int opt = 0; 109 | int longIndex = 0; 110 | for (i = 0; i < argc; ++i) { 111 | sprintf(&title[strlen(title)], "%s ", argv[i]); 112 | } 113 | show_message(CONSOLE_WHITE, "%s\n\n", title); 114 | 115 | if (argc < 2) { 116 | display_usage(); 117 | return -1; 118 | } 119 | 120 | /* Initialize globalArgs before we get to work. */ 121 | p_param->s_infile = NULL; 122 | p_param->s_outfile = NULL; 123 | p_param->s_recfile = NULL; 124 | p_param->s_md5 = NULL; 125 | p_param->g_infile = NULL; 126 | p_param->g_outfile = NULL; 127 | p_param->g_recfile = NULL; 128 | p_param->g_verbose = 0; 129 | p_param->g_psnr = 0; 130 | p_param->g_threads = 1; 131 | p_param->b_y4m = 0; 132 | 133 | opt = getopt_long(argc, argv, optString, longOpts, &longIndex); 134 | while (opt != -1) { 135 | switch (opt) { 136 | case 'i': 137 | p_param->s_infile = optarg; 138 | break; 139 | case 'o': 140 | p_param->s_outfile = optarg; 141 | break; 142 | case 'r': 143 | p_param->s_recfile = optarg; 144 | break; 145 | case 'm': 146 | p_param->s_md5 = optarg; 147 | break; 148 | case 'v': 149 | p_param->g_verbose = 1; 150 | break; 151 | case 't': 152 | p_param->g_threads = atoi(optarg); 153 | break; 154 | case 'h': /* fall-through is intentional */ 155 | case '?': 156 | display_usage(); 157 | return -1; 158 | case 0: /* long option without a short arg */ 159 | break; 160 | default: 161 | /* You won't actually get here. */ 162 | break; 163 | } 164 | 165 | opt = getopt_long(argc, argv, optString, longOpts, &longIndex); 166 | } 167 | 168 | if (p_param->s_infile == NULL) { 169 | display_usage(); 170 | show_message(CONSOLE_RED, "missing input file.\n"); 171 | return -1; 172 | } 173 | 174 | p_param->g_infile = fopen(p_param->s_infile, "rb"); 175 | 176 | if (p_param->s_recfile != NULL) { 177 | p_param->g_recfile = fopen(p_param->s_recfile, "rb"); 178 | } 179 | 180 | if (p_param->s_outfile != NULL) { 181 | if (!strcmp(p_param->s_outfile, "stdout")) { 182 | p_param->g_outfile = stdout; 183 | } else { 184 | p_param->g_outfile = fopen(p_param->s_outfile, "wb"); 185 | } 186 | } else if (p_param->g_outfile == NULL) { 187 | display_usage(); 188 | show_message(CONSOLE_RED, "WARN: missing output file.\n"); 189 | } 190 | 191 | /* open stream file */ 192 | if (p_param->g_infile == NULL) { 193 | show_message(CONSOLE_RED, "ERROR: failed to open input file: %s\n", p_param->s_infile); 194 | return -1; 195 | } 196 | 197 | /* open rec file */ 198 | if (p_param->s_recfile != NULL && p_param->g_recfile == NULL) { 199 | show_message(CONSOLE_RED, "ERROR: failed to open reference file: %s\n", p_param->s_recfile); 200 | } 201 | p_param->g_psnr = (p_param->g_recfile != NULL); 202 | 203 | /* open output file */ 204 | if (p_param->s_outfile != NULL && p_param->g_outfile == NULL) { 205 | show_message(CONSOLE_RED, "ERROR: failed to open output file: %s\n", p_param->s_outfile); 206 | } else { 207 | int l = (int)strlen(p_param->s_outfile); 208 | if (l > 4) { 209 | if (!strcmp(p_param->s_outfile + l - 4, ".y4m")) { 210 | p_param->b_y4m = 1; 211 | } 212 | } 213 | if (p_param->g_outfile == stdout) { 214 | #if _WIN32 215 | setmode(fileno(stdout), O_BINARY); 216 | #endif 217 | p_param->b_y4m = 1; 218 | } 219 | } 220 | 221 | /* get md5 */ 222 | if (p_param->s_md5 && strlen(p_param->s_md5) != 32) { 223 | show_message(CONSOLE_RED, "ERROR: invalid md5 value"); 224 | } 225 | 226 | show_message(CONSOLE_WHITE, "--------------------------------------------------\n"); 227 | show_message(CONSOLE_WHITE, " AVS2 file : %s\n", p_param->s_infile); 228 | show_message(CONSOLE_WHITE, " Reference file : %s\n", p_param->s_recfile); 229 | show_message(CONSOLE_WHITE, " Output file : %s\n", p_param->s_outfile); 230 | show_message(CONSOLE_WHITE, "--------------------------------------------------\n"); 231 | 232 | return 0; 233 | } 234 | 235 | #endif /// DAVS2_GETOPT_H 236 | -------------------------------------------------------------------------------- /source/test/test.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkuvcl/davs2/b41cf117452e2d73d827f02d3e30aa20f1c721ac/source/test/test.c -------------------------------------------------------------------------------- /source/test/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * utils.h 3 | * 4 | * Description of this file: 5 | * functions definition of the davs2 library 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * davs2 - video decoder of AVS2/IEEE1857.4 video coding standard 10 | * Copyright (C) 2018~ VCL, NELVT, Peking University 11 | * 12 | * Authors: Falei LUO 13 | * etc. 14 | * 15 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 28 | * 29 | * This program is also available under a commercial proprietary license. 30 | * For more information, contact us at sswang @ pku.edu.cn. 31 | */ 32 | 33 | #ifndef DAVS2_UTILS_H 34 | #define DAVS2_UTILS_H 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | #include "davs2.h" 41 | 42 | #define CONSOLE_WHITE 0 43 | #define CONSOLE_YELLOW 1 44 | #define CONSOLE_RED 2 45 | #define CONSOLE_GREEN 3 46 | 47 | #if __ANDROID__ 48 | #include 49 | #include 50 | #define LOGE(format,...) __android_log_print(ANDROID_LOG_ERROR,"davs2", format,##__VA_ARGS__) 51 | #endif 52 | 53 | #if _WIN32 54 | #include 55 | #include 56 | #include 57 | #else 58 | #include 59 | #endif 60 | #include 61 | 62 | /* --------------------------------------------------------------------------- 63 | * time */ 64 | static __inline int64_t get_time() 65 | { 66 | #if _WIN32 67 | struct timeb tb; 68 | ftime(&tb); 69 | return ((int64_t)tb.time * CLOCKS_PER_SEC + (int64_t)tb.millitm); 70 | #else 71 | struct timeval tv_date; 72 | gettimeofday(&tv_date, NULL); 73 | return (int64_t)(tv_date.tv_sec * CLOCKS_PER_SEC + (int64_t)tv_date.tv_usec); 74 | #endif 75 | } 76 | 77 | #if _WIN32 78 | /* --------------------------------------------------------------------------- 79 | */ 80 | static __inline void set_font_color(int color) 81 | { 82 | WORD colors[] = { 83 | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE, 84 | FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN, 85 | FOREGROUND_INTENSITY | FOREGROUND_RED, 86 | FOREGROUND_INTENSITY | FOREGROUND_GREEN, 87 | }; 88 | SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), colors[color]); 89 | } 90 | #endif 91 | 92 | /* --------------------------------------------------------------------------- 93 | */ 94 | static void show_message(int color, const char *format, ...) 95 | { 96 | char message[1024] = { 0 }; 97 | 98 | va_list arg_ptr; 99 | va_start(arg_ptr, format); 100 | 101 | vsprintf(message, format, arg_ptr); 102 | 103 | va_end(arg_ptr); 104 | 105 | #if _WIN32 106 | set_font_color(color); /* set color */ 107 | fprintf(stderr, "%s", message); 108 | set_font_color(0); /* restore to white color */ 109 | 110 | #elif __ANDROID__ 111 | LOGE("%s", message); 112 | #else 113 | fprintf(stderr, "%s", message); 114 | #endif 115 | } 116 | 117 | /* --------------------------------------------------------------------------- 118 | */ 119 | static __inline void show_progress(int frame, int frames) 120 | { 121 | static int64_t first_time = 0; 122 | static int64_t last_time = 0; 123 | float fps = 0.0f; 124 | int64_t total_time = 0; 125 | int64_t cur_time = get_time(); 126 | int eta; 127 | 128 | if (first_time == 0) { 129 | first_time = cur_time; 130 | } else { 131 | total_time = cur_time - first_time; 132 | fps = frame * 1.0f / total_time * CLOCKS_PER_SEC; 133 | } 134 | 135 | if (cur_time - last_time < 300 && frame != frames) { 136 | return; 137 | } 138 | 139 | last_time = cur_time; 140 | 141 | eta = (int)((frames - frame) * total_time / frame) / (CLOCKS_PER_SEC / 1000); 142 | 143 | show_message(CONSOLE_WHITE, "\r frames: %4d/%4d, fps: %4.1f, LeftTime: %8.3f sec\r", 144 | frame, frames, fps, eta * 0.001); 145 | } 146 | 147 | /* --------------------------------------------------------------------------- 148 | */ 149 | static 150 | void write_frame_plane(FILE *fp_out, const uint8_t *p_src, int img_w, int img_h, int bytes_per_sample, int i_stride) 151 | { 152 | const int size_line = img_w * bytes_per_sample; 153 | int i; 154 | 155 | for (i = 0; i < img_h; i++) { 156 | fwrite(p_src, size_line, 1, fp_out); 157 | p_src += i_stride; 158 | } 159 | } 160 | 161 | 162 | /* --------------------------------------------------------------------------- 163 | */ 164 | static 165 | void write_y4m_header(FILE *fp, int w, int h, int fps_num, int fps_den, int bit_depth) 166 | { 167 | static int b_y4m_header_write = 0; 168 | 169 | if (fp != NULL && !b_y4m_header_write) { 170 | char buf[64]; 171 | 172 | if (bit_depth != 8) { 173 | sprintf(buf, "YUV4MPEG2 W%d H%d F%d:%d Ip C%sp%d\n", 174 | w, h, fps_num, fps_den, "420", bit_depth); 175 | fwrite(buf, 1, strlen(buf), fp); 176 | } else { 177 | sprintf(buf, "YUV4MPEG2 W%d H%d F%d:%d Ip C%s\n", 178 | w, h, fps_num, fps_den, "420"); 179 | fwrite(buf, 1, strlen(buf), fp); 180 | } 181 | 182 | b_y4m_header_write = 1; 183 | } 184 | } 185 | 186 | 187 | /* --------------------------------------------------------------------------- 188 | */ 189 | static 190 | void write_frame(davs2_picture_t *pic, FILE *fp, int b_y4m) 191 | { 192 | const int bytes_per_sample = pic->bytes_per_sample; 193 | 194 | if (b_y4m) { 195 | const char *s_frm = "FRAME\n"; 196 | fwrite(s_frm, 1, strlen(s_frm), fp); 197 | } 198 | 199 | /* write y */ 200 | write_frame_plane(fp, pic->planes[0], pic->widths[0], pic->lines[0], bytes_per_sample, pic->strides[0]); 201 | 202 | if (pic->num_planes == 3) { 203 | /* write u */ 204 | write_frame_plane(fp, pic->planes[1], pic->widths[1], pic->lines[1], bytes_per_sample, pic->strides[1]); 205 | 206 | /* write v */ 207 | write_frame_plane(fp, pic->planes[2], pic->widths[2], pic->lines[2], bytes_per_sample, pic->strides[2]); 208 | } 209 | } 210 | 211 | #endif /// DAVS2_UTILS_H 212 | -------------------------------------------------------------------------------- /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 DAVS2_BUILD' < ./source/davs2.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 DAVS2_VERSION_H" >> version.h 39 | echo "#define DAVS2_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 // DAVS2_VERSION_H" >> version.h 57 | 58 | mv version.h source/version.h 59 | 60 | # show version informations 61 | echo "#define DAVS2_BUILD $api" 62 | echo "#define DAVS2_POINTVER \"$VER_MAJOR.$VER_MINOR.$VER_R\"" 63 | --------------------------------------------------------------------------------