├── .gitignore
├── CMakeLists.txt
├── COPYING
├── README.md
├── build
├── android
│ └── ndk
│ │ └── jni
│ │ ├── Android.mk
│ │ ├── Application.mk
│ │ ├── uavs3d_arm64.mk
│ │ ├── uavs3d_armv7a.mk
│ │ ├── uavs3d_avx2.mk
│ │ ├── uavs3d_clear_vars.mk
│ │ ├── uavs3d_main.mk
│ │ └── uavs3d_sse2.mk
├── ios
│ ├── uavs3d.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcshareddata
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── uavs3d.xcscheme
│ └── uavs3d
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ ├── ViewController.h
│ │ ├── ViewController.m
│ │ └── main.m
└── vs2017
│ ├── common.vcxproj
│ ├── common.vcxproj.filters
│ ├── libuavs3d.vcxproj
│ ├── uavs3d.sln
│ └── uavs3d.vcxproj
├── source
├── CMakeLists.txt
├── decoder
│ ├── bitstream.c
│ ├── bitstream.h
│ ├── dec_type.h
│ ├── dec_util.c
│ ├── dec_util.h
│ ├── parser.c
│ ├── parser.h
│ ├── uavs3d.c
│ └── uavs3d.h
└── decore
│ ├── alf.c
│ ├── arm64
│ ├── alf_arm64.S
│ ├── arm64.c
│ ├── arm64.h
│ ├── deblock_arm64.S
│ ├── def_arm64.S
│ ├── inter_pred_arm64.S
│ ├── intra_pred_arm64.S
│ ├── intra_pred_chroma_arm64.S
│ ├── itrans_arm64.c
│ ├── itrans_arm64.h
│ ├── itrans_dct2_arm64.S
│ ├── itrans_dct8_dst7_arm64.S
│ ├── pixel_arm64.S
│ ├── sao_arm64.c
│ ├── sao_kernel_arm64.S
│ └── sao_kernel_arm64.h
│ ├── armv7
│ ├── alf_armv7.S
│ ├── armv7.c
│ ├── armv7.h
│ ├── dct2_armv7.S
│ ├── deblock_armv7.S
│ ├── def_armv7.S
│ ├── inter_pred_armv7.S
│ ├── intra_pred_armv7.S
│ ├── itrans_dct8_dst7_armv7.S
│ ├── pixel_armv7.S
│ ├── sao_armv7.c
│ ├── sao_kernel_armv7.S
│ └── sao_kernel_armv7.h
│ ├── avx2
│ ├── alf_avx2.c
│ ├── avx2.c
│ ├── avx2.h
│ ├── inter_pred_avx2.c
│ ├── intra_pred_avx2.c
│ ├── itrans_avx2.c
│ ├── pixel_avx2.c
│ └── sao_avx2.c
│ ├── com_def.h
│ ├── com_sys.h
│ ├── com_table.c
│ ├── com_table.h
│ ├── com_type.h
│ ├── com_util.c
│ ├── com_util.h
│ ├── contributor.h
│ ├── deblock.c
│ ├── inter_pred.c
│ ├── intra_pred.c
│ ├── inv_trans.c
│ ├── modules.h
│ ├── pic_manager.c
│ ├── recon.c
│ ├── sao.c
│ ├── sse
│ ├── alf_sse.c
│ ├── deblock_sse.c
│ ├── inter_pred_sse.c
│ ├── intra_pred_sse.c
│ ├── itrans_sse.c
│ ├── pixel_sse.c
│ ├── sao_sse.c
│ ├── sse.c
│ └── sse.h
│ ├── threadpool.c
│ ├── threadpool.h
│ ├── win32thread.c
│ └── win32thread.h
├── test
├── utest.c
└── utest.h
├── version.bat
└── version.sh
/.gitignore:
--------------------------------------------------------------------------------
1 | # Prerequisites
2 | *.d
3 |
4 | # Object files
5 | *.o
6 | *.ko
7 | *.obj
8 | *.elf
9 |
10 | # Linker output
11 | *.ilk
12 | *.map
13 | *.exp
14 |
15 | # Precompiled Headers
16 | *.gch
17 | *.pch
18 |
19 | # Libraries
20 | *.lib
21 | *.a
22 | *.la
23 | *.lo
24 |
25 | # Shared objects (inc. Windows DLLs)
26 | *.dll
27 | *.so
28 | *.so.*
29 | *.dylib
30 |
31 | # Executables
32 | *.exe
33 | *.out
34 | *.app
35 | *.i*86
36 | *.x86_64
37 | *.hex
38 |
39 | # Debug files
40 | *.dSYM/
41 | *.su
42 | *.idb
43 | *.pdb
44 |
45 | # Kernel Module Compile Results
46 | *.mod*
47 | *.cmd
48 | .tmp_versions/
49 | modules.order
50 | Module.symvers
51 | Mkfile.old
52 | dkms.conf
53 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.1)
2 |
3 | project(uavs3d)
4 |
5 | option(COMPILE_10BIT "Enable 10bit streams decoding support." OFF)
6 |
7 | set(CMAKE_C_STANDARD 99)
8 | set(CMAKE_POSITION_INDEPENDENT_CODE ON)
9 |
10 | aux_source_directory(./test DIR_SRC_TEST)
11 |
12 | add_subdirectory(./source)
13 |
14 | add_executable(uavs3dec ${DIR_SRC_TEST})
15 |
16 | if (NOT MSVC)
17 | target_link_libraries(uavs3dec m)
18 | endif()
19 | target_link_libraries(uavs3dec uavs3d)
20 | #target_link_libraries(uavs3dec dl)
21 |
--------------------------------------------------------------------------------
/COPYING:
--------------------------------------------------------------------------------
1 | Copyright (c) 2018-2022 ["Peking University Shenzhen Graduate School", "Peng Cheng Laboratory", and "Guangdong Bohua UHD Innovation Corporation"]
2 |
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 | 1. Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | 2. Redistributions in binary form must reproduce the above copyright
10 | notice, this list of conditions and the following disclaimer in the
11 | documentation and/or other materials provided with the distribution.
12 | 3. Neither the name of the organizations (Peking University Shenzhen Graduate School, Peng Cheng Laboratory and Guangdong Bohua UHD Innovation Corporation)
13 | nor the names of its contributors may be used to endorse or promote products
14 | derived from this software without specific prior written permission.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
17 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # uavs3d
2 | uavs3d is an opensource and cross-platform avs3 decoder, supports AVS3-P2 baseline profile.
3 | features:
4 | 1) AVS3-P2 baseline profile.
5 | 2) supports to compile for Android/IOS/Windows/Linux/MacOS systems.
6 | 3) optimized for ARMv7/ARMv8/SSE4/AVX2 chips.
7 | 4) 10bit decoding on all supported platforms.
8 | 5) The uavs3 codec has supported x86 and arm platforms, and has been tested and verified on the Kunpeng processor.
9 | 6) The ARM platform recommends the Kunpeng processor.
10 | # license
11 | Copyright reserved by “Peking University Shenzhen Graduate School”, “Peng Cheng Laboratory”, and “Guangdong Bohua UHD Innovation Corporation”
12 | This program is a free software. You can redistribute it and/or modify it under the terms of the BSD 3-clause license.
13 | For more details, please view the file "COPYING" in the project.
14 |
15 | # compile
16 | The default configuration only support 8bit decoding.
17 | To support 10bit streams decoding: cmake -DCOMPILE_10BIT=1
18 |
19 | ## windows
20 | Prerequisites:
21 | Visual Studio 2017
22 |
23 | build:
24 | 1. ./version.bat (to generate version.h)
25 | 2. solution file: build/x86_windows/uavs3d.sln
26 |
27 | To support 10bit streams decoding, edit source/decore/com_def.h : #define COMPILE_10BIT 1
28 |
29 | ## linux/mac
30 | Prerequisites:
31 | 1. gawk (http://www.gnu.org/software/gawk/)
32 | 2. CMake (https://cmake.org) version 3.1 or higher
33 |
34 | Build:
35 | 1. mkdir build/linux
36 | 2. cd build/linux && cmake -DCOMPILE_10BIT=0 ../..
37 | 3. make && make install
38 |
39 | To support 10bit streams decoding: cmake -DCOMPILE_10BIT=1
40 | to build shared library, set BUILD_SHARED_LIBS=1 please.
41 |
42 | ## ios
43 | Prerequisites:
44 | XCode
45 |
46 | Build:
47 | 1. ./version.sh (generate the version.h)
48 | 2. xcode solution file: build/ios/uavs3d.xcodeproj
49 |
50 | To support 10bit streams decoding:
51 | Find Xcode -> PROJECT -> Build Settings -> Preprocessor Macros, add COMPILE_10BIT=1
52 |
53 | ## android
54 | Prerequisites:
55 | Android NDK (https://developer.android.google.cn/ndk/downloads/).
56 |
57 | Build ndk library or executable file:
58 | 1. ./version.sh (generate the version.h)
59 | 2. cd build/android/ndk/jni
60 | 3. $NDK_PATH/ndk-build
61 |
62 | To support 10bit streams decoding: edit build/android/ndk/jni/uavs3d_main.mk:
63 |
64 | LOCAL_CFLAGS += -DCOMPILE_10BIT=1
65 |
66 | # Run tests
67 | ## window/linux/mac/android
68 | sample: ./uavs3d -i input.avs3 -o output.yuv -t 8 -l 2 -s 1
69 |
70 | Arguments:
71 |
72 | | short name | long name | introduction |
73 | |:-----------:|----------|-------------|
74 | | -h | --help | Print this help |
75 | | -v | --version | Version information |
76 | | -i | --input | Input file |
77 | | -o | --output | Output file |
78 | | -l | --loglevel | Log level:
0: no message; 1: seq level; 2: frame level (default) |
79 | | -t | --threads | Number of frame-level threads |
80 | | -f | --frames | Total frames to decode |
81 | | -s | --check_md5| Enable to check md5 or not |
82 |
83 | ## ios
84 | Edit build/ios/uavs3d/main.m to configure decoding options.
85 |
86 | # Contributors
87 | This program is originally developed by the team of Prof.Ronggang Wang (rgwang@pkusz.edu.cn) at Peking University Shenzhen Graduate School.
88 |
89 | * Main contributors:
90 | * Zhenyu Wang (wangzhenyu@pkusz.edu.cn), Peking University Shenzhen Graduate School.
91 | * Bingjie Han (hanbj@pkusz.edu.cn), Peking University Shenzhen Graduate School.
92 | * Jiang Du, Peking University Shenzhen Graduate School.
93 | * Kui Fan, Peking University Shenzhen Graduate School.
94 | * Xi Xie, Peking University Shenzhen Graduate School.
95 | * Guisen Xu, Peking University Shenzhen Graduate School.
96 | * Xufeng Li, Peking University Shenzhen Graduate School.
97 | * Yangang Cai, Peking University Shenzhen Graduate School.
98 | * Hao Lv, Peng Cheng Laboratory.
99 | * Min Chen.
100 |
101 | ** Ronggang Wang (rgwang@pkusz.edu.cn), Peking University Shenzhen Graduate School
102 |
--------------------------------------------------------------------------------
/build/android/ndk/jni/Android.mk:
--------------------------------------------------------------------------------
1 | ### This file is jni/Android.mk
2 |
3 | LOCAL_PATH := $(call my-dir)
4 | SRC_PATH := ../../../../source
5 | INCLUDE_PATH := ../../../../source/decore
6 |
7 | ### Name of the local module
8 | include $(LOCAL_PATH)/uavs3d_clear_vars.mk
9 | LOCAL_MODULE := uavs3d-static
10 | LOCAL_MODULE_FILENAME := libuavs3d
11 | include $(LOCAL_PATH)/uavs3d_main.mk
12 | include $(BUILD_STATIC_LIBRARY)
13 |
14 | include $(LOCAL_PATH)/uavs3d_clear_vars.mk
15 | LOCAL_MODULE := uavs3d-shared
16 | LOCAL_MODULE_FILENAME := libuavs3d
17 | LOCAL_LDLIBS:=-L$(SYSROOT)/usr/lib -lm -llog
18 | LOCAL_LDFLAGS += -fPIC
19 | include $(LOCAL_PATH)/uavs3d_main.mk
20 | include $(BUILD_SHARED_LIBRARY)
21 |
22 |
23 | include $(LOCAL_PATH)/uavs3d_clear_vars.mk
24 | LOCAL_MODULE := uavs3d
25 | LOCAL_LDLIBS:=-L$(SYSROOT)/usr/lib -lm -llog
26 | LOCAL_CFLAGS += -pie -fPIE
27 | LOCAL_LDFLAGS += -pie -fPIE
28 | uavs3d_srcs_test+= $(SRC_PATH)/../test/utest.c
29 | include $(LOCAL_PATH)/uavs3d_main.mk
30 | include $(BUILD_EXECUTABLE)
31 |
--------------------------------------------------------------------------------
/build/android/ndk/jni/Application.mk:
--------------------------------------------------------------------------------
1 | # APP_ABI := armeabi-v7a
2 | # APP_ABI := arm64-v8a
3 | # APP_ABI := armeabi
4 | # APP_ABI := x86
5 | # APP_ABI := x86_64
6 | APP_ABI := all
7 | APP_OPTIM := release
8 | # TARGET_BUILD_TYPE=release
9 |
10 | APP_STL := c++_static
11 | APP_STL := c++_shared
12 |
13 |
--------------------------------------------------------------------------------
/build/android/ndk/jni/uavs3d_arm64.mk:
--------------------------------------------------------------------------------
1 |
2 | ARM64_SRC_PATH:=../../../../source/decore/arm64
3 |
4 | uavs3d_srcs_arm += $(ARM64_SRC_PATH)/arm64.c
5 | uavs3d_srcs_arm += $(ARM64_SRC_PATH)/def_arm64.S
6 | uavs3d_srcs_arm += $(ARM64_SRC_PATH)/alf_arm64.S
7 | uavs3d_srcs_arm += $(ARM64_SRC_PATH)/deblock_arm64.S
8 | uavs3d_srcs_arm += $(ARM64_SRC_PATH)/inter_pred_arm64.S
9 | uavs3d_srcs_arm += $(ARM64_SRC_PATH)/itrans_arm64.c
10 | uavs3d_srcs_arm += $(ARM64_SRC_PATH)/itrans_dct2_arm64.S
11 | uavs3d_srcs_arm += $(ARM64_SRC_PATH)/itrans_dct8_dst7_arm64.S
12 | uavs3d_srcs_arm += $(ARM64_SRC_PATH)/pixel_arm64.S
13 | uavs3d_srcs_arm += $(ARM64_SRC_PATH)/sao_arm64.c
14 | uavs3d_srcs_arm += $(ARM64_SRC_PATH)/sao_kernel_arm64.S
15 | uavs3d_srcs_arm += $(ARM64_SRC_PATH)/intra_pred_arm64.S
16 | uavs3d_srcs_arm += $(ARM64_SRC_PATH)/intra_pred_chroma_arm64.S
17 |
18 |
--------------------------------------------------------------------------------
/build/android/ndk/jni/uavs3d_armv7a.mk:
--------------------------------------------------------------------------------
1 |
2 | ARMV7_SRC_PATH:=../../../../source/decore/armv7
3 |
4 | uavs3d_srcs_arm += $(ARMV7_SRC_PATH)/armv7.c
5 | uavs3d_srcs_arm += $(ARMV7_SRC_PATH)/def_armv7.S
6 | uavs3d_srcs_arm += $(ARMV7_SRC_PATH)/pixel_armv7.S
7 | uavs3d_srcs_arm += $(ARMV7_SRC_PATH)/inter_pred_armv7.S
8 | uavs3d_srcs_arm += $(ARMV7_SRC_PATH)/intra_pred_armv7.S
9 | uavs3d_srcs_arm += $(ARMV7_SRC_PATH)/deblock_armv7.S
10 | uavs3d_srcs_arm += $(ARMV7_SRC_PATH)/alf_armv7.S
11 | uavs3d_srcs_arm += $(ARMV7_SRC_PATH)/sao_armv7.c
12 | uavs3d_srcs_arm += $(ARMV7_SRC_PATH)/sao_kernel_armv7.S
13 | uavs3d_srcs_arm += $(ARMV7_SRC_PATH)/itrans_dct8_dst7_armv7.S
14 | uavs3d_srcs_arm += $(ARMV7_SRC_PATH)/dct2_armv7.S
15 |
--------------------------------------------------------------------------------
/build/android/ndk/jni/uavs3d_avx2.mk:
--------------------------------------------------------------------------------
1 |
2 | AVX_SRC_PATH:=../../../../source/decore/avx2
3 |
4 | uavs3d_srcs_avx += $(AVX_SRC_PATH)/alf_avx2.c
5 | uavs3d_srcs_avx += $(AVX_SRC_PATH)/avx2.c
6 | uavs3d_srcs_avx += $(AVX_SRC_PATH)/inter_pred_avx2.c
7 | uavs3d_srcs_avx += $(AVX_SRC_PATH)/intra_pred_avx2.c
8 | uavs3d_srcs_avx += $(AVX_SRC_PATH)/itrans_avx2.c
9 | uavs3d_srcs_avx += $(AVX_SRC_PATH)/pixel_avx2.c
10 | uavs3d_srcs_avx += $(AVX_SRC_PATH)/sao_avx2.c
11 |
12 |
--------------------------------------------------------------------------------
/build/android/ndk/jni/uavs3d_clear_vars.mk:
--------------------------------------------------------------------------------
1 | include $(CLEAR_VARS)
2 | uavs3d_srcs_c :=
3 | uavs3d_srcs_test :=
4 | uavs3d_srcs_arm :=
5 | uavs3d_srcs_sse :=
6 | uavs3d_srcs_avx :=
7 |
--------------------------------------------------------------------------------
/build/android/ndk/jni/uavs3d_main.mk:
--------------------------------------------------------------------------------
1 |
2 | ### for posix pthread
3 | #LOCAL_SHARED_LIBRARIES := libcutil
4 |
5 | ### include search path when compiling all sources (C,C++,Assembly)
6 | LOCAL_C_INCLUDES +=$(INCLUDE_PATH) \
7 | $(LOCAL_PATH)/../app
8 |
9 | ### c source code
10 | uavs3d_srcs_c += $(SRC_PATH)/decore/alf.c
11 | uavs3d_srcs_c += $(SRC_PATH)/decore/deblock.c
12 | uavs3d_srcs_c += $(SRC_PATH)/decore/inter_pred.c
13 | uavs3d_srcs_c += $(SRC_PATH)/decore/intra_pred.c
14 | uavs3d_srcs_c += $(SRC_PATH)/decore/inv_trans.c
15 | uavs3d_srcs_c += $(SRC_PATH)/decore/pic_manager.c
16 | uavs3d_srcs_c += $(SRC_PATH)/decore/recon.c
17 | uavs3d_srcs_c += $(SRC_PATH)/decore/sao.c
18 | uavs3d_srcs_c += $(SRC_PATH)/decore/com_table.c
19 | uavs3d_srcs_c += $(SRC_PATH)/decore/threadpool.c
20 | uavs3d_srcs_c += $(SRC_PATH)/decore/win32thread.c
21 | uavs3d_srcs_c += $(SRC_PATH)/decore/com_util.c
22 | uavs3d_srcs_c += $(SRC_PATH)/decoder/uavs3d.c
23 | uavs3d_srcs_c += $(SRC_PATH)/decoder/bitstream.c
24 | uavs3d_srcs_c += $(SRC_PATH)/decoder/parser.c
25 | uavs3d_srcs_c += $(SRC_PATH)/decoder/dec_util.c
26 |
27 |
28 | LOCAL_CFLAGS += -O3 -fPIC -std=gnu99 -I../../../source/decore
29 |
30 | ### To support 10bit streams decoding: edit it to -DCOMPILE_10BIT=1
31 | LOCAL_CFLAGS += -DCOMPILE_10BIT=0
32 |
33 | ifeq ($(TARGET_ARCH),arm)
34 | ifeq ($(TARGET_ARCH_ABI), armeabi-v7a)
35 | # build armv7a
36 | LOCAL_CFLAGS += -mfpu=neon -D_armv7a
37 | include $(LOCAL_PATH)/uavs3d_armv7a.mk
38 | endif
39 | endif
40 |
41 | ifeq ($(TARGET_ARCH),arm64)
42 | # build arm64
43 | LOCAL_CFLAGS += -D_arm64
44 | include $(LOCAL_PATH)/uavs3d_arm64.mk
45 | endif
46 |
47 | ifeq ($(TARGET_ARCH),x86)
48 | # build x86
49 | LOCAL_CFLAGS += -msse4.2 -mavx2
50 | include $(LOCAL_PATH)/uavs3d_sse2.mk
51 | include $(LOCAL_PATH)/uavs3d_avx2.mk
52 | endif
53 |
54 | ifeq ($(TARGET_ARCH),x86_64)
55 | # build x86_64
56 | LOCAL_CFLAGS += -msse4.2 -mavx2
57 | include $(LOCAL_PATH)/uavs3d_sse2.mk
58 | include $(LOCAL_PATH)/uavs3d_avx2.mk
59 | endif
60 |
61 | LOCAL_SRC_FILES := $(uavs3d_srcs_c) $(uavs3d_srcs_arm) $(uavs3d_srcs_sse) $(uavs3d_srcs_avx) $(uavs3d_srcs_test)
62 |
--------------------------------------------------------------------------------
/build/android/ndk/jni/uavs3d_sse2.mk:
--------------------------------------------------------------------------------
1 |
2 | SSE_SRC_PATH:=../../../../source/decore/sse
3 |
4 | uavs3d_srcs_sse += $(SSE_SRC_PATH)/alf_sse.c
5 | uavs3d_srcs_sse += $(SSE_SRC_PATH)/deblock_sse.c
6 | uavs3d_srcs_sse += $(SSE_SRC_PATH)/inter_pred_sse.c
7 | uavs3d_srcs_sse += $(SSE_SRC_PATH)/intra_pred_sse.c
8 | uavs3d_srcs_sse += $(SSE_SRC_PATH)/itrans_sse.c
9 | uavs3d_srcs_sse += $(SSE_SRC_PATH)/pixel_sse.c
10 | uavs3d_srcs_sse += $(SSE_SRC_PATH)/sao_sse.c
11 | uavs3d_srcs_sse += $(SSE_SRC_PATH)/sse.c
12 |
--------------------------------------------------------------------------------
/build/ios/uavs3d.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/build/ios/uavs3d.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/build/ios/uavs3d.xcodeproj/xcshareddata/xcschemes/uavs3d.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
41 |
42 |
52 |
54 |
60 |
61 |
62 |
63 |
69 |
71 |
77 |
78 |
79 |
80 |
82 |
83 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/build/ios/uavs3d/AppDelegate.h:
--------------------------------------------------------------------------------
1 |
2 | #import
3 |
4 | @interface AppDelegate : UIResponder
5 |
6 | @property (strong, nonatomic) UIWindow *window;
7 |
8 |
9 | @end
10 |
11 |
--------------------------------------------------------------------------------
/build/ios/uavs3d/AppDelegate.m:
--------------------------------------------------------------------------------
1 |
2 | #import "AppDelegate.h"
3 |
4 | @interface AppDelegate ()
5 |
6 | @end
7 |
8 | @implementation AppDelegate
9 |
10 |
11 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
12 | // Override point for customization after application launch.
13 | return YES;
14 | }
15 |
16 |
17 | - (void)applicationWillResignActive:(UIApplication *)application {
18 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
19 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
20 | }
21 |
22 |
23 | - (void)applicationDidEnterBackground:(UIApplication *)application {
24 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
25 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
26 | }
27 |
28 |
29 | - (void)applicationWillEnterForeground:(UIApplication *)application {
30 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
31 | }
32 |
33 |
34 | - (void)applicationDidBecomeActive:(UIApplication *)application {
35 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
36 | }
37 |
38 |
39 | - (void)applicationWillTerminate:(UIApplication *)application {
40 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
41 | }
42 |
43 |
44 | @end
45 |
--------------------------------------------------------------------------------
/build/ios/uavs3d/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "20x20",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "20x20",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "29x29",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "29x29",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "40x40",
66 | "scale" : "1x"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "size" : "40x40",
71 | "scale" : "2x"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "size" : "76x76",
76 | "scale" : "1x"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "size" : "76x76",
81 | "scale" : "2x"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "size" : "83.5x83.5",
86 | "scale" : "2x"
87 | },
88 | {
89 | "idiom" : "ios-marketing",
90 | "size" : "1024x1024",
91 | "scale" : "1x"
92 | }
93 | ],
94 | "info" : {
95 | "version" : 1,
96 | "author" : "xcode"
97 | }
98 | }
--------------------------------------------------------------------------------
/build/ios/uavs3d/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/build/ios/uavs3d/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/build/ios/uavs3d/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/build/ios/uavs3d/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | UIFileSharingEnabled
22 |
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/build/ios/uavs3d/ViewController.h:
--------------------------------------------------------------------------------
1 |
2 | #import
3 |
4 | @interface ViewController : UIViewController
5 |
6 |
7 | @end
8 |
9 |
--------------------------------------------------------------------------------
/build/ios/uavs3d/ViewController.m:
--------------------------------------------------------------------------------
1 |
2 | #import "ViewController.h"
3 |
4 | @interface ViewController ()
5 |
6 | @end
7 |
8 | @implementation ViewController
9 |
10 | - (void)viewDidLoad {
11 | [super viewDidLoad];
12 | // Do any additional setup after loading the view, typically from a nib.
13 | }
14 |
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/build/ios/uavs3d/main.m:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * Copyright (c) 2018-2020 ["Peking University Shenzhen Graduate School",
3 | * "Peng Cheng Laboratory", and "Guangdong Bohua UHD Innovation Corporation"]
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. All advertising materials mentioning features or use of this software
15 | * must display the following acknowledgement:
16 | * This product includes software developed by the .
17 | * 4. Neither the name of the nor the
18 | * names of its contributors may be used to endorse or promote products
19 | * derived from this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY
22 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
25 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 | *
32 | * For more information, contact us at rgwang@pkusz.edu.cn.
33 | **************************************************************************************/
34 |
35 | #import
36 | #import "AppDelegate.h"
37 | #import "utest.h"
38 |
39 | #define SPEED_TEST 0
40 |
41 | #define INFILE_NUM 18
42 |
43 | char infile[INFILE_NUM][128]={ // base dir: app/documents
44 | "abr_hpm4.0/PeopleOnStreet_2560x1600_30_7000kbps.avs3",
45 | "abr_hpm4.0/Traffic_2560x1600_30_7000kbps.avs3",
46 | "abr_hpm4.0/BasketballDrive_1920x1080_50_2000kbps.avs3",
47 | "abr_hpm4.0/BQTerrace_1920x1080_60_2000kbps.avs3",
48 | "abr_hpm4.0/Cactus_1920x1080_50_2000kbps.avs3",
49 | "abr_hpm4.0/Kimono_1920x1080_24_2000kbps.avs3",
50 | "abr_hpm4.0/ParkScene_1920x1080_24_2000kbps.avs3",
51 | "abr_hpm4.0/FourPeople_1280x720_60_1000kbps.avs3",
52 | "abr_hpm4.0/Johnny_1280x720_60_1000kbps.avs3",
53 | "abr_hpm4.0/KristenAndSara_1280x720_60_1000kbps.avs3",
54 | "abr_hpm4.0/BQMall_832x480_60_700kbps.avs3",
55 | "abr_hpm4.0/BasketballDrill_832x480_50_700kbps.avs3",
56 | "abr_hpm4.0/PartyScene_832x480_50_700kbps.avs3",
57 | "abr_hpm4.0/RaceHorses_832x480_30_700kbps.avs3",
58 | "abr_hpm4.0/BQSquare_416x240_60_300kbps.avs3",
59 | "abr_hpm4.0/BasketballPass_416x240_50_300kbps.avs3",
60 | "abr_hpm4.0/BlowingBubbles_416x240_50_300kbps.avs3",
61 | "abr_hpm4.0/RaceHorses_416x240_30_300kbps.avs3"
62 | };
63 |
64 | #define THREADS_NUM "1"
65 | #if SPEED_TEST
66 | #define LOG_LEVEL "1"
67 | #define ENABLE_MD5_CHECK 0
68 | #else
69 | #define LOG_LEVEL "2"
70 | #define ENABLE_MD5_CHECK 1
71 | #endif
72 |
73 | #define ENABLE_WRITE_YUV 0
74 |
75 | #define BASE_ARGC 7
76 | #if ENABLE_MD5_CHECK
77 | #define MD5_ARGC 2
78 | #else
79 | #define MD5_ARGC 0
80 | #endif
81 |
82 | #if ENABLE_WRITE_YUV
83 | #define OUTPUT_ARGC 2
84 | #else
85 | #define OUTPUT_ARGC 0
86 | #endif
87 |
88 | int main(int argc, char * argv[]) {
89 | NSString* NsInputFileName, *NsInputFileFullName, *NsOutputFileName, *NsOutputFileFullName;
90 | char InputFileName[256], DecFileName[256];
91 | int i;
92 | unsigned long strLen;
93 |
94 | NSString * NsDocuments = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
95 |
96 | char* uavs3d_argv[BASE_ARGC + MD5_ARGC + OUTPUT_ARGC];
97 | char decfile[64] = "dec.yuv";
98 | int uavs3d_argc = BASE_ARGC + MD5_ARGC + OUTPUT_ARGC;
99 | int j = 0;
100 |
101 | for(i = 0; i < INFILE_NUM; i++)
102 | {
103 | j = 0;
104 | NsInputFileName = [[NSString alloc]initWithCString:(const char *) (infile[i]) encoding:NSUTF8StringEncoding];
105 | NsInputFileFullName = [NSString stringWithFormat:@"%@/%@", NsDocuments, NsInputFileName];
106 | strLen = [NsInputFileFullName length];
107 | [NsInputFileFullName getCString:InputFileName maxLength:strLen+1 encoding:NSUTF8StringEncoding];
108 | printf("stream: %s\n", infile[i]);
109 |
110 | NsOutputFileName = [[NSString alloc]initWithCString:(const char *) (decfile) encoding:NSUTF8StringEncoding];
111 | NsOutputFileFullName = [NSString stringWithFormat:@"%@/%@", NsDocuments, NsOutputFileName];
112 | strLen = [NsOutputFileFullName length];
113 | [NsOutputFileFullName getCString:DecFileName maxLength:strLen+1 encoding:NSUTF8StringEncoding];
114 |
115 | uavs3d_argv[j++] = "uavs3d";
116 | uavs3d_argv[j++] = "-i";
117 | uavs3d_argv[j++] = InputFileName;
118 | uavs3d_argv[j++] = "-t";
119 | uavs3d_argv[j++] = THREADS_NUM;
120 | uavs3d_argv[j++] = "-l";
121 | uavs3d_argv[j++] = LOG_LEVEL;
122 | #if ENABLE_MD5_CHECK
123 | uavs3d_argv[j++] = "-s";
124 | uavs3d_argv[j++] = "1";
125 | #endif
126 | #if ENABLE_WRITE_YUV
127 | uavs3d_argv[j++] = "-o";
128 | uavs3d_argv[j++] = DecFileName;
129 | #endif
130 | uavs3d_decode_sample(uavs3d_argc, uavs3d_argv);
131 | }
132 | return 0;
133 | }
134 |
--------------------------------------------------------------------------------
/build/vs2017/common.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 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | {3F9C7116-C287-40D7-865C-D8C89CF4FF31}
64 | Win32Proj
65 | com_lib_vs17
66 | common
67 | 10.0.16299.0
68 |
69 |
70 |
71 | StaticLibrary
72 | true
73 | MultiByte
74 | v141
75 |
76 |
77 | StaticLibrary
78 | true
79 | MultiByte
80 | v141
81 |
82 |
83 | StaticLibrary
84 | false
85 | true
86 | MultiByte
87 | v141
88 |
89 |
90 | StaticLibrary
91 | false
92 | true
93 | MultiByte
94 | v141
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 | ..\..\lib\
114 |
115 |
116 | $(ProjectName)
117 | $(Platform)\$(Configuration)\$(ProjectName)\
118 |
119 |
120 | $(ProjectName)
121 | $(Platform)\$(Configuration)\$(ProjectName)\
122 |
123 |
124 | ..\..\lib\
125 | $(ProjectName)
126 | $(Platform)\$(Configuration)\$(ProjectName)\
127 |
128 |
129 | $(ProjectName)
130 | $(Platform)\$(Configuration)\$(ProjectName)\
131 |
132 |
133 |
134 | NotUsing
135 | Level3
136 | Disabled
137 | WIN64;X86F;_DEBUG;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS
138 | ..\..\source\decore
139 |
140 |
141 |
142 |
143 | CompileAsC
144 | Prompt
145 | $(IntDir)vc$(PlatformToolsetVersion).pdb
146 | MultiThreadedDebug
147 | true
148 | /arch:AVX %(AdditionalOptions)
149 |
150 |
151 | Windows
152 | true
153 |
154 |
155 | ..\..\lib\$(ProjectName).lib
156 |
157 |
158 |
159 |
160 | NotUsing
161 | Level3
162 | Disabled
163 | WIN64;X86F;_DEBUG;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS
164 | ..\..\source\decore
165 |
166 |
167 |
168 |
169 | CompileAsC
170 | Prompt
171 | $(IntDir)vc$(PlatformToolsetVersion).pdb
172 | MultiThreadedDebug
173 | true
174 | /arch:AVX %(AdditionalOptions)
175 |
176 |
177 | Windows
178 | true
179 |
180 |
181 | ..\..\lib\$(ProjectName).lib
182 |
183 |
184 |
185 |
186 | Level3
187 | NotUsing
188 | MaxSpeed
189 | true
190 | true
191 | WIN64;X86F;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions);
192 | ..\..\source\decore
193 | ProgramDatabase
194 |
195 |
196 |
197 |
198 | CompileAsC
199 | Prompt
200 | $(IntDir)vc$(PlatformToolsetVersion).pdb
201 | MultiThreaded
202 | true
203 | /arch:AVX %(AdditionalOptions)
204 |
205 |
206 | Windows
207 | true
208 | true
209 | true
210 |
211 |
212 | ..\..\lib\$(ProjectName).lib
213 |
214 |
215 |
216 |
217 | Level3
218 | NotUsing
219 | MaxSpeed
220 | true
221 | true
222 | WIN64;X86F;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions);
223 | ..\..\source\decore
224 | ProgramDatabase
225 |
226 |
227 |
228 |
229 | CompileAsC
230 | Prompt
231 | $(IntDir)vc$(PlatformToolsetVersion).pdb
232 | MultiThreaded
233 | true
234 | /arch:AVX %(AdditionalOptions)
235 |
236 |
237 | Windows
238 | true
239 | true
240 | true
241 |
242 |
243 | ..\..\lib\$(ProjectName).lib
244 |
245 |
246 |
247 |
248 |
249 |
--------------------------------------------------------------------------------
/build/vs2017/common.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | sse
6 |
7 |
8 | sse
9 |
10 |
11 | sse
12 |
13 |
14 | sse
15 |
16 |
17 | sse
18 |
19 |
20 | sse
21 |
22 |
23 | sse
24 |
25 |
26 | sse
27 |
28 |
29 | avx2
30 |
31 |
32 | avx2
33 |
34 |
35 | avx2
36 |
37 |
38 | avx2
39 |
40 |
41 | avx2
42 |
43 |
44 | avx2
45 |
46 |
47 | avx2
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | sse
65 |
66 |
67 | avx2
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | {340279a0-726f-4160-815c-fd64856b8480}
81 |
82 |
83 | {c020335b-e9c5-4a35-8a21-bb603784d596}
84 |
85 |
86 |
--------------------------------------------------------------------------------
/build/vs2017/libuavs3d.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 | {40B445E8-306A-4C77-9B19-FC76C2379F79}
37 | dec_lib
38 | 10.0.16299.0
39 | libuavs3d
40 |
41 |
42 |
43 | DynamicLibrary
44 | true
45 | v141
46 | MultiByte
47 |
48 |
49 | DynamicLibrary
50 | true
51 | v141
52 | MultiByte
53 |
54 |
55 | DynamicLibrary
56 | false
57 | v141
58 | true
59 | MultiByte
60 |
61 |
62 | DynamicLibrary
63 | false
64 | v141
65 | true
66 | MultiByte
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 | $(Platform)\$(Configuration)\$(ProjectName)\
88 | ..\..\bin
89 | ..\..\lib;$(LibraryPath)
90 |
91 |
92 | ..\..\lib;$(LibraryPath)
93 | $(Platform)\$(Configuration)\$(ProjectName)\
94 |
95 |
96 | $(Platform)\$(Configuration)\$(ProjectName)\
97 | ..\..\bin
98 | ..\..\lib;$(LibraryPath)
99 |
100 |
101 | ..\..\lib;$(LibraryPath)
102 | $(Platform)\$(Configuration)\$(ProjectName)\
103 |
104 |
105 |
106 | Level3
107 | Disabled
108 | true
109 | ..\..\source\decore;..\..\source\decoder
110 | MultiThreadedDebug
111 | $(IntDir)vc$(PlatformToolsetVersion).pdb
112 | WIN64;;%(PreprocessorDefinitions);UAVS3D_EXPORTS;_DEBUG
113 | true
114 | /arch:AVX %(AdditionalOptions)
115 |
116 |
117 | true
118 | common.lib;%(AdditionalDependencies)
119 | NotSet
120 | 1.0
121 |
122 |
123 |
124 |
125 | Level3
126 | Disabled
127 | true
128 | ..\..\source\decore;..\..\source\decoder
129 | MultiThreadedDebug
130 | $(IntDir)vc$(PlatformToolsetVersion).pdb
131 | WIN64;;%(PreprocessorDefinitions);UAVS3D_EXPORTS;_DEBUG
132 | true
133 | /arch:AVX %(AdditionalOptions)
134 |
135 |
136 | true
137 | common.lib;%(AdditionalDependencies)
138 | NotSet
139 | 1.0
140 |
141 |
142 |
143 |
144 | Level3
145 | MaxSpeed
146 | true
147 | true
148 | true
149 | ..\..\source\decore;..\..\source\decoder
150 | MultiThreaded
151 | CompileAsC
152 | $(IntDir)vc$(PlatformToolsetVersion).pdb
153 | WIN64;;%(PreprocessorDefinitions);UAVS3D_EXPORTS;
154 | true
155 | /arch:AVX %(AdditionalOptions)
156 |
157 |
158 | true
159 | true
160 | true
161 | common.lib;%(AdditionalDependencies)
162 | NotSet
163 | 1.0
164 |
165 |
166 |
167 |
168 | Level3
169 | MaxSpeed
170 | true
171 | true
172 | true
173 | ..\..\source\decore;..\..\source\decoder
174 | MultiThreaded
175 | CompileAsC
176 | $(IntDir)vc$(PlatformToolsetVersion).pdb
177 | WIN64;;%(PreprocessorDefinitions);UAVS3D_EXPORTS;
178 | true
179 | /arch:AVX %(AdditionalOptions)
180 |
181 |
182 | true
183 | true
184 | true
185 | common.lib;%(AdditionalDependencies)
186 | NotSet
187 | 1.0
188 |
189 |
190 |
191 |
192 |
193 |
--------------------------------------------------------------------------------
/build/vs2017/uavs3d.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.26228.4
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "common.vcxproj", "{3F9C7116-C287-40D7-865C-D8C89CF4FF31}"
7 | EndProject
8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uavs3d", "uavs3d.vcxproj", "{798F7D68-C94D-41AF-86A4-98F7726D172C}"
9 | ProjectSection(ProjectDependencies) = postProject
10 | {3F9C7116-C287-40D7-865C-D8C89CF4FF31} = {3F9C7116-C287-40D7-865C-D8C89CF4FF31}
11 | {40B445E8-306A-4C77-9B19-FC76C2379F79} = {40B445E8-306A-4C77-9B19-FC76C2379F79}
12 | EndProjectSection
13 | EndProject
14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libuavs3d", "libuavs3d.vcxproj", "{40B445E8-306A-4C77-9B19-FC76C2379F79}"
15 | ProjectSection(ProjectDependencies) = postProject
16 | {3F9C7116-C287-40D7-865C-D8C89CF4FF31} = {3F9C7116-C287-40D7-865C-D8C89CF4FF31}
17 | EndProjectSection
18 | EndProject
19 | Global
20 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
21 | Debug|x64 = Debug|x64
22 | Debug|x86 = Debug|x86
23 | Release|x64 = Release|x64
24 | Release|x86 = Release|x86
25 | EndGlobalSection
26 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
27 | {3F9C7116-C287-40D7-865C-D8C89CF4FF31}.Debug|x64.ActiveCfg = Debug|x64
28 | {3F9C7116-C287-40D7-865C-D8C89CF4FF31}.Debug|x64.Build.0 = Debug|x64
29 | {3F9C7116-C287-40D7-865C-D8C89CF4FF31}.Debug|x86.ActiveCfg = Debug|Win32
30 | {3F9C7116-C287-40D7-865C-D8C89CF4FF31}.Debug|x86.Build.0 = Debug|Win32
31 | {3F9C7116-C287-40D7-865C-D8C89CF4FF31}.Release|x64.ActiveCfg = Release|x64
32 | {3F9C7116-C287-40D7-865C-D8C89CF4FF31}.Release|x64.Build.0 = Release|x64
33 | {3F9C7116-C287-40D7-865C-D8C89CF4FF31}.Release|x86.ActiveCfg = Release|Win32
34 | {3F9C7116-C287-40D7-865C-D8C89CF4FF31}.Release|x86.Build.0 = Release|Win32
35 | {798F7D68-C94D-41AF-86A4-98F7726D172C}.Debug|x64.ActiveCfg = Debug|x64
36 | {798F7D68-C94D-41AF-86A4-98F7726D172C}.Debug|x64.Build.0 = Debug|x64
37 | {798F7D68-C94D-41AF-86A4-98F7726D172C}.Debug|x86.ActiveCfg = Debug|Win32
38 | {798F7D68-C94D-41AF-86A4-98F7726D172C}.Debug|x86.Build.0 = Debug|Win32
39 | {798F7D68-C94D-41AF-86A4-98F7726D172C}.Release|x64.ActiveCfg = Release|x64
40 | {798F7D68-C94D-41AF-86A4-98F7726D172C}.Release|x64.Build.0 = Release|x64
41 | {798F7D68-C94D-41AF-86A4-98F7726D172C}.Release|x86.ActiveCfg = Release|Win32
42 | {798F7D68-C94D-41AF-86A4-98F7726D172C}.Release|x86.Build.0 = Release|Win32
43 | {40B445E8-306A-4C77-9B19-FC76C2379F79}.Debug|x64.ActiveCfg = Debug|x64
44 | {40B445E8-306A-4C77-9B19-FC76C2379F79}.Debug|x64.Build.0 = Debug|x64
45 | {40B445E8-306A-4C77-9B19-FC76C2379F79}.Debug|x86.ActiveCfg = Debug|Win32
46 | {40B445E8-306A-4C77-9B19-FC76C2379F79}.Debug|x86.Build.0 = Debug|Win32
47 | {40B445E8-306A-4C77-9B19-FC76C2379F79}.Release|x64.ActiveCfg = Release|x64
48 | {40B445E8-306A-4C77-9B19-FC76C2379F79}.Release|x64.Build.0 = Release|x64
49 | {40B445E8-306A-4C77-9B19-FC76C2379F79}.Release|x86.ActiveCfg = Release|Win32
50 | {40B445E8-306A-4C77-9B19-FC76C2379F79}.Release|x86.Build.0 = Release|Win32
51 | EndGlobalSection
52 | GlobalSection(SolutionProperties) = preSolution
53 | HideSolutionNode = FALSE
54 | EndGlobalSection
55 | GlobalSection(ExtensibilityGlobals) = postSolution
56 | SolutionGuid = {ED69324B-A55F-49DC-91D3-5F1D34DF875C}
57 | EndGlobalSection
58 | GlobalSection(Performance) = preSolution
59 | HasPerformanceSessions = true
60 | EndGlobalSection
61 | EndGlobal
62 |
--------------------------------------------------------------------------------
/build/vs2017/uavs3d.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 | {798F7D68-C94D-41AF-86A4-98F7726D172C}
23 | Win32Proj
24 | dec_test_vs17
25 | uavs3d
26 | 10.0.16299.0
27 |
28 |
29 |
30 | Application
31 | true
32 | MultiByte
33 | v141
34 |
35 |
36 | Application
37 | true
38 | MultiByte
39 | v141
40 |
41 |
42 | Application
43 | false
44 | true
45 | MultiByte
46 | v141
47 |
48 |
49 | Application
50 | false
51 | true
52 | MultiByte
53 | v141
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 | false
73 | $(Platform)\$(Configuration)\$(ProjectName)\
74 | $(SolutionDir)\..\..\bin
75 |
76 |
77 | false
78 | $(Platform)\$(Configuration)\$(ProjectName)\
79 |
80 |
81 | false
82 | $(Platform)\$(Configuration)\$(ProjectName)\
83 | $(SolutionDir)\..\..\bin
84 |
85 |
86 | false
87 | $(Platform)\$(Configuration)\$(ProjectName)\
88 |
89 |
90 |
91 |
92 |
93 | Level3
94 | Disabled
95 | WIN64;_CONSOLE;%(PreprocessorDefinitions);_DEBUG
96 | ..\..\inc;..\..\src
97 | $(IntDir)vc$(PlatformToolsetVersion).pdb
98 | MultiThreadedDebug
99 | true
100 | /arch:AVX %(AdditionalOptions)
101 |
102 |
103 | Console
104 | true
105 |
106 |
107 | ..\..\lib
108 |
109 |
110 |
111 |
112 |
113 |
114 | Level3
115 | Disabled
116 | WIN64;_CONSOLE;%(PreprocessorDefinitions);_DEBUG
117 | ..\..\inc;..\..\src
118 | $(IntDir)vc$(PlatformToolsetVersion).pdb
119 | MultiThreadedDebug
120 | true
121 | /arch:AVX %(AdditionalOptions)
122 |
123 |
124 | Console
125 | true
126 |
127 |
128 | ..\..\lib
129 |
130 |
131 |
132 |
133 | Level3
134 |
135 |
136 | MaxSpeed
137 | true
138 | true
139 | WIN64;_CONSOLE;%(PreprocessorDefinitions)
140 | ..\..\inc;..\..\src
141 | $(IntDir)vc$(PlatformToolsetVersion).pdb
142 | ProgramDatabase
143 | MultiThreaded
144 | true
145 | /arch:AVX %(AdditionalOptions)
146 |
147 |
148 | Console
149 | true
150 | true
151 | true
152 |
153 |
154 | ..\..\lib
155 |
156 |
157 |
158 |
159 | Level3
160 |
161 |
162 | MaxSpeed
163 | true
164 | true
165 | WIN64;_CONSOLE;%(PreprocessorDefinitions)
166 | ..\..\inc;..\..\src
167 | $(IntDir)vc$(PlatformToolsetVersion).pdb
168 | ProgramDatabase
169 | MultiThreaded
170 | true
171 | /arch:AVX %(AdditionalOptions)
172 |
173 |
174 | Console
175 | true
176 | true
177 | true
178 |
179 |
180 | ..\..\lib
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 | {3f9c7116-c287-40d7-865c-d8c89cf4ff31}
192 |
193 |
194 | {40b445e8-306a-4c77-9b19-fc76c2379f79}
195 |
196 |
197 |
198 |
199 |
200 |
--------------------------------------------------------------------------------
/source/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | set(LIBNAME uavs3d)
3 |
4 | # check cpu
5 | if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AMD64" OR
6 | "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
7 | if(${CMAKE_SIZEOF_VOID_P} EQUAL 4)
8 | set(UAVS3D_TARGET_CPU "x86")
9 | elseif(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
10 | set(UAVS3D_TARGET_CPU "x86_64")
11 | else()
12 | message(FATAL_ERROR
13 | " Unexpected pointer size ${CMAKE_SIZEOF_VOID_P} for ${CMAKE_SYSTEM_PROCESSOR}\n")
14 | endif()
15 | elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i386" OR
16 | "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86")
17 | set(UAVS3D_TARGET_CPU "x86")
18 | elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64" OR
19 | "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm64")
20 | set(UAVS3D_TARGET_CPU "arm64")
21 | elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "^arm")
22 | set(UAVS3D_TARGET_CPU "armv7")
23 | elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "loongarch64")
24 | set(UAVS3D_TARGET_CPU "loongarch64")
25 | else()
26 | message(WARNING "unsupported architecture: ${CMAKE_SYSTEM_PROCESSOR}\n")
27 | set(UAVS3D_TARGET_CPU "generic")
28 | endif()
29 |
30 | # add source
31 | aux_source_directory(./decoder DIR_UAVS3D_SRC)
32 | aux_source_directory(./decore DIR_UAVS3D_CORE)
33 |
34 | list(APPEND DIR_UAVS3D_SRC ${DIR_UAVS3D_CORE})
35 |
36 | include_directories("decore")
37 | set(UAVS3D_ASM_FILES "")
38 |
39 | if("${UAVS3D_TARGET_CPU}" MATCHES "x86" OR
40 | "${UAVS3D_TARGET_CPU}" MATCHES "x86_64")
41 | aux_source_directory(./decore/sse DIR_X86_SRC)
42 | aux_source_directory(./decore/avx2 DIR_X86_256_SRC)
43 | set_source_files_properties(${DIR_X86_SRC} PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
44 | set_source_files_properties(${DIR_X86_256_SRC} PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -mavx2")
45 |
46 | list(APPEND UAVS3D_ASM_FILES ${DIR_X86_SRC})
47 | list(APPEND UAVS3D_ASM_FILES ${DIR_X86_256_SRC})
48 | elseif("${UAVS3D_TARGET_CPU}" MATCHES "armv7")
49 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/armv7.c")
50 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/alf_armv7.S")
51 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/deblock_armv7.S")
52 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/def_armv7.S")
53 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/inter_pred_armv7.S")
54 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/intra_pred_armv7.S")
55 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/dct2_armv7.S")
56 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/itrans_dct8_dst7_armv7.S")
57 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/pixel_armv7.S")
58 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/sao_armv7.c")
59 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/sao_kernel_armv7.S")
60 |
61 | add_definitions(-D _armv7a)
62 | enable_language(ASM)
63 | elseif("${UAVS3D_TARGET_CPU}" MATCHES "arm64")
64 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/arm64.c")
65 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/alf_arm64.S")
66 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/deblock_arm64.S")
67 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/def_arm64.S")
68 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/inter_pred_arm64.S")
69 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/intra_pred_arm64.S")
70 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/intra_pred_chroma_arm64.S")
71 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/itrans_arm64.c")
72 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/itrans_dct2_arm64.S")
73 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/itrans_dct8_dst7_arm64.S")
74 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/pixel_arm64.S")
75 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/sao_arm64.c")
76 | list(APPEND UAVS3D_ASM_FILES "./decore/arm64/sao_kernel_arm64.S")
77 |
78 | add_definitions(-D _arm64)
79 | enable_language(ASM)
80 | elseif("${UAVS3D_TARGET_CPU}" MATCHES "loongarch64")
81 | # loongarch64
82 | endif()
83 |
84 | if(COMPILE_10BIT)
85 | add_definitions(-DCOMPILE_10BIT=1)
86 | message("-- compile 10bit")
87 | else()
88 | add_definitions(-DCOMPILE_10BIT=0)
89 | message("-- compile 8bit")
90 | endif()
91 |
92 | # get version
93 | set (CONFIG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
94 | execute_process(COMMAND sh ${CONFIG_DIR}/version.sh ${CONFIG_DIR})
95 |
96 | function(extract_version_string version_file version_string_out)
97 | file(STRINGS "${version_file}" uavs3d_version REGEX "VERSION_STR")
98 | string(REPLACE "#define VERSION_STR " "" uavs3d_version "${uavs3d_version}")
99 | string(REPLACE "\"" "" uavs3d_version "${uavs3d_version}")
100 | string(REPLACE " " "" uavs3d_version "${uavs3d_version}")
101 | set("${version_string_out}" "${uavs3d_version}" PARENT_SCOPE)
102 | endfunction()
103 |
104 | extract_version_string("${CONFIG_DIR}/version.h" uavs3d_version)
105 | MESSAGE(STATUS "uavs3d version \t\t: ${uavs3d_version}")
106 |
107 | MESSAGE(STATUS "Target CPU\t\t\t: ${UAVS3D_TARGET_CPU}")
108 | # pkg-config
109 | find_package(Threads REQUIRED)
110 | set(prefix "${CMAKE_INSTALL_PREFIX}")
111 | set(includedir "include")
112 | set(libdir "lib")
113 | set(pc_file "${CONFIG_DIR}/${LIBNAME}.pc")
114 |
115 | set(CMAKE_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/${includedir}")
116 | set(CMAKE_INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/${libdir}")
117 | set(CMAKE_INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_LIB_DIR}/pkgconfig")
118 | MESSAGE(STATUS "INSTALL_INCLUDE_DIR \t\t: ${CMAKE_INSTALL_INCLUDE_DIR}")
119 | MESSAGE(STATUS "INSTALL_LIB_DIR \t\t: ${CMAKE_INSTALL_LIB_DIR}")
120 | MESSAGE(STATUS "INSTALL_PKGCONFIG_DIR\t: ${CMAKE_INSTALL_PKGCONFIG_DIR}")
121 | # write pkg-config file
122 | file(WRITE "${pc_file}" "prefix=${prefix}\n")
123 | file(APPEND "${pc_file}" "exec_prefix=\${prefix}\n")
124 | file(APPEND "${pc_file}" "includedir=\${prefix}/${includedir}\n")
125 | file(APPEND "${pc_file}" "libdir=\${exec_prefix}/${libdir}\n\n")
126 | file(APPEND "${pc_file}" "Name: ${LIBNAME}\n")
127 | file(APPEND "${pc_file}" "Description: AVS3 decoder library \n")
128 | file(APPEND "${pc_file}" "Version: ${uavs3d_version}\n")
129 | if(CMAKE_USE_PTHREADS_INIT)
130 | file(APPEND "${pc_file}" "Libs: -L\${libdir} -l${LIBNAME} -lm -lpthread\n")
131 | else()
132 | file(APPEND "${pc_file}" "Libs: -L\${libdir} -l${LIBNAME} -lm\n")
133 | file(APPEND "${pc_file}" "Libs.private: \n")
134 | endif()
135 | file(APPEND "${pc_file}" "Cflags: -I\${includedir}\n")
136 |
137 | # set library
138 | if(BUILD_SHARED_LIBS)
139 | MESSAGE(STATUS "BUILD_SHARED_LIBS \t\t: true")
140 | else()
141 | MESSAGE(STATUS "BUILD_SHARED_LIBS \t\t: false")
142 | endif()
143 | add_library(${LIBNAME} ${DIR_UAVS3D_SRC} ${UAVS3D_ASM_FILES})
144 |
145 | if (NOT MSVC)
146 | target_link_libraries(${LIBNAME} m)
147 | endif()
148 | if(CMAKE_USE_PTHREADS_INIT)
149 | target_link_libraries(${LIBNAME} pthread)
150 | endif()
151 |
152 | # install
153 | install(TARGETS uavs3d LIBRARY DESTINATION ${CMAKE_INSTALL_LIB_DIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIB_DIR})
154 | install(FILES decoder/uavs3d.h DESTINATION ${CMAKE_INSTALL_INCLUDE_DIR})
155 | install(FILES ${CONFIG_DIR}/${LIBNAME}.pc DESTINATION ${CMAKE_INSTALL_PKGCONFIG_DIR})
156 |
--------------------------------------------------------------------------------
/source/decoder/bitstream.c:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * Copyright (c) 2018-2022 ["Peking University Shenzhen Graduate School",
3 | * "Peng Cheng Laboratory", and "Guangdong Bohua UHD Innovation Corporation"]
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the organizations (Peking University Shenzhen Graduate School,
15 | * Peng Cheng Laboratory and Guangdong Bohua UHD Innovation Corporation) nor the
16 | * names of its contributors may be used to endorse or promote products
17 | * derived from this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | * For more information, contact us at rgwang@pkusz.edu.cn.
31 | **************************************************************************************/
32 |
33 | #include "dec_type.h"
34 |
35 | static tab_u8 tbl_zero_count4[16] =
36 | {
37 | 4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0
38 | };
39 |
40 | void dec_bs_init(com_bs_t * bs, u8 * buf, int size)
41 | {
42 | bs->cur = buf;
43 | bs->end = buf + size - 1;
44 | bs->code = 0;
45 | bs->leftbits = 0;
46 | }
47 |
48 | static int dec_bs_read_bytes(com_bs_t * bs, int byte)
49 | {
50 | int shift = 24;
51 | u32 code = 0;
52 | int remained = (int)(bs->end - bs->cur) + 1;
53 |
54 | if (byte > remained) {
55 | if (remained <= 0) {
56 | return -1;
57 | }
58 | byte = remained;
59 | }
60 | bs->leftbits = byte << 3;
61 | bs->cur += byte;
62 |
63 | while (byte) {
64 | #if CHECK_RAND_STRM
65 | if (rand() % 100 == 0) {
66 | code |= (rand() & 0xFF) << shift;
67 | } else {
68 | code |= *(bs->cur - byte) << shift;
69 | }
70 | #else
71 | code |= *(bs->cur - byte) << shift;
72 | #endif
73 | byte--;
74 | shift -= 8;
75 | }
76 | bs->code = code;
77 | return 0;
78 | }
79 |
80 | u32 dec_bs_read(com_bs_t * bs, int bits, u32 min, u32 max)
81 | {
82 | u32 code = 0;
83 |
84 | if (bs->leftbits < bits) {
85 | code = bs->code >> (32 - bits);
86 | bits -= bs->leftbits;
87 | if (dec_bs_read_bytes(bs, 4)) {
88 | return min;
89 | }
90 | }
91 | code |= bs->code >> (32 - bits);
92 |
93 | bs->code <<= bits;
94 | bs->leftbits -= bits;
95 |
96 | if (code < min || code > max) {
97 | uavs3d_assert(0);
98 | code = min;
99 | }
100 |
101 | return code;
102 | }
103 |
104 | int dec_bs_read1(com_bs_t * bs, int val)
105 | {
106 | int code;
107 | if (bs->leftbits == 0) {
108 | if (dec_bs_read_bytes(bs, 4)) {
109 | return 0;
110 | }
111 | }
112 | code = (int)(bs->code >> 31);
113 | bs->code <<= 1;
114 | bs->leftbits -= 1;
115 |
116 | if (val != -1 && code != val) {
117 | uavs3d_assert(0);
118 | code = val;
119 | }
120 |
121 | return code;
122 | }
123 |
124 | static int dec_bs_clz_in_code(u32 code)
125 | {
126 | if (code == 0) {
127 | return 32; /* protect infinite loop */
128 | }
129 |
130 | int bits4 = 0;
131 | int clz = 0;
132 | int shift = 28;
133 |
134 | while (bits4 == 0 && shift >= 0) {
135 | bits4 = (code >> shift) & 0xf;
136 | clz += tbl_zero_count4[bits4];
137 | shift -= 4;
138 | }
139 | return clz;
140 | }
141 |
142 | u32 dec_bs_read_ue(com_bs_t * bs, u32 min, u32 max)
143 | {
144 | if ((bs->code >> 31) == 1) {
145 | bs->code <<= 1;
146 | bs->leftbits -= 1;
147 | return 0;
148 | }
149 |
150 | int clz = 0;
151 | if (bs->code == 0) {
152 | clz = bs->leftbits;
153 | if (dec_bs_read_bytes(bs, 4)) {
154 | return min;
155 | }
156 | }
157 |
158 | int len = dec_bs_clz_in_code(bs->code);
159 | clz += len;
160 |
161 | if (clz == 0) {
162 | bs->code <<= 1;
163 | bs->leftbits--;
164 | return 0;
165 | }
166 |
167 | u32 code = dec_bs_read(bs, len + clz + 1, 0, COM_UINT32_MAX) - 1;
168 |
169 | if (code < min || code > max) {
170 | uavs3d_assert(0);
171 | code = min;
172 | }
173 |
174 | return code;
175 | }
176 |
177 | int dec_bs_read_se(com_bs_t * bs, int min, int max)
178 | {
179 | int val;
180 | int code;
181 |
182 | val = dec_bs_read_ue(bs, 0, COM_UINT32_MAX);
183 | code = ((val & 0x01) ? ((val + 1) >> 1) : -(val >> 1));
184 |
185 | if (code < min || code > max) {
186 | uavs3d_assert(0);
187 | code = min;
188 | }
189 |
190 | return code;
191 | }
192 |
193 | u32 dec_bs_next(com_bs_t * bs, int size)
194 | {
195 | u32 code = 0;
196 | int shift = 24;
197 | u32 newcode = 0;
198 | int byte = 4;
199 | u8* cur = bs->cur;
200 |
201 | if (bs->leftbits < size) {
202 | code = bs->code >> (32 - size);
203 | size -= bs->leftbits;
204 | int remained = (int)(bs->end - bs->cur) + 1;
205 |
206 | if (byte > remained) {
207 | byte = remained;
208 | }
209 |
210 | cur += byte;
211 | while (byte) {
212 | newcode |= *(cur - byte) << shift;
213 | byte--;
214 | shift -= 8;
215 | }
216 | } else {
217 | newcode = bs->code;
218 | }
219 | code |= newcode >> (32 - size);
220 |
221 | return code;
222 | }
223 |
224 | static uavs3d_always_inline int dec_bs_find_start_code(const u8 *src, int length, int *left)
225 | {
226 | int i;
227 |
228 | #define FIND_FIRST_ZERO \
229 | if (i > 0 && !src[i]) i--; \
230 | while (src[i]) i++
231 |
232 | #define AV_RN32A(x) (*(unsigned int*)(x))
233 |
234 | for (i = 0; i + 1 < length; i += 5) {
235 | if (!((~AV_RN32A(src + i) & (AV_RN32A(src + i) - 0x01000101U)) & 0x80008080U)) {
236 | continue;
237 | }
238 | FIND_FIRST_ZERO;
239 |
240 | if (i + 3 < length && src[i + 1] == 0 && src[i + 2] == 1) {
241 | *left = length - i;
242 | return 1;
243 | }
244 | i -= 3;
245 | }
246 | return 0;
247 | }
248 |
249 | u8* dec_bs_demulate(u8 *start, u8 *end)
250 | {
251 | int i;
252 | int len = (int)(end - start);
253 | int prev_bytes = 0;
254 | u8 *d, *s;
255 | int bit_pos;
256 | int left_bits;
257 |
258 | #define DEMU_FIND_FIRST_ZERO \
259 | if (i > 0 && !start[i]) i--; \
260 | while (start[i]) i++
261 |
262 | // look for the first emulate code
263 | for (i = 0; i + 1 < len; i += 5) {
264 | if (!((~AV_RN32A(start + i) & (AV_RN32A(start + i) - 0x01000101U)) & 0x80008080U)) {
265 | continue;
266 | }
267 | DEMU_FIND_FIRST_ZERO;
268 |
269 | if (i + 3 < len && start[i + 1] == 0 && start[i + 2] == 2) {
270 | break;
271 | }
272 | i -= 3;
273 | }
274 |
275 | if (i + 1 >= len) {
276 | return end;
277 | }
278 |
279 | d = s = start + i;
280 | left_bits = (len - i) * 8;
281 | bit_pos = 0;
282 |
283 | for (i = 0; i < left_bits; i += 8) {
284 | u8 val = *s++;
285 | prev_bytes = ((prev_bytes << 8) | val) & 0xffffff;
286 |
287 | if (prev_bytes != 2) {
288 | *d++ = (val << bit_pos) | ((*s) >> (8 - bit_pos));
289 | }
290 | else {
291 | val = 0;
292 | bit_pos += 2;
293 |
294 | if (bit_pos == 8) {
295 | val = *s++;
296 | *d++ = val;
297 | prev_bytes = ((prev_bytes << 8) | val) & 0xffffff;
298 | bit_pos = 0;
299 | }
300 | else {
301 | *d++ = (*s) >> (8 - bit_pos);
302 | }
303 | }
304 | }
305 |
306 | return d;
307 | }
308 |
309 | u8* dec_bs_get_one_unit(com_bs_t *bs, u8 **next_start)
310 | {
311 | u8 *start = bs->cur;
312 | u8 *end = bs->end + 1;
313 | int len = (int)(end - start);
314 | int left_bytes;
315 |
316 | if (dec_bs_find_start_code(start + 4, len - 4, &left_bytes)) {
317 | end = start + len - left_bytes;
318 | }
319 |
320 | *next_start = end;
321 |
322 | return dec_bs_demulate(start - 1, end);
323 | }
324 |
--------------------------------------------------------------------------------
/source/decoder/bitstream.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * Copyright (c) 2018-2022 ["Peking University Shenzhen Graduate School",
3 | * "Peng Cheng Laboratory", and "Guangdong Bohua UHD Innovation Corporation"]
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the organizations (Peking University Shenzhen Graduate School,
15 | * Peng Cheng Laboratory and Guangdong Bohua UHD Innovation Corporation) nor the
16 | * names of its contributors may be used to endorse or promote products
17 | * derived from this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | * For more information, contact us at rgwang@pkusz.edu.cn.
31 | **************************************************************************************/
32 |
33 | #ifndef __BITSTREAM_H__
34 | #define __BITSTREAM_H__
35 |
36 | #include "com_type.h"
37 |
38 | #define DEC_BS_IS_ALIGN(bs) (!((bs)->leftbits & 0x7))
39 |
40 | void dec_bs_init (com_bs_t * bs, u8 * buf, int size);
41 | u32 dec_bs_read (com_bs_t * bs, int size, u32 min, u32 max);
42 | u32 dec_bs_next (com_bs_t * bs, int size);
43 | int dec_bs_read1 (com_bs_t * bs, int val);
44 | u32 dec_bs_read_ue (com_bs_t * bs, u32 min, u32 max);
45 | int dec_bs_read_se (com_bs_t * bs, int min, int max);
46 | u8* dec_bs_get_one_unit (com_bs_t * bs, u8 **next_start);
47 |
48 | u8* dec_bs_demulate(u8 *start, u8 *end);
49 |
50 | #endif /* __BITSTREAM_H__ */
51 |
--------------------------------------------------------------------------------
/source/decoder/dec_type.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * Copyright (c) 2018-2022 ["Peking University Shenzhen Graduate School",
3 | * "Peng Cheng Laboratory", and "Guangdong Bohua UHD Innovation Corporation"]
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the organizations (Peking University Shenzhen Graduate School,
15 | * Peng Cheng Laboratory and Guangdong Bohua UHD Innovation Corporation) nor the
16 | * names of its contributors may be used to endorse or promote products
17 | * derived from this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | * For more information, contact us at rgwang@pkusz.edu.cn.
31 | **************************************************************************************/
32 |
33 | #ifndef __DEC_TYPE_H__
34 | #define __DEC_TYPE_H__
35 |
36 | #include "modules.h"
37 | #include "uavs3d.h"
38 | #include "bitstream.h"
39 |
40 | #define SPLIT_MAX_PART_COUNT 4
41 |
42 | typedef struct uavs3d_dec_split_info_t {
43 | int part_count;
44 | int width[SPLIT_MAX_PART_COUNT];
45 | int height[SPLIT_MAX_PART_COUNT];
46 | int log_cuw[SPLIT_MAX_PART_COUNT];
47 | int log_cuh[SPLIT_MAX_PART_COUNT];
48 | int x_pos[SPLIT_MAX_PART_COUNT];
49 | int y_pos[SPLIT_MAX_PART_COUNT];
50 | } dec_split_info_t;
51 |
52 | typedef struct uavs3d_dec_t {
53 | u8 init_flag;
54 |
55 | /* Senquence Level Shared Data */
56 | com_seqh_t seqhdr;
57 | u8 *alf_idx_map;
58 |
59 | uavs3d_cfg_t dec_cfg;
60 |
61 | /* CORE data for pic decode, only used in single thread */
62 | com_core_t *core;
63 |
64 | int frm_nodes;
65 | int frm_node_start;
66 | int frm_node_end;
67 | com_frm_t *frm_nodes_list;
68 |
69 | /* current decoding bitstream */
70 | com_bs_t bs;
71 |
72 | /* Reference Frame Management */
73 | com_pic_manager_t pic_manager;
74 | int cur_decoded_doi;
75 | int output;
76 |
77 | /* Frame Level Parallel */
78 | threadpool_t *frm_threads_pool;
79 | int frm_threads_nodes;
80 |
81 | void *callback;
82 | } uavs3d_dec_t;
83 |
84 |
85 | #include "dec_util.h"
86 | #include "parser.h"
87 |
88 | #endif /* __DEC_DEF_H__ */
89 |
--------------------------------------------------------------------------------
/source/decoder/dec_util.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * Copyright (c) 2018-2022 ["Peking University Shenzhen Graduate School",
3 | * "Peng Cheng Laboratory", and "Guangdong Bohua UHD Innovation Corporation"]
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the organizations (Peking University Shenzhen Graduate School,
15 | * Peng Cheng Laboratory and Guangdong Bohua UHD Innovation Corporation) nor the
16 | * names of its contributors may be used to endorse or promote products
17 | * derived from this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | * For more information, contact us at rgwang@pkusz.edu.cn.
31 | **************************************************************************************/
32 |
33 | #ifndef __DEC_UTIL_H__
34 | #define __DEC_UTIL_H__
35 |
36 | #include "com_type.h"
37 |
38 | int dec_check_pic_md5(com_pic_t * pic, u8 md5_buf[16]);
39 |
40 | void dec_update_map (com_core_t * core);
41 | void dec_update_map_for_intra (com_scu_t *map_scu, s8 *map_ipm, int tb_x, int tb_y, int tb_w, int tb_h, int i_scu, int ipm);
42 |
43 | void dec_derive_mvp (com_core_t *core, int ref_list, int emvp_flag, int mvr_idx, s16 mvp[MV_D]);
44 | void dec_derive_skip_mv (com_core_t * core, int spatial_skip_idx);
45 | void dec_derive_skip_mv_affine (com_core_t * core, int mrg_idx);
46 | void dec_derive_skip_mv_umve (com_core_t * core, int umve_idx);
47 |
48 | void dec_scale_affine_mvp (com_core_t *core, int lidx, CPMV mvp[VER_NUM][MV_D], u8 curr_mvr);
49 | void update_hmvp_candidates (com_core_t *core);
50 |
51 |
52 | static u16 uavs3d_always_inline dec_get_avail_intra(int i_scu, int scup, com_scu_t * map_scu)
53 | {
54 | return (map_scu[scup - 1].coded << AVAIL_BIT_LE) |
55 | (map_scu[scup - i_scu ].coded << AVAIL_BIT_UP) |
56 | (map_scu[scup - i_scu - 1].coded << AVAIL_BIT_UL);
57 | }
58 |
59 | void dec_get_split_struct(int split_mode, int x0, int y0, int cu_width, int cu_height, dec_split_info_t* split_struct);
60 | int dec_get_split_available(com_seqh_t* seqhdr, int x, int y, int cu_w, int cu_h, int qt_depth, int bet_depth, int slice_type);
61 |
62 | void dec_get_part_info(com_core_t *core, com_part_info_t* sub_info);
63 | #define dec_get_part_num(size) (g_tbl_part_num[size])
64 | #define dec_get_tb_part_size_by_pb(pb_part) (g_tbl_tb_part[pb_part])
65 | int dec_get_pb_idx_by_tb(com_part_size_t pb_part, int idx);
66 | void dec_get_tb_width_height(int w, int h, com_part_size_t part, int *tb_w, int *tb_h);
67 | void dec_get_tb_start_pos(int w, int h, com_part_size_t part, int idx, int *pos_x, int *pos_y);
68 |
69 | u8 dec_is_separate_tree(int w, int h, com_split_mode_t split);
70 | int dec_dt_allow(int cu_w, int cu_h, int pred_mode, int max_dt_size);
71 | u8 dec_cons_allow(int w, int h, com_split_mode_t split);
72 |
73 |
74 | #endif /* __DEC_UTIL_H__ */
75 |
--------------------------------------------------------------------------------
/source/decoder/parser.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * Copyright (c) 2018-2022 ["Peking University Shenzhen Graduate School",
3 | * "Peng Cheng Laboratory", and "Guangdong Bohua UHD Innovation Corporation"]
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the organizations (Peking University Shenzhen Graduate School,
15 | * Peng Cheng Laboratory and Guangdong Bohua UHD Innovation Corporation) nor the
16 | * names of its contributors may be used to endorse or promote products
17 | * derived from this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | * For more information, contact us at rgwang@pkusz.edu.cn.
31 | **************************************************************************************/
32 |
33 | #ifndef __PARSER_H__
34 | #define __PARSER_H__
35 |
36 | #include "dec_type.h"
37 |
38 | void lbac_init (com_lbac_t *lbac, u8 *cur, u8* end);
39 | int lbac_dec_bin_trm (com_lbac_t *lbac);
40 |
41 | int dec_parse_sqh (com_bs_t * bs, com_seqh_t * seqhdr);
42 | int dec_parse_pic_header (com_bs_t * bs, com_pic_header_t * pichdr, com_seqh_t * seqhdr, com_pic_manager_t *pm);
43 | int dec_parse_patch_header (com_bs_t * bs, com_seqh_t *seqhdr, com_pic_header_t * ph, com_patch_header_t * pichdr);
44 | int dec_parse_patch_end (com_bs_t * bs);
45 | int dec_parse_ext_and_usr_data (com_bs_t * bs, com_seqh_t *seqhdr, com_pic_header_t * pichdr, int i, int slicetype);
46 |
47 | int dec_parse_lcu_delta_qp (com_lbac_t * lbac, int last_dqp);
48 | void dec_parse_sao_param (com_core_t* core, int lcu_idx, com_sao_param_t *sao_cur_param);
49 | u32 dec_parse_alf_enable (com_lbac_t * lbac, int compIdx);
50 |
51 | s8 dec_parse_split_mode (com_core_t *core, com_lbac_t *lbac, int split_tab, int cu_width, int cu_height, int qt_depth, int bet_depth);
52 | u8 dec_parse_cons_pred_mode_child (com_lbac_t * lbac);
53 |
54 | int dec_parse_cu_header (com_core_t * core);
55 | int dec_parse_cu_header_chroma (com_core_t * core);
56 | int dec_parse_run_length_cc (com_core_t *core, s16 *coef, int log2_w, int log2_h, int ch_type);
57 | void dec_parse_ipcm_start (com_lbac_t *lbac);
58 | int dec_parse_ipcm (com_lbac_t *lbac, int *bit_left, int bits);
59 |
60 | #endif /* __PARSER_H__ */
61 |
--------------------------------------------------------------------------------
/source/decoder/uavs3d.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * Copyright (c) 2018-2022 ["Peking University Shenzhen Graduate School",
3 | * "Peng Cheng Laboratory", and "Guangdong Bohua UHD Innovation Corporation"]
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the organizations (Peking University Shenzhen Graduate School,
15 | * Peng Cheng Laboratory and Guangdong Bohua UHD Innovation Corporation) nor the
16 | * names of its contributors may be used to endorse or promote products
17 | * derived from this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | * For more information, contact us at rgwang@pkusz.edu.cn.
31 | **************************************************************************************/
32 |
33 | #ifndef __UAVS3D_H__
34 | #define __UAVS3D_H__
35 |
36 | #ifdef __cplusplus
37 | extern "C"
38 | {
39 | #endif
40 |
41 | #if defined(_WIN32) && !defined(__GNUC__)
42 |
43 | #ifdef UAVS3D_EXPORTS
44 | #define AVS3D_API __declspec(dllexport)
45 | #else
46 | #define AVS3D_API __declspec(dllimport)
47 | #endif
48 |
49 | #else
50 |
51 | #define AVS3D_API
52 | #define __cdecl
53 |
54 | #endif
55 |
56 | typedef struct
57 | {
58 | const char* input_file;
59 | const char* output_file;
60 | int frm_threads;
61 | int dec_frames;
62 | int log_level;
63 | int check_md5;
64 | }uavs3d_cfg_t;
65 |
66 | /*****************************************************************************
67 | * return values and error code
68 | *****************************************************************************/
69 | #define RET_OK 0
70 | #define RET_DELAYED 1
71 | #define RET_SEQ_END 2
72 |
73 | #define ERR_OUT_OF_MEMORY (-1)
74 | #define ERR_UNEXPECTED (-2)
75 | #define ERR_BAD_BITDEPTH (-3)
76 | #define ERR_UNKNOWN_NAL (-4)
77 | #define ERR_LOSS_REF_FRAME (-5)
78 | #define ERR_PIC_HEADER_UNREADY (-6)
79 | #define ERR_SEQ_HEADER_UNREADY (-7)
80 | #define ERR_SEQ_MAININFO_CHANGED (-8)
81 | #define ERR_PIC_BUFFER_FULL (-9)
82 |
83 | #define ERR_UNKNOWN (-100)
84 |
85 | /*****************************************************************************
86 | * nal type
87 | *****************************************************************************/
88 | #define NAL_PIC_HEADER 1
89 | #define NAL_SEQ_HEADER 2
90 | #define NAL_SLICE 3
91 | #define NAL_SEQ_END 7
92 |
93 | /*****************************************************************************
94 | * slice type
95 | *****************************************************************************/
96 | #define SLICE_I 1
97 | #define SLICE_P 2
98 | #define SLICE_B 3
99 |
100 | /*****************************************************************************
101 | * RPL structreu
102 | *****************************************************************************/
103 |
104 | #define MAX_RPLS 32
105 | #define MAX_REFS 17
106 |
107 | typedef struct uavs3d_com_rpl_t {
108 | int num;
109 | int active;
110 | int delta_doi[MAX_REFS];
111 | } com_rpl_t;
112 |
113 | /*****************************************************************************
114 | * sequence header
115 | *****************************************************************************/
116 |
117 | typedef struct uavs3d_com_seqh_t {
118 | unsigned char profile_id; /* 8 bits */
119 | unsigned char level_id; /* 8 bits */
120 | unsigned char progressive_sequence; /* 1 bit */
121 | unsigned char field_coded_sequence; /* 1 bit */
122 | unsigned char chroma_format; /* 2 bits */
123 | unsigned char encoding_precision; /* 3 bits */
124 | unsigned char output_reorder_delay; /* 5 bits */
125 | unsigned char sample_precision; /* 3 bits */
126 | unsigned char aspect_ratio; /* 4 bits */
127 | unsigned char frame_rate_code; /* 4 bits */
128 | unsigned int bit_rate_lower; /* 18 bits */
129 | unsigned int bit_rate_upper; /* 18 bits */
130 | unsigned char low_delay; /* 1 bit */
131 | unsigned char temporal_id_enable_flag; /* 1 bit */
132 | unsigned int bbv_buffer_size; /* 18 bits */
133 | int horizontal_size; /* 14 bits */
134 | int vertical_size; /* 14 bits */
135 | int display_horizontal_size; /* 14 bits */
136 | int display_vertical_size; /* 14 bits */
137 |
138 | unsigned char log2_max_cu_width_height; /* 3 bits */
139 | unsigned char min_cu_size;
140 | unsigned char max_part_ratio_log2;
141 | unsigned char max_split_times;
142 | unsigned char min_qt_size;
143 | unsigned char max_bt_size;
144 | unsigned char max_eqt_size;
145 | unsigned char max_dt_size;
146 |
147 | int rpl1_index_exist_flag;
148 | int rpl1_same_as_rpl0_flag;
149 | com_rpl_t rpls_l0[MAX_RPLS];
150 | com_rpl_t rpls_l1[MAX_RPLS];
151 | int rpls_l0_num;
152 | int rpls_l1_num;
153 | int num_ref_default_active_minus1[2];
154 | int max_dpb_size;
155 | int ipcm_enable_flag;
156 | unsigned char amvr_enable_flag;
157 | int umve_enable_flag;
158 | int ipf_enable_flag;
159 | int emvr_enable_flag;
160 | unsigned char affine_enable_flag;
161 | unsigned char smvd_enable_flag;
162 | unsigned char dt_intra_enable_flag;
163 | unsigned char num_of_hmvp_cand;
164 | unsigned char tscpm_enable_flag;
165 | unsigned char sample_adaptive_offset_enable_flag;
166 | unsigned char adaptive_leveling_filter_enable_flag;
167 | unsigned char secondary_transform_enable_flag;
168 | unsigned char position_based_transform_enable_flag;
169 |
170 | unsigned char wq_enable;
171 | unsigned char seq_wq_mode;
172 | unsigned char wq_4x4_matrix[16];
173 | unsigned char wq_8x8_matrix[64];
174 |
175 | unsigned char patch_stable;
176 | unsigned char cross_patch_loop_filter;
177 | unsigned char patch_ref_colocated;
178 | unsigned char patch_uniform;
179 | unsigned char patch_width;
180 | unsigned char patch_height;
181 |
182 | /**********************************************************************/
183 | /*** Extension info ***/
184 |
185 | int pic_width; /* decoding picture width */
186 | int pic_height; /* decoding picture height */
187 | int max_cuwh; /* maximum CU width and height */
188 | int log2_max_cuwh; /* log2 of maximum CU width and height */
189 |
190 | int pic_width_in_lcu;
191 | int pic_height_in_lcu;
192 | int f_lcu; // = pic_width_in_lcu * pic_height_in_lcu
193 |
194 | int pic_width_in_scu;
195 | int pic_height_in_scu;
196 | int i_scu; // stride of scu data, = pic_width_in_scu + 2
197 | int f_scu; // total scu data size, = i_scu * (pic_height_in_scu + 2)
198 | int a_scu; // actual scu data size, = i_scu * pic_height_in_scu
199 |
200 | int bit_depth_internal;
201 | int bit_depth_input;
202 | int bit_depth_2_qp_offset;
203 |
204 | /* patch size */
205 | int patch_columns;
206 | int patch_rows;
207 | int patch_column_width[64];
208 | int patch_row_height[128];
209 |
210 | /* alf map */
211 | unsigned char *alf_idx_map;
212 |
213 | /* hdr info */
214 | unsigned char colour_description;
215 | unsigned char colour_primaries;
216 | unsigned char transfer_characteristics;
217 | unsigned char matrix_coefficients;
218 |
219 | } com_seqh_t;
220 |
221 | #define FRAME_MAX_PLANES 3
222 | typedef struct uavs3d_io_frm_t {
223 | void * priv;
224 | int got_pic;
225 | int num_plane; /* number of planes */
226 | int bit_depth; /* bit depth */
227 | int width[FRAME_MAX_PLANES]; /* width (in unit of pixel) */
228 | int height[FRAME_MAX_PLANES]; /* height (in unit of pixel) */
229 | int stride[FRAME_MAX_PLANES]; /* buffer stride (in unit of byte) */
230 | void * buffer[FRAME_MAX_PLANES]; /* address of each plane */
231 |
232 | /* frame info */
233 | long long ptr;
234 | long long pts;
235 | long long dtr;
236 | long long dts;
237 | int type;
238 | int refpic_num[2];
239 | long long refpic[2][16];
240 |
241 | long long pkt_pos;
242 | int pkt_size;
243 |
244 | /* bitstream */
245 | unsigned char *bs;
246 | int bs_len;
247 |
248 | int nal_type;
249 |
250 | com_seqh_t *seqhdr;
251 | } uavs3d_io_frm_t;
252 |
253 | typedef void(__cdecl *uavs3d_lib_output_callback_t)(uavs3d_io_frm_t *frm);
254 |
255 | typedef void* (__cdecl *uavs3d_create_t )(uavs3d_cfg_t * dec_cfg, uavs3d_lib_output_callback_t callback, int * err);
256 | AVS3D_API void* __cdecl uavs3d_create (uavs3d_cfg_t * dec_cfg, uavs3d_lib_output_callback_t callback, int * err);
257 |
258 | typedef void (__cdecl *uavs3d_delete_t )(void *h);
259 | AVS3D_API void __cdecl uavs3d_delete (void *h);
260 |
261 | typedef void (__cdecl *uavs3d_reset_t )(void *h);
262 | AVS3D_API void __cdecl uavs3d_reset (void *h);
263 |
264 | typedef int (__cdecl *uavs3d_flush_t )(void *h, uavs3d_io_frm_t* frm);
265 | AVS3D_API int __cdecl uavs3d_flush (void *h, uavs3d_io_frm_t* frm);
266 |
267 | typedef int (__cdecl *uavs3d_decode_t )(void *h, uavs3d_io_frm_t* frm);
268 | AVS3D_API int __cdecl uavs3d_decode (void *h, uavs3d_io_frm_t* frm);
269 |
270 | typedef void (__cdecl *uavs3d_img_cpy_cvt_t)(uavs3d_io_frm_t * dst, uavs3d_io_frm_t * src, int bit_depth);
271 | AVS3D_API void __cdecl uavs3d_img_cpy_cvt (uavs3d_io_frm_t * dst, uavs3d_io_frm_t * src, int bit_depth);
272 |
273 |
274 |
275 | #ifdef __cplusplus
276 | }
277 | #endif
278 |
279 | #endif //#ifndef __UAVS3D_H__
280 |
--------------------------------------------------------------------------------
/source/decore/arm64/def_arm64.S:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * Copyright (c) 2018-2022 ["Peking University Shenzhen Graduate School",
3 | * "Peng Cheng Laboratory", and "Guangdong Bohua UHD Innovation Corporation"]
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the organizations (Peking University Shenzhen Graduate School,
15 | * Peng Cheng Laboratory and Guangdong Bohua UHD Innovation Corporation) nor the
16 | * names of its contributors may be used to endorse or promote products
17 | * derived from this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | * For more information, contact us at rgwang@pkusz.edu.cn.
31 | **************************************************************************************/
32 |
33 | #if defined(__aarch64__) && !defined(__arm64__)
34 | #define __arm64__ 1
35 | #endif
36 |
37 | #if defined(__APPLE__)
38 | .macro function name
39 | .text
40 | .align 4
41 | .global _\name
42 | _\name:
43 | .endm
44 | #else
45 | .macro function name
46 | .text
47 | .align 4
48 | .global \name
49 | .type \name, %function
50 | \name:
51 | .endm
52 | #endif
53 |
--------------------------------------------------------------------------------
/source/decore/arm64/itrans_arm64.c:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * Copyright (c) 2018-2022 ["Peking University Shenzhen Graduate School",
3 | * "Peng Cheng Laboratory", and "Guangdong Bohua UHD Innovation Corporation"]
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the organizations (Peking University Shenzhen Graduate School,
15 | * Peng Cheng Laboratory and Guangdong Bohua UHD Innovation Corporation) nor the
16 | * names of its contributors may be used to endorse or promote products
17 | * derived from this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | * For more information, contact us at rgwang@pkusz.edu.cn.
31 | **************************************************************************************/
32 |
33 | #include "arm64.h"
34 | #if defined(__arm64__)
35 | #include "itrans_arm64.h"
36 |
37 |
38 | void uavs3d_itrans_dct2_h4_w8_arm64(s16 *src, s16 *dst, int bit_depth)
39 | {
40 | ALIGNED_16(s16 tmp[4*8]);
41 | dct2_butterfly_h4_arm64(src, tmp, 8, 5, MAX_TX_DYNAMIC_RANGE);
42 | dct2_butterfly_h8_arm64(tmp, 4, dst, 4, 20 - bit_depth, bit_depth);
43 | }
44 |
45 | void uavs3d_itrans_dct2_h4_w16_arm64(s16 *src, s16 *dst, int bit_depth)
46 | {
47 | ALIGNED_16(s16 tmp[4*16]);
48 | dct2_butterfly_h4_arm64(src, tmp, 16, 5, MAX_TX_DYNAMIC_RANGE);
49 | dct2_butterfly_h16_arm64(tmp, 4, dst, 4, 20 - bit_depth, bit_depth);
50 | }
51 |
52 | void uavs3d_itrans_dct2_h4_w32_arm64(s16 *src, s16 *dst, int bit_depth)
53 | {
54 | ALIGNED_16(s16 tmp[4*32]);
55 | dct2_butterfly_h4_arm64(src, tmp, 32, 5, MAX_TX_DYNAMIC_RANGE);
56 | dct2_butterfly_h32_arm64(tmp, 4, dst, 4, 20 - bit_depth, bit_depth);
57 | }
58 |
59 | void uavs3d_itrans_dct2_h4_w64_arm64(s16 *src, s16 *dst, int bit_depth)
60 | {
61 | ALIGNED_16(s16 tmp[4*64]);
62 | dct2_butterfly_h4_arm64(src, tmp, 64, 5, MAX_TX_DYNAMIC_RANGE);
63 | dct2_butterfly_h64_arm64(tmp, 4, dst, 4, 20 - bit_depth, bit_depth);
64 | }
65 |
66 | void uavs3d_itrans_dct2_h8_w4_arm64(s16 *src, s16 *dst, int bit_depth)
67 | {
68 | ALIGNED_16(s16 tmp[8*4]);
69 | dct2_butterfly_h8_arm64(src, 4, tmp, 4, 5, MAX_TX_DYNAMIC_RANGE);
70 | dct2_butterfly_h4_arm64(tmp, dst, 8, 20 - bit_depth, bit_depth);
71 | }
72 |
73 | void uavs3d_itrans_dct2_h8_w8_arm64(s16 *src, s16 *dst, int bit_depth)
74 | {
75 | ALIGNED_16(s16 tmp[8*8]);
76 | dct2_butterfly_h8_arm64(src, 8, tmp, 8, 5, MAX_TX_DYNAMIC_RANGE);
77 | dct2_butterfly_h8_arm64(tmp, 8, dst, 8, 20 - bit_depth, bit_depth);
78 | }
79 |
80 | void uavs3d_itrans_dct2_h8_w16_arm64(s16 *src, s16 *dst, int bit_depth)
81 | {
82 | ALIGNED_16(s16 tmp[8*16]);
83 | dct2_butterfly_h8_arm64(src, 16, tmp, 16, 5, MAX_TX_DYNAMIC_RANGE);
84 | dct2_butterfly_h16_arm64(tmp, 8, dst, 8, 20 - bit_depth, bit_depth);
85 | }
86 |
87 | void uavs3d_itrans_dct2_h8_w32_arm64(s16 *src, s16 *dst, int bit_depth)
88 | {
89 | ALIGNED_16(s16 tmp[8*32]);
90 | dct2_butterfly_h8_arm64(src, 32, tmp, 32, 5, MAX_TX_DYNAMIC_RANGE);
91 | dct2_butterfly_h32_arm64(tmp, 8, dst, 8, 20 - bit_depth, bit_depth);
92 | }
93 |
94 | void uavs3d_itrans_dct2_h8_w64_arm64(s16 *src, s16 *dst, int bit_depth)
95 | {
96 | ALIGNED_16(s16 tmp[8*64]);
97 | dct2_butterfly_h8_arm64(src, 64, tmp, 32, 5, MAX_TX_DYNAMIC_RANGE);
98 | dct2_butterfly_h64_arm64(tmp, 8, dst, 8, 20 - bit_depth, bit_depth);
99 | }
100 |
101 | void uavs3d_itrans_dct2_h16_w4_arm64(s16 *src, s16 *dst, int bit_depth)
102 | {
103 | ALIGNED_16(s16 tmp[16*4]);
104 | dct2_butterfly_h16_arm64(src, 4, tmp, 4, 5, MAX_TX_DYNAMIC_RANGE);
105 | dct2_butterfly_h4_arm64(tmp, dst, 16, 20 - bit_depth, bit_depth);
106 | }
107 |
108 | void uavs3d_itrans_dct2_h16_w8_arm64(s16 *src, s16 *dst, int bit_depth)
109 | {
110 | ALIGNED_16(s16 tmp[16*8]);
111 | dct2_butterfly_h16_arm64(src, 8, tmp, 8, 5, MAX_TX_DYNAMIC_RANGE);
112 | dct2_butterfly_h8_arm64(tmp, 16, dst, 16, 20 - bit_depth, bit_depth);
113 | }
114 |
115 | void uavs3d_itrans_dct2_h16_w16_arm64(s16 *src, s16 *dst, int bit_depth)
116 | {
117 | ALIGNED_16(s16 tmp[16*16]);
118 | dct2_butterfly_h16_arm64(src, 16, tmp, 16, 5, MAX_TX_DYNAMIC_RANGE);
119 | dct2_butterfly_h16_arm64(tmp, 16, dst, 16, 20 - bit_depth, bit_depth);
120 | }
121 |
122 | void uavs3d_itrans_dct2_h16_w32_arm64(s16 *src, s16 *dst, int bit_depth)
123 | {
124 | ALIGNED_16(s16 tmp[16*32]);
125 | dct2_butterfly_h16_arm64(src, 32, tmp, 32, 5, MAX_TX_DYNAMIC_RANGE);
126 | dct2_butterfly_h32_arm64(tmp, 16, dst, 16, 20 - bit_depth, bit_depth);
127 | }
128 |
129 | void uavs3d_itrans_dct2_h16_w64_arm64(s16 *src, s16 *dst, int bit_depth)
130 | {
131 | ALIGNED_16(s16 tmp[16*64]);
132 | dct2_butterfly_h16_arm64(src, 64, tmp, 32, 5, MAX_TX_DYNAMIC_RANGE);
133 | dct2_butterfly_h64_arm64(tmp, 16, dst, 16, 20 - bit_depth, bit_depth);
134 | }
135 |
136 | void uavs3d_itrans_dct2_h32_w4_arm64(s16 *src, s16 *dst, int bit_depth)
137 | {
138 | ALIGNED_16(s16 tmp[32*4]);
139 | dct2_butterfly_h32_arm64(src, 4, tmp, 4, 5, MAX_TX_DYNAMIC_RANGE);
140 | dct2_butterfly_h4_arm64(tmp, dst, 32, 20 - bit_depth, bit_depth);
141 | }
142 |
143 | void uavs3d_itrans_dct2_h32_w8_arm64(s16 *src, s16 *dst, int bit_depth)
144 | {
145 | ALIGNED_16(s16 tmp[32*8]);
146 | dct2_butterfly_h32_arm64(src, 8, tmp, 8, 5, MAX_TX_DYNAMIC_RANGE);
147 | dct2_butterfly_h8_arm64(tmp, 32, dst, 32, 20 - bit_depth, bit_depth);
148 | }
149 |
150 | void uavs3d_itrans_dct2_h32_w16_arm64(s16 *src, s16 *dst, int bit_depth)
151 | {
152 | ALIGNED_16(s16 tmp[32*16]);
153 | dct2_butterfly_h32_arm64(src, 16, tmp, 16, 5, MAX_TX_DYNAMIC_RANGE);
154 | dct2_butterfly_h16_arm64(tmp, 32, dst, 32, 20 - bit_depth, bit_depth);
155 | }
156 |
157 | void uavs3d_itrans_dct2_h32_w32_arm64(s16 *src, s16 *dst, int bit_depth)
158 | {
159 | ALIGNED_16(s16 tmp[32*32]);
160 | dct2_butterfly_h32_arm64(src, 32, tmp, 32, 5, MAX_TX_DYNAMIC_RANGE);
161 | dct2_butterfly_h32_arm64(tmp, 32, dst, 32, 20 - bit_depth, bit_depth);
162 | }
163 |
164 | void uavs3d_itrans_dct2_h32_w64_arm64(s16 *src, s16 *dst, int bit_depth)
165 | {
166 | ALIGNED_16(s16 tmp[32*64]);
167 | dct2_butterfly_h32_arm64(src, 64, tmp, 32, 5, MAX_TX_DYNAMIC_RANGE);
168 | dct2_butterfly_h64_arm64(tmp, 32, dst, 32, 20 - bit_depth, bit_depth);
169 | }
170 |
171 | void uavs3d_itrans_dct2_h64_w8_arm64(s16 *src, s16 *dst, int bit_depth)
172 | {
173 | ALIGNED_16(s16 tmp[64*8]);
174 | dct2_butterfly_h64_arm64(src, 8, tmp, 8, 5, MAX_TX_DYNAMIC_RANGE);
175 | dct2_butterfly_h8_arm64(tmp, 64, dst, 64, 20 - bit_depth, bit_depth);
176 | }
177 |
178 | void uavs3d_itrans_dct2_h64_w16_arm64(s16 *src, s16 *dst, int bit_depth)
179 | {
180 | ALIGNED_16(s16 tmp[64*16]);
181 | dct2_butterfly_h64_arm64(src, 16, tmp, 16, 5, MAX_TX_DYNAMIC_RANGE);
182 | dct2_butterfly_h16_arm64(tmp, 64, dst, 64, 20 - bit_depth, bit_depth);
183 | }
184 |
185 | void uavs3d_itrans_dct2_h64_w32_arm64(s16 *src, s16 *dst, int bit_depth)
186 | {
187 | ALIGNED_16(s16 tmp[64*32]);
188 | dct2_butterfly_h64_arm64(src, 32, tmp, 32, 5, MAX_TX_DYNAMIC_RANGE);
189 | dct2_butterfly_h32_arm64(tmp, 64, dst, 64, 20 - bit_depth, bit_depth);
190 | }
191 |
192 | void uavs3d_itrans_dct2_h64_w64_arm64(s16 *src, s16 *dst, int bit_depth)
193 | {
194 | ALIGNED_16(s16 tmp[64*64]);
195 | dct2_butterfly_h64_arm64(src, 64, tmp, 32, 5, MAX_TX_DYNAMIC_RANGE);
196 | dct2_butterfly_h64_arm64(tmp, 64, dst, 64, 20 - bit_depth, bit_depth);
197 | }
198 |
199 | #endif
200 |
--------------------------------------------------------------------------------
/source/decore/arm64/itrans_arm64.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * Copyright (c) 2018-2022 ["Peking University Shenzhen Graduate School",
3 | * "Peng Cheng Laboratory", and "Guangdong Bohua UHD Innovation Corporation"]
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the organizations (Peking University Shenzhen Graduate School,
15 | * Peng Cheng Laboratory and Guangdong Bohua UHD Innovation Corporation) nor the
16 | * names of its contributors may be used to endorse or promote products
17 | * derived from this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | * For more information, contact us at rgwang@pkusz.edu.cn.
31 | **************************************************************************************/
32 |
33 | #include "arm64.h"
34 | #if defined(__arm64__)
35 | #ifndef __ITRANS_ARM64_H__
36 | #define __ITRANS_ARM64_H__
37 |
38 | void dct2_butterfly_h4_arm64(s16* src, s16* dst, int width, int shift, int bit_depth);
39 | void dct2_butterfly_h8_arm64(s16* src, int i_src, s16* dst, int width, int shift, int bit_depth);
40 | void dct2_butterfly_h16_arm64(s16* src, int i_src, s16* dst, int width, int shift, int bit_depth);
41 | void dct2_butterfly_h32_arm64(s16* src, int i_src, s16* dst, int width, int shift, int bit_depth);
42 | void dct2_butterfly_h64_arm64(s16* src, int i_src, s16* dst, int width, int shift, int bit_depth);
43 |
44 | #endif
45 | #endif
46 |
--------------------------------------------------------------------------------
/source/decore/arm64/sao_kernel_arm64.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * Copyright (c) 2018-2022 ["Peking University Shenzhen Graduate School",
3 | * "Peng Cheng Laboratory", and "Guangdong Bohua UHD Innovation Corporation"]
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the organizations (Peking University Shenzhen Graduate School,
15 | * Peng Cheng Laboratory and Guangdong Bohua UHD Innovation Corporation) nor the
16 | * names of its contributors may be used to endorse or promote products
17 | * derived from this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | * For more information, contact us at rgwang@pkusz.edu.cn.
31 | **************************************************************************************/
32 |
33 | #include "arm64.h"
34 | #if defined(__arm64__)
35 | #ifndef __SAO_ARM64_H__
36 | #define __SAO_ARM64_H__
37 |
38 |
39 | void uavs3d_sao_eo_0_arm64(pel* src, pel* dst, int src_stride, int dst_stride, int* offset, int start_x, int end_x, int mb_height, pel* mask, int bit_depth);
40 | void uavs3d_sao_eo_90_arm64(pel* src, pel* dst, int src_stride, int dst_stride, int* offset, int start_y, int end_y, int mb_width, int bit_depth);
41 | void uavs3d_sao_eo_135_arm64(pel* src, pel* dst, int src_stride, int dst_stride, int* offset, pel* mask, int mb_height, int bit_depth, int start_x_r0, int end_x_r0, int start_x_r, int end_x_r, int start_x_rn, int end_x_rn);
42 | void uavs3d_sao_eo_45_arm64(pel* src, pel* dst, int src_stride, int dst_stride, int* offset, pel* mask, int mb_height, int bit_depth, int start_x_r0, int end_x_r0, int start_x_r, int end_x_r, int start_x_rn, int end_x_rn);
43 | void uavs3d_sao_bo_arm64(pel* src, pel* dst, int src_stride, int dst_stride, int* offset, int *band_ids, int mb_width, int mb_height, int bit_depth);
44 |
45 | void uavs3d_sao_eo_0_chroma_arm64(pel* src, pel* dst, int src_stride, int dst_stride, int* offset, int start_x, int end_x, int mb_height, pel* mask, int bit_depth);
46 | void uavs3d_sao_eo_90_chroma_arm64(pel* src, pel* dst, int src_stride, int dst_stride, int* offset, int start_y, int end_y, int mb_width, int bit_depth);
47 | void uavs3d_sao_eo_135_chroma_arm64(pel* src, pel* dst, int src_stride, int dst_stride, int* offset, pel* mask, int mb_height, int bit_depth, int start_x_r0, int end_x_r0, int start_x_r, int end_x_r, int start_x_rn, int end_x_rn);
48 | void uavs3d_sao_eo_45_chroma_arm64(pel* src, pel* dst, int src_stride, int dst_stride, int* offset, pel* mask, int mb_height, int bit_depth, int start_x_r0, int end_x_r0, int start_x_r, int end_x_r, int start_x_rn, int end_x_rn);
49 | void uavs3d_sao_bo_chroma_arm64(pel* src, pel* dst, int src_stride, int dst_stride, int* offset, int *band_ids, int mb_width, int mb_height, int bit_depth);
50 |
51 | #endif
52 | #endif
53 |
--------------------------------------------------------------------------------
/source/decore/armv7/def_armv7.S:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * Copyright (c) 2018-2022 ["Peking University Shenzhen Graduate School",
3 | * "Peng Cheng Laboratory", and "Guangdong Bohua UHD Innovation Corporation"]
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the organizations (Peking University Shenzhen Graduate School,
15 | * Peng Cheng Laboratory and Guangdong Bohua UHD Innovation Corporation) nor the
16 | * names of its contributors may be used to endorse or promote products
17 | * derived from this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | * For more information, contact us at rgwang@pkusz.edu.cn.
31 | **************************************************************************************/
32 |
33 | #if defined(__APPLE__)
34 | .macro function name
35 | .text
36 | .align 4
37 | .global _\name
38 | _\name:
39 | .endm
40 | #else
41 | .macro function name
42 | .global \name
43 | .hidden \name
44 | .type \name, %function
45 | \name:
46 | .endm
47 | #endif
48 |
--------------------------------------------------------------------------------
/source/decore/armv7/sao_kernel_armv7.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * Copyright (c) 2018-2022 ["Peking University Shenzhen Graduate School",
3 | * "Peng Cheng Laboratory", and "Guangdong Bohua UHD Innovation Corporation"]
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the organizations (Peking University Shenzhen Graduate School,
15 | * Peng Cheng Laboratory and Guangdong Bohua UHD Innovation Corporation) nor the
16 | * names of its contributors may be used to endorse or promote products
17 | * derived from this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | * For more information, contact us at rgwang@pkusz.edu.cn.
31 | **************************************************************************************/
32 |
33 | #if defined(__arm__)
34 | #ifndef __SAO_ARMV7_H__
35 | #define __SAO_ARMV7_H__
36 |
37 | #include "armv7.h"
38 |
39 | void uavs3d_sao_eo_0_armv7(pel* src, pel* dst, int src_stride, int dst_stride, int* offset, int start_x, int end_x, int mb_height, pel* mask, int bit_depth);
40 | void uavs3d_sao_eo_90_armv7(pel* src, pel* dst, int src_stride, int dst_stride, int* offset, int start_y, int end_y, int mb_width, int bit_depth);
41 | void uavs3d_sao_eo_135_armv7(pel* src, pel* dst, int src_stride, int dst_stride, int* offset, pel* mask, int mb_height, int bit_depth, int start_x_r0, int end_x_r0, int start_x_r, int end_x_r, int start_x_rn, int end_x_rn);
42 | void uavs3d_sao_eo_45_armv7(pel* src, pel* dst, int src_stride, int dst_stride, int* offset, pel* mask, int mb_height, int bit_depth, int start_x_r0, int end_x_r0, int start_x_r, int end_x_r, int start_x_rn, int end_x_rn);
43 | void uavs3d_sao_bo_armv7(pel* src, pel* dst, int src_stride, int dst_stride, int* offset, int *band_ids, int mb_width, int mb_height, int bit_depth);
44 |
45 | void uavs3d_sao_eo_0_chroma_armv7(pel* src, pel* dst, int src_stride, int dst_stride, int* offset, int start_x, int end_x, int mb_height, pel* mask, int bit_depth);
46 | void uavs3d_sao_eo_90_chroma_armv7(pel* src, pel* dst, int src_stride, int dst_stride, int* offset, int start_y, int end_y, int mb_width, int bit_depth);
47 | void uavs3d_sao_eo_135_chroma_armv7(pel* src, pel* dst, int src_stride, int dst_stride, int* offset, pel* mask, int mb_height, int bit_depth, int start_x_r0, int end_x_r0, int start_x_r, int end_x_r, int start_x_rn, int end_x_rn);
48 | void uavs3d_sao_eo_45_chroma_armv7(pel* src, pel* dst, int src_stride, int dst_stride, int* offset, pel* mask, int mb_height, int bit_depth, int start_x_r0, int end_x_r0, int start_x_r, int end_x_r, int start_x_rn, int end_x_rn);
49 | void uavs3d_sao_bo_chroma_armv7(pel* src, pel* dst, int src_stride, int dst_stride, int* offset, int *band_ids, int mb_width, int mb_height, int bit_depth);
50 |
51 | #endif
52 | #endif
53 |
--------------------------------------------------------------------------------
/source/decore/avx2/intra_pred_avx2.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uavs3/uavs3d/1fd04917cff50fac72ae23e45f82ca6fd9130bd8/source/decore/avx2/intra_pred_avx2.c
--------------------------------------------------------------------------------
/source/decore/avx2/itrans_avx2.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uavs3/uavs3d/1fd04917cff50fac72ae23e45f82ca6fd9130bd8/source/decore/avx2/itrans_avx2.c
--------------------------------------------------------------------------------
/source/decore/com_sys.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * Copyright (c) 2018-2022 ["Peking University Shenzhen Graduate School",
3 | * "Peng Cheng Laboratory", and "Guangdong Bohua UHD Innovation Corporation"]
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the organizations (Peking University Shenzhen Graduate School,
15 | * Peng Cheng Laboratory and Guangdong Bohua UHD Innovation Corporation) nor the
16 | * names of its contributors may be used to endorse or promote products
17 | * derived from this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | * For more information, contact us at rgwang@pkusz.edu.cn.
31 | **************************************************************************************/
32 |
33 | #ifndef __COM_SYS_H__
34 | #define __COM_SYS_H__
35 |
36 | #include
37 | #include
38 | #include
39 | #include
40 |
41 | #include "threadpool.h"
42 |
43 | /*****************************************************************************
44 | * basic types
45 | *****************************************************************************/
46 | #if defined(WIN32) || defined(WIN64)
47 | typedef __int8 s8;
48 | typedef unsigned __int8 u8;
49 | typedef __int16 s16;
50 | typedef unsigned __int16 u16;
51 | typedef __int32 s32;
52 | typedef unsigned __int32 u32;
53 | typedef __int64 s64;
54 | typedef unsigned __int64 u64;
55 | #elif defined(__GNUC__)
56 | #include
57 | typedef int8_t s8;
58 | typedef uint8_t u8;
59 | typedef int16_t s16;
60 | typedef uint16_t u16;
61 | typedef int32_t s32;
62 | typedef uint32_t u32;
63 | typedef int64_t s64;
64 | typedef uint64_t u64;
65 | #else
66 | typedef signed char s8;
67 | typedef unsigned char u8;
68 | typedef signed short s16;
69 | typedef unsigned short u16;
70 | typedef signed int s32;
71 | typedef unsigned int u32;
72 | #if defined(X86_64) && !defined(_MSC_VER) /* for 64bit-Linux */
73 | typedef signed long s64;
74 | typedef unsigned long u64;
75 | #else
76 | typedef signed long long s64;
77 | typedef unsigned long long u64;
78 | #endif
79 | #endif
80 |
81 | typedef const u8 tab_u8;
82 | typedef const s8 tab_s8;
83 | typedef const u16 tab_u16;
84 | typedef const s16 tab_s16;
85 | typedef const u32 tab_u32;
86 | typedef const s32 tab_s32;
87 |
88 | #ifndef NULL
89 | #define NULL (void*)0
90 | #endif
91 |
92 | typedef int BOOL;
93 | #define TRUE 1
94 | #define FALSE 0
95 |
96 | /*****************************************************************************
97 | * limit constant
98 | *****************************************************************************/
99 | #define COM_UINT16_MAX ((u16)0xFFFF)
100 | #define COM_UINT16_MIN ((u16)0x0)
101 | #define COM_INT16_MAX ((s16)0x7FFF)
102 | #define COM_INT16_MIN ((s16)0x8000)
103 |
104 | #define COM_UINT_MAX ((u32)0xFFFFFFFF)
105 | #define COM_UINT_MIN ((u32)0x0)
106 | #define COM_INT_MAX ((int)0x7FFFFFFF)
107 | #define COM_INT_MIN ((int)0x80000000)
108 |
109 | #define COM_UINT32_MAX ((u32)0xFFFFFFFF)
110 | #define COM_UINT32_MIN ((u32)0x0)
111 | #define COM_INT32_MAX ((s32)0x7FFFFFFF)
112 | #define COM_INT32_MIN ((s32)0x80000000)
113 |
114 | #define COM_UINT64_MAX ((u64)0xFFFFFFFFFFFFFFFFL)
115 | #define COM_UINT64_MIN ((u64)0x0L)
116 | #define COM_INT64_MAX ((s64)0x7FFFFFFFFFFFFFFFL)
117 | #define COM_INT64_MIN ((s64)0x8000000000000000L)
118 |
119 | #define COM_INT18_MAX ((s32)(131071))
120 | #define COM_INT18_MIN ((s32)(-131072))
121 |
122 | /*****************************************************************************
123 | * inline defines
124 | *****************************************************************************/
125 |
126 | #ifdef __GNUC__
127 | # define UAVS3D_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y)
128 | #else
129 | # define UAVS3D_GCC_VERSION_AT_LEAST(x,y) 0
130 | #endif
131 |
132 | #define uavs3d_inline inline
133 |
134 | #if UAVS3D_GCC_VERSION_AT_LEAST(3,1)
135 | # define uavs3d_always_inline __attribute__((always_inline)) inline
136 | #elif defined(_MSC_VER)
137 | # define uavs3d_always_inline __forceinline
138 | #else
139 | # define uavs3d_always_inline inline
140 | #endif
141 |
142 | #if UAVS3D_GCC_VERSION_AT_LEAST(3,1)
143 | # define uavs3d_no_inline __attribute__((noinline))
144 | #elif defined(_MSC_VER)
145 | # define uavs3d_no_inline __declspec(noinline)
146 | #else
147 | # define uavs3d_no_inline
148 | #endif
149 |
150 |
151 | /*****************************************************************************
152 | * memory operations
153 | *****************************************************************************/
154 | #define com_malloc(size) align_malloc((size))
155 | #define com_free(m) if(m){align_free(m); (m) = NULL; }
156 |
157 | #define ALIGN_SHIFT 5
158 | #define ALIGN_BASIC (1 << ALIGN_SHIFT)
159 | #define ALIGN_MASK (ALIGN_BASIC - 1)
160 | #define ALIGN_POINTER(x) (x + ALIGN_MASK - (((intptr_t)x + ALIGN_MASK) & ((intptr_t)ALIGN_MASK)))
161 |
162 | #define GIVE_BUFFER(d, p, s) { (d) = (void*)(p); p += s; p = ALIGN_POINTER(p); }
163 | #define GIVE_BUFFERV(d, p, s, v) { (d) = (void*)(p); p += s; p = ALIGN_POINTER(p); memset(d, v, s); }
164 |
165 | /* ---------------------------------------------------------------------------
166 | * date align
167 | */
168 | #if defined(_WIN32) && !defined(__GNUC__)
169 | #define DECLARE_ALIGNED(var, n) __declspec(align(n)) var
170 | #else
171 | #define DECLARE_ALIGNED(var, n) var __attribute__((aligned (n)))
172 | #endif
173 | #define ALIGNED_32(var) DECLARE_ALIGNED(var, 32)
174 | #define ALIGNED_16(var) DECLARE_ALIGNED(var, 16)
175 | #define ALIGNED_8(var) DECLARE_ALIGNED(var, 8)
176 | #define ALIGNED_4(var) DECLARE_ALIGNED(var, 4)
177 | #define COM_ALIGN(val, align) ((((val) + (align) - 1) / (align)) * (align))
178 |
179 | #define uavs3d_prefetch(a,b) _mm_prefetch((const char*)a,b)
180 |
181 | typedef union uavs3d_union16_t {
182 | u16 i;
183 | u8 c[2];
184 | } uavs3d_union16_t;
185 |
186 | typedef union uavs3d_union32_t {
187 | u32 i;
188 | u16 b[2];
189 | u8 c[4];
190 | } uavs3d_union32_t;
191 |
192 | typedef union uavs3d_union64_t {
193 | u64 i;
194 | u32 a[2];
195 | u16 b[4];
196 | u8 c[8];
197 | } uavs3d_union64_t;
198 |
199 | typedef struct uavs3d_uint128_t {
200 | u64 i[2];
201 | } uavs3d_uint128_t;
202 |
203 | typedef union uavs3d_union128_t {
204 | uavs3d_uint128_t i;
205 | u64 a[2];
206 | u32 b[4];
207 | u16 c[8];
208 | u8 d[16];
209 | } uavs3d_union128_t;
210 |
211 | #define M16(src) (((uavs3d_union16_t*)(src))->i)
212 | #define M32(src) (((uavs3d_union32_t*)(src))->i)
213 | #define M64(src) (((uavs3d_union64_t*)(src))->i)
214 | #define M128(src) (((uavs3d_union128_t*)(src))->i)
215 |
216 | #define CP16(dst,src) M16(dst) = M16(src)
217 | #define CP32(dst,src) M32(dst) = M32(src)
218 | #define CP64(dst,src) memcpy(dst, src, 8)
219 | #define CP128(dst,src) memcpy(dst, src, 16)
220 | //#define CP64(dst,src) M64(dst) = M64(src)
221 | //#define CP128(dst,src) M128(dst) = M128(src)
222 |
223 | /*****************************************************************************
224 | * assert
225 | *****************************************************************************/
226 | #include
227 |
228 | #if CHECK_RAND_STRM
229 | #define assert(x)
230 | #endif
231 |
232 | #ifdef UAVS3D_DEBUG
233 | #define uavs3d_assert(x) \
234 | {if(!(x)){assert(0);}}
235 | #define uavs3d_assert_return(x,r) \
236 | {if(!(x)){assert(0); return (r);}}
237 | #define uavs3d_assert_goto(x,g) \
238 | {if(!(x)){assert(0); goto g;}}
239 | #else
240 | #define uavs3d_assert(x)
241 | #define uavs3d_assert_return(x,r) \
242 | {if(!(x)){return (r);}}
243 | #define uavs3d_assert_goto(x,g) \
244 | {if(!(x)){goto g;}}
245 | #endif
246 |
247 | #define com_check_val2(x, v1, v2) { \
248 | if (x != v1 && x != v2) { \
249 | uavs3d_assert(0); \
250 | x = v1; \
251 | } \
252 | }
253 |
254 | /*****************************************************************************
255 | * basic operation
256 | *****************************************************************************/
257 |
258 | #define COM_ABS(a) abs(a)
259 | #define COM_ABS64(a) (((a)^((a)>>63)) - ((a)>>63))
260 | #define COM_ABS32(a) (((a)^((a)>>31)) - ((a)>>31))
261 | #define COM_ABS16(a) (((a)^((a)>>15)) - ((a)>>15))
262 |
263 | #define COM_MAX(a,b) (((a) > (b)) ? (a) : (b))
264 | #define COM_MIN(a,b) (((a) < (b)) ? (a) : (b))
265 | #define COM_CLIP3(min_x, max_x, value) COM_MAX((min_x), COM_MIN((max_x), (value)))
266 | #define COM_CLIP(n,min,max) (((n)>(max))? (max) : (((n)<(min))? (min) : (n)))
267 |
268 | #define COM_SIGN(x) (((x) < 0) ? -1 : 1)
269 | #define COM_SIGN_GET(val) ((val<0)? 1: 0)
270 | #define COM_SIGN_SET(val, sign) ((sign)? -val : val)
271 | #define COM_SIGN_GET16(val) (((val)>>15) & 1)
272 | #define COM_SIGN_SET16(val, sign) (((val) ^ ((s16)((sign)<<15)>>15)) + (sign))
273 |
274 | #define COM_LOG2(v) (g_tbl_log2[v])
275 |
276 | #endif /* __COM_SYS_H__ */
277 |
--------------------------------------------------------------------------------
/source/decore/com_table.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * Copyright (c) 2018-2022 ["Peking University Shenzhen Graduate School",
3 | * "Peng Cheng Laboratory", and "Guangdong Bohua UHD Innovation Corporation"]
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the organizations (Peking University Shenzhen Graduate School,
15 | * Peng Cheng Laboratory and Guangdong Bohua UHD Innovation Corporation) nor the
16 | * names of its contributors may be used to endorse or promote products
17 | * derived from this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | * For more information, contact us at rgwang@pkusz.edu.cn.
31 | **************************************************************************************/
32 |
33 | #ifndef __COM_TABLE_H__
34 | #define __COM_TABLE_H__
35 |
36 | #define ITRANS_SIZE_TYPES 6
37 | #define ITRANS_COEFFS_SIZE ((2 * 2 + 4 * 4 + 8 * 8 + 16 * 16 + 32 * 32 + 64 * 64) * NUM_TRANS_TYPE)
38 |
39 | extern s8* g_tbl_itrans[NUM_TRANS_TYPE][ITRANS_SIZE_TYPES];
40 | extern s8 g_tbl_itrans_coeffs[ITRANS_COEFFS_SIZE];
41 |
42 | extern tab_s8 g_tbl_itrans_c4[4][4];
43 | extern tab_s8 g_tbl_itrans_c8[4][4];
44 |
45 | extern tab_u8 g_tbl_part_num[8];
46 | extern const com_part_size_t g_tbl_tb_part[8];
47 |
48 | extern tab_s32 g_tbl_ai_tscpm_div[64];
49 |
50 | extern tab_s8 g_tbl_log2[257];
51 |
52 | extern tab_s8 g_tbl_mc_coeff_luma_hp[16][8];
53 | extern tab_s8 g_tbl_mc_coeff_chroma_hp[32][4];
54 | extern tab_s8 g_tbl_mc_coeff_luma[4][8];
55 | extern tab_s8 g_tbl_mc_coeff_chroma[8][4];
56 |
57 | extern tab_u8 g_tbl_qp_chroma_adjust[64];
58 |
59 | extern tab_u32 g_tbl_wq_default_param[2][6];
60 | extern tab_u8 g_tbl_wq_default_matrix_4x4[16];
61 | extern tab_u8 g_tbl_wq_default_matrix_8x8[64];
62 | extern tab_u8 g_tbl_wq_model_4x4[4][16];
63 | extern tab_u8 g_tbl_wq_model_8x8[4][64];
64 |
65 | extern tab_u16 g_tbl_scan[64516];
66 | extern tab_u16 g_tbl_scan_blkpos[MAX_CU_LOG2][MAX_CU_LOG2];
67 |
68 | #endif // __COM_TABLE_H__
69 |
--------------------------------------------------------------------------------
/source/decore/com_util.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * Copyright (c) 2018-2022 ["Peking University Shenzhen Graduate School",
3 | * "Peng Cheng Laboratory", and "Guangdong Bohua UHD Innovation Corporation"]
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the organizations (Peking University Shenzhen Graduate School,
15 | * Peng Cheng Laboratory and Guangdong Bohua UHD Innovation Corporation) nor the
16 | * names of its contributors may be used to endorse or promote products
17 | * derived from this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | * For more information, contact us at rgwang@pkusz.edu.cn.
31 | **************************************************************************************/
32 |
33 | #ifndef __COM_UTIL_H__
34 | #define __COM_UTIL_H__
35 |
36 | #include "com_type.h"
37 |
38 | /* function selection define based on platforms */
39 | #if defined(_arm64) || (defined(__APPLE__) && defined(__arm64__))
40 | #define ENABLE_FUNCTION_C 1
41 | #define ENABLE_FUNCTION_ARM64 1
42 | #elif defined(_armv7a) || (defined(__APPLE__) && defined(__ARM_NEON__))
43 | #define ENABLE_FUNCTION_C 1
44 | #define ENABLE_FUNCTION_ARM32 1
45 | #elif (defined(__WIN32__) || defined(_WIN32)) || (defined(__MACOSX__) || defined(macintosh) || defined(__linux__) || defined(__unix__)) && (defined(__i386__) || defined(__x86_64__) || defined(__AMD64__))
46 | #define ENABLE_FUNCTION_X86 1
47 | #define ENABLE_FUNCTION_C 1
48 | #else
49 | #define ENABLE_FUNCTION_C 1
50 | #endif
51 |
52 | typedef struct uavs3d_funs_handle_t {
53 | void(*ipcpy[BLOCK_WIDTH_TYPES_NUM]) (const pel *src, int i_src, pel *dst, int i_dst, int width, int height);
54 | void(*ipflt[NUM_IPFILTER][BLOCK_WIDTH_TYPES_NUM]) (const pel *src, int i_src, pel *dst, int i_dst, int width, int height, const s8 *coeff, int max_val);
55 | void(*ipflt_ext[NUM_IPFILTER_Ext][BLOCK_WIDTH_TYPES_NUM]) (const pel *src, int i_src, pel *dst, int i_dst, int width, int height, const s8 *coef_x, const s8 *coef_y, int max_val);
56 | void(*avg_pel[BLOCK_WIDTH_TYPES_NUM])(pel *dst, int i_dst, pel *src1, pel *src2, int width, int height);
57 | void(*avg_pel_rect)(pel *dst, int i_dst, pel *src1, int i_src1, pel *src2, int i_src2, int width, int height); // for watermark
58 | void(*recon_luma[BLOCK_WIDTH_TYPES_NUM])(s16 *resi, pel *pred, int i_pred, int width, int height, pel *rec, int i_rec, int cbf, int bit_depth);
59 | void(*recon_chroma[BLOCK_WIDTH_TYPES_NUM])(s16 *resi_u, s16 *resi_v, pel *pred, int width, int height, pel *rec, int i_rec, u8 cbf[2], int bit_depth);
60 |
61 | void(*itrans_dct2[MAX_TR_LOG2][MAX_TR_LOG2])(s16 *coef, s16 *resi, int bit_depth);
62 | void(*itrans_dct8[MAX_TR_LOG2 - 2])(s16 *coeff, s16 *block, int shift, int line, int limit_line, int max_tr_val, int min_tr_val, s8 *it);
63 | void(*itrans_dst7[MAX_TR_LOG2 - 2])(s16 *coeff, s16 *block, int shift, int line, int limit_line, int max_tr_val, int min_tr_val, s8 *it);
64 |
65 | void(*deblock_luma[2])(pel *src, int stride, int alpha, int beta, int flag);
66 | void(*deblock_chroma[2])(pel *srcuv, int stride, int alphau, int betau, int alphav, int betav, int flag);
67 | void(*sao[2])(pel *src, int i_src, pel *dst, int i_dst, com_sao_param_t *sao_params, int smb_pix_height, int smb_pix_width,
68 | int smb_available_left, int smb_available_right, int smb_available_up, int smb_available_down, int sample_bit_depth);
69 |
70 | /* alf[3] idx: 0(Y); 1(U or V); 2(U and V) */
71 | void(*alf[3])(pel *dst, int i_dst, pel *src, int i_src, int lcu_width, int lcu_height, int *coef, int sample_bit_depth);
72 | void(*alf_fix[2])(pel *dst, int i_dst, pel *src, int i_src, int lcu_width, int lcu_height, int *coef, int sample_bit_depth);
73 |
74 | void(*intra_pred_dc[2])(pel *src, pel *dst, int i_dst, int width, int height, u16 cu_avail, int bit_depth);
75 | void(*intra_pred_plane[2])(pel *src, pel *dst, int i_dst, int width, int height, int bit_depth);
76 | void(*intra_pred_bi[2])(pel *src, pel *dst, int i_dst, int width, int height, int bit_depth);
77 | void(*intra_pred_plane_ipf)(pel *src, s16 *dst, int width, int height);
78 | void(*intra_pred_bi_ipf)(pel *src, s16 *dst, int width, int height);
79 | void(*intra_pred_ver[2])(pel *src, pel *dst, int i_dst, int width, int height);
80 | void(*intra_pred_hor[2])(pel *src, pel *dst, int i_dst, int width, int height);
81 | void(*intra_pred_ang [IPD_CNT])(pel *pSrc, pel *dst, int i_dst, int uiDirMode, int iWidth, int iHeight);
82 | void(*intra_pred_chroma_ang[IPD_CNT])(pel *pSrc, pel *dst, int i_dst, int uiDirMode, int iWidth, int iHeight);
83 | void(*intra_pred_ipf)(pel *src, pel *dst, int i_dst, int flt_range_hor, int flt_range_ver, const s8* flt_hor_coef, const s8* flt_ver_coef, int w, int h, int bit_depth);
84 | void(*intra_pred_ipf_s16)(pel *src, pel *dst, int i_dst, s16* pred, int flt_range_hor, int flt_range_ver, const s8* flt_hor_coef, const s8* flt_ver_coef, int w, int h, int bit_depth);
85 |
86 | void(*padding_rows_luma)(pel *src, int i_src, int width, int height, int start, int rows, int padh, int padv);
87 | void(*padding_rows_chroma)(pel *src, int i_src, int width, int height, int start, int rows, int padh, int padv);
88 |
89 | void(*conv_fmt_8bit)(unsigned char* src_y, unsigned char* src_uv, unsigned char* dst[3], int width, int height, int stride, int stridec, int dst_stride[3], int uv_shift);
90 | void(*conv_fmt_16bit)(unsigned char* src_y, unsigned char* src_uv, unsigned char* dst[3], int width, int height, int stride, int stridec, int dst_stride[3], int uv_shift);
91 | void(*conv_fmt_16to8bit)(unsigned char* src_y, unsigned char* src_uv, unsigned char* dst[3], int width, int height, int stride, int stridec, int dst_stride[3], int uv_shift);
92 |
93 | void(*reset_map_scu)(com_scu_t *map_scu, int length);
94 | } uavs3d_funs_handle_t;
95 |
96 | extern uavs3d_funs_handle_t uavs3d_funs_handle;
97 |
98 | #if ENABLE_FUNCTION_C
99 | void uavs3d_funs_init_mc_c();
100 | void uavs3d_funs_init_intra_pred_c();
101 | void uavs3d_funs_init_itrans_c();
102 | void uavs3d_funs_init_recon_c();
103 | void uavs3d_funs_init_deblock_c();
104 | void uavs3d_funs_init_sao_c();
105 | void uavs3d_funs_init_alf_c();
106 | void uavs3d_funs_init_c();
107 | #endif
108 |
109 | #if ENABLE_FUNCTION_X86
110 | int uavs3d_simd_avx_level(int* phwavx);
111 | void uavs3d_funs_init_sse();
112 | void uavs3d_funs_init_avx2();
113 | #endif
114 |
115 | #if ENABLE_FUNCTION_ARM64
116 | void uavs3d_funs_init_arm64();
117 | #endif
118 |
119 | #if ENABLE_FUNCTION_ARM32
120 | void uavs3d_funs_init_armv7();
121 | #endif
122 |
123 | com_core_t* com_core_init(com_seqh_t *seqhdr);
124 | void com_core_free(com_core_t *core);
125 |
126 | com_pic_t * com_pic_alloc(com_pic_param_t * pic_param, int * ret);
127 | void com_pic_free(com_pic_param_t *pic_param, com_pic_t *pic);
128 | int com_md5_image(com_pic_t *pic, u8 digest[16]);
129 |
130 | void com_lbac_ctx_init(com_lbac_all_ctx_t *sbac_ctx);
131 | void com_dct_coef_init();
132 | void com_dct_coef_destroy();
133 |
134 | #ifndef _WIN32
135 | #define max(a, b) ((a) > (b) ? (a) : (b))
136 | #define min(a, b) ((a) < (b) ? (a) : (b))
137 | #endif
138 |
139 | uavs3d_always_inline void uavs3d_check_ref_avaliable(com_pic_t *pic, int line_num)
140 | {
141 | if (pic->finished_line < line_num) {
142 | uavs3d_pthread_mutex_lock(&pic->mutex);
143 | while (pic->finished_line < line_num) {
144 | uavs3d_pthread_cond_wait(&pic->cond, &pic->mutex);
145 | }
146 | uavs3d_pthread_mutex_unlock(&pic->mutex);
147 | }
148 | }
149 |
150 | static uavs3d_always_inline void com_mset_pel(pel * dst, s16 v, int cnt)
151 | {
152 | #if (BIT_DEPTH == 8)
153 | memset(dst, v, cnt);
154 | #else
155 | int i;
156 | for (i = 0; i < cnt; i++) {
157 | dst[i] = v;
158 | }
159 | #endif
160 | }
161 |
162 | static uavs3d_always_inline void com_mset_2pel(pel * dst, int v, int cnt)
163 | {
164 | int i;
165 | #if (BIT_DEPTH == 8)
166 | s16 *pdst = (s16*)dst;
167 | for (i = 0; i < cnt; i++) {
168 | pdst[i] = v;
169 | }
170 | #else
171 | int *pdst = (int*)dst;
172 | for (i = 0; i < cnt; i++) {
173 | pdst[i] = v;
174 | }
175 | #endif
176 | }
177 |
178 | static uavs3d_always_inline void com_mcpy_2pel(pel * dst, pel *src)
179 | {
180 | #if (BIT_DEPTH == 8)
181 | M16(dst) = M16(src);
182 | #else
183 | M32(dst) = M32(src);
184 | #endif
185 | }
186 | static uavs3d_always_inline void com_mcpy_4pel(pel * dst, pel *src)
187 | {
188 | #if (BIT_DEPTH == 8)
189 | M32(dst) = M32(src);
190 | #else
191 | //M64(dst) = M64(src);
192 | M32(dst) = M32(src);
193 | M32(dst + 2) = M32(src + 2);
194 | #endif
195 | }
196 | void *align_malloc(int i_size);
197 | void align_free(void *p);
198 |
199 |
200 | #endif /* __COM_UTIL_H__ */
201 |
--------------------------------------------------------------------------------
/source/decore/contributor.h:
--------------------------------------------------------------------------------
1 | #ifndef __CONTRIBUTOR_H__
2 | #define __CONTRIBUTOR_H__
3 |
4 | /*************************************************************************
5 | Contributor List
6 | ------------------------------------------
7 | Zhenyu Wang (wangzhenyu@pkusz.edu.cn)
8 | Bingjie Han
9 | Ronggang Wang
10 | Jiang Du
11 | Kui Fan
12 | Xi Xie
13 | Guisen Xu
14 | Xufeng Li
15 | Yangang Cai
16 | Hao Lv
17 |
18 | *************************************************************************/
19 |
20 | #endif // #ifndef __CONTRIBUTOR_H__
21 |
--------------------------------------------------------------------------------
/source/decore/modules.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * Copyright (c) 2018-2022 ["Peking University Shenzhen Graduate School",
3 | * "Peng Cheng Laboratory", and "Guangdong Bohua UHD Innovation Corporation"]
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the organizations (Peking University Shenzhen Graduate School,
15 | * Peng Cheng Laboratory and Guangdong Bohua UHD Innovation Corporation) nor the
16 | * names of its contributors may be used to endorse or promote products
17 | * derived from this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | * For more information, contact us at rgwang@pkusz.edu.cn.
31 | **************************************************************************************/
32 |
33 | #ifndef __MODULES_H__
34 | #define __MODULES_H__
35 |
36 | #include "com_util.h"
37 |
38 | /*** deblock ***/
39 | void com_deblock_set_edge(com_core_t *core);
40 | void com_deblock_lcu_row(com_core_t *core, int lcu_y);
41 |
42 | /*** sao ***/
43 | void com_sao_lcu_row(com_core_t *core, int lcu_y);
44 |
45 | /*** alf ***/
46 | void com_alf_init_map(com_seqh_t *seqhdr, u8 *alf_idx_map);
47 | void com_alf_lcu_row(com_core_t *core, int lcu_y);
48 |
49 | /*** inter mc ***/
50 | void com_mc (com_core_t *core, pel *pred);
51 | void com_mc_affine(com_core_t *core, pel *pred);
52 |
53 | /*** intra pred ***/
54 | void com_get_nbr_l(pel *dst, int ipm, int ipf, int x, int y, int width, int height, pel *srcT, pel *srcL, int s_src, u16 avail_cu, int scup, com_scu_t *map_scu, int i_scu, int bit_depth);
55 | void com_get_nbr_c(pel *dst, int ipm_c, int ipm, int x, int y, int width, int height, pel *srcT, pel *srcL, int s_src, u16 avail_cu, int scup, com_scu_t * map_scu, int i_scu, int bit_depth);
56 | void com_ipred_l(pel *src, pel *dst, int i_dst, pel *tmp_buf, int ipm, int w, int h, int bit_depth, u16 avail_cu, u8 ipf_flag);
57 | void com_ipred_c(pel *dst, int i_dst, pel *src, pel *luma, s16 *tmp_dst, int ipm_c, int ipm, int w, int h, int bit_depth, u16 avail_cu, pel *piRecoY, int uiStrideY);
58 |
59 | /*** itrans ***/
60 | void com_itrans(com_core_t *core, int plane, int blk_idx, s16 *coef, s16 *resi, int log2_w, int log2_h, int bit_depth, int sec_t_vh, int alt_4x4);
61 |
62 | /*** recon ***/
63 | void com_recon_l(s16 *resi, pel *pred, int i_pred, int width, int height, pel *rec, int i_rec, int cbf, int bit_depth);
64 | void com_recon_c(s16 *resi_u, s16 *resi_v, pel *pred, int width, int height, pel *rec, int i_rec, u8 cbf[2], int bit_depth);
65 |
66 | /*** picture manager ***/
67 | com_pic_t * com_picman_get_empty_pic(com_pic_manager_t *pm, int *err);
68 | com_pic_t * com_picman_out_pic(com_pic_manager_t *pm, int *err, u8 cur_pic_doi, int state);
69 | int com_picman_init(com_pic_manager_t *pm, com_seqh_t *seqhdr, int ext_nodes);
70 | int com_picman_free(com_pic_manager_t *pm);
71 | int com_picman_get_active_refp(com_frm_t *frm, com_pic_manager_t *pm);
72 | int com_picman_mark_refp(com_pic_manager_t *pm, com_pic_header_t *sh);
73 |
74 | #endif // #ifndef __MODULES_H__
75 |
--------------------------------------------------------------------------------
/source/decore/pic_manager.c:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * Copyright (c) 2018-2022 ["Peking University Shenzhen Graduate School",
3 | * "Peng Cheng Laboratory", and "Guangdong Bohua UHD Innovation Corporation"]
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the organizations (Peking University Shenzhen Graduate School,
15 | * Peng Cheng Laboratory and Guangdong Bohua UHD Innovation Corporation) nor the
16 | * names of its contributors may be used to endorse or promote products
17 | * derived from this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | * For more information, contact us at rgwang@pkusz.edu.cn.
31 | **************************************************************************************/
32 |
33 | #include "modules.h"
34 |
35 | static void set_ref_pic(com_ref_pic_t * refp, com_pic_t * pic_ref, s64 ptr)
36 | {
37 | refp->pic = pic_ref;
38 | refp->map_mv = pic_ref->map_mv;
39 | refp->map_refi = pic_ref->map_refi;
40 | refp->dist = (s16)(ptr - pic_ref->ptr);
41 |
42 | uavs3d_assert(refp->dist);
43 |
44 | if (refp->dist == 0) {
45 | refp->dist = 1;
46 | }
47 | }
48 |
49 | int com_picman_get_active_refp(com_frm_t *frm, com_pic_manager_t *pm)
50 | {
51 | com_ref_pic_t(*refp)[REFP_NUM] = frm->refp;
52 | com_pic_header_t *pichdr = &frm->pichdr;
53 |
54 | for (int i = 0; i < MAX_REFS; i++) {
55 | refp[i][REFP_0].pic = refp[i][REFP_1].pic = NULL;
56 | }
57 | frm->num_refp[REFP_0] = frm->num_refp[REFP_1] = 0;
58 |
59 | // L0
60 | for (int i = 0; i < pichdr->rpl_l0.active; i++) {
61 | int refPicDoi = (pichdr->decode_order_index - pichdr->rpl_l0.delta_doi[i]);
62 | int j = 0;
63 |
64 | while (j < pm->cur_pb_size && (pm->list[j]->doi != refPicDoi || !pm->list[j]->is_ref)) j++;
65 |
66 | if (j < pm->cur_pb_size) {
67 | set_ref_pic(&refp[i][REFP_0], pm->list[j], pichdr->ptr);
68 | frm->num_refp[REFP_0]++;
69 | pm->list[j]->ref_cnt++;
70 | } else {
71 | return ERR_LOSS_REF_FRAME;
72 | }
73 | }
74 | if (pichdr->slice_type == SLICE_P) {
75 | return RET_OK;
76 | }
77 |
78 | // L1
79 | for (int i = 0; i < pichdr->rpl_l1.active; i++) {
80 | int refPicDoi = (pichdr->decode_order_index - pichdr->rpl_l1.delta_doi[i]);
81 | int j = 0;
82 |
83 | while (j < pm->cur_pb_size && (pm->list[j]->doi != refPicDoi || !pm->list[j]->is_ref)) j++;
84 |
85 | if (j < pm->cur_pb_size) {
86 | set_ref_pic(&refp[i][REFP_1], pm->list[j], pichdr->ptr);
87 | frm->num_refp[REFP_1]++;
88 | pm->list[j]->ref_cnt++;
89 | } else {
90 | return ERR_LOSS_REF_FRAME;
91 | }
92 | }
93 |
94 | return RET_OK;
95 | }
96 |
97 | int com_picman_mark_refp(com_pic_manager_t *pm, com_pic_header_t *pichdr)
98 | {
99 | for (int i = 0; i < pm->cur_pb_size; i++) {
100 | com_pic_t *pic = pm->list[i];
101 |
102 | if (pic && pic->is_ref) {
103 | int j;
104 |
105 | for (j = 0; j < pichdr->rpl_l0.num; j++) {
106 | if (pic->doi == (pichdr->decode_order_index - pichdr->rpl_l0.delta_doi[j])) {
107 | break;
108 | }
109 | }
110 | if (j == pichdr->rpl_l0.num) {
111 | for (j = 0; j < pichdr->rpl_l1.num; j++) {
112 | if (pic->doi == (pichdr->decode_order_index - pichdr->rpl_l1.delta_doi[j])) {
113 | break;
114 | }
115 | }
116 | if (j == pichdr->rpl_l1.num) {
117 | pic->is_ref = 0;
118 | }
119 | }
120 | }
121 | }
122 | return RET_OK;
123 | }
124 |
125 | com_pic_t* com_picman_get_empty_pic(com_pic_manager_t * pm, int * err)
126 | {
127 | com_pic_t * pic = NULL;
128 | int ret;
129 |
130 | for (int i = 0; i < pm->cur_pb_size; i++) {
131 | pic = pm->list[i];
132 | if (pic != NULL && !pic->is_ref && !pic->is_output && !pic->ref_cnt) {
133 | return pic;
134 | }
135 | }
136 |
137 | if (pm->cur_pb_size == pm->max_pb_size) {
138 | *err = ERR_PIC_BUFFER_FULL;
139 | return NULL;
140 | }
141 |
142 | pic = com_pic_alloc(&pm->pic_param, &ret);
143 |
144 | if (pic == NULL) {
145 | *err = ERR_OUT_OF_MEMORY;
146 | return NULL;
147 | }
148 | pm->list[pm->cur_pb_size++] = pic;
149 |
150 | return pic;
151 | }
152 |
153 | com_pic_t* com_picman_out_pic(com_pic_manager_t * pm, int * err, u8 cur_pic_doi, int state)
154 | {
155 | int i, ret, found = 0;
156 | com_pic_t **list = pm->list;
157 |
158 | BOOL exist_pic = 0;
159 | s64 min_ptr = LLONG_MAX;
160 | int min_ptr_idx = 0;
161 |
162 | if (state != 1) {
163 | for (i = 0; i < pm->cur_pb_size; i++) {
164 | com_pic_t *pic = list[i];
165 | if (pic != NULL && pic->is_output) {
166 | found = 1;
167 | if ((pic->doi + pic->output_delay <= cur_pic_doi)) {
168 | exist_pic = 1;
169 | if (min_ptr >= pic->ptr) {
170 | min_ptr = pic->ptr;
171 | min_ptr_idx = i;
172 | }
173 | }
174 | }
175 | }
176 | if (exist_pic) {
177 | list[min_ptr_idx]->is_output = 0;
178 | if (err) *err = RET_OK;
179 | return list[min_ptr_idx];
180 | }
181 | } else { // Bumping
182 | for (i = 0; i < pm->cur_pb_size; i++) {
183 | com_pic_t *pic = list[i];
184 | if (pic != NULL && pic->is_output) {
185 | found = 1;
186 |
187 | if (pic->ptr <= min_ptr) {
188 | exist_pic = 1;
189 | min_ptr = pic->ptr;
190 | min_ptr_idx = i;
191 | }
192 | }
193 | }
194 | if (exist_pic) {
195 | list[min_ptr_idx]->is_output = 0;
196 | if (err) *err = RET_OK;
197 | return list[min_ptr_idx];
198 | }
199 | }
200 |
201 | if (found == 0) {
202 | ret = ERR_UNEXPECTED;
203 | } else {
204 | ret = RET_DELAYED;
205 | }
206 | if (err) *err = ret;
207 | return NULL;
208 | }
209 |
210 | int com_picman_free(com_pic_manager_t * pm)
211 | {
212 | for (int i = 0; i < pm->cur_pb_size; i++) {
213 | if (pm->list[i]) {
214 | com_pic_free(&pm->pic_param, pm->list[i]);
215 | pm->list[i] = NULL;
216 | }
217 | }
218 | com_free(pm->list);
219 | pm->list = NULL;
220 |
221 | return RET_OK;
222 | }
223 |
224 | int com_picman_init(com_pic_manager_t *pm, com_seqh_t *seqhdr, int ext_nodes)
225 | {
226 | pm->pic_param.width = seqhdr->pic_width;
227 | pm->pic_param.height = seqhdr->pic_height;
228 | pm->pic_param.pad_l = PIC_PAD_SIZE_L;
229 | pm->pic_param.pad_c = PIC_PAD_SIZE_C;
230 | pm->pic_param.f_scu = seqhdr->f_scu;
231 | pm->pic_param.i_scu = seqhdr->i_scu;
232 | pm->pic_param.parallel = ext_nodes > 0;
233 | pm->pic_param.bit_depth = seqhdr->bit_depth_internal;
234 |
235 | pm->cur_pb_size = 0;
236 | pm->doi_cycles = 0;
237 | pm->prev_doi = 0;
238 |
239 | pm->max_pb_size = MAX_PB_SIZE + ext_nodes;
240 | pm->list = com_malloc(sizeof(com_pic_t*) * pm->max_pb_size);
241 |
242 | if (pm->list) {
243 | return RET_OK;
244 | } else {
245 | return ERR_OUT_OF_MEMORY;
246 | }
247 | }
248 |
--------------------------------------------------------------------------------
/source/decore/recon.c:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * Copyright (c) 2018-2022 ["Peking University Shenzhen Graduate School",
3 | * "Peng Cheng Laboratory", and "Guangdong Bohua UHD Innovation Corporation"]
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the organizations (Peking University Shenzhen Graduate School,
15 | * Peng Cheng Laboratory and Guangdong Bohua UHD Innovation Corporation) nor the
16 | * names of its contributors may be used to endorse or promote products
17 | * derived from this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | * For more information, contact us at rgwang@pkusz.edu.cn.
31 | **************************************************************************************/
32 |
33 | #include "modules.h"
34 |
35 | void com_recon_l(s16 *resi, pel *pred, int i_pred, int width, int height, pel *rec, int i_rec, int cbf, int bit_depth)
36 | {
37 | int i, j;
38 |
39 | if (cbf == 0) {
40 | for (i = 0; i < height; i++) {
41 | memcpy(rec, pred, width * sizeof(pel));
42 | rec += i_rec;
43 | pred += i_pred;
44 | }
45 | } else {
46 | int max_val = (1 << bit_depth) - 1;
47 |
48 | for (i = 0; i < height; i++) {
49 | for (j = 0; j < width; j++) {
50 | int t0 = *resi++ + pred[j];
51 | rec[j] = COM_CLIP3(0, max_val, t0);
52 | }
53 | pred += i_pred;
54 | rec += i_rec;
55 | }
56 | }
57 | }
58 |
59 | void com_recon_c(s16 *resi_u, s16 *resi_v, pel *pred, int width, int height, pel *rec, int i_rec, u8 cbf[2], int bit_depth)
60 | {
61 | int i, j;
62 | int width2 = width << 1;
63 | pel *p = pred;
64 | pel *r = rec;
65 | int max_val = (1 << bit_depth) - 1;
66 |
67 | if (cbf[0] && cbf[1]) {
68 | for (i = 0; i < height; i++) {
69 | for (j = 0; j < width; j++) {
70 | int j2 = j << 1;
71 | int t0 = resi_u[j] + p[j2 ];
72 | int t1 = resi_v[j] + p[j2 + 1];
73 | r[j2 ] = COM_CLIP3(0, max_val, t0);
74 | r[j2 + 1] = COM_CLIP3(0, max_val, t1);
75 | }
76 | r += i_rec;
77 | resi_u += width;
78 | resi_v += width;
79 | p += width2;
80 | }
81 | } else {
82 | if (cbf[0] == 0) {
83 | for (i = 0; i < height; i++) {
84 | for (j = 0; j < width; j++) {
85 | int j2 = j << 1;
86 | int t0 = resi_v[j] + p[j2 + 1];
87 | r[j2 ] = p[j2];
88 | r[j2 + 1] = COM_CLIP3(0, max_val, t0);
89 | }
90 | r += i_rec;
91 | resi_v += width;
92 | p += width2;
93 | }
94 | }
95 | else {
96 | for (i = 0; i < height; i++) {
97 | for (j = 0; j < width; j++) {
98 | int j2 = j << 1;
99 | int t0 = resi_u[j] + p[j2];
100 | r[j2 ] = COM_CLIP3(0, max_val, t0);
101 | r[j2 + 1] = p[j2 + 1];
102 | }
103 | r += i_rec;
104 | resi_u += width;
105 | p += width2;
106 | }
107 | }
108 | }
109 | }
110 |
111 | void uavs3d_funs_init_recon_c() {
112 | int i;
113 | for (i = 0; i < BLOCK_WIDTH_TYPES_NUM; i++) {
114 | uavs3d_funs_handle.recon_luma[i] = com_recon_l;
115 | uavs3d_funs_handle.recon_chroma[i] = com_recon_c;
116 | }
117 | }
--------------------------------------------------------------------------------
/source/decore/sse/intra_pred_sse.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uavs3/uavs3d/1fd04917cff50fac72ae23e45f82ca6fd9130bd8/source/decore/sse/intra_pred_sse.c
--------------------------------------------------------------------------------
/source/decore/sse/itrans_sse.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uavs3/uavs3d/1fd04917cff50fac72ae23e45f82ca6fd9130bd8/source/decore/sse/itrans_sse.c
--------------------------------------------------------------------------------
/source/decore/sse/sse.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uavs3/uavs3d/1fd04917cff50fac72ae23e45f82ca6fd9130bd8/source/decore/sse/sse.c
--------------------------------------------------------------------------------
/source/decore/threadpool.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "threadpool.h"
4 |
5 | /* ---------------------------------------------------------------------------
6 | * multi line macros
7 | */
8 | #if !defined(_WIN32)
9 | #define __pragma(a)
10 | #endif
11 |
12 | #define MULTI_LINE_MACRO_BEGIN do {
13 | #if defined(__GNUC__)
14 | #define MULTI_LINE_MACRO_END \
15 | } while(0)
16 | #else
17 | #define MULTI_LINE_MACRO_END \
18 | __pragma(warning(push))\
19 | __pragma(warning(disable:4127))\
20 | } while(0)\
21 | __pragma(warning(pop))
22 | #endif
23 |
24 | #define CHECKED_MALLOC(var, type, size)\
25 | MULTI_LINE_MACRO_BEGIN\
26 | (var) = (type)malloc(size);\
27 | if ((var) == NULL) {\
28 | goto fail;\
29 | }\
30 | MULTI_LINE_MACRO_END
31 | #define CHECKED_MALLOCZERO(var, type, size)\
32 | MULTI_LINE_MACRO_BEGIN\
33 | CHECKED_MALLOC(var, type, size);\
34 | memset(var, 0, size);\
35 | MULTI_LINE_MACRO_END
36 |
37 | #define XCHG(type, a, b)\
38 | MULTI_LINE_MACRO_BEGIN\
39 | type __tmp = (a); (a) = (b); (b) = __tmp;\
40 | MULTI_LINE_MACRO_END
41 |
42 |
43 | /**
44 | * ===========================================================================
45 | * function defines
46 | * ===========================================================================
47 | */
48 |
49 | /* ---------------------------------------------------------------------------
50 | */
51 | threadpool_job_t *uavs3d_frame_shift(threadpool_job_t **list)
52 | {
53 | threadpool_job_t *job = list[0];
54 | int i;
55 | for (i = 0; list[i]; i++) {
56 | list[i] = list[i+1];
57 | }
58 | return job;
59 | }
60 |
61 |
62 | /* ---------------------------------------------------------------------------
63 | */
64 | void uavs3d_frame_delete(threadpool_job_t *job)
65 | {
66 | uavs3d_pthread_mutex_destroy(&job->mutex);
67 | uavs3d_pthread_cond_destroy(&job->cv);
68 | free(job);
69 | }
70 | /* ---------------------------------------------------------------------------
71 | */
72 | void uavs3d_frame_delete_list(threadpool_job_t **list)
73 | {
74 | int i = 0;
75 | if (!list) {
76 | return;
77 | }
78 | while (list[i]) {
79 | uavs3d_frame_delete(list[i++]);
80 | }
81 | free(list);
82 | }
83 |
84 | /* ---------------------------------------------------------------------------
85 | */
86 | void uavs3d_sync_frame_list_delete(threadpool_job_list_t *slist)
87 | {
88 | uavs3d_pthread_mutex_destroy(&slist->mutex);
89 | uavs3d_pthread_cond_destroy(&slist->cv_fill);
90 | uavs3d_pthread_cond_destroy(&slist->cv_empty);
91 | uavs3d_frame_delete_list(slist->list);
92 | }
93 |
94 | /* ---------------------------------------------------------------------------
95 | */
96 | void uavs3d_sync_frame_list_push(threadpool_job_list_t *slist, threadpool_job_t *job)
97 | {
98 | uavs3d_pthread_mutex_lock(&slist->mutex);
99 | while (slist->i_size == slist->i_max_size) {
100 | uavs3d_pthread_cond_wait(&slist->cv_empty, &slist->mutex);
101 | }
102 | slist->list[slist->i_size++] = job;
103 | uavs3d_pthread_cond_broadcast(&slist->cv_fill);
104 | uavs3d_pthread_mutex_unlock(&slist->mutex);
105 | }
106 |
107 | /* ---------------------------------------------------------------------------
108 | */
109 | threadpool_job_t *uavs3d_sync_frame_list_pop(threadpool_job_list_t *slist)
110 | {
111 | threadpool_job_t *job;
112 | uavs3d_pthread_mutex_lock(&slist->mutex);
113 | while (!slist->i_size) {
114 | uavs3d_pthread_cond_wait(&slist->cv_fill, &slist->mutex);
115 | }
116 | job = slist->list[--slist->i_size];
117 | slist->list[slist->i_size] = NULL;
118 | uavs3d_pthread_cond_broadcast(&slist->cv_empty);
119 | uavs3d_pthread_mutex_unlock(&slist->mutex);
120 | return job;
121 | }
122 |
123 | /* ---------------------------------------------------------------------------
124 | */
125 | threadpool_job_t *uavs3d_sync_frame_list_pop_try(threadpool_job_list_t *slist)
126 | {
127 | threadpool_job_t *job;
128 | uavs3d_pthread_mutex_lock(&slist->mutex);
129 | if (!slist->i_size) {
130 | uavs3d_pthread_mutex_unlock(&slist->mutex);
131 | return NULL;
132 | }
133 | job = slist->list[--slist->i_size];
134 | slist->list[slist->i_size] = NULL;
135 | uavs3d_pthread_cond_broadcast(&slist->cv_empty);
136 | uavs3d_pthread_mutex_unlock(&slist->mutex);
137 | return job;
138 | }
139 |
140 | /* ---------------------------------------------------------------------------
141 | */
142 | int uavs3d_sync_frame_list_init(threadpool_job_list_t *slist, int max_size)
143 | {
144 | if (max_size < 0) {
145 | return -1;
146 | }
147 | slist->i_max_size = max_size;
148 | slist->i_size = 0;
149 | CHECKED_MALLOCZERO(slist->list, threadpool_job_t **, (max_size + 1) * sizeof(threadpool_job_t *));
150 | if (uavs3d_pthread_mutex_init(&slist->mutex, NULL) ||
151 | uavs3d_pthread_cond_init(&slist->cv_fill, NULL) ||
152 | uavs3d_pthread_cond_init(&slist->cv_empty, NULL)) {
153 | return -1;
154 | }
155 | return 0;
156 | fail:
157 | return -1;
158 | }
159 |
160 | static void uavs3d_threadpool_list_delete(threadpool_job_list_t *slist)
161 | {
162 | int i;
163 | for (i = 0; slist->list[i]; i++) {
164 | free(slist->list[i]);
165 | slist->list[i] = NULL;
166 | }
167 | uavs3d_sync_frame_list_delete(slist);
168 | }
169 |
170 | static void uavs3d_threadpool_thread(threadpool_t *pool)
171 | {
172 | void *handle = NULL;
173 |
174 | if (pool->init_func) {
175 | handle = pool->init_func(pool->init_arg);
176 | }
177 |
178 | while (!pool->exit) {
179 | threadpool_job_t *job = NULL;
180 | uavs3d_pthread_mutex_lock(&pool->run.mutex);
181 | while (!pool->exit && !pool->run.i_size) {
182 | uavs3d_pthread_cond_wait(&pool->run.cv_fill, &pool->run.mutex);
183 | }
184 | if (pool->run.i_size) {
185 | job = (void *)uavs3d_frame_shift(pool->run.list);
186 | pool->run.i_size--;
187 | }
188 |
189 | uavs3d_pthread_mutex_unlock(&pool->run.mutex);
190 | if (!job) {
191 | continue;
192 | }
193 | job->ret = job->func(handle, job->arg); /* execute the function */
194 | if (job->wait) {
195 | uavs3d_sync_frame_list_push(&pool->done, (void *)job);
196 | }
197 | else {
198 | uavs3d_sync_frame_list_push(&pool->uninit, (void *)job);
199 | }
200 | }
201 |
202 | if (pool->deinit_func) {
203 | pool->deinit_func(handle);
204 | }
205 |
206 | pthread_exit(0);
207 | }
208 |
209 | int uavs3d_threadpool_init(threadpool_t **p_pool, int threads, int nodes, void* (*init_func)(void *), void *init_arg, void(*deinit_func)(void *))
210 | {
211 | int i;
212 | threadpool_t *pool;
213 |
214 | if (threads <= 0) {
215 | return -1;
216 | }
217 |
218 | CHECKED_MALLOCZERO(pool, threadpool_t *, sizeof(threadpool_t));
219 | *p_pool = pool;
220 |
221 | pool->init_func = init_func;
222 | pool->init_arg = init_arg;
223 | pool->deinit_func = deinit_func;
224 | pool->threads = threads;
225 |
226 | CHECKED_MALLOC(pool->thread_handle, uavs3d_pthread_t *, pool->threads * sizeof(uavs3d_pthread_t));
227 |
228 | if (uavs3d_sync_frame_list_init(&pool->uninit, nodes) ||
229 | uavs3d_sync_frame_list_init(&pool->run, nodes) ||
230 | uavs3d_sync_frame_list_init(&pool->done, nodes)) {
231 | goto fail;
232 | }
233 |
234 | for (i = 0; i < nodes; i++) {
235 | threadpool_job_t *job;
236 | CHECKED_MALLOC(job, threadpool_job_t*, sizeof(threadpool_job_t));
237 | uavs3d_sync_frame_list_push(&pool->uninit, (void *)job);
238 | }
239 | for (i = 0; i < pool->threads; i++) {
240 | if (uavs3d_pthread_create(pool->thread_handle + i, NULL, (uavs3d_tfunc_a_t)uavs3d_threadpool_thread, pool)) {
241 | goto fail;
242 | }
243 | }
244 |
245 | return 0;
246 | fail:
247 | return -1;
248 | }
249 |
250 | void uavs3d_threadpool_run(threadpool_t *pool, void *(*func)(void *, void *), void *arg, int wait_sign)
251 | {
252 | threadpool_job_t *job = (void *)uavs3d_sync_frame_list_pop(&pool->uninit);
253 | job->func = func;
254 | job->arg = arg;
255 | job->wait = wait_sign;
256 | uavs3d_sync_frame_list_push(&pool->run, (void *)job);
257 | }
258 |
259 | int uavs3d_threadpool_run_try(threadpool_t *pool, void *(*func)(void*, void *), void *arg, int wait_sign)
260 | {
261 | threadpool_job_t *job = (void *)uavs3d_sync_frame_list_pop_try(&pool->uninit);
262 |
263 | if (NULL == job) {
264 | return -1;
265 | }
266 | job->func = func;
267 | job->arg = arg;
268 | job->wait = wait_sign;
269 | uavs3d_sync_frame_list_push(&pool->run, (void *)job);
270 | return 0;
271 | }
272 |
273 | void *uavs3d_threadpool_wait(threadpool_t *pool, void *arg)
274 | {
275 | threadpool_job_t *job = NULL;
276 | int i;
277 | void *ret;
278 |
279 | uavs3d_pthread_mutex_lock(&pool->done.mutex);
280 | while (!job) {
281 | for (i = 0; i < pool->done.i_size; i++) {
282 | threadpool_job_t *t = (void *)pool->done.list[i];
283 | if (t->arg == arg) {
284 | job = (void *)uavs3d_frame_shift(pool->done.list + i);
285 | pool->done.i_size--;
286 | }
287 | }
288 | if (!job) {
289 | uavs3d_pthread_cond_wait(&pool->done.cv_fill, &pool->done.mutex);
290 | }
291 | }
292 | uavs3d_pthread_mutex_unlock(&pool->done.mutex);
293 |
294 | ret = job->ret;
295 | uavs3d_sync_frame_list_push(&pool->uninit, (void *)job);
296 | return ret;
297 | }
298 |
299 | void *uavs3d_threadpool_wait_try(threadpool_t *pool, void *arg)
300 | {
301 | threadpool_job_t *job = NULL;
302 | int i;
303 | void *ret;
304 |
305 | uavs3d_pthread_mutex_lock(&pool->done.mutex);
306 |
307 | for (i = 0; i < pool->done.i_size; i++) {
308 | threadpool_job_t *t = (void *)pool->done.list[i];
309 | if (t->arg == arg) {
310 | job = (void *)uavs3d_frame_shift(pool->done.list + i);
311 | pool->done.i_size--;
312 | }
313 | }
314 |
315 | uavs3d_pthread_mutex_unlock(&pool->done.mutex);
316 |
317 | if (job) {
318 | ret = job->ret;
319 | uavs3d_sync_frame_list_push(&pool->uninit, (void *)job);
320 | return ret;
321 | } else {
322 | return NULL;
323 | }
324 | }
325 |
326 |
327 |
328 | void uavs3d_threadpool_delete(threadpool_t *pool)
329 | {
330 | int i;
331 |
332 | uavs3d_pthread_mutex_lock(&pool->run.mutex);
333 | pool->exit = 1;
334 | uavs3d_pthread_cond_broadcast(&pool->run.cv_fill);
335 | uavs3d_pthread_mutex_unlock(&pool->run.mutex);
336 | for (i = 0; i < pool->threads; i++) {
337 | uavs3d_pthread_join(pool->thread_handle[i], NULL);
338 | }
339 |
340 | uavs3d_threadpool_list_delete(&pool->uninit);
341 | uavs3d_threadpool_list_delete(&pool->run);
342 | uavs3d_threadpool_list_delete(&pool->done);
343 | free(pool->thread_handle);
344 | free(pool);
345 | }
--------------------------------------------------------------------------------
/source/decore/threadpool.h:
--------------------------------------------------------------------------------
1 | #ifndef __THREADPOOL_H__
2 | #define __THREADPOOL_H__
3 |
4 | #if defined(_WIN32)
5 | #include
6 | #endif
7 |
8 | typedef void*(*uavs3d_tfunc_a_t)(void *);
9 | typedef volatile long atom_t; // 32 bits, signed
10 |
11 | #if defined(_WIN32)
12 | #include "win32thread.h"
13 | #else
14 | #include
15 | #define uavs3d_pthread_t pthread_t
16 | #define uavs3d_pthread_create pthread_create
17 | #define uavs3d_pthread_join pthread_join
18 | #define uavs3d_pthread_mutex_t pthread_mutex_t
19 | #define uavs3d_pthread_mutex_init pthread_mutex_init
20 | #define uavs3d_pthread_mutex_destroy pthread_mutex_destroy
21 | #define uavs3d_pthread_mutex_lock pthread_mutex_lock
22 | #define uavs3d_pthread_mutex_unlock pthread_mutex_unlock
23 | #define uavs3d_pthread_cond_t pthread_cond_t
24 | #define uavs3d_pthread_cond_init pthread_cond_init
25 | #define uavs3d_pthread_cond_destroy pthread_cond_destroy
26 | #define uavs3d_pthread_cond_broadcast pthread_cond_broadcast
27 | #define uavs3d_pthread_cond_wait pthread_cond_wait
28 | #define uavs3d_pthread_attr_t pthread_attr_t
29 | #define uavs3d_pthread_attr_init pthread_attr_init
30 | #define uavs3d_pthread_attr_destroy pthread_attr_destroy
31 | #define uavs3d_pthread_num_processors_np pthread_num_processors_np
32 |
33 | #endif
34 |
35 |
36 | /**
37 | * ===========================================================================
38 | * type defines
39 | * ===========================================================================
40 | */
41 | typedef struct uavs3d_threadpool_job_t {
42 | void *(*func)(void *, void *);
43 | void *arg;
44 | void *ret;
45 | int wait;
46 | uavs3d_pthread_mutex_t mutex;
47 | uavs3d_pthread_cond_t cv;
48 | } threadpool_job_t;
49 |
50 | typedef struct uavs3d_threadpool_job_list_t {
51 | threadpool_job_t **list;
52 | int i_max_size;
53 | int i_size;
54 | uavs3d_pthread_mutex_t mutex;
55 | uavs3d_pthread_cond_t cv_fill; /* event signaling that the list became fuller */
56 | uavs3d_pthread_cond_t cv_empty; /* event signaling that the list became emptier */
57 | } threadpool_job_list_t;
58 |
59 | typedef struct uavs3d_threadpool_t {
60 | int exit;
61 | int threads;
62 | uavs3d_pthread_t *thread_handle;
63 | void* (*init_func)(void *);
64 | void (*deinit_func)(void *);
65 | void *init_arg;
66 |
67 | threadpool_job_list_t uninit; /* list of jobs that are awaiting use */
68 | threadpool_job_list_t run; /* list of jobs that are queued for processing by the pool */
69 | threadpool_job_list_t done; /* list of jobs that have finished processing */
70 | } threadpool_t;
71 |
72 | int uavs3d_threadpool_init(threadpool_t **p_pool, int threads, int nodes, void*(*init_func)(void *), void *init_arg, void(*deinit_func)(void *));
73 | void uavs3d_threadpool_run(threadpool_t *pool, void *(*func)(void *, void *), void *arg, int wait_sign);
74 | void *uavs3d_threadpool_wait(threadpool_t *pool, void *arg);
75 | void uavs3d_threadpool_delete(threadpool_t *pool);
76 |
77 | int uavs3d_threadpool_run_try(threadpool_t *pool, void *(*func)(void *, void *), void *arg, int wait_sign);
78 | void *uavs3d_threadpool_wait_try(threadpool_t *pool, void *arg);
79 |
80 |
81 | #endif /* #ifndef __THREADPOOL_H__ */
82 |
--------------------------------------------------------------------------------
/source/decore/win32thread.c:
--------------------------------------------------------------------------------
1 | #if defined(_WIN32)
2 |
3 | #include "win32thread.h"
4 | #include
5 |
6 |
7 | /**
8 | * ===========================================================================
9 | * type defines
10 | * ===========================================================================
11 | */
12 |
13 | /* number of times to spin a thread about to block on a locked mutex before retrying and sleeping if still locked */
14 | #define AVS2_SPIN_COUNT 0
15 |
16 | /* GROUP_AFFINITY struct */
17 | typedef struct uavs3d_group_affinity_t {
18 | ULONG_PTR mask; // KAFFINITY = ULONG_PTR
19 | USHORT group;
20 | USHORT reserved[3];
21 | } uavs3d_group_affinity_t;
22 |
23 | typedef void (WINAPI *cond_func_t)(uavs3d_pthread_cond_t *cond);
24 | typedef BOOL (WINAPI *cond_wait_t)(uavs3d_pthread_cond_t *cond, uavs3d_pthread_mutex_t *mutex, DWORD milliseconds);
25 |
26 | typedef struct uavs3d_win32thread_control_t{
27 | /* global mutex for replacing MUTEX_INITIALIZER instances */
28 | uavs3d_pthread_mutex_t static_mutex;
29 |
30 | /* function pointers to conditional variable API on windows 6.0+ kernels */
31 | cond_func_t cond_broadcast;
32 | cond_func_t cond_init;
33 | cond_func_t cond_signal;
34 | cond_wait_t cond_wait;
35 | } uavs3d_win32thread_control_t;
36 |
37 | static uavs3d_win32thread_control_t thread_control;
38 |
39 |
40 | /**
41 | * ===========================================================================
42 | * function defines
43 | * ===========================================================================
44 | */
45 |
46 | /* _beginthreadex requires that the start routine is __stdcall */
47 | static unsigned __stdcall uavs3d_win32thread_worker(void *arg)
48 | {
49 | uavs3d_pthread_t *h = arg;
50 | h->ret = h->func(h->arg);
51 | return 0;
52 | }
53 |
54 | int uavs3d_pthread_create(uavs3d_pthread_t *thread, const uavs3d_pthread_attr_t *attr,
55 | void *(*start_routine)(void *), void *arg)
56 | {
57 | thread->func = start_routine;
58 | thread->arg = arg;
59 | thread->handle = (void *)_beginthreadex(NULL, 0, uavs3d_win32thread_worker, thread, 0, NULL);
60 | return !thread->handle;
61 | }
62 |
63 | int uavs3d_pthread_join(uavs3d_pthread_t thread, void **value_ptr)
64 | {
65 | DWORD ret = WaitForSingleObject(thread.handle, INFINITE);
66 | if (ret != WAIT_OBJECT_0) {
67 | return -1;
68 | }
69 | if (value_ptr) {
70 | *value_ptr = thread.ret;
71 | }
72 | CloseHandle(thread.handle);
73 | return 0;
74 | }
75 |
76 | int uavs3d_pthread_mutex_init(uavs3d_pthread_mutex_t *mutex, const uavs3d_pthread_mutexattr_t *attr)
77 | {
78 | return !InitializeCriticalSectionAndSpinCount(mutex, AVS2_SPIN_COUNT);
79 | }
80 |
81 | int uavs3d_pthread_mutex_destroy(uavs3d_pthread_mutex_t *mutex)
82 | {
83 | DeleteCriticalSection(mutex);
84 | return 0;
85 | }
86 |
87 | int uavs3d_pthread_mutex_lock(uavs3d_pthread_mutex_t *mutex)
88 | {
89 | static uavs3d_pthread_mutex_t init = { 0 };
90 | if (!memcmp(mutex, &init, sizeof(uavs3d_pthread_mutex_t))) {
91 | *mutex = thread_control.static_mutex;
92 | }
93 | EnterCriticalSection(mutex);
94 | return 0;
95 | }
96 |
97 | int uavs3d_pthread_mutex_unlock(uavs3d_pthread_mutex_t *mutex)
98 | {
99 | LeaveCriticalSection(mutex);
100 | return 0;
101 | }
102 |
103 | /* for pre-Windows 6.0 platforms we need to define and use our own condition variable and api */
104 | typedef struct uavs3d_win32_cond_t {
105 | uavs3d_pthread_mutex_t mtx_broadcast;
106 | uavs3d_pthread_mutex_t mtx_waiter_count;
107 | int waiter_count;
108 | HANDLE semaphore;
109 | HANDLE waiters_done;
110 | int is_broadcast;
111 | } uavs3d_win32_cond_t;
112 |
113 | int uavs3d_pthread_cond_init(uavs3d_pthread_cond_t *cond, const uavs3d_pthread_condattr_t *attr)
114 | {
115 | uavs3d_win32_cond_t *win32_cond;
116 | if (thread_control.cond_init) {
117 | thread_control.cond_init(cond);
118 | return 0;
119 | }
120 |
121 | /* non native condition variables */
122 | win32_cond = calloc(1, sizeof(uavs3d_win32_cond_t));
123 | if (!win32_cond) {
124 | return -1;
125 | }
126 | cond->ptr = win32_cond;
127 | win32_cond->semaphore = CreateSemaphore(NULL, 0, 0x7fffffff, NULL);
128 | if (!win32_cond->semaphore) {
129 | return -1;
130 | }
131 |
132 | if (uavs3d_pthread_mutex_init(&win32_cond->mtx_waiter_count, NULL)) {
133 | return -1;
134 | }
135 | if (uavs3d_pthread_mutex_init(&win32_cond->mtx_broadcast, NULL)) {
136 | return -1;
137 | }
138 |
139 | win32_cond->waiters_done = CreateEvent(NULL, FALSE, FALSE, NULL);
140 | if (!win32_cond->waiters_done) {
141 | return -1;
142 | }
143 |
144 | return 0;
145 | }
146 |
147 | int uavs3d_pthread_cond_destroy(uavs3d_pthread_cond_t *cond)
148 | {
149 | uavs3d_win32_cond_t *win32_cond;
150 | /* native condition variables do not destroy */
151 | if (thread_control.cond_init) {
152 | return 0;
153 | }
154 |
155 | /* non native condition variables */
156 | win32_cond = cond->ptr;
157 | CloseHandle(win32_cond->semaphore);
158 | CloseHandle(win32_cond->waiters_done);
159 | uavs3d_pthread_mutex_destroy(&win32_cond->mtx_broadcast);
160 | uavs3d_pthread_mutex_destroy(&win32_cond->mtx_waiter_count);
161 | free(win32_cond);
162 |
163 | return 0;
164 | }
165 |
166 | int uavs3d_pthread_cond_broadcast(uavs3d_pthread_cond_t *cond)
167 | {
168 | uavs3d_win32_cond_t *win32_cond;
169 | int have_waiter = 0;
170 | if (thread_control.cond_broadcast) {
171 | thread_control.cond_broadcast(cond);
172 | return 0;
173 | }
174 |
175 | /* non native condition variables */
176 | win32_cond = cond->ptr;
177 | uavs3d_pthread_mutex_lock(&win32_cond->mtx_broadcast);
178 | uavs3d_pthread_mutex_lock(&win32_cond->mtx_waiter_count);
179 |
180 | if (win32_cond->waiter_count) {
181 | win32_cond->is_broadcast = 1;
182 | have_waiter = 1;
183 | }
184 |
185 | if (have_waiter) {
186 | ReleaseSemaphore(win32_cond->semaphore, win32_cond->waiter_count, NULL);
187 | uavs3d_pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
188 | WaitForSingleObject(win32_cond->waiters_done, INFINITE);
189 | win32_cond->is_broadcast = 0;
190 | } else {
191 | uavs3d_pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
192 | }
193 | return uavs3d_pthread_mutex_unlock(&win32_cond->mtx_broadcast);
194 | }
195 |
196 | int uavs3d_pthread_cond_signal(uavs3d_pthread_cond_t *cond)
197 | {
198 | uavs3d_win32_cond_t *win32_cond;
199 | int have_waiter;
200 | if (thread_control.cond_signal) {
201 | thread_control.cond_signal(cond);
202 | return 0;
203 | }
204 |
205 | /* non-native condition variables */
206 | win32_cond = cond->ptr;
207 | uavs3d_pthread_mutex_lock(&win32_cond->mtx_waiter_count);
208 | have_waiter = win32_cond->waiter_count;
209 | uavs3d_pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
210 |
211 | if (have_waiter) {
212 | ReleaseSemaphore(win32_cond->semaphore, 1, NULL);
213 | }
214 | return 0;
215 | }
216 |
217 | int uavs3d_pthread_cond_wait(uavs3d_pthread_cond_t *cond, uavs3d_pthread_mutex_t *mutex)
218 | {
219 | uavs3d_win32_cond_t *win32_cond;
220 | int last_waiter;
221 | if (thread_control.cond_wait) {
222 | return !thread_control.cond_wait(cond, mutex, INFINITE);
223 | }
224 |
225 | /* non native condition variables */
226 | win32_cond = cond->ptr;
227 |
228 | uavs3d_pthread_mutex_lock(&win32_cond->mtx_broadcast);
229 | uavs3d_pthread_mutex_unlock(&win32_cond->mtx_broadcast);
230 |
231 | uavs3d_pthread_mutex_lock(&win32_cond->mtx_waiter_count);
232 | win32_cond->waiter_count++;
233 | uavs3d_pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
234 |
235 | // unlock the external mutex
236 | uavs3d_pthread_mutex_unlock(mutex);
237 | WaitForSingleObject(win32_cond->semaphore, INFINITE);
238 |
239 | uavs3d_pthread_mutex_lock(&win32_cond->mtx_waiter_count);
240 | win32_cond->waiter_count--;
241 | last_waiter = !win32_cond->waiter_count && win32_cond->is_broadcast;
242 | uavs3d_pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
243 |
244 | if (last_waiter) {
245 | SetEvent(win32_cond->waiters_done);
246 | }
247 |
248 | // lock the external mutex
249 | return uavs3d_pthread_mutex_lock(mutex);
250 | }
251 |
252 | int uavs3d_win32_threading_init(void)
253 | {
254 | /* find function pointers to API functions, if they exist */
255 | HMODULE kernel_dll = GetModuleHandle(TEXT("kernel32"));
256 | thread_control.cond_init = (cond_func_t)GetProcAddress(kernel_dll, "InitializeConditionVariable");
257 | if (thread_control.cond_init) {
258 | /* we're on a windows 6.0+ kernel, acquire the rest of the functions */
259 | thread_control.cond_broadcast = (cond_func_t)GetProcAddress(kernel_dll, "WakeAllConditionVariable");
260 | thread_control.cond_signal = (cond_func_t)GetProcAddress(kernel_dll, "WakeConditionVariable");
261 | thread_control.cond_wait = (cond_wait_t)GetProcAddress(kernel_dll, "SleepConditionVariableCS");
262 | }
263 | return uavs3d_pthread_mutex_init(&thread_control.static_mutex, NULL);
264 | }
265 |
266 | void uavs3d_win32_threading_destroy(void)
267 | {
268 | uavs3d_pthread_mutex_destroy(&thread_control.static_mutex);
269 | memset(&thread_control, 0, sizeof(uavs3d_win32thread_control_t));
270 | }
271 |
272 | int uavs3d_pthread_num_processors_np()
273 | {
274 | DWORD_PTR system_cpus, process_cpus = 0;
275 | int cpus = 0;
276 | DWORD_PTR bit;
277 |
278 | /* GetProcessAffinityMask returns affinities of 0 when the process has threads in multiple processor groups.
279 | * On platforms that support processor grouping, use GetThreadGroupAffinity to get the current thread's affinity instead. */
280 | #if ARCH_X86_64
281 | /* find function pointers to API functions specific to x86_64 platforms, if they exist */
282 | HANDLE kernel_dll = GetModuleHandle(TEXT("kernel32.dll"));
283 | BOOL (*get_thread_affinity)(HANDLE thread, uavs3d_group_affinity_t * group_affinity) = (void *)GetProcAddress(kernel_dll, "GetThreadGroupAffinity");
284 | if (get_thread_affinity) {
285 | /* running on a platform that supports >64 logical cpus */
286 | uavs3d_group_affinity_t thread_affinity;
287 | if (get_thread_affinity(GetCurrentThread(), &thread_affinity)) {
288 | process_cpus = thread_affinity.mask;
289 | }
290 | }
291 | #endif
292 | if (!process_cpus) {
293 | GetProcessAffinityMask(GetCurrentProcess(), &process_cpus, &system_cpus);
294 | }
295 | for (bit = 1; bit; bit <<= 1) {
296 | cpus += !!(process_cpus & bit);
297 | }
298 |
299 | return cpus ? cpus : 1;
300 | }
301 |
302 | #endif
--------------------------------------------------------------------------------
/source/decore/win32thread.h:
--------------------------------------------------------------------------------
1 | #ifndef __WIN32THREAD_H__
2 | #define __WIN32THREAD_H__
3 |
4 | #include
5 |
6 | /* the following macro is used within cavs */
7 | #undef ERROR
8 |
9 | typedef struct uavs3d_pthread_t {
10 | void *handle;
11 | void *(*func)(void *arg);
12 | void *arg;
13 | void *ret;
14 | } uavs3d_pthread_t;
15 |
16 | #define uavs3d_pthread_attr_t int
17 |
18 | /* the conditional variable api for windows 6.0+ uses critical sections and not mutexes */
19 | typedef CRITICAL_SECTION uavs3d_pthread_mutex_t;
20 |
21 | #define uavs3d_pthread_mutexattr_t int
22 | #define pthread_exit(a)
23 | /* This is the CONDITIONAL_VARIABLE typedef for using Window's native conditional variables on kernels 6.0+.
24 | * MinGW does not currently have this typedef. */
25 | typedef struct uavs3d_pthread_cond_t {
26 | void *ptr;
27 | } uavs3d_pthread_cond_t;
28 |
29 | #define uavs3d_pthread_condattr_t int
30 |
31 | int uavs3d_pthread_create(uavs3d_pthread_t *thread, const uavs3d_pthread_attr_t *attr,
32 | void *(*start_routine)(void *), void *arg);
33 | int uavs3d_pthread_join(uavs3d_pthread_t thread, void **value_ptr);
34 |
35 | int uavs3d_pthread_mutex_init(uavs3d_pthread_mutex_t *mutex, const uavs3d_pthread_mutexattr_t *attr);
36 | int uavs3d_pthread_mutex_destroy(uavs3d_pthread_mutex_t *mutex);
37 | int uavs3d_pthread_mutex_lock(uavs3d_pthread_mutex_t *mutex);
38 | int uavs3d_pthread_mutex_unlock(uavs3d_pthread_mutex_t *mutex);
39 |
40 | int uavs3d_pthread_cond_init(uavs3d_pthread_cond_t *cond, const uavs3d_pthread_condattr_t *attr);
41 | int uavs3d_pthread_cond_destroy(uavs3d_pthread_cond_t *cond);
42 | int uavs3d_pthread_cond_broadcast(uavs3d_pthread_cond_t *cond);
43 | int uavs3d_pthread_cond_wait(uavs3d_pthread_cond_t *cond, uavs3d_pthread_mutex_t *mutex);
44 | int uavs3d_pthread_cond_signal(uavs3d_pthread_cond_t *cond);
45 |
46 | #define uavs3d_pthread_attr_init(a) 0
47 | #define uavs3d_pthread_attr_destroy(a) 0
48 |
49 | int uavs3d_win32_threading_init(void);
50 | void uavs3d_win32_threading_destroy(void);
51 |
52 | int uavs3d_pthread_num_processors_np(void);
53 |
54 | #endif // #ifndef __WIN32THREAD_H__
55 |
--------------------------------------------------------------------------------
/test/utest.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************************
2 | * Copyright (c) 2018-2022 ["Peking University Shenzhen Graduate School",
3 | * "Peng Cheng Laboratory", and "Guangdong Bohua UHD Innovation Corporation"]
4 | *
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the organizations (Peking University Shenzhen Graduate School,
15 | * Peng Cheng Laboratory and Guangdong Bohua UHD Innovation Corporation) nor the
16 | * names of its contributors may be used to endorse or promote products
17 | * derived from this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | * For more information, contact us at rgwang@pkusz.edu.cn.
31 | **************************************************************************************/
32 |
33 | #ifndef __UTEST_H__
34 | #define __UTEST_H__
35 |
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 |
42 | #include "../source/decoder/uavs3d.h"
43 |
44 | /* print function ************************************************************/
45 | //#if defined(__ANDROID__)
46 | //#include
47 | //#define LOGE(format, ...) __android_log_print(ANDROID_LOG_ERROR, "(>_<)", format, ##__VA_ARGS__)
48 | //#define LOGI(format, ...) __android_log_print(ANDROID_LOG_INFO, "(=_=)", format, ##__VA_ARGS__)
49 |
50 | //#define print(args...) LOGI(args)
51 | //#elif defined(__GNUC__)
52 | #if defined(__GNUC__)
53 | #define print(args...) printf(args)
54 | #else
55 | #define print(args, ...) printf(args, __VA_ARGS__)
56 | #endif
57 |
58 | #define LOG_LVL_0 0
59 | #define LOG_LVL_1 1
60 | #define LOG_LVL_2 2
61 |
62 | static int cfg_log_level = 2;
63 |
64 | #if defined(__GNUC__)
65 | #define log_level_0(args...) {if(cfg_log_level >= LOG_LVL_0) {print(args);}}
66 | #define log_level_1(args...) {if(cfg_log_level >= LOG_LVL_1) {print(args);}}
67 | #define log_level_2(args...) {if(cfg_log_level >= LOG_LVL_2) {print(args);}}
68 | #else
69 | #define log_level_0(args,...) {if(cfg_log_level >= LOG_LVL_0){print(args,__VA_ARGS__);}}
70 | #define log_level_1(args,...) {if(cfg_log_level >= LOG_LVL_1){print(args,__VA_ARGS__);}}
71 | #define log_level_2(args,...) {if(cfg_log_level >= LOG_LVL_2){print(args,__VA_ARGS__);}}
72 | #endif
73 | /****************************************************************************/
74 | #if defined(WIN32) || defined(WIN64)
75 | #include
76 |
77 | #define TIME_SCALE 1
78 | #define get_time() GetTickCount()
79 |
80 | /****************************************************************************/
81 | #elif defined(__GNUC__) || defined(ANDROID)
82 | #include
83 | #include
84 |
85 | #define TIME_SCALE 10
86 |
87 | static long long get_time(void)
88 | {
89 | struct timeval t;
90 | gettimeofday(&t, NULL);
91 | return t.tv_sec*10000L + t.tv_usec/100L;
92 | }
93 | #endif
94 |
95 |
96 | static long long app_get_time_dur(long long start)
97 | {
98 | return get_time() - start;
99 | }
100 |
101 | #define SCALE_TIME(clk) ((int)((clk + (TIME_SCALE/2))/TIME_SCALE))
102 |
103 | #if defined(__APPLE__) && (defined(__arm64__) || defined(__ARM_NEON__))
104 | int uavs3d_decode_sample(int argc, const char **argv);
105 | #endif
106 |
107 | #endif /* __APP_UTIL_H__ */
108 |
--------------------------------------------------------------------------------
/version.bat:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 | sh version.sh
3 | pause
4 |
--------------------------------------------------------------------------------
/version.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # ============================================================================
4 | # File:
5 | # version.sh
6 | # - get version of repository and generate the file version.h
7 | # ============================================================================
8 |
9 | # get version of remote and local repository
10 |
11 | shell_dir=""
12 | if [ ! -n "$1" ]; then
13 | shell_dir="."
14 | else
15 | shell_dir=$1
16 | fi
17 |
18 | VER_R=`git rev-list origin/master | sort | wc -l | awk '{print $1}'`
19 | VER_L=`git rev-list HEAD | sort | wc -l | awk '{print $1}'`
20 | VER_SHA1=`git log -n 1 | head -n 1 | cut -d ' ' -f 2`
21 |
22 | major_version="1"
23 | minor_version="2"
24 | type_version="release"
25 |
26 | # generate the file version.h
27 | echo "// ===========================================================================" > $shell_dir/version.h
28 | echo "// version.h" >> $shell_dir/version.h
29 | echo "// - collection of version numbers" >> $shell_dir/version.h
30 | echo "// ===========================================================================" >> $shell_dir/version.h
31 | echo "" >> $shell_dir/version.h
32 | echo "#ifndef __VERSION_H__" >> $shell_dir/version.h
33 | echo "#define __VERSION_H__" >> $shell_dir/version.h
34 | echo "" >> $shell_dir/version.h
35 | echo "#define VER_MAJOR $major_version // major version number" >> $shell_dir/version.h
36 | echo "#define VER_MINOR $minor_version // minor version number" >> $shell_dir/version.h
37 | echo "#define VER_BUILD $VER_L // build number" >> $shell_dir/version.h
38 | echo "" >> $shell_dir/version.h
39 | echo "#define VERSION_TYPE \"$type_version\"" >> $shell_dir/version.h
40 | echo "#define VERSION_STR \"$major_version.$minor_version.$VER_L\"" >> $shell_dir/version.h
41 | echo "#define VERSION_SHA1 \"$VER_SHA1\"" >> $shell_dir/version.h
42 | echo "" >> $shell_dir/version.h
43 | echo "#endif // __VERSION_H__" >> $shell_dir/version.h
44 |
45 | # show version informations
46 | echo " "
47 | echo " GIT VERSION TOOLS"
48 | echo " ====================="
49 | echo " "
50 | echo " get the code version number of remote & local repository."
51 | echo " "
52 | echo " remote: $VER_R"
53 | echo " local: $VER_L"
54 | echo " SHA-1: $VER_SHA1"
55 | echo " "
56 | echo " remote version $VER_L is added to file version.h, such as:"
57 | echo " "
58 | echo " #define VER_BUILD $VER_L"
59 | echo " "
60 | echo " #define VERSION_SHA1 $VER_SHA1"
61 | echo " "
62 |
--------------------------------------------------------------------------------