update
This commit is contained in:
parent
1c78169b75
commit
6aafd284c0
174 changed files with 965 additions and 40240 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
*.tar
|
||||
*.tar.gz
|
||||
*.tar.xz
|
55
apk/v3.13/main/amf-headers/APKBUILD
Normal file
55
apk/v3.13/main/amf-headers/APKBUILD
Normal file
|
@ -0,0 +1,55 @@
|
|||
# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
|
||||
# Contributor: Daniel Bermond <dbermond@archlinux.org>
|
||||
|
||||
pkgname=amf-headers
|
||||
pkgver=1.4.18
|
||||
pkgrel=0
|
||||
pkgdesc='Header files for AMD Advanced Media Framework'
|
||||
arch='noarch'
|
||||
url=https://github.com/GPUOpen-LibrariesAndSDKs/AMF/
|
||||
license='MIT'
|
||||
makedepends='git'
|
||||
_gittag=7a83513f8a0c9f2b2b6270dbb294cd942d27a499
|
||||
_giturl=https://github.com/GPUOpen-LibrariesAndSDKs/AMF
|
||||
source="${pkgname}-${pkgver}.tar.gz"
|
||||
options="!check"
|
||||
|
||||
builddir="$srcdir/$pkgname"
|
||||
|
||||
snapshot() {
|
||||
mkdir -p "$srcdir"
|
||||
cd "${srcdir}"
|
||||
if ! [ -d $pkgname.git ]; then
|
||||
git clone $_giturl $pkgname.git || return 1
|
||||
cd $pkgname.git
|
||||
else
|
||||
cd $pkgname.git
|
||||
git fetch || return 1
|
||||
fi
|
||||
|
||||
echo "Checking out"
|
||||
git checkout $_gittag
|
||||
echo "Repo archive"
|
||||
git archive --prefix="$pkgname/" -o $pkgname.tar --format "tar" $_gittag
|
||||
|
||||
gzip $pkgname.tar -c > "$SRCDEST"/$pkgname-$pkgver.tar.gz
|
||||
ln -s "$SRCDEST"/$pkgname-$pkgver.tar.gz "$startdir"/$pkgname-$pkgver.tar.gz
|
||||
}
|
||||
|
||||
|
||||
pkgver() {
|
||||
cd "$builddir"
|
||||
|
||||
git describe --tags | sed 's/^v//'
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "${builddir}"
|
||||
install -dm 755 "${pkgdir}"/usr/include
|
||||
mkdir "${pkgdir}/usr/include/AMF"
|
||||
cp -r amf/public/include/* "${pkgdir}"/usr/include/AMF/.
|
||||
install -Dm 644 LICENSE.txt -t "${pkgdir}"/usr/share/licenses/amf-headers/
|
||||
}
|
||||
|
||||
# vim: ts=2 sw=2 et:
|
||||
sha512sums="2133612498444877f4aefeadd8d1aa0aa960999f0cb093b1a67bbc7d5c2633424fe6ca4ef4c967c1fa03033de3c926bcbad3915693339be4d08d21df4a4c2b77 amf-headers-1.4.18.tar.gz"
|
|
@ -4,11 +4,10 @@
|
|||
# Contributor: Max Liebkies <mail@maxliebkies.de>
|
||||
# Contributor: Krzysztof Bogacki <krzysztof.bogacki@leancode.pl>
|
||||
|
||||
_pkgbase=dotnet
|
||||
pkgname=dotnet-sdk
|
||||
pkgname=dotnet
|
||||
pkgdesc='The .NET Core SDK'
|
||||
pkgver=5.0.6
|
||||
pkgrel=0
|
||||
pkgrel=1
|
||||
arch='x86_64'
|
||||
url=https://www.microsoft.com/net/core
|
||||
license='MIT'
|
||||
|
@ -40,11 +39,11 @@ makedepends='
|
|||
# libssl1.1
|
||||
# libstdc++zlib
|
||||
#'
|
||||
subpackages="$_pkgbase-host:host $_pkgbase-runtime:runtime aspnet-runtime:aspnet_runtime:noarch netstandard-targeting-pack:netstandard_targeting_pack:noarch $_pkgbase-targeting-pack:targeting_pack aspnet-targeting-pack:aspnet_targeting_pack:noarch"
|
||||
subpackages="$pkgname-sdk:sdk $pkgname-host:host $pkgname-runtime:runtime aspnet-runtime:aspnet_runtime:noarch netstandard-targeting-pack:netstandard_targeting_pack:noarch $pkgname-targeting-pack:targeting_pack aspnet-targeting-pack:aspnet_targeting_pack:noarch"
|
||||
_gittag=a8f12771179965da9f48646ded87068d379563b9
|
||||
_giturl=https://github.com/dotnet/source-build
|
||||
source="
|
||||
$_pkgbase-$pkgver.tar.gz
|
||||
$pkgname-$pkgver.tar.gz
|
||||
dotnet.sh
|
||||
9999-runtime-link-order.patch
|
||||
9999-sdk-telemetry-optout.patch
|
||||
|
@ -54,7 +53,7 @@ source="
|
|||
9999-fixed-net40-location.patch
|
||||
https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.sh
|
||||
"
|
||||
builddir="$srcdir/$_pkgbase"
|
||||
builddir="$srcdir/$pkgname"
|
||||
|
||||
snapshot() {
|
||||
mkdir -p "$srcdir"
|
||||
|
@ -70,10 +69,10 @@ snapshot() {
|
|||
echo "Checking out"
|
||||
git checkout $_gittag
|
||||
echo "Repo archive"
|
||||
git archive --prefix="$_pkgbase/" -o $_pkgbase.tar --format "tar" $_gittag
|
||||
git archive --prefix="$pkgname/" -o $pkgname.tar --format "tar" $_gittag
|
||||
|
||||
gzip $pkgname.tar -c > "$SRCDEST"/$_pkgbase-$pkgver.tar.gz
|
||||
ln -s "$SRCDEST"/$_pkgbase-$pkgver.tar.gz "$startdir"/$_pkgbase-$pkgver.tar.gz
|
||||
gzip $pkgname.tar -c > "$SRCDEST"/$pkgname-$pkgver.tar.gz
|
||||
ln -s "$SRCDEST"/$pkgname-$pkgver.tar.gz "$startdir"/$pkgname-$pkgver.tar.gz
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,6 +136,19 @@ build() {
|
|||
}
|
||||
|
||||
package() {
|
||||
depends='
|
||||
$pkgname-sdk
|
||||
$pkgname-host
|
||||
$pkgname-runtime
|
||||
$pkgname-targetting-pack
|
||||
aspnet-runtime
|
||||
aspnet-targeting-pack
|
||||
netstandard-targeting-pack
|
||||
'
|
||||
mkdir -p "${pkgdir}"
|
||||
}
|
||||
|
||||
sdk() {
|
||||
depends='
|
||||
dotnet-runtime
|
||||
dotnet-targeting-pack
|
||||
|
@ -148,9 +160,9 @@ package() {
|
|||
|
||||
cd "$builddir"/artifacts/x64/Release
|
||||
|
||||
install -dm 755 "$pkgdir"/usr/share/dotnet "$pkgdir"/usr/share/licenses
|
||||
bsdtar -xf dotnet-sdk-*.tar.gz -C "${pkgdir}"/usr/share/dotnet/ --no-same-owner sdk templates
|
||||
ln -s dotnet-host "${pkgdir}"/usr/share/licenses/dotnet-sdk
|
||||
install -dm 755 "$subpkgdir"/usr/share/dotnet "$subpkgdir"/usr/share/licenses
|
||||
bsdtar -xf dotnet-sdk-*.tar.gz -C "${subpkgdir}"/usr/share/dotnet/ --no-same-owner sdk templates
|
||||
ln -s dotnet-host "${subpkgdir}"/usr/share/licenses/dotnet-sdk
|
||||
}
|
||||
|
||||
|
||||
|
@ -186,7 +198,7 @@ runtime() {
|
|||
libgcc
|
||||
musl
|
||||
icu
|
||||
krdb5-libs
|
||||
krb5-libs
|
||||
libunwind
|
||||
zlib
|
||||
openssl
|
58
apk/v3.13/main/ffnvcodec-headers/APKBUILD
Normal file
58
apk/v3.13/main/ffnvcodec-headers/APKBUILD
Normal file
|
@ -0,0 +1,58 @@
|
|||
# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
|
||||
# Contributor: Daniel Bermond <danielbermond@yahoo.com>
|
||||
|
||||
pkgname=ffnvcodec-headers
|
||||
pkgver=11.0.10.1
|
||||
pkgrel=0
|
||||
pkgdesc='FFmpeg version of headers required to interface with Nvidias codec APIs'
|
||||
arch='noarch'
|
||||
url=https://git.videolan.org/?p=ffmpeg/nv-codec-headers.git
|
||||
license='MIT'
|
||||
makedepends='git sed'
|
||||
_gittag=315ad740ac77282c7cea67ba31f2e4b373132919
|
||||
_giturl=https://git.videolan.org/git/ffmpeg/nv-codec-headers
|
||||
source="$pkgname-$pkgver.tar.gz"
|
||||
options='!check'
|
||||
|
||||
builddir="$srcdir/$pkgname"
|
||||
|
||||
snapshot() {
|
||||
mkdir -p "$srcdir"
|
||||
cd "${srcdir}"
|
||||
if ! [ -d $pkgname.git ]; then
|
||||
git clone $_giturl $pkgname.git || return 1
|
||||
cd $pkgname.git
|
||||
else
|
||||
cd $pkgname.git
|
||||
git fetch || return 1
|
||||
fi
|
||||
|
||||
echo "Checking out"
|
||||
git checkout $_gittag
|
||||
echo "Repo archive"
|
||||
git archive --prefix="$pkgname/" -o $pkgname.tar --format "tar" $_gittag
|
||||
|
||||
gzip $pkgname.tar -c > "$SRCDEST"/$pkgname-$pkgver.tar.gz
|
||||
ln -s "$SRCDEST"/$pkgname-$pkgver.tar.gz "$startdir"/$pkgname-$pkgver.tar.gz
|
||||
}
|
||||
|
||||
pkgver() {
|
||||
git describe --tags | sed 's/^n//'
|
||||
}
|
||||
|
||||
build() {
|
||||
cd "${builddir}"
|
||||
make PREFIX=/usr
|
||||
sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE # Extract license
|
||||
sed -i '1,22s/^.\{,3\}//' LICENSE # Delete C comments
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "${builddir}"
|
||||
mkdir -p "${pkgdir}"
|
||||
make PREFIX=/usr DESTDIR="${pkgdir}" install
|
||||
install -Dm 644 LICENSE -t "${pkgdir}"/usr/share/licenses/ffnvcodec-headers/
|
||||
}
|
||||
|
||||
# vim: ts=2 sw=2 et:
|
||||
sha512sums="2f70f981e227bb5eb25e365270bc79cba855975e365d116f434e823c5e00e73eb2d802ccb1f1c143dab9c434546439ca4dba8dd968f538d382ee69b27e3bc932 ffnvcodec-headers-11.0.10.1.tar.gz"
|
|
@ -0,0 +1,40 @@
|
|||
From 785d96be2c3be8c96c8dc3f8275bae435cf1cd3b Mon Sep 17 00:00:00 2001
|
||||
From: "build@apk-groulx" <build@apk-groulx.praxis>
|
||||
Date: Sun, 6 Jun 2021 20:36:23 +0000
|
||||
Subject: [PATCH] Fixed build for musl
|
||||
|
||||
---
|
||||
tools/tracer/tracer/tracer_linux.cpp | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/tools/tracer/tracer/tracer_linux.cpp b/tools/tracer/tracer/tracer_linux.cpp
|
||||
index bea1c070..14d7f07b 100644
|
||||
--- a/tools/tracer/tracer/tracer_linux.cpp
|
||||
+++ b/tools/tracer/tracer/tracer_linux.cpp
|
||||
@@ -78,9 +78,9 @@ mfxStatus MFXInit(mfxIMPL impl, mfxVersion *ver, mfxSession *session)
|
||||
Log::WriteLog(context.dump_mfxStatus("status", MFX_ERR_MEMORY_ALLOC));
|
||||
return MFX_ERR_MEMORY_ALLOC;
|
||||
}
|
||||
- loader->dlhandle = dlopen(g_mfxlib, RTLD_NOW|RTLD_LOCAL|RTLD_DEEPBIND);
|
||||
+ loader->dlhandle = dlopen(g_mfxlib, RTLD_NOW|RTLD_LOCAL);
|
||||
if(!loader->dlhandle)
|
||||
- loader->dlhandle = dlopen(g_mfxlib_in_dir, RTLD_NOW|RTLD_LOCAL|RTLD_DEEPBIND);
|
||||
+ loader->dlhandle = dlopen(g_mfxlib_in_dir, RTLD_NOW|RTLD_LOCAL);
|
||||
if (!loader->dlhandle){
|
||||
Log::WriteLog(context.dump("ver", ver));
|
||||
Log::WriteLog(context.dump("session", *session));
|
||||
@@ -184,9 +184,9 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
|
||||
Log::WriteLog(context.dump_mfxStatus("status", MFX_ERR_MEMORY_ALLOC));
|
||||
return MFX_ERR_MEMORY_ALLOC;
|
||||
}
|
||||
- loader->dlhandle = dlopen(g_mfxlib, RTLD_NOW|RTLD_LOCAL|RTLD_DEEPBIND);
|
||||
+ loader->dlhandle = dlopen(g_mfxlib, RTLD_NOW|RTLD_LOCAL);
|
||||
if(!loader->dlhandle)
|
||||
- loader->dlhandle = dlopen(g_mfxlib_in_dir, RTLD_NOW|RTLD_LOCAL|RTLD_DEEPBIND);
|
||||
+ loader->dlhandle = dlopen(g_mfxlib_in_dir, RTLD_NOW|RTLD_LOCAL);
|
||||
if (!loader->dlhandle){
|
||||
Log::WriteLog(context.dump("par", par));
|
||||
Log::WriteLog(context.dump("session", *session));
|
||||
--
|
||||
2.30.2
|
||||
|
76
apk/v3.13/main/intel-media-sdk/APKBUILD
Normal file
76
apk/v3.13/main/intel-media-sdk/APKBUILD
Normal file
|
@ -0,0 +1,76 @@
|
|||
# Maintainer: Daniel Bermond <dbermond@archlinux.org>
|
||||
|
||||
pkgname=intel-media-sdk
|
||||
pkgver=21.1.3
|
||||
pkgrel=0
|
||||
pkgdesc='API to access hardware-accelerated video on Intel Gen graphics hardware platforms'
|
||||
arch='x86_64'
|
||||
url='https://software.intel.com/en-us/media-sdk/'
|
||||
license='MIT'
|
||||
makedepends='
|
||||
libdrm-dev
|
||||
libva-dev
|
||||
wayland-dev
|
||||
intel-media-driver-dev
|
||||
cmake
|
||||
libpciaccess-dev
|
||||
libx11-dev
|
||||
libxcb-dev
|
||||
python3'
|
||||
|
||||
source="https://github.com/Intel-Media-SDK/MediaSDK/archive/intel-mediasdk-${pkgver}.tar.gz
|
||||
https://github.com/Intel-Media-SDK/MediaSDK/commit/f6925886f27a39eed2e43c5b7b6c342d00f7a970.patch
|
||||
0001-Fixed-build-for-musl.patch"
|
||||
|
||||
subpackages="libmfx:libmfx"
|
||||
builddir="${srcdir}/MediaSDK-intel-mediasdk-${pkgver}"
|
||||
|
||||
build() {
|
||||
cd "${builddir}"
|
||||
cmake -B build \
|
||||
-DBUILD_ALL:BOOL='ON' \
|
||||
-DBUILD_TOOLS:BOOL='ON' \
|
||||
-DCMAKE_BUILD_TYPE:STRING='None' \
|
||||
-DCMAKE_INSTALL_PREFIX:PATH='/usr' \
|
||||
-DCMAKE_INSTALL_LIBDIR:PATH='lib' \
|
||||
-DENABLE_ITT:BOOL='OFF' \
|
||||
-DENABLE_OPENCL:BOOL='OFF' \
|
||||
-DENABLE_WAYLAND:BOOL='ON' \
|
||||
-DENABLE_X11_DRI3:BOOL='ON' \
|
||||
-Wno-dev
|
||||
make -C build
|
||||
}
|
||||
|
||||
check() {
|
||||
cd "${builddir}"
|
||||
make -C build test
|
||||
}
|
||||
|
||||
package() {
|
||||
depends="libdrm libva wayland libmfx=${pkgver} intel-media-driver"
|
||||
cd "${builddir}"
|
||||
|
||||
make -C build DESTDIR="$pkgdir" install
|
||||
ln -s ../share/mfx/samples/libcttmetrics.so "${pkgdir}/usr/lib/libcttmetrics.so"
|
||||
install -D -m644 "${builddir}/LICENSE" -t "${pkgdir}/usr/share/licenses/${pkgname}"
|
||||
|
||||
mkdir -p "${srcdir}"/libmfx/include "${srcdir}"/libmfx/lib/pkgconfig
|
||||
mv "${pkgdir}/usr/include/mfx" "${srcdir}"/libmfx/include
|
||||
mv "${pkgdir}/usr/lib/libmfx.so"* "${srcdir}"/libmfx/lib
|
||||
mv "${pkgdir}"/usr/lib/pkgconfig/mfx.pc "${srcdir}"/libmfx/lib/pkgconfig
|
||||
mv "${pkgdir}"/usr/lib/pkgconfig/libmfx.pc "${srcdir}"/libmfx/lib/pkgconfig
|
||||
rm -r "${pkgdir}/usr/include"
|
||||
}
|
||||
|
||||
libmfx() {
|
||||
pkgdesc='Intel Media SDK dispatcher library'
|
||||
depends='gcc'
|
||||
cd "${builddir}"
|
||||
|
||||
mkdir -p "${subpkgdir}"
|
||||
mv "${srcdir}"/libmfx "${subpkgdir}"/usr
|
||||
install -D -m644 "${builddir}"/LICENSE -t "${subpkgdir}/usr/share/licenses/${pkgname}"
|
||||
}
|
||||
sha512sums="d840db69da285302c1afdcf305c32ec88029c5951af6d2570404b118a9cc8e02345082f5116da496b1b0fdedfa435bac1c7968fbf8e7c9d12e2e5ef687784eda intel-mediasdk-21.1.3.tar.gz
|
||||
c1d56964982b2fc6b5fbc128080d9b5607dbac4470111b62bcc8b52789a40a23dd8c59ed7757e6e8e238db9b828c9afd68060b539ad7800bde42f6e2fc22d854 f6925886f27a39eed2e43c5b7b6c342d00f7a970.patch
|
||||
6049eebb5f1cc2068e50cb3ed672d29f54a53924f435b88e402905f3664bf25d52556547ff68163c67892bc56e60c793bd18092b21a19f1fb0f27b80f18d4dfd 0001-Fixed-build-for-musl.patch"
|
|
@ -1,24 +0,0 @@
|
|||
# Copyright (c) 2017-2020 Intel Corporation
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
add_subdirectory(asg-hevc)
|
||||
add_subdirectory(bs_parser_hevc)
|
||||
add_subdirectory(bs_parser_hevc/tools/hevc_fei_extractor)
|
||||
add_subdirectory(tracer)
|
|
@ -1,16 +0,0 @@
|
|||
find_path( FEI_INCLUDE mfxfeihevc.h PATHS ${MFX_INCLUDE} )
|
||||
|
||||
include_directories (
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../samples/sample_common/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
)
|
||||
|
||||
list( APPEND LIBS sample_common )
|
||||
|
||||
set( defs " -DMFX_VERSION_USE_LATEST " )
|
||||
set(DEPENDENCIES libmfx)
|
||||
|
||||
make_executable( shortname universal )
|
||||
|
||||
install( TARGETS ${target} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
|
||||
set( defs "" )
|
|
@ -1,205 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{270C4BB6-C45C-4541-8F9C-47D30C4744F1}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(ProjectDir)..\..\..\build\win_$(Platform)\$(Configuration)\bin\</OutDir>
|
||||
<IntDir>$(OutDir)..\objs\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(ProjectDir)..\..\..\build\win_$(Platform)\$(Configuration)\bin\</OutDir>
|
||||
<IntDir>$(OutDir)..\objs\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(ProjectDir)..\..\..\build\win_$(Platform)\$(Configuration)\bin\</OutDir>
|
||||
<IntDir>$(OutDir)..\objs\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>$(ProjectDir)..\..\..\build\win_$(Platform)\$(Configuration)\bin\</OutDir>
|
||||
<IntDir>$(OutDir)..\objs\$(ProjectName)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>MFX_VERSION_USE_LATEST;_WIN32;WIN32;_DEBUG;NOMINMAX;MFX_DEPRECATED_OFF; _UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\include;$(ProjectDir)\..\..\api\include;$(ProjectDir)\..\..\samples\sample_common\include\vm;$(ProjectDir)\..\..\samples\sample_common\src;$(ProjectDir)\..\..\samples\sample_common\include;$(INTELMEDIASDKROOT)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>DebugFastLink</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)..\..\..\build\win_$(Platform)\$(Configuration)\lib\;$(INTELMEDIASDKROOT)\lib\$(Platform);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>MFX_VERSION_USE_LATEST;_WIN32;WIN32;NDEBUG;NOMINMAX;MFX_DEPRECATED_OFF; _UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\include;$(ProjectDir)\..\..\api\include;$(ProjectDir)\..\..\samples\sample_common\include\vm;$(ProjectDir)\..\..\samples\sample_common\src;$(ProjectDir)\..\..\samples\sample_common\include;$(INTELMEDIASDKROOT)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)..\..\..\build\win_$(Platform)\$(Configuration)\lib\;$(INTELMEDIASDKROOT)\lib\$(Platform);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib; sample_common.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\include;$(ProjectDir)\..\..\api\include;$(ProjectDir)\..\..\samples\sample_common\include\vm;$(ProjectDir)\..\..\samples\sample_common\src;$(ProjectDir)\..\..\samples\sample_common\include;$(INTELMEDIASDKROOT)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<PreprocessorDefinitions>MFX_VERSION_USE_LATEST;_WIN64;WIN64;_DEBUG;NOMINMAX;MFX_DEPRECATED_OFF; _UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)..\..\..\build\win_$(Platform)\$(Configuration)\lib\;$(INTELMEDIASDKROOT)\lib\$(Platform);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib; sample_common.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<SubSystem>Console</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\include;$(ProjectDir)\..\..\api\include;$(ProjectDir)\..\..\samples\sample_common\include\vm;$(ProjectDir)\..\..\samples\sample_common\src;$(ProjectDir)\..\..\samples\sample_common\include;$(INTELMEDIASDKROOT)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<PreprocessorDefinitions>MFX_VERSION_USE_LATEST;_WIN64;WIN64;NDEBUG;NOMINMAX;MFX_DEPRECATED_OFF; _UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)..\..\..\build\win_$(Platform)\$(Configuration)\lib\;$(INTELMEDIASDKROOT)\lib\$(Platform);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib; sample_common.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\asg-hevc.cpp" />
|
||||
<ClCompile Include="src\block_structures.cpp" />
|
||||
<ClCompile Include="src\frame_marker.cpp" />
|
||||
<ClCompile Include="src\frame_processor.cpp" />
|
||||
<ClCompile Include="src\frame_reorder.cpp" />
|
||||
<ClCompile Include="src\generator.cpp" />
|
||||
<ClCompile Include="src\inputparameters.cpp" />
|
||||
<ClCompile Include="src\mvmvp_processor.cpp" />
|
||||
<ClCompile Include="src\random_generator.cpp" />
|
||||
<ClCompile Include="src\refcontrol.cpp" />
|
||||
<ClCompile Include="src\test_processor.cpp" />
|
||||
<ClCompile Include="src\util_defs.cpp" />
|
||||
<ClCompile Include="src\verifier.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\asglog.h" />
|
||||
<ClInclude Include="include\block_structures.h" />
|
||||
<ClInclude Include="include\frame_change_descriptor.h" />
|
||||
<ClInclude Include="include\frame_marker.h" />
|
||||
<ClInclude Include="include\frame_processor.h" />
|
||||
<ClInclude Include="include\frame_reorder.h" />
|
||||
<ClInclude Include="include\generator.h" />
|
||||
<ClInclude Include="include\hevc_defs.h" />
|
||||
<ClInclude Include="include\inputparameters.h" />
|
||||
<ClInclude Include="include\inter_test.h" />
|
||||
<ClInclude Include="include\intra_test.h" />
|
||||
<ClInclude Include="include\mvmvp_processor.h" />
|
||||
<ClInclude Include="include\random_generator.h" />
|
||||
<ClInclude Include="include\refcontrol.h" />
|
||||
<ClInclude Include="include\test_processor.h" />
|
||||
<ClInclude Include="include\util_defs.h" />
|
||||
<ClInclude Include="include\verifier.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\samples\sample_common\sample_common.vcxproj">
|
||||
<Project>{5fadb243-53c3-4776-a20f-8bd65c10cf41}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -1,111 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\asg-hevc.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\block_structures.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\frame_marker.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\frame_processor.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\frame_reorder.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\generator.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\inputparameters.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mvmvp_processor.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\random_generator.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\refcontrol.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\test_processor.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\util_defs.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\verifier.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\asglog.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\block_structures.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\frame_change_descriptor.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\frame_marker.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\frame_processor.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\frame_reorder.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\generator.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\hevc_defs.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\inputparameters.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\inter_test.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\intra_test.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mvmvp_processor.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\random_generator.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\refcontrol.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\test_processor.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\util_defs.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\verifier.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,135 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef __ASGLOG_H__
|
||||
#define __ASGLOG_H__
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <tuple>
|
||||
#include <iomanip>
|
||||
|
||||
#include "mfxdefs.h"
|
||||
#include "block_structures.h"
|
||||
|
||||
//Logger object, basically a tee into cout and log file
|
||||
class ASGLog
|
||||
{
|
||||
public:
|
||||
//Tuple field designations
|
||||
enum { MVX = 0, MVY = 1, REFIDX = 2 };
|
||||
|
||||
void Init(const InputParams& params)
|
||||
{
|
||||
m_bVerbose = params.m_bVerbose;
|
||||
if (params.m_bUseLog)
|
||||
{
|
||||
m_LogFileOutput.open(params.m_LogFileName.c_str(), std::ofstream::out);
|
||||
if (!m_LogFileOutput.is_open())
|
||||
{
|
||||
throw std::string("ERROR: ASGLog: unable to open log file");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Convenient ofstream-style operator<< with chaining feature
|
||||
template<class T>
|
||||
ASGLog& operator<<(const T& output)
|
||||
{
|
||||
if (m_bVerbose)
|
||||
{
|
||||
std::cout << output;
|
||||
}
|
||||
if (m_LogFileOutput.is_open())
|
||||
{
|
||||
m_LogFileOutput << output;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
//Specialization for basic block info output
|
||||
ASGLog& operator<< (const CTUDescriptor& outCTU)
|
||||
{
|
||||
return (*this << "CTU " << static_cast<BaseBlock>(outCTU));
|
||||
}
|
||||
|
||||
ASGLog& operator<< (const CUBlock& outCU)
|
||||
{
|
||||
return (*this << "CU " << static_cast<BaseBlock>(outCU));
|
||||
}
|
||||
|
||||
ASGLog& operator<< (const PUBlock& outPU)
|
||||
{
|
||||
return (*this << "PU " << static_cast<BaseBlock>(outPU));
|
||||
}
|
||||
|
||||
//Specialization for basic block info output
|
||||
ASGLog& operator<< (const BaseBlock& outBB)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << outBB.m_BHeight << "x" << outBB.m_BWidth <<
|
||||
" (" << outBB.m_AdrX << ";" << outBB.m_AdrY << ")";
|
||||
return (*this << ss.str());
|
||||
}
|
||||
|
||||
//Specialization for MV log output
|
||||
ASGLog& operator<< (const std::tuple<mfxI32, mfxI32, mfxU32>& MV)
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
ss << "(" << std::get<MVX>(MV) << ";" << std::get<MVY>(MV) << ";" << std::get<REFIDX>(MV) << ")";
|
||||
|
||||
return (*this << ss.str());
|
||||
}
|
||||
|
||||
//Specialization for I/O stream manipulators (i.e. std::endl)
|
||||
ASGLog& operator<< (std::ostream&(*pMan)(std::ostream&))
|
||||
{
|
||||
if (m_bVerbose)
|
||||
{
|
||||
std::cout << *pMan;
|
||||
}
|
||||
if (m_LogFileOutput.is_open())
|
||||
{
|
||||
m_LogFileOutput << *pMan;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
~ASGLog()
|
||||
{
|
||||
if (m_LogFileOutput.is_open())
|
||||
{
|
||||
m_LogFileOutput.close();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_bVerbose = false;
|
||||
std::ofstream m_LogFileOutput;
|
||||
};
|
||||
|
||||
#endif // MFX_VERSION > 1024
|
||||
|
||||
#endif //__ASGLOG_H__
|
|
@ -1,349 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef __BLOCK_STRUCTURES_H__
|
||||
#define __BLOCK_STRUCTURES_H__
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include "inter_test.h"
|
||||
#include "intra_test.h"
|
||||
#include "util_defs.h"
|
||||
|
||||
enum COLOR_COMPONENT {
|
||||
LUMA_Y = 0,
|
||||
CHROMA_U = 1,
|
||||
CHROMA_V = 2
|
||||
};
|
||||
|
||||
enum PRED_TYPE {
|
||||
INTRA_PRED = 0,
|
||||
INTER_PRED = 1,
|
||||
};
|
||||
|
||||
struct RefSampleAvail
|
||||
{
|
||||
//parameter answers the question whether samples in the extention of left border to the bottom are final ones
|
||||
//and won't be overwritten by any following blocks
|
||||
bool LeftDown;
|
||||
//parameter answers the question whether samples in the extention of above border to the right are final ones
|
||||
//and won't be overwritten by any following blocks
|
||||
bool UpRight;
|
||||
RefSampleAvail(bool leftdown = true, bool upright = true) : LeftDown(leftdown), UpRight(upright) {}
|
||||
};
|
||||
|
||||
//base block structure with size and coordinates
|
||||
struct BaseBlock {
|
||||
mfxU32 m_AdrX;
|
||||
mfxU32 m_AdrY;
|
||||
mfxU32 m_BWidth;
|
||||
mfxU32 m_BHeight;
|
||||
|
||||
BaseBlock(mfxU32 adrX = 0, mfxU32 adrY = 0, mfxU32 bWidth = 0, mfxU32 bHeight = 0)
|
||||
: m_AdrX(adrX),
|
||||
m_AdrY(adrY),
|
||||
m_BWidth(bWidth),
|
||||
m_BHeight(bHeight)
|
||||
{}
|
||||
|
||||
// Returns true if two rectangles intersect or closer to each other than specified by x_sp and y_sp
|
||||
bool CheckForIntersect(const BaseBlock& other_block, mfxU32 x_sp = 0, mfxU32 y_sp = 0) const
|
||||
{
|
||||
return !((m_AdrX >= other_block.m_AdrX + other_block.m_BWidth + x_sp ||
|
||||
other_block.m_AdrX >= m_AdrX + m_BWidth + x_sp) // If one rectangle is on side of other
|
||||
|
||||
|| (m_AdrY >= other_block.m_AdrY + other_block.m_BHeight + y_sp ||
|
||||
other_block.m_AdrY >= m_AdrY + m_BHeight + y_sp)); // If one rectangle is above other
|
||||
}
|
||||
|
||||
//Returns true if the block is inside frame boundaries
|
||||
bool IsInRange(const mfxFrameInfo& info) const
|
||||
{
|
||||
return ((info.Width > 0 && info.Height > 0) &&
|
||||
(m_AdrX + m_BWidth <= (mfxU32)info.Width) &&
|
||||
(m_AdrY + m_BHeight <= (mfxU32)info.Height));
|
||||
}
|
||||
|
||||
//Returns true if the block is inside another block
|
||||
bool IsInBlock(const BaseBlock& otherBlock) const
|
||||
{
|
||||
return (m_AdrX >= otherBlock.m_AdrX && m_AdrX + m_BWidth <= otherBlock.m_AdrX + otherBlock.m_BWidth
|
||||
&& m_AdrY >= otherBlock.m_AdrY && m_AdrY + m_BHeight <= otherBlock.m_AdrY + otherBlock.m_BHeight);
|
||||
}
|
||||
|
||||
void GetChildBlock(std::vector<BaseBlock>& childrenBlocks) const;
|
||||
void GetChildRefSampleInfo(const RefSampleAvail & currAvail, const BaseBlock & ctu, std::vector<RefSampleAvail>& childrenRefSampleAvail) const;
|
||||
|
||||
bool operator==(const BaseBlock& rhs) const
|
||||
{
|
||||
return (m_AdrX == rhs.m_AdrX && m_AdrY == rhs.m_AdrY &&
|
||||
m_BWidth == rhs.m_BWidth && m_BHeight == rhs.m_BHeight);
|
||||
}
|
||||
};
|
||||
|
||||
//Struct representing a single node in a quad-tree
|
||||
struct QuadTreeNode
|
||||
{
|
||||
std::shared_ptr<QuadTreeNode*> m_pParent;
|
||||
std::vector<QuadTreeNode> m_Children;
|
||||
mfxU8 m_Level;
|
||||
QuadTreeNode() : m_pParent(nullptr), m_Level(0) {}
|
||||
QuadTreeNode(std::shared_ptr<QuadTreeNode*> pParent, mfxU8 level) :
|
||||
m_pParent(pParent),
|
||||
m_Level(level)
|
||||
{}
|
||||
void MakeChildren()
|
||||
{
|
||||
for (mfxU32 i = 0; i < 4; i++)
|
||||
{
|
||||
QuadTreeNode node(std::make_shared<QuadTreeNode*>(this), m_Level + 1);
|
||||
m_Children.push_back(node);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//Structure representing a quad-tree as a whole
|
||||
struct QuadTree
|
||||
{
|
||||
QuadTreeNode root;
|
||||
void Clear()
|
||||
{
|
||||
root.m_Children.clear();
|
||||
}
|
||||
bool IsEmpty()
|
||||
{
|
||||
return root.m_Children.empty();
|
||||
}
|
||||
|
||||
//This recursive function fills outVec with BaseBlocks, coordinates and sizes of which correspond to
|
||||
//the quad-tree structure specified by the quad-tree root node and the base size and coordinates of
|
||||
//the "root node "
|
||||
void GetQuadTreeBlocksRecur(QuadTreeNode & node, mfxU32 baseAdrX, mfxU32 baseAdrY, mfxU32 baseSize, std::vector<BaseBlock>& outVec);
|
||||
//this function is a modification of the one above
|
||||
//it keeps track of refSamples availability for every block
|
||||
//thus it outputs outVec of IntraBlock structures and is used when intra prediction is enabled
|
||||
|
||||
//now algorithm works fine assuming that CTUs cannot lie next to each other
|
||||
//but it limits some cases for intra/inter mix
|
||||
|
||||
void GetQuadTreeRefSampleAvailVector(QuadTreeNode & node, BaseBlock & currBlock, const BaseBlock & ctu, std::vector<RefSampleAvail>& outVec);
|
||||
|
||||
//TODO: develop this function taking into account that INTER coded noise blocks are written prior to INTRA prediction
|
||||
//and include available refSamples for it
|
||||
void GetQuadTreeRefSampleAvailVectorRecur(QuadTreeNode & node, BaseBlock& currBlock, const RefSampleAvail& currAvail, const BaseBlock& CTU, std::vector<RefSampleAvail>& outVec);
|
||||
};
|
||||
|
||||
//block handling patch data which was generated via intra prediction
|
||||
struct PatchBlock : BaseBlock
|
||||
{
|
||||
std::unique_ptr<mfxU8[]> PatchData;
|
||||
mfxU8 *m_YPlane = nullptr;
|
||||
mfxU8 *m_UPlane = nullptr;
|
||||
mfxU8 *m_VPlane = nullptr;
|
||||
|
||||
//Copy constructor
|
||||
PatchBlock(const PatchBlock& rhs);
|
||||
|
||||
//Assignment operator
|
||||
PatchBlock& operator=(const PatchBlock& rhs);
|
||||
|
||||
PatchBlock(const BaseBlock& BB);
|
||||
|
||||
//constructor that memsets PatchBlock with the particurlar sample
|
||||
PatchBlock(const BaseBlock& BB, mfxU8 y_comp, mfxU8 u_comp, mfxU8 v_comp);
|
||||
|
||||
//constructor that fills PatchBlock with coresponding data from the otherPatch
|
||||
PatchBlock(const BaseBlock& dstBlock, const PatchBlock& srcBlock);
|
||||
|
||||
//constructor that filles PatchBlock with coresponding data from the surface
|
||||
PatchBlock(const BaseBlock& BB, const ExtendedSurface& surf);
|
||||
|
||||
//distance between current PatchBlock and other_patch counted as a sum of abs differences between luma components over all samples
|
||||
mfxU32 CalcYSAD(const PatchBlock& otherPatch) const;
|
||||
|
||||
//AdrX and AdrY are given in the luma plane space (i.e. raw frame coords)
|
||||
mfxU8 GetSampleI420(COLOR_COMPONENT comp, mfxU32 AdrX, mfxU32 AdrY) const;
|
||||
|
||||
//Inserts refPatch into this PatchBlock, if refPatch is located inside this PatchBlock
|
||||
void InsertAnotherPatch(const PatchBlock & refPatch);
|
||||
};
|
||||
|
||||
//Structure representing a prediction unit
|
||||
struct PUBlock : BaseBlock
|
||||
{
|
||||
PUBlock(mfxU32 adrX = 0, mfxU32 adrY = 0, mfxU32 bWidth = 0, mfxU32 bHeight = 0) :
|
||||
BaseBlock(adrX, adrY, bWidth, bHeight),
|
||||
m_MV(),
|
||||
m_MVP(),
|
||||
predFlagL0(false),
|
||||
predFlagL1(false)
|
||||
{}
|
||||
|
||||
// Attention: MV and MVP are given in quarter-sample units. Consider scaling when working with PUMotionVector.
|
||||
PUMotionVector m_MV; //Contains complete motion vector (i.e. predictor + additional vector inside SW)
|
||||
PUMotionVector m_MVP; //Contains motion vector predictor only
|
||||
|
||||
// Index of this PU's MVP inside the generation pool
|
||||
// 4 predictors are in pool, valid values are in range [0, 3]
|
||||
// -1 indicates no MVP was applied to this PU's MV
|
||||
mfxI16 usedMVPIndex = -1;
|
||||
|
||||
// Index of the generation pool used to choose MVP from for this PU
|
||||
// -1 indicates no MVP was applied to this PU's MV
|
||||
mfxI16 usedMVPPoolNo = -1;
|
||||
|
||||
// Prediction flags
|
||||
bool predFlagL0;
|
||||
bool predFlagL1;
|
||||
|
||||
//Returns a BaseBlock with coordinates that are shifted by the m_MV L0 motion vector
|
||||
//relative to the current PU position
|
||||
BaseBlock GetShiftedBaseBlock(REF_LIST_INDEX list) const;
|
||||
|
||||
//Returns true if both the block itself and blocks shifted by
|
||||
//L0 and L1 motion vectors are inside frame boundaries
|
||||
bool IsPUInRange(const mfxFrameInfo& info) const
|
||||
{
|
||||
mfxI64 posXL0 = (mfxI64)m_AdrX + (m_MV.MV[0].x >> 2);
|
||||
mfxI64 posYL0 = (mfxI64)m_AdrY + (m_MV.MV[0].y >> 2);
|
||||
|
||||
mfxI64 posXL1 = (mfxI64)m_AdrX + (m_MV.MV[1].x >> 2);
|
||||
mfxI64 posYL1 = (mfxI64)m_AdrY + (m_MV.MV[1].y >> 2);
|
||||
|
||||
//TODO: This may lead to slow performance for tightly packed test CTUs
|
||||
return (IsInRange(info) &&
|
||||
posXL0 >= 0 && (posXL0 + m_BWidth <= info.Width) &&
|
||||
posYL0 >= 0 && (posYL0 + m_BHeight <= info.Height)&&
|
||||
posXL1 >= 0 && (posXL1 + m_BWidth <= info.Width) &&
|
||||
posYL1 >= 0 && (posYL1 + m_BHeight <= info.Height));
|
||||
}
|
||||
|
||||
//For VERIFY purposes. Will only work correctly if ASG PU with correct predFlags is on the left-hand side
|
||||
bool operator==(const PUBlock& rhs) const
|
||||
{
|
||||
return (static_cast<BaseBlock>(*this) == static_cast<BaseBlock>(rhs) &&
|
||||
(predFlagL0 == rhs.predFlagL0) && (predFlagL1 == rhs.predFlagL1) &&
|
||||
(!predFlagL0 || m_MV.GetL0MVTuple() == rhs.m_MV.GetL0MVTuple()) &&
|
||||
(!predFlagL1 || m_MV.GetL1MVTuple() == rhs.m_MV.GetL1MVTuple()));
|
||||
}
|
||||
};
|
||||
|
||||
//Structure representing a transform unit
|
||||
struct TUBlock : BaseBlock
|
||||
{
|
||||
//different intra modes can be set for luma and chroma
|
||||
INTRA_MODE m_IntraModeLuma = INTRA_MODE::DC;
|
||||
INTRA_MODE m_IntraModeChroma = INTRA_MODE::DC;
|
||||
RefSampleAvail m_RefSampleAvail;
|
||||
|
||||
TUBlock(const BaseBlock& base) : BaseBlock(base) {}
|
||||
TUBlock(const BaseBlock& base, INTRA_MODE intraModeLuma, INTRA_MODE intraModeChroma) :
|
||||
BaseBlock(base),
|
||||
m_IntraModeLuma(intraModeLuma),
|
||||
m_IntraModeChroma(intraModeChroma)
|
||||
{}
|
||||
};
|
||||
|
||||
//Structure representing a coding unit
|
||||
struct CUBlock : BaseBlock
|
||||
{
|
||||
// Quadtree representing TU structure
|
||||
QuadTree m_TUQuadTree;
|
||||
PRED_TYPE m_PredType = INTRA_PRED; //intra or inter
|
||||
INTRA_PART_MODE m_IntraPartMode = INTRA_NONE; //partitioning into different intra modes
|
||||
INTER_PART_MODE m_InterPartMode = INTER_NONE; //partitioning into PUs
|
||||
std::vector<PUBlock> m_PUVec; //PU and TU partitioning can be
|
||||
std::vector<TUBlock> m_TUVec; //performed independently
|
||||
|
||||
CUBlock(const BaseBlock& base) : BaseBlock(base) {}
|
||||
|
||||
void BuildPUsVector(INTER_PART_MODE mode);
|
||||
|
||||
//For VERIFY purposes
|
||||
bool operator==(const CUBlock& rhs) const
|
||||
{
|
||||
return (static_cast<BaseBlock>(*this) == static_cast<BaseBlock>(rhs) &&
|
||||
m_PUVec == rhs.m_PUVec);
|
||||
}
|
||||
};
|
||||
|
||||
// Descriptor of CTU
|
||||
struct CTUDescriptor : BaseBlock
|
||||
{
|
||||
// Coordinates in CTUs
|
||||
mfxU32 m_AdrXInCTU = 0;
|
||||
mfxU32 m_AdrYInCTU = 0;
|
||||
|
||||
// Quadtree representing CU structure
|
||||
QuadTree m_CUQuadTree;
|
||||
|
||||
// Contains CU blocks according to the m_CUQuadTree structure
|
||||
// Gets filled in GetCUVecInCTU
|
||||
std::vector<CUBlock> m_CUVec;
|
||||
|
||||
// Contains MVP pools used in MV generator for PUs inside this CTU
|
||||
// Gets filled in DumpMVPPools
|
||||
std::vector<std::vector<PUMotionVector>> m_MVPGenPools;
|
||||
|
||||
CTUDescriptor(mfxU32 addr_x = 0, mfxU32 addr_y = 0, mfxU32 b_addr_x = 0, mfxU32 b_addr_y = 0, mfxU32 b_width = 0, mfxU32 b_height = 0)
|
||||
: BaseBlock(b_addr_x, b_addr_y, b_width, b_height)
|
||||
, m_AdrXInCTU(addr_x)
|
||||
, m_AdrYInCTU(addr_y)
|
||||
{};
|
||||
|
||||
bool operator==(const CTUDescriptor& rhs) const
|
||||
{
|
||||
return (m_AdrXInCTU == rhs.m_AdrXInCTU &&
|
||||
m_AdrYInCTU == rhs.m_AdrYInCTU &&
|
||||
m_CUVec == rhs.m_CUVec);
|
||||
}
|
||||
|
||||
std::vector<PUBlock> GetTotalPUsVec() const
|
||||
{
|
||||
std::vector<PUBlock> retVec;
|
||||
for (auto& CU : m_CUVec)
|
||||
{
|
||||
retVec.insert(retVec.end(), CU.m_PUVec.begin(), CU.m_PUVec.end());
|
||||
}
|
||||
return retVec;
|
||||
}
|
||||
};
|
||||
|
||||
using FrameOccRefBlockRecord = std::map<mfxU32, std::vector<BaseBlock>>;
|
||||
|
||||
struct InterpolWorkBlock : BaseBlock
|
||||
{
|
||||
InterpolWorkBlock() {};
|
||||
InterpolWorkBlock(const BaseBlock& block) :
|
||||
BaseBlock(block),
|
||||
m_YArr(block.m_BHeight * block.m_BWidth, LUMA_DEFAULT),
|
||||
m_UArr(block.m_BHeight / 2 * block.m_BWidth / 2, CHROMA_DEFAULT),
|
||||
m_VArr(block.m_BHeight / 2 * block.m_BWidth / 2, CHROMA_DEFAULT)
|
||||
{}
|
||||
std::vector<mfxI32> m_YArr;
|
||||
std::vector<mfxI32> m_UArr;
|
||||
std::vector<mfxI32> m_VArr;
|
||||
};
|
||||
|
||||
#endif // MFX_VERSION
|
||||
|
||||
#endif //__BLOCK_STRUCTURES_H__
|
|
@ -1,138 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef __ASG_HEVC_FRAME_CHANGE_DESCRIPTOR_H__
|
||||
#define __ASG_HEVC_FRAME_CHANGE_DESCRIPTOR_H__
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include "block_structures.h"
|
||||
#include "inputparameters.h"
|
||||
|
||||
// Descriptor containing all information about frame
|
||||
struct FrameChangeDescriptor
|
||||
{
|
||||
FRAME_MARKER m_changeType = SKIP; // type of frame
|
||||
mfxU16 m_testType = UNDEFINED_TYPE; // test type (i.e. use or not split or use)
|
||||
PROCESSING_MODE m_procMode = UNDEFINED_MODE; // processing mode
|
||||
mfxU32 m_frameNumber = 0; // frame number in display order
|
||||
ExtendedSurface* m_frame = nullptr; // ExtendedSurface for current frame
|
||||
mfxU16 m_frameType = MFX_FRAMETYPE_UNKNOWN; // Frame type, used for bi-prediction decision
|
||||
bool m_bUseBiDirSW = true; // Whether or not bi-directional search window should be used
|
||||
// instead of one-directional
|
||||
|
||||
std::vector<CTUDescriptor> m_vCTUdescr; // vector of generated blocks inside current frame
|
||||
|
||||
std::list<FrameChangeDescriptor> m_refDescrList0; // L0 list
|
||||
std::list<FrameChangeDescriptor> m_refDescrList1; // L1 list
|
||||
|
||||
std::vector<BaseBlock> m_OccupiedRefBlocks; // vector of blocks on the current frame
|
||||
// already taken by PUs from other frames
|
||||
|
||||
mfxU32 GetFrameCropW() const
|
||||
{
|
||||
return m_frame ? m_frame->Info.CropW : 0;
|
||||
}
|
||||
mfxU32 GetFrameCropH() const
|
||||
{
|
||||
return m_frame ? m_frame->Info.CropH : 0;
|
||||
}
|
||||
|
||||
FrameOccRefBlockRecord BackupOccupiedRefBlocks()
|
||||
{
|
||||
FrameOccRefBlockRecord ret;
|
||||
for (const FrameChangeDescriptor& descr : m_refDescrList0)
|
||||
{
|
||||
ret[descr.m_frameNumber] = descr.m_OccupiedRefBlocks;
|
||||
}
|
||||
|
||||
for (const FrameChangeDescriptor& descr : m_refDescrList1)
|
||||
{
|
||||
ret[descr.m_frameNumber] = descr.m_OccupiedRefBlocks;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void RestoreOccupiedRefBlocks(FrameOccRefBlockRecord& bak)
|
||||
{
|
||||
for (FrameChangeDescriptor& descr : m_refDescrList0)
|
||||
{
|
||||
if (bak.find(descr.m_frameNumber) != bak.end())
|
||||
{
|
||||
descr.m_OccupiedRefBlocks = std::move(bak[descr.m_frameNumber]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::string("ERROR: RestoreOccupiedRefBlocks: occupied block data not found in backup for L0");
|
||||
}
|
||||
}
|
||||
|
||||
for (FrameChangeDescriptor& descr : m_refDescrList1)
|
||||
{
|
||||
if (bak.find(descr.m_frameNumber) != bak.end())
|
||||
{
|
||||
descr.m_OccupiedRefBlocks = std::move(bak[descr.m_frameNumber]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::string("ERROR: RestoreOccupiedRefBlocks: occupied block data not found in backup for L1");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
bool IsNewPUValid(const PUBlock & newPU) const
|
||||
{
|
||||
return newPU.IsPUInRange(m_frame->Info) &&
|
||||
!CheckNewPUForIntersection(newPU);
|
||||
}
|
||||
|
||||
bool CheckNewPUForIntersection(const PUBlock & newPU) const
|
||||
{
|
||||
if (newPU.predFlagL0)
|
||||
{
|
||||
const auto& frameDescrL0 = std::next(m_refDescrList0.begin(), newPU.m_MV.RefIdx.RefL0);
|
||||
BaseBlock shiftPU_L0 = newPU.GetShiftedBaseBlock(L0);
|
||||
for (const auto& occBlock : frameDescrL0->m_OccupiedRefBlocks)
|
||||
{
|
||||
if (occBlock.CheckForIntersect(shiftPU_L0)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (newPU.predFlagL1)
|
||||
{
|
||||
const auto& frameDescrL1 = std::next(m_refDescrList1.begin(), newPU.m_MV.RefIdx.RefL1);
|
||||
BaseBlock shiftPU_L1 = newPU.GetShiftedBaseBlock(L1);
|
||||
for (const auto& occBlock : frameDescrL1->m_OccupiedRefBlocks)
|
||||
{
|
||||
if (occBlock.CheckForIntersect(shiftPU_L1)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif // __ASG_HEVC_FRAME_CHANGE_DESCRIPTOR_H__
|
|
@ -1,48 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef __ASG_FRAME_MAKER_H__
|
||||
#define __ASG_FRAME_MAKER_H__
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include "inputparameters.h"
|
||||
|
||||
inline bool GenerateInterMBs(mfxU16 test_type) { return !!(test_type & (~(GENERATE_INTRA | GENERATE_SPLIT))); }
|
||||
inline bool HasBFramesInGOP(mfxU16 refDist) { return refDist > 1; }
|
||||
|
||||
class FrameMarker
|
||||
{
|
||||
public:
|
||||
void PreProcessStreamConfig(InputParams & params);
|
||||
private:
|
||||
void BuildRefLists(const InputParams & params);
|
||||
void TagFrames(const InputParams & params);
|
||||
bool HasAlreadyUsedRefs(mfxU32 frame, mfxU8 list);
|
||||
void SetRefList(mfxU32 frame, mfxU8 list, std::vector<mfxU32> & refFrames, mfxU32 & num_gen);
|
||||
|
||||
std::vector<FrameProcessingParam> m_vProcessingParams; // FrameProcessingParam for entire stream
|
||||
};
|
||||
|
||||
#endif // MFX_VERSION
|
||||
|
||||
#endif // __ASG_FRAME_MAKER_H__
|
|
@ -1,172 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef __ASG_HEVC_FRAME_PROCESSOR_H__
|
||||
#define __ASG_HEVC_FRAME_PROCESSOR_H__
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
#include <random>
|
||||
|
||||
#include "util_defs.h"
|
||||
|
||||
#include "block_structures.h"
|
||||
#include "frame_change_descriptor.h"
|
||||
#include "intra_test.h"
|
||||
#include "inter_test.h"
|
||||
#include "mvmvp_processor.h"
|
||||
#include "random_generator.h"
|
||||
|
||||
class FrameProcessor
|
||||
{
|
||||
public:
|
||||
FrameProcessor() = default;
|
||||
|
||||
void Init(const InputParams ¶ms);
|
||||
|
||||
void ProcessFrame(FrameChangeDescriptor & frame_descr);
|
||||
|
||||
// For verification
|
||||
void GenQuadTreeInCTUWithBitMask(CTUDescriptor& CTU, mfxU32 bitMask);
|
||||
|
||||
private:
|
||||
|
||||
//work with particular samples in the frame
|
||||
bool IsSampleAvailable(mfxU32 X, mfxU32 Y);
|
||||
mfxU8 GetSampleI420(COLOR_COMPONENT comp, mfxU32 AdrX, mfxU32 AdrY, mfxFrameSurface1* surf);
|
||||
|
||||
void GenRandomQuadTreeStructure(QuadTree & QT, mfxU8 minDepth, mfxU8 maxDepth);
|
||||
void GenCUVecInCTU(CTUDescriptor & ctu, mfxU16 test_type);
|
||||
void GenRandomTUQuadTreeInCU(CUBlock & cu_block);
|
||||
void GenRandomCUQuadTreeInCTU(CTUDescriptor & ctu);
|
||||
void GetRefSampleAvailFlagsForTUsInCTU(CTUDescriptor & CTU);
|
||||
//checking if reference samples for INTRA prediction of the current block are mostly constant
|
||||
//TODO: develop flexible criterion of mostly uniform ref samples
|
||||
bool IsBlockUniform(const BaseBlock& block, PatchBlock& tempFrame);
|
||||
void AlterBorderSamples(const BaseBlock& block, PatchBlock& tempFrame);
|
||||
//counting the particurlar intra mode prediction for TU
|
||||
void MakeTUIntraPrediction(const TUBlock& refBlock, PatchBlock& targetBlock);
|
||||
//worst intra mode is found here in order to reach more contrast
|
||||
void ChooseContrastIntraMode(const BaseBlock & block, std::vector<TUBlock>& tu_block_vec, PatchBlock& frame);
|
||||
//function that makes intra prediction for refBlock of particular colorComp plane and saves it into currPlane buffer
|
||||
void GetIntraPredPlane(const BaseBlock& refBlock, INTRA_MODE currMode, const PatchBlock& frame, COLOR_COMPONENT colorComp, mfxU8* currPlane);
|
||||
//function that makes a patch from refBlock with all color components intra predicted
|
||||
PatchBlock GetIntraPatchBlock(const TUBlock & refBlock, const PatchBlock& patch);
|
||||
//intra prediction for particluar TU block and particular intra mode is made here
|
||||
void MakeIntraPredInCTU(CTUDescriptor & ctu, FrameChangeDescriptor & descr);
|
||||
|
||||
//only TU tree intraPartitionMode is determined here
|
||||
void MakeIntraCU(CUBlock & cu_block);
|
||||
void MakeInterCU(CUBlock & cu_block, mfxU16 test_type);
|
||||
mfxU8 CeilLog2(mfxU32 size);
|
||||
//methods used for INTRA prediction
|
||||
|
||||
//filling vector with adjacent samples
|
||||
//all coordinates and sizes here are measured in samples of colorComp
|
||||
void FillIntraRefSamples(mfxU32 cSize, mfxU32 cAdrX, mfxU32 cAdrY, const PatchBlock& frame, COLOR_COMPONENT colorComp, std::vector<mfxU8>& refSamples);
|
||||
|
||||
//choosing filter for the vector of reference samples and making it if needed
|
||||
void ThreeTapFilter(std::vector<mfxU8>& RefSamples, mfxU8 size);
|
||||
void StrongFilter(std::vector<mfxU8>& RefSamples, mfxU8 size);
|
||||
FILTER_TYPE ChooseFilter(std::vector<mfxU8>& RefSamples, mfxU8 size, INTRA_MODE intra_type);
|
||||
FILTER_TYPE MakeFilter(std::vector<mfxU8>& RefSamples, mfxU8 size, INTRA_MODE type);
|
||||
|
||||
//making a projection if needed
|
||||
mfxU8 MakeProjRefArray(const std::vector<mfxU8>& RefSamples, mfxU8 size, const IntraParams& IntraMode, std::vector<mfxU8>& ProjRefSamples);
|
||||
|
||||
//generating prediction using a perticular mode and saving it in IntraPatch structure
|
||||
void PlanarPrediction(const std::vector<mfxU8>& RefSamples, mfxU8 size, mfxU8 * patch);
|
||||
void DCPrediction(const std::vector<mfxU8>& RefSamples, mfxU8 size, mfxU8 * patch);
|
||||
void AngularPrediction(const std::vector<mfxU8>& RefSamples, mfxU8 size, IntraParams& IntraMode, mfxU8 * patch);
|
||||
void MakePostFilter(const std::vector<mfxU8>& RefSamples, mfxU8 cSize, INTRA_MODE currMode, mfxU8* currPlane);
|
||||
void GenerateIntraPrediction(const std::vector<mfxU8>& RefSamples, mfxU8 blockSize, INTRA_MODE currMode, mfxU8* currPlane);
|
||||
|
||||
//function generating INTRA prediction for TU leaves of the tree
|
||||
void ApplyTUIntraPrediction(const TUBlock & block, ExtendedSurface& surf);
|
||||
void ApplyIntraPredInCTU(const CTUDescriptor & CTU, FrameChangeDescriptor & frame_descr);
|
||||
void PutPatchIntoFrame(const PatchBlock & BP, mfxFrameSurface1& surf);
|
||||
//end of intra methods
|
||||
|
||||
//methods used for INTER prediction
|
||||
void GenPredFlagsForPU(PUBlock & PU, mfxU16 frameType);
|
||||
void ApplyInterPredInCTU(CTUDescriptor & CTU, FrameChangeDescriptor & frame_descr);
|
||||
|
||||
void GenCTUParams(FrameChangeDescriptor & frame_descr);
|
||||
void GenAndApplyPrediction(FrameChangeDescriptor & frame_descr);
|
||||
bool MakeInterPredInCTU(CTUDescriptor & CTU, FrameChangeDescriptor & frameDescr);
|
||||
|
||||
void PutNoiseBlocksIntoFrames(const PUBlock & pu, const FrameChangeDescriptor & frameDescr, mfxU32 num_coeff = 12, mfxU32 level = 48);
|
||||
void FillInBlock4x4(mfxU32 num_coeff, mfxU32 level, mfxU8 block[16]);
|
||||
void FillDeltaBlocks4x4(mfxI8 blockL0[16], mfxI8 blockL1[16]);
|
||||
void ApplyDeltaPerPixel(const PUBlock & PU, const mfxI8 deltaBlock[16], const mfxU8 inBlock[16], mfxU8 outBlock[16]);
|
||||
void Inverse4x4(mfxI32 *src, mfxU32 s_pitch, mfxI32 *dst, mfxU32 d_pitch);
|
||||
void PutBlock4x4(mfxU32 x0, mfxU32 y0, mfxU8 block[16], mfxFrameSurface1 * surf);
|
||||
mfxU8 ClipIntToChar(mfxI32 x);
|
||||
void TraceBackAndPutBlockIntoFrame(const PUBlock & PU, FrameChangeDescriptor & descr);
|
||||
InterpolWorkBlock GetInterpolWorkBlockPreWP(const BaseBlock & PU, std::pair<mfxU32, mfxU32> fractOffset, mfxFrameSurface1 * surfTo);
|
||||
PatchBlock ApplyDefaultWeightedPrediction(InterpolWorkBlock & workBlockL0);
|
||||
PatchBlock ApplyDefaultWeightedPrediction(InterpolWorkBlock & workBlockL0, InterpolWorkBlock & workBlockL1);
|
||||
|
||||
mfxU8 SetCorrectMVPBlockSize(mfxU8 mvpBlockSizeParam);
|
||||
|
||||
void UnlockSurfaces(FrameChangeDescriptor & frame_descr);
|
||||
|
||||
void GenRandomQuadTreeSubstrRecur(QuadTreeNode & node, mfxU8 minDepth, mfxU8 maxDepth);
|
||||
// For verification
|
||||
void GenQuadTreeWithBitMaskRecur(QuadTreeNode& node, mfxU32 bitMask);
|
||||
// Used only in quarter-pixel interpolation. Luma sample value should fit in mfxI32.
|
||||
mfxI32 GetClippedSample(COLOR_COMPONENT comp, mfxI32 AdrX, mfxI32 AdrY, mfxFrameSurface1* surf);
|
||||
|
||||
mfxI32 CalculateLumaPredictionSamplePreWP(const std::pair<mfxU32, mfxU32>& refSampleLocationFull,
|
||||
const std::pair<mfxU32, mfxU32>& refSampleLocationFract, mfxFrameSurface1* refSurface);
|
||||
|
||||
mfxI32 ApplyVerticalSubSampleLumaFilter(mfxU32 x, mfxU32 y, mfxFrameSurface1 * refSurface, const mfxI32* coeff);
|
||||
mfxI32 ApplyHorizontalSubSampleLumaFilter(mfxU32 x, mfxU32 y, mfxFrameSurface1 * refSurface, const mfxI32* coeff);
|
||||
|
||||
// These function used in only in CalculateLumaPredictionSamplePreWP
|
||||
// In specifictation default weighted prediction is the final scaling step for sample prediction. (p.168)
|
||||
mfxU8 GetDefaultWeightedPredSample(mfxI32 predSampleLX);
|
||||
mfxU8 GetDefaultWeightedPredSample(mfxI32 predSampleL0, mfxI32 predSampleL1);
|
||||
|
||||
mfxU32 m_Height = 0; // in pixels
|
||||
mfxU32 m_Width = 0;
|
||||
mfxU32 m_HeightInCTU = 0; // in CTUs
|
||||
mfxU32 m_WidthInCTU = 0;
|
||||
mfxU32 m_CropH = 0; // Unaligned size
|
||||
mfxU32 m_CropW = 0;
|
||||
|
||||
mfxU16 m_SubPelMode = 0; // Valid values are: 0, 1 or 3
|
||||
|
||||
bool m_IsForceExtMVPBlockSize = false;
|
||||
mfxU32 m_ForcedExtMVPBlockSize = 0;
|
||||
mfxU32 m_GenMVPBlockSize = 0;
|
||||
|
||||
CTUStructure m_CTUStr; // Some parameters related to CTU generation, i.e. restrictions on CTUs
|
||||
|
||||
PROCESSING_MODE m_ProcMode = UNDEFINED_MODE; // processing mode
|
||||
};
|
||||
|
||||
#endif // MFX_VERSION
|
||||
|
||||
#endif // __ASG_HEVC_FRAME_PROCESSOR_H__
|
|
@ -1,146 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef __ASG_FRAME_REORDER_H__
|
||||
#define __ASG_FRAME_REORDER_H__
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include "inputparameters.h"
|
||||
|
||||
enum NALU_TYPE
|
||||
{
|
||||
TRAIL_N = 0,
|
||||
TRAIL_R,
|
||||
RASL_N,
|
||||
RASL_R,
|
||||
IDR_W_RADL,
|
||||
CRA_NUT
|
||||
};
|
||||
|
||||
inline bool isBFF(mfxVideoParam const & video)
|
||||
{
|
||||
return ((video.mfx.FrameInfo.PicStruct & MFX_PICSTRUCT_FIELD_BOTTOM) == MFX_PICSTRUCT_FIELD_BOTTOM);
|
||||
}
|
||||
|
||||
mfxI32 GetFrameNum(bool bField, mfxI32 Poc, bool bSecondField);
|
||||
|
||||
mfxU8 GetFrameType(
|
||||
mfxVideoParam const & video,
|
||||
mfxU32 pictureOrder,
|
||||
bool isPictureOfLastFrame);
|
||||
|
||||
class FrameReorder
|
||||
{
|
||||
public:
|
||||
FrameReorder(const InputParams & params) :
|
||||
m_nMaxFrames(params.m_numFrames),
|
||||
m_BRefType(params.m_BRefType),
|
||||
m_GopOptFlag(params.m_GopOptFlag),
|
||||
m_NumRef(params.m_NumRef),
|
||||
m_UseGPB(params.m_UseGPB),
|
||||
m_NumRefActiveP(params.m_NumRefActiveP),
|
||||
m_NumRefActiveBL0(params.m_NumRefActiveBL0),
|
||||
m_NumRefActiveBL1(params.m_NumRefActiveBL1),
|
||||
m_lastIdr(0),
|
||||
m_anchorPOC(-1)
|
||||
{};
|
||||
ExternalFrame CreateExternalFrame(mfxI32 order, const mfxVideoParam& param);
|
||||
inline size_t GetBufferedQueueSize() const
|
||||
{
|
||||
return m_queue.size();
|
||||
};
|
||||
private:
|
||||
mfxU32 m_nMaxFrames;
|
||||
mfxU16 m_BRefType;
|
||||
mfxU16 m_GopOptFlag;
|
||||
mfxU16 m_NumRef;
|
||||
bool m_UseGPB;
|
||||
mfxU16 m_NumRefActiveP;
|
||||
mfxU16 m_NumRefActiveBL0;
|
||||
mfxU16 m_NumRefActiveBL1;
|
||||
|
||||
class LastReorderedFieldInfo
|
||||
{
|
||||
public:
|
||||
mfxI32 m_poc;
|
||||
bool m_bReference;
|
||||
bool m_bFirstField;
|
||||
|
||||
LastReorderedFieldInfo() :
|
||||
m_poc(-1),
|
||||
m_bReference(false),
|
||||
m_bFirstField(false) {}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
m_poc = -1;
|
||||
m_bReference = false;
|
||||
m_bFirstField = false;
|
||||
}
|
||||
void SaveInfo(Frame const & frame)
|
||||
{
|
||||
m_poc = frame.Poc;
|
||||
m_bReference = ((frame.Type & MFX_FRAMETYPE_REF) != 0);
|
||||
m_bFirstField = !frame.bSecondField;
|
||||
}
|
||||
void CorrectFrameInfo(Frame & frame)
|
||||
{
|
||||
if (!isCorrespondSecondField(frame))
|
||||
return;
|
||||
// copy params to the 2nd field
|
||||
if (m_bReference)
|
||||
frame.Type |= MFX_FRAMETYPE_REF;
|
||||
}
|
||||
bool isCorrespondSecondField(Frame const & frame)
|
||||
{
|
||||
if (m_poc + 1 != frame.Poc || !frame.bSecondField || !m_bFirstField)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
bool bFirstField() { return m_bFirstField; }
|
||||
};
|
||||
|
||||
typedef std::vector<Frame> FrameArray;
|
||||
typedef std::vector<Frame>::iterator FrameIterator;
|
||||
FrameArray m_queue;
|
||||
LastReorderedFieldInfo m_lastFieldInfo;
|
||||
FrameArray m_dpb;
|
||||
mfxI32 m_lastIdr; // for POC calculation
|
||||
mfxI32 m_anchorPOC; // for P-Pyramid
|
||||
Frame m_lastFrame;
|
||||
|
||||
mfxU8 GetNALUType(Frame const & frame, bool isRAPIntra);
|
||||
bool HasL1(mfxI32 poc);
|
||||
mfxU32 BRefOrder(mfxU32 displayOrder, mfxU32 begin, mfxU32 end, mfxU32 counter, bool & ref);
|
||||
mfxU32 GetBiFrameLocation(mfxU32 displayOrder, mfxU32 num, bool &ref);
|
||||
mfxU32 BPyrReorder(const std::vector<FrameIterator> & bframes);
|
||||
FrameIterator Reorder(bool flush, bool bFields);
|
||||
FrameIterator Reorder(FrameIterator begin, FrameIterator end, bool flush, bool bFields);
|
||||
};
|
||||
|
||||
#endif // MFX_VERSION
|
||||
|
||||
#endif // __ASG_FRAME_REORDER_H__
|
|
@ -1,55 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef __GENERATOR_H__
|
||||
#define __GENERATOR_H__
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include "refcontrol.h"
|
||||
#include "test_processor.h"
|
||||
|
||||
class Generator : public TestProcessor {
|
||||
public:
|
||||
explicit Generator() {}
|
||||
|
||||
~Generator() {}
|
||||
|
||||
private:
|
||||
void Init() override;
|
||||
|
||||
// Get surface and load new YUV frame from file to it
|
||||
ExtendedSurface* PrepareSurface() override;
|
||||
|
||||
// Save all data
|
||||
void DropFrames() override;
|
||||
void DropBuffers(ExtendedSurface& surf) override;
|
||||
virtual void SavePSData() override;
|
||||
|
||||
CSmplYUVReader m_FileReader;
|
||||
CSmplYUVWriter m_FileWriter;
|
||||
BufferWriter m_BufferWriter;
|
||||
};
|
||||
|
||||
#endif // MFX_VERSION
|
||||
|
||||
#endif // __GENERATOR_H__
|
|
@ -1,72 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef __HEVC_DEFS_H__
|
||||
#define __HEVC_DEFS_H__
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
//HEVC standard-defined limits on block sizes in terms of luma samples
|
||||
|
||||
//CTUs
|
||||
#define HEVC_MIN_CTU_SIZE 16
|
||||
#define HEVC_MAX_CTU_SIZE 64
|
||||
|
||||
#define HEVC_MIN_LOG2_CTU_SIZE 4
|
||||
#define HEVC_MAX_LOG2_CTU_SIZE 6
|
||||
|
||||
//CUs
|
||||
//Min size is 8x8, max size is equal to current CTU size
|
||||
#define HEVC_MIN_CU_SIZE 8
|
||||
#define HEVC_MIN_LOG2_CU_SIZE 3
|
||||
|
||||
//PUs
|
||||
//Min size is either 4x8 or 8x4, max size is equal to current CU size
|
||||
#define HEVC_MIN_PU_SIZE_LO 4
|
||||
#define HEVC_MIN_PU_SIZE_HI 8
|
||||
|
||||
//TUs
|
||||
//Min size is 4x4, max size is 32x32 (cannot be larger than CU min size)
|
||||
#define HEVC_MIN_TU_SIZE 4
|
||||
#define HEVC_MAX_TU_SIZE 32
|
||||
|
||||
#define HEVC_MIN_LOG2_TU_SIZE 2
|
||||
#define HEVC_MAX_LOG2_TU_SIZE 5
|
||||
|
||||
//Maximum QP value
|
||||
#define HEVC_MAX_QP 51
|
||||
|
||||
// Luma sub-sample interpolation filter
|
||||
#define LUMA_SUBSAMPLE_INTERPOLATION_FILTER_POSITIONS 4
|
||||
#define LUMA_TAPS_NUMBER 8
|
||||
|
||||
const mfxI32 LUMA_SUBSAMPLE_FILTER_COEFF[LUMA_SUBSAMPLE_INTERPOLATION_FILTER_POSITIONS][LUMA_TAPS_NUMBER] =
|
||||
{
|
||||
{ 0, 0, 0, 1, 0, 0, 0, 0 },
|
||||
{ -1, 4, -10, 58, 17, -5, 1, 0 },
|
||||
{ -1, 4, -11, 40, 40, -11, 4, -1 },
|
||||
{ 0, 1, -5, 17, 58, -10, 4, -1 },
|
||||
};
|
||||
|
||||
#endif // MFX_VERSION
|
||||
|
||||
#endif //__HEVC_DEFS_H__
|
|
@ -1,234 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef __ASG_HEVC_INPUT_PARAMETERS_H__
|
||||
#define __ASG_HEVC_INPUT_PARAMETERS_H__
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include "base_allocator.h"
|
||||
#include "hevc_defs.h"
|
||||
#include "util_defs.h"
|
||||
|
||||
enum PROCESSING_MODE
|
||||
{
|
||||
UNDEFINED_MODE = 0,
|
||||
GENERATE,
|
||||
VERIFY
|
||||
};
|
||||
|
||||
// TODO: use std::bitset instead
|
||||
enum
|
||||
{
|
||||
UNDEFINED_TYPE = 0,
|
||||
GENERATE_MV = 1 << 0,
|
||||
GENERATE_PREDICTION = 1 << 1,
|
||||
GENERATE_SPLIT = 1 << 2,
|
||||
GENERATE_INTRA = 1 << 3,
|
||||
GENERATE_INTER = 1 << 4,
|
||||
GENERATE_PICSTRUCT = 1 << 5,
|
||||
GENERATE_REPACK_CTRL = 1 << 6
|
||||
};
|
||||
|
||||
enum FRAME_MARKER
|
||||
{
|
||||
GEN = 1,
|
||||
MOD = 2,
|
||||
SKIP = 3
|
||||
};
|
||||
|
||||
// Restrictions on CTU for generation of noisy blocks
|
||||
struct CTUStructure
|
||||
{
|
||||
//Below are default values that should be most relaxed
|
||||
mfxU32 log2CTUSize = HEVC_MIN_LOG2_CTU_SIZE;
|
||||
mfxU32 CTUSize = 1 << log2CTUSize;
|
||||
mfxU32 minLog2CUSize = HEVC_MIN_LOG2_CU_SIZE;
|
||||
mfxU32 maxLog2CUSize = HEVC_MIN_LOG2_CTU_SIZE; //NB: can be less than CTU size inside asg-hevc
|
||||
//Standard specifies that CTU size is set equal to
|
||||
//1 << maxLog2CUSize, but this is for encoder only:
|
||||
//inside asg-hevc, we will maintain this separate upper
|
||||
//limit on max CU size
|
||||
|
||||
mfxU32 minLog2TUSize = HEVC_MIN_LOG2_TU_SIZE; //Must be less than minLog2CUSize
|
||||
mfxU32 maxLog2TUSize = HEVC_MIN_LOG2_CTU_SIZE;
|
||||
mfxU32 maxTUQTDepth = HEVC_MAX_LOG2_CTU_SIZE - HEVC_MIN_LOG2_TU_SIZE; //Overrides min TU size while
|
||||
//building TU quadtree in CU
|
||||
mfxU32 CTUMaxNum = 128;
|
||||
mfxU32 MVRange = 12;
|
||||
mfxU32 CTUDist = 3; //Default minimum distance between generated CTU blocks in terms of CTU
|
||||
|
||||
bool bCUToPUSplit = true; //Whether or not CUs should be further split into PUs
|
||||
bool bForceSymmetricPU = false; //Support only symmetric modes for CU into PU partioning
|
||||
|
||||
inline mfxU32 GetMaxNumCuInCtu()
|
||||
{
|
||||
return (1 << (2 * (log2CTUSize - HEVC_MIN_LOG2_CU_SIZE)));
|
||||
}
|
||||
};
|
||||
|
||||
struct Frame
|
||||
{
|
||||
mfxU32 DisplayOrder = 0xffffffff;
|
||||
mfxU32 Type = MFX_FRAMETYPE_UNKNOWN;
|
||||
mfxU8 NalType = 0xff;
|
||||
mfxI32 Poc = -1;
|
||||
mfxU32 Bpo = 0xffffffff;
|
||||
bool bSecondField = false;
|
||||
bool bBottomField = false;
|
||||
mfxI32 LastRAP = -1;
|
||||
mfxI32 IPoc = -1;
|
||||
mfxI32 PrevIPoc = -1;
|
||||
mfxI32 NextIPoc = -1;
|
||||
};
|
||||
|
||||
struct ExternalFrame
|
||||
{
|
||||
mfxU32 DisplayOrder;
|
||||
mfxU32 Type;
|
||||
mfxU8 NalType;
|
||||
mfxI32 Poc;
|
||||
bool bSecondField;
|
||||
bool bBottomField;
|
||||
std::vector<Frame> ListX[2];
|
||||
};
|
||||
|
||||
// Structure which used for initial stream marking
|
||||
|
||||
struct FrameProcessingParam
|
||||
{
|
||||
FRAME_MARKER Mark = SKIP;
|
||||
std::vector<mfxU32> ReferencesL0;
|
||||
std::vector<mfxU32> ReferencesL1;
|
||||
|
||||
mfxU32 DisplayOrder = 0xffffffff;
|
||||
mfxU32 EncodedOrder = 0xffffffff;
|
||||
|
||||
mfxU32 Type = MFX_FRAMETYPE_UNKNOWN;
|
||||
std::vector<Frame> ListX[2];
|
||||
|
||||
FrameProcessingParam & operator= (const ExternalFrame& rhs)
|
||||
{
|
||||
DisplayOrder = rhs.DisplayOrder;
|
||||
Type = rhs.Type;
|
||||
ListX[0] = rhs.ListX[0];
|
||||
ListX[1] = rhs.ListX[1];
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct Thresholds
|
||||
{
|
||||
// asg should exit with non-zero if MV/split-passrate is lower than threshold
|
||||
mfxU32 mvThres = 0;
|
||||
mfxU32 splitThres = 0;
|
||||
};
|
||||
|
||||
class InputParams
|
||||
{
|
||||
public:
|
||||
|
||||
void ParseInputString(msdk_char **strInput, mfxU8 nArgNum);
|
||||
|
||||
mfxU16 m_TestType = UNDEFINED_TYPE;
|
||||
PROCESSING_MODE m_ProcMode = UNDEFINED_MODE;
|
||||
|
||||
mfxU32 m_width = 0;
|
||||
mfxU32 m_height = 0;
|
||||
mfxU32 m_numFrames = 0;
|
||||
|
||||
mfxU16 m_PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
|
||||
mfxU16 m_BRefType = MFX_B_REF_OFF;
|
||||
mfxU16 m_GopOptFlag = 0;
|
||||
mfxU16 m_GopSize = 1;
|
||||
mfxU16 m_RefDist = 1;
|
||||
mfxU16 m_NumRef = 1;
|
||||
mfxU16 m_nIdrInterval = 0xffff;
|
||||
mfxU16 m_NumRefActiveP = 3;
|
||||
mfxU16 m_NumRefActiveBL0 = 3;
|
||||
mfxU16 m_NumRefActiveBL1 = 1;
|
||||
bool m_UseGPB = true;
|
||||
|
||||
// Which blocks to use (it might be possible to forbid CUs of some sizes)
|
||||
// TODO: extend and add to code
|
||||
mfxU16 m_block_size_mask = 3; // 0 - invalid, 001 - 16x16, 010 - 32x32, 100 - 64x64
|
||||
|
||||
// Specifies which sub pixel precision mode is used in motion prediction.
|
||||
// Valid values are: 0 ; 1 ; 3 (integer, half, quarter). 0x0 is default
|
||||
mfxU16 m_SubPixelMode = 0;
|
||||
|
||||
bool m_bVerbose = false;
|
||||
bool m_bPrintHelp = false;
|
||||
bool m_bUseLog = false;
|
||||
|
||||
// Specifies the external MVP block size which is written to mfxFeiHevcEncMVPredictors::BlockSize
|
||||
// Valid values are: 0 ; 1; 2; 3 (no MVP, MVP enabled for 16x16/32x32/64x64 block)
|
||||
bool m_bIsForceExtMVPBlockSize = false;
|
||||
mfxU32 m_ForcedExtMVPBlockSize = 0;
|
||||
|
||||
// Specifies MVP block size used in the actual generation
|
||||
// Valid values are the same as for m_ForcedExtMVPBlockSize
|
||||
mfxU32 m_GenMVPBlockSize = 0;
|
||||
|
||||
// For repack ctrl
|
||||
mfxU32 m_NumAddPasses = 8; // Number of additional passes w/o first pass with clear QP value
|
||||
mfxU8 m_DeltaQP[8] = {1,2,3,3,4,4,4,4};
|
||||
mfxU8 m_InitialQP = 26;
|
||||
|
||||
msdk_string m_InputFileName;
|
||||
msdk_string m_OutputFileName;
|
||||
|
||||
msdk_string m_LogFileName;
|
||||
|
||||
msdk_string m_PredBufferFileName; // filename for predictors ext buffer output
|
||||
msdk_string m_PicStructFileName; // filename for pictures structure output
|
||||
|
||||
msdk_string m_PakCtuBufferFileName; // filename for PAK CTU ext buffer input
|
||||
msdk_string m_PakCuBufferFileName; // filename for PAK CU ext buffer input
|
||||
|
||||
msdk_string m_RepackCtrlFileName; // filename for repack constrol output/input
|
||||
msdk_string m_RepackStrFileName; // filename for multiPakStr input
|
||||
msdk_string m_RepackStatFileName; // filename for repack stat input
|
||||
|
||||
CTUStructure m_CTUStr;
|
||||
|
||||
Thresholds m_Thresholds;
|
||||
// Actual number of MV predictors enabled in FEI ENCODE. Used in verification mode
|
||||
mfxU16 m_NumMVPredictors = 4;
|
||||
|
||||
std::vector<FrameProcessingParam> m_vProcessingParams; // FrameProcessingParam for entire stream
|
||||
|
||||
private:
|
||||
mfxU16 ParseSubPixelMode(msdk_char * strRawSubPelMode);
|
||||
int GetIntArgument(msdk_char ** strInput, mfxU8 index, mfxU8 nArgNum);
|
||||
msdk_string GetStringArgument(msdk_char ** strInput, mfxU8 index, mfxU8 nArgNum);
|
||||
};
|
||||
|
||||
#endif // MFX_VERSION
|
||||
|
||||
#endif // __ASG_HEVC_INPUT_PARAMETERS_H__
|
|
@ -1,49 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
//Some consts and enums for intra prediction
|
||||
|
||||
#ifndef __INTER_TEST_H__
|
||||
#define __INTER_TEST_H__
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include "mfxdefs.h"
|
||||
|
||||
enum INTER_PART_MODE {
|
||||
INTER_NONE = -1,
|
||||
INTER_2Nx2N = 0,
|
||||
INTER_2NxN,
|
||||
INTER_Nx2N,
|
||||
INTER_NxN,
|
||||
INTER_2NxnU,
|
||||
INTER_2NxnD,
|
||||
INTER_nLx2N,
|
||||
INTER_nRx2N
|
||||
};
|
||||
const mfxU32 INTER_PART_MODE_NUM = 8;
|
||||
const mfxU32 INTER_8x8CU_PART_MODE_NUM = 3; //For 8x8 CUs only first 3 modes are available
|
||||
const mfxU32 INTER_SYMM_PART_MODE_NUM = 4; //First 4 modes are symmetric
|
||||
|
||||
#endif // MFX_VERSION
|
||||
|
||||
#endif //__INTER_TEST_H__
|
|
@ -1,141 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
//Some consts and enums for intra prediction
|
||||
|
||||
#ifndef __INTRA_TEST_H__
|
||||
#define __INTRA_TEST_H__
|
||||
|
||||
#include "mfxvideo.h"
|
||||
#include <string>
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include "mfxdefs.h"
|
||||
|
||||
enum INTRA_PART_MODE {
|
||||
INTRA_NONE = -1,
|
||||
INTRA_2Nx2N = 0,
|
||||
INTRA_NxN = 1
|
||||
};
|
||||
|
||||
enum INTRA_MODE {
|
||||
NONE = -1,
|
||||
PLANAR = 0,
|
||||
DC = 1,
|
||||
ANG2 = 2,
|
||||
ANG3 = 3,
|
||||
ANG4 = 4,
|
||||
ANG5 = 5,
|
||||
ANG6 = 6,
|
||||
ANG7 = 7,
|
||||
ANG8 = 8,
|
||||
ANG9 = 9,
|
||||
ANG10_HOR = 10,
|
||||
ANG11 = 11,
|
||||
ANG12 = 12,
|
||||
ANG13 = 13,
|
||||
ANG14 = 14,
|
||||
ANG15 = 15,
|
||||
ANG16 = 16,
|
||||
ANG17 = 17,
|
||||
ANG18 = 18,
|
||||
ANG19 = 19,
|
||||
ANG20 = 20,
|
||||
ANG21 = 21,
|
||||
ANG22 = 22,
|
||||
ANG23 = 23,
|
||||
ANG24 = 24,
|
||||
ANG25 = 25,
|
||||
ANG26_VER = 26,
|
||||
ANG27 = 27,
|
||||
ANG28 = 28,
|
||||
ANG29 = 29,
|
||||
ANG30 = 30,
|
||||
ANG31 = 31,
|
||||
ANG32 = 32,
|
||||
ANG33 = 33,
|
||||
ANG34 = 34
|
||||
};
|
||||
const mfxU32 INTRA_MODE_NUM = 35; //Planar + DC + 33 angular modes (2 thru 34)
|
||||
|
||||
enum INTRA_DIR {
|
||||
HORIZONTAL,
|
||||
VERTICAL,
|
||||
DIR_NOT_SPECIFIED
|
||||
};
|
||||
|
||||
enum FILTER_TYPE {
|
||||
NO_FILTER,
|
||||
THREE_TAP_FILTER,
|
||||
STRONG_INTRA_SMOOTHING_FILTER
|
||||
};
|
||||
|
||||
const mfxI8 angParam[] = { 32, 26, 21, 17, 13, 9, 5, 2, 0, -2, -5, -9, -13, -17, -21, -26, -32 };
|
||||
const mfxI32 inverseAngParam[] = { -256, -315, -390, -482, -630, -910, -1638, -4096 };
|
||||
|
||||
inline bool isValidIntraMode(INTRA_MODE mode)
|
||||
{
|
||||
// NONE is not a valid mode to operate
|
||||
return PLANAR <= mode && mode <= ANG34;
|
||||
}
|
||||
|
||||
struct IntraParams {
|
||||
INTRA_MODE intraMode = NONE;
|
||||
INTRA_DIR direction = DIR_NOT_SPECIFIED;
|
||||
mfxI8 intraPredAngle = 0;
|
||||
mfxI32 invAngle = 0;
|
||||
|
||||
IntraParams(INTRA_MODE mode)
|
||||
: intraMode(mode)
|
||||
{
|
||||
if (!isValidIntraMode(mode))
|
||||
{
|
||||
throw std::string("ERROR: IntraParams: incorrect intra mode");
|
||||
}
|
||||
|
||||
if (intraMode == PLANAR || intraMode == DC)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (intraMode < ANG18)
|
||||
{
|
||||
direction = HORIZONTAL;
|
||||
intraPredAngle = angParam[intraMode - 2];
|
||||
|
||||
if (intraMode > ANG10_HOR)
|
||||
invAngle = inverseAngParam[18 - intraMode];
|
||||
}
|
||||
else
|
||||
{
|
||||
direction = VERTICAL;
|
||||
intraPredAngle = -angParam[intraMode - 18];
|
||||
|
||||
if (intraMode < ANG26_VER)
|
||||
invAngle = inverseAngParam[intraMode - 18];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MFX_VERSION
|
||||
|
||||
#endif // !__INTRA_TEST_H__
|
||||
|
|
@ -1,132 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef __ASG_HEVC_MVMVP_PROCESSOR_H__
|
||||
#define __ASG_HEVC_MVMVP_PROCESSOR_H__
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "block_structures.h"
|
||||
#include "frame_change_descriptor.h"
|
||||
#include "random_generator.h"
|
||||
|
||||
class MVMVPProcessor
|
||||
{
|
||||
public:
|
||||
MVMVPProcessor() = delete;
|
||||
|
||||
MVMVPProcessor(mfxU32 extGenMVPBlockSize, mfxU16 extSubPelMode) :
|
||||
m_GenMVPBlockSize(extGenMVPBlockSize),
|
||||
m_SubPelMode(extSubPelMode), m_DoUseIntra(false) {}
|
||||
|
||||
// Initiates an MVMVPProcessor with data from CTU
|
||||
void InitMVPGridData(const CTUDescriptor& CTU, const FrameChangeDescriptor & frameDescr);
|
||||
|
||||
bool GenValidMVMVPForPU(PUBlock & PU, const FrameChangeDescriptor & frameDescr);
|
||||
|
||||
bool GenValidMVForPU(PUBlock & PU, const FrameChangeDescriptor & frameDescr);
|
||||
|
||||
void FillFrameMVPExtBuffer(FrameChangeDescriptor& frameDescr);
|
||||
|
||||
void GetMVPPools(std::vector<std::vector<PUMotionVector>> &outMVPPools);
|
||||
|
||||
private:
|
||||
|
||||
//Structure representing a single MVP block
|
||||
struct MVPBlock : BaseBlock
|
||||
{
|
||||
MVPBlock(mfxU32 adrX = 0, mfxU32 adrY = 0, mfxU32 bWidth = 0, mfxU32 bHeight = 0) :
|
||||
BaseBlock(adrX, adrY, bWidth, bHeight), mvpPoolGroupNo(MVP_INVALID_POOL_GROUP) {}
|
||||
|
||||
// No. of generation MVP pool group
|
||||
// For each two MVP blocks from the same group
|
||||
// MVP pools should be equal
|
||||
mfxI32 mvpPoolGroupNo = MVP_INVALID_POOL_GROUP;
|
||||
|
||||
bool IsAlreadyInGroup() const { return mvpPoolGroupNo != MVP_INVALID_POOL_GROUP; }
|
||||
|
||||
bool IsInGroup(mfxI32 extGroupNo) const { return mvpPoolGroupNo == extGroupNo; }
|
||||
|
||||
void SetGroup(mfxI32 extGroupNo) { mvpPoolGroupNo = extGroupNo; }
|
||||
|
||||
mfxI32 GetGroupNo() const { return mvpPoolGroupNo; }
|
||||
};
|
||||
|
||||
static constexpr mfxI32 MVP_INVALID_POOL_GROUP = -1;
|
||||
mfxU32 m_GenMVPBlockSize = 0;
|
||||
mfxU16 m_SubPelMode = 0;
|
||||
|
||||
std::vector<MVPBlock> m_mvpBlockGrid;
|
||||
|
||||
// Type to store 32x32 MVP blocks. First value is actual BaseBlock
|
||||
// Second one is no. (m_mvpBlockGrid) of left upper 16x16 block in the group
|
||||
typedef std::pair<BaseBlock, mfxU32> MVP32x32BlockGroup;
|
||||
|
||||
std::vector<std::vector<PUMotionVector>> m_mvpPools;
|
||||
|
||||
// Checking test case type
|
||||
bool m_DoUseIntra = false;
|
||||
|
||||
// Custom hasher used in unordered_map
|
||||
struct BaseBlockHasher
|
||||
{
|
||||
std::size_t operator() (const BaseBlock& key) const
|
||||
{
|
||||
return std::hash<mfxU32>()(key.m_AdrX) ^ ((std::hash<mfxU32>()(key.m_AdrY) << 1) >> 1)
|
||||
^ (std::hash<mfxU32>()(key.m_BHeight) << 1) ^ (std::hash<mfxU32>()(key.m_BWidth) >> 1);
|
||||
}
|
||||
};
|
||||
|
||||
std::unordered_map<BaseBlock, mfxI32, BaseBlockHasher> m_PUtoMVPPoolGroupMap;
|
||||
|
||||
PUMotionVector GenerateMVP(const CTUDescriptor& CTU, const FrameChangeDescriptor& frameChangeDescr);
|
||||
|
||||
PUMotionVector GenerateMV(const FrameChangeDescriptor& frameDescr);
|
||||
|
||||
mfxI32 GetRandomMVComponent(mfxI32 lower, mfxI32 upper);
|
||||
|
||||
// Functions used to put all PUs in CTU and MVP blocks in the correct MVP pool groups
|
||||
// according to INTER splitting and MVPBlockSize parameter
|
||||
// All these functions return actual number of MVP pool groups to generate
|
||||
mfxI32 ConstructMVPPoolGroups(const CTUDescriptor& CTU);
|
||||
|
||||
mfxI32 PutPUAndMVPBlocksIn16x16MVPPoolGroups(const CTUDescriptor& CTU);
|
||||
mfxI32 PutPUAndMVPBlocksIn32x32MVPPoolGroups(const CTUDescriptor& CTU);
|
||||
mfxI32 PutPUAndMVPBlocksInSingleMVPPoolGroup(const CTUDescriptor& CTU);
|
||||
|
||||
// Functions used in MVP Ext buffer dumping
|
||||
|
||||
// Gets offset in mfxExtFeiHevcEncMVPredictors::Data buffer for the provided MVP block element
|
||||
mfxU32 CalculateOffsetInMVPredictorsBuffer(mfxU32 bufferPitch, const MVPBlock& mvpBlock);
|
||||
|
||||
// Fill one mfxFeiHevcEncMVPredictors element in mfxExtFeiHevcEncMVPredictors::Data buffer
|
||||
// associated with provided MVP block
|
||||
void PutMVPIntoExtBuffer(const MVPBlock& mvpBlock, mfxExtFeiHevcEncMVPredictors* outputBuf);
|
||||
};
|
||||
|
||||
#endif // MFX_VERSION
|
||||
|
||||
#endif // __ASG_HEVC_MVMVP_PROCESSOR_H__
|
|
@ -1,61 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef __ASG_HEVC_RANDOM_GENERATOR_H__
|
||||
#define __ASG_HEVC_RANDOM_GENERATOR_H__
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include <random>
|
||||
|
||||
#include "block_structures.h"
|
||||
|
||||
|
||||
class ASGRandomGenerator
|
||||
{
|
||||
public:
|
||||
static ASGRandomGenerator& GetInstance();
|
||||
|
||||
mfxI32 GetRandomNumber(mfxI32 min, mfxI32 max);
|
||||
mfxI32 GetRandomSign();
|
||||
bool GetRandomBit();
|
||||
mfxI32 GetRandomPicField();
|
||||
|
||||
// This method is considered as DEPRECATED - DO NOT USE IT IN THE FUTURE CHANGES
|
||||
// The only purpose of this function to support previous code
|
||||
// in order to sync with data generated with the previous ASG versions
|
||||
void SeedGenerator(mfxU32 extSeed);
|
||||
|
||||
private:
|
||||
static constexpr mfxU32 DEFAULT_SEED = 1;
|
||||
|
||||
ASGRandomGenerator(mfxU32 seed = DEFAULT_SEED) : m_Gen(seed) {}
|
||||
|
||||
std::mt19937 m_Gen; // random number generator
|
||||
};
|
||||
|
||||
// Alias for static GetInstance to use in client code
|
||||
constexpr auto GetRandomGen = &ASGRandomGenerator::GetInstance;
|
||||
|
||||
#endif // MFX_VERSION
|
||||
|
||||
#endif // __ASG_HEVC_RANDOM_GENERATOR_H__
|
|
@ -1,98 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef __REFCONTROL_H__
|
||||
#define __REFCONTROL_H__
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
#include "inputparameters.h"
|
||||
#include "random_generator.h"
|
||||
|
||||
// These structures are used in asg-hevc-based PicStruct test
|
||||
|
||||
struct PictureInfo
|
||||
{
|
||||
mfxI32 orderCount = -1; // display order
|
||||
mfxI32 codingOrder = -1;
|
||||
mfxU32 frameType = MFX_FRAMETYPE_UNKNOWN; // IPB, IDR, ST/LT
|
||||
mfxU32 picStruct = MFX_PICSTRUCT_UNKNOWN; // TF/BF
|
||||
|
||||
bool operator==(const PictureInfo& rhs) const
|
||||
{
|
||||
return codingOrder == rhs.codingOrder &&
|
||||
orderCount == rhs.orderCount &&
|
||||
picStruct == rhs.picStruct &&
|
||||
frameType == rhs.frameType;
|
||||
}
|
||||
};
|
||||
|
||||
struct RefState
|
||||
{
|
||||
PictureInfo picture;
|
||||
std::vector<mfxI32> DPB; // stores FrameOrder (POC)
|
||||
std::vector<mfxI32> RefListActive[2]; // (POC), any from DPB, can be repeated
|
||||
|
||||
void Dump(std::fstream& fp) const;
|
||||
bool Load(std::fstream& fp); // returns false on error
|
||||
|
||||
bool operator==(const RefState& rhs) const
|
||||
{
|
||||
return
|
||||
picture == rhs.picture &&
|
||||
DPB == rhs.DPB &&
|
||||
RefListActive[0] == rhs.RefListActive[0] &&
|
||||
RefListActive[1] == rhs.RefListActive[1];
|
||||
}
|
||||
};
|
||||
|
||||
class RefControl
|
||||
{
|
||||
public:
|
||||
std::vector<RefState> RefLogInfo;
|
||||
|
||||
void Add(mfxI32 frameOrder);
|
||||
void Encode(mfxI32 frameOrder);
|
||||
void SetParams(const InputParams& params);
|
||||
private:
|
||||
mfxU32 maxDPBSize = 1; // max num ref + 1 for current
|
||||
mfxU32 maxDelay = 1; // == number of allocated surfaces used in encoder reordering
|
||||
|
||||
std::vector<PictureInfo> DPB; // can temporary be maxDPBSize+1, stores all active pictures
|
||||
|
||||
std::vector<PictureInfo> RPB; // reordered picture buffer, pic goes to DPB when coded
|
||||
|
||||
InputParams m_params;
|
||||
mfxI32 m_lastIDR = 0;
|
||||
};
|
||||
|
||||
// TODO: Replace global functions with lambdas
|
||||
bool IsOlder(const PictureInfo& a, const PictureInfo& b);
|
||||
bool IsInCodingOrder(const RefState& a, const RefState& b);
|
||||
|
||||
|
||||
#endif // MFX_VERSION
|
||||
|
||||
#endif // __REFCONTROL_H__
|
|
@ -1,101 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef __ASG_HEVC_TEST_PROCESSOR_H__
|
||||
#define __ASG_HEVC_TEST_PROCESSOR_H__
|
||||
|
||||
#include "mfxvideo.h"
|
||||
#include "sample_defs.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "sample_utils.h"
|
||||
#include "base_allocator.h"
|
||||
|
||||
#include "inputparameters.h"
|
||||
#include "frame_processor.h"
|
||||
#include "util_defs.h"
|
||||
#include "asglog.h"
|
||||
|
||||
#include "refcontrol.h"
|
||||
|
||||
class TestProcessor
|
||||
{
|
||||
public:
|
||||
virtual ~TestProcessor() {}
|
||||
|
||||
void RunTest(const InputParams & params);
|
||||
void RunPSTest(const InputParams & params);
|
||||
|
||||
void RunRepackGenerate();
|
||||
void RunRepackVerify();
|
||||
|
||||
static ASGLog asgLog;
|
||||
|
||||
protected:
|
||||
void Init(const InputParams ¶ms);
|
||||
virtual void Init() = 0;
|
||||
|
||||
explicit TestProcessor() : fpPicStruct(), fpRepackCtrl(), fpRepackStr(), fpRepackStat() {}
|
||||
|
||||
ExtendedSurface* GetFreeSurf();
|
||||
|
||||
// Get surface
|
||||
virtual ExtendedSurface* PrepareSurface() { return nullptr; }
|
||||
|
||||
void ChangePicture(ExtendedSurface& surf);
|
||||
|
||||
void PrepareDescriptor(FrameChangeDescriptor & descr, const mfxU32 frameNum);
|
||||
|
||||
// Save all data
|
||||
virtual void DropFrames() {}
|
||||
virtual void DropBuffers(ExtendedSurface& surf) {}
|
||||
virtual void SavePSData() = 0;
|
||||
|
||||
// Verification mode
|
||||
virtual void VerifyDesc(FrameChangeDescriptor & frame_descr) {}
|
||||
|
||||
InputParams m_InputParams;
|
||||
std::vector<FrameProcessingParam> m_vProcessingParams; // markers for all frames
|
||||
std::list<FrameChangeDescriptor> m_ProcessedFramesDescr; // DPB analogue
|
||||
FrameProcessor m_FrameProcessor; // Class which performs processing of frame
|
||||
std::list<ExtendedSurface> m_Surfaces; // Surface pool
|
||||
|
||||
std::fstream fpPicStruct;
|
||||
RefControl m_RefControl;
|
||||
|
||||
std::fstream fpRepackCtrl;
|
||||
std::fstream fpRepackStr;
|
||||
std::fstream fpRepackStat;
|
||||
|
||||
private:
|
||||
//used to be global
|
||||
|
||||
// used once in TestProcessor
|
||||
std::list<FrameChangeDescriptor> GetReferences(const std::list<FrameChangeDescriptor> & RecentProcessed, const std::vector<mfxU32>& ref_idx);
|
||||
// never used actually
|
||||
std::list<FrameChangeDescriptor> GetSkips(const std::list<FrameChangeDescriptor> & RecentProcessed);
|
||||
};
|
||||
|
||||
#endif // MFX_VERSION
|
||||
|
||||
#endif // __ASG_HEVC_TEST_PROCESSOR_H__
|
|
@ -1,638 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef __ASG_HEVC_UTILS_H__
|
||||
#define __ASG_HEVC_UTILS_H__
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include "mfxdefs.h"
|
||||
#include "mfxfeihevc.h"
|
||||
#include "sample_defs.h"
|
||||
|
||||
#define CHECK_THROW_ERR(STS, MESSAGE) { \
|
||||
if (STS < MFX_ERR_NONE)\
|
||||
throw std::string(std::string("ERROR: (") + ConvertMfxStatusToString(STS) + std::string(") ") + MESSAGE);\
|
||||
else if (STS > MFX_ERR_NONE) \
|
||||
std::cout << "WARNING: (" << ConvertMfxStatusToString(STS) << ") " << MESSAGE << std::endl; \
|
||||
}
|
||||
|
||||
#define CHECK_THROW_ERR_BOOL(EXPR, MESSAGE) { \
|
||||
if (!EXPR) \
|
||||
throw std::string(MESSAGE); \
|
||||
}
|
||||
|
||||
#define ASG_HEVC_ERR_LOW_PASS_RATE 100
|
||||
|
||||
#define LUMA_DEFAULT 0
|
||||
#define CHROMA_DEFAULT 127
|
||||
#define MAX_GEN_MV_ATTEMPTS 100
|
||||
#define MVP_BLOCK_SIZE 16
|
||||
#define MVP_PER_16x16_BLOCK 4
|
||||
#define MVMVP_SIZE_LIMIT 2048 //Hardware-imposed limit for either of MV/MVP coordinates in quarter-pixel
|
||||
//units. To be increased in PV5
|
||||
|
||||
#define HW_SEARCH_ELEMENT_SIZE 16 //Hardware search element size in pixels (i.e. each 16x16 block in a CTU
|
||||
//will be searched for in a search window centered on this 16x16 block)
|
||||
|
||||
#define LOG2_MV_COMPARE_BASE_BLOCK_SIZE 2 //While comparing MVs of ASG and FEI CTUs, motion vectors will be compared
|
||||
//on basis of square blocks of this size
|
||||
|
||||
#define DELTA_PIXEL_BI_DIRECT 15 // Delta for bi-prediction test. This value will be used as difference between L0 and L1 references PUs
|
||||
#define SPLIT_LOG_TABLE_SYM_WIDTH 12 //Width of a table field in split testing partition size table output
|
||||
|
||||
//For repack ctrl
|
||||
#define HEVC_MAX_NUMPASSES 8 //Number of additional passes with delta QPs
|
||||
|
||||
std::string ConvertMfxStatusToString(mfxStatus sts);
|
||||
|
||||
enum REF_LIST_INDEX
|
||||
{
|
||||
L0 = 0,
|
||||
L1 = 1
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
inline T Clip3(const T valueToClip, const T low, const T high)
|
||||
{
|
||||
if (valueToClip < low)
|
||||
{
|
||||
return low;
|
||||
}
|
||||
else if (valueToClip > high)
|
||||
{
|
||||
return high;
|
||||
}
|
||||
|
||||
return valueToClip;
|
||||
}
|
||||
|
||||
// Inaccurate limits. For one directional limit is width*height <= 2000; for Bi-dir 1000
|
||||
const mfxU32 SKL_SW_LIM_OD[2] = { 48, 40 }; // One-directional Motion Estimation Search Window limit; 0 - width, 1 - height
|
||||
const mfxU32 SKL_SW_LIM_BD[2] = { 32, 32 }; // Bi-directional Motion Estimation Search Window limit; 0 - width, 1 - height
|
||||
|
||||
|
||||
struct PUMotionVector
|
||||
{
|
||||
PUMotionVector(mfxU8 refl0, mfxU8 refl1, mfxI16 MV1_x, mfxI16 MV1_y, mfxI16 MV2_x, mfxI16 MV2_y)
|
||||
{
|
||||
RefIdx = { refl0, refl1 };
|
||||
|
||||
MV[0] = { MV1_x, MV1_y };
|
||||
MV[1] = { MV2_x, MV2_y };
|
||||
}
|
||||
|
||||
PUMotionVector() : PUMotionVector(0, 0, 0, 0, 0, 0) {}
|
||||
|
||||
PUMotionVector(const PUMotionVector& vec) = default;
|
||||
PUMotionVector& operator= (const PUMotionVector& vec) = default;
|
||||
|
||||
bool CheckMVPExceedsSizeLimits() const
|
||||
{
|
||||
return (abs(MV[0].x) > MVMVP_SIZE_LIMIT || abs(MV[0].y) > MVMVP_SIZE_LIMIT
|
||||
|| abs(MV[1].x) > MVMVP_SIZE_LIMIT || abs(MV[1].y) > MVMVP_SIZE_LIMIT);
|
||||
}
|
||||
|
||||
bool operator==(const PUMotionVector& rhs) const
|
||||
{
|
||||
return (MV[0].x == rhs.MV[0].x &&
|
||||
MV[0].y == rhs.MV[0].y &&
|
||||
MV[1].x == rhs.MV[1].x &&
|
||||
MV[1].y == rhs.MV[1].y &&
|
||||
RefIdx.RefL0 == rhs.RefIdx.RefL0 &&
|
||||
RefIdx.RefL1 == rhs.RefIdx.RefL1);
|
||||
}
|
||||
|
||||
// Important: refIdx is not affected, i.e. inherited from this
|
||||
const PUMotionVector operator+ (const PUMotionVector& rhs) const
|
||||
{
|
||||
return PUMotionVector(RefIdx.RefL0 , RefIdx.RefL1 ,
|
||||
MV[0].x + rhs.MV[0].x, MV[0].y + rhs.MV[0].y,
|
||||
MV[1].x + rhs.MV[1].x, MV[1].y + rhs.MV[1].y);
|
||||
}
|
||||
|
||||
inline std::tuple<mfxI32, mfxI32, mfxU32> GetL0MVTuple() const
|
||||
{
|
||||
return std::make_tuple(MV[0].x, MV[0].y, (mfxU32) RefIdx.RefL0);
|
||||
}
|
||||
|
||||
inline std::tuple<mfxI32, mfxI32, mfxU32> GetL1MVTuple() const
|
||||
{
|
||||
return std::make_tuple(MV[1].x, MV[1].y, (mfxU32)RefIdx.RefL1);
|
||||
}
|
||||
|
||||
struct {
|
||||
mfxU8 RefL0 : 4;
|
||||
mfxU8 RefL1 : 4;
|
||||
} RefIdx;
|
||||
|
||||
mfxI16Pair MV[2]; /* index is 0 for L0 and 1 for L1 */
|
||||
};
|
||||
|
||||
struct Counters
|
||||
{
|
||||
//Mapping (width;height) to (total) partitioning blocks
|
||||
struct BlockSizeMapFEI : std::map<std::pair<mfxU32, mfxU32>, mfxU32>
|
||||
{
|
||||
inline void AddBlockTotal(mfxU32 width, mfxU32 height)
|
||||
{
|
||||
this->operator[](std::make_pair(width, height))++;
|
||||
}
|
||||
|
||||
inline mfxU32 GetTotalCount()
|
||||
{
|
||||
mfxU32 count = 0;
|
||||
for (auto& blockSizeRecord : *this)
|
||||
{
|
||||
count += blockSizeRecord.second;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
void PrintTable()
|
||||
{
|
||||
std::stringstream tmp;
|
||||
for (auto& blockSizeRecord : *this)
|
||||
{
|
||||
tmp.str("");
|
||||
tmp << blockSizeRecord.first.first << 'x' << blockSizeRecord.first.second;
|
||||
std::cout << std::setw(SPLIT_LOG_TABLE_SYM_WIDTH) << tmp.str();
|
||||
}
|
||||
std::cout << std::endl;
|
||||
for (auto& blockSizeRecord : *this)
|
||||
{
|
||||
std::cout << std::setw(SPLIT_LOG_TABLE_SYM_WIDTH) << blockSizeRecord.second;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
//Mapping (width;height) to (correct in FEI; total) partitioning blocks
|
||||
struct BlockSizeMapASG : std::map<std::pair<mfxU32, mfxU32>, std::pair<mfxU32, mfxU32>>
|
||||
{
|
||||
inline void AddBlockCorrect(mfxU32 width, mfxU32 height)
|
||||
{
|
||||
this->operator[](std::make_pair(width, height)).first++;
|
||||
}
|
||||
|
||||
inline void AddBlockTotal(mfxU32 width, mfxU32 height)
|
||||
{
|
||||
this->operator[](std::make_pair(width, height)).second++;
|
||||
}
|
||||
|
||||
inline mfxU32 GetCorrectCount()
|
||||
{
|
||||
mfxU32 count = 0;
|
||||
for (auto& blockSizeRecord : *this)
|
||||
{
|
||||
count += blockSizeRecord.second.first;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
inline mfxU32 GetTotalCount()
|
||||
{
|
||||
mfxU32 count = 0;
|
||||
for (auto& blockSizeRecord : *this)
|
||||
{
|
||||
count += blockSizeRecord.second.second;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
void PrintTable()
|
||||
{
|
||||
std::stringstream tmp;
|
||||
for (auto& blockSizeRecord : *this)
|
||||
{
|
||||
tmp.str("");
|
||||
tmp << blockSizeRecord.first.first << 'x' << blockSizeRecord.first.second;
|
||||
std::cout << std::setw(SPLIT_LOG_TABLE_SYM_WIDTH) << tmp.str();
|
||||
}
|
||||
std::cout << std::endl;
|
||||
for (auto& blockSizeRecord : *this)
|
||||
{
|
||||
tmp.str("");
|
||||
tmp << blockSizeRecord.second.first << '/' << blockSizeRecord.second.second;
|
||||
std::cout << std::setw(SPLIT_LOG_TABLE_SYM_WIDTH) << tmp.str();
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
BlockSizeMapASG m_testPUSizeMapASG;
|
||||
BlockSizeMapFEI m_testPUSizeMapFEI;
|
||||
|
||||
BlockSizeMapASG m_testCUSizeMapASG;
|
||||
BlockSizeMapFEI m_testCUSizeMapFEI;
|
||||
|
||||
mfxU32 m_testCTUs = 0;
|
||||
|
||||
// MV
|
||||
mfxU32 m_correctMVCmpBlocksL0 = 0;
|
||||
mfxU32 m_correctMVCmpBlocksL1 = 0;
|
||||
mfxU32 m_correctMVCmpBlocksBi = 0;
|
||||
|
||||
mfxU32 m_totalMVCmpBlocksL0 = 0;
|
||||
mfxU32 m_totalMVCmpBlocksL1 = 0;
|
||||
mfxU32 m_totalMVCmpBlocksBi = 0;
|
||||
|
||||
// Shouldn't affect test result
|
||||
mfxU32 m_correctMVCmpBlocksL0PerMVPIndex[MVP_PER_16x16_BLOCK] = { 0, 0, 0, 0 };
|
||||
mfxU32 m_correctMVCmpBlocksL1PerMVPIndex[MVP_PER_16x16_BLOCK] = { 0, 0, 0, 0 };
|
||||
mfxU32 m_correctMVCmpBlocksBiPerMVPIndex[MVP_PER_16x16_BLOCK] = { 0, 0, 0, 0 };
|
||||
|
||||
mfxU32 m_totalMVCmpBlocksL0PerMVPIndex[MVP_PER_16x16_BLOCK] = { 0, 0, 0 ,0 };
|
||||
mfxU32 m_totalMVCmpBlocksL1PerMVPIndex[MVP_PER_16x16_BLOCK] = { 0, 0, 0, 0 };
|
||||
mfxU32 m_totalMVCmpBlocksBiPerMVPIndex[MVP_PER_16x16_BLOCK] = { 0, 0, 0, 0 };
|
||||
|
||||
//Won't affect test result
|
||||
mfxU32 m_correctMVsL0FromBiMVCmpBlocks = 0;
|
||||
mfxU32 m_correctMVsL1FromBiMVCmpBlocks = 0;
|
||||
|
||||
mfxU32 m_correctRecords = 0;
|
||||
mfxU32 m_totalPics = 0;
|
||||
|
||||
//Splits
|
||||
mfxU32 m_correctCUs = 0;
|
||||
mfxU32 m_totalCUsASG = 0;
|
||||
mfxU32 m_totalCUsFEI = 0;
|
||||
|
||||
mfxU32 m_correctPUs = 0;
|
||||
mfxU32 m_totalPUsASG = 0;
|
||||
mfxU32 m_totalPUsFEI = 0;
|
||||
|
||||
//Counters for exact matches
|
||||
mfxU32 m_exactCTUs = 0;
|
||||
mfxU32 m_exactCUs = 0;
|
||||
mfxU32 m_exactPUs = 0;
|
||||
};
|
||||
|
||||
// Wrapper on extension buffers
|
||||
class ExtendedBuffer
|
||||
{
|
||||
public:
|
||||
|
||||
explicit ExtendedBuffer(mfxU32 id, mfxU32 pitch, mfxU32 height)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
// Fill buffer. Track dynamic memory with smart pointer
|
||||
|
||||
case MFX_EXTBUFF_HEVCFEI_ENC_MV_PRED:
|
||||
{
|
||||
memset(&m_mvPred, 0, sizeof(m_mvPred));
|
||||
|
||||
m_mvPred.Header.BufferId = MFX_EXTBUFF_HEVCFEI_ENC_MV_PRED;
|
||||
m_mvPred.Header.BufferSz = sizeof(m_mvPred);
|
||||
|
||||
mfxU64 data_size = pitch * height * sizeof(mfxFeiHevcEncMVPredictors);
|
||||
|
||||
m_data.reset(new mfxU8[data_size]);
|
||||
|
||||
m_mvPred.Data = reinterpret_cast<mfxFeiHevcEncMVPredictors*>(m_data.get());
|
||||
memset(m_mvPred.Data, 0, data_size);
|
||||
|
||||
m_mvPred.Pitch = pitch;
|
||||
m_mvPred.Height = height;
|
||||
break;
|
||||
}
|
||||
case MFX_EXTBUFF_HEVCFEI_PAK_CTU_REC:
|
||||
{
|
||||
memset(&m_pakCtuRecord, 0, sizeof(m_pakCtuRecord));
|
||||
|
||||
m_pakCtuRecord.Header.BufferId = MFX_EXTBUFF_HEVCFEI_PAK_CTU_REC;
|
||||
m_pakCtuRecord.Header.BufferSz = sizeof(m_pakCtuRecord);
|
||||
|
||||
mfxU64 data_size = pitch * height * sizeof(mfxFeiHevcPakCtuRecordV0);
|
||||
|
||||
m_data.reset(new mfxU8[data_size]);
|
||||
|
||||
m_pakCtuRecord.Data = reinterpret_cast<mfxFeiHevcPakCtuRecordV0*>(m_data.get());
|
||||
memset(m_pakCtuRecord.Data, 0, data_size);
|
||||
|
||||
m_pakCtuRecord.Pitch = pitch;
|
||||
m_pakCtuRecord.Height = height;
|
||||
|
||||
break;
|
||||
}
|
||||
case MFX_EXTBUFF_HEVCFEI_PAK_CU_REC:
|
||||
{
|
||||
memset(&m_pakCuRecord, 0, sizeof(m_pakCuRecord));
|
||||
|
||||
m_pakCuRecord.Header.BufferId = MFX_EXTBUFF_HEVCFEI_PAK_CU_REC;
|
||||
m_pakCuRecord.Header.BufferSz = sizeof(m_pakCuRecord);
|
||||
|
||||
mfxU64 data_size = pitch * height * sizeof(mfxFeiHevcPakCuRecordV0);
|
||||
m_data.reset(new mfxU8[data_size]);
|
||||
|
||||
m_pakCuRecord.Data = reinterpret_cast<mfxFeiHevcPakCuRecordV0*>(m_data.get());
|
||||
memset(m_pakCuRecord.Data, 0, data_size);
|
||||
|
||||
m_pakCuRecord.Pitch = pitch;
|
||||
m_pakCuRecord.Height = height;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hold this entry first in class
|
||||
union
|
||||
{
|
||||
mfxExtFeiHevcEncMVPredictors m_mvPred;
|
||||
mfxExtFeiHevcPakCtuRecordV0 m_pakCtuRecord;
|
||||
mfxExtFeiHevcPakCuRecordV0 m_pakCuRecord;
|
||||
};
|
||||
|
||||
std::unique_ptr<mfxU8[]> m_data;
|
||||
};
|
||||
|
||||
// Wrapper on mfxFrameSurface1
|
||||
class ExtendedSurface : public mfxFrameSurface1
|
||||
{
|
||||
public:
|
||||
//Flag to track whether the surface in the pool has been written to disk,
|
||||
//but not reused by another frame
|
||||
bool isWritten = false;
|
||||
mfxU32 encodedOrder = 0xffffffff;
|
||||
|
||||
ExtendedSurface() = default;
|
||||
ExtendedSurface(ExtendedSurface &&) = default;
|
||||
ExtendedSurface(const ExtendedSurface &) = delete;
|
||||
ExtendedSurface& operator= (const ExtendedSurface& vec) = delete;
|
||||
|
||||
// Fill info about current surface. Track dynamic memory by smart pointer
|
||||
void AllocData(mfxU32 width, mfxU32 height)
|
||||
{
|
||||
// Only I420 is supported for now
|
||||
|
||||
Info.FourCC = MFX_FOURCC_YV12;
|
||||
Info.ChromaFormat = MFX_CHROMAFORMAT_YUV420;
|
||||
Info.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
|
||||
|
||||
Info.Width = MSDK_ALIGN16(width);
|
||||
Info.Height = (MFX_PICSTRUCT_PROGRESSIVE == Info.PicStruct) ?
|
||||
MSDK_ALIGN16(height) : MSDK_ALIGN32(height);
|
||||
|
||||
Info.CropW = width;
|
||||
Info.CropH = height;
|
||||
|
||||
mfxU32 size = Info.CropH * Info.CropW * 3 / 2;
|
||||
pSurfData.reset(new mfxU8[size]);
|
||||
memset(pSurfData.get(), 0, size); //Zero-init
|
||||
|
||||
Data.Y = pSurfData.get();
|
||||
Data.U = Data.Y + Info.CropH * Info.CropW;
|
||||
Data.V = Data.U + Info.CropH * Info.CropW / 4;
|
||||
Data.Pitch = Info.CropW;
|
||||
}
|
||||
|
||||
// Attach buffer to surface
|
||||
//
|
||||
// Important: after this operation, original buffer is no longer valid. All further ownership is taken by surface
|
||||
void AttachBuffer(ExtendedBuffer & buffer)
|
||||
{
|
||||
|
||||
ExtBuffers.push_back(std::move(buffer)); // Dynamic memory is moved to new instance of ExtendedBuffer
|
||||
|
||||
// Headers of all buffers should be in same place in memory, because union is used
|
||||
vExtBuffersData.push_back(&ExtBuffers.back().m_mvPred.Header);
|
||||
|
||||
++Data.NumExtParam;
|
||||
Data.ExtParam = vExtBuffersData.data();
|
||||
}
|
||||
|
||||
// Get attached buffer by id
|
||||
mfxExtBuffer* GetBuffer(mfxU32 id)
|
||||
{
|
||||
auto it = find_if(vExtBuffersData.begin(), vExtBuffersData.end(),
|
||||
[&](mfxExtBuffer* buffer) { return buffer->BufferId == id; });
|
||||
|
||||
if (it == vExtBuffersData.end())
|
||||
throw std::string("ERROR: ExtendedSurface::GetBuffer: no buffer with id: ") + std::to_string(id);
|
||||
|
||||
return *it;
|
||||
}
|
||||
|
||||
|
||||
void ForceMVPBlockSizeInOutputBuffer(mfxU32 forcedBlockSize)
|
||||
{
|
||||
for (mfxU32 i = 0; i < Data.NumExtParam; ++i)
|
||||
{
|
||||
mfxExtBuffer* buffer = Data.ExtParam[i];
|
||||
if (buffer == nullptr)
|
||||
{
|
||||
throw std::string("ERROR: ForceMVPBlockSizeInOutputBuffer: null pointer reference");
|
||||
}
|
||||
if (buffer->BufferId == MFX_EXTBUFF_HEVCFEI_ENC_MV_PRED)
|
||||
{
|
||||
mfxExtFeiHevcEncMVPredictors* mvpBuff = reinterpret_cast<mfxExtFeiHevcEncMVPredictors*>(buffer);
|
||||
|
||||
for (mfxU32 i = 0; i < mvpBuff->Height * mvpBuff->Pitch; i++)
|
||||
{
|
||||
mvpBuff->Data[i].BlockSize = forcedBlockSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<mfxU8[]> pSurfData; // Surface pixels
|
||||
|
||||
std::list<ExtendedBuffer> ExtBuffers; // List of ext buffers
|
||||
std::vector<mfxExtBuffer*> vExtBuffersData; // Array of pointers
|
||||
};
|
||||
|
||||
// This class performs writing of ext buffers to appropriate file
|
||||
class BufferWriter
|
||||
{
|
||||
public:
|
||||
|
||||
// Start tracking of current buffer; fopen the file with file_name
|
||||
void AddBuffer(mfxU32 id, msdk_string fileName)
|
||||
{
|
||||
FILE* fp = NULL;
|
||||
|
||||
MSDK_FOPEN(fp, fileName.c_str(), MSDK_STRING("wb"));
|
||||
|
||||
if (!fp)
|
||||
throw std::string("ERROR: BufferWriter::AddBuffer : fopen_s failed");
|
||||
|
||||
m_bufferFileTable[id] = fp; //Add current file pointer to the map (buf ID->file)
|
||||
}
|
||||
|
||||
// Find buffer's file pointer in table by buffer id and write the content.
|
||||
void WriteBuffer(mfxExtBuffer* buffer)
|
||||
{
|
||||
FILE* fp;
|
||||
|
||||
if (m_bufferFileTable.find(buffer->BufferId) != m_bufferFileTable.end())
|
||||
{
|
||||
fp = m_bufferFileTable[buffer->BufferId];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::string("ERROR: BufferWriter::WriteBuffer : unknown buffer with id: ") + std::to_string(buffer->BufferId);
|
||||
}
|
||||
|
||||
switch (buffer->BufferId)
|
||||
{
|
||||
case MFX_EXTBUFF_HEVCFEI_ENC_MV_PRED:
|
||||
{
|
||||
mfxExtFeiHevcEncMVPredictors* mvpBuff = reinterpret_cast<mfxExtFeiHevcEncMVPredictors*>(buffer);
|
||||
|
||||
auto numWritten = fwrite(mvpBuff->Data, sizeof(mfxFeiHevcEncMVPredictors) * mvpBuff->Pitch * mvpBuff->Height, 1, fp);
|
||||
|
||||
if (numWritten != 1)
|
||||
throw std::string("ERROR: BufferWriter::WriteBuffer : fwrite failed");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw std::string("ERROR: BufferWriter::WriteBuffer : unknown buffer with id: ") + std::to_string(buffer->BufferId);
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Zero buffer's data
|
||||
void ResetBuffer(mfxExtBuffer* buffer)
|
||||
{
|
||||
switch (buffer->BufferId)
|
||||
{
|
||||
case MFX_EXTBUFF_HEVCFEI_ENC_MV_PRED:
|
||||
{
|
||||
mfxExtFeiHevcEncMVPredictors* mvpBuff = reinterpret_cast<mfxExtFeiHevcEncMVPredictors*>(buffer);
|
||||
memset(mvpBuff->Data, 0, sizeof(mfxFeiHevcEncMVPredictors) * mvpBuff->Pitch * mvpBuff->Height);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw std::string("ERROR: BufferWriter::ResetBuffer : unknown buffer with id: ") + std::to_string(buffer->BufferId);
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Close all file pointers
|
||||
~BufferWriter()
|
||||
{
|
||||
for (auto & fp : m_bufferFileTable)
|
||||
{
|
||||
fflush(fp.second);
|
||||
fclose(fp.second);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::map<mfxU32, FILE*> m_bufferFileTable; // map of id - file pointer
|
||||
};
|
||||
|
||||
// This class performs reading of ext buffers from appropriate file
|
||||
class BufferReader
|
||||
{
|
||||
public:
|
||||
|
||||
// Start tracking of current buffer; fopen the file with file_name
|
||||
void AddBuffer(mfxU32 id, msdk_string fileName)
|
||||
{
|
||||
FILE* fp = NULL;
|
||||
|
||||
MSDK_FOPEN(fp, fileName.c_str(), MSDK_STRING("rb"));
|
||||
|
||||
if (!fp)
|
||||
throw std::string("ERROR: BufferReader::AddBuffer : fopen_s failed");
|
||||
|
||||
m_bufferFileTable[id] = fp; //Add current file pointer to the map (buf ID->file)
|
||||
}
|
||||
|
||||
// Find buffer's file pointer in table by buffer id and write the content.
|
||||
void ReadBuffer(mfxExtBuffer* buffer) //Function for reading can read 1 CU structure per call
|
||||
{
|
||||
FILE* fp;
|
||||
|
||||
if (m_bufferFileTable.find(buffer->BufferId) != m_bufferFileTable.end())
|
||||
{
|
||||
fp = m_bufferFileTable[buffer->BufferId];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::string("ERROR: BufferReader::ReadBuffer : unknown buffer with id: ") + std::to_string(buffer->BufferId);
|
||||
}
|
||||
|
||||
switch (buffer->BufferId)
|
||||
{
|
||||
case MFX_EXTBUFF_HEVCFEI_PAK_CTU_REC:
|
||||
{
|
||||
mfxExtFeiHevcPakCtuRecordV0* pakCtuBuff = reinterpret_cast<mfxExtFeiHevcPakCtuRecordV0*>(buffer);
|
||||
|
||||
auto numRead = fread(pakCtuBuff->Data, sizeof(mfxFeiHevcPakCtuRecordV0) * pakCtuBuff->Pitch * pakCtuBuff->Height, 1, fp);
|
||||
|
||||
if (numRead != 1)
|
||||
throw std::string("ERROR: BufferReader::ReadBuffer : fread failed");
|
||||
}
|
||||
break;
|
||||
|
||||
case MFX_EXTBUFF_HEVCFEI_PAK_CU_REC:
|
||||
{
|
||||
mfxExtFeiHevcPakCuRecordV0* pakCuBuff = reinterpret_cast<mfxExtFeiHevcPakCuRecordV0*>(buffer);
|
||||
|
||||
auto numRead = fread(pakCuBuff->Data, sizeof(mfxFeiHevcPakCuRecordV0) * pakCuBuff->Pitch * pakCuBuff->Height, 1, fp);
|
||||
|
||||
if (numRead != 1)
|
||||
throw std::string("ERROR: BufferReader::ReadBuffer : fread failed");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw std::string("ERROR: BufferReader::ReadBuffer : unknown buffer with id: ") + std::to_string(buffer->BufferId);
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Close all file pointers
|
||||
~BufferReader()
|
||||
{
|
||||
for (auto & fp : m_bufferFileTable)
|
||||
{
|
||||
fflush(fp.second);
|
||||
fclose(fp.second);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::map<mfxU32, FILE*> m_bufferFileTable; // map of id - file pointer
|
||||
};
|
||||
|
||||
#endif // MFX_VERSION
|
||||
|
||||
#endif // __ASG_HEVC_UTILS_H__
|
|
@ -1,97 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef __VERIFIER_H__
|
||||
#define __VERIFIER_H__
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include "refcontrol.h"
|
||||
#include "test_processor.h"
|
||||
|
||||
class Verifier : public TestProcessor {
|
||||
public:
|
||||
explicit Verifier() {}
|
||||
|
||||
~Verifier() {};
|
||||
|
||||
// Verification mode
|
||||
void CheckStatistics(Thresholds thres);
|
||||
|
||||
private:
|
||||
struct MVCompareBlock : BaseBlock
|
||||
{
|
||||
bool predFlagL0 = false;
|
||||
bool predFlagL1 = false;
|
||||
bool bIsIntra = false;
|
||||
mfxI16 usedMVPIndex = -1;
|
||||
mfxI16 usedMVPPoolNo = -1;
|
||||
PUMotionVector MV;
|
||||
};
|
||||
|
||||
const mfxU32 MV_CMP_BLOCK_SIZE = (1 << LOG2_MV_COMPARE_BASE_BLOCK_SIZE);
|
||||
|
||||
std::list<std::string> m_errorMsgList;
|
||||
|
||||
void Init() override;
|
||||
|
||||
// Get surface
|
||||
ExtendedSurface* PrepareSurface() override;
|
||||
|
||||
// Save all data
|
||||
void DropFrames() override;
|
||||
virtual void SavePSData() override;
|
||||
|
||||
// Verification mode
|
||||
void VerifyDesc(FrameChangeDescriptor & frame_descr) override;
|
||||
void ExtractMVs(const CTUDescriptor& ctuDescr, std::vector<MVCompareBlock>& mvCmpBlocks);
|
||||
void CompareSplits(const CTUDescriptor& ctuDescrASG, const CTUDescriptor& ctuDescrFEI);
|
||||
|
||||
void CompareMVs(const CTUDescriptor& asgCTUDescriptor, const CTUDescriptor& feiCTUDescriptor);
|
||||
void CompareMVBlocks(const MVCompareBlock& asgMVCmpBlock, const MVCompareBlock& feiMVCmpBlock);
|
||||
void CalculateTotalMVCmpBlocksInCTU(std::vector<MVCompareBlock>& mvCmpBlocks);
|
||||
|
||||
void CountExactMatches(const CTUDescriptor& asgCTUDescriptor, const CTUDescriptor& feiCTUDescriptor);
|
||||
CTUDescriptor ConvertFeiOutInLocalStr(const mfxFeiHevcPakCtuRecordV0& ctuPakFromFEI, const ExtendedBuffer& tmpCuBuff, const mfxU32 startCuOffset);
|
||||
|
||||
void PrintPercentRatio(mfxU32 numerator, mfxU32 denominator);
|
||||
bool CheckLowerThreshold(mfxU32 numerator, mfxU32 denominator, mfxU32 threshold = 100);
|
||||
|
||||
void CheckMVs(Thresholds threshold);
|
||||
void CheckL0MVs(Thresholds threshold);
|
||||
void CheckL1MVs(Thresholds threshold);
|
||||
void CheckBiMVs(Thresholds threshold);
|
||||
|
||||
void CheckL0MVsPerMVPIndex(Thresholds threshold);
|
||||
void CheckL1MVsPerMVPIndex(Thresholds threshold);
|
||||
void CheckBiMVsPerMVPIndex(Thresholds threshold);
|
||||
|
||||
void CheckSplits(Thresholds threshold);
|
||||
void CheckPicStruct();
|
||||
|
||||
BufferReader m_BufferReader;
|
||||
Counters m_Counters;
|
||||
};
|
||||
|
||||
#endif // MFX_VERSION
|
||||
|
||||
#endif // __VERIFIER_H__
|
|
@ -1,94 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
|
||||
#include "inputparameters.h"
|
||||
#include "test_processor.h"
|
||||
#include "generator.h"
|
||||
#include "verifier.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
mfxI32 _tmain(mfxI32 argc, msdk_char *argv[])
|
||||
#else
|
||||
int main(int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
#if MFX_VERSION < MFX_VERSION_NEXT
|
||||
cout << "ERROR: For correct work minimal API MFX_VERSION_NEXT version is required" << endl;
|
||||
return -1;
|
||||
|
||||
#else
|
||||
try {
|
||||
InputParams params;
|
||||
|
||||
params.ParseInputString(argv, argc);
|
||||
if (params.m_bPrintHelp) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (params.m_ProcMode)
|
||||
{
|
||||
case GENERATE:
|
||||
{
|
||||
Generator generator;
|
||||
generator.RunTest(params);
|
||||
}
|
||||
break;
|
||||
|
||||
case VERIFY:
|
||||
{
|
||||
Verifier verifier;
|
||||
verifier.RunTest(params);
|
||||
|
||||
if (params.m_TestType == GENERATE_REPACK_CTRL)
|
||||
break;
|
||||
|
||||
verifier.CheckStatistics(params.m_Thresholds);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw std::string("ERROR: Undefined processing mode");
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (std::string& e) {
|
||||
cout << e << endl;
|
||||
return -1;
|
||||
}
|
||||
catch (int sts)
|
||||
{
|
||||
return sts;
|
||||
}
|
||||
catch (...) {
|
||||
cout << "ERROR: Unexpected exception triggered" << endl;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
#endif // MFX_VERSION
|
||||
}
|
|
@ -1,364 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include "block_structures.h"
|
||||
|
||||
void BaseBlock::GetChildBlock(std::vector<BaseBlock>& childrenBlocks) const
|
||||
{
|
||||
childrenBlocks.clear();
|
||||
childrenBlocks.reserve(4);
|
||||
|
||||
//sizes and positions
|
||||
mfxU32 childHeight = m_BHeight / 2;
|
||||
mfxU32 childWidth = m_BWidth / 2;
|
||||
for (mfxU32 i = 0; i < 4; i++)
|
||||
{
|
||||
childrenBlocks.emplace_back(m_AdrX + childWidth * (i % 2), m_AdrY + childHeight * (i / 2), childHeight, childWidth);
|
||||
}
|
||||
}
|
||||
|
||||
void BaseBlock::GetChildRefSampleInfo(const RefSampleAvail & currAvail, const BaseBlock & ctu, std::vector<RefSampleAvail>& childrenRefSampleAvail) const
|
||||
{
|
||||
childrenRefSampleAvail.clear();
|
||||
childrenRefSampleAvail.resize(4);
|
||||
|
||||
//is left down block available for children
|
||||
childrenRefSampleAvail[0].LeftDown = true;
|
||||
childrenRefSampleAvail[1].LeftDown = false;
|
||||
|
||||
if (m_AdrY + m_BHeight == ctu.m_AdrY + ctu.m_BHeight)
|
||||
{
|
||||
childrenRefSampleAvail[2].LeftDown = true;
|
||||
childrenRefSampleAvail[3].LeftDown = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
childrenRefSampleAvail[2].LeftDown = currAvail.LeftDown;
|
||||
childrenRefSampleAvail[3].LeftDown = false;
|
||||
}
|
||||
|
||||
//is up right block available for children
|
||||
childrenRefSampleAvail[0].UpRight = true;
|
||||
childrenRefSampleAvail[2].UpRight = true;
|
||||
|
||||
if (m_AdrX + m_BWidth == ctu.m_AdrX + ctu.m_BWidth)
|
||||
{
|
||||
childrenRefSampleAvail[1].UpRight = true;
|
||||
childrenRefSampleAvail[3].UpRight = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
childrenRefSampleAvail[1].UpRight = currAvail.UpRight;
|
||||
childrenRefSampleAvail[3].UpRight = false;
|
||||
}
|
||||
}
|
||||
|
||||
//This recursive function fills outVec with BaseBlocks, coordinates and sizes of which correspond to
|
||||
//the quad-tree structure specified by the quad-tree root node and the base size and coordinates of
|
||||
//the "root node "
|
||||
void QuadTree::GetQuadTreeBlocksRecur(QuadTreeNode & node, mfxU32 baseAdrX, mfxU32 baseAdrY, mfxU32 baseSize, std::vector<BaseBlock>& outVec)
|
||||
{
|
||||
if (!node.m_Children.empty())
|
||||
{
|
||||
for (mfxU32 i_y = 0; i_y < 2; i_y++)
|
||||
{
|
||||
for (mfxU32 i_x = 0; i_x < 2; i_x++)
|
||||
{
|
||||
QuadTreeNode& child = node.m_Children[2 * i_y + i_x];
|
||||
mfxU32 childSize = baseSize / 2;
|
||||
mfxU32 childAdrX = baseAdrX + i_x * childSize;
|
||||
mfxU32 childAdrY = baseAdrY + i_y * childSize;
|
||||
GetQuadTreeBlocksRecur(child, childAdrX, childAdrY, childSize, outVec);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
outVec.emplace_back(baseAdrX, baseAdrY, baseSize, baseSize);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void QuadTree::GetQuadTreeRefSampleAvailVector(QuadTreeNode & node, BaseBlock & currBlock, const BaseBlock & ctu, std::vector<RefSampleAvail>& outVec)
|
||||
{
|
||||
RefSampleAvail helper(true, true);
|
||||
GetQuadTreeRefSampleAvailVectorRecur(node, currBlock, helper, ctu, outVec);
|
||||
}
|
||||
|
||||
void QuadTree::GetQuadTreeRefSampleAvailVectorRecur(QuadTreeNode & node, BaseBlock & currBlock, const RefSampleAvail& currAvail, const BaseBlock & ctu, std::vector<RefSampleAvail>& outVec)
|
||||
{
|
||||
if (!node.m_Children.empty())
|
||||
{
|
||||
//children blocks, refSamples availability for children is counted here
|
||||
std::vector<BaseBlock> childrenBlocks;
|
||||
currBlock.GetChildBlock(childrenBlocks);
|
||||
std::vector<RefSampleAvail> childrenRefSamplesInfo;
|
||||
currBlock.GetChildRefSampleInfo(currAvail, ctu, childrenRefSamplesInfo);
|
||||
|
||||
//recursive call for children
|
||||
for (mfxU32 i = 0; i < 4; i++)
|
||||
{
|
||||
GetQuadTreeRefSampleAvailVectorRecur(node.m_Children[i], childrenBlocks[i], childrenRefSamplesInfo[i], ctu, outVec);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//put leaves into outVec in depth-first order
|
||||
outVec.emplace_back(currAvail);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
PatchBlock::PatchBlock(const PatchBlock & rhs) : PatchBlock(static_cast<BaseBlock>(rhs))
|
||||
{
|
||||
memcpy(PatchData.get(), rhs.PatchData.get(), sizeof(mfxU8) * m_BWidth * m_BHeight * 3 / 2);
|
||||
}
|
||||
|
||||
PatchBlock & PatchBlock::operator=(const PatchBlock & rhs)
|
||||
{
|
||||
BaseBlock::operator=(rhs);
|
||||
|
||||
mfxU32 sq = m_BWidth * m_BHeight;
|
||||
PatchData.reset(new mfxU8[sq * 3 / 2]);
|
||||
|
||||
memcpy(PatchData.get(), rhs.PatchData.get(), sizeof(mfxU8) * sq * 3 / 2);
|
||||
|
||||
m_YPlane = PatchData.get();
|
||||
m_UPlane = m_YPlane + sq;
|
||||
m_VPlane = m_UPlane + (sq / 4);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
PatchBlock::PatchBlock(const BaseBlock& BB) : BaseBlock(BB)
|
||||
{
|
||||
mfxU32 sq = m_BWidth * m_BHeight;
|
||||
PatchData.reset(new mfxU8[sq * 3 / 2]);
|
||||
m_YPlane = PatchData.get();
|
||||
m_UPlane = m_YPlane + sq;
|
||||
m_VPlane = m_UPlane + (sq / 4);
|
||||
|
||||
memset(m_YPlane, LUMA_DEFAULT, sq);
|
||||
memset(m_UPlane, CHROMA_DEFAULT, sq / 4);
|
||||
memset(m_VPlane, CHROMA_DEFAULT, sq / 4);
|
||||
}
|
||||
|
||||
//constructor that memsets PatchBlock with the particurlar sample
|
||||
PatchBlock::PatchBlock(const BaseBlock& BB, mfxU8 y_comp, mfxU8 u_comp, mfxU8 v_comp) : BaseBlock(BB)
|
||||
{
|
||||
mfxU32 sq = m_BWidth * m_BHeight;
|
||||
PatchData.reset(new mfxU8[sq * 3 / 2]);
|
||||
m_YPlane = PatchData.get();
|
||||
m_UPlane = m_YPlane + sq;
|
||||
m_VPlane = m_UPlane + (sq / 4);
|
||||
|
||||
memset(m_YPlane, y_comp, sq);
|
||||
memset(m_UPlane, u_comp, sq / 4);
|
||||
memset(m_VPlane, v_comp, sq / 4);
|
||||
}
|
||||
|
||||
//constructor that fills PatchBlock with coresponding data from the srcPatch
|
||||
PatchBlock::PatchBlock(const BaseBlock& dstBlock, const PatchBlock& srcBlock) : PatchBlock(dstBlock)
|
||||
{
|
||||
if (!dstBlock.IsInBlock(srcBlock))
|
||||
{
|
||||
throw std::string("ERROR: PatchBlock: new PatchBlock should be located inside the old one in frame coords");
|
||||
}
|
||||
|
||||
//Calculating the coords of dstBlock relative to srcBlock
|
||||
mfxU32 offsetX = dstBlock.m_AdrX - srcBlock.m_AdrX;
|
||||
mfxU32 offsetY = dstBlock.m_AdrY - srcBlock.m_AdrY;
|
||||
|
||||
for (mfxU32 i = 0; i < m_BHeight; i++)
|
||||
{
|
||||
memcpy(m_YPlane + i * m_BWidth, srcBlock.m_YPlane + (offsetY + i) * srcBlock.m_BWidth + offsetX, m_BWidth);
|
||||
}
|
||||
for (mfxU32 i = 0; i < m_BHeight / 2; i++)
|
||||
{
|
||||
memcpy(m_UPlane + i * (m_BWidth / 2), srcBlock.m_UPlane + (offsetY / 2 + i) * (srcBlock.m_BWidth / 2) + offsetX / 2, m_BWidth / 2);
|
||||
memcpy(m_VPlane + i * (m_BWidth / 2), srcBlock.m_VPlane + (offsetY / 2 + i) * (srcBlock.m_BWidth / 2) + offsetX / 2, m_BWidth / 2);
|
||||
}
|
||||
}
|
||||
|
||||
//constructor that filles PatchBlock with coresponding data from the surface
|
||||
PatchBlock::PatchBlock(const BaseBlock & BB, const ExtendedSurface & surf) : PatchBlock(BB)
|
||||
{
|
||||
if (!BB.IsInBlock(BaseBlock(0, 0, surf.Info.CropW, surf.Info.CropH)))
|
||||
{
|
||||
throw std::string("ERROR: PatchBlock: new patchBlock should be located inside the surface");
|
||||
}
|
||||
|
||||
for (mfxU32 i = 0; i < m_BHeight; i++)
|
||||
{
|
||||
memcpy(m_YPlane + i * m_BWidth, surf.Data.Y + (m_AdrY + i) * surf.Data.Pitch + m_AdrX, m_BWidth);
|
||||
}
|
||||
for (mfxU32 i = 0; i < m_BHeight / 2; i++)
|
||||
{
|
||||
memcpy(m_UPlane + i * (m_BWidth / 2), surf.Data.U + (m_AdrY / 2 + i) * (surf.Data.Pitch / 2) + m_AdrX / 2, m_BWidth / 2);
|
||||
memcpy(m_VPlane + i * (m_BWidth / 2), surf.Data.V + (m_AdrY / 2 + i) * (surf.Data.Pitch / 2) + m_AdrX / 2, m_BWidth / 2);
|
||||
}
|
||||
}
|
||||
|
||||
//distance between current PatchBlock and other_patch counted as a sum of abs differences between luma components over all samples
|
||||
mfxU32 PatchBlock::CalcYSAD(const PatchBlock & otherPatch) const
|
||||
{
|
||||
mfxU32 curDiff = 0;
|
||||
if (m_BHeight == otherPatch.m_BHeight && m_BWidth == otherPatch.m_BWidth)
|
||||
{
|
||||
for (mfxU32 i = 0; i < m_BHeight*m_BWidth; i++)
|
||||
{
|
||||
curDiff += abs(m_YPlane[i] - otherPatch.m_YPlane[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::string("ERROR: CalcYSAD: block size mismatch");
|
||||
}
|
||||
return curDiff;
|
||||
}
|
||||
|
||||
//compAdrX and compAdrY are given in the comp color space
|
||||
mfxU8 PatchBlock::GetSampleI420(COLOR_COMPONENT comp, mfxU32 compAdrX, mfxU32 compAdrY) const
|
||||
{
|
||||
switch (comp)
|
||||
{
|
||||
case LUMA_Y:
|
||||
return m_YPlane[compAdrY * m_BWidth + compAdrX];
|
||||
case CHROMA_U:
|
||||
return m_UPlane[compAdrY * (m_BWidth / 2) + compAdrX];
|
||||
case CHROMA_V:
|
||||
return m_VPlane[compAdrY * (m_BWidth / 2) + compAdrX];
|
||||
default:
|
||||
throw std::string("ERROR: Trying to get unspecified component");
|
||||
}
|
||||
}
|
||||
|
||||
//Inserts refPatch into this PatchBlock, if refPatch is located inside this PatchBlock
|
||||
void PatchBlock::InsertAnotherPatch(const PatchBlock & refPatch)
|
||||
{
|
||||
if (!refPatch.IsInBlock(*this))
|
||||
{
|
||||
throw std::string("ERROR: InsertAnotherPatch: refPatch should be inside targetPatch\n");
|
||||
}
|
||||
|
||||
//Calculating coordinate offset of refPatch relative to this PatchBlock
|
||||
mfxU32 offsetX = refPatch.m_AdrX - m_AdrX;
|
||||
mfxU32 offsetY = refPatch.m_AdrY - m_AdrY;
|
||||
|
||||
//luma
|
||||
for (mfxU32 i = 0; i < refPatch.m_BHeight; i++)
|
||||
{
|
||||
memcpy(m_YPlane + (offsetY + i) * m_BWidth + offsetX, refPatch.m_YPlane + i * refPatch.m_BWidth, refPatch.m_BWidth);
|
||||
}
|
||||
//chroma U, V
|
||||
for (mfxU32 i = 0; i < refPatch.m_BHeight / 2; ++i)
|
||||
{
|
||||
memcpy(m_UPlane + (offsetY / 2 + i) * m_BWidth / 2 + offsetX / 2, refPatch.m_UPlane + i * (refPatch.m_BWidth / 2), refPatch.m_BWidth / 2);
|
||||
memcpy(m_VPlane + (offsetY / 2 + i) * m_BWidth / 2 + offsetX / 2, refPatch.m_VPlane + i * (refPatch.m_BWidth / 2), refPatch.m_BWidth / 2);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//Returns a BaseBlock with coordinates that are shifted by the m_MV motion vector
|
||||
//from the corresponding list relative to the current PU position
|
||||
BaseBlock PUBlock::GetShiftedBaseBlock(REF_LIST_INDEX list) const
|
||||
{
|
||||
mfxI64 posX = (mfxI64) m_AdrX + (m_MV.MV[list].x >> 2);
|
||||
mfxI64 posY = (mfxI64) m_AdrY + (m_MV.MV[list].y >> 2);
|
||||
|
||||
if (posX < 0 && posY < 0)
|
||||
{
|
||||
throw std::string("ERROR: GetShiftedBaseBlock: negative resulting block coords");
|
||||
}
|
||||
|
||||
return BaseBlock((mfxU32) posX, (mfxU32) posY, m_BWidth, m_BHeight);
|
||||
}
|
||||
|
||||
void CUBlock::BuildPUsVector(INTER_PART_MODE mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case INTER_2NxN:
|
||||
// UP PU
|
||||
m_PUVec.emplace_back(PUBlock(m_AdrX, m_AdrY, m_BWidth, m_BHeight / 2));
|
||||
// DOWN PU
|
||||
m_PUVec.emplace_back(PUBlock(m_AdrX, m_AdrY + m_BHeight / 2, m_BWidth, m_BHeight / 2));
|
||||
break;
|
||||
|
||||
case INTER_Nx2N:
|
||||
// LEFT PU
|
||||
m_PUVec.emplace_back(PUBlock(m_AdrX, m_AdrY, m_BWidth / 2, m_BHeight));
|
||||
// RIGHT PU
|
||||
m_PUVec.emplace_back(PUBlock(m_AdrX + m_BWidth / 2, m_AdrY, m_BWidth / 2, m_BHeight));
|
||||
break;
|
||||
|
||||
case INTER_NxN:
|
||||
// TOP LEFT PU
|
||||
m_PUVec.emplace_back(PUBlock(m_AdrX, m_AdrY, m_BWidth / 2, m_BHeight / 2));
|
||||
// TOP RIGHT PU
|
||||
m_PUVec.emplace_back(PUBlock(m_AdrX + m_BWidth / 2, m_AdrY, m_BWidth / 2, m_BHeight / 2));
|
||||
// BOT LEFT PU
|
||||
m_PUVec.emplace_back(PUBlock(m_AdrX, m_AdrY + m_BHeight / 2, m_BWidth / 2, m_BHeight / 2));
|
||||
// BOT RIGHT PU
|
||||
m_PUVec.emplace_back(PUBlock(m_AdrX + m_BWidth / 2, m_AdrY + m_BHeight / 2, m_BWidth / 2, m_BHeight / 2));
|
||||
break;
|
||||
|
||||
case INTER_2NxnU:
|
||||
// UP SMALL PU
|
||||
m_PUVec.emplace_back(PUBlock(m_AdrX, m_AdrY, m_BWidth, m_BHeight / 4));
|
||||
// DOWN LARGE PU
|
||||
m_PUVec.emplace_back(PUBlock(m_AdrX, m_AdrY + m_BHeight / 4, m_BWidth, (m_BHeight * 3) / 4));
|
||||
break;
|
||||
|
||||
case INTER_2NxnD:
|
||||
// UP LARGE PU
|
||||
m_PUVec.emplace_back(PUBlock(m_AdrX, m_AdrY, m_BWidth, (m_BHeight * 3) / 4));
|
||||
// DOWN SMALL PU
|
||||
m_PUVec.emplace_back(PUBlock(m_AdrX, m_AdrY + (m_BHeight * 3) / 4, m_BWidth, m_BHeight / 4));
|
||||
break;
|
||||
|
||||
case INTER_nLx2N:
|
||||
// LEFT SMALL PU
|
||||
m_PUVec.emplace_back(PUBlock(m_AdrX, m_AdrY, m_BWidth / 4, m_BHeight));
|
||||
// RIGHT LARGE PU
|
||||
m_PUVec.emplace_back(PUBlock(m_AdrX + m_BWidth / 4, m_AdrY, (m_BWidth * 3) / 4, m_BHeight));
|
||||
break;
|
||||
|
||||
case INTER_nRx2N:
|
||||
// LEFT LARGE PU
|
||||
m_PUVec.emplace_back(PUBlock(m_AdrX, m_AdrY, (m_BWidth * 3) / 4, m_BHeight));
|
||||
// RIGHT SMALL PU
|
||||
m_PUVec.emplace_back(PUBlock(m_AdrX + (m_BWidth * 3) / 4, m_AdrY, m_BWidth / 4, m_BHeight));
|
||||
break;
|
||||
|
||||
case INTER_2Nx2N:
|
||||
default:
|
||||
m_PUVec.emplace_back(PUBlock(m_AdrX, m_AdrY, m_BWidth, m_BHeight));
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#endif // MFX_VERSION
|
|
@ -1,191 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include "frame_marker.h"
|
||||
#include "frame_reorder.h"
|
||||
|
||||
void FrameMarker::PreProcessStreamConfig(InputParams & params)
|
||||
{
|
||||
try
|
||||
{
|
||||
BuildRefLists(params);
|
||||
TagFrames(params);
|
||||
|
||||
params.m_vProcessingParams = m_vProcessingParams;
|
||||
}
|
||||
catch (std::string & e) {
|
||||
std::cout << e << std::endl;
|
||||
throw std::string("ERROR: FrameMarker::PreProcessStreamConfig");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void FrameMarker::BuildRefLists(const InputParams & params)
|
||||
{
|
||||
// Parameters for reordering
|
||||
m_vProcessingParams.resize(params.m_numFrames);
|
||||
|
||||
FrameReorder reorder(params);
|
||||
|
||||
mfxVideoParam param = {};
|
||||
param.mfx.GopOptFlag = params.m_GopOptFlag;
|
||||
param.mfx.GopPicSize = params.m_GopSize;
|
||||
param.mfx.GopRefDist = params.m_RefDist;
|
||||
param.mfx.IdrInterval = params.m_nIdrInterval;
|
||||
param.mfx.FrameInfo.PicStruct = params.m_PicStruct;
|
||||
|
||||
// Construction of the frame with correct lists
|
||||
// Reference list creating
|
||||
mfxU32 idxEncoded = 0;
|
||||
for (mfxU32 idxFrame = 0; idxFrame < params.m_numFrames; ++idxFrame)
|
||||
{
|
||||
ExternalFrame f = reorder.CreateExternalFrame(idxFrame, param);
|
||||
if (f.Poc != -1)
|
||||
{
|
||||
m_vProcessingParams.at(f.DisplayOrder) = f;
|
||||
m_vProcessingParams.at(f.DisplayOrder).EncodedOrder = idxEncoded;
|
||||
++idxEncoded;
|
||||
}
|
||||
}
|
||||
// Drain buffered frames
|
||||
while (reorder.GetBufferedQueueSize() != 0)
|
||||
{
|
||||
ExternalFrame f = reorder.CreateExternalFrame(-1, param);
|
||||
m_vProcessingParams.at(f.DisplayOrder) = f;
|
||||
m_vProcessingParams.at(f.DisplayOrder).EncodedOrder = idxEncoded;
|
||||
++idxEncoded;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void FrameMarker::TagFrames(const InputParams & params)
|
||||
{
|
||||
mfxVideoParam param = {};
|
||||
param.mfx.GopOptFlag = params.m_GopOptFlag;
|
||||
param.mfx.GopPicSize = params.m_GopSize;
|
||||
param.mfx.GopRefDist = params.m_RefDist;
|
||||
param.mfx.IdrInterval = params.m_nIdrInterval;
|
||||
param.mfx.FrameInfo.PicStruct = params.m_PicStruct;
|
||||
|
||||
std::vector<mfxU32> refFramesL0;
|
||||
std::vector<mfxU32> refFramesL1;
|
||||
refFramesL0.reserve(std::max(params.m_NumRefActiveP, params.m_NumRefActiveBL0));
|
||||
refFramesL1.reserve(params.m_NumRefActiveBL1);
|
||||
|
||||
mfxU32 num_gen = 0, num_mod = 0;
|
||||
|
||||
if (GenerateInterMBs(params.m_TestType))
|
||||
{
|
||||
// Current test requires P/B frames
|
||||
|
||||
// Creating of the processing parameters for each frame
|
||||
// It contains mark of the frame, reference frames for MOD frames (test frame)
|
||||
// For frames with mark GEN or SKIP reference frames are empty
|
||||
for (mfxU32 idxFrame = 0; idxFrame < params.m_numFrames; ++idxFrame)
|
||||
{
|
||||
// Clear references
|
||||
refFramesL0.clear();
|
||||
refFramesL1.clear();
|
||||
|
||||
// Marker shouldn't set P-frames as MOD in presets with B-frames
|
||||
if ((m_vProcessingParams.at(idxFrame).Type & MFX_FRAMETYPE_P) && !HasBFramesInGOP(params.m_RefDist))
|
||||
{
|
||||
// We need to check number of available reference and their status
|
||||
// If they already are MOD or GEN we won't use them
|
||||
if (m_vProcessingParams.at(idxFrame).ListX[0].size() == params.m_NumRefActiveP && !HasAlreadyUsedRefs(idxFrame, 0))
|
||||
{
|
||||
SetRefList(idxFrame, 0, refFramesL0, num_gen);
|
||||
m_vProcessingParams.at(idxFrame).ReferencesL0 = refFramesL0;
|
||||
if (params.m_UseGPB)
|
||||
{
|
||||
SetRefList(idxFrame, 1, refFramesL1, num_gen);
|
||||
m_vProcessingParams.at(idxFrame).ReferencesL1 = refFramesL1;
|
||||
}
|
||||
|
||||
m_vProcessingParams.at(idxFrame).Mark = MOD;
|
||||
++num_mod;
|
||||
}
|
||||
}
|
||||
else if (m_vProcessingParams.at(idxFrame).Type & MFX_FRAMETYPE_B)
|
||||
{
|
||||
// We need to check number of available reference and their status
|
||||
// If they already are MOD or GEN we won't use them
|
||||
if ((m_vProcessingParams.at(idxFrame).ListX[0].size() == params.m_NumRefActiveBL0 && !HasAlreadyUsedRefs(idxFrame, 0))
|
||||
&& (m_vProcessingParams.at(idxFrame).ListX[1].size() == params.m_NumRefActiveBL1 && !HasAlreadyUsedRefs(idxFrame, 1)))
|
||||
{
|
||||
SetRefList(idxFrame, 0, refFramesL0, num_gen);
|
||||
SetRefList(idxFrame, 1, refFramesL1, num_gen);
|
||||
m_vProcessingParams.at(idxFrame).ReferencesL0 = refFramesL0;
|
||||
m_vProcessingParams.at(idxFrame).ReferencesL1 = refFramesL1;
|
||||
m_vProcessingParams.at(idxFrame).Mark = MOD;
|
||||
++num_mod;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Intra test only
|
||||
for (mfxU32 idxFrame = 0; idxFrame < params.m_numFrames; ++idxFrame)
|
||||
{
|
||||
m_vProcessingParams.at(idxFrame).Mark = MOD;
|
||||
++num_mod;
|
||||
}
|
||||
}
|
||||
|
||||
// Check that preset is valid, i.e. at least test_frames_percent_min frames are utilized for testing
|
||||
const mfxU32 test_frames_percent_min = 15;
|
||||
|
||||
mfxU32 test_frames_percent = 100 * (num_gen + num_mod) / params.m_numFrames;
|
||||
|
||||
if (test_frames_percent < test_frames_percent_min)
|
||||
throw std::string("ERROR: FrameMaker::CreateProcessingParams: Current preset involves too few frames");
|
||||
}
|
||||
|
||||
bool FrameMarker::HasAlreadyUsedRefs(mfxU32 frame, mfxU8 list)
|
||||
{
|
||||
for (mfxU32 idxRefLX = 0; idxRefLX < m_vProcessingParams.at(frame).ListX[list].size(); ++idxRefLX)
|
||||
{
|
||||
if (m_vProcessingParams.at(m_vProcessingParams.at(frame).ListX[list][idxRefLX].DisplayOrder).Mark != SKIP)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void FrameMarker::SetRefList(mfxU32 frame, mfxU8 list, std::vector<mfxU32> & refFrames, mfxU32 & num_gen)
|
||||
{
|
||||
for (mfxU32 idxRefLX = 0; idxRefLX < m_vProcessingParams.at(frame).ListX[list].size(); ++idxRefLX)
|
||||
{
|
||||
mfxU32 idxFrameLX = m_vProcessingParams.at(frame).ListX[list].at(idxRefLX).DisplayOrder;
|
||||
refFrames.push_back(idxFrameLX);
|
||||
m_vProcessingParams.at(idxFrameLX).Mark = GEN;
|
||||
++num_gen;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#endif // MFX_VERSION
|
File diff suppressed because it is too large
Load diff
|
@ -1,465 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include "frame_reorder.h"
|
||||
|
||||
mfxI32 GetFrameNum(bool bField, mfxI32 Poc, bool bSecondField)
|
||||
{
|
||||
return bField ? (Poc + (!bSecondField)) / 2 : Poc;
|
||||
}
|
||||
|
||||
mfxU8 GetFrameType(
|
||||
mfxVideoParam const & video,
|
||||
mfxU32 pictureOrder, // Picture order after last IDR
|
||||
bool isPictureOfLastFrame)
|
||||
{
|
||||
mfxU32 gopOptFlag = video.mfx.GopOptFlag;
|
||||
mfxU32 gopPicSize = video.mfx.GopPicSize;
|
||||
mfxU32 gopRefDist = video.mfx.GopRefDist;
|
||||
mfxU32 idrPicDist = gopPicSize * (video.mfx.IdrInterval);
|
||||
|
||||
if (gopPicSize == 0xffff)
|
||||
idrPicDist = gopPicSize = 0xffffffff;
|
||||
|
||||
bool bFields = !!(video.mfx.FrameInfo.PicStruct & MFX_PICSTRUCT_FIELD_SINGLE);
|
||||
|
||||
mfxU32 frameOrder = bFields ? pictureOrder / 2 : pictureOrder;
|
||||
|
||||
bool bSecondField = bFields && (pictureOrder & 1);
|
||||
bool bIdr = (idrPicDist ? frameOrder % idrPicDist : frameOrder) == 0;
|
||||
|
||||
if (bIdr)
|
||||
return bSecondField ? (MFX_FRAMETYPE_P | MFX_FRAMETYPE_REF) : (MFX_FRAMETYPE_I | MFX_FRAMETYPE_REF | MFX_FRAMETYPE_IDR);
|
||||
|
||||
if (frameOrder % gopPicSize == 0)
|
||||
return (mfxU8)(bSecondField ? MFX_FRAMETYPE_P : MFX_FRAMETYPE_I) | MFX_FRAMETYPE_REF;
|
||||
|
||||
if (frameOrder % gopPicSize % gopRefDist == 0)
|
||||
return (MFX_FRAMETYPE_P | MFX_FRAMETYPE_REF);
|
||||
|
||||
if ((gopOptFlag & MFX_GOP_STRICT) == 0)
|
||||
{
|
||||
if (((frameOrder + 1) % gopPicSize == 0 && (gopOptFlag & MFX_GOP_CLOSED)) ||
|
||||
(idrPicDist && (frameOrder + 1) % idrPicDist == 0) ||
|
||||
isPictureOfLastFrame)
|
||||
{
|
||||
return (MFX_FRAMETYPE_P | MFX_FRAMETYPE_REF);
|
||||
}
|
||||
}
|
||||
|
||||
return MFX_FRAMETYPE_B;
|
||||
}
|
||||
|
||||
ExternalFrame FrameReorder::CreateExternalFrame(mfxI32 order, const mfxVideoParam& param)
|
||||
{
|
||||
mfxI32 poc = -1;
|
||||
ExternalFrame out = { 0xffffffff, 0, 0, poc, false, false };
|
||||
FrameIterator itOut = m_queue.end();
|
||||
|
||||
bool bIsFieldCoding = !!(param.mfx.FrameInfo.PicStruct & MFX_PICSTRUCT_FIELD_SINGLE);
|
||||
|
||||
//=================1. Get type, poc, put frame in the queue=====================
|
||||
|
||||
if (order >= 0)
|
||||
{
|
||||
|
||||
bool isPictureOfLastFrameInGOP = ((mfxU32)order >> (mfxU32)bIsFieldCoding) == ((m_nMaxFrames - 1) >> (mfxU32)bIsFieldCoding); // EOS
|
||||
|
||||
Frame frame;
|
||||
|
||||
frame.DisplayOrder = (mfxU32)order;
|
||||
|
||||
frame.Type = GetFrameType(param, order - m_lastIdr, isPictureOfLastFrameInGOP); // If we will use IDR not only for first field
|
||||
// We need to change this logic
|
||||
|
||||
if(frame.Type & MFX_FRAMETYPE_IDR && (order & 1))
|
||||
throw std::string("ERROR: FrameReorder::CreateExternalFrame: Idr isn't first field");
|
||||
|
||||
if (frame.Type & MFX_FRAMETYPE_IDR)
|
||||
m_lastIdr = order;
|
||||
|
||||
frame.Poc = order - m_lastIdr;
|
||||
frame.bSecondField = bIsFieldCoding && (order & 1);
|
||||
frame.bBottomField = false;
|
||||
if (bIsFieldCoding)
|
||||
{
|
||||
frame.bBottomField = isBFF(param) != frame.bSecondField;
|
||||
}
|
||||
|
||||
if (frame.Type & MFX_FRAMETYPE_I)
|
||||
{
|
||||
m_anchorPOC = frame.Poc;
|
||||
}
|
||||
|
||||
m_queue.emplace_back(frame);
|
||||
}
|
||||
|
||||
//=================2. Reorder frames, fill output frame poc, type, etc=====================
|
||||
itOut = Reorder(order < 0, bIsFieldCoding);
|
||||
if (itOut == m_queue.end())
|
||||
return out;
|
||||
|
||||
out.DisplayOrder = itOut->DisplayOrder;
|
||||
|
||||
bool isIdr = !!(itOut->Type & MFX_FRAMETYPE_IDR);
|
||||
bool isRef = !!(itOut->Type & MFX_FRAMETYPE_REF);
|
||||
bool isI = !!(itOut->Type & MFX_FRAMETYPE_I);
|
||||
bool isB = !!(itOut->Type & MFX_FRAMETYPE_B);
|
||||
|
||||
itOut->LastRAP = m_lastFrame.LastRAP;
|
||||
|
||||
if (isI)
|
||||
{
|
||||
itOut->IPoc = itOut->Poc;
|
||||
itOut->PrevIPoc = m_lastFrame.IPoc;
|
||||
itOut->NextIPoc = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (itOut->Poc >= m_lastFrame.IPoc)
|
||||
{
|
||||
itOut->IPoc = m_lastFrame.IPoc;
|
||||
itOut->PrevIPoc = m_lastFrame.PrevIPoc;
|
||||
itOut->NextIPoc = m_lastFrame.NextIPoc;
|
||||
}
|
||||
else
|
||||
{
|
||||
itOut->IPoc = m_lastFrame.PrevIPoc;
|
||||
itOut->PrevIPoc = -1;
|
||||
itOut->NextIPoc = m_lastFrame.IPoc;
|
||||
}
|
||||
}
|
||||
|
||||
out.Poc = itOut->Poc;
|
||||
out.Type = itOut->Type;
|
||||
out.bSecondField = itOut->bSecondField;
|
||||
out.bBottomField = itOut->bBottomField;
|
||||
|
||||
//=================3. Update DPB=====================
|
||||
if (isIdr)
|
||||
m_dpb.clear();
|
||||
|
||||
if (itOut->Poc > itOut->LastRAP &&
|
||||
m_lastFrame.Poc <= m_lastFrame.LastRAP)
|
||||
{
|
||||
const mfxI32 & lastRAP = itOut->LastRAP;
|
||||
// On the 1st TRAIL remove all except IRAP
|
||||
m_dpb.erase(std::remove_if(m_dpb.begin(), m_dpb.end(),
|
||||
[&lastRAP](Frame const & entry) { return entry.Poc != lastRAP; }),
|
||||
m_dpb.end());
|
||||
}
|
||||
|
||||
//=================4. Construct RPL=====================
|
||||
std::sort(m_dpb.begin(), m_dpb.end(), [](const Frame & lhs_frame, const Frame & rhs_frame)
|
||||
{
|
||||
return lhs_frame.Poc < rhs_frame.Poc;
|
||||
});
|
||||
|
||||
std::vector<Frame> & L0 = out.ListX[0];
|
||||
std::vector<Frame> & L1 = out.ListX[1];
|
||||
|
||||
L0.clear();
|
||||
L1.clear();
|
||||
|
||||
if (!isI)
|
||||
{
|
||||
// Fill L0/L1
|
||||
for (auto it = m_dpb.begin(); it != m_dpb.end(); it++)
|
||||
{
|
||||
bool list = it->Poc > out.Poc;
|
||||
out.ListX[list].push_back(*it);
|
||||
}
|
||||
|
||||
auto preferSamePolarity = [&out](const Frame & lhs_frame, const Frame & rhs_frame)
|
||||
{
|
||||
mfxI32 currFrameNum = GetFrameNum(true, out.Poc, out.bSecondField);
|
||||
|
||||
mfxU32 lhs_distance = std::abs(GetFrameNum(true, lhs_frame.Poc, lhs_frame.bSecondField) - currFrameNum) * 2 + ((lhs_frame.bBottomField == out.bBottomField) ? 0 : 1);
|
||||
|
||||
mfxU32 rhs_distance = std::abs(GetFrameNum(true, rhs_frame.Poc, rhs_frame.bSecondField) - currFrameNum) * 2 + ((rhs_frame.bBottomField == out.bBottomField) ? 0 : 1);
|
||||
|
||||
return lhs_distance <= rhs_distance;
|
||||
};
|
||||
|
||||
auto distance = [&out](const Frame & lhs_frame, const Frame & rhs_frame)
|
||||
{
|
||||
mfxU32 lhs_distance = std::abs(lhs_frame.Poc - out.Poc);
|
||||
mfxU32 rhs_distance = std::abs(rhs_frame.Poc - out.Poc);
|
||||
|
||||
return lhs_distance < rhs_distance;
|
||||
};
|
||||
|
||||
if (bIsFieldCoding)
|
||||
{
|
||||
std::sort(L0.begin(), L0.end(), preferSamePolarity);
|
||||
std::sort(L1.begin(), L1.end(), preferSamePolarity);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::sort(L0.begin(), L0.end(), distance);
|
||||
std::sort(L1.begin(), L1.end(), distance);
|
||||
}
|
||||
|
||||
if ((param.mfx.GopOptFlag & MFX_GOP_CLOSED))
|
||||
{
|
||||
const mfxI32 & IPoc = itOut->IPoc;
|
||||
{
|
||||
// Remove L0 refs beyond GOP
|
||||
L0.erase(std::remove_if(L0.begin(), L0.end(),
|
||||
[&IPoc](const Frame & frame) { return frame.Poc < IPoc; }),
|
||||
L0.end());
|
||||
}
|
||||
|
||||
const mfxI32 & nextIPoc = itOut->NextIPoc;
|
||||
if (nextIPoc != -1)
|
||||
{
|
||||
// Remove L1 refs beyond GOP
|
||||
L1.erase(std::remove_if(L1.begin(), L1.end(),
|
||||
[&nextIPoc](const Frame & frame) { return frame.Poc >= nextIPoc; }),
|
||||
L1.end());
|
||||
}
|
||||
}
|
||||
|
||||
// if B's L1 is zero (e.g. in case of closed gop)
|
||||
if (isB && !L1.size() && L0.size())
|
||||
L1.push_back(L0[0]);
|
||||
|
||||
if (!isB && m_UseGPB)
|
||||
{
|
||||
L1 = L0;
|
||||
std::sort(L1.begin(), L1.end(), distance);
|
||||
}
|
||||
|
||||
// Remove extra entries
|
||||
if (L0.size() > (isB ? m_NumRefActiveBL0 : m_NumRefActiveP))
|
||||
L0.resize(isB ? m_NumRefActiveBL0 : m_NumRefActiveP);
|
||||
|
||||
if (L1.size() > m_NumRefActiveBL1)
|
||||
L1.resize(m_NumRefActiveBL1);
|
||||
|
||||
std::sort(L0.begin(), L0.end(), distance);
|
||||
std::sort(L1.begin(), L1.end(), distance);
|
||||
}
|
||||
|
||||
//=================5. Save current frame in DPB=====================
|
||||
if (isRef)
|
||||
{
|
||||
if (m_dpb.size() == m_NumRef)
|
||||
{
|
||||
auto toRemove = m_dpb.begin();
|
||||
|
||||
m_dpb.erase(toRemove);
|
||||
}
|
||||
m_dpb.push_back(*itOut);
|
||||
}
|
||||
|
||||
itOut->NalType = GetNALUType(*itOut, !bIsFieldCoding);
|
||||
|
||||
if (itOut->NalType == CRA_NUT || itOut->NalType == IDR_W_RADL)
|
||||
itOut->LastRAP = itOut->Poc;
|
||||
|
||||
m_lastFrame = *itOut;
|
||||
|
||||
m_queue.erase(itOut);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
mfxU8 FrameReorder::GetNALUType(Frame const & frame, bool isRAPIntra)
|
||||
{
|
||||
const bool isI = !!(frame.Type & MFX_FRAMETYPE_I);
|
||||
const bool isRef = !!(frame.Type & MFX_FRAMETYPE_REF);
|
||||
const bool isIDR = !!(frame.Type & MFX_FRAMETYPE_IDR);
|
||||
|
||||
if (isIDR)
|
||||
return IDR_W_RADL;
|
||||
|
||||
if (isI && isRAPIntra)
|
||||
{
|
||||
return CRA_NUT;
|
||||
}
|
||||
|
||||
if (frame.Poc > frame.LastRAP)
|
||||
{
|
||||
return isRef ? TRAIL_R : TRAIL_N;
|
||||
}
|
||||
|
||||
if (isRef)
|
||||
return RASL_R;
|
||||
return RASL_N;
|
||||
}
|
||||
|
||||
bool FrameReorder::HasL1(mfxI32 poc)
|
||||
{
|
||||
for (auto it = m_dpb.begin(); it < m_dpb.end(); it++)
|
||||
if (it->Poc > poc)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
mfxU32 FrameReorder::BRefOrder(mfxU32 displayOrder, mfxU32 begin, mfxU32 end, mfxU32 counter, bool & ref)
|
||||
{
|
||||
ref = (end - begin > 1);
|
||||
|
||||
mfxU32 pivot = (begin + end) / 2;
|
||||
if (displayOrder == pivot)
|
||||
return counter;
|
||||
else if (displayOrder < pivot)
|
||||
return BRefOrder(displayOrder, begin, pivot, counter + 1, ref);
|
||||
else
|
||||
return BRefOrder(displayOrder, pivot + 1, end, counter + 1 + pivot - begin, ref);
|
||||
}
|
||||
|
||||
mfxU32 FrameReorder::GetBiFrameLocation(mfxU32 displayOrder, mfxU32 num, bool &ref)
|
||||
{
|
||||
ref = false;
|
||||
return BRefOrder(displayOrder, 0, num, 0, ref);
|
||||
}
|
||||
|
||||
mfxU32 FrameReorder::BPyrReorder(const std::vector<FrameIterator> & bframes)
|
||||
{
|
||||
mfxU32 num = (mfxU32)bframes.size();
|
||||
if (bframes[0]->Bpo == (mfxU32)MFX_FRAMEORDER_UNKNOWN)
|
||||
{
|
||||
bool bRef = false;
|
||||
|
||||
for (mfxU32 i = 0; i < (mfxU32)bframes.size(); i++)
|
||||
{
|
||||
bframes[i]->Bpo = GetBiFrameLocation(i, num, bRef);
|
||||
if (bRef)
|
||||
bframes[i]->Type |= MFX_FRAMETYPE_REF;
|
||||
}
|
||||
}
|
||||
mfxU32 minBPO = (mfxU32)MFX_FRAMEORDER_UNKNOWN;
|
||||
mfxU32 ind = 0;
|
||||
for (mfxU32 i = 0; i < (mfxU32)bframes.size(); i++)
|
||||
{
|
||||
if (bframes[i]->Bpo < minBPO)
|
||||
{
|
||||
ind = i;
|
||||
minBPO = bframes[i]->Bpo;
|
||||
}
|
||||
}
|
||||
return ind;
|
||||
}
|
||||
|
||||
FrameReorder::FrameIterator FrameReorder::Reorder(bool flush, bool bFields)
|
||||
{
|
||||
FrameIterator begin = m_queue.begin();
|
||||
FrameIterator end = m_queue.begin();
|
||||
|
||||
while (end != m_queue.end())
|
||||
{
|
||||
if ((end != begin) && (end->Type & MFX_FRAMETYPE_IDR))
|
||||
{
|
||||
flush = true;
|
||||
break;
|
||||
}
|
||||
end++;
|
||||
}
|
||||
|
||||
if (bFields && m_lastFieldInfo.bFirstField())
|
||||
{
|
||||
while (begin != end && !m_lastFieldInfo.isCorrespondSecondField(*begin))
|
||||
begin++;
|
||||
|
||||
if (begin != end)
|
||||
{
|
||||
m_lastFieldInfo.CorrectFrameInfo(*begin);
|
||||
return begin;
|
||||
}
|
||||
else
|
||||
begin = m_queue.begin();
|
||||
}
|
||||
|
||||
FrameIterator top = Reorder(begin, end, flush, bFields);
|
||||
|
||||
if (top == end)
|
||||
{
|
||||
return top;
|
||||
}
|
||||
|
||||
if (bFields)
|
||||
{
|
||||
m_lastFieldInfo.SaveInfo(*top);
|
||||
}
|
||||
|
||||
return top;
|
||||
}
|
||||
|
||||
FrameReorder::FrameIterator FrameReorder::Reorder(FrameIterator begin, FrameIterator end, bool flush, bool bFields)
|
||||
{
|
||||
FrameIterator top = begin;
|
||||
FrameIterator b0 = end; // 1st non-ref B with L1 > 0
|
||||
std::vector<FrameIterator> bframes;
|
||||
|
||||
bool isBPyramid = !!(m_BRefType == MFX_B_REF_PYRAMID);
|
||||
|
||||
while (top != end && (top->Type & MFX_FRAMETYPE_B))
|
||||
{
|
||||
if (HasL1(top->Poc) && (!top->bSecondField))
|
||||
{
|
||||
if (isBPyramid)
|
||||
bframes.push_back(top);
|
||||
else if (top->Type & MFX_FRAMETYPE_REF)
|
||||
{
|
||||
if (b0 == end || (top->Poc - b0->Poc < bFields + 2))
|
||||
return top;
|
||||
}
|
||||
else if (b0 == end)
|
||||
b0 = top;
|
||||
}
|
||||
top++;
|
||||
}
|
||||
|
||||
if (!bframes.empty())
|
||||
{
|
||||
return bframes[BPyrReorder(bframes)];
|
||||
}
|
||||
|
||||
if (b0 != end)
|
||||
return b0;
|
||||
|
||||
bool strict = !!(m_GopOptFlag & MFX_GOP_STRICT);
|
||||
if (flush && top == end && begin != end)
|
||||
{
|
||||
top--;
|
||||
if (strict)
|
||||
top = begin;
|
||||
else
|
||||
top->Type = MFX_FRAMETYPE_P | MFX_FRAMETYPE_REF;
|
||||
|
||||
if (top->bSecondField && top != begin)
|
||||
{
|
||||
top--;
|
||||
if (strict)
|
||||
top = begin;
|
||||
else
|
||||
top->Type = MFX_FRAMETYPE_P | MFX_FRAMETYPE_REF;
|
||||
}
|
||||
}
|
||||
|
||||
return top;
|
||||
}
|
||||
#endif // MFX_VERSION
|
|
@ -1,117 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include "generator.h"
|
||||
|
||||
// Processor for generation mode
|
||||
void Generator::Init()
|
||||
{
|
||||
try
|
||||
{
|
||||
mfxStatus sts = m_FileReader.Init(std::list<msdk_string>{m_InputParams.m_InputFileName}, MFX_FOURCC_I420);
|
||||
CHECK_THROW_ERR(sts, "Generator::Init::m_FileReader.Init");
|
||||
|
||||
sts = m_FileWriter.Init(m_InputParams.m_OutputFileName.c_str(), 1);
|
||||
CHECK_THROW_ERR(sts, "Generator::Init::m_FileWriter.Init");
|
||||
|
||||
// Add a buffer to bufferWriter
|
||||
if (m_InputParams.m_TestType & GENERATE_PREDICTION)
|
||||
m_BufferWriter.AddBuffer(MFX_EXTBUFF_HEVCFEI_ENC_MV_PRED, m_InputParams.m_PredBufferFileName);
|
||||
}
|
||||
catch (std::string& e) {
|
||||
std::cout << e << std::endl;
|
||||
throw std::string("ERROR: Couldn't initialize Generator");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Get surface and load new YUV frame from file to it
|
||||
ExtendedSurface* Generator::PrepareSurface()
|
||||
{
|
||||
ExtendedSurface* surf = GetFreeSurf();
|
||||
if (!surf)
|
||||
{
|
||||
throw std::string("ERROR: Generator::PrepareSurface: Undefined reference to surface");
|
||||
}
|
||||
++surf->Data.Locked;
|
||||
|
||||
mfxStatus sts = m_FileReader.LoadNextFrame(surf);
|
||||
CHECK_THROW_ERR(sts, "Generator::PrepareSurface::FileReader.LoadNextFrame");
|
||||
|
||||
return surf;
|
||||
}
|
||||
|
||||
void Generator::DropBuffers(ExtendedSurface& frame)
|
||||
{
|
||||
for (mfxU32 i = 0; i < frame.Data.NumExtParam; ++i)
|
||||
{
|
||||
CHECK_THROW_ERR_BOOL(frame.Data.ExtParam[i], "Generator::DropFrames: surf.Data.ExtParam[i] == NULL");
|
||||
|
||||
// Drop data on disk
|
||||
m_BufferWriter.WriteBuffer(frame.Data.ExtParam[i]);
|
||||
// Zero data of written buffer
|
||||
m_BufferWriter.ResetBuffer(frame.Data.ExtParam[i]);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Save all data
|
||||
//
|
||||
// Iterate through all unlocked frames and dump frame + buffers. When Locked frame met, iteration stops.
|
||||
void Generator::DropFrames()
|
||||
{
|
||||
// Sort data by frame order and drop in DisplayOrder
|
||||
|
||||
// TODO / FIXME: Add EncodedOrder processing, it might be required for HEVC FEI PAK
|
||||
m_Surfaces.sort([](ExtendedSurface& left, ExtendedSurface& right) { return left.Data.FrameOrder < right.Data.FrameOrder; });
|
||||
|
||||
for (ExtendedSurface& surf : m_Surfaces)
|
||||
{
|
||||
// If Locked surface met - stop dumping
|
||||
if (surf.Data.Locked) break;
|
||||
|
||||
// If the surface has already been output, move on to the next one in frame order
|
||||
if (surf.isWritten) continue;
|
||||
|
||||
// Write surface on disk
|
||||
mfxStatus sts = m_FileWriter.WriteNextFrameI420(&surf);
|
||||
surf.isWritten = true;
|
||||
CHECK_THROW_ERR(sts, "Generator::DropFrames::m_FileWriter.WriteNextFrameI420");
|
||||
}
|
||||
}
|
||||
|
||||
void Generator::SavePSData()
|
||||
{
|
||||
if (fpPicStruct.is_open())
|
||||
{
|
||||
// sort by coding order
|
||||
std::sort(m_RefControl.RefLogInfo.begin(), m_RefControl.RefLogInfo.end(), IsInCodingOrder);
|
||||
|
||||
for (auto stat : m_RefControl.RefLogInfo)
|
||||
stat.Dump(fpPicStruct);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MFX_VERSION
|
|
@ -1,551 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
|
||||
#include "inputparameters.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void PrintHelp()
|
||||
{
|
||||
printf("Usage:");
|
||||
printf(" -i InputYUVFile -o OutputYUVFile -w width -h height -n number_of_frames_to_process\n");
|
||||
printf(" The above params are required. If -pic_file or repack parameters are enabled, next parameters:-i InputYUVFile -o OutputYUVFile -w width -h height\n");
|
||||
printf(" Can be removed\n");
|
||||
//i/o/log
|
||||
printf(" [-g num] - GOP size\n");
|
||||
printf(" [-r num] - number of B frames plus 1\n");
|
||||
printf(" [-x num] - DPB size in frames\n");
|
||||
printf(" [-idr_interval num] - IDR interval in frames\n");
|
||||
printf(" [-num_active_P num] - number of active references for P frames\n");
|
||||
printf(" [-num_active_BL0 num] - number of active List 0 references for B frames\n");
|
||||
printf(" [-num_active_BL1 num] - number of active List 1 references for B frames\n");
|
||||
printf(" [-generate] - run ASG in test stream generation mode\n"); // required
|
||||
printf(" [-verify] - run ASG in test results verification mode\n"); // required
|
||||
printf(" [-gen_split] - enable CTU splitting\n");
|
||||
printf(" [-no_cu_to_pu_split] - disable CU splitting into PUs\n");
|
||||
printf(" [-force_extbuf_mvp_block_size num] - force mfxFeiHevcEncMVPredictors::BlockSize field\n");
|
||||
printf(" in MVP output buffer to a specified value. *ALL* output \n");
|
||||
printf(" mfxFeiHevcEncMVPredictors structs will be affected.\n");
|
||||
printf(" Supported values are 0, 1, 2 and 3\n");
|
||||
printf(" See MVPredictor description in HEVC FEI manual for details\n");
|
||||
printf(" [-mvp_block_size num] - actual MVP block size used in actual generation algorithm.\n");
|
||||
printf(" If -force_extbuf_mvp_block_size is not specified,\n");
|
||||
printf(" this value is used in output mfxFeiHevcEncMVPredictors::BlockSize\n");
|
||||
printf(" only for the structures for which MVPs were actually generated\n");
|
||||
printf(" When -force_extbuf_mvp_block_size is specified and -mvp_block_size is not\n");
|
||||
printf(" default algorithm for MVP generation is used : MVP block size equals to CTU size.\n");
|
||||
printf(" When both -force_extbuf_mvp_block_size and -mvp_block_size are specified : the 1st one\n");
|
||||
printf(" value is used in the output ExtBuffer regardless to actual MVP block size\n");
|
||||
printf(" Supported values are 0, 1, 2 and 3\n");
|
||||
printf(" [-force_symm_cu_part] - forces using only symmetric CU into PU partioning modes\n");
|
||||
printf(" for inter prediction test\n");
|
||||
printf(" [-gen_inter] - generate inter CUs (inter prediction test)\n");
|
||||
printf(" [-gen_intra] - generate intra CUs (intra prediction test)\n");
|
||||
printf(" [-gen_pred] - generate MV predictors (inter prediction test)\n");
|
||||
printf(" [-gen_mv] - generate motion vectors inside search window (inter prediction test)\n"); // name != sense
|
||||
printf(" If -gen_mv is not specified,\n");
|
||||
printf(" then resulting MVs for PUs will be generated outside\n");
|
||||
printf(" the search window only\n");
|
||||
printf(" [-gen_repack_ctrl] - generate/verify repack control data\n");
|
||||
printf(" [-pred_file File] - output file for MV predictors\n");
|
||||
printf(" [-pic_file File] - output file for pictures' structure\n");
|
||||
printf(" [-log2_ctu_size num] - log2 CTU size to be used for CU quad-tree structure\n");
|
||||
printf(" Default is 4");
|
||||
printf(" Cannot be less than min_log2_tu_size (described below)\n");
|
||||
printf(" [-min_log2_tu_size num] - minimum log2 TU size to be used for quad-tree structure\n");
|
||||
printf(" Must be less than min_log2_cu_size (described below), default is 2\n");
|
||||
printf(" [-max_log2_tu_size num] - maximum log2 TU size to be used for quad-tree structure\n");
|
||||
printf(" Must be less than or equal to Min(log2_ctu_size, 5), default is 4\n");
|
||||
printf(" [-max_tu_qt_depth num] - maximum TU quad-tree depth inside CU\n");
|
||||
printf(" Overrrides min_log2_tu_size, default is 4\n");
|
||||
printf(" [-min_log2_cu_size num] - minimum log2 CU size to be used for quad-tree structure.\n");
|
||||
printf(" Cannot be less than max_log2_tu_size, default is 3\n");
|
||||
printf(" [-max_log2_cu_size num] - maximum log2 CU size to be used for quad-tree structure.\n");
|
||||
printf(" Cannot be larger than log2_ctu_size, default is 4\n");
|
||||
printf(" [-block_size_mask num] - bit mask specifying possible partition sizes\n");
|
||||
printf(" [-ctu_distance num] - minimum distance between generated CTUs\n");
|
||||
printf(" (in units of CTU), default is 3\n");
|
||||
printf(" [-gpb_off] - specifies that regular P frames should be used, not GPB frames\n");
|
||||
printf(" [-bref] - arrange B frames in B pyramid reference structure\n");
|
||||
printf(" [-nobref] - do not use B-pyramid\n");
|
||||
printf(" [-pak_ctu_file File] - input file with per CTU information\n");
|
||||
printf(" [-pak_cu_file File] - input file with per CU information\n");
|
||||
printf(" [-repack_ctrl_file File]- output/input file with repack control data for repack control generation/verify\n");
|
||||
printf(" [-repack_stat_file File]- input file with repack stat data for repack control verify\n");
|
||||
printf(" [-repack_str_file File] - input file with multiPakStr data for repack control generation/verify\n");
|
||||
printf(" [-log File] - log output file\n");
|
||||
printf(" [-csv File] - file to output statistics in CSV format\n"); // ignored
|
||||
printf(" [-config ConfigFile] - input configuration file\n"); // ignored
|
||||
printf(" [-sub_pel_mode num] - specifies sub pixel precision for motion vectors. 0 - integer, 1 - half, 3 - quarter (0 is default)\n");
|
||||
printf(" [-mv_thres num] - threshold for motion vectors in percents (0 is default)\n");
|
||||
printf(" [-numpredictors num] - number of MV predictors enabled. Used in verification mode to check NumMvPredictors FEI control works correctly\n");
|
||||
printf(" - Valid values are in range [1; 4] (4 is default)\n");
|
||||
printf(" [-split_thres num] - thresholds for partitions in percents (0 is default)\n");
|
||||
printf(" [-DeltaQP value(s)] - array of delta QP values for repack ctrl generation, separated by a space (8 values at max)\n");
|
||||
printf(" [-InitialQP value] - the initial QP value for repack ctrl verify (26 is default)\n");
|
||||
}
|
||||
|
||||
void InputParams::ParseInputString(msdk_char **strInput, mfxU8 nArgNum)
|
||||
{
|
||||
try {
|
||||
|
||||
//parse command line parameters
|
||||
for (mfxU8 i = 1; i < nArgNum; ++i)
|
||||
{
|
||||
//Verbose mode, output to command line. Missed in Help
|
||||
if (msdk_strcmp(strInput[i], MSDK_STRING("-verbose")) == 0
|
||||
|| msdk_strcmp(strInput[i], MSDK_STRING("-v")) == 0)
|
||||
m_bVerbose = true;
|
||||
|
||||
//I/O YUV files
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-i")) == 0)
|
||||
m_InputFileName = GetStringArgument(strInput, ++i, nArgNum);
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-o")) == 0)
|
||||
m_OutputFileName = GetStringArgument(strInput, ++i, nArgNum);
|
||||
|
||||
//width
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-w")) == 0)
|
||||
m_width = GetIntArgument(strInput, ++i, nArgNum);
|
||||
|
||||
//height
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-h")) == 0)
|
||||
m_height = GetIntArgument(strInput, ++i, nArgNum);
|
||||
|
||||
//frame number
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-n")) == 0)
|
||||
m_numFrames = GetIntArgument(strInput, ++i, nArgNum);
|
||||
|
||||
// Encoding structure
|
||||
|
||||
// GOP size
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-g")) == 0)
|
||||
m_GopSize = GetIntArgument(strInput, ++i, nArgNum);
|
||||
|
||||
// Number of B frames + 1
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-r")) == 0)
|
||||
m_RefDist = GetIntArgument(strInput, ++i, nArgNum);
|
||||
|
||||
// DPB size
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-x")) == 0)
|
||||
{
|
||||
m_NumRef = GetIntArgument(strInput, ++i, nArgNum);
|
||||
if (m_NumRef > 16) throw std::string("ERROR: Invalid DPB size");
|
||||
}
|
||||
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-idr_interval")) == 0)
|
||||
m_nIdrInterval = GetIntArgument(strInput, ++i, nArgNum);
|
||||
|
||||
// Number active references for P frames
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-num_active_P")) == 0)
|
||||
{
|
||||
m_NumRefActiveP = GetIntArgument(strInput, ++i, nArgNum);
|
||||
if (m_NumRefActiveP > 4) throw std::string("ERROR: Invalid num_active_P");
|
||||
}
|
||||
|
||||
// Number of backward references for B frames
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-num_active_BL0")) == 0)
|
||||
{
|
||||
m_NumRefActiveBL0 = GetIntArgument(strInput, ++i, nArgNum);
|
||||
if (m_NumRefActiveBL0 > 4) throw std::string("ERROR: Invalid num_active_BL0");
|
||||
}
|
||||
|
||||
// Number of forward references for B frames
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-num_active_BL1")) == 0)
|
||||
{
|
||||
m_NumRefActiveBL1 = GetIntArgument(strInput, ++i, nArgNum);
|
||||
if (m_NumRefActiveBL1 > 1) throw std::string("ERROR: Invalid num_active_BL1");
|
||||
}
|
||||
|
||||
// Set parameters for b-pyramid
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-bref")) == 0)
|
||||
{
|
||||
m_BRefType = MFX_B_REF_PYRAMID;
|
||||
}
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-nobref")) == 0)
|
||||
{
|
||||
m_BRefType = MFX_B_REF_OFF;
|
||||
}
|
||||
|
||||
// processing mode
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-generate")) == 0)
|
||||
m_ProcMode = GENERATE;
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-verify")) == 0)
|
||||
m_ProcMode = VERIFY;
|
||||
|
||||
// test type
|
||||
|
||||
// Enable split of CTU
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-gen_split")) == 0)
|
||||
m_TestType |= GENERATE_SPLIT;
|
||||
|
||||
// Generate MVs, Inter-prediction test
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-gen_mv")) == 0)
|
||||
m_TestType |= GENERATE_MV;
|
||||
|
||||
// Generate Intra CUs, Intra-prediction test
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-gen_intra")) == 0)
|
||||
m_TestType |= GENERATE_INTRA;
|
||||
|
||||
// Generate Inter CUs, Inter-prediction test
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-gen_inter")) == 0)
|
||||
m_TestType |= GENERATE_INTER;
|
||||
|
||||
// Generate long MVs which are outside of SW, Inter-prediction test
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-gen_pred")) == 0)
|
||||
m_TestType |= GENERATE_PREDICTION;
|
||||
|
||||
// Generate or verify multi-repack control data
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-gen_repack_ctrl")) == 0)
|
||||
m_TestType |= GENERATE_REPACK_CTRL;
|
||||
|
||||
// Drop data to file
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-pred_file")) == 0)
|
||||
m_PredBufferFileName = GetStringArgument(strInput, ++i, nArgNum);
|
||||
|
||||
// Drop pictures structure to file
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-pic_file")) == 0) {
|
||||
m_PicStructFileName = GetStringArgument(strInput, ++i, nArgNum);
|
||||
m_TestType |= GENERATE_PICSTRUCT;
|
||||
}
|
||||
|
||||
// Minimum log CU size to be used for quad-tree structure
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-min_log2_cu_size")) == 0)
|
||||
m_CTUStr.minLog2CUSize = GetIntArgument(strInput, ++i, nArgNum);
|
||||
|
||||
// Maximum log CU size to be used for quad-tree structure
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-max_log2_cu_size")) == 0)
|
||||
m_CTUStr.maxLog2CUSize = GetIntArgument(strInput, ++i, nArgNum);
|
||||
|
||||
// Disable CU splitting into PUs
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-no_cu_to_pu_split")) == 0)
|
||||
m_CTUStr.bCUToPUSplit = false;
|
||||
|
||||
// Force per-MVP block size in the MVP output file to a supported value
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-force_extbuf_mvp_block_size")) == 0)
|
||||
{
|
||||
m_ForcedExtMVPBlockSize = GetIntArgument(strInput, ++i, nArgNum);
|
||||
m_bIsForceExtMVPBlockSize = true;
|
||||
}
|
||||
|
||||
// Actual per-MVP block size used in generation algorithm
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-mvp_block_size")) == 0)
|
||||
{
|
||||
m_GenMVPBlockSize = GetIntArgument(strInput, ++i, nArgNum);
|
||||
}
|
||||
|
||||
// Force only symmetric CU into PU partioning
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-force_symm_cu_part")) == 0)
|
||||
{
|
||||
m_CTUStr.bForceSymmetricPU = true;
|
||||
}
|
||||
|
||||
// Log2 CTU size to be used for quad-tree structure. Also the maximum
|
||||
// possible CU size
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-log2_ctu_size")) == 0)
|
||||
{
|
||||
m_CTUStr.log2CTUSize = GetIntArgument(strInput, ++i, nArgNum);
|
||||
m_CTUStr.CTUSize = (mfxU32)(1 << m_CTUStr.log2CTUSize);
|
||||
}
|
||||
|
||||
// Minimum log TU size to be used for quad-tree structure
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-min_log2_tu_size")) == 0)
|
||||
m_CTUStr.minLog2TUSize = GetIntArgument(strInput, ++i, nArgNum);
|
||||
|
||||
// Maximum log TU size to be used for quad-tree structure
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-max_log2_tu_size")) == 0)
|
||||
m_CTUStr.maxLog2TUSize = GetIntArgument(strInput, ++i, nArgNum);
|
||||
|
||||
// Maximum TU quad-tree depth inside CU
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-max_tu_qt_depth")) == 0)
|
||||
m_CTUStr.maxTUQTDepth = GetIntArgument(strInput, ++i, nArgNum);
|
||||
|
||||
// which blocks to use in partitions (bitmask)
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-block_size_mask")) == 0)
|
||||
m_block_size_mask = GetIntArgument(strInput, ++i, nArgNum);
|
||||
|
||||
// Minimum distance between generated CTUs in terms of CTU
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-ctu_distance")) == 0)
|
||||
m_CTUStr.CTUDist = GetIntArgument(strInput, ++i, nArgNum);
|
||||
|
||||
// Read CTU data from file
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-pak_ctu_file")) == 0)
|
||||
m_PakCtuBufferFileName = GetStringArgument(strInput, ++i, nArgNum);
|
||||
|
||||
// Read CU data from file
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-pak_cu_file")) == 0)
|
||||
m_PakCuBufferFileName = GetStringArgument(strInput, ++i, nArgNum);
|
||||
|
||||
// Whether GPB frames should be used instead of regular P frames
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-gpb_off")) == 0)
|
||||
m_UseGPB = false;
|
||||
|
||||
// Thresholds
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-mv_thres")) == 0)
|
||||
m_Thresholds.mvThres = GetIntArgument(strInput, ++i, nArgNum);
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-split_thres")) == 0)
|
||||
m_Thresholds.splitThres = GetIntArgument(strInput, ++i, nArgNum);
|
||||
// Number of enabled MV predictors. For disabled predictors upper MV-threshold is ON
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-numpredictors")) == 0)
|
||||
m_NumMVPredictors = GetIntArgument(strInput, ++i, nArgNum);
|
||||
|
||||
// Motion prediction precision mode
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-sub_pel_mode")) == 0)
|
||||
{
|
||||
if (++i < nArgNum)
|
||||
{
|
||||
m_SubPixelMode = ParseSubPixelMode(strInput[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::string("ERROR: sub_pel_mode require an argument");
|
||||
}
|
||||
}
|
||||
|
||||
// The multi-repack control data file
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-repack_ctrl_file")) == 0)
|
||||
m_RepackCtrlFileName = GetStringArgument(strInput, ++i, nArgNum);
|
||||
|
||||
// The multiPakStr data file
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-repack_str_file")) == 0)
|
||||
m_RepackStrFileName = GetStringArgument(strInput, ++i, nArgNum);
|
||||
|
||||
// The multi-repack stat data file
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-repack_stat_file")) == 0)
|
||||
m_RepackStatFileName = GetStringArgument(strInput, ++i, nArgNum);
|
||||
|
||||
//Repack control num passes and delta QP
|
||||
else if((msdk_strcmp(strInput[i], MSDK_STRING("-DeltaQP")) == 0))
|
||||
{
|
||||
mfxU32 idxQP;
|
||||
for(idxQP = 0; idxQP < m_NumAddPasses; idxQP++)
|
||||
{
|
||||
if(msdk_strncmp(strInput[i+1], MSDK_STRING("-"), 1) == 0)
|
||||
break;
|
||||
|
||||
m_DeltaQP[idxQP] = (mfxU8)GetIntArgument(strInput, ++i, nArgNum);
|
||||
}
|
||||
m_NumAddPasses = idxQP;
|
||||
}
|
||||
|
||||
//Repack control initial QP
|
||||
else if((msdk_strcmp(strInput[i], MSDK_STRING("-InitialQP")) == 0))
|
||||
m_InitialQP = GetIntArgument(strInput, ++i, nArgNum);
|
||||
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-log")) == 0)
|
||||
{
|
||||
m_bUseLog = true;
|
||||
m_LogFileName = GetStringArgument(strInput, ++i, nArgNum);
|
||||
}
|
||||
//help
|
||||
else if (msdk_strcmp(strInput[i], MSDK_STRING("-help")) == 0
|
||||
|| msdk_strcmp(strInput[i], MSDK_STRING("--help")) == 0)
|
||||
{
|
||||
m_bPrintHelp = true;
|
||||
}
|
||||
else
|
||||
throw std::string("ERROR: Unknown input argument");
|
||||
}
|
||||
|
||||
if (m_bPrintHelp)
|
||||
{
|
||||
PrintHelp();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_TestType == UNDEFINED_TYPE)
|
||||
throw std::string("ERROR: Undefined test type");
|
||||
|
||||
if (m_ProcMode == UNDEFINED_MODE)
|
||||
throw std::string("ERROR: Undefined mode");
|
||||
|
||||
if (m_numFrames == 0)
|
||||
throw std::string("ERROR: Invalid number of frames");
|
||||
|
||||
if ((m_TestType & GENERATE_PICSTRUCT) && m_TestType != GENERATE_PICSTRUCT)
|
||||
throw std::string("ERROR: Improper arguments mix with pic_struct");
|
||||
|
||||
if (m_TestType == GENERATE_PICSTRUCT)
|
||||
return;
|
||||
|
||||
//Repack control generation checking
|
||||
if (m_TestType & GENERATE_REPACK_CTRL)
|
||||
{
|
||||
if (m_TestType != GENERATE_REPACK_CTRL)
|
||||
throw std::string("ERROR: Improper arguments mix with gen_repack_ctrl");
|
||||
|
||||
if (m_ProcMode == GENERATE)
|
||||
{
|
||||
if (m_NumAddPasses == 0 || m_NumAddPasses > HEVC_MAX_NUMPASSES)
|
||||
throw std::string("ERROR: Wrong NumAddPasses value");
|
||||
|
||||
if (!m_RepackCtrlFileName.empty() && !m_RepackStrFileName.empty())
|
||||
return;
|
||||
else
|
||||
throw std::string("ERROR: repack ctrl and str files required");
|
||||
}
|
||||
else if (m_ProcMode == VERIFY)
|
||||
{
|
||||
if (!m_RepackCtrlFileName.empty()
|
||||
&& !m_RepackStrFileName.empty()
|
||||
&& !m_RepackStatFileName.empty())
|
||||
return;
|
||||
else
|
||||
throw std::string("ERROR: repack ctrl, str and stat files required");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::string("ERROR: Wrong proc mode");
|
||||
}
|
||||
}
|
||||
|
||||
if (m_ProcMode == GENERATE && (m_TestType & (GENERATE_INTER | GENERATE_INTRA)) && (m_InputFileName.length() == 0 || m_OutputFileName.length() == 0))
|
||||
throw std::string("ERROR: input and output YUV files required");
|
||||
|
||||
if (m_ProcMode == GENERATE && (m_TestType & GENERATE_PREDICTION)
|
||||
&& m_PredBufferFileName.length() == 0)
|
||||
throw std::string("ERROR: To generate predictors output file is required");
|
||||
|
||||
if ((m_ProcMode & VERIFY) && (m_TestType & (GENERATE_INTER | GENERATE_INTRA)) && m_PakCtuBufferFileName.length() == 0)
|
||||
throw std::string("ERROR: PAK CTU input file is required");
|
||||
|
||||
if ((m_ProcMode & VERIFY) && (m_TestType & (GENERATE_INTER | GENERATE_INTRA)) && m_PakCuBufferFileName.length() == 0)
|
||||
throw std::string("ERROR: PAK CU input file is required");
|
||||
|
||||
if (m_width == 0 || m_height == 0)
|
||||
throw std::string("ERROR: Invalid width or/and height values");
|
||||
|
||||
if (m_CTUStr.CTUSize != 16 && m_CTUStr.CTUSize != 32 && m_CTUStr.CTUSize != 64)
|
||||
throw std::string("ERROR: Invalid CTU size specified");
|
||||
|
||||
if (m_block_size_mask > 3 || m_block_size_mask == 0)
|
||||
// 64x64 blocks are unsupported on SKL
|
||||
throw std::string("ERROR: Incorrect block_size_mask");
|
||||
|
||||
if (m_bIsForceExtMVPBlockSize && m_ForcedExtMVPBlockSize > 3)
|
||||
throw std::string("ERROR: Invalid forced MVP block size specified");
|
||||
|
||||
if (m_GenMVPBlockSize > 3)
|
||||
throw std::string("ERROR: Invalid actual MVP block size specified");
|
||||
|
||||
//Checking actual MVP block size and CTU size compatibily
|
||||
if (m_GenMVPBlockSize != 0)
|
||||
{
|
||||
if ((m_CTUStr.CTUSize == 16 && m_GenMVPBlockSize > 1))
|
||||
{
|
||||
throw std::string("ERROR: For 16x16 CTU actual buffer MVP block size should be less or equal than CTU size");
|
||||
}
|
||||
else if (m_CTUStr.CTUSize == 32 && m_GenMVPBlockSize > 2)
|
||||
{
|
||||
throw std::string("ERROR: For 32x32 CTU actual buffer MVP block size should be less or equal than CTU size");
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_TestType & (GENERATE_MV | GENERATE_PREDICTION)) && !(m_TestType & GENERATE_INTER))
|
||||
throw std::string("ERROR: MVs can't be generated w/o -gen_inter option");
|
||||
|
||||
if ((m_TestType & GENERATE_SPLIT) && !(m_TestType & (GENERATE_INTER | GENERATE_INTRA)))
|
||||
throw std::string("ERROR: Splits can't be generated w/o -gen_inter or -gen_intra option");
|
||||
|
||||
|
||||
if ((m_ProcMode & VERIFY) && (m_TestType & GENERATE_INTER) && m_Thresholds.mvThres > 100)
|
||||
throw std::string("ERROR: Incorrect threshold for MVs in the verification mode");
|
||||
|
||||
if ((m_ProcMode & VERIFY) && (m_TestType & (GENERATE_INTER | GENERATE_INTRA)) && m_Thresholds.splitThres > 100)
|
||||
throw std::string("ERROR: Incorrect threshold for splits in the verification mode");
|
||||
|
||||
if ((m_ProcMode & VERIFY) && (m_TestType & (GENERATE_INTER | GENERATE_PREDICTION)) && m_NumMVPredictors > 4)
|
||||
throw std::string("ERROR: Incorrect number of enabled MV predictors in the verification mode");
|
||||
|
||||
if (m_CTUStr.maxLog2CUSize < m_CTUStr.minLog2CUSize)
|
||||
throw std::string("ERROR: max_log2_cu_size should be greater than or equal to min_log2_tu_size");
|
||||
|
||||
if ((mfxU32) 1 << m_CTUStr.maxLog2CUSize > m_CTUStr.CTUSize)
|
||||
throw std::string("ERROR: max_log2_cu_size should be less than or equal to log2_ctu_size");
|
||||
|
||||
if (m_CTUStr.maxLog2TUSize < m_CTUStr.minLog2TUSize)
|
||||
throw std::string("ERROR: max_log2_tu_size should be greater than or equal to min_log2_tu_size");
|
||||
|
||||
if (m_CTUStr.minLog2CUSize <= m_CTUStr.minLog2TUSize)
|
||||
throw std::string("ERROR: min_log2_cu_size should be greater than min_log2_tu_size");
|
||||
|
||||
if (m_CTUStr.maxLog2TUSize > (std::min)(m_CTUStr.maxLog2CUSize, (mfxU32) 5))
|
||||
throw std::string("ERROR: max_log2_tu_size should be less than or equal to Min( log2_ctu_size, 5)");
|
||||
}
|
||||
catch (std::string& e) {
|
||||
cout << e << endl;
|
||||
throw std::string("ERROR: InputParams::ParseInputString");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
mfxU16 InputParams::ParseSubPixelMode(msdk_char * strRawSubPelMode)
|
||||
{
|
||||
mfxU16 pelMode = msdk_atoi(strRawSubPelMode);
|
||||
|
||||
switch (pelMode)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 3:
|
||||
return pelMode;
|
||||
default:
|
||||
throw std::string("ERROR: Incorrect sub_pel_mode value");
|
||||
}
|
||||
}
|
||||
|
||||
int InputParams::GetIntArgument(msdk_char **strInput, mfxU8 index, mfxU8 nArgNum)
|
||||
{
|
||||
if (strInput == nullptr || *strInput == nullptr)
|
||||
{
|
||||
throw std::string("ERROR: GetIntArgument: null pointer reference");
|
||||
}
|
||||
if (index < nArgNum)
|
||||
{
|
||||
return msdk_atoi(strInput[index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::string("ERROR: missing secondary integer argument");
|
||||
}
|
||||
}
|
||||
|
||||
msdk_string InputParams::GetStringArgument(msdk_char **strInput, mfxU8 index, mfxU8 nArgNum)
|
||||
{
|
||||
if (strInput == nullptr || *strInput == nullptr)
|
||||
{
|
||||
throw std::string("ERROR: GetStringArgument: null pointer reference");
|
||||
}
|
||||
if (index < nArgNum)
|
||||
{
|
||||
return msdk_string(strInput[index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::string("ERROR: missing secondary string argument");
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MFX_VERSION
|
|
@ -1,734 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include "mvmvp_processor.h"
|
||||
|
||||
// Generates MVP pool groups according to PU positioning in CTU and constructed MVP blocks grid
|
||||
void MVMVPProcessor::InitMVPGridData(const CTUDescriptor& CTU, const FrameChangeDescriptor & frameDescr)
|
||||
{
|
||||
mfxU32 gridSizeIn32x32Blocks = CTU.m_BWidth / (2 * MVP_BLOCK_SIZE);
|
||||
|
||||
// 16x16 MVP blocks in frame; numbers denote order in file:
|
||||
// ++++++++++++++++++++
|
||||
// + 0 + 1 + 4 + 5 +
|
||||
// +++++++++++++++++ ...
|
||||
// + 2 + 3 + 6 + 7 +
|
||||
// +++++++++++++++++
|
||||
// + ...
|
||||
// Each quarter of 16x16 blocks with sequent indecies are forming a 32x32 block group
|
||||
|
||||
m_mvpBlockGrid.reserve(gridSizeIn32x32Blocks * gridSizeIn32x32Blocks);
|
||||
|
||||
if (!gridSizeIn32x32Blocks) // only one 16x16 block
|
||||
{
|
||||
m_mvpBlockGrid.emplace_back(CTU.m_AdrX, CTU.m_AdrY, MVP_BLOCK_SIZE, MVP_BLOCK_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Pushing MVP blocks onto the grid in zig-zag order described above
|
||||
for (mfxU32 gridIdx = 0; gridIdx < gridSizeIn32x32Blocks * gridSizeIn32x32Blocks; ++gridIdx)
|
||||
{
|
||||
for (mfxU32 elemIdx = 0; elemIdx < 4; ++elemIdx)
|
||||
{
|
||||
m_mvpBlockGrid.emplace_back(
|
||||
CTU.m_AdrX + (2 * (gridIdx % gridSizeIn32x32Blocks) + (elemIdx % 2)) * MVP_BLOCK_SIZE,
|
||||
CTU.m_AdrY + (2 * (gridIdx / gridSizeIn32x32Blocks) + (elemIdx / 2)) * MVP_BLOCK_SIZE,
|
||||
MVP_BLOCK_SIZE, MVP_BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mfxI32 mvpGroupsNum = ConstructMVPPoolGroups(CTU);
|
||||
|
||||
// All PUs are processed - constructing actual MVP pools per each group
|
||||
|
||||
m_mvpPools.resize(mvpGroupsNum);
|
||||
|
||||
for (mfxI32 groupNo = 0; groupNo < mvpGroupsNum; ++groupNo)
|
||||
{
|
||||
m_mvpPools[groupNo].reserve(MVP_PER_16x16_BLOCK);
|
||||
|
||||
for (mfxU32 mvpCount = 0; mvpCount < MVP_PER_16x16_BLOCK; ++mvpCount)
|
||||
{
|
||||
m_mvpPools[groupNo].emplace_back(GenerateMVP(CTU, frameDescr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mfxI32 MVMVPProcessor::ConstructMVPPoolGroups(const CTUDescriptor& CTU)
|
||||
{
|
||||
switch (m_GenMVPBlockSize)
|
||||
{
|
||||
case 1:
|
||||
if (CTU.m_BWidth == 32 || CTU.m_BWidth == 64)
|
||||
{
|
||||
return PutPUAndMVPBlocksIn16x16MVPPoolGroups(CTU);
|
||||
}
|
||||
case 2:
|
||||
if (CTU.m_BWidth == 64)
|
||||
{
|
||||
return PutPUAndMVPBlocksIn32x32MVPPoolGroups(CTU);
|
||||
}
|
||||
case 3:
|
||||
return PutPUAndMVPBlocksInSingleMVPPoolGroup(CTU);
|
||||
|
||||
default:
|
||||
throw std::string("ERROR: MVMVPProcessor: ConstructMVPPoolGroups: Incorrect m_GenMVPBlockSize used");
|
||||
}
|
||||
}
|
||||
|
||||
mfxI32 MVMVPProcessor::PutPUAndMVPBlocksIn16x16MVPPoolGroups(const CTUDescriptor & CTU)
|
||||
{
|
||||
mfxI32 extMVPGroupNo = 0;
|
||||
|
||||
for (const auto& CU : CTU.m_CUVec)
|
||||
{
|
||||
if (CU.m_PredType == INTER_PRED)
|
||||
{
|
||||
// For all the inter PUs constructing a MVP block list which this PU has intersections with
|
||||
for (const auto& PU : CU.m_PUVec)
|
||||
{
|
||||
// Construct a list with all MVP blocks which have intersections with current PU
|
||||
|
||||
std::list<MVPBlock> intersectedMVPBlocks;
|
||||
|
||||
for (const auto& mvpBlock : m_mvpBlockGrid)
|
||||
{
|
||||
if (PU.CheckForIntersect(mvpBlock))
|
||||
{
|
||||
intersectedMVPBlocks.push_back(mvpBlock);
|
||||
}
|
||||
}
|
||||
|
||||
// Checking the list validity. It should have at least 1 element
|
||||
if (intersectedMVPBlocks.empty())
|
||||
{
|
||||
throw std::string("ERROR: MVMVPProcessor: PutPUAndMVPBlocksIn16x16MVPPoolGroups: Found a PU which doesn't intersect the MVP grid");
|
||||
}
|
||||
|
||||
// Check if there is at least one block which is included in some group
|
||||
// MVP blocks should have no group or be included in the one group
|
||||
auto validGroupMVPBlock = std::find_if(intersectedMVPBlocks.begin(), intersectedMVPBlocks.end(),
|
||||
[](const MVPBlock& block) { return block.IsAlreadyInGroup(); });
|
||||
|
||||
// If it exists, put all MVP blocks intersected with current PU in this group
|
||||
if (validGroupMVPBlock != intersectedMVPBlocks.end())
|
||||
{
|
||||
mfxI32 firstValidGroupNo = validGroupMVPBlock->GetGroupNo();
|
||||
|
||||
if (std::any_of(intersectedMVPBlocks.begin(), intersectedMVPBlocks.end(),
|
||||
[firstValidGroupNo](const MVPBlock& block)
|
||||
{ return (block.IsAlreadyInGroup() && !block.IsInGroup(firstValidGroupNo)); }))
|
||||
{
|
||||
throw std::string("ERROR: PutPUAndMVPBlocksIn16x16MVPPoolGroups : Found a pair of MVP blocks intersecting with current PU which are in the different MVP groups");
|
||||
}
|
||||
else // include all intersecting MVP blocks in the single group
|
||||
{
|
||||
for (MVPBlock& block : m_mvpBlockGrid)
|
||||
{
|
||||
if (std::find(intersectedMVPBlocks.begin(), intersectedMVPBlocks.end(), block)
|
||||
!= intersectedMVPBlocks.end())
|
||||
{
|
||||
block.SetGroup(firstValidGroupNo);
|
||||
}
|
||||
}
|
||||
// The list is valid - set PU pool group no. with the value for MVP blocks
|
||||
m_PUtoMVPPoolGroupMap[PU] = firstValidGroupNo;
|
||||
}
|
||||
}
|
||||
else // Otherwise, put all MVP blocks in the new group
|
||||
{
|
||||
for (MVPBlock& block : m_mvpBlockGrid)
|
||||
{
|
||||
if (std::find(intersectedMVPBlocks.begin(), intersectedMVPBlocks.end(), block)
|
||||
!= intersectedMVPBlocks.end())
|
||||
{
|
||||
block.SetGroup(extMVPGroupNo);
|
||||
}
|
||||
}
|
||||
// The list is valid - set PU pool group no. with the value for MVPs
|
||||
m_PUtoMVPPoolGroupMap[PU] = extMVPGroupNo;
|
||||
|
||||
++extMVPGroupNo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return extMVPGroupNo;
|
||||
}
|
||||
|
||||
mfxI32 MVMVPProcessor::PutPUAndMVPBlocksIn32x32MVPPoolGroups(const CTUDescriptor & CTU)
|
||||
{
|
||||
// Special case for 64x64 CTUs and 32x32 MVP block size
|
||||
mfxI32 extMVPGroupNo = 0;
|
||||
|
||||
// Construct FOUR 32x32 block groups from the 16x16 block grid
|
||||
std::vector<MVP32x32BlockGroup> mvp32x32BlockGroups;
|
||||
mvp32x32BlockGroups.reserve(4);
|
||||
|
||||
for (mfxU32 gridIdx = 0; gridIdx < m_mvpBlockGrid.size(); gridIdx += 4)
|
||||
{
|
||||
mvp32x32BlockGroups.emplace_back(BaseBlock(m_mvpBlockGrid[gridIdx].m_AdrX,
|
||||
m_mvpBlockGrid[gridIdx].m_AdrY,
|
||||
MVP_BLOCK_SIZE * 2, MVP_BLOCK_SIZE * 2), gridIdx);
|
||||
}
|
||||
|
||||
for (const auto& CU : CTU.m_CUVec)
|
||||
{
|
||||
if (CU.m_PredType == INTER_PRED)
|
||||
{
|
||||
// For all the inter PUs constructing a list of 32x32 MVP block groups
|
||||
// that this PU has intersections with
|
||||
for (const auto& PU : CU.m_PUVec)
|
||||
{
|
||||
// Construct a list with all 32x32 MVP block groups which have intersections with current PU
|
||||
std::list<MVP32x32BlockGroup> intersected32x32MVPBlocks;
|
||||
|
||||
for (const auto& mvp32x32Block : mvp32x32BlockGroups)
|
||||
{
|
||||
if (PU.CheckForIntersect(mvp32x32Block.first))
|
||||
{
|
||||
intersected32x32MVPBlocks.push_back(mvp32x32Block);
|
||||
}
|
||||
}
|
||||
|
||||
// Checking the list validity. It should have at least 1 element
|
||||
if (intersected32x32MVPBlocks.empty())
|
||||
{
|
||||
throw std::string("ERROR: MVMVPProcessor: PutPUAndMVPBlocksIn32x32MVPPoolGroups: Found a PU which doesn't intersect the 32x32 MVP groups grid");
|
||||
}
|
||||
|
||||
// Check if there is at least one block which is included in some group
|
||||
// MVP blocks should have no group or be included in a single group
|
||||
auto validGroupMVPBlock = std::find_if(intersected32x32MVPBlocks.begin(),
|
||||
intersected32x32MVPBlocks.end(), [this](const MVP32x32BlockGroup& block32x32)
|
||||
{ return m_mvpBlockGrid[block32x32.second].IsAlreadyInGroup(); });
|
||||
|
||||
// If it exists, put all MVP blocks intersecting the current PU in this group
|
||||
if (validGroupMVPBlock != intersected32x32MVPBlocks.end())
|
||||
{
|
||||
mfxI32 firstValidGroupNo = m_mvpBlockGrid[validGroupMVPBlock->second].GetGroupNo();
|
||||
|
||||
if (std::any_of(intersected32x32MVPBlocks.begin(),
|
||||
intersected32x32MVPBlocks.end(), [this, firstValidGroupNo](const MVP32x32BlockGroup& block32x32)
|
||||
{ return (m_mvpBlockGrid[block32x32.second].IsAlreadyInGroup() && !m_mvpBlockGrid[block32x32.second].IsInGroup(firstValidGroupNo)); }))
|
||||
{
|
||||
throw std::string("ERROR: PutPUAndMVPBlocksIn32x32MVPPoolGroups : Found a pair of MVP blocks intersecting with current PU which are in the different MVP groups");
|
||||
}
|
||||
else // include all intersecting MVP blocks in the single group
|
||||
{
|
||||
for (MVPBlock& block : m_mvpBlockGrid)
|
||||
{
|
||||
if (std::find_if(intersected32x32MVPBlocks.begin(), intersected32x32MVPBlocks.end(),
|
||||
[this, &block](const MVP32x32BlockGroup& block32x32)
|
||||
{ return m_mvpBlockGrid[block32x32.second] == block; }) != intersected32x32MVPBlocks.end())
|
||||
{
|
||||
block.SetGroup(firstValidGroupNo);
|
||||
}
|
||||
}
|
||||
// The list is valid - set PU pool group no. with the value for MVP blocks
|
||||
m_PUtoMVPPoolGroupMap[PU] = firstValidGroupNo;
|
||||
}
|
||||
}
|
||||
else // Otherwise, put all MVP blocks in the new group
|
||||
{
|
||||
for (MVPBlock& block : m_mvpBlockGrid)
|
||||
{
|
||||
if (std::find_if(intersected32x32MVPBlocks.begin(), intersected32x32MVPBlocks.end(),
|
||||
[this, &block](const MVP32x32BlockGroup& block32x32)
|
||||
{ return m_mvpBlockGrid[block32x32.second] == block; }) != intersected32x32MVPBlocks.end())
|
||||
{
|
||||
block.SetGroup(extMVPGroupNo);
|
||||
}
|
||||
}
|
||||
|
||||
// The list is valid - set PU pool group no. with the value for MVPs
|
||||
m_PUtoMVPPoolGroupMap[PU] = extMVPGroupNo;
|
||||
|
||||
++extMVPGroupNo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return extMVPGroupNo;
|
||||
}
|
||||
|
||||
mfxI32 MVMVPProcessor::PutPUAndMVPBlocksInSingleMVPPoolGroup(const CTUDescriptor & CTU)
|
||||
{
|
||||
const mfxI32 extGroupNo = 0;
|
||||
|
||||
for (MVPBlock& block : m_mvpBlockGrid)
|
||||
{
|
||||
block.SetGroup(extGroupNo);
|
||||
}
|
||||
|
||||
for (const auto& CU : CTU.m_CUVec)
|
||||
{
|
||||
if (CU.m_PredType == INTER_PRED)
|
||||
{
|
||||
for (const auto& PU : CU.m_PUVec)
|
||||
{
|
||||
m_PUtoMVPPoolGroupMap[PU] = extGroupNo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Fills output mfxExtFeiHevcEncMVPredictors::Data with generated MVP Grid data depending on the m_GenMVPBlockSize value
|
||||
//
|
||||
// frameDescr - MOD frame descriptor. It holds ext buffers
|
||||
void MVMVPProcessor::FillFrameMVPExtBuffer(FrameChangeDescriptor& frameDescr)
|
||||
{
|
||||
ExtendedSurface& surf = *frameDescr.m_frame;
|
||||
|
||||
mfxExtFeiHevcEncMVPredictors* mvpBuf =
|
||||
reinterpret_cast<mfxExtFeiHevcEncMVPredictors*>(surf.GetBuffer(MFX_EXTBUFF_HEVCFEI_ENC_MV_PRED));
|
||||
|
||||
m_DoUseIntra = !!(frameDescr.m_testType & GENERATE_INTRA);
|
||||
|
||||
switch (m_GenMVPBlockSize)
|
||||
{
|
||||
case 0:
|
||||
// No MVP specified. Left buffer unchanged
|
||||
break;
|
||||
case 1:
|
||||
// MVP for 16x16 blocks
|
||||
// Iterating over all generated blocks
|
||||
for (const auto& block : m_mvpBlockGrid)
|
||||
{
|
||||
PutMVPIntoExtBuffer(block, mvpBuf);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// MVP for 32x32 blocks
|
||||
// Iterating over each upper-left block in the 32x32 group
|
||||
// | 0* 1 | 4* 5 |
|
||||
// | 2 3 | 6 7 |
|
||||
for (std::size_t gridIdx = 0; gridIdx < m_mvpBlockGrid.size(); gridIdx += 4)
|
||||
{
|
||||
PutMVPIntoExtBuffer(m_mvpBlockGrid[gridIdx], mvpBuf);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// MVP for 64x64 blocks
|
||||
// 16x16 blocks marked with X should be the same in the output predictors buffer
|
||||
// ++++++++++++++++++++
|
||||
// + X + + X + +
|
||||
// +++++++++++++++++ ...
|
||||
// + + + + +
|
||||
// +++++++++++++++++
|
||||
// + X + + X + + ...
|
||||
// +++++++++++++++++
|
||||
// + + + + +
|
||||
// +++++++++++++++++
|
||||
// + ...
|
||||
PutMVPIntoExtBuffer(m_mvpBlockGrid[0], mvpBuf);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool MVMVPProcessor::GenValidMVMVPForPU(PUBlock & PU, const FrameChangeDescriptor & frameDescr)
|
||||
{
|
||||
const auto mvpGroupNo = m_PUtoMVPPoolGroupMap.find(PU);
|
||||
|
||||
if (mvpGroupNo != m_PUtoMVPPoolGroupMap.end())
|
||||
{
|
||||
if (mvpGroupNo->second < 0)
|
||||
{
|
||||
throw std::string("ERROR: MVMVPProcessor: GenValidMVMVPForPU: Some PU has invalid MVP pool no.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::string("ERROR: MVMVPProcessor: GenValidMVMVPForPU: Some PU hasn't been included in MVP pool group map");
|
||||
}
|
||||
|
||||
// Inter prediction test
|
||||
// Try 100 times max to generate valid references
|
||||
for (mfxU32 i = 0; i < MAX_GEN_MV_ATTEMPTS; ++i)
|
||||
{
|
||||
PUMotionVector mvSW;
|
||||
if (frameDescr.m_testType & GENERATE_MV)
|
||||
{
|
||||
// If GENERATE_MV is specified, generate a vector inside SW; else, leave mvSW a zero vector
|
||||
// Always create mv inside SW; mvp - outside SW
|
||||
mvSW = GenerateMV(frameDescr);
|
||||
}
|
||||
|
||||
std::vector<PUMotionVector> mvpPoolForPU(m_mvpPools[mvpGroupNo->second]);
|
||||
|
||||
while (!mvpPoolForPU.empty())
|
||||
{
|
||||
mfxU32 localMvpIndex = GetRandomGen().GetRandomNumber(0, (mfxI32)mvpPoolForPU.size() - 1);
|
||||
|
||||
PU.m_MVP = mvpPoolForPU[localMvpIndex];
|
||||
|
||||
// Final MV; operator + used here
|
||||
// Important: m_MV inherits refIdx from m_MVP. It is done so because MVP would be written to file if required.
|
||||
// MV is never reported outside.
|
||||
PU.m_MV = PU.m_MVP + mvSW;
|
||||
|
||||
if (frameDescr.IsNewPUValid(PU))
|
||||
{
|
||||
// Get index of the MVP applied to this PU from the original MVP generation pool
|
||||
for (mfxU32 originalMvpIndex = 0; originalMvpIndex < MVP_PER_16x16_BLOCK; ++originalMvpIndex)
|
||||
{
|
||||
if (m_mvpPools[mvpGroupNo->second][originalMvpIndex] == PU.m_MVP)
|
||||
{
|
||||
PU.usedMVPPoolNo = mvpGroupNo->second;
|
||||
PU.usedMVPIndex = originalMvpIndex;
|
||||
}
|
||||
}
|
||||
return true; // MV generation for current PU succeeded
|
||||
}
|
||||
else
|
||||
{
|
||||
mvpPoolForPU.erase(mvpPoolForPU.begin() + localMvpIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false; //MV generation for current PU failed
|
||||
}
|
||||
|
||||
//Attempts to generate MVs for PUs inside the CU and store the information about the blocks occupied
|
||||
//by newly generated PUs in corresponding reference frame descriptors
|
||||
bool MVMVPProcessor::GenValidMVForPU(PUBlock & PU, const FrameChangeDescriptor & frameDescr)
|
||||
{
|
||||
if (!(frameDescr.m_testType & GENERATE_MV))
|
||||
{
|
||||
return true; //No MVs requested
|
||||
}
|
||||
|
||||
// Inter prediction test
|
||||
// Try 100 times max to generate valid references
|
||||
for (mfxU32 i = 0; i < MAX_GEN_MV_ATTEMPTS; ++i)
|
||||
{
|
||||
// Always create mv inside SW; mvp - outside SW (if predictors are not required, mvp is zero vector)
|
||||
PUMotionVector mvSW = GenerateMV(frameDescr);
|
||||
|
||||
PU.m_MVP = PUMotionVector(
|
||||
mfxU8(GetRandomGen().GetRandomNumber(0, std::max(0, mfxU8(frameDescr.m_refDescrList0.size()) - 1))),
|
||||
mfxU8(GetRandomGen().GetRandomNumber(0, std::max(0, mfxU8(frameDescr.m_refDescrList1.size()) - 1))),
|
||||
mfxI16(0), mfxI16(0), mfxI16(0), mfxI16(0));
|
||||
|
||||
// Final MV; operator + used here
|
||||
// Important: m_MV inherits refIdx from m_MVP. It is done so because MVP would be written to file if required.
|
||||
// MV is never reported outside.
|
||||
PU.m_MV = PU.m_MVP + mvSW;
|
||||
|
||||
// Check whether the generated PU is located inside frame boundaries
|
||||
// Check generated PU for intersection with previous PUs pointing to other frames
|
||||
if (frameDescr.IsNewPUValid(PU))
|
||||
{
|
||||
return true; //MV generation for current PU succeeded
|
||||
}
|
||||
}
|
||||
|
||||
return false; //MV generation for current PU failed
|
||||
}
|
||||
|
||||
// Generate Motion Vector Predictor, i.e such a vector that all HW_SEARCH_ELEMENT_SIZE-sized square blocks
|
||||
// inside the CTU shifted by this vector will be located outside their own search windows (which have same
|
||||
// size but are centered each on its own search element block), and the CTU itself is still located
|
||||
// inside the frame
|
||||
// If the frame size is smaller than the search window size, generate MVP with zero spatial coordinates.
|
||||
// Function generates predictors for list 1 only on B frames (not on GPB)
|
||||
//
|
||||
// const CTUDescriptor & CTU - current CTU which should be located inside the frame with predictor applied as MV
|
||||
// const FrameChangeDescriptor & frameChangeDescr - descriptor which contains these fields:
|
||||
// mfxU8 numl0_refs / numl1_refs - current limits on number of active references
|
||||
// mfxU32 surf_width / surf_height - size of current surface
|
||||
PUMotionVector MVMVPProcessor::GenerateMVP(const CTUDescriptor & CTU, const FrameChangeDescriptor & frameChangeDescr)
|
||||
{
|
||||
const auto& numl0_refs = frameChangeDescr.m_refDescrList0;
|
||||
const auto& numl1_refs = frameChangeDescr.m_refDescrList1;
|
||||
|
||||
bool hasList1 = !numl1_refs.empty();
|
||||
|
||||
if (hasList1 && !frameChangeDescr.m_bUseBiDirSW)
|
||||
{
|
||||
throw std::string("ERROR: GenerateMVP: attempted to generate MVPs for a B-frame/GPB using unidirectional search window");
|
||||
}
|
||||
|
||||
bool isB = !!(frameChangeDescr.m_frameType & MFX_FRAMETYPE_B);
|
||||
|
||||
const mfxU32* current_lim = frameChangeDescr.m_bUseBiDirSW ? SKL_SW_LIM_BD : SKL_SW_LIM_OD;
|
||||
|
||||
mfxU32 x_lim_SW = current_lim[0] / 2;
|
||||
mfxU32 y_lim_SW = current_lim[1] / 2;
|
||||
|
||||
mfxI32 x_coord[2] = { 0 };
|
||||
mfxI32 y_coord[2] = { 0 };
|
||||
|
||||
// Precomputing min and max possible MVP coordinates so that the MVP points outside SW but inside
|
||||
// the frame (i.e. the CTU with applied MVP should be located outside SW and inside the frame,
|
||||
// if possible)
|
||||
mfxU32 x_min = x_lim_SW + HW_SEARCH_ELEMENT_SIZE / 2; //When determining min absolute shift, one should use
|
||||
//the search element size, not the CTU size. With max
|
||||
//CTU size is still used so that it stays inside the frame
|
||||
|
||||
mfxU32 x_max_pos = frameChangeDescr.GetFrameCropW()
|
||||
- (CTU.m_BWidth + CTU.m_AdrX); //Max absolute value of MVP coord for positive
|
||||
mfxU32 x_max_neg = CTU.m_AdrX; //and negative coordinates respectively.
|
||||
|
||||
mfxU32 y_min = y_lim_SW + HW_SEARCH_ELEMENT_SIZE / 2;
|
||||
|
||||
mfxU32 y_max_pos = frameChangeDescr.GetFrameCropH() - (CTU.m_BWidth + CTU.m_AdrY);
|
||||
mfxU32 y_max_neg = CTU.m_AdrY;
|
||||
|
||||
//Crop the max coords due to hardware limitations
|
||||
x_max_pos = std::min(x_max_pos, ((mfxU32)((MVMVP_SIZE_LIMIT >> 2) - x_lim_SW)));
|
||||
x_max_neg = std::min(x_max_neg, ((mfxU32)((MVMVP_SIZE_LIMIT >> 2) - x_lim_SW)));
|
||||
y_max_pos = std::min(y_max_pos, ((mfxU32)((MVMVP_SIZE_LIMIT >> 2) - y_lim_SW)));
|
||||
y_max_neg = std::min(y_max_neg, ((mfxU32)((MVMVP_SIZE_LIMIT >> 2) - y_lim_SW)));
|
||||
|
||||
enum SHIFT { X_POS, X_NEG, Y_POS, Y_NEG };
|
||||
|
||||
std::vector<SHIFT> availShifts;
|
||||
availShifts.reserve(4);
|
||||
|
||||
if (x_min < x_max_pos) availShifts.push_back(X_POS);
|
||||
if (x_min < x_max_neg) availShifts.push_back(X_NEG);
|
||||
if (y_min < y_max_pos) availShifts.push_back(Y_POS);
|
||||
if (y_min < y_max_neg) availShifts.push_back(Y_NEG);
|
||||
|
||||
if (!availShifts.empty())
|
||||
{
|
||||
for (mfxI32 i = 0; i < (isB ? 2 : 1); i++)
|
||||
{
|
||||
SHIFT shift = availShifts[GetRandomGen().GetRandomNumber(0, (mfxI32)(availShifts.size() - 1))];
|
||||
switch (shift)
|
||||
{
|
||||
case X_POS:
|
||||
x_coord[i] = GetRandomMVComponent(x_min, x_max_pos);
|
||||
break;
|
||||
case X_NEG:
|
||||
x_coord[i] = -GetRandomMVComponent(x_min, x_max_neg);
|
||||
break;
|
||||
case Y_POS:
|
||||
y_coord[i] = GetRandomMVComponent(y_min, y_max_pos);
|
||||
break;
|
||||
case Y_NEG:
|
||||
y_coord[i] = -GetRandomMVComponent(y_min, y_max_neg);
|
||||
break;
|
||||
}
|
||||
|
||||
//The complementary MVP coordinate should be subjected to the HW limit as well
|
||||
if (shift == X_POS || shift == X_NEG)
|
||||
{
|
||||
mfxU32 max_pos_shift_y = std::min(frameChangeDescr.GetFrameCropH() - CTU.m_BHeight - CTU.m_AdrY,
|
||||
(mfxU32)MVMVP_SIZE_LIMIT >> 2);
|
||||
mfxU32 max_neg_shift_y = std::min(CTU.m_AdrY, (mfxU32)MVMVP_SIZE_LIMIT >> 2);
|
||||
y_coord[i] = GetRandomMVComponent(-(mfxI32)max_neg_shift_y, max_pos_shift_y);
|
||||
}
|
||||
else
|
||||
{
|
||||
mfxU32 max_pos_shift_x = std::min(frameChangeDescr.GetFrameCropW() - CTU.m_BWidth - CTU.m_AdrX,
|
||||
(mfxU32)MVMVP_SIZE_LIMIT >> 2);
|
||||
mfxU32 max_neg_shift_x = std::min(CTU.m_AdrX, (mfxU32)MVMVP_SIZE_LIMIT >> 2);
|
||||
x_coord[i] = GetRandomMVComponent(-(mfxI32)max_neg_shift_x, max_pos_shift_x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PUMotionVector(
|
||||
(mfxI32)!numl0_refs.empty() ? mfxU8(GetRandomGen().GetRandomNumber(0, (mfxI32)numl0_refs.size() - 1)) : 0,
|
||||
(mfxI32)!numl1_refs.empty() ? mfxU8(GetRandomGen().GetRandomNumber(0, (mfxI32)numl1_refs.size() - 1)) : 0, // RefIdx struct
|
||||
x_coord[0], // MV[0].x
|
||||
y_coord[0], // MV[0].y
|
||||
isB ? x_coord[1] : 0, // MV[1].x
|
||||
isB ? y_coord[1] : 0 // MV[1].y
|
||||
);
|
||||
}
|
||||
|
||||
// Generates an MV so that a PU_width x PU_height-sized block shifted by this MV
|
||||
// will be located inside(sic!) SW. It doesn't generate refIdx. refIdx is generated in GenerateMVP
|
||||
// Function generates MVs for list 1 only on B frames (not on GPB)
|
||||
//
|
||||
// mfxU32 PU_width/PU_height - size of current PU
|
||||
PUMotionVector MVMVPProcessor::GenerateMV(const FrameChangeDescriptor & frameChangeDescr)
|
||||
{
|
||||
const auto& numl1_refs = frameChangeDescr.m_refDescrList1;
|
||||
|
||||
bool hasList1 = !numl1_refs.empty();
|
||||
|
||||
if (hasList1 && !frameChangeDescr.m_bUseBiDirSW)
|
||||
{
|
||||
throw std::string("ERROR: GenerateMV: attempted to generate MVs for a B-frame/GPB using unidirectional search window");
|
||||
}
|
||||
|
||||
bool isB = !!(frameChangeDescr.m_frameType & MFX_FRAMETYPE_B);
|
||||
|
||||
const mfxU32* current_lim = frameChangeDescr.m_bUseBiDirSW ? SKL_SW_LIM_BD : SKL_SW_LIM_OD;
|
||||
|
||||
// Just half of current SW width / height
|
||||
mfxI32 x_lim = 0, y_lim = 0;
|
||||
|
||||
constexpr mfxU32 searchElementWidth = HW_SEARCH_ELEMENT_SIZE;
|
||||
constexpr mfxU32 searchElementHeight = HW_SEARCH_ELEMENT_SIZE;
|
||||
|
||||
//Leave limits at zero if PU size exceeds the search window
|
||||
if (current_lim[0] >= searchElementWidth && current_lim[1] >= searchElementHeight)
|
||||
{
|
||||
x_lim = (current_lim[0] - searchElementWidth) / 2;
|
||||
y_lim = (current_lim[1] - searchElementHeight) / 2;
|
||||
}
|
||||
|
||||
// Using RVO here
|
||||
return PUMotionVector(
|
||||
0,
|
||||
0, // RefIdx struct
|
||||
GetRandomMVComponent(-x_lim, x_lim), // MV[0].x
|
||||
GetRandomMVComponent(-y_lim, y_lim), // MV[0].y
|
||||
isB ? GetRandomMVComponent(-x_lim, x_lim) : 0, // MV[1].x
|
||||
isB ? GetRandomMVComponent(-y_lim, y_lim) : 0 // MV[1].y
|
||||
);
|
||||
}
|
||||
|
||||
// Randomly generates single MV-component within [lower; upper] accordigly to the sub pixel precision mode
|
||||
// Where lower and upper given in full-pixel units.
|
||||
// Output component is in quarter-pixel units.
|
||||
//
|
||||
// { a = lower * 4 }
|
||||
// { b = upper * 4 }
|
||||
//
|
||||
// [a * # * a+1 * # * a+2 ... b-2 * # * b-1 * # * b]
|
||||
// For mode 0: only full-pixels a, a+1, ... b-2, b-1, b are allowed
|
||||
// For mode 1: full and half-pixels # are allowed
|
||||
// For mode 3: every quarter-pixel value is allowed
|
||||
mfxI32 MVMVPProcessor::GetRandomMVComponent(mfxI32 lower, mfxI32 upper)
|
||||
{
|
||||
ASGRandomGenerator& randomGen = GetRandomGen();
|
||||
switch (m_SubPelMode)
|
||||
{
|
||||
case 0:
|
||||
return 4 * lower + randomGen.GetRandomNumber(0, upper - lower) * 4;
|
||||
case 1:
|
||||
return 4 * lower + randomGen.GetRandomNumber(0, 2 * (upper - lower)) * 2;
|
||||
case 3:
|
||||
return randomGen.GetRandomNumber(4 * lower, 4 * upper);
|
||||
default:
|
||||
throw std::string("ERROR: MVMVPProcessor: GetRandomMVComponent: Incorrect m_SubPelMode used");
|
||||
}
|
||||
}
|
||||
|
||||
mfxU32 MVMVPProcessor::CalculateOffsetInMVPredictorsBuffer(mfxU32 bufferPitch, const MVPBlock & mvpBlock)
|
||||
{
|
||||
// Calculating a no. of 32x32 block corresponding to left upper pixel of the CTU MVP grid
|
||||
// In sum below: first addendum is offset by vertical axis, second addendum is offset by horizontal axis
|
||||
mfxU32 offsetBig = (bufferPitch / 2) * (mvpBlock.m_AdrY / (2 * MVP_BLOCK_SIZE))
|
||||
+ (mvpBlock.m_AdrX / (2 * MVP_BLOCK_SIZE));
|
||||
|
||||
// Calculating a postion for 16x16 block inside parent 32x32 block
|
||||
mfxU32 offsetSmall = 2 * ((mvpBlock.m_AdrY % (2 * MVP_BLOCK_SIZE)) / MVP_BLOCK_SIZE)
|
||||
+ ((mvpBlock.m_AdrX % (2 * MVP_BLOCK_SIZE)) / MVP_BLOCK_SIZE);
|
||||
|
||||
return 4 * offsetBig + offsetSmall;
|
||||
}
|
||||
|
||||
void MVMVPProcessor::PutMVPIntoExtBuffer(const MVPBlock& mvpBlock, mfxExtFeiHevcEncMVPredictors* outputMVPBuf)
|
||||
{
|
||||
if (!outputMVPBuf)
|
||||
{
|
||||
throw std::string("ERROR: MVMVPProcessor: PutMVPIntoExtBuffer: Output mfxExtFeiHevcEncMVPredictors buffer is null");
|
||||
}
|
||||
|
||||
mfxU32 offset = CalculateOffsetInMVPredictorsBuffer(outputMVPBuf->Pitch, mvpBlock);
|
||||
|
||||
mfxFeiHevcEncMVPredictors& actualPredictor = outputMVPBuf->Data[offset];
|
||||
|
||||
mfxI32 mvpGroupNo = mvpBlock.GetGroupNo();
|
||||
|
||||
// In case of INTRAxINTER test some MVP blocks
|
||||
// may not intersect with PUs inside CTU
|
||||
// Otherwise, all MVP blocks should be assigned with a valid group no.
|
||||
if (mvpGroupNo < 0)
|
||||
{
|
||||
if (m_DoUseIntra)
|
||||
{
|
||||
// For such intra MVP block filling corresponding element in the buffer with ignored values
|
||||
for (mfxU32 mvpIdx = 0; mvpIdx < MVP_PER_16x16_BLOCK; mvpIdx++)
|
||||
{
|
||||
actualPredictor.MV[mvpIdx][0].x = actualPredictor.MV[mvpIdx][0].y = (mfxI16)0x8000;
|
||||
actualPredictor.MV[mvpIdx][1].x = actualPredictor.MV[mvpIdx][1].y = (mfxI16)0x8000;
|
||||
|
||||
actualPredictor.RefIdx[mvpIdx].RefL0 = (mfxU8)0xf;
|
||||
actualPredictor.RefIdx[mvpIdx].RefL1 = (mfxU8)0xf;
|
||||
}
|
||||
|
||||
// Nevertheless, setting BlockSize appropriately
|
||||
actualPredictor.BlockSize = m_GenMVPBlockSize;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, something definitely went wrong
|
||||
throw std::string("ERROR: PutMVPIntoExtBuffer: Some MVP block has invalid MVP pool no.");
|
||||
}
|
||||
|
||||
for (mfxU32 mvpIdx = 0; mvpIdx < MVP_PER_16x16_BLOCK; mvpIdx++)
|
||||
{
|
||||
const auto& genMVPred = m_mvpPools[mvpGroupNo][mvpIdx];
|
||||
|
||||
if (genMVPred.CheckMVPExceedsSizeLimits())
|
||||
{
|
||||
throw std::string("ERROR: PutMVPIntoExtBuffer: generated MVP size exceeds hardware limit");
|
||||
}
|
||||
|
||||
actualPredictor.RefIdx[mvpIdx].RefL0 = genMVPred.RefIdx.RefL0;
|
||||
actualPredictor.RefIdx[mvpIdx].RefL1 = genMVPred.RefIdx.RefL1;
|
||||
actualPredictor.MV[mvpIdx][0] = genMVPred.MV[0];
|
||||
actualPredictor.MV[mvpIdx][1] = genMVPred.MV[1];
|
||||
}
|
||||
|
||||
// Assuming that, m_GenMVPBlockSize has correct value
|
||||
actualPredictor.BlockSize = m_GenMVPBlockSize;
|
||||
|
||||
// Special case for 64x64 blocks - copying initialized data to the neighbour blocks
|
||||
if (m_GenMVPBlockSize == 3)
|
||||
{
|
||||
if (outputMVPBuf->Pitch > 0)
|
||||
{
|
||||
outputMVPBuf->Data[offset + 4] = actualPredictor;
|
||||
outputMVPBuf->Data[offset + outputMVPBuf->Pitch] = actualPredictor;
|
||||
outputMVPBuf->Data[offset + outputMVPBuf->Pitch + 4] = actualPredictor;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::string("ERROR: PutMVPIntoExtBuffer: mfxExtFeiHevcEncMVPredictors have zero pitch");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MVMVPProcessor::GetMVPPools(std::vector<std::vector<PUMotionVector>>& outMVPPools)
|
||||
{
|
||||
outMVPPools = m_mvpPools;
|
||||
}
|
||||
|
||||
#endif // MFX_VERSION
|
|
@ -1,67 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include "random_generator.h"
|
||||
|
||||
ASGRandomGenerator& ASGRandomGenerator::GetInstance()
|
||||
{
|
||||
static ASGRandomGenerator instance;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
// Returns random number in range [min, max]
|
||||
mfxI32 ASGRandomGenerator::GetRandomNumber(mfxI32 min, mfxI32 max)
|
||||
{
|
||||
std::uniform_int_distribution<> distr(min, max);
|
||||
return distr(m_Gen);
|
||||
}
|
||||
|
||||
// Returns +1 or -1 with probability 0.5
|
||||
mfxI32 ASGRandomGenerator::GetRandomSign()
|
||||
{
|
||||
return GetRandomBit() ? -1 : 1;
|
||||
}
|
||||
|
||||
// Generates 0 or 1 with probability 0.5
|
||||
bool ASGRandomGenerator::GetRandomBit()
|
||||
{
|
||||
std::bernoulli_distribution distr(0.5);
|
||||
return distr(m_Gen);
|
||||
}
|
||||
|
||||
// Returns TF or BF with probability 0.5
|
||||
mfxI32 ASGRandomGenerator::GetRandomPicField()
|
||||
{
|
||||
static const mfxI32 cases[] = { MFX_PICSTRUCT_FIELD_TOP, MFX_PICSTRUCT_FIELD_BOTTOM };
|
||||
std::uniform_int_distribution<> distr{ 0, sizeof(cases) / sizeof(cases[0]) - 1 };
|
||||
return cases[distr(m_Gen)];
|
||||
}
|
||||
|
||||
void ASGRandomGenerator::SeedGenerator(mfxU32 extSeed)
|
||||
{
|
||||
m_Gen.seed(extSeed);
|
||||
}
|
||||
|
||||
#endif // MFX_VERSION
|
|
@ -1,227 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include "refcontrol.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void RefState::Dump(fstream& ofs) const
|
||||
{
|
||||
const char separator = '|';
|
||||
|
||||
ofs << setw(3) << picture.orderCount << ' '
|
||||
<< hex << showbase << setw(3 + 2) << picture.frameType << ' '
|
||||
<< setw(3 + 2) << picture.picStruct << dec;
|
||||
if (ofs.fail())
|
||||
throw std::string("ERROR: PicStruct buffer writing failed");
|
||||
for (mfxU32 list = 0; list < 2; list++)
|
||||
{
|
||||
ofs << ' ' << separator;
|
||||
for (mfxU32 i = 0; i < 8; i++)
|
||||
ofs << ' ' << setw(3) << (i < RefListActive[list].size() ? RefListActive[list][i] : -1);
|
||||
}
|
||||
ofs << ' ' << separator;
|
||||
for (mfxU32 i = 0; i < 16; i++)
|
||||
ofs << ' ' << setw(3) << (i < DPB.size() ? DPB[i] : -1);
|
||||
ofs << endl;
|
||||
}
|
||||
|
||||
bool RefState::Load(fstream& ifs)
|
||||
{
|
||||
const char separator_char = '|';
|
||||
char separator;
|
||||
RefState state;
|
||||
|
||||
ifs >> state.picture.orderCount >> hex >> state.picture.frameType >> state.picture.picStruct >> dec;
|
||||
if (ifs.fail())
|
||||
return false;
|
||||
|
||||
for (mfxU32 list = 0; list < 2; list++)
|
||||
{
|
||||
ifs >> separator;
|
||||
if (ifs.fail() || separator != separator_char)
|
||||
return false;
|
||||
state.RefListActive[list].clear();
|
||||
for (mfxI32 poc, i = 0; i < 8 && !(ifs >> poc).fail(); i++) {
|
||||
if (poc >= 0)
|
||||
state.RefListActive[list].push_back(poc);
|
||||
}
|
||||
}
|
||||
|
||||
ifs >> separator;
|
||||
if (ifs.fail() || separator != separator_char)
|
||||
return false;
|
||||
state.DPB.clear();
|
||||
for (mfxI32 poc, i = 0; i < 16 && !(ifs >> poc).fail(); i++) {
|
||||
if (poc >= 0)
|
||||
state.DPB.push_back(poc);
|
||||
}
|
||||
|
||||
*this = state;
|
||||
return true;
|
||||
}
|
||||
|
||||
void RefControl::SetParams(const InputParams& params)
|
||||
{
|
||||
m_params = params;
|
||||
maxDelay = params.m_RefDist * 2 + 1; // 2 for fields, 1 from asyncDepth
|
||||
maxDPBSize = params.m_NumRef + 1; // +1 to align with common msdk rules, that current frame is not counted in DPB
|
||||
}
|
||||
|
||||
void RefControl::Encode(mfxI32 codingOrder)
|
||||
{
|
||||
if (RPB.empty())
|
||||
throw std::string("ERROR: PicStruct buffer frame is lost");
|
||||
|
||||
// select next frame to encode (no reordering for I and P)
|
||||
mfxI32 RPBidx = 0;
|
||||
if (RPB[0].frameType & MFX_FRAMETYPE_B)
|
||||
{
|
||||
mfxI32 cnt, i;
|
||||
for (cnt = 1; cnt < static_cast<mfxI32>(RPB.size()) &&
|
||||
(RPB[cnt].frameType & MFX_FRAMETYPE_B) &&
|
||||
RPB[0].orderCount + cnt == RPB[cnt].orderCount;
|
||||
cnt++); // consequent B count
|
||||
if (cnt < static_cast<mfxI32>(RPB.size()) && RPB[0].orderCount + cnt == RPB[cnt].orderCount)
|
||||
RPBidx = cnt; // consequent not B is pyramid's right base
|
||||
else
|
||||
{
|
||||
for (i = 1; i < cnt; i++)
|
||||
if ((RPB[i].frameType & MFX_FRAMETYPE_REF) && std::abs(i - cnt / 2) < std::abs(RPBidx - cnt / 2))
|
||||
RPBidx = i; // Bref closest to center of consequent B
|
||||
}
|
||||
}
|
||||
|
||||
RefState state; // create state
|
||||
PictureInfo& picture = state.picture;
|
||||
|
||||
picture = RPB[RPBidx]; // take from reordered
|
||||
RPB.erase(RPB.begin() + RPBidx); // and remove
|
||||
picture.codingOrder = codingOrder;
|
||||
|
||||
if (picture.frameType & MFX_FRAMETYPE_IDR)
|
||||
DPB.clear();
|
||||
// current frame occupies DPB by spec, free one place
|
||||
if (DPB.size() == maxDPBSize)
|
||||
DPB.erase(std::min_element(DPB.begin(), DPB.end(), IsOlder));
|
||||
|
||||
// fill list randomly from DPB
|
||||
mfxU32 RefListNum[2] = { 0, 0 };
|
||||
if (!DPB.empty())
|
||||
{
|
||||
if (picture.frameType & MFX_FRAMETYPE_P)
|
||||
RefListNum[0] = m_params.m_NumRefActiveP;
|
||||
else if (picture.frameType & MFX_FRAMETYPE_B)
|
||||
{
|
||||
RefListNum[0] = m_params.m_NumRefActiveBL0;
|
||||
RefListNum[1] = m_params.m_NumRefActiveBL1;
|
||||
}
|
||||
if (picture.frameType & MFX_FRAMETYPE_P && m_params.m_UseGPB)
|
||||
{
|
||||
picture.frameType &= ~MFX_FRAMETYPE_P;
|
||||
picture.frameType |= MFX_FRAMETYPE_B;
|
||||
RefListNum[1] = std::min(m_params.m_NumRefActiveP, m_params.m_NumRefActiveBL1);
|
||||
}
|
||||
}
|
||||
|
||||
for (mfxU32 list = 0; list < 2; list++)
|
||||
{
|
||||
state.RefListActive[list].clear();
|
||||
for (mfxU32 pic = 0; pic < RefListNum[list]; pic++)
|
||||
{
|
||||
state.RefListActive[list].push_back(DPB[GetRandomGen().GetRandomNumber(0, (mfxI32)DPB.size() - 1)].orderCount);
|
||||
}
|
||||
}
|
||||
|
||||
state.DPB.clear();
|
||||
for (auto pic : DPB)
|
||||
state.DPB.push_back(pic.orderCount);
|
||||
std::sort(state.DPB.begin(), state.DPB.end()); // to simplify matching
|
||||
|
||||
// store state and put reference picture into DPB
|
||||
RefLogInfo.emplace_back(state);
|
||||
if (picture.frameType & MFX_FRAMETYPE_REF)
|
||||
DPB.emplace_back(picture);
|
||||
}
|
||||
|
||||
// assign types in display order
|
||||
// don't care about fields - must work
|
||||
void RefControl::Add(mfxI32 frameOrder)
|
||||
{
|
||||
PictureInfo picture;
|
||||
picture.codingOrder = -1; // randomly decided later
|
||||
picture.orderCount = frameOrder;
|
||||
picture.picStruct = GetRandomGen().GetRandomPicField();
|
||||
|
||||
mfxU16 type = 0;
|
||||
mfxI32 poc = frameOrder - m_lastIDR;
|
||||
mfxI32 nextIDRpoc = m_params.m_nIdrInterval*m_params.m_GopSize;
|
||||
mfxI32 pocEnd = std::min(nextIDRpoc, static_cast<mfxI32>(m_params.m_numFrames) - m_lastIDR); // last before IDR or last picture
|
||||
|
||||
if (poc == 0 || poc == nextIDRpoc)
|
||||
{
|
||||
type = MFX_FRAMETYPE_IDR | MFX_FRAMETYPE_REF | MFX_FRAMETYPE_I;
|
||||
m_lastIDR = frameOrder;
|
||||
}
|
||||
else if (poc % m_params.m_GopSize == 0)
|
||||
type = MFX_FRAMETYPE_REF | MFX_FRAMETYPE_I;
|
||||
else if (poc % m_params.m_GopSize % m_params.m_RefDist == 0 || poc + 1 == pocEnd) // also last before IDR or last picture
|
||||
type = MFX_FRAMETYPE_REF | MFX_FRAMETYPE_P;
|
||||
else
|
||||
{
|
||||
type = MFX_FRAMETYPE_B;
|
||||
if (m_params.m_BRefType != MFX_B_REF_OFF)
|
||||
{
|
||||
mfxI32 bord = poc % m_params.m_GopSize % m_params.m_RefDist; // pos in consequent B [1; dist-1]
|
||||
mfxI32 s = (pocEnd - (poc - bord) > m_params.m_RefDist) ? m_params.m_RefDist : pocEnd - (poc - bord) - 1; // real num B
|
||||
for (; bord > 1 && s > 2; ) // 1: next to refpoint, 2: max span w/o ref
|
||||
{
|
||||
mfxI32 nexts = (s + 1) / 2; // middle (ref) point; left span is bigger for odds
|
||||
if (bord == nexts) // if in the middle - mark as ref
|
||||
{
|
||||
type |= MFX_FRAMETYPE_REF;
|
||||
break;
|
||||
}
|
||||
else if (bord > nexts) // shift to right span
|
||||
{
|
||||
bord -= nexts;
|
||||
s -= nexts;
|
||||
}
|
||||
else {
|
||||
s = nexts;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
picture.frameType = type;
|
||||
|
||||
RPB.emplace_back(picture);
|
||||
}
|
||||
|
||||
bool IsOlder(const PictureInfo& a, const PictureInfo& b) { return a.orderCount < b.orderCount; }
|
||||
|
||||
bool IsInCodingOrder(const RefState& a, const RefState& b) { return a.picture.codingOrder < b.picture.codingOrder; }
|
||||
|
||||
#endif // MFX_VERSION
|
|
@ -1,505 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
|
||||
#include "frame_marker.h"
|
||||
#include "test_processor.h"
|
||||
|
||||
ASGLog TestProcessor::asgLog;
|
||||
|
||||
//Base
|
||||
// Entry point for all test which uses TestProcessor
|
||||
void TestProcessor::RunTest(const InputParams & params)
|
||||
{
|
||||
try {
|
||||
Init(params);
|
||||
|
||||
switch(params.m_TestType)
|
||||
{
|
||||
case GENERATE_PICSTRUCT:
|
||||
RunPSTest(params);
|
||||
return;
|
||||
case GENERATE_REPACK_CTRL:
|
||||
if (params.m_ProcMode == GENERATE)
|
||||
RunRepackGenerate();
|
||||
else //VERIFY
|
||||
RunRepackVerify();
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//Check that processing parameters have correct number of elements
|
||||
if (m_vProcessingParams.size() != m_InputParams.m_numFrames)
|
||||
throw std::string("ERROR: Incorrect elements number in the m_vProcessingParams");
|
||||
|
||||
// Sort processing params into the encoded order
|
||||
std::sort(m_vProcessingParams.begin(), m_vProcessingParams.end(),
|
||||
[](const FrameProcessingParam& left, const FrameProcessingParam& right) { return left.EncodedOrder < right.EncodedOrder; });
|
||||
|
||||
auto itProcessingParam = m_vProcessingParams.begin();
|
||||
|
||||
// Iterate through frames
|
||||
for (mfxU32 i = 0; i < m_InputParams.m_numFrames; ++i)
|
||||
{
|
||||
// Load picture and obtain a surface
|
||||
ExtendedSurface* frame = PrepareSurface();
|
||||
|
||||
// Set display order for the surface
|
||||
frame->Data.FrameOrder = i;
|
||||
|
||||
// Find surface with the next encoded order in the surface pool
|
||||
auto itSurf = std::find_if(m_Surfaces.begin(), m_Surfaces.end(),
|
||||
[&itProcessingParam](const ExtendedSurface& ext_surf) { return ext_surf.Data.FrameOrder == itProcessingParam->DisplayOrder; });
|
||||
|
||||
// Do next iteration if surface pool hasn't got the required surface
|
||||
if (itSurf == m_Surfaces.end())
|
||||
continue;
|
||||
|
||||
// Set encoded order for the surface
|
||||
itSurf->encodedOrder = itProcessingParam->EncodedOrder;
|
||||
|
||||
// Generate all data
|
||||
ChangePicture(*itSurf);
|
||||
|
||||
// Write next available frames in the display order
|
||||
DropFrames();
|
||||
|
||||
if (m_InputParams.m_bIsForceExtMVPBlockSize)
|
||||
{
|
||||
itSurf->ForceMVPBlockSizeInOutputBuffer(m_InputParams.m_ForcedExtMVPBlockSize);
|
||||
}
|
||||
// Drop buffers in the encoded order
|
||||
DropBuffers(*itSurf);
|
||||
|
||||
// Go to the next frame in the encoded order
|
||||
++itProcessingParam;
|
||||
}
|
||||
|
||||
// Drain buffered frames
|
||||
while (itProcessingParam != m_vProcessingParams.end())
|
||||
{
|
||||
// Find surface with the next encoded order in the surface pool
|
||||
auto itSurf = std::find_if(m_Surfaces.begin(), m_Surfaces.end(),
|
||||
[&itProcessingParam](const ExtendedSurface& ext_surf) { return ext_surf.Data.FrameOrder == itProcessingParam->DisplayOrder; });
|
||||
|
||||
// All surfaces must be into the surface pool
|
||||
if(itSurf == m_Surfaces.end())
|
||||
throw std::string("ERROR: Surface pool doesn't have required surface");
|
||||
|
||||
// Set encoded order for the surface
|
||||
itSurf->encodedOrder = itProcessingParam->EncodedOrder;
|
||||
|
||||
// Generate all data
|
||||
ChangePicture(*itSurf);
|
||||
|
||||
// Write next available frames in the display order
|
||||
DropFrames();
|
||||
|
||||
if (m_InputParams.m_bIsForceExtMVPBlockSize)
|
||||
{
|
||||
itSurf->ForceMVPBlockSizeInOutputBuffer(m_InputParams.m_ForcedExtMVPBlockSize);
|
||||
}
|
||||
// Drop buffers in the encoded order
|
||||
DropBuffers(*itSurf);
|
||||
|
||||
// Go to the next frame in the encoded order
|
||||
++itProcessingParam;
|
||||
}
|
||||
}
|
||||
catch (std::string & e) {
|
||||
std::cout << e << std::endl;
|
||||
throw std::string("ERROR: TestProcessor::RunTest");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
struct sMultiPak
|
||||
{
|
||||
mfxU32 NumBytesInNalUnit;
|
||||
mfxU8 SliceQP;
|
||||
};
|
||||
|
||||
void TestProcessor::RunRepackGenerate()
|
||||
{
|
||||
mfxU32 maxNumBytesInNalUnit = 67104768; //14 bits value with the max unit 4K: 0x3FFF*4*1024
|
||||
mfxU32 MaxFrameSize;
|
||||
|
||||
sMultiPak multiPakInBin;
|
||||
|
||||
mfxU32 partFrame = 0;
|
||||
ASGRandomGenerator& randomGen = GetRandomGen();
|
||||
|
||||
randomGen.SeedGenerator((mfxU32)time(nullptr));
|
||||
|
||||
for (mfxU32 countFrame = 0; countFrame < m_InputParams.m_numFrames; countFrame++)
|
||||
{
|
||||
partFrame = randomGen.GetRandomNumber(0, 9);
|
||||
|
||||
fpRepackStr.read((mfxI8 *)&multiPakInBin, sizeof(multiPakInBin));
|
||||
if (!fpRepackStr.good())
|
||||
throw std::string("ERROR: multiPakStr file read failed");
|
||||
|
||||
if (multiPakInBin.NumBytesInNalUnit > maxNumBytesInNalUnit)
|
||||
throw std::string("ERROR: NumBytesInNalUnit more than HW limitation");
|
||||
|
||||
MaxFrameSize = multiPakInBin.NumBytesInNalUnit
|
||||
- (multiPakInBin.NumBytesInNalUnit*partFrame)/10;
|
||||
MaxFrameSize += 512; //Add a 512B window for headers.
|
||||
|
||||
//If max frame size exceeds 14 bits, the unit is 4KB, otherwise 32B.
|
||||
if (MaxFrameSize >= (0x1 << 14) * 32)
|
||||
MaxFrameSize = (MaxFrameSize + 0xFFF) & ~0xFFF; //Rounding to 4KB.
|
||||
else
|
||||
MaxFrameSize = (MaxFrameSize + 0x1F) & ~0x1F;//Rounding to 32B.
|
||||
|
||||
fpRepackCtrl.write((mfxI8 *)&MaxFrameSize, sizeof(MaxFrameSize));
|
||||
if (!fpRepackCtrl.good())
|
||||
throw std::string("ERROR: Repack ctrl file write failed");
|
||||
|
||||
fpRepackCtrl.write((mfxI8 *)&m_InputParams.m_NumAddPasses, sizeof(m_InputParams.m_NumAddPasses));
|
||||
if (!fpRepackCtrl.good())
|
||||
throw std::string("ERROR: Repack ctrl file write failed");
|
||||
|
||||
fpRepackCtrl.write((mfxI8 *)m_InputParams.m_DeltaQP, sizeof(m_InputParams.m_DeltaQP));
|
||||
if (!fpRepackCtrl.good())
|
||||
throw std::string("ERROR: Repack ctrl file write failed");
|
||||
}
|
||||
}
|
||||
|
||||
void TestProcessor::RunRepackVerify()
|
||||
{
|
||||
sMultiPak multiPakInBin;
|
||||
mfxExtFeiHevcRepackCtrl repackCtrl;
|
||||
mfxI8 repackStat[64];
|
||||
mfxU32 activeNumPasses;
|
||||
mfxU32 activeNumPassesMinus1;
|
||||
|
||||
for (mfxU32 countFrame = 0; countFrame < m_InputParams.m_numFrames; countFrame++)
|
||||
{
|
||||
// Read repack data from files
|
||||
activeNumPasses = -1;
|
||||
|
||||
fpRepackCtrl.read((mfxI8 *)&repackCtrl.MaxFrameSize, sizeof(repackCtrl.MaxFrameSize));
|
||||
if (!fpRepackCtrl.good())
|
||||
throw std::string("ERROR: Repack ctrl file read failed");
|
||||
|
||||
fpRepackCtrl.read((mfxI8 *)&repackCtrl.NumPasses, sizeof(repackCtrl.NumPasses));
|
||||
if (!fpRepackCtrl.good())
|
||||
throw std::string("ERROR: Repack ctrl file read failed");
|
||||
|
||||
fpRepackCtrl.read((mfxI8 *)&repackCtrl.DeltaQP, sizeof(repackCtrl.DeltaQP));
|
||||
if (!fpRepackCtrl.good())
|
||||
throw std::string("ERROR: Repack ctrl file read failed");
|
||||
|
||||
fpRepackStr.read((mfxI8 *)&multiPakInBin, sizeof(multiPakInBin));
|
||||
if (!fpRepackStr.good())
|
||||
throw std::string("ERROR: Repack str file read failed");
|
||||
|
||||
fpRepackStat.getline(repackStat, sizeof(repackStat));
|
||||
if (!fpRepackStat.good())
|
||||
throw std::string("ERROR: Repack stat file read failed");
|
||||
std::istringstream repackStatStream(std::string(repackStat, strlen(repackStat)));
|
||||
repackStatStream >> activeNumPasses;
|
||||
|
||||
// Check read repack data
|
||||
|
||||
if (0xFF == multiPakInBin.SliceQP)
|
||||
{
|
||||
// 0xFF indicates skipping
|
||||
std::cout << "INFO: Frame " << countFrame << " in coded order skipped" << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (repackCtrl.MaxFrameSize == 0)
|
||||
throw std::string("ERROR: Incorrect MaxFrameSize value in repack ctrl");
|
||||
|
||||
if ((repackCtrl.NumPasses < 1) || (repackCtrl.NumPasses > HEVC_MAX_NUMPASSES))
|
||||
throw std::string("ERROR: Incorrect NumPasses value in repack ctrl");
|
||||
|
||||
if ((activeNumPasses > 0) && (activeNumPasses <= (repackCtrl.NumPasses + 1)))
|
||||
activeNumPassesMinus1 = activeNumPasses - 1;
|
||||
else
|
||||
throw std::string("ERROR: Incorrect output NumPasses value in repack stat");
|
||||
|
||||
if ((multiPakInBin.SliceQP < m_InputParams.m_InitialQP)
|
||||
|| (multiPakInBin.SliceQP > HEVC_MAX_QP))
|
||||
throw std::string("ERROR: Incorrect parsed QP value in repack str");
|
||||
|
||||
// Verify repack control result
|
||||
std::vector<mfxU8> validQP(repackCtrl.NumPasses + 1);
|
||||
|
||||
validQP[0] = m_InputParams.m_InitialQP;
|
||||
for (mfxU32 idxPass = 0; idxPass < repackCtrl.NumPasses; ++idxPass)
|
||||
validQP[idxPass+1] = std::min((validQP[idxPass] + repackCtrl.DeltaQP[idxPass]), HEVC_MAX_QP);
|
||||
|
||||
mfxU8 sliceQPParser = multiPakInBin.SliceQP;
|
||||
|
||||
auto it = std::find_if(validQP.begin(), validQP.end(),
|
||||
[sliceQPParser](const mfxU8 curQP) { return curQP == sliceQPParser; });
|
||||
|
||||
if (it == validQP.end() || (distance(validQP.begin(), it) != activeNumPassesMinus1))
|
||||
{
|
||||
std::cout << "ERROR: parsed " << (mfxU32)multiPakInBin.SliceQP
|
||||
<< ", expected " << (mfxU32)*it << " for Frame "
|
||||
<< countFrame << " in coded order" << std::endl;
|
||||
throw std::string("ERROR: QP mismatched");
|
||||
}
|
||||
|
||||
if ((multiPakInBin.NumBytesInNalUnit > repackCtrl.MaxFrameSize)
|
||||
&& (multiPakInBin.SliceQP < validQP[repackCtrl.NumPasses]/*The max */))
|
||||
{
|
||||
std::cout << "ERROR: NumBytesInNalUnit " << multiPakInBin.NumBytesInNalUnit
|
||||
<< " MaxFrameSize " << repackCtrl.MaxFrameSize << " for Frame "
|
||||
<< countFrame << " in coded order" << std::endl;
|
||||
throw std::string("ERROR: Max exceeded");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TestProcessor::RunPSTest(const InputParams & params)
|
||||
{
|
||||
m_RefControl.SetParams(params);
|
||||
|
||||
// Iterate through frames, store with random PS
|
||||
for (mfxU32 i = 0; i < m_InputParams.m_numFrames; ++i)
|
||||
{
|
||||
m_RefControl.Add(i);
|
||||
}
|
||||
|
||||
// Iterate through frames, encode in random order
|
||||
for (mfxU32 i = 0; i < m_InputParams.m_numFrames; ++i)
|
||||
{
|
||||
m_RefControl.Encode(i);
|
||||
}
|
||||
|
||||
// Dump or Load + Compare
|
||||
SavePSData();
|
||||
}
|
||||
|
||||
void TestProcessor::Init(const InputParams ¶ms)
|
||||
{
|
||||
try
|
||||
{
|
||||
// TODO: try to use move constructor for such initialization (InputParams &&)
|
||||
m_InputParams = params;
|
||||
|
||||
asgLog.Init(params);
|
||||
|
||||
if (params.m_TestType == GENERATE_PICSTRUCT)
|
||||
{
|
||||
fpPicStruct.open(params.m_PicStructFileName.c_str(), (params.m_ProcMode == VERIFY) ? std::fstream::in : std::fstream::out);
|
||||
if (!fpPicStruct.is_open())
|
||||
throw std::string("ERROR: PicStruct buffer open failed");
|
||||
}
|
||||
else if (params.m_TestType == GENERATE_REPACK_CTRL)
|
||||
{
|
||||
if (params.m_ProcMode == GENERATE)
|
||||
{
|
||||
fpRepackStr.open(params.m_RepackStrFileName.c_str(), std::fstream::in | std::fstream::binary);
|
||||
if(!fpRepackStr.is_open())
|
||||
throw std::string("ERROR: multiPakStr file open failed");
|
||||
|
||||
fpRepackCtrl.open(params.m_RepackCtrlFileName.c_str(), std::fstream::out | std::fstream::binary);
|
||||
if (!fpRepackCtrl.is_open())
|
||||
throw std::string("ERROR: Repack ctrl file open failed");
|
||||
}
|
||||
else //VERIFY
|
||||
{
|
||||
fpRepackStr.open(params.m_RepackStrFileName.c_str(), std::fstream::in | std::fstream::binary);
|
||||
if(!fpRepackStr.is_open())
|
||||
throw std::string("ERROR: multiPakStr file open failed");
|
||||
|
||||
fpRepackCtrl.open(params.m_RepackCtrlFileName.c_str(), std::fstream::in | std::fstream::binary);
|
||||
if (!fpRepackCtrl.is_open())
|
||||
throw std::string("ERROR: Repack ctrl file open failed");
|
||||
|
||||
fpRepackStat.open(params.m_RepackStatFileName.c_str(), std::fstream::in);
|
||||
if (!fpRepackStat.is_open())
|
||||
throw std::string("ERROR: Repack stat file open failed");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Processing parameters creation
|
||||
// TODO work directly to m_vProcessingParams
|
||||
FrameMarker frameMarker;
|
||||
frameMarker.PreProcessStreamConfig(m_InputParams);
|
||||
m_vProcessingParams = m_InputParams.m_vProcessingParams;
|
||||
|
||||
m_FrameProcessor.Init(params);
|
||||
|
||||
Init(); // calls derived classes initialization
|
||||
}
|
||||
}
|
||||
catch (std::string& e) {
|
||||
std::cout << e << std::endl;
|
||||
throw std::string("ERROR: Couldn't initialize TestProcessor");
|
||||
}
|
||||
}
|
||||
|
||||
void TestProcessor::ChangePicture(ExtendedSurface & frame)
|
||||
{
|
||||
try {
|
||||
FrameChangeDescriptor descr;
|
||||
PrepareDescriptor(descr, frame.encodedOrder);
|
||||
descr.m_frame = &frame;
|
||||
|
||||
m_FrameProcessor.ProcessFrame(descr);
|
||||
|
||||
// Verification mode
|
||||
VerifyDesc(descr);
|
||||
|
||||
switch (descr.m_changeType)
|
||||
{
|
||||
case GEN:
|
||||
// Current GEN frame will be used as reference for MOD frame
|
||||
m_ProcessedFramesDescr.push_back(std::move(descr));
|
||||
break;
|
||||
|
||||
case SKIP:
|
||||
break;
|
||||
|
||||
case MOD:
|
||||
// After processing of MOD frame all previously saved GEN frames could be released
|
||||
m_ProcessedFramesDescr.clear();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
catch (std::string & e) {
|
||||
std::cout << e << std::endl;
|
||||
throw std::string("ERROR: TestProcessor::ChangePicture");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ExtendedSurface* TestProcessor::GetFreeSurf()
|
||||
{
|
||||
// Find unlocked frame in pool
|
||||
auto it = std::find_if(m_Surfaces.begin(), m_Surfaces.end(),
|
||||
[](const ExtendedSurface& ext_surf) { return (ext_surf.Data.Locked == 0 && ext_surf.isWritten); });
|
||||
|
||||
if (it == m_Surfaces.end())
|
||||
{
|
||||
// Create new surface if not found
|
||||
|
||||
m_Surfaces.emplace_back(ExtendedSurface());
|
||||
|
||||
// Allocate data for pixels
|
||||
m_Surfaces.back().AllocData(m_InputParams.m_width, m_InputParams.m_height);
|
||||
|
||||
if (m_InputParams.m_TestType & GENERATE_PREDICTION)
|
||||
{
|
||||
/* Data granularity is always in 16x16 blocks. However, width/height alignment
|
||||
should be 32 because of HW requirements */
|
||||
mfxU32 alignedWidth = 0;
|
||||
mfxU32 alignedHeight = 0;
|
||||
|
||||
if (m_InputParams.m_CTUStr.CTUSize == 16 || m_InputParams.m_CTUStr.CTUSize == 32)
|
||||
{
|
||||
alignedWidth = MSDK_ALIGN32(m_InputParams.m_width);
|
||||
alignedHeight = MSDK_ALIGN32(m_InputParams.m_height);
|
||||
}
|
||||
else if (m_InputParams.m_CTUStr.CTUSize == 64)
|
||||
{
|
||||
//For future 64x64 CTU applications
|
||||
alignedWidth = MSDK_ALIGN(m_InputParams.m_width, 64);
|
||||
alignedHeight = MSDK_ALIGN(m_InputParams.m_height, 64);
|
||||
}
|
||||
|
||||
ExtendedBuffer buff(MFX_EXTBUFF_HEVCFEI_ENC_MV_PRED, alignedWidth / MVP_BLOCK_SIZE, alignedHeight / MVP_BLOCK_SIZE);
|
||||
// Attach buffer to new frame if required
|
||||
m_Surfaces.back().AttachBuffer(buff);
|
||||
}
|
||||
|
||||
return &m_Surfaces.back();
|
||||
}
|
||||
else
|
||||
{
|
||||
//Reset the isWritten flag upon surface reuse
|
||||
it->encodedOrder = 0xffffffff;
|
||||
it->isWritten = false;
|
||||
return &(*it);
|
||||
}
|
||||
}
|
||||
|
||||
void TestProcessor::PrepareDescriptor(FrameChangeDescriptor & descr, const mfxU32 frameNum)
|
||||
{
|
||||
descr.m_testType = m_InputParams.m_TestType;
|
||||
descr.m_procMode = m_InputParams.m_ProcMode;
|
||||
descr.m_changeType = m_vProcessingParams[frameNum].Mark;
|
||||
descr.m_frameNumber = m_vProcessingParams[frameNum].DisplayOrder;
|
||||
descr.m_frameType = m_vProcessingParams[frameNum].Type;
|
||||
descr.m_refDescrList0 = GetReferences(m_ProcessedFramesDescr, m_vProcessingParams[frameNum].ReferencesL0);
|
||||
descr.m_refDescrList1 = GetReferences(m_ProcessedFramesDescr, m_vProcessingParams[frameNum].ReferencesL1);
|
||||
|
||||
// TODO: add support for full reference lists
|
||||
// m_refDescrList0 contains active reference frames with lower display order in descending order
|
||||
descr.m_refDescrList0.sort([](FrameChangeDescriptor const & lhs, FrameChangeDescriptor const & rhs) { return lhs.m_frameNumber > rhs.m_frameNumber; });
|
||||
|
||||
// m_refDescrList1 contains active reference frames with higher display order in ascending order
|
||||
descr.m_refDescrList1.sort([](FrameChangeDescriptor const & lhs, FrameChangeDescriptor const & rhs) { return lhs.m_frameNumber < rhs.m_frameNumber; });
|
||||
|
||||
//TODO: disable for I frames?
|
||||
|
||||
descr.m_bUseBiDirSW = (m_vProcessingParams[frameNum].Type & MFX_FRAMETYPE_B) ||
|
||||
((m_vProcessingParams[frameNum].Type & MFX_FRAMETYPE_P) && m_InputParams.m_UseGPB);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Select references from list
|
||||
// Most recently processed frames are at the end of the return list
|
||||
std::list<FrameChangeDescriptor> TestProcessor::GetReferences(const std::list<FrameChangeDescriptor> & RecentProcessed, const std::vector<mfxU32>& ref_idx)
|
||||
{
|
||||
std::list<FrameChangeDescriptor> refs_for_frame;
|
||||
|
||||
for (auto & frm_descr : RecentProcessed)
|
||||
{
|
||||
if (std::find(ref_idx.begin(), ref_idx.end(), frm_descr.m_frameNumber) != ref_idx.end())
|
||||
refs_for_frame.emplace_back(frm_descr);
|
||||
}
|
||||
|
||||
return refs_for_frame;
|
||||
}
|
||||
|
||||
std::list<FrameChangeDescriptor> TestProcessor::GetSkips(const std::list<FrameChangeDescriptor> & RecentProcessed)
|
||||
{
|
||||
std::list<FrameChangeDescriptor> skips;
|
||||
|
||||
for (auto & frm_descr : RecentProcessed)
|
||||
{
|
||||
if (frm_descr.m_changeType == SKIP)
|
||||
skips.emplace_back(frm_descr);
|
||||
}
|
||||
|
||||
return skips;
|
||||
}
|
||||
|
||||
#endif // MFX_VERSION
|
|
@ -1,116 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include "util_defs.h"
|
||||
|
||||
std::string ConvertMfxStatusToString(mfxStatus sts)
|
||||
{
|
||||
switch (sts)
|
||||
{
|
||||
|
||||
case MFX_ERR_NONE: /* no error */
|
||||
return std::string("MFX_ERR_NONE");
|
||||
|
||||
/* error codes <0 */
|
||||
case MFX_ERR_NULL_PTR: /* null pointer */
|
||||
return std::string("MFX_ERR_NULL_PTR");
|
||||
case MFX_ERR_UNSUPPORTED: /* undeveloped feature */
|
||||
return std::string("MFX_ERR_UNSUPPORTED");
|
||||
case MFX_ERR_MEMORY_ALLOC: /* failed to allocate memory */
|
||||
return std::string("MFX_ERR_MEMORY_ALLOC");
|
||||
case MFX_ERR_NOT_ENOUGH_BUFFER: /* insufficient buffer at input/output */
|
||||
return std::string("MFX_ERR_NOT_ENOUGH_BUFFER");
|
||||
case MFX_ERR_INVALID_HANDLE: /* invalid handle */
|
||||
return std::string("MFX_ERR_INVALID_HANDLE");
|
||||
case MFX_ERR_LOCK_MEMORY: /* failed to lock the memory block */
|
||||
return std::string("MFX_ERR_LOCK_MEMORY");
|
||||
case MFX_ERR_NOT_INITIALIZED: /* member function called before initialization */
|
||||
return std::string("MFX_ERR_NOT_INITIALIZED");
|
||||
case MFX_ERR_NOT_FOUND: /* the specified object is not found */
|
||||
return std::string("MFX_ERR_NOT_FOUND");
|
||||
case MFX_ERR_MORE_DATA: /* expect more data at input */
|
||||
return std::string("MFX_ERR_MORE_DATA");
|
||||
case MFX_ERR_MORE_SURFACE: /* expect more surface at output */
|
||||
return std::string("MFX_ERR_MORE_SURFACE");
|
||||
case MFX_ERR_ABORTED: /* operation aborted */
|
||||
return std::string("MFX_ERR_ABORTED");
|
||||
case MFX_ERR_DEVICE_LOST: /* lose the HW acceleration device */
|
||||
return std::string("MFX_ERR_DEVICE_LOST");
|
||||
case MFX_ERR_INCOMPATIBLE_VIDEO_PARAM: /* incompatible video parameters */
|
||||
return std::string("MFX_ERR_INCOMPATIBLE_VIDEO_PARAM");
|
||||
case MFX_ERR_INVALID_VIDEO_PARAM: /* invalid video parameters */
|
||||
return std::string("MFX_ERR_INVALID_VIDEO_PARAM");
|
||||
case MFX_ERR_UNDEFINED_BEHAVIOR: /* undefined behavior */
|
||||
return std::string("MFX_ERR_UNDEFINED_BEHAVIOR");
|
||||
case MFX_ERR_DEVICE_FAILED: /* device operation failure */
|
||||
return std::string("MFX_ERR_DEVICE_FAILED");
|
||||
case MFX_ERR_MORE_BITSTREAM: /* expect more bitstream buffers at output */
|
||||
return std::string("MFX_ERR_MORE_BITSTREAM");
|
||||
case MFX_ERR_INCOMPATIBLE_AUDIO_PARAM: /* incompatible audio parameters */
|
||||
return std::string("MFX_ERR_INCOMPATIBLE_AUDIO_PARAM");
|
||||
case MFX_ERR_INVALID_AUDIO_PARAM: /* invalid audio parameters */
|
||||
return std::string("MFX_ERR_INVALID_AUDIO_PARAM");
|
||||
case MFX_ERR_GPU_HANG: /* device operation failure caused by GPU hang */
|
||||
return std::string("MFX_ERR_GPU_HANG");
|
||||
case MFX_ERR_REALLOC_SURFACE: /* bigger output surface required */
|
||||
return std::string("MFX_ERR_REALLOC_SURFACE");
|
||||
|
||||
/* warnings >0 */
|
||||
case MFX_WRN_IN_EXECUTION: /* the previous asynchronous operation is in execution */
|
||||
return std::string("MFX_WRN_IN_EXECUTION");
|
||||
case MFX_WRN_DEVICE_BUSY: /* the HW acceleration device is busy */
|
||||
return std::string("MFX_WRN_DEVICE_BUSY");
|
||||
case MFX_WRN_VIDEO_PARAM_CHANGED: /* the video parameters are changed during decoding */
|
||||
return std::string("MFX_WRN_VIDEO_PARAM_CHANGED");
|
||||
case MFX_WRN_PARTIAL_ACCELERATION: /* SW is used */
|
||||
return std::string("MFX_WRN_PARTIAL_ACCELERATION");
|
||||
case MFX_WRN_INCOMPATIBLE_VIDEO_PARAM: /* incompatible video parameters */
|
||||
return std::string("MFX_WRN_INCOMPATIBLE_VIDEO_PARAM");
|
||||
case MFX_WRN_VALUE_NOT_CHANGED: /* the value is saturated based on its valid range */
|
||||
return std::string("MFX_WRN_VALUE_NOT_CHANGED");
|
||||
case MFX_WRN_OUT_OF_RANGE: /* the value is out of valid range */
|
||||
return std::string("MFX_WRN_OUT_OF_RANGE");
|
||||
case MFX_WRN_FILTER_SKIPPED: /* one of requested filters has been skipped */
|
||||
return std::string("MFX_WRN_FILTER_SKIPPED");
|
||||
case MFX_WRN_INCOMPATIBLE_AUDIO_PARAM: /* incompatible audio parameters */
|
||||
return std::string("MFX_WRN_INCOMPATIBLE_AUDIO_PARAM");
|
||||
|
||||
/* threading statuses */
|
||||
//case MFX_TASK_DONE: == ERR_NONE /* task has been completed */
|
||||
case MFX_TASK_WORKING: /* there is some more work to do */
|
||||
return std::string("MFX_TASK_WORKING");
|
||||
case MFX_TASK_BUSY: /* task is waiting for resources */
|
||||
return std::string("MFX_TASK_BUSY");
|
||||
|
||||
/* plug-in statuses */
|
||||
case MFX_ERR_MORE_DATA_SUBMIT_TASK: /* return MFX_ERR_MORE_DATA but submit internal asynchronous task */
|
||||
return std::string("MFX_ERR_MORE_DATA_SUBMIT_TASK");
|
||||
|
||||
case MFX_ERR_UNKNOWN: /* unknown error. */
|
||||
default:
|
||||
return std::string("MFX_ERR_UNKNOWN");
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MFX_VERSION
|
File diff suppressed because it is too large
Load diff
|
@ -1,10 +0,0 @@
|
|||
include_directories (
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
)
|
||||
|
||||
file( GLOB_RECURSE sources "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c" "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp" )
|
||||
|
||||
set( defs " -DMFX_VERSION_USE_LATEST " )
|
||||
|
||||
make_library( bs_parser_hevc_static none static )
|
||||
set( defs "" )
|
|
@ -1,13 +0,0 @@
|
|||
LIBRARY "bs_parser_hevc"
|
||||
EXPORTS
|
||||
BS_HEVC2_Init
|
||||
BS_HEVC2_OpenFile
|
||||
BS_HEVC2_SetBuffer
|
||||
BS_HEVC2_ParseNextAU
|
||||
BS_HEVC2_Close
|
||||
BS_HEVC2_SetTraceLevel
|
||||
BS_HEVC2_Lock
|
||||
BS_HEVC2_Unlock
|
||||
BS_HEVC2_GetOffset
|
||||
BS_HEVC2_Sync
|
||||
BS_HEVC2_GetAsyncDepth
|
|
@ -1,207 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{6A44B0B8-2D21-4D64-9F0A-D73A2BBB3103}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(ProjectDir)..\..\..\build\win_$(Platform)\$(Configuration)\bin\</OutDir>
|
||||
<IntDir>$(OutDir)..\objs\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(ProjectDir)..\..\..\build\win_$(Platform)\$(Configuration)\bin\</OutDir>
|
||||
<IntDir>$(OutDir)..\objs\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>$(ProjectDir)..\..\..\build\win_$(Platform)\$(Configuration)\bin\</OutDir>
|
||||
<IntDir>$(OutDir)..\objs\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<TargetExt>.dll</TargetExt>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(ProjectDir)..\..\..\build\win_$(Platform)\$(Configuration)\bin\</OutDir>
|
||||
<IntDir>$(OutDir)..\objs\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<TargetExt>.dll</TargetExt>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;BS_PARSER_HEVC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>./include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<SupportJustMyCode>false</SupportJustMyCode>
|
||||
<ControlFlowGuard>Guard</ControlFlowGuard>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<ModuleDefinitionFile>bs_parser_hevc.def</ModuleDefinitionFile>
|
||||
<ImportLibrary>$(OutDir)../lib/$(ProjectName).lib</ImportLibrary>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_WIN32;WIN632;NDEBUG;_WINDOWS;_USRDLL;BS_PARSER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>./include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CallingConvention>Cdecl</CallingConvention>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<ModuleDefinitionFile>bs_parser_hevc.def</ModuleDefinitionFile>
|
||||
<ImportLibrary>$(OutDir)../lib/$(ProjectName).lib</ImportLibrary>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>./include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<PreprocessorDefinitions>_WIN64;WIN64;NDEBUG;_WINDOWS;_USRDLL;BS_PARSER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<CallingConvention>StdCall</CallingConvention>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<LinkTimeCodeGeneration>UseFastLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
<ImportLibrary>$(OutDir)../lib/$(ProjectName).lib</ImportLibrary>
|
||||
<ModuleDefinitionFile>bs_parser_hevc.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>./include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<SupportJustMyCode>false</SupportJustMyCode>
|
||||
<PreprocessorDefinitions>_WIN64;WIN64;_DEBUG;_WINDOWS;_USRDLL;BS_PARSER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<ControlFlowGuard>Guard</ControlFlowGuard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<ModuleDefinitionFile>bs_parser_hevc.def</ModuleDefinitionFile>
|
||||
<ImportLibrary>$(OutDir)../lib/$(ProjectName).lib</ImportLibrary>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\bs_reader.cpp" />
|
||||
<ClCompile Include="src\bs_reader2.cpp" />
|
||||
<ClCompile Include="src\bs_thread.cpp" />
|
||||
<ClCompile Include="src\common_cabac.cpp" />
|
||||
<ClCompile Include="src\dll_main.cpp" />
|
||||
<ClCompile Include="src\hevc2_cabac.cpp" />
|
||||
<ClCompile Include="src\hevc2_dec.cpp" />
|
||||
<ClCompile Include="src\hevc2_headers.cpp" />
|
||||
<ClCompile Include="src\hevc2_parser.cpp" />
|
||||
<ClCompile Include="src\hevc2_ssdata.cpp" />
|
||||
<ClCompile Include="src\hevc2_trace.cpp" />
|
||||
<ClCompile Include="src\hevc_cabac.cpp" />
|
||||
<ClCompile Include="src\hevc_cabac_tables.cpp" />
|
||||
<ClCompile Include="src\hevc_sdec_ctx.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\bs_def.h" />
|
||||
<ClInclude Include="include\bs_mem+.h" />
|
||||
<ClInclude Include="include\bs_parser++.h" />
|
||||
<ClInclude Include="include\bs_parser.h" />
|
||||
<ClInclude Include="include\bs_reader.h" />
|
||||
<ClInclude Include="include\bs_reader2.h" />
|
||||
<ClInclude Include="include\bs_thread.h" />
|
||||
<ClInclude Include="include\common_cabac.h" />
|
||||
<ClInclude Include="include\hevc2_parser.h" />
|
||||
<ClInclude Include="include\hevc2_struct.h" />
|
||||
<ClInclude Include="include\hevc2_trace.h" />
|
||||
<ClInclude Include="include\hevc_cabac.h" />
|
||||
<ClInclude Include="include\hevc_struct.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -1,102 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\bs_reader.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\bs_reader2.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\bs_thread.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\common_cabac.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\dll_main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\hevc2_cabac.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\hevc2_dec.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\hevc2_headers.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\hevc2_parser.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\hevc2_ssdata.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\hevc2_trace.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\hevc_cabac.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\hevc_cabac_tables.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\hevc_sdec_ctx.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\bs_def.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\bs_mem+.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\bs_parser++.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\bs_parser.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\bs_reader.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\bs_reader2.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\bs_thread.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\common_cabac.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\hevc2_parser.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\hevc2_struct.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\hevc2_trace.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\hevc_cabac.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\hevc_struct.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,73 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef __BS_DEF_H
|
||||
#define __BS_DEF_H
|
||||
|
||||
//#undef __BS_TRACE__
|
||||
//#define __BS_TRACE__
|
||||
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned char Bs8u;
|
||||
typedef unsigned short Bs16u;
|
||||
typedef unsigned int Bs32u;
|
||||
|
||||
typedef signed char Bs8s;
|
||||
typedef signed short Bs16s;
|
||||
typedef signed int Bs32s;
|
||||
|
||||
#ifdef __GNUC__
|
||||
typedef unsigned long long Bs64u;
|
||||
typedef signed long long Bs64s;
|
||||
#else
|
||||
typedef unsigned __int64 Bs64u;
|
||||
typedef signed __int64 Bs64s;
|
||||
#endif
|
||||
|
||||
#if defined( _WIN32 ) || defined ( _WIN64 )
|
||||
#define __STDCALL __stdcall
|
||||
#define __CDECL __cdecl
|
||||
#define __INT64 __int64
|
||||
#define __UINT64 unsigned __int64
|
||||
#else
|
||||
#define __STDCALL
|
||||
#define __CDECL
|
||||
#define __INT64 long long
|
||||
#define __UINT64 unsigned long long
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BS_ERR_NONE = 0,
|
||||
BS_ERR_UNKNOWN = -1,
|
||||
BS_ERR_WRONG_UNITS_ORDER = -2,
|
||||
BS_ERR_MORE_DATA = -3,
|
||||
BS_ERR_INVALID_PARAMS = -4,
|
||||
BS_ERR_MEM_ALLOC = -5,
|
||||
BS_ERR_NOT_IMPLEMENTED = -6,
|
||||
BS_ERR_NOT_ENOUGH_BUFFER = -7,
|
||||
BS_ERR_BAD_HANDLE = -8,
|
||||
BS_ERR_INCOMPLETE_DATA = -9
|
||||
} BSErr;
|
||||
|
||||
#define BS_MIN(x, y) ( ((x) < (y)) ? (x) : (y) )
|
||||
#define BS_MAX(x, y) ( ((x) > (y)) ? (x) : (y) )
|
||||
#define BS_ABS(x) ( ((x) > 0) ? (x) : (-(x)) )
|
||||
|
||||
#endif //__BS_DEF_H
|
|
@ -1,300 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <mutex>
|
||||
#include <memory.h>
|
||||
|
||||
//#define BS_MEM_TRACE
|
||||
|
||||
#ifdef BS_MEM_TRACE
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
namespace BS_MEM
|
||||
{
|
||||
|
||||
class MemBase
|
||||
{
|
||||
public:
|
||||
virtual void* Get() = 0;
|
||||
virtual ~MemBase(){}
|
||||
};
|
||||
|
||||
template<class T> class MemObj : public MemBase
|
||||
{
|
||||
public:
|
||||
T* m_obj;
|
||||
bool m_del;
|
||||
|
||||
MemObj(unsigned int count, bool zero)
|
||||
{
|
||||
if (zero)
|
||||
m_obj = new T[count]{}; // array value-initialization
|
||||
else
|
||||
m_obj = new T[count];
|
||||
m_del = true;
|
||||
}
|
||||
|
||||
MemObj(T* obj)
|
||||
: m_obj(obj)
|
||||
, m_del(false)
|
||||
{}
|
||||
|
||||
MemObj(const MemObj&) = delete;
|
||||
MemObj& operator=(const MemObj&) = delete;
|
||||
|
||||
virtual ~MemObj()
|
||||
{
|
||||
if (m_del)
|
||||
delete[] m_obj;
|
||||
}
|
||||
|
||||
void* Get() { return m_obj; }
|
||||
};
|
||||
|
||||
class MemD
|
||||
{
|
||||
public:
|
||||
MemD()
|
||||
: locked(0)
|
||||
, to_delete(false)
|
||||
, mem(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
~MemD()
|
||||
{
|
||||
if (mem)
|
||||
delete mem;
|
||||
}
|
||||
|
||||
unsigned int locked;
|
||||
bool to_delete;
|
||||
std::set<void*> base;
|
||||
std::set<void*> dep;
|
||||
MemBase* mem;
|
||||
};
|
||||
|
||||
class Allocator
|
||||
{
|
||||
private:
|
||||
std::map<void*, MemD> m_mem;
|
||||
std::recursive_mutex m_mtx;
|
||||
bool m_zero;
|
||||
|
||||
inline bool Touch(void* p) { return !!m_mem.count(p); }
|
||||
inline void __notrace(const char*, ...) {}
|
||||
|
||||
#ifdef BS_MEM_TRACE
|
||||
#define BS_MEM_TRACE_F printf
|
||||
#else
|
||||
#define BS_MEM_TRACE_F __notrace
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
Allocator()
|
||||
: m_zero(false)
|
||||
{
|
||||
}
|
||||
|
||||
~Allocator()
|
||||
{
|
||||
}
|
||||
|
||||
void SetZero(bool zero)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> _lock(m_mtx);
|
||||
m_zero = zero;
|
||||
}
|
||||
|
||||
bool touch(void* p)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> _lock(m_mtx);
|
||||
BS_MEM_TRACE_F("BS_MEM::touch(%p)\n", p);
|
||||
return Touch(p);
|
||||
}
|
||||
|
||||
void bound(void* dep, void* base)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> _lock(m_mtx);
|
||||
BS_MEM_TRACE_F("BS_MEM::bound(%p, %p)\n", dep, base);
|
||||
|
||||
if (!Touch(base) || !Touch(dep))
|
||||
throw std::bad_alloc();
|
||||
|
||||
m_mem[base].dep.insert(dep);
|
||||
m_mem[dep].base.insert(base);
|
||||
}
|
||||
|
||||
template<class T> T* alloc(void* base = nullptr, unsigned int count = 1)
|
||||
{
|
||||
if (count == 0)
|
||||
return nullptr;
|
||||
|
||||
std::unique_lock<std::recursive_mutex> _lock(m_mtx);
|
||||
|
||||
MemBase* pObj = new MemObj<T>(count, m_zero);
|
||||
T* p = (T*)pObj->Get();
|
||||
|
||||
m_mem[p].mem = pObj;
|
||||
|
||||
BS_MEM_TRACE_F("BS_MEM::alloc(%p, %d) = %p\n", base, count, p);
|
||||
if (base)
|
||||
bound(p, base);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
template<class T> T* alloc_nozero(void* base = nullptr, unsigned int count = 1)
|
||||
{
|
||||
if (count == 0)
|
||||
return nullptr;
|
||||
|
||||
std::unique_lock<std::recursive_mutex> _lock(m_mtx);
|
||||
|
||||
MemBase* pObj = new MemObj<T>(count, false);
|
||||
T* p = (T*)pObj->Get();
|
||||
|
||||
m_mem[p].mem = pObj;
|
||||
|
||||
BS_MEM_TRACE_F("BS_MEM::alloc_nozero(%p, %d) = %p\n", base, count, p);
|
||||
if (base)
|
||||
bound(p, base);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
void free(void* p)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> _lock(m_mtx);
|
||||
BS_MEM_TRACE_F("BS_MEM::free(%p)", p);
|
||||
|
||||
if (!Touch(p))
|
||||
throw std::bad_alloc();
|
||||
|
||||
auto& d = m_mem[p];
|
||||
|
||||
if (d.locked)
|
||||
{
|
||||
BS_MEM_TRACE_F(" - delayed\n", p);
|
||||
d.to_delete = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!d.base.empty())
|
||||
{
|
||||
BS_MEM_TRACE_F(" - delayed\n", p);
|
||||
return;
|
||||
}
|
||||
|
||||
BS_MEM_TRACE_F(" - done\n", p);
|
||||
|
||||
for (auto& pdep : d.dep)
|
||||
{
|
||||
auto& ddep = m_mem[pdep];
|
||||
|
||||
ddep.base.erase(p);
|
||||
|
||||
if (ddep.base.empty())
|
||||
free(pdep);
|
||||
}
|
||||
|
||||
m_mem.erase(p);
|
||||
}
|
||||
|
||||
void lock(void* p)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> _lock(m_mtx);
|
||||
BS_MEM_TRACE_F("BS_MEM::lock(%p)\n", p);
|
||||
|
||||
if (!Touch(p))
|
||||
throw std::bad_alloc();
|
||||
|
||||
m_mem[p].locked++;
|
||||
}
|
||||
|
||||
void unlock(void* p)
|
||||
{
|
||||
BS_MEM_TRACE_F("BS_MEM::unlock(%p)\n", p);
|
||||
|
||||
if (!p)
|
||||
return;
|
||||
|
||||
std::unique_lock<std::recursive_mutex> _lock(m_mtx);
|
||||
|
||||
if (!Touch(p))
|
||||
throw std::bad_alloc();
|
||||
|
||||
auto& d = m_mem[p];
|
||||
|
||||
if (!m_mem[p].locked)
|
||||
throw std::bad_alloc();
|
||||
|
||||
d.locked--;
|
||||
|
||||
if (d.to_delete)
|
||||
free(p);
|
||||
}
|
||||
#undef BS_MEM_TRACE_F
|
||||
};
|
||||
|
||||
class AutoLock
|
||||
{
|
||||
public:
|
||||
Allocator* m_pAllocator;
|
||||
std::list<void*> m_ptr;
|
||||
|
||||
AutoLock(Allocator* pAllocator, void* ptr = 0)
|
||||
: m_pAllocator(pAllocator)
|
||||
{
|
||||
if (m_pAllocator && ptr)
|
||||
{
|
||||
m_pAllocator->lock(ptr);
|
||||
m_ptr.push_back(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
~AutoLock()
|
||||
{
|
||||
if (m_pAllocator)
|
||||
{
|
||||
for (auto p : m_ptr)
|
||||
m_pAllocator->unlock(p);
|
||||
}
|
||||
}
|
||||
|
||||
void Add(void* p)
|
||||
{
|
||||
if (m_pAllocator)
|
||||
{
|
||||
m_pAllocator->lock(p);
|
||||
m_ptr.push_back(p);
|
||||
}
|
||||
else
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
};
|
||||
|
||||
};
|
|
@ -1,90 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef __BS_PARSER_PP_H
|
||||
#define __BS_PARSER_PP_H
|
||||
|
||||
#include <bs_parser.h>
|
||||
#include <memory.h>
|
||||
|
||||
class BS_parser{
|
||||
public:
|
||||
BS_parser(){};
|
||||
virtual BSErr open(const char* file) = 0;
|
||||
virtual BSErr set_buffer(byte* buf, Bs32u buf_size) = 0;
|
||||
virtual BSErr parse_next_unit() = 0;
|
||||
virtual BSErr reset() = 0;
|
||||
virtual BSErr lock (void* p) = 0;
|
||||
virtual BSErr unlock(void* p) = 0;
|
||||
virtual void* get_header() = 0;
|
||||
virtual void* get_handle() = 0;
|
||||
virtual Bs64u get_offset() = 0;
|
||||
virtual void set_trace_level(Bs32u level) = 0;
|
||||
virtual BSErr sync(void* p) { (void) p; return BS_ERR_NONE; };
|
||||
virtual Bs16u async_depth() { return 0; }
|
||||
virtual ~BS_parser(){};
|
||||
};
|
||||
|
||||
class BS_HEVC2_parser : public BS_parser{
|
||||
public:
|
||||
typedef BS_HEVC2::NALU UnitType;
|
||||
|
||||
BS_HEVC2_parser(Bs32u mode = 0)
|
||||
{
|
||||
BS_HEVC2_Init(hdl, mode);
|
||||
hdr = 0;
|
||||
};
|
||||
|
||||
BS_HEVC2_parser(BS_HEVC2_parser const&) = delete;
|
||||
BS_HEVC2_parser& operator=(BS_HEVC2_parser const&) = delete;
|
||||
|
||||
~BS_HEVC2_parser() { BS_HEVC2_Close(hdl); };
|
||||
|
||||
BSErr parse_next_au(UnitType*& pAU) { return BS_HEVC2_ParseNextAU(hdl, pAU); };
|
||||
BSErr parse_next_unit() { return BS_HEVC2_ParseNextAU(hdl, hdr); };
|
||||
BSErr open(const char* file) { return BS_HEVC2_OpenFile(hdl, file); };
|
||||
BSErr set_buffer(byte* buf, Bs32u buf_size) { return BS_HEVC2_SetBuffer(hdl, buf, buf_size); };
|
||||
BSErr lock(void* p) { return BS_HEVC2_Lock(hdl, p); };
|
||||
BSErr unlock(void* p) { return BS_HEVC2_Unlock(hdl, p); };
|
||||
BSErr sync(void* p) { return BS_HEVC2_Sync(hdl, (BS_HEVC2::NALU*)p); };
|
||||
Bs16u async_depth() { return BS_HEVC2_GetAsyncDepth(hdl); }
|
||||
|
||||
void set_trace_level(Bs32u level) { BS_HEVC2_SetTraceLevel(hdl, level); };
|
||||
void* get_header() { return hdr; };
|
||||
void* get_handle() { return hdl; };
|
||||
Bs64u get_offset() {
|
||||
Bs64u offset = -1;
|
||||
BS_HEVC2_GetOffset(hdl, offset);
|
||||
return offset;
|
||||
};
|
||||
|
||||
BSErr reset()
|
||||
{
|
||||
BS_HEVC2_Close(hdl);
|
||||
hdr = 0;
|
||||
return BS_HEVC2_Init(hdl, 0);
|
||||
};
|
||||
private:
|
||||
BS_HEVC2::HDL hdl;
|
||||
UnitType* hdr;
|
||||
};
|
||||
|
||||
|
||||
#endif //__BS_PARSER_PP_H
|
|
@ -1,43 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef __BS_PARSER_H
|
||||
#define __BS_PARSER_H
|
||||
|
||||
#include <hevc2_struct.h>
|
||||
|
||||
extern "C"{
|
||||
|
||||
BSErr __STDCALL BS_HEVC2_Init (BS_HEVC2::HDL& hdl, Bs32u mode);
|
||||
BSErr __STDCALL BS_HEVC2_OpenFile (BS_HEVC2::HDL hdl, const char* file);
|
||||
BSErr __STDCALL BS_HEVC2_SetBuffer (BS_HEVC2::HDL hdl, byte* buf, Bs32u buf_size);
|
||||
BSErr __STDCALL BS_HEVC2_ParseNextAU (BS_HEVC2::HDL hdl, BS_HEVC2::NALU*& pAU);
|
||||
BSErr __STDCALL BS_HEVC2_Close (BS_HEVC2::HDL hdl);
|
||||
BSErr __STDCALL BS_HEVC2_SetTraceLevel (BS_HEVC2::HDL hdl, Bs32u level);
|
||||
BSErr __STDCALL BS_HEVC2_Lock (BS_HEVC2::HDL hdl, void* p);
|
||||
BSErr __STDCALL BS_HEVC2_Unlock (BS_HEVC2::HDL hdl, void* p);
|
||||
BSErr __STDCALL BS_HEVC2_GetOffset (BS_HEVC2::HDL hdl, Bs64u& offset);
|
||||
BSErr __STDCALL BS_HEVC2_Sync (BS_HEVC2::HDL hdl, BS_HEVC2::NALU* slice);
|
||||
Bs16u __STDCALL BS_HEVC2_GetAsyncDepth (BS_HEVC2::HDL hdl);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif //__BS_PARSER_H
|
|
@ -1,247 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef __BS_READER_H
|
||||
#define __BS_READER_H
|
||||
|
||||
#include <memory.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <bs_def.h>
|
||||
#include <new>
|
||||
|
||||
#define BS_BUF_SIZE 2048
|
||||
#if defined(__APPLE__) || defined(LINUX32) || defined(LINUX64) || defined(ANDROID)
|
||||
#define BS_FILE_MODE 0 /* no fteelo64 on OSX */
|
||||
#else
|
||||
#define BS_FILE_MODE 1
|
||||
#endif
|
||||
|
||||
#if (BS_FILE_MODE == 1)
|
||||
#define BS_FADDR_TYPE Bs64u
|
||||
#define BS_FOFFSET_TYPE Bs64s
|
||||
#define BS_TRACE_FORMAT "0x%016I64X[%i]: %s = %i\n"
|
||||
#define BS_TRACE_OFFSET_FORMAT "0x%016I64X[%i]: "
|
||||
#ifdef __GNUC__
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#define BS_FTELL(fh) ftello64(fh)
|
||||
#define BS_FSEEK(fh,offset,origin) fseeko64( fh, offset, origin )
|
||||
#else
|
||||
#include <share.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#define BS_FH_TYPE int
|
||||
#define BS_FOPEN(file, fh) { int tmp_fh = 0; if(!_sopen_s(&tmp_fh, file_name, _O_BINARY|_O_RDONLY, _SH_DENYNO, 0))fh = tmp_fh;}
|
||||
#define BS_FCLOSE(fh) _close(fh)
|
||||
#define BS_FTELL(fh) _telli64(fh)
|
||||
#define BS_FEOF(fh) _eof(fh)
|
||||
#define BS_FREAD(fh,dst,size) _read(fh, dst, size)
|
||||
#define BS_FSEEK(fh,offset,origin) _lseeki64( fh, offset, origin )
|
||||
#endif
|
||||
#endif
|
||||
#if (BS_FILE_MODE == 0) || defined(__GNUC__)
|
||||
#if (BS_FILE_MODE == 0)
|
||||
#define BS_FADDR_TYPE Bs32u
|
||||
#define BS_FOFFSET_TYPE Bs32s
|
||||
#define BS_TRACE_FORMAT "0x%08X[%i]: %s = %i\n"
|
||||
#define BS_TRACE_OFFSET_FORMAT "0x%08X[%i]: "
|
||||
#define BS_FTELL(fh) ftell(fh)
|
||||
#define BS_FSEEK(fh,offset,origin) fseek( fh, offset, origin )
|
||||
#endif
|
||||
#define BS_FH_TYPE FILE*
|
||||
#define BS_FOPEN(file, fh) {fh = fopen( file_name, "rb" );}
|
||||
#define BS_FCLOSE(fh) fclose(fh)
|
||||
#define BS_FEOF(fh) feof(fh)
|
||||
#define BS_FREAD(fh,dst,size) fread( dst, 1, size, fh )
|
||||
#endif
|
||||
|
||||
#ifdef __BS_TRACE__
|
||||
#define BS_TRACE( val, comment ) { \
|
||||
if(trace_flag) {printf( BS_TRACE_FORMAT, file_pos+offset, bit, #comment, (int)(val) ); fflush(stdout);}\
|
||||
else (val); \
|
||||
if(last_err) return last_err; \
|
||||
}
|
||||
#define BS_SET( val, var ) { \
|
||||
if(trace_flag){ printf( BS_TRACE_FORMAT, file_pos+offset, bit, #var, (int)((var) = (val)) ); fflush(stdout);} \
|
||||
else (var) = (val); \
|
||||
if(last_err) return last_err; \
|
||||
}
|
||||
#define BS_GET_BITS( n, var ) { \
|
||||
(var) = (tmp_buf)>>(32-(n)); tmp_buf <<= (n);\
|
||||
if(trace_flag) printf( BS_TRACE_FORMAT, file_pos+offset, bit, #var, (var) ); \
|
||||
}
|
||||
#define BS_TRACE_BITS( n, var ) { \
|
||||
if(trace_flag) printf( BS_TRACE_FORMAT, file_pos+offset, bit, #var, ((tmp_buf)>>(32-(n))) ); \
|
||||
tmp_buf <<= n;\
|
||||
}
|
||||
#define BS_TROX( x, b ) if(trace_flag) printf(BS_TRACE_OFFSET_FORMAT, (unsigned int)(x), (b));
|
||||
#define BS_TRO if(trace_flag) printf(BS_TRACE_OFFSET_FORMAT,file_pos+offset, bit);
|
||||
#define BS_SETM( val, var, map ) {\
|
||||
if(trace_flag) {BS_TRO; (var) = (val); printf("%s = %s (%d)\n", #var, map[var], var);}\
|
||||
else (var) = (val);\
|
||||
if(last_err) return last_err; \
|
||||
}
|
||||
#define BS_TRACE_ARR(name, el, sz) \
|
||||
if(trace_flag){\
|
||||
printf("%s = { ", #name);\
|
||||
for(Bs32u _idx = 0; _idx < (Bs32u)(sz); _idx++ ) {\
|
||||
printf("%d ", (el));\
|
||||
}\
|
||||
printf("}\n");\
|
||||
} else for(Bs32u _idx = 0; _idx < (Bs32u)(sz); _idx++ ) { (el); }
|
||||
#define BS_TRACE_NO_OFFSET( val, comment ) { \
|
||||
if(trace_flag) printf( "%s = %d\n", #comment, (val) ); \
|
||||
else (val); \
|
||||
if(last_err) return last_err; \
|
||||
}
|
||||
#define BS_TRACE_STR( str ) { if(trace_flag) printf( "%s\n", str ); }
|
||||
#else
|
||||
#define BS_TRACE( val, comment ) { (val); if(last_err) return last_err; }
|
||||
#define BS_SET( val, var ) { (var) = (val); if(last_err) return last_err; }
|
||||
#define BS_GET_BITS( n, var ) { (var) = (tmp_buf)>>(32-(n)); tmp_buf <<= (n);}
|
||||
#define BS_TRACE_BITS( n, var ) { tmp_buf <<= (n); }
|
||||
#define BS_TROX( x, b ) { (x); (b); };
|
||||
#define BS_TRO {}
|
||||
#define BS_SETM( val, var, map ) BS_SET( val, var )
|
||||
#define BS_TRACE_ARR(name, el, sz)for(Bs32u _idx = 0; _idx < (Bs32u)(sz); _idx++ ) { (el); }
|
||||
#define BS_TRACE_NO_OFFSET( val, comment ) BS_TRACE( val, comment )
|
||||
#define BS_TRACE_STR( str ) {}
|
||||
#endif
|
||||
|
||||
#define BS_STRUCT_ALLOC( type, var ){ \
|
||||
var = (type*)malloc( sizeof(type) ); \
|
||||
if(var){ \
|
||||
memset( var, 0, sizeof(type) ); \
|
||||
}else{ \
|
||||
return last_err = BS_ERR_MEM_ALLOC; \
|
||||
}; \
|
||||
/*printf("BS_STRUCT_ALLOC:\t0x%p ( %i ) \t %s : %i\n", var, sizeof(type), __FILE__, __LINE__ );*/\
|
||||
}
|
||||
#define BS_CALLOC( type, size, var ){ \
|
||||
var = (type*)calloc( (size), sizeof(type) ); \
|
||||
if(!var) return last_err = BS_ERR_MEM_ALLOC; \
|
||||
/*printf("BS_CALLOC:\t\t0x%p ( %i * %i ) \t %s : %i\n", var, sizeof(type), (size), __FILE__, __LINE__ );*/\
|
||||
}
|
||||
#define BS_FREE(p) {if(p){ free(p); p = NULL;}}
|
||||
#define BSCE if(last_err) return last_err;
|
||||
|
||||
class BS_Reader{
|
||||
public:
|
||||
BS_Reader(){
|
||||
last_err = BS_ERR_NONE;
|
||||
bs = NULL;
|
||||
buf_size = 0;
|
||||
file_pos = 0;
|
||||
offset = 0;
|
||||
bit = 0;
|
||||
buf = NULL;
|
||||
ignore_bytes = (BS_FADDR_TYPE*)malloc(sizeof(BS_FADDR_TYPE));
|
||||
ignore_bytes_cnt = 0;
|
||||
next_ignored_byte = NULL;
|
||||
tmp_buf = 0;
|
||||
trace_flag = true;
|
||||
trace_level = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
BS_Reader(BS_Reader const&) = delete;
|
||||
BS_Reader& operator=(BS_Reader const&) = delete;
|
||||
|
||||
virtual ~BS_Reader(){
|
||||
if( bs && buf ) free( buf );
|
||||
close();
|
||||
if( ignore_bytes ) free(ignore_bytes);
|
||||
}
|
||||
|
||||
BSErr open( const char* file_name );
|
||||
void set_buffer( byte* buf, Bs32u buf_size );
|
||||
|
||||
inline BSErr get_last_err(){ return last_err; };
|
||||
inline BS_FADDR_TYPE get_cur_pos() { return file_pos+offset; };
|
||||
inline BSErr close(){
|
||||
last_err = (bs) ? ( BS_FCLOSE(bs) ? BS_ERR_UNKNOWN : BS_ERR_NONE ) : BS_ERR_NONE;
|
||||
if(!last_err) bs = 0;
|
||||
return last_err;
|
||||
};
|
||||
inline void set_trace_level(Bs32u level) {trace_level = level;};
|
||||
|
||||
protected:
|
||||
Bs32u buf_size;
|
||||
Bs32u offset;
|
||||
byte bit;
|
||||
BS_FADDR_TYPE file_pos;
|
||||
BSErr last_err;
|
||||
|
||||
Bs32u tmp_buf;
|
||||
bool trace_flag;
|
||||
Bs32u trace_level;
|
||||
|
||||
inline void trace_on(Bs32u level) {trace_flag = !!(trace_level & level);};
|
||||
inline void trace_off() {trace_flag = (trace_level == 0xFFFFFFFF);};
|
||||
|
||||
Bs32u ue_v();
|
||||
Bs32s se_v();
|
||||
Bs32u read_bits( Bs32u nBits /*1..32*/ );
|
||||
Bs32u next_bits( Bs32u nBits /*1..32*/ ); // keep current position
|
||||
Bs32u next_bytes( byte nBytes /*1..4*/ );
|
||||
byte read_1_bit();
|
||||
byte read_1_byte();
|
||||
BSErr read_arr(byte* arr, Bs32u size);
|
||||
|
||||
void skip_bytes( Bs32u nBytes );
|
||||
void ignore_next_byte();
|
||||
BSErr shift(long nBytes);
|
||||
BSErr shift_forward( Bs32u nBytes );
|
||||
BSErr shift_back( Bs32u nBytes );
|
||||
|
||||
inline BSErr shift_forward64(Bs64u nBytes){
|
||||
while(nBytes){
|
||||
Bs32u n = (Bs32u)BS_MIN(nBytes,0xFFFFFFFF);
|
||||
shift_forward(n);BSCE;
|
||||
nBytes -= n;
|
||||
}
|
||||
return last_err;
|
||||
};
|
||||
|
||||
inline bool byte_aligned() { return bit ? false : true; };
|
||||
inline void skip_byte() { shift_forward(1); };
|
||||
inline void set_first_ignored_byte() { next_ignored_byte = &ignore_bytes[0]; };
|
||||
inline void wipe_ignore_bytes() { ignore_bytes_cnt = 0; next_ignored_byte = NULL; };
|
||||
Bs32u get_num_ignored_bytes(BS_FADDR_TYPE end){
|
||||
Bs32u n = 0;
|
||||
BS_FADDR_TYPE* b = next_ignored_byte;
|
||||
Bs32u c = 0;
|
||||
|
||||
while(c < ignore_bytes_cnt && b[c++] < end++)
|
||||
n++;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
private:
|
||||
BS_FH_TYPE bs; //file handle
|
||||
byte* buf;
|
||||
BS_FADDR_TYPE* ignore_bytes;
|
||||
BS_FADDR_TYPE* next_ignored_byte;
|
||||
Bs32u ignore_bytes_cnt;
|
||||
|
||||
BSErr read_more_data();
|
||||
|
||||
};
|
||||
#endif //__BS_READER_H
|
|
@ -1,418 +0,0 @@
|
|||
// Copyright (c) 2018-2020 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "bs_def.h"
|
||||
#include <stdio.h>
|
||||
#include <vector>
|
||||
#include <exception>
|
||||
#include <assert.h>
|
||||
|
||||
namespace BsReader2
|
||||
{
|
||||
|
||||
class Exception : public std::exception
|
||||
{
|
||||
private:
|
||||
BSErr m_sts;
|
||||
public:
|
||||
Exception(BSErr sts)
|
||||
: std::exception()
|
||||
, m_sts(sts)
|
||||
{ /*assert(!"Error in bs_parser!");*/ }
|
||||
inline BSErr Err() { return m_sts; }
|
||||
};
|
||||
|
||||
class EndOfBuffer : public Exception
|
||||
{
|
||||
public:
|
||||
EndOfBuffer() : Exception(BS_ERR_MORE_DATA) {}
|
||||
};
|
||||
|
||||
class InvalidSyntax : public Exception
|
||||
{
|
||||
public:
|
||||
InvalidSyntax() : Exception(BS_ERR_UNKNOWN) { /*assert(!"invalid syntax!");*/ }
|
||||
};
|
||||
|
||||
class BufferUpdater
|
||||
{
|
||||
public:
|
||||
virtual bool UpdateBuffer(Bs8u*& start, Bs8u*& cur, Bs8u*& end, Bs32u keepBytes) = 0;
|
||||
virtual ~BufferUpdater() {};
|
||||
};
|
||||
|
||||
class File : public BufferUpdater
|
||||
{
|
||||
private:
|
||||
FILE* m_f;
|
||||
std::vector<Bs8u> m_b;
|
||||
static const Bs32u DEFAULT_BUFF_SIZE = 2048;
|
||||
public:
|
||||
File();
|
||||
~File();
|
||||
|
||||
bool Open(const char* file, Bs32u buffSize = DEFAULT_BUFF_SIZE);
|
||||
void Close();
|
||||
bool UpdateBuffer(Bs8u*& start, Bs8u*& cur, Bs8u*& end, Bs32u keepBytes);
|
||||
};
|
||||
|
||||
#ifdef __BS_TRACE__
|
||||
|
||||
#define BS2_TRO { if (TraceOffset()) fprintf(GetLog(), "0x%016llX[%i]: ", GetByteOffset(), GetBitOffset()); }
|
||||
|
||||
#define BS2_SET(val, var) \
|
||||
{ \
|
||||
if (Trace()) { \
|
||||
BS2_TRO; \
|
||||
var = (val); \
|
||||
fprintf(GetLog(), std::is_same<Bs64u, decltype(var)>::value ? "%s = %lli\n" : "%s = %i\n", #var, var);\
|
||||
fflush(GetLog()); \
|
||||
} else { var = (val); } \
|
||||
}
|
||||
|
||||
#define BS2_SETM(val, var, map) \
|
||||
{ \
|
||||
if (Trace()) { \
|
||||
BS2_TRO; \
|
||||
var = (val); \
|
||||
fprintf(GetLog(), "%s = %s(%d)\n", #var, map[var], var); \
|
||||
fflush(GetLog()); \
|
||||
} else { var = (val); } \
|
||||
}
|
||||
|
||||
#define BS2_TRACE(val, var) \
|
||||
{ \
|
||||
if (Trace()) { \
|
||||
BS2_TRO; \
|
||||
fprintf(GetLog(), std::is_same<Bs64u, decltype(val)>::value ? "%s = %lli\n" : "%s = %i\n", #var, (val));\
|
||||
fflush(GetLog()); } \
|
||||
else { (val); } \
|
||||
}
|
||||
|
||||
#define BS2_TRACE_STR(str)\
|
||||
{ if (Trace()) { BS2_TRO; fprintf(GetLog(), "%s\n", (str)); fflush(GetLog());} }
|
||||
|
||||
#define BS2_SET_ARR_F(val, var, sz, split, format) \
|
||||
{ \
|
||||
if (Trace()){ \
|
||||
BS2_TRO; \
|
||||
fprintf(GetLog(), "%s = { ", #var); \
|
||||
for (Bs32u _i = 0; _i < Bs32u(sz); _i++){ \
|
||||
if ((split) != 0 && _i % (split) == 0) \
|
||||
fprintf(GetLog(), "\n"); \
|
||||
(var)[_i] = (val); \
|
||||
fprintf(GetLog(), format, (var)[_i]); \
|
||||
} \
|
||||
fprintf(GetLog(), "}\n"); fflush(GetLog()); \
|
||||
} else { for (Bs32u _i = 0; _i < (sz); _i++) (var)[_i] = (val); } \
|
||||
}
|
||||
|
||||
#define BS2_SET_ARR_M(val, var, sz, split, format, map) \
|
||||
{ \
|
||||
if (Trace()){ \
|
||||
BS2_TRO; \
|
||||
fprintf(GetLog(), "%s = { ", #var); \
|
||||
for (Bs32u _i = 0; _i < Bs32u(sz); _i++) { \
|
||||
if ((split) != 0 && _i % (split) == 0) \
|
||||
fprintf(GetLog(), "\n"); \
|
||||
(var)[_i] = (val); \
|
||||
fprintf(GetLog(), format, map[(var)[_i]], (var)[_i]);\
|
||||
} \
|
||||
fprintf(GetLog(), "}\n"); fflush(GetLog()); \
|
||||
} \
|
||||
else { for (Bs32u _i = 0; _i < (sz); _i++) (var)[_i] = (val); } \
|
||||
}
|
||||
|
||||
#define BS2_TRACE_ARR_VF(val, var, sz, split, format) \
|
||||
{ \
|
||||
if (Trace()){ \
|
||||
BS2_TRO; \
|
||||
fprintf(GetLog(), "%s = { ", #var); \
|
||||
for (Bs32u _i = 0; _i < Bs32u(sz); _i++) { \
|
||||
if ((split) != 0&& _i % (split) == 0) \
|
||||
fprintf(GetLog(), "\n"); \
|
||||
fprintf(GetLog(), format, (val)); \
|
||||
} \
|
||||
fprintf(GetLog(), "}\n"); fflush(GetLog());\
|
||||
} \
|
||||
else { for (Bs32u _i = 0; _i < (sz); _i++) (val); }\
|
||||
}
|
||||
|
||||
#define BS2_TRACE_MDARR(type, arr, dim, split, split2, format)\
|
||||
{ \
|
||||
if (Trace()){ \
|
||||
BS2_TRO; \
|
||||
fprintf(GetLog(), "%s = \n", #arr); \
|
||||
traceMDArr<type, sizeof(dim) / sizeof(Bs16u)>\
|
||||
(arr, dim, split, format, split2); \
|
||||
fflush(GetLog()); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define BS2_TRACE_BIN(pval, off, sz, var) \
|
||||
{ \
|
||||
if (Trace()) { \
|
||||
BS2_TRO; \
|
||||
fprintf(GetLog(), "%s = ", #var);\
|
||||
traceBin(pval, off, sz); \
|
||||
fprintf(GetLog(), "\n"); \
|
||||
fflush(GetLog()); \
|
||||
} \
|
||||
else { (pval); } \
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define BS2_TRO
|
||||
#define BS2_SET(val, var) { var = (val); }
|
||||
#define BS2_TRACE(val, var) {(void)(val);}
|
||||
#define BS2_TRACE_STR(str) {(void)(str);}
|
||||
#define BS2_SET_ARR_F(val, var, sz, split, format) \
|
||||
{ for (Bs32u _i = 0; _i < (Bs32u)(sz); _i++) (var)[_i] = (val); }
|
||||
#define BS2_TRACE_ARR_VF(val, var, sz, split, format) \
|
||||
{ for (Bs32u _i = 0; _i < (Bs32u)(sz); _i++) (void)(val); }
|
||||
#define BS2_TRACE_MDARR(type, arr, dim, split, split2, format) { (void)(arr);}
|
||||
#define BS2_SET_ARR_M(val, var, sz, split, format, map) BS2_SET_ARR_F(val, var, sz, split, format)
|
||||
#define BS2_SETM(val, var, map) BS2_SET(val, var)
|
||||
#define BS2_TRACE_BIN(pval, off, sz, var) { (void)(pval); }
|
||||
|
||||
#endif
|
||||
|
||||
#define BS2_SET_ARR(val, var, sz, split) BS2_SET_ARR_F(val, var, sz, split, "%i ")
|
||||
#define BS2_TRACE_ARR_F(var, sz, split, format) BS2_TRACE_ARR_VF(var[_i], var, sz, split, format)
|
||||
#define BS2_TRACE_ARR(var, sz, split) BS2_TRACE_ARR_F(var, sz, split, "%i ")
|
||||
|
||||
struct State
|
||||
{
|
||||
BufferUpdater* m_updater;
|
||||
Bs8u* m_bsStart;
|
||||
Bs8u* m_bsEnd;
|
||||
Bs8u* m_bs;
|
||||
Bs8u m_bitStart;
|
||||
Bs8u m_bitOffset;
|
||||
bool m_emulation;
|
||||
Bs32u m_emuBytes;
|
||||
Bs64u m_startOffset;
|
||||
bool m_trace;
|
||||
bool m_traceOffset;
|
||||
Bs32u m_traceLevel;
|
||||
FILE* m_log;
|
||||
};
|
||||
|
||||
class Reader : private State
|
||||
{
|
||||
public:
|
||||
Reader();
|
||||
~Reader();
|
||||
|
||||
Bs32u GetBit();
|
||||
Bs32u GetBits(Bs32u n);
|
||||
void GetBits(void* b, Bs32u o, Bs32u n);
|
||||
Bs32u GetUE();
|
||||
Bs32s GetSE();
|
||||
Bs32u GetByte(); // ignore bit offset
|
||||
Bs32u GetBytes(Bs32u n, bool nothrow = false); // ignore bit offset
|
||||
|
||||
void ReturnByte();
|
||||
void ReturnBits(Bs32u n);
|
||||
|
||||
bool NextStartCode(bool stopBefore);
|
||||
|
||||
bool TrailingBits(bool stopBefore = false);
|
||||
bool NextBytes(Bs8u* b, Bs32u n);
|
||||
|
||||
inline Bs32u NextBits(Bs32u n)
|
||||
{
|
||||
Bs32u b = GetBits(n);
|
||||
ReturnBits(n);
|
||||
return b;
|
||||
}
|
||||
|
||||
Bs32u ExtractRBSP(Bs8u* buf, Bs32u size);
|
||||
Bs32u ExtractData(Bs8u* buf, Bs32u size);
|
||||
|
||||
inline Bs64u GetByteOffset() { return m_startOffset + (m_bs - m_bsStart); }
|
||||
inline Bs16u GetBitOffset() { return m_bitOffset; }
|
||||
|
||||
inline void SetEmulation(bool f) { m_emulation = f; };
|
||||
inline bool GetEmulation() { return m_emulation; };
|
||||
|
||||
inline void SetEmuBytes(Bs32u f) { m_emuBytes = f; };
|
||||
inline Bs32u GetEmuBytes() { return m_emuBytes; };
|
||||
|
||||
void Reset(Bs8u* bs = 0, Bs32u size = 0, Bs8u bitOffset = 0);
|
||||
void Reset(BufferUpdater* reader) { m_updater = reader; m_bsEnd = 0; m_startOffset = 0; }
|
||||
|
||||
void SaveState(State& st){ st = *this; };
|
||||
void LoadState(State& st){ *(State*)this = st; };
|
||||
|
||||
#ifdef __BS_TRACE__
|
||||
inline bool Trace() { return m_trace; }
|
||||
inline bool TraceOffset() { return m_traceOffset; }
|
||||
inline void TLStart(Bs32u level) { m_trace = !!(m_traceLevel & level); m_tln++; m_tla |= (Bs64u(m_trace) << m_tln); };
|
||||
inline void TLEnd() { m_tla &= ~(Bs64u(1) << m_tln); m_tln--; m_trace = !!(1 & (m_tla >> m_tln)); };
|
||||
inline bool TLTest(Bs32u tl) { return !!(m_traceLevel & tl); }
|
||||
inline void SetTraceLevel(Bs32u level) { m_traceLevel = level; m_traceOffset = !!(level & 0x80000000); };
|
||||
#else
|
||||
inline bool Trace() { return false; }
|
||||
inline bool TraceOffset() { return false; }
|
||||
inline void TLStart(Bs32u /*level*/) { };
|
||||
inline void TLEnd() {};
|
||||
inline bool TLTest(Bs32u /*tl*/) { return false; }
|
||||
inline void SetTraceLevel(Bs32u /*level*/) { };
|
||||
#endif
|
||||
|
||||
inline FILE* GetLog() { return m_log; }
|
||||
inline void SetLog(FILE* log) { m_log = log; }
|
||||
|
||||
template<class T, Bs32u depth> void traceMDArr(
|
||||
const void* arr,
|
||||
const Bs16u* sz,
|
||||
Bs16u split,
|
||||
const char* format,
|
||||
Bs16u split2 = 0)
|
||||
{
|
||||
Bs16u off[depth];
|
||||
for (Bs32u i = 0; i < depth; i++)
|
||||
{
|
||||
off[i] = 1;
|
||||
for (Bs32u j = i + 1; j < depth; j++)
|
||||
off[i] *= sz[j];
|
||||
}
|
||||
for (Bs32u i = 0, j = 0; i < Bs32u(off[0] * sz[0]); i++)
|
||||
{
|
||||
while (i % off[j] == 0)
|
||||
{
|
||||
fprintf(GetLog(), "{ ");
|
||||
|
||||
if (j < (split))
|
||||
{
|
||||
fprintf(GetLog(), "\n");
|
||||
for (Bs32u c = 0; c <= j; c++)
|
||||
fprintf(GetLog(), " ");
|
||||
}
|
||||
if (j == depth - 2)
|
||||
break;
|
||||
j++;
|
||||
}
|
||||
fprintf(GetLog(), format, ((const T*)arr)[i]);
|
||||
if (split2 && (i + 1) % split2 == 0
|
||||
&& (i + 1) / split2 > 0
|
||||
&& (i + 1) % off[j] != 0)
|
||||
{
|
||||
fprintf(GetLog(), "\n");
|
||||
for (Bs32u c = 0; c <= j; c++)
|
||||
fprintf(GetLog(), " ");
|
||||
}
|
||||
while ((i + 1) % off[j] == 0)
|
||||
{
|
||||
bool f = j ? (i + 1) % off[--j] == 0 : !!j--;
|
||||
fprintf(GetLog(), "} ");
|
||||
if (j < (split))
|
||||
{
|
||||
fprintf(GetLog(), "\n");
|
||||
for (Bs32u c = 0; c + f <= j; c++)
|
||||
fprintf(GetLog(), " ");
|
||||
}
|
||||
if (!f)
|
||||
{
|
||||
j++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
fprintf(GetLog(), "\n");
|
||||
}
|
||||
|
||||
template<class T> void traceBin(T* p, Bs32u off, Bs32u sz)
|
||||
{
|
||||
Bs32u S0 = sizeof(T) * 8;
|
||||
Bs32u O = off;
|
||||
T* P0 = p;
|
||||
|
||||
if (off + sz > BS_MAX(S0, 32))
|
||||
{
|
||||
fprintf(GetLog(), "\n");
|
||||
|
||||
for (Bs32u i = 0; i < off; i++)
|
||||
fprintf(GetLog(), " ");
|
||||
}
|
||||
|
||||
while (sz)
|
||||
{
|
||||
Bs32u S = S0 - O;
|
||||
Bs32u S1 = S0 - (O + BS_MIN(sz, S));
|
||||
|
||||
sz -= (S - S1);
|
||||
|
||||
while (S-- > S1)
|
||||
fprintf(GetLog(), "%d", !!(*p & (1 << S)));
|
||||
|
||||
p++;
|
||||
O = 0;
|
||||
|
||||
if (sz)
|
||||
{
|
||||
if ((p - P0) * S0 % 32 == 0)
|
||||
fprintf(GetLog(), "\n");
|
||||
else
|
||||
fprintf(GetLog(), " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Bs64u m_tla;
|
||||
Bs32u m_tln;
|
||||
|
||||
void MoreData(Bs32u keepBytes = 4);
|
||||
bool MoreDataNoThrow(Bs32u keepBytes = 4);
|
||||
};
|
||||
|
||||
class TLAuto
|
||||
{
|
||||
private:
|
||||
Reader& m_r;
|
||||
public:
|
||||
TLAuto(Reader& r, Bs32u tl) : m_r(r) { m_r.TLStart(tl); }
|
||||
~TLAuto() { m_r.TLEnd(); }
|
||||
};
|
||||
|
||||
class StateSwitcher
|
||||
{
|
||||
private:
|
||||
State m_st;
|
||||
Reader& m_r;
|
||||
public:
|
||||
StateSwitcher(Reader& r)
|
||||
: m_r(r)
|
||||
{
|
||||
m_r.SaveState(m_st);
|
||||
}
|
||||
|
||||
~StateSwitcher()
|
||||
{
|
||||
m_r.LoadState(m_st);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
#include <exception>
|
||||
|
||||
namespace BsThread
|
||||
{
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DONE = 0
|
||||
, WORKING
|
||||
, WAITING
|
||||
, QUEUED
|
||||
, LOST
|
||||
, FAILED
|
||||
} State;
|
||||
|
||||
typedef State Routine(void*, unsigned int entryCnt);
|
||||
typedef unsigned int SyncPoint;
|
||||
|
||||
struct Task
|
||||
{
|
||||
Routine* Execute;
|
||||
void* param;
|
||||
unsigned int id;
|
||||
int priority;
|
||||
unsigned int n;
|
||||
std::list<Task*> dependent;
|
||||
unsigned int blocked;
|
||||
bool detach;
|
||||
State state;
|
||||
std::mutex mtx;
|
||||
std::condition_variable cv;
|
||||
};
|
||||
|
||||
struct Thread
|
||||
{
|
||||
std::mutex mtx;
|
||||
std::condition_variable cv;
|
||||
std::thread thread;
|
||||
Task* task;
|
||||
bool terminate;
|
||||
unsigned int id;
|
||||
};
|
||||
|
||||
inline bool Ready(State s)
|
||||
{
|
||||
return (s == DONE || s == FAILED || s == LOST);
|
||||
}
|
||||
|
||||
// sync required
|
||||
class TaskQueueOverflow : public std::exception
|
||||
{
|
||||
public:
|
||||
TaskQueueOverflow() {/*printf("TaskQueueOverflow\n"); fflush(stdout);*/}
|
||||
~TaskQueueOverflow() {}
|
||||
};
|
||||
|
||||
class Scheduler
|
||||
{
|
||||
private:
|
||||
std::list<Thread> m_thread;
|
||||
std::list<Task> m_task;
|
||||
std::recursive_mutex m_mtx;
|
||||
std::condition_variable_any m_cv;
|
||||
unsigned int m_id;
|
||||
size_t m_depth;
|
||||
unsigned int m_locked;
|
||||
|
||||
static void Execute (Thread& self, Scheduler& sync);
|
||||
static void Update (Scheduler& self, Thread* thread);
|
||||
|
||||
void _AbortDependent(Task& task);
|
||||
|
||||
public:
|
||||
Scheduler();
|
||||
~Scheduler();
|
||||
|
||||
void Init(unsigned int nThreads, unsigned int depth = 128);
|
||||
void Close();
|
||||
|
||||
SyncPoint Submit (Routine* routine, void* par, int priority, unsigned int nDep, SyncPoint *dep);
|
||||
State Sync (SyncPoint sp, unsigned int waitMS, bool keepStat = false);
|
||||
bool Abort (SyncPoint sp, unsigned int waitMS);
|
||||
|
||||
State AddDependency (SyncPoint task, unsigned int nDep, SyncPoint *dep);
|
||||
void Detach (SyncPoint task); // no sync for this task
|
||||
bool WaitForAny (unsigned int waitMS);
|
||||
};
|
||||
|
||||
};
|
|
@ -1,91 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "bs_reader2.h"
|
||||
#include "hevc_cabac.h"
|
||||
|
||||
#define BS_AVC2_ADE_MODE 1 //0 - literal standard implementation, 1 - optimized(2-byte buffering affects SE offsets in trace)
|
||||
|
||||
namespace COMMON_CABAC
|
||||
{
|
||||
class ADE
|
||||
{
|
||||
private:
|
||||
BsReader2::Reader& m_bs;
|
||||
Bs64u m_bpos = 0;
|
||||
bool m_pcm = false;
|
||||
#if (BS_AVC2_ADE_MODE == 1)
|
||||
Bs32u m_val = 0;
|
||||
Bs32u m_range = 0;
|
||||
Bs32s m_bits = 0;
|
||||
|
||||
inline Bs32u B(Bs16u n) { m_bpos += n * 8; return m_bs.GetBytes(n, true); }
|
||||
#else
|
||||
Bs16u m_codIRange;
|
||||
Bs16u m_codIOffset;
|
||||
|
||||
inline Bs16u b(Bs16u n) { m_bpos += n; return m_bs.GetBits(n); }
|
||||
inline Bs16u b() { m_bpos++; return m_bs.GetBit(); }
|
||||
#endif
|
||||
|
||||
public:
|
||||
ADE(BsReader2::Reader& r) : m_bs(r) {}
|
||||
~ADE() {}
|
||||
|
||||
inline void Init()
|
||||
{
|
||||
#if (BS_AVC2_ADE_MODE == 1)
|
||||
m_val = B(3);
|
||||
m_range = 510;
|
||||
m_bits = 15;
|
||||
|
||||
if (!m_pcm)
|
||||
m_bpos = 15;
|
||||
#else
|
||||
m_codIRange = 510;
|
||||
m_codIOffset = b(9);
|
||||
|
||||
if (!m_pcm)
|
||||
m_bpos = 0;
|
||||
#endif
|
||||
m_pcm = false;
|
||||
}
|
||||
|
||||
Bs8u DecodeDecision(Bs8u& ctxState);
|
||||
Bs8u DecodeBypass();
|
||||
Bs8u DecodeTerminate();
|
||||
|
||||
#if (BS_AVC2_ADE_MODE == 1)
|
||||
inline Bs16u GetR() { return Bs16u(m_range); }
|
||||
inline Bs16u GetV() { return Bs16u((m_val >> (m_bits))); }
|
||||
inline Bs64u BitCount() { return m_bpos - m_bits; }
|
||||
inline void InitPCMBlock() { m_bs.ReturnBits(m_bits); m_bpos -= m_bits; m_bits = 0; m_pcm = true; }
|
||||
#else
|
||||
inline Bs16u GetR() { return m_codIRange; }
|
||||
inline Bs16u GetV() { return m_codIOffset; }
|
||||
inline Bs64u BitCount() { return m_bpos; }
|
||||
inline void InitPCMBlock() { m_pcm = true; };
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
}
|
|
@ -1,623 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "bs_reader2.h"
|
||||
#include "bs_mem+.h"
|
||||
#include "bs_thread.h"
|
||||
#include "hevc2_struct.h"
|
||||
#include "common_cabac.h"
|
||||
#include "hevc_cabac.h"
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
namespace BS_HEVC2
|
||||
{
|
||||
|
||||
template<class T> inline bool GetBit(T f, Bs32u i)
|
||||
{
|
||||
return !!(f & (1 << (sizeof(T) * 8 - 1 - i)));
|
||||
}
|
||||
|
||||
template<class T> inline void SetBit(T& f, Bs32u i, bool b)
|
||||
{
|
||||
T mask = (T(1) << (sizeof(T) * 8 - 1 - i));
|
||||
if (b) f |= mask;
|
||||
else f &= ~mask;
|
||||
}
|
||||
|
||||
template<class T> Bs32u CntBits(T f, Bs32u n = 0)
|
||||
{
|
||||
Bs32u c = 0, sz = sizeof(T) * 8;
|
||||
|
||||
if (!n)
|
||||
n = sz;
|
||||
|
||||
f >>= (sz - n);
|
||||
|
||||
while (n--)
|
||||
{
|
||||
c += (f & 1);
|
||||
f >>= 1;
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
inline Bs32u CeilLog2(Bs32u x) { Bs32u l = 0; while (x > (1U << l)) l++; return l; }
|
||||
#if 0
|
||||
inline Bs32u FloorLog2(Bs32u x) { Bs32u l = 0; while (x >>= 1) ++l; return l; }
|
||||
#else
|
||||
inline Bs32u CountOnes(Bs32u x)
|
||||
{
|
||||
x -= ((x >> 1) & 0x55555555);
|
||||
x = (((x >> 2) & 0x33333333) + (x & 0x33333333));
|
||||
x = (((x >> 4) + x) & 0x0f0f0f0f);
|
||||
x += (x >> 8);
|
||||
x += (x >> 16);
|
||||
return (x & 0x0000003f);
|
||||
}
|
||||
inline Bs32u FloorLog2(Bs32u x)
|
||||
{
|
||||
x |= (x >> 1);
|
||||
x |= (x >> 2);
|
||||
x |= (x >> 4);
|
||||
x |= (x >> 8);
|
||||
x |= (x >> 16);
|
||||
return (CountOnes(x) - 1);
|
||||
//return CountOnes(x >> 1);
|
||||
}
|
||||
#endif
|
||||
template<class T> inline T CeilDiv(T x, T y) { return (x + y - 1) / y; }
|
||||
|
||||
inline bool isSlice(NALU& nalu) {
|
||||
return (nalu.nal_unit_type <= CRA_NUT)
|
||||
&& ((nalu.nal_unit_type < RSV_VCL_N10)
|
||||
|| (nalu.nal_unit_type > RSV_VCL_R15));
|
||||
}
|
||||
inline bool isIRAP(NALU& nalu) {
|
||||
return ((nalu.nal_unit_type >= BLA_W_LP) && (nalu.nal_unit_type <= RSV_IRAP_VCL23));
|
||||
}
|
||||
|
||||
inline bool isIDR(NALU& nalu) {
|
||||
return ((nalu.nal_unit_type == IDR_W_RADL) || (nalu.nal_unit_type == IDR_N_LP));
|
||||
}
|
||||
|
||||
inline bool isCRA(NALU& nalu) {
|
||||
return (nalu.nal_unit_type == CRA_NUT);
|
||||
}
|
||||
|
||||
inline bool isRADL(NALU& nalu) {
|
||||
return ((nalu.nal_unit_type == RADL_R) || (nalu.nal_unit_type == RADL_N));
|
||||
}
|
||||
|
||||
inline bool isRASL(NALU& nalu) {
|
||||
return ((nalu.nal_unit_type == RASL_R) || (nalu.nal_unit_type == RASL_N));
|
||||
}
|
||||
|
||||
inline bool isBLA(NALU& nalu) {
|
||||
return ((nalu.nal_unit_type == BLA_W_LP)
|
||||
|| (nalu.nal_unit_type == BLA_W_RADL)
|
||||
|| (nalu.nal_unit_type == BLA_N_LP));
|
||||
}
|
||||
|
||||
class NoActiveSet : public BsReader2::Exception
|
||||
{
|
||||
public:
|
||||
NoActiveSet() : Exception(BS_ERR_WRONG_UNITS_ORDER) {}
|
||||
};
|
||||
|
||||
struct NALUDesc
|
||||
{
|
||||
NALU* p;
|
||||
Bs32u NuhBytes;
|
||||
bool complete;
|
||||
bool prealloc;
|
||||
};
|
||||
|
||||
struct PocInfo
|
||||
{
|
||||
Bs32s Lsb;
|
||||
Bs32s Msb;
|
||||
};
|
||||
|
||||
extern const Bs8u ScanOrder1[4][2 * 2][2]; //[Up-right diagonal, Horizontal, Vertical, Traverse]
|
||||
extern const Bs8u ScanOrder2[4][4 * 4][2]; //[Up-right diagonal, Horizontal, Vertical, Traverse]
|
||||
extern const Bs8u ScanOrder3[4][8 * 8][2]; //[Up-right diagonal, Horizontal, Vertical, Traverse]
|
||||
extern const Bs8u ScanTraverse4[16 * 16][2]; //(ScanOrder4[3])
|
||||
extern const Bs8u ScanTraverse5[32 * 32][2]; //(ScanOrder5[3])
|
||||
extern const Bs8u ScanPos1[4][2][2]; //[Up-right diagonal, Horizontal, Vertical, Traverse]
|
||||
extern const Bs8u ScanPos2[4][4][4]; //[Up-right diagonal, Horizontal, Vertical, Traverse]
|
||||
extern const Bs8u ScanPos3[4][8][8]; //[Up-right diagonal, Horizontal, Vertical, Traverse]
|
||||
|
||||
class Info
|
||||
{
|
||||
public:
|
||||
Info()
|
||||
{
|
||||
m_prevPOC.Lsb = 0;
|
||||
m_prevPOC.Msb = 0;
|
||||
}
|
||||
|
||||
void decodeSSH (NALU& nalu, bool bNewSequence);
|
||||
void decodePOC (NALU& nalu);
|
||||
void decodeRPL (NALU& nalu);
|
||||
|
||||
bool NoRaslOutputFlag = false;
|
||||
bool NoBackwardPredFlag = false;
|
||||
bool NewPicture = false;
|
||||
bool TwoVersionsOfCurrDecPicFlag = false;
|
||||
Bs32s MaxPicOrderCntLsb = 0;
|
||||
Bs16u MinCbLog2SizeY = 0;
|
||||
Bs16u CtbLog2SizeY = 0;
|
||||
Bs16u CtbSizeY = 0;
|
||||
Bs16u PicWidthInCtbsY = 0;
|
||||
Bs16u PicHeightInCtbsY = 0;
|
||||
Bs16u MinCbSizeY = 0;
|
||||
Bs16u PicWidthInMinCbsY = 0;
|
||||
Bs16u PicHeightInMinCbsY = 0;
|
||||
Bs32u PicSizeInMinCbsY = 0;
|
||||
Bs32u PicSizeInCtbsY = 0;
|
||||
Bs32u PicSizeInSamplesY = 0;
|
||||
Bs16u PicWidthInSamplesC = 0;
|
||||
Bs16u PicHeightInSamplesC = 0;
|
||||
Bs16u MinTbLog2SizeY = 0;
|
||||
Bs16u MaxTbLog2SizeY = 0;
|
||||
Bs16u Log2MinIpcmCbSizeY = 0;
|
||||
Bs16u Log2MaxIpcmCbSizeY = 0;
|
||||
Bs16u Log2MinCuQpDeltaSize = 0;
|
||||
Bs16u Log2ParMrgLevel = 0;
|
||||
Bs16s SliceQpY = 0;
|
||||
Bs16u BitDepthY = 0;
|
||||
Bs16u BitDepthC = 0;
|
||||
Bs16u ChromaArrayType = 0;
|
||||
Bs16u Log2MinCuChromaQpOffsetSize = 0;
|
||||
Bs16u SubWidthC = 0;
|
||||
Bs16u SubHeightC = 0;
|
||||
Bs16u CtbWidthC = 0;
|
||||
Bs16u CtbHeightC = 0;
|
||||
Bs32u RawCtuBits = 0;
|
||||
Bs16s QpBdOffsetY = 0;
|
||||
Bs16s QpBdOffsetC = 0;
|
||||
Bs16u PaletteMaxPredictorSize = 0;
|
||||
|
||||
Slice** ColPicSlices = nullptr;
|
||||
Bs16u NumColSlices = 0;
|
||||
std::vector<Bs16u> colWidth;
|
||||
std::vector<Bs16u> rowHeight;
|
||||
std::vector<Bs16u> colBd;
|
||||
std::vector<Bs16u> rowBd;
|
||||
std::vector<Bs16u> CtbAddrRsToTs;
|
||||
std::vector<Bs16u> CtbAddrTsToRs;
|
||||
std::vector<Bs16u> TileId;
|
||||
std::vector<Bs16s> SliceAddrRsInTs;
|
||||
std::vector<CTU*> CtuInRs;
|
||||
|
||||
PocInfo m_prevPOC;
|
||||
Bs32s m_prevSlicePOC = 0;
|
||||
Slice* m_cSlice = nullptr;
|
||||
std::map<Bs32s, bool> m_DPB;
|
||||
std::map<Bs32s, bool> m_DPBafter;
|
||||
std::vector<Bs32s> m_MinTbAddrZs;
|
||||
Bs32u m_MinTbAddrZsPitch = 0;
|
||||
std::vector<SAO> m_sao[3];
|
||||
|
||||
std::vector<Bs8u> PalettePredictorEntryReuseFlags;
|
||||
Bs16u PaletteIndexIdc[32 * 32] = {};
|
||||
bool CopyAboveIndicesFlag[32][32] = {};
|
||||
Bs16u PaletteIndexMap[32][32] = {};
|
||||
std::vector<Bs16u> CurrentPaletteEntries[3];
|
||||
bool m_bRPLDecoded = false;
|
||||
|
||||
inline Bs32s& MinTbAddrZs(Bs32u x, Bs32u y) { return m_MinTbAddrZs[y * m_MinTbAddrZsPitch + x]; }
|
||||
inline SAO& GetSAO(Bs16u cIdx, Bs16u rx, Bs16u ry) { return m_sao[cIdx][ry * PicWidthInCtbsY + rx]; }
|
||||
|
||||
bool AvailableZs(Bs16s xCurr, Bs16s yCurr, Bs16s xNbY, Bs16s yNbY);
|
||||
bool AvailablePb(Bs16s xCb, Bs16s yCb, Bs16u nCbS, Bs16s xPb, Bs16s yPb,
|
||||
Bs16s nPbW, Bs16s nPbH, Bs16u partIdx, Bs16s xNbY, Bs16s yNbY);
|
||||
CU* GetCU(Bs16s x, Bs16s y);
|
||||
PU* GetPU(Bs16s x, Bs16s y);
|
||||
TU* GetTU(CU& cu, Bs16s x, Bs16s y);
|
||||
Bs16s GetQpCb(Bs16s QpY, Bs16s CuQpOffsetCb);
|
||||
Bs16s GetQpCr(Bs16s QpY, Bs16s CuQpOffsetCr);
|
||||
void decodeMvLX(CU& cu, PU&pu, Bs16u X, Bs32s (&MvdLX)[2], Bs16u partIdx);
|
||||
void decodeMvLX(CU& cu, PU&pu, Bs16u partIdx);
|
||||
bool decodeMvLXCol(Bs16u xPb, Bs16u yPb, Bs16u nPbW, Bs16u nPbH, Bs16u X, Bs16u refIdxLX, Bs16s (&mvLXCol)[2]);
|
||||
};
|
||||
|
||||
struct CabacCtx
|
||||
{
|
||||
CabacCtx() = default;
|
||||
|
||||
Bs8u m_ctxState[BS_HEVC::CtxTblSize];
|
||||
Bs16u StatCoeff[4];
|
||||
std::vector<Bs16u> PredictorPaletteEntries[3];
|
||||
Bs16u PredictorPaletteSize;
|
||||
};
|
||||
|
||||
class CABAC
|
||||
: private COMMON_CABAC::ADE
|
||||
, public virtual Info
|
||||
, public CabacCtx
|
||||
{
|
||||
private:
|
||||
Bs16s m_g1I = 0;
|
||||
Bs16s m_rI = 0;
|
||||
CabacCtx m_ctxWPP;
|
||||
CabacCtx m_ctxDS;
|
||||
Bs16u ctxSet = 0;
|
||||
Bs16u lastGreater1Ctx = 0;
|
||||
bool lastGreater1Flag = false;
|
||||
Bs32u cLastAbsLevel = 0;
|
||||
Bs16u cLastRiceParam = 0;
|
||||
Bs16u m_paletteIdxCnt = 0;
|
||||
|
||||
inline Bs8u DecodeBin(Bs16s off, Bs16s inc)
|
||||
{
|
||||
BinCount++;
|
||||
if (off < 0) inc = off;
|
||||
if (inc == -1) return DecodeBypass();
|
||||
if (inc == -2) return DecodeTerminate();
|
||||
if (inc < 0) throw BsReader2::InvalidSyntax();
|
||||
return DecodeDecision(m_ctxState[off + inc]);
|
||||
}
|
||||
Bs32u EGkBypass(Bs32u k);
|
||||
Bs32u TBBypass(Bs32u cMax);
|
||||
inline Bs8u& CtxState(Bs16u se, Bs16s inc = 0) { return m_ctxState[BS_HEVC::CtxOffset[se] + inc]; }
|
||||
inline bool DD(Bs16u se, Bs16s inc = 0) { BinCount++; return !!DecodeDecision(CtxState(se, inc)); }
|
||||
inline bool DT() { BinCount++; return !!DecodeTerminate(); }
|
||||
inline bool DB() { BinCount++; return !!DecodeBypass(); }
|
||||
|
||||
public:
|
||||
Bs64u BinCount = 0;
|
||||
|
||||
CABAC(BsReader2::Reader& r)
|
||||
: ADE(r)
|
||||
{}
|
||||
|
||||
void InitCtx();
|
||||
inline void InitADE() { ADE::Init(); }
|
||||
inline void InitPCMBlock() { ADE::InitPCMBlock(); }
|
||||
|
||||
inline void SyncWPP () { (CabacCtx&)(*this) = m_ctxWPP; }
|
||||
inline void SyncDS () { (CabacCtx&)(*this) = m_ctxDS; }
|
||||
inline void StoreWPP() { m_ctxWPP = (CabacCtx&)(*this); }
|
||||
inline void StoreDS () { m_ctxDS = (CabacCtx&)(*this); }
|
||||
|
||||
inline Bs16u GetR() { return ADE::GetR(); }
|
||||
inline Bs16u GetV() { return ADE::GetV(); }
|
||||
inline Bs64u BitCount() { return ADE::BitCount(); }
|
||||
|
||||
// slice_segment_data()
|
||||
inline bool EndOfSliceSegmentFlag() {return DT(); }
|
||||
inline bool EndOfSubsetOneBit() {return DT(); }
|
||||
|
||||
// sao()
|
||||
inline bool SaoMergeLeftFlag() { return DD(BS_HEVC::SAO_MERGE_LEFT_FLAG); }
|
||||
inline bool SaoMergeUpFlag() { return DD(BS_HEVC::SAO_MERGE_UP_FLAG); }
|
||||
inline Bs8u SaoTypeIdxChroma() { return SaoTypeIdxLuma(); }
|
||||
Bs8u SaoTypeIdxLuma();
|
||||
Bs8u SaoOffsetAbs(Bs16u bitDepth);
|
||||
inline bool SaoOffsetSign() { return DB(); }
|
||||
Bs8u SaoBandPosition();
|
||||
Bs8u SaoEoClassLuma();
|
||||
inline Bs8u SaoEoClassChroma() { return SaoEoClassLuma(); }
|
||||
|
||||
//coding_quadtree()
|
||||
bool SplitCuFlag(Bs16s x0, Bs16s y0);
|
||||
|
||||
//coding_unit()
|
||||
inline bool CuTransquantBypassFlag() { return DD(BS_HEVC::CU_TRANSQUANT_BYPASS_FLAG); }
|
||||
bool CuSkipFlag(Bs16s x0, Bs16s y0);
|
||||
inline bool PaletteModeFlag() { return DD(BS_HEVC::PALETTE_MODE_FLAG); }
|
||||
inline bool PredModeFlag() { return DD(BS_HEVC::PRED_MODE_FLAG); }
|
||||
Bs8u PartMode(bool intra, Bs16u log2CbSize);
|
||||
inline bool PcmFlag() { return DT(); }
|
||||
inline bool PrevIntraLumaPredFlag() { return DD(BS_HEVC::PREV_INTRA_LUMA_PRED_FLAG); }
|
||||
Bs8u MpmIdx();
|
||||
inline Bs8u RemIntraLumaPredMode() { return SaoBandPosition(); }
|
||||
Bs8u IntraChromaPredMode();
|
||||
inline bool RqtRootCbf() { return DD(BS_HEVC::RQT_ROOT_CBF); }
|
||||
|
||||
//prediction_unit()
|
||||
inline bool MergeFlag() { return DD(BS_HEVC::MERGE_FLAG); }
|
||||
Bs8u MergeIdx();
|
||||
Bs8u InterPredIdc(Bs16u nPbW, Bs16u nPbH, Bs16u CtDepth);
|
||||
Bs8u RefIdxL0();
|
||||
Bs8u RefIdxL1();
|
||||
inline bool MvpL0Flag() { return DD(BS_HEVC::MVP_LX_FLAG); }
|
||||
inline bool MvpL1Flag() { return MvpL0Flag(); }
|
||||
|
||||
//transform_tree()
|
||||
inline bool SplitTransformFlag(Bs16u log2TrafoSize) { return DD(BS_HEVC::SPLIT_TRANSFORM_FLAG, 5 - log2TrafoSize); }
|
||||
inline bool CbfLuma(Bs16u trafoDepth) { return DD(BS_HEVC::CBF_LUMA, !trafoDepth); }
|
||||
inline bool CbfCb(Bs16u trafoDepth) { return DD(BS_HEVC::CBF_CX, trafoDepth); }
|
||||
inline bool CbfCr(Bs16u trafoDepth) { return CbfCb(trafoDepth); }
|
||||
|
||||
//mvd_coding()
|
||||
inline bool AbsMvdGreater0Flag() { return DD(BS_HEVC::ABS_MVD_GREATER0_FLAG); }
|
||||
inline bool AbsMvdGreater1Flag() { return DD(BS_HEVC::ABS_MVD_GREATER1_FLAG); }
|
||||
inline bool MvdSignFlag() { return DB(); }
|
||||
inline Bs16u AbsMvdMinus2() { return (Bs16u)EGkBypass(1); }
|
||||
|
||||
//transform_unit()
|
||||
inline bool TuResidualActFlag() { return DD(BS_HEVC::TU_RESIDUAL_ACT_FLAG); }
|
||||
//delta_qp()
|
||||
Bs16u CuQpDeltaAbs();
|
||||
inline bool CuQpDeltaSignFlag() { return DB(); }
|
||||
//chroma_qp_offset()
|
||||
inline bool CuChromaQpOffsetFlag() { return DD(BS_HEVC::CU_CHROMA_QP_OFFSET_FLAG); }
|
||||
Bs8u CuChromaQpOffsetIdx();
|
||||
|
||||
//cross_comp_pred()
|
||||
Bs8u Log2ResScaleAbsPlus1(Bs16u c);
|
||||
inline bool ResScaleSignFlag(Bs16u c) { return DD(BS_HEVC::RES_SCALE_SIGN_FLAG, c); }
|
||||
|
||||
//residual_coding()
|
||||
inline bool TransformSkipFlag(Bs16u cIdx) { return DD(BS_HEVC::TRANSFORM_SKIP_FLAG0, !!cIdx); }
|
||||
inline bool ExplicitRdpcmFlag(Bs16u cIdx) { return DD(BS_HEVC::EXPLICIT_RDPCM_FLAG, !!cIdx); }
|
||||
inline bool ExplicitRdpcmDirFlag(Bs16u cIdx) { return DD(BS_HEVC::EXPLICIT_RDPCM_DIR_FLAG, !!cIdx); }
|
||||
Bs8u LastSigCoeffXPrefix(Bs16u cIdx, Bs16u log2TrafoSize);
|
||||
Bs8u LastSigCoeffYPrefix(Bs16u cIdx, Bs16u log2TrafoSize);
|
||||
Bs32u LastSigCoeffXSuffix(Bs16u prefix);
|
||||
inline Bs32u LastSigCoeffYSuffix(Bs16u prefix) { return LastSigCoeffXSuffix(prefix); }
|
||||
inline bool CodedSubBlockFlag(Bs16u ctxInc) { return DD(BS_HEVC::CODED_SUB_BLOCK_FLAG, ctxInc); }
|
||||
inline bool SigCoeffFlag(Bs16u ctxInc) { return DD(BS_HEVC::SIG_COEFF_FLAG, ctxInc); }
|
||||
bool CoeffAbsLevelGreater1Flag(Bs16u cIdx, Bs16u i);
|
||||
inline bool CoeffAbsLevelGreater2Flag(Bs16u cIdx) { return DD(BS_HEVC::COEFF_ABS_LEVEL_GREATER2_FLAG, ctxSet + 4 * !!cIdx); }
|
||||
Bs32u CoeffAbsLevelRemaining(Bs16u i, Bs16u baseLevel, Bs16u cIdx, CU& cu, TU& tu);
|
||||
inline bool CoeffSignFlag() { return DB(); }
|
||||
|
||||
//palette_coding()
|
||||
inline Bs8u PalettePredictorRun() { return (Bs8u)EGkBypass(0); }
|
||||
inline Bs8u NumSignalledPaletteEntries() { return (Bs8u)EGkBypass(0); }
|
||||
Bs16u NewPaletteEntries(Bs16u cIdx);
|
||||
inline bool PaletteEscapeValPresentFlag() { return DB(); }
|
||||
Bs16u NumPaletteIndices(Bs16u MaxPaletteIndex);
|
||||
inline Bs16u PaletteIndexIdc(Bs16u MaxPaletteIndex) { return (Bs16u)TBBypass(MaxPaletteIndex - !!(m_paletteIdxCnt++)); };
|
||||
inline bool CopyAboveIndicesForFinalRunFlag() { return DD(BS_HEVC::COPY_ABOVE_INDICES_FOR_FINAL_RUN_FLAG); }
|
||||
inline bool PaletteTransposeFlag() { return DD(BS_HEVC::PALETTE_TRANSPOSE_FLAG); }
|
||||
inline bool CopyAbovePaletteIndicesFlag() { return DD(BS_HEVC::COPY_ABOVE_PALETTE_INDICES_FLAG); }
|
||||
Bs16u PaletteRunPrefix(Bs16u PaletteMaxRun, bool copy_above_palette_indices_flag, Bs16u palette_index_idc);
|
||||
inline Bs16u PaletteRunSuffix(Bs16u PaletteMaxRun, Bs16u PrefixOffset)
|
||||
{ return (Bs16u)TBBypass((PrefixOffset << 1) > PaletteMaxRun ? (PaletteMaxRun - PrefixOffset) : (PrefixOffset - 1)); }
|
||||
Bs16u PaletteEscapeVal(Bs16u cIdx, bool cu_transquant_bypass_flag);
|
||||
};
|
||||
|
||||
class SDParser //Slice data parser
|
||||
: public BsReader2::Reader
|
||||
, private CABAC
|
||||
, public virtual Info
|
||||
{
|
||||
private:
|
||||
std::vector<CTU> m_ctu;
|
||||
std::vector<CU> m_cu;
|
||||
std::vector<PU> m_pu;
|
||||
std::vector<TU> m_tu;
|
||||
std::vector<Bs32s> m_TC_lvl;
|
||||
|
||||
bool IntraSplitFlag = false;
|
||||
Bs16u MaxTrafoDepth = 0;
|
||||
Bs16s CuQpDeltaVal = 0;
|
||||
Bs16s qPY_PREV = 0;
|
||||
bool IsCuQpDeltaCoded = false;
|
||||
bool IsCuChromaQpOffsetCoded = false;
|
||||
Bs8u intra_chroma_pred_mode[2][2] = {};
|
||||
|
||||
bool report_TCLevels = false;
|
||||
std::vector<Bs32s> TCLevels;
|
||||
|
||||
template<class T> T* Alloc(Bs16u n_elem = 1)
|
||||
{
|
||||
if (std::is_same<CTU, T>::value)
|
||||
{
|
||||
assert(m_ctu.capacity() >= m_ctu.size() + 1);
|
||||
CTU z{};
|
||||
m_ctu.push_back(z);
|
||||
return (T*)&m_ctu.back();
|
||||
}
|
||||
if (std::is_same<CU, T>::value)
|
||||
{
|
||||
assert(m_cu.capacity() >= m_cu.size() + 1);
|
||||
CU z{};
|
||||
m_cu.push_back(z);
|
||||
return (T*)&m_cu.back();
|
||||
}
|
||||
if (std::is_same<PU, T>::value)
|
||||
{
|
||||
assert(m_pu.capacity() >= m_pu.size() + 1);
|
||||
PU z{};
|
||||
m_pu.push_back(z);
|
||||
return (T*)&m_pu.back();
|
||||
}
|
||||
if (std::is_same<TU, T>::value)
|
||||
{
|
||||
assert(m_tu.capacity() >= m_tu.size() + 1);
|
||||
TU z{};
|
||||
m_tu.push_back(z);
|
||||
return (T*)&m_tu.back();
|
||||
}
|
||||
if (std::is_same<Bs32s, T>::value)
|
||||
{
|
||||
assert(m_TC_lvl.capacity() >= m_TC_lvl.size() + n_elem);
|
||||
m_TC_lvl.insert(m_TC_lvl.end(), n_elem, 0);
|
||||
return (T*)&m_TC_lvl[m_TC_lvl.size() - n_elem];
|
||||
}
|
||||
throw std::bad_alloc();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void parseSAO(CTU& ctu, Bs16u rx, Bs16u ry);
|
||||
CU* parseCQT(CU& cu, Bs16u log2CbSize, Bs16u cqtDepth);
|
||||
void parseCU (CU& cu);
|
||||
void parsePC (CU& cu);
|
||||
void parsePU (CU& cu, PU& pu, Bs16u CtDepth, Bs16u partIdx);
|
||||
TU* parseTT (CU& cu, TU& tu, TU& tuBase, Bs16u blkIdx);
|
||||
void parseTU (CU& cu, TU& tu, TU& tuBase, Bs16u blkIdx);
|
||||
void parseResidual(CU& cu, TU& tu, Bs16u x0, Bs16u y0, Bs16u log2TrafoSize, Bs16u cIdx);
|
||||
void parseDQP (CU& cu);
|
||||
void parseCQPO(CU& cu);
|
||||
|
||||
public:
|
||||
BS_MEM::Allocator* m_pAllocator;
|
||||
|
||||
SDParser(bool report_TC = false);
|
||||
|
||||
inline Bs32u u(Bs32u n) { return GetBits(n); };
|
||||
inline Bs32u u1() { return GetBit(); };
|
||||
inline Bs32u u8() { return GetBits(8); };
|
||||
inline Bs32u ue() { return GetUE(); };
|
||||
inline Bs32s se() { return GetSE(); };
|
||||
|
||||
bool more_rbsp_data();
|
||||
|
||||
CTU* parseSSD(NALU& nalu, NALU* pColPic, Bs32u NumCtb = -1);
|
||||
};
|
||||
|
||||
struct SDDesc
|
||||
{
|
||||
BsThread::SyncPoint sp;
|
||||
BsThread::State state;
|
||||
NALU* Slice;
|
||||
};
|
||||
|
||||
struct SDPar
|
||||
{
|
||||
NALU* Slice;
|
||||
NALU* ColPic;
|
||||
Bs32u HeaderSize;
|
||||
Bs32u NumCtb;
|
||||
bool Emulation;
|
||||
bool NewPicture;
|
||||
SDDesc* pTask;
|
||||
};
|
||||
|
||||
struct SDThread
|
||||
{
|
||||
SDParser p;
|
||||
std::vector<Bs8u> rbsp;
|
||||
std::list<SDPar> par;
|
||||
Bs32u locked;
|
||||
Bs32u RBSPSize;
|
||||
Bs32u RBSPOffset;
|
||||
std::mutex mtx;
|
||||
};
|
||||
|
||||
struct SyncPoint
|
||||
{
|
||||
BsThread::SyncPoint AU; // headers parsed, slice tasks submitted
|
||||
BsThread::SyncPoint AUDone;
|
||||
BSErr sts;
|
||||
std::list<SDDesc> SD;
|
||||
BS_MEM::Allocator* pAllocator;
|
||||
};
|
||||
|
||||
class Parser
|
||||
: private BS_MEM::Allocator
|
||||
, private BsReader2::File
|
||||
, private SDParser
|
||||
{
|
||||
private:
|
||||
Bs32u m_mode;
|
||||
NALUDesc m_lastNALU;
|
||||
NALU* m_au;
|
||||
SPS* m_activeSPS;
|
||||
VPS* m_vps[16];
|
||||
SPS* m_sps[16];
|
||||
PPS* m_pps[64];
|
||||
bool m_bNewSequence;
|
||||
std::list<SEI*> m_postponedSEI;
|
||||
std::map<Bs32s, NALU*> m_ColPic;
|
||||
|
||||
void parseNUH(NALU& nalu);
|
||||
void parseRBSP(NALU& nalu);
|
||||
|
||||
void parseAUD(AUD& aud);
|
||||
void parseVPS(VPS& vps);
|
||||
void parseSPS(SPS& sps);
|
||||
void parsePPS(PPS& pps);
|
||||
void parseSEI(SEI& sei);
|
||||
void parseSSH(NALU& nalu);
|
||||
void parseVUI(VUI& vui, Bs32u maxNumSubLayersMinus1);
|
||||
void parsePTL(PTL& ptl);
|
||||
void parsePTL(SubLayers& sl, Bs32u max_sub_layers_minus1);
|
||||
void parseHRD(HRD& hrd, void* base, bool commonInfPresentFlag, Bs32u maxNumSubLayersMinus1);
|
||||
void parseSLO(SubLayerOrderingInfo* slo, bool f, Bs32u n);
|
||||
void parseSLD(QM& qm);
|
||||
void ParseSTRPS(STRPS* strps, Bs32u num, Bs32u idx);
|
||||
void parseSEIPL(SEI& sei);
|
||||
void parseSEIPL(APS_SEI& aps);
|
||||
void parseSEIPL(BP_SEI& bp);
|
||||
void parseSEIPL(PT_SEI& pt);
|
||||
void parseSEIPL(RP_SEI& rp);
|
||||
|
||||
void parseMLE(PPS& pps);
|
||||
void parse3DE(PPS& pps);
|
||||
|
||||
Bs32u parseEXT(Bs8u*& ExtData);
|
||||
|
||||
NALU* GetColPic(Slice& slice);
|
||||
void UpdateColPics(NALU* AU, Slice& slice);
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
/*static*/ BsThread::Scheduler m_thread;
|
||||
std::list<SDThread> m_sdt;
|
||||
std::mutex m_mtx;
|
||||
std::map<NALU*, SyncPoint> m_spAuToId;
|
||||
std::vector<Bs8u> m_rbsp;
|
||||
NALU* m_prevSP;
|
||||
BSErr m_auErr;
|
||||
Bs16u m_asyncAUMax;
|
||||
Bs16u m_asyncAUCnt;
|
||||
|
||||
static BsThread::State ParallelAU(void* self, unsigned int);
|
||||
static BsThread::State ParallelSD(void* self, unsigned int);
|
||||
static BsThread::State AUDone(void* self, unsigned int);
|
||||
static BsThread::State SDTWait(void* self, unsigned int);
|
||||
|
||||
BSErr ParseNextAuSubmit(NALU*& pAU);
|
||||
BSErr ParseNextAu(NALU*& pAU);
|
||||
Bs32u ParseSSDSubmit(SDThread*& pSDT, NALU* AU);
|
||||
|
||||
public:
|
||||
Parser(Bs32u mode = 0);
|
||||
|
||||
~Parser();
|
||||
|
||||
BSErr open(const char* file_name);
|
||||
void close() { Close(); }
|
||||
|
||||
void set_buffer(Bs8u* buf, Bs32u buf_size) { Reset(buf, buf_size, 0); }
|
||||
|
||||
BSErr parse_next_au(NALU*& pAU);
|
||||
BSErr sync(NALU* pAU);
|
||||
|
||||
BSErr Lock(void* p);
|
||||
BSErr Unlock(void* p);
|
||||
|
||||
void set_trace_level(Bs32u level);
|
||||
inline Bs64u get_cur_pos() { return GetByteOffset(); }
|
||||
inline Bs16u get_async_depth() { return m_asyncAUMax; }
|
||||
|
||||
};
|
||||
|
||||
};
|
|
@ -1,983 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "bs_def.h"
|
||||
|
||||
namespace BS_HEVC2
|
||||
{
|
||||
|
||||
typedef class Parser* HDL;
|
||||
|
||||
enum INIT_MODE
|
||||
{
|
||||
INIT_MODE_DEFAULT = 0x00,
|
||||
PARSE_SSD = 0x01,
|
||||
PARALLEL_AU = 0x02,
|
||||
PARALLEL_SD = 0x04,
|
||||
PARALLEL_TILES = 0x08,
|
||||
PARSE_SSD_TC = 0x10 | PARSE_SSD,
|
||||
|
||||
ASYNC = (PARALLEL_AU | PARALLEL_SD | PARALLEL_TILES)
|
||||
};
|
||||
|
||||
enum TRACE_LEVEL
|
||||
{
|
||||
TRACE_NUH = 0x00000001,
|
||||
TRACE_AUD = 0x00000002,
|
||||
TRACE_VPS = 0x00000004,
|
||||
TRACE_SPS = 0x00000008,
|
||||
TRACE_PPS = 0x00000010,
|
||||
TRACE_SEI = 0x00000020,
|
||||
TRACE_SSH = 0x00000040,
|
||||
TRACE_REF = 0x00000080,
|
||||
TRACE_CTU = 0x00000100,
|
||||
TRACE_SAO = 0x00000200,
|
||||
TRACE_CQT = 0x00000400,
|
||||
TRACE_CU = 0x00000800,
|
||||
TRACE_PU = 0x00001000,
|
||||
TRACE_TT = 0x00002000,
|
||||
TRACE_TU = 0x00004000,
|
||||
TRACE_RESIDUAL = 0x00008000,
|
||||
TRACE_PRED = 0x04000000,
|
||||
TRACE_QP = 0x08000000,
|
||||
TRACE_COEF = 0x10000000,
|
||||
TRACE_SIZE = 0x40000000,
|
||||
TRACE_OFFSET = 0x80000000,
|
||||
TRACE_DEFAULT =
|
||||
TRACE_NUH
|
||||
| TRACE_AUD
|
||||
| TRACE_VPS
|
||||
| TRACE_SPS
|
||||
| TRACE_PPS
|
||||
| TRACE_SEI
|
||||
| TRACE_SSH
|
||||
| TRACE_REF
|
||||
| TRACE_SIZE
|
||||
//| TRACE_OFFSET
|
||||
};
|
||||
|
||||
enum NALU_TYPE
|
||||
{
|
||||
TRAIL_N = 0,
|
||||
TRAIL_R,
|
||||
TSA_N,
|
||||
TSA_R,
|
||||
STSA_N,
|
||||
STSA_R,
|
||||
RADL_N,
|
||||
RADL_R,
|
||||
RASL_N,
|
||||
RASL_R,
|
||||
RSV_VCL_N10, RSV_VCL_R11, RSV_VCL_N12,
|
||||
RSV_VCL_R13, RSV_VCL_N14, RSV_VCL_R15,
|
||||
BLA_W_LP,
|
||||
BLA_W_RADL,
|
||||
BLA_N_LP,
|
||||
IDR_W_RADL,
|
||||
IDR_N_LP,
|
||||
CRA_NUT,
|
||||
RSV_IRAP_VCL22, RSV_IRAP_VCL23,
|
||||
RSV_VCL24, RSV_VCL25, RSV_VCL26, RSV_VCL27,
|
||||
RSV_VCL28, RSV_VCL29, RSV_VCL30, RSV_VCL31,
|
||||
VPS_NUT,
|
||||
SPS_NUT,
|
||||
PPS_NUT,
|
||||
AUD_NUT,
|
||||
EOS_NUT,
|
||||
EOB_NUT,
|
||||
FD_NUT,
|
||||
PREFIX_SEI_NUT,
|
||||
SUFFIX_SEI_NUT,
|
||||
RSV_NVCL41, RSV_NVCL42, RSV_NVCL43, RSV_NVCL44,
|
||||
RSV_NVCL45, RSV_NVCL46, RSV_NVCL47,
|
||||
UNSPEC48, UNSPEC49, UNSPEC50, UNSPEC51,
|
||||
UNSPEC52, UNSPEC53, UNSPEC54, UNSPEC55,
|
||||
UNSPEC56, UNSPEC57, UNSPEC58, UNSPEC59,
|
||||
UNSPEC60, UNSPEC61, UNSPEC62, UNSPEC63,
|
||||
num_NALU_TYPE
|
||||
};
|
||||
|
||||
enum PROFILE
|
||||
{
|
||||
MAIN = 1,
|
||||
MAIN_10 = 2,
|
||||
MAIN_SP = 3,
|
||||
REXT = 4,
|
||||
REXT_HT = 5,
|
||||
MAIN_MV = 6,
|
||||
MAIN_SC = 7,
|
||||
MAIN_3D = 8,
|
||||
SCC = 9,
|
||||
REXT_SC = 10
|
||||
};
|
||||
|
||||
enum PIC_TYPE
|
||||
{
|
||||
PIC_I = 0,
|
||||
PIC_PI,
|
||||
PIC_BPI
|
||||
};
|
||||
|
||||
enum CHROMA_FORMAT
|
||||
{
|
||||
CHROMA_400 = 0,
|
||||
CHROMA_420 = 1,
|
||||
CHROMA_422 = 2,
|
||||
CHROMA_444 = 3
|
||||
};
|
||||
|
||||
enum AR_IDC
|
||||
{
|
||||
AR_IDC_1_1 = 1,
|
||||
AR_IDC_square = 1,
|
||||
AR_IDC_12_11 = 2,
|
||||
AR_IDC_10_11 = 3,
|
||||
AR_IDC_16_11 = 4,
|
||||
AR_IDC_40_33 = 5,
|
||||
AR_IDC_24_11 = 6,
|
||||
AR_IDC_20_11 = 7,
|
||||
AR_IDC_32_11 = 8,
|
||||
AR_IDC_80_33 = 9,
|
||||
AR_IDC_18_11 = 10,
|
||||
AR_IDC_15_11 = 11,
|
||||
AR_IDC_64_33 = 12,
|
||||
AR_IDC_160_99 = 13,
|
||||
AR_IDC_4_3 = 14,
|
||||
AR_IDC_3_2 = 15,
|
||||
AR_IDC_2_1 = 16,
|
||||
Extended_SAR = 255,
|
||||
};
|
||||
|
||||
enum VIDEO_FORMAT
|
||||
{
|
||||
Component = 0,
|
||||
PAL = 1,
|
||||
NTSC = 2,
|
||||
SECAM = 3,
|
||||
MAC = 4
|
||||
};
|
||||
|
||||
enum SEI_TYPE
|
||||
{
|
||||
SEI_BUFFERING_PERIOD = 0,
|
||||
SEI_PICTURE_TIMING = 1,
|
||||
SEI_PAN_SCAN_RECT = 2,
|
||||
SEI_FILLER_PAYLOAD = 3,
|
||||
SEI_USER_DATA_REGISTERED_ITU_T_T35 = 4,
|
||||
SEI_USER_DATA_UNREGISTERED = 5,
|
||||
SEI_RECOVERY_POINT = 6,
|
||||
SEI_SCENE_INFO = 9,
|
||||
SEI_FULL_FRAME_SNAPSHOT = 15,
|
||||
SEI_PROGRESSIVE_REFINEMENT_SEGMENT_START = 16,
|
||||
SEI_PROGRESSIVE_REFINEMENT_SEGMENT_END = 17,
|
||||
SEI_FILM_GRAIN_CHARACTERISTICS = 19,
|
||||
SEI_POST_FILTER_HINT = 22,
|
||||
SEI_TONE_MAPPING_INFO = 23,
|
||||
SEI_FRAME_PACKING = 45,
|
||||
SEI_DISPLAY_ORIENTATION = 47,
|
||||
SEI_SOP_DESCRIPTION = 128,
|
||||
SEI_ACTIVE_PARAMETER_SETS = 129,
|
||||
SEI_DECODING_UNIT_INFO = 130,
|
||||
SEI_TEMPORAL_LEVEL0_INDEX = 131,
|
||||
SEI_DECODED_PICTURE_HASH = 132,
|
||||
SEI_SCALABLE_NESTING = 133,
|
||||
SEI_REGION_REFRESH_INFO = 134,
|
||||
SEI_NO_DISPLAY = 135,
|
||||
SEI_TIME_CODE = 136,
|
||||
SEI_MASTERING_DISPLAY_COLOUR_VOLUME = 137,
|
||||
SEI_SEGM_RECT_FRAME_PACKING = 138,
|
||||
SEI_TEMP_MOTION_CONSTRAINED_TILE_SETS = 139,
|
||||
SEI_CHROMA_RESAMPLING_FILTER_HINT = 140,
|
||||
SEI_KNEE_FUNCTION_INFO = 141,
|
||||
SEI_COLOUR_REMAPPING_INFO = 142,
|
||||
};
|
||||
|
||||
enum PIC_STRUCT
|
||||
{
|
||||
FRAME = 0,
|
||||
TOP,
|
||||
BOT,
|
||||
TOP_BOT,
|
||||
BOT_TOP,
|
||||
TOP_BOT_TOP,
|
||||
BOT_TOP_BOT,
|
||||
FRAME_x2,
|
||||
FRAME_x3,
|
||||
TOP_PREVBOT,
|
||||
BOT_PREVTOP,
|
||||
TOP_NEXTBOT,
|
||||
BOT_NEXTTOP
|
||||
};
|
||||
|
||||
enum SOURCE_SCAN_TYPE
|
||||
{
|
||||
SCAN_INTERLACED = 0,
|
||||
SCAN_PROGRESSIVE,
|
||||
SCAN_UNKNOWN,
|
||||
SCAN_RESERVED
|
||||
};
|
||||
|
||||
enum SLICE_TYPE
|
||||
{
|
||||
B = 0,
|
||||
P,
|
||||
I
|
||||
};
|
||||
|
||||
enum PRED_MODE
|
||||
{
|
||||
MODE_INTER = 0
|
||||
, MODE_INTRA
|
||||
, MODE_SKIP
|
||||
};
|
||||
|
||||
enum PART_MODE
|
||||
{
|
||||
PART_2Nx2N = 0
|
||||
, PART_2NxN
|
||||
, PART_Nx2N
|
||||
, PART_NxN
|
||||
, PART_2NxnU
|
||||
, PART_2NxnD
|
||||
, PART_nLx2N
|
||||
, PART_nRx2N
|
||||
};
|
||||
|
||||
enum INTER_PRED
|
||||
{
|
||||
PRED_L0 = 0
|
||||
, PRED_L1
|
||||
, PRED_BI
|
||||
};
|
||||
|
||||
enum SAO_TYPE
|
||||
{
|
||||
NOT_APPLIED = 0
|
||||
, BAND_OFFSET
|
||||
, EDGE_OFFSET
|
||||
};
|
||||
|
||||
enum SAO_EO_CLASS
|
||||
{
|
||||
EO_0 = 0
|
||||
, EO_90
|
||||
, EO_135
|
||||
, EO_45
|
||||
};
|
||||
|
||||
struct AUD
|
||||
{
|
||||
Bs8u pic_type;
|
||||
};
|
||||
|
||||
struct PTL
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
Bs32u profile_space : 2;
|
||||
Bs32u tier_flag : 1;
|
||||
Bs32u profile_idc : 5;
|
||||
Bs32u progressive_source_flag : 1;
|
||||
Bs32u interlaced_source_flag : 1;
|
||||
Bs32u non_packed_constraint_flag : 1;
|
||||
Bs32u frame_only_constraint_flag : 1;
|
||||
Bs32u max_12bit_constraint_flag : 1;
|
||||
Bs32u max_10bit_constraint_flag : 1;
|
||||
Bs32u max_8bit_constraint_flag : 1;
|
||||
Bs32u max_422chroma_constraint_flag : 1;
|
||||
Bs32u max_420chroma_constraint_flag : 1;
|
||||
Bs32u max_monochrome_constraint_flag : 1;
|
||||
Bs32u intra_constraint_flag : 1;
|
||||
Bs32u one_picture_only_constraint_flag : 1;
|
||||
Bs32u lower_bit_rate_constraint_flag : 1;
|
||||
Bs32u reserved_zero_34bits_0_10 : 11;
|
||||
|
||||
Bs32u reserved_zero_34bits_11_33 : 23;
|
||||
Bs32u inbld_flag : 1;
|
||||
Bs32u level_idc : 8;
|
||||
};
|
||||
struct
|
||||
{
|
||||
Bs32u : 21;
|
||||
Bs32u max_14bit_constraint_flag : 1;
|
||||
Bs32u reserved_zero_33bits_0_9 : 10;
|
||||
|
||||
Bs32u reserved_zero_33bits_10_32 : 23;
|
||||
Bs32u : 9;
|
||||
};
|
||||
struct
|
||||
{
|
||||
Bs32u : 12;
|
||||
Bs32u reserved_zero_43bits_0_19 : 20;
|
||||
|
||||
Bs32u reserved_zero_43bits_20_42 : 23;
|
||||
Bs32u reserved_zero_bit : 1;
|
||||
Bs32u : 8;
|
||||
};
|
||||
};
|
||||
|
||||
Bs32u profile_compatibility_flags;
|
||||
|
||||
Bs32u profile_present_flag : 1;
|
||||
Bs32u level_present_flag : 1;
|
||||
Bs32u : 30;
|
||||
};
|
||||
|
||||
struct SubLayerOrderingInfo
|
||||
{
|
||||
Bs32u max_dec_pic_buffering_minus1 : 4;
|
||||
Bs32u max_num_reorder_pics : 4;
|
||||
Bs32u : 24;
|
||||
Bs32u max_latency_increase_plus1;
|
||||
};
|
||||
|
||||
struct HRD
|
||||
{
|
||||
Bs32u nal_hrd_parameters_present_flag : 1;
|
||||
Bs32u vcl_hrd_parameters_present_flag : 1;
|
||||
Bs32u sub_pic_hrd_params_present_flag : 1;
|
||||
Bs32u du_cpb_removal_delay_increment_length_minus1 : 5;
|
||||
Bs32u dpb_output_delay_du_length_minus1 : 5;
|
||||
Bs32u bit_rate_scale : 4;
|
||||
Bs32u initial_cpb_removal_delay_length_minus1 : 5;
|
||||
Bs32u au_cpb_removal_delay_length_minus1 : 5;
|
||||
Bs32u dpb_output_delay_length_minus1 : 5;
|
||||
|
||||
Bs32u tick_divisor_minus2 : 8;
|
||||
Bs32u cpb_size_scale : 4;
|
||||
Bs32u cpb_size_du_scale : 4;
|
||||
Bs32u sub_pic_cpb_params_in_pic_timing_sei_flag : 1;
|
||||
Bs32u : 15;
|
||||
|
||||
struct SubLayer
|
||||
{
|
||||
Bs32u fixed_pic_rate_general_flag : 1;
|
||||
Bs32u fixed_pic_rate_within_cvs_flag : 1;
|
||||
Bs32u elemental_duration_in_tc_minus1 : 11;
|
||||
Bs32u low_delay_hrd_flag : 1;
|
||||
Bs32u cpb_cnt_minus1 : 5;
|
||||
Bs32u : 14;
|
||||
|
||||
struct CPB
|
||||
{
|
||||
Bs32u bit_rate_value_minus1;
|
||||
Bs32u cpb_size_value_minus1;
|
||||
Bs32u cpb_size_du_value_minus1;
|
||||
Bs32u bit_rate_du_value_minus1;
|
||||
Bs32u cbr_flag : 1;
|
||||
Bs32u : 31;
|
||||
} *nal, *vcl;
|
||||
} sl[8];
|
||||
};
|
||||
|
||||
struct SubLayers
|
||||
{
|
||||
SubLayerOrderingInfo slo[8];
|
||||
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
PTL general;
|
||||
PTL sub_layer[7];
|
||||
};
|
||||
PTL ptl[8];
|
||||
};
|
||||
};
|
||||
|
||||
struct VPS : SubLayers
|
||||
{
|
||||
Bs32u video_parameter_set_id : 4;
|
||||
Bs32u base_layer_internal_flag : 1;
|
||||
Bs32u base_layer_available_flag : 1;
|
||||
Bs32u max_layers_minus1 : 6;
|
||||
Bs32u max_sub_layers_minus1 : 3;
|
||||
Bs32u temporal_id_nesting_flag : 1;
|
||||
Bs32u reserved_0xffff_16bits : 16;
|
||||
|
||||
Bs32u num_units_in_tick;
|
||||
Bs32u time_scale;
|
||||
|
||||
Bs32u timing_info_present_flag : 1;
|
||||
Bs32u poc_proportional_to_timing_flag : 1;
|
||||
Bs32u sub_layer_ordering_info_present_flag : 1;
|
||||
Bs32u extension_flag : 1;
|
||||
Bs32u num_ticks_poc_diff_one_minus1 : 10;
|
||||
Bs32u num_hrd_parameters : 10;
|
||||
Bs32u : 8;
|
||||
|
||||
Bs32u max_layer_id : 6;
|
||||
Bs32u num_layer_sets_minus1 : 10;
|
||||
Bs32u : 16;
|
||||
|
||||
Bs32u ExtBits;
|
||||
|
||||
Bs8u* layer_id_included_flags;
|
||||
|
||||
struct VPSHRD : HRD
|
||||
{
|
||||
Bs16u hrd_layer_set_idx : 10;
|
||||
Bs16u cprms_present_flag : 1;
|
||||
Bs16u : 5;
|
||||
} *hrd;
|
||||
|
||||
Bs8u* ExtData;
|
||||
};
|
||||
|
||||
|
||||
struct VUI
|
||||
{
|
||||
Bs32u sar_width : 16;
|
||||
Bs32u sar_height : 16;
|
||||
|
||||
Bs32u aspect_ratio_info_present_flag : 1;
|
||||
Bs32u timing_info_present_flag : 1;
|
||||
Bs32u hrd_parameters_present_flag : 1;
|
||||
Bs32u poc_proportional_to_timing_flag : 1;
|
||||
Bs32u bitstream_restriction_flag : 1;
|
||||
Bs32u tiles_fixed_structure_flag : 1;
|
||||
Bs32u motion_vectors_over_pic_boundaries_flag : 1;
|
||||
Bs32u restricted_ref_pic_lists_flag : 1;
|
||||
Bs32u aspect_ratio_idc : 8;
|
||||
Bs32u overscan_info_present_flag : 1;
|
||||
Bs32u overscan_appropriate_flag : 1;
|
||||
Bs32u video_signal_type_present_flag : 1;
|
||||
Bs32u video_full_range_flag : 1;
|
||||
Bs32u colour_description_present_flag : 1;
|
||||
Bs32u video_format : 3;
|
||||
Bs32u chroma_loc_info_present_flag : 1;
|
||||
Bs32u neutral_chroma_indication_flag : 1;
|
||||
Bs32u chroma_sample_loc_type_top_field : 3;
|
||||
Bs32u chroma_sample_loc_type_bottom_field : 3;
|
||||
|
||||
Bs32u field_seq_flag : 1;
|
||||
Bs32u frame_field_info_present_flag : 1;
|
||||
Bs32u default_display_window_flag : 1;
|
||||
Bs32u max_bytes_per_pic_denom : 5;
|
||||
Bs32u colour_primaries : 8;
|
||||
Bs32u transfer_characteristics : 8;
|
||||
Bs32u matrix_coeffs : 8;
|
||||
|
||||
Bs32u log2_max_mv_length_horizontal : 4;
|
||||
Bs32u log2_max_mv_length_vertical : 4;
|
||||
Bs32u max_bits_per_min_cu_denom : 5;
|
||||
Bs32u : 7;
|
||||
Bs32u min_spatial_segmentation_idc : 12;
|
||||
|
||||
Bs32u def_disp_win_left_offset;
|
||||
Bs32u def_disp_win_right_offset;
|
||||
Bs32u def_disp_win_top_offset;
|
||||
Bs32u def_disp_win_bottom_offset;
|
||||
|
||||
Bs32u num_units_in_tick;
|
||||
Bs32u time_scale;
|
||||
Bs32u num_ticks_poc_diff_one_minus1;
|
||||
|
||||
HRD* hrd;
|
||||
};
|
||||
|
||||
enum QM_IDX
|
||||
{
|
||||
QM_IntraY = 0,
|
||||
QM_IntraCb,
|
||||
QM_IntraCr,
|
||||
QM_InterY,
|
||||
QM_InterCb,
|
||||
QM_InterCr,
|
||||
};
|
||||
|
||||
struct QM
|
||||
{
|
||||
Bs8u ScalingFactor0[6][4][4];
|
||||
Bs8u ScalingFactor1[6][8][8];
|
||||
Bs8u ScalingFactor2[6][16][16];
|
||||
Bs8u ScalingFactor3[6][32][32];
|
||||
};
|
||||
|
||||
struct STRPS
|
||||
{
|
||||
Bs16u NumDeltaPocs;
|
||||
Bs16u UsedByCurrPicFlags;
|
||||
Bs16s DeltaPoc[16];
|
||||
};
|
||||
|
||||
struct SPS : SubLayers
|
||||
{
|
||||
Bs32u seq_parameter_set_id : 4;
|
||||
Bs32u video_parameter_set_id : 4;
|
||||
Bs32u temporal_id_nesting_flag : 1;
|
||||
Bs32u num_short_term_ref_pic_sets : 7;
|
||||
Bs32u separate_colour_plane_flag : 1;
|
||||
Bs32u conformance_window_flag : 1;
|
||||
Bs32u sub_layer_ordering_info_present_flag : 1;
|
||||
Bs32u chroma_format_idc : 2;
|
||||
Bs32u max_sub_layers_minus1 : 3;
|
||||
Bs32u scaling_list_enabled_flag : 1;
|
||||
Bs32u scaling_list_data_present_flag : 1;
|
||||
Bs32u amp_enabled_flag : 1;
|
||||
Bs32u sample_adaptive_offset_enabled_flag : 1;
|
||||
Bs32u pcm_sample_bit_depth_luma_minus1 : 4;
|
||||
|
||||
Bs32u pcm_enabled_flag : 1;
|
||||
Bs32u pcm_loop_filter_disabled_flag : 1;
|
||||
Bs32u long_term_ref_pics_present_flag : 1;
|
||||
Bs32u temporal_mvp_enabled_flag : 1;
|
||||
Bs32u pcm_sample_bit_depth_chroma_minus1 : 4;
|
||||
Bs32u strong_intra_smoothing_enabled_flag : 1;
|
||||
Bs32u bit_depth_chroma_minus8 : 4;
|
||||
Bs32u log2_max_pic_order_cnt_lsb_minus4 : 4;
|
||||
Bs32u vui_parameters_present_flag : 1;
|
||||
Bs32u bit_depth_luma_minus8 : 4;
|
||||
Bs32u num_long_term_ref_pics : 7;
|
||||
Bs32u motion_vector_resolution_control_idc : 2;
|
||||
Bs32u intra_boundary_filtering_disabled_flag : 1;
|
||||
|
||||
Bs32u extension_present_flag : 1;
|
||||
Bs32u range_extension_flag : 1;
|
||||
Bs32u multilayer_extension_flag : 1;
|
||||
Bs32u extension_3d_flag : 1;
|
||||
Bs32u scc_extension_flag : 1;
|
||||
Bs32u extension_xbits : 4;
|
||||
Bs32u transform_skip_rotation_enabled_flag : 1;
|
||||
Bs32u transform_skip_context_enabled_flag : 1;
|
||||
Bs32u implicit_rdpcm_enabled_flag : 1;
|
||||
Bs32u explicit_rdpcm_enabled_flag : 1;
|
||||
Bs32u extended_precision_processing_flag : 1;
|
||||
Bs32u intra_smoothing_disabled_flag : 1;
|
||||
Bs32u high_precision_offsets_enabled_flag : 1;
|
||||
Bs32u persistent_rice_adaptation_enabled_flag : 1;
|
||||
Bs32u cabac_bypass_alignment_enabled_flag : 1;
|
||||
Bs32u inter_view_mv_vert_constraint_flag : 1;
|
||||
Bs32u log2_min_luma_transform_block_size_minus2 : 5;
|
||||
Bs32u log2_diff_max_min_luma_transform_block_size : 5;
|
||||
Bs32u curr_pic_ref_enabled_flag : 1;
|
||||
Bs32u palette_mode_enabled_flag : 1;
|
||||
Bs32u palette_predictor_initializer_present_flag : 1;
|
||||
|
||||
Bs32u log2_min_luma_coding_block_size_minus3 : 5;
|
||||
Bs32u log2_diff_max_min_luma_coding_block_size : 5;
|
||||
Bs32u log2_min_pcm_luma_coding_block_size_minus3 : 5;
|
||||
Bs32u log2_diff_max_min_pcm_luma_coding_block_size : 5;
|
||||
Bs32u max_transform_hierarchy_depth_inter : 6;
|
||||
Bs32u max_transform_hierarchy_depth_intra : 6;
|
||||
|
||||
Bs16u pic_width_in_luma_samples;
|
||||
Bs16u pic_height_in_luma_samples;
|
||||
|
||||
Bs16u conf_win_left_offset;
|
||||
Bs16u conf_win_right_offset;
|
||||
|
||||
Bs16u conf_win_top_offset;
|
||||
Bs16u conf_win_bottom_offset;
|
||||
|
||||
Bs32u used_by_curr_pic_lt_flags;
|
||||
|
||||
Bs8u palette_max_size;
|
||||
Bs8s delta_palette_max_predictor_size;
|
||||
Bs16u num_palette_predictor_initializer;
|
||||
|
||||
Bs32u ExtBits;
|
||||
|
||||
Bs8u *ExtData;
|
||||
STRPS *strps;
|
||||
Bs16u *lt_ref_pic_poc_lsb;
|
||||
QM *qm;
|
||||
VUI *vui;
|
||||
Bs16u *palette_predictor_initializers[3];
|
||||
};
|
||||
|
||||
struct PPS
|
||||
{
|
||||
Bs32u pic_parameter_set_id : 6;
|
||||
Bs32u seq_parameter_set_id : 4;
|
||||
Bs32u dependent_slice_segments_enabled_flag : 1;
|
||||
Bs32u output_flag_present_flag : 1;
|
||||
Bs32u sign_data_hiding_enabled_flag : 1;
|
||||
Bs32u cabac_init_present_flag : 1;
|
||||
Bs32u constrained_intra_pred_flag : 1;
|
||||
Bs32u transform_skip_enabled_flag : 1;
|
||||
Bs32u cu_qp_delta_enabled_flag : 1;
|
||||
Bs32u slice_chroma_qp_offsets_present_flag : 1;
|
||||
Bs32u weighted_pred_flag : 1;
|
||||
Bs32u weighted_bipred_flag : 1;
|
||||
Bs32u transquant_bypass_enabled_flag : 1;
|
||||
Bs32u tiles_enabled_flag : 1;
|
||||
Bs32u entropy_coding_sync_enabled_flag : 1;
|
||||
Bs32u uniform_spacing_flag : 1;
|
||||
Bs32u loop_filter_across_tiles_enabled_flag : 1;
|
||||
Bs32u loop_filter_across_slices_enabled_flag : 1;
|
||||
Bs32u deblocking_filter_control_present_flag : 1;
|
||||
Bs32u deblocking_filter_override_enabled_flag : 1;
|
||||
Bs32u deblocking_filter_disabled_flag : 1;
|
||||
Bs32u scaling_list_data_present_flag : 1;
|
||||
Bs32u lists_modification_present_flag : 1;
|
||||
Bs32u slice_segment_header_extension_present_flag : 1;
|
||||
|
||||
Bs32u num_extra_slice_header_bits : 3;
|
||||
Bs32u num_ref_idx_l0_default_active_minus1 : 4;
|
||||
Bs32u num_ref_idx_l1_default_active_minus1 : 4;
|
||||
Bs32u extension_present_flag : 1;
|
||||
Bs32u range_extension_flag : 1;
|
||||
Bs32u multilayer_extension_flag : 1;
|
||||
Bs32u extension_3d_flag : 1;
|
||||
Bs32u scc_extension_flag : 1;
|
||||
Bs32u extension_xbits : 4;
|
||||
Bs32u : 12;
|
||||
|
||||
Bs32u curr_pic_ref_enabled_flag : 1;
|
||||
Bs32u residual_adaptive_colour_transform_enabled_flag : 1;
|
||||
Bs32u slice_act_qp_offsets_present_flag : 1;
|
||||
Bs32u palette_predictor_initializer_present_flag : 1;
|
||||
Bs32u monochrome_palette_flag : 1;
|
||||
Bs32u luma_bit_depth_entry_minus8 : 4;
|
||||
Bs32u chroma_bit_depth_entry_minus8 : 4;
|
||||
Bs32u num_palette_predictor_initializer : 16;
|
||||
Bs32u : 3;
|
||||
Bs32s ActQpOffsetY : 5; //-12 to +12,
|
||||
Bs32s ActQpOffsetCb : 5; //-12 to +12,
|
||||
Bs32s ActQpOffsetCr : 5; //-12 to +12,
|
||||
Bs32s : 17;
|
||||
|
||||
Bs8s init_qp_minus26;
|
||||
Bs8s cb_qp_offset;
|
||||
Bs8s cr_qp_offset;
|
||||
Bs8s beta_offset_div2 : 4;
|
||||
Bs8s tc_offset_div2 : 4;
|
||||
|
||||
Bs32u cross_component_prediction_enabled_flag : 1;
|
||||
Bs32u chroma_qp_offset_list_enabled_flag : 1;
|
||||
Bs32u log2_sao_offset_scale_luma : 3;
|
||||
Bs32u log2_sao_offset_scale_chroma : 3;
|
||||
Bs32u chroma_qp_offset_list_len_minus1 : 3;
|
||||
Bs32u diff_cu_chroma_qp_offset_depth : 5;
|
||||
Bs32u log2_max_transform_skip_block_size_minus2 : 5;
|
||||
Bs32u : 11;
|
||||
|
||||
Bs8s cb_qp_offset_list[6];
|
||||
Bs8s cr_qp_offset_list[6];
|
||||
|
||||
Bs16u diff_cu_qp_delta_depth;
|
||||
Bs16u num_tile_columns_minus1;
|
||||
Bs16u num_tile_rows_minus1;
|
||||
Bs16u log2_parallel_merge_level_minus2;
|
||||
|
||||
Bs32u ExtBits;
|
||||
|
||||
Bs8u *ExtData;
|
||||
Bs16u *column_width_minus1;
|
||||
Bs16u *row_height_minus1;
|
||||
Bs16u *CtbAddrRsToTs;
|
||||
QM *qm;
|
||||
Bs16u *palette_predictor_initializers[3];
|
||||
};
|
||||
|
||||
struct APS_SEI
|
||||
{
|
||||
Bs32u active_video_parameter_set_id : 4;
|
||||
Bs32u self_contained_cvs_flag : 1;
|
||||
Bs32u no_parameter_set_update_flag : 1;
|
||||
Bs32u num_sps_ids_minus1 : 4;
|
||||
Bs32u : 22;
|
||||
Bs8u* active_seq_parameter_set_id;
|
||||
Bs8u* layer_sps_idx;
|
||||
};
|
||||
|
||||
struct BP_SEI
|
||||
{
|
||||
Bs32u seq_parameter_set_id : 4;
|
||||
Bs32u irap_cpb_params_present_flag : 1;
|
||||
Bs32u concatenation_flag : 1;
|
||||
Bs32u use_alt_cpb_params_flag : 1;
|
||||
Bs32u au_cpb_removal_delay_delta_minus1;
|
||||
Bs32u cpb_delay_offset;
|
||||
Bs32u dpb_delay_offset;
|
||||
|
||||
struct CPB
|
||||
{
|
||||
Bs32u initial_cpb_removal_delay;
|
||||
Bs32u initial_cpb_removal_offset;
|
||||
Bs32u initial_alt_cpb_removal_delay;
|
||||
Bs32u initial_alt_cpb_removal_offset;
|
||||
} *nal, *vcl;
|
||||
};
|
||||
|
||||
struct PT_SEI
|
||||
{
|
||||
Bs32u pic_struct : 4;
|
||||
Bs32u source_scan_type : 2;
|
||||
Bs32u duplicate_flag : 1;
|
||||
Bs32u du_common_cpb_removal_delay_flag : 1;
|
||||
|
||||
Bs32u au_cpb_removal_delay_minus1;
|
||||
Bs32u pic_dpb_output_delay;
|
||||
Bs32u pic_dpb_output_du_delay;
|
||||
Bs32u num_decoding_units_minus1;
|
||||
Bs32u du_common_cpb_removal_delay_increment_minus1;
|
||||
|
||||
Bs32u *num_nalus_in_du_minus1;
|
||||
Bs32u *du_cpb_removal_delay_increment_minus1;
|
||||
|
||||
VUI* vui;
|
||||
};
|
||||
|
||||
struct RP_SEI
|
||||
{
|
||||
Bs16s recovery_poc_cnt;
|
||||
Bs16u exact_match_flag : 1;
|
||||
Bs16u broken_link_flag : 1;
|
||||
};
|
||||
|
||||
struct SEI
|
||||
{
|
||||
Bs32u payloadType;
|
||||
Bs32u payloadSize;
|
||||
|
||||
Bs8u* rawData;
|
||||
|
||||
union
|
||||
{
|
||||
APS_SEI *aps;
|
||||
BP_SEI *bp;
|
||||
PT_SEI *pt;
|
||||
RP_SEI *rp;
|
||||
};
|
||||
|
||||
SEI* next;
|
||||
};
|
||||
|
||||
typedef Bs16s PWT[16][3][2];
|
||||
|
||||
struct RefPic
|
||||
{
|
||||
Bs32u long_term : 1;
|
||||
Bs32u lost : 1;
|
||||
Bs32u used : 1;
|
||||
Bs32u : 29;
|
||||
Bs32s POC;
|
||||
};
|
||||
|
||||
struct PU
|
||||
{
|
||||
Bs16u x;
|
||||
Bs16u y;
|
||||
Bs16u w : 8;
|
||||
Bs16u h : 8;
|
||||
|
||||
Bs16u merge_idx : 3;
|
||||
Bs16u merge_flag : 1;
|
||||
Bs16u inter_pred_idc : 2;
|
||||
Bs16u mvp_l0_flag : 1;
|
||||
Bs16u mvp_l1_flag : 1;
|
||||
Bs16u ref_idx_l0 : 4;
|
||||
Bs16u ref_idx_l1 : 4;
|
||||
|
||||
Bs16s MvLX[2][2];
|
||||
|
||||
PU* Next;
|
||||
};
|
||||
|
||||
struct TU
|
||||
{
|
||||
Bs16u x;
|
||||
Bs16u y;
|
||||
|
||||
Bs32u log2TrafoSize : 8;
|
||||
Bs32u transform_skip_flag : 3;
|
||||
Bs32u cbf_cb : 1;
|
||||
Bs32u cbf_cb1 : 1;
|
||||
Bs32u cbf_cr : 1;
|
||||
Bs32u cbf_cr1 : 1;
|
||||
Bs32u cbf_luma : 1;
|
||||
|
||||
Bs32u log2_res_scale_abs_plus1_0 : 3;
|
||||
Bs32u res_scale_sign_flag_0 : 1;
|
||||
Bs32u log2_res_scale_abs_plus1_1 : 3;
|
||||
Bs32u res_scale_sign_flag_1 : 1;
|
||||
Bs32u tu_residual_act_flag : 1;
|
||||
Bs32u : 7;
|
||||
|
||||
Bs16s QP[3];
|
||||
|
||||
Bs32s* tc_levels_luma;
|
||||
|
||||
TU* Next;
|
||||
};
|
||||
|
||||
struct CU
|
||||
{
|
||||
Bs16u x;
|
||||
Bs16u y;
|
||||
|
||||
Bs32u log2CbSize : 8;
|
||||
Bs32u transquant_bypass_flag : 1;
|
||||
Bs32u PredMode : 2;
|
||||
Bs32u PartMode : 4;
|
||||
Bs32u pcm_flag : 1;
|
||||
Bs32u palette_mode_flag : 1;
|
||||
Bs32u chroma_qp_offset_flag : 1;
|
||||
Bs32u chroma_qp_offset_idx : 3;
|
||||
Bs32u : 11;
|
||||
|
||||
Bs8u IntraPredModeY[2][2];
|
||||
Bs8u IntraPredModeC[2][2];
|
||||
|
||||
Bs16s QpY;
|
||||
Bs16s QpCb;
|
||||
Bs16s QpCr;
|
||||
|
||||
PU* Pu;
|
||||
TU* Tu;
|
||||
CU* Next;
|
||||
};
|
||||
|
||||
struct SAO
|
||||
{
|
||||
Bs16u type_idx : 2;
|
||||
Bs16u band_position : 5;
|
||||
Bs16u eo_class : 2;
|
||||
Bs16u : 7;
|
||||
Bs8s offset[4];
|
||||
};
|
||||
|
||||
struct CTU
|
||||
{
|
||||
Bs16u CtbAddrInRs;
|
||||
Bs16u CtbAddrInTs;
|
||||
|
||||
Bs16u end_of_slice_segment_flag : 1;
|
||||
Bs16u sao_merge_left_flag : 1;
|
||||
Bs16u sao_merge_up_flag : 1;
|
||||
Bs16u : 13;
|
||||
|
||||
SAO sao[3];
|
||||
CU* Cu;
|
||||
CTU* Next;
|
||||
};
|
||||
|
||||
struct Slice
|
||||
{
|
||||
Bs32u first_slice_segment_in_pic_flag : 1;
|
||||
Bs32u no_output_of_prior_pics_flag : 1;
|
||||
Bs32u dependent_slice_segment_flag : 1;
|
||||
Bs32u sao_luma_flag : 1;
|
||||
Bs32u sao_chroma_flag : 1;
|
||||
Bs32u colour_plane_id : 2;
|
||||
Bs32u num_ref_idx_l0_active : 4;
|
||||
Bs32u num_ref_idx_l1_active : 4;
|
||||
Bs32u num_long_term_pics : 4;
|
||||
Bs32u collocated_ref_idx : 4;
|
||||
Bs32u short_term_ref_pic_set_idx : 6;
|
||||
Bs32u ref_pic_list_modification_flag_l0 : 1;
|
||||
Bs32u ref_pic_list_modification_flag_l1 : 1;
|
||||
Bs32u Split : 1;
|
||||
|
||||
Bs32u temporal_mvp_enabled_flag : 1;
|
||||
Bs32u num_ref_idx_active_override_flag : 1;
|
||||
Bs32u mvd_l1_zero_flag : 1;
|
||||
Bs32u cabac_init_flag : 1;
|
||||
Bs32u collocated_from_l0_flag : 1;
|
||||
Bs32u cu_chroma_qp_offset_enabled_flag : 1;
|
||||
Bs32u deblocking_filter_override_flag : 1;
|
||||
Bs32u deblocking_filter_disabled_flag : 1;
|
||||
Bs32u loop_filter_across_slices_enabled_flag : 1;
|
||||
Bs32u pic_output_flag : 1;
|
||||
Bs32u short_term_ref_pic_set_sps_flag : 1;
|
||||
Bs32u type : 2;
|
||||
Bs32u MaxNumMergeCand : 3;
|
||||
Bs32u num_long_term_sps : 5;
|
||||
Bs32u offset_len_minus1 : 5;
|
||||
Bs32u pic_parameter_set_id : 6;
|
||||
|
||||
Bs32u pic_order_cnt_lsb : 16;
|
||||
Bs32u reserved_flags : 8;
|
||||
Bs32u luma_log2_weight_denom : 3;
|
||||
Bs32u chroma_log2_weight_denom : 3;
|
||||
Bs32u use_integer_mv_flag : 1;
|
||||
Bs32u : 1;
|
||||
|
||||
Bs32u slice_segment_address;
|
||||
|
||||
Bs32u num_entry_point_offsets;
|
||||
Bs32u ExtBits;
|
||||
|
||||
Bs32s qp_delta : 8;
|
||||
Bs32s cb_qp_offset : 8;
|
||||
Bs32s cr_qp_offset : 8;
|
||||
Bs32s beta_offset_div2 : 4;
|
||||
Bs32s tc_offset_div2 : 4;
|
||||
|
||||
Bs32u used_by_curr_pic_lt_flags;
|
||||
|
||||
Bs32s POC;
|
||||
Bs32u NumCTU;
|
||||
|
||||
Bs32s act_y_qp_offset : 6;
|
||||
Bs32s act_cb_qp_offset : 6;
|
||||
Bs32s act_cr_qp_offset : 6;
|
||||
Bs32s : 14;
|
||||
|
||||
STRPS strps;
|
||||
Bs8u list_entry_lx[2][16];
|
||||
|
||||
Bs8u *ExtData;
|
||||
Bs16u *poc_lsb_lt;
|
||||
Bs16u *DeltaPocMsbCycleLt;
|
||||
PWT *pwt; //[list][entry][Y, Cb, Cr][Weight, Offset]
|
||||
Bs32u *entry_point_offset_minus1;
|
||||
|
||||
RefPic *DPB;
|
||||
RefPic *L0;
|
||||
RefPic *L1;
|
||||
|
||||
PPS *pps;
|
||||
SPS *sps;
|
||||
CTU *ctu;
|
||||
};
|
||||
|
||||
struct NALU
|
||||
{
|
||||
Bs64u StartOffset;
|
||||
Bs32u NumBytesInNalUnit;
|
||||
Bs32u NumBytesInRbsp;
|
||||
|
||||
Bs16u forbidden_zero_bit : 1;
|
||||
Bs16u nal_unit_type : 6;
|
||||
Bs16u nuh_layer_id : 6;
|
||||
Bs16u nuh_temporal_id_plus1 : 3;
|
||||
|
||||
union
|
||||
{
|
||||
void *unit;
|
||||
AUD *aud;
|
||||
VPS *vps;
|
||||
SPS *sps;
|
||||
PPS *pps;
|
||||
SEI *sei;
|
||||
Slice *slice;
|
||||
};
|
||||
|
||||
NALU* next;
|
||||
};
|
||||
|
||||
};
|
|
@ -1,64 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hevc2_struct.h"
|
||||
|
||||
namespace BS_HEVC2
|
||||
{
|
||||
|
||||
extern const char NaluTraceMap[64][16];
|
||||
extern const char PicTypeTraceMap[3][4];
|
||||
extern const char ChromaFormatTraceMap[4][12];
|
||||
extern const char VideoFormatTraceMap[6][12];
|
||||
extern const char PicStructTraceMap[13][12];
|
||||
extern const char ScanTypeTraceMap[4][12];
|
||||
extern const char SliceTypeTraceMap[4][2];
|
||||
extern const char PredModeTraceMap[3][6];
|
||||
extern const char PartModeTraceMap[8][12];
|
||||
extern const char IntraPredModeTraceMap[35][9];
|
||||
extern const char SAOTypeTraceMap[3][5];
|
||||
extern const char EOClassTraceMap[4][5];
|
||||
|
||||
struct ProfileTraceMap
|
||||
{
|
||||
static const char map[11][12];
|
||||
const char* operator[] (unsigned int i);
|
||||
};
|
||||
|
||||
struct ARIdcTraceMap
|
||||
{
|
||||
static const char map[19][16];
|
||||
const char* operator[] (unsigned int i);
|
||||
};
|
||||
|
||||
struct SEITypeTraceMap
|
||||
{
|
||||
const char* operator[] (unsigned int i);
|
||||
};
|
||||
|
||||
struct RPLTraceMap
|
||||
{
|
||||
char m_buf[80];
|
||||
const char* operator[] (const RefPic& r);
|
||||
};
|
||||
|
||||
}
|
|
@ -1,351 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef __HEVC_CABAC_H
|
||||
#define __HEVC_CABAC_H
|
||||
|
||||
#include "bs_reader.h"
|
||||
#include "hevc_struct.h"
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <bitset>
|
||||
#include <algorithm>
|
||||
|
||||
namespace BS_HEVC{
|
||||
|
||||
enum SE{
|
||||
SAO_MERGE_LEFT_FLAG
|
||||
, SAO_MERGE_UP_FLAG = SAO_MERGE_LEFT_FLAG
|
||||
, SAO_TYPE_IDX_LUMA
|
||||
, SAO_TYPE_IDX_CHROMA = SAO_TYPE_IDX_LUMA
|
||||
, SPLIT_CU_FLAG
|
||||
, CU_TRANSQUANT_BYPASS_FLAG
|
||||
, CU_SKIP_FLAG
|
||||
, PRED_MODE_FLAG
|
||||
, PART_MODE
|
||||
, PREV_INTRA_LUMA_PRED_FLAG
|
||||
, INTRA_CHROMA_PRED_MODE
|
||||
, RQT_ROOT_CBF
|
||||
, MERGE_FLAG
|
||||
, MERGE_IDX
|
||||
, INTER_PRED_IDC
|
||||
, REF_IDX_LX
|
||||
, MVP_LX_FLAG
|
||||
, SPLIT_TRANSFORM_FLAG
|
||||
, CBF_LUMA
|
||||
, CBF_CX
|
||||
, ABS_MVD_GREATER0_FLAG
|
||||
, ABS_MVD_GREATER1_FLAG
|
||||
, CU_QP_DELTA_ABS
|
||||
, TRANSFORM_SKIP_FLAG0
|
||||
, TRANSFORM_SKIP_FLAG1
|
||||
, TRANSFORM_SKIP_FLAG2 = TRANSFORM_SKIP_FLAG1
|
||||
, LAST_SIG_COEFF_X_PREFIX
|
||||
, LAST_SIG_COEFF_Y_PREFIX
|
||||
, CODED_SUB_BLOCK_FLAG
|
||||
, SIG_COEFF_FLAG
|
||||
, COEFF_ABS_LEVEL_GREATER1_FLAG
|
||||
, COEFF_ABS_LEVEL_GREATER2_FLAG
|
||||
, CU_CHROMA_QP_OFFSET_FLAG
|
||||
, CU_CHROMA_QP_OFFSET_IDX
|
||||
, LOG2_RES_SCALE_ABS_PLUS1
|
||||
, RES_SCALE_SIGN_FLAG
|
||||
, EXPLICIT_RDPCM_FLAG
|
||||
, EXPLICIT_RDPCM_DIR_FLAG
|
||||
, PALETTE_MODE_FLAG
|
||||
, TU_RESIDUAL_ACT_FLAG
|
||||
, PALETTE_RUN_PREFIX
|
||||
, COPY_ABOVE_PALETTE_INDICES_FLAG
|
||||
, COPY_ABOVE_INDICES_FOR_FINAL_RUN_FLAG
|
||||
, PALETTE_TRANSPOSE_FLAG
|
||||
, num_SE
|
||||
, END_OF_SLICE_SEGMENT_FLAG = num_SE
|
||||
, END_OF_SUB_STREAM_ONE_BIT
|
||||
, SAO_OFFSET_ABS
|
||||
, SAO_OFFSET_SIGN
|
||||
, SAO_BAND_POSITION
|
||||
, SAO_EO_CLASS_LUMA
|
||||
, SAO_EO_CLASS_CHROMA = SAO_EO_CLASS_LUMA
|
||||
, MPM_IDX
|
||||
, REM_INTRA_LUMA_PRED_MODE
|
||||
, ABS_MVD_MINUS2
|
||||
, MVD_SIGN_FLAG
|
||||
, CU_QP_DELTA_SIGN_FLAG
|
||||
, LAST_SIG_COEFF_X_SUFFIX
|
||||
, LAST_SIG_COEFF_Y_SUFFIX
|
||||
, COEFF_ABS_LEVEL_REMAINING
|
||||
, COEFF_SIGN_FLAG
|
||||
, PCM_FLAG
|
||||
, num_SE_full
|
||||
};
|
||||
|
||||
enum PRED_MODE{
|
||||
MODE_INTER = 0
|
||||
, MODE_INTRA
|
||||
, MODE_SKIP
|
||||
, num_PRED_MODE
|
||||
};
|
||||
|
||||
enum PART_MODE{
|
||||
PART_2Nx2N
|
||||
, PART_2NxN
|
||||
, PART_Nx2N
|
||||
, PART_NxN
|
||||
, PART_2NxnU
|
||||
, PART_2NxnD
|
||||
, PART_nLx2N
|
||||
, PART_nRx2N
|
||||
, num_PART_MODE
|
||||
};
|
||||
|
||||
enum PRED_IDC{
|
||||
PRED_L0
|
||||
, PRED_L1
|
||||
, PRED_BI
|
||||
, num_PRED_IDC
|
||||
};
|
||||
|
||||
static const Bs8u SubWidthC[5] = {1,2,2,1,1};
|
||||
static const Bs8u SubHeightC[5] = {1,2,1,1,1};
|
||||
|
||||
inline Bs32u CeilLog2(Bs32s x){
|
||||
Bs32s size = 0;
|
||||
while(x > (1<<size)) size++;
|
||||
return size;
|
||||
}
|
||||
|
||||
template<class _T, size_t _S> class _unsafe_array{
|
||||
private:
|
||||
_T arr[_S];
|
||||
public:
|
||||
inline _T& operator[](size_t idx){
|
||||
return arr[idx];
|
||||
}
|
||||
};
|
||||
|
||||
struct SDecCtx{
|
||||
void update(Slice& s);
|
||||
void updateIntraPredModeY(CQT& cqt);
|
||||
bool zAvailableN(Bs16s xCurr, Bs16s yCurr, Bs16s xNbY, Bs16s yNbY);
|
||||
CQT* get(Bs16u x, Bs16u y);
|
||||
TransTree* getTU(Bs16u x, Bs16u y);
|
||||
Bs8u IntraPredModeY(Bs16u x, Bs16u y, CQT* _cqt = 0);
|
||||
Bs8u IntraPredModeC(Bs16u x, Bs16u y, CQT* _cqt = 0);
|
||||
inline Bs16u ColumnWidthInLumaSamples(Bs16u i) { return (colWidth[ i ] << CtbLog2SizeY); }
|
||||
inline Bs16u RowHeightInLumaSamples (Bs16u j) { return (rowHeight[ j ] << CtbLog2SizeY ); }
|
||||
inline Bs16u bitDepth (Bs16u cIdx){ return cIdx ? (8+slice->sps->bit_depth_chroma_minus8) : (8+slice->sps->bit_depth_luma_minus8); }
|
||||
inline Bs16u CuPredMode (CQT& cqt) { return (cqt.cu_skip_flag ? 2 : cqt.pred_mode_flag); }
|
||||
inline Bs16u PartMode (CQT& cqt) { return ((cqt.pred_mode_flag && cqt.part_mode) ? PART_NxN : cqt.part_mode); }
|
||||
|
||||
Slice* slice;
|
||||
CTU* ctu;
|
||||
|
||||
Bs16u RawBits;
|
||||
Bs16u MinCbLog2SizeY;
|
||||
Bs16u CtbLog2SizeY;
|
||||
Bs16u CtbSizeY;
|
||||
Bs16u PicWidthInCtbsY;
|
||||
Bs16u PicHeightInCtbsY;
|
||||
Bs16u MinCbSizeY;
|
||||
Bs16u PicWidthInMinCbsY;
|
||||
Bs16u PicHeightInMinCbsY;
|
||||
Bs16u PicSizeInMinCbsY;
|
||||
Bs16u PicSizeInCtbsY;
|
||||
Bs16u PicSizeInSamplesY;
|
||||
Bs16u PicWidthInSamplesC;
|
||||
Bs16u PicHeightInSamplesC;
|
||||
Bs16u Log2MinTrafoSize;
|
||||
Bs16u Log2MaxTrafoSize;
|
||||
Bs16u Log2MinIpcmCbSizeY;
|
||||
Bs16u Log2MaxIpcmCbSizeY;
|
||||
Bs16u Log2MinCuQpDeltaSize;
|
||||
Bs8u IsCuQpDeltaCoded;
|
||||
Bs8s CuQpDeltaVal;
|
||||
Bs8s SliceQpY;
|
||||
Bs8s QpYprev;
|
||||
|
||||
Bs16u MaxTrafoDepth;
|
||||
Bs16u MaxNumMergeCand;
|
||||
bool IntraSplitFlag;
|
||||
|
||||
std::vector<Bs16u> colWidth;
|
||||
std::vector<Bs16u> rowHeight;
|
||||
std::vector<Bs16u> colBd;
|
||||
std::vector<Bs16u> rowBd;
|
||||
std::vector<Bs16u> CtbAddrRsToTs;
|
||||
std::vector<Bs16u> CtbAddrTsToRs;
|
||||
std::vector<Bs16u> TileId;
|
||||
|
||||
std::vector<Bs16s> vSliceAddrRs;
|
||||
std::vector<std::vector<Bs32u> > MinTbAddrZs;
|
||||
std::vector<std::vector<SAO> > Sao[3];
|
||||
std::vector<_unsafe_array<Bs16u,2> > ScanOrder[4][3];
|
||||
std::vector<std::vector<Bs8s> > vIntraPredModeY;
|
||||
};
|
||||
|
||||
const Bs16u CtxTblSize = 185;
|
||||
extern const Bs8u CtxInitTbl[3][CtxTblSize];
|
||||
extern const Bs8u CtxOffset[num_SE + 1];
|
||||
extern const Bs8u rangeTabLpsT[4][64];
|
||||
extern const Bs8u transIdxLps[64];
|
||||
extern const Bs8u transIdxMps[64];
|
||||
|
||||
class HEVC_CABAC : public BS_Reader{
|
||||
public:
|
||||
HEVC_CABAC();
|
||||
~HEVC_CABAC(){
|
||||
};
|
||||
|
||||
|
||||
void Init (SDecCtx& ctx, Bs32s CtbAddrInRs);
|
||||
void Store (bool is2ndCtuInRow, bool endOfSliceSegment);
|
||||
Bs32u ae (Bs16u se, Bs32s par = 0);
|
||||
|
||||
inline void NewBlock() { m_cSBIdx = -1; };
|
||||
inline void PCMEnd () { init_ade(); };
|
||||
|
||||
inline void ResetLog() {
|
||||
#ifdef HEVC_CABAC_STATE_TRACE
|
||||
if(m_cnt > 0x40000){
|
||||
char name[256];
|
||||
sprintf(name, "%s%d", HEVC_CABAC_STATE_TRACE, ++m_n);
|
||||
m_cnt = 0;
|
||||
fclose(flog);
|
||||
flog = fopen( name, "w" );
|
||||
}
|
||||
#endif //HEVC_CABAC_STATE_TRACE
|
||||
}
|
||||
|
||||
private:
|
||||
Bs32s m_decPar;
|
||||
Bs16u m_lastGreater1Ctx;
|
||||
Bs16u m_ctxSet;
|
||||
SDecCtx* m_pCtx;
|
||||
|
||||
inline Bs16u idxStart(Bs16u se) { return CtxOffset[se];}
|
||||
inline Bs16u idxEnd (Bs16u se) { return CtxOffset[se+1];}
|
||||
|
||||
void init_ctx(); // 9.3.2.2
|
||||
void init_ade(); // 9.4.2.5
|
||||
|
||||
enum CTX_INC{
|
||||
ERROR = -4
|
||||
, EXTERNAL
|
||||
, TERMINATE
|
||||
, BYPASS
|
||||
};
|
||||
Bs8s ctxInc(Bs16u se, Bs16u binIdx);
|
||||
|
||||
Bs32u decCAbsLvlR(Bs32s i, Bs32s baseLevel);
|
||||
Bs32u decAbsMvdMinus2();
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
struct Bin{
|
||||
static const Bs16u capacity = 32;
|
||||
static const Bs32u ff = 0xFFFFFFFF;
|
||||
|
||||
Bin(Bs32u value, Bs8u size) :
|
||||
n(size)
|
||||
, b(value & ( ff >> (capacity-size))) {
|
||||
}
|
||||
bool operator () (const Bin &bin) const {
|
||||
return (bin.n == n && bin.b.to_ulong() == b.to_ulong());
|
||||
}
|
||||
void put (Bs32u bits, Bs8u num = 1) {
|
||||
if(!num) return;
|
||||
b <<= num;
|
||||
b |= std::bitset<capacity>(bits & ( ff >> (capacity-num)));
|
||||
n += num;
|
||||
}
|
||||
Bs32u get() {
|
||||
return b.to_ulong();
|
||||
}
|
||||
|
||||
Bs8u n;
|
||||
std::bitset<capacity> b;
|
||||
};
|
||||
typedef std::list<Bin> Bins;
|
||||
static const Bs32u binTRx0Size = 32;
|
||||
|
||||
Bs32s m_cAbsLevel;
|
||||
Bs32s m_cRiceParam;
|
||||
Bs32s m_cSBIdx;
|
||||
|
||||
Bins m_binFL1;
|
||||
Bins m_binFL3;
|
||||
Bins m_binFL31;
|
||||
Bins m_binICPM;
|
||||
Bins m_binIPIDC0;
|
||||
Bins m_binDefault;
|
||||
Bins m_binTRx0[binTRx0Size];
|
||||
|
||||
Bins& GetBinarization(Bs16u se);
|
||||
|
||||
void initBins ();
|
||||
Bins& PartModeBin (bool isIntra, Bs32u log2CbSize);
|
||||
Bins& CUQPDAbsBin ();
|
||||
Bin TR (Bs32s synVal, Bs32u cMax, Bs32u cRiceParam);
|
||||
Bin EGk (Bs32s synVal, Bs32u k);
|
||||
Bin FL (Bs32s synVal, Bs32u cMax);
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
static const Bs8s CtxIncTbl[num_SE_full][6];
|
||||
|
||||
Bs8u CtxState [CtxTblSize];
|
||||
Bs8u CtxStateWpp[CtxTblSize];
|
||||
Bs8u CtxStateDs [CtxTblSize];
|
||||
|
||||
Bs16u ivlCurrRange;
|
||||
Bs16u ivlOffset;
|
||||
|
||||
Bs8u DecodeBin (Bs8u* ctxTable, Bs16u ctxIdx, bool bypassFlag);
|
||||
Bs8u DecodeDecision (Bs8u* ctxTable, Bs16u ctxIdx);
|
||||
Bs8u DecodeBypass ();
|
||||
Bs8u DecodeTerminate ();
|
||||
|
||||
inline void sync (Bs8u* t) { memcpy(CtxState, t, CtxTblSize); }
|
||||
inline void store(Bs8u* t) { memcpy(t, CtxState, CtxTblSize); }
|
||||
inline void RenormD() {
|
||||
while(ivlCurrRange < 256){
|
||||
ivlCurrRange <<= 1;
|
||||
ivlOffset = ((ivlOffset << 1) | read_1_bit());
|
||||
m_pCtx->RawBits ++;
|
||||
}
|
||||
}
|
||||
|
||||
inline void trace(Bs8u b = 7) {
|
||||
#ifdef HEVC_CABAC_STATE_TRACE
|
||||
fprintf(flog, "Count: %d \tValue: %d \tRange: %d \tBin: %d\n", m_cnt++, ivlOffset, ivlCurrRange, b);
|
||||
fflush(flog);
|
||||
#else
|
||||
(void)b;
|
||||
#endif //HEVC_CABAC_STATE_TRACE
|
||||
};
|
||||
|
||||
#ifdef HEVC_CABAC_STATE_TRACE
|
||||
Bs32u m_cnt;
|
||||
Bs32u m_n;
|
||||
FILE* flog;
|
||||
#endif //HEVC_CABAC_STATE_TRACE
|
||||
|
||||
};
|
||||
}// namespace BS_HEVC;
|
||||
|
||||
#endif // __HEVC_CABAC_H
|
|
@ -1,931 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef __HEVC_STRUCT_H
|
||||
#define __HEVC_STRUCT_H
|
||||
|
||||
#include <bs_def.h>
|
||||
|
||||
typedef class HEVC_BitStream* BS_HEVC_hdl;
|
||||
|
||||
namespace BS_HEVC{
|
||||
|
||||
enum INIT_MODE {
|
||||
INIT_MODE_DEFAULT = 0,
|
||||
INIT_MODE_CABAC = 1,
|
||||
INIT_MODE_STORE_SEI_DATA = 2,
|
||||
};
|
||||
|
||||
enum TRACE_LEVEL {
|
||||
TRACE_LEVEL_NALU = 0x00000001,
|
||||
TRACE_LEVEL_SPS = 0x00000002,
|
||||
TRACE_LEVEL_PPS = 0x00000004,
|
||||
TRACE_LEVEL_SLICE = 0x00000008,
|
||||
TRACE_LEVEL_SEI = 0x00000010,
|
||||
TRACE_LEVEL_VPS = 0x00000020,
|
||||
TRACE_LEVEL_REF_LIST = 0x00000040,
|
||||
TRACE_LEVEL_AU = 0x00000080,
|
||||
TRACE_LEVEL_CABAC = 0x00000100,
|
||||
TRACE_LEVEL_FULL = 0xFFFFFFFF
|
||||
};
|
||||
|
||||
enum NALU_TYPE{
|
||||
TRAIL_N = 0,
|
||||
TRAIL_R,
|
||||
TSA_N,
|
||||
TSA_R,
|
||||
STSA_N,
|
||||
STSA_R,
|
||||
RADL_N,
|
||||
RADL_R,
|
||||
RASL_N,
|
||||
RASL_R,
|
||||
RSV_VCL_N10,
|
||||
RSV_VCL_R11,
|
||||
RSV_VCL_N12,
|
||||
RSV_VCL_R13,
|
||||
RSV_VCL_N14,
|
||||
RSV_VCL_R15,
|
||||
BLA_W_LP,
|
||||
BLA_W_RADL,
|
||||
BLA_N_LP,
|
||||
IDR_W_RADL,
|
||||
IDR_N_LP,
|
||||
CRA_NUT,
|
||||
RSV_IRAP_VCL22,
|
||||
RSV_IRAP_VCL23,
|
||||
RSV_VCL24,
|
||||
RSV_VCL25,
|
||||
RSV_VCL26,
|
||||
RSV_VCL27,
|
||||
RSV_VCL28,
|
||||
RSV_VCL29,
|
||||
RSV_VCL30,
|
||||
RSV_VCL31,
|
||||
VPS_NUT,
|
||||
SPS_NUT,
|
||||
PPS_NUT,
|
||||
AUD_NUT,
|
||||
EOS_NUT,
|
||||
EOB_NUT,
|
||||
FD_NUT,
|
||||
PREFIX_SEI_NUT,
|
||||
SUFFIX_SEI_NUT,
|
||||
RSV_NVCL41,
|
||||
RSV_NVCL42,
|
||||
RSV_NVCL43,
|
||||
RSV_NVCL44,
|
||||
RSV_NVCL45,
|
||||
RSV_NVCL46,
|
||||
RSV_NVCL47,
|
||||
UNSPEC48,
|
||||
UNSPEC49,
|
||||
UNSPEC50,
|
||||
UNSPEC51,
|
||||
UNSPEC52,
|
||||
UNSPEC53,
|
||||
UNSPEC54,
|
||||
UNSPEC55,
|
||||
UNSPEC56,
|
||||
UNSPEC57,
|
||||
UNSPEC58,
|
||||
UNSPEC59,
|
||||
UNSPEC60,
|
||||
UNSPEC61,
|
||||
UNSPEC62,
|
||||
UNSPEC63,
|
||||
num_NALU_TYPE
|
||||
};
|
||||
|
||||
enum PROFILE {
|
||||
MAIN = 1,
|
||||
MAIN_10 = 2,
|
||||
MAIN_SP = 3,
|
||||
REXT = 4,
|
||||
REXT_HT = 5,
|
||||
MAIN_MV = 6,
|
||||
MAIN_SC = 7,
|
||||
MAIN_3D = 8,
|
||||
SCC = 9,
|
||||
};
|
||||
|
||||
enum ASPECT_RATIO{
|
||||
AR_Unspecified = 0,
|
||||
AR_1_1,
|
||||
AR_SQUARE = AR_1_1,
|
||||
AR_12_11,
|
||||
AR_10_11,
|
||||
AR_16_11,
|
||||
AR_40_33,
|
||||
AR_24_11,
|
||||
AR_20_11,
|
||||
AR_32_11,
|
||||
AR_80_33,
|
||||
AR_18_11,
|
||||
AR_15_11,
|
||||
AR_64_33,
|
||||
AR_160_99,
|
||||
AR_4_3,
|
||||
AR_3_2,
|
||||
AR_2_1,
|
||||
//Reserved
|
||||
EXTENDED_SAR = 255,
|
||||
num_ASPECT_RATIO
|
||||
};
|
||||
|
||||
enum HASH_TYPE{
|
||||
HASH_MD5 = 0,
|
||||
HASH_CRC,
|
||||
HASH_CHECKSUM,
|
||||
num_HASH_TYPE
|
||||
};
|
||||
|
||||
enum SLICE_TYPE{
|
||||
B = 0,
|
||||
P,
|
||||
I,
|
||||
num_SLICE_TYPE
|
||||
};
|
||||
|
||||
enum PICTURE_MARKING{
|
||||
UNUSED_FOR_REFERENCE = 0x00,
|
||||
USED_FOR_SHORTTERM_REFERENCE = 0x01,
|
||||
USED_FOR_LONGTERM_REFERENCE = 0x02,
|
||||
USED_FOR_REFERENCE = 0x03,
|
||||
};
|
||||
|
||||
struct PTLEntry{
|
||||
Bs8u profile_space : 2;
|
||||
Bs8u tier_flag : 1;
|
||||
Bs8u profile_idc : 5;
|
||||
|
||||
union{
|
||||
Bs32u profile_compatibility_flags;
|
||||
struct{
|
||||
Bs32u profile_compatibility_flag31 : 1;
|
||||
Bs32u profile_compatibility_flag30 : 1;
|
||||
Bs32u profile_compatibility_flag29 : 1;
|
||||
Bs32u profile_compatibility_flag28 : 1;
|
||||
Bs32u profile_compatibility_flag27 : 1;
|
||||
Bs32u profile_compatibility_flag26 : 1;
|
||||
Bs32u profile_compatibility_flag25 : 1;
|
||||
Bs32u profile_compatibility_flag24 : 1;
|
||||
Bs32u profile_compatibility_flag23 : 1;
|
||||
Bs32u profile_compatibility_flag22 : 1;
|
||||
Bs32u profile_compatibility_flag21 : 1;
|
||||
Bs32u profile_compatibility_flag20 : 1;
|
||||
Bs32u profile_compatibility_flag19 : 1;
|
||||
Bs32u profile_compatibility_flag18 : 1;
|
||||
Bs32u profile_compatibility_flag17 : 1;
|
||||
Bs32u profile_compatibility_flag16 : 1;
|
||||
Bs32u profile_compatibility_flag15 : 1;
|
||||
Bs32u profile_compatibility_flag14 : 1;
|
||||
Bs32u profile_compatibility_flag13 : 1;
|
||||
Bs32u profile_compatibility_flag12 : 1;
|
||||
Bs32u profile_compatibility_flag11 : 1;
|
||||
Bs32u profile_compatibility_flag10 : 1;
|
||||
Bs32u profile_compatibility_flag9 : 1;
|
||||
Bs32u profile_compatibility_flag8 : 1;
|
||||
Bs32u profile_compatibility_flag7 : 1;
|
||||
Bs32u profile_compatibility_flag6 : 1;
|
||||
Bs32u profile_compatibility_flag5 : 1;
|
||||
Bs32u profile_compatibility_flag4 : 1;
|
||||
Bs32u profile_compatibility_flag3 : 1;
|
||||
Bs32u profile_compatibility_flag2 : 1;
|
||||
Bs32u profile_compatibility_flag1 : 1;
|
||||
Bs32u profile_compatibility_flag0 : 1;
|
||||
};
|
||||
};
|
||||
|
||||
Bs8u progressive_source_flag : 1;
|
||||
Bs8u interlaced_source_flag : 1;
|
||||
Bs8u non_packed_constraint_flag : 1;
|
||||
Bs8u frame_only_constraint_flag : 1;
|
||||
Bs8u profile_present_flag : 1;
|
||||
Bs8u level_present_flag : 1;
|
||||
Bs8u level_idc;
|
||||
};
|
||||
|
||||
struct ProfileTierLevel{
|
||||
PTLEntry general;
|
||||
PTLEntry sub_layer[8];
|
||||
};
|
||||
|
||||
struct sub_layer_ordering_info{
|
||||
Bs8u max_dec_pic_buffering_minus1 : 4;
|
||||
Bs8u max_num_reorder_pics : 4;
|
||||
Bs32u max_latency_increase_plus1;
|
||||
};
|
||||
|
||||
struct SubLayerHRD{
|
||||
Bs8u fixed_pic_rate_general_flag : 1;
|
||||
Bs8u fixed_pic_rate_within_cvs_flag : 1;
|
||||
Bs8u low_delay_hrd_flag : 1;
|
||||
Bs16u elemental_duration_in_tc_minus1 : 11;
|
||||
Bs16u cpb_cnt_minus1 : 5;
|
||||
|
||||
struct{
|
||||
Bs32u bit_rate_value_minus1 : 31;
|
||||
Bs32u cpb_size_value_minus1 : 31;
|
||||
Bs32u cpb_size_du_value_minus1 : 31;
|
||||
Bs32u bit_rate_du_value_minus1 : 31;
|
||||
Bs32u cbr_flag : 1;
|
||||
}cpb[32];
|
||||
};
|
||||
|
||||
struct HRD{
|
||||
Bs8u nal_hrd_parameters_present_flag : 1;
|
||||
Bs8u vcl_hrd_parameters_present_flag : 1;
|
||||
Bs8u sub_pic_hrd_params_present_flag : 1;
|
||||
|
||||
Bs8u tick_divisor_minus2;
|
||||
Bs16u du_cpb_removal_delay_increment_length_minus1 : 5;
|
||||
Bs16u sub_pic_cpb_params_in_pic_timing_sei_flag : 1;
|
||||
Bs16u dpb_output_delay_du_length_minus1 : 5;
|
||||
|
||||
Bs16u bit_rate_scale : 4;
|
||||
Bs8u cpb_size_scale : 4;
|
||||
|
||||
Bs8u cpb_size_du_scale : 4;
|
||||
Bs16u initial_cpb_removal_delay_length_minus1 : 5;
|
||||
Bs16u au_cpb_removal_delay_length_minus1 : 5;
|
||||
Bs16u dpb_output_delay_length_minus1 : 5;
|
||||
|
||||
SubLayerHRD sl[8];
|
||||
};
|
||||
|
||||
struct VPSHRD : HRD{
|
||||
Bs16u hrd_layer_set_idx : 10;
|
||||
Bs16u cprms_present_flag : 1;
|
||||
};
|
||||
|
||||
struct VPS{
|
||||
Bs16u video_parameter_set_id : 4;
|
||||
Bs16u reserved_three_2bits : 2;
|
||||
Bs16u max_layers_minus1 : 6;
|
||||
Bs16u max_sub_layers_minus1 : 3;
|
||||
Bs16u temporal_id_nesting_flag : 1;
|
||||
Bs16u reserved_0xffff_16bits;
|
||||
|
||||
ProfileTierLevel ptl;
|
||||
|
||||
Bs8u sub_layer_ordering_info_present_flag : 1;
|
||||
|
||||
sub_layer_ordering_info sub_layer[8];
|
||||
|
||||
Bs16u max_layer_id : 6;
|
||||
Bs16u num_layer_sets_minus1 : 10;
|
||||
|
||||
Bs8u** layer_id_included_flag; // max [1024][64];
|
||||
|
||||
Bs32u num_units_in_tick;
|
||||
Bs32u time_scale;
|
||||
Bs32u timing_info_present_flag : 1;
|
||||
Bs32u poc_proportional_to_timing_flag : 1;
|
||||
Bs32u num_ticks_poc_diff_one_minus1 : 10;
|
||||
Bs32u num_hrd_parameters : 10;
|
||||
|
||||
Bs8u extension_flag : 1;
|
||||
Bs8u extension_data_flag : 1;
|
||||
|
||||
VPSHRD* hrd; //max 1024
|
||||
};
|
||||
|
||||
struct ScalingListData{
|
||||
struct{
|
||||
Bs16s pred_mode_flag : 2;
|
||||
Bs16s pred_matrix_id_delta : 4;
|
||||
Bs16s dc_coef_minus8 : 10;
|
||||
Bs8s delta_coef[64];
|
||||
}entry[4][6];
|
||||
Bs16s ScalingList[4][6][64];
|
||||
};
|
||||
|
||||
struct ShortTermRefPicSet{
|
||||
Bs8u inter_ref_pic_set_prediction_flag : 1;
|
||||
Bs8u delta_idx_minus1 : 6;
|
||||
Bs8u delta_rps_sign : 1;
|
||||
|
||||
Bs16u abs_delta_rps_minus1;
|
||||
|
||||
Bs8u num_negative_pics : 4;
|
||||
Bs8u num_positive_pics : 4;
|
||||
|
||||
struct{
|
||||
struct{
|
||||
Bs8u used_by_curr_pic_flag;
|
||||
Bs8u use_delta_flag;
|
||||
};
|
||||
union{
|
||||
struct {
|
||||
Bs16u delta_poc_s0_minus1 : 15;
|
||||
Bs16u used_by_curr_pic_s0_flag : 1;
|
||||
Bs16s DeltaPocS0;
|
||||
};
|
||||
struct {
|
||||
Bs16u delta_poc_s1_minus1 : 15;
|
||||
Bs16u used_by_curr_pic_s1_flag : 1;
|
||||
Bs16s DeltaPocS1;
|
||||
};
|
||||
};
|
||||
}pic[16];
|
||||
};
|
||||
|
||||
struct ShortTermRefPicSets{
|
||||
Bs8u num_short_term_ref_pic_sets; //0-64
|
||||
ShortTermRefPicSet* set;
|
||||
};
|
||||
|
||||
struct VUI{
|
||||
Bs8u aspect_ratio_info_present_flag : 1;
|
||||
Bs8u aspect_ratio_idc;
|
||||
Bs16u sar_width;
|
||||
Bs16u sar_height;
|
||||
|
||||
Bs8u overscan_info_present_flag : 1;
|
||||
Bs8u overscan_appropriate_flag : 1;
|
||||
Bs8u video_signal_type_present_flag : 1;
|
||||
Bs8u video_format : 3;
|
||||
Bs8u video_full_range_flag : 1;
|
||||
Bs8u colour_description_present_flag : 1;
|
||||
Bs8u colour_primaries;
|
||||
Bs8u transfer_characteristics;
|
||||
Bs8u matrix_coeffs;
|
||||
|
||||
Bs8u chroma_loc_info_present_flag : 1;
|
||||
Bs8u chroma_sample_loc_type_top_field : 3;
|
||||
Bs8u chroma_sample_loc_type_bottom_field : 3;
|
||||
|
||||
Bs8u neutral_chroma_indication_flag : 1;
|
||||
Bs8u field_seq_flag : 1;
|
||||
Bs8u frame_field_info_present_flag : 1;
|
||||
Bs8u default_display_window_flag : 1;
|
||||
|
||||
Bs32u def_disp_win_left_offset;
|
||||
Bs32u def_disp_win_right_offset;
|
||||
Bs32u def_disp_win_top_offset;
|
||||
Bs32u def_disp_win_bottom_offset;
|
||||
|
||||
Bs8u timing_info_present_flag : 1;
|
||||
Bs8u hrd_parameters_present_flag : 1;
|
||||
Bs8u poc_proportional_to_timing_flag : 1;
|
||||
|
||||
Bs8u bitstream_restriction_flag : 1;
|
||||
Bs8u tiles_fixed_structure_flag : 1;
|
||||
Bs8u motion_vectors_over_pic_boundaries_flag : 1;
|
||||
Bs8u restricted_ref_pic_lists_flag : 1;
|
||||
|
||||
Bs32u num_units_in_tick;
|
||||
Bs32u time_scale;
|
||||
Bs32u num_ticks_poc_diff_one_minus1;
|
||||
|
||||
Bs32u min_spatial_segmentation_idc : 12;
|
||||
Bs32u max_bytes_per_pic_denom : 5;
|
||||
Bs32u max_bits_per_min_cu_denom : 5;
|
||||
Bs16u log2_max_mv_length_horizontal : 5;
|
||||
Bs16u log2_max_mv_length_vertical : 4;
|
||||
|
||||
HRD hrd;
|
||||
};
|
||||
|
||||
struct SpsRangeExtension{
|
||||
Bs8u transform_skip_rotation_enabled_flag : 1;
|
||||
Bs8u transform_skip_context_enabled_flag : 1;
|
||||
Bs8u implicit_residual_dpcm_enabled_flag : 1;
|
||||
Bs8u explicit_residual_dpcm_enabled_flag : 1;
|
||||
Bs8u extended_precision_processing_flag : 1;
|
||||
Bs8u intra_smoothing_disabled_flag : 1;
|
||||
Bs8u high_precision_offsets_enabled_flag : 1;
|
||||
Bs8u fast_rice_adaptation_enabled_flag : 1;
|
||||
Bs8u cabac_bypass_alignment_enabled_flag : 1;
|
||||
};
|
||||
|
||||
struct SpsSccExtension{
|
||||
Bs8u sps_curr_pic_ref_enabled_flag : 1;
|
||||
Bs8u palette_mode_enabled_flag : 1;
|
||||
|
||||
Bs32u max_bits_ppalette_max_size;
|
||||
Bs32u delta_palette_max_predictor_size;
|
||||
|
||||
Bs8u sps_palette_predictor_initializer_present_flag : 1;
|
||||
|
||||
Bs32u sps_num_palette_predictor_initializer_minus1;
|
||||
|
||||
Bs8u motion_vector_resolution_control_idc : 2;
|
||||
Bs8u intra_boundary_filtering_disabled_flag : 1;
|
||||
|
||||
Bs32u* paletteInitializers;
|
||||
};
|
||||
|
||||
struct SPS{
|
||||
Bs8u video_parameter_set_id : 4;
|
||||
Bs8u max_sub_layers_minus1 : 3;
|
||||
Bs8u temporal_id_nesting_flag : 1;
|
||||
|
||||
ProfileTierLevel ptl;
|
||||
|
||||
Bs8u seq_parameter_set_id : 4;
|
||||
Bs8u chroma_format_idc : 2;
|
||||
Bs8u separate_colour_plane_flag : 1;
|
||||
Bs8u conformance_window_flag : 1;
|
||||
|
||||
Bs32u pic_width_in_luma_samples;
|
||||
Bs32u pic_height_in_luma_samples;
|
||||
|
||||
Bs32u conf_win_left_offset;
|
||||
Bs32u conf_win_right_offset;
|
||||
Bs32u conf_win_top_offset;
|
||||
Bs32u conf_win_bottom_offset;
|
||||
|
||||
Bs8u bit_depth_luma_minus8 : 3;
|
||||
Bs8u bit_depth_chroma_minus8 : 3;
|
||||
Bs8u log2_max_pic_order_cnt_lsb_minus4 : 4;
|
||||
Bs8u sub_layer_ordering_info_present_flag : 1;
|
||||
|
||||
sub_layer_ordering_info sub_layer[8];
|
||||
|
||||
Bs32u log2_min_luma_coding_block_size_minus3;
|
||||
Bs32u log2_diff_max_min_luma_coding_block_size;
|
||||
Bs32u log2_min_transform_block_size_minus2;
|
||||
Bs32u log2_diff_max_min_transform_block_size;
|
||||
Bs32u max_transform_hierarchy_depth_inter;
|
||||
Bs32u max_transform_hierarchy_depth_intra;
|
||||
|
||||
Bs8u scaling_list_enabled_flag : 1;
|
||||
Bs8u scaling_list_data_present_flag : 1;
|
||||
|
||||
Bs8u amp_enabled_flag : 1;
|
||||
Bs8u sample_adaptive_offset_enabled_flag : 1;
|
||||
|
||||
Bs8u pcm_enabled_flag : 1;
|
||||
Bs8u pcm_loop_filter_disabled_flag : 1;
|
||||
Bs8u pcm_sample_bit_depth_luma_minus1 : 4;
|
||||
Bs8u pcm_sample_bit_depth_chroma_minus1 : 4;
|
||||
Bs32u log2_min_pcm_luma_coding_block_size_minus3;
|
||||
Bs32u log2_diff_max_min_pcm_luma_coding_block_size;
|
||||
|
||||
ScalingListData* sld;
|
||||
|
||||
ShortTermRefPicSets strps;
|
||||
|
||||
Bs8u long_term_ref_pics_present_flag : 1;
|
||||
Bs8u num_long_term_ref_pics_sps : 6;
|
||||
|
||||
Bs16u lt_ref_pic_poc_lsb_sps[32];
|
||||
Bs8u used_by_curr_pic_lt_sps_flag[32];
|
||||
|
||||
Bs8u temporal_mvp_enabled_flag : 1;
|
||||
Bs8u strong_intra_smoothing_enabled_flag : 1;
|
||||
Bs8u vui_parameters_present_flag : 1;
|
||||
Bs8u extension_flag : 1;
|
||||
Bs8u sps_range_extension_flag : 1;
|
||||
Bs8u sps_scc_extension_flag : 1;
|
||||
|
||||
VUI vui;
|
||||
SpsRangeExtension range_extension;
|
||||
SpsSccExtension scc_extension;
|
||||
};
|
||||
|
||||
struct PpsRangeExtension{
|
||||
Bs32u log2_max_transform_skip_block_size_minus2;
|
||||
Bs8u cross_component_prediction_enabled_flag;
|
||||
|
||||
Bs8u chroma_qp_offset_list_enabled_flag;
|
||||
Bs8u diff_cu_chroma_qp_offset_depth;
|
||||
|
||||
Bs32u chroma_qp_offset_list_len_minus1;
|
||||
Bs32u* cb_qp_offset_list;
|
||||
Bs32u* cr_qp_offset_list;
|
||||
|
||||
Bs32u log2_sao_offset_scale_luma;
|
||||
Bs32u log2_sao_offset_scale_chroma;
|
||||
};
|
||||
|
||||
struct PpsSccExtension{
|
||||
Bs8u pps_curr_pic_ref_enabled_flag;
|
||||
Bs8u residual_adaptive_colour_transform_enabled_flag;
|
||||
|
||||
Bs8u pps_slice_act_qp_offsets_present_flag;
|
||||
Bs32u pps_act_y_qp_offset_plus5;
|
||||
Bs32u pps_act_cb_qp_offset_plus5;
|
||||
Bs32u pps_act_cr_qp_offset_plus3;
|
||||
|
||||
Bs8u pps_palette_predictor_initializer_present_flag;
|
||||
|
||||
Bs32u pps_num_palette_predictor_initializer;
|
||||
|
||||
Bs8u monochrome_palette_flag;
|
||||
Bs32u luma_bit_depth_entry_minus8;
|
||||
Bs32u chroma_bit_depth_entry_minus8;
|
||||
|
||||
Bs32u* paletteInitializers;
|
||||
};
|
||||
|
||||
struct PPS{
|
||||
Bs16u pic_parameter_set_id : 6;
|
||||
Bs16u seq_parameter_set_id : 4;
|
||||
Bs16u dependent_slice_segments_enabled_flag : 1;
|
||||
Bs16u output_flag_present_flag : 1;
|
||||
Bs16u num_extra_slice_header_bits : 3;
|
||||
Bs16u sign_data_hiding_enabled_flag : 1;
|
||||
Bs16u cabac_init_present_flag : 1;
|
||||
Bs16u num_ref_idx_l0_default_active_minus1 : 4;
|
||||
Bs16u num_ref_idx_l1_default_active_minus1 : 4;
|
||||
Bs16u constrained_intra_pred_flag : 1;
|
||||
Bs16u transform_skip_enabled_flag : 1;
|
||||
Bs16u cu_qp_delta_enabled_flag : 1;
|
||||
Bs16u slice_segment_header_extension_present_flag : 1;
|
||||
|
||||
Bs32u diff_cu_qp_delta_depth;
|
||||
Bs8s init_qp_minus26 : 6;
|
||||
Bs16s cb_qp_offset : 6;
|
||||
Bs16s cr_qp_offset : 6;
|
||||
|
||||
Bs8u slice_chroma_qp_offsets_present_flag : 1;
|
||||
Bs8u weighted_pred_flag : 1;
|
||||
Bs8u weighted_bipred_flag : 1;
|
||||
Bs8u transquant_bypass_enabled_flag : 1;
|
||||
Bs8u tiles_enabled_flag : 1;
|
||||
Bs8u entropy_coding_sync_enabled_flag : 1;
|
||||
Bs8u uniform_spacing_flag : 1;
|
||||
Bs8u loop_filter_across_tiles_enabled_flag : 1;
|
||||
|
||||
Bs16u num_tile_columns_minus1;
|
||||
Bs16u num_tile_rows_minus1;
|
||||
|
||||
Bs16u* column_width_minus1;
|
||||
Bs16u* row_height_minus1;
|
||||
|
||||
Bs8u loop_filter_across_slices_enabled_flag : 1;
|
||||
Bs8u deblocking_filter_control_present_flag : 1;
|
||||
Bs8u deblocking_filter_override_enabled_flag : 1;
|
||||
Bs8u deblocking_filter_disabled_flag : 1;
|
||||
Bs8u scaling_list_data_present_flag : 1;
|
||||
Bs8u lists_modification_present_flag : 1;
|
||||
Bs8u extension_flag : 1;
|
||||
Bs8u range_extension_flag : 1;
|
||||
Bs8u pps_scc_extension_flag : 1;
|
||||
|
||||
Bs8s beta_offset_div2 : 4;
|
||||
Bs8s tc_offset_div2 : 4;
|
||||
|
||||
ScalingListData* sld;
|
||||
|
||||
Bs16u log2_parallel_merge_level_minus2;
|
||||
|
||||
PpsRangeExtension range_extension;
|
||||
PpsSccExtension scc_extension;
|
||||
};
|
||||
|
||||
struct BufferingPeriod{
|
||||
Bs8u seq_parameter_set_id : 4;
|
||||
Bs8u irap_cpb_params_present_flag : 1;
|
||||
Bs8u concatenation_flag : 1;
|
||||
|
||||
Bs32u cpb_delay_offset;
|
||||
Bs32u dpb_delay_offset;
|
||||
Bs32u au_cpb_removal_delay_delta_minus1;
|
||||
|
||||
struct CPB{
|
||||
Bs32u initial_cpb_removal_delay;
|
||||
Bs32u initial_cpb_removal_offset;
|
||||
Bs32u initial_alt_cpb_removal_delay;
|
||||
Bs32u initial_alt_cpb_removal_offset;
|
||||
} nal[32], vcl[32];
|
||||
};
|
||||
|
||||
struct PicTiming{
|
||||
Bs8u pic_struct : 4;
|
||||
Bs8u source_scan_type : 2;
|
||||
Bs8u duplicate_flag : 1;
|
||||
Bs8u du_common_cpb_removal_delay_flag : 1;
|
||||
|
||||
Bs32u au_cpb_removal_delay_minus1;
|
||||
Bs32u pic_dpb_output_delay;
|
||||
Bs32u pic_dpb_output_du_delay;
|
||||
Bs32u num_decoding_units_minus1;
|
||||
Bs32u du_common_cpb_removal_delay_increment_minus1;
|
||||
|
||||
Bs32u *num_nalus_in_du_minus1;
|
||||
Bs32u *du_cpb_removal_delay_increment_minus1;
|
||||
|
||||
//////////////////////////
|
||||
VUI* vui;
|
||||
};
|
||||
|
||||
struct ActiveParameterSets{
|
||||
Bs16u active_video_parameter_set_id : 4;
|
||||
Bs16u self_contained_cvs_flag : 1;
|
||||
Bs16u no_parameter_set_update_flag : 1;
|
||||
Bs16u num_sps_ids_minus1 : 4;
|
||||
|
||||
Bs8u active_seq_parameter_set_id[16];
|
||||
};
|
||||
|
||||
struct RecoveryPoint{
|
||||
Bs32s recovery_poc_cnt;
|
||||
Bs8u exact_match_flag : 1;
|
||||
Bs8u broken_link_flag : 1;
|
||||
};
|
||||
|
||||
struct DecodedPictureHash{
|
||||
Bs8u hash_type;
|
||||
union ColorPlane{
|
||||
Bs8u picture_md5[16];
|
||||
Bs16u picture_crc;
|
||||
Bs32u picture_checksum;
|
||||
}plane[3];
|
||||
};
|
||||
|
||||
static const Bs16u MaxSEIPayloads = 64;
|
||||
|
||||
struct SEI{
|
||||
Bs16u NumMessage;
|
||||
|
||||
struct MSG{
|
||||
Bs32u payloadType;
|
||||
Bs32u payloadSize;
|
||||
|
||||
union {
|
||||
void *payload;
|
||||
ActiveParameterSets *aps;
|
||||
BufferingPeriod *bp;
|
||||
PicTiming *pt;
|
||||
RecoveryPoint *rp;
|
||||
DecodedPictureHash *dph;
|
||||
Bs8u *rawData;
|
||||
};
|
||||
|
||||
} message[MaxSEIPayloads];
|
||||
};
|
||||
|
||||
struct AUD{
|
||||
Bs8u pic_type : 3;
|
||||
};
|
||||
|
||||
struct LongTerm{
|
||||
Bs8u lt_idx_sps : 5;
|
||||
Bs8u used_by_curr_pic_lt_flag : 1;
|
||||
Bs8u delta_poc_msb_present_flag : 1;
|
||||
Bs32u poc_lsb_lt;
|
||||
Bs32u delta_poc_msb_cycle_lt;
|
||||
};
|
||||
|
||||
struct RefPicListsMod{
|
||||
Bs8u ref_pic_list_modification_flag_l0 : 1;
|
||||
Bs8u ref_pic_list_modification_flag_l1 : 1;
|
||||
Bs16u list_entry_l0[16];
|
||||
Bs16u list_entry_l1[16];
|
||||
};
|
||||
|
||||
struct PredWeightTable{
|
||||
Bs8u luma_log2_weight_denom : 3;
|
||||
Bs8s delta_chroma_log2_weight_denom : 4;
|
||||
|
||||
struct {
|
||||
Bs8u luma_weight_lx_flag : 1;
|
||||
Bs8u chroma_weight_lx_flag : 1;
|
||||
Bs8s delta_luma_weight_lx;
|
||||
Bs8s luma_offset_lx;
|
||||
Bs8s delta_chroma_weight_lx[2];
|
||||
Bs8s delta_chroma_offset_lx[2];
|
||||
} l0[16], l1[16];
|
||||
};
|
||||
|
||||
struct SAO{
|
||||
Bs8u type_idx: 2;
|
||||
union{
|
||||
Bs8u band_position : 5;
|
||||
Bs8u eo_class : 2;
|
||||
};
|
||||
Bs8s offset[4];
|
||||
};
|
||||
|
||||
struct Residual{
|
||||
Bs8u transform_skip_flag : 1;
|
||||
|
||||
Bs8u last_sig_coeff_x_prefix;
|
||||
Bs8u last_sig_coeff_y_prefix;
|
||||
Bs8u last_sig_coeff_x_suffix;
|
||||
Bs8u last_sig_coeff_y_suffix;
|
||||
|
||||
//rest data skipped for now
|
||||
//Bs16u coded_sub_block_flags;
|
||||
};
|
||||
|
||||
struct PredUnit{
|
||||
Bs16u x;
|
||||
Bs16u y;
|
||||
|
||||
Bs8u merge_idx : 3;
|
||||
Bs8u merge_flag : 1;
|
||||
Bs8u inter_pred_idc : 2;
|
||||
Bs8u mvp_l0_flag : 1;
|
||||
Bs8u mvp_l1_flag : 1;
|
||||
Bs8u ref_idx_l0 : 4;
|
||||
Bs8u ref_idx_l1 : 4;
|
||||
|
||||
Bs16s MvdLX[2][2];
|
||||
};
|
||||
|
||||
struct TransTree{
|
||||
Bs16u x;
|
||||
Bs16u y;
|
||||
Bs8u QpY;
|
||||
Bs8u trafoDepth;
|
||||
Bs8s cu_qp_delta;
|
||||
Bs8u split_transform_flag : 1;
|
||||
Bs8u cbf_cb : 1;
|
||||
Bs8u cbf_cr : 1;
|
||||
Bs8u cbf_luma : 1;
|
||||
|
||||
//Residual rc[3];
|
||||
TransTree* split;
|
||||
};
|
||||
|
||||
struct CQT{
|
||||
Bs16u x;
|
||||
Bs16u y;
|
||||
Bs16u CtDepth;
|
||||
|
||||
Bs8u split_cu_flag : 1;
|
||||
Bs8u cu_transquant_bypass_flag : 1;
|
||||
Bs8u cu_skip_flag : 1;
|
||||
Bs8u pred_mode_flag : 1;
|
||||
Bs8u part_mode : 3;
|
||||
Bs8u pcm_flag : 1;
|
||||
|
||||
struct LumaPred{
|
||||
Bs8u prev_intra_luma_pred_flag : 1;
|
||||
Bs8u mpm_idx : 2;
|
||||
Bs8u rem_intra_luma_pred_mode : 5;
|
||||
}luma_pred[2][2];
|
||||
|
||||
Bs8u intra_chroma_pred_mode : 4;
|
||||
Bs8u rqt_root_cbf : 1;
|
||||
|
||||
TransTree* tu;
|
||||
PredUnit* pu;
|
||||
CQT* split;
|
||||
};
|
||||
|
||||
struct CTU{
|
||||
CQT cqt;
|
||||
Bs16u CtbAddrInRs;
|
||||
Bs16u CtbAddrInTs;
|
||||
Bs16u RawBits;
|
||||
|
||||
Bs8u end_of_slice_segment_flag : 1;
|
||||
Bs8u sao_merge_left_flag : 1;
|
||||
Bs8u sao_merge_up_flag : 1;
|
||||
|
||||
SAO sao[3];
|
||||
};
|
||||
|
||||
struct Slice{
|
||||
Bs8u no_output_of_prior_pics_flag : 1;
|
||||
Bs8u pic_parameter_set_id : 6;
|
||||
Bs8u dependent_slice_segment_flag : 1;
|
||||
|
||||
Bs32u segment_address;
|
||||
|
||||
Bs8u reserved_flags;
|
||||
Bs8u type : 2;
|
||||
Bs8u colour_plane_id : 2;
|
||||
Bs8u short_term_ref_pic_set_idx;
|
||||
|
||||
Bs8u pic_output_flag : 1;
|
||||
Bs8u short_term_ref_pic_set_sps_flag : 1;
|
||||
Bs8u num_long_term_sps : 6;
|
||||
|
||||
Bs8u first_slice_segment_in_pic_flag : 1;
|
||||
Bs8u temporal_mvp_enabled_flag : 1;
|
||||
Bs8u sao_luma_flag : 1;
|
||||
Bs8u sao_chroma_flag : 1;
|
||||
Bs8u num_ref_idx_active_override_flag : 1;
|
||||
Bs8u mvd_l1_zero_flag : 1;
|
||||
Bs8u cabac_init_flag : 1;
|
||||
Bs8u collocated_from_l0_flag : 1;
|
||||
|
||||
Bs8u collocated_ref_idx : 4;
|
||||
Bs8u five_minus_max_num_merge_cand : 3;
|
||||
Bs8u use_integer_mv_flag : 1;
|
||||
|
||||
Bs8u num_ref_idx_l0_active_minus1 : 4;
|
||||
Bs8u num_ref_idx_l1_active_minus1 : 4;
|
||||
|
||||
Bs32u pic_order_cnt_lsb;
|
||||
Bs16u num_long_term_pics;
|
||||
|
||||
Bs16s slice_qp_delta : 6;
|
||||
Bs16s slice_cb_qp_offset : 5;
|
||||
Bs16s slice_cr_qp_offset : 5;
|
||||
|
||||
Bs16s act_y_qp_offset : 5;
|
||||
Bs16s act_cb_qp_offset : 5;
|
||||
Bs16s act_cr_qp_offset : 5;
|
||||
|
||||
Bs8u cu_chroma_qp_offset_enabled_flag : 1;
|
||||
Bs8u deblocking_filter_override_flag : 1;
|
||||
Bs8u deblocking_filter_disabled_flag : 1;
|
||||
Bs8u loop_filter_across_slices_enabled_flag : 1;
|
||||
Bs8u offset_len_minus1 : 5;
|
||||
|
||||
Bs8s beta_offset_div2 : 4;
|
||||
Bs8s tc_offset_div2 : 4;
|
||||
|
||||
Bs32u num_entry_point_offsets;
|
||||
|
||||
ShortTermRefPicSet strps;
|
||||
|
||||
LongTerm *lt;
|
||||
RefPicListsMod *rplm;
|
||||
PredWeightTable *pwt;
|
||||
Bs32u *entry_point_offset_minus1;
|
||||
|
||||
//////////////////////////
|
||||
Bs16u NumPocTotalCurr;
|
||||
Bs32s PicOrderCntVal;
|
||||
|
||||
SPS *sps;
|
||||
PPS *pps;
|
||||
|
||||
Bs32u NumCU;
|
||||
CTU **CuInTs; //coding units in tile scan
|
||||
};
|
||||
|
||||
struct NALU{
|
||||
Bs64u StartOffset;
|
||||
Bs32u NumBytesInNalUnit;
|
||||
Bs32u NumBytesInRbsp;
|
||||
|
||||
Bs16u forbidden_zero_bit : 1;
|
||||
Bs16u nal_unit_type : 6;
|
||||
Bs16u nuh_layer_id : 6;
|
||||
Bs16u nuh_temporal_id_plus1 : 3;
|
||||
|
||||
union{
|
||||
void *unit;
|
||||
VPS *vps;
|
||||
SPS *sps;
|
||||
PPS *pps;
|
||||
SEI *sei;
|
||||
AUD *aud;
|
||||
Slice *slice;
|
||||
};
|
||||
};
|
||||
|
||||
struct Picture{
|
||||
union {
|
||||
Bs8u used; //used for reference
|
||||
struct{
|
||||
Bs8u st : 1; // used for short-term reference
|
||||
Bs8u lt : 1; // used for long-term reference
|
||||
Bs8u reserved0 : 1;
|
||||
Bs8u reserved1 : 1;
|
||||
Bs8u reserved2 : 1;
|
||||
Bs8u reserved3 : 1;
|
||||
Bs8u reserved4 : 1;
|
||||
Bs8u reserved5 : 1;
|
||||
};
|
||||
};
|
||||
Bs8s TId;
|
||||
Bs32s PicOrderCntVal;
|
||||
Bs32u pic_order_cnt_lsb;
|
||||
|
||||
Bs32u NumSlice;
|
||||
NALU** slice;
|
||||
|
||||
Picture* RefPicList0[16];
|
||||
Picture* RefPicList1[16];
|
||||
|
||||
Bs32u NumCU;
|
||||
CTU* CuInRs; //coding units in raster scan
|
||||
};
|
||||
|
||||
struct AU{
|
||||
Bs32u NumUnits;
|
||||
NALU** nalu; //NALU* nalu[NumUnits];
|
||||
Picture* pic;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif //#ifndef __HEVC_STRUCT_H
|
|
@ -1,288 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <bs_reader.h>
|
||||
|
||||
#define BS_SKIP_IGNORED_BYTES() \
|
||||
if( ignore_bytes_cnt && next_ignored_byte ) \
|
||||
if( *next_ignored_byte == (file_pos+offset) ){ \
|
||||
offset++; \
|
||||
next_ignored_byte++; \
|
||||
ignore_bytes_cnt--; \
|
||||
if( buf_size < offset+readBytes+((lastBits)?1:0) ){ \
|
||||
if(read_more_data()) return last_err; \
|
||||
} \
|
||||
}
|
||||
|
||||
Bs32u BS_Reader::ue_v(){
|
||||
Bs32s leadingZeroBits = -1;
|
||||
for( byte b = 0; !b; leadingZeroBits++ ) b = read_1_bit();
|
||||
return (1<<leadingZeroBits) + read_bits( leadingZeroBits ) - 1;
|
||||
}
|
||||
|
||||
Bs32s BS_Reader::se_v(){
|
||||
Bs32u val = ue_v();
|
||||
return (val&0x01) ? (Bs32s)((val+1)>>1) : -(Bs32s)((val+1)>>1);
|
||||
}
|
||||
|
||||
BSErr BS_Reader::read_more_data(){
|
||||
if( !bs ) return last_err = BS_ERR_MORE_DATA;
|
||||
if( BS_FEOF(bs) ) return last_err = BS_ERR_MORE_DATA;
|
||||
Bs32u keep_bytes = buf_size-offset;
|
||||
if( keep_bytes == buf_size ) return last_err = BS_ERR_NOT_ENOUGH_BUFFER;
|
||||
if( offset < buf_size ) memcpy( buf, buf+offset, keep_bytes );
|
||||
file_pos = BS_FTELL(bs) - keep_bytes;
|
||||
if( !(buf_size = (Bs32u)BS_FREAD( bs, buf+keep_bytes, offset)) ) /*return*/ last_err = BS_ERR_MORE_DATA;
|
||||
buf_size += keep_bytes;
|
||||
offset = 0;
|
||||
return last_err;
|
||||
}
|
||||
|
||||
byte BS_Reader::read_1_bit(){
|
||||
if(!bit){
|
||||
// skip start code emulation prevention byte
|
||||
if( ignore_bytes_cnt && next_ignored_byte ){
|
||||
if( *next_ignored_byte == (file_pos+offset) ){
|
||||
if (buf_size == offset)
|
||||
if (read_more_data())
|
||||
return last_err;
|
||||
offset++;
|
||||
next_ignored_byte++;
|
||||
ignore_bytes_cnt--;
|
||||
}
|
||||
}
|
||||
if( buf_size <= offset ){
|
||||
if(read_more_data()) return last_err;
|
||||
}
|
||||
}
|
||||
byte res = ((buf[offset] >> (7 - bit)) & 1);
|
||||
bit = (bit+1)&0x07;
|
||||
offset += !bit;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
byte BS_Reader::read_1_byte(){
|
||||
if( buf_size == offset ){
|
||||
if(read_more_data()) return (byte)last_err;
|
||||
};
|
||||
if( !bit ) return buf[offset++];
|
||||
offset++;
|
||||
return (buf[offset-1]<<bit)|(buf[offset]>>(8-bit));
|
||||
}
|
||||
|
||||
Bs32u BS_Reader::next_bits( Bs32u nBits /*1..32*/ ){
|
||||
byte haveBits = bit ? (8-bit) : 0; // already in buffer
|
||||
byte lockedByte = bit ? 1 : 0;
|
||||
Bs32u readBytes = (byte)(nBits - haveBits + 7)>>3; //bytes to read
|
||||
byte lastBits = (byte)( readBytes ? ((nBits - haveBits)%8) : nBits ); //bits to read in last byte
|
||||
Bs32u tmp_offset = offset;
|
||||
Bs32u res = 0;
|
||||
|
||||
if( readBytes ){
|
||||
if( buf_size < offset+lockedByte+readBytes ){
|
||||
if(read_more_data()) return last_err;
|
||||
tmp_offset = offset;
|
||||
};
|
||||
|
||||
if( lockedByte ){
|
||||
res = (byte)( buf[tmp_offset]<<bit )>>bit;
|
||||
tmp_offset++;
|
||||
}
|
||||
|
||||
if( lastBits )readBytes--;
|
||||
while( readBytes-- ){
|
||||
res = (res<<8)|(byte)(buf[tmp_offset]);
|
||||
tmp_offset++;
|
||||
}
|
||||
if( lastBits ){
|
||||
res = (res<<lastBits)|(byte)(buf[tmp_offset]>>(8-lastBits));
|
||||
}
|
||||
}else if( lastBits ){
|
||||
res = (byte)( buf[tmp_offset]<<bit )>>(8-lastBits);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Bs32u BS_Reader::next_bytes(byte nBytes /*1..4*/){
|
||||
if(buf_size < offset + nBytes){
|
||||
if(read_more_data()) return last_err;
|
||||
}
|
||||
|
||||
//in order from most often invoked
|
||||
if(nBytes == 3) return (buf[offset]<<16)|(buf[offset+1]<<8)|buf[offset+2];
|
||||
else if(nBytes == 4) return (buf[offset]<<24)|(buf[offset+1]<<16)|(buf[offset+2]<<8)|buf[offset+3];
|
||||
else if(nBytes == 1) return buf[offset];
|
||||
else if(nBytes == 2) return (buf[offset]<<8)|buf[offset+1];
|
||||
|
||||
return last_err = BS_ERR_INVALID_PARAMS;
|
||||
}
|
||||
|
||||
|
||||
Bs32u BS_Reader::read_bits( Bs32u nBits /*1..32*/){
|
||||
byte haveBits = bit ? (8-bit) : 0; // already in buffer
|
||||
byte lockedByte = bit ? 1 : 0;
|
||||
Bs32u readBytes = (byte)(nBits - haveBits + 7)>>3; //bytes to read
|
||||
byte lastBits = (byte)( readBytes ? ((nBits - haveBits)%8) : nBits ); //bits to read in last byte
|
||||
Bs32u res = 0;
|
||||
|
||||
if( readBytes ){
|
||||
if( buf_size < offset+lockedByte+readBytes ){
|
||||
if(read_more_data()) return last_err;
|
||||
}
|
||||
|
||||
if( lockedByte ){
|
||||
res = (byte)( buf[offset]<<bit )>>bit;
|
||||
offset++;
|
||||
}
|
||||
|
||||
if( lastBits )readBytes--;
|
||||
while( readBytes-- ){
|
||||
BS_SKIP_IGNORED_BYTES();
|
||||
res = (res<<8)|(byte)(buf[offset]);
|
||||
offset++;
|
||||
}
|
||||
BS_SKIP_IGNORED_BYTES();
|
||||
|
||||
if( lastBits ){
|
||||
res = (res<<lastBits)|(byte)(buf[offset]>>(8-lastBits));
|
||||
}
|
||||
|
||||
bit = lastBits;
|
||||
|
||||
}else if( lastBits ){
|
||||
if( buf_size <= offset ){
|
||||
if(read_more_data()) return last_err;
|
||||
}
|
||||
res = (byte)( buf[offset]<<bit )>>(8-lastBits);
|
||||
if( (lastBits + bit)>>3 ){
|
||||
bit = 0;
|
||||
offset++;
|
||||
}else bit = (byte)(lastBits + bit );
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
BSErr BS_Reader::shift( long nBytes ){
|
||||
if(nBytes > 0)
|
||||
return shift_forward(nBytes);
|
||||
else
|
||||
return shift_back(-nBytes);
|
||||
|
||||
return BS_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
BSErr BS_Reader::shift_forward( Bs32u nBytes ){
|
||||
bit = 0;
|
||||
if( nBytes+offset > buf_size){
|
||||
if(bs){
|
||||
nBytes -= (buf_size-offset);
|
||||
BS_FSEEK( bs, nBytes, SEEK_CUR );
|
||||
buf_size = BS_BUF_SIZE; // set max buf size
|
||||
offset = buf_size;
|
||||
last_err = read_more_data();
|
||||
file_pos = BS_FTELL(bs) - buf_size;
|
||||
}else{
|
||||
return last_err = BS_ERR_MORE_DATA;
|
||||
}
|
||||
}else{
|
||||
offset += nBytes;
|
||||
}
|
||||
return BS_ERR_NONE;
|
||||
}
|
||||
|
||||
BSErr BS_Reader::shift_back( Bs32u nBytes ){
|
||||
bit = 0;
|
||||
if( nBytes > offset ){
|
||||
if(bs){
|
||||
nBytes += (buf_size-offset);
|
||||
BS_FSEEK( bs, -(BS_FOFFSET_TYPE)nBytes, SEEK_CUR );
|
||||
buf_size = BS_BUF_SIZE; // set max buf size
|
||||
offset = buf_size;
|
||||
last_err = read_more_data();
|
||||
file_pos = BS_FTELL(bs) - buf_size;
|
||||
}else{
|
||||
return last_err = BS_ERR_MORE_DATA;
|
||||
}
|
||||
}else{
|
||||
offset -= nBytes;
|
||||
}
|
||||
return BS_ERR_NONE;
|
||||
}
|
||||
|
||||
void BS_Reader::ignore_next_byte(){
|
||||
ignore_bytes = (BS_FADDR_TYPE*)realloc(ignore_bytes,(ignore_bytes_cnt+1)*sizeof(BS_FADDR_TYPE));
|
||||
if (!ignore_bytes)
|
||||
throw std::bad_alloc();
|
||||
ignore_bytes[ignore_bytes_cnt] = file_pos+offset;
|
||||
ignore_bytes_cnt++;
|
||||
}
|
||||
|
||||
BSErr BS_Reader::open( const char* file_name ) {
|
||||
buf_size = BS_BUF_SIZE;
|
||||
offset = buf_size;
|
||||
buf = (byte*)malloc( buf_size );
|
||||
|
||||
if(bs) {
|
||||
if(close()) return last_err;
|
||||
}
|
||||
|
||||
BS_FOPEN(file_name, bs);
|
||||
|
||||
return last_err = (bs) ? BS_ERR_NONE : BS_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
void BS_Reader::set_buffer(byte *buf, Bs32u buf_size){
|
||||
if(bs){
|
||||
close();
|
||||
bs = NULL;
|
||||
}
|
||||
last_err = BS_ERR_NONE;
|
||||
file_pos = 0;
|
||||
offset = 0;
|
||||
bit = 0;
|
||||
ignore_bytes_cnt = 0;
|
||||
next_ignored_byte = NULL;
|
||||
this->buf = buf;
|
||||
this->buf_size = buf_size;
|
||||
}
|
||||
|
||||
void BS_Reader::skip_bytes( Bs32u nBytes ){
|
||||
while( Bs32u(next_ignored_byte - ignore_bytes) < ignore_bytes_cnt ){
|
||||
if( (*next_ignored_byte) > (file_pos+offset+nBytes) ) break;
|
||||
nBytes++;
|
||||
next_ignored_byte++;
|
||||
}
|
||||
shift_forward(nBytes);
|
||||
}
|
||||
|
||||
BSErr BS_Reader::read_arr(byte *arr, Bs32u size){
|
||||
if(bit) return BS_ERR_UNKNOWN;
|
||||
while(size){
|
||||
Bs32u to_copy = BS_MIN(size, buf_size - offset);
|
||||
memcpy(arr, buf+offset, to_copy);
|
||||
size -= to_copy;
|
||||
offset += to_copy;
|
||||
if(size && read_more_data()) return last_err;
|
||||
arr += to_copy;
|
||||
}
|
||||
return last_err;
|
||||
}
|
|
@ -1,523 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "bs_reader2.h"
|
||||
#include <memory.h>
|
||||
|
||||
namespace BsReader2
|
||||
{
|
||||
File::File()
|
||||
: m_f(0)
|
||||
{}
|
||||
|
||||
File::~File()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
bool File::Open(const char* file, Bs32u buffSize)
|
||||
{
|
||||
Close();
|
||||
#if !defined(__GNUC__) && !defined(__clang__)
|
||||
#pragma warning(disable:4996)
|
||||
#endif
|
||||
|
||||
m_f = fopen(file, "rb");
|
||||
if (m_f)
|
||||
m_b.resize(buffSize);
|
||||
return !!m_f;
|
||||
}
|
||||
|
||||
void File::Close()
|
||||
{
|
||||
if (m_f)
|
||||
fclose(m_f);
|
||||
m_f = 0;
|
||||
}
|
||||
|
||||
bool File::UpdateBuffer(Bs8u*& start, Bs8u*& cur, Bs8u*& end, Bs32u keepBytes)
|
||||
{
|
||||
if (!m_f || feof(m_f))
|
||||
return false;
|
||||
|
||||
keepBytes = BS_MIN(keepBytes, Bs32u(cur - start));
|
||||
cur -= keepBytes;
|
||||
|
||||
if (Bs32u(end - cur) >= m_b.size())
|
||||
return false;
|
||||
|
||||
memmove(&m_b[0], cur, end - cur);
|
||||
|
||||
start = &m_b[0];
|
||||
end = start + (end - cur);
|
||||
cur = start + keepBytes;
|
||||
|
||||
end += fread(end, 1, m_b.size() - (end - start), m_f);
|
||||
|
||||
#if 0
|
||||
printf("\n");
|
||||
for (Bs32u i = 0; i < keepBytes; i++)
|
||||
printf("%02X ", start[i]);
|
||||
printf("\n");
|
||||
|
||||
for (Bs32u i = 0; i < (end - cur); i++)
|
||||
{
|
||||
if (i%16 == 0)
|
||||
printf("\n");
|
||||
printf("%02X ", cur[i]);
|
||||
}
|
||||
printf("\n");
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reader::Reader()
|
||||
{
|
||||
m_bsStart = 0;
|
||||
m_bsEnd = 0;
|
||||
m_bs = 0;
|
||||
m_bitOffset = 0;
|
||||
m_bitStart = 0;
|
||||
m_emulation = false;
|
||||
m_updater = 0;
|
||||
m_trace = true;
|
||||
m_traceOffset = true;
|
||||
m_traceLevel = 0xFFFFFFFF;
|
||||
m_tla = m_trace;
|
||||
m_tln = 0;
|
||||
m_log = stdout;
|
||||
}
|
||||
|
||||
Reader::~Reader()
|
||||
{
|
||||
}
|
||||
|
||||
void Reader::Reset(Bs8u* bs, Bs32u size, Bs8u bitOffset)
|
||||
{
|
||||
if (bs)
|
||||
{
|
||||
m_bsStart = bs;
|
||||
m_bsEnd = bs + size;
|
||||
m_bs = bs;
|
||||
m_bitOffset = (bitOffset & 7);
|
||||
m_bitStart = (bitOffset & 7);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bs = m_bsStart;
|
||||
m_bitOffset = m_bitStart;
|
||||
}
|
||||
m_updater = 0;
|
||||
m_startOffset = 0;
|
||||
}
|
||||
|
||||
void Reader::MoreData(Bs32u keepBytes)
|
||||
{
|
||||
auto NewOffset = m_startOffset;
|
||||
keepBytes = BS_MIN(keepBytes, Bs32u(m_bs - m_bsStart));
|
||||
|
||||
if (m_bsStart && m_bs && m_bsEnd)
|
||||
NewOffset += (m_bs - m_bsStart) - keepBytes;
|
||||
|
||||
if ( !m_updater
|
||||
|| !m_updater->UpdateBuffer(m_bsStart, m_bs, m_bsEnd, keepBytes))
|
||||
throw EndOfBuffer();
|
||||
|
||||
m_startOffset = NewOffset;
|
||||
}
|
||||
|
||||
bool Reader::MoreDataNoThrow(Bs32u keepBytes)
|
||||
{
|
||||
auto NewOffset = m_startOffset;
|
||||
keepBytes = BS_MIN(keepBytes, Bs32u(m_bs - m_bsStart));
|
||||
|
||||
if (m_bsStart && m_bs && m_bsEnd)
|
||||
NewOffset += (m_bs - m_bsStart) - keepBytes;
|
||||
|
||||
if ( !m_updater
|
||||
|| !m_updater->UpdateBuffer(m_bsStart, m_bs, m_bsEnd, keepBytes))
|
||||
return false;
|
||||
|
||||
m_startOffset = NewOffset;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Reader::NextStartCode(bool stopBefore)
|
||||
{
|
||||
if (m_bitOffset)
|
||||
++m_bs;
|
||||
|
||||
m_bitOffset = 0;
|
||||
|
||||
for (;; m_bs++)
|
||||
{
|
||||
if (m_bs >= m_bsEnd)
|
||||
MoreData();
|
||||
|
||||
if ( m_bs - m_bsStart >= 2
|
||||
&& m_bs[0] == 0x01
|
||||
&& m_bs[-1] == 0x00
|
||||
&& m_bs[-2] == 0x00)
|
||||
{
|
||||
bool LongSC = (m_bs - m_bsStart >= 3) && m_bs[-3] == 0x00;
|
||||
|
||||
if (stopBefore)
|
||||
m_bs -= (3 + LongSC);
|
||||
|
||||
++m_bs;
|
||||
|
||||
return LongSC;
|
||||
}
|
||||
|
||||
if ( m_emulation
|
||||
&& m_bs - m_bsStart >= 2
|
||||
&& m_bs[-1] == 0x00
|
||||
&& m_bs[-2] == 0x00)
|
||||
{
|
||||
if (m_bs + 1 >= m_bsEnd)
|
||||
MoreDataNoThrow();
|
||||
|
||||
if ( (m_bsEnd - m_bs) >= 1
|
||||
&& m_bs[0] == 0x03
|
||||
&& (m_bs[1] & 0xfc) == 0x00)
|
||||
{
|
||||
++m_bs;
|
||||
++m_emuBytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Reader::TrailingBits(bool stopBefore)
|
||||
{
|
||||
if (m_bs >= m_bsEnd)
|
||||
MoreData();
|
||||
|
||||
if (Bs8u((*m_bs) << m_bitOffset) == 0x80)
|
||||
{
|
||||
if (!stopBefore)
|
||||
{
|
||||
m_bitOffset = 0;
|
||||
++m_bs;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Reader::NextBytes(Bs8u* b, Bs32u n)
|
||||
{
|
||||
if (m_bs + n >= m_bsEnd)
|
||||
MoreDataNoThrow();
|
||||
|
||||
if (m_bs + n >= m_bsEnd)
|
||||
return false;
|
||||
|
||||
if (b != m_bs)
|
||||
memcpy(b, m_bs, n);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Bs32u Reader::GetByte()
|
||||
{
|
||||
if (m_bs >= m_bsEnd)
|
||||
MoreData();
|
||||
|
||||
Bs32u b = *m_bs;
|
||||
|
||||
++m_bs;
|
||||
|
||||
if ( m_emulation
|
||||
&& m_bs - m_bsStart >= 2
|
||||
&& m_bs[-1] == 0x00
|
||||
&& m_bs[-2] == 0x00)
|
||||
{
|
||||
if (m_bs+1 >= m_bsEnd)
|
||||
MoreDataNoThrow();
|
||||
|
||||
if ( (m_bsEnd - m_bs) >= 1
|
||||
&& m_bs[0] == 0x03
|
||||
&& (m_bs[1] & 0xfc) == 0x00)
|
||||
{
|
||||
++m_bs;
|
||||
++m_emuBytes;
|
||||
}
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
Bs32u Reader::GetBytes(Bs32u n, bool nothrow)
|
||||
{
|
||||
Bs32u b = 0;
|
||||
|
||||
while (n--)
|
||||
{
|
||||
if (m_bs >= m_bsEnd)
|
||||
{
|
||||
if (!nothrow)
|
||||
MoreData();
|
||||
else if (!MoreDataNoThrow())
|
||||
return (b << (8 * (n + 1)));
|
||||
}
|
||||
|
||||
b = (b << 8) | *m_bs;
|
||||
|
||||
++m_bs;
|
||||
|
||||
if ( m_emulation
|
||||
&& m_bs - m_bsStart >= 2
|
||||
&& m_bs[-1] == 0x00
|
||||
&& m_bs[-2] == 0x00)
|
||||
{
|
||||
if (m_bs + 1 >= m_bsEnd)
|
||||
MoreDataNoThrow();
|
||||
|
||||
if ((m_bsEnd - m_bs) >= 1
|
||||
&& m_bs[0] == 0x03
|
||||
&& (m_bs[1] & 0xfc) == 0x00)
|
||||
{
|
||||
++m_bs;
|
||||
++m_emuBytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
void Reader::ReturnByte()
|
||||
{
|
||||
if (--m_bs < m_bsStart)
|
||||
throw Exception(BS_ERR_NOT_ENOUGH_BUFFER);
|
||||
|
||||
if ( m_emulation
|
||||
&& (m_bs - m_bsStart) > 3
|
||||
&& m_bs[ 0] == 0x03
|
||||
&& m_bs[-1] == 0x00
|
||||
&& m_bs[-2] == 0x00
|
||||
&& (m_bs[1] >> 2) == 0x00)
|
||||
{
|
||||
--m_emuBytes;
|
||||
|
||||
if (--m_bs < m_bsStart)
|
||||
throw Exception(BS_ERR_NOT_ENOUGH_BUFFER);
|
||||
}
|
||||
}
|
||||
|
||||
void Reader::ReturnBits(Bs32u n)
|
||||
{
|
||||
while (n >= 8)
|
||||
{
|
||||
ReturnByte();
|
||||
n -= 8;
|
||||
}
|
||||
|
||||
if (n > m_bitOffset)
|
||||
{
|
||||
ReturnByte();
|
||||
m_bitOffset += 8;
|
||||
}
|
||||
|
||||
m_bitOffset -= n;
|
||||
}
|
||||
|
||||
Bs32u Reader::ExtractData(Bs8u* buf, Bs32u size)
|
||||
{
|
||||
assert(!m_bitOffset); // TODO
|
||||
assert(!m_emulation); // TODO
|
||||
Bs8u* begin = buf;
|
||||
Bs8u* end = buf + size;
|
||||
|
||||
while (buf < end)
|
||||
{
|
||||
Bs32u S = Bs32u(m_bsEnd - m_bs);
|
||||
S = BS_MIN(S, size);
|
||||
|
||||
memmove(buf, m_bs, S);
|
||||
buf += S;
|
||||
m_bs += S;
|
||||
|
||||
if (m_bsEnd == m_bs)
|
||||
{
|
||||
if (MoreDataNoThrow())
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return Bs32u(buf - begin);
|
||||
}
|
||||
|
||||
Bs32u Reader::ExtractRBSP(Bs8u* buf, Bs32u size)
|
||||
{
|
||||
Bs8u* begin = buf;
|
||||
|
||||
m_bitOffset = 0;
|
||||
|
||||
if (size < 4)
|
||||
throw Exception(BS_ERR_NOT_ENOUGH_BUFFER);
|
||||
|
||||
if (m_bs + 4 >= m_bsEnd)
|
||||
MoreDataNoThrow();
|
||||
|
||||
if (m_bs + 3 >= m_bsEnd)
|
||||
{
|
||||
while (m_bs < m_bsEnd)
|
||||
*buf++ = *m_bs++;
|
||||
|
||||
return Bs32u(buf - begin);
|
||||
}
|
||||
|
||||
*buf++ = *m_bs++;
|
||||
*buf++ = *m_bs++;
|
||||
*buf++ = *m_bs++;
|
||||
|
||||
if (m_bs >= m_bsEnd && !MoreDataNoThrow())
|
||||
return Bs32u(buf - begin);
|
||||
|
||||
size -= 3;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if ( m_bs[0] == 0x01
|
||||
&& m_bs[-1] == 0x00
|
||||
&& m_bs[-2] == 0x00)
|
||||
{
|
||||
bool LongSC = (m_bs - m_bsStart >= 3) && *(m_bs - 3) == 0x00;
|
||||
m_bs -= (1 + LongSC);
|
||||
buf -= (1 + LongSC);
|
||||
|
||||
return Bs32u(buf - begin);
|
||||
}
|
||||
|
||||
if (!size--)
|
||||
throw Exception(BS_ERR_NOT_ENOUGH_BUFFER);
|
||||
|
||||
*buf++ = *m_bs++;
|
||||
|
||||
if (m_bs >= m_bsEnd && !MoreDataNoThrow())
|
||||
return Bs32u(buf - begin);
|
||||
|
||||
if ( m_emulation
|
||||
&& m_bs[-1] == 0x03
|
||||
&& m_bs[-2] == 0x00
|
||||
&& m_bs[-3] == 0x00
|
||||
&& (m_bs[0] >> 2) == 0x00)
|
||||
{
|
||||
m_emuBytes++;
|
||||
buf--;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Bs32u Reader::GetBit()
|
||||
{
|
||||
if (m_bs >= m_bsEnd)
|
||||
MoreData();
|
||||
|
||||
Bs32u b = (*m_bs >> (7 - m_bitOffset)) & 1;
|
||||
|
||||
if (++m_bitOffset == 8)
|
||||
{
|
||||
++m_bs;
|
||||
m_bitOffset = 0;
|
||||
|
||||
if ( m_emulation
|
||||
&& m_bs - m_bsStart >= 2
|
||||
&& m_bs[-1] == 0x00
|
||||
&& m_bs[-2] == 0x00)
|
||||
{
|
||||
if (m_bs+1 >= m_bsEnd)
|
||||
MoreDataNoThrow();
|
||||
|
||||
if ( (m_bsEnd - m_bs) >= 1
|
||||
&& m_bs[0] == 0x03
|
||||
&& (m_bs[1] & 0xfc) == 0x00)
|
||||
{
|
||||
++m_bs;
|
||||
++m_emuBytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
Bs32u Reader::GetBits(Bs32u n)
|
||||
{
|
||||
Bs32u b = 0;
|
||||
|
||||
while (n--)
|
||||
b = (b << 1) | GetBit();
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
void Reader::GetBits(void* b, Bs32u o, Bs32u n)
|
||||
{
|
||||
Bs8u *p = (Bs8u*)b;
|
||||
|
||||
if (o)
|
||||
{
|
||||
p += (o / 8);
|
||||
o &= 7;
|
||||
*p = (*p & ~(0xFF >> o));
|
||||
}
|
||||
|
||||
o = 7 - o;
|
||||
|
||||
while (n--)
|
||||
{
|
||||
*p |= GetBit() << o;
|
||||
|
||||
if (!o--)
|
||||
{
|
||||
o = 7;
|
||||
*++p = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Bs32u Reader::GetUE()
|
||||
{
|
||||
Bs32u lz = 0;
|
||||
|
||||
while (!GetBit())
|
||||
lz++;
|
||||
|
||||
return !lz ? 0 : ((1 << lz) | GetBits(lz)) - 1;
|
||||
}
|
||||
|
||||
Bs32s Reader::GetSE()
|
||||
{
|
||||
Bs32u ue = GetUE();
|
||||
return (ue & 1) ? (Bs32s)((ue + 1) >> 1) : -(Bs32s)((ue + 1) >> 1);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,602 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "bs_thread.h"
|
||||
|
||||
//#define BS_THREAD_TRACE
|
||||
|
||||
#ifdef BS_THREAD_TRACE
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
inline void __notrace(const char*, ...) {}
|
||||
|
||||
const char State2CS[6][8] = { "DONE", "WORKING", "WAITING", "QUEUED", "LOST", "FAILED" };
|
||||
|
||||
#ifdef BS_THREAD_TRACE
|
||||
#define BS_THREAD_TRACE_F printf
|
||||
#define BS_THREAD_TRACE_FLUSH fflush(stdout);
|
||||
struct __UIA2CS
|
||||
{
|
||||
static char c_str[256];
|
||||
__UIA2CS(unsigned int n, unsigned int *s)
|
||||
{
|
||||
char* p = c_str;
|
||||
p++[0] = '{';
|
||||
while (n--)
|
||||
p += sprintf_s(p, 256, " %d", s++[0]);
|
||||
p++[0] = ' ';
|
||||
p++[0] = '}';
|
||||
p++[0] = 0;
|
||||
}
|
||||
};
|
||||
char __UIA2CS::c_str[256];
|
||||
#else
|
||||
struct __UIA2CS
|
||||
{
|
||||
char* c_str = nullptr;
|
||||
__UIA2CS(unsigned int n, unsigned int *s)
|
||||
{
|
||||
(void)n;
|
||||
(void)s;
|
||||
}
|
||||
};
|
||||
#define BS_THREAD_TRACE_F __notrace
|
||||
#define BS_THREAD_TRACE_FLUSH
|
||||
#endif
|
||||
|
||||
using namespace BsThread;
|
||||
|
||||
Scheduler::Scheduler()
|
||||
{
|
||||
m_locked = 0;
|
||||
m_id = 0;
|
||||
m_depth = 0;
|
||||
}
|
||||
|
||||
Scheduler::~Scheduler()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
void Scheduler::Init(unsigned int nThreads, unsigned int depth)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mtx);
|
||||
|
||||
BS_THREAD_TRACE_F("Scheduler::Init(%d, %d); //T=%d, D=%d, L=%d\n",
|
||||
nThreads, depth, m_thread.size() + nThreads, m_depth + depth, m_locked + 1);
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
|
||||
if (nThreads > m_thread.size())
|
||||
{
|
||||
unsigned int id = (unsigned int)m_thread.size();
|
||||
|
||||
m_thread.resize(nThreads);
|
||||
|
||||
auto t = m_thread.begin();
|
||||
std::advance(t, id);
|
||||
|
||||
for (; t != m_thread.end(); t++)
|
||||
{
|
||||
t->id = id++;
|
||||
t->task = 0;
|
||||
t->terminate = false;
|
||||
t->thread = std::thread(Execute, std::ref(*t), std::ref(*this));
|
||||
}
|
||||
}
|
||||
|
||||
m_depth += depth;
|
||||
m_locked++;
|
||||
}
|
||||
|
||||
void Scheduler::Close()
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mtx);
|
||||
BS_THREAD_TRACE_F("Scheduler::Close(); //T=%d, D=%d, L=%d\n",
|
||||
m_thread.size(), m_depth, m_locked ? m_locked - 1 : 0);
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
|
||||
if (!m_locked || !--m_locked)
|
||||
{
|
||||
for (auto& t : m_thread)
|
||||
{
|
||||
std::unique_lock<std::mutex> lockTask(t.mtx);
|
||||
|
||||
while (t.task && t.task->state == WORKING)
|
||||
t.cv.wait(lockTask);
|
||||
|
||||
t.terminate = true;
|
||||
t.cv.notify_one();
|
||||
}
|
||||
|
||||
for (auto& t : m_thread)
|
||||
t.thread.join();
|
||||
|
||||
m_thread.resize(0);
|
||||
m_task.resize(0);
|
||||
|
||||
m_id = 0;
|
||||
m_depth = 0;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int Scheduler::Submit(Routine* routine, void* par, int priority, unsigned int nDep, unsigned int *dep)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mtx);
|
||||
BS_THREAD_TRACE_F("Scheduler::Submit(P=%d, D=%s) ", priority, __UIA2CS(nDep, dep).c_str);
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
|
||||
while (m_task.size() >= m_depth)
|
||||
{
|
||||
bool flag = false;
|
||||
|
||||
m_task.remove_if(
|
||||
[&] (Task& t) -> bool
|
||||
{
|
||||
if (t.state != DONE || !t.dependent.empty())
|
||||
return false;
|
||||
flag = true;
|
||||
return true;
|
||||
}
|
||||
);
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
BS_THREAD_TRACE_F(" -- TaskQueueOverflow\n");
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
throw TaskQueueOverflow();
|
||||
}
|
||||
else
|
||||
{
|
||||
BS_THREAD_TRACE_F(": TaskDequeued ");
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
}
|
||||
}
|
||||
|
||||
m_task.resize(m_task.size() + 1);
|
||||
Task& task = m_task.back();
|
||||
|
||||
task.id = m_id++;
|
||||
task.Execute = routine;
|
||||
task.param = par;
|
||||
task.priority = priority;
|
||||
task.blocked = 0;
|
||||
task.n = 0;
|
||||
task.detach = false;
|
||||
|
||||
for (unsigned int i = 0; i < nDep; i++)
|
||||
{
|
||||
auto it = std::find_if(m_task.begin(), m_task.end(),
|
||||
[&] (Task& t) -> bool { return t.id == dep[i]; });
|
||||
|
||||
if (it != m_task.end())
|
||||
{
|
||||
if (it->state == FAILED || it->state == LOST)
|
||||
{
|
||||
BS_THREAD_TRACE_F(": ID=%d BL=0 -- LOST on %d\n", task.id, it->id);
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
|
||||
task.blocked = 0;
|
||||
task.state = LOST;
|
||||
return task.id;
|
||||
}
|
||||
|
||||
if (it->state != DONE)
|
||||
{
|
||||
it->dependent.push_back(&task);
|
||||
task.blocked++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task.state = task.blocked ? WAITING : QUEUED;
|
||||
|
||||
BS_THREAD_TRACE_F(": ID=%d BL=%d -- QUEUED\n", task.id, task.blocked);
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
|
||||
Update(*this, 0);
|
||||
|
||||
return task.id;
|
||||
}
|
||||
|
||||
State Scheduler::Sync(unsigned int id, unsigned int waitMS, bool keepStat)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mtx);
|
||||
State st = LOST;
|
||||
BS_THREAD_TRACE_F("Scheduler::Sync(ID=%d, Wait=%d, Keep=%d) ", id, waitMS, keepStat);
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
|
||||
auto it = std::find_if(m_task.begin(), m_task.end(),
|
||||
[&] (Task& t) -> bool { return t.id == id; });
|
||||
|
||||
if (it == m_task.end() || it->detach)
|
||||
{
|
||||
BS_THREAD_TRACE_F("-- LOST(DEQUEUED)\n");
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
return LOST;
|
||||
}
|
||||
Task* pTask = &*it;
|
||||
st = pTask->state;
|
||||
|
||||
if (waitMS)
|
||||
{
|
||||
BS_THREAD_TRACE_F(": wait\n");
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
|
||||
lock.unlock();
|
||||
|
||||
{
|
||||
std::unique_lock<std::mutex> lockTask(pTask->mtx);
|
||||
|
||||
pTask->cv.wait_for(lockTask, std::chrono::milliseconds(waitMS),
|
||||
[&]() -> bool { return Ready(pTask->state); } );
|
||||
|
||||
st = pTask->state;
|
||||
}
|
||||
|
||||
lock.lock();
|
||||
|
||||
BS_THREAD_TRACE_F("Scheduler::Sync(ID=%d, Wait=%d, Keep=%d) : return ", id, waitMS, keepStat);
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
}
|
||||
|
||||
if (Ready(st) && !keepStat)
|
||||
{
|
||||
m_task.remove_if([&] (Task& t) -> bool { return t.id == id; });
|
||||
}
|
||||
|
||||
BS_THREAD_TRACE_F("-- %s\n", State2CS[st]);
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
|
||||
return st;
|
||||
}
|
||||
|
||||
void Scheduler::Detach(SyncPoint id)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mtx);
|
||||
BS_THREAD_TRACE_F("Scheduler::Detach(ID=%d) ", id);
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
|
||||
auto itT = std::find_if(m_task.begin(), m_task.end(),
|
||||
[&] (Task& t) -> bool { return t.id == id; });
|
||||
|
||||
if (itT == m_task.end())
|
||||
{
|
||||
BS_THREAD_TRACE_F("-- LOST(DEQUEUED)\n");
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
return;
|
||||
}
|
||||
|
||||
BS_THREAD_TRACE_F(" -- %s\n", State2CS[itT->state]);
|
||||
|
||||
itT->detach = true;
|
||||
|
||||
if (Ready(itT->state))
|
||||
{
|
||||
m_task.remove_if([&] (Task& t) -> bool { return t.id == id; });
|
||||
}
|
||||
}
|
||||
|
||||
bool Scheduler::WaitForAny(unsigned int waitMS)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mtx);
|
||||
|
||||
return (std::cv_status::timeout == m_cv.wait_for(lock, std::chrono::milliseconds(waitMS)));
|
||||
}
|
||||
|
||||
State Scheduler::AddDependency(SyncPoint id, unsigned int nDep, SyncPoint *dep)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mtx);
|
||||
BS_THREAD_TRACE_F("Scheduler::AddDependency(ID=%d, D=%s) ", id, __UIA2CS(nDep, dep).c_str);
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
|
||||
auto itT = std::find_if(m_task.begin(), m_task.end(),
|
||||
[&] (Task& t) -> bool { return t.id == id; });
|
||||
|
||||
if (itT == m_task.end())
|
||||
{
|
||||
BS_THREAD_TRACE_F("-- LOST(DEQUEUED)\n");
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
return LOST;
|
||||
}
|
||||
Task& task = *itT;
|
||||
|
||||
if (Ready(task.state) || task.state == WORKING)
|
||||
{
|
||||
BS_THREAD_TRACE_F("-- %s\n", State2CS[task.state]);
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
return task.state;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < nDep; i++)
|
||||
{
|
||||
auto it = std::find_if(m_task.begin(), m_task.end(),
|
||||
[&] (Task& t) -> bool { return t.id == dep[i]; });
|
||||
|
||||
if (it != m_task.end())
|
||||
{
|
||||
auto& base = *it;
|
||||
std::unique_lock<std::mutex> lockTask(task.mtx);
|
||||
|
||||
if (base.state == FAILED || base.state == LOST)
|
||||
{
|
||||
BS_THREAD_TRACE_F(" -- LOST on %d\n", base.id);
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
|
||||
task.blocked = 0;
|
||||
task.state = LOST;
|
||||
return LOST;
|
||||
}
|
||||
|
||||
if (base.state != DONE)
|
||||
{
|
||||
//std::unique_lock<std::mutex> lockBase(task.mtx);
|
||||
base.dependent.push_back(&task);
|
||||
task.blocked++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (task.blocked)
|
||||
{
|
||||
std::unique_lock<std::mutex> lockTask(task.mtx);
|
||||
task.state = WAITING;
|
||||
}
|
||||
|
||||
BS_THREAD_TRACE_F("-- %s\n", State2CS[task.state]);
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
|
||||
return task.state;
|
||||
}
|
||||
|
||||
bool Scheduler::Abort(SyncPoint id, unsigned int waitMS)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mtx);
|
||||
BS_THREAD_TRACE_F("Scheduler::Abort(ID=%d, Wait=%d) ", id, waitMS);
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
|
||||
auto it = std::find_if(m_task.begin(), m_task.end(),
|
||||
[&] (Task& t) -> bool { return t.id == id; });
|
||||
|
||||
if (it == m_task.end())
|
||||
{
|
||||
BS_THREAD_TRACE_F("-- LOST(DEQUEUED)\n");
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
return true;
|
||||
}
|
||||
|
||||
Task* pTask = &*it;
|
||||
BS_THREAD_TRACE_F(": wait\n");
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
|
||||
lock.unlock();
|
||||
|
||||
{
|
||||
std::unique_lock<std::mutex> lockTask(pTask->mtx);
|
||||
|
||||
pTask->cv.wait_for(lockTask, std::chrono::milliseconds(waitMS),
|
||||
[&]() -> bool { return pTask->state != WORKING; } );
|
||||
}
|
||||
|
||||
lock.lock();
|
||||
|
||||
if (pTask->state != WORKING)
|
||||
{
|
||||
BS_THREAD_TRACE_F("Scheduler::Abort(ID=%d, Wait=%d) : DONE\n", id, waitMS);
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
pTask->state = LOST;
|
||||
|
||||
if (!pTask->dependent.empty())
|
||||
_AbortDependent(*pTask);
|
||||
|
||||
if (pTask->blocked)
|
||||
{
|
||||
for (auto& t : m_task)
|
||||
t.dependent.remove(pTask);
|
||||
}
|
||||
|
||||
m_task.remove_if([&] (Task& t) -> bool { return t.id == id; });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BS_THREAD_TRACE_F("Scheduler::Abort(ID=%d, Wait=%d) : WORKING\n", id, waitMS);
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Scheduler::_AbortDependent(Task& task)
|
||||
{
|
||||
BS_THREAD_TRACE_F(" Abort:");
|
||||
|
||||
for (auto& dep : task.dependent)
|
||||
{
|
||||
std::unique_lock<std::mutex> lockDep(dep->mtx);
|
||||
dep->blocked = 0;
|
||||
dep->state = LOST;
|
||||
BS_THREAD_TRACE_F(" %d", dep->id);
|
||||
dep->cv.notify_one();
|
||||
}
|
||||
task.dependent.resize(0);
|
||||
|
||||
BS_THREAD_TRACE_F("\n");
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
}
|
||||
|
||||
void Scheduler::Execute(Thread& self, Scheduler& sync)
|
||||
{
|
||||
std::unique_lock<std::mutex> lockThread(self.mtx);
|
||||
|
||||
while (!self.terminate)
|
||||
{
|
||||
while (self.task)
|
||||
{
|
||||
auto st = self.task->Execute(self.task->param, self.task->n);
|
||||
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> lock(sync.m_mtx);
|
||||
self.task->state = st;
|
||||
self.task->n++;
|
||||
Update(sync, &self);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
while (!self.task && !self.terminate)
|
||||
self.cv.wait(lockThread);
|
||||
}
|
||||
}
|
||||
|
||||
void Scheduler::Update(Scheduler& self, Thread* thread)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> lock(self.m_mtx);
|
||||
auto FindThread = [&] () -> Thread*
|
||||
{
|
||||
auto it = std::find_if(self.m_thread.begin(), self.m_thread.end(),
|
||||
[] (Thread& t) -> bool { return !t.task; });
|
||||
|
||||
if (it == self.m_thread.end())
|
||||
return 0;
|
||||
|
||||
return &*it;
|
||||
};
|
||||
std::list<Task*> queued;
|
||||
std::list<SyncPoint> detached;
|
||||
|
||||
BS_THREAD_TRACE_F("Scheduler::Update()\n");
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
|
||||
if (thread && thread->task)
|
||||
{
|
||||
BS_THREAD_TRACE_F(" : TH=%d ID=%d N=%d -- %s\n",
|
||||
thread->id, thread->task->id, thread->task->n, State2CS[thread->task->state]);
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
|
||||
if (thread->task->state == WORKING)
|
||||
thread->task->state = QUEUED;
|
||||
|
||||
if ( thread->task->state == DONE
|
||||
|| thread->task->state == FAILED)
|
||||
{
|
||||
std::unique_lock<std::mutex> lockTask(thread->task->mtx);
|
||||
|
||||
if (thread->task->state == DONE)
|
||||
{
|
||||
BS_THREAD_TRACE_F(" Unlock:");
|
||||
|
||||
for (auto& dep : thread->task->dependent)
|
||||
{
|
||||
if (dep->blocked)
|
||||
{
|
||||
dep->blocked--;
|
||||
|
||||
if (!dep->blocked)
|
||||
dep->state = QUEUED;
|
||||
|
||||
BS_THREAD_TRACE_F(" %d(%d)", dep->id, dep->blocked);
|
||||
}
|
||||
}
|
||||
BS_THREAD_TRACE_F("\n");
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
}
|
||||
else if (!thread->task->dependent.empty())
|
||||
self._AbortDependent(*thread->task);
|
||||
|
||||
thread->task->cv.notify_one();
|
||||
}
|
||||
|
||||
if (Ready(thread->task->state))
|
||||
{
|
||||
for (auto& task : self.m_task)
|
||||
{
|
||||
if ( task.state == WAITING
|
||||
&& !task.blocked
|
||||
&& task.id != thread->task->id)
|
||||
{
|
||||
task.state = QUEUED;
|
||||
}
|
||||
task.dependent.remove(thread->task);
|
||||
}
|
||||
|
||||
if (thread->task->detach)
|
||||
detached.push_back(thread->task->id);
|
||||
|
||||
self.m_cv.notify_one();
|
||||
}
|
||||
|
||||
thread->task = 0;
|
||||
}
|
||||
|
||||
for (auto& task : self.m_task)
|
||||
{
|
||||
if (task.state == LOST)
|
||||
{
|
||||
if (task.dependent.size())
|
||||
self._AbortDependent(task);
|
||||
if (task.detach)
|
||||
detached.push_back(task.id);
|
||||
else
|
||||
{
|
||||
std::unique_lock<std::mutex> lockTask(task.mtx);
|
||||
task.cv.notify_one();
|
||||
}
|
||||
}
|
||||
else if (task.state == QUEUED)
|
||||
queued.push_back(&task);
|
||||
|
||||
BS_THREAD_TRACE_F(" : ID=%d BL=%d P=%d N=%d -- %s\n",
|
||||
task.id, task.blocked, task.priority, task.n, State2CS[task.state]);
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
}
|
||||
|
||||
for (auto& id : detached)
|
||||
{
|
||||
self.m_task.remove_if([&id] (Task& t) -> bool { return t.id == id; });
|
||||
}
|
||||
|
||||
queued.sort([](Task* l, Task* r) { return (l->priority > r->priority); });
|
||||
|
||||
for (Task* pTask : queued)
|
||||
{
|
||||
Thread* pThread = FindThread();
|
||||
|
||||
if (!pThread)
|
||||
break;
|
||||
|
||||
std::unique_lock<std::mutex> lockThread(pThread->mtx, std::defer_lock);
|
||||
|
||||
if (pThread != thread)
|
||||
lockThread.lock();
|
||||
|
||||
pThread->task = pTask;
|
||||
pTask->state = WORKING;
|
||||
|
||||
BS_THREAD_TRACE_F(" : TH=%d ID=%d P=%d N=%d -- EXECUTE\n",
|
||||
pThread->id, pTask->id, pTask->priority, pTask->n);
|
||||
BS_THREAD_TRACE_FLUSH;
|
||||
|
||||
if (pThread != thread)
|
||||
{
|
||||
pThread->cv.notify_one();
|
||||
lockThread.unlock();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,183 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "common_cabac.h"
|
||||
|
||||
using namespace COMMON_CABAC;
|
||||
using namespace BS_HEVC;
|
||||
|
||||
// ADE ////////////////////////////////////////////////////////////////////////
|
||||
static const Bs8u renormTab[32] =
|
||||
{
|
||||
6, 5, 4, 4, 3, 3, 3, 3,
|
||||
2, 2, 2, 2, 2, 2, 2, 2,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1
|
||||
};
|
||||
|
||||
Bs8u ADE::DecodeDecision(Bs8u& ctxState)
|
||||
{
|
||||
#if (BS_AVC2_ADE_MODE == 1)
|
||||
Bs32u vMPS = (ctxState & 1);
|
||||
Bs32u bin = vMPS;
|
||||
Bs32u state = (ctxState >> 1);
|
||||
Bs32u rLPS = rangeTabLpsT[(m_range >> 6) & 3][state];
|
||||
|
||||
m_range -= rLPS;
|
||||
|
||||
if (m_val < (m_range << m_bits))
|
||||
{
|
||||
ctxState = (transIdxMps[state] << 1) | vMPS;
|
||||
|
||||
if (m_range >= 256)
|
||||
return bin;
|
||||
|
||||
m_range <<= 1;
|
||||
m_bits--;
|
||||
}
|
||||
else
|
||||
{
|
||||
Bs8u renorm = renormTab[(rLPS >> 3) & 0x1F];
|
||||
m_val -= (m_range << m_bits);
|
||||
m_range = (rLPS << renorm);
|
||||
m_bits -= renorm;
|
||||
|
||||
bin ^= 1;
|
||||
if (!state)
|
||||
vMPS ^= 1;
|
||||
|
||||
ctxState = (transIdxLps[state] << 1) | vMPS;
|
||||
}
|
||||
|
||||
if (m_bits > 0)
|
||||
return bin;
|
||||
|
||||
m_val = (m_val << 16) | B(2);
|
||||
m_bits += 16;
|
||||
|
||||
return bin;
|
||||
#else
|
||||
Bs8u binVal = 0;
|
||||
Bs8u valMPS = (ctxState & 1);
|
||||
Bs8u pStateIdx = (ctxState >> 1);
|
||||
Bs16u codIRangeLPS = rangeTabLpsT[(m_codIRange >> 6) & 3][pStateIdx];
|
||||
|
||||
m_codIRange -= codIRangeLPS;
|
||||
|
||||
if (m_codIOffset >= m_codIRange)
|
||||
{
|
||||
binVal = !valMPS;
|
||||
m_codIOffset -= m_codIRange;
|
||||
m_codIRange = codIRangeLPS;
|
||||
|
||||
if (pStateIdx == 0)
|
||||
valMPS = !valMPS;
|
||||
|
||||
pStateIdx = transIdxLps[pStateIdx];
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
binVal = valMPS;
|
||||
pStateIdx = transIdxMps[pStateIdx];
|
||||
}
|
||||
|
||||
ctxState = (pStateIdx << 1) | valMPS;
|
||||
|
||||
while (m_codIRange < 256)
|
||||
{
|
||||
m_codIRange <<= 1;
|
||||
m_codIOffset = (m_codIOffset << 1) | b();
|
||||
}
|
||||
|
||||
return binVal;
|
||||
#endif
|
||||
}
|
||||
Bs8u ADE::DecodeBypass()
|
||||
{
|
||||
#if (BS_AVC2_ADE_MODE == 1)
|
||||
if (!--m_bits)
|
||||
{
|
||||
m_val = (m_val << 16) | B(2);
|
||||
m_bits = 16;
|
||||
}
|
||||
|
||||
Bs32s val = m_val - (m_range << m_bits);
|
||||
|
||||
if (val < 0)
|
||||
return 0;
|
||||
|
||||
m_val = Bs32u(val);
|
||||
return 1;
|
||||
#else
|
||||
m_codIOffset = (m_codIOffset << 1) | b();
|
||||
//nBits++;
|
||||
|
||||
if (m_codIOffset >= m_codIRange)
|
||||
{
|
||||
m_codIOffset -= m_codIRange;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
Bs8u ADE::DecodeTerminate()
|
||||
{
|
||||
#if (BS_AVC2_ADE_MODE == 1)
|
||||
Bs32u range = m_range - 2;
|
||||
Bs32s val = m_val - (range << m_bits);
|
||||
|
||||
if (val < 0)
|
||||
{
|
||||
if (range >= 256)
|
||||
{
|
||||
m_range = range;
|
||||
return 0;
|
||||
}
|
||||
|
||||
m_range = (range << 1);
|
||||
|
||||
if (--m_bits)
|
||||
return 0;
|
||||
|
||||
m_val = (m_val << 16) | B(2);
|
||||
m_bits = 16;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
m_range = range;
|
||||
|
||||
return 1;
|
||||
#else
|
||||
m_codIRange -= 2;
|
||||
|
||||
if (m_codIOffset >= m_codIRange)
|
||||
return 1;
|
||||
|
||||
while (m_codIRange < 256)
|
||||
{
|
||||
m_codIRange <<= 1;
|
||||
m_codIOffset = (m_codIOffset << 1) | b();
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <hevc2_parser.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
// For Perl compatibility only:
|
||||
Bs32u BS_GetVal( void* hdr, Bs32u* element_idx ){
|
||||
if( !hdr ) return (Bs32u)BS_ERR_WRONG_UNITS_ORDER;
|
||||
if( !element_idx ) return (Bs32u)BS_ERR_INVALID_PARAMS;
|
||||
|
||||
Bs32u val = 0;
|
||||
void* addr = hdr;
|
||||
Bs32s nesting_level = *element_idx;
|
||||
while( nesting_level-- ){
|
||||
addr = *(void**)((Bs64s)addr + *(++element_idx));
|
||||
}
|
||||
addr = (void*)((Bs64s)addr + *(++element_idx));
|
||||
for( Bs32u i = 0; i<(*(element_idx+1));i++ ){
|
||||
val += ((*((byte*)addr+i))<<(i<<3));
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
BSErr __STDCALL BS_HEVC2_Init(BS_HEVC2::HDL& hdl, Bs32u mode){
|
||||
hdl = NULL;
|
||||
hdl = new BS_HEVC2::Parser(mode);
|
||||
if (hdl)
|
||||
return BS_ERR_NONE;
|
||||
return BS_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
BSErr __STDCALL BS_HEVC2_OpenFile(BS_HEVC2::HDL hdl, const char* file){
|
||||
if (!hdl) return BS_ERR_BAD_HANDLE;
|
||||
return hdl->open(file);
|
||||
}
|
||||
|
||||
BSErr __STDCALL BS_HEVC2_SetBuffer(BS_HEVC2::HDL hdl, byte* buf, Bs32u buf_size){
|
||||
if (!hdl) return BS_ERR_BAD_HANDLE;
|
||||
hdl->set_buffer(buf, buf_size);
|
||||
return BS_ERR_NONE;
|
||||
}
|
||||
|
||||
BSErr __STDCALL BS_HEVC2_ParseNextAU(BS_HEVC2::HDL hdl, BS_HEVC2::NALU*& header){
|
||||
if (!hdl) return BS_ERR_BAD_HANDLE;
|
||||
return hdl->parse_next_au(header);
|
||||
}
|
||||
|
||||
BSErr __STDCALL BS_HEVC2_Close(BS_HEVC2::HDL hdl){
|
||||
if (!hdl) return BS_ERR_BAD_HANDLE;
|
||||
delete (hdl);
|
||||
hdl = NULL;
|
||||
return BS_ERR_NONE;
|
||||
}
|
||||
|
||||
BSErr __STDCALL BS_HEVC2_SetTraceLevel(BS_HEVC2::HDL hdl, Bs32u level){
|
||||
if (!hdl) return BS_ERR_BAD_HANDLE;
|
||||
hdl->set_trace_level(level);
|
||||
return BS_ERR_NONE;
|
||||
}
|
||||
|
||||
BSErr __STDCALL BS_HEVC2_Lock(BS_HEVC2::HDL hdl, void* p){
|
||||
if (!hdl) return BS_ERR_BAD_HANDLE;
|
||||
return hdl->Lock(p);
|
||||
}
|
||||
|
||||
BSErr __STDCALL BS_HEVC2_Unlock(BS_HEVC2::HDL hdl, void* p){
|
||||
if (!hdl) return BS_ERR_BAD_HANDLE;
|
||||
return hdl->Unlock(p);
|
||||
}
|
||||
|
||||
BSErr __STDCALL BS_HEVC2_GetOffset(BS_HEVC2::HDL hdl, Bs64u& offset){
|
||||
if (!hdl) return BS_ERR_BAD_HANDLE;
|
||||
offset = hdl->get_cur_pos();
|
||||
return BS_ERR_NONE;
|
||||
}
|
||||
|
||||
BSErr __STDCALL BS_HEVC2_Sync(BS_HEVC2::HDL hdl, BS_HEVC2::NALU* slice){
|
||||
if (!hdl) return BS_ERR_BAD_HANDLE;
|
||||
return hdl->sync(slice);
|
||||
}
|
||||
|
||||
Bs16u __STDCALL BS_HEVC2_GetAsyncDepth(BS_HEVC2::HDL hdl){
|
||||
if (!hdl) return 0;
|
||||
return hdl->get_async_depth();
|
||||
}
|
||||
|
||||
} // extern "C"
|
|
@ -1,898 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "hevc2_parser.h"
|
||||
|
||||
using namespace BS_HEVC2;
|
||||
using namespace BsReader2;
|
||||
|
||||
#define Clip3(_min, _max, _x) BS_MIN(BS_MAX(_min, _x), _max)
|
||||
|
||||
void CABAC::InitCtx()
|
||||
{
|
||||
Slice& slice = *m_cSlice;
|
||||
auto& pps = *slice.pps;
|
||||
auto& sps = *slice.sps;
|
||||
Bs16u initType = 0;
|
||||
Bs16s Clip3_0_51_SliceQpY = 26 + slice.pps->init_qp_minus26 + slice.qp_delta;
|
||||
Bs8u* state = m_ctxState;
|
||||
Bs16s preCtxState;
|
||||
Bs16u numComps = (ChromaArrayType == 0) ? 1 : 3;
|
||||
|
||||
Clip3_0_51_SliceQpY = Clip3(0, 51, Clip3_0_51_SliceQpY);
|
||||
|
||||
memset(StatCoeff, 0, sizeof(StatCoeff));
|
||||
|
||||
if (slice.type == I)
|
||||
initType = 0;
|
||||
else if (slice.type == P)
|
||||
initType = slice.cabac_init_flag ? 2 : 1;
|
||||
else
|
||||
initType = slice.cabac_init_flag ? 1 : 2;
|
||||
|
||||
for (Bs16s initValue : BS_HEVC::CtxInitTbl[initType])
|
||||
{
|
||||
preCtxState = ((((initValue >> 4) * 5 - 45) * Clip3_0_51_SliceQpY) >> 4) + ((initValue & 15) << 3) - 16;
|
||||
preCtxState = Clip3(1, 126, preCtxState);
|
||||
|
||||
if (preCtxState <= 63)
|
||||
*state = ((63 - preCtxState) << 1);
|
||||
else
|
||||
*state = (((preCtxState - 64) << 1) | 1);
|
||||
state++;
|
||||
}
|
||||
|
||||
Bs32u sz = (sps.palette_max_size + PaletteMaxPredictorSize);
|
||||
PredictorPaletteEntries[0].resize(sz);
|
||||
PredictorPaletteEntries[1].resize(sz);
|
||||
PredictorPaletteEntries[2].resize(sz);
|
||||
PredictorPaletteSize = 0;
|
||||
|
||||
if (pps.palette_predictor_initializer_present_flag )
|
||||
{
|
||||
for (Bs16u cIdx = 0; cIdx < numComps && pps.num_palette_predictor_initializer; cIdx++)
|
||||
{
|
||||
PredictorPaletteSize = pps.num_palette_predictor_initializer;
|
||||
memmove(&PredictorPaletteEntries[cIdx][0]
|
||||
, pps.palette_predictor_initializers[cIdx]
|
||||
, pps.num_palette_predictor_initializer * sizeof(pps.palette_predictor_initializers[cIdx][0]));
|
||||
}
|
||||
}
|
||||
else if (sps.palette_predictor_initializer_present_flag)
|
||||
{
|
||||
for (Bs16u cIdx = 0; cIdx < numComps && sps.num_palette_predictor_initializer; cIdx++)
|
||||
{
|
||||
PredictorPaletteSize = sps.num_palette_predictor_initializer;
|
||||
memmove(&PredictorPaletteEntries[cIdx][0]
|
||||
, sps.palette_predictor_initializers[cIdx]
|
||||
, sps.num_palette_predictor_initializer * sizeof(sps.palette_predictor_initializers[cIdx][0]));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Bs8u CABAC::SaoTypeIdxLuma()
|
||||
{
|
||||
//TR cMax = 2, cRiceParam = 0
|
||||
//1+0, bypass
|
||||
|
||||
if (!DD(BS_HEVC::SAO_TYPE_IDX_LUMA))
|
||||
return 0;
|
||||
|
||||
BinCount++;
|
||||
return DecodeBypass() + 1;
|
||||
}
|
||||
|
||||
Bs8u CABAC::SaoOffsetAbs(Bs16u bitDepth)
|
||||
{
|
||||
//TR cMax = (1 << (Min(bitDepth, 10) - 5)) - 1, cRiceParam = 0
|
||||
//bypass bypass bypass bypass bypass na
|
||||
Bs16u cMax = (1 << (BS_MIN(bitDepth, 10) - 5)) - 1;
|
||||
Bs8u binIdx = 0;
|
||||
|
||||
while (binIdx < cMax)
|
||||
{
|
||||
if (!DecodeBypass())
|
||||
{
|
||||
BinCount += binIdx + 1;
|
||||
return binIdx;
|
||||
}
|
||||
|
||||
binIdx++;
|
||||
}
|
||||
|
||||
BinCount += binIdx;
|
||||
|
||||
return binIdx;
|
||||
}
|
||||
|
||||
Bs8u CABAC::SaoBandPosition()
|
||||
{
|
||||
//FL cMax = 31
|
||||
//bypass bypass bypass bypass bypass bypass
|
||||
Bs8u b;
|
||||
|
||||
b = (DecodeBypass() << 4);
|
||||
b |= (DecodeBypass() << 3);
|
||||
b |= (DecodeBypass() << 2);
|
||||
b |= (DecodeBypass() << 1);
|
||||
b |= DecodeBypass();
|
||||
|
||||
BinCount += 5;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
Bs8u CABAC::SaoEoClassLuma()
|
||||
{
|
||||
//FL cMax = 3
|
||||
//bypass bypass bypass na na na
|
||||
Bs8u b;
|
||||
|
||||
b = (DecodeBypass() << 1);
|
||||
b |= DecodeBypass();
|
||||
|
||||
BinCount += 2;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
bool CABAC::SplitCuFlag(Bs16s x0, Bs16s y0)
|
||||
{
|
||||
//FL cMax = 1
|
||||
//9.3.4.2.2
|
||||
Bs16u ctxInc = 0;
|
||||
bool availableL = AvailableZs(x0, y0, x0 - 1, y0);
|
||||
bool availableA = AvailableZs(x0, y0, x0, y0 - 1);
|
||||
|
||||
if (availableL || availableA)
|
||||
{
|
||||
CU* c0 = GetCU(x0, y0);
|
||||
if (!c0)
|
||||
throw InvalidSyntax();
|
||||
|
||||
CU* c1 = nullptr;
|
||||
if (availableL)
|
||||
{
|
||||
c1 = GetCU(x0 - 1, y0);
|
||||
if (!c1)
|
||||
throw InvalidSyntax();
|
||||
}
|
||||
|
||||
CU* c2 = nullptr;
|
||||
if (availableA)
|
||||
{
|
||||
c2 = GetCU(x0, y0 - 1);
|
||||
if (!c2)
|
||||
throw InvalidSyntax();
|
||||
}
|
||||
|
||||
ctxInc =
|
||||
(availableL && (c1->log2CbSize < c0->log2CbSize))
|
||||
+ (availableA && (c2->log2CbSize < c0->log2CbSize));
|
||||
}
|
||||
|
||||
return DD(BS_HEVC::SPLIT_CU_FLAG, ctxInc);
|
||||
}
|
||||
|
||||
bool CABAC::CuSkipFlag(Bs16s x0, Bs16s y0)
|
||||
{
|
||||
//FL cMax = 1
|
||||
//9.3.4.2.2
|
||||
bool availableL = AvailableZs(x0, y0, x0 - 1, y0);
|
||||
bool availableA = AvailableZs(x0, y0, x0, y0 - 1);
|
||||
|
||||
CU* c1 = nullptr;
|
||||
if (availableL)
|
||||
{
|
||||
c1 = GetCU(x0 - 1, y0);
|
||||
if (!c1)
|
||||
throw InvalidSyntax();
|
||||
}
|
||||
|
||||
CU* c2 = nullptr;
|
||||
if (availableA)
|
||||
{
|
||||
c2 = GetCU(x0, y0 - 1);
|
||||
if (!c2)
|
||||
throw InvalidSyntax();
|
||||
}
|
||||
|
||||
Bs16u ctxInc =
|
||||
(availableL && (c1->PredMode == MODE_SKIP))
|
||||
+ (availableA && (c2->PredMode == MODE_SKIP));
|
||||
|
||||
return DD(BS_HEVC::CU_SKIP_FLAG, ctxInc);
|
||||
}
|
||||
|
||||
Bs8u CABAC::PartMode(bool intra, Bs16u log2CbSize)
|
||||
{
|
||||
//9.3.3.6 (xCb, yCb ) = (x0, y0), log2CbSize
|
||||
// 0 1 (3 - (log2CbSize == MinCbLog2SizeY)) bypass
|
||||
bool b = DD(BS_HEVC::PART_MODE);
|
||||
|
||||
if (intra)
|
||||
return b ? PART_2Nx2N : PART_NxN;
|
||||
|
||||
if (b)
|
||||
return PART_2Nx2N;
|
||||
|
||||
b = DD(BS_HEVC::PART_MODE, 1);
|
||||
|
||||
if (log2CbSize == MinCbLog2SizeY)
|
||||
{
|
||||
if (b)
|
||||
return PART_2NxN;
|
||||
|
||||
if (log2CbSize == 3)
|
||||
return PART_Nx2N;
|
||||
|
||||
b = DD(BS_HEVC::PART_MODE, 2);
|
||||
|
||||
return b ? PART_Nx2N : PART_NxN;
|
||||
}
|
||||
|
||||
if (!m_cSlice->sps->amp_enabled_flag)
|
||||
return b ? PART_2NxN : PART_Nx2N;
|
||||
|
||||
bool v = b;
|
||||
|
||||
b = DD(BS_HEVC::PART_MODE, 3);
|
||||
|
||||
if (b)
|
||||
return v ? PART_2NxN : PART_Nx2N;
|
||||
|
||||
b = DB();
|
||||
|
||||
if (v)
|
||||
return b ? PART_2NxnD : PART_2NxnU;
|
||||
|
||||
return b ? PART_nRx2N : PART_nLx2N;
|
||||
}
|
||||
|
||||
Bs8u CABAC::MpmIdx()
|
||||
{
|
||||
//TR cMax = 2, cRiceParam = 0
|
||||
//bypass, bypass
|
||||
BinCount++;
|
||||
if (!DecodeBypass())
|
||||
return 0;
|
||||
|
||||
BinCount++;
|
||||
return DecodeBypass() + 1;
|
||||
}
|
||||
|
||||
Bs8u CABAC::IntraChromaPredMode()
|
||||
{
|
||||
//9.3.3.7
|
||||
//0 bypass bypass na na na
|
||||
if (!DD(BS_HEVC::INTRA_CHROMA_PRED_MODE))
|
||||
return 4;
|
||||
|
||||
BinCount += 2;
|
||||
Bs8u b = (DecodeBypass() << 1);
|
||||
|
||||
return b | DecodeBypass();
|
||||
}
|
||||
|
||||
Bs8u CABAC::MergeIdx()
|
||||
{
|
||||
//TR cMax = MaxNumMergeCand - 1, cRiceParam = 0
|
||||
//0 bypass bypass bypass na na
|
||||
Bs32s cMax = m_cSlice->MaxNumMergeCand - 1;
|
||||
Bs8u binIdx = 0;
|
||||
|
||||
if (cMax > 0)
|
||||
{
|
||||
if (!DD(BS_HEVC::MERGE_IDX))
|
||||
return 0;
|
||||
binIdx++;
|
||||
}
|
||||
|
||||
while (binIdx < cMax)
|
||||
{
|
||||
if (!DecodeBypass())
|
||||
{
|
||||
BinCount += binIdx + 1;
|
||||
return binIdx;
|
||||
}
|
||||
|
||||
binIdx++;
|
||||
}
|
||||
|
||||
BinCount += binIdx;
|
||||
|
||||
return binIdx;
|
||||
}
|
||||
|
||||
Bs8u CABAC::InterPredIdc(Bs16u nPbW, Bs16u nPbH, Bs16u CtDepth)
|
||||
{
|
||||
//9.3.3.8 nPbW, nPbH
|
||||
//( nPbW + nPbH ) != 12 ? CtDepth[x0][y0] : 4 4 na na na na
|
||||
|
||||
if (nPbW + nPbH != 12)
|
||||
{
|
||||
if (DD(BS_HEVC::INTER_PRED_IDC, CtDepth))
|
||||
return PRED_BI;
|
||||
}
|
||||
|
||||
if (DD(BS_HEVC::INTER_PRED_IDC, 4))
|
||||
return PRED_L1;
|
||||
|
||||
return PRED_L0;
|
||||
}
|
||||
|
||||
Bs8u CABAC::RefIdxL0()
|
||||
{
|
||||
//TR cMax = num_ref_idx_l0_active_minus1, cRiceParam = 0
|
||||
//0 1 bypass bypass bypass bypass
|
||||
Bs32s cMax = m_cSlice->num_ref_idx_l0_active - 1;
|
||||
Bs8u binIdx = 0;
|
||||
|
||||
if (cMax > 0)
|
||||
{
|
||||
if (!DD(BS_HEVC::REF_IDX_LX))
|
||||
return 0;
|
||||
binIdx++;
|
||||
}
|
||||
|
||||
if (binIdx < cMax)
|
||||
{
|
||||
if (!DD(BS_HEVC::REF_IDX_LX, 1))
|
||||
return binIdx;
|
||||
binIdx++;
|
||||
}
|
||||
|
||||
while (binIdx < cMax)
|
||||
{
|
||||
if (!DecodeBypass())
|
||||
{
|
||||
BinCount += binIdx;
|
||||
return binIdx;
|
||||
}
|
||||
binIdx++;
|
||||
}
|
||||
|
||||
BinCount += binIdx - 1;
|
||||
|
||||
return binIdx;
|
||||
}
|
||||
|
||||
Bs8u CABAC::RefIdxL1()
|
||||
{
|
||||
//TR cMax = num_ref_idx_l1_active_minus1, cRiceParam = 0
|
||||
//0 1 bypass bypass bypass bypass
|
||||
Bs32s cMax = m_cSlice->num_ref_idx_l1_active - 1;
|
||||
Bs8u binIdx = 0;
|
||||
|
||||
if (cMax > 0)
|
||||
{
|
||||
if (!DD(BS_HEVC::REF_IDX_LX))
|
||||
return 0;
|
||||
binIdx++;
|
||||
}
|
||||
|
||||
if (binIdx < cMax)
|
||||
{
|
||||
if (!DD(BS_HEVC::REF_IDX_LX, 1))
|
||||
return binIdx;
|
||||
binIdx++;
|
||||
}
|
||||
|
||||
while (binIdx < cMax)
|
||||
{
|
||||
if (!DecodeBypass())
|
||||
{
|
||||
BinCount += binIdx;
|
||||
return binIdx;
|
||||
}
|
||||
binIdx++;
|
||||
}
|
||||
|
||||
BinCount += binIdx - 1;
|
||||
|
||||
return binIdx;
|
||||
}
|
||||
|
||||
Bs16u CABAC::CuQpDeltaAbs()
|
||||
{
|
||||
//9.3.3.9
|
||||
//0 1 1 1 1 bypass
|
||||
Bs16u k = 0, v0 = 0, v1 = 0, b;
|
||||
|
||||
while (v0 < 5)
|
||||
{
|
||||
if (!DecodeDecision(CtxState(BS_HEVC::CU_QP_DELTA_ABS, !!v0)))
|
||||
{
|
||||
BinCount += v0;
|
||||
return v0;
|
||||
}
|
||||
v0++;
|
||||
}
|
||||
|
||||
while (DecodeBypass())
|
||||
{
|
||||
v0 += (1 << k);
|
||||
k++;
|
||||
}
|
||||
|
||||
BinCount += k * 2 + 1;
|
||||
|
||||
while (k--)
|
||||
{
|
||||
b = DecodeBypass();
|
||||
v1 |= (b << k);
|
||||
}
|
||||
|
||||
return (v0 + v1);
|
||||
}
|
||||
|
||||
Bs8u CABAC::CuChromaQpOffsetIdx()
|
||||
{
|
||||
//TR cMax = chroma_qp_offset_list_len_minus1, cRiceParam = 0
|
||||
//0 0 0 0 0 na
|
||||
Bs32s cMax = m_cSlice->pps->chroma_qp_offset_list_len_minus1;
|
||||
Bs8u binIdx = 0;
|
||||
|
||||
while (binIdx < cMax)
|
||||
{
|
||||
if (!DecodeDecision(CtxState(BS_HEVC::CU_CHROMA_QP_OFFSET_IDX)))
|
||||
{
|
||||
BinCount += binIdx + 1;
|
||||
return binIdx;
|
||||
}
|
||||
|
||||
binIdx++;
|
||||
}
|
||||
|
||||
BinCount += binIdx;
|
||||
|
||||
return binIdx;
|
||||
}
|
||||
|
||||
Bs8u CABAC::Log2ResScaleAbsPlus1(Bs16u c)
|
||||
{
|
||||
//TR cMax = 4, cRiceParam = 0
|
||||
//4 * c + 0, 4 * c + 1, 4 * c + 2, 4 * c + 3, na, na
|
||||
Bs8u binIdx = 0;
|
||||
|
||||
while (binIdx < 4)
|
||||
{
|
||||
if (!DecodeDecision(CtxState(BS_HEVC::LOG2_RES_SCALE_ABS_PLUS1, 4 * c + binIdx)))
|
||||
{
|
||||
BinCount += binIdx + 1;
|
||||
return binIdx;
|
||||
}
|
||||
binIdx++;
|
||||
}
|
||||
|
||||
BinCount += binIdx;
|
||||
|
||||
return binIdx;
|
||||
}
|
||||
|
||||
Bs8u CABAC::LastSigCoeffXPrefix(Bs16u cIdx, Bs16u log2TrafoSize)
|
||||
{
|
||||
//TR cMax = ( log2TrafoSize << 1 ) - 1, cRiceParam = 0
|
||||
//0..17 (clause 9.3.4.2.3)
|
||||
Bs32u cMax = (log2TrafoSize << 1) - 1;
|
||||
Bs32u binIdx = 0;
|
||||
Bs16u ctxOffset;
|
||||
Bs16u ctxShift;
|
||||
|
||||
m_g1I = -1;
|
||||
m_rI = -1;
|
||||
|
||||
if (cIdx == 0)
|
||||
{
|
||||
ctxOffset = 3 * (log2TrafoSize - 2) + ((log2TrafoSize - 1) >> 2);
|
||||
ctxShift = ((log2TrafoSize + 1) >> 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
ctxOffset = 15;
|
||||
ctxShift = log2TrafoSize - 2;
|
||||
}
|
||||
|
||||
while (binIdx < cMax)
|
||||
{
|
||||
if (!DecodeDecision(CtxState(BS_HEVC::LAST_SIG_COEFF_X_PREFIX, (binIdx >> ctxShift) + ctxOffset)))
|
||||
{
|
||||
BinCount += binIdx + 1;
|
||||
return binIdx;
|
||||
}
|
||||
|
||||
binIdx++;
|
||||
}
|
||||
|
||||
BinCount += binIdx;
|
||||
|
||||
return binIdx;
|
||||
}
|
||||
|
||||
Bs8u CABAC::LastSigCoeffYPrefix(Bs16u cIdx, Bs16u log2TrafoSize)
|
||||
{
|
||||
//TR cMax = ( log2TrafoSize << 1 ) - 1, cRiceParam = 0
|
||||
//0..17 (clause 9.3.4.2.3)
|
||||
Bs32u cMax = (log2TrafoSize << 1) - 1;
|
||||
Bs32u binIdx = 0;
|
||||
Bs16u ctxOffset;
|
||||
Bs16u ctxShift;
|
||||
|
||||
if (cIdx == 0)
|
||||
{
|
||||
ctxOffset = 3 * (log2TrafoSize - 2) + ((log2TrafoSize - 1) >> 2);
|
||||
ctxShift = ((log2TrafoSize + 1) >> 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
ctxOffset = 15;
|
||||
ctxShift = log2TrafoSize - 2;
|
||||
}
|
||||
|
||||
while (binIdx < cMax)
|
||||
{
|
||||
if (!DecodeDecision(CtxState(BS_HEVC::LAST_SIG_COEFF_Y_PREFIX, (binIdx >> ctxShift) + ctxOffset)))
|
||||
{
|
||||
BinCount += binIdx + 1;
|
||||
return binIdx;
|
||||
}
|
||||
|
||||
binIdx++;
|
||||
}
|
||||
|
||||
BinCount += binIdx;
|
||||
|
||||
return binIdx;
|
||||
}
|
||||
|
||||
Bs32u CABAC::LastSigCoeffXSuffix(Bs16u prefix)
|
||||
{
|
||||
//FL cMax = ( 1 << ( ( last_sig_coeff_x_prefix >> 1 ) - 1 ) - 1 )
|
||||
//bypass bypass bypass bypass bypass bypass
|
||||
Bs32u b = 0;
|
||||
|
||||
prefix = CeilLog2(1 << ((prefix >> 1) - 1));
|
||||
|
||||
BinCount += prefix;
|
||||
|
||||
while (prefix--)
|
||||
b = (b << 1) | DecodeBypass();
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
bool CABAC::CoeffAbsLevelGreater1Flag(Bs16u cIdx, Bs16u i)
|
||||
{
|
||||
//FL cMax = 1
|
||||
//9.3.4.2.6
|
||||
auto& greater1Ctx = lastGreater1Ctx;
|
||||
Bs16s ctxInc;
|
||||
|
||||
if (m_g1I != i)
|
||||
{
|
||||
if (i == 0 || cIdx > 0)
|
||||
ctxSet = 0;
|
||||
else
|
||||
ctxSet = 2;
|
||||
|
||||
if (m_g1I < 0)
|
||||
{
|
||||
lastGreater1Ctx = 1;
|
||||
}
|
||||
else if (lastGreater1Ctx > 0)
|
||||
{
|
||||
if (lastGreater1Flag)
|
||||
lastGreater1Ctx = 0;
|
||||
else
|
||||
lastGreater1Ctx++;
|
||||
}
|
||||
|
||||
if (lastGreater1Ctx == 0)
|
||||
ctxSet++;
|
||||
|
||||
greater1Ctx = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (greater1Ctx > 0)
|
||||
{
|
||||
if (lastGreater1Flag)
|
||||
greater1Ctx = 0;
|
||||
else
|
||||
greater1Ctx++;
|
||||
}
|
||||
}
|
||||
|
||||
m_g1I = i;
|
||||
ctxInc = (ctxSet * 4) + BS_MIN(3, greater1Ctx);
|
||||
|
||||
if (cIdx > 0)
|
||||
ctxInc += 16;
|
||||
|
||||
lastGreater1Flag = DD(BS_HEVC::COEFF_ABS_LEVEL_GREATER1_FLAG, ctxInc);
|
||||
|
||||
return lastGreater1Flag;
|
||||
}
|
||||
|
||||
Bs32u CABAC::CoeffAbsLevelRemaining(Bs16u i, Bs16u baseLevel, Bs16u cIdx, CU& cu, TU& tu)
|
||||
{
|
||||
//9.3.3.10 current sub-block scan index i, baseLevel
|
||||
//bypass bypass bypass bypass bypass bypass
|
||||
auto& sps = *m_cSlice->sps;
|
||||
auto& cAbsLevel = cLastAbsLevel;
|
||||
auto& cRiceParam = cLastRiceParam;
|
||||
Bs16u initRiceValue, sbType = 0;
|
||||
Bs32u b = 0, cMax, k, v0, v1;
|
||||
|
||||
if (sps.persistent_rice_adaptation_enabled_flag)
|
||||
{
|
||||
if ( (tu.transform_skip_flag & (1 << cIdx)) == 0
|
||||
&& cu.transquant_bypass_flag == 0)
|
||||
{
|
||||
sbType = 2 * !cIdx;
|
||||
}
|
||||
else
|
||||
{
|
||||
sbType = 2 * !cIdx + 1;
|
||||
}
|
||||
|
||||
initRiceValue = StatCoeff[sbType] / 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
initRiceValue = 0;
|
||||
}
|
||||
|
||||
if (i != m_rI)
|
||||
{
|
||||
cLastAbsLevel = 0;
|
||||
cLastRiceParam = initRiceValue;
|
||||
}
|
||||
|
||||
cRiceParam = cLastRiceParam + (cLastAbsLevel > (3u * (1u << cLastRiceParam)));
|
||||
|
||||
if (sps.persistent_rice_adaptation_enabled_flag == 0)
|
||||
cRiceParam = BS_MIN(cRiceParam, 4);
|
||||
|
||||
cMax = 4 << cRiceParam;
|
||||
|
||||
while (b < 4)
|
||||
{
|
||||
if (!DecodeBypass())
|
||||
{
|
||||
BinCount++;
|
||||
break;
|
||||
}
|
||||
|
||||
b++;
|
||||
}
|
||||
|
||||
BinCount += b;
|
||||
|
||||
if (b < 4)
|
||||
{
|
||||
for (Bs16u c = 0; c < cRiceParam; c++)
|
||||
b = ((b << 1) | DecodeBypass());
|
||||
|
||||
BinCount += cRiceParam;
|
||||
}
|
||||
else if (sps.persistent_rice_adaptation_enabled_flag == 0)
|
||||
{
|
||||
b = EGkBypass(cRiceParam + 1) + cMax;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Limited EGk
|
||||
Bs16u log2TransformRange = (cIdx == 0) ? BS_MAX(15, BitDepthY + 6) : BS_MAX(15, BitDepthC + 6);
|
||||
Bs16u maxPrefixExtensionLength = 28 - log2TransformRange;
|
||||
|
||||
k = cRiceParam + 1;
|
||||
b = 0;
|
||||
v0 = 0;
|
||||
v1 = 0;
|
||||
|
||||
while (b < maxPrefixExtensionLength && DecodeBypass())
|
||||
b++;
|
||||
|
||||
v0 = (((1 << b) - 1) << k);
|
||||
|
||||
if (b == maxPrefixExtensionLength)
|
||||
{
|
||||
k = log2TransformRange;
|
||||
BinCount += b + k;
|
||||
}
|
||||
else
|
||||
{
|
||||
k += b;
|
||||
BinCount += b + k + 1;
|
||||
}
|
||||
|
||||
while (k--)
|
||||
{
|
||||
b = DecodeBypass();
|
||||
v1 |= (b << k);
|
||||
}
|
||||
|
||||
b = v0 + v1 + cMax;
|
||||
}
|
||||
|
||||
if (sps.persistent_rice_adaptation_enabled_flag && i != m_rI)
|
||||
{
|
||||
if (b >= (3u << (StatCoeff[sbType] / 4)))
|
||||
StatCoeff[sbType]++;
|
||||
else if (2 * b < (1u << (StatCoeff[sbType] / 4)) && StatCoeff[sbType] > 0)
|
||||
StatCoeff[sbType]--;
|
||||
}
|
||||
|
||||
m_rI = i;
|
||||
cAbsLevel = baseLevel + b;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
Bs32u CABAC::EGkBypass(Bs32u k)
|
||||
{
|
||||
//EGk
|
||||
//bypass bypass bypass bypass bypass bypass
|
||||
Bs32u v0 = 0, v1 = 0, b;
|
||||
|
||||
while (DecodeBypass())
|
||||
{
|
||||
v0 |= (1 << k);
|
||||
k++;
|
||||
BinCount++;
|
||||
}
|
||||
|
||||
BinCount += k;
|
||||
|
||||
while (k--)
|
||||
{
|
||||
b = DecodeBypass();
|
||||
v1 |= (b << k);
|
||||
}
|
||||
|
||||
return (v0 + v1);
|
||||
}
|
||||
|
||||
Bs16u CABAC::NewPaletteEntries(Bs16u cIdx)
|
||||
{
|
||||
//FL cMax = cIdx == 0 ? ((1 << BitDepthY) - 1) : ((1 << BitDepthC) - 1)
|
||||
//bypass bypass bypass bypass bypass bypass
|
||||
Bs16u b = 0;
|
||||
Bs32u n = (cIdx == 0) ? BitDepthY : BitDepthC;
|
||||
|
||||
BinCount += n;
|
||||
|
||||
while (n--)
|
||||
b = (b << 1) | DecodeBypass();
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
Bs16u CABAC::NumPaletteIndices(Bs16u MaxPaletteIndex)
|
||||
{
|
||||
//9.3.3.14
|
||||
//bypass bypass bypass bypass bypass bypass
|
||||
Bs16u cRiceParam = 3 + ((MaxPaletteIndex + 1) >> 3);
|
||||
Bs16u cMax = 4 << cRiceParam;
|
||||
Bs16u prefixVal = 0;
|
||||
|
||||
m_paletteIdxCnt = 0;
|
||||
|
||||
while (prefixVal < 4 && DecodeBypass())
|
||||
{
|
||||
prefixVal++;
|
||||
BinCount++;
|
||||
}
|
||||
|
||||
if (prefixVal == 4)
|
||||
return EGkBypass(cRiceParam + 1) + cMax + 1;
|
||||
|
||||
BinCount += cRiceParam;
|
||||
|
||||
while (cRiceParam--)
|
||||
prefixVal = (prefixVal << 1) | DecodeBypass();
|
||||
|
||||
return prefixVal + 1;
|
||||
}
|
||||
|
||||
Bs32u CABAC::TBBypass(Bs32u cMax)
|
||||
{
|
||||
//TB
|
||||
//bypass bypass bypass bypass bypass bypass
|
||||
Bs32u n = cMax + 1;
|
||||
Bs32u k = (Bs16u)FloorLog2(n);
|
||||
Bs32u u = (1 << (k + 1)) - n;
|
||||
Bs32u v = 0;
|
||||
|
||||
BinCount += k;
|
||||
|
||||
while (k--)
|
||||
v = (v << 1) | DecodeBypass();
|
||||
|
||||
if (v < u)
|
||||
return v;
|
||||
|
||||
BinCount++;
|
||||
v = (v << 1) | DecodeBypass();
|
||||
|
||||
return (v - u);
|
||||
}
|
||||
|
||||
Bs16u CABAC::PaletteRunPrefix(Bs16u PaletteMaxRun, bool copy_above_palette_indices_flag, Bs16u palette_index_idc)
|
||||
{
|
||||
//TR cMax = Floor(Log2(PaletteMaxRun)) + 1, cRiceParam = 0
|
||||
//0..7 (clause 9.3.4.2.8)
|
||||
Bs16u cMax = FloorLog2(PaletteMaxRun) + 1;
|
||||
Bs16u v = 0;
|
||||
auto NextBin = [&](Bs16u ctxInc) -> bool
|
||||
{
|
||||
if (!DD(BS_HEVC::PALETTE_RUN_PREFIX, ctxInc))
|
||||
return false;
|
||||
return (++v < cMax);
|
||||
};
|
||||
|
||||
if (copy_above_palette_indices_flag)
|
||||
{
|
||||
//5 6 6 7 7 bypass
|
||||
if (!NextBin(5)) return v;
|
||||
if (!NextBin(6)) return v;
|
||||
if (!NextBin(6)) return v;
|
||||
if (!NextBin(7)) return v;
|
||||
if (!NextBin(7)) return v;
|
||||
}
|
||||
else
|
||||
{
|
||||
//(0,1,2) 3 3 4 4 bypass
|
||||
if (!NextBin((palette_index_idc < 1) ? 0 : ((palette_index_idc < 3) ? 1 : 2)))
|
||||
return v;
|
||||
if (!NextBin(3)) return v;
|
||||
if (!NextBin(3)) return v;
|
||||
if (!NextBin(4)) return v;
|
||||
if (!NextBin(4)) return v;
|
||||
}
|
||||
|
||||
while (DecodeBypass() && (++v < cMax));
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
Bs16u CABAC::PaletteEscapeVal(Bs16u cIdx, bool cu_transquant_bypass_flag)
|
||||
{
|
||||
//9.3.3.12 cIdx, cu_transquant_bypass_flag
|
||||
//bypass bypass bypass bypass bypass bypass
|
||||
|
||||
if (cu_transquant_bypass_flag)
|
||||
{
|
||||
//FL ( 1 << bitdepth ) - 1
|
||||
Bs16u bd = (cIdx == 0) ? BitDepthY : BitDepthC;
|
||||
Bs16u v = 0;
|
||||
|
||||
BinCount += bd;
|
||||
|
||||
while (bd--)
|
||||
v = (v << 1) | DecodeBypass();
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
return (Bs16u)EGkBypass(3);
|
||||
}
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,201 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "hevc2_trace.h"
|
||||
#include "hevc2_struct.h"
|
||||
#include <stdio.h>
|
||||
|
||||
namespace BS_HEVC2
|
||||
{
|
||||
|
||||
const char NaluTraceMap[64][16] =
|
||||
{
|
||||
"TRAIL_N", "TRAIL_R", "TSA_N", "TSA_R",
|
||||
"STSA_N", "STSA_R", "RADL_N", "RADL_R",
|
||||
"RASL_N", "RASL_R", "RSV_VCL_N10", "RSV_VCL_R11",
|
||||
"RSV_VCL_N12", "RSV_VCL_R13", "RSV_VCL_N14", "RSV_VCL_R15",
|
||||
"BLA_W_LP", "BLA_W_RADL", "BLA_N_LP", "IDR_W_RADL",
|
||||
"IDR_N_LP", "CRA_NUT", "RSV_IRAP_VCL22", "RSV_IRAP_VCL23",
|
||||
"RSV_VCL24", "RSV_VCL25", "RSV_VCL26", "RSV_VCL27",
|
||||
"RSV_VCL28", "RSV_VCL29", "RSV_VCL30", "RSV_VCL31",
|
||||
"VPS_NUT", "SPS_NUT", "PPS_NUT", "AUD_NUT",
|
||||
"EOS_NUT", "EOB_NUT", "FD_NUT", "PREFIX_SEI_NUT",
|
||||
"SUFFIX_SEI_NUT", "RSV_NVCL41", "RSV_NVCL42", "RSV_NVCL43",
|
||||
"RSV_NVCL44", "RSV_NVCL45", "RSV_NVCL46", "RSV_NVCL47",
|
||||
"UNSPEC48", "UNSPEC49", "UNSPEC50", "UNSPEC51",
|
||||
"UNSPEC52", "UNSPEC53", "UNSPEC54", "UNSPEC55",
|
||||
"UNSPEC56", "UNSPEC57", "UNSPEC58", "UNSPEC59",
|
||||
"UNSPEC60", "UNSPEC61", "UNSPEC62", "UNSPEC63"
|
||||
};
|
||||
|
||||
const char PicTypeTraceMap[3][4] =
|
||||
{
|
||||
"I", "PI", "BPI"
|
||||
};
|
||||
|
||||
const char ProfileTraceMap::map[11][12] =
|
||||
{
|
||||
"UNKNOWN", "MAIN", "MAIN_10", "MAIN_SP",
|
||||
"REXT", "REXT_HT", "MAIN_SV", "MAIN_SC",
|
||||
"MAIN_3D", "SCC", "REXT_SC"
|
||||
};
|
||||
|
||||
const char* ProfileTraceMap::operator[] (unsigned int i)
|
||||
{
|
||||
return map[(i < (sizeof(map) / sizeof(map[0]))) ? i : 0];
|
||||
}
|
||||
|
||||
const char ChromaFormatTraceMap[4][12] =
|
||||
{
|
||||
"CHROMA_400", "CHROMA_420", "CHROMA_422", "CHROMA_444"
|
||||
};
|
||||
|
||||
const char ARIdcTraceMap::map[19][16] =
|
||||
{
|
||||
"Unspecified",
|
||||
"1:1", "12:11", "10:11", "16:11",
|
||||
"40:33", "24:11", "20:11", "32:11",
|
||||
"80:33", "18:11", "15:11", "64:33",
|
||||
"160:99", "4:3", "3:2", "2:1",
|
||||
"Reserved",
|
||||
"Extended_SAR"
|
||||
};
|
||||
|
||||
const char* ARIdcTraceMap::operator[] (unsigned int i)
|
||||
{
|
||||
if (i < 17)
|
||||
return map[i];
|
||||
if (i == Extended_SAR)
|
||||
return map[18];
|
||||
return map[17];
|
||||
}
|
||||
|
||||
const char VideoFormatTraceMap[6][12] =
|
||||
{
|
||||
"Component", "PAL", "NTSC", "SECAM", "MAC", "Unspecified"
|
||||
};
|
||||
|
||||
const char* SEITypeTraceMap::operator[] (unsigned int i)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case SEI_BUFFERING_PERIOD : return "SEI_BUFFERING_PERIOD";
|
||||
case SEI_PICTURE_TIMING : return "SEI_PICTURE_TIMING";
|
||||
case SEI_PAN_SCAN_RECT : return "SEI_PAN_SCAN_RECT";
|
||||
case SEI_FILLER_PAYLOAD : return "SEI_FILLER_PAYLOAD";
|
||||
case SEI_USER_DATA_REGISTERED_ITU_T_T35 : return "SEI_USER_DATA_REGISTERED_ITU_T_T35";
|
||||
case SEI_USER_DATA_UNREGISTERED : return "SEI_USER_DATA_UNREGISTERED";
|
||||
case SEI_RECOVERY_POINT : return "SEI_RECOVERY_POINT";
|
||||
case SEI_SCENE_INFO : return "SEI_SCENE_INFO";
|
||||
case SEI_FULL_FRAME_SNAPSHOT : return "SEI_FULL_FRAME_SNAPSHOT";
|
||||
case SEI_PROGRESSIVE_REFINEMENT_SEGMENT_START: return "SEI_PROGRESSIVE_REFINEMENT_SEGMENT_START";
|
||||
case SEI_PROGRESSIVE_REFINEMENT_SEGMENT_END : return "SEI_PROGRESSIVE_REFINEMENT_SEGMENT_END";
|
||||
case SEI_FILM_GRAIN_CHARACTERISTICS : return "SEI_FILM_GRAIN_CHARACTERISTICS";
|
||||
case SEI_POST_FILTER_HINT : return "SEI_POST_FILTER_HINT";
|
||||
case SEI_TONE_MAPPING_INFO : return "SEI_TONE_MAPPING_INFO";
|
||||
case SEI_FRAME_PACKING : return "SEI_FRAME_PACKING";
|
||||
case SEI_DISPLAY_ORIENTATION : return "SEI_DISPLAY_ORIENTATION";
|
||||
case SEI_SOP_DESCRIPTION : return "SEI_SOP_DESCRIPTION";
|
||||
case SEI_ACTIVE_PARAMETER_SETS : return "SEI_ACTIVE_PARAMETER_SETS";
|
||||
case SEI_DECODING_UNIT_INFO : return "SEI_DECODING_UNIT_INFO";
|
||||
case SEI_TEMPORAL_LEVEL0_INDEX : return "SEI_TEMPORAL_LEVEL0_INDEX";
|
||||
case SEI_DECODED_PICTURE_HASH : return "SEI_DECODED_PICTURE_HASH";
|
||||
case SEI_SCALABLE_NESTING : return "SEI_SCALABLE_NESTING";
|
||||
case SEI_REGION_REFRESH_INFO : return "SEI_REGION_REFRESH_INFO";
|
||||
case SEI_NO_DISPLAY : return "SEI_NO_DISPLAY";
|
||||
case SEI_TIME_CODE : return "SEI_TIME_CODE";
|
||||
case SEI_MASTERING_DISPLAY_COLOUR_VOLUME : return "SEI_MASTERING_DISPLAY_COLOUR_VOLUME";
|
||||
case SEI_SEGM_RECT_FRAME_PACKING : return "SEI_SEGM_RECT_FRAME_PACKING";
|
||||
case SEI_TEMP_MOTION_CONSTRAINED_TILE_SETS : return "SEI_TEMP_MOTION_CONSTRAINED_TILE_SETS";
|
||||
case SEI_CHROMA_RESAMPLING_FILTER_HINT : return "SEI_CHROMA_RESAMPLING_FILTER_HINT";
|
||||
case SEI_KNEE_FUNCTION_INFO : return "SEI_KNEE_FUNCTION_INFO";
|
||||
case SEI_COLOUR_REMAPPING_INFO : return "SEI_COLOUR_REMAPPING_INFO";
|
||||
default : return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
const char PicStructTraceMap[13][12] =
|
||||
{
|
||||
"FRAME", "TOP", "BOT", "TOP_BOT",
|
||||
"BOT_TOP", "TOP_BOT_TOP", "BOT_TOP_BOT", "FRAME_x2",
|
||||
"FRAME_x3", "TOP_PREVBOT", "BOT_PREVTOP", "TOP_NEXTBOT",
|
||||
"BOT_NEXTTOP"
|
||||
};
|
||||
|
||||
const char ScanTypeTraceMap[4][12] =
|
||||
{
|
||||
"INTERLACED", "PROGRESSIVE", "UNKNOWN", "RESERVED"
|
||||
};
|
||||
|
||||
const char SliceTypeTraceMap[4][2] =
|
||||
{
|
||||
"B", "P", "I", "?"
|
||||
};
|
||||
|
||||
const char* RPLTraceMap::operator[] (const RefPic& r)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
sprintf
|
||||
#else
|
||||
sprintf_s
|
||||
#endif
|
||||
(m_buf, "POC: %4d LT: %d Used: %d Lost: %d", r.POC, r.long_term, r.used, r.lost);
|
||||
return m_buf;
|
||||
}
|
||||
|
||||
const char PredModeTraceMap[3][6] =
|
||||
{
|
||||
"INTER", "INTRA", "SKIP"
|
||||
};
|
||||
|
||||
const char PartModeTraceMap[8][12] =
|
||||
{
|
||||
"PART_2Nx2N",
|
||||
"PART_2NxN",
|
||||
"PART_Nx2N",
|
||||
"PART_NxN",
|
||||
"PART_2NxnU",
|
||||
"PART_2NxnD",
|
||||
"PART_nLx2N",
|
||||
"PART_nRx2N"
|
||||
};
|
||||
|
||||
const char IntraPredModeTraceMap[35][9] =
|
||||
{
|
||||
"Planar", "DC",
|
||||
"225\xF8", "230.625\xF8", "236.25\xF8", "241.875\xF8", "247.5\xF8", "253.125\xF8", "258.75\xF8", "264.375\xF8",
|
||||
"270\xF8", "275.625\xF8", "281.25\xF8", "286.875\xF8", "292.5\xF8", "298.125\xF8", "303.75\xF8", "309.375\xF8",
|
||||
"315\xF8", "320.625\xF8", "326.25\xF8", "331.875\xF8", "337.5\xF8", "343.125\xF8", "348.75\xF8", "354.375\xF8",
|
||||
"0\xF8", "5.625\xF8", "11.25\xF8", " 16.875\xF8", "22.5\xF8", "28.125\xF8", "33.75\xF8", "39.375\xF8",
|
||||
"45\xF8"
|
||||
};
|
||||
|
||||
const char SAOTypeTraceMap[3][5] =
|
||||
{
|
||||
"N/A", "Band", "Edge"
|
||||
};
|
||||
|
||||
const char EOClassTraceMap[4][5] =
|
||||
{
|
||||
"0\xF8", "90\xF8", "135\xF8", "45\xF8"
|
||||
};
|
||||
|
||||
|
||||
};
|
|
@ -1,577 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "hevc_cabac.h"
|
||||
|
||||
using namespace BS_HEVC;
|
||||
|
||||
HEVC_CABAC::HEVC_CABAC()
|
||||
: m_decPar(0)
|
||||
, m_lastGreater1Ctx(0)
|
||||
, m_ctxSet(0)
|
||||
, m_pCtx(NULL)
|
||||
, m_cAbsLevel(0)
|
||||
, m_cRiceParam(0)
|
||||
, m_cSBIdx(-1)
|
||||
, ivlCurrRange(510)
|
||||
, ivlOffset(0)
|
||||
{
|
||||
memset(CtxState, 0, sizeof(CtxState));
|
||||
initBins();
|
||||
|
||||
#ifdef HEVC_CABAC_STATE_TRACE
|
||||
m_cnt = 0;
|
||||
m_n = 0;
|
||||
flog = fopen(HEVC_CABAC_STATE_TRACE, "w");
|
||||
#endif //HEVC_CABAC_STATE_TRACE
|
||||
};
|
||||
|
||||
void HEVC_CABAC::initBins(){
|
||||
//m_binFL1.clear();
|
||||
m_binFL1.push_back(Bin(0,1));
|
||||
m_binFL1.push_back(Bin(1,1));
|
||||
|
||||
//m_binFL3.clear();
|
||||
m_binFL3.push_back(Bin(0,2));
|
||||
m_binFL3.push_back(Bin(1,2));
|
||||
m_binFL3.push_back(Bin(2,2));
|
||||
m_binFL3.push_back(Bin(3,2));
|
||||
|
||||
//m_binFL31.clear();
|
||||
for(Bs32u synVal = 0; synVal <= 31; synVal++)
|
||||
m_binFL31.push_back(Bin(synVal, 5));
|
||||
|
||||
for(Bs32u cMax = 0; cMax < binTRx0Size; cMax++){
|
||||
for(Bs32u synVal = 0; synVal <= cMax; synVal++)
|
||||
m_binTRx0[cMax].push_back(TR(synVal, cMax, 0));
|
||||
}
|
||||
|
||||
//m_binICPM.clear();
|
||||
m_binICPM.push_back(Bin(4, 3));
|
||||
m_binICPM.push_back(Bin(5, 3));
|
||||
m_binICPM.push_back(Bin(6, 3));
|
||||
m_binICPM.push_back(Bin(7, 3));
|
||||
m_binICPM.push_back(Bin(0, 1));
|
||||
|
||||
//m_binIPIDC0.clear();
|
||||
m_binIPIDC0.push_back(Bin(0, 2));
|
||||
m_binIPIDC0.push_back(Bin(1, 2));
|
||||
m_binIPIDC0.push_back(Bin(1, 1));
|
||||
}
|
||||
|
||||
#define Clip3(_min, _max, _x) BS_MIN(BS_MAX(_min, _x), _max)
|
||||
|
||||
void HEVC_CABAC::init_ctx(){
|
||||
Slice& slice = *m_pCtx->slice;
|
||||
Bs16u initType = 0;
|
||||
Bs16u SliceQpY = 26 + slice.pps->init_qp_minus26 + slice.slice_qp_delta;
|
||||
|
||||
if( slice.type == I )
|
||||
initType = 0;
|
||||
else if( slice.type == P )
|
||||
initType = slice.cabac_init_flag ? 2 : 1;
|
||||
else
|
||||
initType = slice.cabac_init_flag ? 1 : 2;
|
||||
|
||||
for(Bs16u idx = 0; idx < CtxTblSize; idx++){
|
||||
Bs16s initValue = CtxInitTbl[initType][idx];
|
||||
Bs16s m = (initValue >> 4) * 5 - 45;
|
||||
Bs16s n = ( (initValue & 15) << 3 ) - 16;
|
||||
Bs16s preCtxState = Clip3( 1, 126, ( ( m * Clip3( 0, 51, SliceQpY ) ) >> 4 ) + n );
|
||||
Bs8u valMps = ( preCtxState <= 63 ) ? 0 : 1;
|
||||
CtxState[idx] = ((valMps ? ( preCtxState - 64 ) : ( 63 - preCtxState )) << 1) | valMps;
|
||||
}
|
||||
}
|
||||
|
||||
void HEVC_CABAC::init_ade(){
|
||||
ivlCurrRange = 510;
|
||||
ivlOffset = read_bits(9);
|
||||
}
|
||||
|
||||
HEVC_CABAC::Bin HEVC_CABAC::TR(Bs32s synVal, Bs32u cMax, Bs32u cRiceParam){
|
||||
Bin bin(0, 0);
|
||||
Bs32u prefixVal = synVal >> cRiceParam;
|
||||
Bs32u suffixVal = synVal - ( ( prefixVal ) << cRiceParam );
|
||||
Bs32u cLen = (cMax >> cRiceParam);
|
||||
|
||||
if(prefixVal < cLen){
|
||||
bin.put(0xFFFFFFFF, prefixVal);
|
||||
bin.put(0);
|
||||
} else {
|
||||
bin.put(0xFFFFFFFF, cLen);
|
||||
}
|
||||
if(cRiceParam && cMax > (Bs32u)synVal)
|
||||
bin.put(suffixVal, cRiceParam);
|
||||
|
||||
return bin;
|
||||
}
|
||||
|
||||
HEVC_CABAC::Bin HEVC_CABAC::EGk(Bs32s synVal, Bs32u k){
|
||||
Bin bin(0, 0);
|
||||
Bs32u absV = BS_ABS(synVal);
|
||||
Bs8u stopLoop = 0;
|
||||
|
||||
do {
|
||||
if( absV >= Bs32u( 1 << k ) ) {
|
||||
bin.put( 1 );
|
||||
absV = absV - ( 1 << k );
|
||||
k++;
|
||||
} else {
|
||||
bin.put( 0 );
|
||||
while( k-- )
|
||||
bin.put( ( absV >> k ) & 1 );
|
||||
stopLoop = 1;
|
||||
}
|
||||
} while( !stopLoop );
|
||||
|
||||
return bin;
|
||||
}
|
||||
|
||||
HEVC_CABAC::Bin HEVC_CABAC::FL(Bs32s synVal, Bs32u cMax){
|
||||
Bs32u fixedLength = CeilLog2( cMax + 1 );
|
||||
Bin bin(synVal, fixedLength);
|
||||
return bin;
|
||||
}
|
||||
|
||||
HEVC_CABAC::Bins& HEVC_CABAC::PartModeBin(bool isIntra, Bs32u log2CbSize){
|
||||
Bins& b = m_binDefault;
|
||||
SPS& sps = *m_pCtx->slice->sps;
|
||||
|
||||
b.clear();
|
||||
b.push_back(Bin(1, 1));
|
||||
|
||||
if(isIntra){
|
||||
b.push_back(Bin(0, 1));
|
||||
} else {
|
||||
bool isMinSz = (log2CbSize == (sps.log2_min_luma_coding_block_size_minus3 + 3));
|
||||
|
||||
if(!isMinSz && sps.amp_enabled_flag){
|
||||
b.push_back(Bin(3, 3));
|
||||
} else {
|
||||
b.push_back(Bin(1, 2));
|
||||
}
|
||||
|
||||
if( (isMinSz && log2CbSize == 3)
|
||||
|| (!isMinSz && !sps.amp_enabled_flag)){
|
||||
b.push_back(Bin(0, 2));
|
||||
} else {
|
||||
b.push_back(Bin(1, 3));
|
||||
}
|
||||
if(isMinSz && log2CbSize > 3){
|
||||
b.push_back(Bin(0, 3));
|
||||
} else {
|
||||
b.push_back(Bin(0xFF, 16));//invalid
|
||||
}
|
||||
b.push_back(Bin(4, 4));
|
||||
b.push_back(Bin(5, 4));
|
||||
b.push_back(Bin(0, 4));
|
||||
b.push_back(Bin(1, 4));
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
HEVC_CABAC::Bins& HEVC_CABAC::CUQPDAbsBin (){
|
||||
Bins& b = m_binDefault;
|
||||
Bs32s maxVal = 26 + ((6 * m_pCtx->slice->sps->bit_depth_luma_minus8) / 2);
|
||||
|
||||
b.clear();
|
||||
|
||||
for(Bs32s i = 0; i <= maxVal; i++){
|
||||
Bs32u val = BS_MIN(i, 5);
|
||||
b.push_back( TR( val, 5, 0 ) );
|
||||
|
||||
if(val > 4){
|
||||
val = i - 5;
|
||||
Bin suffix = EGk(val, 0);
|
||||
b.back().put(suffix.get(), suffix.n);
|
||||
}
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
Bs32u HEVC_CABAC::decCAbsLvlR(Bs32s i, Bs32s baseLevel){
|
||||
Bs32u synVal = 0;
|
||||
Bin v(0,0);
|
||||
|
||||
if(i != m_cSBIdx){
|
||||
m_cAbsLevel = 0;
|
||||
m_cRiceParam = 0;
|
||||
m_cSBIdx = i;
|
||||
}
|
||||
|
||||
m_cRiceParam = BS_MIN( m_cRiceParam + ( m_cAbsLevel > ( 3 * ( 1 << m_cRiceParam ) ) ? 1 : 0 ), 4 );
|
||||
Bs32u cMax = (4 << m_cRiceParam);
|
||||
|
||||
while(v.n <= Bin::capacity){
|
||||
Bin b = TR( BS_MIN(cMax, synVal), cMax, m_cRiceParam );
|
||||
|
||||
if(b.n == 4 && b.get() == 0x0F){
|
||||
Bin suffix = EGk( synVal - cMax, m_cRiceParam + 1);
|
||||
b.put(suffix.get(), suffix.n);
|
||||
}
|
||||
|
||||
while(v.n < b.n){
|
||||
v.put(DecodeBypass());
|
||||
}
|
||||
|
||||
if(v.get() == b.get()){
|
||||
m_cAbsLevel = baseLevel + synVal;
|
||||
return synVal;
|
||||
}
|
||||
|
||||
synVal ++;
|
||||
}
|
||||
|
||||
return last_err = BS_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
Bs32u HEVC_CABAC::decAbsMvdMinus2(){
|
||||
Bin v(0,0);
|
||||
|
||||
for(Bs32u synVal = 0; synVal <= ((1<<15) - 2); synVal++){
|
||||
Bin b = EGk(synVal, 1);
|
||||
|
||||
while(v.n < b.n)
|
||||
v.put(DecodeBypass());
|
||||
|
||||
if(v.get() == b.get())
|
||||
return synVal;
|
||||
}
|
||||
|
||||
return last_err = BS_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
#define FL1(_bins, _val, _cmax) _bins.clear(); _bins.push_back( FL(_val, _cmax) );
|
||||
#define FL_FLAG(_bins) _bins.clear(); FL1(_bins, 0, 1); FL1(_bins, 1, 1);
|
||||
#define FL_RANGE(_bins, _max) _bins.clear(); for(Bs32s _i = 0; _i <= (_max); _i++){ _bins.push_back( FL(_i, (_max)) ); }
|
||||
#define TR_RANGE(_bins, _max, _rice) _bins.clear(); for(Bs32s _i = 0; _i <= (_max); _i++){ _bins.push_back( TR(_i, (_max), (_rice)) ); }
|
||||
#define EGK_RANGE(_bins, _max, _k) _bins.clear(); for(Bs32s _i = 0; _i <= (_max); _i++){ _bins.push_back( EGk(_i, (_k)) ); }
|
||||
#define TR_RANGE0(_bins, _max) if((Bs32s)(_max) < (Bs32s)binTRx0Size){ return m_binTRx0[(_max)]; } TR_RANGE(_bins, _max, 0)
|
||||
|
||||
HEVC_CABAC::Bins& HEVC_CABAC::GetBinarization(Bs16u se){
|
||||
Bins& b = m_binDefault;
|
||||
|
||||
switch(se){
|
||||
case END_OF_SLICE_SEGMENT_FLAG :
|
||||
case SAO_MERGE_LEFT_FLAG :
|
||||
/* = SAO_MERGE_UP_FLAG */
|
||||
case SAO_OFFSET_SIGN :
|
||||
case SPLIT_CU_FLAG :
|
||||
case CU_TRANSQUANT_BYPASS_FLAG :
|
||||
case CU_SKIP_FLAG :
|
||||
case PRED_MODE_FLAG :
|
||||
case PCM_FLAG :
|
||||
case RQT_ROOT_CBF :
|
||||
case PREV_INTRA_LUMA_PRED_FLAG :
|
||||
case MERGE_FLAG :
|
||||
case MVP_LX_FLAG :
|
||||
case SPLIT_TRANSFORM_FLAG :
|
||||
case CBF_LUMA :
|
||||
case CBF_CX :
|
||||
case ABS_MVD_GREATER0_FLAG :
|
||||
case ABS_MVD_GREATER1_FLAG :
|
||||
case MVD_SIGN_FLAG :
|
||||
case CU_QP_DELTA_SIGN_FLAG :
|
||||
case TRANSFORM_SKIP_FLAG0 :
|
||||
case TRANSFORM_SKIP_FLAG1 :
|
||||
case CODED_SUB_BLOCK_FLAG :
|
||||
case SIG_COEFF_FLAG :
|
||||
case COEFF_ABS_LEVEL_GREATER1_FLAG :
|
||||
case COEFF_ABS_LEVEL_GREATER2_FLAG :
|
||||
case COEFF_SIGN_FLAG : return m_binFL1;
|
||||
case SAO_EO_CLASS_LUMA :
|
||||
/* = SAO_EO_CLASS_CHROMA */ return m_binFL3;
|
||||
case SAO_TYPE_IDX_LUMA :
|
||||
/* = SAO_TYPE_IDX_CHROMA */
|
||||
case MPM_IDX : return m_binTRx0[2];
|
||||
case SAO_BAND_POSITION :
|
||||
case REM_INTRA_LUMA_PRED_MODE : return m_binFL31;
|
||||
case INTRA_CHROMA_PRED_MODE : return m_binICPM;
|
||||
case INTER_PRED_IDC : return (m_decPar&1) ? m_binFL1 : m_binIPIDC0; //9.3.3.7 m_decPar = (( nPbW + nPbH ) == 12)
|
||||
case SAO_OFFSET_ABS : TR_RANGE0(b, ( 1 << ( BS_MIN( m_decPar/*bitDepth*/, 10 ) - 5 ) ) - 1); break;
|
||||
case MERGE_IDX : TR_RANGE0(b, m_decPar/*MaxNumMergeCand*/ - 1); break;
|
||||
case REF_IDX_LX : TR_RANGE0(b, m_decPar/*num_ref_idx_lx_active_minus1*/); break;
|
||||
case ABS_MVD_MINUS2 : EGK_RANGE(b, (1<<15) - 2, 1); break;
|
||||
case LAST_SIG_COEFF_X_PREFIX : TR_RANGE0(b, ((m_decPar>>2)/*log2TrafoSize*/<<1) - 1); break;
|
||||
case LAST_SIG_COEFF_Y_PREFIX : TR_RANGE0(b, ((m_decPar>>2)/*log2TrafoSize*/<<1) - 1); break;
|
||||
case LAST_SIG_COEFF_X_SUFFIX : FL_RANGE(b, (1<<((m_decPar/*last_sig_coeff_x_prefix*/>>1) - 1)) - 1); break;
|
||||
case LAST_SIG_COEFF_Y_SUFFIX : FL_RANGE(b, (1<<((m_decPar/*last_sig_coeff_y_prefix*/>>1) - 1)) - 1); break;
|
||||
case PART_MODE : return PartModeBin(!!(m_decPar&1), (m_decPar>>1)); //9.3.3.5 ( xCb, yCb ) = ( x0, y0), log2CbSize
|
||||
case CU_QP_DELTA_ABS : return CUQPDAbsBin(); //9.3.3.8
|
||||
//case COEFF_ABS_LEVEL_REMAINING : return CAbsLvlRBin( (m_decPar>>2), (m_decPar&3) ); //9.3.3.9 current sub-block scan index i, baseLevel
|
||||
case END_OF_SUB_STREAM_ONE_BIT : FL1(b, 1, 1); break;
|
||||
default:
|
||||
last_err = BS_ERR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
return b;
|
||||
};
|
||||
|
||||
Bs8s HEVC_CABAC::ctxInc(Bs16u se, Bs16u binIdx){
|
||||
Bs8s inc = CtxIncTbl[se][BS_MIN(binIdx, 5)];
|
||||
|
||||
if(EXTERNAL == inc){
|
||||
switch(se){
|
||||
case SPLIT_CU_FLAG :
|
||||
case CU_SKIP_FLAG : {
|
||||
Bs16u x0 = Bs16u(m_decPar&0xFFFF);
|
||||
Bs16u y0 = Bs16u(m_decPar >> 16);
|
||||
bool availableL = m_pCtx->zAvailableN( x0, y0, x0 - 1, y0 );
|
||||
bool availableA = m_pCtx->zAvailableN( x0, y0, x0, y0 - 1 );
|
||||
|
||||
if(se == SPLIT_CU_FLAG){
|
||||
CQT* c0 = m_pCtx->get(x0, y0);
|
||||
return (( availableL && (m_pCtx->get(x0 - 1, y0)->CtDepth > c0->CtDepth) )
|
||||
+ ( availableA && (m_pCtx->get(x0, y0 - 1)->CtDepth > c0->CtDepth) ));
|
||||
} else /*if(se == CU_SKIP_FLAG)*/{
|
||||
return (( availableL && (m_pCtx->get(x0 - 1, y0)->cu_skip_flag) )
|
||||
+ ( availableA && (m_pCtx->get(x0, y0 - 1)->cu_skip_flag) ));
|
||||
}
|
||||
}
|
||||
case PART_MODE :
|
||||
return (3 - (/*log2CbSize*/(m_decPar>>1) == m_pCtx->MinCbLog2SizeY));
|
||||
case INTER_PRED_IDC :
|
||||
return (m_decPar&1) ? 4 : (m_decPar>>1);
|
||||
//return ERROR; //( nPbW + nPbH ) != 12 ? CtDepth[ x0 ][ y0 ] : 4
|
||||
case SPLIT_TRANSFORM_FLAG :
|
||||
return (5 - m_decPar/*log2TrafoSize*/);
|
||||
case CBF_LUMA :
|
||||
return !m_decPar/*trafoDepth*/;
|
||||
case CBF_CX :
|
||||
return BS_MIN(m_decPar/*trafoDepth*/,5);
|
||||
case LAST_SIG_COEFF_X_PREFIX :
|
||||
case LAST_SIG_COEFF_Y_PREFIX : {
|
||||
//9.3.4.2.3
|
||||
Bs32u cIdx = (m_decPar & 3);
|
||||
Bs32u log2TrafoSize = (m_decPar>>2);
|
||||
if(!cIdx)
|
||||
return ( binIdx >> (( log2TrafoSize + 1 ) >> 2) ) + ( 3 * ( log2TrafoSize - 2 ) + ( ( log2TrafoSize - 1 ) >> 2 ) );
|
||||
return ( binIdx >> ( log2TrafoSize - 2 ) ) + 15;
|
||||
}
|
||||
case CODED_SUB_BLOCK_FLAG :
|
||||
case SIG_COEFF_FLAG : return m_decPar;
|
||||
case COEFF_ABS_LEVEL_GREATER1_FLAG :{
|
||||
//9.3.4.2.6
|
||||
Bs16u i = (m_decPar&15);
|
||||
//Bs16u n = ((m_decPar>>4)&15);
|
||||
Bs16u cIdx = ((m_decPar>>8)&3);
|
||||
bool is1stSB = ((m_decPar>>10)&1);
|
||||
bool is1stTB = ((m_decPar>>11)&1);
|
||||
bool lastGreater1Flag = ((m_decPar>>12)&1);
|
||||
Bs16u lastGreater1Ctx = 0;
|
||||
|
||||
if(is1stSB){
|
||||
m_ctxSet = 0;
|
||||
if(i && !cIdx){
|
||||
m_ctxSet = 2;
|
||||
}
|
||||
if(is1stTB){
|
||||
lastGreater1Ctx = 1;
|
||||
} else {
|
||||
lastGreater1Ctx = m_lastGreater1Ctx;
|
||||
if(lastGreater1Ctx){
|
||||
if(lastGreater1Flag){
|
||||
lastGreater1Ctx = 0;
|
||||
} else {
|
||||
lastGreater1Ctx ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_ctxSet += (lastGreater1Ctx == 0);
|
||||
m_lastGreater1Ctx = 1;
|
||||
} else {
|
||||
if(m_lastGreater1Ctx){
|
||||
if(lastGreater1Flag){
|
||||
m_lastGreater1Ctx = 0;
|
||||
} else {
|
||||
m_lastGreater1Ctx ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (( m_ctxSet * 4 ) + BS_MIN( 3, m_lastGreater1Ctx ) + 16 * !!cIdx);
|
||||
}
|
||||
case COEFF_ABS_LEVEL_GREATER2_FLAG :
|
||||
//9.3.4.2.7
|
||||
//Bs16u cIdx = m_decPar&3;
|
||||
return (m_ctxSet + 4 * !!m_decPar);
|
||||
default: return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return inc;
|
||||
}
|
||||
|
||||
Bs8u HEVC_CABAC::DecodeDecision(Bs8u* ctxTable, Bs16u ctxIdx){
|
||||
Bs8u pStateIdx = (ctxTable[ctxIdx] >> 1);
|
||||
Bs8u valMps = (ctxTable[ctxIdx] & 1);
|
||||
Bs8u qRangeIdx = ((ivlCurrRange >> 6) & 3);
|
||||
Bs8u ivlLpsRange = rangeTabLpsT[ qRangeIdx ][ pStateIdx ];
|
||||
Bs8u binVal = 0;
|
||||
|
||||
ivlCurrRange -= ivlLpsRange;
|
||||
|
||||
if(ivlOffset >= ivlCurrRange){
|
||||
binVal = !valMps;
|
||||
ivlOffset -= ivlCurrRange;
|
||||
ivlCurrRange = ivlLpsRange;
|
||||
|
||||
if( pStateIdx == 0 )
|
||||
valMps = !valMps;
|
||||
|
||||
pStateIdx = transIdxLps[pStateIdx];
|
||||
} else {
|
||||
binVal = valMps;
|
||||
pStateIdx = transIdxMps[pStateIdx];
|
||||
}
|
||||
|
||||
#ifdef HEVC_CABAC_STATE_TRACE
|
||||
fprintf(flog, "%3d -> %3d;\n", /*ctxIdx,*/ ctxTable[ctxIdx], ((pStateIdx << 1) | valMps));
|
||||
fflush(flog);
|
||||
#endif // HEVC_CABAC_STATE_TRACE
|
||||
|
||||
ctxTable[ctxIdx] = ((pStateIdx << 1) | valMps);
|
||||
|
||||
RenormD();
|
||||
|
||||
trace(binVal);
|
||||
|
||||
return binVal;
|
||||
}
|
||||
|
||||
Bs8u HEVC_CABAC::DecodeBypass(){
|
||||
ivlOffset = ((ivlOffset << 1) | read_1_bit());
|
||||
m_pCtx->RawBits ++;
|
||||
|
||||
if(ivlOffset >= ivlCurrRange){
|
||||
ivlOffset -= ivlCurrRange;
|
||||
trace(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
trace(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Bs8u HEVC_CABAC::DecodeTerminate(){
|
||||
ivlCurrRange -= 2;
|
||||
|
||||
if(ivlOffset >= ivlCurrRange){
|
||||
trace(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
RenormD();
|
||||
|
||||
trace(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Bs8u HEVC_CABAC::DecodeBin(Bs8u* ctxTable, Bs16u ctxIdx, bool bypassFlag){
|
||||
if(bypassFlag)
|
||||
return DecodeBypass();
|
||||
|
||||
if(ctxTable == 0)
|
||||
return DecodeTerminate();
|
||||
|
||||
return DecodeDecision( ctxTable, ctxIdx );
|
||||
}
|
||||
|
||||
Bs32u HEVC_CABAC::ae( Bs16u se, Bs32s par) {
|
||||
m_decPar = par;
|
||||
|
||||
if(se == COEFF_ABS_LEVEL_REMAINING)
|
||||
return decCAbsLvlR( (m_decPar>>2), (m_decPar&3) );
|
||||
else if(se == ABS_MVD_MINUS2)
|
||||
return decAbsMvdMinus2();
|
||||
|
||||
Bin v(0,0);
|
||||
Bins& b = GetBinarization(se);
|
||||
Bins::iterator it, begin = b.begin(), end = b.end();
|
||||
Bs32u synValBase = 0;
|
||||
|
||||
for(Bs32s binIdx = 0; binIdx <= Bin::capacity; binIdx++){
|
||||
Bs32u synValInc = 0;
|
||||
Bs8s inc = ctxInc(se, binIdx);
|
||||
|
||||
switch(inc){
|
||||
case ERROR:
|
||||
last_err = BS_ERR_UNKNOWN;
|
||||
return -1;
|
||||
case BYPASS:
|
||||
v.put(DecodeBypass());
|
||||
break;
|
||||
case TERMINATE:
|
||||
v.put(DecodeTerminate());
|
||||
break;
|
||||
default:
|
||||
v.put(DecodeDecision(CtxState+idxStart(se), inc));
|
||||
break;
|
||||
}
|
||||
|
||||
it = begin;
|
||||
while(it != end && it->n < v.n){ it++; synValBase++; }
|
||||
begin = it;
|
||||
while(it != end && !(it->n == v.n && it->b.to_ulong() == v.b.to_ulong())){ it++; synValInc++; }
|
||||
|
||||
if(end != it){
|
||||
return synValBase + synValInc;
|
||||
}
|
||||
}
|
||||
|
||||
last_err = BS_ERR_UNKNOWN;
|
||||
return -2;
|
||||
}
|
||||
|
||||
void HEVC_CABAC::Init(SDecCtx& ctx, Bs32s CtbAddrInRs){
|
||||
m_pCtx = &ctx;
|
||||
Bs16u CtbAddrInTs = ctx.CtbAddrRsToTs[CtbAddrInRs];
|
||||
|
||||
if( CtbAddrInTs && ctx.TileId[CtbAddrInTs] != ctx.TileId[CtbAddrInTs-1] ){ //first coding tree unit in a tile
|
||||
init_ctx();
|
||||
} else if(m_pCtx->slice->pps->entropy_coding_sync_enabled_flag && 0 == (CtbAddrInRs % m_pCtx->PicWidthInCtbsY) ){
|
||||
Bs16s x0 = ( CtbAddrInRs % m_pCtx->PicWidthInCtbsY ) << m_pCtx->CtbLog2SizeY;
|
||||
Bs16s y0 = ( CtbAddrInRs / m_pCtx->PicWidthInCtbsY ) << m_pCtx->CtbLog2SizeY;
|
||||
|
||||
if( m_pCtx->zAvailableN(x0, y0, x0 + m_pCtx->CtbLog2SizeY, y0 - m_pCtx->CtbLog2SizeY) ){
|
||||
sync(CtxStateWpp);
|
||||
} else {
|
||||
init_ctx();
|
||||
}
|
||||
} else if(m_pCtx->slice->dependent_slice_segment_flag && CtbAddrInRs == (Bs32s)m_pCtx->slice->segment_address){
|
||||
sync(CtxStateDs);
|
||||
} else {
|
||||
init_ctx();
|
||||
}
|
||||
init_ade();
|
||||
}
|
||||
|
||||
void HEVC_CABAC::Store(bool is2ndCtuInRow, bool endOfSliceSegment){
|
||||
if(is2ndCtuInRow && m_pCtx->slice->pps->entropy_coding_sync_enabled_flag){
|
||||
store(CtxStateWpp);
|
||||
}
|
||||
|
||||
if(m_pCtx->slice->pps->dependent_slice_segments_enabled_flag && endOfSliceSegment){
|
||||
store(CtxStateDs);
|
||||
}
|
||||
}
|
|
@ -1,219 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "hevc_cabac.h"
|
||||
|
||||
namespace BS_HEVC
|
||||
{
|
||||
|
||||
const Bs8u CtxOffset[num_SE+1] = {
|
||||
/*SAO_MERGE_LEFT_FLAG */ 0,
|
||||
/*SAO_TYPE_IDX_LUMA */ 1,
|
||||
/*SPLIT_CU_FLAG */ 2,
|
||||
/*CU_TRANSQUANT_BYPASS_FLAG */ 5,
|
||||
/*CU_SKIP_FLAG */ 6,
|
||||
/*PRED_MODE_FLAG */ 9,
|
||||
/*PART_MODE */ 10,
|
||||
/*PREV_INTRA_LUMA_PRED_FLAG */ 14,
|
||||
/*INTRA_CHROMA_PRED_MODE */ 15,
|
||||
/*RQT_ROOT_CBF */ 16,
|
||||
/*MERGE_FLAG */ 17,
|
||||
/*MERGE_IDX */ 18,
|
||||
/*INTER_PRED_IDC */ 19,
|
||||
/*REF_IDX_LX */ 24,
|
||||
/*MVP_LX_FLAG */ 26,
|
||||
/*SPLIT_TRANSFORM_FLAG */ 27,
|
||||
/*CBF_LUMA */ 30,
|
||||
/*CBF_CX */ 32,
|
||||
/*ABS_MVD_GREATER0_FLAG */ 36 + 1,
|
||||
/*ABS_MVD_GREATER1_FLAG */ 37 + 1,
|
||||
/*CU_QP_DELTA_ABS */ 38 + 1,
|
||||
/*TRANSFORM_SKIP_FLAG0 */ 40 + 1,
|
||||
/*TRANSFORM_SKIP_FLAG1 */ 41 + 1,
|
||||
/*LAST_SIG_COEFF_X_PREFIX */ 42 + 1,
|
||||
/*LAST_SIG_COEFF_Y_PREFIX */ 60 + 1,
|
||||
/*CODED_SUB_BLOCK_FLAG */ 78 + 1,
|
||||
/*SIG_COEFF_FLAG */ 82 + 1,
|
||||
/*COEFF_ABS_LEVEL_GREATER1_FLAG*/ 124 + 1 + 2,
|
||||
/*COEFF_ABS_LEVEL_GREATER2_FLAG*/ 148 + 1 + 2,
|
||||
/*CU_CHROMA_QP_OFFSET_FLAG */ 154 + 1 + 2,
|
||||
/*CU_CHROMA_QP_OFFSET_IDX */ 155 + 1 + 2,
|
||||
/*LOG2_RES_SCALE_ABS_PLUS1 */ 156 + 1 + 2,
|
||||
/*RES_SCALE_SIGN_FLAG */ 164 + 1 + 2,
|
||||
/*EXPLICIT_RDPCM_FLAG */ 166 + 1 + 2,
|
||||
/*EXPLICIT_RDPCM_DIR_FLAG */ 168 + 1 + 2,
|
||||
/*PALETTE_MODE_FLAG */170 + 1 + 2,
|
||||
/*TU_RESIDUAL_ACT_FLAG */171 + 1 + 2,
|
||||
/*PALETTE_RUN_PREFIX */172 + 1 + 2,
|
||||
/*COPY_ABOVE_PALETTE_INDICES_FLAG */180 + 1 + 2,
|
||||
/*COPY_ABOVE_INDICES_FOR_FINAL_RUN_FLAG*/180 + 1 + 2,
|
||||
/*PALETTE_TRANSPOSE_FLAG */181 + 1 + 2,
|
||||
/* */ CtxTblSize
|
||||
};
|
||||
|
||||
const Bs8u CtxInitTbl[3][CtxTblSize] =
|
||||
{
|
||||
{
|
||||
12 + 141, 59 + 141, 88 + 51, 39 + 102, 99 + 58, 98 + 56, 140 + 14, 91 + 63, 36 + 118, 101 + 53,
|
||||
113 + 71, 145 + 9, 46 + 108, 80 + 74, 120 + 64, 40 + 23, 25 + 129, 128 + 26, 71 + 83, 141 + 13,
|
||||
29 + 125, 5 + 149, 118 + 36, 152 + 2, 17 + 137, 43 + 111, 85 + 69, 83 + 70, 114 + 24, 121 + 17,
|
||||
89 + 22, 111 + 30, 17 + 77, 9 + 129, 39 + 143, 33 + 121, 90 + 64, 140 + 14, 127 + 27, 126 + 28,
|
||||
88 + 66, 10 + 129, 61 + 78, 49 + 61, 30 + 80, 41 + 83, 61 + 64, 4 + 136, 116 + 37, 95 + 30,
|
||||
125 + 2, 6 + 134, 75 + 34, 31 + 80, 32 + 111, 67 + 60, 2 + 109, 62 + 17, 93 + 15, 57 + 66,
|
||||
31 + 32, 28 + 82, 99 + 11, 30 + 94, 1 + 124, 113 + 27, 26 + 127, 49 + 76, 108 + 19, 14 + 126,
|
||||
25 + 84, 67 + 44, 113 + 30, 41 + 86, 97 + 14, 23 + 56, 100 + 8, 103 + 20, 36 + 27, 9 + 82,
|
||||
109 + 62, 16 + 118, 92 + 49, 64 + 47, 70 + 41, 3 + 122, 85 + 25, 55 + 55, 74 + 20, 85 + 39,
|
||||
91 + 17, 55 + 69, 62 + 45, 58 + 67, 138 + 3, 76 + 103, 138 + 15, 73 + 52, 3 + 104, 14 + 111,
|
||||
129 + 12, 57 + 122, 11 + 142, 102 + 23, 21 + 86, 88 + 37, 15 + 126, 165 + 14, 148 + 5, 8 + 117,
|
||||
90 + 50, 32 + 107, 141 + 41, 122 + 60, 8 + 144, 63 + 73, 12 + 140, 20 + 116, 109 + 44, 119 + 17,
|
||||
86 + 53, 97 + 14, 107 + 29, 109 + 30, 105 + 6, 85 + 56, 106 + 5, 51 + 89, 10 + 82, 97 + 40,
|
||||
32 + 106, 137 + 3, 62 + 90, 22 + 116, 21 + 118, 73 + 80, 28 + 46, 116 + 33, 2 + 90, 32 + 107,
|
||||
57 + 50, 20 + 102, 28 + 124, 55 + 85, 66 + 113, 55 + 111, 51 + 131, 46 + 94, 79 + 148, 5 + 117,
|
||||
16 + 181, 79 + 59, 111 + 42, 54 + 82, 56 + 111, 120 + 32, 45 + 107, 5 + 149, 56 + 98, 128 + 26,
|
||||
125 + 29, 141 + 13, 142 + 12, 73 + 81, 62 + 92, 42 + 112, 125 + 29, 21 + 133, 98 + 56, 103 + 36,
|
||||
25 + 114, 34 + 105, 57 + 82, 76 + 78, 111 + 43, 27 + 127, 80 + 74, 135 + 19, 76 + 78, 121 + 33,
|
||||
4 + 150, 129 + 25, 141 + 13, 139 + 15, 38 + 116
|
||||
},
|
||||
{
|
||||
99 + 54, 181 + 4, 106 + 1, 3 + 136, 105 + 21, 133 + 21, 196 + 1, 92 + 93, 168 + 33, 5 + 144,
|
||||
143 + 11, 78 + 61, 46 + 108, 12 + 142, 110 + 44, 89 + 63, 5 + 74, 47 + 63, 74 + 48, 29 + 66,
|
||||
63 + 16, 21 + 42, 15 + 16, 15 + 16, 54 + 99, 89 + 64, 1 + 167, 102 + 22, 102 + 36, 11 + 83,
|
||||
65 + 88, 106 + 5, 94 + 55, 87 + 20, 81 + 86, 83 + 71, 132 + 22, 41 + 99, 10 + 188, 101 + 53,
|
||||
60 + 94, 95 + 44, 6 + 133, 34 + 91, 14 + 96, 13 + 81, 62 + 48, 59 + 36, 20 + 59, 124 + 1,
|
||||
93 + 18, 20 + 90, 36 + 42, 84 + 26, 33 + 78, 52 + 59, 82 + 13, 57 + 37, 31 + 77, 56 + 67,
|
||||
47 + 61, 124 + 1, 61 + 49, 27 + 67, 20 + 90, 0 + 95, 9 + 70, 51 + 74, 82 + 29, 103 + 7,
|
||||
74 + 4, 98 + 12, 30 + 81, 80 + 31, 92 + 3, 74 + 20, 91 + 17, 46 + 77, 28 + 80, 20 + 101,
|
||||
96 + 44, 17 + 44, 87 + 67, 5 + 150, 149 + 5, 138 + 1, 40 + 113, 115 + 24, 103 + 20, 45 + 78,
|
||||
59 + 4, 136 + 17, 7 + 159, 96 + 87, 124 + 16, 86 + 50, 5 + 148, 67 + 87, 71 + 95, 12 + 171,
|
||||
109 + 31, 92 + 44, 66 + 87, 80 + 74, 162 + 4, 102 + 81, 125 + 15, 98 + 38, 97 + 56, 115 + 39,
|
||||
35 + 135, 150 + 3, 44 + 79, 65 + 58, 55 + 52, 76 + 45, 71 + 36, 111 + 10, 105 + 62, 105 + 46,
|
||||
54 + 129, 75 + 65, 89 + 62, 143 + 40, 92 + 48, 105 + 35, 89 + 51, 17 + 137, 91 + 105, 89 + 107,
|
||||
45 + 122, 89 + 65, 118 + 34, 73 + 94, 116 + 66, 103 + 79, 27 + 107, 83 + 66, 87 + 49, 132 + 21,
|
||||
119 + 2, 89 + 47, 94 + 43, 40 + 129, 50 + 144, 86 + 80, 74 + 93, 96 + 58, 108 + 59, 56 + 81,
|
||||
133 + 49, 38 + 69, 22 + 145, 32 + 59, 16 + 106, 88 + 19, 96 + 71, 29 + 125, 151 + 3, 92 + 62,
|
||||
135 + 19, 58 + 96, 30 + 124, 117 + 37, 66 + 88, 50 + 104, 111 + 43, 27 + 127, 98 + 56, 100 + 39,
|
||||
111 + 28, 120 + 19, 50 + 89, 49 + 105, 59 + 95, 81 + 73, 137 + 17, 97 + 57, 24 + 130, 118 + 36,
|
||||
33 + 121, 132 + 22, 71 + 83, 47 + 107, 109 + 45
|
||||
},
|
||||
{
|
||||
61 + 92, 48 + 112, 89 + 18, 73 + 66, 12 + 114, 49 + 105, 129 + 68, 127 + 58, 81 + 120, 17 + 117,
|
||||
153 + 1, 133 + 6, 105 + 49, 27 + 127, 119 + 64, 64 + 88, 60 + 19, 34 + 120, 43 + 94, 35 + 60,
|
||||
55 + 24, 50 + 13, 19 + 12, 12 + 19, 73 + 80, 9 + 144, 18 + 150, 160 + 64, 39 + 128, 88 + 34,
|
||||
73 + 80, 98 + 13, 32 + 117, 34 + 58, 10 + 157, 25 + 129, 140 + 14, 100 + 69, 48 + 150, 68 + 86,
|
||||
50 + 104, 83 + 56, 38 + 101, 88 + 37, 53 + 57, 51 + 73, 30 + 80, 49 + 46, 36 + 58, 2 + 123,
|
||||
52 + 59, 90 + 21, 58 + 21, 124 + 1, 115 + 11, 108 + 3, 6 + 105, 36 + 43, 64 + 44, 16 + 107,
|
||||
80 + 13, 44 + 81, 59 + 51, 67 + 57, 29 + 81, 46 + 49, 10 + 84, 83 + 42, 88 + 23, 82 + 29,
|
||||
62 + 17, 6 + 119, 123 + 3, 10 + 101, 56 + 55, 44 + 35, 33 + 75, 73 + 50, 54 + 39, 79 + 42,
|
||||
135 + 5, 55 + 6, 83 + 71, 150 + 20, 54 + 100, 41 + 98, 111 + 42, 18 + 121, 39 + 84, 65 + 58,
|
||||
21 + 42, 31 + 93, 127 + 39, 114 + 69, 98 + 42, 33 + 103, 130 + 23, 121 + 33, 133 + 33, 104 + 79,
|
||||
131 + 9, 60 + 76, 131 + 22, 128 + 26, 135 + 31, 172 + 11, 5 + 135, 113 + 23, 102 + 51, 115 + 39,
|
||||
69 + 101, 0 + 153, 73 + 65, 23 + 115, 102 + 20, 17 + 104, 20 + 102, 60 + 61, 140 + 27, 7 + 144,
|
||||
27 + 156, 99 + 41, 122 + 29, 73 + 110, 85 + 55, 113 + 27, 93 + 47, 47 + 107, 165 + 31, 56 + 111,
|
||||
38 + 129, 87 + 67, 128 + 24, 9 + 158, 162 + 20, 136 + 46, 120 + 14, 62 + 87, 33 + 103, 6 + 147,
|
||||
0 + 121, 61 + 75, 9 + 113, 120 + 49, 169 + 39, 37 + 129, 22 + 145, 143 + 11, 146 + 6, 162 + 5,
|
||||
65 + 117, 17 + 90, 122 + 45, 80 + 11, 27 + 80, 51 + 56, 103 + 64, 21 + 133, 86 + 68, 26 + 128,
|
||||
105 + 49, 59 + 95, 115 + 39, 130 + 24, 150 + 4, 26 + 128, 99 + 55, 97 + 57, 44 + 110, 133 + 6,
|
||||
8 + 131, 133 + 6, 22 + 117, 116 + 38, 109 + 45, 16 + 138, 86 + 68, 53 + 101, 8 + 146, 72 + 82,
|
||||
15 + 139, 48 + 106, 6 + 148, 95 + 59, 2 + 152
|
||||
}
|
||||
};
|
||||
|
||||
const Bs8s HEVC_CABAC::CtxIncTbl[num_SE_full][6] = {
|
||||
/*SAO_MERGE_LEFT_FLAG */ { 0, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*SAO_TYPE_IDX_LUMA */ { 0, BYPASS, ERROR, ERROR, ERROR, ERROR },
|
||||
/*SPLIT_CU_FLAG */ { EXTERNAL, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*CU_TRANSQUANT_BYPASS_FLAG */ { 0, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*CU_SKIP_FLAG */ { EXTERNAL, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*PRED_MODE_FLAG */ { 0, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*PART_MODE */ { 0, 1, EXTERNAL, BYPASS, ERROR, ERROR },
|
||||
/*PREV_INTRA_LUMA_PRED_FLAG */ { 0, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*INTRA_CHROMA_PRED_MODE */ { 0, BYPASS, BYPASS, ERROR, ERROR, ERROR },
|
||||
/*RQT_ROOT_CBF */ { 0, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*MERGE_FLAG */ { 0, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*MERGE_IDX */ { 0, BYPASS, BYPASS, BYPASS, ERROR, ERROR },
|
||||
/*INTER_PRED_IDC */ { EXTERNAL, 4, ERROR, ERROR, ERROR, ERROR },
|
||||
/*REF_IDX_LX */ { 0, 1, BYPASS, BYPASS, BYPASS, BYPASS },
|
||||
/*MVP_LX_FLAG */ { 0, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*SPLIT_TRANSFORM_FLAG */ { EXTERNAL, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*CBF_LUMA */ { EXTERNAL, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*CBF_CX */ { EXTERNAL, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*ABS_MVD_GREATER0_FLAG */ { 0, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*ABS_MVD_GREATER1_FLAG */ { 0, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*CU_QP_DELTA_ABS */ { 0, 1, 1, 1, 1, BYPASS },
|
||||
/*TRANSFORM_SKIP_FLAG0 */ { 0, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*TRANSFORM_SKIP_FLAG1 */ { 0, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*LAST_SIG_COEFF_X_PREFIX */ { EXTERNAL, EXTERNAL, EXTERNAL, EXTERNAL, EXTERNAL, EXTERNAL },
|
||||
/*LAST_SIG_COEFF_Y_PREFIX */ { EXTERNAL, EXTERNAL, EXTERNAL, EXTERNAL, EXTERNAL, EXTERNAL },
|
||||
/*CODED_SUB_BLOCK_FLAG */ { EXTERNAL, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*SIG_COEFF_FLAG */ { EXTERNAL, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*COEFF_ABS_LEVEL_GREATER1_FLAG*/ { EXTERNAL, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*COEFF_ABS_LEVEL_GREATER2_FLAG*/ { EXTERNAL, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*CU_QP_DELTA_ABS */ { 0, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*CU_QP_DELTA_ABS */ { 0, 0, 0, 0, 0, ERROR },
|
||||
/*LOG2_RES_SCALE_ABS_PLUS1 */ { EXTERNAL, EXTERNAL, EXTERNAL, EXTERNAL, ERROR, ERROR },
|
||||
/*RES_SCALE_SIGN_FLAG */ { EXTERNAL, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*EXPLICIT_RDPCM_FLAG */ { 0, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*EXPLICIT_RDPCM_DIR_FLAG */ { 0, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*PALETTE_MODE_FLAG */ { 0, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*TU_RESIDUAL_ACT_FLAG */ { 0, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*PALETTE_RUN_PREFIX */ { EXTERNAL, EXTERNAL, EXTERNAL, EXTERNAL, EXTERNAL, EXTERNAL },
|
||||
/*COPY_ABOVE_PALETTE_INDICES_FL*/ { 0, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*COPY_ABOVE_INDICES_FOR_FINAL_*/ { 0, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*PALETTE_TRANSPOSE_FLAG */ { 0, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*END_OF_SLICE_SEGMENT_FLAG */ { TERMINATE, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*END_OF_SUB_STREAM_ONE_BIT */ { TERMINATE, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*SAO_OFFSET_ABS */ { BYPASS, BYPASS, BYPASS, BYPASS, BYPASS, BYPASS },
|
||||
/*SAO_OFFSET_SIGN */ { BYPASS, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*SAO_BAND_POSITION */ { BYPASS, BYPASS, BYPASS, BYPASS, BYPASS, BYPASS },
|
||||
/*SAO_EO_CLASS_LUMA */ { BYPASS, BYPASS, BYPASS, ERROR, ERROR, ERROR },
|
||||
/*MPM_IDX */ { BYPASS, BYPASS, ERROR, ERROR, ERROR, ERROR },
|
||||
/*REM_INTRA_LUMA_PRED_MODE */ { BYPASS, BYPASS, BYPASS, BYPASS, BYPASS, BYPASS },
|
||||
/*ABS_MVD_MINUS2 */ { BYPASS, BYPASS, BYPASS, BYPASS, BYPASS, BYPASS },
|
||||
/*MVD_SIGN_FLAG */ { BYPASS, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*CU_QP_DELTA_SIGN_FLAG */ { BYPASS, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*LAST_SIG_COEFF_X_SUFFIX */ { BYPASS, BYPASS, BYPASS, BYPASS, BYPASS, BYPASS },
|
||||
/*LAST_SIG_COEFF_Y_SUFFIX */ { BYPASS, BYPASS, BYPASS, BYPASS, BYPASS, BYPASS },
|
||||
/*COEFF_ABS_LEVEL_REMAINING */ { BYPASS, BYPASS, BYPASS, BYPASS, BYPASS, BYPASS },
|
||||
/*COEFF_SIGN_FLAG */ { BYPASS, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
/*PCM_FLAG */ { TERMINATE, ERROR, ERROR, ERROR, ERROR, ERROR },
|
||||
};
|
||||
|
||||
const Bs8u rangeTabLpsT[4][64] = {
|
||||
{ 15 + 113, 100 + 28, 74 + 54, 6 + 117, 103 + 13, 57 + 54, 60 + 45, 24 + 76, 61 + 34, 81 + 9, 27 + 58, 1 + 80, 29 + 48, 29 + 44, 36 + 33, 62 + 4, 49 + 13, 52 + 7, 0 + 56, 24 + 29, 20 + 31, 4 + 44, 33 + 13, 2 + 41, 35 + 6, 14 + 25, 21 + 16, 20 + 15, 3 + 30, 24 + 8, 6 + 24, 1 + 28, 9 + 18, 10 + 16, 14 + 10, 8 + 15, 6 + 16, 8 + 13, 10 + 10, 7 + 12, 6 + 12, 16 + 1, 6 + 10, 10 + 5, 3 + 11, 2 + 12, 0 + 13, 3 + 9, 10 + 2, 7 + 4, 5 + 6, 7 + 3, 7 + 3, 8 + 1, 6 + 3, 0 + 8, 5 + 3, 2 + 5, 2 + 5, 4 + 3, 0 + 6, 4 + 2, 3 + 3, 0 + 2 },
|
||||
{ 151 + 25, 125 + 42, 68 + 90, 50 + 100, 132 + 10, 77 + 58, 66 + 62, 94 + 28, 61 + 55, 42 + 68, 64 + 40, 7 + 92, 47 + 47, 52 + 37, 50 + 35, 72 + 8, 22 + 54, 13 + 59, 36 + 33, 31 + 34, 16 + 46, 57 + 2, 45 + 11, 39 + 14, 34 + 16, 30 + 18, 11 + 34, 7 + 36, 7 + 34, 25 + 14, 15 + 22, 11 + 24, 18 + 15, 18 + 13, 20 + 10, 23 + 5, 10 + 17, 4 + 22, 0 + 24, 20 + 3, 11 + 11, 6 + 15, 1 + 19, 4 + 15, 12 + 6, 6 + 11, 11 + 5, 5 + 10, 10 + 4, 2 + 12, 6 + 7, 4 + 8, 0 + 12, 9 + 2, 5 + 6, 1 + 9, 3 + 6, 3 + 6, 3 + 6, 4 + 4, 1 + 7, 6 + 1, 5 + 2, 0 + 2 },
|
||||
{ 164 + 44, 117 + 80, 146 + 41, 92 + 86, 61 + 108, 136 + 24, 50 + 102, 111 + 33, 0 + 137, 105 + 25, 69 + 54, 75 + 42, 9 + 102, 68 + 37, 31 + 69, 65 + 30, 43 + 47, 62 + 24, 67 + 14, 34 + 43, 19 + 54, 22 + 47, 62 + 4, 46 + 17, 20 + 39, 9 + 47, 23 + 31, 40 + 11, 46 + 2, 8 + 38, 28 + 15, 2 + 39, 0 + 39, 4 + 33, 3 + 32, 31 + 2, 28 + 4, 8 + 22, 22 + 7, 25 + 2, 18 + 8, 23 + 2, 20 + 3, 20 + 2, 4 + 17, 8 + 12, 18 + 1, 8 + 10, 13 + 4, 13 + 3, 10 + 5, 5 + 10, 9 + 5, 2 + 11, 9 + 3, 1 + 11, 2 + 9, 8 + 3, 4 + 6, 4 + 6, 6 + 3, 4 + 5, 3 + 5, 1 + 1 },
|
||||
{ 135 + 105, 102 + 125, 100 + 116, 145 + 60, 163 + 32, 157 + 28, 114 + 61, 24 + 142, 23 + 135, 63 + 87, 59 + 83, 99 + 36, 113 + 15, 25 + 97, 102 + 14, 60 + 50, 73 + 31, 79 + 20, 21 + 73, 0 + 89, 30 + 55, 32 + 48, 13 + 63, 65 + 7, 40 + 29, 20 + 45, 13 + 49, 51 + 8, 41 + 15, 33 + 20, 47 + 3, 1 + 47, 40 + 5, 25 + 18, 20 + 21, 38 + 1, 17 + 20, 2 + 33, 20 + 13, 14 + 17, 28 + 2, 11 + 17, 23 + 4, 23 + 2, 7 + 17, 13 + 10, 11 + 11, 7 + 14, 7 + 13, 7 + 12, 6 + 12, 1 + 16, 12 + 4, 7 + 8, 8 + 6, 0 + 14, 4 + 9, 6 + 6, 9 + 3, 5 + 6, 10 + 1, 5 + 5, 7 + 2, 0 + 2 },
|
||||
};
|
||||
|
||||
const Bs8u transIdxLps[64] = {
|
||||
104 - 104, 62 - 62, 0 + 1, 1 + 1, 0 + 2, 0 + 4, 0 + 4, 2 + 3, 3 + 3, 5 + 2, 0 + 8, 3 + 6, 3 + 6, 0 + 11, 10 + 1, 8 + 4,
|
||||
3 + 10, 1 + 12, 4 + 11, 7 + 8, 1 + 15, 2 + 14, 1 + 17, 3 + 15, 10 + 9, 2 + 17, 3 + 18, 10 + 11, 2 + 20, 18 + 4, 10 + 13, 14 + 10,
|
||||
4 + 20, 3 + 22, 21 + 5, 15 + 11, 14 + 13, 18 + 9, 15 + 13, 10 + 19, 2 + 27, 6 + 24, 27 + 3, 18 + 12, 15 + 16, 9 + 23, 5 + 27, 9 + 24,
|
||||
16 + 17, 22 + 11, 14 + 20, 0 + 34, 5 + 30, 31 + 4, 19 + 16, 27 + 9, 13 + 23, 16 + 20, 23 + 14, 19 + 18, 23 + 14, 30 + 8, 0 + 38, 43 + 20
|
||||
};
|
||||
|
||||
const Bs8u transIdxMps[64] = {
|
||||
0 + 1, 0 + 2, 0 + 3, 2 + 2, 2 + 3, 5 + 1, 2 + 5, 7 + 1, 0 + 9, 2 + 8, 9 + 2, 6 + 6, 8 + 5, 10 + 4, 12 + 3, 12 + 4,
|
||||
10 + 7, 9 + 9, 13 + 6, 13 + 7, 16 + 5, 15 + 7, 14 + 9, 1 + 23, 8 + 17, 10 + 16, 26 + 1, 16 + 12, 19 + 10, 7 + 23, 4 + 27, 27 + 5,
|
||||
6 + 27, 5 + 29, 16 + 19, 20 + 16, 34 + 3, 33 + 5, 1 + 38, 13 + 27, 13 + 28, 4 + 38, 20 + 23, 20 + 24, 15 + 30, 23 + 23, 17 + 30, 7 + 41,
|
||||
4 + 45, 4 + 46, 50 + 1, 3 + 49, 5 + 48, 27 + 27, 22 + 33, 35 + 21, 47 + 10, 31 + 27, 50 + 9, 5 + 55, 39 + 22, 0 + 62, 41 + 21, 6 + 57
|
||||
};
|
||||
|
||||
};
|
|
@ -1,400 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "hevc_cabac.h"
|
||||
|
||||
using namespace BS_HEVC;
|
||||
|
||||
template <class Type> class fill_vector
|
||||
{
|
||||
public:
|
||||
fill_vector ( const Type& _val ) : val ( _val ) {}
|
||||
void operator () ( std::vector<Type>& el ) const { std::fill(el.begin(), el.end(), val); }
|
||||
private:
|
||||
Type val;
|
||||
};
|
||||
|
||||
void SDecCtx::update(Slice& s){
|
||||
Bs32s i = 0, j = 0, x = 0, y = 0, p = 0, m = 0, tileIdx = 0;
|
||||
|
||||
MaxNumMergeCand = 5 - s.five_minus_max_num_merge_cand;
|
||||
QpYprev = SliceQpY = 26 + s.pps->init_qp_minus26 + s.slice_qp_delta;
|
||||
|
||||
if( slice
|
||||
&& slice->sps == s.sps
|
||||
&& slice->pps == s.pps){
|
||||
bool newPicture = (slice->pic_order_cnt_lsb != s.pic_order_cnt_lsb);
|
||||
slice = &s;
|
||||
|
||||
if(newPicture){
|
||||
std::for_each(vIntraPredModeY.begin(), vIntraPredModeY.end(), fill_vector<Bs8s>(-1));
|
||||
std::fill(vSliceAddrRs.begin(), vSliceAddrRs.end(), -1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
slice = &s;
|
||||
ctu = NULL;
|
||||
|
||||
MinCbLog2SizeY = s.sps->log2_min_luma_coding_block_size_minus3 + 3;
|
||||
CtbLog2SizeY = MinCbLog2SizeY + s.sps->log2_diff_max_min_luma_coding_block_size;
|
||||
CtbSizeY = (1 << CtbLog2SizeY);
|
||||
PicWidthInCtbsY = (s.sps->pic_width_in_luma_samples + CtbSizeY - 1) / CtbSizeY;
|
||||
PicHeightInCtbsY = (s.sps->pic_height_in_luma_samples + CtbSizeY - 1) / CtbSizeY;
|
||||
MinCbSizeY = (1 << MinCbLog2SizeY);
|
||||
PicWidthInMinCbsY = s.sps->pic_width_in_luma_samples / MinCbSizeY;
|
||||
PicHeightInMinCbsY = s.sps->pic_height_in_luma_samples / MinCbSizeY;
|
||||
PicSizeInMinCbsY = PicWidthInMinCbsY * PicHeightInMinCbsY;
|
||||
PicSizeInCtbsY = PicWidthInCtbsY * PicHeightInCtbsY;
|
||||
PicSizeInSamplesY = s.sps->pic_width_in_luma_samples * s.sps->pic_height_in_luma_samples;
|
||||
PicWidthInSamplesC = s.sps->pic_width_in_luma_samples / SubWidthC[s.sps->chroma_format_idc + s.sps->separate_colour_plane_flag];
|
||||
PicHeightInSamplesC = s.sps->pic_height_in_luma_samples / SubHeightC[s.sps->chroma_format_idc + s.sps->separate_colour_plane_flag];
|
||||
Log2MinTrafoSize = s.sps->log2_min_transform_block_size_minus2 + 2;
|
||||
Log2MaxTrafoSize = Log2MinTrafoSize + s.sps->log2_diff_max_min_transform_block_size;
|
||||
Log2MinIpcmCbSizeY = s.sps->log2_min_pcm_luma_coding_block_size_minus3 + 3;
|
||||
Log2MaxIpcmCbSizeY = Log2MinIpcmCbSizeY + s.sps->log2_diff_max_min_pcm_luma_coding_block_size;
|
||||
Log2MinCuQpDeltaSize= CtbLog2SizeY - s.pps->diff_cu_qp_delta_depth;
|
||||
IsCuQpDeltaCoded = 0;
|
||||
|
||||
vIntraPredModeY.resize(((s.sps->pic_width_in_luma_samples+64) >> Log2MinTrafoSize),
|
||||
std::vector<Bs8s> (((s.sps->pic_height_in_luma_samples+64) >> Log2MinTrafoSize), -1));
|
||||
std::for_each(vIntraPredModeY.begin(), vIntraPredModeY.end(), fill_vector<Bs8s>(-1));
|
||||
|
||||
colWidth.resize(s.pps->num_tile_columns_minus1+1);
|
||||
if( s.pps->uniform_spacing_flag ){
|
||||
for( i = 0; i <= s.pps->num_tile_columns_minus1; i++ ){
|
||||
colWidth[ i ] = ( ( i + 1 ) * PicWidthInCtbsY ) / ( s.pps->num_tile_columns_minus1 + 1 ) -
|
||||
( i * PicWidthInCtbsY ) / ( s.pps->num_tile_columns_minus1 + 1 );
|
||||
}
|
||||
} else {
|
||||
colWidth[ s.pps->num_tile_columns_minus1 ] = PicWidthInCtbsY;
|
||||
for( i = 0; i < s.pps->num_tile_columns_minus1; i++ ) {
|
||||
colWidth[ i ] = s.pps->column_width_minus1[ i ] + 1;
|
||||
colWidth[ s.pps->num_tile_columns_minus1 ] -= colWidth[ i ];
|
||||
}
|
||||
}
|
||||
|
||||
rowHeight.resize(s.pps->num_tile_rows_minus1+1);
|
||||
if( s.pps->uniform_spacing_flag ){
|
||||
for( j = 0; j <= s.pps->num_tile_rows_minus1; j++ ){
|
||||
rowHeight[ j ] = ( ( j + 1 ) * PicHeightInCtbsY ) / ( s.pps->num_tile_rows_minus1 + 1 ) -
|
||||
( j * PicHeightInCtbsY ) / ( s.pps->num_tile_rows_minus1 + 1 );
|
||||
}
|
||||
} else {
|
||||
rowHeight[ s.pps->num_tile_rows_minus1 ] = PicHeightInCtbsY;
|
||||
for( j = 0; j < s.pps->num_tile_rows_minus1; j++ ) {;
|
||||
rowHeight[ j ] = s.pps->row_height_minus1[ j ] + 1;
|
||||
rowHeight[ s.pps->num_tile_rows_minus1 ] -= rowHeight[ j ];
|
||||
}
|
||||
}
|
||||
|
||||
colBd.resize(s.pps->num_tile_columns_minus1+2);
|
||||
for( colBd[ 0 ] = 0, i = 0; i <= s.pps->num_tile_columns_minus1; i++ )
|
||||
colBd[ i + 1 ] = colBd[ i ] + colWidth[ i ];
|
||||
|
||||
rowBd.resize(s.pps->num_tile_rows_minus1+2);
|
||||
for( rowBd[ 0 ] = 0, j = 0; j <= s.pps->num_tile_rows_minus1; j++ )
|
||||
rowBd[ j + 1 ] = rowBd[ j ] + rowHeight[ j ];
|
||||
|
||||
CtbAddrRsToTs.resize(PicSizeInCtbsY);
|
||||
for( Bs16u ctbAddrRs = 0; ctbAddrRs < PicSizeInCtbsY; ctbAddrRs++ ) {
|
||||
Bs16u tbX = ctbAddrRs % PicWidthInCtbsY;
|
||||
Bs16u tbY = ctbAddrRs / PicWidthInCtbsY;
|
||||
Bs16u tileX = 0;
|
||||
Bs16u tileY = 0;
|
||||
|
||||
for( i = 0; i <= s.pps->num_tile_columns_minus1; i++ )
|
||||
if( tbX >= colBd[ i ] )
|
||||
tileX = i;
|
||||
|
||||
for( j = 0; j <= s.pps->num_tile_rows_minus1; j++ )
|
||||
if( tbY >= rowBd[ j ] )
|
||||
tileY = j;
|
||||
|
||||
CtbAddrRsToTs[ ctbAddrRs ] = 0;
|
||||
|
||||
for( i = 0; i < tileX; i++ )
|
||||
CtbAddrRsToTs[ ctbAddrRs ] += rowHeight[ tileY ] * colWidth[ i ];
|
||||
|
||||
for( j = 0; j < tileY; j++ )
|
||||
CtbAddrRsToTs[ ctbAddrRs ] += PicWidthInCtbsY * rowHeight[ j ];
|
||||
|
||||
CtbAddrRsToTs[ ctbAddrRs ] += ( tbY - rowBd[ tileY ] ) * colWidth[ tileX ] + tbX - colBd[ tileX ];
|
||||
}
|
||||
|
||||
CtbAddrTsToRs.resize(PicSizeInCtbsY);
|
||||
for(Bs16u ctbAddrRs = 0; ctbAddrRs < PicSizeInCtbsY; ctbAddrRs++ )
|
||||
CtbAddrTsToRs[ CtbAddrRsToTs[ ctbAddrRs ] ] = ctbAddrRs;
|
||||
|
||||
|
||||
TileId.resize(PicSizeInCtbsY);
|
||||
for( j = 0, tileIdx = 0; j <= s.pps->num_tile_rows_minus1; j++ )
|
||||
for( i = 0; i <= s.pps->num_tile_columns_minus1; i++, tileIdx++ )
|
||||
for( y = rowBd[ j ]; y < rowBd[ j + 1 ]; y++ )
|
||||
for( x = colBd[ i ]; x < colBd[ i + 1 ]; x++ )
|
||||
TileId[ CtbAddrRsToTs[ y * PicWidthInCtbsY+ x ] ] = tileIdx;
|
||||
|
||||
|
||||
MinTbAddrZs.resize(
|
||||
( PicWidthInCtbsY << ( CtbLog2SizeY - Log2MinTrafoSize ) ),
|
||||
std::vector<Bs32u>(( PicHeightInCtbsY << ( CtbLog2SizeY - Log2MinTrafoSize ) ))
|
||||
);
|
||||
for( y = 0; y < ( PicHeightInCtbsY << ( CtbLog2SizeY - Log2MinTrafoSize ) ); y++ ){
|
||||
for( x = 0; x < ( PicWidthInCtbsY << ( CtbLog2SizeY - Log2MinTrafoSize ) ); x++) {
|
||||
Bs32u tbX = ( x << Log2MinTrafoSize ) >> CtbLog2SizeY;
|
||||
Bs32u tbY = ( y << Log2MinTrafoSize ) >> CtbLog2SizeY;
|
||||
Bs32u ctbAddrRs = PicWidthInCtbsY * tbY + tbX;
|
||||
|
||||
MinTbAddrZs[ x ][ y ] = CtbAddrRsToTs[ ctbAddrRs ] << ( ( CtbLog2SizeY - Log2MinTrafoSize ) * 2 );
|
||||
for( i = 0, p = 0; i < ( CtbLog2SizeY - Log2MinTrafoSize ); i++ ) {
|
||||
m = 1 << i;
|
||||
p += ( m & x ? m * m : 0 ) + ( m & y ? 2 * m * m : 0 );
|
||||
}
|
||||
MinTbAddrZs[ x ][ y ] += p;
|
||||
}
|
||||
}
|
||||
|
||||
vSliceAddrRs.resize(PicSizeInCtbsY, -1);
|
||||
std::fill(vSliceAddrRs.begin(), vSliceAddrRs.end(), -1);
|
||||
|
||||
for(i = 0; i < 3; i++)
|
||||
Sao[i].resize(PicWidthInCtbsY, std::vector<SAO>(PicHeightInCtbsY));
|
||||
|
||||
for(Bs16u log2BlockSize = 0; log2BlockSize < 4; log2BlockSize ++){
|
||||
Bs16u blkSize = ( 1 << log2BlockSize );
|
||||
Bs16u sz = blkSize * blkSize;
|
||||
|
||||
ScanOrder[log2BlockSize][0].resize(sz);
|
||||
i = 0; x = 0; y = 0;
|
||||
while( 1 ) {
|
||||
while( y >= 0 ) {
|
||||
if( x < blkSize && y < blkSize ) {
|
||||
ScanOrder[log2BlockSize][0][ i ][ 0 ] = x;
|
||||
ScanOrder[log2BlockSize][0][ i ][ 1 ] = y;
|
||||
i++;
|
||||
}
|
||||
y--;
|
||||
x++;
|
||||
}
|
||||
y = x;
|
||||
x = 0;
|
||||
if( i >= sz )
|
||||
break;
|
||||
}
|
||||
|
||||
ScanOrder[log2BlockSize][1].resize(sz);
|
||||
i = 0;
|
||||
for( y = 0; y < blkSize; y++ ){
|
||||
for( x = 0; x < blkSize; x++ ) {
|
||||
ScanOrder[log2BlockSize][1][ i ][ 0 ] = x;
|
||||
ScanOrder[log2BlockSize][1][ i ][ 1 ] = y;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
ScanOrder[log2BlockSize][2].resize(sz);
|
||||
i = 0;
|
||||
for( x = 0; x < blkSize; x++ ){
|
||||
for( y = 0; y < blkSize; y++ ) {
|
||||
ScanOrder[log2BlockSize][2][ i ][ 0 ] = x;
|
||||
ScanOrder[log2BlockSize][2][ i ][ 1 ] = y;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool SDecCtx::zAvailableN(Bs16s xCurr, Bs16s yCurr, Bs16s xNbY, Bs16s yNbY){
|
||||
Bs32s minBlockAddrCurr = MinTbAddrZs[ xCurr >> Log2MinTrafoSize ][ yCurr >> Log2MinTrafoSize ];
|
||||
Bs32s minBlockAddrN = -1;
|
||||
Bs32u CtbAddrInTsCurr = CtbAddrRsToTs[(yCurr>>CtbLog2SizeY)*PicWidthInCtbsY + (xCurr>>CtbLog2SizeY)];
|
||||
Bs32u CtbAddrInTsN = 0;
|
||||
|
||||
if( xNbY >= 0 && yNbY >= 0
|
||||
&& xNbY < (Bs32s)slice->sps->pic_width_in_luma_samples
|
||||
&& yNbY < (Bs32s)slice->sps->pic_height_in_luma_samples){
|
||||
minBlockAddrN = MinTbAddrZs[ xNbY >> Log2MinTrafoSize ][ yNbY >> Log2MinTrafoSize ];
|
||||
CtbAddrInTsN = CtbAddrRsToTs[(yNbY>>CtbLog2SizeY)*PicWidthInCtbsY + (xNbY>>CtbLog2SizeY)];
|
||||
}
|
||||
|
||||
if ( minBlockAddrN < 0
|
||||
|| minBlockAddrN > minBlockAddrCurr
|
||||
|| vSliceAddrRs[CtbAddrInTsN] != vSliceAddrRs[CtbAddrInTsCurr]
|
||||
|| TileId[CtbAddrInTsN] != TileId[CtbAddrInTsCurr])
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<class T> T* get_unit(T& cqt, Bs16u x, Bs16u y){
|
||||
if(cqt.split){
|
||||
T* res = 0;
|
||||
|
||||
for(Bs16u i = 0; i < 4; i++){
|
||||
T* t = get_unit(cqt.split[i], x, y);
|
||||
|
||||
if(t->x > x || t->y > y){
|
||||
continue;
|
||||
}
|
||||
|
||||
res = t;
|
||||
}
|
||||
|
||||
if(res){
|
||||
return res;
|
||||
}
|
||||
}
|
||||
return &cqt;
|
||||
}
|
||||
|
||||
CQT* SDecCtx::get(Bs16u x, Bs16u y){
|
||||
Bs16u CtbAddrInRs = (y>>CtbLog2SizeY)*PicWidthInCtbsY + (x>>CtbLog2SizeY);
|
||||
return get_unit(ctu[CtbAddrInRs].cqt, x, y);
|
||||
}
|
||||
|
||||
TransTree* SDecCtx::getTU(Bs16u x, Bs16u y) {
|
||||
CQT* cqt = get(x, y);
|
||||
if (!cqt || !cqt->tu)
|
||||
return 0;
|
||||
return get_unit(*cqt->tu, x, y);
|
||||
}
|
||||
|
||||
void SDecCtx::updateIntraPredModeY(CQT& cqt){
|
||||
Bs16u nCbS = ( 1 << (CtbLog2SizeY - cqt.CtDepth) );
|
||||
Bs16u pbOffset = ( PartMode(cqt) == PART_NxN ) ? ( nCbS / 2 ) : nCbS;
|
||||
|
||||
for(Bs16u j = 0; j < nCbS/pbOffset; j ++ ){
|
||||
for(Bs16u i = 0; i < nCbS/pbOffset; i ++ ){
|
||||
Bs16u x0 = cqt.x + j*pbOffset;
|
||||
Bs16u y0 = cqt.y + i*pbOffset;
|
||||
Bs8s mode = IntraPredModeY(x0, y0, &cqt);
|
||||
|
||||
for(Bs16u xIdx = (x0>>Log2MinTrafoSize); xIdx < ((x0>>Log2MinTrafoSize) + (pbOffset>>Log2MinTrafoSize)); xIdx++){
|
||||
for(Bs16u yIdx = (y0>>Log2MinTrafoSize); yIdx < ((y0>>Log2MinTrafoSize) + (pbOffset>>Log2MinTrafoSize)); yIdx++){
|
||||
vIntraPredModeY[xIdx][yIdx] = mode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Bs8u SDecCtx::IntraPredModeY(Bs16u xPb, Bs16u yPb, CQT* _cqt){
|
||||
Bs8s& IntraPredModeY = vIntraPredModeY[xPb >> Log2MinTrafoSize][yPb >> Log2MinTrafoSize];
|
||||
|
||||
if(IntraPredModeY >= 0){
|
||||
return IntraPredModeY;
|
||||
}
|
||||
|
||||
CQT* cqt = _cqt ? _cqt : get(xPb, yPb);
|
||||
Bs16u nCbS = ( 1 << (CtbLog2SizeY - cqt->CtDepth) );
|
||||
Bs16u pbOffset = ( PartMode(*cqt) == PART_NxN ) ? ( nCbS / 2 ) : nCbS;
|
||||
Bs8u xIdx = (xPb - cqt->x) / pbOffset;
|
||||
Bs8u yIdx = (yPb - cqt->y) / pbOffset;
|
||||
CQT::LumaPred& lp = cqt->luma_pred[xIdx][yIdx];
|
||||
bool availableX[2] = { zAvailableN(xPb, yPb, xPb - 1, yPb), zAvailableN(xPb, yPb, xPb, yPb - 1) };
|
||||
Bs8u candIntraPredModeX[2] = {0,};
|
||||
Bs8u candModeList[3] = {0,};
|
||||
|
||||
for(Bs16u i = 0; i < 2; i++){
|
||||
if(!availableX[i]){
|
||||
candIntraPredModeX[i] = 1;
|
||||
} else {
|
||||
CQT* cqtX = get(xPb - !i, yPb - i);
|
||||
if(CuPredMode(*cqtX) != MODE_INTRA || cqtX->pcm_flag ){
|
||||
candIntraPredModeX[i] = 1;
|
||||
} else if(i && ((yPb - i) < (( yPb >> CtbLog2SizeY ) << CtbLog2SizeY ))){
|
||||
candIntraPredModeX[i] = 1;
|
||||
} else {
|
||||
candIntraPredModeX[i] = this->IntraPredModeY(xPb - !i, yPb - i, cqtX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(candIntraPredModeX[0] == candIntraPredModeX[1]){
|
||||
if(candIntraPredModeX[0] < 2){
|
||||
candModeList[0] = 0;
|
||||
candModeList[1] = 1;
|
||||
candModeList[2] = 26;
|
||||
} else {
|
||||
candModeList[0] = candIntraPredModeX[0];
|
||||
candModeList[1] = 2 + ( ( candIntraPredModeX[0] + 29 ) % 32 );
|
||||
candModeList[2] = 2 + ( ( candIntraPredModeX[0] - 2 + 1 ) % 32 );
|
||||
}
|
||||
} else {
|
||||
candModeList[0] = candIntraPredModeX[0];
|
||||
candModeList[1] = candIntraPredModeX[1];
|
||||
|
||||
if(candModeList[0] != 0 && candModeList[1] != 0){
|
||||
candModeList[2] = 0;
|
||||
} else if(candModeList[0] != 1 && candModeList[1] != 1){
|
||||
candModeList[2] = 1;
|
||||
} else {
|
||||
candModeList[2] = 26;
|
||||
}
|
||||
}
|
||||
|
||||
if(lp.prev_intra_luma_pred_flag)
|
||||
return IntraPredModeY = candModeList[lp.mpm_idx];
|
||||
|
||||
if(candModeList[0] > candModeList[1])
|
||||
std::swap(candModeList[0], candModeList[1]);
|
||||
|
||||
if(candModeList[0] > candModeList[2])
|
||||
std::swap(candModeList[0], candModeList[2]);
|
||||
|
||||
if(candModeList[1] > candModeList[2])
|
||||
std::swap(candModeList[1], candModeList[2]);
|
||||
|
||||
IntraPredModeY = lp.rem_intra_luma_pred_mode;
|
||||
for(Bs16u i = 0; i < 3; i++)
|
||||
IntraPredModeY += (IntraPredModeY >= candModeList[i]);
|
||||
|
||||
return IntraPredModeY;
|
||||
}
|
||||
|
||||
static const Bs8s PredModeY2C[5][5] = {
|
||||
{ 0, 34, 0, 0, 0},
|
||||
{26, 26, 34, 26, 26},
|
||||
{10, 10, 10, 34, 10},
|
||||
{ 1, 1, 1, 1, 34},
|
||||
{-1, 0, 26, 10, 1}
|
||||
};
|
||||
|
||||
inline Bs8u IntraPredModeC(Bs8u IntraPredModeY, Bs8u intra_chroma_pred_mode){
|
||||
Bs8s IntraPredModeC = PredModeY2C[intra_chroma_pred_mode][
|
||||
1 * (IntraPredModeY == 0)
|
||||
+ 2 * (IntraPredModeY == 26)
|
||||
+ 3 * (IntraPredModeY == 10)
|
||||
+ 4 * (IntraPredModeY == 1)
|
||||
];
|
||||
return (IntraPredModeC < 0) ? IntraPredModeY : IntraPredModeC;
|
||||
}
|
||||
|
||||
Bs8u SDecCtx::IntraPredModeC(Bs16u xPb, Bs16u yPb, CQT* _cqt){
|
||||
CQT* cqt = _cqt ? _cqt : get(xPb, yPb);
|
||||
bool xShift = (2 == SubWidthC[slice->sps->chroma_format_idc]);
|
||||
bool yShift = (2 == SubHeightC[slice->sps->chroma_format_idc]);
|
||||
|
||||
return ::IntraPredModeC(
|
||||
IntraPredModeY(xShift ? cqt->x : xPb, yShift ? cqt->y : yPb, cqt), //FIXME: map luma (xPb, yPb) to chroma
|
||||
cqt->intra_chroma_pred_mode );
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
find_path( FEI_INCLUDE mfxfeihevc.h PATHS ${MFX_INCLUDE} )
|
||||
|
||||
include_directories (
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../include
|
||||
)
|
||||
|
||||
list( APPEND LIBS bs_parser_hevc_static )
|
||||
|
||||
set( defs " -DMFX_VERSION_USE_LATEST " )
|
||||
set(DEPENDENCIES pthread)
|
||||
|
||||
make_executable( shortname universal )
|
||||
|
||||
install( TARGETS ${target} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
|
||||
set( defs "" )
|
|
@ -1,184 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{11CDD87B-B0B9-4BA3-BC68-6501053C28A7}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(ProjectDir)..\..\..\..\..\build\win_$(Platform)\$(Configuration)\bin\</OutDir>
|
||||
<IntDir>$(OutDir)..\objs\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(ProjectDir)..\..\..\..\..\build\win_$(Platform)\$(Configuration)\bin\</OutDir>
|
||||
<IntDir>$(OutDir)..\objs\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(ProjectDir)..\..\..\..\..\build\win_$(Platform)\$(Configuration)\bin\</OutDir>
|
||||
<IntDir>$(OutDir)..\objs\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>$(ProjectDir)..\..\..\..\..\build\win_$(Platform)\$(Configuration)\bin\</OutDir>
|
||||
<IntDir>$(OutDir)..\objs\$(ProjectName)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>MFX_VERSION_USE_LATEST;WIN32;_WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\..\api\include;$(ProjectDir)\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)..\..\..\..\..\build\win_$(Platform)\$(Configuration)\lib\;$(INTELMEDIASDKROOT)\lib\$(Platform);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>bs_parser_hevc.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>MFX_VERSION_USE_LATEST;WIN32;_WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\..\api\include;$(ProjectDir)\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<SupportJustMyCode>true</SupportJustMyCode>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)..\..\..\..\..\build\win_$(Platform)\$(Configuration)\lib\;$(INTELMEDIASDKROOT)\lib\$(Platform);$(ProjectDir)..\..\..\..\..\build\win_$(Platform)\$(Configuration)\bin\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>bs_parser_hevc.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\..\api\include;$(ProjectDir)\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<PreprocessorDefinitions>MFX_VERSION_USE_LATEST;WIN64;_WIN64;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)..\..\..\..\..\build\win_$(Platform)\$(Configuration)\lib\;$(INTELMEDIASDKROOT)\lib\$(Platform);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>bs_parser_hevc.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<LinkTimeCodeGeneration>UseFastLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\..\api\include;$(ProjectDir)\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<SupportJustMyCode>true</SupportJustMyCode>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<PreprocessorDefinitions>MFX_VERSION_USE_LATEST;_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)..\..\..\..\..\build\win_$(Platform)\$(Configuration)\lib\;$(INTELMEDIASDKROOT)\lib\$(Platform);$(ProjectDir)..\..\..\..\..\build\win_$(Platform)\$(Configuration)\bin\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<LinkTimeCodeGeneration>UseFastLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
<AdditionalDependencies>bs_parser_hevc.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>xcopy /y /d "$(ProjectDir)..\..\..\..\..\build\win_$(Platform)\$(Configuration)\bin\bs_parser_hevc.dll" "$(OutDir)"</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\bs_parser_hevc.vcxproj">
|
||||
<Project>{6a44b0b8-2d21-4d64-9f0a-d73a2bbb3103}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,678 +0,0 @@
|
|||
// Copyright (c) 2018-2019 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#if MFX_VERSION >= MFX_VERSION_NEXT
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <algorithm>
|
||||
#include <bs_parser++.h>
|
||||
#include "mfxfeihevc.h"
|
||||
|
||||
#define MAX_PU_NUM 4
|
||||
|
||||
struct CUBlock
|
||||
{
|
||||
Bs32u m_AdrX = 0;
|
||||
Bs32u m_AdrY = 0;
|
||||
Bs32u m_Log2CbSize = 0;
|
||||
|
||||
CUBlock(Bs32u adrX, Bs32u adrY, Bs32u log2CbSize) :
|
||||
m_AdrX(adrX),
|
||||
m_AdrY(adrY),
|
||||
m_Log2CbSize(log2CbSize)
|
||||
{};
|
||||
};
|
||||
|
||||
class FileHandler
|
||||
{
|
||||
private:
|
||||
bool m_errorSts = false;
|
||||
FILE* m_pFile = nullptr;
|
||||
|
||||
public:
|
||||
FileHandler(char const* fileName, char const* mode)
|
||||
{
|
||||
if (!fileName) {
|
||||
printf("\nERROR: Unable to read file name with CU/CTU structures\n");
|
||||
m_errorSts = true;// Error sts
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mode) {
|
||||
printf("\nERROR: Unable to read file open mode\n");
|
||||
m_errorSts = true;// Error sts
|
||||
return;
|
||||
}
|
||||
|
||||
if ((m_pFile = fopen(fileName, mode)) == nullptr) {
|
||||
printf("\nERROR: Unable to open the %s file in the FileHandler::FileHandler\n", fileName);
|
||||
m_errorSts = true;// Error sts
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
~FileHandler()
|
||||
{
|
||||
if (m_pFile != nullptr)
|
||||
fclose(m_pFile);
|
||||
};
|
||||
|
||||
bool CheckStatus()
|
||||
{
|
||||
return m_errorSts;
|
||||
};
|
||||
|
||||
template< class T > void Write(T& structure)
|
||||
{
|
||||
size_t elementsWritten = fwrite(&structure, sizeof(structure), 1, m_pFile);
|
||||
if (elementsWritten != 1) {
|
||||
printf("\nERROR: File wasn't written in the FileHandler::WriteFile\n");
|
||||
m_errorSts = true;// Error sts
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
using namespace BS_HEVC2;
|
||||
|
||||
inline bool IsHEVCSlice(Bs32u nut) { return (nut <= 21) && ((nut < 10) || (nut > 15)); }
|
||||
|
||||
#define CHECK_STATUS(code,sts)\
|
||||
bs_sts = (code);\
|
||||
if(bs_sts != (sts)){\
|
||||
printf("FAILED in %s at %s: %i\nReturn code = %i\n", #code, __FILE__, __LINE__, bs_sts);\
|
||||
return bs_sts;\
|
||||
}
|
||||
|
||||
#define ALIGN(value, alignment) (alignment) * ( (value) / (alignment) + (((value) % (alignment)) ? 1 : 0))
|
||||
|
||||
int printUsage(char* argv[])
|
||||
{
|
||||
printf("Parser for HEVC bit-streams dumps fei-specific information.\n");
|
||||
printf("Usage: %s <stream_name> <fei_hevc_pak_ctu> <fei_hevc_pak_cu>\n", argv[0]);
|
||||
printf(" or: %s <stream_name> -pic_file <pic_refinfo>\n", argv[0]);
|
||||
printf(" or: %s <stream_name> -multi_pak_str <multi_repack_output_file>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
BSErr ConvertPredModeToFeiPredMode(Bs16u const predModeParser/*in*/, mfxFeiHevcPakCuRecordV0& pakCuRecorderV0/*out*/)
|
||||
{
|
||||
switch (predModeParser) {
|
||||
case MODE_INTER:
|
||||
pakCuRecorderV0.PredMode = (1 & 0x01);
|
||||
break;
|
||||
case MODE_INTRA:
|
||||
pakCuRecorderV0.PredMode = (0 & 0x01);
|
||||
break;
|
||||
case MODE_SKIP:
|
||||
pakCuRecorderV0.PredMode = (1 & 0x01);
|
||||
break;
|
||||
default:
|
||||
return BS_ERR_INVALID_PARAMS;
|
||||
}
|
||||
return BS_ERR_NONE;
|
||||
}
|
||||
|
||||
mfxU32 GetIntraChromaModeFEI(Bs8u intraPredModeC_0_0)
|
||||
{
|
||||
switch (intraPredModeC_0_0)
|
||||
{
|
||||
case 0://Planar
|
||||
return 2;
|
||||
case 1://DC
|
||||
return 5;
|
||||
case 10://Horiz
|
||||
return 4;
|
||||
case 26://Vertic
|
||||
return 3;
|
||||
default://DM
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void SetIntraPredModeFEI(const CU* pCU, mfxFeiHevcPakCuRecordV0& pakCuRecorderV0)
|
||||
{
|
||||
if(pCU == nullptr)
|
||||
throw std::string("ERROR: SetIntraPredModeFEI: pCU is equal to nullptr");
|
||||
|
||||
// Luma
|
||||
if (pCU->IntraPredModeY[0][0] > 34
|
||||
|| pCU->IntraPredModeY[1][0] > 34
|
||||
|| pCU->IntraPredModeY[0][1] > 34
|
||||
|| pCU->IntraPredModeY[1][1] > 34)
|
||||
{
|
||||
throw std::string("ERROR: SetIntraPredModeFEI: incorrect IntraPredModeY[X][X]\n");
|
||||
}
|
||||
|
||||
pakCuRecorderV0.IntraMode0 = pCU->IntraPredModeY[0][0];
|
||||
pakCuRecorderV0.IntraMode1 = pCU->IntraPredModeY[1][0];
|
||||
pakCuRecorderV0.IntraMode2 = pCU->IntraPredModeY[0][1];
|
||||
pakCuRecorderV0.IntraMode3 = pCU->IntraPredModeY[1][1];
|
||||
|
||||
// Chroma
|
||||
// For ChromaArrayType != 3 (4:4:4) all elements of the array intra_chroma_pred_mode[2][2] are equal
|
||||
// Table 7.3.8.5 from ITU-T H.265 (V4)
|
||||
// HEVC FEI ENCODE on SKL supports 4:2:0 mode only
|
||||
if (pCU->IntraPredModeC[0][0] > 34)
|
||||
{
|
||||
throw std::string("ERROR: SetIntraPredModeFEI: incorrect IntraPredModeC[0][0]");
|
||||
}
|
||||
|
||||
pakCuRecorderV0.IntraChromaMode = GetIntraChromaModeFEI(pCU->IntraPredModeC[0][0]);
|
||||
}
|
||||
|
||||
void SetLevel2(mfxFeiHevcPakCtuRecordV0& pakCtuRecordV0, Bs32u& startShift, Bs32u ctbLog2SizeY, Bs32u log2CbSize, Bs32u idxQuadTreeLevel2, Bs32u idxQuadTreeLevel1)
|
||||
{
|
||||
if (log2CbSize == ctbLog2SizeY - 2)
|
||||
{
|
||||
startShift++;
|
||||
}
|
||||
else if (log2CbSize == ctbLog2SizeY - 3)
|
||||
{
|
||||
switch (idxQuadTreeLevel1)
|
||||
{
|
||||
case 0:
|
||||
pakCtuRecordV0.SplitLevel2Part0 |= 1 << idxQuadTreeLevel2;
|
||||
break;
|
||||
case 1:
|
||||
pakCtuRecordV0.SplitLevel2Part1 |= 1 << idxQuadTreeLevel2;
|
||||
break;
|
||||
case 2:
|
||||
pakCtuRecordV0.SplitLevel2Part2 |= 1 << idxQuadTreeLevel2;
|
||||
break;
|
||||
case 3:
|
||||
pakCtuRecordV0.SplitLevel2Part3 |= 1 << idxQuadTreeLevel2;
|
||||
break;
|
||||
}
|
||||
startShift += 4;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void SetLevel1(mfxFeiHevcPakCtuRecordV0& pakCtuRecordV0, Bs32u& startShift, Bs32u ctbLog2SizeY, const std::vector<CUBlock>& vecCUs, Bs32u idxQuadTreeLevel1)
|
||||
{
|
||||
Bs32u log2CbSize = vecCUs.at(startShift).m_Log2CbSize;
|
||||
|
||||
if (log2CbSize == ctbLog2SizeY - 1)
|
||||
{
|
||||
startShift++;
|
||||
}
|
||||
else if ((log2CbSize == ctbLog2SizeY - 2) || (log2CbSize == ctbLog2SizeY - 3))
|
||||
{
|
||||
pakCtuRecordV0.SplitLevel1 |= 1 << idxQuadTreeLevel1;
|
||||
|
||||
for (Bs32u idxQuadTreeLevel2 = 0; idxQuadTreeLevel2 < 4; ++idxQuadTreeLevel2)
|
||||
{
|
||||
SetLevel2(pakCtuRecordV0, startShift, ctbLog2SizeY, vecCUs.at(startShift).m_Log2CbSize, idxQuadTreeLevel2, idxQuadTreeLevel1);
|
||||
}
|
||||
}
|
||||
else
|
||||
throw std::string("ERROR: SetLevel1: incorrect Cb size");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool IsInQuarter(Bs32u idxQuadTreeLevel1, CUBlock cu, Bs32u ctbLog2SizeY)
|
||||
{
|
||||
Bs32u ctuSize = 1 << ctbLog2SizeY;
|
||||
Bs32u ctuQuarterLog2SizeY = ctbLog2SizeY - 1;
|
||||
Bs32u adrXInsideCTU = cu.m_AdrX % ctuSize;
|
||||
Bs32u adrYInsideCTU = cu.m_AdrY % ctuSize;
|
||||
|
||||
return (((adrYInsideCTU >> ctuQuarterLog2SizeY) << 1) + (adrXInsideCTU >> ctuQuarterLog2SizeY)) == idxQuadTreeLevel1;
|
||||
}
|
||||
|
||||
void SetLevel0(mfxFeiHevcPakCtuRecordV0& pakCtuRecordV0, Bs32u ctbLog2SizeY, const std::vector<CUBlock>& vecCUs)
|
||||
{
|
||||
Bs32u startShift = 0;
|
||||
if (vecCUs.at(startShift).m_Log2CbSize == ctbLog2SizeY)
|
||||
return;
|
||||
else
|
||||
{
|
||||
pakCtuRecordV0.SplitLevel0 = 1;
|
||||
// If we have 4 parts of the CTU, we need to check each part in the loop
|
||||
for (Bs32u idxQuadTreeLevel1 = 0; idxQuadTreeLevel1 < 4; ++idxQuadTreeLevel1)
|
||||
{
|
||||
// This check is needed for work with different resolution.
|
||||
// If last CTU in the line hasn't got right quarters
|
||||
// or CTU in the last line hasn't got bottom quarters.
|
||||
// Function will be called only for first CU in quarter of the CTU
|
||||
if (startShift >= vecCUs.size() || !IsInQuarter(idxQuadTreeLevel1, vecCUs.at(startShift), ctbLog2SizeY))
|
||||
continue;
|
||||
SetLevel1(pakCtuRecordV0, startShift, ctbLog2SizeY, vecCUs, idxQuadTreeLevel1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
inline void SetInterpredIdc(mfxFeiHevcPakCuRecordV0& pakCuRecordV0, Bs16u interpredIdc, Bs32u countPU)
|
||||
{
|
||||
if (interpredIdc >= 3)
|
||||
throw std::string("ERROR: SetInterpredIdc: unsupported value for InterpredIdc");
|
||||
else
|
||||
pakCuRecordV0.InterpredIdc |= interpredIdc << (2 * countPU);
|
||||
}
|
||||
|
||||
inline void SetPURefIdx(mfxFeiHevcPakCuRecordV0& pakCuRecordV0, PU* pPU, Bs32u countPU)
|
||||
{
|
||||
switch (countPU)
|
||||
{
|
||||
case 0:
|
||||
pakCuRecordV0.RefIdx[0].Ref0 = pPU->ref_idx_l0;
|
||||
pakCuRecordV0.RefIdx[1].Ref0 = pPU->ref_idx_l1;
|
||||
break;
|
||||
case 1:
|
||||
pakCuRecordV0.RefIdx[0].Ref1 = pPU->ref_idx_l0;
|
||||
pakCuRecordV0.RefIdx[1].Ref1 = pPU->ref_idx_l1;
|
||||
break;
|
||||
case 2:
|
||||
pakCuRecordV0.RefIdx[0].Ref2 = pPU->ref_idx_l0;
|
||||
pakCuRecordV0.RefIdx[1].Ref2 = pPU->ref_idx_l1;
|
||||
break;
|
||||
case 3:
|
||||
pakCuRecordV0.RefIdx[0].Ref3 = pPU->ref_idx_l0;
|
||||
pakCuRecordV0.RefIdx[1].Ref3 = pPU->ref_idx_l1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int DumpPicStruct(BS_HEVC2_parser& parser, const char* name)
|
||||
{
|
||||
std::ofstream ofs(name, std::ofstream::out);
|
||||
if (!ofs.is_open())
|
||||
return 1;
|
||||
|
||||
//common with asg-hevc
|
||||
struct PictureInfo
|
||||
{
|
||||
Bs32s orderCount = -1; // display order
|
||||
Bs32s codingOrder = -1;
|
||||
Bs32u type = 0; // IPB, IDR
|
||||
Bs32u picStruct = 0; // TF/BF
|
||||
};
|
||||
|
||||
struct RefState
|
||||
{
|
||||
PictureInfo picture;
|
||||
std::vector<Bs32s> DPB; // stores FrameOrder (POC)
|
||||
std::vector<Bs32s> RefListActive[2]; // (POC), any from DPB, can be repeated
|
||||
};
|
||||
|
||||
Bs32u recordsWritten = 0;
|
||||
Bs32s dispOrderIDR = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
BS_HEVC2::NALU* pNALU = nullptr;
|
||||
BSErr bs_sts = parser.parse_next_au(pNALU);
|
||||
|
||||
if (bs_sts == BS_ERR_NOT_IMPLEMENTED)
|
||||
continue;
|
||||
if (bs_sts != BS_ERR_NONE)
|
||||
break;
|
||||
|
||||
RefState record;
|
||||
record.DPB.reserve(16);
|
||||
record.RefListActive[0].reserve(8);
|
||||
record.RefListActive[1].reserve(8);
|
||||
record.picture.type = 0; // updated in different nalu
|
||||
record.picture.picStruct = MFX_PICSTRUCT_PROGRESSIVE; // for if no SEI PT
|
||||
|
||||
bool isFirstSlice = true;
|
||||
for (auto pNALUIdx = pNALU; pNALUIdx != nullptr; pNALUIdx = pNALUIdx->next)
|
||||
{
|
||||
if (IsHEVCSlice(pNALUIdx->nal_unit_type) && isFirstSlice) // slice
|
||||
{
|
||||
if (pNALUIdx->nal_unit_type == NALU_TYPE::IDR_W_RADL || pNALUIdx->nal_unit_type == NALU_TYPE::IDR_N_LP) // IDR, REF
|
||||
{
|
||||
dispOrderIDR = recordsWritten; // assume IDR POC == codingOrder
|
||||
record.picture.type |= MFX_FRAMETYPE_IDR | MFX_FRAMETYPE_REF;
|
||||
}
|
||||
if (pNALUIdx->nal_unit_type >= NALU_TYPE::BLA_W_LP && pNALUIdx->nal_unit_type <= NALU_TYPE::CRA_NUT) // other IRAP -> REF
|
||||
{
|
||||
record.picture.type |= MFX_FRAMETYPE_REF;
|
||||
}
|
||||
else if (pNALUIdx->nal_unit_type <= NALU_TYPE::RASL_R && (pNALUIdx->nal_unit_type & 1)) // !IRAP, REF
|
||||
record.picture.type |= MFX_FRAMETYPE_REF;
|
||||
|
||||
record.picture.orderCount = pNALUIdx->slice->POC + dispOrderIDR;
|
||||
if (pNALUIdx->slice->pps->curr_pic_ref_enabled_flag) // check
|
||||
record.picture.type |= MFX_FRAMETYPE_REF;
|
||||
|
||||
record.picture.type |= (pNALUIdx->slice->type == SLICE_TYPE::I) ? MFX_FRAMETYPE_I :
|
||||
((pNALUIdx->slice->type == SLICE_TYPE::P) ? MFX_FRAMETYPE_P : MFX_FRAMETYPE_B);
|
||||
for (Bs32u i = 0; i < pNALUIdx->slice->strps.NumDeltaPocs; i++) // ignore LT
|
||||
record.DPB.push_back(pNALUIdx->slice->DPB[i].POC + dispOrderIDR);
|
||||
for (Bs32u i = 0; i < pNALUIdx->slice->num_ref_idx_l0_active; i++)
|
||||
record.RefListActive[0].push_back(pNALUIdx->slice->L0[i].POC + dispOrderIDR);
|
||||
for (Bs32u i = 0; i < pNALUIdx->slice->num_ref_idx_l1_active; i++)
|
||||
record.RefListActive[1].push_back(pNALUIdx->slice->L1[i].POC + dispOrderIDR);
|
||||
isFirstSlice = false; // use only first slice, others must provide equal parameters
|
||||
}
|
||||
|
||||
if (pNALUIdx->nal_unit_type != NALU_TYPE::PREFIX_SEI_NUT) // not SEI
|
||||
continue;
|
||||
|
||||
for (auto sei = pNALUIdx->sei; sei != nullptr; sei = sei->next)
|
||||
{
|
||||
if (sei->payloadType != SEI_TYPE::SEI_PICTURE_TIMING) // not Picture Timing
|
||||
continue;
|
||||
switch (sei->pt->pic_struct)
|
||||
{
|
||||
case PIC_STRUCT::TOP: case PIC_STRUCT::TOP_PREVBOT: case PIC_STRUCT::TOP_NEXTBOT:
|
||||
record.picture.picStruct = MFX_PICSTRUCT_FIELD_TOP;
|
||||
break;
|
||||
case PIC_STRUCT::BOT: case PIC_STRUCT::BOT_PREVTOP: case PIC_STRUCT::BOT_NEXTTOP:
|
||||
record.picture.picStruct = MFX_PICSTRUCT_FIELD_BOTTOM;
|
||||
break;
|
||||
default:
|
||||
break; // progressive
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (record.picture.orderCount != -1 && record.picture.type != 0)
|
||||
{
|
||||
record.picture.codingOrder = recordsWritten;
|
||||
|
||||
const char separator = '|';
|
||||
ofs << std::setw(3) << record.picture.orderCount << ' '
|
||||
<< std::hex << std::showbase << std::setw(3 + 2) << record.picture.type << ' '
|
||||
<< std::setw(3 + 2) << record.picture.picStruct << std::dec;
|
||||
if (ofs.fail())
|
||||
throw std::string("ERROR: PicStruct buffer writing failed");
|
||||
for (Bs32u list = 0; list < 2; list++)
|
||||
{
|
||||
ofs << ' ' << separator;
|
||||
for (Bs32u i = 0; i < 8; i++)
|
||||
ofs << ' ' << std::setw(3) << (i < record.RefListActive[list].size() ? record.RefListActive[list][i] : -1);
|
||||
}
|
||||
std::sort(record.DPB.begin(), record.DPB.end()); // to simplify matching
|
||||
ofs << ' ' << separator;
|
||||
for (Bs32u i = 0; i < 16; i++)
|
||||
ofs << ' ' << std::setw(3) << (i < record.DPB.size() ? record.DPB[i] : -1);
|
||||
ofs << std::endl;
|
||||
recordsWritten ++;
|
||||
}
|
||||
}
|
||||
|
||||
ofs.close();
|
||||
|
||||
if (recordsWritten==0)
|
||||
printf("\nERROR: NO picture structure info in stream\n");
|
||||
|
||||
return (recordsWritten==0); // 0 for OK
|
||||
}
|
||||
|
||||
struct sMultiPak
|
||||
{
|
||||
Bs32u NumBytesInNalUnit;
|
||||
Bs8u SliceQP;
|
||||
};
|
||||
|
||||
int DumpMultiPassPak(BS_HEVC2_parser& parser, const char* name)
|
||||
{
|
||||
FILE *fMultiPak = nullptr;
|
||||
if ((fMultiPak = fopen(name, "wb")) == nullptr)
|
||||
throw std::string("ERROR: Opening multipasspak file failed");
|
||||
|
||||
sMultiPak multiPakInfo;
|
||||
BSErr bs_sts = BS_ERR_NONE;
|
||||
BS_HEVC2::NALU* pNALU = nullptr;
|
||||
|
||||
while (true)
|
||||
{
|
||||
bs_sts = parser.parse_next_au(pNALU);
|
||||
|
||||
if (bs_sts == BS_ERR_NOT_IMPLEMENTED)
|
||||
continue;
|
||||
if (bs_sts)
|
||||
break;
|
||||
|
||||
multiPakInfo.NumBytesInNalUnit = 0;
|
||||
for (; pNALU; pNALU = pNALU->next)
|
||||
{
|
||||
if (!IsHEVCSlice(pNALU->nal_unit_type))
|
||||
continue;
|
||||
|
||||
if (!pNALU->slice)
|
||||
throw std::string("ERROR: Invalid parser pointer");
|
||||
|
||||
multiPakInfo.SliceQP = 0xFF; //0xFF indicates skipping
|
||||
for (auto pCTU = pNALU->slice->ctu; pCTU; pCTU = pCTU->Next)
|
||||
{
|
||||
for (auto pCU = pCTU->Cu; pCU; pCU = pCU->Next)
|
||||
{
|
||||
if (pCU->palette_mode_flag)
|
||||
{
|
||||
multiPakInfo.SliceQP = (Bs8u)pCU->QpY;
|
||||
break;
|
||||
}
|
||||
|
||||
for (auto pTU = pCU->Tu; pTU; pTU = pTU->Next)
|
||||
{
|
||||
if (pTU->cbf_luma
|
||||
|| pTU->cbf_cb
|
||||
|| pTU->cbf_cb1
|
||||
|| pTU->cbf_cr
|
||||
|| pTU->cbf_cr1)
|
||||
{
|
||||
multiPakInfo.SliceQP = (Bs8u)pCU->QpY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (multiPakInfo.SliceQP != 0xFF)
|
||||
break;
|
||||
}
|
||||
|
||||
if (multiPakInfo.SliceQP != 0xFF)
|
||||
break;
|
||||
}
|
||||
|
||||
multiPakInfo.NumBytesInNalUnit += pNALU->NumBytesInNalUnit;
|
||||
}
|
||||
|
||||
//Write into the Multi-pass PAK file
|
||||
size_t sizeWrite = 0;
|
||||
sizeWrite = fwrite(&multiPakInfo, sizeof(sMultiPak), 1, fMultiPak);
|
||||
if (sizeWrite != 1)
|
||||
{
|
||||
fclose(fMultiPak);
|
||||
throw std::string("ERROR: Writing to multipasspak file failed");
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fMultiPak);
|
||||
|
||||
CHECK_STATUS(bs_sts, BS_ERR_MORE_DATA);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // MFX_VERSION
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
#if MFX_VERSION < MFX_VERSION_NEXT
|
||||
std::cout << "ERROR: For correct work minimal API MFX_VERSION_NEXT version is required" << std::endl;
|
||||
return -1;
|
||||
#else
|
||||
try
|
||||
{
|
||||
if (argc < 4) {
|
||||
return printUsage(argv);
|
||||
}
|
||||
BSErr bs_sts = BS_ERR_NONE;
|
||||
|
||||
BS_HEVC2_parser parser(PARSE_SSD);
|
||||
|
||||
CHECK_STATUS(parser.open(argv[1]), BS_ERR_NONE);
|
||||
|
||||
if (strcmp(argv[2], "-pic_file") == 0)
|
||||
{
|
||||
return DumpPicStruct(parser, argv[3]);
|
||||
}
|
||||
|
||||
if (strcmp(argv[2], "-multi_pak_str") == 0)
|
||||
{
|
||||
return DumpMultiPassPak(parser, argv[3]);
|
||||
}
|
||||
|
||||
// Opening of the file for CTU
|
||||
FileHandler handlerCTU(argv[2], "wb");
|
||||
if (handlerCTU.CheckStatus())
|
||||
throw std::string("ERROR: main: issue with file opening");
|
||||
|
||||
// Opening of the file for CU
|
||||
FileHandler handlerCU(argv[3], "wb");
|
||||
if (handlerCU.CheckStatus())
|
||||
throw std::string("ERROR: main: issue with file opening");
|
||||
|
||||
// CTU information
|
||||
mfxFeiHevcPakCtuRecordV0 pakCtuRecordV0;
|
||||
memset(&pakCtuRecordV0, 0, sizeof(pakCtuRecordV0));
|
||||
|
||||
// CU information
|
||||
mfxFeiHevcPakCuRecordV0 pakCuRecordV0;
|
||||
memset(&pakCuRecordV0, 0, sizeof(pakCuRecordV0));
|
||||
|
||||
BS_HEVC2::NALU* pNALU = nullptr;
|
||||
|
||||
while (true)
|
||||
{
|
||||
bs_sts = parser.parse_next_au(pNALU);
|
||||
|
||||
if (bs_sts == BS_ERR_NOT_IMPLEMENTED)
|
||||
continue;
|
||||
if (bs_sts)
|
||||
break;
|
||||
|
||||
for (auto pNALUIdx = pNALU; pNALUIdx; pNALUIdx = pNALUIdx->next)
|
||||
{
|
||||
if (!IsHEVCSlice(pNALUIdx->nal_unit_type))
|
||||
continue;
|
||||
|
||||
auto& slice = *pNALUIdx->slice;
|
||||
|
||||
// CTB_Y size calculating
|
||||
Bs32u minCbLog2SizeY = slice.sps->log2_min_luma_coding_block_size_minus3 + 3;
|
||||
Bs32u ctbLog2SizeY = minCbLog2SizeY + slice.sps->log2_diff_max_min_luma_coding_block_size;
|
||||
Bs32u ctbSizeY = 1 << ctbLog2SizeY;
|
||||
|
||||
// Parameters for FEI compatibility
|
||||
Bs32u maxNumCuInCtu = (1 << (slice.sps->log2_diff_max_min_luma_coding_block_size + slice.sps->log2_diff_max_min_luma_coding_block_size));
|
||||
|
||||
// Number CTB_Y in the line
|
||||
Bs32u widthInCTU = ALIGN(slice.sps->pic_width_in_luma_samples, ctbSizeY) >> ctbLog2SizeY;
|
||||
|
||||
Bs32u countCTU = 0;
|
||||
for (auto pCTU = slice.ctu; pCTU; pCTU = pCTU->Next, ++countCTU)
|
||||
{
|
||||
// pakCtuRecordV0 cleaning
|
||||
memset(&pakCtuRecordV0, 0, sizeof(pakCtuRecordV0));
|
||||
|
||||
std::vector<CUBlock> vecCUs;
|
||||
vecCUs.reserve(maxNumCuInCtu);
|
||||
|
||||
Bs16u countCU = 0;
|
||||
for (auto pCU = pCTU->Cu; pCU; pCU = pCU->Next, ++countCU)
|
||||
{
|
||||
// pakCuRecordV0 cleaning
|
||||
memset(&pakCuRecordV0, 0, sizeof(pakCuRecordV0));
|
||||
|
||||
vecCUs.emplace_back((Bs32u)pCU->x, (Bs32u)pCU->y, (Bs32u)pCU->log2CbSize);
|
||||
|
||||
// Set information about prediction and partition mode
|
||||
CHECK_STATUS(ConvertPredModeToFeiPredMode(pCU->PredMode, pakCuRecordV0), BS_ERR_NONE);
|
||||
pakCuRecordV0.PartMode = pCU->PartMode;// need to investigate
|
||||
|
||||
// Set information about Intra prediction mode
|
||||
if (pCU->PredMode == MODE_INTRA)
|
||||
SetIntraPredModeFEI(pCU, pakCuRecordV0);
|
||||
|
||||
// Set information about MVs
|
||||
Bs32u countPU = 0;
|
||||
for (auto pPU = pCU->Pu; pPU; pPU = pPU->Next, ++countPU)
|
||||
{
|
||||
if (countPU >= MAX_PU_NUM) // CU can't include more than 4 PUs
|
||||
throw std::string("ERROR: main: Number of PUs more than 4");
|
||||
|
||||
SetInterpredIdc(pakCuRecordV0, pPU->inter_pred_idc, countPU);
|
||||
|
||||
for (Bs32u listIdx = 0; listIdx < 2; listIdx++)
|
||||
{
|
||||
pakCuRecordV0.MVs[listIdx].x[countPU] = pPU->MvLX[listIdx][0];
|
||||
pakCuRecordV0.MVs[listIdx].y[countPU] = pPU->MvLX[listIdx][1];
|
||||
}
|
||||
|
||||
SetPURefIdx(pakCuRecordV0, pPU, countPU);
|
||||
}
|
||||
|
||||
// Writing CU information into file
|
||||
handlerCU.Write(pakCuRecordV0);
|
||||
if (handlerCU.CheckStatus())
|
||||
throw std::string("ERROR: main: issue with file writing");
|
||||
}// End for (auto pCU = pCTU->Cu; pCU; pCU = pCU->Next, ++countCU)
|
||||
|
||||
if (countCU < maxNumCuInCtu)
|
||||
{
|
||||
// Alignment with zero-padding for FEI CU buffer
|
||||
memset(&pakCuRecordV0, 0, sizeof(pakCuRecordV0));
|
||||
|
||||
for (Bs32u idxEmptyCU = countCU; idxEmptyCU < maxNumCuInCtu; ++idxEmptyCU)
|
||||
{
|
||||
// Writing zero CU information into file
|
||||
handlerCU.Write(pakCuRecordV0);
|
||||
if (handlerCU.CheckStatus())
|
||||
throw std::string("ERROR: main: issue with file writing");
|
||||
}
|
||||
}
|
||||
|
||||
SetLevel0(pakCtuRecordV0, ctbLog2SizeY, vecCUs);
|
||||
|
||||
pakCtuRecordV0.CuCountMinus1 = countCU - 1;
|
||||
pakCtuRecordV0.CtuAddrX = countCTU % widthInCTU;
|
||||
pakCtuRecordV0.CtuAddrY = countCTU / widthInCTU;
|
||||
|
||||
// Writing CTU information into file
|
||||
handlerCTU.Write(pakCtuRecordV0);
|
||||
if (handlerCTU.CheckStatus())
|
||||
throw std::string("ERROR: main: issue with file writing");
|
||||
} // End for (auto pCTU = slice.ctu; pCTU; pCTU = pCTU->Next)
|
||||
}// End for (auto pNALUIdx = pNALU; pNALUIdx; pNALUIdx = pNALUIdx->next)
|
||||
}// End while(1)
|
||||
CHECK_STATUS(bs_sts, BS_ERR_MORE_DATA);
|
||||
}
|
||||
catch (std::string & e) {
|
||||
std::cout << e << std::endl;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
#endif // MFX_VERSION
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
add_subdirectory(tools/configure)
|
||||
|
||||
set (TRACER_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
include_directories(
|
||||
"$ENV{MFX_HOME}/include"
|
||||
"${TRACER_DIR}"
|
||||
)
|
||||
|
||||
set(headers
|
||||
"${TRACER_DIR}/config/config.h"
|
||||
"${TRACER_DIR}/dumps/dump.h"
|
||||
"${TRACER_DIR}/loggers/ilog.h"
|
||||
"${TRACER_DIR}/loggers/log.h"
|
||||
"${TRACER_DIR}/loggers/log_console.h"
|
||||
"${TRACER_DIR}/loggers/log_etw_events.h"
|
||||
"${TRACER_DIR}/loggers/log_file.h"
|
||||
"${TRACER_DIR}/loggers/log_syslog.h"
|
||||
"${TRACER_DIR}/loggers/timer.h"
|
||||
"${TRACER_DIR}/loggers/thread_info.h"
|
||||
"${TRACER_DIR}/tracer/tracer.h"
|
||||
"${TRACER_DIR}/tracer/functions_table.h"
|
||||
"${TRACER_DIR}/tracer/bits/mfxfunctions.h"
|
||||
"${TRACER_DIR}/wrappers/mfx_structures.h"
|
||||
)
|
||||
|
||||
set(sources
|
||||
"${TRACER_DIR}/config/config.cpp"
|
||||
"${TRACER_DIR}/dumps/dump.cpp"
|
||||
"${TRACER_DIR}/dumps/dump_mfxbrc.cpp"
|
||||
"${TRACER_DIR}/dumps/dump_mfxcommon.cpp"
|
||||
"${TRACER_DIR}/dumps/dump_mfxdefs.cpp"
|
||||
"${TRACER_DIR}/dumps/dump_mfxenc.cpp"
|
||||
"${TRACER_DIR}/dumps/dump_mfxplugin.cpp"
|
||||
"${TRACER_DIR}/dumps/dump_mfxsession.cpp"
|
||||
"${TRACER_DIR}/dumps/dump_mfxstructures.cpp"
|
||||
"${TRACER_DIR}/dumps/dump_mfxvideo.cpp"
|
||||
"${TRACER_DIR}/dumps/dump_mfxfei.cpp"
|
||||
"${TRACER_DIR}/dumps/dump_mfxla.cpp"
|
||||
"${TRACER_DIR}/dumps/dump_mfxvp8.cpp"
|
||||
"${TRACER_DIR}/loggers/log.cpp"
|
||||
"${TRACER_DIR}/loggers/log_console.cpp"
|
||||
"${TRACER_DIR}/loggers/log_etw_events.cpp"
|
||||
"${TRACER_DIR}/loggers/log_file.cpp"
|
||||
"${TRACER_DIR}/loggers/log_syslog.cpp"
|
||||
"${TRACER_DIR}/tracer/tracer.cpp"
|
||||
"${TRACER_DIR}/tracer/tracer_linux.cpp"
|
||||
"${TRACER_DIR}/tracer/tracer_windows.cpp"
|
||||
"${TRACER_DIR}/wrappers/mfx_core.cpp"
|
||||
"${TRACER_DIR}/wrappers/mfx_video_core.cpp"
|
||||
"${TRACER_DIR}/wrappers/mfx_video_decode.cpp"
|
||||
"${TRACER_DIR}/wrappers/mfx_video_enc.cpp"
|
||||
"${TRACER_DIR}/wrappers/mfx_video_encode.cpp"
|
||||
"${TRACER_DIR}/wrappers/mfx_video_user.cpp"
|
||||
"${TRACER_DIR}/wrappers/mfx_video_vpp.cpp"
|
||||
"${TRACER_DIR}/wrappers/mfx_video_fei.cpp"
|
||||
)
|
||||
|
||||
if( NOT DEFINED MFX_MODULES_DIR )
|
||||
set( MFX_MODULES_DIR ${CMAKE_INSTALL_FULL_LIBDIR} )
|
||||
endif( )
|
||||
add_definitions( -DMFX_MODULES_DIR="${MFX_MODULES_DIR}" )
|
||||
|
||||
make_library(mfx-tracer none shared)
|
||||
|
||||
set_target_properties( mfx-tracer PROPERTIES LINK_FLAGS
|
||||
"${LINK_FLAGS} -Wl,--version-script=${CMAKE_HOME_DIRECTORY}/api/mfx_dispatch/linux/libmfx.map" )
|
||||
|
||||
get_mfx_version(mfx_version_major mfx_version_minor)
|
||||
set_target_properties(mfx-tracer PROPERTIES VERSION ${mfx_version_major}.${mfx_version_minor})
|
||||
set_target_properties(mfx-tracer PROPERTIES SOVERSION ${mfx_version_major})
|
||||
|
||||
target_link_libraries( mfx-tracer ${CMAKE_DL_LIBS})
|
||||
target_compile_options(mfx-tracer PRIVATE -Wno-deprecated-declarations)
|
||||
|
||||
install(TARGETS mfx-tracer LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
set(defs "")
|
|
@ -1,57 +0,0 @@
|
|||
# Media SDK Tracer
|
||||
|
||||
## Overview
|
||||
|
||||
**Media SDK Tracer** is a tool which permits to dump logging information from the calls
|
||||
of the application to the Media SDK library. Trace log obtained from this tool is a
|
||||
recommended information to provide to Media SDK team on submitting questions and
|
||||
issues.
|
||||
|
||||
## Installation
|
||||
|
||||
Use the following sequence to generate config file for the tracer:
|
||||
|
||||
Generate default config file:
|
||||
```
|
||||
# $INSTALLDIR/bin/mfx-tracer-config --default
|
||||
```
|
||||
Set API level coverage:
|
||||
```
|
||||
# $INSTALLDIR/bin/mfx-tracer-config core.level full
|
||||
```
|
||||
Set trace type:
|
||||
```
|
||||
# $INSTALLDIR/bin/mfx-tracer-config core.type file
|
||||
```
|
||||
Set log file:
|
||||
```
|
||||
# $INSTALLDIR/bin/mfx-tracer-config core.log ~/mfxtracer.log
|
||||
```
|
||||
|
||||
Following this procedure you will generate a configuration file called `~/.mfxtracer` and set the tracer to dump
|
||||
logs to `~/mfxtracer_<PID>.log` files. You may adjust your configuration with **mfx-tracer-config** tool.
|
||||
Run `mfx-tracer-config -h` to get full list of supported options.
|
||||
|
||||
## Running
|
||||
|
||||
For use the tracer, run the application with **LD_PRELOAD**:
|
||||
|
||||
```
|
||||
LD_PRELOAD=libmfx-tracer.so.1.34 <./some_application>
|
||||
```
|
||||
|
||||
Make sure that the tracer library is added to the search path:
|
||||
|
||||
```
|
||||
export LD_LIBRARY_PATH=$INSTALLDIR/lib:$LD_LIBRARY_PATH
|
||||
```
|
||||
|
||||
After each run of some Media SDK based application you should see traces in the configured log files.
|
||||
Note that the tracer library reads settings from `~/.mfxtracer` located in the home directory of a current user.
|
||||
If you need to run application with 'sudo', copy `~/.mfxtracer` file to a home directory of the root user.
|
||||
|
||||
## Known issues & limitations
|
||||
|
||||
- This is prototype release of the tracer - not all functionality can be available
|
||||
- Syslog logger is not supported
|
||||
- Some API functions may not be covered by the tracing
|
|
@ -1,203 +0,0 @@
|
|||
/* ****************************************************************************** *\
|
||||
|
||||
Copyright (C) 2012-2020 Intel Corporation. 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.
|
||||
- Neither the name of Intel Corporation nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "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 INTEL CORPORATION 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 Name: config.cpp
|
||||
|
||||
\* ****************************************************************************** */
|
||||
|
||||
#include <algorithm>
|
||||
#include <ctype.h>
|
||||
#include <sstream>
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#include <windows.h>
|
||||
const char* get_path_reg()
|
||||
{
|
||||
char* path = new char[128];
|
||||
DWORD size = sizeof(char)*128;
|
||||
DWORD sts = RegGetValue(HKEY_LOCAL_MACHINE, (LPCTSTR)("Software\\Intel\\MediaSDK\\Dispatch\\tracer"), (LPCTSTR)("_conf"), RRF_RT_REG_SZ, (LPDWORD)0, (PVOID)path, (LPDWORD)&size);
|
||||
size_t len = strnlen_s(path, 128);
|
||||
|
||||
if (sts == ERROR_SUCCESS)
|
||||
{
|
||||
for (size_t i = 0; i < len; i++)
|
||||
{
|
||||
if (path[i] == '\\')
|
||||
path[i] = '/';
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
GetCurrentDirectory(128, path);
|
||||
len = strnlen_s(path, 128);
|
||||
for (size_t i = 0; i < len; i++)
|
||||
{
|
||||
if (path[i] == '\\')
|
||||
path[i] = '/';
|
||||
}
|
||||
}
|
||||
return path;
|
||||
}
|
||||
#endif
|
||||
|
||||
Config* Config::conf = NULL;
|
||||
|
||||
Config::Config()
|
||||
{
|
||||
const char* home =
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
get_path_reg();
|
||||
#else
|
||||
getenv("HOME");
|
||||
#endif
|
||||
if (home) {
|
||||
_file_path = std::string(home) + "/.mfxtracer";
|
||||
|
||||
if(!_file.is_open()){
|
||||
_file.open(_file_path.c_str(), std::ifstream::binary);
|
||||
}
|
||||
}
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
Config::~Config()
|
||||
{
|
||||
if(_file.is_open())
|
||||
_file.close();
|
||||
|
||||
//delete ini;
|
||||
}
|
||||
|
||||
void Config::Init()
|
||||
{
|
||||
//delete tabs and spaces
|
||||
//delete comments
|
||||
//parse sections
|
||||
//parse params in sections
|
||||
|
||||
if(_file.is_open()){
|
||||
//TODO parse
|
||||
std::string curent_section;
|
||||
std::map<std::string, std::string> section_params;
|
||||
for (;;) {
|
||||
std::string inistr;
|
||||
getline(_file, inistr);
|
||||
|
||||
//delete tabs and spaces
|
||||
size_t firstQuote = inistr.find("\"");
|
||||
size_t secondQuote = inistr.find_last_of("\"");
|
||||
std::string firstPart="";
|
||||
std::string secondPart="";
|
||||
std::string quotePart="";
|
||||
if ((firstQuote != std::string::npos) && firstQuote < secondQuote)
|
||||
{
|
||||
firstPart = inistr.substr(0,firstQuote);
|
||||
if (secondQuote != std::string::npos)
|
||||
{
|
||||
secondPart = inistr.substr(secondQuote+1);
|
||||
quotePart = inistr.substr(firstQuote+1, secondQuote-firstQuote-1);
|
||||
}
|
||||
|
||||
firstPart.erase(std::remove_if(firstPart.begin(), firstPart.end(), &::isspace),firstPart.end());
|
||||
secondPart.erase(std::remove_if(secondPart.begin(), secondPart.end(), &::isspace),secondPart.end());
|
||||
inistr = firstPart + quotePart + secondPart;
|
||||
}
|
||||
else
|
||||
{
|
||||
inistr.erase(std::remove_if(inistr.begin(), inistr.end(), &::isspace),inistr.end());
|
||||
}
|
||||
|
||||
//delete comments
|
||||
std::basic_string <char>::size_type n1 = inistr.find("#");
|
||||
std::basic_string <char>::size_type n2 = inistr.find(";");
|
||||
|
||||
if(n1 != std::string::npos && n2 != std::string::npos)
|
||||
n1>=n2 ? inistr.erase(n1, inistr.length()) : inistr.erase(n2, inistr.length());
|
||||
else if (n1 != std::string::npos)
|
||||
inistr.erase(n1, inistr.length());
|
||||
else if(n2 != std::string::npos)
|
||||
inistr.erase(n2, inistr.length());
|
||||
|
||||
|
||||
std::basic_string <char>::size_type s1 = inistr.find("[");
|
||||
std::basic_string <char>::size_type s2 = inistr.find("]");
|
||||
if(s1 != std::string::npos && s2 != std::string::npos) {
|
||||
inistr.erase(s1, s1+1);
|
||||
inistr.erase(s2-1, s2);
|
||||
curent_section = inistr;
|
||||
section_params.clear();
|
||||
|
||||
ini.insert(std::pair<std::string, std::map<std::string, std::string> >(inistr, section_params));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!curent_section.empty()){
|
||||
std::vector<std::string> key_val = split(inistr, '=');
|
||||
if(key_val.size() == 2){
|
||||
ini[curent_section].insert(std::pair<std::string, std::string>(key_val[0], key_val[1]));
|
||||
}
|
||||
}
|
||||
|
||||
if(_file.eof())
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
//TODO add init default config
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> &Config::split(const std::string &s, char delim, std::vector<std::string> &elems) {
|
||||
std::stringstream ss(s);
|
||||
std::string item;
|
||||
while (std::getline(ss, item, delim)) {
|
||||
elems.push_back(item);
|
||||
}
|
||||
return elems;
|
||||
}
|
||||
|
||||
std::vector<std::string> Config::split(const std::string &s, char delim) {
|
||||
std::vector<std::string> elems;
|
||||
split(s, delim, elems);
|
||||
return elems;
|
||||
}
|
||||
|
||||
std::string Config::GetParam(std::string section, std::string key)
|
||||
{
|
||||
if(!conf)
|
||||
conf = new Config();
|
||||
|
||||
return conf->ini[section][key];
|
||||
}
|
||||
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
// Copyright (c) 2018-2020 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
#ifndef CONFIG_H_
|
||||
#define CONFIG_H_
|
||||
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class Config
|
||||
{
|
||||
public:
|
||||
static std::string GetParam(std::string section, std::string key);
|
||||
|
||||
private:
|
||||
static Config *conf;
|
||||
Config();
|
||||
~Config();
|
||||
|
||||
std::string _file_path;
|
||||
std::ifstream _file;
|
||||
|
||||
std::map<std::string, std::map<std::string, std::string> > ini;
|
||||
|
||||
void Init();
|
||||
std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems);
|
||||
std::vector<std::string> split(const std::string &s, char delim);
|
||||
};
|
||||
|
||||
#endif //CONFIG_H_
|
|
@ -1,476 +0,0 @@
|
|||
/* ****************************************************************************** *\
|
||||
|
||||
Copyright (C) 2012-2020 Intel Corporation. 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.
|
||||
- Neither the name of Intel Corporation nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "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 INTEL CORPORATION 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 Name: dump.cpp
|
||||
|
||||
\* ****************************************************************************** */
|
||||
|
||||
#include "dump.h"
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#include "windows.h"
|
||||
#else
|
||||
#include "unistd.h"
|
||||
#endif
|
||||
|
||||
std::string pVoidToHexString(void* x)
|
||||
{
|
||||
std::ostringstream result;
|
||||
result << std::setw(16) << std::setfill('0') << std::hex <<std::uppercase << ((mfxU64)x);
|
||||
return result.str();
|
||||
}
|
||||
|
||||
struct IdTable
|
||||
{
|
||||
mfxI32 id;
|
||||
const char* str;
|
||||
};
|
||||
|
||||
#define TABLE_ENTRY(_name) \
|
||||
{ _name, #_name }
|
||||
|
||||
|
||||
static IdTable g_BufferIdTable[] =
|
||||
{
|
||||
TABLE_ENTRY(MFX_EXTBUFF_AVC_REFLIST_CTRL),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_AVC_TEMPORAL_LAYERS),
|
||||
|
||||
TABLE_ENTRY(MFX_EXTBUFF_CODING_OPTION),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_CODING_OPTION2),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_CODING_OPTION3),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_CODING_OPTION_SPSPPS),
|
||||
|
||||
|
||||
TABLE_ENTRY(MFX_EXTBUFF_ENCODER_CAPABILITY),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_ENCODED_FRAME_INFO),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_ENCODER_RESET_OPTION),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_ENCODER_ROI),
|
||||
|
||||
TABLE_ENTRY(MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION),
|
||||
|
||||
TABLE_ENTRY(MFX_EXTBUFF_PICTURE_TIMING_SEI),
|
||||
|
||||
TABLE_ENTRY(MFX_EXTBUFF_VPP_AUXDATA),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_VPP_COMPOSITE),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_VPP_DEINTERLACING),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_VPP_DENOISE),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_VPP_DETAIL),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_VPP_DONOTUSE),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_VPP_DOUSE),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_VPP_FRAME_RATE_CONVERSION),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_VPP_IMAGE_STABILIZATION),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_VPP_PICSTRUCT_DETECTION),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_VPP_PROCAMP),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_VPP_SCENE_ANALYSIS),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_VPP_SCENE_CHANGE),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_VPP_VIDEO_SIGNAL_INFO),
|
||||
|
||||
TABLE_ENTRY(MFX_EXTBUFF_VIDEO_SIGNAL_INFO),
|
||||
|
||||
TABLE_ENTRY(MFX_EXTBUFF_LOOKAHEAD_CTRL),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_LOOKAHEAD_STAT),
|
||||
|
||||
TABLE_ENTRY(MFX_EXTBUFF_FEI_PARAM),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_FEI_PREENC_CTRL),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_FEI_PREENC_MV_PRED),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_FEI_PREENC_MV),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_FEI_PREENC_MB),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_FEI_ENC_CTRL),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_FEI_ENC_MV_PRED),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_FEI_ENC_MB),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_FEI_ENC_QP),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_FEI_ENC_MV),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_FEI_ENC_MB_STAT),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_FEI_PAK_CTRL),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_FEI_SPS),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_FEI_PPS),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_FEI_SLICE),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_FEI_DEC_STREAM_OUT),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_FEI_REPACK_CTRL),
|
||||
TABLE_ENTRY(MFX_EXTBUF_CAM_GAMMA_CORRECTION),
|
||||
TABLE_ENTRY(MFX_EXTBUF_CAM_WHITE_BALANCE),
|
||||
TABLE_ENTRY(MFX_EXTBUF_CAM_HOT_PIXEL_REMOVAL),
|
||||
TABLE_ENTRY(MFX_EXTBUF_CAM_BLACK_LEVEL_CORRECTION),
|
||||
TABLE_ENTRY(MFX_EXTBUF_CAM_VIGNETTE_CORRECTION),
|
||||
TABLE_ENTRY(MFX_EXTBUF_CAM_BAYER_DENOISE),
|
||||
TABLE_ENTRY(MFX_EXTBUF_CAM_COLOR_CORRECTION_3X3),
|
||||
TABLE_ENTRY(MFX_EXTBUF_CAM_PADDING),
|
||||
TABLE_ENTRY(MFX_EXTBUF_CAM_PIPECONTROL),
|
||||
TABLE_ENTRY(MFX_EXTBUF_CAM_FORWARD_GAMMA_CORRECTION),
|
||||
TABLE_ENTRY(MFX_EXTBUF_CAM_LENS_GEOM_DIST_CORRECTION),
|
||||
TABLE_ENTRY(MFX_EXTBUF_CAM_TOTAL_COLOR_CONTROL),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_LOOKAHEAD_CTRL),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_LOOKAHEAD_STAT),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_AVC_REFLIST_CTRL),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_AVC_TEMPORAL_LAYERS),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_ENCODED_FRAME_INFO),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_AVC_REFLISTS),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_JPEG_QT),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_JPEG_HUFFMAN),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_MVC_SEQ_DESC),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_MVC_TARGET_VIEWS),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_HEVC_TILES),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_HEVC_PARAM),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_HEVC_REGION),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_DECODED_FRAME_INFO),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_TIME_CODE),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_THREADS_PARAM),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_PRED_WEIGHT_TABLE),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_DIRTY_RECTANGLES),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_MOVING_RECTANGLES),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_CODING_OPTION_VPS),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_VPP_ROTATION),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_ENCODED_SLICES_INFO),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_VPP_SCALING),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_FEI_CODING_OPTION),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_ENCODER_IPCM_AREA),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_INSERT_HEADERS),
|
||||
#if (MFX_VERSION >= MFX_VERSION_NEXT)
|
||||
TABLE_ENTRY(MFX_EXTBUFF_VP9_SEGMENTATION),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_VP9_TEMPORAL_LAYERS),
|
||||
TABLE_ENTRY(MFX_EXTBUFF_VP9_PARAM)
|
||||
#endif
|
||||
};
|
||||
|
||||
static IdTable tbl_impl[] = {
|
||||
TABLE_ENTRY(MFX_IMPL_SOFTWARE),
|
||||
TABLE_ENTRY(MFX_IMPL_HARDWARE),
|
||||
TABLE_ENTRY(MFX_IMPL_AUTO_ANY),
|
||||
TABLE_ENTRY(MFX_IMPL_HARDWARE_ANY),
|
||||
TABLE_ENTRY(MFX_IMPL_HARDWARE2),
|
||||
TABLE_ENTRY(MFX_IMPL_HARDWARE3),
|
||||
TABLE_ENTRY(MFX_IMPL_HARDWARE4),
|
||||
TABLE_ENTRY(MFX_IMPL_RUNTIME),
|
||||
TABLE_ENTRY(MFX_IMPL_VIA_ANY),
|
||||
TABLE_ENTRY(MFX_IMPL_VIA_D3D9),
|
||||
TABLE_ENTRY(MFX_IMPL_VIA_D3D11),
|
||||
TABLE_ENTRY(MFX_IMPL_VIA_VAAPI),
|
||||
TABLE_ENTRY(MFX_IMPL_AUDIO)
|
||||
};
|
||||
|
||||
static IdTable tbl_fourcc[] = {
|
||||
TABLE_ENTRY(MFX_FOURCC_NV12),
|
||||
TABLE_ENTRY(MFX_FOURCC_YV12),
|
||||
TABLE_ENTRY(MFX_FOURCC_NV16),
|
||||
TABLE_ENTRY(MFX_FOURCC_YUY2),
|
||||
TABLE_ENTRY(MFX_FOURCC_RGB3),
|
||||
TABLE_ENTRY(MFX_FOURCC_RGB4),
|
||||
TABLE_ENTRY(MFX_FOURCC_P8),
|
||||
TABLE_ENTRY(MFX_FOURCC_P8_TEXTURE),
|
||||
TABLE_ENTRY(MFX_FOURCC_P010),
|
||||
#if (MFX_VERSION >= MFX_VERSION_NEXT)
|
||||
TABLE_ENTRY(MFX_FOURCC_P016),
|
||||
#endif
|
||||
TABLE_ENTRY(MFX_FOURCC_P210),
|
||||
TABLE_ENTRY(MFX_FOURCC_BGR4),
|
||||
TABLE_ENTRY(MFX_FOURCC_A2RGB10),
|
||||
TABLE_ENTRY(MFX_FOURCC_ARGB16),
|
||||
TABLE_ENTRY(MFX_FOURCC_R16),
|
||||
TABLE_ENTRY(MFX_FOURCC_ABGR16),
|
||||
TABLE_ENTRY(MFX_FOURCC_AYUV),
|
||||
TABLE_ENTRY(MFX_FOURCC_AYUV_RGB4),
|
||||
TABLE_ENTRY(MFX_FOURCC_UYVY),
|
||||
#if (MFX_VERSION >= 1027)
|
||||
TABLE_ENTRY(MFX_FOURCC_Y210),
|
||||
TABLE_ENTRY(MFX_FOURCC_Y410),
|
||||
#endif
|
||||
TABLE_ENTRY(MFX_FOURCC_NV21),
|
||||
TABLE_ENTRY(MFX_FOURCC_IYUV),
|
||||
TABLE_ENTRY(MFX_FOURCC_I010),
|
||||
#if (MFX_VERSION >= MFX_VERSION_NEXT)
|
||||
TABLE_ENTRY(MFX_FOURCC_Y216),
|
||||
TABLE_ENTRY(MFX_FOURCC_Y416),
|
||||
TABLE_ENTRY(MFX_FOURCC_RGBP),
|
||||
#endif
|
||||
};
|
||||
|
||||
static IdTable tbl_sts[] = {
|
||||
TABLE_ENTRY(MFX_ERR_NONE),
|
||||
TABLE_ENTRY(MFX_ERR_UNKNOWN),
|
||||
TABLE_ENTRY(MFX_ERR_NULL_PTR),
|
||||
TABLE_ENTRY(MFX_ERR_UNSUPPORTED),
|
||||
TABLE_ENTRY(MFX_ERR_MEMORY_ALLOC),
|
||||
TABLE_ENTRY(MFX_ERR_NOT_ENOUGH_BUFFER),
|
||||
TABLE_ENTRY(MFX_ERR_INVALID_HANDLE),
|
||||
TABLE_ENTRY(MFX_ERR_LOCK_MEMORY),
|
||||
TABLE_ENTRY(MFX_ERR_NOT_INITIALIZED),
|
||||
TABLE_ENTRY(MFX_ERR_NOT_FOUND),
|
||||
TABLE_ENTRY(MFX_ERR_MORE_DATA),
|
||||
TABLE_ENTRY(MFX_ERR_MORE_SURFACE),
|
||||
TABLE_ENTRY(MFX_ERR_ABORTED),
|
||||
TABLE_ENTRY(MFX_ERR_DEVICE_LOST),
|
||||
TABLE_ENTRY(MFX_ERR_INCOMPATIBLE_VIDEO_PARAM),
|
||||
TABLE_ENTRY(MFX_ERR_INVALID_VIDEO_PARAM),
|
||||
TABLE_ENTRY(MFX_ERR_UNDEFINED_BEHAVIOR),
|
||||
TABLE_ENTRY(MFX_ERR_DEVICE_FAILED),
|
||||
TABLE_ENTRY(MFX_ERR_MORE_BITSTREAM),
|
||||
TABLE_ENTRY(MFX_ERR_INCOMPATIBLE_AUDIO_PARAM),
|
||||
TABLE_ENTRY(MFX_ERR_INVALID_AUDIO_PARAM),
|
||||
TABLE_ENTRY(MFX_WRN_IN_EXECUTION),
|
||||
TABLE_ENTRY(MFX_WRN_DEVICE_BUSY),
|
||||
TABLE_ENTRY(MFX_WRN_VIDEO_PARAM_CHANGED),
|
||||
TABLE_ENTRY(MFX_WRN_PARTIAL_ACCELERATION),
|
||||
TABLE_ENTRY(MFX_WRN_INCOMPATIBLE_VIDEO_PARAM),
|
||||
TABLE_ENTRY(MFX_WRN_VALUE_NOT_CHANGED),
|
||||
TABLE_ENTRY(MFX_WRN_OUT_OF_RANGE),
|
||||
TABLE_ENTRY(MFX_WRN_FILTER_SKIPPED),
|
||||
TABLE_ENTRY(MFX_WRN_INCOMPATIBLE_AUDIO_PARAM),
|
||||
TABLE_ENTRY(MFX_TASK_DONE),
|
||||
TABLE_ENTRY(MFX_TASK_WORKING),
|
||||
TABLE_ENTRY(MFX_TASK_BUSY),
|
||||
TABLE_ENTRY(MFX_ERR_NONE_PARTIAL_OUTPUT)
|
||||
};
|
||||
|
||||
static IdTable tbl_codecid[] = {
|
||||
TABLE_ENTRY(MFX_CODEC_AVC),
|
||||
TABLE_ENTRY(MFX_CODEC_HEVC),
|
||||
TABLE_ENTRY(MFX_CODEC_MPEG2),
|
||||
TABLE_ENTRY(MFX_CODEC_VC1),
|
||||
TABLE_ENTRY(MFX_CODEC_CAPTURE),
|
||||
TABLE_ENTRY(MFX_CODEC_VP9),
|
||||
TABLE_ENTRY(MFX_CODEC_AV1)
|
||||
};
|
||||
|
||||
static IdTable tbl_iopattern[] = {
|
||||
TABLE_ENTRY(MFX_IOPATTERN_IN_VIDEO_MEMORY),
|
||||
TABLE_ENTRY(MFX_IOPATTERN_IN_SYSTEM_MEMORY),
|
||||
TABLE_ENTRY(MFX_IOPATTERN_IN_OPAQUE_MEMORY),
|
||||
TABLE_ENTRY(MFX_IOPATTERN_OUT_VIDEO_MEMORY),
|
||||
TABLE_ENTRY(MFX_IOPATTERN_OUT_SYSTEM_MEMORY),
|
||||
TABLE_ENTRY(MFX_IOPATTERN_OUT_OPAQUE_MEMORY)
|
||||
};
|
||||
|
||||
|
||||
const char* DumpContext::get_bufferid_str(mfxU32 bufferid)
|
||||
{
|
||||
for (size_t i = 0; i < GET_ARRAY_SIZE(g_BufferIdTable); ++i)
|
||||
{
|
||||
if (g_BufferIdTable[i].id == static_cast<int>(bufferid))
|
||||
{
|
||||
return g_BufferIdTable[i].str;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::string GetmfxIMPL(mfxIMPL impl) {
|
||||
|
||||
std::basic_stringstream<char> stream;
|
||||
std::string name = "UNKNOWN";
|
||||
|
||||
for (unsigned int i = 0; i < (sizeof(tbl_impl) / sizeof(tbl_impl[0])); i++)
|
||||
if (tbl_impl[i].id == (impl & (MFX_IMPL_VIA_ANY - 1)))
|
||||
name = tbl_impl[i].str;
|
||||
stream << name;
|
||||
|
||||
int via_flag = impl & ~(MFX_IMPL_VIA_ANY - 1);
|
||||
|
||||
if (0 != via_flag)
|
||||
{
|
||||
stream << "|";
|
||||
name = "UNKNOWN";
|
||||
for (unsigned int i = 0; i < (sizeof(tbl_impl) / sizeof(tbl_impl[0])); i++)
|
||||
if (tbl_impl[i].id == via_flag)
|
||||
name = tbl_impl[i].str;
|
||||
stream << name;
|
||||
}
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
std::string GetFourCC(mfxU32 fourcc) {
|
||||
|
||||
std::basic_stringstream<char> stream;
|
||||
std::string name = "UNKNOWN";
|
||||
int j = 0;
|
||||
for (unsigned int i = 0; i < (sizeof(tbl_fourcc) / sizeof(tbl_fourcc[0])); i++)
|
||||
{
|
||||
if (tbl_fourcc[i].id == static_cast<int>(fourcc))
|
||||
{
|
||||
name = "";
|
||||
while (tbl_fourcc[i].str[j + 11] != '\0')
|
||||
{
|
||||
name = name + tbl_fourcc[i].str[j + 11];
|
||||
j++;
|
||||
}
|
||||
name = name + "\0";
|
||||
break;
|
||||
}
|
||||
}
|
||||
stream<<name;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
std::string GetStatusString(mfxStatus sts) {
|
||||
|
||||
std::basic_stringstream<char> stream;
|
||||
std::string name = "UNKNOWN_STATUS";
|
||||
for (unsigned int i = 0; i < (sizeof(tbl_sts) / sizeof(tbl_sts[0])); i++)
|
||||
{
|
||||
if (tbl_sts[i].id == sts)
|
||||
{
|
||||
name = tbl_sts[i].str;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
stream<<name;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
std::string GetCodecIdString(mfxU32 id) {
|
||||
|
||||
std::basic_stringstream<char> stream;
|
||||
std::string name = "UNKNOWN";
|
||||
for (unsigned int i = 0; i < (sizeof(tbl_codecid) / sizeof(tbl_codecid[0])); i++)
|
||||
{
|
||||
if (tbl_codecid[i].id == static_cast<int>(id))
|
||||
{
|
||||
name = tbl_codecid[i].str;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
stream<<name;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
std::string GetIOPattern(mfxU32 io) {
|
||||
|
||||
std::basic_stringstream<char> stream;
|
||||
std::string name;
|
||||
for (unsigned int i = 0; i < (sizeof(tbl_iopattern) / sizeof(tbl_iopattern[0])); i++)
|
||||
{
|
||||
if (tbl_iopattern[i].id & static_cast<int>(io))
|
||||
{
|
||||
name += tbl_iopattern[i].str;
|
||||
name += "; ";
|
||||
}
|
||||
|
||||
}
|
||||
if (!name.length())
|
||||
{
|
||||
name = "UNKNOWN";
|
||||
name += "(" + ToString(io) + ")";
|
||||
}
|
||||
stream<<name;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
bool _IsBadReadPtr(void *ptr, size_t size)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
return !!IsBadReadPtr(ptr, size);
|
||||
#else
|
||||
int fb[2];
|
||||
if (pipe(fb) >= 0)
|
||||
{
|
||||
bool tmp = (write(fb[1], ptr, size) <= 0);
|
||||
close(fb[0]);
|
||||
close(fb[1]);
|
||||
return tmp;
|
||||
}
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
//mfxcommon
|
||||
DEFINE_GET_TYPE_DEF(mfxBitstream);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtBuffer);
|
||||
DEFINE_GET_TYPE_DEF(mfxIMPL);
|
||||
DEFINE_GET_TYPE_DEF(mfxInitParam);
|
||||
DEFINE_GET_TYPE_DEF(mfxPriority);
|
||||
DEFINE_GET_TYPE_DEF(mfxVersion);
|
||||
DEFINE_GET_TYPE_DEF(mfxSyncPoint);
|
||||
|
||||
//mfxenc
|
||||
DEFINE_GET_TYPE_DEF(mfxENCInput);
|
||||
DEFINE_GET_TYPE_DEF(mfxENCOutput);
|
||||
|
||||
//mfxplugin
|
||||
DEFINE_GET_TYPE_DEF(mfxPlugin);
|
||||
|
||||
//mfxstructures
|
||||
DEFINE_GET_TYPE_DEF(mfxDecodeStat);
|
||||
DEFINE_GET_TYPE_DEF(mfxEncodeCtrl);
|
||||
DEFINE_GET_TYPE_DEF(mfxEncodeStat);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtCodingOption);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtCodingOption2);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtCodingOption3);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtEncoderResetOption);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtVppAuxData);
|
||||
DEFINE_GET_TYPE_DEF(mfxFrameAllocRequest);
|
||||
DEFINE_GET_TYPE_DEF(mfxFrameData);
|
||||
DEFINE_GET_TYPE_DEF(mfxFrameId);
|
||||
DEFINE_GET_TYPE_DEF(mfxFrameInfo);
|
||||
DEFINE_GET_TYPE_DEF(mfxFrameSurface1);
|
||||
DEFINE_GET_TYPE_DEF(mfxHandleType);
|
||||
DEFINE_GET_TYPE_DEF(mfxInfoMFX);
|
||||
DEFINE_GET_TYPE_DEF(mfxInfoVPP);
|
||||
DEFINE_GET_TYPE_DEF(mfxPayload);
|
||||
DEFINE_GET_TYPE_DEF(mfxSkipMode);
|
||||
DEFINE_GET_TYPE_DEF(mfxVideoParam);
|
||||
DEFINE_GET_TYPE_DEF(mfxVPPStat);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtVPPDoNotUse);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtCodingOptionVPS);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtVPPRotation);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtEncodedSlicesInfo);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtVPPScaling);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtVPPMirroring);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtMVOverPicBoundaries);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtVPPColorFill);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtEncoderIPCMArea);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtInsertHeaders);
|
||||
|
||||
//mfxsession
|
||||
DEFINE_GET_TYPE_DEF(mfxSession);
|
||||
|
||||
//mfxvideo
|
||||
DEFINE_GET_TYPE_DEF(mfxBufferAllocator);
|
||||
DEFINE_GET_TYPE_DEF(mfxFrameAllocator);
|
||||
|
||||
//mfxfei
|
||||
DEFINE_GET_TYPE_DEF(mfxExtFeiPreEncCtrl);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtFeiPreEncMV);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtFeiPreEncMBStat);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtFeiEncFrameCtrl);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtFeiEncMVPredictors);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtFeiEncQP);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtFeiEncMBCtrl);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtFeiEncMV);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtFeiEncMBStat);
|
||||
DEFINE_GET_TYPE_DEF(mfxFeiPakMBCtrl);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtFeiPakMBCtrl);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtFeiParam);
|
||||
DEFINE_GET_TYPE_DEF(mfxPAKInput);
|
||||
DEFINE_GET_TYPE_DEF(mfxPAKOutput);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtFeiSPS);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtFeiPPS);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtFeiSliceHeader);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtFeiCodingOption);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtFeiRepackCtrl);
|
||||
DEFINE_GET_TYPE_DEF(mfxFeiDecStreamOutMBCtrl);
|
||||
DEFINE_GET_TYPE_DEF(mfxExtFeiDecStreamOut);
|
||||
|
||||
|
|
@ -1,714 +0,0 @@
|
|||
/* ****************************************************************************** *\
|
||||
|
||||
Copyright (C) 2012-2020 Intel Corporation. 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.
|
||||
- Neither the name of Intel Corporation nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "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 INTEL CORPORATION 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 Name: dump.h
|
||||
|
||||
\* ****************************************************************************** */
|
||||
|
||||
#ifndef DUMP_H_
|
||||
#define DUMP_H_
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <iterator>
|
||||
#include <typeinfo>
|
||||
#include "mfxstructures.h"
|
||||
#include "mfxvideo.h"
|
||||
#include "mfxplugin.h"
|
||||
#include "mfxenc.h"
|
||||
#include "mfxfei.h"
|
||||
#include "mfxla.h"
|
||||
#include "mfxvp8.h"
|
||||
#include "mfxcamera.h"
|
||||
#include "mfxjpeg.h"
|
||||
#include "mfxmvc.h"
|
||||
#include "mfxbrc.h"
|
||||
|
||||
|
||||
|
||||
std::string pVoidToHexString(void* x);
|
||||
std::string GetStatusString(mfxStatus sts);
|
||||
std::string GetmfxIMPL(mfxIMPL impl);
|
||||
std::string GetFourCC(mfxU32 fourcc);
|
||||
std::string GetCodecIdString (mfxU32 id);
|
||||
std::string GetIOPattern (mfxU32 io);
|
||||
bool _IsBadReadPtr(void *ptr, size_t size);
|
||||
|
||||
#define GET_ARRAY_SIZE(x) sizeof(x)/sizeof(x[0])
|
||||
#define DUMP_RESERVED_ARRAY(r) dump_reserved_array(&(r[0]), GET_ARRAY_SIZE(r))
|
||||
|
||||
#define DUMP_FIELD(_field) \
|
||||
str += structName + "." #_field "=" + ToString(_struct._field) + "\n";
|
||||
|
||||
#define DUMP_FIELD_RESERVED(_field) \
|
||||
str += structName + "." #_field "[]=" + DUMP_RESERVED_ARRAY(_struct._field) + "\n";
|
||||
|
||||
#define ToString( x ) static_cast< std::ostringstream const & >( \
|
||||
( std::ostringstream() << std::dec << x ) ).str()
|
||||
|
||||
#define TimeToString( x ) static_cast< std::ostringstream const & >( \
|
||||
( std::ostringstream() << std::left << std::setw(4) << std::dec << x <<" msec") ).str()
|
||||
|
||||
/*
|
||||
#define ToHexFormatString( x ) static_cast< std::ostringstream const & >( \
|
||||
( std::ostringstream() << std::hex << x ) ).str()
|
||||
*/
|
||||
|
||||
#define ToHexFormatString( x ) (static_cast< std::ostringstream const & >( \
|
||||
( std::ostringstream() << std::hex << pVoidToHexString((void*)x) ) ).str() )
|
||||
/*
|
||||
#define DEFINE_GET_TYPE(type) \
|
||||
template<> \
|
||||
inline const char* get_type<type>(){ return #type; };
|
||||
*/
|
||||
|
||||
#define DEFINE_GET_TYPE(type) \
|
||||
template<> \
|
||||
const char* get_type<type>();
|
||||
|
||||
#define DEFINE_GET_TYPE_DEF(type) \
|
||||
template<> const char* DumpContext::get_type<type>(){ return #type; }
|
||||
|
||||
#define DEFINE_DUMP_FUNCTION(type) \
|
||||
std::string dump(const std::string structName, const type & var);
|
||||
|
||||
enum eDumpContect {
|
||||
DUMPCONTEXT_MFX,
|
||||
DUMPCONTEXT_VPP,
|
||||
DUMPCONTEXT_ALL,
|
||||
};
|
||||
|
||||
enum eDumpFormat {
|
||||
DUMP_DEC,
|
||||
DUMP_HEX
|
||||
};
|
||||
|
||||
class DumpContext
|
||||
{
|
||||
public:
|
||||
eDumpContect context;
|
||||
|
||||
DumpContext(void) {
|
||||
context = DUMPCONTEXT_ALL;
|
||||
};
|
||||
~DumpContext(void) {};
|
||||
|
||||
template<typename T>
|
||||
inline std::string toString( T x, eDumpFormat format = DUMP_DEC){
|
||||
return static_cast< std::ostringstream const & >(
|
||||
( std::ostringstream() << ((format == DUMP_DEC) ? std::dec : std::hex) << x )).str();
|
||||
}
|
||||
|
||||
const char* get_bufferid_str(mfxU32 bufferid);
|
||||
|
||||
template<typename T>
|
||||
std::string dump_reserved_array(T* data, size_t size)
|
||||
{
|
||||
std::stringstream result;
|
||||
|
||||
result << "{ ";
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
result << data[i];
|
||||
if (i < (size-1)) result << ", ";
|
||||
}
|
||||
result << " }";
|
||||
return result.str();
|
||||
}
|
||||
|
||||
template<typename T0, typename T1>
|
||||
std::string dump_array_with_cast(T0* data, size_t size)
|
||||
{
|
||||
std::stringstream result;
|
||||
|
||||
result << "{ ";
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
result << (T1)data[i];
|
||||
if (i < (size - 1)) result << ", ";
|
||||
}
|
||||
result << " }";
|
||||
return result.str();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::string dump_hex_array(T* data, size_t size)
|
||||
{
|
||||
std::stringstream result;
|
||||
result << "{ " << std::hex << std::uppercase;
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
result << std::setw(sizeof(T) * 2) << std::setfill('0') << (mfxU64)data[i];
|
||||
result << " }";
|
||||
return result.str();
|
||||
}
|
||||
template<typename T, size_t N>
|
||||
inline std::string dump_hex_array(T (&data)[N]) { return dump_hex_array(data, N); }
|
||||
|
||||
|
||||
template<typename T>
|
||||
inline const char* get_type(){ return typeid(T).name(); }
|
||||
|
||||
template<typename T>
|
||||
std::string dump(const std::string structName, const T *_struct)
|
||||
{
|
||||
std::string str = get_type<T>();
|
||||
str += "* " + structName + "=" + ToHexFormatString(_struct) + "\n";
|
||||
if (_struct) str += dump(" " + structName, *_struct);
|
||||
return str;
|
||||
}
|
||||
std::string dump(const std::string structName, const void *_struct)
|
||||
{
|
||||
std::string str = "void";
|
||||
str += "* " + structName + "=" + ToHexFormatString(_struct) + "\n";
|
||||
return str;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline std::string dump_mfxExtParams(const std::string structName, const T& _struct)
|
||||
{
|
||||
std::string str;
|
||||
std::string name;
|
||||
|
||||
str += structName + ".NumExtParam=" + ToString(_struct.NumExtParam) + "\n";
|
||||
str += structName + ".ExtParam=" + ToString(_struct.ExtParam) + "\n";
|
||||
|
||||
if (_struct.ExtParam) {
|
||||
for (mfxU16 i = 0; i < _struct.NumExtParam; ++i)
|
||||
{
|
||||
if ((!_IsBadReadPtr(_struct.ExtParam, sizeof(mfxExtBuffer**))) && (!_IsBadReadPtr(_struct.ExtParam[i], sizeof(mfxExtBuffer*))))
|
||||
{
|
||||
name = structName + ".ExtParam[" + ToString(i) + "]";
|
||||
str += name + "=" + ToString(_struct.ExtParam[i]) + "\n";
|
||||
switch (_struct.ExtParam[i]->BufferId)
|
||||
{
|
||||
case MFX_EXTBUFF_CODING_OPTION:
|
||||
str += dump(name, *((mfxExtCodingOption*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_CODING_OPTION2:
|
||||
str += dump(name, *((mfxExtCodingOption2*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_CODING_OPTION3:
|
||||
str += dump(name, *((mfxExtCodingOption3*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_ENCODER_RESET_OPTION:
|
||||
str += dump(name, *((mfxExtEncoderResetOption*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUF_CAM_GAMMA_CORRECTION:
|
||||
str += dump(name, *((mfxExtCamGammaCorrection*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUF_CAM_WHITE_BALANCE:
|
||||
str += dump(name, *((mfxExtCamWhiteBalance*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUF_CAM_HOT_PIXEL_REMOVAL:
|
||||
str += dump(name, *((mfxExtCamHotPixelRemoval*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUF_CAM_BLACK_LEVEL_CORRECTION:
|
||||
str += dump(name, *((mfxExtCamBlackLevelCorrection*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUF_CAM_VIGNETTE_CORRECTION:
|
||||
str += dump(name, *((mfxExtCamVignetteCorrection*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUF_CAM_BAYER_DENOISE:
|
||||
str += dump(name, *((mfxExtCamBayerDenoise*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUF_CAM_COLOR_CORRECTION_3X3:
|
||||
str += dump(name, *((mfxExtCamColorCorrection3x3*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUF_CAM_PADDING:
|
||||
str += dump(name, *((mfxExtCamPadding*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUF_CAM_PIPECONTROL:
|
||||
str += dump(name, *((mfxExtCamPipeControl*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUF_CAM_FORWARD_GAMMA_CORRECTION:
|
||||
str += dump(name, *((mfxExtCamFwdGamma*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUF_CAM_LENS_GEOM_DIST_CORRECTION:
|
||||
str += dump(name, *((mfxExtCamLensGeomDistCorrection*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUF_CAM_TOTAL_COLOR_CONTROL:
|
||||
str += dump(name, *((mfxExtCamTotalColorControl*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUF_CAM_CSC_YUV_RGB:
|
||||
str += dump(name, *((mfxExtCamCscYuvRgb*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_LOOKAHEAD_CTRL:
|
||||
str += dump(name, *((mfxExtLAControl*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_LOOKAHEAD_STAT:
|
||||
str += dump(name, *((mfxExtLAFrameStatistics*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_AVC_REFLIST_CTRL:
|
||||
str += dump(name, *((mfxExtAVCRefListCtrl*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_AVC_TEMPORAL_LAYERS:
|
||||
str += dump(name, *((mfxExtAvcTemporalLayers*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_ENCODED_FRAME_INFO:
|
||||
str += dump(name, *((mfxExtAVCEncodedFrameInfo*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_AVC_REFLISTS:
|
||||
str += dump(name, *((mfxExtAVCRefLists*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_JPEG_QT:
|
||||
str += dump(name, *((mfxExtJPEGQuantTables*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_JPEG_HUFFMAN:
|
||||
str += dump(name, *((mfxExtJPEGHuffmanTables*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_MVC_SEQ_DESC:
|
||||
str += dump(name, *((mfxExtMVCSeqDesc*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_MVC_TARGET_VIEWS:
|
||||
str += dump(name, *((mfxExtMVCTargetViews*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION:
|
||||
str += dump(name, *((mfxExtOpaqueSurfaceAlloc*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_VPP_DENOISE:
|
||||
str += dump(name, *((mfxExtVPPDenoise*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_VPP_DETAIL:
|
||||
str += dump(name, *((mfxExtVPPDetail*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_VPP_PROCAMP:
|
||||
str += dump(name, *((mfxExtVPPProcAmp*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_CODING_OPTION_SPSPPS:
|
||||
str += dump(name, *((mfxExtCodingOptionSPSPPS*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_VIDEO_SIGNAL_INFO:
|
||||
str += dump(name, *((mfxExtVideoSignalInfo*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_VPP_DOUSE:
|
||||
str += dump(name, *((mfxExtVPPDoUse*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_PICTURE_TIMING_SEI:
|
||||
str += dump(name, *((mfxExtPictureTimingSEI*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_VPP_COMPOSITE:
|
||||
str += dump(name, *((mfxExtVPPComposite*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_VPP_VIDEO_SIGNAL_INFO:
|
||||
str += dump(name, *((mfxExtVPPVideoSignalInfo*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_VPP_DEINTERLACING:
|
||||
str += dump(name, *((mfxExtVPPDeinterlacing*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_HEVC_TILES:
|
||||
str += dump(name, *((mfxExtHEVCTiles*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_HEVC_PARAM:
|
||||
str += dump(name, *((mfxExtHEVCParam*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_HEVC_REGION:
|
||||
str += dump(name, *((mfxExtHEVCRegion*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_DECODED_FRAME_INFO:
|
||||
str += dump(name, *((mfxExtDecodedFrameInfo*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_TIME_CODE:
|
||||
str += dump(name, *((mfxExtTimeCode*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_PRED_WEIGHT_TABLE:
|
||||
str += dump(name, *((mfxExtPredWeightTable*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_ENCODER_CAPABILITY:
|
||||
str += dump(name, *((mfxExtEncoderCapability*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_DIRTY_RECTANGLES:
|
||||
str += dump(name, *((mfxExtDirtyRect*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_MOVING_RECTANGLES:
|
||||
str += dump(name, *((mfxExtMoveRect*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_VPP_FRAME_RATE_CONVERSION:
|
||||
str += dump(name, *((mfxExtVPPFrameRateConversion*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_VPP_IMAGE_STABILIZATION:
|
||||
str += dump(name, *((mfxExtVPPImageStab*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_ENCODER_ROI:
|
||||
str += dump(name, *((mfxExtEncoderROI*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_FEI_PARAM:
|
||||
str += dump(name, *((mfxExtFeiParam*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_FEI_PREENC_CTRL:
|
||||
str += dump(name, *((mfxExtFeiPreEncCtrl*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_FEI_PREENC_MV_PRED:
|
||||
str += dump(name, *((mfxExtFeiPreEncMVPredictors*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_FEI_ENC_QP:
|
||||
str += dump(name, *((mfxExtFeiEncQP*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_FEI_PREENC_MV:
|
||||
str += dump(name, *((mfxExtFeiPreEncMV*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_FEI_PREENC_MB:
|
||||
str += dump(name, *((mfxExtFeiPreEncMBStat*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_FEI_ENC_CTRL:
|
||||
str += dump(name, *((mfxExtFeiEncFrameCtrl*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_FEI_ENC_MV_PRED:
|
||||
str += dump(name, *((mfxExtFeiEncMVPredictors*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_FEI_ENC_MB:
|
||||
str += dump(name, *((mfxExtFeiEncMBCtrl*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_FEI_ENC_MV:
|
||||
str += dump(name, *((mfxExtFeiEncMV*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_FEI_ENC_MB_STAT:
|
||||
str += dump(name, *((mfxExtFeiEncMBStat*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_FEI_PAK_CTRL:
|
||||
str += dump(name, *((mfxFeiPakMBCtrl*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_FEI_SPS:
|
||||
str += dump(name, *((mfxExtFeiSPS*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_FEI_PPS:
|
||||
str += dump(name, *((mfxExtFeiPPS*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_FEI_SLICE:
|
||||
str += dump(name, *((mfxExtFeiSliceHeader*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_CODING_OPTION_VPS:
|
||||
str += dump(name, *((mfxExtCodingOptionVPS*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_VPP_ROTATION:
|
||||
str += dump(name, *(( mfxExtVPPRotation*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_ENCODED_SLICES_INFO:
|
||||
str += dump(name, *((mfxExtEncodedSlicesInfo*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_VPP_SCALING:
|
||||
str += dump(name, *((mfxExtVPPScaling*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_FEI_CODING_OPTION:
|
||||
str += dump(name, *((mfxExtFeiCodingOption*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_FEI_DEC_STREAM_OUT:
|
||||
str += dump(name, *((mfxExtFeiDecStreamOut*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_FEI_REPACK_CTRL:
|
||||
str += dump(name, *((mfxExtFeiRepackCtrl*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
#if (MFX_VERSION >= 1025)
|
||||
case MFX_EXTBUFF_FEI_REPACK_STAT:
|
||||
str += dump(name, *((mfxExtFeiRepackStat*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
#endif
|
||||
case MFX_EXTBUFF_VPP_MIRRORING:
|
||||
str += dump(name, *((mfxExtVPPMirroring*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_MV_OVER_PIC_BOUNDARIES:
|
||||
str += dump(name, *((mfxExtMVOverPicBoundaries*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_VPP_COLORFILL:
|
||||
str += dump(name, *((mfxExtVPPColorFill*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_DEC_VIDEO_PROCESSING:
|
||||
str += dump(name, *((mfxExtDecVideoProcessing*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_BRC:
|
||||
str += dump(name, *((mfxExtBRC*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_MBQP:
|
||||
str += dump(name, *((mfxExtMBQP*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_ENCODER_IPCM_AREA:
|
||||
str += dump(name, *((mfxExtEncoderIPCMArea*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_INSERT_HEADERS:
|
||||
str += dump(name, *((mfxExtInsertHeaders*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
#if (MFX_VERSION >= 1025)
|
||||
case MFX_EXTBUFF_DECODE_ERROR_REPORT:
|
||||
str += dump(name, *((mfxExtDecodeErrorReport*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_MASTERING_DISPLAY_COLOUR_VOLUME:
|
||||
str += dump(name, *((mfxExtMasteringDisplayColourVolume*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_CONTENT_LIGHT_LEVEL_INFO:
|
||||
str += dump(name, *((mfxExtContentLightLevelInfo*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_MULTI_FRAME_PARAM:
|
||||
str += dump(name, *((mfxExtMultiFrameParam*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_MULTI_FRAME_CONTROL:
|
||||
str += dump(name, *((mfxExtMultiFrameControl*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_ENCODED_UNITS_INFO:
|
||||
str += dump(name, *((mfxExtEncodedUnitsInfo*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_VPP_COLOR_CONVERSION:
|
||||
str += dump(name, *((mfxExtColorConversion*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
#endif
|
||||
#if (MFX_VERSION >= 1026)
|
||||
case MFX_EXTBUFF_VPP_MCTF:
|
||||
str += dump(name, *((mfxExtVppMctf*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if (MFX_VERSION >= 1026)
|
||||
case MFX_EXTBUFF_VP9_SEGMENTATION:
|
||||
str += dump(name, *((mfxExtVP9Segmentation*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_VP9_TEMPORAL_LAYERS:
|
||||
str += dump(name, *((mfxExtVP9TemporalLayers*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
case MFX_EXTBUFF_VP9_PARAM:
|
||||
str += dump(name, *((mfxExtVP9Param*)_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
str += dump(name, *(_struct.ExtParam[i])) + "\n";
|
||||
break;
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
str += "WARNING: Can't read from ExtParam[" + ToString(i) + "]!\n";
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
//mfxdefs
|
||||
std::string dump_mfxU32(const std::string structName, mfxU32 u32);
|
||||
std::string dump_mfxU64(const std::string structName, mfxU64 u64);
|
||||
std::string dump_mfxHDL(const std::string structName, const mfxHDL *hdl);
|
||||
std::string dump_mfxStatus(const std::string structName, mfxStatus status);
|
||||
|
||||
//mfxcommon
|
||||
DEFINE_DUMP_FUNCTION(mfxBitstream);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtBuffer);
|
||||
DEFINE_DUMP_FUNCTION(mfxIMPL);
|
||||
DEFINE_DUMP_FUNCTION(mfxInitParam);
|
||||
DEFINE_DUMP_FUNCTION(mfxPriority);
|
||||
DEFINE_DUMP_FUNCTION(mfxVersion);
|
||||
DEFINE_DUMP_FUNCTION(mfxSyncPoint);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtThreadsParam);
|
||||
DEFINE_DUMP_FUNCTION(mfxPlatform);
|
||||
|
||||
//mfxenc
|
||||
DEFINE_DUMP_FUNCTION(mfxENCInput);
|
||||
DEFINE_DUMP_FUNCTION(mfxENCOutput);
|
||||
|
||||
//mfxplugin
|
||||
DEFINE_DUMP_FUNCTION(mfxPlugin);
|
||||
DEFINE_DUMP_FUNCTION(mfxCoreParam);
|
||||
DEFINE_DUMP_FUNCTION(mfxPluginParam);
|
||||
DEFINE_DUMP_FUNCTION(mfxCoreInterface);
|
||||
|
||||
//mfxstructures
|
||||
DEFINE_DUMP_FUNCTION(mfxDecodeStat);
|
||||
DEFINE_DUMP_FUNCTION(mfxEncodeCtrl);
|
||||
DEFINE_DUMP_FUNCTION(mfxEncodeStat);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtCodingOption);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtCodingOption2);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtCodingOption3);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtEncoderResetOption);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtVppAuxData);
|
||||
DEFINE_DUMP_FUNCTION(mfxFrameAllocRequest);
|
||||
DEFINE_DUMP_FUNCTION(mfxFrameAllocResponse);
|
||||
DEFINE_DUMP_FUNCTION(mfxFrameData);
|
||||
DEFINE_DUMP_FUNCTION(mfxFrameId);
|
||||
DEFINE_DUMP_FUNCTION(mfxFrameInfo);
|
||||
DEFINE_DUMP_FUNCTION(mfxFrameSurface1);
|
||||
DEFINE_DUMP_FUNCTION(mfxHandleType);
|
||||
DEFINE_DUMP_FUNCTION(mfxInfoMFX);
|
||||
DEFINE_DUMP_FUNCTION(mfxInfoVPP);
|
||||
DEFINE_DUMP_FUNCTION(mfxPayload);
|
||||
DEFINE_DUMP_FUNCTION(mfxSkipMode);
|
||||
DEFINE_DUMP_FUNCTION(mfxVideoParam);
|
||||
DEFINE_DUMP_FUNCTION(mfxVPPStat);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtVPPDoNotUse);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtAVCRefListCtrl);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtAvcTemporalLayers);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtAVCEncodedFrameInfo);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtAVCRefLists);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtOpaqueSurfaceAlloc);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtVPPDenoise);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtVPPDetail);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtVPPProcAmp);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtCodingOptionSPSPPS);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtVideoSignalInfo);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtVPPDoUse);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtPictureTimingSEI);
|
||||
DEFINE_DUMP_FUNCTION(mfxVPPCompInputStream);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtVPPComposite);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtVPPVideoSignalInfo);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtVPPDeinterlacing);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtHEVCTiles);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtHEVCParam);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtHEVCRegion);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtDecodedFrameInfo);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtTimeCode);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtPredWeightTable);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtEncoderCapability);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtDirtyRect);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtMoveRect);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtVPPFrameRateConversion);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtVPPImageStab);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtEncoderROI);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtCodingOptionVPS);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtVPPRotation);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtEncodedSlicesInfo);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtVPPScaling);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtVPPMirroring);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtMVOverPicBoundaries);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtVPPColorFill);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtDecVideoProcessing);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtMBQP);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtEncoderIPCMArea);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtInsertHeaders);
|
||||
#if (MFX_VERSION >= 1025)
|
||||
DEFINE_DUMP_FUNCTION(mfxExtDecodeErrorReport);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtMasteringDisplayColourVolume);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtContentLightLevelInfo);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtMultiFrameParam);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtMultiFrameControl);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtEncodedUnitsInfo);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtColorConversion);
|
||||
#endif
|
||||
#if (MFX_VERSION >= 1026)
|
||||
DEFINE_DUMP_FUNCTION(mfxExtVppMctf);
|
||||
#endif
|
||||
|
||||
#if (MFX_VERSION >= 1026)
|
||||
|
||||
DEFINE_DUMP_FUNCTION(mfxVP9SegmentParam);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtVP9Segmentation);
|
||||
DEFINE_DUMP_FUNCTION(mfxVP9TemporalLayer);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtVP9TemporalLayers);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtVP9Param);
|
||||
#endif
|
||||
|
||||
#if (MFX_VERSION >= 1034)
|
||||
DEFINE_DUMP_FUNCTION(mfxExtAV1FilmGrainParam);
|
||||
#endif
|
||||
|
||||
//mfxsession
|
||||
DEFINE_DUMP_FUNCTION(mfxSession);
|
||||
|
||||
//mfxvideo
|
||||
DEFINE_DUMP_FUNCTION(mfxBufferAllocator);
|
||||
DEFINE_DUMP_FUNCTION(mfxFrameAllocator);
|
||||
|
||||
//mfxla
|
||||
DEFINE_DUMP_FUNCTION(mfxExtLAControl);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtLAControl::mfxStream);
|
||||
DEFINE_DUMP_FUNCTION(mfxLAFrameInfo);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtLAFrameStatistics);
|
||||
|
||||
//mfxfei
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiPreEncCtrl);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiPreEncMVPredictors);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiPreEncMV);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiPreEncMBStat);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiEncFrameCtrl);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiEncMVPredictors);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiEncMVPredictors::mfxExtFeiEncMVPredictorsMB);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiEncQP);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiEncMBCtrl);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiEncMBCtrl::mfxExtFeiEncMBCtrlMB);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiEncMV);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiEncMBStat);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiEncMBStat::mfxExtFeiEncMBStatMB);
|
||||
DEFINE_DUMP_FUNCTION(mfxFeiPakMBCtrl);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiPakMBCtrl);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiRepackCtrl);
|
||||
#if (MFX_VERSION >= 1025)
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiRepackStat);
|
||||
#endif
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiParam);
|
||||
DEFINE_DUMP_FUNCTION(mfxPAKInput);
|
||||
DEFINE_DUMP_FUNCTION(mfxPAKOutput);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiSPS);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiPPS);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiSliceHeader);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiSliceHeader::mfxSlice);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiCodingOption);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtFeiDecStreamOut);
|
||||
DEFINE_DUMP_FUNCTION(mfxFeiDecStreamOutMBCtrl);
|
||||
|
||||
|
||||
//mfxvp8
|
||||
DEFINE_DUMP_FUNCTION(mfxExtVP8CodingOption)
|
||||
|
||||
//mfxcamera
|
||||
DEFINE_DUMP_FUNCTION(mfxExtCamGammaCorrection);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtCamWhiteBalance);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtCamHotPixelRemoval);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtCamBlackLevelCorrection);
|
||||
DEFINE_DUMP_FUNCTION(mfxCamVignetteCorrectionParam);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtCamVignetteCorrection);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtCamBayerDenoise);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtCamColorCorrection3x3);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtCamPadding);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtCamPipeControl);
|
||||
DEFINE_DUMP_FUNCTION(mfxCamFwdGammaSegment);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtCamFwdGamma);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtCamLensGeomDistCorrection);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtCamTotalColorControl);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtCamCscYuvRgb);
|
||||
|
||||
//mfxjpeg
|
||||
DEFINE_DUMP_FUNCTION(mfxExtJPEGQuantTables);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtJPEGHuffmanTables);
|
||||
|
||||
//mfxmvc
|
||||
DEFINE_DUMP_FUNCTION(mfxMVCViewDependency);
|
||||
DEFINE_DUMP_FUNCTION(mfxMVCOperationPoint);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtMVCSeqDesc);
|
||||
DEFINE_DUMP_FUNCTION(mfxExtMVCTargetViews);
|
||||
|
||||
//mfxbrc
|
||||
DEFINE_DUMP_FUNCTION(mfxExtBRC);
|
||||
DEFINE_DUMP_FUNCTION(mfxBRCFrameParam);
|
||||
DEFINE_DUMP_FUNCTION(mfxBRCFrameCtrl);
|
||||
DEFINE_DUMP_FUNCTION(mfxBRCFrameStatus);
|
||||
|
||||
#if (MFX_VERSION >= MFX_VERSION_NEXT)
|
||||
//custom scaling matrices
|
||||
DEFINE_DUMP_FUNCTION(mfxExtAVCScalingMatrix);
|
||||
#endif
|
||||
|
||||
#if (MFX_VERSION >= MFX_VERSION_NEXT)
|
||||
//partial output
|
||||
DEFINE_DUMP_FUNCTION(mfxExtPartialBitstreamParam);
|
||||
#endif
|
||||
};
|
||||
#endif //DUMP_H_
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
/* ****************************************************************************** *\
|
||||
|
||||
Copyright (C) 2017-2020 Intel Corporation. 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.
|
||||
- Neither the name of Intel Corporation nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "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 INTEL CORPORATION 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 Name: dump_mfxbrc.cpp
|
||||
|
||||
\* ****************************************************************************** */
|
||||
|
||||
#include "dump.h"
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtBRC &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
str += dump(structName + ".Header", _struct.Header) + "\n";
|
||||
|
||||
DUMP_FIELD_RESERVED(reserved);
|
||||
|
||||
DUMP_FIELD(pthis);
|
||||
DUMP_FIELD(Init);
|
||||
DUMP_FIELD(Reset);
|
||||
DUMP_FIELD(Close);
|
||||
DUMP_FIELD(GetFrameCtrl);
|
||||
DUMP_FIELD(Update);
|
||||
|
||||
DUMP_FIELD_RESERVED(reserved1);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxBRCFrameParam &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
DUMP_FIELD_RESERVED(reserved);
|
||||
|
||||
DUMP_FIELD(EncodedOrder);
|
||||
DUMP_FIELD(DisplayOrder);
|
||||
DUMP_FIELD(CodedFrameSize);
|
||||
DUMP_FIELD(FrameType);
|
||||
DUMP_FIELD(PyramidLayer);
|
||||
DUMP_FIELD(NumRecode);
|
||||
dump_mfxExtParams(structName, _struct);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxBRCFrameCtrl &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
DUMP_FIELD(QpY);
|
||||
#if (MFX_VERSION >= 1029)
|
||||
DUMP_FIELD(InitialCpbRemovalDelay);
|
||||
DUMP_FIELD(InitialCpbRemovalOffset);
|
||||
DUMP_FIELD_RESERVED(reserved1);
|
||||
DUMP_FIELD(MaxFrameSize);
|
||||
DUMP_FIELD(DeltaQP);
|
||||
DUMP_FIELD(MaxNumRepak);
|
||||
dump_mfxExtParams(structName, _struct);
|
||||
#else
|
||||
DUMP_FIELD_RESERVED(reserved1);
|
||||
DUMP_FIELD(reserved2);
|
||||
#endif
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxBRCFrameStatus &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
DUMP_FIELD(MinFrameSize);
|
||||
DUMP_FIELD(BRCStatus);
|
||||
DUMP_FIELD_RESERVED(reserved);
|
||||
DUMP_FIELD(reserved1);
|
||||
|
||||
return str;
|
||||
}
|
|
@ -1,113 +0,0 @@
|
|||
/* ****************************************************************************** *\
|
||||
|
||||
Copyright (C) 2012-2020 Intel Corporation. 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.
|
||||
- Neither the name of Intel Corporation nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "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 INTEL CORPORATION 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 Name: dump_mfxcommon.cpp
|
||||
|
||||
\* ****************************************************************************** */
|
||||
|
||||
#include "dump.h"
|
||||
#include "../loggers/log.h"
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxBitstream &bitstream)
|
||||
{
|
||||
std::string str;
|
||||
str += structName + ".EncryptedData=" + ToString(bitstream.EncryptedData) + "\n";
|
||||
str += dump_mfxExtParams(structName, bitstream) + "\n";
|
||||
str += structName + ".reserved[]=" + DUMP_RESERVED_ARRAY(bitstream.reserved) + "\n";
|
||||
str += structName + ".DecodeTimeStamp=" + ToString(bitstream.DecodeTimeStamp) + "\n";
|
||||
str += structName + ".TimeStamp=" + ToString(bitstream.TimeStamp) + "\n";
|
||||
if (Log::GetLogLevel() == LOG_LEVEL_FULL) {
|
||||
str += structName + ".Data=" + ToHexFormatString(bitstream.Data) + "\n";
|
||||
}
|
||||
str += structName + ".DataOffset=" + ToString(bitstream.DataOffset) + "\n";
|
||||
str += structName + ".DataLength=" + ToString(bitstream.DataLength) + "\n";
|
||||
str += structName + ".MaxLength=" + ToString(bitstream.MaxLength) + "\n";
|
||||
str += structName + ".PicStruct=" + ToString(bitstream.PicStruct) + "\n";
|
||||
str += structName + ".FrameType=" + ToString(bitstream.FrameType) + "\n";
|
||||
str += structName + ".DataFlag=" + ToString(bitstream.DataFlag) + "\n";
|
||||
str += structName + ".reserved2=" + ToString(bitstream.reserved2);
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtBuffer &extBuffer)
|
||||
{
|
||||
std::string str;
|
||||
const char* bufid_str = get_bufferid_str(extBuffer.BufferId);
|
||||
if (bufid_str)
|
||||
str += structName + ".BufferId=" + std::string(bufid_str) + "\n";
|
||||
else
|
||||
str += structName + ".BufferId=" + ToString(extBuffer.BufferId) + "\n";
|
||||
str += structName + ".BufferSz=" + ToString(extBuffer.BufferSz);
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxIMPL &impl)
|
||||
{
|
||||
return std::string("mfxIMPL " + structName + "=" + GetmfxIMPL(impl));
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxPriority &priority)
|
||||
{
|
||||
return std::string("mfxPriority " + structName + "=" + ToString(priority));
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxInitParam &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
str += structName + ".Implementation=" + GetmfxIMPL(_struct.Implementation) + "\n";
|
||||
str += dump(structName + ".Version", _struct.Version) + "\n";
|
||||
DUMP_FIELD(ExternalThreads);
|
||||
DUMP_FIELD(NumExtParam);
|
||||
str += structName + ".ExtParam=" + ToHexFormatString(_struct.ExtParam) + "\n";
|
||||
str += structName + ".reserved2[]=" + DUMP_RESERVED_ARRAY(_struct.reserved2) + "\n";
|
||||
str += structName + ".GPUCopy=" + ToString(_struct.GPUCopy) + "\n";
|
||||
DUMP_FIELD_RESERVED(reserved);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxSyncPoint &syncPoint)
|
||||
{
|
||||
return std::string("mfxSyncPoint* " + structName + "=" + ToString(syncPoint));
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxVersion &version)
|
||||
{
|
||||
std::string str;
|
||||
str += structName + ".Major=" + ToString(version.Major) + "\n";
|
||||
str += structName + ".Minor=" + ToString(version.Minor) + "\n";
|
||||
str += structName + ".Version=" + ToString(version.Version);
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxPlatform &platform)
|
||||
{
|
||||
std::string str;
|
||||
str += structName + ".CodeName=" + ToString(platform.CodeName) + "\n";
|
||||
str += structName + ".DeviceId=" + ToString(platform.DeviceId) + "\n";
|
||||
return str;
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
// Copyright (c) 2020 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "dump.h"
|
||||
|
||||
std::string DumpContext::dump_mfxU32(const std::string structName, mfxU32 u32)
|
||||
{
|
||||
return std::string("mfxU32 " + structName + "=" + ToString(u32));
|
||||
}
|
||||
|
||||
std::string DumpContext::dump_mfxU64(const std::string structName, mfxU64 u64)
|
||||
{
|
||||
return std::string("mfxU64 " + structName + "=" + ToString(u64));
|
||||
}
|
||||
|
||||
std::string DumpContext::dump_mfxHDL(const std::string structName, const mfxHDL *hdl)
|
||||
{
|
||||
return std::string("mfxHDL* " + structName + "=" + ToString(hdl));
|
||||
}
|
||||
|
||||
std::string DumpContext::dump_mfxStatus(const std::string structName, mfxStatus status)
|
||||
{
|
||||
return std::string(structName + "=" + GetStatusString(status));
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
// Copyright (c) 2020 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "dump.h"
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxENCInput &encIn)
|
||||
{
|
||||
std::string str;
|
||||
str += structName + ".reserved[]=" + DUMP_RESERVED_ARRAY(encIn.reserved) + "\n";
|
||||
str += structName + ".InSurface=" + ToString(encIn.InSurface) + "\n";
|
||||
str += structName + ".NumFrameL0=" + ToString(encIn.NumFrameL0) + "\n";
|
||||
str += structName + ".L0Surface=" + ToString(encIn.L0Surface) + "\n";
|
||||
str += structName + ".NumFrameL1=" + ToString(encIn.NumFrameL1) + "\n";
|
||||
str += structName + ".L1Surface=" + ToString(encIn.L1Surface) + "\n";
|
||||
str += dump_mfxExtParams(structName, encIn);
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxENCOutput &encOut)
|
||||
{
|
||||
std::string str;
|
||||
str += structName + ".reserved[]=" + DUMP_RESERVED_ARRAY(encOut.reserved) + "\n";
|
||||
str += dump_mfxExtParams(structName, encOut);
|
||||
return str;
|
||||
}
|
|
@ -1,802 +0,0 @@
|
|||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// INTEL CORPORATION PROPRIETARY INFORMATION
|
||||
// This software is supplied under the terms of a license agreement or
|
||||
// nondisclosure agreement with Intel Corporation and may not be copied
|
||||
// or disclosed except in accordance with the terms of that agreement.
|
||||
// Copyright(c) 2015-2020 Intel Corporation. All Rights Reserved.
|
||||
//
|
||||
*/
|
||||
#include "dump.h"
|
||||
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiPreEncCtrl &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
str += dump(structName + ".Header", _struct.Header) + "\n";
|
||||
DUMP_FIELD(Qp);
|
||||
DUMP_FIELD(LenSP);
|
||||
DUMP_FIELD(SearchPath);
|
||||
DUMP_FIELD(SubMBPartMask);
|
||||
DUMP_FIELD(SubPelMode);
|
||||
DUMP_FIELD(InterSAD);
|
||||
DUMP_FIELD(IntraSAD);
|
||||
DUMP_FIELD(AdaptiveSearch);
|
||||
DUMP_FIELD(MVPredictor);
|
||||
DUMP_FIELD(MBQp);
|
||||
DUMP_FIELD(FTEnable);
|
||||
DUMP_FIELD(IntraPartMask);
|
||||
DUMP_FIELD(RefWidth);
|
||||
DUMP_FIELD(RefHeight);
|
||||
DUMP_FIELD(SearchWindow);
|
||||
DUMP_FIELD(DisableMVOutput);
|
||||
DUMP_FIELD(DisableStatisticsOutput);
|
||||
DUMP_FIELD(Enable8x8Stat);
|
||||
DUMP_FIELD(PictureType);
|
||||
DUMP_FIELD(DownsampleInput);
|
||||
DUMP_FIELD(RefPictureType[0]);
|
||||
DUMP_FIELD(RefPictureType[1]);
|
||||
DUMP_FIELD(DownsampleReference[0]);
|
||||
DUMP_FIELD(DownsampleReference[1]);
|
||||
DUMP_FIELD(RefFrame[0]);
|
||||
DUMP_FIELD(RefFrame[1]);
|
||||
DUMP_FIELD_RESERVED(reserved);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiPreEncMVPredictors &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
str += dump(structName + ".Header", _struct.Header) + "\n";
|
||||
DUMP_FIELD_RESERVED(reserved1);
|
||||
DUMP_FIELD(NumMBAlloc);
|
||||
DUMP_FIELD_RESERVED(reserved2);
|
||||
if (_struct.MB)
|
||||
{
|
||||
str += structName + ".MB[]={\n";
|
||||
for (unsigned int i = 0; i < _struct.NumMBAlloc; i++)
|
||||
{
|
||||
str += "{ L0: {" + ToString(_struct.MB[i].MV[0].x) + "," + ToString(_struct.MB[i].MV[0].y)
|
||||
+ "}, L1: {" + ToString(_struct.MB[i].MV[1].x) + "," + ToString(_struct.MB[i].MV[1].y)
|
||||
+ "}}\n";
|
||||
}
|
||||
str += "}\n";
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiPreEncMV &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
str += dump(structName + ".Header", _struct.Header) + "\n";
|
||||
DUMP_FIELD_RESERVED(reserved1);
|
||||
DUMP_FIELD(NumMBAlloc);
|
||||
DUMP_FIELD_RESERVED(reserved2);
|
||||
if (_struct.MB)
|
||||
{
|
||||
str += structName + ".MB[]={\n";
|
||||
for (unsigned int i = 0; i < _struct.NumMBAlloc; i++)
|
||||
{
|
||||
str += "{\n";
|
||||
for (unsigned int j = 0; j < GET_ARRAY_SIZE(_struct.MB[i].MV); j++)
|
||||
{
|
||||
str += "{ L0: {" + ToString(_struct.MB[i].MV[j][0].x) + "," + ToString(_struct.MB[i].MV[j][0].y)
|
||||
+ "}, L1: {" + ToString(_struct.MB[i].MV[j][1].x) + "," + ToString(_struct.MB[i].MV[j][1].y)
|
||||
+ "}}, ";
|
||||
}
|
||||
str += "}\n";
|
||||
}
|
||||
str += "}\n";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiPreEncMBStat &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
str += dump(structName + ".Header", _struct.Header) + "\n";
|
||||
DUMP_FIELD_RESERVED(reserved1);
|
||||
DUMP_FIELD(NumMBAlloc);
|
||||
DUMP_FIELD_RESERVED(reserved2);
|
||||
if (_struct.MB)
|
||||
{
|
||||
for (unsigned int i = 0; i < _struct.NumMBAlloc; i++)
|
||||
{
|
||||
std::string prefix = structName + ".MB[" + ToString(i) + "]";
|
||||
str += prefix + ".Inter[0].BestDistortion=" + ToString(_struct.MB[i].Inter[0].BestDistortion) + "\n";
|
||||
str += prefix + ".Inter[0].Mode=" + ToString(_struct.MB[i].Inter[0].Mode) + "\n";
|
||||
str += prefix + ".Inter[1].BestDistortion=" + ToString(_struct.MB[i].Inter[1].BestDistortion) + "\n";
|
||||
str += prefix + ".Inter[1].Mode=" + ToString(_struct.MB[i].Inter[1].Mode) + "\n";
|
||||
str += prefix + ".BestIntraDistortion=" + ToString(_struct.MB[i].BestIntraDistortion) + "\n";
|
||||
str += prefix + ".IntraMode=" + ToString(_struct.MB[i].IntraMode) + "\n";
|
||||
str += prefix + ".NumOfNonZeroCoef=" + ToString(_struct.MB[i].NumOfNonZeroCoef) + "\n";
|
||||
str += prefix + ".reserved1=" + ToString(_struct.MB[i].reserved1) + "\n";
|
||||
str += prefix + ".SumOfCoef=" + ToString(_struct.MB[i].SumOfCoef) + "\n";
|
||||
str += prefix + ".reserved2=" + ToString(_struct.MB[i].reserved2) + "\n";
|
||||
str += prefix + ".Variance16x16=" + ToString(_struct.MB[i].Variance16x16) + "\n";
|
||||
str += prefix + ".Variance8x8[0]=" + ToString(_struct.MB[i].Variance8x8[0]) + "\n";
|
||||
str += prefix + ".Variance8x8[1]=" + ToString(_struct.MB[i].Variance8x8[1]) + "\n";
|
||||
str += prefix + ".Variance8x8[2]=" + ToString(_struct.MB[i].Variance8x8[2]) + "\n";
|
||||
str += prefix + ".Variance8x8[3]=" + ToString(_struct.MB[i].Variance8x8[3]) + "\n";
|
||||
str += prefix + ".PixelAverage16x16=" + ToString(_struct.MB[i].PixelAverage16x16) + "\n";
|
||||
str += prefix + ".PixelAverage8x8[0]=" + ToString(_struct.MB[i].PixelAverage8x8[0]) + "\n";
|
||||
str += prefix + ".PixelAverage8x8[1]=" + ToString(_struct.MB[i].PixelAverage8x8[1]) + "\n";
|
||||
str += prefix + ".PixelAverage8x8[2]=" + ToString(_struct.MB[i].PixelAverage8x8[2]) + "\n";
|
||||
str += prefix + ".PixelAverage8x8[3]=" + ToString(_struct.MB[i].PixelAverage8x8[3]) + "\n";
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiEncFrameCtrl &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
DUMP_FIELD(SearchPath);
|
||||
DUMP_FIELD(LenSP);
|
||||
DUMP_FIELD(SubMBPartMask);
|
||||
DUMP_FIELD(IntraPartMask);
|
||||
DUMP_FIELD(MultiPredL0);
|
||||
DUMP_FIELD(MultiPredL1);
|
||||
DUMP_FIELD(SubPelMode);
|
||||
DUMP_FIELD(InterSAD);
|
||||
DUMP_FIELD(IntraSAD);
|
||||
DUMP_FIELD(DistortionType);
|
||||
DUMP_FIELD(RepartitionCheckEnable);
|
||||
DUMP_FIELD(AdaptiveSearch);
|
||||
DUMP_FIELD(MVPredictor);
|
||||
DUMP_FIELD(NumMVPredictors[0]);
|
||||
DUMP_FIELD(NumMVPredictors[1]);
|
||||
DUMP_FIELD(PerMBQp);
|
||||
DUMP_FIELD(PerMBInput);
|
||||
DUMP_FIELD(MBSizeCtrl);
|
||||
DUMP_FIELD(RefWidth);
|
||||
DUMP_FIELD(RefHeight);
|
||||
DUMP_FIELD(SearchWindow);
|
||||
DUMP_FIELD(ColocatedMbDistortion);
|
||||
DUMP_FIELD_RESERVED(reserved);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiEncMVPredictors &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
str += dump(structName + ".Header", _struct.Header) + "\n";
|
||||
DUMP_FIELD_RESERVED(reserved1);
|
||||
DUMP_FIELD(NumMBAlloc);
|
||||
DUMP_FIELD_RESERVED(reserved2);
|
||||
if (_struct.MB)
|
||||
{
|
||||
str += structName + ".MB[]={\n";
|
||||
for (unsigned int i = 0; i < _struct.NumMBAlloc; i++)
|
||||
{
|
||||
str += dump("", _struct.MB[i]) + ",\n";
|
||||
}
|
||||
str += "}\n";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiEncMVPredictors::mfxExtFeiEncMVPredictorsMB &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
for (unsigned int i = 0; i < GET_ARRAY_SIZE(_struct.RefIdx); i++)
|
||||
{
|
||||
str += structName + ".RefIdx[" + ToString(i) + "].RefL0=" + ToString(_struct.RefIdx[i].RefL0) + "\n";
|
||||
str += structName + ".RefIdx[" + ToString(i) + "].RefL1=" + ToString(_struct.RefIdx[i].RefL1) + "\n";
|
||||
}
|
||||
|
||||
DUMP_FIELD(reserved);
|
||||
|
||||
// mfxI16Pair MV[4][2]; /* first index is predictor number, second is 0 for L0 and 1 for L1 */
|
||||
|
||||
str += structName + ".MV[]={\n";
|
||||
for (unsigned int i = 0; i < GET_ARRAY_SIZE(_struct.MV); i++)
|
||||
{
|
||||
str += "{ L0: {" + ToString(_struct.MV[i][0].x) + "," + ToString(_struct.MV[i][0].y)
|
||||
+ "}, L1: {" + ToString(_struct.MV[i][1].x) + "," + ToString(_struct.MV[i][1].y)
|
||||
+ "}}, ";
|
||||
}
|
||||
str += "}\n";
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiEncQP &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
str += dump(structName + ".Header", _struct.Header) + "\n";
|
||||
DUMP_FIELD_RESERVED(reserved1);
|
||||
DUMP_FIELD(NumMBAlloc); /* size of allocated memory in number of QPs value*/
|
||||
DUMP_FIELD_RESERVED(reserved2);
|
||||
|
||||
str += structName + ".QP[]=" + dump_reserved_array(_struct.MB, _struct.NumMBAlloc) + "\n";
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiEncMBCtrl &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
str += dump(structName + ".Header", _struct.Header) + "\n";
|
||||
DUMP_FIELD_RESERVED(reserved1);
|
||||
DUMP_FIELD(NumMBAlloc);
|
||||
DUMP_FIELD_RESERVED(reserved2);
|
||||
if (_struct.MB)
|
||||
{
|
||||
str += structName + ".MB[]={\n";
|
||||
for (unsigned int i = 0; i < _struct.NumMBAlloc; i++)
|
||||
{
|
||||
str += dump("", _struct.MB[i]) + ",\n";
|
||||
}
|
||||
str += "}\n";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiEncMBCtrl::mfxExtFeiEncMBCtrlMB &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
DUMP_FIELD(ForceToIntra);
|
||||
DUMP_FIELD(ForceToSkip);
|
||||
DUMP_FIELD(ForceToNoneSkip);
|
||||
#if (MFX_VERSION >= 1025)
|
||||
DUMP_FIELD(DirectBiasAdjustment);
|
||||
DUMP_FIELD(GlobalMotionBiasAdjustment);
|
||||
DUMP_FIELD(MVCostScalingFactor);
|
||||
#endif
|
||||
DUMP_FIELD(reserved1);
|
||||
|
||||
DUMP_FIELD(reserved2);
|
||||
DUMP_FIELD(reserved3);
|
||||
|
||||
DUMP_FIELD(reserved4);
|
||||
DUMP_FIELD(TargetSizeInWord);
|
||||
DUMP_FIELD(MaxSizeInWord);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiEncMV &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
str += dump(structName + ".Header", _struct.Header) + "\n";
|
||||
DUMP_FIELD_RESERVED(reserved1);
|
||||
DUMP_FIELD(NumMBAlloc);
|
||||
DUMP_FIELD_RESERVED(reserved2);
|
||||
if (_struct.MB)
|
||||
{
|
||||
str += structName + ".MB[]={\n";
|
||||
for (unsigned int i = 0; i < _struct.NumMBAlloc; i++)
|
||||
{
|
||||
str += "{\n";
|
||||
for (unsigned int j = 0; j < GET_ARRAY_SIZE(_struct.MB[i].MV); j++)
|
||||
{
|
||||
str += "{ L0: {" + ToString(_struct.MB[i].MV[j][0].x) + "," + ToString(_struct.MB[i].MV[j][0].y)
|
||||
+ "}, L1: {" + ToString(_struct.MB[i].MV[j][1].x) + "," + ToString(_struct.MB[i].MV[j][1].y)
|
||||
+ "}}, ";
|
||||
}
|
||||
str += "}\n";
|
||||
}
|
||||
str += "}\n";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiEncMBStat &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
str += dump(structName + ".Header", _struct.Header) + "\n";
|
||||
DUMP_FIELD_RESERVED(reserved1);
|
||||
DUMP_FIELD(NumMBAlloc);
|
||||
DUMP_FIELD_RESERVED(reserved2);
|
||||
if (_struct.MB)
|
||||
{
|
||||
str += structName + ".MB[]={\n";
|
||||
for (unsigned int i = 0; i < _struct.NumMBAlloc; i++)
|
||||
{
|
||||
str += dump("", _struct.MB[i]) + ",\n";
|
||||
}
|
||||
str += "}\n";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiEncMBStat::mfxExtFeiEncMBStatMB &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
DUMP_FIELD_RESERVED(InterDistortion);
|
||||
DUMP_FIELD(BestInterDistortion);
|
||||
DUMP_FIELD(BestIntraDistortion);
|
||||
DUMP_FIELD(ColocatedMbDistortion);
|
||||
DUMP_FIELD(reserved);
|
||||
DUMP_FIELD_RESERVED(reserved1);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxFeiPakMBCtrl &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
DUMP_FIELD(Header);
|
||||
DUMP_FIELD(MVDataLength);
|
||||
DUMP_FIELD(MVDataOffset);
|
||||
DUMP_FIELD(InterMbMode);
|
||||
DUMP_FIELD(MBSkipFlag);
|
||||
DUMP_FIELD(Reserved00);
|
||||
DUMP_FIELD(IntraMbMode);
|
||||
DUMP_FIELD(Reserved01);
|
||||
DUMP_FIELD(FieldMbPolarityFlag);
|
||||
DUMP_FIELD(MbType);
|
||||
DUMP_FIELD(IntraMbFlag);
|
||||
DUMP_FIELD(FieldMbFlag);
|
||||
DUMP_FIELD(Transform8x8Flag);
|
||||
DUMP_FIELD(Reserved02);
|
||||
DUMP_FIELD(DcBlockCodedCrFlag);
|
||||
DUMP_FIELD(DcBlockCodedCbFlag);
|
||||
DUMP_FIELD(DcBlockCodedYFlag);
|
||||
DUMP_FIELD(MVFormat);
|
||||
DUMP_FIELD(Reserved03);
|
||||
DUMP_FIELD(ExtendedFormat);
|
||||
DUMP_FIELD(HorzOrigin);
|
||||
DUMP_FIELD(VertOrigin);
|
||||
DUMP_FIELD(CbpY);
|
||||
DUMP_FIELD(CbpCb);
|
||||
DUMP_FIELD(CbpCr);
|
||||
DUMP_FIELD(QpPrimeY);
|
||||
DUMP_FIELD(Reserved30);
|
||||
DUMP_FIELD(MbSkipConvDisable);
|
||||
DUMP_FIELD(IsLastMB);
|
||||
DUMP_FIELD(EnableCoefficientClamp);
|
||||
DUMP_FIELD(Direct8x8Pattern);
|
||||
|
||||
if (_struct.IntraMbMode)
|
||||
{
|
||||
//dword 7,8
|
||||
str += structName + ".IntraMB.LumaIntraPredModes[]=" + DUMP_RESERVED_ARRAY(_struct.IntraMB.LumaIntraPredModes) + "\n";
|
||||
//dword 9
|
||||
str += structName + ".IntraMB.ChromaIntraPredMode=" + ToString(_struct.IntraMB.ChromaIntraPredMode) + "\n";
|
||||
str += structName + ".IntraMB.IntraPredAvailFlags=" + ToString(_struct.IntraMB.IntraPredAvailFlags) + "\n";
|
||||
str += structName + ".IntraMB.Reserved60=" + ToString(_struct.IntraMB.Reserved60) + "\n";
|
||||
}
|
||||
|
||||
if (_struct.InterMbMode)
|
||||
{
|
||||
//dword 7
|
||||
str += structName + ".InterMB.SubMbShapes=" + ToString(_struct.InterMB.SubMbShapes) + "\n";
|
||||
str += structName + ".InterMB.SubMbPredModes=" + ToString(_struct.InterMB.SubMbPredModes) + "\n";
|
||||
str += structName + ".InterMB.Reserved40=" + ToString(_struct.InterMB.Reserved40) + "\n";
|
||||
//dword 8, 9
|
||||
for (unsigned int i = 0; i < GET_ARRAY_SIZE(_struct.InterMB.RefIdx); i++)
|
||||
{
|
||||
for (unsigned int j = 0; j < GET_ARRAY_SIZE(_struct.InterMB.RefIdx[0]); j++)
|
||||
{
|
||||
str += structName + ".InterMB.RefIdx[" + ToString(i) + "][" + ToString(j) + "]=" + ToString(_struct.InterMB.RefIdx[i][j]) + "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//dword 10
|
||||
DUMP_FIELD(Reserved70);
|
||||
DUMP_FIELD(TargetSizeInWord);
|
||||
DUMP_FIELD(MaxSizeInWord);
|
||||
|
||||
DUMP_FIELD_RESERVED(reserved2);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiPakMBCtrl &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
str += dump(structName + ".Header", _struct.Header) + "\n";
|
||||
DUMP_FIELD_RESERVED(reserved1);
|
||||
DUMP_FIELD(NumMBAlloc);
|
||||
DUMP_FIELD_RESERVED(reserved2);
|
||||
if (_struct.MB)
|
||||
{
|
||||
str += structName + ".MB[]={\n";
|
||||
for (unsigned int i = 0; i < _struct.NumMBAlloc; i++)
|
||||
{
|
||||
str += dump("", _struct.MB[i]) + ",\n";
|
||||
}
|
||||
str += "}\n";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiRepackCtrl &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
str += dump(structName + ".Header", _struct.Header) + "\n";
|
||||
DUMP_FIELD(MaxFrameSize);
|
||||
DUMP_FIELD(NumPasses);
|
||||
DUMP_FIELD_RESERVED(reserved);
|
||||
DUMP_FIELD_RESERVED(DeltaQP);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
#if (MFX_VERSION >= 1025)
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiRepackStat &_struct)
|
||||
{
|
||||
std::string str;
|
||||
str += dump(structName + ".Header", _struct.Header) + "\n";
|
||||
DUMP_FIELD(NumPasses);
|
||||
DUMP_FIELD_RESERVED(reserved);
|
||||
return str;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxFeiDecStreamOutMBCtrl &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
//dword 0
|
||||
DUMP_FIELD(InterMbMode);
|
||||
DUMP_FIELD(MBSkipFlag);
|
||||
DUMP_FIELD(Reserved00);
|
||||
DUMP_FIELD(IntraMbMode);
|
||||
DUMP_FIELD(Reserved01);
|
||||
DUMP_FIELD(FieldMbPolarityFlag);
|
||||
DUMP_FIELD(MbType);
|
||||
DUMP_FIELD(IntraMbFlag);
|
||||
DUMP_FIELD(FieldMbFlag);
|
||||
DUMP_FIELD(Transform8x8Flag);
|
||||
DUMP_FIELD(Reserved02);
|
||||
DUMP_FIELD(DcBlockCodedCrFlag);
|
||||
DUMP_FIELD(DcBlockCodedCbFlag);
|
||||
DUMP_FIELD(DcBlockCodedYFlag);
|
||||
DUMP_FIELD(Reserved03);
|
||||
//dword 1
|
||||
DUMP_FIELD(HorzOrigin);
|
||||
DUMP_FIELD(VertOrigin);
|
||||
//dword 2
|
||||
DUMP_FIELD(CbpY);
|
||||
DUMP_FIELD(CbpCb);
|
||||
DUMP_FIELD(CbpCr);
|
||||
DUMP_FIELD(Reserved20);
|
||||
DUMP_FIELD(IsLastMB);
|
||||
DUMP_FIELD(ConcealMB);
|
||||
//dword 3
|
||||
DUMP_FIELD(QpPrimeY);
|
||||
DUMP_FIELD(Reserved30);
|
||||
DUMP_FIELD(Reserved31);
|
||||
DUMP_FIELD(NzCoeffCount);
|
||||
DUMP_FIELD(Reserved32);
|
||||
DUMP_FIELD(Direct8x8Pattern);
|
||||
|
||||
if (_struct.IntraMbMode)
|
||||
{
|
||||
//dword 4, 5
|
||||
str += structName + ".IntraMB.LumaIntraPredModes[]=" + DUMP_RESERVED_ARRAY(_struct.IntraMB.LumaIntraPredModes) + "\n";
|
||||
//dword 6
|
||||
str += structName + ".IntraMB.ChromaIntraPredMode=" + ToString(_struct.IntraMB.ChromaIntraPredMode) + "\n";
|
||||
str += structName + ".IntraMB.IntraPredAvailFlags=" + ToString(_struct.IntraMB.IntraPredAvailFlags) + "\n";
|
||||
str += structName + ".IntraMB.Reserved60=" + ToString(_struct.IntraMB.Reserved60) + "\n";
|
||||
}
|
||||
|
||||
if (_struct.InterMbMode)
|
||||
{
|
||||
//dword 4
|
||||
str += structName + ".InterMB.SubMbShapes=" + ToString(_struct.InterMB.SubMbShapes) + "\n";
|
||||
str += structName + ".InterMB.SubMbPredModes=" + ToString(_struct.InterMB.SubMbPredModes) + "\n";
|
||||
str += structName + ".InterMB.Reserved40=" + ToString(_struct.InterMB.Reserved40) + "\n";
|
||||
//dword 5, 6
|
||||
for (unsigned int i = 0; i < GET_ARRAY_SIZE(_struct.InterMB.RefIdx); i++)
|
||||
{
|
||||
for (unsigned int j = 0; j < GET_ARRAY_SIZE(_struct.InterMB.RefIdx[0]); j++)
|
||||
{
|
||||
str += structName + ".InterMB.RefIdx[" + ToString(i) + "][" + ToString(j) + "]=" + ToString(_struct.InterMB.RefIdx[i][j]) + "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//dword 7
|
||||
DUMP_FIELD(Reserved70);
|
||||
|
||||
//dword 8-15
|
||||
str += structName + ".MV[]={\n";
|
||||
for (unsigned int i = 0; i < GET_ARRAY_SIZE(_struct.MV); i++)
|
||||
{
|
||||
str += "{ L0: {" + ToString(_struct.MV[i][0].x) + "," + ToString(_struct.MV[i][0].y)
|
||||
+ "}, L1: {" + ToString(_struct.MV[i][1].x) + "," + ToString(_struct.MV[i][1].y)
|
||||
+ "}}, ";
|
||||
}
|
||||
str += "}\n";
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiDecStreamOut &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
str += dump(structName + ".Header", _struct.Header) + "\n";
|
||||
DUMP_FIELD_RESERVED(reserved1);
|
||||
DUMP_FIELD(NumMBAlloc);
|
||||
DUMP_FIELD(RemapRefIdx);
|
||||
DUMP_FIELD(PicStruct);
|
||||
DUMP_FIELD_RESERVED(reserved2);
|
||||
if (_struct.MB)
|
||||
{
|
||||
str += structName + ".MB[]={\n";
|
||||
for (unsigned int i = 0; i < _struct.NumMBAlloc; i++)
|
||||
{
|
||||
str += dump("", _struct.MB[i]) + ",\n";
|
||||
}
|
||||
str += "}\n";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiParam &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
str += dump(structName + ".Header", _struct.Header) + "\n";
|
||||
DUMP_FIELD(Func);
|
||||
DUMP_FIELD(SingleFieldProcessing);
|
||||
DUMP_FIELD_RESERVED(reserved);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxPAKInput &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
DUMP_FIELD_RESERVED(reserved);
|
||||
|
||||
if (_struct.InSurface)
|
||||
{
|
||||
str += dump(structName + ".InSurface", *_struct.InSurface) + "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
str += structName + ".InSurface=NULL\n";
|
||||
}
|
||||
DUMP_FIELD(NumFrameL0);
|
||||
if (_struct.L0Surface)
|
||||
{
|
||||
for (int i = 0; i < _struct.NumFrameL0; i++)
|
||||
{
|
||||
if (_struct.L0Surface[i])
|
||||
{
|
||||
str += dump(structName + ".L0Surface[" + ToString(i) + "]", *_struct.L0Surface[i]) + "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
str += structName + ".L0Surface[" + ToString(i) + "]=NULL\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
DUMP_FIELD(NumFrameL1);
|
||||
if (_struct.L1Surface)
|
||||
{
|
||||
for (int i = 0; i < _struct.NumFrameL1; i++)
|
||||
{
|
||||
if (_struct.L1Surface[i])
|
||||
{
|
||||
str += dump(structName + ".L1Surface[" + ToString(i) + "]", *_struct.L1Surface[i]) + "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
str += structName + ".L1Surface[" + ToString(i) + "]=NULL\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
str += dump_mfxExtParams(structName, _struct) + "\n";
|
||||
DUMP_FIELD(NumPayload);
|
||||
if (_struct.Payload)
|
||||
{
|
||||
for (int i = 0; i < _struct.NumPayload; i++)
|
||||
{
|
||||
if (_struct.Payload[i])
|
||||
{
|
||||
str += dump(structName + ".Payload[" + ToString(i) + "]", *_struct.Payload[i]) + "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
str += structName + ".Payload[" + ToString(i) +"]=NULL\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxPAKOutput &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
DUMP_FIELD_RESERVED(reserved);
|
||||
|
||||
if (_struct.Bs)
|
||||
{
|
||||
str += dump(structName + ".Bs", *_struct.Bs) + "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
str += structName + ".Bs=NULL\n";
|
||||
}
|
||||
|
||||
if (_struct.OutSurface)
|
||||
{
|
||||
str += dump(structName + ".OutSurface", *_struct.OutSurface) + "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
str += structName + ".OutSurface=NULL\n";
|
||||
}
|
||||
|
||||
str += dump_mfxExtParams(structName, _struct) + "\n";
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiSPS &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
str += dump(structName + ".Header", _struct.Header) + "\n";
|
||||
DUMP_FIELD(SPSId);
|
||||
DUMP_FIELD(PicOrderCntType);
|
||||
DUMP_FIELD(Log2MaxPicOrderCntLsb);
|
||||
DUMP_FIELD_RESERVED(reserved);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiPPS &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
str += dump(structName + ".Header", _struct.Header) + "\n";
|
||||
DUMP_FIELD(SPSId);
|
||||
DUMP_FIELD(PPSId);
|
||||
DUMP_FIELD(PictureType);
|
||||
DUMP_FIELD(FrameType);
|
||||
DUMP_FIELD(PicInitQP);
|
||||
DUMP_FIELD(NumRefIdxL0Active);
|
||||
DUMP_FIELD(NumRefIdxL1Active);
|
||||
DUMP_FIELD(ChromaQPIndexOffset);
|
||||
DUMP_FIELD(SecondChromaQPIndexOffset);
|
||||
DUMP_FIELD(Transform8x8ModeFlag);
|
||||
DUMP_FIELD_RESERVED(reserved);
|
||||
|
||||
str += structName + ".DpbBefore[]={\n";
|
||||
for (unsigned int i = 0; i < GET_ARRAY_SIZE(_struct.DpbBefore); i++)
|
||||
{
|
||||
str += " [" + ToString(i) + "]\n";
|
||||
str += " {\n";
|
||||
str += " .Index" + ToString(_struct.DpbBefore[i].Index) + "\n";
|
||||
str += " .PicType" + ToString(_struct.DpbBefore[i].PicType) + "\n";
|
||||
str += " .FrameNumWrap" + ToString(_struct.DpbBefore[i].FrameNumWrap) + "\n";
|
||||
str += " .LongTermFrameIdx" + ToString(_struct.DpbBefore[i].LongTermFrameIdx) + "\n";
|
||||
str += " .reserved[0]" + ToString(_struct.DpbBefore[i].reserved[0]) + "\n";
|
||||
str += " .reserved[1]" + ToString(_struct.DpbBefore[i].reserved[1]) + "\n";
|
||||
str += " .reserved[2]" + ToString(_struct.DpbBefore[i].reserved[2]) + "\n";
|
||||
str += " }\n";
|
||||
}
|
||||
str += "}\n";
|
||||
|
||||
str += structName + ".DpbAfter[]={\n";
|
||||
for (unsigned int i = 0; i < GET_ARRAY_SIZE(_struct.DpbAfter); i++)
|
||||
{
|
||||
str += " [" + ToString(i) + "]\n";
|
||||
str += " {\n";
|
||||
str += " .Index" + ToString(_struct.DpbAfter[i].Index) + "\n";
|
||||
str += " .PicType" + ToString(_struct.DpbAfter[i].PicType) + "\n";
|
||||
str += " .FrameNumWrap" + ToString(_struct.DpbAfter[i].FrameNumWrap) + "\n";
|
||||
str += " .LongTermFrameIdx" + ToString(_struct.DpbAfter[i].LongTermFrameIdx) + "\n";
|
||||
str += " }\n";
|
||||
}
|
||||
str += "}\n";
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiSliceHeader &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
str += dump(structName + ".Header", _struct.Header) + "\n";
|
||||
|
||||
DUMP_FIELD(NumSlice);
|
||||
DUMP_FIELD_RESERVED(reserved);
|
||||
|
||||
if (_struct.Slice)
|
||||
{
|
||||
str += structName + ".Slice[]={\n";
|
||||
for (int i = 0; i < _struct.NumSlice; i++)
|
||||
{
|
||||
str += dump("", _struct.Slice[i]) + ",\n";
|
||||
}
|
||||
str += "}\n";
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiSliceHeader::mfxSlice &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
DUMP_FIELD(MBAddress);
|
||||
DUMP_FIELD(NumMBs);
|
||||
DUMP_FIELD(SliceType);
|
||||
DUMP_FIELD(PPSId);
|
||||
DUMP_FIELD(IdrPicId);
|
||||
DUMP_FIELD(CabacInitIdc);
|
||||
DUMP_FIELD(NumRefIdxL0Active);
|
||||
DUMP_FIELD(NumRefIdxL1Active);
|
||||
DUMP_FIELD(SliceQPDelta);
|
||||
DUMP_FIELD(DisableDeblockingFilterIdc);
|
||||
DUMP_FIELD(SliceAlphaC0OffsetDiv2);
|
||||
DUMP_FIELD(SliceBetaOffsetDiv2);
|
||||
DUMP_FIELD_RESERVED(reserved);
|
||||
|
||||
for (unsigned int i = 0; i < GET_ARRAY_SIZE(_struct.RefL0); i++)
|
||||
{
|
||||
str += structName + ".RefL0[" + ToString(i) + "].PictureType=" + ToString(_struct.RefL0[i].PictureType) + "\n";
|
||||
str += structName + ".RefL0[" + ToString(i) + "].Index=" + ToString(_struct.RefL0[i].Index) + "\n";
|
||||
str += structName + ".RefL0[" + ToString(i) + "].reserved[0]=" + ToString(_struct.RefL0[i].reserved[0]) + "\n";
|
||||
str += structName + ".RefL0[" + ToString(i) + "].reserved[1]=" + ToString(_struct.RefL0[i].reserved[1]) + "\n";
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < GET_ARRAY_SIZE(_struct.RefL1); i++)
|
||||
{
|
||||
str += structName + ".RefL1[" + ToString(i) + "].PictureType=" + ToString(_struct.RefL1[i].PictureType) + "\n";
|
||||
str += structName + ".RefL1[" + ToString(i) + "].Index=" + ToString(_struct.RefL1[i].Index) + "\n";
|
||||
str += structName + ".RefL1[" + ToString(i) + "].reserved[0]=" + ToString(_struct.RefL1[i].reserved[0]) + "\n";
|
||||
str += structName + ".RefL1[" + ToString(i) + "].reserved[1]=" + ToString(_struct.RefL1[i].reserved[1]) + "\n";
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtFeiCodingOption &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
str += dump(structName + ".Header", _struct.Header) + "\n";
|
||||
|
||||
DUMP_FIELD(DisableHME);
|
||||
DUMP_FIELD(DisableSuperHME);
|
||||
DUMP_FIELD(DisableUltraHME);
|
||||
DUMP_FIELD_RESERVED(reserved);
|
||||
return str;
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
// Copyright (c) 2020 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "dump.h"
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtLAControl &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
str += dump(structName + ".Header", _struct.Header) + "\n";
|
||||
DUMP_FIELD(LookAheadDepth);
|
||||
DUMP_FIELD(DependencyDepth);
|
||||
DUMP_FIELD(DownScaleFactor);
|
||||
DUMP_FIELD(BPyramid);
|
||||
|
||||
DUMP_FIELD_RESERVED(reserved1);
|
||||
|
||||
DUMP_FIELD(NumOutStream);
|
||||
|
||||
str += structName + ".OutStream[]={\n";
|
||||
for (int i = 0; i < _struct.NumOutStream; i++)
|
||||
{
|
||||
str += dump("", _struct.OutStream[i]) + ",\n";
|
||||
}
|
||||
str += "}\n";
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtLAControl::mfxStream &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
DUMP_FIELD(Width);
|
||||
DUMP_FIELD(Height);
|
||||
|
||||
DUMP_FIELD_RESERVED(reserved2);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxLAFrameInfo &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
DUMP_FIELD(Width);
|
||||
DUMP_FIELD(Height);
|
||||
|
||||
DUMP_FIELD(FrameType);
|
||||
DUMP_FIELD(FrameDisplayOrder);
|
||||
DUMP_FIELD(FrameEncodeOrder);
|
||||
|
||||
DUMP_FIELD(IntraCost);
|
||||
DUMP_FIELD(InterCost);
|
||||
DUMP_FIELD(DependencyCost);
|
||||
DUMP_FIELD(Layer);
|
||||
DUMP_FIELD_RESERVED(reserved);
|
||||
|
||||
DUMP_FIELD_RESERVED(EstimatedRate);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtLAFrameStatistics &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
str += dump(structName + ".Header", _struct.Header) + "\n";
|
||||
|
||||
DUMP_FIELD_RESERVED(reserved);
|
||||
|
||||
DUMP_FIELD(NumAlloc);
|
||||
DUMP_FIELD(NumStream);
|
||||
DUMP_FIELD(NumFrame);
|
||||
|
||||
|
||||
str += structName + ".FrameStat[]={\n";
|
||||
for (int i = 0; i < _struct.NumStream; i++)
|
||||
{
|
||||
str += dump("", _struct.FrameStat[i]) + ",\n";
|
||||
}
|
||||
str += "}\n";
|
||||
|
||||
|
||||
if (_struct.OutSurface)
|
||||
{
|
||||
str += dump(structName + ".OutSurface", *_struct.OutSurface) + "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
str += structName + ".OutSurface=NULL\n";
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
/* ****************************************************************************** *\
|
||||
|
||||
Copyright (C) 2020 Intel Corporation. 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.
|
||||
- Neither the name of Intel Corporation nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "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 INTEL CORPORATION 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 Name: dump_mfxplugin.cpp
|
||||
|
||||
\* ****************************************************************************** */
|
||||
|
||||
#include "dump.h"
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxPlugin &plugin)
|
||||
{
|
||||
std::string str;
|
||||
str += structName + ".pthis=" + ToString(plugin.pthis) + "\n";
|
||||
str += structName + ".PluginInit=" + ToString(plugin.PluginInit) + "\n";
|
||||
str += structName + ".PluginClose=" + ToString(plugin.PluginClose) + "\n";
|
||||
str += structName + ".GetPluginParam=" + ToString(plugin.GetPluginParam) + "\n";
|
||||
str += structName + ".Submit=" + ToString(plugin.Submit) + "\n";
|
||||
str += structName + ".Execute=" + ToString(plugin.Execute) + "\n";
|
||||
str += structName + ".FreeResources=" + ToString(plugin.FreeResources) + "\n";
|
||||
str += structName + ".reserved[]=" + DUMP_RESERVED_ARRAY(plugin.reserved) + "\n";
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxCoreParam &CoreParam)
|
||||
{
|
||||
std::string str;
|
||||
str += structName + ".reserved[]=" + DUMP_RESERVED_ARRAY(CoreParam.reserved) + "\n";
|
||||
str += structName + ".Impl=" + GetmfxIMPL(CoreParam.Impl) + "\n";
|
||||
str += dump(structName + ".Version=", CoreParam.Version) + "\n";
|
||||
str += structName + ".NumWorkingThread=" + ToString(CoreParam.NumWorkingThread) + "\n";
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxPluginParam &PluginParam)
|
||||
{
|
||||
std::string str;
|
||||
str += structName + ".reserved[]=" + DUMP_RESERVED_ARRAY(PluginParam.reserved) + "\n";
|
||||
str += structName + ".reserved1=" + ToString(PluginParam.reserved1) + "\n";
|
||||
str += structName + ".PluginVersion=" + ToString(PluginParam.PluginVersion) + "\n";
|
||||
str += dump(structName + ".APIVersion=", PluginParam.APIVersion) + "\n";
|
||||
str += structName + ".PluginUID=" + dump_hex_array(PluginParam.PluginUID.Data) + "\n";
|
||||
str += structName + ".Type=" + ToString(PluginParam.Type) + "\n";
|
||||
str += structName + ".CodecId=" + GetCodecIdString(PluginParam.CodecId) + "\n";
|
||||
str += structName + ".ThreadPolicy=" + ToString(PluginParam.ThreadPolicy) + "\n";
|
||||
str += structName + ".MaxThreadNum=" + ToString(PluginParam.MaxThreadNum) + "\n";
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxCoreInterface &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
DUMP_FIELD(pthis);
|
||||
DUMP_FIELD_RESERVED(reserved1);
|
||||
str += dump(structName + ".FrameAllocator", _struct.FrameAllocator) + "\n";
|
||||
DUMP_FIELD(GetCoreParam);
|
||||
DUMP_FIELD(GetHandle);
|
||||
DUMP_FIELD(IncreaseReference);
|
||||
DUMP_FIELD(DecreaseReference);
|
||||
DUMP_FIELD(CopyFrame);
|
||||
DUMP_FIELD(CopyBuffer);
|
||||
DUMP_FIELD(MapOpaqueSurface);
|
||||
DUMP_FIELD(UnmapOpaqueSurface);
|
||||
DUMP_FIELD(GetRealSurface);
|
||||
DUMP_FIELD(GetOpaqueSurface);
|
||||
DUMP_FIELD(CreateAccelerationDevice);
|
||||
DUMP_FIELD(GetFrameHandle);
|
||||
DUMP_FIELD(GetFrameHandle);
|
||||
DUMP_FIELD(QueryPlatform);
|
||||
DUMP_FIELD_RESERVED(reserved4);
|
||||
|
||||
return str;
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
// Copyright (c) 2020 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "dump.h"
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxSession &session)
|
||||
{
|
||||
return std::string("mfxSession " + structName + "=" + ToString(session));
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,47 +0,0 @@
|
|||
/* ****************************************************************************** *\
|
||||
|
||||
Copyright (C) 2012-2020 Intel Corporation. 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.
|
||||
- Neither the name of Intel Corporation nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "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 INTEL CORPORATION 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 Name: dump_mfxvideo.cpp
|
||||
|
||||
\* ****************************************************************************** */
|
||||
|
||||
#include "dump.h"
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxFrameAllocator &allocator)
|
||||
{
|
||||
std::string str;
|
||||
str += structName + ".pthis=" + ToHexFormatString(&allocator.pthis) + "\n";
|
||||
str += structName + ".reserved[]=" + DUMP_RESERVED_ARRAY(allocator.reserved) + "\n";
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxBufferAllocator &allocator)
|
||||
{
|
||||
std::string str;
|
||||
str += structName + ".pthis=" + ToHexFormatString(&allocator.pthis) + "\n";
|
||||
str += structName + ".reserved[]=" + DUMP_RESERVED_ARRAY(allocator.reserved) + "\n";
|
||||
return str;
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
/* ****************************************************************************** *\
|
||||
|
||||
Copyright (C) 2012-2020 Intel Corporation. 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.
|
||||
- Neither the name of Intel Corporation nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "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 INTEL CORPORATION 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 Name: dump_mfxvp8.cpp
|
||||
|
||||
\* ****************************************************************************** */
|
||||
|
||||
#include "dump.h"
|
||||
|
||||
std::string DumpContext::dump(const std::string structName, const mfxExtVP8CodingOption &_struct)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
str += dump(structName + ".Header", _struct.Header) + "\n";
|
||||
|
||||
DUMP_FIELD(Version);
|
||||
DUMP_FIELD(EnableMultipleSegments);
|
||||
DUMP_FIELD(LoopFilterType);
|
||||
DUMP_FIELD_RESERVED(LoopFilterLevel);
|
||||
DUMP_FIELD(SharpnessLevel);
|
||||
DUMP_FIELD(NumTokenPartitions);
|
||||
DUMP_FIELD_RESERVED(LoopFilterRefTypeDelta);
|
||||
DUMP_FIELD_RESERVED(LoopFilterMbModeDelta);
|
||||
DUMP_FIELD_RESERVED(SegmentQPDelta);
|
||||
DUMP_FIELD_RESERVED(CoeffTypeQPDelta);
|
||||
DUMP_FIELD(WriteIVFHeaders);
|
||||
DUMP_FIELD(NumFramesForIVFHeader);
|
||||
DUMP_FIELD(reserved);
|
||||
|
||||
return str;
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
/* ****************************************************************************** *\
|
||||
|
||||
INTEL CORPORATION PROPRIETARY INFORMATION
|
||||
This software is supplied under the terms of a license agreement or nondisclosure
|
||||
agreement with Intel Corporation and may not be copied or disclosed except in
|
||||
accordance with the terms of that agreement
|
||||
Copyright(c) 2012-2020 Intel Corporation. All Rights Reserved.
|
||||
|
||||
File Name: ConficManager.cs
|
||||
|
||||
\* ****************************************************************************** */
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace msdk_analyzer
|
||||
{
|
||||
class ConfigManager
|
||||
{
|
||||
public ConfigManager() { }
|
||||
|
||||
public bool CreateConfig (string config_path, Dictionary<string, Dictionary<string, string>> config)
|
||||
{
|
||||
FileInfo _file = new FileInfo(config_path);
|
||||
StreamWriter writer = new StreamWriter(config_path);
|
||||
if(_file.Exists){
|
||||
foreach (KeyValuePair<string, Dictionary <string, string>> pair in config)
|
||||
{
|
||||
writer.WriteLine("[" + pair.Key + "]");
|
||||
|
||||
Dictionary <string, string> section_params = pair.Value;
|
||||
foreach (KeyValuePair<string, string> ppair in section_params)
|
||||
{
|
||||
writer.WriteLine(" " + ppair.Key + " = " + ppair.Value);
|
||||
}
|
||||
|
||||
writer.Write("\n");
|
||||
}
|
||||
|
||||
writer.Close();
|
||||
writer.Dispose();
|
||||
return true;
|
||||
}
|
||||
writer.Close();
|
||||
writer.Dispose();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue