Compare commits
334 Commits
openh264v1
...
v1.4.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4adf9cd6dd | ||
|
|
343c7f2923 | ||
|
|
bdb850d29e | ||
|
|
d3ff712c15 | ||
|
|
52cb8c1135 | ||
|
|
440689458a | ||
|
|
dc8471894b | ||
|
|
3cbcc043f9 | ||
|
|
f0732c2c76 | ||
|
|
f3005bbe37 | ||
|
|
56fc515b02 | ||
|
|
51a38ab17a | ||
|
|
e8db09fb56 | ||
|
|
366b012d68 | ||
|
|
26aeb3494c | ||
|
|
0bc453423c | ||
|
|
3a75956fb2 | ||
|
|
d086f28a30 | ||
|
|
18b202df0a | ||
|
|
46de229fee | ||
|
|
0ef69e55e2 | ||
|
|
5921e5e7d3 | ||
|
|
2c44dbae5c | ||
|
|
4048b9791a | ||
|
|
3022d4f655 | ||
|
|
b304687197 | ||
|
|
06b8e1abb7 | ||
|
|
5b12578960 | ||
|
|
9ef0c74fdd | ||
|
|
94d1976a4e | ||
|
|
5a1aedb622 | ||
|
|
153dd0d3f5 | ||
|
|
63926a3d10 | ||
|
|
303bf77e42 | ||
|
|
d28970d625 | ||
|
|
2da0ce6451 | ||
|
|
afbb499c77 | ||
|
|
7c9597c36d | ||
|
|
bf3cc1ed63 | ||
|
|
cea83438bf | ||
|
|
e8cdbd2ea7 | ||
|
|
67664f4dc0 | ||
|
|
c301db696e | ||
|
|
2294b786cf | ||
|
|
9ea4d5bd73 | ||
|
|
497b38e341 | ||
|
|
861f54887d | ||
|
|
7208ed14b1 | ||
|
|
e29ceca392 | ||
|
|
15723e1204 | ||
|
|
1641ce9ee5 | ||
|
|
f9080ac090 | ||
|
|
a73c1e6814 | ||
|
|
7d6d86b63a | ||
|
|
4e9e5f5c36 | ||
|
|
5683393f38 | ||
|
|
ab3b55ae9c | ||
|
|
943981abc4 | ||
|
|
bea361a1f0 | ||
|
|
9391c1586d | ||
|
|
58d9efb582 | ||
|
|
9008b15d94 | ||
|
|
8fc2af760f | ||
|
|
296ab4d490 | ||
|
|
431bcee310 | ||
|
|
7d055cae94 | ||
|
|
8246225eed | ||
|
|
3f19534dd6 | ||
|
|
0a2cd1e59a | ||
|
|
bc1b28b5dd | ||
|
|
09518da545 | ||
|
|
6c1aa29431 | ||
|
|
dc067286b3 | ||
|
|
0a8a4f2284 | ||
|
|
d3b2be5ec2 | ||
|
|
442230a91d | ||
|
|
2211324e2b | ||
|
|
87b73257cb | ||
|
|
fba745f04e | ||
|
|
1734133012 | ||
|
|
e4a278620b | ||
|
|
4f237b51ef | ||
|
|
713beb7df7 | ||
|
|
5fdd01ec0c | ||
|
|
e7a7a35611 | ||
|
|
a3063531c4 | ||
|
|
ee515e8b35 | ||
|
|
fb5c60b6fc | ||
|
|
7629543e3e | ||
|
|
79b38f55ff | ||
|
|
16ca41cada | ||
|
|
0f1737e035 | ||
|
|
5a78735802 | ||
|
|
8d539600bb | ||
|
|
84b3216d7c | ||
|
|
3243a78959 | ||
|
|
195df08bb9 | ||
|
|
4394d22b70 | ||
|
|
2356eb1ff6 | ||
|
|
078d96bef7 | ||
|
|
869870e670 | ||
|
|
3c085aec79 | ||
|
|
9b442b3d44 | ||
|
|
e48cf9f471 | ||
|
|
28469ab3dc | ||
|
|
76b0f8c17a | ||
|
|
02365371e8 | ||
|
|
9ea6603071 | ||
|
|
30d7352d03 | ||
|
|
a4f09f4d76 | ||
|
|
4f4adcec49 | ||
|
|
59b3b428a2 | ||
|
|
8a84d14617 | ||
|
|
7ab0386436 | ||
|
|
605f2fb858 | ||
|
|
f03edd79c2 | ||
|
|
9a0663620a | ||
|
|
1a7d0ab831 | ||
|
|
909a508749 | ||
|
|
5d67df4adb | ||
|
|
151dfe04d5 | ||
|
|
9a9fc4c489 | ||
|
|
1127aa7761 | ||
|
|
8b6bf0499f | ||
|
|
bb21b62cbd | ||
|
|
1cf68cad13 | ||
|
|
a8262dd9e6 | ||
|
|
c245cd2d68 | ||
|
|
095bb83e77 | ||
|
|
b6e28495dd | ||
|
|
1be2cd14c0 | ||
|
|
e4260f6e97 | ||
|
|
b444f8d9d0 | ||
|
|
853d2922db | ||
|
|
7354a8cbae | ||
|
|
c4c73ee5d6 | ||
|
|
051a16e02e | ||
|
|
5752888c81 | ||
|
|
a00dd56f1c | ||
|
|
e5c2f333be | ||
|
|
d9ee702031 | ||
|
|
23b20fb14c | ||
|
|
279e14b34e | ||
|
|
10e2f90b7e | ||
|
|
ca97f78ae8 | ||
|
|
8084a2c797 | ||
|
|
4df4c1d757 | ||
|
|
49af2b592d | ||
|
|
cf3e7b5dec | ||
|
|
478af8f00c | ||
|
|
8ecb8b4200 | ||
|
|
420a81afe4 | ||
|
|
9fc9acfd14 | ||
|
|
7d9fc35235 | ||
|
|
5b27407993 | ||
|
|
1b48e6c88c | ||
|
|
d557578be3 | ||
|
|
f404ce2e56 | ||
|
|
e64e2bb620 | ||
|
|
4192165ec9 | ||
|
|
faf62464a8 | ||
|
|
4ca8ad2612 | ||
|
|
deccd1eadb | ||
|
|
1ae06eab91 | ||
|
|
e2fb48d404 | ||
|
|
8d5ec6759d | ||
|
|
89159ab25f | ||
|
|
f13624316e | ||
|
|
45e3424364 | ||
|
|
4b52d99d97 | ||
|
|
de68ec6f45 | ||
|
|
51f1ea3839 | ||
|
|
acafbb442d | ||
|
|
6afdf36ecc | ||
|
|
7f967f6fc4 | ||
|
|
dfd24a987d | ||
|
|
a45c661525 | ||
|
|
6dcaf2f890 | ||
|
|
e7fff10d91 | ||
|
|
17030193e6 | ||
|
|
d74234d975 | ||
|
|
6664593ef7 | ||
|
|
4b231c8fe6 | ||
|
|
96b1183574 | ||
|
|
5b10c1ff8d | ||
|
|
bd7fabd892 | ||
|
|
8cc53b0231 | ||
|
|
489d121549 | ||
|
|
ee40ba6392 | ||
|
|
8bef6bc942 | ||
|
|
2df0185252 | ||
|
|
d6f7a07b14 | ||
|
|
c1aa2a1edb | ||
|
|
fcae7fd300 | ||
|
|
58f1fef520 | ||
|
|
01fd220ef9 | ||
|
|
eb7b149fcc | ||
|
|
4930111ad3 | ||
|
|
d9502aa71d | ||
|
|
50ce93e31c | ||
|
|
7d1d2d658f | ||
|
|
5702e7c0ca | ||
|
|
c69d628a82 | ||
|
|
4df6f9420f | ||
|
|
3cf2be2590 | ||
|
|
9e00bf89aa | ||
|
|
4f33b38ac1 | ||
|
|
b83b19254d | ||
|
|
96384bd578 | ||
|
|
af938a640f | ||
|
|
ef82e18d74 | ||
|
|
1646f86b37 | ||
|
|
a1b8ffc9df | ||
|
|
a852ac99ed | ||
|
|
93cb617932 | ||
|
|
99925984b3 | ||
|
|
cd55201600 | ||
|
|
a44643aeda | ||
|
|
aea1017562 | ||
|
|
9ba316caf4 | ||
|
|
d6b4b5365d | ||
|
|
75bbc286e1 | ||
|
|
c8972f1c32 | ||
|
|
98ed302990 | ||
|
|
e9ec603fd7 | ||
|
|
dbcbe180e6 | ||
|
|
b603844126 | ||
|
|
0250acc665 | ||
|
|
d7304bbaf4 | ||
|
|
264cf57616 | ||
|
|
5b5cc8434e | ||
|
|
ea533e6405 | ||
|
|
993caea18c | ||
|
|
cb49f8ecbd | ||
|
|
fc6ea7e5a8 | ||
|
|
9a55a8609e | ||
|
|
560a33a373 | ||
|
|
c02d9b0865 | ||
|
|
4f826f2e94 | ||
|
|
a39c46601d | ||
|
|
f594d96a51 | ||
|
|
34661f1d86 | ||
|
|
cdd072e1d4 | ||
|
|
47dd4de412 | ||
|
|
1518b5da58 | ||
|
|
8e35224134 | ||
|
|
ea06cbe06b | ||
|
|
04cb9f3477 | ||
|
|
958c60d041 | ||
|
|
44bce08d60 | ||
|
|
a4ae5e3747 | ||
|
|
76ef30dc82 | ||
|
|
a5cb0ea22c | ||
|
|
900a908929 | ||
|
|
3a91abf28c | ||
|
|
e48585236e | ||
|
|
d92853c88e | ||
|
|
fb33b359d5 | ||
|
|
17a87e8081 | ||
|
|
71123f29ef | ||
|
|
178a18b30e | ||
|
|
735172d387 | ||
|
|
5c3c2a569c | ||
|
|
aa1ec23ecd | ||
|
|
62c6a1e099 | ||
|
|
207082e237 | ||
|
|
68ff8468af | ||
|
|
61cd77d487 | ||
|
|
e8b68d2460 | ||
|
|
ac08cc4b2f | ||
|
|
9a89ee72b0 | ||
|
|
c72d3ad51a | ||
|
|
ce14a0e4f9 | ||
|
|
3244f11cfe | ||
|
|
b719c3b0d5 | ||
|
|
3422d3b976 | ||
|
|
01b74ea7c1 | ||
|
|
7d5e88ffda | ||
|
|
2ef9a8aee9 | ||
|
|
65e73d969a | ||
|
|
50dc4757e4 | ||
|
|
1a995cc991 | ||
|
|
93621d6d9a | ||
|
|
a24bac34bd | ||
|
|
3901045318 | ||
|
|
ba314d16e7 | ||
|
|
bdd02db04a | ||
|
|
e3e5208509 | ||
|
|
47d8a840c0 | ||
|
|
ad8ba85136 | ||
|
|
81805ab23d | ||
|
|
22cabd39ca | ||
|
|
a53dc467f6 | ||
|
|
d2d4ab8c67 | ||
|
|
65dcd57c1b | ||
|
|
dc86cfe5d8 | ||
|
|
b12b39a47b | ||
|
|
7ee00b0618 | ||
|
|
6050bf89f6 | ||
|
|
26ccd837f1 | ||
|
|
4ebeb4bb70 | ||
|
|
586893ca4b | ||
|
|
b455c035f7 | ||
|
|
00a2dc290c | ||
|
|
bac135ae81 | ||
|
|
1fb6b91b72 | ||
|
|
9c0bbeb4da | ||
|
|
0babd8d7ab | ||
|
|
13f6ff59cc | ||
|
|
bd50f64152 | ||
|
|
8b7be9f3bc | ||
|
|
8de54078d7 | ||
|
|
328094acfd | ||
|
|
cf6450b269 | ||
|
|
59aee6052a | ||
|
|
2e4fd4248a | ||
|
|
9cc395fc4e | ||
|
|
2c99f5810e | ||
|
|
1c7d3d4b47 | ||
|
|
bdbda13929 | ||
|
|
63375de8d7 | ||
|
|
09f6eeb940 | ||
|
|
692614b057 | ||
|
|
ca36fe5128 | ||
|
|
eb8e25a038 | ||
|
|
e3bf63db59 | ||
|
|
83b502b3f6 | ||
|
|
1699775cbb | ||
|
|
9a602cac1b | ||
|
|
c1752e2818 | ||
|
|
397c7caa56 | ||
|
|
887b4f47fc | ||
|
|
7411469e1d | ||
|
|
173ec608ff |
64
Makefile
64
Makefile
@@ -22,12 +22,14 @@ V=Yes
|
||||
PREFIX=/usr/local
|
||||
SHARED=-shared
|
||||
OBJ=o
|
||||
DESTDIR=
|
||||
SHAREDLIB_DIR=$(PREFIX)/lib
|
||||
PROJECT_NAME=openh264
|
||||
MODULE_NAME=gmpopenh264
|
||||
GMP_API_BRANCH=Firefox36
|
||||
GMP_API_BRANCH=Firefox38
|
||||
CCASFLAGS=$(CFLAGS)
|
||||
VERSION=1.2
|
||||
VERSION=1.4
|
||||
STATIC_LDFLAGS=-lstdc++
|
||||
|
||||
ifeq (,$(wildcard $(SRC_PATH)gmp-api))
|
||||
HAVE_GMP_API=No
|
||||
@@ -46,7 +48,7 @@ ifeq ($(BUILDTYPE), Release)
|
||||
CFLAGS += $(CFLAGS_OPT)
|
||||
USE_ASM = Yes
|
||||
else
|
||||
CFLAGS = $(CFLAGS_DEBUG)
|
||||
CFLAGS += $(CFLAGS_DEBUG)
|
||||
USE_ASM = No
|
||||
endif
|
||||
|
||||
@@ -59,7 +61,7 @@ SHAREDLIBVERSION=0
|
||||
include $(SRC_PATH)build/platform-$(OS).mk
|
||||
|
||||
|
||||
CFLAGS +=
|
||||
CFLAGS += -DGENERATED_VERSION_HEADER
|
||||
LDFLAGS +=
|
||||
|
||||
ifeq (Yes, $(GCOV))
|
||||
@@ -104,6 +106,7 @@ GTEST_INCLUDES += \
|
||||
CODEC_UNITTEST_INCLUDES += \
|
||||
-I$(SRC_PATH)gtest/include \
|
||||
-I$(SRC_PATH)codec/common/inc \
|
||||
-I$(SRC_PATH)test
|
||||
|
||||
CONSOLE_COMMON_INCLUDES += \
|
||||
-I$(SRC_PATH)codec/console/common/inc
|
||||
@@ -118,14 +121,20 @@ H264ENC_DEPS = $(LIBPREFIX)encoder.$(LIBSUFFIX) $(LIBPREFIX)processing.$(LIBSUFF
|
||||
|
||||
CODEC_UNITTEST_LDFLAGS = $(LINK_LOCAL_DIR) $(call LINK_LIB,gtest) $(call LINK_LIB,decoder) $(call LINK_LIB,encoder) $(call LINK_LIB,processing) $(call LINK_LIB,common) $(CODEC_UNITTEST_LDFLAGS_SUFFIX)
|
||||
CODEC_UNITTEST_DEPS = $(LIBPREFIX)gtest.$(LIBSUFFIX) $(LIBPREFIX)decoder.$(LIBSUFFIX) $(LIBPREFIX)encoder.$(LIBSUFFIX) $(LIBPREFIX)processing.$(LIBSUFFIX) $(LIBPREFIX)common.$(LIBSUFFIX)
|
||||
DECODER_UNITTEST_INCLUDES += $(CODEC_UNITTEST_INCLUDES) $(DECODER_INCLUDES) -I$(SRC_PATH)test -I$(SRC_PATH)test/decoder
|
||||
ENCODER_UNITTEST_INCLUDES += $(CODEC_UNITTEST_INCLUDES) $(ENCODER_INCLUDES) -I$(SRC_PATH)test -I$(SRC_PATH)test/encoder
|
||||
PROCESSING_UNITTEST_INCLUDES += $(CODEC_UNITTEST_INCLUDES) $(PROCESSING_INCLUDES) -I$(SRC_PATH)test -I$(SRC_PATH)test/processing
|
||||
API_TEST_INCLUDES += $(CODEC_UNITTEST_INCLUDES) -I$(SRC_PATH)test -I$(SRC_PATH)test/api
|
||||
COMMON_UNITTEST_INCLUDES += $(CODEC_UNITTEST_INCLUDES) $(DECODER_INCLUDES) -I$(SRC_PATH)test -I$(SRC_PATH)test/common
|
||||
DECODER_UNITTEST_INCLUDES += $(CODEC_UNITTEST_INCLUDES) $(DECODER_INCLUDES)
|
||||
ENCODER_UNITTEST_INCLUDES += $(CODEC_UNITTEST_INCLUDES) $(ENCODER_INCLUDES)
|
||||
PROCESSING_UNITTEST_INCLUDES += $(CODEC_UNITTEST_INCLUDES) $(PROCESSING_INCLUDES)
|
||||
API_TEST_INCLUDES += $(CODEC_UNITTEST_INCLUDES)
|
||||
COMMON_UNITTEST_INCLUDES += $(CODEC_UNITTEST_INCLUDES)
|
||||
MODULE_INCLUDES += -I$(SRC_PATH)gmp-api
|
||||
|
||||
.PHONY: test gtest-bootstrap clean $(PROJECT_NAME).pc
|
||||
DECODER_UNITTEST_CFLAGS += $(CODEC_UNITTEST_CFLAGS)
|
||||
ENCODER_UNITTEST_CFLAGS += $(CODEC_UNITTEST_CFLAGS)
|
||||
PROCESSING_UNITTEST_CFLAGS += $(CODEC_UNITTEST_CFLAGS)
|
||||
API_TEST_CFLAGS += $(CODEC_UNITTEST_CFLAGS)
|
||||
COMMON_UNITTEST_CFLAGS += $(CODEC_UNITTEST_CFLAGS)
|
||||
|
||||
.PHONY: test gtest-bootstrap clean $(PROJECT_NAME).pc $(PROJECT_NAME)-static.pc
|
||||
|
||||
all: libraries binaries
|
||||
|
||||
@@ -139,7 +148,7 @@ clean:
|
||||
ifeq (android,$(OS))
|
||||
clean: clean_Android
|
||||
endif
|
||||
$(QUIET)rm -f $(OBJS) $(OBJS:.$(OBJ)=.d) $(OBJS:.$(OBJ)=.obj) $(LIBRARIES) $(BINARIES) *.lib *.a *.dylib *.dll *.so
|
||||
$(QUIET)rm -f $(OBJS) $(OBJS:.$(OBJ)=.d) $(OBJS:.$(OBJ)=.obj) $(LIBRARIES) $(BINARIES) *.lib *.a *.dylib *.dll *.so *.exe *.pdb *.exp *.pc
|
||||
|
||||
gmp-bootstrap:
|
||||
if [ ! -d gmp-api ] ; then git clone https://github.com/mozilla/gmp-api gmp-api ; fi
|
||||
@@ -220,29 +229,36 @@ $(LIBPREFIX)$(MODULE_NAME).$(SHAREDLIBSUFFIX): $(LIBPREFIX)$(MODULE_NAME).$(SHAR
|
||||
endif
|
||||
|
||||
$(PROJECT_NAME).pc: $(PROJECT_NAME).pc.in
|
||||
@sed -e 's;@prefix@;$(PREFIX);' -e 's;@VERSION@;$(VERSION);' < $(PROJECT_NAME).pc.in > $(PROJECT_NAME).pc
|
||||
@sed -e 's;@prefix@;$(PREFIX);' -e 's;@VERSION@;$(VERSION);' -e 's;@LIBS@;;' -e 's;@LIBS_PRIVATE@;$(STATIC_LDFLAGS);' < $(PROJECT_NAME).pc.in > $@
|
||||
|
||||
$(PROJECT_NAME)-static.pc: $(PROJECT_NAME).pc.in
|
||||
@sed -e 's;@prefix@;$(PREFIX);' -e 's;@VERSION@;$(VERSION);' -e 's;@LIBS@;$(STATIC_LDFLAGS);' -e 's;@LIBS_PRIVATE@;;' < $(PROJECT_NAME).pc.in > $@
|
||||
|
||||
install-headers:
|
||||
mkdir -p $(PREFIX)/include/wels
|
||||
install -m 644 codec/api/svc/codec*.h $(PREFIX)/include/wels
|
||||
mkdir -p $(DESTDIR)/$(PREFIX)/include/wels
|
||||
install -m 644 codec/api/svc/codec*.h $(DESTDIR)/$(PREFIX)/include/wels
|
||||
|
||||
install-static: $(LIBPREFIX)$(PROJECT_NAME).$(LIBSUFFIX) install-headers
|
||||
mkdir -p $(PREFIX)/lib
|
||||
install -m 644 $(LIBPREFIX)$(PROJECT_NAME).$(LIBSUFFIX) $(PREFIX)/lib
|
||||
install-static-lib: $(LIBPREFIX)$(PROJECT_NAME).$(LIBSUFFIX) install-headers
|
||||
mkdir -p $(DESTDIR)/$(PREFIX)/lib
|
||||
install -m 644 $(LIBPREFIX)$(PROJECT_NAME).$(LIBSUFFIX) $(DESTDIR)/$(PREFIX)/lib
|
||||
|
||||
install-static: install-static-lib $(PROJECT_NAME)-static.pc
|
||||
mkdir -p $(DESTDIR)/$(PREFIX)/lib/pkgconfig
|
||||
install -m 644 $(PROJECT_NAME)-static.pc $(DESTDIR)/$(PREFIX)/lib/pkgconfig/$(PROJECT_NAME).pc
|
||||
|
||||
install-shared: $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIX) install-headers $(PROJECT_NAME).pc
|
||||
mkdir -p $(SHAREDLIB_DIR)
|
||||
install -m 755 $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIXVER) $(SHAREDLIB_DIR)
|
||||
mkdir -p $(DESTDIR)/$(SHAREDLIB_DIR)
|
||||
install -m 755 $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIXVER) $(DESTDIR)/$(SHAREDLIB_DIR)
|
||||
if [ "$(SHAREDLIBSUFFIXVER)" != "$(SHAREDLIBSUFFIX)" ]; then \
|
||||
cp -a $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIX) $(SHAREDLIB_DIR); \
|
||||
cp -a $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIX) $(DESTDIR)/$(SHAREDLIB_DIR); \
|
||||
fi
|
||||
mkdir -p $(PREFIX)/lib/pkgconfig
|
||||
install -m 444 $(PROJECT_NAME).pc $(PREFIX)/lib/pkgconfig
|
||||
mkdir -p $(DESTDIR)/$(PREFIX)/lib/pkgconfig
|
||||
install -m 644 $(PROJECT_NAME).pc $(DESTDIR)/$(PREFIX)/lib/pkgconfig
|
||||
ifneq ($(EXTRA_LIBRARY),)
|
||||
install -m 644 $(EXTRA_LIBRARY) $(PREFIX)/lib
|
||||
install -m 644 $(EXTRA_LIBRARY) $(DESTDIR)/$(PREFIX)/lib
|
||||
endif
|
||||
|
||||
install: install-static install-shared
|
||||
install: install-static-lib install-shared
|
||||
@:
|
||||
|
||||
ifeq ($(HAVE_GTEST),Yes)
|
||||
|
||||
@@ -38,13 +38,13 @@ OS Support
|
||||
- Windows 64-bit and 32-bit
|
||||
- Mac OS X 64-bit and 32-bit
|
||||
- Linux 64-bit and 32-bit
|
||||
- Android 32-bit
|
||||
- Android 64-bit and 32-bit
|
||||
- iOS 64-bit and 32-bit
|
||||
|
||||
Processor Support
|
||||
-----------------
|
||||
- Intel x86 optionally with MMX/SSE (no AVX yet, help is welcome)
|
||||
- ARMv7 optionally with NEON
|
||||
- ARMv7 optionally with NEON, AArch64 optionally with NEON
|
||||
- Any architecture using C/C++ fallback functions
|
||||
|
||||
Building the Library
|
||||
|
||||
30
RELEASES
30
RELEASES
@@ -1,5 +1,27 @@
|
||||
|
||||
Releases
|
||||
-----------
|
||||
v1.4.0
|
||||
------
|
||||
- Decoder new interface of DecodeFrameNoDelay
|
||||
- Added new encoder and decoder statistics
|
||||
- Added option for generating pdb in windows builds
|
||||
- Added new rate control mode (RC_TIMESTAMP_MODE) for inconstant frame rate input
|
||||
- Added new Sps/Pps strategies for real-time video
|
||||
— Added support for simulcast avc
|
||||
- Improvements in code structure, assembly, input parameter checking, logging, UT and comments
|
||||
- In gmp-openh264, return decoder error correctly and other fixes
|
||||
- Decoder bug fixes when for Error Concealment disabled
|
||||
- Bug fixes for ParseOnly functions
|
||||
- Bug fixes for encoding large frame size (>32767MBs)
|
||||
- Fixes to avoid valgrind warnings, potential crash and calculation overflow
|
||||
|
||||
-----------
|
||||
v1.3.1
|
||||
------
|
||||
- Fixed and enhanced protection to avoid crash when reading lossy bitstreams
|
||||
- Adjust the default mode of Error Concealment used by gmp-openh264
|
||||
|
||||
-----------
|
||||
v1.3.0
|
||||
------
|
||||
@@ -47,7 +69,13 @@ http://www.openh264.org/BINARY_LICENSE.txt
|
||||
|
||||
v1.3.0
|
||||
------
|
||||
// to be added
|
||||
http://ciscobinary.openh264.org/libopenh264-1.3.0-android19.so.bz2
|
||||
http://ciscobinary.openh264.org/libopenh264-1.3.0-linux32.so.bz2
|
||||
http://ciscobinary.openh264.org/libopenh264-1.3.0-linux64.so.bz2
|
||||
http://ciscobinary.openh264.org/libopenh264-1.3.0-osx32.dylib.bz2
|
||||
http://ciscobinary.openh264.org/libopenh264-1.3.0-osx64.dylib.bz2
|
||||
http://ciscobinary.openh264.org/openh264-1.3.0-win32msvc.dll.bz2
|
||||
http://ciscobinary.openh264.org/openh264-1.3.0-win64msvc.dll.bz2
|
||||
|
||||
v1.2.0
|
||||
------
|
||||
|
||||
@@ -10,7 +10,7 @@ else
|
||||
endif
|
||||
ifeq ($(ASM_ARCH), arm)
|
||||
CCAS = gas-preprocessor.pl -as-type armasm -force-thumb -- armasm
|
||||
CCASFLAGS = -nologo -DHAVE_NEON
|
||||
CCASFLAGS = -nologo -DHAVE_NEON -ignore 4509
|
||||
endif
|
||||
|
||||
CC=cl
|
||||
@@ -22,7 +22,7 @@ CXX_O=-Fo$@
|
||||
# it unconditionally. The same issue can also be worked around by adding
|
||||
# -DGTEST_HAS_TR1_TUPLE=0 instead, but we prefer this version since it
|
||||
# matches what gtest itself does.
|
||||
CFLAGS += -nologo -W3 -EHsc -fp:precise -Zc:wchar_t -Zc:forScope -D_VARIADIC_MAX=10
|
||||
CFLAGS += -nologo -Fd$(PROJECT_NAME).pdb -W3 -EHsc -fp:precise -Zc:wchar_t -Zc:forScope -D_VARIADIC_MAX=10
|
||||
CXX_LINK_O=-nologo -Fe$@
|
||||
AR_OPTS=-nologo -out:$@
|
||||
CFLAGS_OPT=-O2 -Ob1 -Oy- -Zi -GF -Gm- -GS -Gy -DNDEBUG
|
||||
@@ -40,4 +40,6 @@ SHAREDLIBSUFFIX=dll
|
||||
SHAREDLIBSUFFIXVER=$(SHAREDLIBSUFFIX)
|
||||
SHARED=-LD
|
||||
EXTRA_LIBRARY=$(PROJECT_NAME)_dll.lib
|
||||
SHLDFLAGS=-link -def:openh264.def -implib:$(EXTRA_LIBRARY)
|
||||
SHLDFLAGS=-Fd$(PROJECT_NAME).pdb -link -def:openh264.def -implib:$(EXTRA_LIBRARY)
|
||||
STATIC_LDFLAGS=
|
||||
CODEC_UNITTEST_CFLAGS=-D_CRT_SECURE_NO_WARNINGS
|
||||
|
||||
@@ -12,9 +12,6 @@ ifeq ($(ARCH), arm)
|
||||
LDFLAGS += -march=armv7-a -Wl,--fix-cortex-a8
|
||||
APP_ABI = armeabi-v7a
|
||||
endif
|
||||
ifeq (Yes, $(USE_ASM))
|
||||
ASMFLAGS += -march=armv7-a -mfpu=neon
|
||||
endif
|
||||
else ifeq ($(ARCH), arm64)
|
||||
APP_ABI = arm64-v8a
|
||||
else ifeq ($(ARCH), x86)
|
||||
|
||||
@@ -114,6 +114,8 @@ typedef unsigned char bool;
|
||||
* this can be done in a loop until data ends
|
||||
* @code
|
||||
* //for Decoding only
|
||||
* iRet = DecodeFrameNoDelay(pBuf, iSize, pData, &sDstBufInfo);
|
||||
* //or
|
||||
* iRet = DecodeFrame2(pBuf, iSize, pData, &sDstBufInfo);
|
||||
* //for Parsing only
|
||||
* iRet = DecodeParser(pBuf, iSize, &sDstParseInfo);
|
||||
@@ -126,10 +128,11 @@ typedef unsigned char bool;
|
||||
* output pData[0], pData[1], pData[2];
|
||||
* }
|
||||
* //for Parsing only, sDstParseInfo can be used for, e.g., HW decoding
|
||||
* if (sDstBufInfo.iBufferStatus==1){
|
||||
* if (sDstBufInfo.iNalNum > 0){
|
||||
* Hardware decoding sDstParseInfo;
|
||||
* }
|
||||
* //no-delay decoding can be realized by directly calling decoder again with NULL input, as in the following. In this case, decoder would immediately reconstruct the input data. This can also be used similarly for Parsing only. Consequent decoding error and output indication should also be considered as above.
|
||||
* //no-delay decoding can be realized by directly calling DecodeFrameNoDelay(), which is the recommended usage.
|
||||
* //no-delay decoding can also be realized by directly calling DecodeFrame2() again with NULL input, as in the following. In this case, decoder would immediately reconstruct the input data. This can also be used similarly for Parsing only. Consequent decoding error and output indication should also be considered as above.
|
||||
* iRet = DecodeFrame2(NULL, 0, pData, &sDstBufInfo);
|
||||
* judge iRet, sDstBufInfo.iBufferStatus ...
|
||||
* @endcode
|
||||
@@ -369,6 +372,23 @@ class ISVCDecoder {
|
||||
int& iWidth,
|
||||
int& iHeight) = 0;
|
||||
|
||||
/**
|
||||
* @brief For slice level DecodeFrameNoDelay() (4 parameters input),
|
||||
* whatever the function return value is, the output data
|
||||
* of I420 format will only be available when pDstInfo->iBufferStatus == 1,.
|
||||
* This function will parse and reconstruct the input frame immediately if it is complete
|
||||
* It is recommended as the main decoding function for H.264/AVC format input
|
||||
* @param pSrc the h264 stream to be decoded
|
||||
* @param iSrcLen the length of h264 stream
|
||||
* @param ppDst buffer pointer of decoded data (YUV)
|
||||
* @param pDstInfo information provided to API(width, height, etc.)
|
||||
* @return 0 - success; otherwise -failed;
|
||||
*/
|
||||
virtual DECODING_STATE EXTAPI DecodeFrameNoDelay (const unsigned char* pSrc,
|
||||
const int iSrcLen,
|
||||
unsigned char** ppDst,
|
||||
SBufferInfo* pDstInfo) = 0;
|
||||
|
||||
/**
|
||||
* @brief For slice level DecodeFrame2() (4 parameters input),
|
||||
* whatever the function return value is, the output data
|
||||
@@ -472,6 +492,11 @@ DECODING_STATE (*DecodeFrame) (ISVCDecoder*, const unsigned char* pSrc,
|
||||
int* iWidth,
|
||||
int* iHeight);
|
||||
|
||||
DECODING_STATE (*DecodeFrameNoDelay) (ISVCDecoder*, const unsigned char* pSrc,
|
||||
const int iSrcLen,
|
||||
unsigned char** ppDst,
|
||||
SBufferInfo* pDstInfo);
|
||||
|
||||
DECODING_STATE (*DecodeFrame2) (ISVCDecoder*, const unsigned char* pSrc,
|
||||
const int iSrcLen,
|
||||
unsigned char** ppDst,
|
||||
@@ -532,9 +557,17 @@ long WelsCreateDecoder (ISVCDecoder** ppDecoder);
|
||||
void WelsDestroyDecoder (ISVCDecoder* pDecoder);
|
||||
|
||||
/** @brief Get codec version
|
||||
* Note, old versions of Mingw (GCC < 4.7) are buggy and use an
|
||||
* incorrect/different ABI for calling this function, making it
|
||||
* incompatible with MSVC builds.
|
||||
* @return The linked codec version
|
||||
*/
|
||||
OpenH264Version WelsGetCodecVersion ();
|
||||
OpenH264Version WelsGetCodecVersion (void);
|
||||
|
||||
/** @brief Get codec version
|
||||
* @param pVersion struct to fill in with the version
|
||||
*/
|
||||
void WelsGetCodecVersionEx (OpenH264Version *pVersion);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -64,8 +64,7 @@
|
||||
*/
|
||||
///
|
||||
/// E.g. SDK version is 1.2.0.0, major version number is 1, minor version number is 2, and revision number is 0.
|
||||
typedef struct _tagVersion
|
||||
{
|
||||
typedef struct _tagVersion {
|
||||
unsigned int uMajor; ///< The major version number
|
||||
unsigned int uMinor; ///< The minor version number
|
||||
unsigned int uRevision; ///< The revision number
|
||||
@@ -284,6 +283,7 @@ typedef enum {
|
||||
RC_QUALITY_MODE = 0, ///< quality mode
|
||||
RC_BITRATE_MODE = 1, ///< bitrate mode
|
||||
RC_BUFFERBASED_MODE = 2, ///< no bitrate control,only using buffer status,adjust the video quality
|
||||
RC_TIMESTAMP_MODE = 3, //rate control based timestamp
|
||||
RC_OFF_MODE = -1 ///< rate control off mode
|
||||
} RC_MODES;
|
||||
|
||||
@@ -371,8 +371,9 @@ typedef struct {
|
||||
* @brief Encoder usage type
|
||||
*/
|
||||
typedef enum {
|
||||
CAMERA_VIDEO_REAL_TIME, ///< camera video signal
|
||||
SCREEN_CONTENT_REAL_TIME ///< screen content signal
|
||||
CAMERA_VIDEO_REAL_TIME, ///< camera video for real-time communication
|
||||
SCREEN_CONTENT_REAL_TIME, ///< screen content signal
|
||||
CAMERA_VIDEO_NON_REAL_TIME
|
||||
} EUsageType;
|
||||
|
||||
/**
|
||||
@@ -384,6 +385,17 @@ typedef enum {
|
||||
HIGH_COMPLEXITY ///< high complexity, lowest speed, high quality
|
||||
} ECOMPLEXITY_MODE;
|
||||
|
||||
/**
|
||||
* @brief Enumulate for the stategy of SPS/PPS strategy
|
||||
*/
|
||||
typedef enum {
|
||||
CONSTANT_ID = 0, ///< constant id in SPS/PPS
|
||||
INCREASING_ID = 0x01, ///< SPS/PPS id increases at each IDR
|
||||
SPS_LISTING = 0x02, ///< using SPS in the existing list if possible
|
||||
SPS_LISTING_AND_PPS_INCREASING = 0x03,
|
||||
SPS_PPS_LISTING = 0x06,
|
||||
} EParameterSetStrategy;
|
||||
|
||||
// TODO: Refine the parameters definition.
|
||||
/**
|
||||
* @brief SVC Encoding Parameters
|
||||
@@ -420,9 +432,11 @@ typedef struct TagEncParamExt {
|
||||
ECOMPLEXITY_MODE iComplexityMode;
|
||||
unsigned int uiIntraPeriod; ///< period of Intra frame
|
||||
int iNumRefFrame; ///< number of reference frame used
|
||||
bool bEnableSpsPpsIdAddition; ///< false:not adjust ID in SPS/PPS; true: adjust ID in SPS/PPS
|
||||
EParameterSetStrategy
|
||||
eSpsPpsIdStrategy; ///< different stategy in adjust ID in SPS/PPS: 0- constant ID, 1-additional ID, 6-mapping and additional
|
||||
bool bPrefixNalAddingCtrl; ///< false:not use Prefix NAL; true: use Prefix NAL
|
||||
bool bEnableSSEI; ///< false:not use SSEI; true: use SSEI
|
||||
bool bEnableSSEI; ///< false:not use SSEI; true: use SSEI -- TODO: planning to remove the interface of SSEI
|
||||
bool bSimulcastAVC; ///< (when encoding more than 1 spatial layer) false: use SVC syntax for higher layers; true: use Simulcast AVC -- coming soon
|
||||
int iPaddingFlag; ///< 0:disable padding;1:padding
|
||||
int iEntropyCodingModeFlag; ///< 0:CAVLC 1:CABAC.
|
||||
|
||||
@@ -618,6 +632,8 @@ typedef struct TagVideoEncoderStatistics {
|
||||
unsigned int uiIDRReqNum; ///< number of IDR requests
|
||||
unsigned int uiIDRSentNum; ///< number of actual IDRs sent
|
||||
unsigned int uiLTRSentNum; ///< number of LTR sent/marked
|
||||
|
||||
long long iStatisticsTs; ///< Timestamp of updating the statistics
|
||||
} SEncoderStatistics; // in building, coming soon
|
||||
|
||||
/**
|
||||
@@ -639,10 +655,16 @@ typedef struct TagVideoDecoderStatistics {
|
||||
unsigned int uiEcIDRNum; ///< number of actual unintegrity IDR or not received but eced
|
||||
unsigned int uiEcFrameNum; ///<
|
||||
unsigned int uiIDRLostNum; ///< number of whole lost IDR
|
||||
unsigned int uiFreezingIDRNum; ///< number of freezing IDR with error (partly received), under resolution change
|
||||
unsigned int
|
||||
uiFreezingIDRNum; ///< number of freezing IDR with error (partly received), under resolution change
|
||||
unsigned int uiFreezingNonIDRNum; ///< number of freezing non-IDR with error
|
||||
int iAvgLumaQp; ///< average luma QP. default: -1, no correct frame outputted
|
||||
|
||||
int iSpsReportErrorNum; ///< number of Sps Invalid report
|
||||
int iSubSpsReportErrorNum; ///< number of SubSps Invalid report
|
||||
int iPpsReportErrorNum; ///< number of Pps Invalid report
|
||||
int iSpsNoExistNalNum; ///< number of Sps NoExist Nal
|
||||
int iSubSpsNoExistNalNum; ///< number of SubSps NoExist Nal
|
||||
int iPpsNoExistNalNum; ///< number of Pps NoExist Nal
|
||||
} SDecoderStatistics; // in building, coming soon
|
||||
|
||||
#endif//WELS_VIDEO_CODEC_APPLICATION_DEFINITION_H__
|
||||
|
||||
@@ -121,6 +121,17 @@ enum ENalPriority {
|
||||
#define FRAME_NUM_PARAM_SET (-1)
|
||||
#define FRAME_NUM_IDR 0
|
||||
|
||||
/**
|
||||
* @brief eDeblockingIdc
|
||||
*/
|
||||
enum {
|
||||
DEBLOCKING_IDC_0 = 0,
|
||||
DEBLOCKING_IDC_1 = 1,
|
||||
DEBLOCKING_IDC_2 = 2
|
||||
};
|
||||
#define DEBLOCKING_OFFSET (6)
|
||||
#define DEBLOCKING_OFFSET_MINUS (-6)
|
||||
|
||||
/* Error Tools definition */
|
||||
typedef unsigned short ERR_TOOL;
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
#include "codec_app_def.h"
|
||||
|
||||
static const OpenH264Version g_stCodecVersion = {1,3,0,0};
|
||||
static const char* g_strCodecVer = "OpenH264 version:1.3.0.0";
|
||||
static const OpenH264Version g_stCodecVersion = {1,4,0,0};
|
||||
static const char* const g_strCodecVer = "OpenH264 version:1.4.0.0";
|
||||
|
||||
#define OPENH264_MAJOR (1)
|
||||
#define OPENH264_MINOR (3)
|
||||
#define OPENH264_MINOR (4)
|
||||
#define OPENH264_REVISION (0)
|
||||
#define OPENH264_RESERVED (0)
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ JNIEXPORT void JNICALL Java_com_wels_enc_WelsEncTest_DoEncoderTest
|
||||
/**************** Add the native codes/API *****************/
|
||||
char* argv[2];
|
||||
int argc = 2;
|
||||
argv[0] = (char*) ("decConsole.exe");
|
||||
argv[0] = (char*) ("encConsole.exe");
|
||||
argv[1] = (char*) ((*env).GetStringUTFChars (jsFileNameIn, NULL));
|
||||
LOGI ("Start to run JNI module!+++");
|
||||
EncMain (argc, argv);
|
||||
|
||||
@@ -28,11 +28,11 @@ echo "#include \"codec_app_def.h\"" >>codec_ver.h
|
||||
echo "" >>codec_ver.h
|
||||
|
||||
echo "static const OpenH264Version g_stCodecVersion = {$1};"|tr '.' ',' >>codec_ver.h
|
||||
echo "static const char* g_strCodecVer = \"OpenH264 version:$1\";" >>codec_ver.h
|
||||
echo "static const char* const g_strCodecVer = \"OpenH264 version:$1\";" >>codec_ver.h
|
||||
#if [ "$2"x = ""x ]; then
|
||||
#echo "static const char* g_strCodecBuildNum = \"OpenH264 revision:$revision\";" >> codec_ver.h
|
||||
#echo "static const char* const g_strCodecBuildNum = \"OpenH264 revision:$revision\";" >> codec_ver.h
|
||||
#else
|
||||
#echo "static const char* g_strCodecBuildNum = \"OpenH264 build:$2, OpenH264 revision:$revision\";" >> codec_ver.h
|
||||
#echo "static const char* const g_strCodecBuildNum = \"OpenH264 build:$2, OpenH264 revision:$revision\";" >> codec_ver.h
|
||||
#fi
|
||||
echo "" >>codec_ver.h
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
4CE443D918B722CD0017DF25 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CE443D818B722CD0017DF25 /* Foundation.framework */; };
|
||||
53C1C9BC193F0FB000404D8F /* expand_pic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53C1C9BB193F0FB000404D8F /* expand_pic.cpp */; };
|
||||
5BA8F2C019603F5F00011CE4 /* common_tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5BA8F2BF19603F5F00011CE4 /* common_tables.cpp */; };
|
||||
5BD896BA1A7B839B00D32B7D /* memory_align.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5BD896B91A7B839B00D32B7D /* memory_align.cpp */; };
|
||||
5BDD15ED1A79027600B6CA2E /* mc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5BDD15EC1A79027600B6CA2E /* mc.cpp */; };
|
||||
F0B204F918FD23BF005DA23F /* copy_mb.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F0B204F818FD23BF005DA23F /* copy_mb.cpp */; };
|
||||
F556A8241906673900E156A8 /* arm_arch64_common_macro.S in Sources */ = {isa = PBXBuildFile; fileRef = F556A8221906673900E156A8 /* arm_arch64_common_macro.S */; };
|
||||
F556A8251906673900E156A8 /* expand_picture_aarch64_neon.S in Sources */ = {isa = PBXBuildFile; fileRef = F556A8231906673900E156A8 /* expand_picture_aarch64_neon.S */; };
|
||||
@@ -54,7 +56,6 @@
|
||||
4C3406BA18D96EA600DFA14A /* deblocking_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = deblocking_common.h; sourceTree = "<group>"; };
|
||||
4C3406BD18D96EA600DFA14A /* ls_defines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ls_defines.h; sourceTree = "<group>"; };
|
||||
4C3406BE18D96EA600DFA14A /* macros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = macros.h; sourceTree = "<group>"; };
|
||||
4C3406BF18D96EA600DFA14A /* mc_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mc_common.h; sourceTree = "<group>"; };
|
||||
4C3406C018D96EA600DFA14A /* measure_time.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = measure_time.h; sourceTree = "<group>"; };
|
||||
4C3406C118D96EA600DFA14A /* typedefs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = typedefs.h; sourceTree = "<group>"; };
|
||||
4C3406C218D96EA600DFA14A /* WelsThreadLib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WelsThreadLib.h; sourceTree = "<group>"; };
|
||||
@@ -68,8 +69,13 @@
|
||||
4CE443E918B722CD0017DF25 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
|
||||
53C1C9BA193F0F9E00404D8F /* expand_pic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = expand_pic.h; sourceTree = "<group>"; };
|
||||
53C1C9BB193F0FB000404D8F /* expand_pic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = expand_pic.cpp; sourceTree = "<group>"; };
|
||||
5B9196F91A7F8BA40075D641 /* wels_const_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wels_const_common.h; sourceTree = "<group>"; };
|
||||
5BA8F2BE19603F3500011CE4 /* wels_common_defs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wels_common_defs.h; sourceTree = "<group>"; };
|
||||
5BA8F2BF19603F5F00011CE4 /* common_tables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = common_tables.cpp; sourceTree = "<group>"; };
|
||||
5BD896B81A7B837700D32B7D /* memory_align.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = memory_align.h; sourceTree = "<group>"; };
|
||||
5BD896B91A7B839B00D32B7D /* memory_align.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = memory_align.cpp; sourceTree = "<group>"; };
|
||||
5BDD15EB1A79026A00B6CA2E /* mc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mc.h; sourceTree = "<group>"; };
|
||||
5BDD15EC1A79027600B6CA2E /* mc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mc.cpp; sourceTree = "<group>"; };
|
||||
F0B204F718FD23B6005DA23F /* copy_mb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = copy_mb.h; sourceTree = "<group>"; };
|
||||
F0B204F818FD23BF005DA23F /* copy_mb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = copy_mb.cpp; sourceTree = "<group>"; };
|
||||
F556A8221906673900E156A8 /* arm_arch64_common_macro.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = arm_arch64_common_macro.S; path = arm64/arm_arch64_common_macro.S; sourceTree = "<group>"; };
|
||||
@@ -123,10 +129,12 @@
|
||||
4C3406BA18D96EA600DFA14A /* deblocking_common.h */,
|
||||
4C3406BD18D96EA600DFA14A /* ls_defines.h */,
|
||||
4C3406BE18D96EA600DFA14A /* macros.h */,
|
||||
4C3406BF18D96EA600DFA14A /* mc_common.h */,
|
||||
5BDD15EB1A79026A00B6CA2E /* mc.h */,
|
||||
4C3406C018D96EA600DFA14A /* measure_time.h */,
|
||||
5BD896B81A7B837700D32B7D /* memory_align.h */,
|
||||
4C3406C118D96EA600DFA14A /* typedefs.h */,
|
||||
5BA8F2BE19603F3500011CE4 /* wels_common_defs.h */,
|
||||
5B9196F91A7F8BA40075D641 /* wels_const_common.h */,
|
||||
4C3406C218D96EA600DFA14A /* WelsThreadLib.h */,
|
||||
);
|
||||
path = inc;
|
||||
@@ -143,6 +151,8 @@
|
||||
4C3406C518D96EA600DFA14A /* crt_util_safe_x.cpp */,
|
||||
53C1C9BB193F0FB000404D8F /* expand_pic.cpp */,
|
||||
4C3406C618D96EA600DFA14A /* deblocking_common.cpp */,
|
||||
5BDD15EC1A79027600B6CA2E /* mc.cpp */,
|
||||
5BD896B91A7B839B00D32B7D /* memory_align.cpp */,
|
||||
4C3406C818D96EA600DFA14A /* WelsThreadLib.cpp */,
|
||||
);
|
||||
path = src;
|
||||
@@ -253,9 +263,11 @@
|
||||
F5B8D82D190757290037849A /* mc_aarch64_neon.S in Sources */,
|
||||
4C3406C918D96EA600DFA14A /* arm_arch_common_macro.S in Sources */,
|
||||
F556A8241906673900E156A8 /* arm_arch64_common_macro.S in Sources */,
|
||||
5BDD15ED1A79027600B6CA2E /* mc.cpp in Sources */,
|
||||
F5AC94FF193EB7D800F58154 /* deblocking_aarch64_neon.S in Sources */,
|
||||
4C3406CE18D96EA600DFA14A /* crt_util_safe_x.cpp in Sources */,
|
||||
F791965919D3BE2200F60C6B /* intra_pred_common.cpp in Sources */,
|
||||
5BD896BA1A7B839B00D32B7D /* memory_align.cpp in Sources */,
|
||||
4C3406CF18D96EA600DFA14A /* deblocking_common.cpp in Sources */,
|
||||
5BA8F2C019603F5F00011CE4 /* common_tables.cpp in Sources */,
|
||||
F791965419D3B89D00F60C6B /* intra_pred_common_aarch64_neon.S in Sources */,
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
4CE4469318BC5EAB0017DF25 /* fmo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4467018BC5EAA0017DF25 /* fmo.cpp */; };
|
||||
4CE4469418BC5EAB0017DF25 /* get_intra_predictor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4467118BC5EAA0017DF25 /* get_intra_predictor.cpp */; };
|
||||
4CE4469518BC5EAB0017DF25 /* manage_dec_ref.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4467218BC5EAA0017DF25 /* manage_dec_ref.cpp */; };
|
||||
4CE4469618BC5EAB0017DF25 /* mc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4467318BC5EAA0017DF25 /* mc.cpp */; };
|
||||
4CE4469718BC5EAB0017DF25 /* mem_align.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4467418BC5EAA0017DF25 /* mem_align.cpp */; };
|
||||
4CE4469818BC5EAB0017DF25 /* memmgr_nal_unit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4467518BC5EAA0017DF25 /* memmgr_nal_unit.cpp */; };
|
||||
4CE4469918BC5EAB0017DF25 /* mv_pred.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4467618BC5EAA0017DF25 /* mv_pred.cpp */; };
|
||||
4CE4469A18BC5EAB0017DF25 /* parse_mb_syn_cavlc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4467718BC5EAA0017DF25 /* parse_mb_syn_cavlc.cpp */; };
|
||||
@@ -33,7 +31,6 @@
|
||||
6A3E814219D79AE900C19C1F /* cabac_decoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6A3E814119D79AE900C19C1F /* cabac_decoder.cpp */; };
|
||||
6A3E814419D7A40600C19C1F /* parse_mb_syn_cabac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6A3E814319D7A40600C19C1F /* parse_mb_syn_cabac.cpp */; };
|
||||
6C749B6A197CC6E600A111F9 /* block_add_aarch64_neon.S in Sources */ = {isa = PBXBuildFile; fileRef = 6C749B69197CC6E600A111F9 /* block_add_aarch64_neon.S */; };
|
||||
9ABF4382193EB60900A6BD61 /* expand_pic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9ABF4381193EB60900A6BD61 /* expand_pic.cpp */; };
|
||||
9AED66561946A1DE009A3567 /* welsCodecTrace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AED66551946A1DE009A3567 /* welsCodecTrace.cpp */; };
|
||||
9AED66591946A203009A3567 /* utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AED66581946A203009A3567 /* utils.cpp */; };
|
||||
F0B204FC18FD23D8005DA23F /* error_concealment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F0B204FB18FD23D8005DA23F /* error_concealment.cpp */; };
|
||||
@@ -73,8 +70,6 @@
|
||||
4CE4465318BC5EAA0017DF25 /* get_intra_predictor.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = get_intra_predictor.h; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; };
|
||||
4CE4465418BC5EAA0017DF25 /* manage_dec_ref.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = manage_dec_ref.h; sourceTree = "<group>"; };
|
||||
4CE4465518BC5EAA0017DF25 /* mb_cache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mb_cache.h; sourceTree = "<group>"; };
|
||||
4CE4465618BC5EAA0017DF25 /* mc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mc.h; sourceTree = "<group>"; };
|
||||
4CE4465718BC5EAA0017DF25 /* mem_align.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mem_align.h; sourceTree = "<group>"; };
|
||||
4CE4465818BC5EAA0017DF25 /* memmgr_nal_unit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = memmgr_nal_unit.h; sourceTree = "<group>"; };
|
||||
4CE4465918BC5EAA0017DF25 /* mv_pred.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mv_pred.h; sourceTree = "<group>"; };
|
||||
4CE4465A18BC5EAA0017DF25 /* nal_prefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nal_prefix.h; sourceTree = "<group>"; };
|
||||
@@ -99,8 +94,6 @@
|
||||
4CE4467018BC5EAA0017DF25 /* fmo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fmo.cpp; sourceTree = "<group>"; };
|
||||
4CE4467118BC5EAA0017DF25 /* get_intra_predictor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = get_intra_predictor.cpp; sourceTree = "<group>"; };
|
||||
4CE4467218BC5EAA0017DF25 /* manage_dec_ref.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = manage_dec_ref.cpp; sourceTree = "<group>"; };
|
||||
4CE4467318BC5EAA0017DF25 /* mc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mc.cpp; sourceTree = "<group>"; tabWidth = 1; usesTabs = 0; wrapsLines = 1; };
|
||||
4CE4467418BC5EAA0017DF25 /* mem_align.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mem_align.cpp; sourceTree = "<group>"; };
|
||||
4CE4467518BC5EAA0017DF25 /* memmgr_nal_unit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = memmgr_nal_unit.cpp; sourceTree = "<group>"; };
|
||||
4CE4467618BC5EAA0017DF25 /* mv_pred.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mv_pred.cpp; sourceTree = "<group>"; };
|
||||
4CE4467718BC5EAA0017DF25 /* parse_mb_syn_cavlc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = parse_mb_syn_cavlc.cpp; sourceTree = "<group>"; };
|
||||
@@ -116,8 +109,6 @@
|
||||
6A3E814319D7A40600C19C1F /* parse_mb_syn_cabac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = parse_mb_syn_cabac.cpp; sourceTree = "<group>"; };
|
||||
6A3E814519D7A40D00C19C1F /* parse_mb_syn_cabac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = parse_mb_syn_cabac.h; sourceTree = "<group>"; };
|
||||
6C749B69197CC6E600A111F9 /* block_add_aarch64_neon.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = block_add_aarch64_neon.S; path = arm64/block_add_aarch64_neon.S; sourceTree = "<group>"; };
|
||||
9ABF4380193EB5F700A6BD61 /* expand_pic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = expand_pic.h; path = ../../../common/inc/expand_pic.h; sourceTree = "<group>"; };
|
||||
9ABF4381193EB60900A6BD61 /* expand_pic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = expand_pic.cpp; path = ../../../common/src/expand_pic.cpp; sourceTree = "<group>"; };
|
||||
9AED66551946A1DE009A3567 /* welsCodecTrace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = welsCodecTrace.cpp; path = ../../../common/src/welsCodecTrace.cpp; sourceTree = "<group>"; };
|
||||
9AED66571946A1EB009A3567 /* welsCodecTrace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = welsCodecTrace.h; path = ../../../common/inc/welsCodecTrace.h; sourceTree = "<group>"; };
|
||||
9AED66581946A203009A3567 /* utils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = utils.cpp; path = ../../../common/src/utils.cpp; sourceTree = "<group>"; };
|
||||
@@ -200,7 +191,6 @@
|
||||
6A3E814519D7A40D00C19C1F /* parse_mb_syn_cabac.h */,
|
||||
6A3E814019D79AD900C19C1F /* cabac_decoder.h */,
|
||||
9AED665A1946A21D009A3567 /* utils.h */,
|
||||
9ABF4380193EB5F700A6BD61 /* expand_pic.h */,
|
||||
F0B204FA18FD23CF005DA23F /* error_concealment.h */,
|
||||
4CE4464518BC5EAA0017DF25 /* as264_common.h */,
|
||||
4CE4464618BC5EAA0017DF25 /* au_parser.h */,
|
||||
@@ -218,8 +208,6 @@
|
||||
4CE4465318BC5EAA0017DF25 /* get_intra_predictor.h */,
|
||||
4CE4465418BC5EAA0017DF25 /* manage_dec_ref.h */,
|
||||
4CE4465518BC5EAA0017DF25 /* mb_cache.h */,
|
||||
4CE4465618BC5EAA0017DF25 /* mc.h */,
|
||||
4CE4465718BC5EAA0017DF25 /* mem_align.h */,
|
||||
4CE4465818BC5EAA0017DF25 /* memmgr_nal_unit.h */,
|
||||
4CE4465918BC5EAA0017DF25 /* mv_pred.h */,
|
||||
4CE4465A18BC5EAA0017DF25 /* nal_prefix.h */,
|
||||
@@ -243,7 +231,6 @@
|
||||
6A3E814319D7A40600C19C1F /* parse_mb_syn_cabac.cpp */,
|
||||
6A3E814119D79AE900C19C1F /* cabac_decoder.cpp */,
|
||||
9AED66581946A203009A3567 /* utils.cpp */,
|
||||
9ABF4381193EB60900A6BD61 /* expand_pic.cpp */,
|
||||
F0B204FB18FD23D8005DA23F /* error_concealment.cpp */,
|
||||
4CE4466718BC5EAA0017DF25 /* au_parser.cpp */,
|
||||
4CE4466818BC5EAA0017DF25 /* bit_stream.cpp */,
|
||||
@@ -256,8 +243,6 @@
|
||||
4CE4467018BC5EAA0017DF25 /* fmo.cpp */,
|
||||
4CE4467118BC5EAA0017DF25 /* get_intra_predictor.cpp */,
|
||||
4CE4467218BC5EAA0017DF25 /* manage_dec_ref.cpp */,
|
||||
4CE4467318BC5EAA0017DF25 /* mc.cpp */,
|
||||
4CE4467418BC5EAA0017DF25 /* mem_align.cpp */,
|
||||
4CE4467518BC5EAA0017DF25 /* memmgr_nal_unit.cpp */,
|
||||
4CE4467618BC5EAA0017DF25 /* mv_pred.cpp */,
|
||||
4CE4467718BC5EAA0017DF25 /* parse_mb_syn_cavlc.cpp */,
|
||||
@@ -361,8 +346,6 @@
|
||||
4CE4469F18BC5EAB0017DF25 /* welsDecoderExt.cpp in Sources */,
|
||||
4CE4469318BC5EAB0017DF25 /* fmo.cpp in Sources */,
|
||||
4CE4469118BC5EAB0017DF25 /* decoder_data_tables.cpp in Sources */,
|
||||
4CE4469718BC5EAB0017DF25 /* mem_align.cpp in Sources */,
|
||||
9ABF4382193EB60900A6BD61 /* expand_pic.cpp in Sources */,
|
||||
4CE4469518BC5EAB0017DF25 /* manage_dec_ref.cpp in Sources */,
|
||||
4CE4468A18BC5EAB0017DF25 /* au_parser.cpp in Sources */,
|
||||
4CE4469918BC5EAB0017DF25 /* mv_pred.cpp in Sources */,
|
||||
@@ -375,7 +358,6 @@
|
||||
4CBC1B81194AC4E100214D9E /* intra_pred_aarch64_neon.S in Sources */,
|
||||
4CE4469018BC5EAB0017DF25 /* decoder_core.cpp in Sources */,
|
||||
4CE447AE18BC6BE90017DF25 /* intra_pred_neon.S in Sources */,
|
||||
4CE4469618BC5EAB0017DF25 /* mc.cpp in Sources */,
|
||||
4CE4469C18BC5EAB0017DF25 /* rec_mb.cpp in Sources */,
|
||||
4CE4468B18BC5EAB0017DF25 /* bit_stream.cpp in Sources */,
|
||||
4CE4468D18BC5EAB0017DF25 /* decode_mb_aux.cpp in Sources */,
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
4CE4471318BC605C0017DF25 /* encoder_data_tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE446E218BC605C0017DF25 /* encoder_data_tables.cpp */; };
|
||||
4CE4471418BC605C0017DF25 /* encoder_ext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE446E318BC605C0017DF25 /* encoder_ext.cpp */; };
|
||||
4CE4471618BC605C0017DF25 /* get_intra_predictor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE446E518BC605C0017DF25 /* get_intra_predictor.cpp */; };
|
||||
4CE4471718BC605C0017DF25 /* mc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE446E618BC605C0017DF25 /* mc.cpp */; };
|
||||
4CE4471818BC605C0017DF25 /* md.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE446E718BC605C0017DF25 /* md.cpp */; };
|
||||
4CE4471918BC605C0017DF25 /* memory_align.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE446E818BC605C0017DF25 /* memory_align.cpp */; };
|
||||
4CE4471A18BC605C0017DF25 /* mv_pred.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE446E918BC605C0017DF25 /* mv_pred.cpp */; };
|
||||
4CE4471B18BC605C0017DF25 /* nal_encap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE446EA18BC605C0017DF25 /* nal_encap.cpp */; };
|
||||
4CE4471C18BC605C0017DF25 /* picture_handle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE446EB18BC605C0017DF25 /* picture_handle.cpp */; };
|
||||
@@ -93,9 +91,7 @@
|
||||
4CE446B518BC605C0017DF25 /* extern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = extern.h; sourceTree = "<group>"; };
|
||||
4CE446B618BC605C0017DF25 /* get_intra_predictor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = get_intra_predictor.h; sourceTree = "<group>"; };
|
||||
4CE446B718BC605C0017DF25 /* mb_cache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mb_cache.h; sourceTree = "<group>"; };
|
||||
4CE446B818BC605C0017DF25 /* mc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mc.h; sourceTree = "<group>"; };
|
||||
4CE446B918BC605C0017DF25 /* md.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = md.h; sourceTree = "<group>"; };
|
||||
4CE446BA18BC605C0017DF25 /* memory_align.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = memory_align.h; sourceTree = "<group>"; };
|
||||
4CE446BB18BC605C0017DF25 /* mt_defs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mt_defs.h; sourceTree = "<group>"; };
|
||||
4CE446BC18BC605C0017DF25 /* mv_pred.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mv_pred.h; sourceTree = "<group>"; };
|
||||
4CE446BD18BC605C0017DF25 /* nal_encap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nal_encap.h; sourceTree = "<group>"; };
|
||||
@@ -135,9 +131,7 @@
|
||||
4CE446E218BC605C0017DF25 /* encoder_data_tables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = encoder_data_tables.cpp; sourceTree = "<group>"; };
|
||||
4CE446E318BC605C0017DF25 /* encoder_ext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = encoder_ext.cpp; sourceTree = "<group>"; };
|
||||
4CE446E518BC605C0017DF25 /* get_intra_predictor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = get_intra_predictor.cpp; sourceTree = "<group>"; };
|
||||
4CE446E618BC605C0017DF25 /* mc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mc.cpp; sourceTree = "<group>"; };
|
||||
4CE446E718BC605C0017DF25 /* md.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = md.cpp; sourceTree = "<group>"; };
|
||||
4CE446E818BC605C0017DF25 /* memory_align.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = memory_align.cpp; sourceTree = "<group>"; };
|
||||
4CE446E918BC605C0017DF25 /* mv_pred.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mv_pred.cpp; sourceTree = "<group>"; };
|
||||
4CE446EA18BC605C0017DF25 /* nal_encap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = nal_encap.cpp; sourceTree = "<group>"; };
|
||||
4CE446EB18BC605C0017DF25 /* picture_handle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = picture_handle.cpp; sourceTree = "<group>"; };
|
||||
@@ -276,9 +270,7 @@
|
||||
4CE446B518BC605C0017DF25 /* extern.h */,
|
||||
4CE446B618BC605C0017DF25 /* get_intra_predictor.h */,
|
||||
4CE446B718BC605C0017DF25 /* mb_cache.h */,
|
||||
4CE446B818BC605C0017DF25 /* mc.h */,
|
||||
4CE446B918BC605C0017DF25 /* md.h */,
|
||||
4CE446BA18BC605C0017DF25 /* memory_align.h */,
|
||||
4CE446BB18BC605C0017DF25 /* mt_defs.h */,
|
||||
4CE446BC18BC605C0017DF25 /* mv_pred.h */,
|
||||
4CE446BD18BC605C0017DF25 /* nal_encap.h */,
|
||||
@@ -328,9 +320,7 @@
|
||||
4CE446E218BC605C0017DF25 /* encoder_data_tables.cpp */,
|
||||
4CE446E318BC605C0017DF25 /* encoder_ext.cpp */,
|
||||
4CE446E518BC605C0017DF25 /* get_intra_predictor.cpp */,
|
||||
4CE446E618BC605C0017DF25 /* mc.cpp */,
|
||||
4CE446E718BC605C0017DF25 /* md.cpp */,
|
||||
4CE446E818BC605C0017DF25 /* memory_align.cpp */,
|
||||
4CE446E918BC605C0017DF25 /* mv_pred.cpp */,
|
||||
4CE446EA18BC605C0017DF25 /* nal_encap.cpp */,
|
||||
4CE446EB18BC605C0017DF25 /* picture_handle.cpp */,
|
||||
@@ -455,13 +445,11 @@
|
||||
4CE4470E18BC605C0017DF25 /* au_set.cpp in Sources */,
|
||||
F5BE8005196B913200ED02ED /* memory_aarch64_neon.S in Sources */,
|
||||
4CBC1B83194ACBB400214D9E /* intra_pred_aarch64_neon.S in Sources */,
|
||||
4CE4471718BC605C0017DF25 /* mc.cpp in Sources */,
|
||||
F7E9994519EBD1E9009B1021 /* svc_set_mb_syn_cabac.cpp in Sources */,
|
||||
F5617A50196A833A006E2B20 /* reconstruct_aarch64_neon.S in Sources */,
|
||||
4CE4472918BC605C0017DF25 /* svc_set_mb_syn_cavlc.cpp in Sources */,
|
||||
4CE4471818BC605C0017DF25 /* md.cpp in Sources */,
|
||||
4CE4471B18BC605C0017DF25 /* nal_encap.cpp in Sources */,
|
||||
4CE4471918BC605C0017DF25 /* memory_align.cpp in Sources */,
|
||||
4CE4472418BC605C0017DF25 /* svc_enc_slice_segment.cpp in Sources */,
|
||||
4CE4472318BC605C0017DF25 /* svc_base_layer_md.cpp in Sources */,
|
||||
4CB8F2B419235FC5005D6386 /* pixel_aarch64_neon.S in Sources */,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -351,51 +351,47 @@
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="SW"
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl"
|
||||
>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
<File
|
||||
RelativePath="..\..\..\common\inc\mem_align.h"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\..\decoder\plus\res\welsdec.rc"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\common\inc\welsCodecTrace.h"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\..\decoder\plus\src\wels_dec_export.def"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\common\src\welsCodecTrace.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\decoder\plus\src\welsDecoderExt.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl"
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\decoder\plus\inc\welsDecoderExt.h"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\..\decoder\core\inc\mem_align.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\common\inc\welsCodecTrace.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\decoder\plus\inc\welsDecoderExt.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\..\decoder\plus\res\welsdec.rc"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\..\decoder\plus\src\wels_dec_export.def"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\common\src\welsCodecTrace.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\decoder\plus\src\welsDecoderExt.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
|
||||
@@ -386,7 +386,7 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\encoder\core\src\mc.cpp"
|
||||
RelativePath="..\..\..\common\src\mc.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@@ -394,7 +394,7 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\encoder\core\src\memory_align.cpp"
|
||||
RelativePath="..\..\..\common\src\memory_align.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@@ -563,11 +563,7 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\encoder\core\inc\mc.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\common\inc\mc_common.h"
|
||||
RelativePath="..\..\..\common\inc\mc.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@@ -579,7 +575,7 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\encoder\core\inc\memory_align.h"
|
||||
RelativePath="..\..\..\common\inc\memory_align.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@@ -726,6 +722,10 @@
|
||||
RelativePath="..\..\..\encoder\core\inc\wels_const.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\common\inc\wels_const_common.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\encoder\core\inc\wels_func_ptr_def.h"
|
||||
>
|
||||
|
||||
@@ -50,6 +50,8 @@ mov pc, lr
|
||||
|
||||
.section .note.GNU-stack,"",%progbits // Mark stack as non-executable
|
||||
.text
|
||||
.arch armv7-a
|
||||
.fpu neon
|
||||
|
||||
.macro WELS_ASM_FUNC_BEGIN funcName
|
||||
.align 2
|
||||
|
||||
@@ -834,17 +834,12 @@ WELS_ASM_FUNC_END
|
||||
|
||||
|
||||
WELS_ASM_FUNC_BEGIN WelsNonZeroCount_neon
|
||||
|
||||
vld1.64 {d0-d2}, [r0]
|
||||
|
||||
vceq.s8 q0, q0, #0
|
||||
vceq.s8 d2, d2, #0
|
||||
vmvn q0, q0
|
||||
vmvn d2, d2
|
||||
vabs.s8 q0, q0
|
||||
vabs.s8 d2, d2
|
||||
|
||||
vst1.64 {d0-d2}, [r0]
|
||||
mov r1, #1
|
||||
vdup.8 q2, r1
|
||||
vld1.64 {d0,d1,d2}, [r0]
|
||||
vmin.s8 q0, q0, q2
|
||||
vmin.s8 d2, d2, d4
|
||||
vst1.64 {d0,d1,d2}, [r0]
|
||||
WELS_ASM_FUNC_END
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
@@ -553,16 +553,12 @@ bs_mv_check_jump1:
|
||||
#endif
|
||||
|
||||
WELS_ASM_AARCH64_FUNC_BEGIN WelsNonZeroCount_AArch64_neon
|
||||
mov w1, #1
|
||||
dup v3.8b, w1
|
||||
ld1 {v0.8b, v1.8b, v2.8b}, [x0]
|
||||
ins v0.d[1], v1.d[0]
|
||||
uzp1 v0.2d, v0.2d, v1.2d
|
||||
cmeq v0.16b, v0.16b, #0
|
||||
cmeq v2.8b, v2.8b, #0
|
||||
mvn v0.16b, v0.16b
|
||||
mvn v2.8b, v2.8b
|
||||
abs v0.16b, v0.16b
|
||||
abs v2.8b, v2.8b
|
||||
ins v1.d[0], v0.d[1]
|
||||
umin v0.8b, v0.8b, v3.8b
|
||||
umin v1.8b, v1.8b, v3.8b
|
||||
umin v2.8b, v2.8b, v3.8b
|
||||
st1 {v0.8b, v1.8b, v2.8b}, [x0]
|
||||
WELS_ASM_AARCH64_FUNC_END
|
||||
|
||||
|
||||
@@ -14,13 +14,13 @@ fi
|
||||
GIT_VERSION='"'$GIT_VERSION'"'
|
||||
rm -f config.git-hash
|
||||
|
||||
cat codec/common/inc/version.h.template | sed "s/\$FULL_VERSION/$GIT_VERSION/g" > codec/common/inc/version.h.new
|
||||
if cmp codec/common/inc/version.h.new codec/common/inc/version.h > /dev/null 2>&1; then
|
||||
cat codec/common/inc/version_gen.h.template | sed "s/\$FULL_VERSION/$GIT_VERSION/g" > codec/common/inc/version_gen.h.new
|
||||
if cmp codec/common/inc/version_gen.h.new codec/common/inc/version_gen.h > /dev/null 2>&1; then
|
||||
# Identical to old version, don't touch it (to avoid unnecessary rebuilds)
|
||||
rm codec/common/inc/version.h.new
|
||||
echo "Keeping existing codec/common/inc/version.h"
|
||||
rm codec/common/inc/version_gen.h.new
|
||||
echo "Keeping existing codec/common/inc/version_gen.h"
|
||||
exit 0
|
||||
fi
|
||||
mv codec/common/inc/version.h.new codec/common/inc/version.h
|
||||
mv codec/common/inc/version_gen.h.new codec/common/inc/version_gen.h
|
||||
|
||||
echo "Generated codec/common/inc/version.h"
|
||||
echo "Generated codec/common/inc/version_gen.h"
|
||||
|
||||
1
codec/common/inc/.gitignore
vendored
Normal file
1
codec/common/inc/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
version_gen.h
|
||||
@@ -15,6 +15,16 @@ void DeblockChromaLt4H_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int
|
||||
int8_t* pTc);
|
||||
void DeblockChromaEq4H_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
|
||||
|
||||
void DeblockChromaLt4V2_c (uint8_t* pPixCbCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
|
||||
int8_t* pTc);
|
||||
void DeblockChromaEq4V2_c (uint8_t* pPixCbCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
|
||||
|
||||
void DeblockChromaLt4H2_c (uint8_t* pPixCbCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
|
||||
int8_t* pTc);
|
||||
void DeblockChromaEq4H2_c (uint8_t* pPixCbCr,int32_t iStride, int32_t iAlpha, int32_t iBeta);
|
||||
|
||||
void WelsNonZeroCount_c (int8_t* pNonZeroCount);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif//__cplusplus
|
||||
@@ -32,6 +42,7 @@ void DeblockChromaLt4V_ssse3 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride,
|
||||
void DeblockChromaEq4H_ssse3 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
|
||||
void DeblockChromaLt4H_ssse3 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
|
||||
int8_t* pTC);
|
||||
void WelsNonZeroCount_sse2 (int8_t* pNonZeroCount);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_NEON)
|
||||
@@ -48,6 +59,7 @@ void DeblockChromaEq4V_neon (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride,
|
||||
void DeblockChromaLt4H_neon (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
|
||||
int8_t* pTC);
|
||||
void DeblockChromaEq4H_neon (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
|
||||
void WelsNonZeroCount_neon (int8_t* pNonZeroCount);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_NEON_AARCH64)
|
||||
@@ -61,6 +73,7 @@ void DeblockChromaEq4V_AArch64_neon (uint8_t* pPixCb, uint8_t* pPixCr, int32_t i
|
||||
void DeblockChromaLt4H_AArch64_neon (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
|
||||
int8_t* pTC);
|
||||
void DeblockChromaEq4H_AArch64_neon (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
|
||||
void WelsNonZeroCount_AArch64_neon (int8_t* pNonZeroCount);
|
||||
#endif
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
||||
@@ -30,11 +30,36 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MC_COMMON_H
|
||||
#define MC_COMMON_H
|
||||
#ifndef MC_H
|
||||
#define MC_H
|
||||
|
||||
#include "typedefs.h"
|
||||
|
||||
typedef void (*PWelsMcFunc) (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight);
|
||||
|
||||
typedef void (*PWelsLumaHalfpelMcFunc) (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight);
|
||||
typedef void (*PWelsSampleAveragingFunc) (uint8_t*, int32_t, const uint8_t*, int32_t, const uint8_t*, int32_t,
|
||||
int32_t, int32_t);
|
||||
|
||||
typedef struct TagMcFunc {
|
||||
PWelsLumaHalfpelMcFunc pfLumaHalfpelHor;
|
||||
PWelsLumaHalfpelMcFunc pfLumaHalfpelVer;
|
||||
PWelsLumaHalfpelMcFunc pfLumaHalfpelCen;
|
||||
PWelsMcFunc pMcChromaFunc;
|
||||
|
||||
PWelsMcFunc pMcLumaFunc;
|
||||
PWelsSampleAveragingFunc pfSampleAveraging;
|
||||
} SMcFunc;
|
||||
|
||||
namespace WelsCommon {
|
||||
|
||||
void InitMcFunc (SMcFunc* pMcFunc, uint32_t iCpu);
|
||||
|
||||
} // namespace WelsCommon
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif//__cplusplus
|
||||
@@ -272,4 +297,4 @@ void McChromaWidthEq8_ssse3 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* p
|
||||
}
|
||||
#endif//__cplusplus
|
||||
|
||||
#endif//MC_COMMON_H
|
||||
#endif//MC_H
|
||||
@@ -30,16 +30,26 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(WELS_ENCODER_MEMORY_ALIGN_H__)
|
||||
#define WELS_ENCODER_MEMORY_ALIGN_H__
|
||||
#if !defined(WELS_COMMON_MEMORY_ALIGN_H__)
|
||||
#define WELS_COMMON_MEMORY_ALIGN_H__
|
||||
|
||||
#include "typedefs.h"
|
||||
#include "as264_common.h"
|
||||
|
||||
// NOTE: please do not clean below lines even comment, turn on for potential memory leak verify and memory usage monitor etc.
|
||||
//#define MEMORY_CHECK
|
||||
#define MEMORY_MONITOR
|
||||
#ifdef MEMORY_CHECK
|
||||
#ifndef MEMORY_MONITOR
|
||||
#define MEMORY_MONITOR
|
||||
#endif//MEMORY_MONITOR
|
||||
#endif//MEMORY_CHECK
|
||||
|
||||
|
||||
#ifdef MEMORY_CHECK
|
||||
#include <stdio.h>
|
||||
#endif//MEMORY_CHECK
|
||||
|
||||
namespace WelsEnc {
|
||||
namespace WelsCommon {
|
||||
|
||||
class CMemoryAlign {
|
||||
public:
|
||||
@@ -63,13 +73,38 @@ uint32_t m_nCacheLineSize;
|
||||
#ifdef MEMORY_MONITOR
|
||||
uint32_t m_nMemoryUsageInBytes;
|
||||
#endif//MEMORY_MONITOR
|
||||
|
||||
#ifdef MEMORY_CHECK
|
||||
FILE* m_fpMemChkPoint;
|
||||
uint32_t m_nCountRequestNum;
|
||||
#endif//MEMORY_CHECK
|
||||
};
|
||||
|
||||
/*!
|
||||
*************************************************************************************
|
||||
* \brief malloc with zero filled utilization in Wels
|
||||
*
|
||||
* \param kuiSize size of memory block required
|
||||
*
|
||||
* \return allocated memory pointer exactly, failed in case of NULL return
|
||||
*
|
||||
* \note N/A
|
||||
*************************************************************************************
|
||||
*/
|
||||
void* WelsMallocz (const uint32_t kuiSize, const char* kpTag);
|
||||
|
||||
/*!
|
||||
*************************************************************************************
|
||||
* \brief free utilization in Wels
|
||||
*
|
||||
* \param pPtr data pointer to be free.
|
||||
* i.e, uint8_t *pPtr = actual data to be free, argv = &pPtr.
|
||||
*
|
||||
* \return NONE
|
||||
*
|
||||
* \note N/A
|
||||
*************************************************************************************
|
||||
*/
|
||||
void WelsFree (void* pPtr, const char* kpTag);
|
||||
|
||||
#define WELS_SAFE_FREE(pPtr, pTag) if (pPtr) { WelsFree(pPtr, pTag); pPtr = NULL; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif//WELS_ENCODER_MEMORY_ALIGN_H__
|
||||
#endif//WELS_COMMON_MEMORY_ALIGN_H__
|
||||
@@ -1,6 +1,10 @@
|
||||
#ifndef VERSION_H
|
||||
#define VERSION_H
|
||||
|
||||
#define VERSION_NUMBER "openh264 default: 1.2"
|
||||
#ifdef GENERATED_VERSION_HEADER
|
||||
#include "version_gen.h"
|
||||
#else
|
||||
#define VERSION_NUMBER "openh264 default: 1.4"
|
||||
#endif
|
||||
|
||||
#endif // VERSION_H
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#ifndef VERSION_H
|
||||
#define VERSION_H
|
||||
|
||||
#define VERSION_NUMBER $FULL_VERSION
|
||||
|
||||
#endif // VERSION_H
|
||||
6
codec/common/inc/version_gen.h.template
Normal file
6
codec/common/inc/version_gen.h.template
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef VERSION_GEN_H
|
||||
#define VERSION_GEN_H
|
||||
|
||||
#define VERSION_NUMBER $FULL_VERSION
|
||||
|
||||
#endif // VERSION_GEN_H
|
||||
@@ -65,6 +65,8 @@ extern const uint8_t g_kuiMbCountScan4Idx[24];
|
||||
extern const uint8_t g_kuiCache30ScanIdx[16];
|
||||
extern const uint8_t g_kuiCache48CountScan4Idx[24];
|
||||
|
||||
extern const uint8_t g_kuiDequantScaling4x4Default[2][16];
|
||||
extern const uint8_t g_kuiDequantScaling8x8Default[2][64];
|
||||
extern const ALIGNED_DECLARE (uint16_t, g_kuiDequantCoeff[52][8], 16);
|
||||
extern const uint8_t g_kuiChromaQpTable[52];
|
||||
|
||||
|
||||
@@ -30,21 +30,27 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef WELS_MC_H__
|
||||
#define WELS_MC_H__
|
||||
#ifndef WELS_CONST_COMMON_H__
|
||||
#define WELS_CONST_COMMON_H__
|
||||
|
||||
#include "wels_const.h"
|
||||
#include "macros.h"
|
||||
#include "decoder_context.h"
|
||||
#include "mc_common.h"
|
||||
// Miscellaneous sizing infos
|
||||
#ifndef MAX_FNAME_LEN
|
||||
#define MAX_FNAME_LEN 256 // maximal length of file name in char size
|
||||
#endif//MAX_FNAME_LEN
|
||||
|
||||
namespace WelsDec {
|
||||
#ifndef WELS_LOG_BUF_SIZE
|
||||
#define WELS_LOG_BUF_SIZE 4096
|
||||
#endif//WELS_LOG_BUF_SIZE
|
||||
|
||||
typedef void (*PMcChromaWidthExtFunc) (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
const uint8_t* kpABCD, int32_t iHeight);
|
||||
#ifndef MAX_TRACE_LOG_SIZE
|
||||
#define MAX_TRACE_LOG_SIZE (50 * (1<<20)) // max trace log size: 50 MB, overwrite occur if log file size exceeds this size
|
||||
#endif//MAX_TRACE_LOG_SIZE
|
||||
|
||||
void InitMcFunc (SMcFunc* pMcFunc, int32_t iCpu);
|
||||
/* MB width in pixels for specified colorspace I420 usually used in codec */
|
||||
#define MB_WIDTH_LUMA 16
|
||||
#define MB_WIDTH_CHROMA (MB_WIDTH_LUMA>>1)
|
||||
/* MB height in pixels for specified colorspace I420 usually used in codec */
|
||||
#define MB_HEIGHT_LUMA 16
|
||||
#define MB_HEIGHT_CHROMA (MB_HEIGHT_LUMA>>1)
|
||||
|
||||
} // namespace WelsDec
|
||||
|
||||
#endif//WELS_MC_H__
|
||||
#endif//WELS_CONST_COMMON_H__
|
||||
@@ -74,6 +74,7 @@ const uint8_t g_kuiCache30ScanIdx[16] = { //mv or uiRefIndex cache scan index, 4
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// extern at wels_common_defs.h
|
||||
const uint8_t g_kuiChromaQpTable[52] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
||||
@@ -119,7 +120,29 @@ const EVclType g_keTypeMap[32][2] = {
|
||||
{ NON_VCL, NON_VCL }, // 30: NAL_UNIT_UNSPEC_30
|
||||
{ NON_VCL, NON_VCL } // 31: NAL_UNIT_UNSPEC_31
|
||||
};
|
||||
|
||||
//default scaling list matrix value of 4x4
|
||||
const uint8_t g_kuiDequantScaling4x4Default[2][16]={
|
||||
{ 6, 13, 20, 28, 13, 20, 28, 32, 20, 28, 32, 37, 28, 32, 37, 42 },
|
||||
{ 10, 14, 20, 24, 14, 20, 24, 27, 20, 24, 27, 30, 24, 27, 30, 34 }
|
||||
};
|
||||
//default scaling list matrix value of 8x8
|
||||
const uint8_t g_kuiDequantScaling8x8Default[2][64]={
|
||||
{ 6, 10, 13, 16, 18, 23, 25, 27, 10, 11, 16, 18, 23, 25, 27, 29,
|
||||
13, 16, 18, 23, 25, 27, 29, 31,
|
||||
16, 18, 23, 25, 27, 29, 31, 33,
|
||||
18, 23, 25, 27, 29, 31, 33, 36,
|
||||
23, 25, 27, 29, 31, 33, 36, 38,
|
||||
25, 27, 29, 31, 33, 36, 38, 40,
|
||||
27, 29, 31, 33, 36, 38, 40, 42 },
|
||||
{ 9, 13, 15, 17, 19, 21, 22, 24,
|
||||
13, 13, 17, 19, 21, 22, 24, 25,
|
||||
15, 17, 19, 21, 22, 24, 25, 27,
|
||||
17, 19, 21, 22, 24, 25, 27, 28,
|
||||
19, 21, 22, 24, 25, 27, 28, 30,
|
||||
21, 22, 24, 25, 27, 28, 30, 32,
|
||||
22, 24, 25, 27, 28, 30, 32, 33,
|
||||
24, 25, 27, 28, 30, 32, 33, 35 }
|
||||
};
|
||||
ALIGNED_DECLARE (const uint16_t, g_kuiDequantCoeff[52][8], 16) = {
|
||||
/* 0*/{ 10, 13, 10, 13, 13, 16, 13, 16 }, /* 1*/{ 11, 14, 11, 14, 14, 18, 14, 18 },
|
||||
/* 2*/{ 13, 16, 13, 16, 16, 20, 16, 20 }, /* 3*/{ 14, 18, 14, 18, 18, 23, 18, 23 },
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "deblocking_common.h"
|
||||
#include "macros.h"
|
||||
|
||||
// C code only
|
||||
void DeblockLumaLt4_c (uint8_t* pPix, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta,
|
||||
int8_t* pTc) {
|
||||
@@ -180,6 +181,77 @@ void DeblockChromaEq4H_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int
|
||||
DeblockChromaEq4_c (pPixCb, pPixCr, 1, iStride, iAlpha, iBeta);
|
||||
}
|
||||
|
||||
void DeblockChromaLt42_c (uint8_t* pPixCbCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha,
|
||||
int32_t iBeta, int8_t* pTc) {
|
||||
int32_t p0, p1, q0, q1, iDeta;
|
||||
bool bDetaP0Q0, bDetaP1P0, bDetaQ1Q0;
|
||||
|
||||
for (int32_t i = 0; i < 8; i++) {
|
||||
int32_t iTc0 = pTc[i >> 1];
|
||||
if (iTc0 > 0) {
|
||||
p0 = pPixCbCr[-iStrideX];
|
||||
p1 = pPixCbCr[-2 * iStrideX];
|
||||
q0 = pPixCbCr[0];
|
||||
q1 = pPixCbCr[iStrideX];
|
||||
|
||||
bDetaP0Q0 = WELS_ABS (p0 - q0) < iAlpha;
|
||||
bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta;
|
||||
bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta;
|
||||
if (bDetaP0Q0 && bDetaP1P0 && bDetaQ1Q0) {
|
||||
iDeta = WELS_CLIP3 ((((q0 - p0) << 2) + (p1 - q1) + 4) >> 3, -iTc0, iTc0);
|
||||
pPixCbCr[-iStrideX] = WelsClip1 (p0 + iDeta); /* p0' */
|
||||
pPixCbCr[0] = WelsClip1 (q0 - iDeta); /* q0' */
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
pPixCbCr += iStrideY;
|
||||
}
|
||||
}
|
||||
void DeblockChromaEq42_c (uint8_t* pPixCbCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha,
|
||||
int32_t iBeta) {
|
||||
int32_t p0, p1, q0, q1;
|
||||
bool bDetaP0Q0, bDetaP1P0, bDetaQ1Q0;
|
||||
for (int32_t i = 0; i < 8; i++) {
|
||||
p0 = pPixCbCr[-iStrideX];
|
||||
p1 = pPixCbCr[-2 * iStrideX];
|
||||
q0 = pPixCbCr[0];
|
||||
q1 = pPixCbCr[iStrideX];
|
||||
bDetaP0Q0 = WELS_ABS (p0 - q0) < iAlpha;
|
||||
bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta;
|
||||
bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta;
|
||||
if (bDetaP0Q0 && bDetaP1P0 && bDetaQ1Q0) {
|
||||
pPixCbCr[-iStrideX] = ((p1 << 1) + p0 + q1 + 2) >> 2; /* p0' */
|
||||
pPixCbCr[0] = ((q1 << 1) + q0 + p1 + 2) >> 2; /* q0' */
|
||||
}
|
||||
|
||||
pPixCbCr += iStrideY;
|
||||
}
|
||||
}
|
||||
|
||||
void DeblockChromaLt4V2_c (uint8_t* pPixCbCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
|
||||
int8_t* tc) {
|
||||
DeblockChromaLt42_c (pPixCbCr, iStride, 1, iAlpha, iBeta, tc);
|
||||
}
|
||||
void DeblockChromaLt4H2_c (uint8_t* pPixCbCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
|
||||
int8_t* tc) {
|
||||
|
||||
DeblockChromaLt42_c (pPixCbCr, 1, iStride, iAlpha, iBeta, tc);
|
||||
}
|
||||
void DeblockChromaEq4V2_c (uint8_t* pPixCbCr, int32_t iStride, int32_t iAlpha, int32_t iBeta) {
|
||||
DeblockChromaEq42_c (pPixCbCr, iStride, 1, iAlpha, iBeta);
|
||||
}
|
||||
void DeblockChromaEq4H2_c (uint8_t* pPixCbCr, int32_t iStride, int32_t iAlpha, int32_t iBeta) {
|
||||
DeblockChromaEq42_c (pPixCbCr, 1, iStride, iAlpha, iBeta);
|
||||
}
|
||||
|
||||
void WelsNonZeroCount_c (int8_t* pNonZeroCount) {
|
||||
int32_t i;
|
||||
for (i = 0; i < 24; i++) {
|
||||
pNonZeroCount[i] = !!pNonZeroCount[i];
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef X86_ASM
|
||||
extern "C" {
|
||||
void DeblockLumaLt4H_ssse3 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc) {
|
||||
|
||||
@@ -41,8 +41,17 @@
|
||||
#include "mc.h"
|
||||
|
||||
#include "cpu_core.h"
|
||||
#include "ls_defines.h"
|
||||
#include "macros.h"
|
||||
|
||||
namespace WelsDec {
|
||||
typedef void (*PMcChromaWidthExtFunc) (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
const uint8_t* kpABCD, int32_t iHeight);
|
||||
typedef void (*PWelsSampleWidthAveragingFunc) (uint8_t*, int32_t, const uint8_t*, int32_t, const uint8_t*,
|
||||
int32_t, int32_t);
|
||||
typedef void (*PWelsMcWidthHeightFunc) (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight);
|
||||
|
||||
namespace WelsCommon {
|
||||
|
||||
/*------------------weight for chroma fraction pixel interpolation------------------*/
|
||||
//iA = (8 - dx) * (8 - dy);
|
||||
@@ -84,9 +93,6 @@ static const uint8_t g_kuiABCD[8][8][4] = { //g_kA[dy][dx], g_kB[dy][dx], g_kC[d
|
||||
}
|
||||
};
|
||||
|
||||
typedef void (*PWelsMcWidthHeightFunc) (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight);
|
||||
|
||||
//***************************************************************************//
|
||||
// C code implementation //
|
||||
//***************************************************************************//
|
||||
@@ -133,10 +139,10 @@ static inline void McCopyWidthEq16_c (const uint8_t* pSrc, int32_t iSrcStride, u
|
||||
|
||||
//--------------------Luma sample MC------------------//
|
||||
|
||||
static inline int32_t HorFilterInput16bit_c (int16_t* pSrc) {
|
||||
int32_t iPix05 = pSrc[-2] + pSrc[3];
|
||||
int32_t iPix14 = pSrc[-1] + pSrc[2];
|
||||
int32_t iPix23 = pSrc[ 0] + pSrc[1];
|
||||
static inline int32_t HorFilterInput16bit_c (const int16_t* pSrc) {
|
||||
int32_t iPix05 = pSrc[0] + pSrc[5];
|
||||
int32_t iPix14 = pSrc[1] + pSrc[4];
|
||||
int32_t iPix23 = pSrc[2] + pSrc[3];
|
||||
|
||||
return (iPix05 - (iPix14 * 5) + (iPix23 * 20));
|
||||
}
|
||||
@@ -176,6 +182,7 @@ static inline void McCopy_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* p
|
||||
McCopyWidthEq2_c (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
}
|
||||
|
||||
//horizontal filter to gain half sample, that is (2, 0) location in quarter sample
|
||||
static inline void McHorVer20_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
@@ -189,6 +196,7 @@ static inline void McHorVer20_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_
|
||||
}
|
||||
}
|
||||
|
||||
//vertical filter to gain half sample, that is (0, 2) location in quarter sample
|
||||
static inline void McHorVer02_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
@@ -202,10 +210,11 @@ static inline void McHorVer02_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_
|
||||
}
|
||||
}
|
||||
|
||||
//horizontal and vertical filter to gain half sample, that is (2, 2) location in quarter sample
|
||||
static inline void McHorVer22_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
int16_t iTmp[16 + 5]; //16
|
||||
int16_t iTmp[17 + 5];
|
||||
int32_t i, j, k;
|
||||
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
@@ -213,7 +222,7 @@ static inline void McHorVer22_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_
|
||||
iTmp[j] = FilterInput8bitWithStride_c (pSrc - 2 + j, iSrcStride);
|
||||
}
|
||||
for (k = 0; k < iWidth; k++) {
|
||||
pDst[k] = WelsClip1 ((HorFilterInput16bit_c (&iTmp[2 + k]) + 512) >> 10);
|
||||
pDst[k] = WelsClip1 ((HorFilterInput16bit_c (&iTmp[k]) + 512) >> 10);
|
||||
}
|
||||
pSrc += iSrcStride;
|
||||
pDst += iDstStride;
|
||||
@@ -390,6 +399,14 @@ static inline void McHorVer22WidthEq16_sse2 (const uint8_t* pSrc, int32_t iSrcSt
|
||||
McHorVer22WidthEq8_sse2 (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
McHorVer22WidthEq8_sse2 (&pSrc[8], iSrcStride, &pDst[8], iDstStride, iHeight);
|
||||
}
|
||||
void McHorVer22Width9Or17Height9Or17_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_2D (int16_t, pTap, 22, 24, 16)
|
||||
int32_t tmp1 = 2 * (iWidth - 8);
|
||||
McHorVer22HorFirst_sse2 (pSrc - 2, iSrcStride, (uint8_t*)pTap, 48, iWidth, iHeight + 5);
|
||||
McHorVer22Width8VerLastAlign_sse2 ((uint8_t*)pTap, 48, pDst, iDstStride, iWidth - 1, iHeight);
|
||||
McHorVer22Width8VerLastUnAlign_sse2 ((uint8_t*)pTap + tmp1, 48, pDst + iWidth - 8, iDstStride, 8, iHeight);
|
||||
}
|
||||
|
||||
static inline void McCopy_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth,
|
||||
@@ -667,19 +684,69 @@ void McChroma_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int3
|
||||
McChromaWithFragMv_c (pSrc, iSrcStride, pDst, iDstStride, iMvX, iMvY, iWidth, iHeight);
|
||||
}
|
||||
|
||||
void McChroma_ssse3 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight) {
|
||||
static const PMcChromaWidthExtFunc kpMcChromaWidthFuncs[2] = {
|
||||
McChromaWidthEq4_mmx,
|
||||
McChromaWidthEq8_ssse3
|
||||
};
|
||||
const int32_t kiD8x = iMvX & 0x07;
|
||||
const int32_t kiD8y = iMvY & 0x07;
|
||||
if (kiD8x == 0 && kiD8y == 0) {
|
||||
McCopy_sse2 (pSrc, iSrcStride, pDst, iDstStride, iWidth, iHeight);
|
||||
return;
|
||||
}
|
||||
if (iWidth != 2) {
|
||||
kpMcChromaWidthFuncs[iWidth >> 3] (pSrc, iSrcStride, pDst, iDstStride, g_kuiABCD[kiD8y][kiD8x], iHeight);
|
||||
} else
|
||||
McChromaWithFragMv_c (pSrc, iSrcStride, pDst, iDstStride, iMvX, iMvY, iWidth, iHeight);
|
||||
}
|
||||
|
||||
void PixelAvg_sse2 (uint8_t* pDst, int32_t iDstStride, const uint8_t* pSrcA, int32_t iSrcAStride,
|
||||
const uint8_t* pSrcB, int32_t iSrcBStride, int32_t iWidth, int32_t iHeight) {
|
||||
static const PWelsSampleWidthAveragingFunc kpfFuncs[2] = {
|
||||
PixelAvgWidthEq8_mmx,
|
||||
PixelAvgWidthEq16_sse2
|
||||
};
|
||||
kpfFuncs[iWidth >> 4] (pDst, iDstStride, pSrcA, iSrcAStride, pSrcB, iSrcBStride, iHeight);
|
||||
}
|
||||
|
||||
#endif //X86_ASM
|
||||
//***************************************************************************//
|
||||
// NEON implementation //
|
||||
//***************************************************************************//
|
||||
#if defined(HAVE_NEON)
|
||||
void McHorVer20Width9Or17_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
if (iWidth == 17)
|
||||
McHorVer20Width17_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else //if (iWidth == 9)
|
||||
McHorVer20Width9_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
}
|
||||
void McHorVer02Height9Or17_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
if (iWidth == 16)
|
||||
McHorVer02Height17_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else //if (iWidth == 8)
|
||||
McHorVer02Height9_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
}
|
||||
void McHorVer22Width9Or17Height9Or17_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
if (iWidth == 17)
|
||||
McHorVer22Width17_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else //if (iWidth == 9)
|
||||
McHorVer22Width9_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
}
|
||||
void McCopy_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
if (16 == iWidth)
|
||||
McCopyWidthEq16_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else if (8 == iWidth)
|
||||
McCopyWidthEq8_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else
|
||||
else if (4 == iWidth)
|
||||
McCopyWidthEq4_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else
|
||||
McCopyWidthEq2_c (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
}
|
||||
void McHorVer20_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
@@ -921,16 +988,48 @@ void McChroma_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int3
|
||||
McChromaWithFragMv_c (pSrc, iSrcStride, pDst, iDstStride, iMvX, iMvY, iWidth, iHeight);
|
||||
}
|
||||
}
|
||||
void PixelAvg_neon (uint8_t* pDst, int32_t iDstStride, const uint8_t* pSrcA, int32_t iSrcAStride,
|
||||
const uint8_t* pSrcB, int32_t iSrcBStride, int32_t iWidth, int32_t iHeight) {
|
||||
static const PWelsSampleWidthAveragingFunc kpfFuncs[2] = {
|
||||
PixStrideAvgWidthEq8_neon,
|
||||
PixStrideAvgWidthEq16_neon
|
||||
};
|
||||
kpfFuncs[iWidth >> 4] (pDst, iDstStride, pSrcA, iSrcAStride, pSrcB, iSrcBStride, iHeight);
|
||||
}
|
||||
#endif
|
||||
#if defined(HAVE_NEON_AARCH64)
|
||||
void McHorVer20Width9Or17_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
if (iWidth == 17)
|
||||
McHorVer20Width17_AArch64_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else //if (iWidth == 9)
|
||||
McHorVer20Width9_AArch64_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
}
|
||||
void McHorVer02Height9Or17_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
if (iWidth == 16)
|
||||
McHorVer02Height17_AArch64_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else //if (iWidth == 8)
|
||||
McHorVer02Height9_AArch64_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
}
|
||||
void McHorVer22Width9Or17Height9Or17_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst,
|
||||
int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
if (iWidth == 17)
|
||||
McHorVer22Width17_AArch64_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else //if (iWidth == 9)
|
||||
McHorVer22Width9_AArch64_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
}
|
||||
void McCopy_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
if (16 == iWidth)
|
||||
McCopyWidthEq16_AArch64_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else if (8 == iWidth)
|
||||
McCopyWidthEq8_AArch64_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else
|
||||
else if (4 == iWidth)
|
||||
McCopyWidthEq4_AArch64_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else
|
||||
McCopyWidthEq2_c (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
}
|
||||
void McHorVer20_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
@@ -1172,30 +1271,58 @@ void McChroma_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pD
|
||||
McChromaWithFragMv_c (pSrc, iSrcStride, pDst, iDstStride, iMvX, iMvY, iWidth, iHeight);
|
||||
}
|
||||
}
|
||||
void PixelAvg_AArch64_neon (uint8_t* pDst, int32_t iDstStride, const uint8_t* pSrcA, int32_t iSrcAStride,
|
||||
const uint8_t* pSrcB, int32_t iSrcBStride, int32_t iWidth, int32_t iHeight) {
|
||||
static const PWelsSampleWidthAveragingFunc kpfFuncs[2] = {
|
||||
PixStrideAvgWidthEq8_AArch64_neon,
|
||||
PixStrideAvgWidthEq16_AArch64_neon
|
||||
};
|
||||
kpfFuncs[iWidth >> 4] (pDst, iDstStride, pSrcA, iSrcAStride, pSrcB, iSrcBStride, iHeight);
|
||||
}
|
||||
#endif
|
||||
|
||||
void InitMcFunc (SMcFunc* pMcFunc, int32_t iCpu) {
|
||||
pMcFunc->pMcLumaFunc = McLuma_c;
|
||||
pMcFunc->pMcChromaFunc = McChroma_c;
|
||||
void InitMcFunc (SMcFunc* pMcFuncs, uint32_t uiCpuFlag) {
|
||||
pMcFuncs->pfLumaHalfpelHor = McHorVer20_c;
|
||||
pMcFuncs->pfLumaHalfpelVer = McHorVer02_c;
|
||||
pMcFuncs->pfLumaHalfpelCen = McHorVer22_c;
|
||||
pMcFuncs->pfSampleAveraging = PixelAvg_c;
|
||||
pMcFuncs->pMcChromaFunc = McChroma_c;
|
||||
pMcFuncs->pMcLumaFunc = McLuma_c;
|
||||
|
||||
#ifdef HAVE_NEON
|
||||
if (iCpu & WELS_CPU_NEON) {
|
||||
pMcFunc->pMcLumaFunc = McLuma_neon;
|
||||
pMcFunc->pMcChromaFunc = McChroma_neon;
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_NEON_AARCH64
|
||||
if (iCpu & WELS_CPU_NEON) {
|
||||
pMcFunc->pMcLumaFunc = McLuma_AArch64_neon;
|
||||
pMcFunc->pMcChromaFunc = McChroma_AArch64_neon;
|
||||
}
|
||||
#endif
|
||||
#if defined (X86_ASM)
|
||||
if (iCpu & WELS_CPU_SSE2) {
|
||||
pMcFunc->pMcLumaFunc = McLuma_sse2;
|
||||
pMcFunc->pMcChromaFunc = McChroma_sse2;
|
||||
if (uiCpuFlag & WELS_CPU_SSE2) {
|
||||
pMcFuncs->pfLumaHalfpelHor = McHorVer20Width9Or17_sse2;
|
||||
pMcFuncs->pfLumaHalfpelVer = McHorVer02Height9Or17_sse2;
|
||||
pMcFuncs->pfLumaHalfpelCen = McHorVer22Width9Or17Height9Or17_sse2;
|
||||
pMcFuncs->pfSampleAveraging = PixelAvg_sse2;
|
||||
pMcFuncs->pMcChromaFunc = McChroma_sse2;
|
||||
pMcFuncs->pMcLumaFunc = McLuma_sse2;
|
||||
}
|
||||
|
||||
if (uiCpuFlag & WELS_CPU_SSSE3) {
|
||||
pMcFuncs->pMcChromaFunc = McChroma_ssse3;
|
||||
}
|
||||
#endif //(X86_ASM)
|
||||
}
|
||||
|
||||
} // namespace WelsDec
|
||||
#if defined(HAVE_NEON)
|
||||
if (uiCpuFlag & WELS_CPU_NEON) {
|
||||
pMcFuncs->pMcLumaFunc = McLuma_neon;
|
||||
pMcFuncs->pMcChromaFunc = McChroma_neon;
|
||||
pMcFuncs->pfSampleAveraging = PixelAvg_neon;
|
||||
pMcFuncs->pfLumaHalfpelHor = McHorVer20Width9Or17_neon;//iWidth+1:8/16
|
||||
pMcFuncs->pfLumaHalfpelVer = McHorVer02Height9Or17_neon;//heigh+1:8/16
|
||||
pMcFuncs->pfLumaHalfpelCen = McHorVer22Width9Or17Height9Or17_neon;//iWidth+1/heigh+1
|
||||
}
|
||||
#endif
|
||||
#if defined(HAVE_NEON_AARCH64)
|
||||
if (uiCpuFlag & WELS_CPU_NEON) {
|
||||
pMcFuncs->pMcLumaFunc = McLuma_AArch64_neon;
|
||||
pMcFuncs->pMcChromaFunc = McChroma_AArch64_neon;
|
||||
pMcFuncs->pfSampleAveraging = PixelAvg_AArch64_neon;
|
||||
pMcFuncs->pfLumaHalfpelHor = McHorVer20Width9Or17_AArch64_neon;//iWidth+1:8/16
|
||||
pMcFuncs->pfLumaHalfpelVer = McHorVer02Height9Or17_AArch64_neon;//heigh+1:8/16
|
||||
pMcFuncs->pfLumaHalfpelCen = McHorVer22Width9Or17Height9Or17_AArch64_neon;//iWidth+1/heigh+1
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} // namespace WelsCommon
|
||||
@@ -35,7 +35,13 @@
|
||||
#include "memory_align.h"
|
||||
#include "macros.h"
|
||||
|
||||
namespace WelsEnc {
|
||||
namespace WelsCommon {
|
||||
|
||||
#ifdef MEMORY_CHECK
|
||||
static FILE* fpMemChkPoint;
|
||||
static uint32_t nCountRequestNum;
|
||||
#endif
|
||||
|
||||
|
||||
CMemoryAlign::CMemoryAlign (const uint32_t kuiCacheLineSize)
|
||||
#ifdef MEMORY_MONITOR
|
||||
@@ -46,24 +52,66 @@ CMemoryAlign::CMemoryAlign (const uint32_t kuiCacheLineSize)
|
||||
m_nCacheLineSize = 0x10;
|
||||
else
|
||||
m_nCacheLineSize = kuiCacheLineSize;
|
||||
|
||||
#ifdef MEMORY_CHECK
|
||||
m_fpMemChkPoint = fopen ("./enc_mem_check_point.txt", "wt+");
|
||||
m_nCountRequestNum = 0;
|
||||
#endif//MEMORY_CHECK
|
||||
}
|
||||
|
||||
CMemoryAlign::~CMemoryAlign() {
|
||||
#ifdef MEMORY_MONITOR
|
||||
assert (m_nMemoryUsageInBytes == 0);
|
||||
#endif//MEMORY_MONITOR
|
||||
}
|
||||
|
||||
void* WelsMalloc (const uint32_t kuiSize, const char* kpTag, const uint32_t kiAlign) {
|
||||
const int32_t kiSizeOfVoidPointer = sizeof (void**);
|
||||
const int32_t kiSizeOfInt = sizeof (int32_t);
|
||||
const int32_t kiAlignedBytes = kiAlign - 1;
|
||||
const int32_t kiTrialRequestedSize = kuiSize + kiAlignedBytes + kiSizeOfVoidPointer + kiSizeOfInt;
|
||||
const int32_t kiActualRequestedSize = kiTrialRequestedSize;
|
||||
const uint32_t kiPayloadSize = kuiSize;
|
||||
|
||||
uint8_t* pBuf = (uint8_t*) malloc (kiActualRequestedSize);
|
||||
#ifdef MEMORY_CHECK
|
||||
fclose (m_fpMemChkPoint);
|
||||
m_fpMemChkPoint = NULL;
|
||||
if (fpMemChkPoint == NULL) {
|
||||
m_fpMemChkPoint = fopen ("./enc_mem_check_point.txt", "at+");
|
||||
m_nCountRequestNum = 0;
|
||||
}
|
||||
|
||||
m_nCountRequestNum = 0;
|
||||
#endif//MEMORY_CHECK
|
||||
if (fpMemChkPoint != NULL) {
|
||||
if (kpTag != NULL)
|
||||
fprintf (fpMemChkPoint, "WelsMalloc(), 0x%x : actual uiSize:\t%d\tbytes, input uiSize: %d bytes, %d - %s\n",
|
||||
(void*)pBuf, kiActualRequestedSize, kuiSize, nCountRequestNum++, kpTag);
|
||||
else
|
||||
fprintf (fpMemChkPoint, "WelsMalloc(), 0x%x : actual uiSize:\t%d\tbytes, input uiSize: %d bytes, %d \n", (void*)pBuf,
|
||||
kiActualRequestedSize, kuiSize, nCountRequestNum++);
|
||||
fflush (fpMemChkPoint);
|
||||
}
|
||||
#endif
|
||||
uint8_t* pAlignedBuffer;
|
||||
|
||||
if (NULL == pBuf)
|
||||
return NULL;
|
||||
|
||||
pAlignedBuffer = pBuf + kiAlignedBytes + kiSizeOfVoidPointer + kiSizeOfInt;
|
||||
pAlignedBuffer -= ((uintptr_t) pAlignedBuffer & kiAlignedBytes);
|
||||
* ((void**) (pAlignedBuffer - kiSizeOfVoidPointer)) = pBuf;
|
||||
* ((int32_t*) (pAlignedBuffer - (kiSizeOfVoidPointer + kiSizeOfInt))) = kiPayloadSize;
|
||||
|
||||
return pAlignedBuffer;
|
||||
}
|
||||
|
||||
void WelsFree (void* pPointer, const char* kpTag) {
|
||||
if (pPointer) {
|
||||
#ifdef MEMORY_CHECK
|
||||
if (m_fpMemChkPoint != NULL) {
|
||||
if (kpTag != NULL)
|
||||
fprintf (fpMemChkPoint, "WelsFree(), 0x%x - %s: \t%d\t bytes \n", (void*) (* (((void**) pPointer) - 1)), kpTag,
|
||||
kiMemoryLength);
|
||||
else
|
||||
fprintf (fpMemChkPoint, "WelsFree(), 0x%x \n", (void*) (* (((void**) pPointer) - 1)));
|
||||
fflush (fpMemChkPoint);
|
||||
}
|
||||
#endif
|
||||
free (* (((void**) pPointer) - 1));
|
||||
}
|
||||
}
|
||||
|
||||
void* CMemoryAlign::WelsMallocz (const uint32_t kuiSize, const char* kpTag) {
|
||||
@@ -78,40 +126,15 @@ void* CMemoryAlign::WelsMallocz (const uint32_t kuiSize, const char* kpTag) {
|
||||
}
|
||||
|
||||
void* CMemoryAlign::WelsMalloc (const uint32_t kuiSize, const char* kpTag) {
|
||||
const int32_t kiSizeOfVoidPointer = sizeof (void**);
|
||||
const int32_t kiSizeOfInt = sizeof (int32_t);
|
||||
const int32_t kiAlignedBytes = m_nCacheLineSize - 1;
|
||||
const int32_t kiTrialRequestedSize = kuiSize + kiAlignedBytes + kiSizeOfVoidPointer + kiSizeOfInt;
|
||||
const int32_t kiActualRequestedSize = kiTrialRequestedSize;
|
||||
const uint32_t kiPayloadSize = kuiSize;
|
||||
|
||||
uint8_t* pBuf = (uint8_t*) malloc (kiActualRequestedSize);
|
||||
#ifdef MEMORY_CHECK
|
||||
if (m_fpMemChkPoint != NULL) {
|
||||
if (kpTag != NULL)
|
||||
fprintf (m_fpMemChkPoint, "WelsMalloc(), 0x%x : actual uiSize:\t%d\tbytes, input uiSize: %d bytes, %d - %s\n",
|
||||
(void*)pBuf, kiActualRequestedSize, kuiSize, m_nCountRequestNum++, kpTag);
|
||||
else
|
||||
fprintf (m_fpMemChkPoint, "WelsMalloc(), 0x%x : actual uiSize:\t%d\tbytes, input uiSize: %d bytes, %d \n", (void*)pBuf,
|
||||
kiActualRequestedSize, kuiSize, m_nCountRequestNum++);
|
||||
fflush (m_fpMemChkPoint);
|
||||
}
|
||||
#endif
|
||||
uint8_t* pAlignedBuffer;
|
||||
|
||||
if (NULL == pBuf)
|
||||
return NULL;
|
||||
|
||||
pAlignedBuffer = pBuf + kiAlignedBytes + kiSizeOfVoidPointer + kiSizeOfInt;
|
||||
pAlignedBuffer -= ((uintptr_t) pAlignedBuffer & kiAlignedBytes);
|
||||
* ((void**) (pAlignedBuffer - kiSizeOfVoidPointer)) = pBuf;
|
||||
* ((int32_t*) (pAlignedBuffer - (kiSizeOfVoidPointer + kiSizeOfInt))) = kiPayloadSize;
|
||||
|
||||
void* pPointer = WelsCommon::WelsMalloc (kuiSize, kpTag, m_nCacheLineSize);
|
||||
#ifdef MEMORY_MONITOR
|
||||
m_nMemoryUsageInBytes += kiActualRequestedSize;
|
||||
if (pPointer != NULL) {
|
||||
const int32_t kiMemoryLength = * ((int32_t*) ((uint8_t*)pPointer - sizeof (void**) - sizeof (
|
||||
int32_t))) + m_nCacheLineSize - 1 + sizeof (void**) + sizeof (int32_t);
|
||||
m_nMemoryUsageInBytes += kiMemoryLength;
|
||||
}
|
||||
#endif//MEMORY_MONITOR
|
||||
|
||||
return pAlignedBuffer;
|
||||
return pPointer;
|
||||
}
|
||||
|
||||
void CMemoryAlign::WelsFree (void* pPointer, const char* kpTag) {
|
||||
@@ -121,18 +144,17 @@ void CMemoryAlign::WelsFree (void* pPointer, const char* kpTag) {
|
||||
int32_t))) + m_nCacheLineSize - 1 + sizeof (void**) + sizeof (int32_t);
|
||||
m_nMemoryUsageInBytes -= kiMemoryLength;
|
||||
#endif//MEMORY_MONITOR
|
||||
#ifdef MEMORY_CHECK
|
||||
if (m_fpMemChkPoint != NULL) {
|
||||
if (kpTag != NULL)
|
||||
fprintf (m_fpMemChkPoint, "WelsFree(), 0x%x - %s: \t%d\t bytes \n", (void*) (* (((void**) pPointer) - 1)), kpTag,
|
||||
kiMemoryLength);
|
||||
else
|
||||
fprintf (m_fpMemChkPoint, "WelsFree(), 0x%x \n", (void*) (* (((void**) pPointer) - 1)));
|
||||
fflush (m_fpMemChkPoint);
|
||||
}
|
||||
#endif
|
||||
free (* (((void**) pPointer) - 1));
|
||||
}
|
||||
WelsCommon::WelsFree (pPointer, kpTag);
|
||||
}
|
||||
|
||||
void* WelsMallocz (const uint32_t kuiSize, const char* kpTag) {
|
||||
void* pPointer = WelsMalloc (kuiSize, kpTag, 16);
|
||||
if (NULL == pPointer) {
|
||||
return NULL;
|
||||
}
|
||||
memset (pPointer, 0, kuiSize);
|
||||
return pPointer;
|
||||
}
|
||||
|
||||
const uint32_t CMemoryAlign::WelsGetCacheLineSize() const {
|
||||
@@ -143,4 +165,4 @@ const uint32_t CMemoryAlign::WelsGetMemoryUsage() const {
|
||||
return m_nMemoryUsageInBytes;
|
||||
}
|
||||
|
||||
} // end of namespace WelsEnc
|
||||
} // end of namespace WelsCommon
|
||||
@@ -58,6 +58,7 @@ welsCodecTrace::welsCodecTrace() {
|
||||
|
||||
m_sLogCtx.pLogCtx = this;
|
||||
m_sLogCtx.pfLog = StaticCodecTrace;
|
||||
m_sLogCtx.pCodecInstance = NULL;
|
||||
}
|
||||
|
||||
welsCodecTrace::~welsCodecTrace() {
|
||||
|
||||
@@ -7,6 +7,8 @@ COMMON_CPP_SRCS=\
|
||||
$(COMMON_SRCDIR)/src/deblocking_common.cpp\
|
||||
$(COMMON_SRCDIR)/src/expand_pic.cpp\
|
||||
$(COMMON_SRCDIR)/src/intra_pred_common.cpp\
|
||||
$(COMMON_SRCDIR)/src/mc.cpp\
|
||||
$(COMMON_SRCDIR)/src/memory_align.cpp\
|
||||
$(COMMON_SRCDIR)/src/sad_common.cpp\
|
||||
$(COMMON_SRCDIR)/src/utils.cpp\
|
||||
$(COMMON_SRCDIR)/src/welsCodecTrace.cpp\
|
||||
|
||||
@@ -60,10 +60,10 @@
|
||||
; Macros
|
||||
;***********************************************************************
|
||||
|
||||
DEFAULT REL
|
||||
|
||||
%ifdef WIN64 ; Windows x64 ;************************************
|
||||
|
||||
DEFAULT REL
|
||||
|
||||
BITS 64
|
||||
|
||||
%define arg1 rcx
|
||||
@@ -114,6 +114,8 @@ BITS 64
|
||||
|
||||
%elifdef UNIX64 ; Unix x64 ;************************************
|
||||
|
||||
DEFAULT REL
|
||||
|
||||
BITS 64
|
||||
|
||||
%ifidn __OUTPUT_FORMAT__,elf64
|
||||
|
||||
@@ -5276,3 +5276,14 @@ WELS_EXTERN DeblockLumaTransposeV2H_sse2
|
||||
pop r3
|
||||
ret
|
||||
|
||||
WELS_EXTERN WelsNonZeroCount_sse2
|
||||
%assign push_num 0
|
||||
LOAD_1_PARA
|
||||
movdqu xmm0, [r0]
|
||||
movq xmm1, [r0+16]
|
||||
WELS_DB1 xmm2
|
||||
pminub xmm0, xmm2
|
||||
pminub xmm1, xmm2
|
||||
movdqu [r0], xmm0
|
||||
movq [r0+16], xmm1
|
||||
ret
|
||||
|
||||
@@ -605,23 +605,17 @@ int CUtils::CheckOS() {
|
||||
OSVERSIONINFOEX osvi;
|
||||
ZeroMemory (&osvi, sizeof (OSVERSIONINFOEX));
|
||||
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
|
||||
osvi.dwPlatformId = VER_PLATFORM_WIN32_NT;
|
||||
osvi.dwMajorVersion = 6; // Vista
|
||||
DWORDLONG condmask = VerSetConditionMask (VerSetConditionMask (0, VER_MAJORVERSION, VER_GREATER_EQUAL),
|
||||
VER_PLATFORMID, VER_EQUAL);
|
||||
|
||||
if (!GetVersionEx ((OSVERSIONINFO*) &osvi)) {
|
||||
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
|
||||
if (! GetVersionEx ((OSVERSIONINFO*) &osvi))
|
||||
return iType;
|
||||
}
|
||||
|
||||
switch (osvi.dwPlatformId) {
|
||||
case VER_PLATFORM_WIN32_NT:
|
||||
if (osvi.dwMajorVersion >= 6)
|
||||
iType = OS_VISTA_UPPER;
|
||||
else if (osvi.dwMajorVersion == 5)
|
||||
if (VerifyVersionInfo (&osvi, VER_MAJORVERSION | VER_PLATFORMID, condmask)) {
|
||||
iType = OS_VISTA_UPPER;
|
||||
} else {
|
||||
osvi.dwMajorVersion = 5; // XP/2000
|
||||
if (VerifyVersionInfo (&osvi, VER_MAJORVERSION | VER_PLATFORMID, condmask))
|
||||
iType = OS_XP;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -62,18 +62,22 @@ using namespace std;
|
||||
#endif
|
||||
//using namespace WelsDec;
|
||||
|
||||
//#define STICK_STREAM_SIZE // For Demo interfaces test with track file of integrated frames
|
||||
//#define NO_DELAY_DECODING // For Demo interfaces test with no delay decoding
|
||||
|
||||
void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, const char* kpOuputFileName,
|
||||
int32_t& iWidth, int32_t& iHeight, const char* pOptionFileName) {
|
||||
int32_t& iWidth, int32_t& iHeight, const char* pOptionFileName, const char* pLengthFileName) {
|
||||
FILE* pH264File = NULL;
|
||||
FILE* pYuvFile = NULL;
|
||||
FILE* pOptionFile = NULL;
|
||||
#if defined ( STICK_STREAM_SIZE )
|
||||
FILE* fpTrack = fopen ("3.len", "rb");
|
||||
unsigned long pInfo[4];
|
||||
#endif// STICK_STREAM_SIZE
|
||||
// Lenght input mode support
|
||||
FILE* fpTrack = NULL;
|
||||
if (pLengthFileName != NULL) {
|
||||
fpTrack = fopen (pLengthFileName, "rb");
|
||||
if (fpTrack == NULL)
|
||||
printf ("Length file open ERROR!\n");
|
||||
}
|
||||
int32_t pInfo[4];
|
||||
|
||||
unsigned long long uiTimeStamp = 0;
|
||||
int64_t iStart = 0, iEnd = 0, iTotal = 0;
|
||||
int32_t iSliceSize;
|
||||
@@ -92,7 +96,10 @@ void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, cons
|
||||
int32_t iFrameCount = 0;
|
||||
int32_t iEndOfStreamFlag = 0;
|
||||
int32_t iColorFormat = videoFormatInternal;
|
||||
|
||||
//for coverage test purpose
|
||||
int32_t iErrorConMethod = (int32_t) ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE;
|
||||
pDecoder->SetOption (DECODER_OPTION_ERROR_CON_IDC, &iErrorConMethod);
|
||||
//~end for
|
||||
CUtils cOutputModule;
|
||||
double dElapsed = 0;
|
||||
|
||||
@@ -167,21 +174,24 @@ void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, cons
|
||||
pDecoder->SetOption (DECODER_OPTION_END_OF_STREAM, (void*)&iEndOfStreamFlag);
|
||||
break;
|
||||
}
|
||||
|
||||
#if defined ( STICK_STREAM_SIZE )
|
||||
// Read length from file if needed
|
||||
if (fpTrack) {
|
||||
fread (pInfo, 4, sizeof (unsigned long), fpTrack);
|
||||
iSliceSize = static_cast<int32_t>(pInfo[2]);
|
||||
}
|
||||
#else
|
||||
for (i = 0; i < iFileSize; i++) {
|
||||
if ((pBuf[iBufPos + i] == 0 && pBuf[iBufPos + i + 1] == 0 && pBuf[iBufPos + i + 2] == 0 && pBuf[iBufPos + i + 3] == 1
|
||||
&& i > 0) || (pBuf[iBufPos + i] == 0 && pBuf[iBufPos + i + 1] == 0 && pBuf[iBufPos + i + 2] == 1 && i > 0)) {
|
||||
break;
|
||||
if (fread (pInfo, 4, sizeof (int32_t), fpTrack) < 4)
|
||||
return;
|
||||
iSliceSize = static_cast<int32_t> (pInfo[2]);
|
||||
} else {
|
||||
for (i = 0; i < iFileSize; i++) {
|
||||
if ((pBuf[iBufPos + i] == 0 && pBuf[iBufPos + i + 1] == 0 && pBuf[iBufPos + i + 2] == 0 && pBuf[iBufPos + i + 3] == 1
|
||||
&& i > 0) || (pBuf[iBufPos + i] == 0 && pBuf[iBufPos + i + 1] == 0 && pBuf[iBufPos + i + 2] == 1 && i > 0)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
iSliceSize = i;
|
||||
}
|
||||
if (iSliceSize < 4) { //too small size, no effective data, ignore
|
||||
iBufPos += iSliceSize;
|
||||
continue;
|
||||
}
|
||||
iSliceSize = i;
|
||||
#endif
|
||||
|
||||
//for coverage test purpose
|
||||
int32_t iOutputColorFormat;
|
||||
@@ -200,8 +210,6 @@ void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, cons
|
||||
pDecoder->GetOption (DECODER_OPTION_VCL_NAL, &iFeedbackVclNalInAu);
|
||||
int32_t iFeedbackTidInAu;
|
||||
pDecoder->GetOption (DECODER_OPTION_TEMPORAL_ID, &iFeedbackTidInAu);
|
||||
int32_t iErrorConMethod = (int32_t) ERROR_CON_SLICE_COPY_CROSS_IDR_FREEZE_RES_CHANGE;
|
||||
pDecoder->SetOption (DECODER_OPTION_ERROR_CON_IDC, &iErrorConMethod);
|
||||
//~end for
|
||||
|
||||
iStart = WelsTime();
|
||||
@@ -211,7 +219,11 @@ void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, cons
|
||||
uiTimeStamp ++;
|
||||
memset (&sDstBufInfo, 0, sizeof (SBufferInfo));
|
||||
sDstBufInfo.uiInBsTimeStamp = uiTimeStamp;
|
||||
#ifndef NO_DELAY_DECODING
|
||||
pDecoder->DecodeFrameNoDelay (pBuf + iBufPos, iSliceSize, pData, &sDstBufInfo);
|
||||
#else
|
||||
pDecoder->DecodeFrame2 (pBuf + iBufPos, iSliceSize, pData, &sDstBufInfo);
|
||||
#endif
|
||||
|
||||
if (sDstBufInfo.iBufferStatus == 1) {
|
||||
pDst[0] = pData[0];
|
||||
@@ -273,42 +285,10 @@ void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, cons
|
||||
++ iSliceIndex;
|
||||
}
|
||||
|
||||
// Get pending last frame
|
||||
pData[0] = NULL;
|
||||
pData[1] = NULL;
|
||||
pData[2] = NULL;
|
||||
memset (&sDstBufInfo, 0, sizeof (SBufferInfo));
|
||||
|
||||
pDecoder->DecodeFrame2 (NULL, 0, pData, &sDstBufInfo);
|
||||
if (sDstBufInfo.iBufferStatus == 1) {
|
||||
pDst[0] = pData[0];
|
||||
pDst[1] = pData[1];
|
||||
pDst[2] = pData[2];
|
||||
}
|
||||
|
||||
if (sDstBufInfo.iBufferStatus == 1) {
|
||||
cOutputModule.Process ((void**)pDst, &sDstBufInfo, pYuvFile);
|
||||
iWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth;
|
||||
iHeight = sDstBufInfo.UsrData.sSystemBuffer.iHeight;
|
||||
|
||||
if (pOptionFile != NULL) {
|
||||
/* Anyway, we need write in case of final frame decoding */
|
||||
fwrite (&iFrameCount, sizeof (iFrameCount), 1, pOptionFile);
|
||||
fwrite (&iWidth , sizeof (iWidth) , 1, pOptionFile);
|
||||
fwrite (&iHeight, sizeof (iHeight), 1, pOptionFile);
|
||||
iLastWidth = iWidth;
|
||||
iLastHeight = iHeight;
|
||||
}
|
||||
++ iFrameCount;
|
||||
}
|
||||
|
||||
|
||||
#if defined ( STICK_STREAM_SIZE )
|
||||
if (fpTrack) {
|
||||
fclose (fpTrack);
|
||||
fpTrack = NULL;
|
||||
}
|
||||
#endif// STICK_STREAM_SIZE
|
||||
|
||||
dElapsed = iTotal / 1e6;
|
||||
fprintf (stderr, "-------------------------------------------------------\n");
|
||||
@@ -344,8 +324,8 @@ int32_t main (int32_t iArgC, char* pArgV[]) {
|
||||
ISVCDecoder* pDecoder = NULL;
|
||||
|
||||
SDecodingParam sDecParam = {0};
|
||||
string strInputFile (""), strOutputFile (""), strOptionFile ("");
|
||||
int iLevelSetting = -1;
|
||||
string strInputFile (""), strOutputFile (""), strOptionFile (""), strLengthFile ("");
|
||||
int iLevelSetting = (int) WELS_LOG_WARNING;
|
||||
|
||||
sDecParam.sVideoProperty.size = sizeof (sDecParam.sVideoProperty);
|
||||
|
||||
@@ -431,6 +411,13 @@ int32_t main (int32_t iArgC, char* pArgV[]) {
|
||||
printf ("trace level not specified.\n");
|
||||
return 1;
|
||||
}
|
||||
} else if (!strcmp (cmd, "-length")) {
|
||||
if (i + 1 < iArgC)
|
||||
strLengthFile = pArgV[++i];
|
||||
else {
|
||||
printf ("lenght file not specified.\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -469,7 +456,7 @@ int32_t main (int32_t iArgC, char* pArgV[]) {
|
||||
|
||||
H264DecodeInstance (pDecoder, strInputFile.c_str(), !strOutputFile.empty() ? strOutputFile.c_str() : NULL, iWidth,
|
||||
iHeight,
|
||||
(!strOptionFile.empty() ? strOptionFile.c_str() : NULL));
|
||||
(!strOptionFile.empty() ? strOptionFile.c_str() : NULL), (!strLengthFile.empty() ? strLengthFile.c_str() : NULL));
|
||||
|
||||
if (sDecParam.pFileNameRestructed != NULL) {
|
||||
delete []sDecParam.pFileNameRestructed;
|
||||
|
||||
@@ -232,8 +232,28 @@ int ParseConfig (CReadConfig& cRdCfg, SSourcePicture* pSrcPic, SEncParamExt& pSv
|
||||
pSvcParam.uiIntraPeriod = atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("MaxNalSize") == 0) {
|
||||
pSvcParam.uiMaxNalSize = atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("EnableSpsPpsIDAddition") == 0) {
|
||||
pSvcParam.bEnableSpsPpsIdAddition = atoi (strTag[1].c_str()) ? true : false;
|
||||
} else if (strTag[0].compare ("SpsPpsIDStrategy") == 0) {
|
||||
int32_t iValue = atoi (strTag[1].c_str());
|
||||
switch (iValue) {
|
||||
case 0:
|
||||
pSvcParam.eSpsPpsIdStrategy = CONSTANT_ID;
|
||||
break;
|
||||
case 0x01:
|
||||
pSvcParam.eSpsPpsIdStrategy = INCREASING_ID;
|
||||
break;
|
||||
case 0x02:
|
||||
pSvcParam.eSpsPpsIdStrategy = SPS_LISTING;
|
||||
break;
|
||||
case 0x03:
|
||||
pSvcParam.eSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING;
|
||||
break;
|
||||
case 0x06:
|
||||
pSvcParam.eSpsPpsIdStrategy = SPS_PPS_LISTING;
|
||||
break;
|
||||
default:
|
||||
pSvcParam.eSpsPpsIdStrategy = CONSTANT_ID;
|
||||
break;
|
||||
}
|
||||
} else if (strTag[0].compare ("EnableScalableSEI") == 0) {
|
||||
pSvcParam.bEnableSSEI = atoi (strTag[1].c_str()) ? true : false;
|
||||
} else if (strTag[0].compare ("EnableFrameCropping") == 0) {
|
||||
@@ -420,9 +440,29 @@ int ParseCommandLine (int argc, char** argv, SSourcePicture* pSrcPic, SEncParamE
|
||||
else if (!strcmp (pCommand, "-nalsize") && (n < argc))
|
||||
pSvcParam.uiMaxNalSize = atoi (argv[n++]);
|
||||
|
||||
else if (!strcmp (pCommand, "-spsid") && (n < argc))
|
||||
pSvcParam.bEnableSpsPpsIdAddition = atoi (argv[n++]) ? true : false;
|
||||
|
||||
else if (!strcmp (pCommand, "-spsid") && (n < argc)) {
|
||||
int32_t iValue = atoi (argv[n++]);
|
||||
switch (iValue) {
|
||||
case 0:
|
||||
pSvcParam.eSpsPpsIdStrategy = CONSTANT_ID;
|
||||
break;
|
||||
case 0x01:
|
||||
pSvcParam.eSpsPpsIdStrategy = INCREASING_ID;
|
||||
break;
|
||||
case 0x02:
|
||||
pSvcParam.eSpsPpsIdStrategy = SPS_LISTING;
|
||||
break;
|
||||
case 0x03:
|
||||
pSvcParam.eSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING;
|
||||
break;
|
||||
case 0x06:
|
||||
pSvcParam.eSpsPpsIdStrategy = SPS_PPS_LISTING;
|
||||
break;
|
||||
default:
|
||||
pSvcParam.eSpsPpsIdStrategy = CONSTANT_ID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (!strcmp (pCommand, "-cabac") && (n < argc))
|
||||
pSvcParam.iEntropyCodingModeFlag = atoi (argv[n++]);
|
||||
|
||||
@@ -591,7 +631,7 @@ int FillSpecificParameters (SEncParamExt& sParam) {
|
||||
sParam.bEnableLongTermReference = 0; // long term reference control
|
||||
sParam.iLtrMarkPeriod = 30;
|
||||
sParam.uiIntraPeriod = 320; // period of Intra frame
|
||||
sParam.bEnableSpsPpsIdAddition = 1;
|
||||
sParam.eSpsPpsIdStrategy = INCREASING_ID;
|
||||
sParam.bPrefixNalAddingCtrl = 0;
|
||||
sParam.iComplexityMode = MEDIUM_COMPLEXITY;
|
||||
int iIndexLayer = 0;
|
||||
@@ -667,7 +707,7 @@ int ProcessEncoding (ISVCEncoder* pPtrEnc, int argc, char** argv, bool bConfigFi
|
||||
FILE* fpGolden = NULL;
|
||||
#endif
|
||||
#if defined ( STICK_STREAM_SIZE )
|
||||
FILE* fTrackStream = fopen ("coding_size.stream", "wb");;
|
||||
FILE* fTrackStream = fopen ("coding_size.stream", "wb");
|
||||
#endif
|
||||
SFilesSet fs;
|
||||
// for configuration file
|
||||
|
||||
@@ -99,18 +99,6 @@
|
||||
// }
|
||||
.endm
|
||||
#endif
|
||||
// r0 int8_t* non_zero_count,
|
||||
WELS_ASM_FUNC_BEGIN SetNonZeroCount_neon
|
||||
vld1.64 {d0-d2}, [r0]
|
||||
vceq.s8 q0, q0, #0
|
||||
vceq.s8 d2, d2, #0
|
||||
vmvn q0, q0
|
||||
vmvn d2, d2
|
||||
vabs.s8 q0, q0
|
||||
vabs.s8 d2, d2
|
||||
vst1.64 {d0-d2}, [r0]
|
||||
WELS_ASM_FUNC_END
|
||||
|
||||
|
||||
// uint8_t *pred, const int32_t stride, int16_t *rs
|
||||
WELS_ASM_FUNC_BEGIN IdctResAddPred_neon
|
||||
|
||||
@@ -100,20 +100,6 @@
|
||||
// }
|
||||
.endm
|
||||
#endif
|
||||
// x0 int8_t* non_zero_count,
|
||||
WELS_ASM_AARCH64_FUNC_BEGIN SetNonZeroCount_AArch64_neon
|
||||
mov x1, x0
|
||||
ld1 {v0.16b}, [x1], #16
|
||||
ld1 {v1.8b}, [x1]
|
||||
cmeq v0.16b, v0.16b, #0
|
||||
cmeq v1.8b, v1.8b, #0
|
||||
mvn v0.16b, v0.16b
|
||||
mvn v1.8b, v1.8b
|
||||
abs v0.16b, v0.16b
|
||||
abs v1.8b, v1.8b
|
||||
st1 {v0.16b}, [x0], #16
|
||||
st1 {v1.8b}, [x0]
|
||||
WELS_ASM_AARCH64_FUNC_END
|
||||
|
||||
// uint8_t *pred, const int32_t stride, int16_t *rs
|
||||
WELS_ASM_AARCH64_FUNC_BEGIN IdctResAddPred_AArch64_neon
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include "parameter_sets.h"
|
||||
#include "decoder_context.h"
|
||||
|
||||
#define DISABLE_HP_BRANCH_1_4
|
||||
namespace WelsDec {
|
||||
|
||||
/*!
|
||||
@@ -131,11 +132,26 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
|
||||
*/
|
||||
int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux, uint8_t* pSrcNal, const int32_t kSrcNalLen);
|
||||
|
||||
/*!
|
||||
*************************************************************************************
|
||||
* \brief to parse scaling list message payload
|
||||
*
|
||||
* \param PPS SPS scaling list matrix message to be parsed output
|
||||
* \param pBsAux bitstream reader auxiliary
|
||||
*
|
||||
* \return 0 - successed
|
||||
* 1 - failed
|
||||
*
|
||||
* \note Call it in case scaling matrix present at sps or pps
|
||||
*************************************************************************************
|
||||
*/
|
||||
int32_t SetScalingListValue (uint8_t *pScalingList,int iScalingListNum,bool* bUseDefaultScalingMatrixFlag,PBitStringAux pBsAux);
|
||||
int32_t ParseScalingList(PSps pSps,PBitStringAux pBs,bool bPPS,bool *bScalingListPresentFlag,uint8_t(*iScalingList4x4)[16],uint8_t(*iScalingList8x8)[64]);
|
||||
/*!
|
||||
*************************************************************************************
|
||||
* \brief to parse SEI message payload
|
||||
*
|
||||
* \param pSei sei message to be parsed output
|
||||
* \param pSei sei message to be parsed output
|
||||
* \param pBsAux bitstream reader auxiliary
|
||||
*
|
||||
* \return 0 - successed
|
||||
|
||||
@@ -69,7 +69,7 @@ struct TagDqLayer {
|
||||
int16_t (*pMvd[LIST_A])[MB_BLOCK4x4_NUM][MV_A];
|
||||
int8_t (*pRefIndex[LIST_A])[MB_BLOCK4x4_NUM];
|
||||
int8_t* pLumaQp;
|
||||
int8_t* pChromaQp;
|
||||
int8_t (*pChromaQp)[2];
|
||||
int8_t* pCbp;
|
||||
uint8_t *pCbfDc;
|
||||
int8_t (*pNzc)[24];
|
||||
@@ -102,13 +102,16 @@ struct TagDqLayer {
|
||||
int32_t iInterLayerSliceBetaOffset;
|
||||
//SPosOffset sScaledRefLayer;
|
||||
int32_t iSliceGroupChangeCycle;
|
||||
|
||||
PRefPicListReorderSyn pRefPicListReordering;
|
||||
PPredWeightTabSyn pPredWeightTable;
|
||||
PRefPicMarking pRefPicMarking; // Decoded reference picture marking syntaxs
|
||||
PRefBasePicMarking pRefPicBaseMarking;
|
||||
|
||||
PPicture pRef; // reference picture pointer
|
||||
PPicture pDec; // reconstruction picture pointer for layer
|
||||
|
||||
bool bUseWeightPredictionFlag;
|
||||
bool bStoreRefBasePicFlag; // iCurTid == 0 && iCurQid = 0 && bEncodeKeyPic = 1
|
||||
bool bTCoeffLevelPredFlag;
|
||||
bool bConstrainedIntraResamplingFlag;
|
||||
|
||||
@@ -89,7 +89,9 @@ static inline int32_t BsGetBits (PBitStringAux pBs, int32_t iNumBits, uint32_t*
|
||||
|
||||
// for data sharing cross modules and try to reduce size of binary generated, 12/10/2009
|
||||
extern const uint8_t g_kuiIntra4x4CbpTable[48];
|
||||
extern const uint8_t g_kuiIntra4x4CbpTable400[16];
|
||||
extern const uint8_t g_kuiInterCbpTable[48];
|
||||
extern const uint8_t g_kuiInterCbpTable400[16];
|
||||
|
||||
extern const uint8_t g_kuiLeadingZeroTable[256];
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ int32_t WelsMbIntraPredictionConstruction (PWelsDecoderContext pCtx, PDqLayer pC
|
||||
int32_t WelsMbInterSampleConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer,
|
||||
uint8_t* pDstY, uint8_t* pDstU, uint8_t* pDstV, int32_t iStrideL, int32_t iStrideC);
|
||||
int32_t WelsMbInterConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer);
|
||||
void WelsLumaDcDequantIdct (int16_t* pBlock, int32_t iQp);
|
||||
void WelsLumaDcDequantIdct (int16_t* pBlock, int32_t iQp,PWelsDecoderContext pCtx);
|
||||
int32_t WelsMbInterPrediction (PWelsDecoderContext pCtx, PDqLayer pCurLayer);
|
||||
void WelsChromaDcIdct (int16_t* pBlock);
|
||||
|
||||
@@ -73,13 +73,11 @@ void WelsBlockZero8x8_sse2(int16_t * block, int32_t stride);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_NEON)
|
||||
void SetNonZeroCount_neon (int8_t* pNonZeroCount);
|
||||
void WelsBlockZero16x16_neon(int16_t * block, int32_t stride);
|
||||
void WelsBlockZero8x8_neon(int16_t * block, int32_t stride);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_NEON_AARCH64)
|
||||
void SetNonZeroCount_AArch64_neon (int8_t* pNonZeroCount);
|
||||
void WelsBlockZero16x16_AArch64_neon(int16_t * block, int32_t stride);
|
||||
void WelsBlockZero8x8_AArch64_neon(int16_t * block, int32_t stride);
|
||||
#endif
|
||||
@@ -87,8 +85,6 @@ void WelsBlockZero8x8_AArch64_neon(int16_t * block, int32_t stride);
|
||||
}
|
||||
#endif//__cplusplus
|
||||
|
||||
void SetNonZeroCount_c (int8_t* pNonZeroCount);
|
||||
|
||||
void WelsBlockFuncInit (SBlockFunc* pFunc, int32_t iCpu);
|
||||
void WelsBlockZero16x16_c(int16_t * block, int32_t stride);
|
||||
void WelsBlockZero8x8_c(int16_t * block, int32_t stride);
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
#include "crt_util_safe_x.h"
|
||||
#include "mb_cache.h"
|
||||
#include "expand_pic.h"
|
||||
#include "mc.h"
|
||||
|
||||
namespace WelsDec {
|
||||
#define MAX_PRED_MODE_ID_I16x16 3
|
||||
@@ -65,16 +66,15 @@ namespace WelsDec {
|
||||
typedef struct SWels_Cabac_Element {
|
||||
uint8_t uiState;
|
||||
uint8_t uiMPS;
|
||||
}SWelsCabacCtx, *PWelsCabacCtx;
|
||||
} SWelsCabacCtx, *PWelsCabacCtx;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
uint64_t uiRange;
|
||||
uint64_t uiOffset;
|
||||
int32_t iBitsLeft;
|
||||
uint8_t *pBuffStart;
|
||||
uint8_t *pBuffCurr;
|
||||
uint8_t *pBuffEnd;
|
||||
uint8_t* pBuffStart;
|
||||
uint8_t* pBuffCurr;
|
||||
uint8_t* pBuffEnd;
|
||||
} SWelsCabacDecEngine, *PWelsCabacDecEngine;
|
||||
|
||||
#define NEW_CTX_OFFSET_MB_TYPE_I 3
|
||||
@@ -95,11 +95,11 @@ typedef struct
|
||||
#define CTX_NUM_CBP 4
|
||||
|
||||
typedef struct TagDataBuffer {
|
||||
uint8_t* pHead;
|
||||
uint8_t* pEnd;
|
||||
uint8_t* pHead;
|
||||
uint8_t* pEnd;
|
||||
|
||||
uint8_t* pStartPos;
|
||||
uint8_t* pCurPos;
|
||||
uint8_t* pStartPos;
|
||||
uint8_t* pCurPos;
|
||||
} SDataBuffer;
|
||||
|
||||
//limit size for SPS PPS total permitted size for parse_only
|
||||
@@ -133,40 +133,33 @@ typedef void (*PExpandPictureFunc) (uint8_t* pDst, const int32_t kiStride, const
|
||||
|
||||
/**/
|
||||
typedef struct TagRefPic {
|
||||
PPicture pRefList[LIST_A][MAX_REF_PIC_COUNT]; // reference picture marking plus FIFO scheme
|
||||
PPicture pShortRefList[LIST_A][MAX_SHORT_REF_COUNT];
|
||||
PPicture pLongRefList[LIST_A][MAX_LONG_REF_COUNT];
|
||||
uint8_t uiRefCount[LIST_A];
|
||||
uint8_t uiShortRefCount[LIST_A];
|
||||
uint8_t uiLongRefCount[LIST_A]; // dependend on ref pic module
|
||||
int32_t iMaxLongTermFrameIdx;
|
||||
PPicture pRefList[LIST_A][MAX_REF_PIC_COUNT]; // reference picture marking plus FIFO scheme
|
||||
PPicture pShortRefList[LIST_A][MAX_SHORT_REF_COUNT];
|
||||
PPicture pLongRefList[LIST_A][MAX_LONG_REF_COUNT];
|
||||
uint8_t uiRefCount[LIST_A];
|
||||
uint8_t uiShortRefCount[LIST_A];
|
||||
uint8_t uiLongRefCount[LIST_A]; // dependend on ref pic module
|
||||
int32_t iMaxLongTermFrameIdx;
|
||||
} SRefPic, *PRefPic;
|
||||
|
||||
typedef void (*PWelsMcFunc) (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight);
|
||||
typedef struct TagMcFunc {
|
||||
PWelsMcFunc pMcLumaFunc;
|
||||
PWelsMcFunc pMcChromaFunc;
|
||||
} SMcFunc;
|
||||
|
||||
typedef void (*PCopyFunc) (uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS);
|
||||
typedef struct TagCopyFunc {
|
||||
PCopyFunc pCopyLumaFunc;
|
||||
PCopyFunc pCopyChromaFunc;
|
||||
PCopyFunc pCopyLumaFunc;
|
||||
PCopyFunc pCopyChromaFunc;
|
||||
} SCopyFunc;
|
||||
|
||||
//deblock module defination
|
||||
struct TagDeblockingFunc;
|
||||
|
||||
typedef struct tagDeblockingFilter {
|
||||
uint8_t* pCsData[3]; // pointer to reconstructed picture data
|
||||
int32_t iCsStride[2]; // Cs stride
|
||||
EWelsSliceType eSliceType;
|
||||
int8_t iSliceAlphaC0Offset;
|
||||
int8_t iSliceBetaOffset;
|
||||
int8_t iChromaQP;
|
||||
int8_t iLumaQP;
|
||||
struct TagDeblockingFunc* pLoopf;
|
||||
uint8_t* pCsData[3]; // pointer to reconstructed picture data
|
||||
int32_t iCsStride[2]; // Cs stride
|
||||
EWelsSliceType eSliceType;
|
||||
int8_t iSliceAlphaC0Offset;
|
||||
int8_t iSliceBetaOffset;
|
||||
int8_t iChromaQP[2];
|
||||
int8_t iLumaQP;
|
||||
struct TagDeblockingFunc* pLoopf;
|
||||
} SDeblockingFilter, *PDeblockingFilter;
|
||||
|
||||
typedef void (*PDeblockingFilterMbFunc) (PDqLayer pCurDqLayer, PDeblockingFilter filter, int32_t boundry_flag);
|
||||
@@ -177,25 +170,35 @@ typedef void (*PChromaDeblockingLT4Func) (uint8_t* iSampleCb, uint8_t* iSampleCr
|
||||
int32_t iBeta, int8_t* iTc);
|
||||
typedef void (*PChromaDeblockingEQ4Func) (uint8_t* iSampleCb, uint8_t* iSampleCr, int32_t iStride, int32_t iAlpha,
|
||||
int32_t iBeta);
|
||||
typedef void (*PChromaDeblockingLT4Func2) (uint8_t* iSampleCbr, int32_t iStride, int32_t iAlpha,
|
||||
int32_t iBeta, int8_t* iTc);
|
||||
typedef void (*PChromaDeblockingEQ4Func2) (uint8_t* iSampleCbr, int32_t iStride, int32_t iAlpha,
|
||||
int32_t iBeta);
|
||||
|
||||
typedef struct TagDeblockingFunc {
|
||||
PLumaDeblockingLT4Func pfLumaDeblockingLT4Ver;
|
||||
PLumaDeblockingEQ4Func pfLumaDeblockingEQ4Ver;
|
||||
PLumaDeblockingLT4Func pfLumaDeblockingLT4Hor;
|
||||
PLumaDeblockingEQ4Func pfLumaDeblockingEQ4Hor;
|
||||
PLumaDeblockingLT4Func pfLumaDeblockingLT4Ver;
|
||||
PLumaDeblockingEQ4Func pfLumaDeblockingEQ4Ver;
|
||||
PLumaDeblockingLT4Func pfLumaDeblockingLT4Hor;
|
||||
PLumaDeblockingEQ4Func pfLumaDeblockingEQ4Hor;
|
||||
|
||||
PChromaDeblockingLT4Func pfChromaDeblockingLT4Ver;
|
||||
PChromaDeblockingEQ4Func pfChromaDeblockingEQ4Ver;
|
||||
PChromaDeblockingLT4Func pfChromaDeblockingLT4Hor;
|
||||
PChromaDeblockingEQ4Func pfChromaDeblockingEQ4Hor;
|
||||
|
||||
PChromaDeblockingLT4Func2 pfChromaDeblockingLT4Ver2;
|
||||
PChromaDeblockingEQ4Func2 pfChromaDeblockingEQ4Ver2;
|
||||
PChromaDeblockingLT4Func2 pfChromaDeblockingLT4Hor2;
|
||||
PChromaDeblockingEQ4Func2 pfChromaDeblockingEQ4Hor2;
|
||||
|
||||
PChromaDeblockingLT4Func pfChromaDeblockingLT4Ver;
|
||||
PChromaDeblockingEQ4Func pfChromaDeblockingEQ4Ver;
|
||||
PChromaDeblockingLT4Func pfChromaDeblockingLT4Hor;
|
||||
PChromaDeblockingEQ4Func pfChromaDeblockingEQ4Hor;
|
||||
} SDeblockingFunc, *PDeblockingFunc;
|
||||
|
||||
typedef void (*PWelsNonZeroCountFunc) (int8_t* pNonZeroCount);
|
||||
typedef void (*PWelsBlockZeroFunc) (int16_t* block,int32_t stride);
|
||||
typedef void (*PWelsBlockZeroFunc) (int16_t* block, int32_t stride);
|
||||
typedef struct TagBlockFunc {
|
||||
PWelsNonZeroCountFunc pWelsSetNonZeroCountFunc;
|
||||
PWelsBlockZeroFunc pWelsBlockZero16x16Func;
|
||||
PWelsBlockZeroFunc pWelsBlockZero8x8Func;
|
||||
PWelsNonZeroCountFunc pWelsSetNonZeroCountFunc;
|
||||
PWelsBlockZeroFunc pWelsBlockZero16x16Func;
|
||||
PWelsBlockZeroFunc pWelsBlockZero8x8Func;
|
||||
} SBlockFunc;
|
||||
|
||||
typedef void (*PWelsFillNeighborMbInfoIntra4x4Func) (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount,
|
||||
@@ -207,10 +210,10 @@ typedef int32_t (*PWelsParseIntra4x4ModeFunc) (PWelsNeighAvail pNeighAvail, int8
|
||||
typedef int32_t (*PWelsParseIntra16x16ModeFunc) (PWelsNeighAvail pNeighAvail, PBitStringAux pBs, PDqLayer pCurDqLayer);
|
||||
|
||||
enum {
|
||||
OVERWRITE_NONE = 0,
|
||||
OVERWRITE_PPS = 1,
|
||||
OVERWRITE_SPS = 1 << 1,
|
||||
OVERWRITE_SUBSETSPS = 1 << 2
|
||||
OVERWRITE_NONE = 0,
|
||||
OVERWRITE_PPS = 1,
|
||||
OVERWRITE_SPS = 1 << 1,
|
||||
OVERWRITE_SUBSETSPS = 1 << 2
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -218,203 +221,228 @@ OVERWRITE_SUBSETSPS = 1 << 2
|
||||
*/
|
||||
|
||||
typedef struct TagWelsDecoderContext {
|
||||
SLogContext sLogCtx;
|
||||
SLogContext sLogCtx;
|
||||
// Input
|
||||
void* pArgDec; // structured arguments for decoder, reserved here for extension in the future
|
||||
void* pArgDec; // structured arguments for decoder, reserved here for extension in the future
|
||||
|
||||
SDataBuffer sRawData;
|
||||
SDataBuffer sSavedData; //for parse only purpose
|
||||
SDataBuffer sRawData;
|
||||
SDataBuffer sSavedData; //for parse only purpose
|
||||
|
||||
// Configuration
|
||||
SDecodingParam* pParam;
|
||||
uint32_t uiCpuFlag; // CPU compatibility detected
|
||||
SDecodingParam* pParam;
|
||||
uint32_t uiCpuFlag; // CPU compatibility detected
|
||||
|
||||
EVideoFormatType eOutputColorFormat; // color space format to be outputed
|
||||
VIDEO_BITSTREAM_TYPE eVideoType; //indicate the type of video to decide whether or not to do qp_delta error detection.
|
||||
bool bHaveGotMemory; // global memory for decoder context related ever requested?
|
||||
EVideoFormatType eOutputColorFormat; // color space format to be outputed
|
||||
VIDEO_BITSTREAM_TYPE eVideoType; //indicate the type of video to decide whether or not to do qp_delta error detection.
|
||||
bool bHaveGotMemory; // global memory for decoder context related ever requested?
|
||||
|
||||
int32_t iImgWidthInPixel; // width of image in pixel reconstruction picture to be output
|
||||
int32_t iImgHeightInPixel;// height of image in pixel reconstruction picture to be output
|
||||
int32_t iLastImgWidthInPixel; // width of image in last successful pixel reconstruction picture to be output
|
||||
int32_t iLastImgHeightInPixel;// height of image in last successful pixel reconstruction picture to be output
|
||||
bool bFreezeOutput; // indicating current frame freezing. Default: true
|
||||
int32_t iImgWidthInPixel; // width of image in pixel reconstruction picture to be output
|
||||
int32_t iImgHeightInPixel;// height of image in pixel reconstruction picture to be output
|
||||
int32_t iLastImgWidthInPixel; // width of image in last successful pixel reconstruction picture to be output
|
||||
int32_t iLastImgHeightInPixel;// height of image in last successful pixel reconstruction picture to be output
|
||||
bool bFreezeOutput; // indicating current frame freezing. Default: true
|
||||
|
||||
|
||||
// Derived common elements
|
||||
SNalUnitHeader sCurNalHead;
|
||||
EWelsSliceType eSliceType; // Slice type
|
||||
int32_t iFrameNum;
|
||||
int32_t iPrevFrameNum; // frame number of previous frame well decoded for non-truncated mode yet
|
||||
bool bLastHasMmco5; //
|
||||
int32_t iErrorCode; // error code return while decoding in case packets lost
|
||||
SFmo sFmoList[MAX_PPS_COUNT]; // list for FMO storage
|
||||
PFmo pFmo; // current fmo context after parsed slice_header
|
||||
int32_t iActiveFmoNum; // active count number of fmo context in list
|
||||
SNalUnitHeader sCurNalHead;
|
||||
EWelsSliceType eSliceType; // Slice type
|
||||
int32_t iFrameNum;
|
||||
int32_t iPrevFrameNum; // frame number of previous frame well decoded for non-truncated mode yet
|
||||
bool bLastHasMmco5; //
|
||||
int32_t iErrorCode; // error code return while decoding in case packets lost
|
||||
SFmo sFmoList[MAX_PPS_COUNT]; // list for FMO storage
|
||||
PFmo pFmo; // current fmo context after parsed slice_header
|
||||
int32_t iActiveFmoNum; // active count number of fmo context in list
|
||||
|
||||
/*needed info by decode slice level and mb level*/
|
||||
int32_t
|
||||
iDecBlockOffsetArray[24]; // address talbe for sub 4x4 block in intra4x4_mb, so no need to caculta the address every time.
|
||||
/*needed info by decode slice level and mb level*/
|
||||
int32_t
|
||||
iDecBlockOffsetArray[24]; // address talbe for sub 4x4 block in intra4x4_mb, so no need to caculta the address every time.
|
||||
|
||||
struct {
|
||||
int8_t* pMbType[LAYER_NUM_EXCHANGEABLE]; /* mb type */
|
||||
int16_t (*pMv[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM][MV_A]; //[LAYER_NUM_EXCHANGEABLE MB_BLOCK4x4_NUM*]
|
||||
int8_t (*pRefIndex[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM];
|
||||
int8_t* pLumaQp[LAYER_NUM_EXCHANGEABLE]; /*mb luma_qp*/
|
||||
int8_t* pChromaQp[LAYER_NUM_EXCHANGEABLE]; /*mb chroma_qp*/
|
||||
int16_t (*pMvd[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM][MV_A]; //[LAYER_NUM_EXCHANGEABLE MB_BLOCK4x4_NUM*]
|
||||
uint8_t *pCbfDc[LAYER_NUM_EXCHANGEABLE];
|
||||
int8_t (*pNzc[LAYER_NUM_EXCHANGEABLE])[24];
|
||||
int8_t (*pNzcRs[LAYER_NUM_EXCHANGEABLE])[24];
|
||||
int16_t (*pScaledTCoeff[LAYER_NUM_EXCHANGEABLE])[MB_COEFF_LIST_SIZE]; /*need be aligned*/
|
||||
int8_t (*pIntraPredMode[LAYER_NUM_EXCHANGEABLE])[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16
|
||||
int8_t (*pIntra4x4FinalMode[LAYER_NUM_EXCHANGEABLE])[MB_BLOCK4x4_NUM];
|
||||
int8_t* pChromaPredMode[LAYER_NUM_EXCHANGEABLE];
|
||||
int8_t* pCbp[LAYER_NUM_EXCHANGEABLE];
|
||||
uint8_t (*pMotionPredFlag[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_PARTITION_SIZE]; // 8x8
|
||||
int8_t (*pSubMbType[LAYER_NUM_EXCHANGEABLE])[MB_SUB_PARTITION_SIZE];
|
||||
int32_t* pSliceIdc[LAYER_NUM_EXCHANGEABLE]; // using int32_t for slice_idc
|
||||
int8_t* pResidualPredFlag[LAYER_NUM_EXCHANGEABLE];
|
||||
int8_t* pInterPredictionDoneFlag[LAYER_NUM_EXCHANGEABLE];
|
||||
bool* pMbCorrectlyDecodedFlag[LAYER_NUM_EXCHANGEABLE];
|
||||
bool* pMbRefConcealedFlag[LAYER_NUM_EXCHANGEABLE];
|
||||
uint32_t iMbWidth;
|
||||
uint32_t iMbHeight;
|
||||
} sMb;
|
||||
struct {
|
||||
int8_t* pMbType[LAYER_NUM_EXCHANGEABLE]; /* mb type */
|
||||
int16_t (*pMv[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM][MV_A]; //[LAYER_NUM_EXCHANGEABLE MB_BLOCK4x4_NUM*]
|
||||
int8_t (*pRefIndex[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM];
|
||||
int8_t* pLumaQp[LAYER_NUM_EXCHANGEABLE]; /*mb luma_qp*/
|
||||
int8_t (*pChromaQp[LAYER_NUM_EXCHANGEABLE])[2]; /*mb chroma_qp*/
|
||||
int16_t (*pMvd[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM][MV_A]; //[LAYER_NUM_EXCHANGEABLE MB_BLOCK4x4_NUM*]
|
||||
uint8_t* pCbfDc[LAYER_NUM_EXCHANGEABLE];
|
||||
int8_t (*pNzc[LAYER_NUM_EXCHANGEABLE])[24];
|
||||
int8_t (*pNzcRs[LAYER_NUM_EXCHANGEABLE])[24];
|
||||
int16_t (*pScaledTCoeff[LAYER_NUM_EXCHANGEABLE])[MB_COEFF_LIST_SIZE]; /*need be aligned*/
|
||||
int8_t (*pIntraPredMode[LAYER_NUM_EXCHANGEABLE])[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16
|
||||
int8_t (*pIntra4x4FinalMode[LAYER_NUM_EXCHANGEABLE])[MB_BLOCK4x4_NUM];
|
||||
int8_t* pChromaPredMode[LAYER_NUM_EXCHANGEABLE];
|
||||
int8_t* pCbp[LAYER_NUM_EXCHANGEABLE];
|
||||
uint8_t (*pMotionPredFlag[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_PARTITION_SIZE]; // 8x8
|
||||
int8_t (*pSubMbType[LAYER_NUM_EXCHANGEABLE])[MB_SUB_PARTITION_SIZE];
|
||||
int32_t* pSliceIdc[LAYER_NUM_EXCHANGEABLE]; // using int32_t for slice_idc
|
||||
int8_t* pResidualPredFlag[LAYER_NUM_EXCHANGEABLE];
|
||||
int8_t* pInterPredictionDoneFlag[LAYER_NUM_EXCHANGEABLE];
|
||||
bool* pMbCorrectlyDecodedFlag[LAYER_NUM_EXCHANGEABLE];
|
||||
bool* pMbRefConcealedFlag[LAYER_NUM_EXCHANGEABLE];
|
||||
uint32_t iMbWidth;
|
||||
uint32_t iMbHeight;
|
||||
} sMb;
|
||||
|
||||
|
||||
// reconstruction picture
|
||||
PPicture pDec; //pointer to current picture being reconstructed
|
||||
PPicture pDec; //pointer to current picture being reconstructed
|
||||
|
||||
// reference pictures
|
||||
SRefPic sRefPic;
|
||||
SRefPic sRefPic;
|
||||
|
||||
SVlcTable sVlcTable; // vlc table
|
||||
SVlcTable sVlcTable; // vlc table
|
||||
|
||||
SBitStringAux sBs;
|
||||
int32_t iMaxBsBufferSizeInByte; //actual memory size for BS buffer
|
||||
SBitStringAux sBs;
|
||||
int32_t iMaxBsBufferSizeInByte; //actual memory size for BS buffer
|
||||
|
||||
/* Global memory external */
|
||||
/* Global memory external */
|
||||
|
||||
SPosOffset sFrameCrop;
|
||||
SPosOffset sFrameCrop;
|
||||
|
||||
SSps sSpsBuffer[MAX_SPS_COUNT + 1];
|
||||
SPps sPpsBuffer[MAX_PPS_COUNT + 1];
|
||||
PSliceHeader pSliceHeader;
|
||||
SSps sSpsBuffer[MAX_SPS_COUNT + 1];
|
||||
SPps sPpsBuffer[MAX_PPS_COUNT + 1];
|
||||
PSliceHeader pSliceHeader;
|
||||
|
||||
PPicBuff pPicBuff[LIST_A]; // Initially allocated memory for pictures which are used in decoding.
|
||||
int32_t iPicQueueNumber;
|
||||
PPicBuff pPicBuff[LIST_A]; // Initially allocated memory for pictures which are used in decoding.
|
||||
int32_t iPicQueueNumber;
|
||||
|
||||
SSubsetSps sSubsetSpsBuffer[MAX_SPS_COUNT + 1];
|
||||
SNalUnit sPrefixNal;
|
||||
SSubsetSps sSubsetSpsBuffer[MAX_SPS_COUNT + 1];
|
||||
SNalUnit sPrefixNal;
|
||||
|
||||
PAccessUnit pAccessUnitList; // current access unit list to be performed
|
||||
PSps pActiveLayerSps[MAX_LAYER_NUM];
|
||||
PSps pSps; // used by current AU
|
||||
PPps pPps; // used by current AU
|
||||
PAccessUnit pAccessUnitList; // current access unit list to be performed
|
||||
PSps pActiveLayerSps[MAX_LAYER_NUM];
|
||||
PSps pSps; // used by current AU
|
||||
PPps pPps; // used by current AU
|
||||
// Memory for pAccessUnitList is dynamically held till decoder destruction.
|
||||
PDqLayer pCurDqLayer; // current DQ layer representation, also carry reference base layer if applicable
|
||||
PDqLayer pDqLayersList[LAYER_NUM_EXCHANGEABLE]; // DQ layers list with memory allocated
|
||||
PDqLayer pCurDqLayer; // current DQ layer representation, also carry reference base layer if applicable
|
||||
PDqLayer pDqLayersList[LAYER_NUM_EXCHANGEABLE]; // DQ layers list with memory allocated
|
||||
|
||||
int32_t iPicWidthReq; // picture width have requested the memory
|
||||
int32_t iPicHeightReq; // picture height have requested the memory
|
||||
int32_t iPicWidthReq; // picture width have requested the memory
|
||||
int32_t iPicHeightReq; // picture height have requested the memory
|
||||
|
||||
uint8_t uiTargetDqId; // maximal DQ ID in current access unit, meaning target layer ID
|
||||
bool bAvcBasedFlag; // For decoding bitstream:
|
||||
bool bEndOfStreamFlag; // Flag on end of stream requested by external application layer
|
||||
bool bInstantDecFlag; // Flag for no-delay decoding
|
||||
bool bInitialDqLayersMem; // dq layers related memory is available?
|
||||
uint8_t uiTargetDqId; // maximal DQ ID in current access unit, meaning target layer ID
|
||||
bool bAvcBasedFlag; // For decoding bitstream:
|
||||
bool bEndOfStreamFlag; // Flag on end of stream requested by external application layer
|
||||
bool bInstantDecFlag; // Flag for no-delay decoding
|
||||
bool bInitialDqLayersMem; // dq layers related memory is available?
|
||||
|
||||
bool bOnlyOneLayerInCurAuFlag; //only one layer in current AU: 1
|
||||
bool bOnlyOneLayerInCurAuFlag; //only one layer in current AU: 1
|
||||
|
||||
// for EC parameter sets
|
||||
bool bSpsExistAheadFlag; // whether does SPS NAL exist ahead of sequence?
|
||||
bool bSubspsExistAheadFlag;// whether does Subset SPS NAL exist ahead of sequence?
|
||||
bool bPpsExistAheadFlag; // whether does PPS NAL exist ahead of sequence?
|
||||
bool bSpsExistAheadFlag; // whether does SPS NAL exist ahead of sequence?
|
||||
bool bSubspsExistAheadFlag;// whether does Subset SPS NAL exist ahead of sequence?
|
||||
bool bPpsExistAheadFlag; // whether does PPS NAL exist ahead of sequence?
|
||||
|
||||
bool bSpsAvailFlags[MAX_SPS_COUNT];
|
||||
bool bSubspsAvailFlags[MAX_SPS_COUNT];
|
||||
bool bPpsAvailFlags[MAX_PPS_COUNT];
|
||||
bool bReferenceLostAtT0Flag;
|
||||
int32_t iTotalNumMbRec; //record current number of decoded MB
|
||||
int32_t iSpsErrorIgnored;
|
||||
int32_t iSubSpsErrorIgnored;
|
||||
int32_t iPpsErrorIgnored;
|
||||
|
||||
bool bSpsAvailFlags[MAX_SPS_COUNT];
|
||||
bool bSubspsAvailFlags[MAX_SPS_COUNT];
|
||||
bool bPpsAvailFlags[MAX_PPS_COUNT];
|
||||
int32_t iPPSLastInvalidId;
|
||||
int32_t iPPSInvalidNum;
|
||||
int32_t iSPSLastInvalidId;
|
||||
int32_t iSPSInvalidNum;
|
||||
int32_t iSubSPSLastInvalidId;
|
||||
int32_t iSubSPSInvalidNum;
|
||||
|
||||
bool bReferenceLostAtT0Flag;
|
||||
int32_t iTotalNumMbRec; //record current number of decoded MB
|
||||
#ifdef LONG_TERM_REF
|
||||
bool bParamSetsLostFlag; //sps or pps do not exist or not correct
|
||||
bool bParamSetsLostFlag; //sps or pps do not exist or not correct
|
||||
|
||||
bool
|
||||
bCurAuContainLtrMarkSeFlag; //current AU has the LTR marking syntax element, mark the previous frame or self
|
||||
int32_t iFrameNumOfAuMarkedLtr; //if bCurAuContainLtrMarkSeFlag==true, SHOULD set this variable
|
||||
bool
|
||||
bCurAuContainLtrMarkSeFlag; //current AU has the LTR marking syntax element, mark the previous frame or self
|
||||
int32_t iFrameNumOfAuMarkedLtr; //if bCurAuContainLtrMarkSeFlag==true, SHOULD set this variable
|
||||
|
||||
uint16_t uiCurIdrPicId;
|
||||
uint16_t uiCurIdrPicId;
|
||||
#endif
|
||||
bool bNewSeqBegin;
|
||||
bool bNextNewSeqBegin;
|
||||
int iOverwriteFlags;
|
||||
ERROR_CON_IDC eErrorConMethod; //
|
||||
bool bNewSeqBegin;
|
||||
bool bNextNewSeqBegin;
|
||||
int iOverwriteFlags;
|
||||
ERROR_CON_IDC eErrorConMethod; //
|
||||
|
||||
//for Parse only
|
||||
bool bParseOnly;
|
||||
SSpsBsInfo sSpsBsInfo [MAX_SPS_COUNT];
|
||||
SSpsBsInfo sSubsetSpsBsInfo [MAX_PPS_COUNT];
|
||||
SPpsBsInfo sPpsBsInfo [MAX_PPS_COUNT];
|
||||
SParserBsInfo* pParserBsInfo;
|
||||
bool bParseOnly;
|
||||
bool bFramePending;
|
||||
int32_t iNalNum;
|
||||
int32_t iNalLenInByte[MAX_NAL_UNITS_IN_LAYER];
|
||||
SSpsBsInfo sSpsBsInfo [MAX_SPS_COUNT];
|
||||
SSpsBsInfo sSubsetSpsBsInfo [MAX_PPS_COUNT];
|
||||
SPpsBsInfo sPpsBsInfo [MAX_PPS_COUNT];
|
||||
SParserBsInfo* pParserBsInfo;
|
||||
|
||||
PPicture pPreviousDecodedPictureInDpb; //pointer to previously decoded picture in DPB for error concealment
|
||||
PGetIntraPredFunc pGetI16x16LumaPredFunc[7]; //h264_predict_copy_16x16;
|
||||
PGetIntraPredFunc pGetI4x4LumaPredFunc[14]; // h264_predict_4x4_t
|
||||
PGetIntraPredFunc pGetIChromaPredFunc[7]; // h264_predict_8x8_t
|
||||
PIdctResAddPredFunc pIdctResAddPredFunc;
|
||||
SMcFunc sMcFunc;
|
||||
PPicture pPreviousDecodedPictureInDpb; //pointer to previously decoded picture in DPB for error concealment
|
||||
PGetIntraPredFunc pGetI16x16LumaPredFunc[7]; //h264_predict_copy_16x16;
|
||||
PGetIntraPredFunc pGetI4x4LumaPredFunc[14]; // h264_predict_4x4_t
|
||||
PGetIntraPredFunc pGetIChromaPredFunc[7]; // h264_predict_8x8_t
|
||||
PIdctResAddPredFunc pIdctResAddPredFunc;
|
||||
SMcFunc sMcFunc;
|
||||
|
||||
//For error concealment
|
||||
SCopyFunc sCopyFunc;
|
||||
/* For Deblocking */
|
||||
SDeblockingFunc sDeblockingFunc;
|
||||
SExpandPicFunc sExpandPicFunc;
|
||||
SCopyFunc sCopyFunc;
|
||||
/* For Deblocking */
|
||||
SDeblockingFunc sDeblockingFunc;
|
||||
SExpandPicFunc sExpandPicFunc;
|
||||
|
||||
/* For Block */
|
||||
SBlockFunc sBlockFunc;
|
||||
/* For Block */
|
||||
SBlockFunc sBlockFunc;
|
||||
|
||||
int32_t iCurSeqIntervalTargetDependId;
|
||||
int32_t iCurSeqIntervalMaxPicWidth;
|
||||
int32_t iCurSeqIntervalMaxPicHeight;
|
||||
int32_t iCurSeqIntervalTargetDependId;
|
||||
int32_t iCurSeqIntervalMaxPicWidth;
|
||||
int32_t iCurSeqIntervalMaxPicHeight;
|
||||
|
||||
PWelsFillNeighborMbInfoIntra4x4Func pFillInfoCacheIntra4x4Func;
|
||||
PWelsMapNeighToSample pMap4x4NeighToSampleFunc;
|
||||
PWelsMap16NeighToSample pMap16x16NeighToSampleFunc;
|
||||
PWelsFillNeighborMbInfoIntra4x4Func pFillInfoCacheIntra4x4Func;
|
||||
PWelsMapNeighToSample pMap4x4NeighToSampleFunc;
|
||||
PWelsMap16NeighToSample pMap16x16NeighToSampleFunc;
|
||||
|
||||
//feedback whether or not have VCL in current AU, and the temporal ID
|
||||
int32_t iFeedbackVclNalInAu;
|
||||
int32_t iFeedbackTidInAu;
|
||||
int32_t iFeedbackVclNalInAu;
|
||||
int32_t iFeedbackTidInAu;
|
||||
|
||||
bool bAuReadyFlag; // true: one au is ready for decoding; false: default value
|
||||
bool bAuReadyFlag; // true: one au is ready for decoding; false: default value
|
||||
|
||||
bool bPrintFrameErrorTraceFlag; //true: can print info for upper layer
|
||||
int32_t iIgnoredErrorInfoPacketCount; //store the packet number with error decoding info
|
||||
bool bPrintFrameErrorTraceFlag; //true: can print info for upper layer
|
||||
int32_t iIgnoredErrorInfoPacketCount; //store the packet number with error decoding info
|
||||
//trace handle
|
||||
void* pTraceHandle;
|
||||
void* pTraceHandle;
|
||||
|
||||
//Save the last nal header info
|
||||
SNalUnitHeaderExt sLastNalHdrExt;
|
||||
SSliceHeader sLastSliceHeader;
|
||||
SWelsCabacCtx sWelsCabacContexts[4][WELS_QP_MAX + 1][WELS_CONTEXT_COUNT];
|
||||
bool bCabacInited;
|
||||
SWelsCabacCtx pCabacCtx[WELS_CONTEXT_COUNT];
|
||||
PWelsCabacDecEngine pCabacDecEngine;
|
||||
double dDecTime;
|
||||
SDecoderStatistics sDecoderStatistics;// For real time debugging
|
||||
int32_t iMbEcedNum;
|
||||
int32_t iMbEcedPropNum;
|
||||
int32_t iMbNum;
|
||||
bool bMbRefConcealed;
|
||||
bool bRPLRError;
|
||||
int32_t iECMVs[16][2];
|
||||
PPicture pECRefPic[16];
|
||||
unsigned long long uiTimeStamp;
|
||||
SNalUnitHeaderExt sLastNalHdrExt;
|
||||
SSliceHeader sLastSliceHeader;
|
||||
SWelsCabacCtx sWelsCabacContexts[4][WELS_QP_MAX + 1][WELS_CONTEXT_COUNT];
|
||||
bool bCabacInited;
|
||||
SWelsCabacCtx pCabacCtx[WELS_CONTEXT_COUNT];
|
||||
PWelsCabacDecEngine pCabacDecEngine;
|
||||
double dDecTime;
|
||||
SDecoderStatistics sDecoderStatistics;// For real time debugging
|
||||
int32_t iMbEcedNum;
|
||||
int32_t iMbEcedPropNum;
|
||||
int32_t iMbNum;
|
||||
bool bMbRefConcealed;
|
||||
bool bRPLRError;
|
||||
int32_t iECMVs[16][2];
|
||||
PPicture pECRefPic[16];
|
||||
unsigned long long uiTimeStamp;
|
||||
// To support scaling list HP
|
||||
uint16_t pDequant_coeff_buffer4x4[6][52][16];
|
||||
uint16_t pDequant_coeff_buffer8x8[6][52][64];
|
||||
uint16_t (*pDequant_coeff4x4[6])[16];// 4x4 sclaing list value pointer
|
||||
uint16_t (*pDequant_coeff8x8[6])[64];//64 residual coeff ,with 6 kinds of residual type, 52 qp level
|
||||
int iDequantCoeffPpsid;//When a new pps actived, reinitialised the scaling list value
|
||||
bool bDequantCoeff4x4Init;
|
||||
bool bSpsLatePps;
|
||||
bool bUseScalingList;
|
||||
} SWelsDecoderContext, *PWelsDecoderContext;
|
||||
|
||||
static inline void ResetActiveSPSForEachLayer (PWelsDecoderContext pCtx) {
|
||||
for (int i = 0; i < MAX_LAYER_NUM; i++) {
|
||||
pCtx->pActiveLayerSps[i] = NULL;
|
||||
}
|
||||
if (pCtx->iTotalNumMbRec == 0) {
|
||||
for (int i = 0; i < MAX_LAYER_NUM; i++) {
|
||||
pCtx->pActiveLayerSps[i] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
//#ifdef __cplusplus
|
||||
//}
|
||||
|
||||
@@ -153,6 +153,7 @@ void WelsDqLayerDecodeStart (PWelsDecoderContext pCtx, PNalUnit pCurNal, PSps pS
|
||||
|
||||
int32_t WelsDecodeAccessUnitStart (PWelsDecoderContext pCtx);
|
||||
void WelsDecodeAccessUnitEnd (PWelsDecoderContext pCtx);
|
||||
void DecodeFinishUpdate (PWelsDecoderContext pCtx);
|
||||
|
||||
void ForceResetCurrentAccessUnit (PAccessUnit pAu);
|
||||
void ForceClearCurrentNal (PAccessUnit pAu);
|
||||
|
||||
@@ -104,6 +104,7 @@ ERR_INFO_INVALID_POC_TYPE,
|
||||
ERR_INFO_INVALID_MB_SIZE_INFO,
|
||||
ERR_INFO_REF_COUNT_OVERFLOW,
|
||||
ERR_INFO_CROPPING_NO_SUPPORTED,
|
||||
ERR_INFO_INVALID_CROPPING_DATA,
|
||||
ERR_INFO_INVALID_SLICEGROUP,
|
||||
ERR_INFO_INVALID_SLICEGROUP_MAP_TYPE,
|
||||
ERR_INFO_INVALID_FRAME_NUM,
|
||||
@@ -146,6 +147,13 @@ ERR_INFO_INVALID_I4x4_PRED_MODE,
|
||||
ERR_INFO_INVALID_I16x16_PRED_MODE,
|
||||
ERR_INFO_INVALID_I_CHROMA_PRED_MODE,
|
||||
|
||||
ERR_INFO_INVALID_LUMA_LOG2_WEIGHT_DENOM,
|
||||
ERR_INFO_INVALID_CHROMA_LOG2_WEIGHT_DENOM,
|
||||
ERR_INFO_INVALID_LUMA_WEIGHT,
|
||||
ERR_INFO_INVALID_CHROMA_WEIGHT,
|
||||
ERR_INFO_INVALID_LUMA_OFFSET,
|
||||
ERR_INFO_INVALID_CHROMA_OFFSET,
|
||||
|
||||
ERR_INFO_UNSUPPORTED_NON_BASELINE,
|
||||
ERR_INFO_UNSUPPORTED_FMOTYPE,
|
||||
ERR_INFO_UNSUPPORTED_MBAFF,
|
||||
@@ -185,6 +193,8 @@ ERR_INFO_INVALID_MMCO_REF_NUM_NOT_ENOUGH,
|
||||
ERR_INFO_INVALID_MMCO_LONG_TERM_IDX_EXCEED_MAX,
|
||||
//for CABAC
|
||||
ERR_CABAC_NO_BS_TO_READ,
|
||||
//for scaling list
|
||||
ERR_SCALING_LIST_DELTA_SCALE,
|
||||
};
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
/*!
|
||||
* \copy
|
||||
* Copyright (c) 2013, Cisco Systems
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* memory alignment utilization
|
||||
*/
|
||||
|
||||
#ifndef WELS_MEM_ALIGN_H__
|
||||
#define WELS_MEM_ALIGN_H__
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "utils.h"
|
||||
|
||||
namespace WelsDec {
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif//__cplusplus
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
*************************************************************************************
|
||||
* \brief malloc with zero filled utilization in Wels
|
||||
*
|
||||
* \param kuiSize size of memory block required
|
||||
*
|
||||
* \return allocated memory pointer exactly, failed in case of NULL return
|
||||
*
|
||||
* \note N/A
|
||||
*************************************************************************************
|
||||
*/
|
||||
void* WelsMalloc (const uint32_t kuiSize, const char* kpTag);
|
||||
|
||||
/*!
|
||||
*************************************************************************************
|
||||
* \brief free utilization in Wels
|
||||
*
|
||||
* \param pPtr data pointer to be free.
|
||||
* i.e, uint8_t *pPtr = actual data to be free, argv = &pPtr.
|
||||
*
|
||||
* \return NONE
|
||||
*
|
||||
* \note N/A
|
||||
*************************************************************************************
|
||||
*/
|
||||
void WelsFree (void* pPtr, const char* kpTag);
|
||||
|
||||
#define WELS_SAFE_FREE(pPtr, pTag) if (pPtr) { WelsFree(pPtr, pTag); pPtr = NULL; }
|
||||
|
||||
/*
|
||||
* memory operation routines
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif//__cplusplus
|
||||
|
||||
} // namespace WelsDec
|
||||
|
||||
#endif //WELS_MEM_ALIGN_H__
|
||||
@@ -88,7 +88,11 @@ typedef struct TagSps {
|
||||
bool bQpPrimeYZeroTransfBypassFlag;
|
||||
bool bSeqScalingMatrixPresentFlag;
|
||||
bool bSeqScalingListPresentFlag[12];
|
||||
const SLevelLimits* pSLevelLimits;
|
||||
//Add scaling list supporting
|
||||
uint8_t iScalingList4x4[6][16];
|
||||
uint8_t iScalingList8x8[6][64];
|
||||
|
||||
const SLevelLimits* pSLevelLimits;
|
||||
} SSps, *PSps;
|
||||
|
||||
|
||||
@@ -151,7 +155,7 @@ typedef struct TagPps {
|
||||
|
||||
int32_t iPicInitQp;
|
||||
int32_t iPicInitQs;
|
||||
int32_t iChromaQpIndexOffset;
|
||||
int32_t iChromaQpIndexOffset[2];//cb,cr
|
||||
|
||||
bool bEntropyCodingModeFlag;
|
||||
bool bPicOrderPresentFlag;
|
||||
@@ -163,7 +167,12 @@ typedef struct TagPps {
|
||||
bool bRedundantPicCntPresentFlag;
|
||||
bool bWeightedPredFlag;
|
||||
uint8_t uiWeightedBipredIdc;
|
||||
|
||||
bool bTransform_8x8_mode_flag;
|
||||
//Add for scalinglist support
|
||||
bool bPicScalingMatrixPresentFlag;
|
||||
bool bPicScalingListPresentFlag[12];
|
||||
uint8_t iScalingList4x4[6][16];
|
||||
uint8_t iScalingList8x8[6][64];
|
||||
} SPps, *PPps;
|
||||
|
||||
} // namespace WelsDec
|
||||
|
||||
@@ -68,7 +68,7 @@ struct {
|
||||
bool bLumaWeightFlag;
|
||||
bool bChromaWeightFlag;
|
||||
} sPredList[LIST_A];
|
||||
} SPredWeightTabSyn;
|
||||
} SPredWeightTabSyn,*PPredWeightTabSyn;
|
||||
|
||||
/* Decoded reference picture marking syntax, refer to Page 66 in JVT X201wcm */
|
||||
typedef struct TagRefPicMarking {
|
||||
|
||||
@@ -132,6 +132,12 @@ typedef int32_t SubMbType;
|
||||
#define CHROMA_DC_V 7
|
||||
#define CHROMA_AC_U 8
|
||||
#define CHROMA_AC_V 9
|
||||
#define LUMA_DC_AC_INTRA 10
|
||||
#define LUMA_DC_AC_INTER 11
|
||||
#define CHROMA_DC_U_INTER 12
|
||||
#define CHROMA_DC_V_INTER 13
|
||||
#define CHROMA_AC_U_INTER 14
|
||||
#define CHROMA_AC_V_INTER 15
|
||||
|
||||
typedef struct TagReadBitsCache {
|
||||
uint32_t uiCache32Bit;
|
||||
@@ -150,6 +156,59 @@ static const uint8_t g_kuiZigzagScan[16] = { //4*4block residual zig-zag scan or
|
||||
};
|
||||
|
||||
|
||||
static inline void GetMbResProperty(int32_t * pMBproperty,int32_t* pResidualProperty,bool bCavlc)
|
||||
{
|
||||
switch(*pResidualProperty)
|
||||
{
|
||||
case CHROMA_AC_U:
|
||||
*pMBproperty = 1;
|
||||
*pResidualProperty = bCavlc ? CHROMA_AC : CHROMA_AC_U;
|
||||
break;
|
||||
case CHROMA_AC_V:
|
||||
*pMBproperty = 2;
|
||||
*pResidualProperty = bCavlc ? CHROMA_AC : CHROMA_AC_V;
|
||||
break;
|
||||
case LUMA_DC_AC_INTRA:
|
||||
*pMBproperty = 0;
|
||||
*pResidualProperty = LUMA_DC_AC;
|
||||
break;
|
||||
case CHROMA_DC_U:
|
||||
*pMBproperty = 1;
|
||||
*pResidualProperty = bCavlc ? CHROMA_DC : CHROMA_DC_U;
|
||||
break;
|
||||
case CHROMA_DC_V:
|
||||
*pMBproperty = 2;
|
||||
*pResidualProperty = bCavlc ? CHROMA_DC : CHROMA_DC_V;
|
||||
break;
|
||||
case I16_LUMA_AC:
|
||||
*pMBproperty = 0;
|
||||
break;
|
||||
case I16_LUMA_DC:
|
||||
*pMBproperty = 0;
|
||||
break;
|
||||
case LUMA_DC_AC_INTER:
|
||||
*pMBproperty = 3;
|
||||
*pResidualProperty = LUMA_DC_AC;
|
||||
break;
|
||||
case CHROMA_DC_U_INTER:
|
||||
*pMBproperty = 4;
|
||||
*pResidualProperty = bCavlc ? CHROMA_DC : CHROMA_DC_U;
|
||||
break;
|
||||
case CHROMA_DC_V_INTER:
|
||||
*pMBproperty = 5;
|
||||
*pResidualProperty = bCavlc ? CHROMA_DC : CHROMA_DC_V;
|
||||
break;
|
||||
case CHROMA_AC_U_INTER:
|
||||
*pMBproperty = 4;
|
||||
*pResidualProperty = bCavlc ? CHROMA_AC : CHROMA_AC_U;
|
||||
break;
|
||||
case CHROMA_AC_V_INTER:
|
||||
*pMBproperty = 5;
|
||||
*pResidualProperty = bCavlc ?CHROMA_AC:CHROMA_AC_V;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct TagI16PredInfo {
|
||||
int8_t iPredMode;
|
||||
int8_t iLeftAvail;
|
||||
|
||||
@@ -31,28 +31,10 @@
|
||||
*/
|
||||
|
||||
//wels_const.h
|
||||
#ifndef WELS_CONSTANCE_H__
|
||||
#define WELS_CONSTANCE_H__
|
||||
#ifndef WELS_CONST_H__
|
||||
#define WELS_CONST_H__
|
||||
|
||||
// Miscellaneous sizing infos
|
||||
#ifndef MAX_FNAME_LEN
|
||||
#define MAX_FNAME_LEN 256 // maximal length of file name in char size
|
||||
#endif//MAX_FNAME_LEN
|
||||
|
||||
#ifndef WELS_LOG_BUF_SIZE
|
||||
#define WELS_LOG_BUF_SIZE 4096
|
||||
#endif//WELS_LOG_BUF_SIZE
|
||||
|
||||
#ifndef MAX_TRACE_LOG_SIZE
|
||||
#define MAX_TRACE_LOG_SIZE (50 * (1<<20)) // max trace log size: 50 MB, overwrite occur if log file size exceeds this size
|
||||
#endif//MAX_TRACE_LOG_SIZE
|
||||
|
||||
/* MB width in pixels for specified colorspace I420 usually used in codec */
|
||||
#define MB_WIDTH_LUMA 16
|
||||
#define MB_WIDTH_CHROMA (MB_WIDTH_LUMA>>1)
|
||||
/* MB height in pixels for specified colorspace I420 usually used in codec */
|
||||
#define MB_HEIGHT_LUMA 16
|
||||
#define MB_HEIGHT_CHROMA (MB_HEIGHT_LUMA>>1)
|
||||
#include "wels_const_common.h"
|
||||
|
||||
/* Some list size */
|
||||
#define MB_COEFF_LIST_SIZE (256+((MB_WIDTH_CHROMA*MB_HEIGHT_CHROMA)<<1))
|
||||
@@ -95,11 +77,10 @@
|
||||
#define MAX_BUFFERED_NUM 3 //mamixum stored number of AU|packet to prevent overwrite
|
||||
#define MAX_ACCESS_UNIT_CAPACITY 7077888 //Maximum AU size in bytes for level 5.2 for single frame
|
||||
#define MAX_MACROBLOCK_CAPACITY 5000 //Maximal legal MB capacity, 15000 bits is enough
|
||||
|
||||
enum {
|
||||
BASE_MB = 0,
|
||||
NON_AVC_REWRITE_ENHANCE_MB =1,
|
||||
AVC_REWRITE_ENHANCE_MB = 2
|
||||
BASE_MB = 0,
|
||||
NON_AVC_REWRITE_ENHANCE_MB = 1,
|
||||
AVC_REWRITE_ENHANCE_MB = 2
|
||||
};
|
||||
|
||||
#endif//WELS_CONSTANCE_H__
|
||||
#endif//WELS_CONST_H__
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include "memmgr_nal_unit.h"
|
||||
#include "decoder_core.h"
|
||||
#include "bit_stream.h"
|
||||
#include "mem_align.h"
|
||||
#include "memory_align.h"
|
||||
|
||||
namespace WelsDec {
|
||||
/*!
|
||||
@@ -146,38 +146,50 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade
|
||||
|
||||
if (! (IS_SEI_NAL (pNalUnitHeader->eNalUnitType) || IS_SPS_NAL (pNalUnitHeader->eNalUnitType)
|
||||
|| pCtx->bSpsExistAheadFlag)) {
|
||||
if (pCtx->bPrintFrameErrorTraceFlag) {
|
||||
if (pCtx->bPrintFrameErrorTraceFlag && pCtx->iSpsErrorIgnored == 0) {
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING,
|
||||
"parse_nal(), no exist Sequence Parameter Sets ahead of sequence when try to decode NAL(type:%d).",
|
||||
pNalUnitHeader->eNalUnitType);
|
||||
} else {
|
||||
pCtx->iSpsErrorIgnored++;
|
||||
}
|
||||
pCtx->sDecoderStatistics.iSpsNoExistNalNum++;
|
||||
pCtx->iErrorCode = dsNoParamSets;
|
||||
return NULL;
|
||||
}
|
||||
pCtx->iSpsErrorIgnored = 0;
|
||||
if (! (IS_SEI_NAL (pNalUnitHeader->eNalUnitType) || IS_PARAM_SETS_NALS (pNalUnitHeader->eNalUnitType)
|
||||
|| pCtx->bPpsExistAheadFlag)) {
|
||||
if (pCtx->bPrintFrameErrorTraceFlag) {
|
||||
if (pCtx->bPrintFrameErrorTraceFlag && pCtx->iPpsErrorIgnored == 0) {
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING,
|
||||
"parse_nal(), no exist Picture Parameter Sets ahead of sequence when try to decode NAL(type:%d).",
|
||||
pNalUnitHeader->eNalUnitType);
|
||||
} else {
|
||||
pCtx->iPpsErrorIgnored++;
|
||||
}
|
||||
pCtx->sDecoderStatistics.iPpsNoExistNalNum++;
|
||||
pCtx->iErrorCode = dsNoParamSets;
|
||||
return NULL;
|
||||
}
|
||||
pCtx->iPpsErrorIgnored = 0;
|
||||
if ((IS_VCL_NAL_AVC_BASE (pNalUnitHeader->eNalUnitType) && ! (pCtx->bSpsExistAheadFlag || pCtx->bPpsExistAheadFlag)) ||
|
||||
(IS_NEW_INTRODUCED_SVC_NAL (pNalUnitHeader->eNalUnitType) && ! (pCtx->bSpsExistAheadFlag || pCtx->bSubspsExistAheadFlag
|
||||
|| pCtx->bPpsExistAheadFlag))) {
|
||||
if (pCtx->bPrintFrameErrorTraceFlag) {
|
||||
if (pCtx->bPrintFrameErrorTraceFlag && pCtx->iSubSpsErrorIgnored == 0) {
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING,
|
||||
"ParseNalHeader(), no exist Parameter Sets ahead of sequence when try to decode slice(type:%d).",
|
||||
pNalUnitHeader->eNalUnitType);
|
||||
} else {
|
||||
pCtx->iSubSpsErrorIgnored++;
|
||||
}
|
||||
pCtx->sDecoderStatistics.iSubSpsNoExistNalNum++;
|
||||
pCtx->iErrorCode |= dsNoParamSets;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pCtx->iSubSpsErrorIgnored = 0;
|
||||
|
||||
switch (pNalUnitHeader->eNalUnitType) {
|
||||
case NAL_UNIT_AU_DELIMITER:
|
||||
case NAL_UNIT_SEI:
|
||||
if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {
|
||||
pCtx->pAccessUnitList->uiEndPos = pCtx->pAccessUnitList->uiAvailUnitsNum - 1;
|
||||
@@ -306,25 +318,49 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade
|
||||
|
||||
if (pCtx->bParseOnly) {
|
||||
pCurNal->sNalData.sVclNal.pNalPos = pSavedData->pCurPos;
|
||||
pCurNal->sNalData.sVclNal.iNalLength = iSrcNalLen - NAL_UNIT_HEADER_EXT_SIZE;
|
||||
if (pCurNal->sNalHeaderExt.bIdrFlag) {
|
||||
* (pSrcNal + 3) &= 0xE0;
|
||||
* (pSrcNal + 3) |= 0x05;
|
||||
} else {
|
||||
* (pSrcNal + 3) &= 0xE0;
|
||||
* (pSrcNal + 3) |= 0x01;
|
||||
int32_t iTrailingZeroByte = 0;
|
||||
while (pSrcNal[iSrcNalLen - iTrailingZeroByte - 1] == 0x0) //remove final trailing 0 bytes
|
||||
iTrailingZeroByte++;
|
||||
int32_t iActualLen = iSrcNalLen - iTrailingZeroByte;
|
||||
pCurNal->sNalData.sVclNal.iNalLength = iActualLen - NAL_UNIT_HEADER_EXT_SIZE;
|
||||
//unify start code as 0x0001
|
||||
int32_t iCurrStartByte = 4; //4 for 0x0001, 3 for 0x001
|
||||
if (pSrcNal[0] == 0x0 && pSrcNal[1] == 0x0 && pSrcNal[2] == 0x1) { //if 0x001
|
||||
iCurrStartByte = 3;
|
||||
pCurNal->sNalData.sVclNal.iNalLength++;
|
||||
}
|
||||
memcpy (pSavedData->pCurPos, pSrcNal, 4);
|
||||
pSavedData->pCurPos += 4;
|
||||
memcpy (pSavedData->pCurPos, pSrcNal + 7, iSrcNalLen - 7);
|
||||
pSavedData->pCurPos += iSrcNalLen - 7;
|
||||
if (pCurNal->sNalHeaderExt.bIdrFlag) {
|
||||
* (pSrcNal + iCurrStartByte) &= 0xE0;
|
||||
* (pSrcNal + iCurrStartByte) |= 0x05;
|
||||
} else {
|
||||
* (pSrcNal + iCurrStartByte) &= 0xE0;
|
||||
* (pSrcNal + iCurrStartByte) |= 0x01;
|
||||
}
|
||||
pSavedData->pCurPos[0] = pSavedData->pCurPos[1] = pSavedData->pCurPos[2] = 0x0;
|
||||
pSavedData->pCurPos[3] = 0x1;
|
||||
pSavedData->pCurPos[4] = * (pSrcNal + iCurrStartByte);
|
||||
pSavedData->pCurPos += 5;
|
||||
int32_t iOffset = iCurrStartByte + 1 + NAL_UNIT_HEADER_EXT_SIZE;
|
||||
memcpy (pSavedData->pCurPos, pSrcNal + iOffset, iActualLen - iOffset);
|
||||
pSavedData->pCurPos += iActualLen - iOffset;
|
||||
}
|
||||
} else {
|
||||
if (pCtx->bParseOnly) {
|
||||
pCurNal->sNalData.sVclNal.pNalPos = pSavedData->pCurPos;
|
||||
pCurNal->sNalData.sVclNal.iNalLength = iSrcNalLen;
|
||||
memcpy (pSavedData->pCurPos, pSrcNal, iSrcNalLen);
|
||||
pSavedData->pCurPos += iSrcNalLen;
|
||||
int32_t iTrailingZeroByte = 0;
|
||||
while (pSrcNal[iSrcNalLen - iTrailingZeroByte - 1] == 0x0) //remove final trailing 0 bytes
|
||||
iTrailingZeroByte++;
|
||||
int32_t iActualLen = iSrcNalLen - iTrailingZeroByte;
|
||||
pCurNal->sNalData.sVclNal.iNalLength = iActualLen;
|
||||
//unify start code as 0x0001
|
||||
int32_t iStartDeltaByte = 0; //0 for 0x0001, 1 for 0x001
|
||||
if (pSrcNal[0] == 0x0 && pSrcNal[1] == 0x0 && pSrcNal[2] == 0x1) { //if 0x001
|
||||
pSavedData->pCurPos[0] = 0x0;
|
||||
iStartDeltaByte = 1;
|
||||
pCurNal->sNalData.sVclNal.iNalLength++;
|
||||
}
|
||||
memcpy (pSavedData->pCurPos + iStartDeltaByte, pSrcNal, iActualLen);
|
||||
pSavedData->pCurPos += iStartDeltaByte + iActualLen;
|
||||
}
|
||||
if (NAL_UNIT_PREFIX == pCtx->sPrefixNal.sNalHeaderExt.sNalUnitHeader.eNalUnitType) {
|
||||
if (pCtx->sPrefixNal.sNalData.sPrefixNal.bPrefixNalCorrectFlag) {
|
||||
@@ -449,9 +485,9 @@ bool CheckAccessUnitBoundaryExt (PNalUnitHeaderExt pLastNalHdrExt, PNalUnitHeade
|
||||
if (pLastSliceHeader->iDeltaPicOrderCnt[1] != pCurSliceHeader->iDeltaPicOrderCnt[1])
|
||||
return true;
|
||||
}
|
||||
if(memcmp(pLastSliceHeader->pPps, pCurSliceHeader->pPps, sizeof(SPps)) != 0
|
||||
|| memcmp(pLastSliceHeader->pSps, pCurSliceHeader->pSps, sizeof(SSps)) != 0) {
|
||||
return true;
|
||||
if (memcmp (pLastSliceHeader->pPps, pCurSliceHeader->pPps, sizeof (SPps)) != 0
|
||||
|| memcmp (pLastSliceHeader->pSps, pCurSliceHeader->pSps, sizeof (SSps)) != 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -808,18 +844,30 @@ bool CheckSpsActive (PWelsDecoderContext pCtx, PSps pSps, bool bUseSubsetFlag) {
|
||||
if (bUseSubsetFlag) {
|
||||
if (pSps->iMbWidth > 0 && pSps->iMbHeight > 0 && pCtx->bSubspsAvailFlags[pSps->iSpsId]
|
||||
&& pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {
|
||||
PSps pNextUsedSps =
|
||||
pCtx->pAccessUnitList->pNalUnitsList[pCtx->pAccessUnitList->uiStartPos]->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pSps;
|
||||
if (pNextUsedSps->iSpsId == pSps->iSpsId)
|
||||
return true;
|
||||
int i = 0, iNum = (int32_t) pCtx->pAccessUnitList->uiAvailUnitsNum;
|
||||
while (i < iNum) {
|
||||
PNalUnit pNalUnit = pCtx->pAccessUnitList->pNalUnitsList[i];
|
||||
if (pNalUnit->sNalData.sVclNal.bSliceHeaderExtFlag) { //ext data
|
||||
PSps pNextUsedSps = pNalUnit->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pSps;
|
||||
if (pNextUsedSps->iSpsId == pSps->iSpsId)
|
||||
return true;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (pSps->iMbWidth > 0 && pSps->iMbHeight > 0 && pCtx->bSpsAvailFlags[pSps->iSpsId]
|
||||
&& pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {
|
||||
PSps pNextUsedSps =
|
||||
pCtx->pAccessUnitList->pNalUnitsList[pCtx->pAccessUnitList->uiStartPos]->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pSps;
|
||||
if (pNextUsedSps->iSpsId == pSps->iSpsId)
|
||||
return true;
|
||||
int i = 0, iNum = (int32_t) pCtx->pAccessUnitList->uiAvailUnitsNum;
|
||||
while (i < iNum) {
|
||||
PNalUnit pNalUnit = pCtx->pAccessUnitList->pNalUnitsList[i];
|
||||
if (!pNalUnit->sNalData.sVclNal.bSliceHeaderExtFlag) { //non-ext data
|
||||
PSps pNextUsedSps = pNalUnit->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pSps;
|
||||
if (pNextUsedSps->iSpsId == pSps->iSpsId)
|
||||
return true;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -833,6 +881,8 @@ bool CheckSpsActive (PWelsDecoderContext pCtx, PSps pSps, bool bUseSubsetFlag) {
|
||||
#define PPS_PIC_INIT_QP_QS_MAX 51
|
||||
#define PPS_CHROMA_QP_INDEX_OFFSET_MIN -12
|
||||
#define PPS_CHROMA_QP_INDEX_OFFSET_MAX 12
|
||||
#define SCALING_LIST_DELTA_SCALE_MAX 127
|
||||
#define SCALING_LIST_DELTA_SCALE_MIN -128
|
||||
|
||||
/*!
|
||||
*************************************************************************************
|
||||
@@ -910,11 +960,19 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
|
||||
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //chroma_format_idc
|
||||
pSps->uiChromaFormatIdc = uiCode;
|
||||
#ifdef DISABLE_HP_BRANCH_1_4
|
||||
if (pSps->uiChromaFormatIdc != 1) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "ParseSps(): chroma_format_idc (%d) = 1 supported.",
|
||||
pSps->uiChromaFormatIdc);
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);
|
||||
}
|
||||
#endif
|
||||
if (pSps->uiChromaFormatIdc > 1) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "ParseSps(): chroma_format_idc (%d) <=1 supported.",
|
||||
pSps->uiChromaFormatIdc);
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);
|
||||
|
||||
}// To support 4:0:0; 4:2:0
|
||||
pSps->uiChromaArrayType = pSps->uiChromaFormatIdc;
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //bit_depth_luma_minus8
|
||||
if (uiCode != 0) {
|
||||
@@ -935,11 +993,17 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //seq_scaling_matrix_present_flag
|
||||
pSps->bSeqScalingMatrixPresentFlag = !!uiCode;
|
||||
|
||||
if (pSps->bSeqScalingMatrixPresentFlag) { // For high profile, it is not used in current application. FIXME
|
||||
if (pSps->bSeqScalingMatrixPresentFlag) {// For high profile, it is not used in current application. FIXME
|
||||
#ifndef DISABLE_HP_BRANCH_1_4
|
||||
WELS_READ_VERIFY (ParseScalingList (pSps, pBs, 0, pSps->bSeqScalingListPresentFlag, pSps->iScalingList4x4,
|
||||
pSps->iScalingList8x8));
|
||||
//if exist, to parse scalinglist matrix value
|
||||
#else
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
|
||||
"ParseSps(): seq_scaling_matrix_present_flag (%d). Feature not supported.",
|
||||
pSps->bSeqScalingMatrixPresentFlag);
|
||||
"ParseSps(): seq_scaling_matrix_present_flag (%d). Feature not supported.",
|
||||
pSps->bSeqScalingMatrixPresentFlag);
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //log2_max_frame_num_minus4
|
||||
@@ -1033,14 +1097,16 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //frame_crop_right_offset
|
||||
pSps->sFrameCrop.iRightOffset = uiCode;
|
||||
if ((pSps->sFrameCrop.iLeftOffset + pSps->sFrameCrop.iRightOffset) > ((int32_t)pSps->iMbWidth * 16 / 2)) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "frame_crop_left_offset + frame_crop_right_offset exceeds limits!");
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "frame_crop_left_offset + frame_crop_right_offset exceeds limits!");
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_CROPPING_DATA);
|
||||
}
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //frame_crop_top_offset
|
||||
pSps->sFrameCrop.iTopOffset = uiCode;
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //frame_crop_bottom_offset
|
||||
pSps->sFrameCrop.iBottomOffset = uiCode;
|
||||
if ((pSps->sFrameCrop.iTopOffset + pSps->sFrameCrop.iBottomOffset) > ((int32_t)pSps->iMbHeight * 16 / 2)) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "frame_crop_top_offset + frame_crop_right_offset exceeds limits!");
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "frame_crop_top_offset + frame_crop_right_offset exceeds limits!");
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_CROPPING_DATA);
|
||||
}
|
||||
} else {
|
||||
pSps->sFrameCrop.iLeftOffset = 0; // frame_crop_left_offset
|
||||
@@ -1059,8 +1125,19 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
|
||||
if (!kbUseSubsetFlag) { //SPS
|
||||
SSpsBsInfo* pSpsBs = &pCtx->sSpsBsInfo [iSpsId];
|
||||
pSpsBs->iSpsId = iSpsId;
|
||||
memcpy (pSpsBs->pSpsBsBuf, pSrcNal, kSrcNalLen);
|
||||
pSpsBs->uiSpsBsLen = (uint32_t) kSrcNalLen;
|
||||
int32_t iTrailingZeroByte = 0;
|
||||
while (pSrcNal[kSrcNalLen - iTrailingZeroByte - 1] == 0x0) //remove final trailing 0 bytes
|
||||
iTrailingZeroByte++;
|
||||
int32_t iActualLen = kSrcNalLen - iTrailingZeroByte;
|
||||
pSpsBs->uiSpsBsLen = (uint16_t) iActualLen;
|
||||
//unify start code as 0x0001
|
||||
int32_t iStartDeltaByte = 0; //0 for 0x0001, 1 for 0x001
|
||||
if (pSrcNal[0] == 0x0 && pSrcNal[1] == 0x0 && pSrcNal[2] == 0x1) { //if 0x001
|
||||
pSpsBs->pSpsBsBuf[0] = 0x0; //add 0 to form 0x0001
|
||||
iStartDeltaByte++;
|
||||
pSpsBs->uiSpsBsLen++;
|
||||
}
|
||||
memcpy (pSpsBs->pSpsBsBuf + iStartDeltaByte, pSrcNal, iActualLen);
|
||||
} else { //subset SPS
|
||||
SSpsBsInfo* pSpsBs = &pCtx->sSubsetSpsBsInfo [iSpsId];
|
||||
pSpsBs->iSpsId = iSpsId;
|
||||
@@ -1070,7 +1147,7 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
|
||||
|
||||
//re-write subset SPS to SPS
|
||||
SBitStringAux sSubsetSpsBs;
|
||||
uint8_t* pBsBuf = static_cast<uint8_t*> (WelsMalloc (SPS_PPS_BS_SIZE + 4,
|
||||
uint8_t* pBsBuf = static_cast<uint8_t*> (WelsMallocz (SPS_PPS_BS_SIZE + 4,
|
||||
"Temp buffer for parse only usage.")); //to reserve 4 bytes for UVLC writing buffer
|
||||
if (NULL == pBsBuf) {
|
||||
pCtx->iErrorCode |= dsOutOfMemory;
|
||||
@@ -1139,8 +1216,6 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
|
||||
|
||||
if (PRO_SCALABLE_BASELINE == uiProfileIdc || PRO_SCALABLE_HIGH == uiProfileIdc)
|
||||
pCtx->bAvcBasedFlag = false;
|
||||
else
|
||||
pCtx->bAvcBasedFlag = true; // added for avc base pBs
|
||||
|
||||
*pPicWidth = pSps->iMbWidth << 4;
|
||||
*pPicHeight = pSps->iMbHeight << 4;
|
||||
@@ -1282,13 +1357,21 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux,
|
||||
pPps->bWeightedPredFlag = !!uiCode;
|
||||
WELS_READ_VERIFY (BsGetBits (pBsAux, 2, &uiCode)); //weighted_bipred_idc
|
||||
pPps->uiWeightedBipredIdc = uiCode;
|
||||
#ifdef DISABLE_HP_BRANCH_1_4
|
||||
if (pPps->bWeightedPredFlag || pPps->uiWeightedBipredIdc != 0) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
|
||||
"ParsePps(): weighted_pred_flag (%d) weighted_bipred_idc (%d) neither supported.\n",
|
||||
pPps->bWeightedPredFlag, pPps->uiWeightedBipredIdc);
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_WP);
|
||||
}
|
||||
|
||||
#else
|
||||
if (pPps->uiWeightedBipredIdc != 0) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
|
||||
"ParsePps(): weighted_bipred_idc (%d) not supported.\n",
|
||||
pPps->uiWeightedBipredIdc);
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_WP);
|
||||
}
|
||||
#endif
|
||||
WELS_READ_VERIFY (BsGetSe (pBsAux, &iCode)); //pic_init_qp_minus26
|
||||
pPps->iPicInitQp = PIC_INIT_QP_OFFSET + iCode;
|
||||
WELS_CHECK_SE_BOTH_ERROR (pPps->iPicInitQp, PPS_PIC_INIT_QP_QS_MIN, PPS_PIC_INIT_QP_QS_MAX, "pic_init_qp_minus26 + 26",
|
||||
@@ -1297,16 +1380,40 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux,
|
||||
pPps->iPicInitQs = PIC_INIT_QS_OFFSET + iCode;
|
||||
WELS_CHECK_SE_BOTH_ERROR (pPps->iPicInitQs, PPS_PIC_INIT_QP_QS_MIN, PPS_PIC_INIT_QP_QS_MAX, "pic_init_qs_minus26 + 26",
|
||||
GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_PIC_INIT_QS));
|
||||
WELS_READ_VERIFY (BsGetSe (pBsAux, &iCode)); //chroma_qp_index_offset
|
||||
pPps->iChromaQpIndexOffset = iCode;
|
||||
WELS_CHECK_SE_BOTH_ERROR (pPps->iChromaQpIndexOffset, PPS_CHROMA_QP_INDEX_OFFSET_MIN, PPS_CHROMA_QP_INDEX_OFFSET_MAX,
|
||||
WELS_READ_VERIFY (BsGetSe (pBsAux, &iCode)); //chroma_qp_index_offset,cb
|
||||
pPps->iChromaQpIndexOffset[0] = iCode;
|
||||
WELS_CHECK_SE_BOTH_ERROR (pPps->iChromaQpIndexOffset[0], PPS_CHROMA_QP_INDEX_OFFSET_MIN, PPS_CHROMA_QP_INDEX_OFFSET_MAX,
|
||||
"chroma_qp_index_offset", GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_CHROMA_QP_INDEX_OFFSET));
|
||||
pPps->iChromaQpIndexOffset[1] = pPps->iChromaQpIndexOffset[0];//init cr qp offset
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //deblocking_filter_control_present_flag
|
||||
pPps->bDeblockingFilterControlPresentFlag = !!uiCode;
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //constrained_intra_pred_flag
|
||||
pPps->bConstainedIntraPredFlag = !!uiCode;
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //redundant_pic_cnt_present_flag
|
||||
pPps->bRedundantPicCntPresentFlag = !!uiCode;
|
||||
/*TODO: to judge whether going on to parse*/
|
||||
//going on to parse high profile syntax, need fix me
|
||||
#ifndef DISABLE_HP_BRANCH_1_4
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode));
|
||||
pPps->bTransform_8x8_mode_flag = !!uiCode;
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode));
|
||||
pPps->bPicScalingMatrixPresentFlag = !!uiCode;
|
||||
if (pPps->bPicScalingMatrixPresentFlag) {
|
||||
if (pCtx->bSpsAvailFlags[pPps->iSpsId])
|
||||
WELS_READ_VERIFY (ParseScalingList (&pCtx->sSpsBuffer[pPps->iSpsId], pBsAux, 1, pPps->bPicScalingListPresentFlag,
|
||||
pPps->iScalingList4x4, pPps->iScalingList8x8));
|
||||
else {
|
||||
pCtx->bSpsLatePps = true;
|
||||
WELS_READ_VERIFY (ParseScalingList (NULL, pBsAux, 1, pPps->bPicScalingListPresentFlag, pPps->iScalingList4x4,
|
||||
pPps->iScalingList8x8));
|
||||
}
|
||||
}
|
||||
//add second chroma qp parsing process
|
||||
WELS_READ_VERIFY (BsGetSe (pBsAux, &iCode)); //chroma_qp_index_offset,cr
|
||||
pPps->iChromaQpIndexOffset[1] = iCode;
|
||||
WELS_CHECK_SE_BOTH_ERROR (pPps->iChromaQpIndexOffset[1], PPS_CHROMA_QP_INDEX_OFFSET_MIN, PPS_CHROMA_QP_INDEX_OFFSET_MAX,
|
||||
"second_chroma_qp_index_offset", GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_CHROMA_QP_INDEX_OFFSET));
|
||||
#endif
|
||||
if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {
|
||||
PNalUnit pLastNalUnit = pCtx->pAccessUnitList->pNalUnitsList[pCtx->pAccessUnitList->uiAvailUnitsNum - 1];
|
||||
PPps pLastPps = pLastNalUnit->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pPps;
|
||||
@@ -1331,8 +1438,19 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux,
|
||||
}
|
||||
SPpsBsInfo* pPpsBs = &pCtx->sPpsBsInfo [uiPpsId];
|
||||
pPpsBs->iPpsId = (int32_t) uiPpsId;
|
||||
memcpy (pPpsBs->pPpsBsBuf, pSrcNal, kSrcNalLen);
|
||||
pPpsBs->uiPpsBsLen = kSrcNalLen;
|
||||
int32_t iTrailingZeroByte = 0;
|
||||
while (pSrcNal[kSrcNalLen - iTrailingZeroByte - 1] == 0x0) //remove final trailing 0 bytes
|
||||
iTrailingZeroByte++;
|
||||
int32_t iActualLen = kSrcNalLen - iTrailingZeroByte;
|
||||
pPpsBs->uiPpsBsLen = (uint16_t) iActualLen;
|
||||
//unify start code as 0x0001
|
||||
int32_t iStartDeltaByte = 0; //0 for 0x0001, 1 for 0x001
|
||||
if (pSrcNal[0] == 0x0 && pSrcNal[1] == 0x0 && pSrcNal[2] == 0x1) { //if 0x001
|
||||
pPpsBs->pPpsBsBuf[0] = 0x0; //add 0 to form 0x0001
|
||||
iStartDeltaByte++;
|
||||
pPpsBs->uiPpsBsLen++;
|
||||
}
|
||||
memcpy (pPpsBs->pPpsBsBuf + iStartDeltaByte, pSrcNal, iActualLen);
|
||||
}
|
||||
return ERR_NONE;
|
||||
}
|
||||
@@ -1355,6 +1473,113 @@ int32_t ParseSei (void* pSei, PBitStringAux pBsAux) { // reserved Sei_Msg type
|
||||
|
||||
return ERR_NONE;
|
||||
}
|
||||
/*
|
||||
*************************************************************************************
|
||||
* \brief to parse scalinglist message payload
|
||||
*
|
||||
* \param pps sps scaling list matrix message to be parsed output
|
||||
* \param pBsAux bitstream reader auxiliary
|
||||
*
|
||||
* \return 0 - successed
|
||||
* 1 - failed
|
||||
*
|
||||
* \note Call it in case scaling list matrix present at sps or pps level
|
||||
*************************************************************************************
|
||||
*/
|
||||
int32_t SetScalingListValue (uint8_t* pScalingList, int iScalingListNum, bool* bUseDefaultScalingMatrixFlag,
|
||||
PBitStringAux pBsAux) { // reserved Sei_Msg type
|
||||
int iLastScale = 8;
|
||||
int iNextScale = 8;
|
||||
int iDeltaScale;
|
||||
int32_t iCode;
|
||||
for (int j = 0; j < iScalingListNum; j++) {
|
||||
if (iNextScale != 0) {
|
||||
WELS_READ_VERIFY (BsGetSe (pBsAux, &iCode));
|
||||
WELS_CHECK_SE_BOTH_ERROR_NOLOG (iCode, SCALING_LIST_DELTA_SCALE_MIN, SCALING_LIST_DELTA_SCALE_MAX, "DeltaScale",
|
||||
ERR_SCALING_LIST_DELTA_SCALE);
|
||||
iDeltaScale = iCode;
|
||||
iNextScale = (iLastScale + iDeltaScale + 256) % 256;
|
||||
*bUseDefaultScalingMatrixFlag = (j == 0 && iNextScale == 0);
|
||||
if (*bUseDefaultScalingMatrixFlag)
|
||||
break;
|
||||
}
|
||||
pScalingList[g_kuiZigzagScan[j]] = (iNextScale == 0) ? iLastScale : iNextScale;
|
||||
iLastScale = pScalingList[g_kuiZigzagScan[j]];
|
||||
}
|
||||
|
||||
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t ParseScalingList (PSps pSps, PBitStringAux pBs, bool bPPS, bool* pScalingListPresentFlag,
|
||||
uint8_t (*iScalingList4x4)[16], uint8_t (*iScalingList8x8)[64]) {
|
||||
uint32_t uiScalingListNum;
|
||||
uint32_t uiCode;
|
||||
int32_t iRetTmp;
|
||||
bool bUseDefaultScalingMatrixFlag4x4 = false;
|
||||
bool bUseDefaultScalingMatrixFlag8x8 = false;
|
||||
bool bInit = false;
|
||||
const uint8_t* defaultScaling[4];
|
||||
|
||||
if (pSps != NULL) {
|
||||
uiScalingListNum = (pSps->uiChromaFormatIdc != 3) ? 8 : 12;
|
||||
bInit = bPPS && pSps->bSeqScalingMatrixPresentFlag;
|
||||
} else
|
||||
uiScalingListNum = 12;
|
||||
|
||||
//Init default_scaling_list value for sps or pps
|
||||
defaultScaling[0] = bInit ? pSps->iScalingList4x4[0] : g_kuiDequantScaling4x4Default[0];
|
||||
defaultScaling[1] = bInit ? pSps->iScalingList4x4[3] : g_kuiDequantScaling4x4Default[1];
|
||||
defaultScaling[2] = bInit ? pSps->iScalingList8x8[0] : g_kuiDequantScaling8x8Default[0];
|
||||
defaultScaling[3] = bInit ? pSps->iScalingList8x8[1] : g_kuiDequantScaling8x8Default[1];
|
||||
|
||||
for (unsigned int i = 0; i < uiScalingListNum; i++) {
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode));
|
||||
pScalingListPresentFlag[i] = !!uiCode;
|
||||
if (!!uiCode) {
|
||||
if (i < 6) {
|
||||
iRetTmp = SetScalingListValue (iScalingList4x4[i], 16, &bUseDefaultScalingMatrixFlag4x4, pBs);
|
||||
if (iRetTmp == ERR_NONE) {
|
||||
if (bUseDefaultScalingMatrixFlag4x4) {
|
||||
bUseDefaultScalingMatrixFlag4x4 = false;
|
||||
memcpy (iScalingList4x4[i], g_kuiDequantScaling4x4Default[i / 3], sizeof (uint8_t) * 16);
|
||||
}
|
||||
} else
|
||||
return iRetTmp;
|
||||
|
||||
} else {
|
||||
SetScalingListValue (iScalingList8x8[i - 6], 64, &bUseDefaultScalingMatrixFlag8x8, pBs);
|
||||
//if(iRetTmp == ERR_NONE)
|
||||
//{
|
||||
if (bUseDefaultScalingMatrixFlag8x8) {
|
||||
bUseDefaultScalingMatrixFlag8x8 = false;
|
||||
memcpy (iScalingList8x8[i - 6], g_kuiDequantScaling8x8Default[ (i - 6) & 1], sizeof (uint8_t) * 64);
|
||||
}
|
||||
// }
|
||||
|
||||
//else
|
||||
// return iRetTmp;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (i < 6) {
|
||||
if ((i != 0) && (i != 3))
|
||||
memcpy (iScalingList4x4[i], iScalingList4x4[i - 1], sizeof (uint8_t) * 16);
|
||||
else
|
||||
memcpy (iScalingList4x4[i], defaultScaling[i / 3], sizeof (uint8_t) * 16);
|
||||
|
||||
} else {
|
||||
if ((i == 6) || (i == 7))
|
||||
memcpy (iScalingList8x8[i - 6], defaultScaling[ (i & 1) + 2], sizeof (uint8_t) * 64);
|
||||
else
|
||||
memcpy (iScalingList8x8[i - 6], iScalingList8x8[ (i - 6) / 3], sizeof (uint8_t) * 64);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return ERR_NONE;
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
*************************************************************************************
|
||||
|
||||
@@ -332,13 +332,33 @@ void FilteringEdgeChromaH (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t*
|
||||
int32_t iAlpha;
|
||||
int32_t iBeta;
|
||||
ENFORCE_STACK_ALIGN_1D (int8_t, tc, 4, 16);
|
||||
if (pFilter->iChromaQP[0] == pFilter->iChromaQP[1]) {
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[0], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if (iAlpha | iBeta) {
|
||||
TC0_TBL_LOOKUP (tc, iIndexA, pBS, 1);
|
||||
pFilter->pLoopf->pfChromaDeblockingLT4Ver (pPixCb, pPixCr, iStride, iAlpha, iBeta, tc);
|
||||
}
|
||||
} else {
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[i], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if (iAlpha | iBeta) {
|
||||
uint8_t* pPixCbCr = (i == 0) ? pPixCb : pPixCr;
|
||||
TC0_TBL_LOOKUP (tc, iIndexA, pBS, 1);
|
||||
pFilter->pLoopf->pfChromaDeblockingLT4Ver2 (pPixCbCr, iStride, iAlpha, iBeta, tc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (iAlpha | iBeta) {
|
||||
TC0_TBL_LOOKUP (tc, iIndexA, pBS, 1);
|
||||
pFilter->pLoopf->pfChromaDeblockingLT4Ver (pPixCb, pPixCr, iStride, iAlpha, iBeta, tc);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -348,13 +368,33 @@ void FilteringEdgeChromaV (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t*
|
||||
int32_t iAlpha;
|
||||
int32_t iBeta;
|
||||
ENFORCE_STACK_ALIGN_1D (int8_t, tc, 4, 16);
|
||||
if (pFilter->iChromaQP[0] == pFilter->iChromaQP[1]) {
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if (iAlpha | iBeta) {
|
||||
TC0_TBL_LOOKUP (tc, iIndexA, pBS, 1);
|
||||
pFilter->pLoopf->pfChromaDeblockingLT4Hor (pPixCb, pPixCr, iStride, iAlpha, iBeta, tc);
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[0], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if (iAlpha | iBeta) {
|
||||
TC0_TBL_LOOKUP (tc, iIndexA, pBS, 1);
|
||||
pFilter->pLoopf->pfChromaDeblockingLT4Hor (pPixCb, pPixCr, iStride, iAlpha, iBeta, tc);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[i], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if (iAlpha | iBeta) {
|
||||
uint8_t* pPixCbCr = (i == 0) ? pPixCb : pPixCr;
|
||||
TC0_TBL_LOOKUP (tc, iIndexA, pBS, 1);
|
||||
pFilter->pLoopf->pfChromaDeblockingLT4Hor2 (pPixCbCr, iStride, iAlpha, iBeta, tc);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -364,12 +404,27 @@ void FilteringEdgeChromaIntraH (SDeblockingFilter* pFilter, uint8_t* pPixCb, uin
|
||||
int32_t iIndexA;
|
||||
int32_t iAlpha;
|
||||
int32_t iBeta;
|
||||
if (pFilter->iChromaQP[0] == pFilter->iChromaQP[1]) {
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[0], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if (iAlpha | iBeta) {
|
||||
pFilter->pLoopf->pfChromaDeblockingEQ4Ver (pPixCb, pPixCr, iStride, iAlpha, iBeta);
|
||||
if (iAlpha | iBeta) {
|
||||
pFilter->pLoopf->pfChromaDeblockingEQ4Ver (pPixCb, pPixCr, iStride, iAlpha, iBeta);
|
||||
}
|
||||
} else {
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[i], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if (iAlpha | iBeta) {
|
||||
uint8_t* pPixCbCr = (i == 0) ? pPixCb : pPixCr;
|
||||
pFilter->pLoopf->pfChromaDeblockingEQ4Ver2 (pPixCbCr, iStride, iAlpha, iBeta);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -379,12 +434,29 @@ void FilteringEdgeChromaIntraV (SDeblockingFilter* pFilter, uint8_t* pPixCb, uin
|
||||
int32_t iIndexA;
|
||||
int32_t iAlpha;
|
||||
int32_t iBeta;
|
||||
if (pFilter->iChromaQP[0] == pFilter->iChromaQP[1]) { // QP of cb and cr are the same
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if (iAlpha | iBeta) {
|
||||
pFilter->pLoopf->pfChromaDeblockingEQ4Hor (pPixCb, pPixCr, iStride, iAlpha, iBeta);
|
||||
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[0], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
if (iAlpha | iBeta) {
|
||||
pFilter->pLoopf->pfChromaDeblockingEQ4Hor (pPixCb, pPixCr, iStride, iAlpha, iBeta);
|
||||
}
|
||||
} else {
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[i], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
if (iAlpha | iBeta) {
|
||||
uint8_t* pPixCbCr = (i == 0) ? pPixCb : pPixCr;
|
||||
pFilter->pLoopf->pfChromaDeblockingEQ4Hor2 (pPixCbCr, iStride, iAlpha, iBeta);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -397,7 +469,8 @@ void DeblockingInterMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_
|
||||
int32_t iMbY = pCurDqLayer->iMbY;
|
||||
|
||||
int32_t iCurLumaQp = pCurDqLayer->pLumaQp[iMbXyIndex];
|
||||
int32_t iCurChromaQp = pCurDqLayer->pChromaQp[iMbXyIndex];
|
||||
//int32_t* iCurChromaQp = pCurDqLayer->pChromaQp[iMbXyIndex];
|
||||
int8_t* pCurChromaQp = pCurDqLayer->pChromaQp[iMbXyIndex];
|
||||
int32_t iLineSize = pFilter->iCsStride[0];
|
||||
int32_t iLineSizeUV = pFilter->iCsStride[1];
|
||||
|
||||
@@ -406,11 +479,13 @@ void DeblockingInterMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_
|
||||
pDestCb = pFilter->pCsData[1] + ((iMbY * iLineSizeUV + iMbX) << 3);
|
||||
pDestCr = pFilter->pCsData[2] + ((iMbY * iLineSizeUV + iMbX) << 3);
|
||||
|
||||
//Vertical margrin
|
||||
if (iBoundryFlag & LEFT_FLAG_MASK) {
|
||||
int32_t iLeftXyIndex = iMbXyIndex - 1;
|
||||
pFilter->iLumaQP = (iCurLumaQp + pCurDqLayer->pLumaQp[iLeftXyIndex] + 1) >> 1;
|
||||
pFilter->iChromaQP = (iCurChromaQp + pCurDqLayer->pChromaQp[iLeftXyIndex] + 1) >> 1;
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
pFilter->iChromaQP[i] = (pCurChromaQp[i] + pCurDqLayer->pChromaQp[iLeftXyIndex][i] + 1) >> 1;
|
||||
}
|
||||
if (nBS[0][0][0] == 0x04) {
|
||||
FilteringEdgeLumaIntraV (pFilter, pDestY, iLineSize, NULL);
|
||||
FilteringEdgeChromaIntraV (pFilter, pDestCb, pDestCr, iLineSizeUV, NULL);
|
||||
@@ -423,7 +498,8 @@ void DeblockingInterMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_
|
||||
}
|
||||
|
||||
pFilter->iLumaQP = iCurLumaQp;
|
||||
pFilter->iChromaQP = iCurChromaQp;
|
||||
pFilter->iChromaQP[0] = pCurChromaQp[0];
|
||||
pFilter->iChromaQP[1] = pCurChromaQp[1];
|
||||
|
||||
if (* (uint32_t*)nBS[0][1] != 0) {
|
||||
FilteringEdgeLumaV (pFilter, &pDestY[1 << 2], iLineSize, nBS[0][1]);
|
||||
@@ -441,7 +517,9 @@ void DeblockingInterMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_
|
||||
if (iBoundryFlag & TOP_FLAG_MASK) {
|
||||
int32_t iTopXyIndex = iMbXyIndex - pCurDqLayer->iMbWidth;
|
||||
pFilter->iLumaQP = (iCurLumaQp + pCurDqLayer->pLumaQp[iTopXyIndex] + 1) >> 1;
|
||||
pFilter->iChromaQP = (iCurChromaQp + pCurDqLayer->pChromaQp[iTopXyIndex] + 1) >> 1;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
pFilter->iChromaQP[i] = (pCurChromaQp[i] + pCurDqLayer->pChromaQp[iTopXyIndex][i] + 1) >> 1;
|
||||
}
|
||||
|
||||
if (nBS[1][0][0] == 0x04) {
|
||||
FilteringEdgeLumaIntraH (pFilter, pDestY, iLineSize, NULL);
|
||||
@@ -455,7 +533,8 @@ void DeblockingInterMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_
|
||||
}
|
||||
|
||||
pFilter->iLumaQP = iCurLumaQp;
|
||||
pFilter->iChromaQP = iCurChromaQp;
|
||||
pFilter->iChromaQP[0] = pCurChromaQp[0];
|
||||
pFilter->iChromaQP[1] = pCurChromaQp[1];
|
||||
|
||||
if (* (uint32_t*)nBS[1][1] != 0) {
|
||||
FilteringEdgeLumaH (pFilter, &pDestY[ (1 << 2)*iLineSize], iLineSize, nBS[1][1]);
|
||||
@@ -527,8 +606,10 @@ void FilteringEdgeChromaHV (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, in
|
||||
int32_t iMbWidth = pCurDqLayer->iMbWidth;
|
||||
int32_t iLineSize = pFilter->iCsStride[1];
|
||||
|
||||
uint8_t* pDestCb, *pDestCr;
|
||||
int32_t iCurQp;
|
||||
uint8_t* pDestCb;
|
||||
uint8_t* pDestCr;
|
||||
//int32_t iCurQp;
|
||||
int8_t* pCurQp;
|
||||
int32_t iIndexA, iAlpha, iBeta;
|
||||
|
||||
ENFORCE_STACK_ALIGN_1D (int8_t, iTc, 4, 16);
|
||||
@@ -536,33 +617,76 @@ void FilteringEdgeChromaHV (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, in
|
||||
|
||||
pDestCb = pFilter->pCsData[1] + ((iMbY * iLineSize + iMbX) << 3);
|
||||
pDestCr = pFilter->pCsData[2] + ((iMbY * iLineSize + iMbX) << 3);
|
||||
iCurQp = pCurDqLayer->pChromaQp[iMbXyIndex];
|
||||
pCurQp = pCurDqLayer->pChromaQp[iMbXyIndex];
|
||||
|
||||
* (uint32_t*)uiBSx4 = 0x03030303;
|
||||
|
||||
// chroma v
|
||||
|
||||
// chroma v
|
||||
if (iBoundryFlag & LEFT_FLAG_MASK) {
|
||||
pFilter->iChromaQP = (iCurQp + pCurDqLayer->pChromaQp[iMbXyIndex - 1] + 1) >> 1;
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
pFilter->iChromaQP[i] = (pCurQp[i] + pCurDqLayer->pChromaQp[iMbXyIndex - 1][i] + 1) >> 1;
|
||||
|
||||
}
|
||||
FilteringEdgeChromaIntraV (pFilter, pDestCb, pDestCr, iLineSize, NULL);
|
||||
}
|
||||
|
||||
pFilter->iChromaQP = iCurQp;
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
if (iAlpha | iBeta) {
|
||||
TC0_TBL_LOOKUP (iTc, iIndexA, uiBSx4, 1);
|
||||
pFilter->pLoopf->pfChromaDeblockingLT4Hor (&pDestCb[2 << 1], &pDestCr[2 << 1], iLineSize, iAlpha, iBeta, iTc);
|
||||
pFilter->iChromaQP[0] = pCurQp[0];
|
||||
pFilter->iChromaQP[1] = pCurQp[1];
|
||||
if (pFilter->iChromaQP[0] == pFilter->iChromaQP[1]) {
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[0], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
if (iAlpha | iBeta) {
|
||||
TC0_TBL_LOOKUP (iTc, iIndexA, uiBSx4, 1);
|
||||
pFilter->pLoopf->pfChromaDeblockingLT4Hor (&pDestCb[2 << 1], &pDestCr[2 << 1], iLineSize, iAlpha, iBeta, iTc);
|
||||
}
|
||||
} else {
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[i], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
if (iAlpha | iBeta) {
|
||||
uint8_t* pDestCbCr = (i == 0) ? &pDestCb[2 << 1] : &pDestCr[2 << 1];
|
||||
TC0_TBL_LOOKUP (iTc, iIndexA, uiBSx4, 1);
|
||||
pFilter->pLoopf->pfChromaDeblockingLT4Hor2 (pDestCbCr, iLineSize, iAlpha, iBeta, iTc);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// chroma h
|
||||
|
||||
if (iBoundryFlag & TOP_FLAG_MASK) {
|
||||
pFilter->iChromaQP = (iCurQp + pCurDqLayer->pChromaQp[iMbXyIndex - iMbWidth] + 1) >> 1;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
pFilter->iChromaQP[i] = (pCurQp[i] + pCurDqLayer->pChromaQp[iMbXyIndex - iMbWidth][i] + 1) >> 1;
|
||||
}
|
||||
FilteringEdgeChromaIntraH (pFilter, pDestCb, pDestCr, iLineSize, NULL);
|
||||
}
|
||||
|
||||
pFilter->iChromaQP = iCurQp;
|
||||
if (iAlpha | iBeta) {
|
||||
pFilter->pLoopf->pfChromaDeblockingLT4Ver (&pDestCb[ (2 << 1)*iLineSize], &pDestCr[ (2 << 1)*iLineSize], iLineSize,
|
||||
iAlpha, iBeta, iTc);
|
||||
pFilter->iChromaQP[0] = pCurQp[0];
|
||||
pFilter->iChromaQP[1] = pCurQp[1];
|
||||
|
||||
if (pFilter->iChromaQP[0] == pFilter->iChromaQP[1]) {
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[0], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
if (iAlpha | iBeta) {
|
||||
pFilter->pLoopf->pfChromaDeblockingLT4Ver (&pDestCb[ (2 << 1)*iLineSize], &pDestCr[ (2 << 1)*iLineSize], iLineSize,
|
||||
iAlpha, iBeta, iTc);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[i], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
if (iAlpha | iBeta) {
|
||||
uint8_t* pDestCbCr = (i == 0) ? &pDestCb[ (2 << 1) * iLineSize] : &pDestCr[ (2 << 1) * iLineSize];
|
||||
pFilter->pLoopf->pfChromaDeblockingLT4Ver2 (pDestCbCr, iLineSize,
|
||||
iAlpha, iBeta, iTc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -706,6 +830,11 @@ void DeblockingInit (SDeblockingFunc* pFunc, int32_t iCpu) {
|
||||
pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_c;
|
||||
pFunc->pfChromaDeblockingEQ4Hor = DeblockChromaEq4H_c;
|
||||
|
||||
pFunc->pfChromaDeblockingLT4Ver2 = DeblockChromaLt4V2_c;
|
||||
pFunc->pfChromaDeblockingEQ4Ver2 = DeblockChromaEq4V2_c;
|
||||
pFunc->pfChromaDeblockingLT4Hor2 = DeblockChromaLt4H2_c;
|
||||
pFunc->pfChromaDeblockingEQ4Hor2 = DeblockChromaEq4H2_c;
|
||||
|
||||
#ifdef X86_ASM
|
||||
if (iCpu & WELS_CPU_SSSE3) {
|
||||
pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_ssse3;
|
||||
|
||||
@@ -90,12 +90,14 @@ int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (WelsTargetMbConstruction (pCtx)) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
|
||||
"WelsTargetSliceConstruction():::MB(%d, %d) construction error. pCurSlice_type:%d",
|
||||
pCurLayer->iMbX, pCurLayer->iMbY, pCurSlice->eSliceType);
|
||||
if (!pCtx->bParseOnly) { //for parse only, actual recon MB unnecessary
|
||||
if (WelsTargetMbConstruction (pCtx)) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
|
||||
"WelsTargetSliceConstruction():::MB(%d, %d) construction error. pCurSlice_type:%d",
|
||||
pCurLayer->iMbX, pCurLayer->iMbY, pCurSlice->eSliceType);
|
||||
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
++iCountNumMb;
|
||||
@@ -132,9 +134,13 @@ int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) {
|
||||
if ((pCurSlice->eSliceType != I_SLICE) && (pCurSlice->eSliceType != P_SLICE))
|
||||
return 0;
|
||||
|
||||
if (pCtx->bParseOnly) //for parse only, deblocking should not go on
|
||||
return 0;
|
||||
|
||||
pDeblockMb = WelsDeblockingMb;
|
||||
|
||||
if (1 == pSliceHeader->uiDisableDeblockingFilterIdc) {
|
||||
if (1 == pSliceHeader->uiDisableDeblockingFilterIdc
|
||||
|| pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer.iTotalMbInCurSlice <= 0) {
|
||||
return 0;//NO_SUPPORTED_FILTER_IDX
|
||||
} else {
|
||||
WelsDeblockingFilterSlice (pCtx, pDeblockMb);
|
||||
@@ -197,8 +203,8 @@ int32_t WelsMbInterConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void WelsLumaDcDequantIdct (int16_t* pBlock, int32_t iQp) {
|
||||
const int32_t kiQMul = g_kuiDequantCoeff[iQp][0];
|
||||
void WelsLumaDcDequantIdct (int16_t* pBlock, int32_t iQp, PWelsDecoderContext pCtx) {
|
||||
const int32_t kiQMul = pCtx->bUseScalingList ? pCtx->pDequant_coeff4x4[0][iQp][0] >> 4 : g_kuiDequantCoeff[iQp][0];
|
||||
#define STRIDE 16
|
||||
int32_t i;
|
||||
int32_t iTemp[16]; //FIXME check if this is a good idea
|
||||
@@ -246,7 +252,7 @@ int32_t WelsMbIntraPredictionConstruction (PWelsDecoderContext pCtx, PDqLayer pC
|
||||
WelsFillRecNeededMbInfo (pCtx, bOutput, pCurLayer);
|
||||
|
||||
if (IS_INTRA16x16 (pCurLayer->pMbType[iMbXy])) {
|
||||
WelsLumaDcDequantIdct (pCurLayer->pScaledTCoeff[iMbXy], pCurLayer->pLumaQp[iMbXy]);
|
||||
WelsLumaDcDequantIdct (pCurLayer->pScaledTCoeff[iMbXy], pCurLayer->pLumaQp[iMbXy], pCtx);
|
||||
RecI16x16Mb (iMbXy, pCtx, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer);
|
||||
|
||||
return 0;
|
||||
@@ -438,6 +444,10 @@ int32_t ParseIntra4x4Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail
|
||||
pCurDqLayer->pIntraPredMode[iMbXy][4] = pIntraPredMode[4 + 8 * 1];
|
||||
pCurDqLayer->pIntraPredMode[iMbXy][5] = pIntraPredMode[4 + 8 * 2];
|
||||
pCurDqLayer->pIntraPredMode[iMbXy][6] = pIntraPredMode[4 + 8 * 3];
|
||||
|
||||
if (pCtx->pSps->uiChromaFormatIdc == 0)//no need parse chroma
|
||||
return ERR_NONE;
|
||||
|
||||
if (pCurDqLayer->sLayerInfo.pPps->bEntropyCodingModeFlag) {
|
||||
WELS_READ_VERIFY (ParseIntraPredModeChromaCabac (pCtx, uiNeighAvail, iCode));
|
||||
if (iCode > MAX_PRED_MODE_ID_CHROMA) {
|
||||
@@ -456,7 +466,6 @@ int32_t ParseIntra4x4Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail
|
||||
|| CheckIntraChromaPredMode (uiNeighAvail, &pCurDqLayer->pChromaPredMode[iMbXy])) {
|
||||
return ERR_INFO_INVALID_I_CHROMA_PRED_MODE;
|
||||
}
|
||||
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
@@ -472,6 +481,9 @@ int32_t ParseIntra16x16Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAva
|
||||
&pCurDqLayer->pIntraPredMode[iMbXy][7])) { //invalid iPredMode, must stop decoding
|
||||
return ERR_INFO_INVALID_I16x16_PRED_MODE;
|
||||
}
|
||||
if (pCtx->pSps->uiChromaFormatIdc == 0)
|
||||
return ERR_NONE;
|
||||
|
||||
if (pCurDqLayer->sLayerInfo.pPps->bEntropyCodingModeFlag) {
|
||||
WELS_READ_VERIFY (ParseIntraPredModeChromaCabac (pCtx, uiNeighAvail, iCode));
|
||||
if (iCode > MAX_PRED_MODE_ID_CHROMA) {
|
||||
@@ -513,6 +525,9 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui
|
||||
WELS_READ_VERIFY (ParseMBTypeISliceCabac (pCtx, &sNeighAvail, uiMbType));
|
||||
if (uiMbType > 25) {
|
||||
return ERR_INFO_INVALID_MB_TYPE;
|
||||
} else if (!pCtx->pSps->uiChromaFormatIdc && ((uiMbType >= 5 && uiMbType <= 12) || (uiMbType >= 17
|
||||
&& uiMbType <= 24))) {
|
||||
return ERR_INFO_INVALID_MB_TYPE;
|
||||
} else if (25 == uiMbType) { //I_PCM
|
||||
WELS_READ_VERIFY (ParseIPCMInfoCabac (pCtx));
|
||||
pSlice->iLastDeltaQp = 0;
|
||||
@@ -530,19 +545,18 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui
|
||||
WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, &sNeighAvail, uiCbp));
|
||||
pCurLayer->pCbp[iMbXy] = uiCbp;
|
||||
pSlice->iLastDeltaQp = uiCbp == 0 ? 0 : pSlice->iLastDeltaQp;
|
||||
uiCbpChroma = uiCbp >> 4;
|
||||
uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? uiCbp >> 4 : 0;
|
||||
uiCbpLuma = uiCbp & 15;
|
||||
} else { //I16x16;
|
||||
pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
|
||||
pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
|
||||
pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
|
||||
uiCbpChroma = pCurLayer->pCbp[iMbXy] >> 4;
|
||||
uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0 ;
|
||||
uiCbpLuma = pCurLayer->pCbp[iMbXy] & 15;
|
||||
WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurLayer);
|
||||
WELS_READ_VERIFY (ParseIntra16x16Mode (pCtx, &sNeighAvail, pBsAux, pCurLayer));
|
||||
}
|
||||
|
||||
|
||||
ST32 (&pCurLayer->pNzc[iMbXy][0], 0);
|
||||
ST32 (&pCurLayer->pNzc[iMbXy][4], 0);
|
||||
ST32 (&pCurLayer->pNzc[iMbXy][8], 0);
|
||||
@@ -553,8 +567,10 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui
|
||||
|
||||
if (pCurLayer->pCbp[iMbXy] == 0 && IS_INTRA4x4 (pCurLayer->pMbType[iMbXy])) {
|
||||
pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
|
||||
pCurLayer->pChromaQp[iMbXy] = g_kuiChromaQpTable[WELS_CLIP3 ((pCurLayer->pLumaQp[iMbXy] +
|
||||
pSliceHeader->pPps->iChromaQpIndexOffset), 0, 51)];
|
||||
for (i = 0; i < 2; i++) {
|
||||
pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 ((pCurLayer->pLumaQp[iMbXy] +
|
||||
pSliceHeader->pPps->iChromaQpIndexOffset[i]), 0, 51)];
|
||||
}
|
||||
}
|
||||
|
||||
if (pCurLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) {
|
||||
@@ -566,8 +582,10 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui
|
||||
}
|
||||
pCurLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp
|
||||
pSlice->iLastMbQp = pCurLayer->pLumaQp[iMbXy];
|
||||
pCurLayer->pChromaQp[iMbXy] = g_kuiChromaQpTable[WELS_CLIP3 ((pSlice->iLastMbQp +
|
||||
pSliceHeader->pPps->iChromaQpIndexOffset), 0, 51)];
|
||||
for (i = 0; i < 2; i++) {
|
||||
pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 ((pSlice->iLastMbQp +
|
||||
pSliceHeader->pPps->iChromaQpIndexOffset[i]), 0, 51)];
|
||||
}
|
||||
if (MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) {
|
||||
//step1: Luma DC
|
||||
WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, 0, 16, g_kuiLumaDcZigzagScan,
|
||||
@@ -596,7 +614,8 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui
|
||||
for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
|
||||
//Luma (DC and AC decoding together)
|
||||
WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - iScanIdxStart + 1,
|
||||
g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), pCurLayer->pLumaQp[iMbXy],
|
||||
g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC_INTRA, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4),
|
||||
pCurLayer->pLumaQp[iMbXy],
|
||||
pCtx));
|
||||
iIdx++;
|
||||
}
|
||||
@@ -610,26 +629,27 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui
|
||||
ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
|
||||
ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
|
||||
}
|
||||
|
||||
int32_t iMbResProperty;
|
||||
//chroma
|
||||
//step1: DC
|
||||
if (1 == uiCbpChroma || 2 == uiCbpChroma) {
|
||||
//Cb Cr
|
||||
WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, 16 + (0 << 2), 4, g_kuiChromaDcScan,
|
||||
CHROMA_DC_V, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (0 << 6), pCurLayer->pChromaQp[iMbXy], pCtx));
|
||||
WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, 16 + (1 << 2), 4, g_kuiChromaDcScan,
|
||||
CHROMA_DC_U, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (1 << 6), pCurLayer->pChromaQp[iMbXy], pCtx));
|
||||
for (i = 0; i < 2; i++) {
|
||||
iMbResProperty = i ? CHROMA_DC_V : CHROMA_DC_U;
|
||||
WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, 16 + (i << 2), 4, g_kuiChromaDcScan,
|
||||
iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurLayer->pChromaQp[iMbXy][i], pCtx));
|
||||
}
|
||||
}
|
||||
|
||||
//step2: AC
|
||||
if (2 == uiCbpChroma) {
|
||||
for (i = 0; i < 2; i++) { //Cb Cr
|
||||
int32_t iResProperty = i ? CHROMA_AC_V : CHROMA_AC_U;
|
||||
iMbResProperty = i ? CHROMA_AC_V : CHROMA_AC_U;
|
||||
int32_t iIdx = 16 + (i << 2);
|
||||
for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
|
||||
WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, iIdx,
|
||||
iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), iResProperty,
|
||||
pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), pCurLayer->pChromaQp[iMbXy], pCtx));
|
||||
iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), iMbResProperty,
|
||||
pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), pCurLayer->pChromaQp[iMbXy][i], pCtx));
|
||||
iIdx++;
|
||||
}
|
||||
}
|
||||
@@ -673,7 +693,7 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv
|
||||
int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart;
|
||||
int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd;
|
||||
int32_t iMbXy = pCurLayer->iMbXyIndex;
|
||||
|
||||
int32_t iMbResProperty;
|
||||
int32_t i;
|
||||
uint32_t uiMbType = 0, uiCbp = 0, uiCbpLuma = 0, uiCbpChroma = 0;
|
||||
|
||||
@@ -693,9 +713,10 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv
|
||||
pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;
|
||||
} else { //Intra mode
|
||||
uiMbType -= 5;
|
||||
if (uiMbType > 25) {
|
||||
if (uiMbType > 25)
|
||||
return ERR_INFO_INVALID_MB_TYPE;
|
||||
if (!pCtx->pSps->uiChromaFormatIdc && ((uiMbType >= 5 && uiMbType <= 12) || (uiMbType >= 17 && uiMbType <= 24)))
|
||||
return ERR_INFO_INVALID_MB_TYPE;
|
||||
}
|
||||
|
||||
if (25 == uiMbType) { //I_PCM
|
||||
WELS_READ_VERIFY (ParseIPCMInfoCabac (pCtx));
|
||||
@@ -715,7 +736,7 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv
|
||||
pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
|
||||
pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
|
||||
pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
|
||||
uiCbpChroma = pCurLayer->pCbp[iMbXy] >> 4;
|
||||
uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;
|
||||
uiCbpLuma = pCurLayer->pCbp[iMbXy] & 15;
|
||||
WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurLayer);
|
||||
WELS_READ_VERIFY (ParseIntra16x16Mode (pCtx, pNeighAvail, pBsAux, pCurLayer));
|
||||
@@ -732,9 +753,10 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv
|
||||
|
||||
if (MB_TYPE_INTRA16x16 != pCurLayer->pMbType[iMbXy]) {
|
||||
WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, pNeighAvail, uiCbp));
|
||||
|
||||
pCurLayer->pCbp[iMbXy] = uiCbp;
|
||||
pSlice->iLastDeltaQp = uiCbp == 0 ? 0 : pSlice->iLastDeltaQp;
|
||||
uiCbpChroma = pCurLayer->pCbp[iMbXy] >> 4;
|
||||
uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0 ;
|
||||
uiCbpLuma = pCurLayer->pCbp[iMbXy] & 15;
|
||||
}
|
||||
|
||||
@@ -749,8 +771,10 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv
|
||||
}
|
||||
pCurLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp
|
||||
pSlice->iLastMbQp = pCurLayer->pLumaQp[iMbXy];
|
||||
pCurLayer->pChromaQp[iMbXy] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp +
|
||||
pSliceHeader->pPps->iChromaQpIndexOffset, 0, 51)];
|
||||
for (i = 0; i < 2; i++) {
|
||||
pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp +
|
||||
pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)];
|
||||
}
|
||||
|
||||
if (MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) {
|
||||
//step1: Luma DC
|
||||
@@ -774,13 +798,15 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv
|
||||
ST32 (&pCurLayer->pNzc[iMbXy][12], 0);
|
||||
}
|
||||
} else { //non-MB_TYPE_INTRA16x16
|
||||
iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER;
|
||||
for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
|
||||
if (uiCbpLuma & (1 << iId8x8)) {
|
||||
int32_t iIdx = (iId8x8 << 2);
|
||||
for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
|
||||
//Luma (DC and AC decoding together)
|
||||
WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - iScanIdxStart + 1,
|
||||
g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), pCurLayer->pLumaQp[iMbXy],
|
||||
g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4),
|
||||
pCurLayer->pLumaQp[iMbXy],
|
||||
pCtx));
|
||||
iIdx++;
|
||||
}
|
||||
@@ -799,20 +825,27 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv
|
||||
//step1: DC
|
||||
if (1 == uiCbpChroma || 2 == uiCbpChroma) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
int32_t iResProperty = i ? CHROMA_DC_V : CHROMA_DC_U;
|
||||
if (IS_INTRA (pCurLayer->pMbType[iMbXy]))
|
||||
iMbResProperty = i ? CHROMA_DC_V : CHROMA_DC_U;
|
||||
else
|
||||
iMbResProperty = i ? CHROMA_DC_V_INTER : CHROMA_DC_U_INTER;
|
||||
|
||||
WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, 16 + (i << 2), 4, g_kuiChromaDcScan,
|
||||
iResProperty, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurLayer->pChromaQp[iMbXy], pCtx));
|
||||
iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurLayer->pChromaQp[iMbXy][i], pCtx));
|
||||
}
|
||||
}
|
||||
//step2: AC
|
||||
if (2 == uiCbpChroma) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
int32_t iResProperty = i ? CHROMA_AC_V : CHROMA_AC_U;
|
||||
if (IS_INTRA (pCurLayer->pMbType[iMbXy]))
|
||||
iMbResProperty = i ? CHROMA_AC_V : CHROMA_AC_U;
|
||||
else
|
||||
iMbResProperty = i ? CHROMA_AC_V_INTER : CHROMA_AC_U_INTER;
|
||||
int32_t index = 16 + (i << 2);
|
||||
for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
|
||||
WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, index,
|
||||
iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1),
|
||||
iResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (index << 4), pCurLayer->pChromaQp[iMbXy], pCtx));
|
||||
iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (index << 4), pCurLayer->pChromaQp[iMbXy][i], pCtx));
|
||||
index++;
|
||||
}
|
||||
}
|
||||
@@ -826,8 +859,10 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv
|
||||
}
|
||||
} else {
|
||||
pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
|
||||
pCurLayer->pChromaQp[iMbXy] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] +
|
||||
pSliceHeader->pPps->iChromaQpIndexOffset, 0, 51)];
|
||||
for (i = 0; i < 2; i++) {
|
||||
pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] +
|
||||
pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)];
|
||||
}
|
||||
}
|
||||
|
||||
WELS_READ_VERIFY (ParseEndOfSliceCabac (pCtx, uiEosFlag));
|
||||
@@ -879,8 +914,10 @@ int32_t WelsDecodeMbCabacPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin
|
||||
|
||||
//reset rS
|
||||
pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; //??????????????? dqaunt of previous mb
|
||||
pCurLayer->pChromaQp[iMbXy] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] +
|
||||
pSliceHeader->pPps->iChromaQpIndexOffset, 0, 51)];
|
||||
for (i = 0; i < 2; i++) {
|
||||
pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] +
|
||||
pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)];
|
||||
}
|
||||
|
||||
//for neighboring CABAC usage
|
||||
pSlice->iLastDeltaQp = 0;
|
||||
@@ -893,6 +930,44 @@ int32_t WelsDecodeMbCabacPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin
|
||||
WELS_READ_VERIFY (WelsDecodeMbCabacPSliceBaseMode0 (pCtx, &uiNeighAvail, uiEosFlag));
|
||||
return ERR_NONE;
|
||||
}
|
||||
// Calculate deqaunt coeff scaling list value
|
||||
int32_t WelsCalcDeqCoeffScalingList (PWelsDecoderContext pCtx) {
|
||||
if (pCtx->pSps->bSeqScalingMatrixPresentFlag || pCtx->pPps->bPicScalingMatrixPresentFlag) {
|
||||
pCtx->bUseScalingList = true;
|
||||
|
||||
if (!pCtx->bDequantCoeff4x4Init || (pCtx->iDequantCoeffPpsid != pCtx->pPps->iPpsId)) {
|
||||
int i, q, x;
|
||||
// Rewrite pps scaling list for scalingList present flag=0
|
||||
if (pCtx->bSpsLatePps) {
|
||||
for (i = 0; i < 6; i++) {
|
||||
if (!pCtx->pSps->bSeqScalingListPresentFlag[i]) {
|
||||
if (i == 0 || i == 3)
|
||||
memcpy (pCtx->pPps->iScalingList4x4[i], pCtx->pSps->iScalingList4x4[i], 16 * sizeof (uint8_t));
|
||||
else
|
||||
memcpy (pCtx->pPps->iScalingList4x4[i], pCtx->pPps->iScalingList4x4[i - 1], 16 * sizeof (uint8_t));
|
||||
|
||||
}
|
||||
}
|
||||
//TO DO, SUPPORT 8x8 SCALINGlist
|
||||
|
||||
}
|
||||
//Init dequant coeff value for different QP
|
||||
for (i = 0; i < 6; i++) {
|
||||
pCtx->pDequant_coeff4x4[i] = pCtx->pDequant_coeff_buffer4x4[i];
|
||||
for (q = 0; q < 51; q++) {
|
||||
for (x = 0; x < 16; x++) {
|
||||
pCtx->pDequant_coeff4x4[i][q][x] = pCtx->pPps->bPicScalingMatrixPresentFlag ? pCtx->pPps->iScalingList4x4[i][x] *
|
||||
g_kuiDequantCoeff[q][x & 0x07] : pCtx->pSps->iScalingList4x4[i][x] * g_kuiDequantCoeff[q][x & 0x07];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pCtx->bDequantCoeff4x4Init = true;
|
||||
}
|
||||
} else
|
||||
pCtx->bUseScalingList = false;
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t WelsDecodeSlice (PWelsDecoderContext pCtx, bool bFirstSliceInLayer, PNalUnit pNalCur) {
|
||||
PDqLayer pCurLayer = pCtx->pCurDqLayer;
|
||||
@@ -950,6 +1025,8 @@ int32_t WelsDecodeSlice (PWelsDecoderContext pCtx, bool bFirstSliceInLayer, PNal
|
||||
pSlice->iLastDeltaQp = 0;
|
||||
WELS_READ_VERIFY (InitCabacDecEngineFromBS (pCtx->pCabacDecEngine, pCtx->pCurDqLayer->pBitStringAux));
|
||||
}
|
||||
//try to calculate the dequant_coeff
|
||||
WelsCalcDeqCoeffScalingList (pCtx);
|
||||
|
||||
iNextMbXyIndex = pSliceHeader->iFirstMbInSlice;
|
||||
iMbX = iNextMbXyIndex % pCurLayer->iMbWidth;
|
||||
@@ -1001,6 +1078,7 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) {
|
||||
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
|
||||
|
||||
SWelsNeighAvail sNeighAvail;
|
||||
int32_t iMbResProperty;
|
||||
|
||||
int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart;
|
||||
int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd;
|
||||
@@ -1021,9 +1099,10 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) {
|
||||
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //uiMbType
|
||||
uiMbType = uiCode;
|
||||
if (uiMbType > 25) {
|
||||
if (uiMbType > 25)
|
||||
return ERR_INFO_INVALID_MB_TYPE;
|
||||
if (!pCtx->pSps->uiChromaFormatIdc && ((uiMbType >= 5 && uiMbType <= 12) || (uiMbType >= 17 && uiMbType <= 24)))
|
||||
return ERR_INFO_INVALID_MB_TYPE;
|
||||
}
|
||||
|
||||
if (25 == uiMbType) {
|
||||
int32_t iDecStrideL = pCurLayer->pDec->iLinesize[0];
|
||||
@@ -1038,6 +1117,7 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) {
|
||||
|
||||
uint8_t* pTmpBsBuf;
|
||||
|
||||
|
||||
int32_t i;
|
||||
int32_t iCopySizeY = (sizeof (uint8_t) << 4);
|
||||
int32_t iCopySizeUV = (sizeof (uint8_t) << 3);
|
||||
@@ -1071,7 +1151,7 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) {
|
||||
|
||||
//step 3: update QP and pNonZeroCount
|
||||
pCurLayer->pLumaQp[iMbXy] = 0;
|
||||
pCurLayer->pChromaQp[iMbXy] = 0;
|
||||
memset (pCurLayer->pChromaQp[iMbXy], 0, sizeof (pCurLayer->pChromaQp[iMbXy]));
|
||||
memset (pNzc, 16, sizeof (pCurLayer->pNzc[iMbXy])); //Rec. 9.2.1 for PCM, nzc=16
|
||||
WELS_READ_VERIFY (InitReadBits (pBs, 0));
|
||||
return 0;
|
||||
@@ -1085,11 +1165,15 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) {
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //coded_block_pattern
|
||||
uiCbp = uiCode;
|
||||
//G.9.1 Alternative parsing process for coded pBlock pattern
|
||||
if (uiCbp > 47)
|
||||
if (pCtx->pSps->uiChromaFormatIdc && (uiCbp > 47))
|
||||
return ERR_INFO_INVALID_CBP;
|
||||
if (!pCtx->pSps->uiChromaFormatIdc && (uiCbp > 15))
|
||||
return ERR_INFO_INVALID_CBP;
|
||||
|
||||
uiCbp = g_kuiIntra4x4CbpTable[uiCbp];
|
||||
|
||||
if (pCtx->pSps->uiChromaFormatIdc)
|
||||
uiCbp = g_kuiIntra4x4CbpTable[uiCbp];
|
||||
else
|
||||
uiCbp = g_kuiIntra4x4CbpTable400[uiCbp];
|
||||
pCurLayer->pCbp[iMbXy] = uiCbp;
|
||||
uiCbpC = uiCbp >> 4;
|
||||
uiCbpL = uiCbp & 15;
|
||||
@@ -1097,7 +1181,7 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) {
|
||||
pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
|
||||
pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
|
||||
pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
|
||||
uiCbpC = pCurLayer->pCbp[iMbXy] >> 4;
|
||||
uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;
|
||||
uiCbpL = pCurLayer->pCbp[iMbXy] & 15;
|
||||
WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurLayer);
|
||||
WELS_READ_VERIFY (ParseIntra16x16Mode (pCtx, &sNeighAvail, pBs, pCurLayer));
|
||||
@@ -1112,8 +1196,10 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) {
|
||||
|
||||
if (pCurLayer->pCbp[iMbXy] == 0 && IS_INTRA4x4 (pCurLayer->pMbType[iMbXy])) {
|
||||
pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
|
||||
pCurLayer->pChromaQp[iMbXy] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] +
|
||||
pSliceHeader->pPps->iChromaQpIndexOffset, 0, 51)];
|
||||
for (i = 0; i < 2; i++) {
|
||||
pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] +
|
||||
pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1130,9 +1216,11 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) {
|
||||
|
||||
pCurLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp
|
||||
pSlice->iLastMbQp = pCurLayer->pLumaQp[iMbXy];
|
||||
pCurLayer->pChromaQp[iMbXy] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp +
|
||||
pSliceHeader->pPps->iChromaQpIndexOffset, 0,
|
||||
51)];
|
||||
for (i = 0; i < 2; i++) {
|
||||
pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp +
|
||||
pSliceHeader->pPps->iChromaQpIndexOffset[i], 0,
|
||||
51)];
|
||||
}
|
||||
|
||||
|
||||
BsStartCavlc (pBs);
|
||||
@@ -1165,7 +1253,7 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) {
|
||||
//Luma (DC and AC decoding together)
|
||||
if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex,
|
||||
iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan + iScanIdxStart,
|
||||
LUMA_DC_AC, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pLumaQp[iMbXy], pCtx)) {
|
||||
LUMA_DC_AC_INTRA, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pLumaQp[iMbXy], pCtx)) {
|
||||
return -1;//abnormal
|
||||
}
|
||||
iIndex++;
|
||||
@@ -1185,9 +1273,10 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) {
|
||||
//step1: DC
|
||||
if (1 == uiCbpC || 2 == uiCbpC) {
|
||||
for (i = 0; i < 2; i++) { //Cb Cr
|
||||
iMbResProperty = i ? CHROMA_DC_V : CHROMA_DC_U;
|
||||
if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs,
|
||||
16 + (i << 2), 4, g_kuiChromaDcScan, CHROMA_DC, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6),
|
||||
pCurLayer->pChromaQp[iMbXy], pCtx)) {
|
||||
16 + (i << 2), 4, g_kuiChromaDcScan, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6),
|
||||
pCurLayer->pChromaQp[iMbXy][i], pCtx)) {
|
||||
return -1;//abnormal
|
||||
}
|
||||
}
|
||||
@@ -1196,11 +1285,12 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) {
|
||||
//step2: AC
|
||||
if (2 == uiCbpC) {
|
||||
for (i = 0; i < 2; i++) { //Cb Cr
|
||||
iMbResProperty = i ? CHROMA_AC_V : CHROMA_AC_U;
|
||||
int32_t iIndex = 16 + (i << 2);
|
||||
for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
|
||||
if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex,
|
||||
iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1),
|
||||
CHROMA_AC, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pChromaQp[iMbXy], pCtx)) {
|
||||
iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pChromaQp[iMbXy][i], pCtx)) {
|
||||
return -1;//abnormal
|
||||
}
|
||||
iIndex++;
|
||||
@@ -1277,6 +1367,8 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) {
|
||||
uint32_t uiMbType = 0, uiCbp = 0, uiCbpL = 0, uiCbpC = 0;
|
||||
uint32_t uiCode;
|
||||
int32_t iCode;
|
||||
int32_t iMbResProperty;
|
||||
|
||||
GetNeighborAvailMbType (&sNeighAvail, pCurLayer);
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pNonZeroCount, 48, 16);
|
||||
pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;//2009.10.23
|
||||
@@ -1306,9 +1398,10 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) {
|
||||
}
|
||||
} else { //intra MB type
|
||||
uiMbType -= 5;
|
||||
if (uiMbType > 25) {
|
||||
if (uiMbType > 25)
|
||||
return ERR_INFO_INVALID_MB_TYPE;
|
||||
if (!pCtx->pSps->uiChromaFormatIdc && ((uiMbType >= 5 && uiMbType <= 12) || (uiMbType >= 17 && uiMbType <= 24)))
|
||||
return ERR_INFO_INVALID_MB_TYPE;
|
||||
}
|
||||
|
||||
if (25 == uiMbType) {
|
||||
int32_t iDecStrideL = pCurLayer->pDec->iLinesize[0];
|
||||
@@ -1357,7 +1450,7 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) {
|
||||
|
||||
//step 3: update QP and pNonZeroCount
|
||||
pCurLayer->pLumaQp[iMbXy] = 0;
|
||||
pCurLayer->pChromaQp[iMbXy] = 0;
|
||||
pCurLayer->pChromaQp[iMbXy][0] = pCurLayer->pChromaQp[iMbXy][1] = 0;
|
||||
//Rec. 9.2.1 for PCM, nzc=16
|
||||
ST32A4 (&pNzc[0], 0x10101010);
|
||||
ST32A4 (&pNzc[4], 0x10101010);
|
||||
@@ -1379,7 +1472,7 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) {
|
||||
pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
|
||||
pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
|
||||
pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
|
||||
uiCbpC = pCurLayer->pCbp[iMbXy] >> 4;
|
||||
uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;
|
||||
uiCbpL = pCurLayer->pCbp[iMbXy] & 15;
|
||||
WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurLayer);
|
||||
if (ParseIntra16x16Mode (pCtx, &sNeighAvail, pBs, pCurLayer)) {
|
||||
@@ -1393,13 +1486,15 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) {
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //coded_block_pattern
|
||||
uiCbp = uiCode;
|
||||
{
|
||||
if (uiCbp > 47)
|
||||
if (pCtx->pSps->uiChromaFormatIdc && (uiCbp > 47))
|
||||
return ERR_INFO_INVALID_CBP;
|
||||
if (!pCtx->pSps->uiChromaFormatIdc && (uiCbp > 15))
|
||||
return ERR_INFO_INVALID_CBP;
|
||||
|
||||
if (MB_TYPE_INTRA4x4 == pCurLayer->pMbType[iMbXy]) {
|
||||
uiCbp = g_kuiIntra4x4CbpTable[uiCbp];
|
||||
|
||||
uiCbp = pCtx->pSps->uiChromaFormatIdc ? g_kuiIntra4x4CbpTable[uiCbp] : g_kuiIntra4x4CbpTable400[uiCbp];
|
||||
} else //inter
|
||||
uiCbp = g_kuiInterCbpTable[uiCbp];
|
||||
uiCbp = pCtx->pSps->uiChromaFormatIdc ? g_kuiInterCbpTable[uiCbp] : g_kuiInterCbpTable400[uiCbp];
|
||||
}
|
||||
|
||||
pCurLayer->pCbp[iMbXy] = uiCbp;
|
||||
@@ -1407,8 +1502,6 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) {
|
||||
uiCbpL = pCurLayer->pCbp[iMbXy] & 15;
|
||||
}
|
||||
|
||||
memset (pCurLayer->pScaledTCoeff[iMbXy], 0, MB_COEFF_LIST_SIZE * sizeof (int16_t));
|
||||
|
||||
ST32A4 (&pNzc[0], 0);
|
||||
ST32A4 (&pNzc[4], 0);
|
||||
ST32A4 (&pNzc[8], 0);
|
||||
@@ -1417,13 +1510,15 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) {
|
||||
ST32A4 (&pNzc[20], 0);
|
||||
if (pCurLayer->pCbp[iMbXy] == 0 && !IS_INTRA16x16 (pCurLayer->pMbType[iMbXy]) && !IS_I_BL (pCurLayer->pMbType[iMbXy])) {
|
||||
pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
|
||||
pCurLayer->pChromaQp[iMbXy] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] +
|
||||
pSliceHeader->pPps->iChromaQpIndexOffset, 0, 51)];
|
||||
for (i = 0; i < 2; i++) {
|
||||
pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] +
|
||||
pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)];
|
||||
}
|
||||
}
|
||||
|
||||
if (pCurLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) {
|
||||
int32_t iQpDelta, iId8x8, iId4x4;
|
||||
|
||||
memset (pCurLayer->pScaledTCoeff[iMbXy], 0, MB_COEFF_LIST_SIZE * sizeof (int16_t));
|
||||
WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //mb_qp_delta
|
||||
iQpDelta = iCode;
|
||||
|
||||
@@ -1433,9 +1528,11 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) {
|
||||
|
||||
pCurLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp
|
||||
pSlice->iLastMbQp = pCurLayer->pLumaQp[iMbXy];
|
||||
pCurLayer->pChromaQp[iMbXy] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp +
|
||||
pSliceHeader->pPps->iChromaQpIndexOffset, 0,
|
||||
51)];
|
||||
for (i = 0; i < 2; i++) {
|
||||
pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp +
|
||||
pSliceHeader->pPps->iChromaQpIndexOffset[i], 0,
|
||||
51)];
|
||||
}
|
||||
|
||||
BsStartCavlc (pBs);
|
||||
|
||||
@@ -1461,12 +1558,13 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) {
|
||||
}
|
||||
} else { //non-MB_TYPE_INTRA16x16
|
||||
for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
|
||||
iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER;
|
||||
if (uiCbpL & (1 << iId8x8)) {
|
||||
int32_t iIndex = (iId8x8 << 2);
|
||||
for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
|
||||
//Luma (DC and AC decoding together)
|
||||
if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex,
|
||||
iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC,
|
||||
iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan + iScanIdxStart, iMbResProperty,
|
||||
pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pLumaQp[iMbXy], pCtx)) {
|
||||
return -1;//abnormal
|
||||
}
|
||||
@@ -1488,9 +1586,14 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) {
|
||||
//step1: DC
|
||||
if (1 == uiCbpC || 2 == uiCbpC) {
|
||||
for (i = 0; i < 2; i++) { //Cb Cr
|
||||
if (IS_INTRA (pCurLayer->pMbType[iMbXy]))
|
||||
iMbResProperty = i ? CHROMA_DC_V : CHROMA_DC_U;
|
||||
else
|
||||
iMbResProperty = i ? CHROMA_DC_V_INTER : CHROMA_DC_U_INTER;
|
||||
|
||||
if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs,
|
||||
16 + (i << 2), 4, g_kuiChromaDcScan, CHROMA_DC, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6),
|
||||
pCurLayer->pChromaQp[iMbXy], pCtx)) {
|
||||
16 + (i << 2), 4, g_kuiChromaDcScan, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6),
|
||||
pCurLayer->pChromaQp[iMbXy][i], pCtx)) {
|
||||
return -1;//abnormal
|
||||
}
|
||||
}
|
||||
@@ -1499,11 +1602,16 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) {
|
||||
//step2: AC
|
||||
if (2 == uiCbpC) {
|
||||
for (i = 0; i < 2; i++) { //Cb Cr
|
||||
if (IS_INTRA (pCurLayer->pMbType[iMbXy]))
|
||||
iMbResProperty = i ? CHROMA_AC_V : CHROMA_AC_U;
|
||||
else
|
||||
iMbResProperty = i ? CHROMA_AC_V_INTER : CHROMA_AC_U_INTER;
|
||||
|
||||
int32_t iIndex = 16 + (i << 2);
|
||||
for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
|
||||
if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex,
|
||||
iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1),
|
||||
CHROMA_AC, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pChromaQp[iMbXy], pCtx)) {
|
||||
iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pChromaQp[iMbXy][i], pCtx)) {
|
||||
return -1;//abnormal
|
||||
}
|
||||
iIndex++;
|
||||
@@ -1568,8 +1676,10 @@ int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin
|
||||
if (!pSlice->sSliceHeaderExt.bDefaultResidualPredFlag ||
|
||||
(pNalCur->sNalHeaderExt.uiQualityId == 0 && pNalCur->sNalHeaderExt.uiDependencyId == 0)) {
|
||||
pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
|
||||
pCurLayer->pChromaQp[iMbXy] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] +
|
||||
pSliceHeader->pPps->iChromaQpIndexOffset, 0, 51)];
|
||||
for (i = 0; i < 2; i++) {
|
||||
pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] +
|
||||
pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)];
|
||||
}
|
||||
}
|
||||
|
||||
pCurLayer->pCbp[iMbXy] = 0;
|
||||
@@ -1608,25 +1718,13 @@ int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin
|
||||
}
|
||||
|
||||
void WelsBlockFuncInit (SBlockFunc* pFunc, int32_t iCpu) {
|
||||
pFunc->pWelsSetNonZeroCountFunc = SetNonZeroCount_c;
|
||||
|
||||
#ifdef HAVE_NEON
|
||||
if (iCpu & WELS_CPU_NEON) {
|
||||
pFunc->pWelsSetNonZeroCountFunc = SetNonZeroCount_neon;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NEON_AARCH64
|
||||
if (iCpu & WELS_CPU_NEON) {
|
||||
pFunc->pWelsSetNonZeroCountFunc = SetNonZeroCount_AArch64_neon;
|
||||
}
|
||||
#endif
|
||||
|
||||
pFunc->pWelsSetNonZeroCountFunc = WelsNonZeroCount_c;
|
||||
pFunc->pWelsBlockZero16x16Func = WelsBlockZero16x16_c;
|
||||
pFunc->pWelsBlockZero8x8Func = WelsBlockZero8x8_c;
|
||||
//TO DO add neon and X86
|
||||
pFunc->pWelsBlockZero8x8Func = WelsBlockZero8x8_c;
|
||||
|
||||
#ifdef HAVE_NEON
|
||||
if (iCpu & WELS_CPU_NEON) {
|
||||
pFunc->pWelsSetNonZeroCountFunc = WelsNonZeroCount_neon;
|
||||
pFunc->pWelsBlockZero16x16Func = WelsBlockZero16x16_neon;
|
||||
pFunc->pWelsBlockZero8x8Func = WelsBlockZero8x8_neon;
|
||||
}
|
||||
@@ -1634,6 +1732,7 @@ void WelsBlockFuncInit (SBlockFunc* pFunc, int32_t iCpu) {
|
||||
|
||||
#ifdef HAVE_NEON_AARCH64
|
||||
if (iCpu & WELS_CPU_NEON) {
|
||||
pFunc->pWelsSetNonZeroCountFunc = WelsNonZeroCount_AArch64_neon;
|
||||
pFunc->pWelsBlockZero16x16Func = WelsBlockZero16x16_AArch64_neon;
|
||||
pFunc->pWelsBlockZero8x8Func = WelsBlockZero8x8_AArch64_neon;
|
||||
}
|
||||
@@ -1641,6 +1740,7 @@ void WelsBlockFuncInit (SBlockFunc* pFunc, int32_t iCpu) {
|
||||
|
||||
#if defined(X86_ASM)
|
||||
if (iCpu & WELS_CPU_SSE2) {
|
||||
pFunc->pWelsSetNonZeroCountFunc = WelsNonZeroCount_sse2;
|
||||
pFunc->pWelsBlockZero16x16Func = WelsBlockZero16x16_sse2;
|
||||
pFunc->pWelsBlockZero8x8Func = WelsBlockZero8x8_sse2;
|
||||
}
|
||||
@@ -1648,14 +1748,6 @@ void WelsBlockFuncInit (SBlockFunc* pFunc, int32_t iCpu) {
|
||||
|
||||
}
|
||||
|
||||
void SetNonZeroCount_c (int8_t* pNonZeroCount) {
|
||||
int32_t i;
|
||||
|
||||
for (i = 0; i < 24; i++) {
|
||||
pNonZeroCount[i] = !!pNonZeroCount[i];
|
||||
}
|
||||
}
|
||||
|
||||
void WelsBlockInit (int16_t* pBlock, int iW, int iH, int iStride, uint8_t uiVal) {
|
||||
int32_t i;
|
||||
int16_t* pDst = pBlock;
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
#include "expand_pic.h"
|
||||
#include "decode_slice.h"
|
||||
#include "error_concealment.h"
|
||||
#include "mem_align.h"
|
||||
#include "memory_align.h"
|
||||
|
||||
namespace WelsDec {
|
||||
|
||||
@@ -67,13 +67,13 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons
|
||||
return 1;
|
||||
}
|
||||
|
||||
pPicBuf = (PPicBuff)WelsMalloc (sizeof (SPicBuff), "PPicBuff");
|
||||
pPicBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff");
|
||||
|
||||
if (NULL == pPicBuf) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
pPicBuf->ppPic = (PPicture*)WelsMalloc (kiSize * sizeof (PPicture), "PPicture*");
|
||||
pPicBuf->ppPic = (PPicture*)WelsMallocz (kiSize * sizeof (PPicture), "PPicture*");
|
||||
|
||||
if (NULL == pPicBuf->ppPic) {
|
||||
pPicBuf->iCapacity = 0;
|
||||
@@ -109,13 +109,13 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co
|
||||
return 1;
|
||||
}
|
||||
|
||||
pPicNewBuf = (PPicBuff)WelsMalloc (sizeof (SPicBuff), "PPicBuff");
|
||||
pPicNewBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff");
|
||||
|
||||
if (NULL == pPicNewBuf) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
pPicNewBuf->ppPic = (PPicture*)WelsMalloc (kiNewSize * sizeof (PPicture), "PPicture*");
|
||||
pPicNewBuf->ppPic = (PPicture*)WelsMallocz (kiNewSize * sizeof (PPicture), "PPicture*");
|
||||
|
||||
if (NULL == pPicNewBuf->ppPic) {
|
||||
pPicNewBuf->iCapacity = 0;
|
||||
@@ -171,13 +171,13 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co
|
||||
return 1;
|
||||
}
|
||||
|
||||
pPicNewBuf = (PPicBuff)WelsMalloc (sizeof (SPicBuff), "PPicBuff");
|
||||
pPicNewBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff");
|
||||
|
||||
if (NULL == pPicNewBuf) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
pPicNewBuf->ppPic = (PPicture*)WelsMalloc (kiNewSize * sizeof (PPicture), "PPicture*");
|
||||
pPicNewBuf->ppPic = (PPicture*)WelsMallocz (kiNewSize * sizeof (PPicture), "PPicture*");
|
||||
|
||||
if (NULL == pPicNewBuf->ppPic) {
|
||||
pPicNewBuf->iCapacity = 0;
|
||||
@@ -306,10 +306,20 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) {
|
||||
pCtx->pPicBuff[LIST_1] = NULL;
|
||||
|
||||
pCtx->bAvcBasedFlag = true;
|
||||
pCtx->eErrorConMethod = ERROR_CON_SLICE_COPY_CROSS_IDR_FREEZE_RES_CHANGE;
|
||||
pCtx->eErrorConMethod = ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE;
|
||||
pCtx->pPreviousDecodedPictureInDpb = NULL;
|
||||
pCtx->sDecoderStatistics.iAvgLumaQp = -1;
|
||||
|
||||
pCtx->bSpsLatePps = false;
|
||||
pCtx->bUseScalingList = false;
|
||||
pCtx->iSpsErrorIgnored = 0;
|
||||
pCtx->iSubSpsErrorIgnored = 0;
|
||||
pCtx->iPpsErrorIgnored = 0;
|
||||
pCtx->iPPSInvalidNum = 0;
|
||||
pCtx->iPPSLastInvalidId = -1;
|
||||
pCtx->iSPSInvalidNum = 0;
|
||||
pCtx->iSPSLastInvalidId = -1;
|
||||
pCtx->iSubSPSInvalidNum = 0;
|
||||
pCtx->iSubSPSLastInvalidId = -1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -415,8 +425,8 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const
|
||||
pCtx->pDec = NULL; // need prefetch a new pic due to spatial size changed
|
||||
|
||||
if (pCtx->pCabacDecEngine == NULL)
|
||||
pCtx->pCabacDecEngine = (SWelsCabacDecEngine*) WelsMalloc (sizeof (SWelsCabacDecEngine), "pCtx->pCabacDecEngine");
|
||||
|
||||
pCtx->pCabacDecEngine = (SWelsCabacDecEngine*) WelsMallocz (sizeof (SWelsCabacDecEngine), "pCtx->pCabacDecEngine");
|
||||
WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY, (NULL == pCtx->pCabacDecEngine))
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
@@ -457,7 +467,6 @@ int32_t WelsOpenDecoder (PWelsDecoderContext pCtx) {
|
||||
//initial MC function pointer--
|
||||
int iRet = ERR_NONE;
|
||||
InitMcFunc (& (pCtx->sMcFunc), pCtx->uiCpuFlag);
|
||||
InitErrorCon (pCtx);
|
||||
|
||||
InitExpandPictureFunc (& (pCtx->sExpandPicFunc), pCtx->uiCpuFlag);
|
||||
AssignFuncPointerForRec (pCtx);
|
||||
@@ -507,20 +516,23 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa
|
||||
if (NULL == pCtx || NULL == kpParam)
|
||||
return 1;
|
||||
|
||||
pCtx->pParam = (SDecodingParam*)WelsMalloc (sizeof (SDecodingParam), "SDecodingParam");
|
||||
pCtx->pParam = (SDecodingParam*)WelsMallocz (sizeof (SDecodingParam), "SDecodingParam");
|
||||
|
||||
if (NULL == pCtx->pParam)
|
||||
return 1;
|
||||
|
||||
memcpy (pCtx->pParam, kpParam, sizeof (SDecodingParam));
|
||||
pCtx->eOutputColorFormat = pCtx->pParam->eOutputColorFormat;
|
||||
int32_t iRet = DecoderSetCsp (pCtx, pCtx->pParam->eOutputColorFormat);
|
||||
if (iRet)
|
||||
return iRet;
|
||||
if (!pCtx->bParseOnly) {
|
||||
int32_t iRet = DecoderSetCsp (pCtx, pCtx->pParam->eOutputColorFormat);
|
||||
if (iRet)
|
||||
return iRet;
|
||||
}
|
||||
pCtx->eErrorConMethod = pCtx->pParam->eEcActiveIdc;
|
||||
|
||||
if (pCtx->bParseOnly) //parse only, disable EC method
|
||||
pCtx->eErrorConMethod = ERROR_CON_DISABLE;
|
||||
InitErrorCon (pCtx);
|
||||
|
||||
if (VIDEO_BITSTREAM_SVC == pCtx->pParam->sVideoProperty.eVideoBsType ||
|
||||
VIDEO_BITSTREAM_AVC == pCtx->pParam->sVideoProperty.eVideoBsType) {
|
||||
@@ -657,25 +669,24 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in
|
||||
0; // set 4 reserved bytes to zero
|
||||
pNalPayload = ParseNalHeader (pCtx, &pCtx->sCurNalHead, pDstNal, iDstIdx, pSrcNal - 3, iSrcIdx + 3, &iConsumedBytes);
|
||||
if (pNalPayload) { //parse correct
|
||||
if (IS_VCL_NAL (pCtx->sCurNalHead.eNalUnitType, 1)) {
|
||||
CheckAndFinishLastPic (pCtx, ppDst, pDstBufInfo);
|
||||
}
|
||||
if (IS_PARAM_SETS_NALS (pCtx->sCurNalHead.eNalUnitType)) {
|
||||
iRet = ParseNonVclNal (pCtx, pNalPayload, iDstIdx - iConsumedBytes, pSrcNal - 3, iSrcIdx + 3);
|
||||
}
|
||||
if (pCtx->bAuReadyFlag) {
|
||||
CheckAndFinishLastPic (pCtx, ppDst, pDstBufInfo);
|
||||
if (pCtx->bAuReadyFlag && pCtx->pAccessUnitList->uiAvailUnitsNum != 0) {
|
||||
ConstructAccessUnit (pCtx, ppDst, pDstBufInfo);
|
||||
}
|
||||
}
|
||||
DecodeFinishUpdate (pCtx);
|
||||
|
||||
if ((dsOutOfMemory | dsNoParamSets) & pCtx->iErrorCode) {
|
||||
if ((dsOutOfMemory | dsNoParamSets) & pCtx->iErrorCode) {
|
||||
#ifdef LONG_TERM_REF
|
||||
pCtx->bParamSetsLostFlag = true;
|
||||
pCtx->bParamSetsLostFlag = true;
|
||||
#else
|
||||
pCtx->bReferenceLostAtT0Flag = true;
|
||||
pCtx->bReferenceLostAtT0Flag = true;
|
||||
#endif
|
||||
if (dsOutOfMemory & pCtx->iErrorCode) {
|
||||
return pCtx->iErrorCode;
|
||||
}
|
||||
}
|
||||
if (dsOutOfMemory & pCtx->iErrorCode) {
|
||||
return pCtx->iErrorCode;
|
||||
}
|
||||
}
|
||||
if (iRet) {
|
||||
@@ -713,27 +724,27 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in
|
||||
iConsumedBytes = 0;
|
||||
pDstNal[iDstIdx] = pDstNal[iDstIdx + 1] = pDstNal[iDstIdx + 2] = pDstNal[iDstIdx + 3] =
|
||||
0; // set 4 reserved bytes to zero
|
||||
pRawData->pCurPos = pDstNal + iDstIdx + 4; //init, increase 4 reserved zero bytes, used to store the next NAL
|
||||
pNalPayload = ParseNalHeader (pCtx, &pCtx->sCurNalHead, pDstNal, iDstIdx, pSrcNal - 3, iSrcIdx + 3, &iConsumedBytes);
|
||||
if (pNalPayload) { //parse correct
|
||||
if (IS_VCL_NAL (pCtx->sCurNalHead.eNalUnitType, 1)) {
|
||||
CheckAndFinishLastPic (pCtx, ppDst, pDstBufInfo);
|
||||
}
|
||||
if (IS_PARAM_SETS_NALS (pCtx->sCurNalHead.eNalUnitType)) {
|
||||
iRet = ParseNonVclNal (pCtx, pNalPayload, iDstIdx - iConsumedBytes, pSrcNal - 3, iSrcIdx + 3);
|
||||
}
|
||||
if (pCtx->bAuReadyFlag) {
|
||||
CheckAndFinishLastPic (pCtx, ppDst, pDstBufInfo);
|
||||
if (pCtx->bAuReadyFlag && pCtx->pAccessUnitList->uiAvailUnitsNum != 0) {
|
||||
ConstructAccessUnit (pCtx, ppDst, pDstBufInfo);
|
||||
|
||||
if ((dsOutOfMemory | dsNoParamSets) & pCtx->iErrorCode) {
|
||||
#ifdef LONG_TERM_REF
|
||||
pCtx->bParamSetsLostFlag = true;
|
||||
#else
|
||||
pCtx->bReferenceLostAtT0Flag = true;
|
||||
#endif
|
||||
return pCtx->iErrorCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
DecodeFinishUpdate (pCtx);
|
||||
|
||||
if ((dsOutOfMemory | dsNoParamSets) & pCtx->iErrorCode) {
|
||||
#ifdef LONG_TERM_REF
|
||||
pCtx->bParamSetsLostFlag = true;
|
||||
#else
|
||||
pCtx->bReferenceLostAtT0Flag = true;
|
||||
#endif
|
||||
return pCtx->iErrorCode;
|
||||
}
|
||||
if (iRet) {
|
||||
iRet = 0;
|
||||
if (dsNoParamSets & pCtx->iErrorCode) {
|
||||
@@ -745,7 +756,6 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in
|
||||
}
|
||||
return pCtx->iErrorCode;
|
||||
}
|
||||
pRawData->pCurPos = pDstNal + iDstIdx + 4; //init, increase 4 reserved zero bytes, used to store the next NAL
|
||||
} else { /* no supplementary picture payload input, but stored a picture */
|
||||
PAccessUnit pCurAu =
|
||||
pCtx->pAccessUnitList; // current access unit, it will never point to NULL after decode's successful initialization
|
||||
@@ -756,15 +766,16 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in
|
||||
pCtx->pAccessUnitList->uiEndPos = pCtx->pAccessUnitList->uiAvailUnitsNum - 1;
|
||||
|
||||
ConstructAccessUnit (pCtx, ppDst, pDstBufInfo);
|
||||
}
|
||||
DecodeFinishUpdate (pCtx);
|
||||
|
||||
if ((dsOutOfMemory | dsNoParamSets) & pCtx->iErrorCode) {
|
||||
if ((dsOutOfMemory | dsNoParamSets) & pCtx->iErrorCode) {
|
||||
#ifdef LONG_TERM_REF
|
||||
pCtx->bParamSetsLostFlag = true;
|
||||
pCtx->bParamSetsLostFlag = true;
|
||||
#else
|
||||
pCtx->bReferenceLostAtT0Flag = true;
|
||||
pCtx->bReferenceLostAtT0Flag = true;
|
||||
#endif
|
||||
return pCtx->iErrorCode;
|
||||
}
|
||||
return pCtx->iErrorCode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -989,8 +1000,8 @@ void UpdateDecStatNoFreezingInfo (PWelsDecoderContext pCtx) {
|
||||
ResetDecStatNums (pDecStat);
|
||||
pDecStat->iAvgLumaQp = iTotalQp;
|
||||
} else
|
||||
pDecStat->iAvgLumaQp = (uint64_t) (pDecStat->iAvgLumaQp * pDecStat->uiDecodedFrameCount + iTotalQp) /
|
||||
(pDecStat->uiDecodedFrameCount + 1);
|
||||
pDecStat->iAvgLumaQp = (int) ((uint64_t) (pDecStat->iAvgLumaQp * pDecStat->uiDecodedFrameCount + iTotalQp) /
|
||||
(pDecStat->uiDecodedFrameCount + 1));
|
||||
|
||||
//update IDR number
|
||||
if (pCurDq->sLayerInfo.sNalHeaderExt.bIdrFlag) {
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include "expand_pic.h"
|
||||
#include "decoder.h"
|
||||
#include "decode_mb_aux.h"
|
||||
#include "mem_align.h"
|
||||
#include "memory_align.h"
|
||||
#include "error_concealment.h"
|
||||
|
||||
namespace WelsDec {
|
||||
@@ -72,6 +72,79 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t
|
||||
}
|
||||
}
|
||||
|
||||
if (pCtx->bParseOnly) { //should exit for parse only to prevent access NULL pDstInfo
|
||||
PAccessUnit pCurAu = pCtx->pAccessUnitList;
|
||||
static bool bFirstIDR = true;
|
||||
if (dsErrorFree == pCtx->iErrorCode) { //correct decoding, add to data buffer
|
||||
SParserBsInfo* pParser = pCtx->pParserBsInfo;
|
||||
SNalUnit* pCurNal = NULL;
|
||||
int32_t iTotalNalLen = 0;
|
||||
int32_t iNalLen = 0;
|
||||
int32_t iNum = 0;
|
||||
while (iNum < pParser->iNalNum) {
|
||||
iTotalNalLen += pParser->iNalLenInByte[iNum++];
|
||||
}
|
||||
uint8_t* pDstBuf = pParser->pDstBuff + iTotalNalLen;
|
||||
int32_t iIdx = pCurAu->uiStartPos;
|
||||
int32_t iEndIdx = pCurAu->uiEndPos;
|
||||
uint8_t* pNalBs = NULL;
|
||||
pParser->uiOutBsTimeStamp = (pCurAu->pNalUnitsList [iIdx]) ? pCurAu->pNalUnitsList [iIdx]->uiTimeStamp : 0;
|
||||
//pParser->iNalNum = 0;
|
||||
pParser->iSpsWidthInPixel = (pCtx->pSps->iMbWidth << 4);
|
||||
pParser->iSpsHeightInPixel = (pCtx->pSps->iMbHeight << 4);
|
||||
|
||||
if (pCurAu->pNalUnitsList [iIdx]->sNalHeaderExt.bIdrFlag) { //IDR
|
||||
if (bFirstIDR) { //add required sps/pps
|
||||
bool bSubSps = (NAL_UNIT_CODED_SLICE_EXT == pCurAu->pNalUnitsList [iIdx]->sNalHeaderExt.sNalUnitHeader.eNalUnitType);
|
||||
SSpsBsInfo* pSpsBs = NULL;
|
||||
SPpsBsInfo* pPpsBs = NULL;
|
||||
int32_t iSpsId = pCtx->pSps->iSpsId;
|
||||
int32_t iPpsId = pCtx->pPps->iPpsId;
|
||||
pCtx->bParamSetsLostFlag = false;
|
||||
//find required sps, pps and write into dst buff
|
||||
pSpsBs = bSubSps ? &pCtx->sSubsetSpsBsInfo [iSpsId] : &pCtx->sSpsBsInfo [iSpsId];
|
||||
memcpy (pDstBuf, pSpsBs->pSpsBsBuf, pSpsBs->uiSpsBsLen);
|
||||
pParser->iNalLenInByte [pParser->iNalNum ++] = pSpsBs->uiSpsBsLen;
|
||||
pCtx->iNalLenInByte[pCtx->iNalNum ++] = pSpsBs->uiSpsBsLen;
|
||||
pDstBuf += pSpsBs->uiSpsBsLen;
|
||||
pPpsBs = &pCtx->sPpsBsInfo [iPpsId];
|
||||
memcpy (pDstBuf, pPpsBs->pPpsBsBuf, pPpsBs->uiPpsBsLen);
|
||||
pParser->iNalLenInByte [pParser->iNalNum ++] = pPpsBs->uiPpsBsLen;
|
||||
pDstBuf += pPpsBs->uiPpsBsLen;
|
||||
bFirstIDR = false;
|
||||
}
|
||||
} else { //IDR required SPS, PPS
|
||||
bFirstIDR = true;
|
||||
}
|
||||
//then VCL data re-write
|
||||
while (iIdx <= iEndIdx) {
|
||||
pCurNal = pCurAu->pNalUnitsList [iIdx ++];
|
||||
iNalLen = pCurNal->sNalData.sVclNal.iNalLength;
|
||||
pNalBs = pCurNal->sNalData.sVclNal.pNalPos;
|
||||
pParser->iNalLenInByte [pParser->iNalNum ++] = iNalLen;
|
||||
memcpy (pDstBuf, pNalBs, iNalLen);
|
||||
pDstBuf += iNalLen;
|
||||
}
|
||||
if (pCtx->iTotalNumMbRec == kiTotalNumMbInCurLayer) { //frame complete
|
||||
pCtx->iTotalNumMbRec = 0;
|
||||
pCtx->bFramePending = false;
|
||||
} else if (pCtx->iTotalNumMbRec != 0) { //frame incomplete
|
||||
pCtx->bFramePending = true;
|
||||
pCtx->pDec->bIsComplete = false;
|
||||
pCtx->iErrorCode |= dsFramePending;
|
||||
return -1;
|
||||
//pCtx->pParserBsInfo->iNalNum = 0;
|
||||
}
|
||||
} else { //error
|
||||
pCtx->pParserBsInfo->uiOutBsTimeStamp = 0;
|
||||
pCtx->pParserBsInfo->iNalNum = 0;
|
||||
pCtx->pParserBsInfo->iSpsWidthInPixel = 0;
|
||||
pCtx->pParserBsInfo->iSpsHeightInPixel = 0;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (pCtx->iTotalNumMbRec != kiTotalNumMbInCurLayer) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG,
|
||||
"DecodeFrameConstruction(): iTotalNumMbRec:%d, total_num_mb_sps:%d, cur_layer_mb_width:%d, cur_layer_mb_height:%d ",
|
||||
@@ -170,6 +243,78 @@ inline int32_t WelsDecodeConstructSlice (PWelsDecoderContext pCtx, PNalUnit pCu
|
||||
return iRet;
|
||||
}
|
||||
|
||||
int32_t ParsePredWeightedTable (PBitStringAux pBs, PSliceHeader pSh) {
|
||||
uint32_t uiCode;
|
||||
int32_t iList = 0;
|
||||
int32_t iCode;
|
||||
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode));
|
||||
WELS_CHECK_SE_BOTH_ERROR_NOLOG (uiCode, 0, 7, "luma_log2_weight_denom",
|
||||
GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_LUMA_LOG2_WEIGHT_DENOM));
|
||||
pSh->sPredWeightTable.uiLumaLog2WeightDenom = uiCode;
|
||||
if (pSh->pSps->uiChromaArrayType != 0) {
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode));
|
||||
WELS_CHECK_SE_BOTH_ERROR_NOLOG (uiCode, 0, 7, "chroma_log2_weight_denom",
|
||||
GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_CHROMA_LOG2_WEIGHT_DENOM));
|
||||
pSh->sPredWeightTable.uiChromaLog2WeightDenom = uiCode;
|
||||
}
|
||||
|
||||
|
||||
do {
|
||||
|
||||
for (int i = 0; i < pSh->uiRefCount[iList]; i++) {
|
||||
//luma
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode));
|
||||
if (!!uiCode) {
|
||||
|
||||
WELS_READ_VERIFY (BsGetSe (pBs, &iCode));
|
||||
WELS_CHECK_SE_BOTH_ERROR_NOLOG (iCode, -128, 127, "luma_weight",
|
||||
GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_LUMA_WEIGHT));
|
||||
pSh->sPredWeightTable.sPredList[iList].iLumaWeight[i] = iCode;
|
||||
|
||||
WELS_READ_VERIFY (BsGetSe (pBs, &iCode));
|
||||
WELS_CHECK_SE_BOTH_ERROR_NOLOG (iCode, -128, 127, "luma_offset",
|
||||
GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_LUMA_OFFSET));
|
||||
pSh->sPredWeightTable.sPredList[iList].iLumaOffset[i] = iCode;
|
||||
} else {
|
||||
pSh->sPredWeightTable.sPredList[iList].iLumaWeight[i] = 1 << (pSh->sPredWeightTable.uiLumaLog2WeightDenom);
|
||||
pSh->sPredWeightTable.sPredList[iList].iLumaOffset[i] = 0;
|
||||
|
||||
}
|
||||
//chroma
|
||||
if (pSh->pSps->uiChromaArrayType == 0)
|
||||
continue;
|
||||
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode));
|
||||
if (!!uiCode) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
|
||||
|
||||
WELS_READ_VERIFY (BsGetSe (pBs, &iCode));
|
||||
WELS_CHECK_SE_BOTH_ERROR_NOLOG (iCode, -128, 127, "chroma_weight",
|
||||
GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_CHROMA_WEIGHT));
|
||||
pSh->sPredWeightTable.sPredList[iList].iChromaWeight[i][j] = iCode;
|
||||
|
||||
WELS_READ_VERIFY (BsGetSe (pBs, &iCode));
|
||||
WELS_CHECK_SE_BOTH_ERROR_NOLOG (iCode, -128, 127, "chroma_offset",
|
||||
GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_CHROMA_OFFSET));
|
||||
pSh->sPredWeightTable.sPredList[iList].iChromaOffset[i][j] = iCode;
|
||||
}
|
||||
} else {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
|
||||
|
||||
pSh->sPredWeightTable.sPredList[iList].iChromaWeight[i][j] = 1 << (pSh->sPredWeightTable.uiChromaLog2WeightDenom);
|
||||
pSh->sPredWeightTable.sPredList[iList].iChromaOffset[i][j] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
++iList;
|
||||
} while (iList < LIST_1);//TODO: SUPPORT LIST_A
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Predeclared function routines ..
|
||||
*/
|
||||
@@ -313,14 +458,26 @@ int32_t InitBsBuffer (PWelsDecoderContext pCtx) {
|
||||
return ERR_INFO_INVALID_PTR;
|
||||
|
||||
pCtx->iMaxBsBufferSizeInByte = MIN_ACCESS_UNIT_CAPACITY * MAX_BUFFERED_NUM;
|
||||
if ((pCtx->sRawData.pHead = static_cast<uint8_t*> (WelsMalloc (pCtx->iMaxBsBufferSizeInByte,
|
||||
if ((pCtx->sRawData.pHead = static_cast<uint8_t*> (WelsMallocz (pCtx->iMaxBsBufferSizeInByte,
|
||||
"pCtx->sRawData.pHead"))) == NULL) {
|
||||
return ERR_INFO_OUT_OF_MEMORY;
|
||||
}
|
||||
pCtx->sRawData.pStartPos = pCtx->sRawData.pCurPos = pCtx->sRawData.pHead;
|
||||
pCtx->sRawData.pEnd = pCtx->sRawData.pHead + pCtx->iMaxBsBufferSizeInByte;
|
||||
if (pCtx->bParseOnly) {
|
||||
if ((pCtx->sSavedData.pHead = static_cast<uint8_t*> (WelsMalloc (pCtx->iMaxBsBufferSizeInByte,
|
||||
pCtx->pParserBsInfo = static_cast<SParserBsInfo*> (WelsMallocz (sizeof (SParserBsInfo), "pCtx->pParserBsInfo"));
|
||||
if (pCtx->pParserBsInfo == NULL) {
|
||||
return ERR_INFO_OUT_OF_MEMORY;
|
||||
}
|
||||
memset (pCtx->pParserBsInfo, 0, sizeof (SParserBsInfo));
|
||||
pCtx->pParserBsInfo->pDstBuff = static_cast<uint8_t*> (WelsMallocz (MAX_ACCESS_UNIT_CAPACITY * sizeof (uint8_t),
|
||||
"pCtx->pParserBsInfo->pDstBuff"));
|
||||
if (pCtx->pParserBsInfo->pDstBuff == NULL) {
|
||||
return ERR_INFO_OUT_OF_MEMORY;
|
||||
}
|
||||
memset (pCtx->pParserBsInfo->pDstBuff, 0, MAX_ACCESS_UNIT_CAPACITY * sizeof (uint8_t));
|
||||
|
||||
if ((pCtx->sSavedData.pHead = static_cast<uint8_t*> (WelsMallocz (pCtx->iMaxBsBufferSizeInByte,
|
||||
"pCtx->sSavedData.pHead"))) == NULL) {
|
||||
return ERR_INFO_OUT_OF_MEMORY;
|
||||
}
|
||||
@@ -336,7 +493,7 @@ int32_t ExpandBsBuffer (PWelsDecoderContext pCtx, const int kiSrcLen) {
|
||||
int32_t iExpandStepShift = 1;
|
||||
int32_t iNewBuffLen = WELS_MAX ((kiSrcLen * MAX_BUFFERED_NUM), (pCtx->iMaxBsBufferSizeInByte << iExpandStepShift));
|
||||
//allocate new bs buffer
|
||||
uint8_t* pNewBsBuff = static_cast<uint8_t*> (WelsMalloc (iNewBuffLen, "pCtx->sRawData.pHead"));
|
||||
uint8_t* pNewBsBuff = static_cast<uint8_t*> (WelsMallocz (iNewBuffLen, "pCtx->sRawData.pHead"));
|
||||
if (pNewBsBuff == NULL)
|
||||
return ERR_INFO_OUT_OF_MEMORY;
|
||||
|
||||
@@ -425,15 +582,24 @@ void WelsFreeMemory (PWelsDecoderContext pCtx) {
|
||||
pCtx->sRawData.pEnd = NULL;
|
||||
pCtx->sRawData.pStartPos = NULL;
|
||||
pCtx->sRawData.pCurPos = NULL;
|
||||
if (pCtx->sSavedData.pHead) {
|
||||
WelsFree (pCtx->sSavedData.pHead, "pCtx->sSavedData->pHead");
|
||||
if (pCtx->bParseOnly) {
|
||||
if (pCtx->sSavedData.pHead) {
|
||||
WelsFree (pCtx->sSavedData.pHead, "pCtx->sSavedData->pHead");
|
||||
}
|
||||
pCtx->sSavedData.pHead = NULL;
|
||||
pCtx->sSavedData.pEnd = NULL;
|
||||
pCtx->sSavedData.pStartPos = NULL;
|
||||
pCtx->sSavedData.pCurPos = NULL;
|
||||
if (pCtx->pParserBsInfo) {
|
||||
if (pCtx->pParserBsInfo->pDstBuff) {
|
||||
WelsFree (pCtx->pParserBsInfo->pDstBuff, "pCtx->pParserBsInfo->pDstBuff");
|
||||
pCtx->pParserBsInfo->pDstBuff = NULL;
|
||||
}
|
||||
WelsFree (pCtx->pParserBsInfo, "pCtx->pParserBsInfo");
|
||||
pCtx->pParserBsInfo = NULL;
|
||||
}
|
||||
}
|
||||
pCtx->sSavedData.pHead = NULL;
|
||||
pCtx->sSavedData.pEnd = NULL;
|
||||
pCtx->sSavedData.pStartPos = NULL;
|
||||
pCtx->sSavedData.pCurPos = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* DecodeNalHeaderExt
|
||||
* Trigger condition: NAL_UNIT_TYPE = NAL_UNIT_PREFIX or NAL_UNIT_CODED_SLICE_EXT
|
||||
@@ -557,15 +723,21 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
|
||||
|
||||
//add check PPS available here
|
||||
if (pCtx->bPpsAvailFlags[iPpsId] == false) {
|
||||
WelsLog (pLogCtx, WELS_LOG_ERROR, "PPS id is invalid!");
|
||||
pCtx->sDecoderStatistics.iPpsReportErrorNum++;
|
||||
if (pCtx->iPPSLastInvalidId != iPpsId) {
|
||||
WelsLog (pLogCtx, WELS_LOG_ERROR, "PPS id (%d) is invalid, previous id (%d) error ignored (%d)!", iPpsId,
|
||||
pCtx->iPPSLastInvalidId, pCtx->iPPSInvalidNum);
|
||||
pCtx->iPPSLastInvalidId = iPpsId;
|
||||
pCtx->iPPSInvalidNum = 0;
|
||||
} else {
|
||||
pCtx->iPPSInvalidNum++;
|
||||
}
|
||||
pCtx->iErrorCode |= dsNoParamSets;
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_PPS_ID);
|
||||
}
|
||||
pCtx->iPPSLastInvalidId = -1;
|
||||
|
||||
if (pCtx->iOverwriteFlags & OVERWRITE_PPS)
|
||||
pPps = &pCtx->sPpsBuffer[MAX_PPS_COUNT];
|
||||
else
|
||||
pPps = &pCtx->sPpsBuffer[iPpsId];
|
||||
pPps = &pCtx->sPpsBuffer[iPpsId];
|
||||
|
||||
if (pPps->uiNumSliceGroups == 0) {
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING, "Invalid PPS referenced");
|
||||
@@ -574,26 +746,38 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
|
||||
}
|
||||
|
||||
if (kbExtensionFlag) {
|
||||
if (pCtx->iOverwriteFlags & OVERWRITE_SUBSETSPS)
|
||||
pSubsetSps = &pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT];
|
||||
else
|
||||
pSubsetSps = &pCtx->sSubsetSpsBuffer[pPps->iSpsId];
|
||||
pSubsetSps = &pCtx->sSubsetSpsBuffer[pPps->iSpsId];
|
||||
pSps = &pSubsetSps->sSps;
|
||||
if (pCtx->bSubspsAvailFlags[pPps->iSpsId] == false) {
|
||||
WelsLog (pLogCtx, WELS_LOG_ERROR, "SPS id is invalid!");
|
||||
pCtx->sDecoderStatistics.iSubSpsReportErrorNum++;
|
||||
if (pCtx->iSubSPSLastInvalidId != pPps->iSpsId) {
|
||||
WelsLog (pLogCtx, WELS_LOG_ERROR, "Sub SPS id (%d) is invalid, previous id (%d) error ignored (%d)!", pPps->iSpsId,
|
||||
pCtx->iSubSPSLastInvalidId, pCtx->iSubSPSInvalidNum);
|
||||
pCtx->iSubSPSLastInvalidId = pPps->iSpsId;
|
||||
pCtx->iSubSPSInvalidNum = 0;
|
||||
} else {
|
||||
pCtx->iSubSPSInvalidNum++;
|
||||
}
|
||||
pCtx->iErrorCode |= dsNoParamSets;
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SPS_ID);
|
||||
}
|
||||
pCtx->iSubSPSLastInvalidId = -1;
|
||||
} else {
|
||||
if (pCtx->bSpsAvailFlags[pPps->iSpsId] == false) {
|
||||
WelsLog (pLogCtx, WELS_LOG_ERROR, "SPS id is invalid!");
|
||||
pCtx->sDecoderStatistics.iSpsReportErrorNum++;
|
||||
if (pCtx->iSPSLastInvalidId != pPps->iSpsId) {
|
||||
WelsLog (pLogCtx, WELS_LOG_ERROR, "SPS id (%d) is invalid, previous id (%d) error ignored (%d)!", pPps->iSpsId,
|
||||
pCtx->iSPSLastInvalidId, pCtx->iSPSInvalidNum);
|
||||
pCtx->iSPSLastInvalidId = pPps->iSpsId;
|
||||
pCtx->iSPSInvalidNum = 0;
|
||||
} else {
|
||||
pCtx->iSPSInvalidNum++;
|
||||
}
|
||||
pCtx->iErrorCode |= dsNoParamSets;
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SPS_ID);
|
||||
}
|
||||
if (pCtx->iOverwriteFlags & OVERWRITE_SPS)
|
||||
pSps = &pCtx->sSpsBuffer[MAX_SPS_COUNT];
|
||||
else
|
||||
pSps = &pCtx->sSpsBuffer[pPps->iSpsId];
|
||||
pCtx->iSPSLastInvalidId = -1;
|
||||
pSps = &pCtx->sSpsBuffer[pPps->iSpsId];
|
||||
}
|
||||
pSliceHead->iPpsId = iPpsId;
|
||||
pSliceHead->iSpsId = pPps->iSpsId;
|
||||
@@ -701,6 +885,14 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
|
||||
return iRet;
|
||||
}
|
||||
|
||||
if (pPps->bWeightedPredFlag && (uiSliceType == P_SLICE)) {
|
||||
iRet = ParsePredWeightedTable (pBs, pSliceHead);
|
||||
if (iRet != ERR_NONE) {
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING, "invalid weighted prediction syntaxs!");
|
||||
return iRet;
|
||||
}
|
||||
}
|
||||
|
||||
if (kbExtensionFlag) {
|
||||
if (pNalHeaderExt->iNoInterLayerPredFlag || pNalHeaderExt->uiQualityId > 0)
|
||||
pSliceHeadExt->bBasePredWeightTableFlag = false;
|
||||
@@ -1031,56 +1223,57 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid
|
||||
UninitialDqLayersContext (pCtx);
|
||||
|
||||
do {
|
||||
PDqLayer pDq = (PDqLayer)WelsMalloc (sizeof (SDqLayer), "PDqLayer");
|
||||
PDqLayer pDq = (PDqLayer)WelsMallocz (sizeof (SDqLayer), "PDqLayer");
|
||||
|
||||
if (pDq == NULL)
|
||||
return ERR_INFO_OUT_OF_MEMORY;
|
||||
|
||||
memset (pDq, 0, sizeof (SDqLayer));
|
||||
|
||||
pCtx->sMb.pMbType[i] = (int8_t*)WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
|
||||
pCtx->sMb.pMbType[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
|
||||
"pCtx->sMb.pMbType[]");
|
||||
pCtx->sMb.pMv[i][0] = (int16_t (*)[16][2])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
|
||||
pCtx->sMb.pMv[i][0] = (int16_t (*)[16][2])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
|
||||
int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMv[][]");
|
||||
pCtx->sMb.pRefIndex[i][0] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
|
||||
pCtx->sMb.pRefIndex[i][0] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight *
|
||||
sizeof (
|
||||
int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pRefIndex[][]");
|
||||
pCtx->sMb.pLumaQp[i] = (int8_t*)WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
|
||||
pCtx->sMb.pLumaQp[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
|
||||
"pCtx->sMb.pLumaQp[]");
|
||||
pCtx->sMb.pChromaQp[i] = (int8_t*)WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
|
||||
pCtx->sMb.pChromaQp[i] = (int8_t (*)[2])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 2,
|
||||
"pCtx->sMb.pChromaQp[]");
|
||||
pCtx->sMb.pMvd[i][0] = (int16_t (*)[16][2])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
|
||||
pCtx->sMb.pMvd[i][0] = (int16_t (*)[16][2])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
|
||||
int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMvd[][]");
|
||||
pCtx->sMb.pCbfDc[i] = (uint8_t*)WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (uint8_t),
|
||||
pCtx->sMb.pCbfDc[i] = (uint8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (uint8_t),
|
||||
"pCtx->sMb.pCbfDc[]");
|
||||
pCtx->sMb.pNzc[i] = (int8_t (*)[24])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24,
|
||||
pCtx->sMb.pNzc[i] = (int8_t (*)[24])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24,
|
||||
"pCtx->sMb.pNzc[]");
|
||||
pCtx->sMb.pNzcRs[i] = (int8_t (*)[24])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24,
|
||||
pCtx->sMb.pNzcRs[i] = (int8_t (*)[24])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24,
|
||||
"pCtx->sMb.pNzcRs[]");
|
||||
pCtx->sMb.pScaledTCoeff[i] = (int16_t (*)[MB_COEFF_LIST_SIZE])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight *
|
||||
pCtx->sMb.pScaledTCoeff[i] = (int16_t (*)[MB_COEFF_LIST_SIZE])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight *
|
||||
sizeof (int16_t) * MB_COEFF_LIST_SIZE, "pCtx->sMb.pScaledTCoeff[]");
|
||||
pCtx->sMb.pIntraPredMode[i] = (int8_t (*)[8])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 8,
|
||||
pCtx->sMb.pIntraPredMode[i] = (int8_t (*)[8])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
|
||||
int8_t) * 8,
|
||||
"pCtx->sMb.pIntraPredMode[]");
|
||||
pCtx->sMb.pIntra4x4FinalMode[i] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight *
|
||||
pCtx->sMb.pIntra4x4FinalMode[i] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight *
|
||||
sizeof (int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pIntra4x4FinalMode[]");
|
||||
pCtx->sMb.pChromaPredMode[i] = (int8_t*)WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
|
||||
pCtx->sMb.pChromaPredMode[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
|
||||
"pCtx->sMb.pChromaPredMode[]");
|
||||
pCtx->sMb.pCbp[i] = (int8_t*)WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
|
||||
pCtx->sMb.pCbp[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
|
||||
"pCtx->sMb.pCbp[]");
|
||||
pCtx->sMb.pSubMbType[i] = (int8_t (*)[MB_PARTITION_SIZE])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
|
||||
pCtx->sMb.pSubMbType[i] = (int8_t (*)[MB_PARTITION_SIZE])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight *
|
||||
sizeof (
|
||||
int8_t) * MB_PARTITION_SIZE, "pCtx->sMb.pSubMbType[]");
|
||||
pCtx->sMb.pSliceIdc[i] = (int32_t*) WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t),
|
||||
pCtx->sMb.pSliceIdc[i] = (int32_t*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t),
|
||||
"pCtx->sMb.pSliceIdc[]"); // using int32_t for slice_idc, 4/21/2010
|
||||
if (pCtx->sMb.pSliceIdc[i] != NULL)
|
||||
memset (pCtx->sMb.pSliceIdc[i], 0xff, (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t)));
|
||||
pCtx->sMb.pResidualPredFlag[i] = (int8_t*) WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
|
||||
pCtx->sMb.pResidualPredFlag[i] = (int8_t*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
|
||||
"pCtx->sMb.pResidualPredFlag[]");
|
||||
//pCtx->sMb.pMotionPredFlag[i] = (uint8_t *) WelsMalloc(pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof(uint8_t), "pCtx->sMb.pMotionPredFlag[]");
|
||||
pCtx->sMb.pInterPredictionDoneFlag[i] = (int8_t*) WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
|
||||
//pCtx->sMb.pMotionPredFlag[i] = (uint8_t *) WelsMallocz(pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof(uint8_t), "pCtx->sMb.pMotionPredFlag[]");
|
||||
pCtx->sMb.pInterPredictionDoneFlag[i] = (int8_t*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
|
||||
int8_t), "pCtx->sMb.pInterPredictionDoneFlag[]");
|
||||
|
||||
pCtx->sMb.pMbCorrectlyDecodedFlag[i] = (bool*) WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool),
|
||||
pCtx->sMb.pMbCorrectlyDecodedFlag[i] = (bool*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool),
|
||||
"pCtx->sMb.pMbCorrectlyDecodedFlag[]");
|
||||
pCtx->sMb.pMbRefConcealedFlag[i] = (bool*) WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool),
|
||||
pCtx->sMb.pMbRefConcealedFlag[i] = (bool*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool),
|
||||
"pCtx->pMbRefConcealedFlag[]");
|
||||
|
||||
// check memory block valid due above allocated..
|
||||
@@ -1108,6 +1301,8 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid
|
||||
)
|
||||
)
|
||||
|
||||
memset (pCtx->sMb.pSliceIdc[i], 0xff, (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t)));
|
||||
|
||||
pCtx->pDqLayersList[i] = pDq;
|
||||
++ i;
|
||||
} while (i < LAYER_NUM_EXCHANGEABLE);
|
||||
@@ -1266,7 +1461,7 @@ void UninitialDqLayersContext (PWelsDecoderContext pCtx) {
|
||||
|
||||
void ResetCurrentAccessUnit (PWelsDecoderContext pCtx) {
|
||||
PAccessUnit pCurAu = pCtx->pAccessUnitList;
|
||||
|
||||
pCurAu->uiStartPos = 0;
|
||||
pCurAu->uiEndPos = 0;
|
||||
pCurAu->bCompletedAuFlag = false;
|
||||
if (pCurAu->uiActualUnitsNum > 0) {
|
||||
@@ -1311,6 +1506,7 @@ void ForceResetCurrentAccessUnit (PAccessUnit pAu) {
|
||||
else
|
||||
pAu->uiAvailUnitsNum = 0;
|
||||
pAu->uiActualUnitsNum = 0;
|
||||
pAu->uiStartPos = 0;
|
||||
pAu->uiEndPos = 0;
|
||||
pAu->bCompletedAuFlag = false;
|
||||
}
|
||||
@@ -1688,6 +1884,22 @@ static void WriteBackActiveParameters (PWelsDecoderContext pCtx) {
|
||||
}
|
||||
pCtx->iOverwriteFlags = OVERWRITE_NONE;
|
||||
}
|
||||
|
||||
/*
|
||||
* DecodeFinishUpdate
|
||||
* decoder finish decoding, update active parameter sets and new seq status
|
||||
*
|
||||
*/
|
||||
|
||||
void DecodeFinishUpdate (PWelsDecoderContext pCtx) {
|
||||
pCtx->bNewSeqBegin = false;
|
||||
WriteBackActiveParameters (pCtx);
|
||||
pCtx->bNewSeqBegin = pCtx->bNewSeqBegin || pCtx->bNextNewSeqBegin;
|
||||
pCtx->bNextNewSeqBegin = false; // reset it
|
||||
if (pCtx->bNewSeqBegin)
|
||||
ResetActiveSPSForEachLayer (pCtx);
|
||||
}
|
||||
|
||||
/*
|
||||
* ConstructAccessUnit
|
||||
* construct an access unit for given input bitstream, maybe partial NAL Unit, one or more Units are involved to
|
||||
@@ -1714,6 +1926,10 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI
|
||||
ForceResetCurrentAccessUnit (pCtx->pAccessUnitList);
|
||||
if (!pCtx->bParseOnly)
|
||||
pDstInfo->iBufferStatus = 0;
|
||||
pCtx->bNewSeqBegin = pCtx->bNewSeqBegin || pCtx->bNextNewSeqBegin;
|
||||
pCtx->bNextNewSeqBegin = false; // reset it
|
||||
if (pCtx->bNewSeqBegin)
|
||||
ResetActiveSPSForEachLayer (pCtx);
|
||||
return iErr;
|
||||
}
|
||||
|
||||
@@ -1731,65 +1947,10 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
iErr = DecodeCurrentAccessUnit (pCtx, ppDst, pDstInfo);
|
||||
|
||||
if (pCtx->bParseOnly) {
|
||||
if (dsErrorFree == pCtx->iErrorCode) {
|
||||
SParserBsInfo* pParser = pCtx->pParserBsInfo;
|
||||
uint8_t* pDstBuf = pParser->pDstBuff;
|
||||
SNalUnit* pCurNal = NULL;
|
||||
int32_t iNalLen = 0;
|
||||
int32_t iIdx = pCurAu->uiStartPos;
|
||||
int32_t iEndIdx = pCurAu->uiEndPos;
|
||||
uint8_t* pNalBs = NULL;
|
||||
pParser->uiOutBsTimeStamp = (pCurAu->pNalUnitsList [iIdx]) ? pCurAu->pNalUnitsList [iIdx]->uiTimeStamp : 0;
|
||||
pParser->iNalNum = 0;
|
||||
pParser->iSpsWidthInPixel = (pCtx->pSps->iMbWidth << 4);
|
||||
pParser->iSpsHeightInPixel = (pCtx->pSps->iMbHeight << 4);
|
||||
|
||||
if (pCurAu->pNalUnitsList [iIdx]->sNalHeaderExt.bIdrFlag) { //IDR
|
||||
bool bSubSps = (NAL_UNIT_CODED_SLICE_EXT == pCurAu->pNalUnitsList [iIdx]->sNalHeaderExt.sNalUnitHeader.eNalUnitType);
|
||||
SSpsBsInfo* pSpsBs = NULL;
|
||||
SPpsBsInfo* pPpsBs = NULL;
|
||||
int32_t iSpsId = pCtx->pSps->iSpsId;
|
||||
int32_t iPpsId = pCtx->pPps->iPpsId;
|
||||
pCtx->bParamSetsLostFlag = false;
|
||||
//find required sps, pps and write into dst buff
|
||||
pSpsBs = bSubSps ? &pCtx->sSubsetSpsBsInfo [iSpsId] : &pCtx->sSpsBsInfo [iSpsId];
|
||||
memcpy (pDstBuf, pSpsBs->pSpsBsBuf, pSpsBs->uiSpsBsLen);
|
||||
pParser->iNalLenInByte [pParser->iNalNum ++] = pSpsBs->uiSpsBsLen;
|
||||
pDstBuf += pSpsBs->uiSpsBsLen;
|
||||
pPpsBs = &pCtx->sPpsBsInfo [iPpsId];
|
||||
memcpy (pDstBuf, pPpsBs->pPpsBsBuf, pPpsBs->uiPpsBsLen);
|
||||
pParser->iNalLenInByte [pParser->iNalNum ++] = pPpsBs->uiPpsBsLen;
|
||||
pDstBuf += pPpsBs->uiPpsBsLen;
|
||||
} //IDR required SPS, PPS
|
||||
//then VCL data re-write
|
||||
while (iIdx <= iEndIdx) {
|
||||
pCurNal = pCurAu->pNalUnitsList [iIdx ++];
|
||||
iNalLen = pCurNal->sNalData.sVclNal.iNalLength;
|
||||
pNalBs = pCurNal->sNalData.sVclNal.pNalPos;
|
||||
pParser->iNalLenInByte [pParser->iNalNum ++] = iNalLen;
|
||||
memcpy (pDstBuf, pNalBs, iNalLen);
|
||||
pDstBuf += iNalLen;
|
||||
}
|
||||
} else { //error
|
||||
pCtx->pParserBsInfo->uiOutBsTimeStamp = 0;
|
||||
pCtx->pParserBsInfo->iNalNum = 0;
|
||||
pCtx->pParserBsInfo->iSpsWidthInPixel = 0;
|
||||
pCtx->pParserBsInfo->iSpsHeightInPixel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
WelsDecodeAccessUnitEnd (pCtx);
|
||||
|
||||
pCtx->bNewSeqBegin = false;
|
||||
WriteBackActiveParameters (pCtx);
|
||||
pCtx->bNewSeqBegin = pCtx->bNewSeqBegin || pCtx->bNextNewSeqBegin;
|
||||
pCtx->bNextNewSeqBegin = false; // reset it
|
||||
if (pCtx->bNewSeqBegin)
|
||||
ResetActiveSPSForEachLayer (pCtx);
|
||||
if (ERR_NONE != iErr) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "returned error from decoding:[0x%x]", iErr);
|
||||
return iErr;
|
||||
@@ -1829,6 +1990,14 @@ static inline void InitDqLayerInfo (PDqLayer pDqLayer, PLayerInfo pLayerInfo, PN
|
||||
if (kuiQualityId == BASE_QUALITY_ID) {
|
||||
pDqLayer->pRefPicListReordering = &pSh->pRefPicListReordering;
|
||||
pDqLayer->pRefPicMarking = &pSh->sRefMarking;
|
||||
|
||||
if (pSh->pPps->bWeightedPredFlag) {
|
||||
pDqLayer->bUseWeightPredictionFlag = true;
|
||||
pDqLayer->pPredWeightTable = &pSh->sPredWeightTable;
|
||||
|
||||
} else
|
||||
pDqLayer->bUseWeightPredictionFlag = false;
|
||||
|
||||
pDqLayer->pRefPicBaseMarking = &pShExt->sRefBasePicMarking;
|
||||
}
|
||||
|
||||
@@ -1921,6 +2090,8 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf
|
||||
|
||||
if (pCtx->pDec == NULL) {
|
||||
pCtx->pDec = PrefetchPic (pCtx->pPicBuff[0]);
|
||||
if (pCtx->iTotalNumMbRec != 0)
|
||||
pCtx->iTotalNumMbRec = 0;
|
||||
|
||||
if (NULL == pCtx->pDec) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR,
|
||||
@@ -2034,10 +2205,12 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf
|
||||
pCtx->bRPLRError = true;
|
||||
bAllRefComplete = false; // RPLR error, set ref pictures complete flag false
|
||||
HandleReferenceLost (pCtx, pNalCur);
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG,
|
||||
"reference picture introduced by this frame is lost during transmission! uiTId: %d",
|
||||
pNalCur->sNalHeaderExt.uiTemporalId);
|
||||
if (pCtx->eErrorConMethod == ERROR_CON_DISABLE) {
|
||||
if (pCtx->iTotalNumMbRec == 0)
|
||||
pCtx->pDec = NULL;
|
||||
return iRet;
|
||||
}
|
||||
}
|
||||
@@ -2053,16 +2226,16 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf
|
||||
bAllRefComplete = false;
|
||||
HandleReferenceLostL0 (pCtx, pNalCur);
|
||||
if (pCtx->eErrorConMethod == ERROR_CON_DISABLE) {
|
||||
if (pCtx->iTotalNumMbRec == 0)
|
||||
pCtx->pDec = NULL;
|
||||
return iRet;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pCtx->bParseOnly) {
|
||||
if (bReconstructSlice) {
|
||||
if (WelsDecodeConstructSlice (pCtx, pNalCur)) {
|
||||
pCtx->pDec->bIsComplete = false; // reconstruction error, directly set the flag false
|
||||
return -1;
|
||||
}
|
||||
if (bReconstructSlice) {
|
||||
if (WelsDecodeConstructSlice (pCtx, pNalCur)) {
|
||||
pCtx->pDec->bIsComplete = false; // reconstruction error, directly set the flag false
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (bAllRefComplete && pCtx->eSliceType != I_SLICE) {
|
||||
@@ -2109,8 +2282,8 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf
|
||||
#endif//#if !CODEC_FOR_TESTBED
|
||||
|
||||
if (dq_cur->uiLayerDqId == kuiTargetLayerDqId) {
|
||||
if (!pCtx->bParseOnly) {
|
||||
if (!pCtx->bInstantDecFlag) {
|
||||
if (!pCtx->bInstantDecFlag) {
|
||||
if (!pCtx->bParseOnly) {
|
||||
//Do error concealment here
|
||||
if ((NeedErrorCon (pCtx)) && (pCtx->eErrorConMethod != ERROR_CON_DISABLE)) {
|
||||
ImplementErrorCon (pCtx);
|
||||
@@ -2119,11 +2292,12 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf
|
||||
pCtx->pDec->iPpsId = pCtx->pPps->iPpsId;
|
||||
}
|
||||
}
|
||||
|
||||
if (DecodeFrameConstruction (pCtx, ppDst, pDstInfo)) {
|
||||
return ERR_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
iRet = DecodeFrameConstruction (pCtx, ppDst, pDstInfo);
|
||||
if (iRet)
|
||||
return iRet;
|
||||
|
||||
pCtx->pPreviousDecodedPictureInDpb = pCtx->pDec; //store latest decoded picture for EC
|
||||
if (uiNalRefIdc > 0) {
|
||||
iRet = WelsMarkAsRef (pCtx);
|
||||
@@ -2133,9 +2307,10 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf
|
||||
return iRet;
|
||||
}
|
||||
}
|
||||
ExpandReferencingPicture (pCtx->pDec->pData, pCtx->pDec->iWidthInPixel, pCtx->pDec->iHeightInPixel,
|
||||
pCtx->pDec->iLinesize,
|
||||
pCtx->sExpandPicFunc.pfExpandLumaPicture, pCtx->sExpandPicFunc.pfExpandChromaPicture);
|
||||
if (!pCtx->bParseOnly)
|
||||
ExpandReferencingPicture (pCtx->pDec->pData, pCtx->pDec->iWidthInPixel, pCtx->pDec->iHeightInPixel,
|
||||
pCtx->pDec->iLinesize,
|
||||
pCtx->sExpandPicFunc.pfExpandLumaPicture, pCtx->sExpandPicFunc.pfExpandChromaPicture);
|
||||
}
|
||||
pCtx->pDec = NULL; //after frame decoding, always set to NULL
|
||||
}
|
||||
@@ -2151,36 +2326,54 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf
|
||||
|
||||
bool CheckAndFinishLastPic (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {
|
||||
PAccessUnit pAu = pCtx->pAccessUnitList;
|
||||
if (pAu->uiAvailUnitsNum == 0)
|
||||
return true;
|
||||
PNalUnit pCurNal = pAu->pNalUnitsList[pAu->uiEndPos];
|
||||
if ((pCtx->iTotalNumMbRec != 0)
|
||||
&& (CheckAccessUnitBoundaryExt (&pCtx->sLastNalHdrExt, &pCurNal->sNalHeaderExt, &pCtx->sLastSliceHeader,
|
||||
&pCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader))) {
|
||||
//Do Error Concealment here
|
||||
if (NeedErrorCon (pCtx)) { //should always be true!
|
||||
if (pCtx->eErrorConMethod != ERROR_CON_DISABLE) {
|
||||
ImplementErrorCon (pCtx);
|
||||
pCtx->iTotalNumMbRec = pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight;
|
||||
pCtx->pDec->iSpsId = pCtx->pSps->iSpsId;
|
||||
pCtx->pDec->iPpsId = pCtx->pPps->iPpsId;
|
||||
|
||||
DecodeFrameConstruction (pCtx, ppDst, pDstInfo);
|
||||
pCtx->pPreviousDecodedPictureInDpb = pCtx->pDec; //save ECed pic for future use
|
||||
if (pCtx->sLastNalHdrExt.sNalUnitHeader.uiNalRefIdc > 0) {
|
||||
MarkECFrameAsRef (pCtx);
|
||||
}
|
||||
} else {
|
||||
if (DecodeFrameConstruction (pCtx, ppDst, pDstInfo)) {
|
||||
pCtx->pDec = NULL;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
pCtx->pDec = NULL;
|
||||
pCtx->iPrevFrameNum = pCtx->sLastSliceHeader.iFrameNum; //save frame_num
|
||||
if (pCtx->bLastHasMmco5)
|
||||
pCtx->iPrevFrameNum = 0;
|
||||
bool bAuBoundaryFlag = false;
|
||||
if (IS_VCL_NAL (pCtx->sCurNalHead.eNalUnitType, 1)) { //VCL data, AU list should have data
|
||||
PNalUnit pCurNal = pAu->pNalUnitsList[pAu->uiEndPos];
|
||||
bAuBoundaryFlag = (pCtx->iTotalNumMbRec != 0)
|
||||
&& (CheckAccessUnitBoundaryExt (&pCtx->sLastNalHdrExt, &pCurNal->sNalHeaderExt, &pCtx->sLastSliceHeader,
|
||||
&pCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader));
|
||||
} else { //non VCL
|
||||
if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_AU_DELIMITER) {
|
||||
bAuBoundaryFlag = true;
|
||||
} else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_SEI) {
|
||||
bAuBoundaryFlag = true;
|
||||
} else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_SPS) {
|
||||
bAuBoundaryFlag = !! (pCtx->iOverwriteFlags & OVERWRITE_SPS);
|
||||
} else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_SUBSET_SPS) {
|
||||
bAuBoundaryFlag = !! (pCtx->iOverwriteFlags & OVERWRITE_SUBSETSPS);
|
||||
} else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_PPS) {
|
||||
bAuBoundaryFlag = !! (pCtx->iOverwriteFlags & OVERWRITE_PPS);
|
||||
}
|
||||
if (bAuBoundaryFlag && pCtx->pAccessUnitList->uiAvailUnitsNum != 0) { //Construct remaining data first
|
||||
ConstructAccessUnit (pCtx, ppDst, pDstInfo);
|
||||
}
|
||||
}
|
||||
|
||||
//Do Error Concealment here
|
||||
if (bAuBoundaryFlag && (pCtx->iTotalNumMbRec != 0) && NeedErrorCon (pCtx)) { //AU ready but frame not completely reconed
|
||||
if (pCtx->eErrorConMethod != ERROR_CON_DISABLE) {
|
||||
ImplementErrorCon (pCtx);
|
||||
pCtx->iTotalNumMbRec = pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight;
|
||||
pCtx->pDec->iSpsId = pCtx->pSps->iSpsId;
|
||||
pCtx->pDec->iPpsId = pCtx->pPps->iPpsId;
|
||||
|
||||
DecodeFrameConstruction (pCtx, ppDst, pDstInfo);
|
||||
pCtx->pPreviousDecodedPictureInDpb = pCtx->pDec; //save ECed pic for future use
|
||||
if (pCtx->sLastNalHdrExt.sNalUnitHeader.uiNalRefIdc > 0) {
|
||||
MarkECFrameAsRef (pCtx);
|
||||
}
|
||||
} else if (pCtx->bParseOnly) { //clear parse only internal data status
|
||||
pCtx->pParserBsInfo->iNalNum = 0;
|
||||
} else {
|
||||
if (DecodeFrameConstruction (pCtx, ppDst, pDstInfo)) {
|
||||
pCtx->pDec = NULL;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
pCtx->pDec = NULL;
|
||||
pCtx->iPrevFrameNum = pCtx->sLastSliceHeader.iFrameNum; //save frame_num
|
||||
if (pCtx->bLastHasMmco5)
|
||||
pCtx->iPrevFrameNum = 0;
|
||||
}
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
@@ -134,12 +134,21 @@ const uint8_t g_kuiIntra4x4CbpTable[48] = {
|
||||
8, 17, 18, 20, 24, 6, 9, 22, 25, 32, 33, 34, 36, 40, 38, 41 //47
|
||||
};
|
||||
|
||||
const uint8_t g_kuiIntra4x4CbpTable400[16] = {
|
||||
15, 0, 7, 11, 13, 14, 3, 5, 10, 12, 1, 2, 4, 8, 6, 9
|
||||
|
||||
};
|
||||
|
||||
const uint8_t g_kuiInterCbpTable[48] = {
|
||||
0, 16, 1, 2, 4, 8, 32, 3, 5, 10, 12, 15, 47, 7, 11, 13, //15
|
||||
14, 6, 9, 31, 35, 37, 42, 44, 33, 34, 36, 40, 39, 43, 45, 46, //31
|
||||
17, 18, 20, 24, 19, 21, 26, 28, 23, 27, 29, 30, 22, 25, 38, 41 //47
|
||||
};
|
||||
|
||||
const uint8_t g_kuiInterCbpTable400[16] = {
|
||||
0, 1, 2, 4, 8, 3, 5, 10, 12, 15, 7, 11, 13, 14, 6, 9
|
||||
};
|
||||
|
||||
const uint8_t g_kuiLeadingZeroTable[256] = {
|
||||
8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
|
||||
@@ -125,7 +125,7 @@ void DoErrorConSliceCopy (PWelsDecoderContext pCtx) {
|
||||
if (pSrcPic != NULL) {
|
||||
iSrcStride = pSrcPic->iLinesize[0];
|
||||
//Y component
|
||||
pDstData = pDstPic->pData[0] + iMbY * 16 * iDstStride + iMbX * 16;;
|
||||
pDstData = pDstPic->pData[0] + iMbY * 16 * iDstStride + iMbX * 16;
|
||||
pSrcData = pSrcPic->pData[0] + iMbY * 16 * iSrcStride + iMbX * 16;
|
||||
pCtx->sCopyFunc.pCopyLumaFunc (pDstData, iDstStride, pSrcData, iSrcStride);
|
||||
//U component
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
*/
|
||||
|
||||
#include "fmo.h"
|
||||
#include "mem_align.h"
|
||||
#include "memory_align.h"
|
||||
|
||||
namespace WelsDec {
|
||||
|
||||
@@ -133,7 +133,7 @@ static inline int32_t FmoGenerateSliceGroup (PFmo pFmo, const PPps kpPps, const
|
||||
|
||||
|
||||
WelsFree (pFmo->pMbAllocMap, "_fmo->pMbAllocMap");
|
||||
pFmo->pMbAllocMap = (uint8_t*)WelsMalloc (iNumMb * sizeof (uint8_t), "_fmo->pMbAllocMap");
|
||||
pFmo->pMbAllocMap = (uint8_t*)WelsMallocz (iNumMb * sizeof (uint8_t), "_fmo->pMbAllocMap");
|
||||
WELS_VERIFY_RETURN_IF (1, (NULL == pFmo->pMbAllocMap)) // out of memory
|
||||
|
||||
pFmo->iCountMbNum = iNumMb;
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
/*!
|
||||
* \copy
|
||||
* Copyright (c) 2013, Cisco Systems
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mem_align.h"
|
||||
|
||||
namespace WelsDec {
|
||||
|
||||
//#define MEMORY_CHECK
|
||||
#ifdef MEMORY_CHECK
|
||||
|
||||
WelsFileHandle* pMemCheckMalloc = NULL;
|
||||
WelsFileHandle* pMemCheckFree = NULL;
|
||||
|
||||
int32_t iCountMalloc = 0;
|
||||
#endif
|
||||
//
|
||||
|
||||
void* WelsMalloc (const uint32_t kuiSize, const char* kpTag) {
|
||||
const int32_t kiSizeVoidPtr = sizeof (void**);
|
||||
const int32_t kiSizeInt = sizeof (int32_t);
|
||||
const int32_t kiAlignBytes = 15;
|
||||
uint8_t* pBuf = (uint8_t*) malloc (kuiSize + kiAlignBytes + kiSizeVoidPtr + kiSizeInt);
|
||||
uint8_t* pAlignBuf;
|
||||
|
||||
#ifdef MEMORY_CHECK
|
||||
if (pMemCheckMalloc == NULL) {
|
||||
pMemCheckMalloc = WelsFopen ("mem_check_malloc.txt", "at+");
|
||||
pMemCheckFree = WelsFopen ("mem_check_free.txt", "at+");
|
||||
}
|
||||
|
||||
if (kpTag != NULL) {
|
||||
if (pMemCheckMalloc != NULL) {
|
||||
fprintf (pMemCheckMalloc, "0x%x, size: %d , malloc %s\n", (void*)pBuf,
|
||||
(kuiSize + kiAlignBytes + kiSizeVoidPtr + kiSizeInt), kpTag);
|
||||
}
|
||||
if (pMemCheckMalloc != NULL) {
|
||||
fflush (pMemCheckMalloc);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (NULL == pBuf)
|
||||
return NULL;
|
||||
|
||||
// to fill zero values
|
||||
memset (pBuf, 0, kuiSize + kiAlignBytes + kiSizeVoidPtr + kiSizeInt);
|
||||
|
||||
pAlignBuf = pBuf + kiAlignBytes + kiSizeVoidPtr + kiSizeInt;
|
||||
pAlignBuf -= (uintptr_t) pAlignBuf & kiAlignBytes;
|
||||
* ((void**) (pAlignBuf - kiSizeVoidPtr)) = pBuf;
|
||||
* ((int32_t*) (pAlignBuf - (kiSizeVoidPtr + kiSizeInt))) = kuiSize;
|
||||
|
||||
return (pAlignBuf);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void WelsFree (void* pPtr, const char* kpTag) {
|
||||
if (pPtr) {
|
||||
#ifdef MEMORY_CHECK
|
||||
if (NULL != pMemCheckFree && kpTag != NULL) {
|
||||
fprintf (pMemCheckFree, "0x%x, free %s\n", (void*) (* (((void**) pPtr) - 1)), kpTag);
|
||||
fflush (pMemCheckFree);
|
||||
}
|
||||
#endif
|
||||
free (* (((void**) pPtr) - 1));
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
} // namespace WelsDec
|
||||
@@ -39,7 +39,7 @@
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include "memmgr_nal_unit.h"
|
||||
#include "mem_align.h"
|
||||
#include "memory_align.h"
|
||||
|
||||
namespace WelsDec {
|
||||
|
||||
@@ -58,7 +58,7 @@ int32_t MemInitNalList (PAccessUnit* ppAu, const uint32_t kuiSize) {
|
||||
MemFreeNalList (ppAu);
|
||||
}
|
||||
|
||||
pBase = (uint8_t*)WelsMalloc (kuiCountSize, "Access Unit");
|
||||
pBase = (uint8_t*)WelsMallocz (kuiCountSize, "Access Unit");
|
||||
if (pBase == NULL)
|
||||
return 1;
|
||||
pPtr = pBase;
|
||||
@@ -75,7 +75,8 @@ int32_t MemInitNalList (PAccessUnit* ppAu, const uint32_t kuiSize) {
|
||||
(*ppAu)->uiCountUnitsNum = kuiSize;
|
||||
(*ppAu)->uiAvailUnitsNum = 0;
|
||||
(*ppAu)->uiActualUnitsNum = 0;
|
||||
(*ppAu)->uiEndPos = 0;
|
||||
(*ppAu)->uiStartPos = 0;
|
||||
(*ppAu)->uiEndPos = 0;
|
||||
(*ppAu)->bCompletedAuFlag = false;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -385,7 +385,8 @@ int32_t ParseInterMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNe
|
||||
return ERR_INFO_INVALID_REF_INDEX;
|
||||
}
|
||||
}
|
||||
pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || !(ppRefPic[iRef[0]]&&ppRefPic[iRef[0]]->bIsComplete);
|
||||
pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[iRef[0]]
|
||||
&& ppRefPic[iRef[0]]->bIsComplete);
|
||||
PredMv (pMotionVector, pRefIndex, 0, 4, iRef[0], pMv);
|
||||
WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, LIST_0, 0, pMvd[0]));
|
||||
WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, LIST_0, 1, pMvd[1]));
|
||||
@@ -410,7 +411,8 @@ int32_t ParseInterMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNe
|
||||
return ERR_INFO_INVALID_REF_INDEX;
|
||||
}
|
||||
}
|
||||
pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || !(ppRefPic[iRef[i]]&&ppRefPic[iRef[i]]->bIsComplete);
|
||||
pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[iRef[i]]
|
||||
&& ppRefPic[iRef[i]]->bIsComplete);
|
||||
UpdateP16x8RefIdxCabac (pCurDqLayer, pRefIndex, iPartIdx, iRef[i], LIST_0);
|
||||
}
|
||||
for (i = 0; i < 2; i++) {
|
||||
@@ -439,7 +441,8 @@ int32_t ParseInterMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNe
|
||||
return ERR_INFO_INVALID_REF_INDEX;
|
||||
}
|
||||
}
|
||||
pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || !(ppRefPic[iRef[i]]&&ppRefPic[iRef[i]]->bIsComplete);
|
||||
pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[iRef[i]]
|
||||
&& ppRefPic[iRef[i]]->bIsComplete);
|
||||
UpdateP8x16RefIdxCabac (pCurDqLayer, pRefIndex, iPartIdx, iRef[i], LIST_0);
|
||||
}
|
||||
for (i = 0; i < 2; i++) {
|
||||
@@ -483,7 +486,8 @@ int32_t ParseInterMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNe
|
||||
return ERR_INFO_INVALID_REF_INDEX;
|
||||
}
|
||||
}
|
||||
pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || !(ppRefPic[pRefIdx[i]]&&ppRefPic[pRefIdx[i]]->bIsComplete);
|
||||
pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[pRefIdx[i]]
|
||||
&& ppRefPic[pRefIdx[i]]->bIsComplete);
|
||||
UpdateP8x8RefIdxCabac (pCurDqLayer, pRefIndex, iIdx8, pRefIdx[i], LIST_0);
|
||||
}
|
||||
//mv
|
||||
@@ -665,6 +669,10 @@ int32_t ParseCbpInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail
|
||||
if (pCbpBit[3])
|
||||
uiCbp += 0x08;
|
||||
|
||||
if (pCtx->pSps->uiChromaFormatIdc == 0)//monochroma
|
||||
return ERR_NONE;
|
||||
|
||||
|
||||
//Chroma: bit by bit
|
||||
iIdxB = pNeighAvail->iTopAvail && (pNeighAvail->iTopType == MB_TYPE_INTRA_PCM || (pNeighAvail->iTopCbp >> 4));
|
||||
iIdxA = pNeighAvail->iLeftAvail && (pNeighAvail->iLeftType == MB_TYPE_INTRA_PCM || (pNeighAvail->iLeftCbp >> 4));
|
||||
@@ -683,7 +691,9 @@ int32_t ParseCbpInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail
|
||||
pCtx->pCabacCtx + NEW_CTX_OFFSET_CBP + 2 * CTX_NUM_CBP + iCtxInc,
|
||||
pCbpBit[5]));
|
||||
uiCbp += 1 << (4 + pCbpBit[5]);
|
||||
|
||||
}
|
||||
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
@@ -821,11 +831,15 @@ int32_t ParseResidualBlockCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroC
|
||||
const uint8_t* pScanTable, int32_t iResProperty, short* sTCoeff, /*int mb_mode*/ uint8_t uiQp,
|
||||
PWelsDecoderContext pCtx) {
|
||||
int32_t iCurNzCacheIdx;
|
||||
const uint16_t* pDeQuantMul = g_kuiDequantCoeff[uiQp];
|
||||
uint32_t uiTotalCoeffNum = 0;
|
||||
uint32_t uiCbpBit;
|
||||
int32_t pSignificantMap[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
int32_t iMbResProperty = 0;
|
||||
GetMbResProperty (&iMbResProperty, &iResProperty, false);
|
||||
const uint16_t* pDeQuantMul = (pCtx->bUseScalingList) ? pCtx->pDequant_coeff4x4[iMbResProperty][uiQp] :
|
||||
g_kuiDequantCoeff[uiQp];
|
||||
|
||||
WELS_READ_VERIFY (ParseCbfInfoCabac (pNeighAvail, pNonZeroCountCache, iIndex, iResProperty, pCtx, uiCbpBit));
|
||||
if (uiCbpBit) { //has coeff
|
||||
WELS_READ_VERIFY (ParseSignificantMapCabac (pSignificantMap, iResProperty, pCtx, uiTotalCoeffNum));
|
||||
@@ -847,13 +861,15 @@ int32_t ParseResidualBlockCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroC
|
||||
} else if (iResProperty == CHROMA_DC_U || iResProperty == CHROMA_DC_V) {
|
||||
do {
|
||||
if (pSignificantMap[j] != 0)
|
||||
sTCoeff[pScanTable[j]] = pSignificantMap[j] * pDeQuantMul[0];
|
||||
sTCoeff[pScanTable[j]] = pCtx->bUseScalingList ? (pSignificantMap[j] * pDeQuantMul[0]) >> 4 :
|
||||
(pSignificantMap[j] * pDeQuantMul[0]);
|
||||
++j;
|
||||
} while (j < 16);
|
||||
} else { //luma ac, chroma ac
|
||||
do {
|
||||
if (pSignificantMap[j] != 0)
|
||||
sTCoeff[pScanTable[j]] = pSignificantMap[j] * pDeQuantMul[pScanTable[j] & 0x07];
|
||||
sTCoeff[pScanTable[j]] = pCtx->bUseScalingList ? (pSignificantMap[j] * pDeQuantMul[pScanTable[j]] >> 4) :
|
||||
pSignificantMap[j] * pDeQuantMul[pScanTable[j] & 0x07];
|
||||
++j;
|
||||
} while (j < 16);
|
||||
}
|
||||
@@ -906,7 +922,7 @@ int32_t ParseIPCMInfoCabac (PWelsDecoderContext pCtx) {
|
||||
pBsAux->pCurBuf += 384;
|
||||
|
||||
pCurLayer->pLumaQp[iMbXy] = 0;
|
||||
pCurLayer->pChromaQp[iMbXy] = 0;
|
||||
pCurLayer->pChromaQp[iMbXy][0] = pCurLayer->pChromaQp[iMbXy][1] = 0;
|
||||
memset (pCurLayer->pNzc[iMbXy], 16, sizeof (pCurLayer->pNzc[iMbXy]));
|
||||
|
||||
//step 4: cabac engine init
|
||||
|
||||
@@ -236,8 +236,8 @@ void WelsFillCacheConstrain0Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNon
|
||||
}
|
||||
}
|
||||
|
||||
void WelsFillCacheInterCabac(PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int16_t iMvArray[LIST_A][30][MV_A], int16_t iMvdCache[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurLayer)
|
||||
{
|
||||
void WelsFillCacheInterCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int16_t iMvArray[LIST_A][30][MV_A],
|
||||
int16_t iMvdCache[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurLayer) {
|
||||
int32_t iCurXy = pCurLayer->iMbXyIndex;
|
||||
int32_t iTopXy = 0;
|
||||
int32_t iLeftXy = 0;
|
||||
@@ -267,10 +267,10 @@ void WelsFillCacheInterCabac(PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount
|
||||
ST32 (iMvArray[0][18], LD32 (pCurLayer->pMv[0][iLeftXy][11]));
|
||||
ST32 (iMvArray[0][24], LD32 (pCurLayer->pMv[0][iLeftXy][15]));
|
||||
|
||||
ST32(iMvdCache[0][ 6], LD32(pCurLayer->pMvd[0][iLeftXy][ 3]));
|
||||
ST32(iMvdCache[0][12], LD32(pCurLayer->pMvd[0][iLeftXy][ 7]));
|
||||
ST32(iMvdCache[0][18], LD32(pCurLayer->pMvd[0][iLeftXy][11]));
|
||||
ST32(iMvdCache[0][24], LD32(pCurLayer->pMvd[0][iLeftXy][15]));
|
||||
ST32 (iMvdCache[0][ 6], LD32 (pCurLayer->pMvd[0][iLeftXy][ 3]));
|
||||
ST32 (iMvdCache[0][12], LD32 (pCurLayer->pMvd[0][iLeftXy][ 7]));
|
||||
ST32 (iMvdCache[0][18], LD32 (pCurLayer->pMvd[0][iLeftXy][11]));
|
||||
ST32 (iMvdCache[0][24], LD32 (pCurLayer->pMvd[0][iLeftXy][15]));
|
||||
|
||||
iRefIdxArray[0][ 6] = pCurLayer->pRefIndex[0][iLeftXy][ 3];
|
||||
iRefIdxArray[0][12] = pCurLayer->pRefIndex[0][iLeftXy][ 7];
|
||||
@@ -282,31 +282,31 @@ void WelsFillCacheInterCabac(PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount
|
||||
ST32 (iMvArray[0][18], 0);
|
||||
ST32 (iMvArray[0][24], 0);
|
||||
|
||||
ST32(iMvdCache[0][ 6], 0);
|
||||
ST32(iMvdCache[0][12], 0);
|
||||
ST32(iMvdCache[0][18], 0);
|
||||
ST32(iMvdCache[0][24], 0);
|
||||
ST32 (iMvdCache[0][ 6], 0);
|
||||
ST32 (iMvdCache[0][12], 0);
|
||||
ST32 (iMvdCache[0][18], 0);
|
||||
ST32 (iMvdCache[0][24], 0);
|
||||
|
||||
|
||||
if (0 == pNeighAvail->iLeftAvail) { //not available
|
||||
iRefIdxArray[0][ 6] =
|
||||
iRefIdxArray[0][12] =
|
||||
iRefIdxArray[0][18] =
|
||||
iRefIdxArray[0][24] = REF_NOT_AVAIL;
|
||||
iRefIdxArray[0][12] =
|
||||
iRefIdxArray[0][18] =
|
||||
iRefIdxArray[0][24] = REF_NOT_AVAIL;
|
||||
} else { //available but is intra mb type
|
||||
iRefIdxArray[0][ 6] =
|
||||
iRefIdxArray[0][12] =
|
||||
iRefIdxArray[0][18] =
|
||||
iRefIdxArray[0][24] = REF_NOT_IN_LIST;
|
||||
iRefIdxArray[0][12] =
|
||||
iRefIdxArray[0][18] =
|
||||
iRefIdxArray[0][24] = REF_NOT_IN_LIST;
|
||||
}
|
||||
}
|
||||
if (pNeighAvail->iLeftTopAvail && IS_INTER (pNeighAvail->iLeftTopType)) {
|
||||
ST32 (iMvArray[0][0], LD32 (pCurLayer->pMv[0][iLeftTopXy][15]));
|
||||
ST32(iMvdCache[0][0], LD32(pCurLayer->pMvd[0][iLeftTopXy][15]));
|
||||
ST32 (iMvdCache[0][0], LD32 (pCurLayer->pMvd[0][iLeftTopXy][15]));
|
||||
iRefIdxArray[0][0] = pCurLayer->pRefIndex[0][iLeftTopXy][15];
|
||||
} else {
|
||||
ST32 (iMvArray[0][0], 0);
|
||||
ST32(iMvdCache[0][0], 0);
|
||||
ST32 (iMvdCache[0][0], 0);
|
||||
if (0 == pNeighAvail->iLeftTopAvail) { //not available
|
||||
iRefIdxArray[0][0] = REF_NOT_AVAIL;
|
||||
} else { //available but is intra mb type
|
||||
@@ -317,30 +317,30 @@ void WelsFillCacheInterCabac(PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount
|
||||
if (pNeighAvail->iTopAvail && IS_INTER (pNeighAvail->iTopType)) {
|
||||
ST64 (iMvArray[0][1], LD64 (pCurLayer->pMv[0][iTopXy][12]));
|
||||
ST64 (iMvArray[0][3], LD64 (pCurLayer->pMv[0][iTopXy][14]));
|
||||
ST64(iMvdCache[0][1], LD64(pCurLayer->pMvd[0][iTopXy][12]));
|
||||
ST64(iMvdCache[0][3], LD64(pCurLayer->pMvd[0][iTopXy][14]));
|
||||
ST64 (iMvdCache[0][1], LD64 (pCurLayer->pMvd[0][iTopXy][12]));
|
||||
ST64 (iMvdCache[0][3], LD64 (pCurLayer->pMvd[0][iTopXy][14]));
|
||||
ST32 (&iRefIdxArray[0][1], LD32 (&pCurLayer->pRefIndex[0][iTopXy][12]));
|
||||
} else {
|
||||
ST64 (iMvArray[0][1], 0);
|
||||
ST64 (iMvArray[0][3], 0);
|
||||
ST64(iMvdCache[0][1], 0);
|
||||
ST64(iMvdCache[0][3], 0);
|
||||
ST64 (iMvdCache[0][1], 0);
|
||||
ST64 (iMvdCache[0][3], 0);
|
||||
if (0 == pNeighAvail->iTopAvail) { //not available
|
||||
iRefIdxArray[0][1] =
|
||||
iRefIdxArray[0][2] =
|
||||
iRefIdxArray[0][3] =
|
||||
iRefIdxArray[0][4] = REF_NOT_AVAIL;
|
||||
iRefIdxArray[0][2] =
|
||||
iRefIdxArray[0][3] =
|
||||
iRefIdxArray[0][4] = REF_NOT_AVAIL;
|
||||
} else { //available but is intra mb type
|
||||
iRefIdxArray[0][1] =
|
||||
iRefIdxArray[0][2] =
|
||||
iRefIdxArray[0][3] =
|
||||
iRefIdxArray[0][4] = REF_NOT_IN_LIST;
|
||||
iRefIdxArray[0][2] =
|
||||
iRefIdxArray[0][3] =
|
||||
iRefIdxArray[0][4] = REF_NOT_IN_LIST;
|
||||
}
|
||||
}
|
||||
|
||||
if (pNeighAvail->iRightTopAvail && IS_INTER (pNeighAvail->iRightTopType)) {
|
||||
ST32 (iMvArray[0][5], LD32 (pCurLayer->pMv[0][iRightTopXy][12]));
|
||||
ST32(iMvdCache[0][5], LD32(pCurLayer->pMvd[0][iRightTopXy][12]));
|
||||
ST32 (iMvdCache[0][5], LD32 (pCurLayer->pMvd[0][iRightTopXy][12]));
|
||||
iRefIdxArray[0][5] = pCurLayer->pRefIndex[0][iRightTopXy][12];
|
||||
} else {
|
||||
ST32 (iMvArray[0][5], 0);
|
||||
@@ -357,21 +357,20 @@ void WelsFillCacheInterCabac(PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount
|
||||
ST32 (iMvArray[0][11], 0);
|
||||
ST32 (iMvArray[0][17], 0);
|
||||
ST32 (iMvArray[0][23], 0);
|
||||
ST32(iMvdCache[0][ 9], 0);
|
||||
ST32(iMvdCache[0][21], 0);
|
||||
ST32(iMvdCache[0][11], 0);
|
||||
ST32(iMvdCache[0][17], 0);
|
||||
ST32(iMvdCache[0][23], 0);
|
||||
ST32 (iMvdCache[0][ 9], 0);
|
||||
ST32 (iMvdCache[0][21], 0);
|
||||
ST32 (iMvdCache[0][11], 0);
|
||||
ST32 (iMvdCache[0][17], 0);
|
||||
ST32 (iMvdCache[0][23], 0);
|
||||
iRefIdxArray[0][ 9] =
|
||||
iRefIdxArray[0][21] =
|
||||
iRefIdxArray[0][11] =
|
||||
iRefIdxArray[0][17] =
|
||||
iRefIdxArray[0][23] = REF_NOT_AVAIL;
|
||||
iRefIdxArray[0][21] =
|
||||
iRefIdxArray[0][11] =
|
||||
iRefIdxArray[0][17] =
|
||||
iRefIdxArray[0][23] = REF_NOT_AVAIL;
|
||||
}
|
||||
|
||||
void WelsFillCacheInter (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount,
|
||||
int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurLayer)
|
||||
{
|
||||
int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurLayer) {
|
||||
int32_t iCurXy = pCurLayer->iMbXyIndex;
|
||||
int32_t iTopXy = 0;
|
||||
int32_t iLeftXy = 0;
|
||||
@@ -798,7 +797,13 @@ int32_t WelsResidualBlockCavlc (SVlcTable* pVlcTable, uint8_t* pNonZeroCountCach
|
||||
int32_t iLevel[16], iZerosLeft, iCoeffNum;
|
||||
int32_t iRun[16];
|
||||
int32_t iCurNonZeroCacheIdx, i;
|
||||
const uint16_t* kpDequantCoeff = g_kuiDequantCoeff[uiQp];
|
||||
|
||||
|
||||
int32_t iMbResProperty = 0;
|
||||
GetMbResProperty (&iMbResProperty, &iResidualProperty, 1);
|
||||
const uint16_t* kpDequantCoeff = pCtx->bUseScalingList ? pCtx->pDequant_coeff4x4[iMbResProperty][uiQp] :
|
||||
g_kuiDequantCoeff[uiQp];
|
||||
|
||||
int8_t nA, nB, nC;
|
||||
uint8_t uiTotalCoeff, uiTrailingOnes;
|
||||
int32_t iUsedBits = 0;
|
||||
@@ -867,7 +872,7 @@ int32_t WelsResidualBlockCavlc (SVlcTable* pVlcTable, uint8_t* pNonZeroCountCach
|
||||
int32_t j;
|
||||
iCoeffNum += iRun[i] + 1; //FIXME add 1 earlier ?
|
||||
j = kpZigzagTable[ iCoeffNum ];
|
||||
pTCoeff[j] = iLevel[i] * kpDequantCoeff[0];
|
||||
pTCoeff[j] = pCtx->bUseScalingList ? (iLevel[i] * kpDequantCoeff[0]) >> 4 : (iLevel[i] * kpDequantCoeff[0]);
|
||||
}
|
||||
} else if (iResidualProperty == I16_LUMA_DC) { //DC coefficent, only call in Intra_16x16, base_mode_flag = 0
|
||||
for (i = uiTotalCoeff - 1; i >= 0; --i) { //FIXME merge into rundecode?
|
||||
@@ -881,7 +886,7 @@ int32_t WelsResidualBlockCavlc (SVlcTable* pVlcTable, uint8_t* pNonZeroCountCach
|
||||
int32_t j;
|
||||
iCoeffNum += iRun[i] + 1; //FIXME add 1 earlier ?
|
||||
j = kpZigzagTable[ iCoeffNum ];
|
||||
pTCoeff[j] = iLevel[i] * kpDequantCoeff[j & 0x07];
|
||||
pTCoeff[j] = pCtx->bUseScalingList ? (iLevel[i] * kpDequantCoeff[j]) >> 4 : (iLevel[i] * kpDequantCoeff[j & 0x07]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include "pic_queue.h"
|
||||
#include "decoder_context.h"
|
||||
#include "codec_def.h"
|
||||
#include "mem_align.h"
|
||||
#include "memory_align.h"
|
||||
|
||||
namespace WelsDec {
|
||||
|
||||
@@ -69,7 +69,7 @@ PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const
|
||||
int32_t iLumaSize = 0;
|
||||
int32_t iChromaSize = 0;
|
||||
|
||||
pPic = (PPicture) WelsMalloc (sizeof (SPicture), "PPicture");
|
||||
pPic = (PPicture) WelsMallocz (sizeof (SPicture), "PPicture");
|
||||
WELS_VERIFY_RETURN_IF (NULL, NULL == pPic);
|
||||
|
||||
memset (pPic, 0, sizeof (SPicture));
|
||||
@@ -82,19 +82,25 @@ PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const
|
||||
iLumaSize = iPicWidth * iPicHeight;
|
||||
iChromaSize = iPicChromaWidth * iPicChromaHeight;
|
||||
|
||||
pPic->pBuffer[0] = static_cast<uint8_t*> (WelsMalloc (iLumaSize /* luma */
|
||||
+ (iChromaSize << 1) /* Cb,Cr */, "_pic->buffer[0]"));
|
||||
memset (pPic->pBuffer[0], 128, (iLumaSize + (iChromaSize << 1)));
|
||||
|
||||
WELS_VERIFY_RETURN_PROC_IF (NULL, NULL == pPic->pBuffer[0], FreePicture (pPic));
|
||||
pPic->iLinesize[0] = iPicWidth;
|
||||
pPic->iLinesize[1] = pPic->iLinesize[2] = iPicChromaWidth;
|
||||
pPic->pBuffer[1] = pPic->pBuffer[0] + iLumaSize;
|
||||
pPic->pBuffer[2] = pPic->pBuffer[1] + iChromaSize;
|
||||
pPic->pData[0] = pPic->pBuffer[0] + (1 + pPic->iLinesize[0]) * PADDING_LENGTH;
|
||||
pPic->pData[1] = pPic->pBuffer[1] + /*WELS_ALIGN*/ (((1 + pPic->iLinesize[1]) * PADDING_LENGTH) >> 1);
|
||||
pPic->pData[2] = pPic->pBuffer[2] + /*WELS_ALIGN*/ (((1 + pPic->iLinesize[2]) * PADDING_LENGTH) >> 1);
|
||||
if (pCtx->bParseOnly) {
|
||||
pPic->pBuffer[0] = pPic->pBuffer[1] = pPic->pBuffer[2] = NULL;
|
||||
pPic->pData[0] = pPic->pData[1] = pPic->pData[2] = NULL;
|
||||
pPic->iLinesize[0] = iPicWidth;
|
||||
pPic->iLinesize[1] = pPic->iLinesize[2] = iPicChromaWidth;
|
||||
} else {
|
||||
pPic->pBuffer[0] = static_cast<uint8_t*> (WelsMallocz (iLumaSize /* luma */
|
||||
+ (iChromaSize << 1) /* Cb,Cr */, "_pic->buffer[0]"));
|
||||
WELS_VERIFY_RETURN_PROC_IF (NULL, NULL == pPic->pBuffer[0], FreePicture (pPic));
|
||||
|
||||
memset (pPic->pBuffer[0], 128, (iLumaSize + (iChromaSize << 1)));
|
||||
pPic->iLinesize[0] = iPicWidth;
|
||||
pPic->iLinesize[1] = pPic->iLinesize[2] = iPicChromaWidth;
|
||||
pPic->pBuffer[1] = pPic->pBuffer[0] + iLumaSize;
|
||||
pPic->pBuffer[2] = pPic->pBuffer[1] + iChromaSize;
|
||||
pPic->pData[0] = pPic->pBuffer[0] + (1 + pPic->iLinesize[0]) * PADDING_LENGTH;
|
||||
pPic->pData[1] = pPic->pBuffer[1] + /*WELS_ALIGN*/ (((1 + pPic->iLinesize[1]) * PADDING_LENGTH) >> 1);
|
||||
pPic->pData[2] = pPic->pBuffer[2] + /*WELS_ALIGN*/ (((1 + pPic->iLinesize[2]) * PADDING_LENGTH) >> 1);
|
||||
}
|
||||
pPic->iPlanes = 3; // yv12 in default
|
||||
pPic->iWidthInPixel = kiPicWidth;
|
||||
pPic->iHeightInPixel = kiPicHeight;
|
||||
|
||||
@@ -186,7 +186,7 @@ static inline void GetRefPic (sMCRefMember* pMCRefMem, PWelsDecoderContext pCtx,
|
||||
#define MC_FLOW_SIMPLE_JUDGE 1
|
||||
#endif //MC_FLOW_SIMPLE_JUDGE
|
||||
void BaseMC (sMCRefMember* pMCRefMem, int32_t iXOffset, int32_t iYOffset, SMcFunc* pMCFunc,
|
||||
int32_t iBlkWidth, int32_t iBlkHeight, int16_t iMVs[2]) {
|
||||
int32_t iBlkWidth, int32_t iBlkHeight, int16_t iMVs[2]) {
|
||||
int32_t iFullMVx = (iXOffset << 2) + iMVs[0]; //quarter pixel
|
||||
int32_t iFullMVy = (iYOffset << 2) + iMVs[1];
|
||||
iFullMVx = WELS_CLIP3 (iFullMVx, ((-PADDING_LENGTH + 2) << 2), ((pMCRefMem->iPicWidth + PADDING_LENGTH - 19) << 2));
|
||||
@@ -214,6 +214,74 @@ void BaseMC (sMCRefMember* pMCRefMem, int32_t iXOffset, int32_t iYOffset, SMcFun
|
||||
|
||||
}
|
||||
|
||||
void WeightPrediction (PDqLayer pCurDqLayer, sMCRefMember* pMCRefMem, int32_t iRefIdx, int32_t iBlkWidth,
|
||||
int32_t iBlkHeight) {
|
||||
|
||||
|
||||
int32_t iLog2denom, iWoc, iOoc;
|
||||
int32_t iPredTemp, iLineStride;
|
||||
int32_t iPixel = 0;
|
||||
uint8_t* pDst;
|
||||
//luma
|
||||
iLog2denom = pCurDqLayer->pPredWeightTable->uiLumaLog2WeightDenom;
|
||||
iWoc = pCurDqLayer->pPredWeightTable->sPredList[LIST_0].iLumaWeight[iRefIdx];
|
||||
iOoc = pCurDqLayer->pPredWeightTable->sPredList[LIST_0].iLumaOffset[iRefIdx];
|
||||
iLineStride = pMCRefMem->iDstLineLuma;
|
||||
|
||||
for (int i = 0; i < iBlkHeight; i++) {
|
||||
for (int j = 0; j < iBlkWidth; j++) {
|
||||
iPixel = j + i * (iLineStride);
|
||||
if (iLog2denom >= 1) {
|
||||
iPredTemp = ((pMCRefMem->pDstY[iPixel] * iWoc + (1 << (iLog2denom - 1))) >> iLog2denom) + iOoc;
|
||||
|
||||
pMCRefMem->pDstY[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255);
|
||||
} else {
|
||||
iPredTemp = pMCRefMem->pDstY[iPixel] * iWoc + iOoc;
|
||||
|
||||
pMCRefMem->pDstY[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//UV
|
||||
iBlkWidth = iBlkWidth >> 2;
|
||||
iBlkHeight = iBlkHeight >> 2;
|
||||
iLog2denom = pCurDqLayer->pPredWeightTable->uiChromaLog2WeightDenom;
|
||||
iLineStride = pMCRefMem->iDstLineChroma;
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
||||
|
||||
//iLog2denom = pCurDqLayer->pPredWeightTable->uiChromaLog2WeightDenom;
|
||||
iWoc = pCurDqLayer->pPredWeightTable->sPredList[LIST_0].iChromaWeight[iRefIdx][i];
|
||||
iOoc = pCurDqLayer->pPredWeightTable->sPredList[LIST_0].iChromaOffset[iRefIdx][i];
|
||||
pDst = i ? pMCRefMem->pDstV : pMCRefMem->pDstU;
|
||||
//iLineStride = pMCRefMem->iDstLineChroma;
|
||||
|
||||
for (int i = 0; i < iBlkHeight ; i++) {
|
||||
for (int j = 0; j < iBlkWidth; j++) {
|
||||
iPixel = j + i * (iLineStride);
|
||||
if (iLog2denom >= 1) {
|
||||
iPredTemp = ((pDst[iPixel] * iWoc + (1 << (iLog2denom - 1))) >> iLog2denom) + iOoc;
|
||||
|
||||
pDst[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255);
|
||||
} else {
|
||||
iPredTemp = pDst[iPixel] * iWoc + iOoc;
|
||||
|
||||
pDst[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDecoderContext pCtx) {
|
||||
sMCRefMember pMCRefMem;
|
||||
PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
|
||||
@@ -242,6 +310,9 @@ void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDec
|
||||
|
||||
pMCRefMem.iDstLineLuma = iDstLineLuma;
|
||||
pMCRefMem.iDstLineChroma = iDstLineChroma;
|
||||
|
||||
int32_t iRefIndex = 0;
|
||||
|
||||
switch (iMBType) {
|
||||
case MB_TYPE_SKIP:
|
||||
case MB_TYPE_16x16:
|
||||
@@ -249,6 +320,11 @@ void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDec
|
||||
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1];
|
||||
GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0);
|
||||
BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs);
|
||||
|
||||
if (pCurDqLayer->bUseWeightPredictionFlag) {
|
||||
iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][0];
|
||||
WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 16, 16);
|
||||
}
|
||||
break;
|
||||
case MB_TYPE_16x8:
|
||||
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0];
|
||||
@@ -256,6 +332,11 @@ void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDec
|
||||
GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0);
|
||||
BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 8, iMVs);
|
||||
|
||||
if (pCurDqLayer->bUseWeightPredictionFlag) {
|
||||
iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][0];
|
||||
WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 16, 8);
|
||||
}
|
||||
|
||||
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][8][0];
|
||||
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][8][1];
|
||||
GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 8);
|
||||
@@ -263,12 +344,21 @@ void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDec
|
||||
pMCRefMem.pDstU = pPredCb + (iDstLineChroma << 2);
|
||||
pMCRefMem.pDstV = pPredCr + (iDstLineChroma << 2);
|
||||
BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY + 8, pMCFunc, 16, 8, iMVs);
|
||||
|
||||
if (pCurDqLayer->bUseWeightPredictionFlag) {
|
||||
iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][8];
|
||||
WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 16, 8);
|
||||
}
|
||||
break;
|
||||
case MB_TYPE_8x16:
|
||||
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0];
|
||||
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1];
|
||||
GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0);
|
||||
BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 8, 16, iMVs);
|
||||
if (pCurDqLayer->bUseWeightPredictionFlag) {
|
||||
iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][0];
|
||||
WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 8, 16);
|
||||
}
|
||||
|
||||
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][2][0];
|
||||
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][2][1];
|
||||
@@ -277,6 +367,11 @@ void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDec
|
||||
pMCRefMem.pDstU = pPredCb + 4;
|
||||
pMCRefMem.pDstV = pPredCr + 4;
|
||||
BaseMC (&pMCRefMem, iMBOffsetX + 8, iMBOffsetY, pMCFunc, 8, 16, iMVs);
|
||||
|
||||
if (pCurDqLayer->bUseWeightPredictionFlag) {
|
||||
iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][2];
|
||||
WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 8, 16);
|
||||
}
|
||||
break;
|
||||
case MB_TYPE_8x8:
|
||||
case MB_TYPE_8x8_REF0: {
|
||||
@@ -292,6 +387,7 @@ void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDec
|
||||
|
||||
iIIdx = ((i >> 1) << 3) + ((i & 1) << 1);
|
||||
GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], iIIdx);
|
||||
iRefIndex = pCurDqLayer->bUseWeightPredictionFlag ? pCurDqLayer->pRefIndex[0][iMBXY][iIIdx] : 0;
|
||||
|
||||
pDstY = pPredY + iBlk8X + iBlk8Y * iDstLineLuma;
|
||||
pDstU = pPredCb + (iBlk8X >> 1) + (iBlk8Y >> 1) * iDstLineChroma;
|
||||
@@ -304,11 +400,21 @@ void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDec
|
||||
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];
|
||||
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];
|
||||
BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs);
|
||||
if (pCurDqLayer->bUseWeightPredictionFlag) {
|
||||
|
||||
WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 8, 8);
|
||||
}
|
||||
|
||||
break;
|
||||
case SUB_MB_TYPE_8x4:
|
||||
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];
|
||||
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];
|
||||
BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs);
|
||||
if (pCurDqLayer->bUseWeightPredictionFlag) {
|
||||
|
||||
WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 8, 4);
|
||||
}
|
||||
|
||||
|
||||
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 4][0];
|
||||
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 4][1];
|
||||
@@ -316,11 +422,21 @@ void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDec
|
||||
pMCRefMem.pDstU += (iDstLineChroma << 1);
|
||||
pMCRefMem.pDstV += (iDstLineChroma << 1);
|
||||
BaseMC (&pMCRefMem, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs);
|
||||
if (pCurDqLayer->bUseWeightPredictionFlag) {
|
||||
|
||||
WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 8, 4);
|
||||
}
|
||||
|
||||
break;
|
||||
case SUB_MB_TYPE_4x8:
|
||||
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];
|
||||
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];
|
||||
BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs);
|
||||
if (pCurDqLayer->bUseWeightPredictionFlag) {
|
||||
|
||||
WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 4, 8);
|
||||
}
|
||||
|
||||
|
||||
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 1][0];
|
||||
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 1][1];
|
||||
@@ -328,6 +444,11 @@ void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDec
|
||||
pMCRefMem.pDstU += 2;
|
||||
pMCRefMem.pDstV += 2;
|
||||
BaseMC (&pMCRefMem, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs);
|
||||
if (pCurDqLayer->bUseWeightPredictionFlag) {
|
||||
|
||||
WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 4, 8);
|
||||
}
|
||||
|
||||
break;
|
||||
case SUB_MB_TYPE_4x4: {
|
||||
for (j = 0; j < 4; j++) {
|
||||
@@ -345,6 +466,11 @@ void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDec
|
||||
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + iJIdx][0];
|
||||
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + iJIdx][1];
|
||||
BaseMC (&pMCRefMem, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs);
|
||||
if (pCurDqLayer->bUseWeightPredictionFlag) {
|
||||
|
||||
WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 4, 4);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -259,6 +259,13 @@ WELS_EXTERN WelsDecoderI16x16LumaPredPlane_sse2
|
||||
pmullw xmm7, xmm6
|
||||
psubw xmm7, xmm0
|
||||
|
||||
; Indicate that xmm2 is fully initialized. Its actual value doesn't
|
||||
; matter in SUMW_HORIZON below, but after being used in LOAD_COLUMN above,
|
||||
; valgrind thinks that xmm2 contains uninitalized data (if the columns outside
|
||||
; of the left are uninitialized, such as in DecUT_IntraPrediction), which taints
|
||||
; r2d below, even if actually isn't based on the uninitialized data.
|
||||
pxor xmm2, xmm2
|
||||
|
||||
SUMW_HORIZON xmm7,xmm0,xmm2
|
||||
movd r2d, xmm7 ; V
|
||||
movsx r2, r2w
|
||||
|
||||
@@ -81,6 +81,11 @@ virtual DECODING_STATE EXTAPI DecodeFrame (const unsigned char* kpSrc,
|
||||
int& iWidth,
|
||||
int& iHeight);
|
||||
|
||||
virtual DECODING_STATE EXTAPI DecodeFrameNoDelay (const unsigned char* kpSrc,
|
||||
const int kiSrcLen,
|
||||
unsigned char** ppDst,
|
||||
SBufferInfo* pDstInfo);
|
||||
|
||||
virtual DECODING_STATE EXTAPI DecodeFrame2 (const unsigned char* kpSrc,
|
||||
const int kiSrcLen,
|
||||
unsigned char** ppDst,
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include "welsCodecTrace.h"
|
||||
#include "codec_def.h"
|
||||
#include "typedefs.h"
|
||||
#include "mem_align.h"
|
||||
#include "memory_align.h"
|
||||
#include "utils.h"
|
||||
#include "version.h"
|
||||
|
||||
@@ -240,7 +240,7 @@ int32_t CWelsDecoder::InitDecoder (const bool bParseOnly) {
|
||||
|
||||
if (m_pDecContext) //free
|
||||
UninitDecoder();
|
||||
m_pDecContext = (PWelsDecoderContext)WelsMalloc (sizeof (SWelsDecoderContext), "m_pDecContext");
|
||||
m_pDecContext = (PWelsDecoderContext)WelsMallocz (sizeof (SWelsDecoderContext), "m_pDecContext");
|
||||
if (NULL == m_pDecContext)
|
||||
return cmMallocMemeError;
|
||||
|
||||
@@ -258,6 +258,11 @@ long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) {
|
||||
return dsInitialOptExpected;
|
||||
|
||||
if (eOptID == DECODER_OPTION_DATAFORMAT) { // Set color space of decoding output frame
|
||||
if (m_pDecContext->bParseOnly) {
|
||||
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING,
|
||||
"CWelsDecoder::SetOption for data format meaningless for parseonly.");
|
||||
return cmResultSuccess;
|
||||
}
|
||||
if (pOption == NULL)
|
||||
return cmInitParaError;
|
||||
|
||||
@@ -280,6 +285,12 @@ long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) {
|
||||
iVal = * ((int*)pOption); // int value for error concealment idc
|
||||
iVal = WELS_CLIP3 (iVal, (int32_t) ERROR_CON_DISABLE, (int32_t) ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE);
|
||||
m_pDecContext->eErrorConMethod = (ERROR_CON_IDC) iVal;
|
||||
if ((m_pDecContext->bParseOnly) && (m_pDecContext->eErrorConMethod != ERROR_CON_DISABLE)) {
|
||||
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
|
||||
"CWelsDecoder::SetOption for ERROR_CON_IDC = %d not allowd for parse only!.", iVal);
|
||||
return cmInitParaError;
|
||||
}
|
||||
|
||||
InitErrorCon (m_pDecContext);
|
||||
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
|
||||
"CWelsDecoder::SetOption for ERROR_CON_IDC = %d.", iVal);
|
||||
@@ -383,6 +394,22 @@ long CWelsDecoder::GetOption (DECODER_OPTION eOptID, void* pOption) {
|
||||
return cmInitParaError;
|
||||
}
|
||||
|
||||
DECODING_STATE CWelsDecoder::DecodeFrameNoDelay (const unsigned char* kpSrc,
|
||||
const int kiSrcLen,
|
||||
unsigned char** ppDst,
|
||||
SBufferInfo* pDstInfo) {
|
||||
int iRet;
|
||||
SBufferInfo sTmpBufferInfo;
|
||||
iRet = (int) DecodeFrame2 (kpSrc, kiSrcLen, ppDst, pDstInfo);
|
||||
memcpy (&sTmpBufferInfo, pDstInfo, sizeof (SBufferInfo));
|
||||
iRet |= DecodeFrame2 (NULL, 0, ppDst, pDstInfo);
|
||||
if ((pDstInfo->iBufferStatus == 0) && (sTmpBufferInfo.iBufferStatus == 1)) {
|
||||
memcpy (pDstInfo, &sTmpBufferInfo, sizeof (SBufferInfo));
|
||||
}
|
||||
|
||||
return (DECODING_STATE) iRet;
|
||||
}
|
||||
|
||||
DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc,
|
||||
const int kiSrcLen,
|
||||
unsigned char** ppDst,
|
||||
@@ -546,7 +573,11 @@ DECODING_STATE CWelsDecoder::DecodeParser (const unsigned char* kpSrc,
|
||||
}
|
||||
|
||||
m_pDecContext->iErrorCode = dsErrorFree; //initialize at the starting of AU decoding.
|
||||
m_pDecContext->pParserBsInfo = pDstInfo;
|
||||
m_pDecContext->eErrorConMethod = ERROR_CON_DISABLE; //add protection to disable EC here.
|
||||
if (!m_pDecContext->bFramePending) { //frame complete
|
||||
m_pDecContext->pParserBsInfo->iNalNum = 0;
|
||||
memset (m_pDecContext->pParserBsInfo->iNalLenInByte, 0, MAX_NAL_UNITS_IN_LAYER);
|
||||
}
|
||||
pDstInfo->iNalNum = 0;
|
||||
pDstInfo->iSpsWidthInPixel = pDstInfo->iSpsHeightInPixel = 0;
|
||||
if (pDstInfo) {
|
||||
@@ -556,6 +587,11 @@ DECODING_STATE CWelsDecoder::DecodeParser (const unsigned char* kpSrc,
|
||||
m_pDecContext->uiTimeStamp = 0;
|
||||
}
|
||||
WelsDecodeBs (m_pDecContext, kpSrc, kiSrcLen, NULL, NULL, pDstInfo);
|
||||
if (!m_pDecContext->bFramePending && m_pDecContext->pParserBsInfo->iNalNum) {
|
||||
memcpy (pDstInfo, m_pDecContext->pParserBsInfo, sizeof (SParserBsInfo));
|
||||
}
|
||||
|
||||
m_pDecContext->bInstantDecFlag = false; //reset no-delay flag
|
||||
|
||||
return (DECODING_STATE) m_pDecContext->iErrorCode;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,6 @@ DECODER_CPP_SRCS=\
|
||||
$(DECODER_SRCDIR)/core/src/fmo.cpp\
|
||||
$(DECODER_SRCDIR)/core/src/get_intra_predictor.cpp\
|
||||
$(DECODER_SRCDIR)/core/src/manage_dec_ref.cpp\
|
||||
$(DECODER_SRCDIR)/core/src/mc.cpp\
|
||||
$(DECODER_SRCDIR)/core/src/mem_align.cpp\
|
||||
$(DECODER_SRCDIR)/core/src/memmgr_nal_unit.cpp\
|
||||
$(DECODER_SRCDIR)/core/src/mv_pred.cpp\
|
||||
$(DECODER_SRCDIR)/core/src/parse_mb_syn_cabac.cpp\
|
||||
|
||||
@@ -139,16 +139,5 @@ $(TargetPath)
|
||||
#endif//MB_TYPES_CHECK
|
||||
#endif//MB_TYPES_INFO_OUTPUT
|
||||
|
||||
// NOTE: please do not clean below lines even comment, turn on for potential memory leak verify and memory usage monitor etc.
|
||||
//#define MEMORY_CHECK
|
||||
#define MEMORY_MONITOR
|
||||
#ifdef MEMORY_CHECK
|
||||
#ifndef MEMORY_MONITOR
|
||||
#define MEMORY_MONITOR
|
||||
#endif//MEMORY_MONITOR
|
||||
#endif//MEMORY_CHECK
|
||||
|
||||
|
||||
|
||||
#endif // AS264_COMMON_H_
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ int32_t WelsWritePpsSyntax (SWelsPPS* pPps, SBitStringAux* pBitStringAux, SParaS
|
||||
int32_t WelsInitSps (SWelsSPS* pSps, SSpatialLayerConfig* pLayerParam, SSpatialLayerInternal* pLayerParamInternal,
|
||||
const uint32_t kuiIntraPeriod, const int32_t kiNumRefFrame,
|
||||
const uint32_t kiSpsId, const bool kbEnableFrameCropping, bool bEnableRc,
|
||||
const int32_t kiDlayerCount);
|
||||
const int32_t kiDlayerCount,bool bSVCBaselayer);
|
||||
|
||||
/*!
|
||||
* \brief initialize subset pSps based on configurable parameters in svc
|
||||
@@ -121,7 +121,8 @@ int32_t WelsInitSps (SWelsSPS* pSps, SSpatialLayerConfig* pLayerParam, SSpatialL
|
||||
int32_t WelsInitSubsetSps (SSubsetSps* pSubsetSps, SSpatialLayerConfig* pLayerParam,
|
||||
SSpatialLayerInternal* pLayerParamInternal,
|
||||
const uint32_t kuiIntraPeriod, const int32_t kiNumRefFrame,
|
||||
const uint32_t kiSpsId, const bool kbEnableFrameCropping, bool bEnableRc);
|
||||
const uint32_t kiSpsId, const bool kbEnableFrameCropping, bool bEnableRc,
|
||||
const int32_t kiDlayerCount);
|
||||
|
||||
/*!
|
||||
* \brief initialize pPps based on configurable parameters and pSps(subset pSps) in svc
|
||||
@@ -141,7 +142,27 @@ int32_t WelsInitPps (SWelsPPS* pPps,
|
||||
const bool kbDeblockingFilterPresentFlag,
|
||||
const bool kbUsingSubsetSps,
|
||||
const bool kbEntropyCodingModeFlag);
|
||||
int32_t WelsCheckRefFrameLimitation (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam);
|
||||
int32_t WelsAdjustLevel( SSpatialLayerConfig* pSpatialLayer);
|
||||
|
||||
int32_t WelsCheckRefFrameLimitationNumRefFirst (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam);
|
||||
int32_t WelsCheckRefFrameLimitationLevelIdcFirst (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam);
|
||||
|
||||
int32_t WelsAdjustLevel (SSpatialLayerConfig* pSpatialLayer);
|
||||
|
||||
/*!
|
||||
* \brief check if the current parameter can found a presenting sps
|
||||
* \param pParam the current encoding paramter in SWelsSvcCodingParam
|
||||
* \param kbUseSubsetSps bool
|
||||
* \param iDlayerIndex int, the index of current D layer
|
||||
* \param iDlayerCount int, the number of total D layer
|
||||
* \param pSpsArray array of all the stored SPSs
|
||||
* \param pSubsetArray array of all the stored Subset-SPSs
|
||||
* \return 0 - successful
|
||||
* -1 - cannot find existing SPS for current encoder parameter
|
||||
*/
|
||||
int32_t FindExistingSps (SWelsSvcCodingParam* pParam, const bool kbUseSubsetSps, const int32_t iDlayerIndex,
|
||||
const int32_t iDlayerCount, const int32_t iSpsNumInUse,
|
||||
SWelsSPS* pSpsArray,
|
||||
SSubsetSps* pSubsetArray,
|
||||
bool bSVCBaselayer);
|
||||
}
|
||||
#endif//WELS_ACCESS_UNIT_PARSER_H__
|
||||
|
||||
@@ -65,12 +65,10 @@ typedef struct TagDeblockingFilter {
|
||||
extern "C" {
|
||||
#endif//__cplusplus
|
||||
#if defined(HAVE_NEON)
|
||||
void WelsNonZeroCount_neon (int8_t* pNonZeroCount);
|
||||
void DeblockingBSCalcEnc_neon (int8_t* pNzc, SMVUnitXY* pMv, int32_t iBoundryFlag, int32_t iMbStride,
|
||||
uint8_t (*pBS)[4][4]);
|
||||
#endif
|
||||
#if defined(HAVE_NEON_AARCH64)
|
||||
void WelsNonZeroCount_AArch64_neon (int8_t* pNonZeroCount);
|
||||
void DeblockingBSCalcEnc_AArch64_neon (int8_t* pNzc, SMVUnitXY* pMv, int32_t iBoundryFlag, int32_t iMbStride,
|
||||
uint8_t (*pBS)[4][4]);
|
||||
#endif
|
||||
@@ -79,7 +77,6 @@ void DeblockingBSCalcEnc_AArch64_neon (int8_t* pNzc, SMVUnitXY* pMv, int32_t iBo
|
||||
#endif//__cplusplus
|
||||
void DeblockingInit (DeblockingFunc* pFunc, int32_t iCpu);
|
||||
|
||||
void WelsNonZeroCount_c (int8_t* pNonZeroCount);
|
||||
void WelsBlockFuncInit (PSetNoneZeroCountZeroFunc* pfSetNZCZero, int32_t iCpu);
|
||||
|
||||
void PerformDeblockingFilter (sWelsEncCtx* pEnc);
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace WelsEnc {
|
||||
* \param pEncCtx sWelsEncCtx*
|
||||
* \return successful - 0; otherwise none 0 for failed
|
||||
*/
|
||||
int32_t RequestMemorySvc (sWelsEncCtx** ppCtx);
|
||||
int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingParasetList);
|
||||
|
||||
/*!
|
||||
* \brief free memory in SVC core encoder
|
||||
|
||||
@@ -191,6 +191,7 @@ typedef struct TagWelsEncCtx {
|
||||
SSubsetSps* pSubsetArray; // MAX_SPS_COUNT by standard compatible
|
||||
SSubsetSps* pSubsetSps;
|
||||
int32_t iSpsNum; // number of pSps used
|
||||
int32_t iSubsetSpsNum; // number of pSps used
|
||||
int32_t iPpsNum; // number of pPps used
|
||||
|
||||
// Output
|
||||
@@ -201,10 +202,10 @@ typedef struct TagWelsEncCtx {
|
||||
|
||||
SSpatialPicIndex sSpatialIndexMap[MAX_DEPENDENCY_LAYER];
|
||||
|
||||
bool bLongTermRefFlag[MAX_DEPENDENCY_LAYER][MAX_TEMPORAL_LEVEL + 1/*+LONG_TERM_REF_NUM*/];
|
||||
bool bRefOfCurTidIsLtr[MAX_DEPENDENCY_LAYER][MAX_TEMPORAL_LEVEL];
|
||||
uint16_t uiIdrPicId; // IDR picture id: [0, 65535], this one is used for LTR
|
||||
|
||||
int16_t iMaxSliceCount;// maximal count number of slices for all layers observation
|
||||
int32_t iMaxSliceCount;// maximal count number of slices for all layers observation
|
||||
int16_t iActiveThreadsNum; // number of threads active so far
|
||||
|
||||
/*
|
||||
@@ -216,6 +217,7 @@ typedef struct TagWelsEncCtx {
|
||||
pDqIdcMap; // overall DQ map of full scalability in specific frame (All full D/T/Q layers involved) // pDqIdcMap[dq_index] for each SDqIdc pData
|
||||
|
||||
SParaSetOffset sPSOVector;
|
||||
SParaSetOffset* pPSOVector;
|
||||
CMemoryAlign* pMemAlign;
|
||||
|
||||
#if defined(STAT_OUTPUT)
|
||||
@@ -241,6 +243,31 @@ typedef struct TagWelsEncCtx {
|
||||
bool bDependencyRecFlag[MAX_DEPENDENCY_LAYER];
|
||||
bool bRecFlag;
|
||||
#endif
|
||||
|
||||
uint32_t GetNeededSpsNum() {
|
||||
if (0 == sPSOVector.uiNeededSpsNum) {
|
||||
sPSOVector.uiNeededSpsNum = ((SPS_LISTING & pSvcParam->eSpsPpsIdStrategy) ? (MAX_SPS_COUNT) : (1));
|
||||
sPSOVector.uiNeededSpsNum *= ((pSvcParam->bSimulcastAVC) ? (pSvcParam->iSpatialLayerNum) : (1));
|
||||
}
|
||||
return sPSOVector.uiNeededSpsNum;
|
||||
}
|
||||
|
||||
uint32_t GetNeededSubsetSpsNum() {
|
||||
if (0 == sPSOVector.uiNeededSubsetSpsNum) {
|
||||
sPSOVector.uiNeededSubsetSpsNum = ((pSvcParam->bSimulcastAVC) ? (0) :
|
||||
((SPS_LISTING & pSvcParam->eSpsPpsIdStrategy) ? (MAX_SPS_COUNT) : (pSvcParam->iSpatialLayerNum - 1)));
|
||||
}
|
||||
return sPSOVector.uiNeededSubsetSpsNum;
|
||||
}
|
||||
|
||||
uint32_t GetNeededPpsNum() {
|
||||
if (0 == sPSOVector.uiNeededPpsNum) {
|
||||
sPSOVector.uiNeededPpsNum = ((pSvcParam->eSpsPpsIdStrategy & SPS_PPS_LISTING) ? (MAX_PPS_COUNT) :
|
||||
(1 + pSvcParam->iSpatialLayerNum));
|
||||
sPSOVector.uiNeededPpsNum *= ((pSvcParam->bSimulcastAVC) ? (pSvcParam->iSpatialLayerNum) : (1));
|
||||
}
|
||||
return sPSOVector.uiNeededPpsNum;
|
||||
}
|
||||
} sWelsEncCtx/*, *PWelsEncCtx*/;
|
||||
}
|
||||
#endif//sWelsEncCtx_H__
|
||||
|
||||
@@ -75,7 +75,8 @@ void GomValidCheck (const int32_t kiMbWidth, const int32_t kiMbHeight, int32_t*
|
||||
* \param para SWelsSvcCodingParam*
|
||||
* \return successful - 0; otherwise none 0 for failed
|
||||
*/
|
||||
int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pPara, SLogContext* pLogCtx);
|
||||
int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pPara, SLogContext* pLogCtx,
|
||||
SExistingParasetList* pExistingParasetList);
|
||||
|
||||
/*!
|
||||
* \brief uninitialize Wels encoder core library
|
||||
@@ -112,7 +113,9 @@ int32_t WelsEncoderApplyBitRate (SLogContext* pLogCtx, SWelsSvcCodingParam* pPar
|
||||
int32_t WelsEncoderApplyBitVaryRang(SLogContext* pLogCtx, SWelsSvcCodingParam* pParam, int32_t iRang);
|
||||
int32_t WelsEncoderApplyLTR (SLogContext* pLogCtx, sWelsEncCtx** ppCtx, SLTRConfig* pLTRValue);
|
||||
int32_t FilterLTRRecoveryRequest (sWelsEncCtx* pCtx, SLTRRecoverRequest* pLTRRecoverRequest);
|
||||
|
||||
void CheckProfileSetting (SLogContext* pLogCtx,SWelsSvcCodingParam* pParam,int32_t iLayer, EProfileIdc uiProfileIdc);
|
||||
void CheckLevelSetting (SLogContext* pLogCtx,SWelsSvcCodingParam* pParam,int32_t iLayer, ELevelIdc uiLevelIdc);
|
||||
void CheckReferenceNumSetting (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam,int32_t iNumRef);
|
||||
void FilterLTRMarkingFeedback (sWelsEncCtx* pCtx, SLTRMarkingFeedback* pLTRMarkingFeedback);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/*!
|
||||
* \copy
|
||||
* Copyright (c) 2013, Cisco Systems
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
//macroblock.h
|
||||
#ifndef WELS_MC_H__
|
||||
#define WELS_MC_H__
|
||||
|
||||
#include <string.h>
|
||||
#include "typedefs.h"
|
||||
#include "wels_const.h"
|
||||
#include "macros.h"
|
||||
#include "wels_func_ptr_def.h"
|
||||
#include "mc_common.h"
|
||||
|
||||
/////////////////////luma MC//////////////////////////
|
||||
//x y means dx(mv[0] & 3) and dy(mv[1] & 3)
|
||||
|
||||
namespace WelsEnc {
|
||||
void WelsInitMcFuncs (SWelsFuncPtrList* pFuncList, uint32_t uiCpuFlag);
|
||||
|
||||
}
|
||||
#endif//WELS_MC_H__
|
||||
@@ -122,6 +122,7 @@ uint8_t* pHalfPixHV;
|
||||
uint8_t* pQuarPixBest;
|
||||
uint8_t* pQuarPixTmp;
|
||||
|
||||
PCopyFunc pfCopyBlockByMode;
|
||||
} SMeRefinePointer;
|
||||
|
||||
void FillNeighborCacheIntra (SMbCache* pMbCache, SMB* pCurMb, int32_t iMbWidth/*, bool constrained_intra_pred_flag*/);
|
||||
|
||||
@@ -135,14 +135,15 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
|
||||
param.fMaxFrameRate = MAX_FRAME_RATE; // maximal frame rate [Hz / fps]
|
||||
|
||||
param.iComplexityMode = MEDIUM_COMPLEXITY;
|
||||
param.iTargetBitrate = 0; // overall target bitrate introduced in RC module
|
||||
param.iTargetBitrate = UNSPECIFIED_BIT_RATE; // overall target bitrate introduced in RC module
|
||||
param.iMaxBitrate = UNSPECIFIED_BIT_RATE;
|
||||
param.iMultipleThreadIdc = 1;
|
||||
|
||||
param.iLTRRefNum = 0;
|
||||
param.iLtrMarkPeriod = 30; //the min distance of two int32_t references
|
||||
|
||||
param.bEnableSSEI = true;
|
||||
param.bEnableSSEI = false;
|
||||
param.bSimulcastAVC = false;
|
||||
param.bEnableFrameCroppingFlag = true; // enable frame cropping flag: true alwayse in application
|
||||
// false: Streaming Video Sharing; true: Video Conferencing Meeting;
|
||||
|
||||
@@ -161,7 +162,7 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
|
||||
param.bEnableAdaptiveQuant = true; // adaptive quantization control
|
||||
param.bEnableFrameSkip = true; // frame skipping
|
||||
param.bEnableLongTermReference = false; // long term reference control
|
||||
param.bEnableSpsPpsIdAddition = true; // pSps pPps id addition control
|
||||
param.eSpsPpsIdStrategy = INCREASING_ID; // pSps pPps id addition control
|
||||
param.bPrefixNalAddingCtrl = false; // prefix NAL adding control
|
||||
param.iSpatialLayerNum = 1; // number of dependency(Spatial/CGS) layers used to be encoded
|
||||
param.iTemporalLayerNum = 1; // number of temporal layer specified
|
||||
@@ -173,7 +174,7 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
|
||||
param.bIsLosslessLink = false;
|
||||
for (int32_t iLayer = 0; iLayer < MAX_SPATIAL_LAYER_NUM; iLayer++) {
|
||||
param.sSpatialLayers[iLayer].uiProfileIdc = PRO_BASELINE;
|
||||
param.sSpatialLayers[iLayer].uiLevelIdc = LEVEL_5_0;
|
||||
param.sSpatialLayers[iLayer].uiLevelIdc = LEVEL_UNKNOWN;
|
||||
param.sSpatialLayers[iLayer].iDLayerQp = SVC_QUALITY_BASE_QP;
|
||||
param.sSpatialLayers[iLayer].fFrameRate = param.fMaxFrameRate;
|
||||
param.sSpatialLayers[iLayer].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
|
||||
@@ -189,7 +190,7 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
|
||||
void FillDefault() {
|
||||
FillDefault (*this);
|
||||
uiGopSize = 1; // GOP size (at maximal frame rate: 16)
|
||||
iMaxNumRefFrame = 1;
|
||||
iMaxNumRefFrame = AUTO_REF_PIC_COUNT;
|
||||
SUsedPicRect.iLeft =
|
||||
SUsedPicRect.iTop =
|
||||
SUsedPicRect.iWidth =
|
||||
@@ -229,6 +230,7 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
|
||||
while (iIdxSpatial < iSpatialLayerNum) {
|
||||
|
||||
sSpatialLayers->uiProfileIdc = uiProfileIdc;
|
||||
sSpatialLayers->uiLevelIdc = LEVEL_UNKNOWN;
|
||||
sSpatialLayers[iIdxSpatial].fFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate,
|
||||
MIN_FRAME_RATE, MAX_FRAME_RATE);
|
||||
pDlp->fInputFrameRate =
|
||||
@@ -243,9 +245,10 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
|
||||
sSpatialLayers->iSpatialBitrate =
|
||||
sSpatialLayers[iIdxSpatial].iSpatialBitrate = pCodingParam.iTargetBitrate; // target bitrate for current spatial layer
|
||||
|
||||
sSpatialLayers->iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE;
|
||||
sSpatialLayers->iDLayerQp = SVC_QUALITY_BASE_QP;
|
||||
|
||||
uiProfileIdc = PRO_SCALABLE_BASELINE;
|
||||
uiProfileIdc = (!bSimulcastAVC) ? PRO_SCALABLE_BASELINE : PRO_BASELINE;
|
||||
++ pDlp;
|
||||
++ iIdxSpatial;
|
||||
}
|
||||
@@ -286,6 +289,7 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
|
||||
|
||||
/* Rate Control */
|
||||
iRCMode = pCodingParam.iRCMode; // rc mode
|
||||
bSimulcastAVC = pCodingParam.bSimulcastAVC;
|
||||
iPaddingFlag = pCodingParam.iPaddingFlag;
|
||||
|
||||
iTargetBitrate = pCodingParam.iTargetBitrate; // target bitrate
|
||||
@@ -320,6 +324,7 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
|
||||
|
||||
/* For ssei information */
|
||||
bEnableSSEI = pCodingParam.bEnableSSEI;
|
||||
bSimulcastAVC = pCodingParam.bSimulcastAVC;
|
||||
|
||||
/* Layer definition */
|
||||
iSpatialLayerNum = (int8_t)WELS_CLIP3 (pCodingParam.iSpatialLayerNum, 1,
|
||||
@@ -335,33 +340,30 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
|
||||
else if (uiIntraPeriod & (uiGopSize - 1)) // none multiple of GOP size
|
||||
uiIntraPeriod = ((uiIntraPeriod + uiGopSize - 1) / uiGopSize) * uiGopSize;
|
||||
|
||||
if (iUsageType == SCREEN_CONTENT_REAL_TIME) {
|
||||
if (bEnableLongTermReference) {
|
||||
iLTRRefNum = LONG_TERM_REF_NUM_SCREEN;
|
||||
if (iNumRefFrame == AUTO_REF_PIC_COUNT)
|
||||
iNumRefFrame = WELS_MAX (1, WELS_LOG2 (uiGopSize)) + iLTRRefNum;
|
||||
} else {
|
||||
iLTRRefNum = 0;
|
||||
|
||||
if (iNumRefFrame == AUTO_REF_PIC_COUNT)
|
||||
iNumRefFrame = WELS_MAX (1, uiGopSize >> 1);
|
||||
}
|
||||
} else {
|
||||
iLTRRefNum = bEnableLongTermReference ? LONG_TERM_REF_NUM : 0;
|
||||
if (iNumRefFrame == AUTO_REF_PIC_COUNT) {
|
||||
iNumRefFrame = ((uiGopSize >> 1) > 1) ? ((uiGopSize >> 1) + iLTRRefNum) : (MIN_REF_PIC_COUNT + iLTRRefNum);
|
||||
iNumRefFrame = WELS_CLIP3 (iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA);
|
||||
}
|
||||
if (((pCodingParam.iNumRefFrame != AUTO_REF_PIC_COUNT)
|
||||
&& ((pCodingParam.iNumRefFrame > MAX_REF_PIC_COUNT) || (pCodingParam.iNumRefFrame < MIN_REF_PIC_COUNT)))
|
||||
|| ((iNumRefFrame != AUTO_REF_PIC_COUNT) && (pCodingParam.iNumRefFrame == AUTO_REF_PIC_COUNT))) {
|
||||
iNumRefFrame = pCodingParam.iNumRefFrame;
|
||||
}
|
||||
if (iNumRefFrame > iMaxNumRefFrame)
|
||||
if ((iNumRefFrame != AUTO_REF_PIC_COUNT) && (iNumRefFrame > iMaxNumRefFrame)) {
|
||||
iMaxNumRefFrame = iNumRefFrame;
|
||||
}
|
||||
iLTRRefNum = (pCodingParam.bEnableLongTermReference ? pCodingParam.iLTRRefNum : 0);
|
||||
iLtrMarkPeriod = pCodingParam.iLtrMarkPeriod;
|
||||
|
||||
bPrefixNalAddingCtrl = pCodingParam.bPrefixNalAddingCtrl;
|
||||
|
||||
bEnableSpsPpsIdAddition =
|
||||
pCodingParam.bEnableSpsPpsIdAddition;//For SVC meeting application, to avoid mosaic issue caused by cross-IDR reference.
|
||||
if ( (CONSTANT_ID == pCodingParam.eSpsPpsIdStrategy)
|
||||
|| (INCREASING_ID == pCodingParam.eSpsPpsIdStrategy)
|
||||
|| (SPS_LISTING == pCodingParam.eSpsPpsIdStrategy)
|
||||
|| (SPS_LISTING_AND_PPS_INCREASING == pCodingParam.eSpsPpsIdStrategy)
|
||||
|| (SPS_PPS_LISTING == pCodingParam.eSpsPpsIdStrategy)) {
|
||||
eSpsPpsIdStrategy =
|
||||
pCodingParam.eSpsPpsIdStrategy;//For SVC meeting application, to avoid mosaic issue caused by cross-IDR reference.
|
||||
//SHOULD enable this feature.
|
||||
} else {
|
||||
// keep the default value
|
||||
}
|
||||
|
||||
SSpatialLayerInternal* pDlp = &sDependencyLayers[0];
|
||||
SSpatialLayerConfig* pSpatialLayer = &sSpatialLayers[0];
|
||||
@@ -370,8 +372,7 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
|
||||
while (iIdxSpatial < iSpatialLayerNum) {
|
||||
pSpatialLayer->uiProfileIdc = (pCodingParam.sSpatialLayers[iIdxSpatial].uiProfileIdc == PRO_UNKNOWN) ? uiProfileIdc :
|
||||
pCodingParam.sSpatialLayers[iIdxSpatial].uiProfileIdc;
|
||||
pSpatialLayer->uiLevelIdc = (pCodingParam.sSpatialLayers[iIdxSpatial].uiLevelIdc == LEVEL_UNKNOWN) ? LEVEL_5_0 :
|
||||
pCodingParam.sSpatialLayers[iIdxSpatial].uiLevelIdc;
|
||||
pSpatialLayer->uiLevelIdc = pCodingParam.sSpatialLayers[iIdxSpatial].uiLevelIdc;
|
||||
|
||||
float fLayerFrameRate = WELS_CLIP3 (pCodingParam.sSpatialLayers[iIdxSpatial].fFrameRate,
|
||||
MIN_FRAME_RATE, fParamMaxFrameRate);
|
||||
@@ -405,7 +406,7 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
|
||||
|
||||
pSpatialLayer->iDLayerQp = pCodingParam.sSpatialLayers[iIdxSpatial].iDLayerQp;
|
||||
|
||||
uiProfileIdc = PRO_SCALABLE_BASELINE;
|
||||
uiProfileIdc = (!bSimulcastAVC) ? PRO_SCALABLE_BASELINE : PRO_BASELINE;
|
||||
++ pDlp;
|
||||
++ pSpatialLayer;
|
||||
++ iIdxSpatial;
|
||||
@@ -475,7 +476,8 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
|
||||
return ENC_RETURN_INVALIDINPUT;
|
||||
}
|
||||
|
||||
uiProfileIdc = iEntropyCodingModeFlag ? PRO_SCALABLE_HIGH : PRO_SCALABLE_BASELINE;
|
||||
uiProfileIdc = bSimulcastAVC ? (iEntropyCodingModeFlag ? PRO_HIGH : PRO_BASELINE) :
|
||||
(iEntropyCodingModeFlag ? PRO_SCALABLE_HIGH : PRO_SCALABLE_BASELINE);
|
||||
++ pDlp;
|
||||
++ pSpatialLayer;
|
||||
++ i;
|
||||
@@ -486,6 +488,18 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
|
||||
|
||||
} SWelsSvcCodingParam;
|
||||
|
||||
|
||||
typedef struct TagExistingParasetList {
|
||||
SWelsSPS sSps[MAX_SPS_COUNT];
|
||||
SSubsetSps sSubsetSps[MAX_SPS_COUNT];
|
||||
SWelsPPS sPps[MAX_PPS_COUNT];
|
||||
|
||||
uint32_t uiInUseSpsNum;
|
||||
uint32_t uiInUseSubsetSpsNum;
|
||||
uint32_t uiInUsePpsNum;
|
||||
} SExistingParasetList;
|
||||
|
||||
|
||||
static inline int32_t FreeCodingParam (SWelsSvcCodingParam** pParam, CMemoryAlign* pMa) {
|
||||
if (pParam == NULL || *pParam == NULL || pMa == NULL)
|
||||
return 1;
|
||||
|
||||
@@ -68,14 +68,14 @@ uint8_t iLevelIdc;
|
||||
// uint8_t uiBitDepthChroma; //=8
|
||||
/* TO BE CONTINUE: POC type 1 */
|
||||
// bool bDeltaPicOrderAlwaysZeroFlag;
|
||||
// bool bGapsInFrameNumValueAllowedFlag; //=true
|
||||
bool bGapsInFrameNumValueAllowedFlag;
|
||||
|
||||
// bool bFrameMbsOnlyFlag;
|
||||
// bool bMbaffFlag; // MB Adapative Frame Field
|
||||
// bool bDirect8x8InferenceFlag;
|
||||
bool bFrameCroppingFlag;
|
||||
|
||||
// bool bVuiParamPresentFlag;
|
||||
bool bVuiParamPresentFlag;
|
||||
// bool bTimingInfoPresentFlag;
|
||||
// bool bFixedFrameRateFlag;
|
||||
|
||||
|
||||
@@ -49,6 +49,9 @@
|
||||
#include "slice.h"
|
||||
|
||||
namespace WelsEnc {
|
||||
|
||||
typedef struct TagWelsEncCtx sWelsEncCtx;
|
||||
|
||||
//trace
|
||||
#define GOM_TRACE_FLAG 0
|
||||
#define GOM_H_SCC 8
|
||||
@@ -107,9 +110,10 @@ enum {
|
||||
|
||||
//bits allocation
|
||||
#define MAX_BITS_VARY_PERCENTAGE 100 //bits vary range in percentage
|
||||
#define MAX_BITS_VARY_PERCENTAGE_x3d2 150 //bits vary range in percentage * 3/2
|
||||
#define INT_MULTIPLY 100 // use to multiply in Double to Int Conversion, should be same as AQ_QSTEP_INT_MULTIPLY in WelsVP
|
||||
#define WEIGHT_MULTIPLY 2000
|
||||
#define REMAIN_BITS_TH (10) // *INT_MULTIPLY
|
||||
#define REMAIN_BITS_TH (1)
|
||||
#define VGOP_BITS_PERCENTAGE_DIFF 5
|
||||
#define IDR_BITRATE_RATIO 4
|
||||
#define FRAME_iTargetBits_VARY_RANGE 50 // *INT_MULTIPLY
|
||||
@@ -168,12 +172,12 @@ int32_t iRcVaryPercentage;
|
||||
int32_t iRcVaryRatio;
|
||||
|
||||
int32_t iInitialQp; //initial qp
|
||||
int32_t iBitRate;
|
||||
int64_t iBitRate; // Note: although the max bit rate is 240000*1200 which can be represented by int32, but there are many multipler of this iBitRate in the calculation of RC, so use int64 to avoid type conversion at all such places
|
||||
int32_t iPreviousBitrate;
|
||||
int32_t iPreviousGopSize;
|
||||
double fFrameRate;
|
||||
int64_t iBitsPerFrame; // *INT_MULTIPLY
|
||||
int64_t iMaxBitsPerFrame; // *INT_MULTIPLY
|
||||
int32_t iBitsPerFrame;
|
||||
int32_t iMaxBitsPerFrame;
|
||||
double dPreviousFps;
|
||||
|
||||
// bits allocation and status
|
||||
@@ -182,7 +186,7 @@ int32_t iTargetBits;
|
||||
int32_t iCurrentBitsLevel;//0:normal; 1:limited; 2:exceeded.
|
||||
|
||||
int32_t iIdrNum;
|
||||
int32_t iIntraComplexity;
|
||||
int64_t iIntraComplexity; //255*255(MaxMbSAD)*36864(MaxFS) make the highest bit of 32-bit integer 1
|
||||
int32_t iIntraMbCount;
|
||||
|
||||
int8_t iTlOfFrames[VGOP_SIZE];
|
||||
@@ -223,8 +227,8 @@ int32_t iLastCalculatedQScale;
|
||||
|
||||
//for skip frame and padding
|
||||
int32_t iBufferSizeSkip;
|
||||
int32_t iBufferFullnessSkip;
|
||||
int32_t iBufferMaxBRFullness[TIME_WINDOW_TOTAL];//0: EVEN_TIME_WINDOW; 1: ODD_TIME_WINDOW
|
||||
int64_t iBufferFullnessSkip;
|
||||
int64_t iBufferMaxBRFullness[TIME_WINDOW_TOTAL];//0: EVEN_TIME_WINDOW; 1: ODD_TIME_WINDOW
|
||||
int32_t iPredFrameBit;
|
||||
bool bNeedShiftWindowCheck[TIME_WINDOW_TOTAL];
|
||||
int32_t iBufferSizePadding;
|
||||
@@ -247,11 +251,15 @@ int32_t iActualBitRate; // TODO: to complete later
|
||||
float fLatestFrameRate; // TODO: to complete later
|
||||
} SWelsSvcRc;
|
||||
|
||||
typedef void (*PWelsRCPictureInitFunc) (void* pCtx);
|
||||
typedef void (*PWelsRCPictureDelayJudgeFunc) (void* pCtx, EVideoFrameType eFrameType, long long uiTimeStamp);
|
||||
typedef void (*PWelsRCPictureInfoUpdateFunc) (void* pCtx, int32_t iLayerSize);
|
||||
typedef void (*PWelsRCMBInfoUpdateFunc) (void* pCtx, SMB* pCurMb, int32_t iCostLuma, SSlice* pSlice);
|
||||
typedef void (*PWelsRCMBInitFunc) (void* pCtx, SMB* pCurMb, SSlice* pSlice);
|
||||
typedef void (*PWelsRCPictureInitFunc) (sWelsEncCtx* pCtx,long long uiTimeStamp);
|
||||
typedef void (*PWelsRCPictureDelayJudgeFunc) (sWelsEncCtx* pCtx, EVideoFrameType eFrameType, long long uiTimeStamp);
|
||||
typedef void (*PWelsRCPictureInfoUpdateFunc) (sWelsEncCtx* pCtx, int32_t iLayerSize);
|
||||
typedef void (*PWelsRCMBInfoUpdateFunc) (sWelsEncCtx* pCtx, SMB* pCurMb, int32_t iCostLuma, SSlice* pSlice);
|
||||
typedef void (*PWelsRCMBInitFunc) (sWelsEncCtx* pCtx, SMB* pCurMb, SSlice* pSlice);
|
||||
typedef bool (*PWelsCheckFrameSkipBasedMaxbrFunc) (sWelsEncCtx* pCtx, int32_t iSpatialNum, EVideoFrameType eFrameType,
|
||||
const uint32_t uiTimeStamp);
|
||||
typedef void (*PWelsUpdateBufferWhenFrameSkippedFunc)(sWelsEncCtx* pCtx, int32_t iSpatialNum);
|
||||
typedef void (*PWelsUpdateMaxBrCheckWindowStatusFunc)(sWelsEncCtx* pCtx, int32_t iSpatialNum, const long long uiTimeStamp);
|
||||
|
||||
typedef struct WelsRcFunc_s {
|
||||
PWelsRCPictureInitFunc pfWelsRcPictureInit;
|
||||
@@ -259,15 +267,18 @@ PWelsRCPictureDelayJudgeFunc pfWelsRcPicDelayJudge;
|
||||
PWelsRCPictureInfoUpdateFunc pfWelsRcPictureInfoUpdate;
|
||||
PWelsRCMBInitFunc pfWelsRcMbInit;
|
||||
PWelsRCMBInfoUpdateFunc pfWelsRcMbInfoUpdate;
|
||||
PWelsCheckFrameSkipBasedMaxbrFunc pfWelsCheckSkipBasedMaxbr;
|
||||
PWelsUpdateBufferWhenFrameSkippedFunc pfWelsUpdateBufferWhenSkip;
|
||||
PWelsUpdateMaxBrCheckWindowStatusFunc pfWelsUpdateMaxBrWindowStatus;
|
||||
} SWelsRcFunc;
|
||||
|
||||
bool CheckFrameSkipBasedMaxbr (void* pCtx, int32_t iSpatialNum, EVideoFrameType eFrameType,
|
||||
bool CheckFrameSkipBasedMaxbr (sWelsEncCtx* pCtx, int32_t iSpatialNum, EVideoFrameType eFrameType,
|
||||
const uint32_t uiTimeStamp);
|
||||
void UpdateBufferWhenFrameSkipped(void* pCtx, int32_t iSpatialNum);
|
||||
void UpdateMaxBrCheckWindowStatus(void* pCtx, int32_t iSpatialNum, const long long uiTimeStamp);
|
||||
void RcTraceFrameBits (void* pEncCtx, long long uiTimeStamp);
|
||||
void WelsRcInitModule (void* pCtx, RC_MODES iRcMode);
|
||||
void WelsRcFreeMemory (void* pCtx);
|
||||
void UpdateBufferWhenFrameSkipped(sWelsEncCtx* pCtx, int32_t iSpatialNum);
|
||||
void UpdateMaxBrCheckWindowStatus(sWelsEncCtx* pCtx, int32_t iSpatialNum, const long long uiTimeStamp);
|
||||
void RcTraceFrameBits (sWelsEncCtx* pEncCtx, long long uiTimeStamp);
|
||||
void WelsRcInitModule (sWelsEncCtx* pCtx, RC_MODES iRcMode);
|
||||
void WelsRcFreeMemory (sWelsEncCtx* pCtx);
|
||||
|
||||
}
|
||||
#endif //RC_H
|
||||
|
||||
@@ -93,6 +93,8 @@ int16_t iMbWidth; // MB width of this picture, equal to pSps.iMbWidth
|
||||
int16_t iMbHeight; // MB height of this picture, equal to pSps.iMbHeight;
|
||||
|
||||
bool bBaseLayerAvailableFlag; // whether base layer is available for prediction?
|
||||
bool bSatdInMdFlag; // whether SATD is calculated in ME and integer-pel MD
|
||||
|
||||
uint8_t iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries
|
||||
int8_t iLoopFilterAlphaC0Offset;// AlphaOffset: valid range [-6, 6], default 0
|
||||
int8_t iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0
|
||||
|
||||
@@ -50,9 +50,9 @@ typedef struct TagMB {
|
||||
/*************************mb_layer() syntax and generated********************************/
|
||||
/*mb_layer():*/
|
||||
Mb_Type uiMbType; // including MB detailed partition type, number and type of reference list
|
||||
int16_t iMbXY; // offset position of MB top left point based
|
||||
int16_t iMbX; // position of MB in horizontal axis
|
||||
int16_t iMbY; // position of MB in vertical axis
|
||||
int32_t iMbXY; // offset position of MB top left point based
|
||||
int16_t iMbX; // position of MB in horizontal axis [0..32767]
|
||||
int16_t iMbY; // position of MB in vertical axis [0..32767]
|
||||
|
||||
uint8_t uiNeighborAvail; // avail && same_slice: LEFT_MB_POS:0x01, TOP_MB_POS:0x02, TOPRIGHT_MB_POS = 0x04 ,TOPLEFT_MB_POS = 0x08;
|
||||
uint8_t uiCbp;
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
#include "codec_app_def.h"
|
||||
#include "set_mb_syn_cabac.h"
|
||||
|
||||
using namespace WelsCommon;
|
||||
|
||||
namespace WelsEnc {
|
||||
|
||||
|
||||
@@ -78,10 +80,10 @@ typedef struct SlicepEncCtx_s {
|
||||
SliceModeEnum uiSliceMode; /* 0: single slice in frame; 1: multiple slices in frame; */
|
||||
int16_t iMbWidth; /* width of picture size in mb */
|
||||
int16_t iMbHeight; /* height of picture size in mb */
|
||||
int16_t iSliceNumInFrame; /* count number of slices in frame; */
|
||||
int32_t iSliceNumInFrame; /* count number of slices in frame; */
|
||||
int32_t iMbNumInFrame; /* count number of MBs in frame */
|
||||
uint16_t* pOverallMbMap; /* overall MB map in frame, store virtual slice idc; */
|
||||
int16_t* pFirstMbInSlice; /* first MB address top-left based in every slice respectively; */
|
||||
int32_t* pFirstMbInSlice; /* first MB address top-left based in every slice respectively; */
|
||||
int32_t* pCountMbNumInSlice; /* count number of MBs in every slice respectively; */
|
||||
uint32_t uiSliceSizeConstraint;/*in byte*/
|
||||
int32_t iMaxSliceNumConstraint;/*maximal number of slices constraint*/
|
||||
@@ -140,7 +142,7 @@ void UninitSlicePEncCtx (SSliceCtx* pSliceCtx, CMemoryAlign* pMa);
|
||||
*
|
||||
* \return uiSliceIdc - successful; (uint8_t)(-1) - failed;
|
||||
*/
|
||||
uint16_t WelsMbToSliceIdc (SSliceCtx* pSliceCtx, const int16_t kiMbXY);
|
||||
uint16_t WelsMbToSliceIdc (SSliceCtx* pSliceCtx, const int32_t kiMbXY);
|
||||
|
||||
/*!
|
||||
* \brief Get first mb in slice/slice_group: uiSliceIdc (apply in Single/multiple slices and FMO)
|
||||
@@ -160,7 +162,7 @@ int32_t WelsGetFirstMbOfSlice (SSliceCtx* pSliceCtx, const int32_t kiSliceIdc);
|
||||
*
|
||||
* \return next_mb - successful; -1 - failed;
|
||||
*/
|
||||
int32_t WelsGetNextMbOfSlice (SSliceCtx* pSliceCtx, const int16_t kiMbXY);
|
||||
int32_t WelsGetNextMbOfSlice (SSliceCtx* pSliceCtx, const int32_t kiMbXY);
|
||||
|
||||
/*!
|
||||
* \brief Get previous mb to be processed in slice/slice_group: uiSliceIdc (apply in Single/multiple slices and FMO)
|
||||
@@ -170,7 +172,7 @@ int32_t WelsGetNextMbOfSlice (SSliceCtx* pSliceCtx, const int16_t kiMbXY);
|
||||
*
|
||||
* \return prev_mb - successful; -1 - failed;
|
||||
*/
|
||||
int32_t WelsGetPrevMbOfSlice (SSliceCtx* pSliceCtx, const int16_t kiMbXY);
|
||||
int32_t WelsGetPrevMbOfSlice (SSliceCtx* pSliceCtx, const int32_t kiMbXY);
|
||||
|
||||
/*!
|
||||
* \brief Get number of mb in slice/slice_group: uiSliceIdc (apply in Single/multiple slices and FMO)
|
||||
|
||||
@@ -83,9 +83,19 @@ typedef struct TagParaSetOffset {
|
||||
bool
|
||||
bPpsIdMappingIntoSubsetsps[MAX_DQ_LAYER_NUM/*+1*/]; // need not extra +1 due no MGS and FMO case so far
|
||||
|
||||
int32_t iPpsIdList[MAX_DQ_LAYER_NUM][MAX_PPS_COUNT]; //index0: max pps types; index1: for differnt IDRs, if only index0=1, index1 can reach MAX_PPS_COUNT
|
||||
|
||||
#if _DEBUG
|
||||
bool bEnableSpsPpsIdAddition;
|
||||
int32_t eSpsPpsIdStrategy;
|
||||
#endif
|
||||
|
||||
uint32_t uiNeededSpsNum;
|
||||
uint32_t uiNeededSubsetSpsNum;
|
||||
uint32_t uiNeededPpsNum;
|
||||
|
||||
uint32_t uiInUseSpsNum;
|
||||
uint32_t uiInUseSubsetSpsNum;
|
||||
uint32_t uiInUsePpsNum;
|
||||
} SParaSetOffset;
|
||||
|
||||
|
||||
|
||||
@@ -31,39 +31,20 @@
|
||||
*/
|
||||
|
||||
//wels_const.h
|
||||
#ifndef WELS_CONSTANCE_H__
|
||||
#define WELS_CONSTANCE_H__
|
||||
#ifndef WELS_CONST_H__
|
||||
#define WELS_CONST_H__
|
||||
|
||||
#include "as264_common.h" // to communicate with specific macros there, 3/18/2010
|
||||
#include "codec_app_def.h"
|
||||
#include "wels_const_common.h"
|
||||
|
||||
/* To control number of spatial, quality and temporal layers constraint by application layer? */
|
||||
#define NUM_SPATIAL_LAYERS_CONSTRAINT
|
||||
#define NUM_QUALITY_LAYERS_CONSTRAINT
|
||||
|
||||
|
||||
// Miscellaneous sizing infos
|
||||
#ifndef MAX_FNAME_LEN
|
||||
#define MAX_FNAME_LEN 256 // maximal length of file name in char size
|
||||
#endif//MAX_FNAME_LEN
|
||||
|
||||
#ifndef WELS_LOG_BUF_SIZE
|
||||
#define WELS_LOG_BUF_SIZE 4096
|
||||
#endif//WELS_LOG_BUF_SIZE
|
||||
|
||||
#ifndef MAX_TRACE_LOG_SIZE
|
||||
#define MAX_TRACE_LOG_SIZE (50 * (1<<20)) // max trace log size: 50 MB, overwrite occur if log file size exceeds this size
|
||||
#endif//MAX_TRACE_LOG_SIZE
|
||||
|
||||
#define STATISTICS_LOG_INTERVAL_MS (5000) // output statistics log every 5s
|
||||
|
||||
/* MB width in pixels for specified colorspace I420 usually used in codec */
|
||||
#define MB_WIDTH_LUMA 16
|
||||
#define MB_WIDTH_CHROMA (MB_WIDTH_LUMA>>1)
|
||||
/* MB height in pixels for specified colorspace I420 usually used in codec */
|
||||
#define MB_HEIGHT_LUMA 16
|
||||
#define MB_HEIGHT_CHROMA (MB_HEIGHT_LUMA>>1)
|
||||
|
||||
/* Some list size */
|
||||
#define MB_COEFF_LIST_SIZE (256+((MB_WIDTH_CHROMA*MB_HEIGHT_CHROMA)<<1))
|
||||
#define MB_REQ_LUMA_CACHE_SIZE 40 // 8x5 Size of MB cache only luma component required to store
|
||||
@@ -125,9 +106,11 @@
|
||||
#endif//PPS_BUFFER_SIZE
|
||||
|
||||
#if !defined(MAX_MACROBLOCK_SIZE_IN_BYTE)
|
||||
#define MAX_MACROBLOCK_SIZE_IN_BYTE 800 //3200*2/8
|
||||
#define MAX_MACROBLOCK_SIZE_IN_BYTE 400 //3200/8, 3200 is from Annex A.3.1.(n)
|
||||
#endif
|
||||
|
||||
#define MAX_MACROBLOCK_SIZE_IN_BYTE_x2 (MAX_MACROBLOCK_SIZE_IN_BYTE<<1)
|
||||
|
||||
#if defined(NUM_SPATIAL_LAYERS_CONSTRAINT)
|
||||
#define MAX_DEPENDENCY_LAYER MAX_SPATIAL_LAYER_NUM // Maximal dependency layer
|
||||
#else
|
||||
@@ -171,6 +154,7 @@
|
||||
|
||||
#define UNAVAILABLE_DQ_ID ((uint8_t)(-1))
|
||||
#define LAYER_NUM_EXCHANGEABLE 2
|
||||
#define INVALID_ID (-1)
|
||||
|
||||
#define NAL_HEADER_ADD_0X30BYTES 50
|
||||
|
||||
@@ -214,4 +198,4 @@ enum {
|
||||
};
|
||||
//TODO: need to complete the return checking in encoder and fill in more types if needed
|
||||
|
||||
#endif//WELS_CONSTANCE_H__
|
||||
#endif//WELS_CONST_H__
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "expand_pic.h"
|
||||
#include "rc.h"
|
||||
#include "IWelsVP.h"
|
||||
#include "mc.h"
|
||||
|
||||
namespace WelsEnc {
|
||||
|
||||
@@ -74,25 +75,6 @@ typedef int32_t (*PQuantizationSkipFunc) (int16_t* pDct, int16_t iFF, int16_t i
|
||||
typedef int32_t (*PQuantizationHadamardFunc) (int16_t* pRes, const int16_t kiFF, int16_t iMF, int16_t* pDct,
|
||||
int16_t* pBlock);
|
||||
|
||||
typedef void (*PWelsMcFunc) (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
SMVUnitXY mv, int32_t iWidth, int32_t iHeight);
|
||||
|
||||
typedef void (*PWelsLumaHalfpelMcFunc) (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight);
|
||||
typedef void (*PWelsLumaQuarpelMcFunc) (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight);
|
||||
typedef void (*PWelsSampleAveragingFunc) (uint8_t*, int32_t, const uint8_t*, int32_t, const uint8_t*, int32_t, int32_t);
|
||||
|
||||
typedef struct TagMcFunc {
|
||||
PWelsLumaHalfpelMcFunc pfLumaHalfpelHor;
|
||||
PWelsLumaHalfpelMcFunc pfLumaHalfpelVer;
|
||||
PWelsLumaHalfpelMcFunc pfLumaHalfpelCen;
|
||||
PWelsMcFunc pfChromaMc;
|
||||
|
||||
PWelsLumaQuarpelMcFunc pfLumaQuarpelMc[16];
|
||||
PWelsSampleAveragingFunc pfSampleAveraging[2];
|
||||
} SMcFunc;
|
||||
|
||||
typedef void (*PLumaDeblockingLT4Func) (uint8_t* iSampleY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* iTc);
|
||||
typedef void (*PLumaDeblockingEQ4Func) (uint8_t* iSampleY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
|
||||
typedef void (*PChromaDeblockingLT4Func) (uint8_t* iSampleCb, uint8_t* iSampleCr, int32_t iStride, int32_t iAlpha,
|
||||
|
||||
@@ -62,9 +62,9 @@ typedef struct {
|
||||
|
||||
|
||||
typedef struct {
|
||||
int32_t iMinFrameComplexity;
|
||||
int32_t iMinFrameComplexity08;
|
||||
int32_t iMinFrameComplexity11;
|
||||
int64_t iMinFrameComplexity;
|
||||
int64_t iMinFrameComplexity08;
|
||||
int64_t iMinFrameComplexity11;
|
||||
|
||||
int32_t iMinFrameNumGap;
|
||||
int32_t iMinFrameQp;
|
||||
@@ -145,6 +145,7 @@ class CWelsPreProcess {
|
||||
int32_t WelsPreprocessCreate();
|
||||
int32_t WelsPreprocessDestroy();
|
||||
int32_t InitLastSpatialPictures (sWelsEncCtx* pEncCtx);
|
||||
int32_t GetCurPicPosition(const int32_t kiDidx);
|
||||
|
||||
private:
|
||||
int32_t SingleLayerPreprocess (sWelsEncCtx* pEncCtx, const SSourcePicture* kpSrc, Scaled_Picture* m_sScaledPicture);
|
||||
@@ -152,7 +153,8 @@ class CWelsPreProcess {
|
||||
void BilateralDenoising (SPicture* pSrc, const int32_t iWidth, const int32_t iHeight);
|
||||
bool DetectSceneChange (SPicture* pCurPicture, SPicture* pRefPicture);
|
||||
int32_t DownsamplePadding (SPicture* pSrc, SPicture* pDstPic, int32_t iSrcWidth, int32_t iSrcHeight,
|
||||
int32_t iShrinkWidth, int32_t iShrinkHeight, int32_t iTargetWidth, int32_t iTargetHeight);
|
||||
int32_t iShrinkWidth, int32_t iShrinkHeight, int32_t iTargetWidth, int32_t iTargetHeight,
|
||||
bool bForceCopy);
|
||||
|
||||
void VaaCalculation (SVAAFrameInfo* pVaaInfo, SPicture* pCurPicture, SPicture* pRefPicture, bool bCalculateSQDiff,
|
||||
bool bCalculateVar, bool bCalculateBGD);
|
||||
@@ -175,9 +177,9 @@ class CWelsPreProcess {
|
||||
void GetAvailableRefList (SPicture** pSrcPicList, uint8_t iCurTid, const int32_t iClosestLtrFrameNum,
|
||||
SRefInfoParam* pAvailableRefList, int32_t& iAvailableRefNum, int32_t& iAvailableSceneRefNum);
|
||||
void InitRefJudgement (SRefJudgement* pRefJudgement);
|
||||
bool JudgeBestRef (SPicture* pRefPic, const SRefJudgement& sRefJudgement, const int32_t iFrameComplexity,
|
||||
bool JudgeBestRef (SPicture* pRefPic, const SRefJudgement& sRefJudgement, const int64_t iFrameComplexity,
|
||||
const bool bIsClosestLtrFrame);
|
||||
void SaveBestRefToJudgement (const int32_t iRefPictureAvQP, const int32_t iComplexity, SRefJudgement* pRefJudgement);
|
||||
void SaveBestRefToJudgement (const int32_t iRefPictureAvQP, const int64_t iComplexity, SRefJudgement* pRefJudgement);
|
||||
void SaveBestRefToLocal (SRefInfoParam* pRefPicInfo, const SSceneChangeResult& sSceneChangeResult,
|
||||
SRefInfoParam* pRefSaved);
|
||||
void SaveBestRefToVaa (SRefInfoParam& sRefSaved, SRefInfoParam* pVaaBestRef);
|
||||
|
||||
@@ -65,7 +65,7 @@ static inline int32_t WelsCheckLevelLimitation (const SWelsSPS* kpSps, const SLe
|
||||
return 0;
|
||||
if (kpLevelLimit->uiMaxDPBMbs < uiNumRefFrames * uiPicInMBs)
|
||||
return 0;
|
||||
if (iTargetBitRate
|
||||
if ((iTargetBitRate != UNSPECIFIED_BIT_RATE)
|
||||
&& ((int32_t) kpLevelLimit->uiMaxBR * 1200) < iTargetBitRate) //RC enabled, considering bitrate constraint
|
||||
return 0;
|
||||
//add more checks here if needed in future
|
||||
@@ -86,32 +86,106 @@ int32_t WelsAdjustLevel (SSpatialLayerConfig* pSpatialLayer) {
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
int32_t WelsCheckRefFrameLimitation (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam) {
|
||||
|
||||
static int32_t WelsCheckNumRefSetting (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam, bool bStrictCheck) {
|
||||
// validate LTR num
|
||||
int32_t iCurrentSupportedLtrNum = (pParam->iUsageType == CAMERA_VIDEO_REAL_TIME) ? LONG_TERM_REF_NUM :
|
||||
LONG_TERM_REF_NUM_SCREEN;
|
||||
if ((pParam->bEnableLongTermReference) && (iCurrentSupportedLtrNum != pParam->iLTRRefNum)) {
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING, "iLTRRefNum(%d) does not equal to currently supported %d, will be reset",
|
||||
pParam->iLTRRefNum, iCurrentSupportedLtrNum);
|
||||
pParam->iLTRRefNum = iCurrentSupportedLtrNum;
|
||||
} else if (!pParam->bEnableLongTermReference) {
|
||||
pParam->iLTRRefNum = 0;
|
||||
}
|
||||
|
||||
//TODO: here is a fix needed here, the most reasonable value should be:
|
||||
// iCurrentStrNum = WELS_MAX (1, WELS_LOG2 (pParam->uiGopSize));
|
||||
// but reference list updating need to be changed
|
||||
int32_t iCurrentStrNum = ((pParam->iUsageType == SCREEN_CONTENT_REAL_TIME && pParam->bEnableLongTermReference)
|
||||
? (WELS_MAX (1, WELS_LOG2 (pParam->uiGopSize)))
|
||||
: (WELS_MAX (1, (pParam->uiGopSize >> 1))));
|
||||
int32_t iNeededRefNum = (pParam->uiIntraPeriod != 1) ? (iCurrentStrNum + pParam->iLTRRefNum) : 0;
|
||||
|
||||
iNeededRefNum = WELS_CLIP3 (iNeededRefNum,
|
||||
MIN_REF_PIC_COUNT,
|
||||
(pParam->iUsageType == CAMERA_VIDEO_REAL_TIME) ? MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA :
|
||||
MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN);
|
||||
// to adjust default or invalid input, in case pParam->iNumRefFrame do not have a valid value for the next step
|
||||
if (pParam->iNumRefFrame == AUTO_REF_PIC_COUNT) {
|
||||
pParam->iNumRefFrame = iNeededRefNum;
|
||||
} else if (pParam->iNumRefFrame < iNeededRefNum) {
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING,
|
||||
"iNumRefFrame(%d) setting does not support the temporal and LTR setting, will be reset to %d",
|
||||
pParam->iNumRefFrame, iNeededRefNum);
|
||||
if (bStrictCheck) {
|
||||
return ENC_RETURN_UNSUPPORTED_PARA;
|
||||
}
|
||||
pParam->iNumRefFrame = iNeededRefNum;
|
||||
}
|
||||
|
||||
// after adjustment, do the following:
|
||||
// if the setting is larger than needed, we will use the needed, and write the max into sps and for memory to wait for further expanding
|
||||
if (pParam->iMaxNumRefFrame < pParam->iNumRefFrame) {
|
||||
pParam->iMaxNumRefFrame = pParam->iNumRefFrame;
|
||||
}
|
||||
pParam->iNumRefFrame = iNeededRefNum;
|
||||
|
||||
return ENC_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t WelsCheckRefFrameLimitationNumRefFirst (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam) {
|
||||
|
||||
if (WelsCheckNumRefSetting (pLogCtx, pParam, true)) {
|
||||
// we take num-ref as the honored setting but it conflicts with temporal and LTR
|
||||
return ENC_RETURN_UNSUPPORTED_PARA;
|
||||
}
|
||||
return ENC_RETURN_SUCCESS;
|
||||
}
|
||||
int32_t WelsCheckRefFrameLimitationLevelIdcFirst (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam) {
|
||||
if ((pParam->iNumRefFrame == AUTO_REF_PIC_COUNT) || (pParam->iMaxNumRefFrame == AUTO_REF_PIC_COUNT)) {
|
||||
//no need to do the checking
|
||||
return ENC_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
WelsCheckNumRefSetting (pLogCtx, pParam, false);
|
||||
|
||||
int32_t i = 0;
|
||||
int32_t iRefFrame = 1;
|
||||
int32_t iRefFrame;
|
||||
//get the number of reference frame according to level limitation.
|
||||
for (i = 0; i < pParam->iSpatialLayerNum; ++ i) {
|
||||
SSpatialLayerConfig* pSpatialLayer = &pParam->sSpatialLayers[i];
|
||||
uint32_t uiPicInMBs = ((pSpatialLayer->iVideoHeight + 15) >> 4) * ((pSpatialLayer->iVideoWidth + 15) >> 4);
|
||||
if (pSpatialLayer->uiLevelIdc == LEVEL_UNKNOWN) {
|
||||
pSpatialLayer->uiLevelIdc = LEVEL_5_0;
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING, "change level to level5.0");
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t uiPicInMBs = ((pSpatialLayer->iVideoHeight + 15) >> 4) * ((pSpatialLayer->iVideoWidth + 15) >> 4);
|
||||
iRefFrame = g_ksLevelLimits[pSpatialLayer->uiLevelIdc - 1].uiMaxDPBMbs / uiPicInMBs;
|
||||
|
||||
//check iMaxNumRefFrame
|
||||
if (iRefFrame < pParam->iMaxNumRefFrame) {
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING, "iMaxNumRefFrame(%d) adjusted to %d because of limitation from uiLevelIdc=%d",
|
||||
pParam->iMaxNumRefFrame, iRefFrame, pSpatialLayer->uiLevelIdc);
|
||||
pParam->iMaxNumRefFrame = iRefFrame;
|
||||
|
||||
//check iNumRefFrame
|
||||
if (iRefFrame < pParam->iNumRefFrame) {
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING, "iNumRefFrame(%d) adjusted to %d because of limitation from uiLevelIdc=%d",
|
||||
pParam->iNumRefFrame, iRefFrame, pSpatialLayer->uiLevelIdc);
|
||||
pParam->iNumRefFrame = iRefFrame;
|
||||
}
|
||||
} else {
|
||||
//because it is level first now, so adjust max-ref
|
||||
WelsLog (pLogCtx, WELS_LOG_INFO,
|
||||
"iMaxNumRefFrame(%d) adjusted to %d because of uiLevelIdc=%d -- under level-idc first strategy ",
|
||||
pParam->iMaxNumRefFrame, iRefFrame, pSpatialLayer->uiLevelIdc);
|
||||
pParam->iMaxNumRefFrame = iRefFrame;
|
||||
if (pParam->iMaxNumRefFrame < pParam->iNumRefFrame)
|
||||
pParam->iNumRefFrame = pParam->iMaxNumRefFrame;
|
||||
}
|
||||
if (pParam->iMaxNumRefFrame < 1) {
|
||||
pParam->iMaxNumRefFrame = 1;
|
||||
WelsLog (pLogCtx, WELS_LOG_ERROR, "error Level setting (%d)", pSpatialLayer->uiLevelIdc);
|
||||
return ENC_RETURN_UNSUPPORTED_PARA;
|
||||
}
|
||||
}
|
||||
|
||||
return ENC_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
static inline ELevelIdc WelsGetLevelIdc (const SWelsSPS* kpSps, float fFrameRate, int32_t iTargetBitRate) {
|
||||
int32_t iOrder;
|
||||
for (iOrder = 0; iOrder < LEVEL_NUMBER; iOrder++) {
|
||||
@@ -122,6 +196,32 @@ static inline ELevelIdc WelsGetLevelIdc (const SWelsSPS* kpSps, float fFrameRate
|
||||
return LEVEL_5_1; //final decision: select the biggest level
|
||||
}
|
||||
|
||||
int32_t WelsWriteVUI (SWelsSPS* pSps, SBitStringAux* pBitStringAux) {
|
||||
SBitStringAux* pLocalBitStringAux = pBitStringAux;
|
||||
assert (pSps != NULL && pBitStringAux != NULL);
|
||||
|
||||
BsWriteOneBit (pLocalBitStringAux, false); //aspect_ratio_info_present_flag
|
||||
BsWriteOneBit (pLocalBitStringAux, false); //overscan_info_present_flag
|
||||
BsWriteOneBit (pLocalBitStringAux, false); //video_signal_type_present_flag
|
||||
BsWriteOneBit (pLocalBitStringAux, false); //chroma_loc_info_present_flag
|
||||
BsWriteOneBit (pLocalBitStringAux, false); //timing_info_present_flag
|
||||
BsWriteOneBit (pLocalBitStringAux, false); //nal_hrd_parameters_present_flag
|
||||
BsWriteOneBit (pLocalBitStringAux, false); //vcl_hrd_parameters_present_flag
|
||||
BsWriteOneBit (pLocalBitStringAux, false); //pic_struct_present_flag
|
||||
BsWriteOneBit (pLocalBitStringAux, true); //bitstream_restriction_flag
|
||||
|
||||
//
|
||||
BsWriteOneBit (pLocalBitStringAux, true); //motion_vectors_over_pic_boundaries_flag
|
||||
BsWriteUE (pLocalBitStringAux, 0); //max_bytes_per_pic_denom
|
||||
BsWriteUE (pLocalBitStringAux, 0); //max_bits_per_mb_denom
|
||||
BsWriteUE (pLocalBitStringAux, 16); //log2_max_mv_length_horizontal
|
||||
BsWriteUE (pLocalBitStringAux, 16); //log2_max_mv_length_vertical
|
||||
|
||||
BsWriteUE (pLocalBitStringAux, 0); //max_num_reorder_frames
|
||||
BsWriteUE (pLocalBitStringAux, pSps->iNumRefFrames); //max_dec_frame_buffering
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
*************************************************************************************
|
||||
@@ -136,7 +236,7 @@ static inline ELevelIdc WelsGetLevelIdc (const SWelsSPS* kpSps, float fFrameRate
|
||||
* \note Call it in case EWelsNalUnitType is SPS.
|
||||
*************************************************************************************
|
||||
*/
|
||||
int32_t WelsWriteSpsSyntax (SWelsSPS* pSps, SBitStringAux* pBitStringAux, int32_t* pSpsIdDelta) {
|
||||
int32_t WelsWriteSpsSyntax (SWelsSPS* pSps, SBitStringAux* pBitStringAux, int32_t* pSpsIdDelta, bool bBaseLayer) {
|
||||
SBitStringAux* pLocalBitStringAux = pBitStringAux;
|
||||
|
||||
assert (pSps != NULL && pBitStringAux != NULL);
|
||||
@@ -167,7 +267,7 @@ int32_t WelsWriteSpsSyntax (SWelsSPS* pSps, SBitStringAux* pBitStringAux, int32_
|
||||
BsWriteUE (pLocalBitStringAux, pSps->iLog2MaxPocLsb - 4); // log2_max_pic_order_cnt_lsb_minus4
|
||||
|
||||
BsWriteUE (pLocalBitStringAux, pSps->iNumRefFrames); // max_num_ref_frames
|
||||
BsWriteOneBit (pLocalBitStringAux, true/*pSps->bGapsInFrameNumValueAllowedFlag*/); // bGapsInFrameNumValueAllowedFlag
|
||||
BsWriteOneBit (pLocalBitStringAux, pSps->bGapsInFrameNumValueAllowedFlag); //gaps_in_frame_numvalue_allowed_flag
|
||||
BsWriteUE (pLocalBitStringAux, pSps->iMbWidth - 1); // pic_width_in_mbs_minus1
|
||||
BsWriteUE (pLocalBitStringAux, pSps->iMbHeight - 1); // pic_height_in_map_units_minus1
|
||||
BsWriteOneBit (pLocalBitStringAux, true/*pSps->bFrameMbsOnlyFlag*/); // bFrameMbsOnlyFlag
|
||||
@@ -180,15 +280,18 @@ int32_t WelsWriteSpsSyntax (SWelsSPS* pSps, SBitStringAux* pBitStringAux, int32_
|
||||
BsWriteUE (pLocalBitStringAux, pSps->sFrameCrop.iCropTop); // frame_crop_top_offset
|
||||
BsWriteUE (pLocalBitStringAux, pSps->sFrameCrop.iCropBottom); // frame_crop_bottom_offset
|
||||
}
|
||||
|
||||
BsWriteOneBit (pLocalBitStringAux, 0/*pSps->bVuiParamPresentFlag*/); // vui_parameters_present_flag
|
||||
|
||||
if (bBaseLayer) {
|
||||
BsWriteOneBit (pLocalBitStringAux, true); // vui_parameters_present_flag
|
||||
WelsWriteVUI (pSps, pBitStringAux);
|
||||
} else {
|
||||
BsWriteOneBit (pLocalBitStringAux, false);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t WelsWriteSpsNal (SWelsSPS* pSps, SBitStringAux* pBitStringAux, int32_t* pSpsIdDelta) {
|
||||
WelsWriteSpsSyntax (pSps, pBitStringAux, pSpsIdDelta);
|
||||
WelsWriteSpsSyntax (pSps, pBitStringAux, pSpsIdDelta, true);
|
||||
|
||||
BsRbspTrailingBits (pBitStringAux);
|
||||
|
||||
@@ -212,7 +315,7 @@ int32_t WelsWriteSpsNal (SWelsSPS* pSps, SBitStringAux* pBitStringAux, int32_t*
|
||||
int32_t WelsWriteSubsetSpsSyntax (SSubsetSps* pSubsetSps, SBitStringAux* pBitStringAux , int32_t* pSpsIdDelta) {
|
||||
SWelsSPS* pSps = &pSubsetSps->pSps;
|
||||
|
||||
WelsWriteSpsSyntax (pSps, pBitStringAux, pSpsIdDelta);
|
||||
WelsWriteSpsSyntax (pSps, pBitStringAux, pSpsIdDelta, false);
|
||||
|
||||
if (pSps->uiProfileIdc == PRO_SCALABLE_BASELINE || pSps->uiProfileIdc == PRO_SCALABLE_HIGH) {
|
||||
SSpsSvcExt* pSubsetSpsExt = &pSubsetSps->sSpsSvcExt;
|
||||
@@ -257,27 +360,27 @@ int32_t WelsWriteSubsetSpsSyntax (SSubsetSps* pSubsetSps, SBitStringAux* pBitStr
|
||||
* \note Call it in case EWelsNalUnitType is PPS.
|
||||
*************************************************************************************
|
||||
*/
|
||||
int32_t WelsWritePpsSyntax (SWelsPPS* pPps, SBitStringAux* pBitStringAux, SParaSetOffset* sPSOVector) {
|
||||
int32_t WelsWritePpsSyntax (SWelsPPS* pPps, SBitStringAux* pBitStringAux, SParaSetOffset* pPSOVector) {
|
||||
SBitStringAux* pLocalBitStringAux = pBitStringAux;
|
||||
|
||||
bool bUsedSubset = sPSOVector->bPpsIdMappingIntoSubsetsps[pPps->iPpsId];
|
||||
int32_t iParameterSetType = (bUsedSubset ? PARA_SET_TYPE_SUBSETSPS : PARA_SET_TYPE_AVCSPS);
|
||||
const int32_t kiParameterSetType = (pPSOVector != NULL) ? (pPSOVector->bPpsIdMappingIntoSubsetsps[pPps->iPpsId] ?
|
||||
PARA_SET_TYPE_SUBSETSPS : PARA_SET_TYPE_AVCSPS) : 0;
|
||||
|
||||
BsWriteUE (pLocalBitStringAux, pPps->iPpsId +
|
||||
sPSOVector->sParaSetOffsetVariable[PARA_SET_TYPE_PPS].iParaSetIdDelta[pPps->iPpsId]);
|
||||
BsWriteUE (pLocalBitStringAux, pPps->iSpsId +
|
||||
sPSOVector->sParaSetOffsetVariable[iParameterSetType].iParaSetIdDelta[pPps->iSpsId]);
|
||||
BsWriteUE (pLocalBitStringAux, pPps->iPpsId
|
||||
+ ((pPSOVector != NULL) ? (pPSOVector->sParaSetOffsetVariable[PARA_SET_TYPE_PPS].iParaSetIdDelta[pPps->iPpsId]) : 0));
|
||||
BsWriteUE (pLocalBitStringAux, pPps->iSpsId
|
||||
+ ((pPSOVector != NULL) ? (pPSOVector->sParaSetOffsetVariable[kiParameterSetType].iParaSetIdDelta[pPps->iSpsId]) : 0));
|
||||
|
||||
#if _DEBUG
|
||||
//SParaSetOffset use, 110421
|
||||
if (sPSOVector->bEnableSpsPpsIdAddition) {
|
||||
if ((pPSOVector != NULL) && (INCREASING_ID & pPSOVector->eSpsPpsIdStrategy)) {
|
||||
const int32_t kiTmpSpsIdInBs = pPps->iSpsId +
|
||||
sPSOVector->sParaSetOffsetVariable[iParameterSetType].iParaSetIdDelta[pPps->iSpsId];
|
||||
pPSOVector->sParaSetOffsetVariable[kiParameterSetType].iParaSetIdDelta[pPps->iSpsId];
|
||||
const int32_t tmp_pps_id_in_bs = pPps->iPpsId +
|
||||
sPSOVector->sParaSetOffsetVariable[PARA_SET_TYPE_PPS].iParaSetIdDelta[pPps->iPpsId];
|
||||
pPSOVector->sParaSetOffsetVariable[PARA_SET_TYPE_PPS].iParaSetIdDelta[pPps->iPpsId];
|
||||
assert (MAX_SPS_COUNT > kiTmpSpsIdInBs);
|
||||
assert (MAX_PPS_COUNT > tmp_pps_id_in_bs);
|
||||
assert (sPSOVector->sParaSetOffsetVariable[iParameterSetType].bUsedParaSetIdInBs[kiTmpSpsIdInBs]);
|
||||
assert (pPSOVector->sParaSetOffsetVariable[kiParameterSetType].bUsedParaSetIdInBs[kiTmpSpsIdInBs]);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -363,9 +466,8 @@ static inline bool WelsGetPaddingOffset (int32_t iActualWidth, int32_t iActualHe
|
||||
int32_t WelsInitSps (SWelsSPS* pSps, SSpatialLayerConfig* pLayerParam, SSpatialLayerInternal* pLayerParamInternal,
|
||||
const uint32_t kuiIntraPeriod, const int32_t kiNumRefFrame,
|
||||
const uint32_t kuiSpsId, const bool kbEnableFrameCropping, bool bEnableRc,
|
||||
const int32_t kiDlayerCount) {
|
||||
const int32_t kiDlayerCount, bool bSVCBaselayer) {
|
||||
memset (pSps, 0, sizeof (SWelsSPS));
|
||||
ELevelIdc uiLevel = LEVEL_5_2;
|
||||
pSps->uiSpsId = kuiSpsId;
|
||||
pSps->iMbWidth = (pLayerParam->iVideoWidth + 15) >> 4;
|
||||
pSps->iMbHeight = (pLayerParam->iVideoHeight + 15) >> 4;
|
||||
@@ -383,26 +485,18 @@ int32_t WelsInitSps (SWelsSPS* pSps, SSpatialLayerConfig* pLayerParam, SSpatialL
|
||||
} else {
|
||||
pSps->bFrameCroppingFlag = false;
|
||||
}
|
||||
|
||||
pSps->uiProfileIdc = pLayerParam->uiProfileIdc ? pLayerParam->uiProfileIdc : PRO_BASELINE;
|
||||
|
||||
if (bEnableRc) //fixed QP condition
|
||||
uiLevel = WelsGetLevelIdc (pSps, pLayerParamInternal->fOutputFrameRate, pLayerParam->iSpatialBitrate);
|
||||
else
|
||||
uiLevel = WelsGetLevelIdc (pSps, pLayerParamInternal->fOutputFrameRate,
|
||||
0); // Set tar_br = 0 to remove the bitrate constraint; a better way is to set actual tar_br as 0
|
||||
|
||||
|
||||
if (pLayerParam->uiProfileIdc == PRO_BASELINE) {
|
||||
pSps->bConstraintSet0Flag = true;
|
||||
}
|
||||
if (pLayerParam->uiProfileIdc <= PRO_MAIN) {
|
||||
pSps->bConstraintSet1Flag = true;
|
||||
}
|
||||
if (kiDlayerCount > 1) {
|
||||
if ((kiDlayerCount > 1) && bSVCBaselayer) {
|
||||
pSps->bConstraintSet2Flag = true;
|
||||
}
|
||||
|
||||
ELevelIdc uiLevel = WelsGetLevelIdc (pSps, pLayerParamInternal->fOutputFrameRate, pLayerParam->iSpatialBitrate);
|
||||
//update level
|
||||
//for Scalable Baseline, Scalable High, and Scalable High Intra profiles.If level_idc is equal to 9, the indicated level is level 1b.
|
||||
//for the Baseline, Constrained Baseline, Main, and Extended profiles,If level_idc is equal to 11 and constraint_set3_flag is equal to 1, the indicated level is level 1b.
|
||||
@@ -411,10 +505,18 @@ int32_t WelsInitSps (SWelsSPS* pSps, SSpatialLayerConfig* pLayerParam, SSpatialL
|
||||
uiLevel = LEVEL_1_1;
|
||||
pSps->bConstraintSet3Flag = true;
|
||||
}
|
||||
if (pLayerParam->uiLevelIdc < uiLevel) {
|
||||
if ((pLayerParam->uiLevelIdc == LEVEL_UNKNOWN) || (pLayerParam->uiLevelIdc < uiLevel)) {
|
||||
pLayerParam->uiLevelIdc = uiLevel;
|
||||
}
|
||||
pSps->iLevelIdc = g_kuiLevelMaps[pLayerParam->uiLevelIdc - 1];
|
||||
|
||||
//bGapsInFrameNumValueAllowedFlag is false when only spatial layer number and temporal layer number is 1, and ltr is 0.
|
||||
if ((kiDlayerCount == 1) && (pSps->iNumRefFrames == 1))
|
||||
pSps->bGapsInFrameNumValueAllowedFlag = false;
|
||||
else
|
||||
pSps->bGapsInFrameNumValueAllowedFlag = true;
|
||||
|
||||
pSps->bVuiParamPresentFlag = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -422,13 +524,14 @@ int32_t WelsInitSps (SWelsSPS* pSps, SSpatialLayerConfig* pLayerParam, SSpatialL
|
||||
int32_t WelsInitSubsetSps (SSubsetSps* pSubsetSps, SSpatialLayerConfig* pLayerParam,
|
||||
SSpatialLayerInternal* pLayerParamInternal,
|
||||
const uint32_t kuiIntraPeriod, const int32_t kiNumRefFrame,
|
||||
const uint32_t kuiSpsId, const bool kbEnableFrameCropping, bool bEnableRc) {
|
||||
const uint32_t kuiSpsId, const bool kbEnableFrameCropping, bool bEnableRc,
|
||||
const int32_t kiDlayerCount) {
|
||||
SWelsSPS* pSps = &pSubsetSps->pSps;
|
||||
|
||||
memset (pSubsetSps, 0, sizeof (SSubsetSps));
|
||||
|
||||
WelsInitSps (pSps, pLayerParam, pLayerParamInternal, kuiIntraPeriod, kiNumRefFrame, kuiSpsId, kbEnableFrameCropping,
|
||||
bEnableRc, 1);
|
||||
bEnableRc, kiDlayerCount, false);
|
||||
|
||||
pSps->uiProfileIdc = (pLayerParam->uiProfileIdc >= PRO_SCALABLE_BASELINE) ? pLayerParam->uiProfileIdc :
|
||||
PRO_SCALABLE_BASELINE;
|
||||
|
||||
@@ -774,13 +774,6 @@ void PerformDeblockingFilter (sWelsEncCtx* pEnc) {
|
||||
}
|
||||
}
|
||||
|
||||
void WelsNonZeroCount_c (int8_t* pNonZeroCount) {
|
||||
int32_t i;
|
||||
|
||||
for (i = 0; i < 24; i++) {
|
||||
pNonZeroCount[i] = !!pNonZeroCount[i];
|
||||
}
|
||||
}
|
||||
void WelsBlockFuncInit (PSetNoneZeroCountZeroFunc* pfSetNZCZero, int32_t iCpu) {
|
||||
*pfSetNZCZero = WelsNonZeroCount_c;
|
||||
#ifdef HAVE_NEON
|
||||
@@ -793,6 +786,11 @@ void WelsBlockFuncInit (PSetNoneZeroCountZeroFunc* pfSetNZCZero, int32_t iCpu)
|
||||
*pfSetNZCZero = WelsNonZeroCount_AArch64_neon;
|
||||
}
|
||||
#endif
|
||||
#if defined(X86_ASM)
|
||||
if (iCpu & WELS_CPU_SSE2) {
|
||||
*pfSetNZCZero = WelsNonZeroCount_sse2;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void DeblockingInit (DeblockingFunc* pFunc, int32_t iCpu) {
|
||||
|
||||
@@ -209,7 +209,7 @@ int32_t InitFunctionPointers (sWelsEncCtx* pEncCtx, SWelsSvcCodingParam* pParam,
|
||||
/* Motion compensation */
|
||||
/*init pixel average function*/
|
||||
/*get one column or row pixel when refinement*/
|
||||
WelsInitMcFuncs (pFuncList, uiCpuFlag);
|
||||
InitMcFunc (&pFuncList->sMcFuncs, uiCpuFlag);
|
||||
InitCoeffFunc (pFuncList,uiCpuFlag,pParam->iEntropyCodingModeFlag);
|
||||
|
||||
WelsInitEncodingFuncs (pFuncList, uiCpuFlag);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,849 +0,0 @@
|
||||
/*!
|
||||
* \copy
|
||||
* Copyright (c) 2009-2013, Cisco Systems
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* \file mc.c
|
||||
*
|
||||
* \brief Interfaces implementation for motion compensation
|
||||
*
|
||||
* \date 03/17/2009 Created
|
||||
*
|
||||
*************************************************************************************
|
||||
*/
|
||||
|
||||
#include "mc.h"
|
||||
#include "cpu_core.h"
|
||||
|
||||
namespace WelsEnc {
|
||||
/*------------------weight for chroma fraction pixel interpolation------------------*/
|
||||
//kuiA = (8 - dx) * (8 - dy);
|
||||
//kuiB = dx * (8 - dy);
|
||||
//kuiC = (8 - dx) * dy;
|
||||
//kuiD = dx * dy
|
||||
static const uint8_t g_kuiABCD[8][8][4] = { ////g_kuiA[dy][dx], g_kuiB[dy][dx], g_kuiC[dy][dx], g_kuiD[dy][dx]
|
||||
{
|
||||
{64, 0, 0, 0}, {56, 8, 0, 0}, {48, 16, 0, 0}, {40, 24, 0, 0},
|
||||
{32, 32, 0, 0}, {24, 40, 0, 0}, {16, 48, 0, 0}, {8, 56, 0, 0}
|
||||
},
|
||||
{
|
||||
{56, 0, 8, 0}, {49, 7, 7, 1}, {42, 14, 6, 2}, {35, 21, 5, 3},
|
||||
{28, 28, 4, 4}, {21, 35, 3, 5}, {14, 42, 2, 6}, {7, 49, 1, 7}
|
||||
},
|
||||
{
|
||||
{48, 0, 16, 0}, {42, 6, 14, 2}, {36, 12, 12, 4}, {30, 18, 10, 6},
|
||||
{24, 24, 8, 8}, {18, 30, 6, 10}, {12, 36, 4, 12}, {6, 42, 2, 14}
|
||||
},
|
||||
{
|
||||
{40, 0, 24, 0}, {35, 5, 21, 3}, {30, 10, 18, 6}, {25, 15, 15, 9},
|
||||
{20, 20, 12, 12}, {15, 25, 9, 15}, {10, 30, 6, 18}, {5, 35, 3, 21}
|
||||
},
|
||||
{
|
||||
{32, 0, 32, 0}, {28, 4, 28, 4}, {24, 8, 24, 8}, {20, 12, 20, 12},
|
||||
{16, 16, 16, 16}, {12, 20, 12, 20}, {8, 24, 8, 24}, {4, 28, 4, 28}
|
||||
},
|
||||
{
|
||||
{24, 0, 40, 0}, {21, 3, 35, 5}, {18, 6, 30, 10}, {15, 9, 25, 15},
|
||||
{12, 12, 20, 20}, {9, 15, 15, 25}, {6, 18, 10, 30}, {3, 21, 5, 35}
|
||||
},
|
||||
{
|
||||
{16, 0, 48, 0}, {14, 2, 42, 6}, {12, 4, 36, 12}, {10, 6, 30, 18},
|
||||
{8, 8, 24, 24}, {6, 10, 18, 30}, {4, 12, 12, 36}, {2, 14, 6, 42}
|
||||
},
|
||||
{
|
||||
{8, 0, 56, 0}, {7, 1, 49, 7}, {6, 2, 42, 14}, {5, 3, 35, 21},
|
||||
{4, 4, 28, 28}, {3, 5, 21, 35}, {2, 6, 14, 42}, {1, 7, 7, 49}
|
||||
}
|
||||
};
|
||||
|
||||
//***************************************************************************//
|
||||
// C code implementation //
|
||||
//***************************************************************************//
|
||||
static inline void McCopyWidthEq4_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
int32_t i;
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
memcpy (pDst, pSrc, 4); // confirmed_safe_unsafe_usage
|
||||
pDst += iDstStride;
|
||||
pSrc += iSrcStride;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void McCopyWidthEq8_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight)
|
||||
|
||||
{
|
||||
int32_t i;
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
memcpy (pDst, pSrc, 8); // confirmed_safe_unsafe_usage
|
||||
pDst += iDstStride;
|
||||
pSrc += iSrcStride;
|
||||
}
|
||||
}
|
||||
static inline void McCopyWidthEq16_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
int32_t i;
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
memcpy (pDst, pSrc, 16); // confirmed_safe_unsafe_usage
|
||||
pDst += iDstStride;
|
||||
pSrc += iSrcStride;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------Luma sample MC------------------//
|
||||
static inline int32_t HorFilter_c (const uint8_t* pSrc) {
|
||||
int32_t iPix05 = pSrc[-2] + pSrc[3];
|
||||
int32_t iPix14 = pSrc[-1] + pSrc[2];
|
||||
int32_t iPix23 = pSrc[ 0] + pSrc[1];
|
||||
|
||||
return (iPix05 - ((iPix14 << 2) + iPix14) + (iPix23 << 4) + (iPix23 << 2));
|
||||
}
|
||||
|
||||
static inline int32_t HorFilterInput16bit1_c (int16_t* pSrc) {
|
||||
int32_t iPix05 = pSrc[-2] + pSrc[3];
|
||||
int32_t iPix14 = pSrc[-1] + pSrc[2];
|
||||
int32_t iPix23 = pSrc[ 0] + pSrc[1];
|
||||
|
||||
return (iPix05 - ((iPix14 << 2) + iPix14) + (iPix23 << 4) + (iPix23 << 2));
|
||||
}
|
||||
static inline int32_t VerFilter_c (const uint8_t* pSrc, const int32_t kiSrcStride) {
|
||||
const int32_t kiLine1 = kiSrcStride;
|
||||
const int32_t kiLine2 = (kiSrcStride << 1);
|
||||
const int32_t kiLine3 = kiLine1 + kiLine2;
|
||||
const uint32_t kuiPix05 = * (pSrc - kiLine2) + * (pSrc + kiLine3);
|
||||
const uint32_t kuiPix14 = * (pSrc - kiLine1) + * (pSrc + kiLine2);
|
||||
const uint32_t kuiPix23 = * (pSrc) + * (pSrc + kiLine1);
|
||||
|
||||
return (kuiPix05 - ((kuiPix14 << 2) + kuiPix14) + (kuiPix23 << 4) + (kuiPix23 << 2));
|
||||
}
|
||||
|
||||
static inline void PixelAvgWidthEq8_c (uint8_t* pDst, int32_t iDstStride, const uint8_t* pSrcA, int32_t iSrcAStride,
|
||||
const uint8_t* pSrcB, int32_t iSrcBStride, int32_t iHeight) {
|
||||
int32_t i, j;
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
for (j = 0; j < 8; j++) {
|
||||
pDst[j] = (pSrcA[j] + pSrcB[j] + 1) >> 1;
|
||||
}
|
||||
pDst += iDstStride;
|
||||
pSrcA += iSrcAStride;
|
||||
pSrcB += iSrcBStride;
|
||||
}
|
||||
}
|
||||
static inline void PixelAvgWidthEq16_c (uint8_t* pDst, int32_t iDstStride, const uint8_t* pSrcA, int32_t iSrcAStride,
|
||||
const uint8_t* pSrcB, int32_t iSrcBStride, int32_t iHeight) {
|
||||
int32_t i, j;
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
for (j = 0; j < 16; j++) {
|
||||
pDst[j] = (pSrcA[j] + pSrcB[j] + 1) >> 1;
|
||||
}
|
||||
pDst += iDstStride;
|
||||
pSrcA += iSrcAStride;
|
||||
pSrcB += iSrcBStride;
|
||||
}
|
||||
}
|
||||
|
||||
//horizontal filter to gain half sample, that is (2, 0) location in quarter sample
|
||||
static inline void McHorVer20WidthEq16_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
int32_t i, j;
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
for (j = 0; j < 16; j++) {
|
||||
pDst[j] = WelsClip1 ((HorFilter_c (pSrc + j) + 16) >> 5);
|
||||
}
|
||||
pDst += iDstStride;
|
||||
pSrc += iSrcStride;
|
||||
}
|
||||
}
|
||||
//vertical filter to gain half sample, that is (0, 2) location in quarter sample
|
||||
static inline void McHorVer02WidthEq16_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
int32_t i, j;
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
for (j = 0; j < 16; j++) {
|
||||
pDst[j] = WelsClip1 ((VerFilter_c (pSrc + j, iSrcStride) + 16) >> 5);
|
||||
}
|
||||
pDst += iDstStride;
|
||||
pSrc += iSrcStride;
|
||||
}
|
||||
}
|
||||
//horizontal and vertical filter to gain half sample, that is (2, 2) location in quarter sample
|
||||
static inline void McHorVer22WidthEq16_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
int16_t pTmp[16 + 5] = {0}; //16
|
||||
int32_t i, j, k;
|
||||
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
for (j = 0; j < 16 + 5; j++) {
|
||||
pTmp[j] = VerFilter_c (pSrc - 2 + j, iSrcStride);
|
||||
}
|
||||
for (k = 0; k < 16; k++) {
|
||||
pDst[k] = WelsClip1 ((HorFilterInput16bit1_c (&pTmp[2 + k]) + 512) >> 10);
|
||||
}
|
||||
pSrc += iSrcStride;
|
||||
pDst += iDstStride;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////luma MC//////////////////////////
|
||||
|
||||
static inline void McHorVer01WidthEq16_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 256, 16)
|
||||
|
||||
McHorVer02WidthEq16_c (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
PixelAvgWidthEq16_c (pDst, iDstStride, pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
}
|
||||
static inline void McHorVer03WidthEq16_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 256, 16)
|
||||
|
||||
McHorVer02WidthEq16_c (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
PixelAvgWidthEq16_c (pDst, iDstStride, pSrc + iSrcStride, iSrcStride, pTmp, 16, iHeight);
|
||||
}
|
||||
static inline void McHorVer10WidthEq16_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 256, 16)
|
||||
|
||||
McHorVer20WidthEq16_c (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
PixelAvgWidthEq16_c (pDst, iDstStride, pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
}
|
||||
static inline void McHorVer11WidthEq16_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
|
||||
McHorVer20WidthEq16_c (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer02WidthEq16_c (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_c (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
static inline void McHorVer12WidthEq16_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
|
||||
McHorVer02WidthEq16_c (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer22WidthEq16_c (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_c (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
static inline void McHorVer13WidthEq16_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
|
||||
McHorVer20WidthEq16_c (pSrc + iSrcStride, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer02WidthEq16_c (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_c (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
static inline void McHorVer21WidthEq16_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
|
||||
McHorVer20WidthEq16_c (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer22WidthEq16_c (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_c (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
static inline void McHorVer23WidthEq16_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
|
||||
McHorVer20WidthEq16_c (pSrc + iSrcStride, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer22WidthEq16_c (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_c (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
static inline void McHorVer30WidthEq16_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 256, 16)
|
||||
|
||||
McHorVer20WidthEq16_c (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
PixelAvgWidthEq16_c (pDst, iDstStride, pSrc + 1, iSrcStride, pTmp, 16, iHeight);
|
||||
}
|
||||
static inline void McHorVer31WidthEq16_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
|
||||
McHorVer20WidthEq16_c (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer02WidthEq16_c (pSrc + 1, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_c (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
static inline void McHorVer32WidthEq16_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
|
||||
McHorVer02WidthEq16_c (pSrc + 1, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer22WidthEq16_c (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_c (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
static inline void McHorVer33WidthEq16_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
|
||||
McHorVer20WidthEq16_c (pSrc + iSrcStride, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer02WidthEq16_c (pSrc + 1, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_c (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
|
||||
static inline void McHorVer20_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
int32_t i, j;
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
for (j = 0; j < iWidth; j++) {
|
||||
pDst[j] = WelsClip1 ((HorFilter_c (pSrc + j) + 16) >> 5);
|
||||
}
|
||||
pDst += iDstStride;
|
||||
pSrc += iSrcStride;
|
||||
}
|
||||
}
|
||||
//vertical filter to gain half sample, that is (0, 2) location in quarter sample
|
||||
static inline void McHorVer02_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
int32_t i, j;
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
for (j = 0; j < iWidth; j++) {
|
||||
pDst[j] = WelsClip1 ((VerFilter_c (pSrc + j, iSrcStride) + 16) >> 5);
|
||||
}
|
||||
pDst += iDstStride;
|
||||
pSrc += iSrcStride;
|
||||
}
|
||||
}
|
||||
//horizontal and vertical filter to gain half sample, that is (2, 2) location in quarter sample
|
||||
static inline void McHorVer22_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
int16_t pTmp[17 + 5] = {0}; //w+1
|
||||
int32_t i, j, k;
|
||||
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
for (j = 0; j < iWidth + 5; j++) {
|
||||
pTmp[j] = VerFilter_c (pSrc - 2 + j, iSrcStride);
|
||||
}
|
||||
for (k = 0; k < iWidth; k++) {
|
||||
pDst[k] = WelsClip1 ((HorFilterInput16bit1_c (&pTmp[2 + k]) + 512) >> 10);
|
||||
}
|
||||
pSrc += iSrcStride;
|
||||
pDst += iDstStride;
|
||||
}
|
||||
}
|
||||
static inline void McCopy_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
int32_t i;
|
||||
if (iWidth == 16)
|
||||
McCopyWidthEq16_c (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else if (iWidth == 8)
|
||||
McCopyWidthEq8_c (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else if (iWidth == 4)
|
||||
McCopyWidthEq4_c (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else {
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
memcpy (pDst, pSrc, iWidth); // confirmed_safe_unsafe_usage
|
||||
pDst += iDstStride;
|
||||
pSrc += iSrcStride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void McChroma_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
SMVUnitXY mv, int32_t iWidth, int32_t iHeight)
|
||||
//pSrc has been added the offset of mv
|
||||
{
|
||||
const int32_t kiDx = mv.iMvX & 0x07;
|
||||
const int32_t kiDy = mv.iMvY & 0x07;
|
||||
|
||||
if (0 == kiDx && 0 == kiDy) {
|
||||
McCopy_c (pSrc, iSrcStride, pDst, iDstStride, iWidth, iHeight);
|
||||
} else {
|
||||
const int32_t kiDA = g_kuiABCD[kiDy][kiDx][0];
|
||||
const int32_t kiDB = g_kuiABCD[kiDy][kiDx][1];
|
||||
const int32_t kiDC = g_kuiABCD[kiDy][kiDx][2];
|
||||
const int32_t kiDD = g_kuiABCD[kiDy][kiDx][3];
|
||||
|
||||
int32_t i, j;
|
||||
|
||||
const uint8_t* pSrcNext = pSrc + iSrcStride;
|
||||
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
for (j = 0; j < iWidth; j++) {
|
||||
pDst[j] = (kiDA * pSrc[j] + kiDB * pSrc[j + 1] + kiDC * pSrcNext[j] + kiDD * pSrcNext[j + 1] + 32) >> 6;
|
||||
}
|
||||
pDst += iDstStride;
|
||||
pSrc = pSrcNext;
|
||||
pSrcNext += iSrcStride;
|
||||
}
|
||||
}
|
||||
}
|
||||
//***************************************************************************//
|
||||
// MMXEXT and SSE2 implementation //
|
||||
//***************************************************************************//
|
||||
#if defined(X86_ASM)
|
||||
|
||||
static inline void McHorVer22WidthEq8_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_2D (int16_t, pTap, 21, 8, 16)
|
||||
McHorVer22Width8HorFirst_sse2 (pSrc - 2, iSrcStride, (uint8_t*)pTap, 16, iHeight + 5);
|
||||
McHorVer22Width8VerLastAlign_sse2 ((uint8_t*)pTap, 16, pDst, iDstStride, 8, iHeight);
|
||||
}
|
||||
|
||||
//2010.2.5
|
||||
|
||||
static inline void McHorVer02WidthEq16_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* PDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
McHorVer02WidthEq8_sse2 (pSrc, iSrcStride, PDst, iDstStride, iHeight);
|
||||
McHorVer02WidthEq8_sse2 (&pSrc[8], iSrcStride, &PDst[8], iDstStride, iHeight);
|
||||
}
|
||||
static inline void McHorVer22WidthEq16_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
McHorVer22WidthEq8_sse2 (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
McHorVer22WidthEq8_sse2 (&pSrc[8], iSrcStride, &pDst[8], iDstStride, iHeight);
|
||||
}
|
||||
void McHorVer22Width9Or17Height9Or17_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_2D (int16_t, pTap, 22, 24, 16)
|
||||
int32_t tmp1 = 2 * (iWidth - 8);
|
||||
McHorVer22HorFirst_sse2 (pSrc - 2, iSrcStride, (uint8_t*)pTap, 48, iWidth, iHeight + 5);
|
||||
McHorVer22Width8VerLastAlign_sse2 ((uint8_t*)pTap, 48, pDst, iDstStride, iWidth - 1, iHeight);
|
||||
McHorVer22Width8VerLastUnAlign_sse2 ((uint8_t*)pTap + tmp1, 48, pDst + iWidth - 8, iDstStride, 8, iHeight);
|
||||
}
|
||||
|
||||
static inline void McHorVer01WidthEq16_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 256, 16)
|
||||
|
||||
McHorVer02WidthEq16_sse2 (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
}
|
||||
static inline void McHorVer03WidthEq16_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 256, 16)
|
||||
|
||||
McHorVer02WidthEq16_sse2 (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pSrc + iSrcStride, iSrcStride, pTmp, 16, iHeight);
|
||||
}
|
||||
static inline void McHorVer10WidthEq16_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 256, 16)
|
||||
|
||||
McHorVer20WidthEq16_sse2 (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
}
|
||||
static inline void McHorVer11WidthEq16_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
|
||||
McHorVer20WidthEq16_sse2 (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer02WidthEq16_sse2 (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
static inline void McHorVer12WidthEq16_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
|
||||
McHorVer02WidthEq16_sse2 (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer22WidthEq16_sse2 (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
static inline void McHorVer13WidthEq16_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
|
||||
McHorVer20WidthEq16_sse2 (pSrc + iSrcStride, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer02WidthEq16_sse2 (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
static inline void McHorVer21WidthEq16_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
|
||||
McHorVer20WidthEq16_sse2 (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer22WidthEq16_sse2 (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
static inline void McHorVer23WidthEq16_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
|
||||
McHorVer20WidthEq16_sse2 (pSrc + iSrcStride, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer22WidthEq16_sse2 (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
static inline void McHorVer30WidthEq16_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 256, 16)
|
||||
|
||||
McHorVer20WidthEq16_sse2 (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pSrc + 1, iSrcStride, pTmp, 16, iHeight);
|
||||
}
|
||||
static inline void McHorVer31WidthEq16_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
|
||||
McHorVer20WidthEq16_sse2 (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer02WidthEq16_sse2 (pSrc + 1, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
static inline void McHorVer32WidthEq16_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
|
||||
McHorVer02WidthEq16_sse2 (pSrc + 1, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer22WidthEq16_sse2 (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
static inline void McHorVer33WidthEq16_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
|
||||
McHorVer20WidthEq16_sse2 (pSrc + iSrcStride, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer02WidthEq16_sse2 (pSrc + 1, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
|
||||
static inline void McCopy_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
int32_t i;
|
||||
if (iWidth == 16)
|
||||
McCopyWidthEq16_sse2 (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else if (iWidth == 8)
|
||||
McCopyWidthEq8_mmx (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else if (iWidth == 4)
|
||||
McCopyWidthEq4_mmx (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else {
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
memcpy (pDst, pSrc, iWidth); // confirmed_safe_unsafe_usage
|
||||
pDst += iDstStride;
|
||||
pSrc += iSrcStride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef void (*McChromaWidthEqx) (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
const uint8_t* pABCD, int32_t iHeigh);
|
||||
void McChroma_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
SMVUnitXY sMv, int32_t iWidth, int32_t iHeight) {
|
||||
const int32_t kiD8x = sMv.iMvX & 0x07;
|
||||
const int32_t kiD8y = sMv.iMvY & 0x07;
|
||||
static const McChromaWidthEqx kpfFuncs[2] = {
|
||||
McChromaWidthEq4_mmx,
|
||||
McChromaWidthEq8_sse2
|
||||
};
|
||||
|
||||
if (0 == kiD8x && 0 == kiD8y) {
|
||||
McCopy_sse2 (pSrc, iSrcStride, pDst, iDstStride, iWidth, iHeight);
|
||||
} else {
|
||||
kpfFuncs[ (iWidth >> 3)] (pSrc, iSrcStride, pDst, iDstStride, g_kuiABCD[kiD8y][kiD8x], iHeight);
|
||||
}
|
||||
}
|
||||
|
||||
void McChroma_ssse3 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
SMVUnitXY sMv, int32_t iWidth, int32_t iHeight) {
|
||||
const int32_t kiD8x = sMv.iMvX & 0x07;
|
||||
const int32_t kiD8y = sMv.iMvY & 0x07;
|
||||
|
||||
static const McChromaWidthEqx kpfFuncs[2] = {
|
||||
McChromaWidthEq4_mmx,
|
||||
McChromaWidthEq8_ssse3
|
||||
};
|
||||
if (0 == kiD8x && 0 == kiD8y) {
|
||||
McCopy_sse2 (pSrc, iSrcStride, pDst, iDstStride, iWidth, iHeight);
|
||||
} else {
|
||||
kpfFuncs[ (iWidth >> 3)] (pSrc, iSrcStride, pDst, iDstStride, g_kuiABCD[kiD8y][kiD8x], iHeight);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //X86_ASM
|
||||
|
||||
//***************************************************************************//
|
||||
// NEON implementation //
|
||||
//***************************************************************************//
|
||||
#if defined(HAVE_NEON)
|
||||
void McHorVer20Width9Or17_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
if (iWidth == 17)
|
||||
McHorVer20Width17_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else //if (iWidth == 9)
|
||||
McHorVer20Width9_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
}
|
||||
void McHorVer02Height9Or17_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
if (iWidth == 16)
|
||||
McHorVer02Height17_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else //if (iWidth == 8)
|
||||
McHorVer02Height9_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
}
|
||||
void McHorVer22Width9Or17Height9Or17_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
if (iWidth == 17)
|
||||
McHorVer22Width17_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else //if (iWidth == 9)
|
||||
McHorVer22Width9_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
}
|
||||
void EncMcHorVer11_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
McHorVer20WidthEq16_neon (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer02WidthEq16_neon (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_neon (pDst, iDstStride, pTmp, &pTmp[256], iHeight);
|
||||
}
|
||||
void EncMcHorVer12_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
McHorVer02WidthEq16_neon (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer22WidthEq16_neon (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_neon (pDst, iDstStride, pTmp, &pTmp[256], iHeight);
|
||||
}
|
||||
void EncMcHorVer13_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
McHorVer20WidthEq16_neon (pSrc + iSrcStride, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer02WidthEq16_neon (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_neon (pDst, iDstStride, pTmp, &pTmp[256], iHeight);
|
||||
}
|
||||
void EncMcHorVer21_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
McHorVer20WidthEq16_neon (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer22WidthEq16_neon (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_neon (pDst, iDstStride, pTmp, &pTmp[256], iHeight);
|
||||
}
|
||||
void EncMcHorVer23_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
McHorVer20WidthEq16_neon (pSrc + iSrcStride, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer22WidthEq16_neon (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_neon (pDst, iDstStride, pTmp, &pTmp[256], iHeight);
|
||||
}
|
||||
void EncMcHorVer31_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
McHorVer20WidthEq16_neon (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer02WidthEq16_neon (pSrc + 1, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_neon (pDst, iDstStride, pTmp, &pTmp[256], iHeight);
|
||||
}
|
||||
void EncMcHorVer32_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
McHorVer02WidthEq16_neon (pSrc + 1, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer22WidthEq16_neon (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_neon (pDst, iDstStride, pTmp, &pTmp[256], iHeight);
|
||||
}
|
||||
void EncMcHorVer33_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
McHorVer20WidthEq16_neon (pSrc + iSrcStride, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer02WidthEq16_neon (pSrc + 1, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_neon (pDst, iDstStride, pTmp, &pTmp[256], iHeight);
|
||||
}
|
||||
void EncMcChroma_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
SMVUnitXY sMv, int32_t iWidth, int32_t iHeight) {
|
||||
const int32_t kiD8x = sMv.iMvX & 0x07;
|
||||
const int32_t kiD8y = sMv.iMvY & 0x07;
|
||||
if (0 == kiD8x && 0 == kiD8y) {
|
||||
if (8 == iWidth)
|
||||
McCopyWidthEq8_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else // iWidth == 4
|
||||
McCopyWidthEq4_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
} else {
|
||||
if (8 == iWidth)
|
||||
McChromaWidthEq8_neon (pSrc, iSrcStride, pDst, iDstStride, (int32_t*) (g_kuiABCD[kiD8y][kiD8x]), iHeight);
|
||||
else //if(4 == iWidth)
|
||||
McChromaWidthEq4_neon (pSrc, iSrcStride, pDst, iDstStride, (int32_t*) (g_kuiABCD[kiD8y][kiD8x]), iHeight);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_NEON_AARCH64)
|
||||
void McHorVer20Width9Or17_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
if (iWidth == 17)
|
||||
McHorVer20Width17_AArch64_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else //if (iWidth == 9)
|
||||
McHorVer20Width9_AArch64_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
}
|
||||
void McHorVer02Height9Or17_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
if (iWidth == 16)
|
||||
McHorVer02Height17_AArch64_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else //if (iWidth == 8)
|
||||
McHorVer02Height9_AArch64_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
}
|
||||
void McHorVer22Width9Or17Height9Or17_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst,
|
||||
int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
if (iWidth == 17)
|
||||
McHorVer22Width17_AArch64_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else //if (iWidth == 9)
|
||||
McHorVer22Width9_AArch64_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
}
|
||||
void EncMcHorVer11_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
McHorVer20WidthEq16_AArch64_neon (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer02WidthEq16_AArch64_neon (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_AArch64_neon (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
void EncMcHorVer12_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
McHorVer02WidthEq16_AArch64_neon (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer22WidthEq16_AArch64_neon (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_AArch64_neon (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
void EncMcHorVer13_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
McHorVer20WidthEq16_AArch64_neon (pSrc + iSrcStride, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer02WidthEq16_AArch64_neon (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_AArch64_neon (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
void EncMcHorVer21_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
McHorVer20WidthEq16_AArch64_neon (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer22WidthEq16_AArch64_neon (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_AArch64_neon (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
void EncMcHorVer23_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
McHorVer20WidthEq16_AArch64_neon (pSrc + iSrcStride, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer22WidthEq16_AArch64_neon (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_AArch64_neon (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
void EncMcHorVer31_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
McHorVer20WidthEq16_AArch64_neon (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer02WidthEq16_AArch64_neon (pSrc + 1, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_AArch64_neon (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
void EncMcHorVer32_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
McHorVer02WidthEq16_AArch64_neon (pSrc + 1, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer22WidthEq16_AArch64_neon (pSrc, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_AArch64_neon (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
void EncMcHorVer33_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, pTmp, 512, 16)
|
||||
McHorVer20WidthEq16_AArch64_neon (pSrc + iSrcStride, iSrcStride, pTmp, 16, iHeight);
|
||||
McHorVer02WidthEq16_AArch64_neon (pSrc + 1, iSrcStride, &pTmp[256], 16, iHeight);
|
||||
PixelAvgWidthEq16_AArch64_neon (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||
}
|
||||
void EncMcChroma_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
SMVUnitXY sMv, int32_t iWidth, int32_t iHeight) {
|
||||
const int32_t kiD8x = sMv.iMvX & 0x07;
|
||||
const int32_t kiD8y = sMv.iMvY & 0x07;
|
||||
if (0 == kiD8x && 0 == kiD8y) {
|
||||
if (8 == iWidth)
|
||||
McCopyWidthEq8_AArch64_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else // iWidth == 4
|
||||
McCopyWidthEq4_AArch64_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
} else {
|
||||
if (8 == iWidth)
|
||||
McChromaWidthEq8_AArch64_neon (pSrc, iSrcStride, pDst, iDstStride, (int32_t*) (g_kuiABCD[kiD8y][kiD8x]), iHeight);
|
||||
else //if(4 == iWidth)
|
||||
McChromaWidthEq4_AArch64_neon (pSrc, iSrcStride, pDst, iDstStride, (int32_t*) (g_kuiABCD[kiD8y][kiD8x]), iHeight);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef void (*PixelAvgFunc) (uint8_t*, int32_t, const uint8_t*, int32_t, const uint8_t*, int32_t, int32_t);
|
||||
void WelsInitMcFuncs (SWelsFuncPtrList* pFuncList, uint32_t uiCpuFlag) {
|
||||
static const PixelAvgFunc pfPixAvgFunc[2] = {PixelAvgWidthEq8_c, PixelAvgWidthEq16_c};
|
||||
|
||||
static const PWelsLumaQuarpelMcFunc pWelsMcFuncWidthEq16[16] = { //[y*4+x]
|
||||
McCopyWidthEq16_c, McHorVer10WidthEq16_c, McHorVer20WidthEq16_c, McHorVer30WidthEq16_c,
|
||||
McHorVer01WidthEq16_c, McHorVer11WidthEq16_c, McHorVer21WidthEq16_c, McHorVer31WidthEq16_c,
|
||||
McHorVer02WidthEq16_c, McHorVer12WidthEq16_c, McHorVer22WidthEq16_c, McHorVer32WidthEq16_c,
|
||||
McHorVer03WidthEq16_c, McHorVer13WidthEq16_c, McHorVer23WidthEq16_c, McHorVer33WidthEq16_c
|
||||
};
|
||||
#if defined (X86_ASM)
|
||||
static const PWelsLumaQuarpelMcFunc pWelsMcFuncWidthEq16_sse2[16] = {
|
||||
McCopyWidthEq16_sse2, McHorVer10WidthEq16_sse2, McHorVer20WidthEq16_sse2, McHorVer30WidthEq16_sse2,
|
||||
McHorVer01WidthEq16_sse2, McHorVer11WidthEq16_sse2, McHorVer21WidthEq16_sse2, McHorVer31WidthEq16_sse2,
|
||||
McHorVer02WidthEq16_sse2, McHorVer12WidthEq16_sse2, McHorVer22WidthEq16_sse2, McHorVer32WidthEq16_sse2,
|
||||
McHorVer03WidthEq16_sse2, McHorVer13WidthEq16_sse2, McHorVer23WidthEq16_sse2, McHorVer33WidthEq16_sse2
|
||||
};
|
||||
#endif
|
||||
#if defined(HAVE_NEON)
|
||||
static const PWelsLumaQuarpelMcFunc pWelsMcFuncWidthEq16_neon[16] = { //[x][y]
|
||||
McCopyWidthEq16_neon, McHorVer10WidthEq16_neon, McHorVer20WidthEq16_neon, McHorVer30WidthEq16_neon,
|
||||
McHorVer01WidthEq16_neon, EncMcHorVer11_neon, EncMcHorVer21_neon, EncMcHorVer31_neon,
|
||||
McHorVer02WidthEq16_neon, EncMcHorVer12_neon, McHorVer22WidthEq16_neon, EncMcHorVer32_neon,
|
||||
McHorVer03WidthEq16_neon, EncMcHorVer13_neon, EncMcHorVer23_neon, EncMcHorVer33_neon
|
||||
};
|
||||
#endif
|
||||
#if defined(HAVE_NEON_AARCH64)
|
||||
static const PWelsLumaQuarpelMcFunc pWelsMcFuncWidthEq16_AArch64_neon[16] = { //[x][y]
|
||||
McCopyWidthEq16_AArch64_neon, McHorVer10WidthEq16_AArch64_neon, McHorVer20WidthEq16_AArch64_neon, McHorVer30WidthEq16_AArch64_neon,
|
||||
McHorVer01WidthEq16_AArch64_neon, EncMcHorVer11_AArch64_neon, EncMcHorVer21_AArch64_neon, EncMcHorVer31_AArch64_neon,
|
||||
McHorVer02WidthEq16_AArch64_neon, EncMcHorVer12_AArch64_neon, McHorVer22WidthEq16_AArch64_neon, EncMcHorVer32_AArch64_neon,
|
||||
McHorVer03WidthEq16_AArch64_neon, EncMcHorVer13_AArch64_neon, EncMcHorVer23_AArch64_neon, EncMcHorVer33_AArch64_neon
|
||||
};
|
||||
#endif
|
||||
pFuncList->sMcFuncs.pfLumaHalfpelHor = McHorVer20_c;
|
||||
pFuncList->sMcFuncs.pfLumaHalfpelVer = McHorVer02_c;
|
||||
pFuncList->sMcFuncs.pfLumaHalfpelCen = McHorVer22_c;
|
||||
memcpy (pFuncList->sMcFuncs.pfSampleAveraging, pfPixAvgFunc, sizeof (pfPixAvgFunc));
|
||||
pFuncList->sMcFuncs.pfChromaMc = McChroma_c;
|
||||
memcpy (pFuncList->sMcFuncs.pfLumaQuarpelMc, pWelsMcFuncWidthEq16, sizeof (pWelsMcFuncWidthEq16));
|
||||
#if defined (X86_ASM)
|
||||
if (uiCpuFlag & WELS_CPU_SSE2) {
|
||||
pFuncList->sMcFuncs.pfLumaHalfpelHor = McHorVer20Width9Or17_sse2;
|
||||
pFuncList->sMcFuncs.pfLumaHalfpelVer = McHorVer02Height9Or17_sse2;
|
||||
pFuncList->sMcFuncs.pfLumaHalfpelCen = McHorVer22Width9Or17Height9Or17_sse2;
|
||||
pFuncList->sMcFuncs.pfSampleAveraging[0] = PixelAvgWidthEq8_mmx;
|
||||
pFuncList->sMcFuncs.pfSampleAveraging[1] = PixelAvgWidthEq16_sse2;
|
||||
pFuncList->sMcFuncs.pfChromaMc = McChroma_sse2;
|
||||
memcpy (pFuncList->sMcFuncs.pfLumaQuarpelMc, pWelsMcFuncWidthEq16_sse2, sizeof (pWelsMcFuncWidthEq16_sse2));
|
||||
}
|
||||
|
||||
if (uiCpuFlag & WELS_CPU_SSSE3) {
|
||||
pFuncList->sMcFuncs.pfChromaMc = McChroma_ssse3;
|
||||
}
|
||||
|
||||
#endif //(X86_ASM)
|
||||
|
||||
#if defined(HAVE_NEON)
|
||||
if (uiCpuFlag & WELS_CPU_NEON) {
|
||||
memcpy (pFuncList->sMcFuncs.pfLumaQuarpelMc, pWelsMcFuncWidthEq16_neon, sizeof (pWelsMcFuncWidthEq16_neon));
|
||||
pFuncList->sMcFuncs.pfChromaMc = EncMcChroma_neon;
|
||||
pFuncList->sMcFuncs.pfSampleAveraging[0] = PixStrideAvgWidthEq8_neon;
|
||||
pFuncList->sMcFuncs.pfSampleAveraging[1] = PixStrideAvgWidthEq16_neon;
|
||||
pFuncList->sMcFuncs.pfLumaHalfpelHor = McHorVer20Width9Or17_neon;//iWidth+1:8/16
|
||||
pFuncList->sMcFuncs.pfLumaHalfpelVer = McHorVer02Height9Or17_neon;//heigh+1:8/16
|
||||
pFuncList->sMcFuncs.pfLumaHalfpelCen = McHorVer22Width9Or17Height9Or17_neon;//iWidth+1/heigh+1
|
||||
}
|
||||
#endif
|
||||
#if defined(HAVE_NEON_AARCH64)
|
||||
if (uiCpuFlag & WELS_CPU_NEON) {
|
||||
memcpy (pFuncList->sMcFuncs.pfLumaQuarpelMc, pWelsMcFuncWidthEq16_AArch64_neon,
|
||||
sizeof (pWelsMcFuncWidthEq16_AArch64_neon));
|
||||
pFuncList->sMcFuncs.pfChromaMc = EncMcChroma_AArch64_neon;
|
||||
pFuncList->sMcFuncs.pfSampleAveraging[0] = PixStrideAvgWidthEq8_AArch64_neon;
|
||||
pFuncList->sMcFuncs.pfSampleAveraging[1] = PixStrideAvgWidthEq16_AArch64_neon;
|
||||
pFuncList->sMcFuncs.pfLumaHalfpelHor = McHorVer20Width9Or17_AArch64_neon;//iWidth+1:8/16
|
||||
pFuncList->sMcFuncs.pfLumaHalfpelVer = McHorVer02Height9Or17_AArch64_neon;//heigh+1:8/16
|
||||
pFuncList->sMcFuncs.pfLumaHalfpelCen = McHorVer22Width9Or17Height9Or17_AArch64_neon;//iWidth+1/heigh+1
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -531,15 +531,14 @@ typedef struct TagQuarParams {
|
||||
|
||||
inline void MeRefineQuarPixel (SWelsFuncPtrList* pFunc, SWelsME* pMe, SMeRefinePointer* pMeRefine,
|
||||
const int32_t kiWidth, const int32_t kiHeight, SQuarRefineParams* pParams, int32_t iStrideEnc) {
|
||||
PWelsSampleAveragingFunc* pSampleAvg = pFunc->sMcFuncs.pfSampleAveraging;
|
||||
const int32_t kiAvgIndex = kiWidth >> 4;
|
||||
PWelsSampleAveragingFunc pSampleAvg = pFunc->sMcFuncs.pfSampleAveraging;
|
||||
int32_t iCurCost;
|
||||
uint8_t* pEncMb = pMe->pEncMb;
|
||||
uint8_t* pTmp = NULL;
|
||||
const uint8_t kuiPixel = pMe->uiBlockSize;
|
||||
|
||||
pSampleAvg[kiAvgIndex] (pMeRefine->pQuarPixTmp, ME_REFINE_BUF_STRIDE, pParams->pSrcA[0], ME_REFINE_BUF_STRIDE,
|
||||
pParams->pSrcB[0], pParams->iStrideA, kiHeight);
|
||||
pSampleAvg (pMeRefine->pQuarPixTmp, ME_REFINE_BUF_STRIDE, pParams->pSrcA[0], ME_REFINE_BUF_STRIDE,
|
||||
pParams->pSrcB[0], pParams->iStrideA, kiWidth, kiHeight);
|
||||
|
||||
iCurCost = CALC_COST (pMeRefine->pQuarPixTmp, pParams->iLms[0]);
|
||||
if (iCurCost < pParams->iBestCost) {
|
||||
@@ -547,24 +546,24 @@ inline void MeRefineQuarPixel (SWelsFuncPtrList* pFunc, SWelsME* pMe, SMeRefineP
|
||||
SWITCH_BEST_TMP_BUF (pMeRefine->pQuarPixBest, pMeRefine->pQuarPixTmp);
|
||||
}
|
||||
//=========================(0, 1)=======================//
|
||||
pSampleAvg[kiAvgIndex] (pMeRefine->pQuarPixTmp, ME_REFINE_BUF_STRIDE, pParams->pSrcA[1],
|
||||
ME_REFINE_BUF_STRIDE, pParams->pSrcB[1], pParams->iStrideA, kiHeight);
|
||||
pSampleAvg (pMeRefine->pQuarPixTmp, ME_REFINE_BUF_STRIDE, pParams->pSrcA[1],
|
||||
ME_REFINE_BUF_STRIDE, pParams->pSrcB[1], pParams->iStrideA, kiWidth, kiHeight);
|
||||
iCurCost = CALC_COST (pMeRefine->pQuarPixTmp, pParams->iLms[1]);
|
||||
if (iCurCost < pParams->iBestCost) {
|
||||
pParams->iBestQuarPix = ME_QUAR_PIXEL_BOTTOM;
|
||||
SWITCH_BEST_TMP_BUF (pMeRefine->pQuarPixBest, pMeRefine->pQuarPixTmp);
|
||||
}
|
||||
//==========================(-1, 0)=========================//
|
||||
pSampleAvg[kiAvgIndex] (pMeRefine->pQuarPixTmp, ME_REFINE_BUF_STRIDE, pParams->pSrcA[2],
|
||||
ME_REFINE_BUF_STRIDE, pParams->pSrcB[2], pParams->iStrideB, kiHeight);
|
||||
pSampleAvg (pMeRefine->pQuarPixTmp, ME_REFINE_BUF_STRIDE, pParams->pSrcA[2],
|
||||
ME_REFINE_BUF_STRIDE, pParams->pSrcB[2], pParams->iStrideB, kiWidth, kiHeight);
|
||||
iCurCost = CALC_COST (pMeRefine->pQuarPixTmp, pParams->iLms[2]);
|
||||
if (iCurCost < pParams->iBestCost) {
|
||||
pParams->iBestQuarPix = ME_QUAR_PIXEL_LEFT;
|
||||
SWITCH_BEST_TMP_BUF (pMeRefine->pQuarPixBest, pMeRefine->pQuarPixTmp);
|
||||
}
|
||||
//==========================(1, 0)=========================//
|
||||
pSampleAvg[kiAvgIndex] (pMeRefine->pQuarPixTmp, ME_REFINE_BUF_STRIDE, pParams->pSrcA[3],
|
||||
ME_REFINE_BUF_STRIDE, pParams->pSrcB[3], pParams->iStrideB, kiHeight);
|
||||
pSampleAvg (pMeRefine->pQuarPixTmp, ME_REFINE_BUF_STRIDE, pParams->pSrcA[3],
|
||||
ME_REFINE_BUF_STRIDE, pParams->pSrcB[3], pParams->iStrideB, kiWidth, kiHeight);
|
||||
|
||||
iCurCost = CALC_COST (pMeRefine->pQuarPixTmp, pParams->iLms[3]);
|
||||
if (iCurCost < pParams->iBestCost) {
|
||||
@@ -599,8 +598,7 @@ void MeRefineFracPixel (sWelsEncCtx* pEncCtx, uint8_t* pMemPredInterMb, SWelsME*
|
||||
int32_t iCurCost;
|
||||
int32_t iBestHalfPix;
|
||||
|
||||
if ((pFunc->sSampleDealingFuncs.pfMeCost == pFunc->sSampleDealingFuncs.pfSampleSatd)
|
||||
&& (pFunc->sSampleDealingFuncs.pfMdCost == pFunc->sSampleDealingFuncs.pfSampleSatd)) {
|
||||
if (pEncCtx->pCurDqLayer->bSatdInMdFlag) {
|
||||
iBestCost = pMe->uSadPredISatd.uiSatd + COST_MVD (pMe->pMvdCost, iMvx - pMe->sMvp.iMvX, iMvy - pMe->sMvp.iMvY);
|
||||
} else {
|
||||
iBestCost = pFunc->sSampleDealingFuncs.pfMeCost[pMe->uiBlockSize] (pEncData, kiStrideEnc, pRef, kiStrideRef) +
|
||||
@@ -766,17 +764,8 @@ void MeRefineFracPixel (sWelsEncCtx* pEncCtx, uint8_t* pMemPredInterMb, SWelsME*
|
||||
pBestPredInter = pRef;
|
||||
iInterBlk4Stride = kiStrideRef;
|
||||
}
|
||||
if (MB_WIDTH_LUMA == iWidth && MB_HEIGHT_LUMA == iHeight) { //P16x16
|
||||
pFunc->pfCopy16x16NotAligned (pMemPredInterMb, MB_WIDTH_LUMA, pBestPredInter,
|
||||
iInterBlk4Stride); // dst can be align with 16 bytes, but not sure at pSrc, 12/29/2011
|
||||
} else if (MB_WIDTH_LUMA == iWidth && MB_HEIGHT_CHROMA == iHeight) { //P16x8
|
||||
pFunc->pfCopy16x8NotAligned (pMemPredInterMb, MB_WIDTH_LUMA, pBestPredInter,
|
||||
iInterBlk4Stride); // dst can be align with 16 bytes, but not sure at pSrc, 12/29/2011
|
||||
} else if (MB_WIDTH_CHROMA == iWidth && MB_HEIGHT_LUMA == iHeight) { //P8x16
|
||||
pFunc->pfCopy8x16Aligned (pMemPredInterMb, MB_WIDTH_LUMA, pBestPredInter, iInterBlk4Stride);
|
||||
} else { //P8x8
|
||||
pFunc->pfCopy8x8Aligned (pMemPredInterMb, MB_WIDTH_LUMA, pBestPredInter, iInterBlk4Stride);
|
||||
}
|
||||
pMeRefine->pfCopyBlockByMode (pMemPredInterMb, MB_WIDTH_LUMA, pBestPredInter,
|
||||
iInterBlk4Stride);
|
||||
}
|
||||
|
||||
void InitBlkStrideWithRef (int32_t* pBlkStride, const int32_t kiStrideRef) {
|
||||
|
||||
@@ -216,35 +216,37 @@ void RcUpdateBitrateFps (sWelsEncCtx* pEncCtx) {
|
||||
SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
|
||||
const int32_t kiGopSize = (1 << pDLayerParamInternal->iDecompositionStages);
|
||||
const int32_t kiHighestTid = pDLayerParamInternal->iHighestTemporalId;
|
||||
int64_t input_iBitsPerFrame = WELS_ROUND64 (((int64_t)pDLayerParam->iSpatialBitrate) * INT_MULTIPLY /
|
||||
pDLayerParamInternal->fInputFrameRate);
|
||||
const int32_t kiGopBits = WELS_DIV_ROUND (input_iBitsPerFrame * kiGopSize, INT_MULTIPLY);
|
||||
const int32_t input_iBitsPerFrame = WELS_DIV_ROUND (pDLayerParam->iSpatialBitrate,
|
||||
pDLayerParamInternal->fOutputFrameRate);
|
||||
const int64_t kiGopBits = input_iBitsPerFrame * kiGopSize;
|
||||
int32_t i;
|
||||
|
||||
pWelsSvcRc->iBitRate = pDLayerParam->iSpatialBitrate;
|
||||
pWelsSvcRc->fFrameRate = pDLayerParamInternal->fInputFrameRate;
|
||||
pWelsSvcRc->fFrameRate = pDLayerParamInternal->fOutputFrameRate;
|
||||
|
||||
int32_t iTargetVaryRange = FRAME_iTargetBits_VARY_RANGE * (MAX_BITS_VARY_PERCENTAGE - pWelsSvcRc->iRcVaryRatio);
|
||||
int32_t iMinBitsRatio = (MAX_BITS_VARY_PERCENTAGE) * INT_MULTIPLY - iTargetVaryRange;
|
||||
int32_t iMaxBitsRatio = (MAX_BITS_VARY_PERCENTAGE) * (INT_MULTIPLY + FRAME_iTargetBits_VARY_RANGE);
|
||||
int32_t iTargetVaryRange = ((MAX_BITS_VARY_PERCENTAGE - pWelsSvcRc->iRcVaryRatio) >> 1);
|
||||
int32_t iMinBitsRatio = MAX_BITS_VARY_PERCENTAGE - iTargetVaryRange;
|
||||
int32_t iMaxBitsRatio = MAX_BITS_VARY_PERCENTAGE_x3d2;
|
||||
|
||||
for (i = 0; i <= kiHighestTid; i++) {
|
||||
const int64_t kdConstraitBits = kiGopBits * pTOverRc[i].iTlayerWeight;
|
||||
pTOverRc[i].iMinBitsTl = WELS_DIV_ROUND (kdConstraitBits * iMinBitsRatio,
|
||||
INT_MULTIPLY * MAX_BITS_VARY_PERCENTAGE * WEIGHT_MULTIPLY);
|
||||
MAX_BITS_VARY_PERCENTAGE * WEIGHT_MULTIPLY);
|
||||
pTOverRc[i].iMaxBitsTl = WELS_DIV_ROUND (kdConstraitBits * iMaxBitsRatio,
|
||||
INT_MULTIPLY * MAX_BITS_VARY_PERCENTAGE * WEIGHT_MULTIPLY);
|
||||
MAX_BITS_VARY_PERCENTAGE * WEIGHT_MULTIPLY);
|
||||
}
|
||||
//When bitrate is changed, pBuffer size should be updated
|
||||
pWelsSvcRc->iBufferSizeSkip = WELS_DIV_ROUND (pWelsSvcRc->iBitRate * pWelsSvcRc->iSkipBufferRatio, INT_MULTIPLY);
|
||||
pWelsSvcRc->iBufferSizePadding = WELS_DIV_ROUND (pWelsSvcRc->iBitRate * PADDING_BUFFER_RATIO, INT_MULTIPLY);
|
||||
|
||||
//change remaining bits
|
||||
if (pWelsSvcRc->iBitsPerFrame > REMAIN_BITS_TH)
|
||||
pWelsSvcRc->iRemainingBits = (int32_t) (pWelsSvcRc->iRemainingBits * input_iBitsPerFrame / pWelsSvcRc->iBitsPerFrame);
|
||||
if (pWelsSvcRc->iBitsPerFrame > REMAIN_BITS_TH) {
|
||||
pWelsSvcRc->iRemainingBits = WELS_DIV_ROUND (static_cast<int64_t> (pWelsSvcRc->iRemainingBits) * input_iBitsPerFrame,
|
||||
pWelsSvcRc->iBitsPerFrame);
|
||||
}
|
||||
pWelsSvcRc->iBitsPerFrame = input_iBitsPerFrame;
|
||||
pWelsSvcRc->iMaxBitsPerFrame = WELS_DIV_ROUND64 ((pDLayerParam->iMaxSpatialBitrate) * INT_MULTIPLY,
|
||||
pDLayerParamInternal->fInputFrameRate);
|
||||
pWelsSvcRc->iMaxBitsPerFrame = WELS_DIV_ROUND (pDLayerParam->iMaxSpatialBitrate,
|
||||
pDLayerParamInternal->fOutputFrameRate);
|
||||
}
|
||||
|
||||
|
||||
@@ -254,7 +256,7 @@ void RcInitVGop (sWelsEncCtx* pEncCtx) {
|
||||
SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
|
||||
const int32_t kiHighestTid = pEncCtx->pSvcParam->sDependencyLayers[kiDid].iHighestTemporalId;
|
||||
|
||||
pWelsSvcRc->iRemainingBits = WELS_DIV_ROUND (VGOP_SIZE * pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
|
||||
pWelsSvcRc->iRemainingBits = VGOP_SIZE * pWelsSvcRc->iBitsPerFrame;
|
||||
pWelsSvcRc->iRemainingWeights = pWelsSvcRc->iGopNumberInVGop * WEIGHT_MULTIPLY;
|
||||
|
||||
pWelsSvcRc->iFrameCodedInVGop = 0;
|
||||
@@ -297,7 +299,7 @@ void RcInitRefreshParameter (sWelsEncCtx* pEncCtx) {
|
||||
|
||||
//Backup the initial bitrate and fps
|
||||
pWelsSvcRc->iPreviousBitrate = pDLayerParam->iSpatialBitrate;
|
||||
pWelsSvcRc->dPreviousFps = pDLayerParamInternal->fInputFrameRate;
|
||||
pWelsSvcRc->dPreviousFps = pDLayerParamInternal->fOutputFrameRate;
|
||||
|
||||
memset (pWelsSvcRc->pCurrentFrameGomSad, 0, pWelsSvcRc->iGomSize * sizeof (int32_t));
|
||||
|
||||
@@ -313,10 +315,10 @@ bool RcJudgeBitrateFpsUpdate (sWelsEncCtx* pEncCtx) {
|
||||
SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[iCurDid];
|
||||
|
||||
if ((pWelsSvcRc->iPreviousBitrate != pDLayerParam->iSpatialBitrate) ||
|
||||
(pWelsSvcRc->dPreviousFps - pDLayerParamInternal->fInputFrameRate) > EPSN ||
|
||||
(pWelsSvcRc->dPreviousFps - pDLayerParamInternal->fInputFrameRate) < -EPSN) {
|
||||
(pWelsSvcRc->dPreviousFps - pDLayerParamInternal->fOutputFrameRate) > EPSN ||
|
||||
(pWelsSvcRc->dPreviousFps - pDLayerParamInternal->fOutputFrameRate) < -EPSN) {
|
||||
pWelsSvcRc->iPreviousBitrate = pDLayerParam->iSpatialBitrate;
|
||||
pWelsSvcRc->dPreviousFps = pDLayerParamInternal->fInputFrameRate;
|
||||
pWelsSvcRc->dPreviousFps = pDLayerParamInternal->fOutputFrameRate;
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
@@ -388,9 +390,10 @@ void RcInitIdrQp (sWelsEncCtx* pEncCtx) {
|
||||
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
|
||||
|
||||
if (pDLayerParam->fFrameRate > EPSN && pDLayerParam->iVideoWidth && pDLayerParam->iVideoHeight)
|
||||
dBpp = (double) (pDLayerParam->iSpatialBitrate) / (double) (pDLayerParam->fFrameRate * pDLayerParam->iVideoWidth *
|
||||
SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
|
||||
if (pDLayerParamInternal->fOutputFrameRate > EPSN && pDLayerParam->iVideoWidth && pDLayerParam->iVideoHeight)
|
||||
dBpp = (double) (pDLayerParam->iSpatialBitrate) / (double) (pDLayerParamInternal->fOutputFrameRate *
|
||||
pDLayerParam->iVideoWidth *
|
||||
pDLayerParam->iVideoHeight);
|
||||
else
|
||||
dBpp = 0.1;
|
||||
@@ -424,8 +427,8 @@ void RcCalculateIdrQp (sWelsEncCtx* pEncCtx) {
|
||||
pWelsSvcRc->iIntraComplexity = pWelsSvcRc->iIntraComplexity * pWelsSvcRc->iNumberMbFrame /
|
||||
pWelsSvcRc->iIntraMbCount;
|
||||
}
|
||||
pWelsSvcRc->iInitialQp = RcConvertQStep2Qp (pWelsSvcRc->iIntraComplexity /
|
||||
pWelsSvcRc->iTargetBits);
|
||||
pWelsSvcRc->iInitialQp = RcConvertQStep2Qp (WELS_DIV_ROUND (pWelsSvcRc->iIntraComplexity,
|
||||
pWelsSvcRc->iTargetBits));
|
||||
pWelsSvcRc->iInitialQp = WELS_CLIP3 (pWelsSvcRc->iInitialQp, MIN_IDR_QP, MAX_IDR_QP);
|
||||
pEncCtx->iGlobalQp = pWelsSvcRc->iInitialQp;
|
||||
pWelsSvcRc->iQStep = RcConvertQp2QStep (pEncCtx->iGlobalQp);
|
||||
@@ -515,7 +518,8 @@ void RcInitSliceInformation (sWelsEncCtx* pEncCtx) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0];
|
||||
const int32_t kiSliceNum = pWelsSvcRc->iSliceNum;
|
||||
const int32_t kiBitsPerMb = WELS_DIV_ROUND (pWelsSvcRc->iTargetBits * INT_MULTIPLY, pWelsSvcRc->iNumberMbFrame);
|
||||
const int32_t kiBitsPerMb = WELS_DIV_ROUND (static_cast<int64_t> (pWelsSvcRc->iTargetBits) * INT_MULTIPLY,
|
||||
pWelsSvcRc->iNumberMbFrame);
|
||||
|
||||
for (int32_t i = 0; i < kiSliceNum; i++) {
|
||||
pSOverRc->iStartMbSlice =
|
||||
@@ -537,11 +541,11 @@ void RcDecideTargetBits (sWelsEncCtx* pEncCtx) {
|
||||
pWelsSvcRc->iCurrentBitsLevel = BITS_NORMAL;
|
||||
//allocate bits
|
||||
if (pEncCtx->eSliceType == I_SLICE) {
|
||||
pWelsSvcRc->iTargetBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame * IDR_BITRATE_RATIO, INT_MULTIPLY);
|
||||
pWelsSvcRc->iTargetBits = pWelsSvcRc->iBitsPerFrame * IDR_BITRATE_RATIO;
|
||||
} else {
|
||||
if (pWelsSvcRc->iRemainingWeights > pTOverRc->iTlayerWeight)
|
||||
pWelsSvcRc->iTargetBits = (int32_t) ((int64_t)pWelsSvcRc->iRemainingBits * pTOverRc->iTlayerWeight /
|
||||
pWelsSvcRc->iRemainingWeights);
|
||||
pWelsSvcRc->iTargetBits = WELS_DIV_ROUND (static_cast<int64_t> (pWelsSvcRc->iRemainingBits) * pTOverRc->iTlayerWeight,
|
||||
pWelsSvcRc->iRemainingWeights);
|
||||
else //this case should be not hit. needs to more test case to verify this
|
||||
pWelsSvcRc->iTargetBits = pWelsSvcRc->iRemainingBits;
|
||||
if ((pWelsSvcRc->iTargetBits <= 0) && ((pEncCtx->pSvcParam->iRCMode == RC_BITRATE_MODE)
|
||||
@@ -561,7 +565,7 @@ void RcInitGomParameters (sWelsEncCtx* pEncCtx) {
|
||||
const int32_t kiGlobalQp = pEncCtx->iGlobalQp;
|
||||
|
||||
pWelsSvcRc->iAverageFrameQp = 0;
|
||||
pWelsSvcRc->iMinFrameQp = 51;;
|
||||
pWelsSvcRc->iMinFrameQp = 51;
|
||||
pWelsSvcRc->iMaxFrameQp = 0;
|
||||
for (int32_t i = 0; i < kiSliceNum; ++i) {
|
||||
pSOverRc->iComplexityIndexSlice = 0;
|
||||
@@ -672,7 +676,8 @@ void RcCalculateGomQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iSliceId) {
|
||||
|
||||
pSOverRc->iCalculatedQpSlice = WELS_CLIP3 (pSOverRc->iCalculatedQpSlice,
|
||||
pEncCtx->iGlobalQp - pWelsSvcRc->iQpRangeLowerInFrame, pEncCtx->iGlobalQp + pWelsSvcRc->iQpRangeUpperInFrame);
|
||||
if (! ((pEncCtx->pSvcParam->iRCMode == RC_BITRATE_MODE) && (pEncCtx->pSvcParam->bEnableFrameSkip == false)))
|
||||
if (! (((pEncCtx->pSvcParam->iRCMode == RC_BITRATE_MODE) || (pEncCtx->pSvcParam->iRCMode == RC_TIMESTAMP_MODE))
|
||||
&& (pEncCtx->pSvcParam->bEnableFrameSkip == false)))
|
||||
pSOverRc->iCalculatedQpSlice = WELS_CLIP3 (pSOverRc->iCalculatedQpSlice, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
|
||||
|
||||
pSOverRc->iGomBitsSlice = 0;
|
||||
@@ -682,21 +687,21 @@ void RcCalculateGomQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iSliceId) {
|
||||
void RcVBufferCalculationSkip (sWelsEncCtx* pEncCtx) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
|
||||
const int32_t kiOutputBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
|
||||
const int32_t kiOutputMaxBits = WELS_DIV_ROUND (pWelsSvcRc->iMaxBitsPerFrame, INT_MULTIPLY);
|
||||
const int32_t kiOutputBits = pWelsSvcRc->iBitsPerFrame;
|
||||
const int32_t kiOutputMaxBits = pWelsSvcRc->iMaxBitsPerFrame;
|
||||
//condition 1: whole pBuffer fullness
|
||||
pWelsSvcRc->iBufferFullnessSkip += (pWelsSvcRc->iFrameDqBits - kiOutputBits);
|
||||
pWelsSvcRc->iBufferMaxBRFullness[EVEN_TIME_WINDOW] += (pWelsSvcRc->iFrameDqBits - kiOutputMaxBits);
|
||||
pWelsSvcRc->iBufferMaxBRFullness[ODD_TIME_WINDOW] += (pWelsSvcRc->iFrameDqBits - kiOutputMaxBits);
|
||||
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] bits in buffer = %d, bits in Max bitrate buffer = %d",
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] bits in buffer = %"PRId64", bits in Max bitrate buffer = %"PRId64,
|
||||
pWelsSvcRc->iBufferFullnessSkip, pWelsSvcRc->iBufferMaxBRFullness[EVEN_TIME_WINDOW]);
|
||||
//condition 2: VGOP bits constraint
|
||||
int32_t iVGopBitsPred = 0;
|
||||
int64_t iVGopBitsPred = 0;
|
||||
for (int32_t i = pWelsSvcRc->iFrameCodedInVGop + 1; i < VGOP_SIZE; i++)
|
||||
iVGopBitsPred += pTOverRc[pWelsSvcRc->iTlOfFrames[i]].iMinBitsTl;
|
||||
iVGopBitsPred -= pWelsSvcRc->iRemainingBits;
|
||||
double dIncPercent = iVGopBitsPred * 100.0 * INT_MULTIPLY / (pWelsSvcRc->iBitsPerFrame * VGOP_SIZE) -
|
||||
double dIncPercent = iVGopBitsPred * 100.0 / (pWelsSvcRc->iBitsPerFrame * VGOP_SIZE) -
|
||||
(double)VGOP_BITS_PERCENTAGE_DIFF;
|
||||
|
||||
if ((pWelsSvcRc->iBufferFullnessSkip > pWelsSvcRc->iBufferSizeSkip
|
||||
@@ -705,15 +710,15 @@ void RcVBufferCalculationSkip (sWelsEncCtx* pEncCtx) {
|
||||
pEncCtx->iSkipFrameFlag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void WelsRcFrameDelayJudge (void* pCtx, EVideoFrameType eFrameType, long long uiTimeStamp) {
|
||||
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
|
||||
void WelsRcFrameDelayJudge (sWelsEncCtx* pEncCtx, EVideoFrameType eFrameType, long long uiTimeStamp) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
|
||||
SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
|
||||
|
||||
const int32_t iSentBits = WELS_ROUND (pDLayerParam->iSpatialBitrate / pDLayerParamInternal->fOutputFrameRate);
|
||||
const int32_t kiOutputMaxBits = WELS_DIV_ROUND (pWelsSvcRc->iMaxBitsPerFrame, INT_MULTIPLY);
|
||||
//SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
|
||||
if (!pEncCtx->pSvcParam->bEnableFrameSkip)
|
||||
return;
|
||||
const int32_t iSentBits = pWelsSvcRc->iBitsPerFrame;
|
||||
const int32_t kiOutputMaxBits = pWelsSvcRc->iMaxBitsPerFrame;
|
||||
const int64_t kiMaxSpatialBitRate = pDLayerParam->iMaxSpatialBitrate;
|
||||
|
||||
//estimate allowed continual skipped frames in the sequence
|
||||
const int32_t iPredSkipFramesTarBr = (WELS_DIV_ROUND (pWelsSvcRc->iBufferFullnessSkip, iSentBits) + 1) >> 1;
|
||||
@@ -722,10 +727,9 @@ void WelsRcFrameDelayJudge (void* pCtx, EVideoFrameType eFrameType, long long ui
|
||||
|
||||
//calculate the remaining bits in TIME_CHECK_WINDOW
|
||||
const int32_t iAvailableBitsInTimeWindow = WELS_DIV_ROUND ((TIME_CHECK_WINDOW - pEncCtx->iCheckWindowInterval) *
|
||||
pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId].iMaxSpatialBitrate, 1000);
|
||||
kiMaxSpatialBitRate, 1000);
|
||||
const int32_t iAvailableBitsInShiftTimeWindow = WELS_DIV_ROUND ((TIME_CHECK_WINDOW - pEncCtx->iCheckWindowIntervalShift)
|
||||
*
|
||||
pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId].iMaxSpatialBitrate, 1000);
|
||||
* kiMaxSpatialBitRate, 1000);
|
||||
|
||||
bool bJudgeMaxBRbSkip[TIME_WINDOW_TOTAL];//0: EVEN_TIME_WINDOW; 1: ODD_TIME_WINDOW
|
||||
|
||||
@@ -760,7 +764,7 @@ void WelsRcFrameDelayJudge (void* pCtx, EVideoFrameType eFrameType, long long ui
|
||||
pWelsSvcRc->iBufferMaxBRFullness[EVEN_TIME_WINDOW] -= kiOutputMaxBits;
|
||||
pWelsSvcRc->iBufferMaxBRFullness[ODD_TIME_WINDOW] -= kiOutputMaxBits;
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
|
||||
"[Rc] bits in buffer = %d, bits in Max bitrate buffer = %d, Predict skip frames = %d and %d",
|
||||
"[Rc] bits in buffer = %"PRId64", bits in Max bitrate buffer = %"PRId64", Predict skip frames = %d and %d",
|
||||
pWelsSvcRc->iBufferFullnessSkip, pWelsSvcRc->iBufferMaxBRFullness[EVEN_TIME_WINDOW], iPredSkipFramesTarBr,
|
||||
iPredSkipFramesMaxBr);
|
||||
pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (pWelsSvcRc->iBufferFullnessSkip, 0);
|
||||
@@ -769,44 +773,42 @@ void WelsRcFrameDelayJudge (void* pCtx, EVideoFrameType eFrameType, long long ui
|
||||
|
||||
|
||||
//loop each layer to check if have skip frame when RC and frame skip enable (maxbr>0)
|
||||
bool CheckFrameSkipBasedMaxbr (void* pCtx, int32_t iSpatialNum, EVideoFrameType eFrameType,
|
||||
bool CheckFrameSkipBasedMaxbr (sWelsEncCtx* pEncCtx, int32_t iSpatialNum, EVideoFrameType eFrameType,
|
||||
const uint32_t uiTimeStamp) {
|
||||
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
|
||||
SSpatialPicIndex* pSpatialIndexMap = &pEncCtx->sSpatialIndexMap[0];
|
||||
bool bSkipMustFlag = false;
|
||||
if (pEncCtx->pSvcParam->bEnableFrameSkip) {
|
||||
if ((RC_QUALITY_MODE == pEncCtx->pSvcParam->iRCMode) || (RC_BITRATE_MODE == pEncCtx->pSvcParam->iRCMode)) {
|
||||
|
||||
for (int32_t i = 0; i < iSpatialNum; i++) {
|
||||
if (UNSPECIFIED_BIT_RATE == pEncCtx->pSvcParam->sSpatialLayers[i].iMaxSpatialBitrate) {
|
||||
break;
|
||||
}
|
||||
pEncCtx->uiDependencyId = (uint8_t) (pSpatialIndexMap + i)->iDid;
|
||||
pEncCtx->pFuncList->pfRc.pfWelsRcPicDelayJudge (pEncCtx, eFrameType, uiTimeStamp);
|
||||
if (true == pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId].bSkipFlag) {
|
||||
bSkipMustFlag = true;
|
||||
pEncCtx->iContinualSkipFrames++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!pEncCtx->pFuncList->pfRc.pfWelsRcPicDelayJudge)
|
||||
return false;
|
||||
for (int32_t i = 0; i < iSpatialNum; i++) {
|
||||
if (UNSPECIFIED_BIT_RATE == pEncCtx->pSvcParam->sSpatialLayers[i].iMaxSpatialBitrate) {
|
||||
break;
|
||||
}
|
||||
pEncCtx->uiDependencyId = (uint8_t) (pSpatialIndexMap + i)->iDid;
|
||||
|
||||
pEncCtx->pFuncList->pfRc.pfWelsRcPicDelayJudge (pEncCtx, eFrameType, uiTimeStamp);
|
||||
if (true == pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId].bSkipFlag) {
|
||||
bSkipMustFlag = true;
|
||||
pEncCtx->iContinualSkipFrames++;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return bSkipMustFlag;
|
||||
}
|
||||
|
||||
void UpdateBufferWhenFrameSkipped (void* pCtx, int32_t iSpatialNum) {
|
||||
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
|
||||
void UpdateBufferWhenFrameSkipped (sWelsEncCtx* pEncCtx, int32_t iSpatialNum) {
|
||||
SSpatialPicIndex* pSpatialIndexMap = &pEncCtx->sSpatialIndexMap[0];
|
||||
|
||||
for (int32_t i = 0; i < iSpatialNum; i++) {
|
||||
int32_t iCurDid = (pSpatialIndexMap + i)->iDid;
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[iCurDid];
|
||||
const int32_t kiOutputBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
|
||||
const int32_t kiOutputMaxBits = WELS_DIV_ROUND (pWelsSvcRc->iMaxBitsPerFrame, INT_MULTIPLY);
|
||||
const int32_t kiOutputBits = pWelsSvcRc->iBitsPerFrame;
|
||||
const int32_t kiOutputMaxBits = pWelsSvcRc->iMaxBitsPerFrame;
|
||||
pWelsSvcRc->iBufferFullnessSkip = pWelsSvcRc->iBufferFullnessSkip - kiOutputBits;
|
||||
pWelsSvcRc->iBufferMaxBRFullness[EVEN_TIME_WINDOW] -= kiOutputMaxBits;
|
||||
pWelsSvcRc->iBufferMaxBRFullness[ODD_TIME_WINDOW] -= kiOutputMaxBits;
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] bits in buffer = %d, bits in Max bitrate buffer = %d",
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] bits in buffer = %"PRId64", bits in Max bitrate buffer = %"PRId64,
|
||||
pWelsSvcRc->iBufferFullnessSkip, pWelsSvcRc->iBufferMaxBRFullness[EVEN_TIME_WINDOW]);
|
||||
|
||||
pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (pWelsSvcRc->iBufferFullnessSkip, 0);
|
||||
@@ -818,9 +820,7 @@ void UpdateBufferWhenFrameSkipped (void* pCtx, int32_t iSpatialNum) {
|
||||
}
|
||||
pEncCtx->iContinualSkipFrames++;
|
||||
}
|
||||
|
||||
void UpdateMaxBrCheckWindowStatus (void* pCtx, int32_t iSpatialNum, const long long uiTimeStamp) {
|
||||
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
|
||||
void UpdateMaxBrCheckWindowStatus (sWelsEncCtx* pEncCtx, int32_t iSpatialNum, const long long uiTimeStamp) {
|
||||
SSpatialPicIndex* pSpatialIndexMap = &pEncCtx->sSpatialIndexMap[0];
|
||||
if (pEncCtx->bCheckWindowStatusRefreshFlag) {
|
||||
pEncCtx->iCheckWindowCurrentTs = uiTimeStamp;
|
||||
@@ -865,7 +865,7 @@ void UpdateMaxBrCheckWindowStatus (void* pCtx, int32_t iSpatialNum, const long l
|
||||
|
||||
void RcVBufferCalculationPadding (sWelsEncCtx* pEncCtx) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
const int32_t kiOutputBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
|
||||
const int32_t kiOutputBits = pWelsSvcRc->iBitsPerFrame;
|
||||
const int32_t kiBufferThreshold = WELS_DIV_ROUND (PADDING_THRESHOLD * (-pWelsSvcRc->iBufferSizePadding), INT_MULTIPLY);
|
||||
|
||||
pWelsSvcRc->iBufferFullnessPadding += (pWelsSvcRc->iFrameDqBits - kiOutputBits);
|
||||
@@ -879,8 +879,7 @@ void RcVBufferCalculationPadding (sWelsEncCtx* pEncCtx) {
|
||||
}
|
||||
|
||||
|
||||
void RcTraceFrameBits (void* pCtx, long long uiTimeStamp) {
|
||||
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
|
||||
void RcTraceFrameBits (sWelsEncCtx* pEncCtx, long long uiTimeStamp) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
|
||||
if (pWelsSvcRc->iPredFrameBit != 0)
|
||||
@@ -890,13 +889,11 @@ void RcTraceFrameBits (void* pCtx, long long uiTimeStamp) {
|
||||
pWelsSvcRc->iPredFrameBit = pWelsSvcRc->iFrameDqBits;
|
||||
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
|
||||
"[Rc] Frame timestamp = %lld, Frame type =%d, dependency ID = %d, encoding_qp =%d, average qp = %3d, max qp = %3d, min qp = %3d, index = %8d,\
|
||||
"[Rc] Frame timestamp = %lld, Frame type =%d, encoding_qp = %d, average qp = %3d, max qp = %3d, min qp = %3d, index = %8d,\
|
||||
iTid = %1d, used = %8d, bitsperframe = %8d, target = %8d, remaingbits = %8d, skipbuffersize = %8d",
|
||||
uiTimeStamp, pEncCtx->eSliceType, pEncCtx->uiDependencyId, pEncCtx->iGlobalQp, pWelsSvcRc->iAverageFrameQp,
|
||||
pWelsSvcRc->iMaxFrameQp,
|
||||
uiTimeStamp, pEncCtx->eSliceType, pEncCtx->iGlobalQp, pWelsSvcRc->iAverageFrameQp, pWelsSvcRc->iMaxFrameQp,
|
||||
pWelsSvcRc->iMinFrameQp,
|
||||
pEncCtx->iFrameIndex, pEncCtx->uiTemporalId, pWelsSvcRc->iFrameDqBits, WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame,
|
||||
INT_MULTIPLY),
|
||||
pEncCtx->iFrameIndex, pEncCtx->uiTemporalId, pWelsSvcRc->iFrameDqBits, pWelsSvcRc->iBitsPerFrame,
|
||||
pWelsSvcRc->iTargetBits, pWelsSvcRc->iRemainingBits, pWelsSvcRc->iBufferSizeSkip);
|
||||
|
||||
}
|
||||
@@ -930,7 +927,7 @@ void RcUpdateIntraComplexity (sWelsEncCtx* pEncCtx) {
|
||||
int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pWelsSvcRc->iIdrNum));
|
||||
if (iAlpha < (INT_MULTIPLY / 4)) iAlpha = INT_MULTIPLY / 4;
|
||||
|
||||
int64_t iIntraCmplx = pWelsSvcRc->iQStep * pWelsSvcRc->iFrameDqBits;
|
||||
int64_t iIntraCmplx = pWelsSvcRc->iQStep * static_cast<int64_t> (pWelsSvcRc->iFrameDqBits);
|
||||
pWelsSvcRc->iIntraComplexity = WELS_DIV_ROUND (((INT_MULTIPLY - iAlpha) * pWelsSvcRc->iIntraComplexity + iAlpha *
|
||||
iIntraCmplx), INT_MULTIPLY);
|
||||
pWelsSvcRc->iIntraMbCount = pWelsSvcRc->iNumberMbFrame;
|
||||
@@ -938,6 +935,9 @@ void RcUpdateIntraComplexity (sWelsEncCtx* pEncCtx) {
|
||||
pWelsSvcRc->iIdrNum++;
|
||||
if (pWelsSvcRc->iIdrNum > 255)
|
||||
pWelsSvcRc->iIdrNum = 255;
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_INFO,
|
||||
"RcUpdateIntraComplexity iFrameDqBits = %d,iQStep= %d,iIntraCmplx = %"PRId64,
|
||||
pWelsSvcRc->iFrameDqBits, pWelsSvcRc->iQStep, pWelsSvcRc->iIntraComplexity);
|
||||
}
|
||||
|
||||
void RcUpdateFrameComplexity (sWelsEncCtx* pEncCtx) {
|
||||
@@ -955,12 +955,16 @@ void RcUpdateFrameComplexity (sWelsEncCtx* pEncCtx) {
|
||||
int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pTOverRc->iPFrameNum));
|
||||
if (iAlpha < SMOOTH_FACTOR_MIN_VALUE)
|
||||
iAlpha = SMOOTH_FACTOR_MIN_VALUE;
|
||||
pTOverRc->iFrameCmplxMean = WELS_DIV_ROUND (((INT_MULTIPLY - iAlpha) * pTOverRc->iFrameCmplxMean + iAlpha *
|
||||
pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity), INT_MULTIPLY);
|
||||
pTOverRc->iFrameCmplxMean = WELS_DIV_ROUND (((INT_MULTIPLY - iAlpha) * static_cast<int64_t> (pTOverRc->iFrameCmplxMean)
|
||||
+ iAlpha * pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity),
|
||||
INT_MULTIPLY);
|
||||
|
||||
pTOverRc->iPFrameNum++;
|
||||
if (pTOverRc->iPFrameNum > 255)
|
||||
pTOverRc->iPFrameNum = 255;
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
|
||||
"RcUpdateFrameComplexity iFrameDqBits = %d,iQStep= %d,pTOverRc->iLinearCmplx = %"PRId64, pWelsSvcRc->iFrameDqBits,
|
||||
pWelsSvcRc->iQStep, pTOverRc->iLinearCmplx);
|
||||
}
|
||||
|
||||
int32_t RcCalculateCascadingQp (struct TagWelsEncCtx* pEncCtx, int32_t iQp) {
|
||||
@@ -976,8 +980,7 @@ int32_t RcCalculateCascadingQp (struct TagWelsEncCtx* pEncCtx, int32_t iQp) {
|
||||
return iTemporalQp;
|
||||
}
|
||||
|
||||
void WelsRcPictureInitGom (void* pCtx) {
|
||||
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
|
||||
void WelsRcPictureInitGom (sWelsEncCtx* pEncCtx, long long uiTimeStamp) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
|
||||
if (pEncCtx->eSliceType == I_SLICE) {
|
||||
@@ -1007,10 +1010,7 @@ void WelsRcPictureInitGom (void* pCtx) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void WelsRcPictureInfoUpdateGom (void* pCtx, int32_t iLayerSize) {
|
||||
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
|
||||
void WelsRcPictureInfoUpdateGom (sWelsEncCtx* pEncCtx, int32_t iLayerSize) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
int32_t iCodedBits = (iLayerSize << 3);
|
||||
|
||||
@@ -1033,8 +1033,7 @@ void WelsRcPictureInfoUpdateGom (void* pCtx, int32_t iLayerSize) {
|
||||
pWelsSvcRc->iFrameCodedInVGop++;
|
||||
}
|
||||
|
||||
void WelsRcMbInitGom (void* pCtx, SMB* pCurMb, SSlice* pSlice) {
|
||||
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
|
||||
void WelsRcMbInitGom (sWelsEncCtx* pEncCtx, SMB* pCurMb, SSlice* pSlice) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
const int32_t kiSliceId = pSlice->uiSliceIdx;
|
||||
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId];
|
||||
@@ -1061,8 +1060,7 @@ void WelsRcMbInitGom (void* pCtx, SMB* pCurMb, SSlice* pSlice) {
|
||||
RcCalculateMbQp (pEncCtx, pCurMb, kiSliceId);
|
||||
}
|
||||
|
||||
void WelsRcMbInfoUpdateGom (void* pCtx, SMB* pCurMb, int32_t iCostLuma, SSlice* pSlice) {
|
||||
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
|
||||
void WelsRcMbInfoUpdateGom (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iCostLuma, SSlice* pSlice) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
SBitStringAux* bs = pSlice->pSliceBsa;
|
||||
int32_t iSliceId = pSlice->uiSliceIdx;
|
||||
@@ -1083,8 +1081,7 @@ void WelsRcMbInfoUpdateGom (void* pCtx, SMB* pCurMb, int32_t iCostLuma, SSlice*
|
||||
}
|
||||
}
|
||||
|
||||
void WelsRcPictureInitDisable (void* pCtx) {
|
||||
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
|
||||
void WelsRcPictureInitDisable (sWelsEncCtx* pEncCtx, long long uiTimeStamp) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
|
||||
const int32_t kiQp = pDLayerParam->iDLayerQp;
|
||||
@@ -1101,11 +1098,10 @@ void WelsRcPictureInitDisable (void* pCtx) {
|
||||
pWelsSvcRc->iAverageFrameQp = pEncCtx->iGlobalQp;
|
||||
}
|
||||
|
||||
void WelsRcPictureInfoUpdateDisable (void* pCtx, int32_t iLayerSize) {
|
||||
void WelsRcPictureInfoUpdateDisable (sWelsEncCtx* pEncCtx, int32_t iLayerSize) {
|
||||
}
|
||||
|
||||
void WelsRcMbInitDisable (void* pCtx, SMB* pCurMb, SSlice* pSlice) {
|
||||
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
|
||||
void WelsRcMbInitDisable (sWelsEncCtx* pEncCtx, SMB* pCurMb, SSlice* pSlice) {
|
||||
int32_t iLumaQp = pEncCtx->iGlobalQp;
|
||||
|
||||
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
|
||||
@@ -1122,11 +1118,10 @@ void WelsRcMbInitDisable (void* pCtx, SMB* pCurMb, SSlice* pSlice) {
|
||||
pCurMb->uiLumaQp = iLumaQp;
|
||||
}
|
||||
|
||||
void WelsRcMbInfoUpdateDisable (void* pCtx, SMB* pCurMb, int32_t iCostLuma, SSlice* pSlice) {
|
||||
void WelsRcMbInfoUpdateDisable (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iCostLuma, SSlice* pSlice) {
|
||||
}
|
||||
|
||||
void WelRcPictureInitBufferBasedQp (void* pCtx) {
|
||||
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
|
||||
void WelRcPictureInitBufferBasedQp (sWelsEncCtx* pEncCtx, long long uiTimeStamp) {
|
||||
SVAAFrameInfo* pVaa = static_cast<SVAAFrameInfo*> (pEncCtx->pVaa);
|
||||
|
||||
int32_t iMinQp = MIN_SCREEN_QP;
|
||||
@@ -1142,39 +1137,27 @@ void WelRcPictureInitBufferBasedQp (void* pCtx) {
|
||||
pEncCtx->iGlobalQp += 2;
|
||||
pEncCtx->iGlobalQp = WELS_CLIP3 (pEncCtx->iGlobalQp, iMinQp, MAX_SCREEN_QP);
|
||||
}
|
||||
|
||||
void InitRcModuleScc (void* pCtx) {
|
||||
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
pWelsSvcRc->iBaseQp = 30;
|
||||
|
||||
pWelsSvcRc->iBufferFullnessSkip = 0;
|
||||
pWelsSvcRc->uiLastTimeStamp = 0;
|
||||
|
||||
pWelsSvcRc->iCost2BitsIntra = INT_MULTIPLY;
|
||||
pWelsSvcRc->iAvgCost2Bits = INT_MULTIPLY;
|
||||
}
|
||||
void WelRcPictureInitScc (void* pCtx) {
|
||||
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
|
||||
void WelRcPictureInitScc (sWelsEncCtx* pEncCtx, long long uiTimeStamp) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
SVAAFrameInfoExt* pVaa = static_cast<SVAAFrameInfoExt*> (pEncCtx->pVaa);
|
||||
SSpatialLayerConfig* pDLayerConfig = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
|
||||
int32_t iFrameCplx = pVaa->sComplexityScreenParam.iFrameComplexity;
|
||||
SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
|
||||
int64_t iFrameCplx = pVaa->sComplexityScreenParam.iFrameComplexity;
|
||||
int32_t iBitRate = pDLayerConfig->iSpatialBitrate;// pEncCtx->pSvcParam->target_bitrate;
|
||||
|
||||
int32_t iBaseQp = pWelsSvcRc->iBaseQp;
|
||||
pEncCtx->iGlobalQp = iBaseQp;
|
||||
int32_t iDeltaQp = 0;
|
||||
if (pEncCtx->eSliceType == I_SLICE) {
|
||||
int32_t iTargetBits = iBitRate * 2 - pWelsSvcRc->iBufferFullnessSkip;
|
||||
int64_t iTargetBits = iBitRate * 2 - pWelsSvcRc->iBufferFullnessSkip;
|
||||
iTargetBits = WELS_MAX (1, iTargetBits);
|
||||
int32_t iQstep = WELS_DIV_ROUND ((((int64_t)iFrameCplx) * pWelsSvcRc->iCost2BitsIntra), iTargetBits);
|
||||
int32_t iQstep = WELS_DIV_ROUND (iFrameCplx * pWelsSvcRc->iCost2BitsIntra, iTargetBits);
|
||||
int32_t iQp = RcConvertQStep2Qp (iQstep);
|
||||
|
||||
pEncCtx->iGlobalQp = WELS_CLIP3 (iQp, MIN_IDR_QP, MAX_IDR_QP);
|
||||
} else {
|
||||
int32_t iTargetBits = WELS_ROUND (((float)iBitRate / pDLayerConfig->fFrameRate)); //iBitRate / 10;
|
||||
int32_t iQstep = (int32_t) (WELS_DIV_ROUND64 (iFrameCplx * pWelsSvcRc->iAvgCost2Bits, iTargetBits));
|
||||
int64_t iTargetBits = WELS_ROUND (((float)iBitRate / pDLayerParamInternal->fOutputFrameRate)); //iBitRate / 10;
|
||||
int32_t iQstep = WELS_DIV_ROUND (iFrameCplx * pWelsSvcRc->iAvgCost2Bits, iTargetBits);
|
||||
int32_t iQp = RcConvertQStep2Qp (iQstep);
|
||||
iDeltaQp = iQp - iBaseQp;
|
||||
if (pWelsSvcRc->iBufferFullnessSkip > iBitRate) {
|
||||
@@ -1212,55 +1195,20 @@ void WelRcPictureInitScc (void* pCtx) {
|
||||
}
|
||||
pWelsSvcRc->iAverageFrameQp = pEncCtx->iGlobalQp;
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, "WelRcPictureInitScc iLumaQp = %d\n", pEncCtx->iGlobalQp);
|
||||
|
||||
}
|
||||
void WelsRcFrameDelayJudgeScc (void* pCtx, EVideoFrameType eFrameType, long long uiTimeStamp) {
|
||||
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[0];
|
||||
SSpatialLayerConfig* pDLayerConfig = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
|
||||
|
||||
if (pDLayerConfig->iSpatialBitrate > pDLayerConfig->iMaxSpatialBitrate)
|
||||
pDLayerConfig->iSpatialBitrate = pDLayerConfig->iMaxSpatialBitrate;
|
||||
|
||||
int32_t iBitRate = pDLayerConfig->iSpatialBitrate;
|
||||
int32_t iEncTimeInv = (pWelsSvcRc->uiLastTimeStamp == 0) ? 0 : (int32_t) (uiTimeStamp - pWelsSvcRc->uiLastTimeStamp);
|
||||
int32_t iSentBits = (int32_t) ((double)iBitRate * iEncTimeInv * (1.0E-3) + 0.5);
|
||||
iSentBits = WELS_MAX (iSentBits, 0);
|
||||
|
||||
const int32_t iVbufferThRatio = (eFrameType == videoFrameTypeI
|
||||
|| eFrameType == videoFrameTypeIDR) ? VIRTUAL_BUFFER_HIGH_TH : VIRTUAL_BUFFER_LOW_TH;
|
||||
const int32_t iVbufferTh = WELS_DIV_ROUND ((((int64_t)iBitRate) * iVbufferThRatio), INT_MULTIPLY);
|
||||
|
||||
pWelsSvcRc->iBufferFullnessSkip -= iSentBits;
|
||||
pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (0, pWelsSvcRc->iBufferFullnessSkip);
|
||||
|
||||
pWelsSvcRc->bSkipFlag = true;
|
||||
if (pWelsSvcRc->iBufferFullnessSkip < iVbufferTh) {
|
||||
pWelsSvcRc->bSkipFlag = false;
|
||||
}
|
||||
if (pWelsSvcRc->bSkipFlag) {
|
||||
pWelsSvcRc->iSkipFrameNum++;
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_INFO,
|
||||
"SCC iSkipFrameNum = %d,buffer = %d,threadhold = %d,bitrate = %d,timestamp=%lld\n", pWelsSvcRc->iSkipFrameNum,
|
||||
pWelsSvcRc->iBufferFullnessSkip, iVbufferTh, iBitRate, uiTimeStamp);
|
||||
}
|
||||
pWelsSvcRc->uiLastTimeStamp = uiTimeStamp;
|
||||
}
|
||||
|
||||
void WelsRcDropFrameUpdate (void* pCtx, uint32_t iDropSize) {
|
||||
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
|
||||
}
|
||||
void WelsRcDropFrameUpdate (sWelsEncCtx* pEncCtx, uint32_t iDropSize) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[0];
|
||||
|
||||
pWelsSvcRc->iBufferFullnessSkip -= (int32_t)iDropSize;
|
||||
pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (0, pWelsSvcRc->iBufferFullnessSkip);
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_INFO, "[WelsRcDropFrameUpdate:\tdrop:%d\t%d\n", iDropSize,
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_INFO, "[WelsRcDropFrameUpdate:\tdrop:%d\t%"PRId64"\n", iDropSize,
|
||||
pWelsSvcRc->iBufferFullnessSkip);
|
||||
}
|
||||
|
||||
void WelsRcPictureInfoUpdateScc (void* pCtx, int32_t iNalSize) {
|
||||
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
|
||||
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[0];
|
||||
void WelsRcPictureInfoUpdateScc (sWelsEncCtx* pEncCtx, int32_t iNalSize) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
int32_t iFrameBits = (iNalSize << 3);
|
||||
pWelsSvcRc->iBufferFullnessSkip += iFrameBits;
|
||||
|
||||
@@ -1277,18 +1225,185 @@ void WelsRcPictureInfoUpdateScc (void* pCtx, int32_t iNalSize) {
|
||||
}
|
||||
|
||||
|
||||
void WelsRcMbInitScc (void* pCtx, SMB* pCurMb, SSlice* pSlice) {
|
||||
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
|
||||
|
||||
void WelsRcMbInitScc (sWelsEncCtx* pEncCtx, SMB* pCurMb, SSlice* pSlice) {
|
||||
/* Get delta iQp of this MB */
|
||||
pCurMb->uiLumaQp = pEncCtx->iGlobalQp;
|
||||
pCurMb->uiChromaQp = g_kuiChromaQpTable[WELS_CLIP3 (pCurMb->uiLumaQp + pEncCtx->pPps->uiChromaQpIndexOffset, 0, 51)];
|
||||
}
|
||||
|
||||
void WelsRcInitModule (void* pCtx, RC_MODES iRcMode) {
|
||||
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
|
||||
SWelsRcFunc* pRcf = &pEncCtx->pFuncList->pfRc;
|
||||
void InitRcModuleTimeStamp (sWelsEncCtx* pEncCtx) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
pWelsSvcRc->iBaseQp = 30;
|
||||
|
||||
pWelsSvcRc->iBufferFullnessSkip = 0;
|
||||
pWelsSvcRc->uiLastTimeStamp = 0;
|
||||
|
||||
pWelsSvcRc->iCost2BitsIntra = INT_MULTIPLY;
|
||||
pWelsSvcRc->iAvgCost2Bits = INT_MULTIPLY;
|
||||
pWelsSvcRc->iSkipBufferRatio = SKIP_RATIO;
|
||||
}
|
||||
void WelsRcFrameDelayJudgeTimeStamp (sWelsEncCtx* pEncCtx, EVideoFrameType eFrameType, long long uiTimeStamp) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
SSpatialLayerConfig* pDLayerConfig = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
|
||||
|
||||
if (pDLayerConfig->iSpatialBitrate > pDLayerConfig->iMaxSpatialBitrate)
|
||||
pDLayerConfig->iSpatialBitrate = pDLayerConfig->iMaxSpatialBitrate;
|
||||
|
||||
int32_t iBitRate = pDLayerConfig->iSpatialBitrate;
|
||||
int32_t iEncTimeInv = (pWelsSvcRc->uiLastTimeStamp == 0) ? 0 : (int32_t) (uiTimeStamp - pWelsSvcRc->uiLastTimeStamp);
|
||||
int32_t iSentBits = (int32_t) ((double)iBitRate * iEncTimeInv * (1.0E-3) + 0.5);
|
||||
iSentBits = WELS_MAX (iSentBits, 0);
|
||||
|
||||
//When bitrate is changed, pBuffer size should be updated
|
||||
pWelsSvcRc->iBufferSizeSkip = WELS_DIV_ROUND (pDLayerConfig->iSpatialBitrate * pWelsSvcRc->iSkipBufferRatio,
|
||||
INT_MULTIPLY);
|
||||
pWelsSvcRc->iBufferSizePadding = WELS_DIV_ROUND (pDLayerConfig->iSpatialBitrate * PADDING_BUFFER_RATIO, INT_MULTIPLY);
|
||||
|
||||
pWelsSvcRc->iBufferFullnessSkip -= iSentBits;
|
||||
pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (0, pWelsSvcRc->iBufferFullnessSkip);
|
||||
|
||||
if (pEncCtx->pSvcParam->bEnableFrameSkip) {
|
||||
pWelsSvcRc->bSkipFlag = true;
|
||||
if (pWelsSvcRc->iBufferFullnessSkip < pWelsSvcRc->iBufferSizeSkip) {
|
||||
pWelsSvcRc->bSkipFlag = false;
|
||||
}
|
||||
if (pWelsSvcRc->bSkipFlag) {
|
||||
pWelsSvcRc->iSkipFrameNum++;
|
||||
pWelsSvcRc->uiLastTimeStamp = uiTimeStamp;
|
||||
}
|
||||
}
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
|
||||
"WelsRcFrameDelayJudgeTimeStamp iSkipFrameNum = %d,buffer = %"PRId64",threadhold = %d,bitrate = %d,iSentBits = %d,lasttimestamp = %lld,timestamp=%lld\n",
|
||||
pWelsSvcRc->iSkipFrameNum, pWelsSvcRc->iBufferFullnessSkip, pWelsSvcRc->iBufferSizeSkip, iBitRate, iSentBits,
|
||||
pWelsSvcRc->uiLastTimeStamp, uiTimeStamp);
|
||||
}
|
||||
void WelsRcPictureInitGomTimeStamp (sWelsEncCtx* pEncCtx, long long uiTimeStamp) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
|
||||
int32_t iLumaQp = pWelsSvcRc->iLastCalculatedQScale;
|
||||
//decide one frame bits allocated
|
||||
if (pEncCtx->eSliceType == I_SLICE) {
|
||||
if (0 == pWelsSvcRc->iIdrNum) { //iIdrNum == 0 means encoder has been initialed
|
||||
RcInitRefreshParameter (pEncCtx);
|
||||
double dBpp = 0.05;
|
||||
if ((pDLayerParam->fFrameRate > EPSN) && (pDLayerParam->iVideoWidth && pDLayerParam->iVideoHeight))
|
||||
dBpp = (double) (pDLayerParam->iSpatialBitrate) / (double) (pDLayerParam->fFrameRate * pDLayerParam->iVideoWidth *
|
||||
pDLayerParam->iVideoHeight);
|
||||
pWelsSvcRc->iInitialQp = (int32_t) (50 - dBpp * 10 * 4);
|
||||
pWelsSvcRc->iInitialQp = WELS_CLIP3 (pWelsSvcRc->iInitialQp, MIN_IDR_QP, MAX_IDR_QP);
|
||||
|
||||
iLumaQp = pWelsSvcRc->iInitialQp;
|
||||
pWelsSvcRc->iTargetBits = static_cast<int32_t> (((double) (pDLayerParam->iSpatialBitrate) / (double) (
|
||||
pDLayerParam->fFrameRate) *
|
||||
IDR_BITRATE_RATIO));
|
||||
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
|
||||
"[Rc] First IDR iSpatialBitrate = %d,iBufferFullnessSkip = %"PRId64",iTargetBits= %d,dBpp = %f,initQp = %d",
|
||||
pDLayerParam->iSpatialBitrate, pWelsSvcRc->iBufferFullnessSkip, pWelsSvcRc->iTargetBits, dBpp,
|
||||
pWelsSvcRc->iInitialQp);
|
||||
|
||||
} else {
|
||||
int32_t iMaxTh = static_cast<int32_t> (pWelsSvcRc->iBufferSizeSkip - pWelsSvcRc->iBufferFullnessSkip);
|
||||
int32_t iMinTh = iMaxTh / 2;
|
||||
pWelsSvcRc->iTargetBits = static_cast<int32_t> (((double) (pDLayerParam->iSpatialBitrate) / (double) (
|
||||
pDLayerParam->fFrameRate) *
|
||||
IDR_BITRATE_RATIO));
|
||||
if (iMaxTh > 0) {
|
||||
pWelsSvcRc->iTargetBits = WELS_CLIP3 (pWelsSvcRc->iTargetBits, iMinTh, iMaxTh);
|
||||
|
||||
pWelsSvcRc->iQStep = WELS_DIV_ROUND ((((int64_t)pWelsSvcRc->iIntraComplexity) *
|
||||
pWelsSvcRc->iCost2BitsIntra), pWelsSvcRc->iTargetBits);
|
||||
iLumaQp = RcConvertQStep2Qp (pWelsSvcRc->iQStep);
|
||||
|
||||
iLumaQp = WELS_CLIP3 (iLumaQp, pEncCtx->iGlobalQp - DELTA_QP_BGD_THD, pEncCtx->iGlobalQp + DELTA_QP_BGD_THD);
|
||||
|
||||
} else {
|
||||
iLumaQp = pWelsSvcRc->iLastCalculatedQScale + DELTA_QP_BGD_THD;
|
||||
}
|
||||
iLumaQp = WELS_CLIP3 (iLumaQp, MIN_IDR_QP, MAX_IDR_QP);
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
|
||||
"[Rc]I iLumaQp = %d,iQStep = %d,iTargetBits = %d,iBufferFullnessSkip =%"PRId64",iMaxTh=%d,iMinTh = %d,iFrameComplexity= %"PRId64,
|
||||
iLumaQp, pWelsSvcRc->iQStep, pWelsSvcRc->iTargetBits, pWelsSvcRc->iBufferFullnessSkip, iMaxTh, iMinTh,
|
||||
pWelsSvcRc->iIntraComplexity);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
int32_t iTl = pEncCtx->uiTemporalId;
|
||||
SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[iTl];
|
||||
int32_t iMaxTh = static_cast<int32_t> (pWelsSvcRc->iBufferSizeSkip - pWelsSvcRc->iBufferFullnessSkip);
|
||||
int32_t iMinTh = iMaxTh / (iTl + 2);
|
||||
|
||||
SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
|
||||
const int32_t kiGopSize = (1 << pDLayerParamInternal->iDecompositionStages);
|
||||
int32_t iAverageFrameSize = (int32_t) ((double) (pDLayerParam->iSpatialBitrate) / (double) (pDLayerParam->fFrameRate));
|
||||
const int32_t kiGopBits = iAverageFrameSize * kiGopSize;
|
||||
int64_t iCmplxRatio = WELS_DIV_ROUND64 (pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity * INT_MULTIPLY,
|
||||
pTOverRc->iFrameCmplxMean);
|
||||
iCmplxRatio = WELS_CLIP3 (iCmplxRatio, INT_MULTIPLY - FRAME_CMPLX_RATIO_RANGE, INT_MULTIPLY + FRAME_CMPLX_RATIO_RANGE);
|
||||
|
||||
|
||||
pWelsSvcRc->iTargetBits = WELS_DIV_ROUND (pTOverRc->iTlayerWeight * kiGopBits, INT_MULTIPLY * 10 * 2);
|
||||
if (iMaxTh > 0) {
|
||||
pWelsSvcRc->iTargetBits = WELS_CLIP3 (pWelsSvcRc->iTargetBits, iMinTh, iMaxTh);
|
||||
if (0 == pTOverRc->iPFrameNum)
|
||||
iLumaQp = pWelsSvcRc->iInitialQp;
|
||||
else {
|
||||
|
||||
pWelsSvcRc->iQStep = WELS_DIV_ROUND ((pTOverRc->iLinearCmplx * iCmplxRatio), (pWelsSvcRc->iTargetBits * INT_MULTIPLY));
|
||||
iLumaQp = RcConvertQStep2Qp (pWelsSvcRc->iQStep);
|
||||
iLumaQp = WELS_CLIP3 (iLumaQp, pEncCtx->iGlobalQp - DELTA_QP_BGD_THD, pEncCtx->iGlobalQp + DELTA_QP_BGD_THD);
|
||||
}
|
||||
} else {
|
||||
iLumaQp = pWelsSvcRc->iLastCalculatedQScale + DELTA_QP_BGD_THD;
|
||||
}
|
||||
|
||||
iLumaQp = WELS_CLIP3 (iLumaQp, GOM_MIN_QP_MODE, GOM_MAX_QP_MODE);
|
||||
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
|
||||
"[Rc]P iTl = %d,iLumaQp = %d,iQStep = %d,iTargetBits = %d,iBufferFullnessSkip =%"PRId64",iMaxTh=%d,iMinTh = %d,iFrameComplexity= %lld,iCmplxRatio=%"PRId64,
|
||||
iTl, iLumaQp, pWelsSvcRc->iQStep, pWelsSvcRc->iTargetBits, pWelsSvcRc->iBufferFullnessSkip, iMaxTh, iMinTh,
|
||||
pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity, iCmplxRatio);
|
||||
}
|
||||
|
||||
pWelsSvcRc->iQStep = RcConvertQp2QStep (iLumaQp);
|
||||
pWelsSvcRc->iLastCalculatedQScale = iLumaQp;
|
||||
pEncCtx->iGlobalQp = iLumaQp;
|
||||
|
||||
RcInitSliceInformation (pEncCtx);
|
||||
RcInitGomParameters (pEncCtx);
|
||||
float fInstantFps = (uiTimeStamp - pWelsSvcRc->uiLastTimeStamp) > 0 ? (1000.0f / (uiTimeStamp -
|
||||
pWelsSvcRc->uiLastTimeStamp)) : 0;
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
|
||||
"[Rc]pEncCtx->iGlobalQp= %d,uiTimeStamp = %lld,uiLastTimeStamp = %lld,InstantFps = %f,settingFps = %f",
|
||||
pEncCtx->iGlobalQp, uiTimeStamp, pWelsSvcRc->uiLastTimeStamp,
|
||||
fInstantFps, pDLayerParam->fFrameRate);
|
||||
pWelsSvcRc->uiLastTimeStamp = uiTimeStamp;
|
||||
|
||||
}
|
||||
|
||||
void WelsRcPictureInfoUpdateGomTimeStamp (sWelsEncCtx* pEncCtx, int32_t iLayerSize) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
int32_t iCodedBits = (iLayerSize << 3);
|
||||
|
||||
RcUpdatePictureQpBits (pEncCtx, iCodedBits);
|
||||
if (pEncCtx->eSliceType == P_SLICE) {
|
||||
RcUpdateFrameComplexity (pEncCtx);
|
||||
} else {
|
||||
RcUpdateIntraComplexity (pEncCtx);
|
||||
}
|
||||
|
||||
pWelsSvcRc->iRemainingBits -= pWelsSvcRc->iFrameDqBits;
|
||||
//condition 1: whole pBuffer fullness
|
||||
pWelsSvcRc->iBufferFullnessSkip += pWelsSvcRc->iFrameDqBits;
|
||||
|
||||
|
||||
if (pEncCtx->pSvcParam->iPaddingFlag)
|
||||
RcVBufferCalculationPadding (pEncCtx);
|
||||
pWelsSvcRc->iFrameCodedInVGop++;
|
||||
}
|
||||
void WelsRcInitModule (sWelsEncCtx* pEncCtx, RC_MODES iRcMode) {
|
||||
SWelsRcFunc* pRcf = &pEncCtx->pFuncList->pfRc;
|
||||
switch (iRcMode) {
|
||||
case RC_OFF_MODE:
|
||||
pRcf->pfWelsRcPictureInit = WelsRcPictureInitDisable;
|
||||
@@ -1296,6 +1411,9 @@ void WelsRcInitModule (void* pCtx, RC_MODES iRcMode) {
|
||||
pRcf->pfWelsRcPictureInfoUpdate = WelsRcPictureInfoUpdateDisable;
|
||||
pRcf->pfWelsRcMbInit = WelsRcMbInitDisable;
|
||||
pRcf->pfWelsRcMbInfoUpdate = WelsRcMbInfoUpdateDisable;
|
||||
pRcf->pfWelsCheckSkipBasedMaxbr = NULL;
|
||||
pRcf->pfWelsUpdateBufferWhenSkip = NULL;
|
||||
pRcf->pfWelsUpdateMaxBrWindowStatus = NULL;
|
||||
break;
|
||||
case RC_BUFFERBASED_MODE:
|
||||
pRcf->pfWelsRcPictureInit = WelRcPictureInitBufferBasedQp;
|
||||
@@ -1303,23 +1421,38 @@ void WelsRcInitModule (void* pCtx, RC_MODES iRcMode) {
|
||||
pRcf->pfWelsRcPictureInfoUpdate = WelsRcPictureInfoUpdateDisable;
|
||||
pRcf->pfWelsRcMbInit = WelsRcMbInitDisable;
|
||||
pRcf->pfWelsRcMbInfoUpdate = WelsRcMbInfoUpdateDisable;
|
||||
pRcf->pfWelsCheckSkipBasedMaxbr = NULL;
|
||||
pRcf->pfWelsUpdateBufferWhenSkip = NULL;
|
||||
pRcf->pfWelsUpdateMaxBrWindowStatus = NULL;
|
||||
break;
|
||||
case RC_BITRATE_MODE:
|
||||
pRcf->pfWelsRcPictureInit = WelsRcPictureInitGom;
|
||||
pRcf->pfWelsRcPicDelayJudge = WelsRcFrameDelayJudge;
|
||||
pRcf->pfWelsRcPictureInfoUpdate = WelsRcPictureInfoUpdateGom;
|
||||
pRcf->pfWelsRcMbInit = WelsRcMbInitGom;
|
||||
pRcf->pfWelsRcMbInfoUpdate = WelsRcMbInfoUpdateGom;
|
||||
pRcf->pfWelsCheckSkipBasedMaxbr = CheckFrameSkipBasedMaxbr;
|
||||
pRcf->pfWelsUpdateBufferWhenSkip = UpdateBufferWhenFrameSkipped;
|
||||
pRcf->pfWelsUpdateMaxBrWindowStatus = UpdateMaxBrCheckWindowStatus;
|
||||
break;
|
||||
case RC_TIMESTAMP_MODE:
|
||||
if (pEncCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {
|
||||
pRcf->pfWelsRcPictureInit = WelRcPictureInitScc;
|
||||
pRcf->pfWelsRcPicDelayJudge = WelsRcFrameDelayJudgeScc;
|
||||
pRcf->pfWelsRcPictureInfoUpdate = WelsRcPictureInfoUpdateScc;
|
||||
pRcf->pfWelsRcMbInit = WelsRcMbInitScc;
|
||||
pRcf->pfWelsRcMbInfoUpdate = WelsRcMbInfoUpdateDisable;
|
||||
InitRcModuleScc (pEncCtx);
|
||||
|
||||
} else {
|
||||
pRcf->pfWelsRcPictureInit = WelsRcPictureInitGom;
|
||||
pRcf->pfWelsRcPicDelayJudge = WelsRcFrameDelayJudge;
|
||||
pRcf->pfWelsRcPictureInfoUpdate = WelsRcPictureInfoUpdateGom;
|
||||
pRcf->pfWelsRcPictureInit = WelsRcPictureInitGomTimeStamp;
|
||||
pRcf->pfWelsRcPictureInfoUpdate = WelsRcPictureInfoUpdateGomTimeStamp;
|
||||
pRcf->pfWelsRcMbInit = WelsRcMbInitGom;
|
||||
pRcf->pfWelsRcMbInfoUpdate = WelsRcMbInfoUpdateGom;
|
||||
}
|
||||
pRcf->pfWelsRcPicDelayJudge = WelsRcFrameDelayJudgeTimeStamp;
|
||||
pRcf->pfWelsCheckSkipBasedMaxbr = CheckFrameSkipBasedMaxbr;
|
||||
pRcf->pfWelsUpdateBufferWhenSkip = NULL;
|
||||
pRcf->pfWelsUpdateMaxBrWindowStatus = NULL;
|
||||
InitRcModuleTimeStamp (pEncCtx);
|
||||
break;
|
||||
case RC_QUALITY_MODE:
|
||||
default:
|
||||
@@ -1328,14 +1461,17 @@ void WelsRcInitModule (void* pCtx, RC_MODES iRcMode) {
|
||||
pRcf->pfWelsRcPictureInfoUpdate = WelsRcPictureInfoUpdateGom;
|
||||
pRcf->pfWelsRcMbInit = WelsRcMbInitGom;
|
||||
pRcf->pfWelsRcMbInfoUpdate = WelsRcMbInfoUpdateGom;
|
||||
pRcf->pfWelsCheckSkipBasedMaxbr = CheckFrameSkipBasedMaxbr;
|
||||
pRcf->pfWelsUpdateBufferWhenSkip = UpdateBufferWhenFrameSkipped;
|
||||
pRcf->pfWelsUpdateMaxBrWindowStatus = UpdateMaxBrCheckWindowStatus;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
RcInitSequenceParameter (pEncCtx);
|
||||
}
|
||||
|
||||
void WelsRcFreeMemory (void* pCtx) {
|
||||
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
|
||||
void WelsRcFreeMemory (sWelsEncCtx* pEncCtx) {
|
||||
SWelsSvcRc* pWelsSvcRc = NULL;
|
||||
int32_t i = 0;
|
||||
for (i = 0; i < pEncCtx->pSvcParam->iSpatialLayerNum; i++) {
|
||||
|
||||
@@ -289,8 +289,10 @@ static inline void LTRMarkProcess (sWelsEncCtx* pCtx) {
|
||||
}
|
||||
}
|
||||
|
||||
if ((pLtr->iLTRMarkMode == LTR_DELAY_MARK && pLtr->bLTRMarkingFlag) || ((pLtr->iLTRMarkMode == LTR_DIRECT_MARK)
|
||||
&& (bMoveLtrFromShortToLong))) {
|
||||
if ((pLtr->iLTRMarkMode == LTR_DELAY_MARK && pLtr->bLTRMarkingFlag)
|
||||
|| ((pLtr->iLTRMarkMode == LTR_DIRECT_MARK) && (bMoveLtrFromShortToLong))) {
|
||||
pCtx->bRefOfCurTidIsLtr[pCtx->uiDependencyId][pCtx->uiTemporalId] = true;
|
||||
|
||||
if (pRefList->uiLongRefCount > 0) {
|
||||
memmove (&pRefList->pLongRefList[1], &pRefList->pLongRefList[0],
|
||||
pRefList->uiLongRefCount * sizeof (SPicture*)); // confirmed_safe_unsafe_usage
|
||||
@@ -595,6 +597,9 @@ bool WelsBuildRefList (sWelsEncCtx* pCtx, const int32_t iPOC, int32_t iBestLtrRe
|
||||
} else { // safe for IDR
|
||||
WelsResetRefList (pCtx); //for IDR, SHOULD reset pRef list.
|
||||
ResetLtrState (&pCtx->pLtr[pCtx->uiDependencyId]); //SHOULD update it when IDR.
|
||||
for (int32_t k = 0; k < MAX_TEMPORAL_LEVEL; k++) {
|
||||
pCtx->bRefOfCurTidIsLtr[pCtx->uiDependencyId][k] = false;
|
||||
}
|
||||
pCtx->pRefList0[0] = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -1148,7 +1148,8 @@ void WelsMdInterFinePartition (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* p
|
||||
}
|
||||
}
|
||||
|
||||
void WelsMdInterFinePartitionVaa (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* pSlice, SMB* pCurMb, int32_t iBestCost) {
|
||||
void WelsMdInterFinePartitionVaa (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* pSlice, SMB* pCurMb,
|
||||
int32_t iBestCost) {
|
||||
SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer;
|
||||
// SMbCache *pMbCache = &pSlice->sMbCacheInfo;
|
||||
int32_t iCostP8x16, iCostP16x8, iCostP8x8;
|
||||
@@ -1247,9 +1248,9 @@ void WelsMdBackgroundMbEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb,
|
||||
pDstCr = pMbCache->pMemPredChroma + 64;
|
||||
}
|
||||
//MC
|
||||
pFunc->sMcFuncs.pfLumaQuarpelMc[0] (pRefLuma, iLineSizeY, pDstLuma, 16, 16);
|
||||
pFunc->sMcFuncs.pfChromaMc (pRefCb, iLineSizeUV, pDstCb, 8, sMvp, 8, 8); //Cb
|
||||
pFunc->sMcFuncs.pfChromaMc (pRefCr, iLineSizeUV, pDstCr, 8, sMvp, 8, 8); //Cr
|
||||
pFunc->sMcFuncs.pMcLumaFunc (pRefLuma, iLineSizeY, pDstLuma, 16, 0, 0, 16, 16);
|
||||
pFunc->sMcFuncs.pMcChromaFunc (pRefCb, iLineSizeUV, pDstCb, 8, sMvp.iMvX, sMvp.iMvY, 8, 8); //Cb
|
||||
pFunc->sMcFuncs.pMcChromaFunc (pRefCr, iLineSizeUV, pDstCr, 8, sMvp.iMvX, sMvp.iMvY, 8, 8); //Cr
|
||||
|
||||
pCurMb->uiCbp = 0;
|
||||
pMbCache->bCollocatedPredFlag = true;
|
||||
@@ -1313,7 +1314,6 @@ bool WelsMdPSkipEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCac
|
||||
uint8_t* pDstCr = pMbCache->pSkipMb + 256 + 64;
|
||||
|
||||
SMVUnitXY sMvp = { 0 };
|
||||
uint8_t uiMvpIdx;
|
||||
int32_t n;
|
||||
|
||||
int32_t iEncStride = pCurLayer->iEncStride[0];
|
||||
@@ -1343,19 +1343,18 @@ bool WelsMdPSkipEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCac
|
||||
|
||||
//luma
|
||||
pRefLuma += sQpelMvp.iMvY * iLineSizeY + sQpelMvp.iMvX;
|
||||
uiMvpIdx = ((sMvp.iMvY & 0x03) << 2) + (sMvp.iMvX & 0x03);
|
||||
pFunc->sMcFuncs.pfLumaQuarpelMc[uiMvpIdx] (pRefLuma, iLineSizeY, pDstLuma, 16, 16);
|
||||
pFunc->sMcFuncs.pMcLumaFunc (pRefLuma, iLineSizeY, pDstLuma, 16, sMvp.iMvX, sMvp.iMvY, 16, 16);
|
||||
iSadCostLuma = pFunc->sSampleDealingFuncs.pfSampleSad[BLOCK_16x16] (pMbCache->SPicData.pEncMb[0],
|
||||
pCurLayer->iEncStride[0], pDstLuma, 16);
|
||||
|
||||
const int32_t iStrideUV = (sQpelMvp.iMvY >> 1) * iLineSizeUV + (sQpelMvp.iMvX >> 1);
|
||||
pRefCb += iStrideUV;
|
||||
pFunc->sMcFuncs.pfChromaMc (pRefCb, iLineSizeUV, pDstCb, 8, sMvp, 8, 8); //Cb
|
||||
pFunc->sMcFuncs.pMcChromaFunc (pRefCb, iLineSizeUV, pDstCb, 8, sMvp.iMvX, sMvp.iMvY, 8, 8); //Cb
|
||||
iSadCostChroma = pFunc->sSampleDealingFuncs.pfSampleSad[BLOCK_8x8] (pMbCache->SPicData.pEncMb[1],
|
||||
pCurLayer->iEncStride[1], pDstCb, 8);
|
||||
|
||||
pRefCr += iStrideUV;
|
||||
pFunc->sMcFuncs.pfChromaMc (pRefCr, iLineSizeUV, pDstCr, 8, sMvp, 8, 8); //Cr
|
||||
pFunc->sMcFuncs.pMcChromaFunc (pRefCr, iLineSizeUV, pDstCr, 8, sMvp.iMvX, sMvp.iMvY, 8, 8); //Cr
|
||||
iSadCostChroma += pFunc->sSampleDealingFuncs.pfSampleSad[BLOCK_8x8] (pMbCache->SPicData.pEncMb[2],
|
||||
pCurLayer->iEncStride[2], pDstCr, 8);
|
||||
|
||||
@@ -1430,6 +1429,7 @@ const int32_t g_kiPixStrideIdx8x8[4] = { 0,
|
||||
|
||||
void WelsMdInterMbRefinement (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCache* pMbCache) {
|
||||
SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer;
|
||||
SWelsFuncPtrList* pFunc = pEncCtx->pFuncList;
|
||||
uint8_t* pTmpRefCb, *pTmpRefCr, *pTmpDstCb, *pTmpDstCr;
|
||||
int32_t iMvStride, iRefBlk4Stride, iDstBlk4Stride;
|
||||
SMVUnitXY* pMv;
|
||||
@@ -1450,6 +1450,8 @@ void WelsMdInterMbRefinement (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurM
|
||||
case MB_TYPE_16x16:
|
||||
//luma
|
||||
InitMeRefinePointer (&sMeRefine, pMbCache, 0);
|
||||
sMeRefine.pfCopyBlockByMode =
|
||||
pFunc->pfCopy16x16NotAligned; // dst can be align with 16 bytes, but not sure at pSrc, 12/29/2011
|
||||
MeRefineFracPixel (pEncCtx, pDstLuma, &pWelsMd->sMe.sMe16x16, &sMeRefine, 16, 16);
|
||||
UpdateP16x16MotionInfo (pMbCache, pCurMb, pWelsMd->uiRef, &pWelsMd->sMe.sMe16x16.sMv);
|
||||
|
||||
@@ -1463,8 +1465,8 @@ void WelsMdInterMbRefinement (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurM
|
||||
iMvStride = (pMv->iMvY >> 3) * iLineSizeRefUV + (pMv->iMvX >> 3);
|
||||
pTmpRefCb = pRefCb + iMvStride;
|
||||
pTmpRefCr = pRefCr + iMvStride;
|
||||
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCb, iLineSizeRefUV, pDstCb, 8, *pMv, 8, 8); //Cb
|
||||
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCr, iLineSizeRefUV, pDstCr, 8, *pMv, 8, 8); //Cr
|
||||
pEncCtx->pFuncList->sMcFuncs.pMcChromaFunc (pTmpRefCb, iLineSizeRefUV, pDstCb, 8, pMv->iMvX, pMv->iMvY, 8, 8); //Cb
|
||||
pEncCtx->pFuncList->sMcFuncs.pMcChromaFunc (pTmpRefCr, iLineSizeRefUV, pDstCr, 8, pMv->iMvX, pMv->iMvY, 8, 8); //Cr
|
||||
|
||||
pWelsMd->iCostSkipMb = pEncCtx->pFuncList->sSampleDealingFuncs.pfSampleSad[BLOCK_16x16] (pMbCache->SPicData.pEncMb[0],
|
||||
pCurDqLayer->iEncStride[0], pDstLuma, 16);
|
||||
@@ -1476,6 +1478,8 @@ void WelsMdInterMbRefinement (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurM
|
||||
|
||||
case MB_TYPE_16x8:
|
||||
iPixStride = 0;
|
||||
sMeRefine.pfCopyBlockByMode =
|
||||
pFunc->pfCopy16x8NotAligned; // dst can be align with 16 bytes, but not sure at pSrc, 12/29/2011
|
||||
for (i = 0; i < 2; i++) {
|
||||
//luma
|
||||
iIdx = i << 3;
|
||||
@@ -1498,13 +1502,14 @@ void WelsMdInterMbRefinement (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurM
|
||||
pTmpRefCr = pRefCr + iRefBlk4Stride + iMvStride;
|
||||
pTmpDstCb = pDstCb + iDstBlk4Stride;
|
||||
pTmpDstCr = pDstCr + iDstBlk4Stride;
|
||||
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCb, iLineSizeRefUV, pTmpDstCb, 8, *pMv, 8, 4); //Cb
|
||||
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCr, iLineSizeRefUV, pTmpDstCr, 8, *pMv, 8, 4); //Cr
|
||||
pEncCtx->pFuncList->sMcFuncs.pMcChromaFunc (pTmpRefCb, iLineSizeRefUV, pTmpDstCb, 8, pMv->iMvX, pMv->iMvY, 8, 4); //Cb
|
||||
pEncCtx->pFuncList->sMcFuncs.pMcChromaFunc (pTmpRefCr, iLineSizeRefUV, pTmpDstCr, 8, pMv->iMvX, pMv->iMvY, 8, 4); //Cr
|
||||
}
|
||||
break;
|
||||
|
||||
case MB_TYPE_8x16:
|
||||
iPixStride = 0;
|
||||
sMeRefine.pfCopyBlockByMode = pFunc->pfCopy8x16Aligned;
|
||||
for (i = 0; i < 2; i++) {
|
||||
//luma
|
||||
iIdx = i << 2;
|
||||
@@ -1526,12 +1531,12 @@ void WelsMdInterMbRefinement (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurM
|
||||
pTmpRefCr = pRefCr + iRefBlk4Stride + iMvStride;
|
||||
pTmpDstCb = pDstCb + iRefBlk4Stride;
|
||||
pTmpDstCr = pDstCr + iRefBlk4Stride;
|
||||
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCb, iLineSizeRefUV, pTmpDstCb, 8, *pMv, 4, 8); //Cb
|
||||
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCr, iLineSizeRefUV, pTmpDstCr, 8, *pMv, 4, 8); //Cr
|
||||
pEncCtx->pFuncList->sMcFuncs.pMcChromaFunc (pTmpRefCb, iLineSizeRefUV, pTmpDstCb, 8, pMv->iMvX, pMv->iMvY, 4, 8); //Cb
|
||||
pEncCtx->pFuncList->sMcFuncs.pMcChromaFunc (pTmpRefCr, iLineSizeRefUV, pTmpDstCr, 8, pMv->iMvX, pMv->iMvY, 4, 8); //Cr
|
||||
}
|
||||
break;
|
||||
|
||||
case MB_TYPE_8x8:
|
||||
sMeRefine.pfCopyBlockByMode = pFunc->pfCopy8x8Aligned;
|
||||
for (i = 0; i < 4; i++) {
|
||||
int32_t iBlk8Idx = i << 2; //0, 4, 8, 12
|
||||
int32_t iBlk4X, iBlk4Y;
|
||||
@@ -1560,8 +1565,10 @@ void WelsMdInterMbRefinement (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurM
|
||||
pTmpDstCb = pDstCb + iDstBlk4Stride;
|
||||
pTmpRefCr = pRefCr + iRefBlk4Stride;
|
||||
pTmpDstCr = pDstCr + iDstBlk4Stride;
|
||||
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCb + iMvStride, iLineSizeRefUV, pTmpDstCb, 8, *pMv, 4, 4); //Cb
|
||||
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCr + iMvStride, iLineSizeRefUV, pTmpDstCr, 8, *pMv, 4, 4); //Cr
|
||||
pEncCtx->pFuncList->sMcFuncs.pMcChromaFunc (pTmpRefCb + iMvStride, iLineSizeRefUV, pTmpDstCb, 8, pMv->iMvX, pMv->iMvY,
|
||||
4, 4); //Cb
|
||||
pEncCtx->pFuncList->sMcFuncs.pMcChromaFunc (pTmpRefCr + iMvStride, iLineSizeRefUV, pTmpDstCr, 8, pMv->iMvX, pMv->iMvY,
|
||||
4, 4); //Cr
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user