Compare commits
41 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4d2632a845 | |||
| 17a262aace | |||
| 205e5c5a59 | |||
| 3584b47fb8 | |||
| de651c0f1a | |||
| e7a8cf2bba | |||
| fb92dcd1c2 | |||
| 8e75f3d8bf | |||
| 5e1e64e50b | |||
| fbe1e62ef2 | |||
| 0c9d3ee33f | |||
| df04c2c54f | |||
| 9da38b8d9c | |||
| 1bc156aab0 | |||
| 399ea9a0f1 | |||
| df70bf00f9 | |||
| 9e6ab9b94d | |||
| 6f409caac7 | |||
| 5977b4b9f1 | |||
| 0a617e7779 | |||
| 75d1322b8a | |||
| 55e7f3fca9 | |||
| 055b95a181 | |||
| f4b52d0bf5 | |||
| bbe4380b41 | |||
| aedee2a4e3 | |||
| c28b10a5b9 | |||
| 78d018ae2f | |||
| 1b58130e68 | |||
| 12d4b025f7 | |||
| 871ebb31ce | |||
| 600693914f | |||
| 4d89dcd3d7 | |||
| 97c5778a36 | |||
| 22b352c1da | |||
| 15233a68cf | |||
| 2a637eaf3f | |||
| 6c976e9dc5 | |||
| 691c064a37 | |||
| 34519566ba | |||
| 44b71e7460 |
@@ -1,4 +1,4 @@
|
||||
# Build the punktfunk-host / punktfunk-client / punktfunk-web pacman packages from
|
||||
# Build the punktfunk-host / punktfunk-client / punktfunk-web / punktfunk-scripting pacman packages from
|
||||
# packaging/arch/PKGBUILD and publish them to Gitea's Arch package registry, so Arch boxes
|
||||
# get new builds via `pacman -Syu`. Counterpart to deb.yml (apt) and rpm.yml (dnf/rpm-ostree).
|
||||
# Arch is rolling, so the packages build against whatever the archlinux:base-devel container
|
||||
@@ -45,8 +45,9 @@ jobs:
|
||||
git nodejs rust clang cmake nasm pkgconf python vulkan-headers \
|
||||
gtk4 libadwaita sdl3 ffmpeg pipewire wayland libxkbcommon opus libei \
|
||||
mesa libglvnd unzip libarchive
|
||||
# bun builds the punktfunk-web console AND is vendored as its runtime (PF_WITH_WEB=1);
|
||||
# it's AUR-only on Arch, so bootstrap the official binary.
|
||||
# bun builds the punktfunk-web console + the punktfunk-scripting runner AND is vendored as
|
||||
# their runtime (PF_WITH_WEB=1 / PF_WITH_SCRIPTING=1); it's AUR-only on Arch, so bootstrap
|
||||
# the official binary.
|
||||
command -v bun >/dev/null || {
|
||||
curl -fsSL https://bun.sh/install | bash
|
||||
install -m0755 "$HOME/.bun/bin/bun" /usr/local/bin/bun
|
||||
@@ -105,7 +106,7 @@ jobs:
|
||||
sudo -u builder git config --global --add safe.directory "$PWD"
|
||||
mkdir -p dist && chown builder: dist
|
||||
cd packaging/arch
|
||||
sudo -u builder env PF_SRCDIR="$GITHUB_WORKSPACE" PF_WITH_WEB=1 \
|
||||
sudo -u builder env PF_SRCDIR="$GITHUB_WORKSPACE" PF_WITH_WEB=1 PF_WITH_SCRIPTING=1 \
|
||||
PF_PKGVER="$PF_PKGVER" PF_PKGREL="$PF_PKGREL" \
|
||||
CARGO_HOME="$CARGO_HOME" PKGDEST="$GITHUB_WORKSPACE/dist" \
|
||||
makepkg -f -d --holdver
|
||||
|
||||
@@ -132,6 +132,8 @@ jobs:
|
||||
VERSION="$VERSION" bash packaging/debian/build-client-deb.sh
|
||||
# Reuse CI's bun for the vendored runtime (matches the amd64 runner) instead of downloading.
|
||||
VERSION="$VERSION" BUN_BIN="$(command -v bun || true)" bash packaging/debian/build-web-deb.sh
|
||||
# The plugin/script runner (bun-bundled Effect SDK) — same vendored-bun mechanics.
|
||||
VERSION="$VERSION" BUN_BIN="$(command -v bun || true)" bash packaging/debian/build-scripting-deb.sh
|
||||
|
||||
- name: Publish to the Gitea apt registry
|
||||
env:
|
||||
|
||||
@@ -258,9 +258,12 @@ jobs:
|
||||
# sdk-scoped one (iOS/tvOS) lands on it and fails the archive ("does not support
|
||||
# provisioning profiles"). Automatic signing assigns a profile only to the app and leaves
|
||||
# the resource bundle (and the macOS-host macro plugins) alone, and bakes the sandbox
|
||||
# entitlements in. No -allowProvisioningUpdates → it stays OFFLINE and never cloud-signs
|
||||
# (the App-Manager ASC key can't), so the runner must have a macOS *development* profile
|
||||
# for io.unom.punktfunk installed. DISTRIBUTION signing happens in the export step below
|
||||
# entitlements in. -allowProvisioningUpdates lets Xcode sync the App ID capabilities and
|
||||
# regenerate the managed *development* profile — needed because the App Groups capability
|
||||
# (group.io.unom.punktfunk, in Config/Punktfunk-macOS.entitlements) invalidated the cached
|
||||
# one. This is DEVELOPMENT signing against the Apple Development cert already in the
|
||||
# keychain, so the App-Manager ASC key suffices. DISTRIBUTION signing happens in the export
|
||||
# step below
|
||||
# (manual, via the plist). Quit Xcode so it can't prune the manually-installed App Store
|
||||
# distribution profile that export needs.
|
||||
osascript -e 'tell application "Xcode" to quit' >/dev/null 2>&1 || true
|
||||
@@ -271,6 +274,10 @@ jobs:
|
||||
-destination 'generic/platform=macOS' \
|
||||
-archivePath "$RUNNER_TEMP/Punktfunk-macos-appstore.xcarchive" \
|
||||
-skipMacroValidation -skipPackagePluginValidation \
|
||||
-allowProvisioningUpdates \
|
||||
-authenticationKeyPath "$RUNNER_TEMP/asc.p8" \
|
||||
-authenticationKeyID "${{ secrets.ASC_API_KEY_ID }}" \
|
||||
-authenticationKeyIssuerID "${{ secrets.ASC_API_ISSUER_ID }}" \
|
||||
MARKETING_VERSION="$VERSION" CURRENT_PROJECT_VERSION="$BUILD_NUM" \
|
||||
CODE_SIGN_STYLE=Automatic \
|
||||
DEVELOPMENT_TEAM="$TEAM_ID"
|
||||
@@ -308,19 +315,32 @@ jobs:
|
||||
# license screens) builds for iphoneos, so even the sdk-scoped PROVISIONING_PROFILE_SPECIFIER
|
||||
# this step used to set matched it and failed the archive ("does not support provisioning
|
||||
# profiles"). Automatic signing profiles only the app and leaves the resource bundle (and
|
||||
# the macOS-host macro plugins) alone. No -allowProvisioningUpdates → OFFLINE, never
|
||||
# cloud-signs (the App-Manager ASC key can't), so the runner needs an iOS *development*
|
||||
# profile for io.unom.punktfunk installed. DISTRIBUTION signing is the export step below
|
||||
# (manual, via the plist). A running Xcode.app prunes unrecognized profiles — quit it so the
|
||||
# manually-installed App Store distribution profile survives for export.
|
||||
# the macOS-host macro plugins) alone. -allowProvisioningUpdates lets Xcode sync the App ID
|
||||
# capabilities and regenerate the managed *development* profiles for both io.unom.punktfunk
|
||||
# AND the embedded io.unom.punktfunk.widgets — needed because adding the App Groups
|
||||
# capability (group.io.unom.punktfunk, shared with the Widget/Live-Activity extension)
|
||||
# invalidated the cached managed dev profile, which had no widgets profile at all. This is
|
||||
# DEVELOPMENT signing against the Apple Development cert already in the keychain — no cert
|
||||
# creation, so the App-Manager ASC key is sufficient (it only manages App IDs/dev profiles).
|
||||
# DISTRIBUTION signing is the export step below (manual, via the plist) and is unaffected.
|
||||
# A running Xcode.app prunes unrecognized profiles — quit it so the manually-installed
|
||||
# App Store distribution profile survives for export.
|
||||
osascript -e 'tell application "Xcode" to quit' >/dev/null 2>&1 || true
|
||||
pkill -x Xcode 2>/dev/null || true
|
||||
PROFILE="Punktfunk iOS App Store Distribution"
|
||||
# The embedded PunktfunkWidgetsExtension (bundle io.unom.punktfunk.widgets) is a second
|
||||
# distribution artifact in the .ipa, so manual signing must map its App ID to its own
|
||||
# App Store profile too — else exportArchive fails ("no profile for io.unom.punktfunk.widgets").
|
||||
WIDGET_PROFILE="Punktfunk iOS Widgets App Store Distribution"
|
||||
DEVELOPER_DIR="$XCODE_DEV_DIR" xcodebuild archive \
|
||||
-project "$PROJECT" -scheme Punktfunk-iOS \
|
||||
-destination 'generic/platform=iOS' \
|
||||
-archivePath "$RUNNER_TEMP/Punktfunk-ios.xcarchive" \
|
||||
-skipMacroValidation -skipPackagePluginValidation \
|
||||
-allowProvisioningUpdates \
|
||||
-authenticationKeyPath "$RUNNER_TEMP/asc.p8" \
|
||||
-authenticationKeyID "${{ secrets.ASC_API_KEY_ID }}" \
|
||||
-authenticationKeyIssuerID "${{ secrets.ASC_API_ISSUER_ID }}" \
|
||||
MARKETING_VERSION="$VERSION" CURRENT_PROJECT_VERSION="$BUILD_NUM" \
|
||||
CODE_SIGN_STYLE=Automatic \
|
||||
DEVELOPMENT_TEAM="$TEAM_ID"
|
||||
@@ -335,7 +355,10 @@ jobs:
|
||||
<key>signingStyle</key><string>manual</string>
|
||||
<key>signingCertificate</key><string>Apple Distribution</string>
|
||||
<key>provisioningProfiles</key>
|
||||
<dict><key>io.unom.punktfunk</key><string>$PROFILE</string></dict>
|
||||
<dict>
|
||||
<key>io.unom.punktfunk</key><string>$PROFILE</string>
|
||||
<key>io.unom.punktfunk.widgets</key><string>$WIDGET_PROFILE</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
EOF
|
||||
@@ -359,9 +382,11 @@ jobs:
|
||||
# resource bundle (PunktfunkKit_PunktfunkKit) builds for appletvos and rejected the
|
||||
# sdk-scoped profile this step used to set; Automatic signing profiles only the app and
|
||||
# leaves the resource bundle + the macOS-host macro plugins (OnceMacro/SwizzlingMacro/
|
||||
# AssociationMacro) alone. No -allowProvisioningUpdates → OFFLINE, never cloud-signs (the
|
||||
# App-Manager ASC key can't), so the runner needs a tvOS *development* profile for
|
||||
# io.unom.punktfunk installed. DISTRIBUTION signing is the export step below (manual, plist).
|
||||
# AssociationMacro) alone. -allowProvisioningUpdates lets Xcode sync the App ID capabilities
|
||||
# and regenerate the managed *development* profile — the tvOS app carries the App Groups key
|
||||
# (group.io.unom.punktfunk) too, which invalidated the cached one. DEVELOPMENT signing against
|
||||
# the Apple Development cert already in the keychain, so the App-Manager ASC key suffices.
|
||||
# DISTRIBUTION signing is the export step below (manual, plist).
|
||||
osascript -e 'tell application "Xcode" to quit' >/dev/null 2>&1 || true
|
||||
pkill -x Xcode 2>/dev/null || true
|
||||
PROFILE="Punktfunk tvOS App Store Distribution"
|
||||
@@ -370,6 +395,10 @@ jobs:
|
||||
-destination 'generic/platform=tvOS' \
|
||||
-archivePath "$RUNNER_TEMP/Punktfunk-tvos.xcarchive" \
|
||||
-skipMacroValidation -skipPackagePluginValidation \
|
||||
-allowProvisioningUpdates \
|
||||
-authenticationKeyPath "$RUNNER_TEMP/asc.p8" \
|
||||
-authenticationKeyID "${{ secrets.ASC_API_KEY_ID }}" \
|
||||
-authenticationKeyIssuerID "${{ secrets.ASC_API_ISSUER_ID }}" \
|
||||
MARKETING_VERSION="$VERSION" CURRENT_PROJECT_VERSION="$BUILD_NUM" \
|
||||
CODE_SIGN_STYLE=Automatic \
|
||||
DEVELOPMENT_TEAM="$TEAM_ID"
|
||||
|
||||
@@ -92,9 +92,10 @@ jobs:
|
||||
echo "rpm $V-$R -> group '$GROUP'"
|
||||
|
||||
- name: Build RPM
|
||||
# PF_WITH_WEB=1 → also build the noarch punktfunk-web subpackage (the publish loop below
|
||||
# globs it in; the host RPM Recommends it). Needs bun (ensured in Prep).
|
||||
run: PF_VERSION="$PF_VERSION" PF_RELEASE="$PF_RELEASE" PF_WITH_WEB=1 bash packaging/rpm/build-rpm.sh
|
||||
# PF_WITH_WEB=1 / PF_WITH_SCRIPTING=1 → also build the punktfunk-web console + the
|
||||
# punktfunk-scripting runner subpackages (the publish loop globs them in; the host RPM
|
||||
# Recommends both). Both need bun (ensured in Prep).
|
||||
run: PF_VERSION="$PF_VERSION" PF_RELEASE="$PF_RELEASE" PF_WITH_WEB=1 PF_WITH_SCRIPTING=1 bash packaging/rpm/build-rpm.sh
|
||||
|
||||
- name: Sign RPMs (dormant until RPM_GPG_PRIVATE_KEY is set — see packaging/rpm/README.md)
|
||||
env:
|
||||
@@ -131,7 +132,8 @@ jobs:
|
||||
bash packaging/bazzite/build-sysext.sh --version-id "${{ matrix.fedver }}" \
|
||||
--out "dist-sysext/punktfunk-${PF_VERSION}-${PF_RELEASE}-x86-64.raw" \
|
||||
dist/punktfunk-"${PF_VERSION}-${PF_RELEASE}"*.rpm \
|
||||
dist/punktfunk-web-"${PF_VERSION}-${PF_RELEASE}"*.rpm
|
||||
dist/punktfunk-web-"${PF_VERSION}-${PF_RELEASE}"*.rpm \
|
||||
dist/punktfunk-scripting-"${PF_VERSION}-${PF_RELEASE}"*.rpm
|
||||
|
||||
- name: Publish the sysext feed
|
||||
env:
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
# Publish the TypeScript SDK (@punktfunk/host) to the Gitea npm registry
|
||||
# (https://git.unom.io/api/packages/unom/npm/).
|
||||
#
|
||||
# Trigger: push a tag `sdk-vX.Y.Z` (must equal sdk/package.json "version"), or run manually.
|
||||
# The SDK versions independently of the app's `v*` tags, so bumping the host doesn't republish it.
|
||||
#
|
||||
# Auth: REGISTRY_TOKEN — the same repo Actions secret docker.yml uses (a Gitea PAT with
|
||||
# write:package scope). No new secret needed.
|
||||
name: sdk-publish
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ['sdk-v*']
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-24.04
|
||||
container:
|
||||
image: oven/bun:1
|
||||
timeout-minutes: 15
|
||||
defaults:
|
||||
run:
|
||||
working-directory: sdk
|
||||
steps:
|
||||
# oven/bun's slim base ships neither git, a CA bundle, nor node — actions/checkout's HTTPS
|
||||
# fetch needs git + ca-certificates, and the version-guard step below uses node.
|
||||
- name: Install git + node + CA certs
|
||||
working-directory: /
|
||||
run: apt-get update && apt-get install -y --no-install-recommends ca-certificates git nodejs
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: bun install --frozen-lockfile --ignore-scripts
|
||||
|
||||
- name: Typecheck
|
||||
run: bun run typecheck
|
||||
|
||||
- name: Test
|
||||
run: bun test
|
||||
|
||||
- name: Build (dist/ JS + .d.ts)
|
||||
run: bun run build
|
||||
|
||||
- name: Tag matches package version
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: |
|
||||
TAG="${GITHUB_REF_NAME#sdk-v}"
|
||||
PKG="$(node -p "require('./package.json').version")"
|
||||
test "$TAG" = "$PKG" || { echo "tag $GITHUB_REF_NAME does not match package version $PKG"; exit 1; }
|
||||
|
||||
- name: Publish to Gitea registry
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
||||
run: |
|
||||
test -n "$NODE_AUTH_TOKEN" || { echo "REGISTRY_TOKEN secret is empty"; exit 1; }
|
||||
# .npmrc already maps the @punktfunk scope to the registry; append the auth line.
|
||||
printf '//git.unom.io/api/packages/unom/npm/:_authToken=%s\n' "$NODE_AUTH_TOKEN" >> .npmrc
|
||||
bun publish
|
||||
@@ -1,7 +1,8 @@
|
||||
# Build the punktfunk Windows HOST as a signed Inno Setup installer and publish it to Gitea's generic
|
||||
# package registry, so a Windows GPU box can install the streaming host (SYSTEM service + bundled
|
||||
# pf-vdisplay virtual-display driver + the web management console, run by a scheduled task on a bundled
|
||||
# bun) from one signed setup.exe. Runs on a self-hosted windows-amd64 runner
|
||||
# pf-vdisplay virtual-display driver + the web management console + the opt-in plugin/script runner,
|
||||
# run by scheduled tasks on a bundled bun) from one signed setup.exe. Runs on a self-hosted
|
||||
# windows-amd64 runner
|
||||
# (host mode; same MSVC/Windows-SDK/LLVM env as windows.yml — generic from unom/infra's
|
||||
# windows-runner/, FFmpeg/Inno Setup self-provision via the "Ensure Windows toolchain" step below).
|
||||
#
|
||||
@@ -23,10 +24,15 @@
|
||||
# an ephemeral self-signed cert is generated and its public .cer published next to the installer
|
||||
# (import once to LocalMachine\TrustedPublisher). See packaging/windows/pack-host-installer.ps1.
|
||||
#
|
||||
# GPU backends: the host builds with --features nvenc,amf-qsv = all three vendors in one installer.
|
||||
# GPU backends: the host builds with --features nvenc,amf-qsv,qsv = all three vendors in one installer.
|
||||
# - NVENC (NVIDIA, direct SDK): nothing needed at build time — the entry points are resolved at
|
||||
# RUNTIME from the driver's nvEncodeAPI64.dll (a link-time import would kill the binary on
|
||||
# AMD/Intel-only boxes before main).
|
||||
# - QSV native (Intel, VPL — design/native-qsv-encoder.md): the MIT dispatcher is built from the
|
||||
# vendored tree (libvpl-sys, cmake+bindgen — LIBCLANG_PATH already in the runner env for
|
||||
# pyrowave-sys) and statically linked; the GPU runtime comes from the Intel driver store at run
|
||||
# time, so no new DLL ships and non-Intel boxes are unaffected. This is the Intel dispatch;
|
||||
# the ffmpeg *_qsv path below stays as its open-failure fallback until Phase 4 deletes it.
|
||||
# - AMF/QSV (AMD/Intel, libavcodec): link-imports the FFmpeg libs from FFMPEG_DIR (the BtbN lgpl-shared
|
||||
# tree the client uses; includes the *_amf/*_qsv encoders) and bundles its DLLs into the installer.
|
||||
# lgpl-shared (not gpl-shared) keeps those bundled DLLs LGPL (we never use the GPL-only x264/x265).
|
||||
@@ -40,9 +46,14 @@ on:
|
||||
- 'crates/punktfunk-host/**'
|
||||
- 'crates/punktfunk-core/**'
|
||||
- 'crates/punktfunk-tray/**'
|
||||
# The encode subsystem (split out in W6) + the vendored VPL dispatcher the `qsv` feature
|
||||
# builds — without these, encoder changes only reached this workflow via Cargo.lock luck.
|
||||
- 'crates/pf-encode/**'
|
||||
- 'crates/libvpl-sys/**'
|
||||
- 'packaging/windows/**'
|
||||
- 'scripts/windows/**'
|
||||
- 'web/**'
|
||||
- 'sdk/**'
|
||||
- 'Cargo.lock'
|
||||
- 'Cargo.toml'
|
||||
- '.gitea/workflows/windows-host.yml'
|
||||
@@ -89,6 +100,12 @@ jobs:
|
||||
# (pwsh Out-File utf8 = no BOM, unlike Windows PowerShell 5.1 — keeps the first line clean).
|
||||
"CARGO_TARGET_DIR=C:\t" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
"CARGO_WORKSPACE_DIR=$env:GITHUB_WORKSPACE" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
# audiopus_sys' vendored opus declares cmake_minimum_required < 3.5, which CMake 4.x
|
||||
# refuses outright. Green runs today only survive on the cached configure output — a
|
||||
# target-dir purge (the runner's disk-cleanup task) would fail the fresh configure, as
|
||||
# observed on a clean build on this very runner (2026-07-17). No-op for compliant
|
||||
# projects (libvpl-sys pins 3.13+).
|
||||
"CMAKE_POLICY_VERSION_MINIMUM=3.5" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
# FFMPEG_DIR: the same BtbN lgpl-shared x64 tree the Windows CLIENT links against (provisioned
|
||||
# by scripts/ci/provision-windows-punktfunk-extras.ps1). The host's AMD/Intel AMF/QSV encode backend
|
||||
# (--features amf-qsv) link-imports avcodec/avutil/swscale from it; pack-host-installer.ps1
|
||||
@@ -114,10 +131,11 @@ jobs:
|
||||
"PUNKTFUNK_BUILD_VERSION=$v" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
Write-Output "host version $v"
|
||||
|
||||
- name: Build (release, nvenc + amf-qsv)
|
||||
- name: Build (release, nvenc + amf-qsv + qsv)
|
||||
shell: pwsh
|
||||
# All-vendor host: NVENC (NVIDIA, direct SDK) + AMF/QSV (AMD/Intel, libavcodec via FFMPEG_DIR).
|
||||
run: cargo build --release -p punktfunk-host --features nvenc,amf-qsv
|
||||
# All-vendor host: NVENC (NVIDIA, direct SDK) + native QSV (Intel, static VPL dispatcher)
|
||||
# + AMF/QSV (AMD + the Intel ffmpeg fallback, libavcodec via FFMPEG_DIR).
|
||||
run: cargo build --release -p punktfunk-host --features nvenc,amf-qsv,qsv
|
||||
|
||||
- name: Build (release, status tray)
|
||||
shell: pwsh
|
||||
@@ -128,7 +146,7 @@ jobs:
|
||||
shell: pwsh
|
||||
# First-ever Windows lint coverage for the host (Linux CI never lints the windows-cfg code).
|
||||
run: |
|
||||
cargo clippy -p punktfunk-host --features nvenc,amf-qsv -- -D warnings; if ($LASTEXITCODE) { throw "host clippy" }
|
||||
cargo clippy -p punktfunk-host --features nvenc,amf-qsv,qsv -- -D warnings; if ($LASTEXITCODE) { throw "host clippy" }
|
||||
cargo clippy -p punktfunk-tray -- -D warnings; if ($LASTEXITCODE) { throw "tray clippy" }
|
||||
|
||||
- name: Build + lint the HDR Vulkan layer (pf-vkhdr-layer)
|
||||
@@ -196,6 +214,24 @@ jobs:
|
||||
if ($code -ne 200) { throw "web console failed to boot under bun" }
|
||||
"WEB_OUTPUT_DIR=$((Resolve-Path 'web\.output').Path)" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
|
||||
- name: Build plugin/script runner bundle (bun)
|
||||
shell: pwsh
|
||||
# `bun build --target=bun` bundles the SDK's runner CLI to ONE self-contained JS (effect + the
|
||||
# SDK inlined; the dynamic plugin import stays a runtime import). pack-host-installer.ps1 ships
|
||||
# it (+ the shared bun) and registers its scheduled task DISABLED (opt-in). The SDK's deps are
|
||||
# public npm (effect), so no @unom token is needed here.
|
||||
run: |
|
||||
$bun = $env:BUN_EXE
|
||||
Push-Location sdk
|
||||
& $bun install --frozen-lockfile --ignore-scripts; if ($LASTEXITCODE) { throw "sdk bun install failed ($LASTEXITCODE)" }
|
||||
New-Item -ItemType Directory -Force -Path C:\t\scripting | Out-Null
|
||||
& $bun build src/runner-cli.ts --target=bun --outfile=C:\t\scripting\runner-cli.js; if ($LASTEXITCODE) { throw "runner bundle build failed ($LASTEXITCODE)" }
|
||||
Pop-Location
|
||||
if (-not (Select-String -Path C:\t\scripting\runner-cli.js -Pattern 'attempt=' -Quiet)) {
|
||||
throw "runner bundle missing the dynamic plugin import - wrong build"
|
||||
}
|
||||
"SCRIPTING_BUNDLE=C:\t\scripting\runner-cli.js" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
|
||||
- name: Pack + sign installer
|
||||
shell: pwsh
|
||||
env:
|
||||
|
||||
@@ -43,3 +43,7 @@ CLAUDE.md
|
||||
/result
|
||||
/result-*
|
||||
.direnv/
|
||||
|
||||
# Gradle build output inside the vendored pyrowave Granite Android platform (regenerated, never ours to commit)
|
||||
/crates/pyrowave-sys/vendor/pyrowave/Granite/application/platforms/android/**/.gradle/
|
||||
/crates/pyrowave-sys/vendor/pyrowave/Granite/application/platforms/android/**/build/
|
||||
|
||||
Generated
+131
-60
@@ -358,28 +358,6 @@ version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
||||
|
||||
[[package]]
|
||||
name = "aws-lc-rs"
|
||||
version = "1.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ec2f1fc3ec205783a5da9a7e6c1509cc69dedf09a1949e412c1e18469326d00"
|
||||
dependencies = [
|
||||
"aws-lc-sys",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aws-lc-sys"
|
||||
version = "0.41.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a2f9779ce85b93ab6170dd940ad0169b5766ff848247aff13bb788b832fe3f4"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"cmake",
|
||||
"dunce",
|
||||
"fs_extra",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "axum"
|
||||
version = "0.8.9"
|
||||
@@ -560,6 +538,12 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "byteorder-lite"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.12.0"
|
||||
@@ -756,6 +740,12 @@ dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "color_quant"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.5"
|
||||
@@ -1022,12 +1012,6 @@ version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2"
|
||||
|
||||
[[package]]
|
||||
name = "dunce"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813"
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.16.0"
|
||||
@@ -1141,6 +1125,15 @@ dependencies = [
|
||||
"getrandom 0.3.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fdeflate"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c"
|
||||
dependencies = [
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fec-rs"
|
||||
version = "0.1.0"
|
||||
@@ -1273,12 +1266,6 @@ dependencies = [
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fs_extra"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.3.32"
|
||||
@@ -1495,6 +1482,16 @@ dependencies = [
|
||||
"polyval",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gif"
|
||||
version = "0.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee8cfcc411d9adbbaba82fb72661cc1bcca13e8bba98b364e62b2dba8f960159"
|
||||
dependencies = [
|
||||
"color_quant",
|
||||
"weezl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gio"
|
||||
version = "0.22.6"
|
||||
@@ -1988,6 +1985,23 @@ dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "image"
|
||||
version = "0.25.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85ab80394333c02fe689eaf900ab500fbd0c2213da414687ebf995a65d5a6104"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"byteorder-lite",
|
||||
"color_quant",
|
||||
"gif",
|
||||
"moxcms",
|
||||
"num-traits",
|
||||
"png",
|
||||
"zune-core",
|
||||
"zune-jpeg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.14.0"
|
||||
@@ -2145,7 +2159,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "latency-probe"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
@@ -2248,6 +2262,14 @@ dependencies = [
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libvpl-sys"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"cmake",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.12.1"
|
||||
@@ -2277,7 +2299,7 @@ checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad"
|
||||
|
||||
[[package]]
|
||||
name = "loss-harness"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"punktfunk-core",
|
||||
]
|
||||
@@ -2386,6 +2408,16 @@ dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "moxcms"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
"pxfm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nasm-rs"
|
||||
version = "0.3.2"
|
||||
@@ -2756,7 +2788,7 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
|
||||
|
||||
[[package]]
|
||||
name = "pf-capture"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"ashpd",
|
||||
@@ -2776,7 +2808,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pf-client-core"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"ash",
|
||||
@@ -2805,6 +2837,7 @@ dependencies = [
|
||||
"anyhow",
|
||||
"ashpd",
|
||||
"futures-util",
|
||||
"image",
|
||||
"libc",
|
||||
"punktfunk-core",
|
||||
"quinn",
|
||||
@@ -2817,7 +2850,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pf-console-ui"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"ash",
|
||||
@@ -2838,13 +2871,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pf-encode"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"ash",
|
||||
"ffmpeg-next",
|
||||
"libc",
|
||||
"libloading",
|
||||
"libvpl-sys",
|
||||
"nvidia-video-codec-sdk",
|
||||
"openh264",
|
||||
"pf-frame",
|
||||
@@ -2860,7 +2894,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pf-ffvk"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"ash",
|
||||
"bindgen",
|
||||
@@ -2869,7 +2903,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pf-frame"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"libc",
|
||||
@@ -2881,7 +2915,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pf-gpu"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"pf-host-config",
|
||||
@@ -2895,7 +2929,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pf-host-config"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
|
||||
[[package]]
|
||||
name = "pf-inject"
|
||||
@@ -2927,14 +2961,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pf-paths"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pf-presenter"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"ash",
|
||||
@@ -2979,7 +3013,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pf-win-display"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"pf-paths",
|
||||
@@ -2991,7 +3025,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pf-zerocopy"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"ash",
|
||||
@@ -3075,6 +3109,19 @@ version = "0.3.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e"
|
||||
|
||||
[[package]]
|
||||
name = "png"
|
||||
version = "0.18.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"crc32fast",
|
||||
"fdeflate",
|
||||
"flate2",
|
||||
"miniz_oxide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "polling"
|
||||
version = "3.11.0"
|
||||
@@ -3174,7 +3221,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "punktfunk-client-android"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"android_logger",
|
||||
"jni",
|
||||
@@ -3190,7 +3237,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "punktfunk-client-linux"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-channel",
|
||||
@@ -3206,7 +3253,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "punktfunk-client-session"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"pf-client-core",
|
||||
@@ -3221,7 +3268,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "punktfunk-client-windows"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"ffmpeg-next",
|
||||
@@ -3240,7 +3287,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "punktfunk-core"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"aes-gcm",
|
||||
"bytes",
|
||||
@@ -3271,7 +3318,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "punktfunk-host"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"aes-gcm",
|
||||
@@ -3353,7 +3400,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "punktfunk-probe"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"mdns-sd",
|
||||
@@ -3367,7 +3414,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "punktfunk-tray"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"ksni",
|
||||
@@ -3382,9 +3429,15 @@ dependencies = [
|
||||
"winresource",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pxfm"
|
||||
version = "0.1.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea"
|
||||
|
||||
[[package]]
|
||||
name = "pyrowave-sys"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"cmake",
|
||||
@@ -3583,7 +3636,6 @@ version = "0.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75e669e5202259b5314d1ea5397316ad400819437857b90861765f24c4cf80a2"
|
||||
dependencies = [
|
||||
"aws-lc-rs",
|
||||
"pem",
|
||||
"ring",
|
||||
"rustls-pki-types",
|
||||
@@ -3812,7 +3864,6 @@ version = "0.23.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b92b125634d9b795e7beca796cc790df15a7fb38323bf3196fda83292d06b1f"
|
||||
dependencies = [
|
||||
"aws-lc-rs",
|
||||
"log",
|
||||
"once_cell",
|
||||
"ring",
|
||||
@@ -3877,7 +3928,6 @@ version = "0.103.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e"
|
||||
dependencies = [
|
||||
"aws-lc-rs",
|
||||
"ring",
|
||||
"rustls-pki-types",
|
||||
"untrusted",
|
||||
@@ -5202,6 +5252,12 @@ dependencies = [
|
||||
"rustls-pki-types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "weezl"
|
||||
version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88"
|
||||
|
||||
[[package]]
|
||||
name = "wide"
|
||||
version = "0.7.33"
|
||||
@@ -6014,6 +6070,21 @@ version = "1.0.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
|
||||
|
||||
[[package]]
|
||||
name = "zune-core"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb8a0807f7c01457d0379ba880ba6322660448ddebc890ce29bb64da71fb40f9"
|
||||
|
||||
[[package]]
|
||||
name = "zune-jpeg"
|
||||
version = "0.5.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296"
|
||||
dependencies = [
|
||||
"zune-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zvariant"
|
||||
version = "5.12.0"
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ members = [
|
||||
"crates/pf-inject",
|
||||
"crates/pf-vdisplay",
|
||||
"crates/pyrowave-sys",
|
||||
"crates/libvpl-sys",
|
||||
"clients/probe",
|
||||
"clients/linux",
|
||||
"clients/session",
|
||||
@@ -47,7 +48,7 @@ exclude = [
|
||||
ndk = { path = "clients/android/native/vendor/ndk" }
|
||||
|
||||
[workspace.package]
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.82"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@
|
||||
"name": "MIT OR Apache-2.0",
|
||||
"identifier": "MIT OR Apache-2.0"
|
||||
},
|
||||
"version": "0.12.0"
|
||||
"version": "0.13.0"
|
||||
},
|
||||
"paths": {
|
||||
"/api/v1/clients": {
|
||||
@@ -2744,7 +2744,7 @@
|
||||
},
|
||||
"CustomEntry": {
|
||||
"type": "object",
|
||||
"description": "A user-added title, persisted in `~/.config/punktfunk/library.json`. Same shape the API\nreturns and the web console edits.",
|
||||
"description": "A user-added title, persisted in the hardened host config dir's `library.json` (see\n[`custom_path`]). Same shape the API returns and the web console edits.",
|
||||
"required": [
|
||||
"id",
|
||||
"title"
|
||||
|
||||
@@ -30,7 +30,13 @@ suspend fun connectToHost(
|
||||
): Long {
|
||||
// Advertise HDR only when the user enabled it AND this device's display can present it (else the
|
||||
// host sends a proper SDR stream rather than PQ the panel would mis-tone-map).
|
||||
val (w, h, hz) = settings.effectiveMode(context)
|
||||
val (baseW, baseH, hz) = settings.effectiveMode(context)
|
||||
// Render scale: ask the host for `chosen mode × scale` (even + codec-clamped) — > 1 supersamples
|
||||
// (the compositor downscales the larger decoded frame to the SurfaceView), < 1 renders under
|
||||
// native. 1.0 leaves the resolved mode untouched.
|
||||
val (w, h) = RenderScale.apply(
|
||||
baseW, baseH, settings.renderScale, RenderScale.maxDimension(settings.codec)
|
||||
)
|
||||
val hdrEnabled = settings.hdrEnabled && displaySupportsHdr(context)
|
||||
// "Automatic" resolves to a concrete pad type from the connected controller's VID/PID.
|
||||
val gamepadPref = Gamepad.resolvePref(settings.gamepad)
|
||||
|
||||
@@ -16,6 +16,14 @@ data class Settings(
|
||||
val height: Int = 0,
|
||||
val hz: Int = 0,
|
||||
val bitrateKbps: Int = 0,
|
||||
/**
|
||||
* Render-resolution multiplier: the client asks the host to render/encode at `chosen mode ×
|
||||
* renderScale` and the compositor downscales the larger decoded frame to the SurfaceView
|
||||
* (`> 1` supersamples for sharpness, at more bandwidth AND decode; `< 1` renders under native
|
||||
* for a lighter host/link). `1.0` = Native. Applied at connect via [RenderScale.apply], clamped
|
||||
* even + to the codec's max dimension. Mirrors the Apple/Linux clients' render scale.
|
||||
*/
|
||||
val renderScale: Double = 1.0,
|
||||
/**
|
||||
* Advertise HDR (10-bit BT.2020 PQ) to the host. Default on, but only *effective* on a panel that
|
||||
* can actually present HDR10 (see [displaySupportsHdr]) — on an SDR display HDR is never
|
||||
@@ -137,6 +145,7 @@ class SettingsStore(context: Context) {
|
||||
height = prefs.getInt(K_H, 0),
|
||||
hz = prefs.getInt(K_HZ, 0),
|
||||
bitrateKbps = prefs.getInt(K_BITRATE, 0),
|
||||
renderScale = prefs.getFloat(K_RENDER_SCALE, 1.0f).toDouble(),
|
||||
hdrEnabled = prefs.getBoolean(K_HDR, true),
|
||||
compositor = prefs.getInt(K_COMPOSITOR, 0),
|
||||
gamepad = prefs.getInt(K_GAMEPAD, 0),
|
||||
@@ -171,6 +180,7 @@ class SettingsStore(context: Context) {
|
||||
.putInt(K_H, s.height)
|
||||
.putInt(K_HZ, s.hz)
|
||||
.putInt(K_BITRATE, s.bitrateKbps)
|
||||
.putFloat(K_RENDER_SCALE, s.renderScale.toFloat())
|
||||
.putBoolean(K_HDR, s.hdrEnabled)
|
||||
.putInt(K_COMPOSITOR, s.compositor)
|
||||
.putInt(K_GAMEPAD, s.gamepad)
|
||||
@@ -193,6 +203,7 @@ class SettingsStore(context: Context) {
|
||||
const val K_H = "height"
|
||||
const val K_HZ = "hz"
|
||||
const val K_BITRATE = "bitrate_kbps"
|
||||
const val K_RENDER_SCALE = "render_scale"
|
||||
const val K_HDR = "hdr_enabled"
|
||||
const val K_COMPOSITOR = "compositor"
|
||||
const val K_GAMEPAD = "gamepad"
|
||||
@@ -281,6 +292,54 @@ fun Settings.effectiveMode(context: Context): Triple<Int, Int, Int> {
|
||||
return Triple(w, h, hz)
|
||||
}
|
||||
|
||||
/**
|
||||
* Client-side render-scale geometry — the Kotlin twin of `punktfunk-core`'s `render_scale` module
|
||||
* (and the Apple client's `RenderScale`). Multiply a base size, preserve aspect, even-floor (the
|
||||
* host rejects odd sizes), and clamp uniformly to the codec's per-axis ceiling so a connect can't
|
||||
* ask for a size the encoder rejects. `1.0` = Native. Pure + covered by [RenderScaleTest].
|
||||
*/
|
||||
object RenderScale {
|
||||
val PRESETS = listOf(0.5, 0.67, 0.75, 1.0, 1.25, 1.5, 2.0, 3.0, 4.0)
|
||||
|
||||
/** H.264 tops out at 4096 px/axis; HEVC/AV1/auto at 8192 — the host's `codec.rs` walls. */
|
||||
fun maxDimension(codec: String): Int = if (codec == "h264") 4096 else 8192
|
||||
|
||||
/** Clamp a raw multiplier into [0.5, 4.0]; a missing / non-positive / NaN value → 1.0. */
|
||||
fun sanitize(raw: Double): Double = if (raw > 0.0) raw.coerceIn(0.5, 4.0) else 1.0
|
||||
|
||||
/** "Native (1×)" / "1.5×" / "2× · supersample" — the picker label. */
|
||||
fun label(scale: Double): String = when {
|
||||
scale == 1.0 -> "Native (1×)"
|
||||
scale > 1.0 -> "${trim(scale)}× · supersample"
|
||||
else -> "${trim(scale)}×"
|
||||
}
|
||||
|
||||
private fun trim(s: Double): String =
|
||||
if (s == s.toLong().toDouble()) s.toLong().toString() else s.toString()
|
||||
|
||||
/** Apply [scale] to a base size → a host-valid even, aspect-preserved, codec-clamped (w, h). */
|
||||
fun apply(baseW: Int, baseH: Int, scale: Double, maxDim: Int): Pair<Int, Int> {
|
||||
val s = sanitize(scale)
|
||||
var w = maxOf(baseW, 1) * s
|
||||
var h = maxOf(baseH, 1) * s
|
||||
val cap = maxDim.toDouble()
|
||||
val over = maxOf(w / cap, h / cap)
|
||||
if (over > 1.0) {
|
||||
w /= over
|
||||
h /= over
|
||||
}
|
||||
return Pair(evenFloor(w, 320), evenFloor(h, 200))
|
||||
}
|
||||
|
||||
private fun evenFloor(value: Double, minimum: Int): Int {
|
||||
val v = maxOf(kotlin.math.floor(value).toInt(), minimum).coerceAtLeast(0)
|
||||
return v / 2 * 2
|
||||
}
|
||||
}
|
||||
|
||||
/** (scale, label) for the render-scale picker. `1.0` = Native. */
|
||||
val RENDER_SCALE_OPTIONS = RenderScale.PRESETS.map { it to RenderScale.label(it) }
|
||||
|
||||
// ---- UI option tables (value, label). The first entry is always the "auto/native" default. ----
|
||||
|
||||
/** (width, height, label). `(0,0)` = native display. */
|
||||
|
||||
@@ -333,6 +333,15 @@ private fun DisplaySettings(s: Settings, update: (Settings) -> Unit, context: an
|
||||
update(s.copy(bitrateKbps = kbps))
|
||||
}
|
||||
|
||||
SettingDropdown(
|
||||
label = "Render scale",
|
||||
options = RENDER_SCALE_OPTIONS,
|
||||
// Snap the stored value (a Float round-tripped to Double) to the nearest preset so the
|
||||
// exact Double keys match. > 1 supersamples for sharpness (more bandwidth AND decode);
|
||||
// < 1 renders under native for a lighter host — this device resamples to the display.
|
||||
selected = RenderScale.PRESETS.minByOrNull { kotlin.math.abs(it - s.renderScale) } ?: 1.0,
|
||||
) { scale -> update(s.copy(renderScale = scale)) }
|
||||
|
||||
// AV1 is only offered when the device has a real AV1 decoder (it's never advertised to the
|
||||
// host otherwise, so preferring it would be a dead setting). A stored "av1" from a capable
|
||||
// device stays visible so the selection is always representable.
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package io.unom.punktfunk
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
/**
|
||||
* Pure JVM test of the client-side render-scale geometry ([RenderScale]) — the Kotlin twin of
|
||||
* `punktfunk-core`'s `render_scale` module. Run: `./gradlew :app:testDebugUnitTest`.
|
||||
*/
|
||||
class RenderScaleTest {
|
||||
@Test
|
||||
fun sanitizeClampsAndDefaults() {
|
||||
assertEquals(1.0, RenderScale.sanitize(0.0), 0.0) // absent / zero → Native
|
||||
assertEquals(1.0, RenderScale.sanitize(-2.0), 0.0)
|
||||
assertEquals(1.0, RenderScale.sanitize(Double.NaN), 0.0)
|
||||
assertEquals(0.5, RenderScale.sanitize(0.1), 0.0) // below the floor
|
||||
assertEquals(4.0, RenderScale.sanitize(9.0), 0.0) // above the ceiling
|
||||
assertEquals(1.5, RenderScale.sanitize(1.5), 0.0)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun maxDimensionIsCodecAware() {
|
||||
assertEquals(4096, RenderScale.maxDimension("h264"))
|
||||
assertEquals(8192, RenderScale.maxDimension("hevc"))
|
||||
assertEquals(8192, RenderScale.maxDimension("av1"))
|
||||
assertEquals(8192, RenderScale.maxDimension("auto"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun nativeIsIdentity() {
|
||||
assertEquals(1920 to 1080, RenderScale.apply(1920, 1080, 1.0, 8192))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun supersampleDoubles() {
|
||||
assertEquals(3840 to 2160, RenderScale.apply(1920, 1080, 2.0, 8192))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun underRenderHalves() {
|
||||
assertEquals(960 to 540, RenderScale.apply(1920, 1080, 0.5, 8192))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun resultsAreEven() {
|
||||
// 1366×768 × 1.5 = 2049×1152 → even-floored to 2048×1152.
|
||||
val (w, h) = RenderScale.apply(1366, 768, 1.5, 8192)
|
||||
assertEquals(0, w % 2)
|
||||
assertEquals(0, h % 2)
|
||||
assertEquals(2048 to 1152, w to h)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun overCeilingClampsUniformly() {
|
||||
// 4K × 4 = 15360×8640; both exceed 8192 → width lands on cap, 16:9 kept (8192×4608).
|
||||
val (w, h) = RenderScale.apply(3840, 2160, 4.0, 8192)
|
||||
assertTrue(w <= 8192 && h <= 8192)
|
||||
assertEquals(8192 to 4608, w to h)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun h264CeilingIsTighter() {
|
||||
// 1080p × 4 = 7680×4320; under H.264's 4096 wall → 4096×2304.
|
||||
assertEquals(4096 to 2304, RenderScale.apply(1920, 1080, 4.0, 4096))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun minimumFloorHonoured() {
|
||||
val (w, h) = RenderScale.apply(400, 300, 0.5, 8192)
|
||||
assertTrue(w >= 320 && h >= 200)
|
||||
}
|
||||
}
|
||||
@@ -712,7 +712,7 @@
|
||||
INFOPLIST_FILE = PunktfunkWidgets/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = PunktfunkWidgets;
|
||||
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 27.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
@@ -757,7 +757,7 @@
|
||||
INFOPLIST_FILE = PunktfunkWidgets/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = PunktfunkWidgets;
|
||||
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 27.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "2700"
|
||||
wasCreatedForAppExtension = "YES"
|
||||
version = "2.0">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES"
|
||||
buildArchitectures = "Automatic">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "E2955696300948B9009F939C"
|
||||
BuildableName = "PunktfunkWidgetsExtension.appex"
|
||||
ReferencedContainer = "container:Punktfunk.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "BB0000000000000000000009"
|
||||
BuildableName = "Punktfunk-iOS.app"
|
||||
ReferencedContainer = "container:Punktfunk.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
shouldAutocreateTestPlan = "YES">
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = ""
|
||||
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
||||
launchStyle = "0"
|
||||
askForAppToLaunch = "Yes"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES"
|
||||
launchAutomaticallySubstyle = "2"
|
||||
queueDebuggingEnabled = "No">
|
||||
<RemoteRunnable
|
||||
runnableDebuggingMode = "2"
|
||||
BundleIdentifier = "com.apple.springboard">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "E2955696300948B9009F939C"
|
||||
BuildableName = "PunktfunkWidgetsExtension.appex"
|
||||
ReferencedContainer = "container:Punktfunk.xcodeproj">
|
||||
</BuildableReference>
|
||||
</RemoteRunnable>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "BB0000000000000000000009"
|
||||
BuildableName = "Punktfunk-iOS.app"
|
||||
ReferencedContainer = "container:Punktfunk.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<EnvironmentVariables>
|
||||
<EnvironmentVariable
|
||||
key = "_XCWidgetKind"
|
||||
value = ""
|
||||
isEnabled = "YES">
|
||||
</EnvironmentVariable>
|
||||
<EnvironmentVariable
|
||||
key = "_XCWidgetDefaultView"
|
||||
value = "timeline"
|
||||
isEnabled = "YES">
|
||||
</EnvironmentVariable>
|
||||
<EnvironmentVariable
|
||||
key = "_XCWidgetFamily"
|
||||
value = "systemMedium"
|
||||
isEnabled = "YES">
|
||||
</EnvironmentVariable>
|
||||
</EnvironmentVariables>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
askForAppToLaunch = "Yes"
|
||||
launchAutomaticallySubstyle = "2">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "BB0000000000000000000009"
|
||||
BuildableName = "Punktfunk-iOS.app"
|
||||
ReferencedContainer = "container:Punktfunk.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -72,6 +72,14 @@ struct StreamCommands: Commands {
|
||||
}
|
||||
.keyboardShortcut("c", modifiers: [.control, .option, .shift])
|
||||
.disabled(session?.isStreaming != true || session?.clipboardAvailable != true)
|
||||
// Toggle the window's fullscreen. ⌃⌘F is the macOS-standard fullscreen combo; here it's
|
||||
// explicit so it's discoverable AND survives capture — while streaming the stream view
|
||||
// swallows keys, so InputCapture's monitor detects the same combo and posts the same
|
||||
// notification the key window's FullscreenController observes.
|
||||
Button("Toggle Fullscreen") {
|
||||
NotificationCenter.default.post(name: .punktfunkToggleFullscreen, object: nil)
|
||||
}
|
||||
.keyboardShortcut("f", modifiers: [.control, .command])
|
||||
#endif
|
||||
Divider()
|
||||
Button("Disconnect") { session?.disconnect() }
|
||||
|
||||
@@ -38,6 +38,7 @@ extension SettingsView {
|
||||
}
|
||||
#endif
|
||||
#if !os(tvOS)
|
||||
renderScaleRow
|
||||
bitrateRows
|
||||
#endif
|
||||
} header: {
|
||||
@@ -54,6 +55,50 @@ extension SettingsView {
|
||||
}
|
||||
}
|
||||
|
||||
#if !os(tvOS)
|
||||
/// Render-scale picker + the resulting host resolution. > 1 supersamples (sharper, at more
|
||||
/// bandwidth AND client decode); < 1 renders under native (lighter). The presenter resamples the
|
||||
/// decoded frame to this display, so the multiplier is where the sharpness/cost trade-off lives.
|
||||
@ViewBuilder var renderScaleRow: some View {
|
||||
Picker("Render scale", selection: $renderScale) {
|
||||
ForEach(RenderScale.presets, id: \.self) { scale in
|
||||
Text(RenderScale.label(scale)).tag(scale)
|
||||
}
|
||||
}
|
||||
// The concrete host resolution makes the cost legible. Only meaningful for the explicit mode
|
||||
// (match-window derives the base from the live window, not these fields).
|
||||
if renderScale != 1.0, !matchWindow {
|
||||
let mode = RenderScale.apply(
|
||||
baseWidth: width, baseHeight: height,
|
||||
scale: renderScale,
|
||||
maxDimension: RenderScale.maxDimension(codec: codec))
|
||||
Text("Host renders \(Int(mode.width))×\(Int(mode.height)); this device downscales it to your display.")
|
||||
.font(.geist(12, relativeTo: .caption))
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
|
||||
/// Keyboard & mouse forwarding — applies wherever a hardware keyboard/mouse drives the stream
|
||||
/// (always on macOS; an attached keyboard/mouse on iPad). Absent on tvOS (no such input path).
|
||||
@ViewBuilder var inputSection: some View {
|
||||
Section {
|
||||
Picker("Modifier keys", selection: $modifierLayout) {
|
||||
ForEach(ModifierLayout.allCases, id: \.self) { layout in
|
||||
Text(layout.label).tag(layout.rawValue)
|
||||
}
|
||||
}
|
||||
Toggle("Invert scroll direction", isOn: $invertScroll)
|
||||
} header: {
|
||||
Text("Keyboard & mouse")
|
||||
} footer: {
|
||||
Text((ModifierLayout(rawValue: modifierLayout) ?? .mac).detail
|
||||
+ " Invert scroll reverses the wheel/trackpad scroll direction sent to the host.")
|
||||
.font(.geist(12, relativeTo: .caption))
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if os(iOS)
|
||||
// MARK: - Stream mode (iOS wheel)
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// App settings. The host creates a native virtual output at exactly the chosen size/refresh —
|
||||
// there is no scaling anywhere in the pipeline.
|
||||
// App settings. The host creates a virtual output at exactly the chosen size/refresh; the only
|
||||
// deliberate resample is the opt-in Render Scale (the host renders at size × scale and this device
|
||||
// downscales — supersampling for sharpness, or under-rendering for a lighter host/link).
|
||||
//
|
||||
// Navigation differs per platform, but all three group the same categories (General, Display,
|
||||
// Audio, Controllers, Advanced, About): macOS uses a tabbed preferences window; iOS/iPadOS uses
|
||||
@@ -25,6 +26,10 @@ struct SettingsView: View {
|
||||
// windowed session instead streams at the window's native pixels (1:1, no scaling) so it stays
|
||||
// pixel-exact rather than the presenter resampling a fixed-mode frame into the window.
|
||||
@AppStorage(DefaultsKey.matchWindow) var matchWindow = false
|
||||
// Render-resolution multiplier: the host renders/encodes at chosen-resolution × this, and the
|
||||
// presenter downscales (> 1 = supersampling for sharpness) or upscales (< 1 = a lighter host /
|
||||
// link). 1.0 = Native (the prior behaviour).
|
||||
@AppStorage(DefaultsKey.renderScale) var renderScale = 1.0
|
||||
@AppStorage(DefaultsKey.compositor) var compositor = 0
|
||||
@AppStorage(DefaultsKey.gamepadType) var gamepadType = 0
|
||||
@AppStorage(DefaultsKey.bitrateKbps) var bitrateKbps = 0
|
||||
@@ -51,6 +56,12 @@ struct SettingsView: View {
|
||||
@AppStorage(DefaultsKey.autoWake) var autoWakeEnabled = true
|
||||
@AppStorage(DefaultsKey.backgroundKeepAlive) var backgroundKeepAlive = false
|
||||
@AppStorage(DefaultsKey.backgroundTimeoutMinutes) var backgroundTimeoutMinutes = 10
|
||||
#if !os(tvOS)
|
||||
// Keyboard & mouse forwarding (macOS + a hardware keyboard/mouse on iPad). Invert-scroll flips
|
||||
// both wheel axes; modifier-layout relocates the ⌥/⌘ → Alt/Super roles by physical position.
|
||||
@AppStorage(DefaultsKey.invertScroll) var invertScroll = false
|
||||
@AppStorage(DefaultsKey.modifierLayout) var modifierLayout = ModifierLayout.mac.rawValue
|
||||
#endif
|
||||
#if DEBUG && !os(tvOS)
|
||||
@State var showControllerTest = false
|
||||
#endif
|
||||
@@ -112,6 +123,7 @@ struct SettingsView: View {
|
||||
TabView {
|
||||
Form {
|
||||
streamModeSection
|
||||
inputSection
|
||||
compositorSection
|
||||
wakeSection
|
||||
}
|
||||
@@ -242,6 +254,7 @@ struct SettingsView: View {
|
||||
Form {
|
||||
streamModeSection
|
||||
pointerSection
|
||||
inputSection
|
||||
compositorSection
|
||||
wakeSection
|
||||
keepAliveSection // iOS-only content; empty on tvOS
|
||||
@@ -334,6 +347,10 @@ struct SettingsView: View {
|
||||
return ScrollView {
|
||||
VStack(spacing: 16) {
|
||||
TVSelectionRow(title: "Stream mode", options: options, selection: modeTag)
|
||||
TVSelectionRow(
|
||||
title: "Render scale",
|
||||
options: RenderScale.presets.map { (label: RenderScale.label($0), tag: $0) },
|
||||
selection: $renderScale)
|
||||
TVSelectionRow(
|
||||
title: "Bitrate",
|
||||
options: SettingsOptions.bitrateOptions(current: bitrateKbps),
|
||||
|
||||
@@ -29,6 +29,11 @@ public final class ClipboardSync: NSObject {
|
||||
("text/rtf", .rtf),
|
||||
("text/html", .html),
|
||||
("image/png", .png),
|
||||
// Original image formats pass through VERBATIM beside the PNG floor — a copied JPEG
|
||||
// never balloons into PNG, a GIF keeps its animation; the destination picks the richest
|
||||
// kind it can place.
|
||||
("image/jpeg", NSPasteboard.PasteboardType("public.jpeg")),
|
||||
("image/gif", NSPasteboard.PasteboardType("com.compuserve.gif")),
|
||||
]
|
||||
/// Pasteboard marker types that must never cross the wire (password managers mark secrets
|
||||
/// with these — see nspasteboard.org).
|
||||
@@ -202,9 +207,20 @@ public final class ClipboardSync: NSObject {
|
||||
let types = pb.types ?? []
|
||||
if types.contains(Self.concealed) || types.contains(Self.transient) { return }
|
||||
offerSeq &+= 1
|
||||
let kinds = Self.wireToPasteboard
|
||||
var kinds = Self.wireToPasteboard
|
||||
.filter { types.contains($0.type) }
|
||||
.map { PunktfunkConnection.ClipKind(mime: $0.wire) }
|
||||
// PNG floor: announce the portable `image/png` whenever ANY convertible image is present
|
||||
// — native PNG, TIFF/HEIC (screenshots, Preview), or a JPEG/GIF original already being
|
||||
// offered verbatim above. `readWireData` converts at fetch time (lazy, §3.5), so the
|
||||
// fallback costs nothing unless a peer actually pastes it.
|
||||
if !kinds.contains(where: { $0.mime == "image/png" }),
|
||||
types.contains(.tiff)
|
||||
|| types.contains(NSPasteboard.PasteboardType("public.heic"))
|
||||
|| kinds.contains(where: { $0.mime.hasPrefix("image/") })
|
||||
{
|
||||
kinds.append(PunktfunkConnection.ClipKind(mime: "image/png"))
|
||||
}
|
||||
// Empty = the pasteboard holds nothing we sync (or was cleared) — clears the host side.
|
||||
connection.clipOffer(seq: offerSeq, kinds: kinds)
|
||||
}
|
||||
@@ -305,8 +321,7 @@ public final class ClipboardSync: NSObject {
|
||||
private func serveFetch(reqId: UInt32, seq: UInt32, mime: String) {
|
||||
let pb = NSPasteboard.general
|
||||
guard seq == offerSeq, pb.changeCount == lastSeenChangeCount,
|
||||
let type = Self.wireToPasteboard.first(where: { $0.wire == mime })?.type,
|
||||
let data = pb.data(forType: type)
|
||||
let data = Self.readWireData(pb, mime)
|
||||
else {
|
||||
connection.clipCancel(id: reqId)
|
||||
return
|
||||
@@ -322,6 +337,30 @@ public final class ClipboardSync: NSObject {
|
||||
connection.clipServe(reqId: reqId, data: Data(), last: true)
|
||||
}
|
||||
}
|
||||
|
||||
/// Read one wire format from the pasteboard, converting where macOS stores a different
|
||||
/// native type: `image/png` is served from a real `.png` entry when present, else converted
|
||||
/// from whatever image representation the pasteboard holds (TIFF from screenshots/Preview,
|
||||
/// WebP/AVIF/GIF from browsers — `NSImage` decodes them all) into PNG at fetch time.
|
||||
private static func readWireData(_ pb: NSPasteboard, _ mime: String) -> Data? {
|
||||
guard mime == "image/png" else {
|
||||
guard let type = wireToPasteboard.first(where: { $0.wire == mime })?.type else {
|
||||
return nil
|
||||
}
|
||||
return pb.data(forType: type)
|
||||
}
|
||||
if let png = pb.data(forType: .png) {
|
||||
return png
|
||||
}
|
||||
// No native PNG: decode whatever image the pasteboard carries and re-encode.
|
||||
guard let img = NSImage(pasteboard: pb),
|
||||
let tiff = img.tiffRepresentation,
|
||||
let rep = NSBitmapImageRep(data: tiff)
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
return rep.representation(using: .png, properties: [:])
|
||||
}
|
||||
}
|
||||
|
||||
/// The lazy paste hook: AppKit calls `provideDataForType` only when a Mac app actually pastes;
|
||||
@@ -354,6 +393,8 @@ private final class RemoteOfferProvider: NSObject, NSPasteboardItemDataProvider
|
||||
case .rtf: return "text/rtf"
|
||||
case .html: return "text/html"
|
||||
case .png: return "image/png"
|
||||
case NSPasteboard.PasteboardType("public.jpeg"): return "image/jpeg"
|
||||
case NSPasteboard.PasteboardType("com.compuserve.gif"): return "image/gif"
|
||||
default: return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import UIKit
|
||||
import Foundation
|
||||
import GameController
|
||||
import PunktfunkCore
|
||||
import PunktfunkShared
|
||||
import os
|
||||
|
||||
/// Diagnostic logging for the input path. Off by default (input is high-rate); set
|
||||
@@ -125,6 +126,12 @@ public final class InputCapture {
|
||||
public var onDisconnect: (() -> Void)?
|
||||
public var onCycleStats: (() -> Void)?
|
||||
|
||||
/// Fired on ⌃⌘F (macOS) — toggle the streaming window in/out of fullscreen. Detected in the
|
||||
/// monitor only WHILE FORWARDING, for the same reason as the ⌃⌥⇧ combos: a captured stream view
|
||||
/// swallows keys, so the Stream menu's identical ⌃⌘F equivalent never reaches it; released, the
|
||||
/// menu handles it. Main queue.
|
||||
public var onToggleFullscreen: (() -> Void)?
|
||||
|
||||
#if os(iOS)
|
||||
/// Windows VKs of the three modifier classes in the ⌃⌥⇧Q release chord, both L/R sides:
|
||||
/// control (0xA2/0xA3), option (0xA4/0xA5), shift (0xA0/0xA1). Used to sift the HID key stream.
|
||||
@@ -273,6 +280,14 @@ public final class InputCapture {
|
||||
break
|
||||
}
|
||||
}
|
||||
// ⌃⌘F toggles the streaming window's fullscreen. Intercepted only while forwarding (the
|
||||
// captured stream view swallows the menu's identical equivalent); the F is latched so its
|
||||
// keyUp can't type into the host. keyCode 3 = kVK_ANSI_F (layout-independent).
|
||||
if self.forwarding, flags == [.control, .command], event.keyCode == 3 /* F */ {
|
||||
self.suppressedVK = 0x46 // VK_F — the same physical F is en route via GC
|
||||
self.onToggleFullscreen?()
|
||||
return nil
|
||||
}
|
||||
return event
|
||||
}
|
||||
#endif
|
||||
@@ -318,7 +333,7 @@ public final class InputCapture {
|
||||
chordModifiersDown.removeAll()
|
||||
suppressedVK = nil
|
||||
for vk in pressedVKs {
|
||||
connection.send(.key(vk, down: false))
|
||||
emitKey(vk, down: false)
|
||||
}
|
||||
for button in pressedButtons {
|
||||
connection.send(.mouseButton(button, down: false))
|
||||
@@ -331,6 +346,15 @@ public final class InputCapture {
|
||||
residualScrollY = 0
|
||||
}
|
||||
|
||||
/// The single wire boundary for a key event. Every `.key` send funnels through here so the
|
||||
/// active location-based modifier layout is applied in exactly one place while all internal
|
||||
/// press/release bookkeeping (`pressedVKs`, `cmdKeysDown`, `resolveModifier`'s `isDown`) stays on
|
||||
/// the physical VK. Read live from the setting so a mid-session change (rare) takes on the next
|
||||
/// key without re-arming capture. Non-modifier VKs pass through untouched.
|
||||
private func emitKey(_ vk: UInt32, down: Bool) {
|
||||
connection.send(.key(Self.applyModifierLayout(vk, ModifierLayout.current), down: down))
|
||||
}
|
||||
|
||||
/// Release any held MOUSE buttons host-side, leaving keyboard state untouched. Used when
|
||||
/// the iPad pointer lock drops while a GCMouse button is held: by then the GCMouse release
|
||||
/// handler is gated off (`gcMouseForwarding` is false), so it can't deliver the release
|
||||
@@ -399,7 +423,7 @@ public final class InputCapture {
|
||||
inputLog.debug(
|
||||
"key \(vk, privacy: .public) \(down ? "down" : "up", privacy: .public) sent")
|
||||
}
|
||||
connection.send(.key(vk, down: down))
|
||||
emitKey(vk, down: down)
|
||||
}
|
||||
|
||||
/// NSEvent modifier path (macOS): modifier keys never fire keyDown/keyUp — they arrive
|
||||
@@ -566,8 +590,15 @@ public final class InputCapture {
|
||||
/// Moonlight's convention). Fed by StreamLayerView.scrollWheel — the only delivery
|
||||
/// path that covers trackpad/Magic Mouse gestures (GCMouse never reports them).
|
||||
/// Fractional remainders accumulate so slow two-finger scrolling isn't truncated away.
|
||||
public func sendScroll(dx: Float, dy: Float) {
|
||||
public func sendScroll(dx rawDx: Float, dy rawDy: Float) {
|
||||
guard forwarding else { return }
|
||||
// Optionally invert both axes (read live). This is the ONE scroll sink for every platform —
|
||||
// the macOS wheel, the iOS trackpad pan, and a GCMouse wheel all land here — so the toggle
|
||||
// flips them consistently. Residuals are accumulated AFTER inversion so a direction change
|
||||
// between events doesn't strand a fractional remainder of the old sign.
|
||||
let invert = UserDefaults.standard.bool(forKey: DefaultsKey.invertScroll)
|
||||
let dx = invert ? -rawDx : rawDx
|
||||
let dy = invert ? -rawDy : rawDy
|
||||
let fy = dy + residualScrollY
|
||||
let fx = dx + residualScrollX
|
||||
let iy = fy.rounded(.towardZero)
|
||||
@@ -643,7 +674,7 @@ public final class InputCapture {
|
||||
} else {
|
||||
self.pressedVKs.remove(vk)
|
||||
}
|
||||
self.connection.send(.key(vk, down: pressed))
|
||||
self.emitKey(vk, down: pressed)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,7 +1,28 @@
|
||||
// InputCapture's static keymap tables: HID usage → Windows VK (the GCKeyboard path on all
|
||||
// platforms) and, on macOS, NSEvent.keyCode → Windows VK (the NSEvent key path).
|
||||
|
||||
import PunktfunkShared
|
||||
|
||||
extension InputCapture {
|
||||
/// Remap one modifier VK for the active location-based [`ModifierLayout`] just before it goes on
|
||||
/// the wire. `.mac` (and every non-modifier VK) is the identity. `.windows` swaps the Alt vs
|
||||
/// Super/Windows ROLE between the Option and Command keys while KEEPING the side, so a Windows
|
||||
/// user's `⌘ = Alt, ⌥ = Win` muscle memory lands correctly:
|
||||
/// L Command 0x5B ↔ L Alt 0xA4 · R Command 0x5C ↔ R Alt 0xA5.
|
||||
/// It's applied ONLY at the send boundary (`InputCapture.emitKey`) — all press/release
|
||||
/// bookkeeping stays on the physical VK, so modifier direction tracking and the client-local
|
||||
/// ⌘-based shortcuts are untouched. The swap is its own inverse: a key that went down remapped
|
||||
/// goes up remapped, so the host never sees a stuck modifier.
|
||||
static func applyModifierLayout(_ vk: UInt32, _ layout: ModifierLayout) -> UInt32 {
|
||||
guard layout == .windows else { return vk }
|
||||
switch vk {
|
||||
case 0x5B: return 0xA4 // L Command → L Alt (VK_LWIN → VK_LMENU)
|
||||
case 0x5C: return 0xA5 // R Command → R Alt (VK_RWIN → VK_RMENU)
|
||||
case 0xA4: return 0x5B // L Option → L Win (VK_LMENU → VK_LWIN)
|
||||
case 0xA5: return 0x5C // R Option → R Win (VK_RMENU → VK_RWIN)
|
||||
default: return vk
|
||||
}
|
||||
}
|
||||
/// HID usage (GCKeyCode raw) → Windows VK (the host maps VK → evdev; every VK emitted
|
||||
/// here exists in punktfunk-host/src/inject.rs::vk_to_evdev — extend the two together).
|
||||
static let hidToVK: [Int: UInt32] = {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
// from looping request → rollback → request.
|
||||
|
||||
import Foundation
|
||||
import PunktfunkShared
|
||||
|
||||
/// The pure, side-effect-free core of the Match-window trigger — so the normalize/skip discipline
|
||||
/// is unit-tested without a live connection or a UI (`MatchWindowTests`).
|
||||
@@ -51,6 +52,11 @@ public final class MatchWindowFollower {
|
||||
private weak var connection: PunktfunkConnection?
|
||||
private let debounce: TimeInterval
|
||||
private let minSpacing: TimeInterval
|
||||
/// Render-scale multiplier applied to the live window size before it's requested, so the
|
||||
/// match-window path supersamples/undersamples exactly like the fixed-mode connect. 1.0 = the
|
||||
/// window's native pixels (the prior behaviour). `maxDimension` is the codec's per-axis ceiling.
|
||||
private let renderScale: Double
|
||||
private let maxDimension: Int
|
||||
private var enabled: Bool
|
||||
|
||||
private var work: DispatchWorkItem?
|
||||
@@ -74,15 +80,28 @@ public final class MatchWindowFollower {
|
||||
public init(
|
||||
connection: PunktfunkConnection,
|
||||
enabled: Bool,
|
||||
renderScale: Double = 1.0,
|
||||
maxDimension: Int = 8192,
|
||||
debounce: TimeInterval = 0.4,
|
||||
minSpacing: TimeInterval = 1.0
|
||||
) {
|
||||
self.connection = connection
|
||||
self.enabled = enabled
|
||||
self.renderScale = RenderScale.sanitize(renderScale)
|
||||
self.maxDimension = maxDimension
|
||||
self.debounce = debounce
|
||||
self.minSpacing = minSpacing
|
||||
}
|
||||
|
||||
/// The host-valid mode for a live window size: the window's physical pixels × the render scale,
|
||||
/// aspect-preserved, even, and clamped to the codec ceiling — the match-window twin of
|
||||
/// ContentView's `scaledMode()`. Reduces to `MatchWindow.normalize` when the scale is 1.0.
|
||||
private func targetMode(widthPx: Int, heightPx: Int) -> (width: UInt32, height: UInt32) {
|
||||
RenderScale.apply(
|
||||
baseWidth: widthPx, baseHeight: heightPx,
|
||||
scale: renderScale, maxDimension: maxDimension)
|
||||
}
|
||||
|
||||
/// Turn following on/off live (a mid-session settings change; off cancels a pending request).
|
||||
public func setEnabled(_ on: Bool) {
|
||||
enabled = on
|
||||
@@ -109,7 +128,7 @@ public final class MatchWindowFollower {
|
||||
/// mode yet → nothing to compare against, skip.
|
||||
private func reportSteering(widthPx: Int, heightPx: Int) {
|
||||
guard let connection else { return }
|
||||
let target = MatchWindow.normalize(widthPx: widthPx, heightPx: heightPx)
|
||||
let target = targetMode(widthPx: widthPx, heightPx: heightPx)
|
||||
let mode = connection.currentMode()
|
||||
guard mode.width > 0, mode.height > 0 else { return }
|
||||
if target.width == mode.width, target.height == mode.height {
|
||||
@@ -137,7 +156,7 @@ public final class MatchWindowFollower {
|
||||
schedule()
|
||||
return
|
||||
}
|
||||
let target = MatchWindow.normalize(widthPx: size.width, heightPx: size.height)
|
||||
let target = targetMode(widthPx: size.width, heightPx: size.height)
|
||||
let mode = connection.currentMode()
|
||||
pendingSize = nil
|
||||
guard let req = MatchWindow.request(
|
||||
|
||||
@@ -621,6 +621,12 @@ public final class StreamLayerView: NSView {
|
||||
guard let self, self.window?.isKeyWindow == true else { return }
|
||||
self.onDisconnectRequest?()
|
||||
}
|
||||
capture.onToggleFullscreen = { [weak self] in
|
||||
// App-level window action: post to the key window's FullscreenController (same routing as
|
||||
// the Stream menu's ⌃⌘F item, so captured and released states hit one code path).
|
||||
guard self?.window?.isKeyWindow == true else { return }
|
||||
NotificationCenter.default.post(name: .punktfunkToggleFullscreen, object: nil)
|
||||
}
|
||||
capture.onCycleStats = { [weak self] in
|
||||
guard self?.window?.isKeyWindow == true else { return }
|
||||
// Advance the shared tier setting directly — every @AppStorage reader (the HUD's
|
||||
@@ -671,7 +677,10 @@ public final class StreamLayerView: NSView {
|
||||
// default keeps the explicit mode.
|
||||
let follower = MatchWindowFollower(
|
||||
connection: connection,
|
||||
enabled: UserDefaults.standard.object(forKey: DefaultsKey.matchWindow) as? Bool ?? false)
|
||||
enabled: UserDefaults.standard.object(forKey: DefaultsKey.matchWindow) as? Bool ?? false,
|
||||
renderScale: UserDefaults.standard.object(forKey: DefaultsKey.renderScale) as? Double ?? 1.0,
|
||||
maxDimension: RenderScale.maxDimension(
|
||||
codec: UserDefaults.standard.string(forKey: DefaultsKey.codec) ?? "auto"))
|
||||
follower.onResizeTarget = onResizeTarget // resize overlay START signal (instant, on the follower)
|
||||
matchFollower = follower
|
||||
layoutPresenter()
|
||||
|
||||
@@ -385,7 +385,10 @@ public final class StreamViewController: StreamViewControllerBase {
|
||||
// default keeps the explicit mode.
|
||||
let follower = MatchWindowFollower(
|
||||
connection: connection,
|
||||
enabled: UserDefaults.standard.object(forKey: DefaultsKey.matchWindow) as? Bool ?? false)
|
||||
enabled: UserDefaults.standard.object(forKey: DefaultsKey.matchWindow) as? Bool ?? false,
|
||||
renderScale: UserDefaults.standard.object(forKey: DefaultsKey.renderScale) as? Double ?? 1.0,
|
||||
maxDimension: RenderScale.maxDimension(
|
||||
codec: UserDefaults.standard.string(forKey: DefaultsKey.codec) ?? "auto"))
|
||||
follower.onResizeTarget = onResizeTarget
|
||||
matchFollower = follower
|
||||
#endif
|
||||
|
||||
@@ -21,6 +21,14 @@ public enum DefaultsKey {
|
||||
/// is native either way, so this degenerates to Auto-native there). Read per session by the
|
||||
/// stream views' `MatchWindowFollower`.
|
||||
public static let matchWindow = "punktfunk.matchWindow"
|
||||
/// Render-resolution multiplier (a `RenderScale` value, default 1.0): the client asks the host
|
||||
/// to render/encode at `chosen resolution × scale`, then the presenter downscales the larger
|
||||
/// decoded frame to this display in one Catmull-Rom pass. > 1 supersamples (sharper, at the cost
|
||||
/// of more bandwidth AND client decode — both grow ∝ scale²); < 1 renders below native for a
|
||||
/// weak host GPU / constrained link (the presenter upscales). Purely client-side — the host just
|
||||
/// sees a normal (larger/smaller) `Mode`, and Automatic bitrate scales with it. Clamped even +
|
||||
/// to the codec's max dimension at connect. Applies to the fixed mode and the match-window path.
|
||||
public static let renderScale = "punktfunk.renderScale"
|
||||
public static let compositor = "punktfunk.compositor"
|
||||
public static let gamepadType = "punktfunk.gamepadType"
|
||||
public static let gamepadID = "punktfunk.gamepadID"
|
||||
@@ -69,6 +77,21 @@ public enum DefaultsKey {
|
||||
public static let hosts = "punktfunk.hosts"
|
||||
/// Client-side cursor mode: "auto" (shown only in gamescope sessions), "always", "never".
|
||||
public static let cursorMode = "punktfunk.cursorMode"
|
||||
/// Invert the scroll-wheel / two-finger-scroll direction sent to the host (both axes). Off by
|
||||
/// default: the local (natural-scrolling) sign passes through untouched. When on, the sign is
|
||||
/// negated at the single scroll sink (`InputCapture.sendScroll`), so it flips consistently across
|
||||
/// the macOS wheel, the iOS trackpad pan, and a GCMouse wheel. For users whose host expects the
|
||||
/// opposite convention from their local OS preference.
|
||||
public static let invertScroll = "punktfunk.invertScroll"
|
||||
/// Location-based modifier mapping (a `ModifierLayout` value, default `.mac`): which Windows VK
|
||||
/// each PHYSICAL modifier position forwards to the host. `.mac` keeps ⌥ Option → Alt and
|
||||
/// ⌘ Command → Super/Win (the Apple positions). `.windows` swaps the Alt/Super ROLE between the
|
||||
/// Option and Command keys — preserving side (L/R) — so the key nearest the space bar acts as
|
||||
/// Alt and the next one as the Windows key, matching a Windows keyboard's `Ctrl / ⊞ / Alt` row.
|
||||
/// Only what's FORWARDED changes; client-local shortcuts (⌘⎋ &co.) stay on the physical ⌘ key.
|
||||
/// Read live at the wire boundary by `InputCapture`. Control/Shift never move (same position on
|
||||
/// both keyboards).
|
||||
public static let modifierLayout = "punktfunk.modifierLayout"
|
||||
/// iPad: capture the mouse/trackpad pointer (pointer lock → relative movement) for games,
|
||||
/// rather than forwarding an absolute cursor position. On by default. Only meaningful on iPad
|
||||
/// with a hardware mouse/trackpad; the system grants the lock only to a full-screen, frontmost
|
||||
@@ -132,6 +155,12 @@ extension Notification.Name {
|
||||
/// discoverable menu-bar surface.
|
||||
public static let punktfunkReleaseCapture = Notification.Name("io.unom.punktfunk.release-capture")
|
||||
|
||||
/// Posted by the app's Stream menu ("Toggle Fullscreen", ⌃⌘F) and by InputCapture's monitor
|
||||
/// when the same combo fires while input is captured (the menu key-equivalent never reaches a
|
||||
/// captured stream view). The key window's `FullscreenController` flips the window's fullscreen
|
||||
/// state. macOS only.
|
||||
public static let punktfunkToggleFullscreen = Notification.Name("io.unom.punktfunk.toggle-fullscreen")
|
||||
|
||||
/// Posted by the Live Activity's / Shortcuts' End-stream intent (`EndStreamIntent.perform`,
|
||||
/// which runs in the app's process): the app tears the active session down deliberately
|
||||
/// (quit-close the host). Same cross-process-signal pattern as `punktfunkReleaseCapture` —
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
// Location-based modifier mapping — which Windows VK each PHYSICAL modifier position forwards to
|
||||
// the host. A Mac keyboard's bottom row is `⌃ Control / ⌥ Option / ⌘ Command / space`; a Windows
|
||||
// keyboard's is `Ctrl / ⊞ Super / Alt / space`. So the key NEAREST the space bar is Command on a
|
||||
// Mac but Alt on Windows, and the next one out is Option on a Mac but the Windows key. A user who
|
||||
// grew up on Windows reaches for Alt where the Mac has Command; this setting lets them get that
|
||||
// muscle memory back WITHOUT relabelling keycaps — it remaps by physical position, not by a blunt
|
||||
// "swap these two VKs" that would also drag Control/Shift or lose the left/right distinction.
|
||||
//
|
||||
// The model: keep the physical detection (which side, which key) exactly as the OS reports it, and
|
||||
// swap only the Alt-vs-Super ROLE between the Option and Command keys, per side. So under `.windows`
|
||||
// the ⌘ position emits Alt (VK_L/RMENU) and the ⌥ position emits the Windows key (VK_L/RWIN), while
|
||||
// left stays left and right stays right. Control and Shift are in the same place on both keyboards,
|
||||
// so they never move. Lives in PunktfunkShared because both the Settings UI (PunktfunkClient) and
|
||||
// the wire-boundary remap (`InputCapture.applyModifierLayout`, PunktfunkKit) resolve it.
|
||||
|
||||
import Foundation
|
||||
|
||||
/// How the physical ⌥ Option / ⌘ Command keys map to host modifiers. The raw values are stable on
|
||||
/// disk — rename the cases freely, never the strings.
|
||||
public enum ModifierLayout: String, CaseIterable, Sendable {
|
||||
/// Apple positions (default): ⌥ Option → Alt, ⌘ Command → Super/Windows. The current behaviour.
|
||||
case mac
|
||||
/// Windows positions: the key nearest the space bar (⌘ Command) → Alt, the next one (⌥ Option)
|
||||
/// → the Windows/Super key. Side (left/right) is preserved.
|
||||
case windows
|
||||
|
||||
/// User-facing label (Settings picker).
|
||||
public var label: String {
|
||||
switch self {
|
||||
case .mac: return "Mac (⌥ Alt · ⌘ Super)"
|
||||
case .windows: return "Windows (⌘ Alt · ⌥ Super)"
|
||||
}
|
||||
}
|
||||
|
||||
/// A one-line explanation for the setting's footer.
|
||||
public var detail: String {
|
||||
switch self {
|
||||
case .mac:
|
||||
return "The ⌥ Option key sends Alt and the ⌘ Command key sends the Windows key — the Apple layout."
|
||||
case .windows:
|
||||
return "The key nearest the space bar sends Alt and the next one sends the Windows key, matching a PC keyboard. Client shortcuts (⌘⎋ and friends) still use the physical ⌘ key."
|
||||
}
|
||||
}
|
||||
|
||||
/// The persisted layout (default `.mac` when unset).
|
||||
public static var current: ModifierLayout {
|
||||
guard let raw = UserDefaults.standard.string(forKey: DefaultsKey.modifierLayout) else {
|
||||
return .mac
|
||||
}
|
||||
return ModifierLayout(rawValue: raw) ?? .mac
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
// Render-resolution scaling — the pure geometry behind `DefaultsKey.renderScale`. The client asks
|
||||
// the host to render/encode at `chosen resolution × scale` and lets the presenter downscale the
|
||||
// larger decoded frame to the display (a Catmull-Rom minification, > 1 = supersampling for
|
||||
// sharpness) or upscale a smaller one (< 1 = a performance mode for a weak host GPU / thin link).
|
||||
//
|
||||
// This is where the multiplier is turned into a host-valid `Mode` dimension: multiply, preserve the
|
||||
// aspect ratio, floor to even (the host's `validate_dimensions` rejects odd sizes), and clamp to the
|
||||
// codec's per-axis ceiling so the connect can't ask for something the encoder will reject. Kept
|
||||
// dependency-free + side-effect-free so it's unit-tested (`RenderScaleTests`) and reused by both the
|
||||
// fixed-mode connect and the match-window follower.
|
||||
|
||||
import Foundation
|
||||
|
||||
public enum RenderScale {
|
||||
/// The supported multiplier range. Below 1 renders under native (upscaled on present); above 1
|
||||
/// supersamples. The UI clamps its slider to this and the connect clamps the raw stored value.
|
||||
public static let range: ClosedRange<Double> = 0.5...4.0
|
||||
|
||||
/// The multipliers the picker offers. 1.0 (Native) is the default; the rest are the round stops
|
||||
/// users reason about.
|
||||
public static let presets: [Double] = [0.5, 0.67, 0.75, 1.0, 1.25, 1.5, 2.0, 3.0, 4.0]
|
||||
|
||||
/// The encoder/host per-axis ceiling for a codec preference string (`DefaultsKey.codec`). H.264
|
||||
/// tops out at 4096 px/axis; HEVC / AV1 / PyroWave (and "auto", which negotiates one of those in
|
||||
/// practice) at 8192. The host enforces the same walls in `codec.rs::validate_dimensions`.
|
||||
public static func maxDimension(codec: String) -> Int {
|
||||
codec == "h264" ? 4096 : 8192
|
||||
}
|
||||
|
||||
/// A compact user-facing label for a multiplier: "Native (1×)", "1.5×", "2× · supersample".
|
||||
/// Shared by every platform's picker so the wording stays identical.
|
||||
public static func label(_ scale: Double) -> String {
|
||||
if scale == 1.0 { return "Native (1×)" }
|
||||
let magnitude = String(format: "%g×", scale)
|
||||
return scale > 1 ? "\(magnitude) · supersample" : magnitude
|
||||
}
|
||||
|
||||
/// Clamp a raw stored multiplier into `range`, treating a missing/zero value as 1.0 (Native).
|
||||
public static func sanitize(_ raw: Double) -> Double {
|
||||
guard raw > 0 else { return 1.0 }
|
||||
return min(max(raw, range.lowerBound), range.upperBound)
|
||||
}
|
||||
|
||||
/// Apply `scale` to a base pixel size, preserving aspect, even-flooring each axis, and clamping
|
||||
/// uniformly so neither axis exceeds `maxDimension` (the larger axis lands on the cap, the ratio
|
||||
/// is kept). Also floors each axis at `minWidth`/`minHeight` (the host never accepts < 320×200).
|
||||
/// The result is a directly host-valid `Mode` width/height.
|
||||
public static func apply(
|
||||
baseWidth: Int,
|
||||
baseHeight: Int,
|
||||
scale rawScale: Double,
|
||||
maxDimension: Int,
|
||||
minWidth: Int = 320,
|
||||
minHeight: Int = 200
|
||||
) -> (width: UInt32, height: UInt32) {
|
||||
let scale = sanitize(rawScale)
|
||||
var w = Double(max(baseWidth, 1)) * scale
|
||||
var h = Double(max(baseHeight, 1)) * scale
|
||||
// Uniform down-clamp if either axis blew past the ceiling — keep the aspect ratio intact.
|
||||
let cap = Double(maxDimension)
|
||||
let over = max(w / cap, h / cap)
|
||||
if over > 1 {
|
||||
w /= over
|
||||
h /= over
|
||||
}
|
||||
let evenFloor: (Double, Int) -> UInt32 = { value, minimum in
|
||||
let clamped = max(Int(value.rounded(.down)), minimum)
|
||||
return UInt32(clamped / 2 * 2)
|
||||
}
|
||||
return (evenFloor(w, minWidth), evenFloor(h, minHeight))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import XCTest
|
||||
|
||||
import PunktfunkShared
|
||||
@testable import PunktfunkKit
|
||||
|
||||
/// Pins the location-based modifier remap (`InputCapture.applyModifierLayout`) — the wire-boundary
|
||||
/// swap that relocates the Alt/Super role between the physical ⌥/⌘ keys per side, without touching
|
||||
/// Control/Shift or the physical detection upstream.
|
||||
final class ModifierLayoutMappingTests: XCTestCase {
|
||||
// The four physical modifier VKs the remap can touch, and everything else it must not.
|
||||
private let lWin: UInt32 = 0x5B, rWin: UInt32 = 0x5C
|
||||
private let lAlt: UInt32 = 0xA4, rAlt: UInt32 = 0xA5
|
||||
|
||||
func testMacLayoutIsIdentity() {
|
||||
for vk: UInt32 in [lWin, rWin, lAlt, rAlt, 0xA0, 0xA2, 0x41, 0x1B] {
|
||||
XCTAssertEqual(InputCapture.applyModifierLayout(vk, .mac), vk)
|
||||
}
|
||||
}
|
||||
|
||||
func testWindowsLayoutSwapsAltAndSuperPerSide() {
|
||||
XCTAssertEqual(InputCapture.applyModifierLayout(lWin, .windows), lAlt) // L ⌘ → L Alt
|
||||
XCTAssertEqual(InputCapture.applyModifierLayout(rWin, .windows), rAlt) // R ⌘ → R Alt
|
||||
XCTAssertEqual(InputCapture.applyModifierLayout(lAlt, .windows), lWin) // L ⌥ → L Win
|
||||
XCTAssertEqual(InputCapture.applyModifierLayout(rAlt, .windows), rWin) // R ⌥ → R Win
|
||||
}
|
||||
|
||||
func testWindowsLayoutKeepsSideNeverCrossesLeftRight() {
|
||||
// A left key never becomes a right VK or vice-versa.
|
||||
XCTAssertNotEqual(InputCapture.applyModifierLayout(lWin, .windows), rAlt)
|
||||
XCTAssertNotEqual(InputCapture.applyModifierLayout(rWin, .windows), lAlt)
|
||||
}
|
||||
|
||||
func testControlShiftAndRegularKeysNeverMove() {
|
||||
for vk: UInt32 in [
|
||||
0xA0, 0xA1, // L/R Shift
|
||||
0xA2, 0xA3, // L/R Control
|
||||
0x41, 0x5A, // A, Z
|
||||
0x1B, 0x0D, // Esc, Return
|
||||
] {
|
||||
XCTAssertEqual(InputCapture.applyModifierLayout(vk, .windows), vk)
|
||||
}
|
||||
}
|
||||
|
||||
func testWindowsRemapIsItsOwnInverse() {
|
||||
// Down-remapped then the same key up-remapped land on the same host VK — no stuck modifier.
|
||||
for vk: UInt32 in [lWin, rWin, lAlt, rAlt] {
|
||||
let once = InputCapture.applyModifierLayout(vk, .windows)
|
||||
XCTAssertEqual(InputCapture.applyModifierLayout(once, .windows), vk)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
import XCTest
|
||||
|
||||
import PunktfunkShared
|
||||
|
||||
/// Pins the render-scale geometry (`RenderScale`) — the multiply → aspect-preserve → even-floor →
|
||||
/// codec-clamp that turns the `renderScale` setting into a host-valid `Mode`, plus the label/clamp
|
||||
/// helpers the UI and the connect share.
|
||||
final class RenderScaleTests: XCTestCase {
|
||||
func testSanitizeClampsToRangeAndDefaultsMissing() {
|
||||
XCTAssertEqual(RenderScale.sanitize(0), 1.0) // absent / zero → Native
|
||||
XCTAssertEqual(RenderScale.sanitize(-2), 1.0) // nonsense → Native
|
||||
XCTAssertEqual(RenderScale.sanitize(0.1), 0.5) // below the floor
|
||||
XCTAssertEqual(RenderScale.sanitize(9), 4.0) // above the ceiling
|
||||
XCTAssertEqual(RenderScale.sanitize(1.5), 1.5) // in range, untouched
|
||||
}
|
||||
|
||||
func testMaxDimensionIsCodecAware() {
|
||||
XCTAssertEqual(RenderScale.maxDimension(codec: "h264"), 4096)
|
||||
XCTAssertEqual(RenderScale.maxDimension(codec: "hevc"), 8192)
|
||||
XCTAssertEqual(RenderScale.maxDimension(codec: "av1"), 8192)
|
||||
XCTAssertEqual(RenderScale.maxDimension(codec: "auto"), 8192)
|
||||
}
|
||||
|
||||
func testNativeScaleIsIdentity() {
|
||||
let m = RenderScale.apply(baseWidth: 1920, baseHeight: 1080, scale: 1.0, maxDimension: 8192)
|
||||
XCTAssertEqual(m.width, 1920)
|
||||
XCTAssertEqual(m.height, 1080)
|
||||
}
|
||||
|
||||
func testSupersampleDoubles() {
|
||||
let m = RenderScale.apply(baseWidth: 1920, baseHeight: 1080, scale: 2.0, maxDimension: 8192)
|
||||
XCTAssertEqual(m.width, 3840)
|
||||
XCTAssertEqual(m.height, 2160)
|
||||
}
|
||||
|
||||
func testUnderRenderHalves() {
|
||||
let m = RenderScale.apply(baseWidth: 1920, baseHeight: 1080, scale: 0.5, maxDimension: 8192)
|
||||
XCTAssertEqual(m.width, 960)
|
||||
XCTAssertEqual(m.height, 540)
|
||||
}
|
||||
|
||||
func testResultsAreAlwaysEven() {
|
||||
// 1280×720 × 1.5 = 1920×1080 (already even); 1366×768 × 1.5 = 2049×1152 → 2048×1152.
|
||||
let m = RenderScale.apply(baseWidth: 1366, baseHeight: 768, scale: 1.5, maxDimension: 8192)
|
||||
XCTAssertEqual(m.width % 2, 0)
|
||||
XCTAssertEqual(m.height % 2, 0)
|
||||
XCTAssertEqual(m.width, 2048)
|
||||
XCTAssertEqual(m.height, 1152)
|
||||
}
|
||||
|
||||
func testOverCeilingClampsUniformlyPreservingAspect() {
|
||||
// 4K × 4 would be 15360×8640; both axes exceed 8192, so the LARGER (width) lands on the cap
|
||||
// and the ratio is kept (16:9 → 8192×4608, even).
|
||||
let m = RenderScale.apply(baseWidth: 3840, baseHeight: 2160, scale: 4.0, maxDimension: 8192)
|
||||
XCTAssertLessThanOrEqual(m.width, 8192)
|
||||
XCTAssertLessThanOrEqual(m.height, 8192)
|
||||
XCTAssertEqual(m.width, 8192)
|
||||
XCTAssertEqual(m.height, 4608)
|
||||
// 16:9 preserved to within the even-floor rounding.
|
||||
XCTAssertEqual(Double(m.width) / Double(m.height), 16.0 / 9.0, accuracy: 0.01)
|
||||
}
|
||||
|
||||
func testH264CeilingIsTighter() {
|
||||
// 1080p × 4 = 7680×4320; under H.264's 4096 wall the width clamps to 4096, aspect kept.
|
||||
let m = RenderScale.apply(baseWidth: 1920, baseHeight: 1080, scale: 4.0, maxDimension: 4096)
|
||||
XCTAssertEqual(m.width, 4096)
|
||||
XCTAssertEqual(m.height, 2304)
|
||||
}
|
||||
|
||||
func testMinimumFloorHonoured() {
|
||||
// A tiny base under a small scale can't fall below 320×200.
|
||||
let m = RenderScale.apply(baseWidth: 400, baseHeight: 300, scale: 0.5, maxDimension: 8192)
|
||||
XCTAssertGreaterThanOrEqual(m.width, 320)
|
||||
XCTAssertGreaterThanOrEqual(m.height, 200)
|
||||
}
|
||||
|
||||
func testLabels() {
|
||||
XCTAssertEqual(RenderScale.label(1.0), "Native (1×)")
|
||||
XCTAssertEqual(RenderScale.label(2.0), "2× · supersample")
|
||||
XCTAssertEqual(RenderScale.label(0.5), "0.5×")
|
||||
}
|
||||
}
|
||||
@@ -896,8 +896,8 @@ class Plugin:
|
||||
except (OSError, json.JSONDecodeError):
|
||||
# The client's own defaults (native display, host-default bitrate, auto pad).
|
||||
return {
|
||||
"width": 0, "height": 0, "refresh_hz": 0, "bitrate_kbps": 0,
|
||||
"codec": "auto", "gamepad": "auto", "compositor": "auto",
|
||||
"width": 0, "height": 0, "refresh_hz": 0, "render_scale": 1.0,
|
||||
"bitrate_kbps": 0, "codec": "auto", "gamepad": "auto", "compositor": "auto",
|
||||
"inhibit_shortcuts": True, "mic_enabled": False,
|
||||
}
|
||||
|
||||
|
||||
@@ -99,6 +99,7 @@ export interface StreamSettings {
|
||||
width: number; // 0 = native
|
||||
height: number; // 0 = native
|
||||
refresh_hz: number; // 0 = native
|
||||
render_scale?: number; // render-resolution multiplier; 1.0 = native (absent in pre-scale files)
|
||||
bitrate_kbps: number; // 0 = host default
|
||||
codec?: string; // "auto" | "hevc" | "h264" | "av1" — soft preference (absent in pre-codec files)
|
||||
gamepad: string; // "auto" | "xbox360" | "xboxone" | "dualsense" | "dualshock4" | "steamdeck"
|
||||
|
||||
@@ -25,6 +25,10 @@ const RESOLUTIONS: [number, number, string][] = [
|
||||
[2560, 1440, "2560 × 1440"],
|
||||
];
|
||||
const REFRESH = [0, 30, 60, 90, 120];
|
||||
// Render-resolution multipliers (mirrors punktfunk_core::render_scale::PRESETS). 1.0 = native.
|
||||
const RENDER_SCALES = [0.5, 0.67, 0.75, 1.0, 1.25, 1.5, 2.0, 3.0, 4.0];
|
||||
const renderScaleLabel = (x: number): string =>
|
||||
x === 1 ? "Native (1×)" : x > 1 ? `${x}× · supersample` : `${x}×`;
|
||||
const GAMEPADS = ["auto", "xbox360", "xboxone", "dualsense", "dualshock4", "steamdeck"];
|
||||
const GAMEPAD_LABELS: Record<string, string> = {
|
||||
auto: "Automatic",
|
||||
@@ -106,6 +110,24 @@ export const SettingsSection: FC = () => {
|
||||
</div>
|
||||
</RowActions>
|
||||
</Field>
|
||||
<Field
|
||||
label="Render scale"
|
||||
description="Supersample for sharpness (> 1×, more bandwidth) or render below native (< 1×) — the Deck resamples to its screen"
|
||||
childrenContainerWidth="max"
|
||||
>
|
||||
<RowActions>
|
||||
<div style={selectShell}>
|
||||
<Dropdown
|
||||
rgOptions={RENDER_SCALES.map((x) => ({ data: x, label: renderScaleLabel(x) }))}
|
||||
// Snap the stored value to the nearest preset so the dropdown always shows a match.
|
||||
selectedOption={RENDER_SCALES.reduce((best, x) =>
|
||||
Math.abs(x - (s.render_scale ?? 1)) < Math.abs(best - (s.render_scale ?? 1)) ? x : best,
|
||||
)}
|
||||
onChange={(o) => patch({ render_scale: o.data as number })}
|
||||
/>
|
||||
</div>
|
||||
</RowActions>
|
||||
</Field>
|
||||
<SliderField
|
||||
label="Bitrate"
|
||||
description="Mbit/s · 0 = host default"
|
||||
|
||||
@@ -17,6 +17,20 @@ const RESOLUTIONS: &[(u32, u32)] = &[
|
||||
];
|
||||
/// `0` = the monitor's native refresh, resolved at connect.
|
||||
const REFRESH: &[u32] = &[0, 30, 60, 90, 120, 144, 165, 240];
|
||||
/// Render-scale multipliers (persisted as f64; mirrors [`punktfunk_core::render_scale::PRESETS`]).
|
||||
/// `1.0` = Native. Applied at connect and each match-window resize.
|
||||
const RENDER_SCALES: &[f64] = &[0.5, 0.67, 0.75, 1.0, 1.25, 1.5, 2.0, 3.0, 4.0];
|
||||
|
||||
/// A compact label for a render-scale multiplier: "Native" / "1.5×" / "2× (supersample)".
|
||||
fn render_scale_label(scale: f64) -> String {
|
||||
if scale == 1.0 {
|
||||
"Native".to_string()
|
||||
} else if scale > 1.0 {
|
||||
format!("{scale}× (supersample)")
|
||||
} else {
|
||||
format!("{scale}×")
|
||||
}
|
||||
}
|
||||
const GAMEPADS: &[&str] = &[
|
||||
"auto",
|
||||
"xbox360",
|
||||
@@ -304,6 +318,18 @@ pub fn show(
|
||||
"",
|
||||
&hz_names.iter().map(String::as_str).collect::<Vec<_>>(),
|
||||
);
|
||||
let scale_names: Vec<String> = RENDER_SCALES
|
||||
.iter()
|
||||
.map(|&s| render_scale_label(s))
|
||||
.collect();
|
||||
let scale_row = ChoiceRow::new(
|
||||
&dialog,
|
||||
inline,
|
||||
"Render scale",
|
||||
"Supersample for sharpness (> 1×, more bandwidth and decode) or render below native \
|
||||
(< 1×) for a lighter host — this device resamples to the window",
|
||||
&scale_names.iter().map(String::as_str).collect::<Vec<_>>(),
|
||||
);
|
||||
let bitrate_row = adw::SpinRow::with_range(0.0, 3000.0, 5.0);
|
||||
bitrate_row.set_title("Bitrate");
|
||||
bitrate_row.set_subtitle("Mbit/s · 0 = host default · run a speed test before going high");
|
||||
@@ -346,6 +372,7 @@ pub fn show(
|
||||
.build();
|
||||
stream.add(res_row.widget());
|
||||
stream.add(hz_row.widget());
|
||||
stream.add(scale_row.widget());
|
||||
stream.add(&bitrate_row);
|
||||
stream.add(compositor_row.widget());
|
||||
stream.add(decoder_row.widget());
|
||||
@@ -500,6 +527,11 @@ pub fn show(
|
||||
res_row.set_selected(res_i as u32);
|
||||
let hz_i = REFRESH.iter().position(|&r| r == s.refresh_hz).unwrap_or(0);
|
||||
hz_row.set_selected(hz_i as u32);
|
||||
let scale_i = RENDER_SCALES
|
||||
.iter()
|
||||
.position(|&x| (x - s.render_scale).abs() < 1e-6)
|
||||
.unwrap_or_else(|| RENDER_SCALES.iter().position(|&x| x == 1.0).unwrap());
|
||||
scale_row.set_selected(scale_i as u32);
|
||||
bitrate_row.set_value(f64::from(s.bitrate_kbps) / 1000.0);
|
||||
let pad_i = GAMEPADS.iter().position(|&g| g == s.gamepad).unwrap_or(0);
|
||||
pad_row.set_selected(pad_i as u32);
|
||||
@@ -545,6 +577,8 @@ pub fn show(
|
||||
RESOLUTIONS[res_i - 1]
|
||||
};
|
||||
s.refresh_hz = REFRESH[(hz_row.selected() as usize).min(REFRESH.len() - 1)];
|
||||
s.render_scale =
|
||||
RENDER_SCALES[(scale_row.selected() as usize).min(RENDER_SCALES.len() - 1)];
|
||||
s.bitrate_kbps = (bitrate_row.value() * 1000.0) as u32;
|
||||
s.gamepad = GAMEPADS[(pad_row.selected() as usize).min(GAMEPADS.len() - 1)].to_string();
|
||||
s.touch_mode =
|
||||
|
||||
@@ -1241,6 +1241,12 @@ async fn session(args: Args) -> Result<()> {
|
||||
std::collections::VecDeque::new();
|
||||
let mut host_us_v: Vec<u64> = Vec::new();
|
||||
let mut net_us_v: Vec<u64> = Vec::new();
|
||||
// T0.1 host-stage split (extended 0xCF): queue/encode/pace + the derived seal/xfer
|
||||
// residual. Empty against a host that predates the stage tail.
|
||||
let mut queue_us_v: Vec<u64> = Vec::new();
|
||||
let mut enc_us_v: Vec<u64> = Vec::new();
|
||||
let mut xfer_us_v: Vec<u64> = Vec::new();
|
||||
let mut pace_us_v: Vec<u64> = Vec::new();
|
||||
let mut last_rx = std::time::Instant::now();
|
||||
let started = std::time::Instant::now();
|
||||
// Stream-duration cap: `--seconds N`, else the 120s default. Ending the loop here reaches the
|
||||
@@ -1316,6 +1322,14 @@ async fn session(args: Args) -> Result<()> {
|
||||
let (_, hostnet_us) = pending_split.remove(i).unwrap();
|
||||
host_us_v.push(t.host_us as u64);
|
||||
net_us_v.push(hostnet_us.saturating_sub(t.host_us as u64));
|
||||
if let Some(s) = t.stages {
|
||||
queue_us_v.push(s.queue_us as u64);
|
||||
enc_us_v.push(s.encode_us as u64);
|
||||
pace_us_v.push(s.pace_us as u64);
|
||||
xfer_us_v.push((t.host_us as u64).saturating_sub(
|
||||
s.queue_us as u64 + s.encode_us as u64 + s.pace_us as u64,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
if expected > 0 {
|
||||
@@ -1399,6 +1413,23 @@ async fn session(args: Args) -> Result<()> {
|
||||
"host/network latency split (host = capture→sent on the host; network = wire + \
|
||||
reassembly)"
|
||||
);
|
||||
if !queue_us_v.is_empty() {
|
||||
// The T0.1 per-stage host attribution: queue (capture→submit) → encode
|
||||
// (submit→bitstream) → xfer (seal/FEC + send-channel wait, derived residual)
|
||||
// → pace (the microburst spread). The four tile host_us per frame.
|
||||
tracing::info!(
|
||||
stage_samples = queue_us_v.len(),
|
||||
queue_p50_us = pcts(&mut queue_us_v, 0.50),
|
||||
queue_p95_us = pcts(&mut queue_us_v, 0.95),
|
||||
encode_p50_us = pcts(&mut enc_us_v, 0.50),
|
||||
encode_p95_us = pcts(&mut enc_us_v, 0.95),
|
||||
xfer_p50_us = pcts(&mut xfer_us_v, 0.50),
|
||||
xfer_p95_us = pcts(&mut xfer_us_v, 0.95),
|
||||
pace_p50_us = pcts(&mut pace_us_v, 0.50),
|
||||
pace_p95_us = pcts(&mut pace_us_v, 0.95),
|
||||
"host stage split (queue → encode → xfer → pace tile the host figure)"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
tracing::info!("no host timing datagrams (0xCF) — old host; host+network unsplit");
|
||||
}
|
||||
|
||||
@@ -175,6 +175,8 @@ pub fn run(target: Option<&str>) -> u8 {
|
||||
// Latched at console start (like the stats tier above): toggling Match window in
|
||||
// the console's settings screen applies from the next console launch.
|
||||
match_window: crate::session_main::match_window(&settings_at_start),
|
||||
render_scale: settings_at_start.render_scale,
|
||||
render_scale_max_dim: punktfunk_core::render_scale::max_dimension(&settings_at_start.codec),
|
||||
};
|
||||
|
||||
let result =
|
||||
|
||||
@@ -127,6 +127,20 @@ mod session_main {
|
||||
settings.refresh_hz
|
||||
},
|
||||
};
|
||||
// Render scale: multiply the resolved mode (even + codec-clamped) so the host renders
|
||||
// larger/smaller and the presenter resamples to the window. 1.0 = Native. Applied after the
|
||||
// Native/explicit resolution so it composes uniformly with both.
|
||||
let (sw, sh) = punktfunk_core::render_scale::apply(
|
||||
mode.width,
|
||||
mode.height,
|
||||
settings.render_scale,
|
||||
punktfunk_core::render_scale::max_dimension(&settings.codec),
|
||||
);
|
||||
let mode = Mode {
|
||||
width: sw,
|
||||
height: sh,
|
||||
..mode
|
||||
};
|
||||
SessionParams {
|
||||
host: addr,
|
||||
port,
|
||||
@@ -372,6 +386,8 @@ mod session_main {
|
||||
overlay: None,
|
||||
window_size: window_size(&settings),
|
||||
match_window: match_window(&settings),
|
||||
render_scale: settings.render_scale,
|
||||
render_scale_max_dim: punktfunk_core::render_scale::max_dimension(&settings.codec),
|
||||
};
|
||||
|
||||
let outcome =
|
||||
|
||||
@@ -19,6 +19,20 @@ const RESOLUTIONS: &[(u32, u32)] = &[
|
||||
];
|
||||
/// `0` = the display's native refresh, resolved at connect.
|
||||
const REFRESH: &[u32] = &[0, 30, 60, 90, 120, 144, 165, 240];
|
||||
/// Render-scale multipliers (persisted as f64; mirrors [`punktfunk_core::render_scale::PRESETS`]).
|
||||
/// `1.0` = Native. Applied at connect and each match-window resize.
|
||||
const RENDER_SCALES: &[f64] = &[0.5, 0.67, 0.75, 1.0, 1.25, 1.5, 2.0, 3.0, 4.0];
|
||||
|
||||
/// A compact label for a render-scale multiplier: "Native" / "1.5×" / "2× (supersample)".
|
||||
fn render_scale_label(scale: f64) -> String {
|
||||
if scale == 1.0 {
|
||||
"Native".to_string()
|
||||
} else if scale > 1.0 {
|
||||
format!("{scale}\u{00D7} (supersample)")
|
||||
} else {
|
||||
format!("{scale}\u{00D7}")
|
||||
}
|
||||
}
|
||||
/// Decode backend presets: `(stored value, display label)`.
|
||||
// A stored legacy "hardware" (the D3D11VA era) matches no preset, so the combo shows
|
||||
// Automatic — which is exactly how the session's decoder chain reads that value.
|
||||
@@ -193,6 +207,24 @@ pub(crate) fn settings_page(
|
||||
s.refresh_hz = REFRESH[i];
|
||||
})
|
||||
.tooltip("\u{201C}Native\u{201D} resolves to this display's refresh rate at connect.");
|
||||
let (scale_names, scale_i) = {
|
||||
let names: Vec<String> = RENDER_SCALES
|
||||
.iter()
|
||||
.map(|&x| render_scale_label(x))
|
||||
.collect();
|
||||
let i = RENDER_SCALES
|
||||
.iter()
|
||||
.position(|&x| (x - s.render_scale).abs() < 1e-6)
|
||||
.unwrap_or_else(|| RENDER_SCALES.iter().position(|&x| x == 1.0).unwrap());
|
||||
(names, i)
|
||||
};
|
||||
let scale_combo = setting_combo(ctx, "Render scale", scale_names, scale_i, |s, i| {
|
||||
s.render_scale = RENDER_SCALES[i];
|
||||
})
|
||||
.tooltip(
|
||||
"Supersample for sharpness (above 1\u{00D7}, more bandwidth and decode) or render below \
|
||||
native (below 1\u{00D7}) for a lighter host \u{2014} this device resamples to the window.",
|
||||
);
|
||||
let (comp_names, comp_i) = presets(COMPOSITORS, |v| *v == s.compositor);
|
||||
let comp_combo = setting_combo(ctx, "Host compositor", comp_names, comp_i, |s, i| {
|
||||
s.compositor = COMPOSITORS[i].0.to_string();
|
||||
@@ -441,6 +473,7 @@ pub(crate) fn settings_page(
|
||||
settings_card(vec![
|
||||
res_combo.into(),
|
||||
hz_combo.into(),
|
||||
scale_combo.into(),
|
||||
fullscreen_toggle.into(),
|
||||
comp_combo.into(),
|
||||
]),
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
# Thin driver over the vendored Intel VPL tree (vendor/libvpl): build the
|
||||
# dispatcher as a static archive, nothing else. Replaces upstream's top-level
|
||||
# CMakeLists.txt (which also wires examples/env/install machinery).
|
||||
cmake_minimum_required(VERSION 3.13.0)
|
||||
if(MSVC)
|
||||
cmake_policy(SET CMP0091 NEW)
|
||||
endif()
|
||||
|
||||
file(STRINGS "vendor/libvpl/version.txt" version_txt)
|
||||
project(vpl VERSION ${version_txt})
|
||||
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
set(BUILD_TESTS OFF)
|
||||
set(INSTALL_DEV OFF)
|
||||
set(INSTALL_LIB OFF)
|
||||
set(INSTALL_EXAMPLES OFF)
|
||||
# Defines ONEVPL_EXPERIMENTAL inside the dispatcher — must match the bindgen
|
||||
# flag in build.rs (the D3D11 import API lives behind it).
|
||||
set(BUILD_EXPERIMENTAL ON)
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE true)
|
||||
# One predictable place for the archive; MSVC multi-config generators still
|
||||
# append a per-config subdir (Release/) — build.rs searches both.
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||
|
||||
# api/ first: it exports API_VERSION_MAJOR/MINOR + the vpl-api interface
|
||||
# target into this scope, which libvpl/ then consumes (same ordering contract
|
||||
# as upstream's top-level).
|
||||
add_subdirectory(vendor/libvpl/api)
|
||||
add_subdirectory(vendor/libvpl/libvpl)
|
||||
@@ -0,0 +1,17 @@
|
||||
[package]
|
||||
name = "libvpl-sys"
|
||||
description = "Vendored Intel VPL (libvpl) dispatcher built from source as a static archive + bindgen over the C API — substrate for the native QSV encoder backend (design/native-qsv-encoder.md). Upstream pin recorded in vendor/libvpl/PUNKTFUNK-VENDOR.txt; the tree builds with ONEVPL_EXPERIMENTAL, so bumping the pin re-opens the experimental-ABI check (§3.1)."
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
repository.workspace = true
|
||||
links = "vpl"
|
||||
|
||||
[build-dependencies]
|
||||
# Same CMake-from-vendored-source model as pyrowave-sys/opus: reproducible
|
||||
# offline builds (CI, MSVC, flatpak) — no network, no system libvpl.
|
||||
cmake = "0.1"
|
||||
# Same bindgen configuration as pyrowave-sys (runtime = dlopen libclang).
|
||||
bindgen = { version = "0.72", features = ["runtime"], default-features = false }
|
||||
@@ -0,0 +1,80 @@
|
||||
//! Build the vendored Intel VPL dispatcher (`vendor/libvpl`) as a static
|
||||
//! archive via CMake and generate bindings over the C API (`vpl/mfx.h`).
|
||||
//!
|
||||
//! Windows only — the native QSV backend is a Windows-host feature
|
||||
//! (design/native-qsv-encoder.md); Linux Intel is served by VAAPI/Vulkan
|
||||
//! Video. Other targets get an empty bindings file so the workspace builds
|
||||
//! everywhere.
|
||||
//!
|
||||
//! The dispatcher is MIT and statically linked: no new runtime DLL. At run
|
||||
//! time it locates the Intel GPU runtimes (`libmfx64-gen.dll`, legacy
|
||||
//! `libmfxhw64.dll`) in the driver store; a box without an Intel driver just
|
||||
//! fails MFXCreateSession and the encoder open falls through — the same
|
||||
//! degrade contract as the NVENC/AMF runtime loaders.
|
||||
//!
|
||||
//! Everything compiles from the committed vendor tree: no network, no system
|
||||
//! libvpl, no pkg-config. Only cmake + a libclang for bindgen are required on
|
||||
//! the build machine (both already in the build closure via pyrowave-sys).
|
||||
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=wrapper.h");
|
||||
println!("cargo:rerun-if-changed=CMakeLists.txt");
|
||||
println!("cargo:rerun-if-changed=vendor/libvpl");
|
||||
|
||||
let out = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
let bindings_path = out.join("bindings.rs");
|
||||
|
||||
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
|
||||
if target_os != "windows" {
|
||||
std::fs::write(
|
||||
&bindings_path,
|
||||
"// libvpl-sys: Windows-only, empty on this target\n",
|
||||
)
|
||||
.unwrap();
|
||||
return;
|
||||
}
|
||||
|
||||
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
|
||||
let api_include = manifest_dir.join("vendor/libvpl/api");
|
||||
|
||||
// Always Release: mirrors pyrowave-sys — a debug dispatcher buys nothing
|
||||
// and the MSVC debug CRT would clash with Rust's release CRT.
|
||||
let dst = cmake::Config::new(&manifest_dir)
|
||||
.profile("Release")
|
||||
.build_target("VPL")
|
||||
.build();
|
||||
let build = dst.join("build");
|
||||
println!("cargo:rustc-link-search=native={}", build.display());
|
||||
// MSVC multi-config generators put the archive in a Release/ subdir.
|
||||
println!(
|
||||
"cargo:rustc-link-search=native={}",
|
||||
build.join("Release").display()
|
||||
);
|
||||
println!("cargo:rustc-link-lib=static=vpl");
|
||||
// The dispatcher's Win32 import closure (registry, DXGI adapter probing
|
||||
// COM plumbing). d3d9.dll/dxgi.dll themselves are LoadLibrary'd at
|
||||
// runtime — no static import.
|
||||
for lib in ["advapi32", "ole32", "user32", "uuid", "gdi32"] {
|
||||
println!("cargo:rustc-link-lib=dylib={lib}");
|
||||
}
|
||||
|
||||
// ONEVPL_EXPERIMENTAL must match the CMake side (BUILD_EXPERIMENTAL=ON):
|
||||
// it gates the D3D11 surface-import API in both the headers and the
|
||||
// dispatcher object code.
|
||||
let bindings = bindgen::Builder::default()
|
||||
.header("wrapper.h")
|
||||
.clang_arg(format!("-I{}", api_include.display()))
|
||||
.clang_arg("-DONEVPL_EXPERIMENTAL")
|
||||
// Plain MFX_* constants instead of EnumName_MFX_* — the C API is used
|
||||
// by FourCC/flag value, never by enum type.
|
||||
.prepend_enum_name(false)
|
||||
.derive_default(true)
|
||||
.generate()
|
||||
.expect("bindgen failed for vpl/mfx.h");
|
||||
bindings
|
||||
.write_to_file(&bindings_path)
|
||||
.expect("failed to write libvpl bindings");
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
//! Raw FFI bindings to the vendored Intel VPL C API (`vpl/mfx.h`) plus the
|
||||
//! statically linked MIT dispatcher.
|
||||
//!
|
||||
//! Empty on targets other than Windows — see build.rs. The safe wrapper lives
|
||||
//! with its consumer (`pf-encode`'s `enc/windows/qsv.rs`); this crate is
|
||||
//! bindings only.
|
||||
|
||||
#![allow(non_upper_case_globals)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_snake_case)]
|
||||
// Bindgen output for a C API: u128 layout warnings and the like are upstream's concern.
|
||||
#![allow(improper_ctypes)]
|
||||
// Generated code — clippy findings in it (missing safety docs on generated unsafe fns, style
|
||||
// nits across 14k lines) are bindgen's shape, not ours; the safe wrapper in pf-encode is the
|
||||
// linted surface.
|
||||
#![allow(clippy::all)]
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||
|
||||
#[cfg(all(test, target_os = "windows"))]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// Link sanity: the static dispatcher resolves and its loader spins up
|
||||
/// without an Intel driver present (enumeration may find zero
|
||||
/// implementations — that's fine, MFXLoad itself must still succeed).
|
||||
#[test]
|
||||
fn dispatcher_links_and_loads() {
|
||||
unsafe {
|
||||
let loader = MFXLoad();
|
||||
assert!(!loader.is_null(), "MFXLoad returned NULL");
|
||||
MFXUnload(loader);
|
||||
}
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
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.
|
||||
@@ -0,0 +1,14 @@
|
||||
Upstream: https://github.com/intel/libvpl
|
||||
Pin: 674d015bcb294bc39fa276e99a652ea045423e82 (v2.17.0 per version.txt, 2026-07)
|
||||
License: MIT (LICENSE; third-party notices in third-party-programs.txt)
|
||||
|
||||
Trimmed vendor tree: only what the static dispatcher build + bindgen need.
|
||||
Dropped from upstream: examples/, doc/, env/, script/, tools, api/strings/,
|
||||
api/tests/, libvpl/test/, top-level CMakeLists.txt (replaced by the crate-root
|
||||
CMakeLists.txt one level up, which pins BUILD_SHARED_LIBS=OFF, all INSTALL_*
|
||||
off, BUILD_EXPERIMENTAL=ON).
|
||||
|
||||
BUILD_EXPERIMENTAL=ON defines ONEVPL_EXPERIMENTAL: the D3D11 surface-import
|
||||
API (mfxMemoryInterface / mfxSurfaceD3D11Tex2D) is experimental ABI that is
|
||||
release-coupled — bumping this pin requires re-checking every ONEVPL_EXPERIMENTAL
|
||||
symbol qsv.rs touches (design/native-qsv-encoder.md §3.1/§3.4).
|
||||
@@ -0,0 +1,41 @@
|
||||
# ##############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
# ##############################################################################
|
||||
|
||||
cmake_minimum_required(VERSION 3.13.0)
|
||||
|
||||
set(VPL_API_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
if(DEFINED ENV{ONEVPL_API_HEADER_DIRECTORY})
|
||||
set(VPL_API_INCLUDE_DIR $ENV{ONEVPL_API_HEADER_DIRECTORY})
|
||||
message(STATUS "Using custom API header directory: ${VPL_API_INCLUDE_DIR}")
|
||||
endif()
|
||||
|
||||
# get API version
|
||||
file(READ ${VPL_API_INCLUDE_DIR}/vpl/mfxdefs.h mfxdefs)
|
||||
|
||||
string(REGEX MATCH "MFX_VERSION_MAJOR ([0-9]*)" _ ${mfxdefs})
|
||||
set(API_VERSION_MAJOR ${CMAKE_MATCH_1})
|
||||
set(API_VERSION_MAJOR
|
||||
${API_VERSION_MAJOR}
|
||||
PARENT_SCOPE)
|
||||
|
||||
string(REGEX MATCH "MFX_VERSION_MINOR ([0-9]*)" _ ${mfxdefs})
|
||||
set(API_VERSION_MINOR ${CMAKE_MATCH_1})
|
||||
set(API_VERSION_MINOR
|
||||
${API_VERSION_MINOR}
|
||||
PARENT_SCOPE)
|
||||
|
||||
message(STATUS "API version: ${API_VERSION_MAJOR}.${API_VERSION_MINOR}")
|
||||
add_library(vpl-api INTERFACE)
|
||||
|
||||
target_include_directories(vpl-api INTERFACE ${VPL_API_INCLUDE_DIR})
|
||||
|
||||
if(INSTALL_DEV)
|
||||
install(
|
||||
DIRECTORY ${VPL_API_INCLUDE_DIR}/vpl
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
COMPONENT ${VPL_COMPONENT_DEV})
|
||||
endif()
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*############################################################################
|
||||
# Copyright Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#ifndef __MFX_H__
|
||||
#define __MFX_H__
|
||||
|
||||
#include "mfxdefs.h"
|
||||
#include "mfxcommon.h"
|
||||
#include "mfxstructures.h"
|
||||
#include "mfxdispatcher.h"
|
||||
#include "mfximplcaps.h"
|
||||
#include "mfxsession.h"
|
||||
#include "mfxvideo.h"
|
||||
#include "mfxadapter.h"
|
||||
|
||||
#include "mfxbrc.h"
|
||||
#include "mfxmvc.h"
|
||||
#include "mfxpcp.h"
|
||||
#include "mfxvp8.h"
|
||||
#include "mfxjpeg.h"
|
||||
|
||||
#include "mfxsurfacepool.h"
|
||||
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
#include "mfxencodestats.h"
|
||||
#endif
|
||||
|
||||
#endif /* __MFXDEFS_H__ */
|
||||
@@ -0,0 +1,85 @@
|
||||
/*############################################################################
|
||||
# Copyright Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#include "mfxdefs.h"
|
||||
#ifndef __MFXADAPTER_H__
|
||||
#define __MFXADAPTER_H__
|
||||
|
||||
#include "mfxstructures.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@brief
|
||||
Returns a list of adapters that are suitable to handle workload @p input_info. The list is sorted in priority order, with iGPU given the highest precedence.
|
||||
This rule may change in the future. If the @p input_info pointer is NULL, the list of all available adapters will be returned.
|
||||
|
||||
@param[in] input_info Pointer to workload description. See mfxComponentInfo description for details.
|
||||
@param[out] adapters Pointer to output description of all suitable adapters for input workload. See mfxAdaptersInfo description for details.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE The function completed successfully. \n
|
||||
MFX_ERR_NULL_PTR
|
||||
@p input_info or adapters pointer is NULL. \n
|
||||
MFX_ERR_NOT_FOUND No suitable adapters found. \n
|
||||
MFX_WRN_OUT_OF_RANGE Not enough memory to report back entire list of adapters. In this case as many adapters as possible will be returned.
|
||||
|
||||
@since This function is available since API version 1.31.
|
||||
|
||||
@deprecated Deprecated in API version 2.9. Use MFXEnumImplementations and MFXSetConfigFilterProperty to query adapter capabilities and
|
||||
to select a suitable adapter for the input workload.
|
||||
Use MFX_DEPRECATED_OFF macro to turn off the deprecation message visualization.
|
||||
*/
|
||||
MFX_DEPRECATED mfxStatus MFX_CDECL MFXQueryAdapters(mfxComponentInfo* input_info, mfxAdaptersInfo* adapters);
|
||||
|
||||
/*!
|
||||
@brief
|
||||
Returns list of adapters that are suitable to decode the input bitstream. The list is sorted in priority order, with iGPU given the highest precedence. This rule may change in the future. This function is a simplification of MFXQueryAdapters, because bitstream is a description of the workload itself.
|
||||
|
||||
@param[in] bitstream Pointer to bitstream with input data.
|
||||
@param[in] codec_id Codec ID to determine the type of codec for the input bitstream.
|
||||
@param[out] adapters Pointer to the output list of adapters. Memory should be allocated by user. See mfxAdaptersInfo description for details.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE The function completed successfully. \n
|
||||
MFX_ERR_NULL_PTR bitstream or @p adapters pointer is NULL. \n
|
||||
MFX_ERR_NOT_FOUND No suitable adapters found. \n
|
||||
MFX_WRN_OUT_OF_RANGE Not enough memory to report back entire list of adapters. In this case as many adapters as possible will be returned.
|
||||
|
||||
@since This function is available since API version 1.31.
|
||||
|
||||
@deprecated Deprecated in API version 2.9. Use MFXEnumImplementations and MFXSetConfigFilterProperty to query adapter capabilities and
|
||||
to select a suitable adapter for the input workload.
|
||||
Use MFX_DEPRECATED_OFF macro to turn off the deprecation message visualization.
|
||||
*/
|
||||
MFX_DEPRECATED mfxStatus MFX_CDECL MFXQueryAdaptersDecode(mfxBitstream* bitstream, mfxU32 codec_id, mfxAdaptersInfo* adapters);
|
||||
|
||||
/*!
|
||||
@brief
|
||||
Returns the number of detected graphics adapters. It can be used before calling MFXQueryAdapters to determine the size of input data that the user will need to allocate.
|
||||
|
||||
@param[out] num_adapters Pointer for the output number of detected graphics adapters.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE The function completed successfully. \n
|
||||
MFX_ERR_NULL_PTR num_adapters pointer is NULL.
|
||||
|
||||
@since This function is available since API version 1.31.
|
||||
|
||||
@deprecated Deprecated in API version 2.9. Use MFXEnumImplementations and MFXSetConfigFilterProperty to query adapter capabilities and
|
||||
to select a suitable adapter for the input workload.
|
||||
Use MFX_DEPRECATED_OFF macro to turn off the deprecation message visualization.
|
||||
*/
|
||||
MFX_DEPRECATED mfxStatus MFX_CDECL MFXQueryAdaptersNumber(mfxU32* num_adapters);
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // __MFXADAPTER_H__
|
||||
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
/*############################################################################
|
||||
# Copyright Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#ifndef __MFXBRC_H__
|
||||
#define __MFXBRC_H__
|
||||
|
||||
#include "mfxstructures.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*! See the mfxExtBRC structure for details. */
|
||||
enum {
|
||||
MFX_EXTBUFF_BRC = MFX_MAKEFOURCC('E','B','R','C')
|
||||
};
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*!
|
||||
Describes frame parameters required for external BRC functions.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxU32 reserved[23];
|
||||
mfxU16 SceneChange; /*!< Frame belongs to a new scene if non zero. */
|
||||
mfxU16 LongTerm; /*!< Frame is a Long Term Reference frame if non zero. */
|
||||
mfxU32 FrameCmplx; /*!< Frame Complexity Frame spatial complexity if non zero. Zero if complexity is not available. */
|
||||
mfxU32 EncodedOrder; /*!< The frame number in a sequence of reordered frames starting from encoder Init. */
|
||||
mfxU32 DisplayOrder; /*!< The frame number in a sequence of frames in display order starting from last IDR. */
|
||||
mfxU32 CodedFrameSize; /*!< Size of the frame in bytes after encoding. */
|
||||
mfxU16 FrameType; /*!< Frame type. See FrameType enumerator for possible values. */
|
||||
mfxU16 PyramidLayer; /*!< B-pyramid or P-pyramid layer that the frame belongs to. */
|
||||
mfxU16 NumRecode; /*!< Number of recodings performed for this frame. */
|
||||
mfxU16 NumExtParam; /*!< Reserved for future use. */
|
||||
mfxExtBuffer** ExtParam;/*!< Reserved for future use. */
|
||||
} mfxBRCFrameParam;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*!
|
||||
Specifies controls for next frame encoding provided by external BRC functions.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxI32 QpY; /*!< Frame-level Luma QP. */
|
||||
mfxU32 InitialCpbRemovalDelay; /*!< See initial_cpb_removal_delay in codec standard. Ignored if no HRD control:
|
||||
mfxExtCodingOption::VuiNalHrdParameters = MFX_CODINGOPTION_OFF. Calculated by encoder if
|
||||
initial_cpb_removal_delay==0 && initial_cpb_removal_offset == 0 && HRD control is switched on. */
|
||||
mfxU32 InitialCpbRemovalOffset; /*!< See initial_cpb_removal_offset in codec standard. Ignored if no HRD control:
|
||||
mfxExtCodingOption::VuiNalHrdParameters = MFX_CODINGOPTION_OFF. Calculated by encoder if
|
||||
initial_cpb_removal_delay==0 && initial_cpb_removal_offset == 0 && HRD control is switched on. */
|
||||
mfxU32 reserved1[7];
|
||||
mfxU32 MaxFrameSize; /*!< Max frame size in bytes. Option for repack feature. Driver calls PAK until current frame size is
|
||||
less than or equal to MaxFrameSize, or number of repacking for this frame is equal to MaxNumRePak. Repack is available
|
||||
if there is driver support, MaxFrameSize !=0, and MaxNumRePak != 0. Ignored if MaxNumRePak == 0. */
|
||||
mfxU8 DeltaQP[8]; /*!< Option for repack feature. Ignored if MaxNumRePak == 0 or MaxNumRePak==0. If current
|
||||
frame size > MaxFrameSize and/or number of repacking (nRepack) for this frame <= MaxNumRePak,
|
||||
PAK is called with QP = mfxBRCFrameCtrl::QpY + Sum(DeltaQP[i]), where i = [0,nRepack].
|
||||
Non zero DeltaQP[nRepack] are ignored if nRepack > MaxNumRePak.
|
||||
If repacking feature is on ( MaxFrameSize & MaxNumRePak are not zero), it is calculated by the encoder. */
|
||||
mfxU16 MaxNumRepak; /*!< Number of possible repacks in driver if current frame size > MaxFrameSize. Ignored if MaxFrameSize==0.
|
||||
See MaxFrameSize description. Possible values are in the range of 0 to 8. */
|
||||
mfxU16 NumExtParam; /*!< Reserved for future use. */
|
||||
mfxExtBuffer** ExtParam; /*!< Reserved for future use. */
|
||||
} mfxBRCFrameCtrl;
|
||||
MFX_PACK_END()
|
||||
|
||||
/*! The BRCStatus enumerator itemizes instructions to the encoder by mfxExtBrc::Update. */
|
||||
enum {
|
||||
MFX_BRC_OK = 0, /*!< CodedFrameSize is acceptable, no further recoding/padding/skip required, proceed to next frame. */
|
||||
MFX_BRC_BIG_FRAME = 1, /*!< Coded frame is too big, recoding required. */
|
||||
MFX_BRC_SMALL_FRAME = 2, /*!< Coded frame is too small, recoding required. */
|
||||
MFX_BRC_PANIC_BIG_FRAME = 3, /*!< Coded frame is too big, no further recoding possible - skip frame. */
|
||||
MFX_BRC_PANIC_SMALL_FRAME = 4 /*!< Coded frame is too small, no further recoding possible - required padding to mfxBRCFrameStatus::MinFrameSize. */
|
||||
};
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*!
|
||||
Specifies instructions for the encoder provided by external BRC after each frame encoding. See the BRCStatus enumerator for details.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxU32 MinFrameSize; /*!< Size in bytes, coded frame must be padded to when Status = MFX_BRC_PANIC_SMALL_FRAME. */
|
||||
mfxU16 BRCStatus; /*!< BRC status. See the BRCStatus enumerator for possible values. */
|
||||
mfxU16 reserved[25];
|
||||
mfxHDL reserved1;
|
||||
} mfxBRCFrameStatus;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*!
|
||||
Contains a set of callbacks to perform external bitrate control. Can be attached to the mfxVideoParam structure during
|
||||
encoder initialization. Set the mfxExtCodingOption2::ExtBRC option to ON to make the encoder use the external BRC instead of the native one.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_BRC. */
|
||||
|
||||
mfxU32 reserved[14];
|
||||
mfxHDL pthis; /*!< Pointer to the BRC object. */
|
||||
|
||||
/*!
|
||||
@brief Initializes the BRC session according to parameters from input mfxVideoParam and attached structures. It does not modify the input mfxVideoParam and attached structures. Invoked during MFXVideoENCODE_Init.
|
||||
|
||||
@param[in] pthis Pointer to the BRC object.
|
||||
@param[in] par Pointer to the mfxVideoParam structure that was used for the encoder initialization.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE The function completed successfully. \n
|
||||
MFX_ERR_UNSUPPORTED The function detected unsupported video parameters.
|
||||
*/
|
||||
mfxStatus (MFX_CDECL *Init) (mfxHDL pthis, mfxVideoParam* par);
|
||||
|
||||
/*!
|
||||
@brief Resets BRC session according to new parameters. It does not modify the input mfxVideoParam and attached structures. Invoked during MFXVideoENCODE_Reset.
|
||||
|
||||
@param[in] pthis Pointer to the BRC object.
|
||||
@param[in] par Pointer to the mfxVideoParam structure that was used for the encoder initialization.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE The function completed successfully. \n
|
||||
MFX_ERR_UNSUPPORTED The function detected unsupported video parameters. \n
|
||||
MFX_ERR_INCOMPATIBLE_VIDEO_PARAM The function detected that the video parameters provided by the application are incompatible with
|
||||
initialization parameters. Reset requires additional memory allocation and cannot be executed.
|
||||
*/
|
||||
mfxStatus (MFX_CDECL *Reset) (mfxHDL pthis, mfxVideoParam* par);
|
||||
|
||||
/*!
|
||||
@brief Deallocates any internal resources acquired in Init for this BRC session. Invoked during MFXVideoENCODE_Close.
|
||||
|
||||
@param[in] pthis Pointer to the BRC object.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE The function completed successfully.
|
||||
*/
|
||||
mfxStatus (MFX_CDECL *Close) (mfxHDL pthis);
|
||||
|
||||
/*! @brief Returns controls (@p ctrl) to encode next frame based on info from input mfxBRCFrameParam structure (@p par) and
|
||||
internal BRC state. Invoked asynchronously before each frame encoding or recoding.
|
||||
|
||||
@param[in] pthis Pointer to the BRC object.
|
||||
@param[in] par Pointer to the mfxVideoParam structure that was used for the encoder initialization.
|
||||
@param[out] ctrl Pointer to the output mfxBRCFrameCtrl structure.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE The function completed successfully.
|
||||
*/
|
||||
mfxStatus (MFX_CDECL* GetFrameCtrl) (mfxHDL pthis, mfxBRCFrameParam* par, mfxBRCFrameCtrl* ctrl);
|
||||
|
||||
/*!
|
||||
@brief Updates internal BRC state and returns status to instruct encoder whether it should recode the previous frame,
|
||||
skip the previous frame, do padding, or proceed to next frame based on info from input mfxBRCFrameParam and mfxBRCFrameCtrl structures.
|
||||
Invoked asynchronously after each frame encoding or recoding.
|
||||
|
||||
@param[in] pthis Pointer to the BRC object.
|
||||
@param[in] par Pointer to the mfxVideoParam structure that was used for the encoder initialization.
|
||||
@param[in] ctrl Pointer to the output mfxBRCFrameCtrl structure.
|
||||
@param[in] status Pointer to the output mfxBRCFrameStatus structure.
|
||||
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE The function completed successfully.
|
||||
*/
|
||||
mfxStatus (MFX_CDECL* Update) (mfxHDL pthis, mfxBRCFrameParam* par, mfxBRCFrameCtrl* ctrl, mfxBRCFrameStatus* status);
|
||||
|
||||
mfxHDL reserved1[10];
|
||||
} mfxExtBRC;
|
||||
MFX_PACK_END()
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
+375
@@ -0,0 +1,375 @@
|
||||
/*############################################################################
|
||||
# Copyright Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
#ifndef __MFXCAMERA_H__
|
||||
#define __MFXCAMERA_H__
|
||||
|
||||
#include "mfxcommon.h"
|
||||
|
||||
|
||||
#if !defined(__GNUC__)
|
||||
#pragma warning(disable : 4201)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*!
|
||||
The ExtendedBufferID enumerator itemizes and defines identifiers (BufferId) for extended buffers in camera processing.
|
||||
The application should attach these extended buffers to the mfxVideoParam structure to configure camera processing through VideoVPP functions.
|
||||
And Implementation capabilities of camera processing features can be delivered by the function MFXQueryImplsDescription via VPP configuration
|
||||
mfxVPPDescription.
|
||||
*/
|
||||
enum {
|
||||
/*!
|
||||
This extended buffer is mandatory for camera raw accelerator initialization. See the mfxExtCamPipeControl structure for details.
|
||||
The application should attach this extended buffer to the mfxVideoParam structure to configure camera processing initialization.
|
||||
*/
|
||||
MFX_EXTBUF_CAM_PIPECONTROL = MFX_MAKEFOURCC('C', 'P', 'P', 'C'),
|
||||
/*!
|
||||
This extended buffer defines control parameters for the Camera White Balance filter algorithm. See mfxExtCamWhiteBalance structure for details.
|
||||
The application should attach this extended buffer to the mfxVideoParam structure to configure camera processing initialization.
|
||||
*/
|
||||
MFX_EXTBUF_CAM_WHITE_BALANCE = MFX_MAKEFOURCC('C', 'W', 'B', 'L'),
|
||||
/*!
|
||||
This extended buffer defines control parameters for the Camera Hot Pixel Removal filter algorithm. See mfxExtCamHotPixelRemoval structure for details.
|
||||
The application should attach this extended buffer to the mfxVideoParam structure to configure camera processing initialization.
|
||||
*/
|
||||
MFX_EXTBUF_CAM_HOT_PIXEL_REMOVAL = MFX_MAKEFOURCC('C', 'H', 'P', 'R'),
|
||||
/*!
|
||||
This extended buffer defines control parameters for the Camera Black Level Correction filter algorithm. See mfxExtCamBlackLevelCorrection structure for details.
|
||||
The application should attach this extended buffer to the mfxVideoParam structure to configure camera processing initialization.
|
||||
*/
|
||||
MFX_EXTBUF_CAM_BLACK_LEVEL_CORRECTION = MFX_MAKEFOURCC('C', 'B', 'L', 'C'),
|
||||
/*!
|
||||
This extended buffer defines control parameters for the Camera Vignette Correction filter algorithm. See mfxCamVignetteCorrectionParam structure for details.
|
||||
The application should attach this extended buffer to the mfxVideoParam structure to configure camera processing initialization.
|
||||
*/
|
||||
MFX_EXTBUF_CAM_VIGNETTE_CORRECTION = MFX_MAKEFOURCC('C', 'V', 'G', 'T'),
|
||||
/*!
|
||||
This extended buffer defines control parameters for the Camera Bayer Denoise filter algorithm. See mfxExtCamBayerDenoise structure for details.
|
||||
The application should attach this extended buffer to the mfxVideoParam structure to configure camera processing initialization.
|
||||
*/
|
||||
MFX_EXTBUF_CAM_BAYER_DENOISE = MFX_MAKEFOURCC('C', 'D', 'N', 'S'),
|
||||
/*!
|
||||
This extended buffer defines control parameters for the Camera Color Correction filter algorithm. See mfxExtCamColorCorrection3x3 structure for details.
|
||||
The application should attach this extended buffer to the mfxVideoParam structure to configure camera processing initialization.
|
||||
*/
|
||||
MFX_EXTBUF_CAM_COLOR_CORRECTION_3X3 = MFX_MAKEFOURCC('C', 'C', '3', '3'),
|
||||
/*!
|
||||
This extended buffer defines control parameters for the Camera Padding. See mfxExtCamPadding structure for details.
|
||||
The application should attach this extended buffer to the mfxVideoParam structure to configure camera processing initialization.
|
||||
*/
|
||||
MFX_EXTBUF_CAM_PADDING = MFX_MAKEFOURCC('C', 'P', 'A', 'D'),
|
||||
/*!
|
||||
This extended buffer defines control parameters for the Camera Forward Gamma Correction filter algorithm. See mfxExtCamFwdGamma structure for details.
|
||||
The application should attach this extended buffer to the mfxVideoParam structure to configure camera processing initialization.
|
||||
*/
|
||||
MFX_EXTBUF_CAM_FORWARD_GAMMA_CORRECTION =
|
||||
MFX_MAKEFOURCC('C', 'F', 'G', 'C'),
|
||||
/*!
|
||||
This extended buffer defines control parameters for the Camera Lens Geometry Distortion and Chroma Aberration Correction filter algorithm. See mfxExtCamLensGeomDistCorrection structure for details.
|
||||
The application should attach this extended buffer to the mfxVideoParam structure to configure camera processing initialization.
|
||||
*/
|
||||
MFX_EXTBUF_CAM_LENS_GEOM_DIST_CORRECTION =
|
||||
MFX_MAKEFOURCC('C', 'L', 'G', 'D'),
|
||||
/*!
|
||||
This extended buffer defines control parameters for the Camera 3DLUT filter algorithm. See mfxExtCam3DLut structure for details.
|
||||
The application should attach this extended buffer to the mfxVideoParam structure to configure camera processing initialization.
|
||||
*/
|
||||
MFX_EXTBUF_CAM_3DLUT = MFX_MAKEFOURCC('C', 'L', 'U', 'T'),
|
||||
/*!
|
||||
This extended buffer defines control parameters for the Camera Total Color Control algorithm. See mfxExtCamTotalColorControl structure for details.
|
||||
The application should attach this extended buffer to the mfxVideoParam structure to configure camera processing initialization.
|
||||
*/
|
||||
MFX_EXTBUF_CAM_TOTAL_COLOR_CONTROL = MFX_MAKEFOURCC('C', 'T', 'C', 'C'),
|
||||
/*!
|
||||
This extended buffer defines control parameters for the Camera YUV to RGB conversion algorithm. See mfxExtCamCscYuvRgb structure for details.
|
||||
The application should attach this extended buffer to the mfxVideoParam structure to configure camera processing initialization.
|
||||
*/
|
||||
MFX_EXTBUF_CAM_CSC_YUV_RGB = MFX_MAKEFOURCC('C', 'C', 'Y', 'R')
|
||||
};
|
||||
|
||||
/*!
|
||||
A enumeration that defines white balance mode.
|
||||
*/
|
||||
typedef enum {
|
||||
MFX_CAM_WHITE_BALANCE_MANUAL = 0x0001, /*!< White balance manual mode.*/
|
||||
MFX_CAM_WHITE_BALANCE_AUTO = 0x0002 /*!< White balance auto mode.*/
|
||||
} mfxCamWhiteBalanceMode;
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*!
|
||||
A hint structure that configures Camera White Balance filter.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUF_CAM_WHITE_BALANCE. */
|
||||
mfxU32 Mode; /*!< Specifies one of White Balance operation modes defined in enumeration mfxCamWhiteBalanceMode. */
|
||||
mfxF64 R; /*!< White Balance Red correction.*/
|
||||
mfxF64 G0; /*!< White Balance Green Top correction.*/
|
||||
mfxF64 B; /*!< White Balance Blue correction.*/
|
||||
mfxF64 G1; /*!< White Balance Green Bottom correction. */
|
||||
mfxU32 reserved[8]; /*!< Reserved for future extension. */
|
||||
} mfxExtCamWhiteBalance;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*!
|
||||
A hint structure that configures Camera Total Color Control filter.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUF_CAM_TOTAL_COLOR_CONTROL. */
|
||||
mfxU16 R; /*!< Red element.*/
|
||||
mfxU16 G; /*!< Green element.*/
|
||||
mfxU16 B; /*!< Blue element.*/
|
||||
mfxU16 C; /*!< Cyan element.*/
|
||||
mfxU16 M; /*!< Magenta element.*/
|
||||
mfxU16 Y; /*!< Yellow element.*/
|
||||
mfxU16 reserved[6]; /*!< Reserved for future extension.*/
|
||||
} mfxExtCamTotalColorControl;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*!
|
||||
A hint structure that configures Camera YUV to RGB format conversion.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUF_CAM_CSC_YUV_RGB. */
|
||||
mfxF32 PreOffset[3]; /*!< Specifies offset for conversion from full range RGB input to limited range YUV for input color coordinate.*/
|
||||
mfxF32 Matrix[3][3]; /*!< Specifies conversion matrix with CSC coefficients.*/
|
||||
mfxF32 PostOffset[3]; /*!< Specifies offset for conversion from full range RGB input to limited range YUV for output color coordinate.*/
|
||||
mfxU16 reserved[30]; /*!< Reserved for future extension.*/
|
||||
} mfxExtCamCscYuvRgb;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*!
|
||||
A hint structure that configures Camera Hot Pixel Removal filter.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUF_CAM_HOT_PIXEL_REMOVAL. */
|
||||
mfxU16 PixelThresholdDifference; /*!< Threshold for Hot Pixel difference. */
|
||||
mfxU16 PixelCountThreshold; /*!< Count pixel detection.*/
|
||||
mfxU16 reserved[32]; /*!< Reserved for future extension.*/
|
||||
} mfxExtCamHotPixelRemoval;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
typedef struct {
|
||||
/*!
|
||||
A hint structure that configures Camera black level correction.
|
||||
*/
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUF_CAM_BLACK_LEVEL_CORRECTION. */
|
||||
mfxU16 R; /*!< Black Level Red correction.*/
|
||||
mfxU16 G0; /*!< Black Level Green Top correction.*/
|
||||
mfxU16 B; /*!< Black Level Blue correction.*/
|
||||
mfxU16 G1; /*!< Black Level Green Bottom correction.*/
|
||||
mfxU32 reserved[4]; /*!< Reserved for future extension.*/
|
||||
} mfxExtCamBlackLevelCorrection;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*!
|
||||
A structure that defines Camera Vignette Correction Element.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxU8 integer; /*!< Integer part of correction element.*/
|
||||
mfxU8 mantissa; /*!< Fractional part of correction element.*/
|
||||
mfxU8 reserved[6]; /*!< Reserved for future extension.*/
|
||||
} mfxCamVignetteCorrectionElement;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*!
|
||||
A structure that defines Camera Vignette Correction Parameters.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxCamVignetteCorrectionElement R; /*!< Red correction element.*/
|
||||
mfxCamVignetteCorrectionElement G0; /*!< Green top correction element.*/
|
||||
mfxCamVignetteCorrectionElement B; /*!< Blue Correction element.*/
|
||||
mfxCamVignetteCorrectionElement G1; /*!< Green bottom correction element.*/
|
||||
mfxU32 reserved[4]; /*!< Reserved for future extension.*/
|
||||
} mfxCamVignetteCorrectionParam;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*!
|
||||
A hint structure that configures Camera Vignette Correction filter.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUF_CAM_VIGNETTE_CORRECTION. */
|
||||
mfxU32 Width; /*!< Width of Correction Map 2D buffer in mfxCamVignetteCorrectionParam elements. */
|
||||
mfxU32 Height; /*!< Height of Correction Map 2D buffer in mfxCamVignetteCorrectionParam elements. */
|
||||
mfxU32 Pitch; /*!< Pitch of Correction Map 2D buffer in mfxCamVignetteCorrectionParam elements. */
|
||||
mfxU32 reserved[7]; /*!< Reserved for future extension.*/
|
||||
|
||||
union {
|
||||
mfxCamVignetteCorrectionParam* CorrectionMap; /*!< 2D buffer of mfxCamVignetteCorrectionParam elements.*/
|
||||
mfxU64 reserved1; /*!< Reserved for alignment on 32bit and 64bit.*/
|
||||
};
|
||||
} mfxExtCamVignetteCorrection;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*!
|
||||
A hint structure that configures Camera Bayer denoise filter.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUF_CAM_BAYER_DENOISE. */
|
||||
mfxU16 Threshold; /*!< Level of denoise, legal values: [0:63].*/
|
||||
mfxU16 reserved[27]; /*!< Reserved for future extension.*/
|
||||
} mfxExtCamBayerDenoise;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
|
||||
/*!
|
||||
A hint structure that configures Camera Color correction filter.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUF_CAM_COLOR_CORRECTION_3X3. */
|
||||
mfxF32 CCM[3][3]; /*!< 3x3 dimension matrix providing RGB Color Correction coefficients.*/
|
||||
mfxU32 reserved[32]; /*!< Reserved for future extension.*/
|
||||
} mfxExtCamColorCorrection3x3;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*!
|
||||
A hint structure that configures Camera Padding.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUF_CAM_PADDING. */
|
||||
mfxU16 Top; /*!< Specify number of padded columns respectively. Currently only 8 pixels supported for all dimensions. */
|
||||
mfxU16 Bottom; /*!< Specify number of padded columns respectively. Currently only 8 pixels supported for all dimensions. */
|
||||
mfxU16 Left; /*!< Specify number of padded rows respectively. Currently only 8 pixels supported for all dimensions. */
|
||||
mfxU16 Right; /*!< Specify number of padded rows respectively. Currently only 8 pixels supported for all dimensions. */
|
||||
mfxU32 reserved[4]; /*!< Reserved for future extension.*/
|
||||
} mfxExtCamPadding;
|
||||
MFX_PACK_END()
|
||||
|
||||
/*!
|
||||
A enumeration that defines Bayer mode.
|
||||
*/
|
||||
typedef enum {
|
||||
/*!
|
||||
Pixel Representation BG
|
||||
GR.
|
||||
*/
|
||||
MFX_CAM_BAYER_BGGR = 0x0000,
|
||||
/*!
|
||||
Pixel Representation RG
|
||||
GB.
|
||||
*/
|
||||
MFX_CAM_BAYER_RGGB = 0x0001,
|
||||
/*!
|
||||
Pixel Representation GB
|
||||
RG.
|
||||
*/
|
||||
MFX_CAM_BAYER_GBRG = 0x0002,
|
||||
/*!
|
||||
Pixel Representation GR
|
||||
BG.
|
||||
*/
|
||||
MFX_CAM_BAYER_GRBG = 0x0003
|
||||
} mfxCamBayerFormat;
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*!
|
||||
A hint structure that configures camera pipe control.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUF_CAM_PIPECONTROL. */
|
||||
mfxU16 RawFormat; /*!< Specifies one of the four Bayer patterns defined in mfxCamBayerFormat enumeration. */
|
||||
mfxU16 reserved1; /*!< Reserved for future extension.*/
|
||||
mfxU32 reserved[5]; /*!< Reserved for future extension.*/
|
||||
} mfxExtCamPipeControl;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*!
|
||||
A structure that specifies forward gamma segment.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxU16 Pixel; /*!< Pixel value.*/
|
||||
mfxU16 Red; /*!< Corrected Red value.*/
|
||||
mfxU16 Green; /*!< Corrected Green value.*/
|
||||
mfxU16 Blue; /*!< Corrected Blue value.*/
|
||||
} mfxCamFwdGammaSegment;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
|
||||
/*!
|
||||
A hint structure that configures Camera Forward Gamma Correction filter.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUF_CAM_FORWARD_GAMMA_CORRECTION. */
|
||||
|
||||
mfxU16 reserved[19]; /*!< Reserved for future extension.*/
|
||||
mfxU16 NumSegments; /*!< Number of Gamma segments.*/
|
||||
union {
|
||||
mfxCamFwdGammaSegment* Segment; /*!< Pointer to Gamma segments array.*/
|
||||
mfxU64 reserved1; /*!< Reserved for future extension.*/
|
||||
};
|
||||
} mfxExtCamFwdGamma;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*!
|
||||
A hint structure that configures Camera Lens Geometry Distortion and Chroma Aberration Correction filter.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxExtBuffer
|
||||
Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUF_CAM_LENS_GEOM_DIST_CORRECTION. */
|
||||
|
||||
mfxF32 a[3]; /*!< Polynomial coefficients a for R/G/B*/
|
||||
mfxF32 b[3]; /*!< Polynomial coefficients b for R/G/B*/
|
||||
mfxF32 c[3]; /*!< Polynomial coefficients c for R/G/B*/
|
||||
mfxF32 d[3]; /*!< Polynomial coefficients d for R/G/B*/
|
||||
mfxU16 reserved[36]; /*!< Reserved for future extension.*/
|
||||
} mfxExtCamLensGeomDistCorrection;
|
||||
MFX_PACK_END()
|
||||
|
||||
/*!
|
||||
A enumeration that defines 3DLUT size.
|
||||
*/
|
||||
enum {
|
||||
MFX_CAM_3DLUT17_SIZE = (17 * 17 * 17), /*!< 17^3 LUT size*/
|
||||
MFX_CAM_3DLUT33_SIZE = (33 * 33 * 33), /*!< 33^3 LUT size*/
|
||||
MFX_CAM_3DLUT65_SIZE = (65 * 65 * 65) /*!< 65^3 LUT size*/
|
||||
};
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*!
|
||||
A structure that defines 3DLUT entry.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxU16 R; /*!< R channel*/
|
||||
mfxU16 G; /*!< G channel*/
|
||||
mfxU16 B; /*!< B channel*/
|
||||
mfxU16 Reserved; /*!< Reserved for future extension.*/
|
||||
} mfxCam3DLutEntry;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
|
||||
/*!
|
||||
A hint structure that configures Camera 3DLUT filter.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUF_CAM_3DLUT. */
|
||||
|
||||
mfxU16 reserved[10]; /*!< Reserved for future extension.*/
|
||||
mfxU32 Size; /*!< LUT size, defined in MFX_CAM_3DLUT17/33/65_SIZE enumeration.*/
|
||||
union {
|
||||
mfxCam3DLutEntry* Table; /*!< Pointer to mfxCam3DLutEntry, size of each dimension depends on LUT size, e.g. LUT[17][17][17] for 17x17x17 look up table.*/
|
||||
mfxU64 reserved1; /*!< Reserved for future extension.*/
|
||||
};
|
||||
} mfxExtCam3DLut;
|
||||
MFX_PACK_END()
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // __MFXCAMERA_H__
|
||||
+740
@@ -0,0 +1,740 @@
|
||||
/*############################################################################
|
||||
# Copyright Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#ifndef __MFXCOMMON_H__
|
||||
#define __MFXCOMMON_H__
|
||||
#include "mfxdefs.h"
|
||||
|
||||
#if !defined (__GNUC__)
|
||||
#pragma warning(disable: 4201)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define MFX_MAKEFOURCC(A,B,C,D) ((((int)A))+(((int)B)<<8)+(((int)C)<<16)+(((int)D)<<24))
|
||||
|
||||
/* Extended Configuration Header Structure */
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*! The common header definition for external buffers and video
|
||||
processing hints. */
|
||||
typedef struct {
|
||||
mfxU32 BufferId; /*!< Identifier of the buffer content. See the ExtendedBufferID enumerator for a complete list of extended buffers. */
|
||||
mfxU32 BufferSz; /*!< Size of the buffer. */
|
||||
} mfxExtBuffer;
|
||||
MFX_PACK_END()
|
||||
|
||||
|
||||
#define MFX_REFINTERFACE_VERSION MFX_STRUCT_VERSION(1, 0)
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*! The structure represents reference counted interface structure.
|
||||
The memory is allocated and released by the implementation.
|
||||
*/
|
||||
typedef struct mfxRefInterface {
|
||||
mfxHDL Context; /*!< The context of the container interface. User should not touch (change, set, null) this pointer. */
|
||||
mfxStructVersion Version; /*!< The version of the structure. */
|
||||
/*! @brief
|
||||
Increments the internal reference counter of the container. The container is not destroyed until the container
|
||||
is released using the mfxRefInterface::Release function.
|
||||
mfxRefInterface::AddRef should be used each time a new link to the container is created
|
||||
(for example, copy structure) for proper management.
|
||||
|
||||
@param[in] ref_interface Valid interface.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE If no error. \n
|
||||
MFX_ERR_NULL_PTR If interface is NULL. \n
|
||||
MFX_ERR_INVALID_HANDLE If mfxRefInterface->Context is invalid (for example NULL). \n
|
||||
MFX_ERR_UNKNOWN Any internal error.
|
||||
|
||||
*/
|
||||
mfxStatus (MFX_CDECL *AddRef)(struct mfxRefInterface* ref_interface);
|
||||
/*! @brief
|
||||
Decrements the internal reference counter of the container. mfxRefInterface::Release should be called after using the
|
||||
mfxRefInterface::AddRef function to add a container or when allocation logic requires it.
|
||||
|
||||
@param[in] ref_interface Valid interface.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE If no error. \n
|
||||
MFX_ERR_NULL_PTR If interface is NULL. \n
|
||||
MFX_ERR_INVALID_HANDLE If mfxRefInterface->Context is invalid (for example NULL). \n
|
||||
MFX_ERR_UNDEFINED_BEHAVIOR If Reference Counter of container is zero before call. \n
|
||||
MFX_ERR_UNKNOWN Any internal error.
|
||||
*/
|
||||
mfxStatus (MFX_CDECL *Release)(struct mfxRefInterface* ref_interface);
|
||||
/*! @brief
|
||||
Returns current reference counter of mfxRefInterface structure.
|
||||
|
||||
@param[in] ref_interface Valid interface.
|
||||
@param[out] counter Sets counter to the current reference counter value.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE If no error. \n
|
||||
MFX_ERR_NULL_PTR If interface or counter is NULL. \n
|
||||
MFX_ERR_INVALID_HANDLE If mfxRefInterface->Context is invalid (for example NULL). \n
|
||||
MFX_ERR_UNKNOWN Any internal error.
|
||||
*/
|
||||
mfxStatus (MFX_CDECL *GetRefCounter)(struct mfxRefInterface* ref_interface, mfxU32* counter);
|
||||
mfxHDL reserved[4];
|
||||
|
||||
}mfxRefInterface;
|
||||
MFX_PACK_END()
|
||||
|
||||
/* Library initialization and deinitialization */
|
||||
/*!
|
||||
This enumerator itemizes implementation types.
|
||||
The implementation type is a bit OR'ed value of the base type and any decorative flags.
|
||||
@note This enumerator is for legacy dispatcher compatibility only. The new dispatcher does not use it.
|
||||
*/
|
||||
typedef mfxI32 mfxIMPL;
|
||||
/*!
|
||||
The application can use the macro MFX_IMPL_BASETYPE(x) to obtain the base implementation type.
|
||||
*/
|
||||
#define MFX_IMPL_BASETYPE(x) (0x00ff & (x))
|
||||
|
||||
enum {
|
||||
MFX_IMPL_AUTO = 0x0000, /*!< Auto Selection/In or Not Supported/Out. */
|
||||
MFX_IMPL_SOFTWARE = 0x0001, /*!< Pure software implementation. */
|
||||
MFX_IMPL_HARDWARE = 0x0002, /*!< Hardware accelerated implementation (default device). */
|
||||
MFX_IMPL_AUTO_ANY = 0x0003, /*!< Auto selection of any hardware/software implementation. */
|
||||
MFX_IMPL_HARDWARE_ANY = 0x0004, /*!< Auto selection of any hardware implementation. */
|
||||
MFX_IMPL_HARDWARE2 = 0x0005, /*!< Hardware accelerated implementation (2nd device). */
|
||||
MFX_IMPL_HARDWARE3 = 0x0006, /*!< Hardware accelerated implementation (3rd device). */
|
||||
MFX_IMPL_HARDWARE4 = 0x0007, /*!< Hardware accelerated implementation (4th device). */
|
||||
MFX_IMPL_RUNTIME = 0x0008, /*!< This value cannot be used for session initialization. It may be returned by the MFXQueryIMPL
|
||||
function to show that the session has been initialized in run-time mode. */
|
||||
MFX_IMPL_VIA_ANY = 0x0100, /*!< Hardware acceleration can go through any supported OS infrastructure. This is the default value. The default value
|
||||
is used by the legacy Intel(r) Media SDK if none of the MFX_IMPL_VIA_xxx flags are specified by the application. */
|
||||
MFX_IMPL_VIA_D3D9 = 0x0200, /*!< Hardware acceleration goes through the Microsoft* Direct3D* 9 infrastructure. */
|
||||
MFX_IMPL_VIA_D3D11 = 0x0300, /*!< Hardware acceleration goes through the Microsoft* Direct3D* 11 infrastructure. */
|
||||
MFX_IMPL_VIA_VAAPI = 0x0400, /*!< Hardware acceleration goes through the Linux* VA-API infrastructure. */
|
||||
MFX_IMPL_VIA_HDDLUNITE = 0x0500, /*!< Hardware acceleration goes through the HDDL* Unite*. */
|
||||
|
||||
MFX_IMPL_UNSUPPORTED = 0x0000 /*!< One of the MFXQueryIMPL returns. */
|
||||
};
|
||||
|
||||
/* Version Info */
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*! The mfxVersion union describes the version of the implementation.*/
|
||||
typedef union {
|
||||
/*! @brief Structure with Major and Minor fields. */
|
||||
/*! @struct Anonymous */
|
||||
struct {
|
||||
/*! @{
|
||||
@name Major and Minor fields
|
||||
Anonymous structure with Major and Minor fields.
|
||||
*/
|
||||
mfxU16 Minor; /*!< Minor number of the implementation. */
|
||||
mfxU16 Major; /*!< Major number of the implementation. */
|
||||
/*! @} */
|
||||
};
|
||||
mfxU32 Version; /*!< Implementation version number. */
|
||||
} mfxVersion;
|
||||
MFX_PACK_END()
|
||||
|
||||
/*! The mfxPriority enumerator describes the session priority. */
|
||||
typedef enum
|
||||
{
|
||||
MFX_PRIORITY_LOW = 0, /*!< Low priority: the session operation halts when high priority tasks are executing and more than 75% of the CPU is being used for normal priority tasks.*/
|
||||
MFX_PRIORITY_NORMAL = 1, /*!< Normal priority: the session operation is halted if there are high priority tasks.*/
|
||||
MFX_PRIORITY_HIGH = 2 /*!< High priority: the session operation blocks other lower priority session operations.*/
|
||||
|
||||
} mfxPriority;
|
||||
|
||||
typedef struct _mfxEncryptedData mfxEncryptedData;
|
||||
MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
|
||||
/*! Defines the buffer that holds compressed video data. */
|
||||
typedef struct {
|
||||
/*! @internal :unnamed(union) @endinternal */
|
||||
union {
|
||||
struct {
|
||||
mfxEncryptedData* EncryptedData; /*!< Reserved and must be zero. */
|
||||
mfxExtBuffer **ExtParam; /*!< Array of extended buffers for additional bitstream configuration. See the ExtendedBufferID enumerator for a complete list of extended buffers. */
|
||||
mfxU16 NumExtParam; /*!< The number of extended buffers attached to this structure. */
|
||||
mfxU16 reserved1; /*!< Reserved for future use. */
|
||||
mfxU32 CodecId; /*!< Specifies the codec format identifier in the FourCC code. See the CodecFormatFourCC enumerator for details. This optional parameter is required for the simplified decode initialization. */
|
||||
|
||||
};
|
||||
mfxU32 reserved[6];
|
||||
};
|
||||
/*! Decode time stamp of the compressed bitstream in units of 90KHz. A value of MFX_TIMESTAMP_UNKNOWN indicates that there is no time stamp.
|
||||
|
||||
This value is calculated by the encoder from the presentation time stamp provided by the application in the mfxFrameSurface1 structure and
|
||||
from the frame rate provided by the application during the encoder initialization. */
|
||||
mfxI64 DecodeTimeStamp;
|
||||
mfxU64 TimeStamp; /*!< Time stamp of the compressed bitstream in units of 90KHz. A value of MFX_TIMESTAMP_UNKNOWN indicates that there is no time stamp. */
|
||||
mfxU8* Data; /*!< Bitstream buffer pointer, 32-bytes aligned. */
|
||||
mfxU32 DataOffset; /*!< Next reading or writing position in the bitstream buffer. */
|
||||
mfxU32 DataLength; /*!< Size of the actual bitstream data in bytes. */
|
||||
mfxU32 MaxLength; /*!< Allocated bitstream buffer size in bytes. */
|
||||
|
||||
mfxU16 PicStruct; /*!< Type of the picture in the bitstream. Output parameter. */
|
||||
mfxU16 FrameType; /*!< Frame type of the picture in the bitstream. Output parameter. */
|
||||
mfxU16 DataFlag; /*!< Indicates additional bitstream properties. See the BitstreamDataFlag enumerator for details. */
|
||||
mfxU16 reserved2; /*!< Reserved for future use. */
|
||||
} mfxBitstream;
|
||||
MFX_PACK_END()
|
||||
|
||||
/*! Synchronization point object handle. */
|
||||
typedef struct _mfxSyncPoint *mfxSyncPoint;
|
||||
|
||||
/*! The GPUCopy enumerator controls usage of GPU accelerated copying between video and system memory in the legacy Intel(r) Media SDK components. */
|
||||
enum {
|
||||
MFX_GPUCOPY_DEFAULT = 0, /*!< Use default mode for the legacy Intel(r) Media SDK implementation. */
|
||||
MFX_GPUCOPY_ON = 1, /*!< The hint to enable GPU accelerated copying when it is supported by the library.
|
||||
If the library doesn't support GPU accelerated copy the operation will be made by CPU.
|
||||
Buffer caching usage decision is up to runtime to decide, for explicit hints please use MFX_GPUCOPY_SAFE or MFX_GPUCOPY_FAST */
|
||||
MFX_GPUCOPY_OFF = 2, /*!< Disable GPU accelerated copying. */
|
||||
MFX_GPUCOPY_SAFE = 3, /*!< The hint to disable buffer caching for GPU accelerated copying. Actual when GPU accelerated copying is supported by the library. */
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
MFX_GPUCOPY_FAST = 4 /*!< The hint to enable buffer caching for GPU accelerated copying. Actual when GPU accelerated copying is supported by the library. */
|
||||
#endif
|
||||
};
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*! Specifies advanced initialization parameters.
|
||||
A zero value in any of the fields indicates that the corresponding field
|
||||
is not explicitly specified.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxIMPL Implementation; /*!< Enumerator that indicates the desired legacy Intel(r) Media SDK implementation. */
|
||||
mfxVersion Version; /*!< Structure which specifies minimum library version or zero, if not specified. */
|
||||
mfxU16 ExternalThreads; /*!< Desired threading mode. Value 0 means internal threading, 1 - external. */
|
||||
/*! @internal :unnamed(union) @endinternal */
|
||||
union {
|
||||
struct {
|
||||
mfxExtBuffer **ExtParam; /*!< Points to an array of pointers to the extra configuration structures; see the ExtendedBufferID enumerator for a list of extended configurations. */
|
||||
mfxU16 NumExtParam; /*!< The number of extra configuration structures attached to this structure. */
|
||||
};
|
||||
mfxU16 reserved2[5];
|
||||
};
|
||||
mfxU16 GPUCopy; /*!< Enables or disables GPU accelerated copying between video and system memory in legacy Intel(r) Media SDK components. See the GPUCopy enumerator for a list of valid values. */
|
||||
mfxU16 reserved[21];
|
||||
} mfxInitParam;
|
||||
MFX_PACK_END()
|
||||
|
||||
enum {
|
||||
MFX_EXTBUFF_THREADS_PARAM = MFX_MAKEFOURCC('T','H','D','P') /*!< mfxExtThreadsParam buffer ID. */
|
||||
};
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*! Specifies options for threads created by this session. Attached to the
|
||||
mfxInitParam structure during legacy Intel(r) Media SDK session initialization
|
||||
or to mfxInitializationParam by the dispatcher in MFXCreateSession function. */
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_THREADS_PARAM. */
|
||||
|
||||
mfxU16 NumThread; /*!< The number of threads. */
|
||||
mfxI32 SchedulingType; /*!< Scheduling policy for all threads.*/
|
||||
mfxI32 Priority; /*!< Priority for all threads. */
|
||||
mfxU16 reserved[55]; /*!< Reserved for future use. */
|
||||
} mfxExtThreadsParam;
|
||||
MFX_PACK_END()
|
||||
|
||||
/*! Deprecated. */
|
||||
enum {
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_UNKNOWN) = 0, /*!< Unknown platform. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_SANDYBRIDGE) = 1, /*!< Intel(r) microarchitecture code name Sandy Bridge. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_IVYBRIDGE) = 2, /*!< Intel(r) microarchitecture code name Ivy Bridge. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_HASWELL) = 3, /*!< Code name Haswell. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_BAYTRAIL) = 4, /*!< Code name Bay Trail. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_BROADWELL) = 5, /*!< Intel(r) microarchitecture code name Broadwell. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_CHERRYTRAIL) = 6, /*!< Code name Cherry Trail. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_SKYLAKE) = 7, /*!< Intel(r) microarchitecture code name Skylake. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_APOLLOLAKE) = 8, /*!< Code name Apollo Lake. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_KABYLAKE) = 9, /*!< Code name Kaby Lake. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_GEMINILAKE) = 10, /*!< Code name Gemini Lake. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_COFFEELAKE) = 11, /*!< Code name Coffee Lake. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_CANNONLAKE) = 20, /*!< Code name Cannon Lake. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_ICELAKE) = 30, /*!< Code name Ice Lake. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_JASPERLAKE) = 32, /*!< Code name Jasper Lake. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_ELKHARTLAKE) = 33, /*!< Code name Elkhart Lake. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_TIGERLAKE) = 40, /*!< Code name Tiger Lake. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_ROCKETLAKE) = 42, /*!< Code name Rocket Lake. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_ALDERLAKE_S) = 43, /*!< Code name Alder Lake S. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_ALDERLAKE_P) = 44, /*!< Code name Alder Lake P. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_ARCTICSOUND_P) = 45,
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_XEHP_SDV) = 45, /*!< Code name XeHP SDV. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_DG2) = 46, /*!< Code name DG2. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_ATS_M) = 46, /*!< Code name ATS-M, same media functionality as DG2. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_ALDERLAKE_N) = 55, /*!< Code name Alder Lake N. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_KEEMBAY) = 50, /*!< Code name Keem Bay. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_METEORLAKE) = 51, /*!< Code name Meteor Lake. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_BATTLEMAGE) = 52, /*!< Code name Battlemage. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_LUNARLAKE) = 53, /*!< Code name Lunar Lake. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_ARROWLAKE) = 54, /*!< Code name Arrow Lake. */
|
||||
MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLATFORM_MAXIMUM) = 65535, /*!< General code name. */
|
||||
};
|
||||
|
||||
/*! The mfxMediaAdapterType enumerator itemizes types of graphics adapters. */
|
||||
typedef enum
|
||||
{
|
||||
MFX_MEDIA_UNKNOWN = 0xffff, /*!< Unknown type. */
|
||||
MFX_MEDIA_INTEGRATED = 0, /*!< Integrated graphics adapter. */
|
||||
MFX_MEDIA_DISCRETE = 1 /*!< Discrete graphics adapter. */
|
||||
} mfxMediaAdapterType;
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*! Contains information about hardware platform for the Legacy mode. */
|
||||
typedef struct {
|
||||
MFX_DEPRECATED mfxU16 CodeName; /*!< Deprecated. */
|
||||
mfxU16 DeviceId; /*!< Unique identifier of graphics device. */
|
||||
mfxU16 MediaAdapterType; /*!< Description of graphics adapter type. See the mfxMediaAdapterType enumerator for a list of possible values. */
|
||||
mfxU16 reserved[13]; /*!< Reserved for future use. */
|
||||
} mfxPlatform;
|
||||
MFX_PACK_END()
|
||||
|
||||
|
||||
/*! The mfxResourceType enumerator specifies types of different native data frames and buffers. */
|
||||
typedef enum {
|
||||
MFX_RESOURCE_SYSTEM_SURFACE = 1, /*!< System memory. */
|
||||
MFX_RESOURCE_VA_SURFACE_PTR = 2, /*!< Pointer to VA surface index. */
|
||||
MFX_RESOURCE_VA_SURFACE = MFX_RESOURCE_VA_SURFACE_PTR, /*!< Pointer to VA surface index. */
|
||||
MFX_RESOURCE_VA_BUFFER_PTR = 3, /*!< Pointer to VA buffer index. */
|
||||
MFX_RESOURCE_VA_BUFFER = MFX_RESOURCE_VA_BUFFER_PTR, /*!< Pointer to VA buffer index. */
|
||||
MFX_RESOURCE_DX9_SURFACE = 4, /*!< Pointer to IDirect3DSurface9. */
|
||||
MFX_RESOURCE_DX11_TEXTURE = 5, /*!< Pointer to ID3D11Texture2D. */
|
||||
MFX_RESOURCE_DX12_RESOURCE = 6, /*!< Pointer to ID3D12Resource. */
|
||||
MFX_RESOURCE_DMA_RESOURCE = 7, /*!< DMA resource. */
|
||||
MFX_RESOURCE_HDDLUNITE_REMOTE_MEMORY = 8, /*!< HDDL Unite Remote memory handle. */
|
||||
} mfxResourceType;
|
||||
|
||||
/*! Maximum allowed length of the implementation name. */
|
||||
#define MFX_IMPL_NAME_LEN 32
|
||||
/*! Maximum allowed length of the implementation name. */
|
||||
#define MFX_STRFIELD_LEN 128
|
||||
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
|
||||
#define MFX_DECEXTDESCRIPTION_VERSION MFX_STRUCT_VERSION(1, 0)
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*! The mfxDecExtDescription structure represents the extended description of a decoder. */
|
||||
typedef struct {
|
||||
mfxStructVersion Version; /*!< Version of the structure. */
|
||||
mfxU16 reserved[14]; /*!< Reserved for future use. */
|
||||
mfxU16 NumExtBufferIDs; /*!< Number of supported extended buffer IDs. */
|
||||
mfxU32* ExtBufferIDs; /*!< Pointer to the array of supported extended buffer IDs. */
|
||||
} mfxDecExtDescription;
|
||||
MFX_PACK_END()
|
||||
|
||||
#define MFX_DECMEMEXTDESCRIPTION_VERSION MFX_STRUCT_VERSION(1, 0)
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*! The mfxDecMemExtDescription structure represents the extended description for decoder memory. */
|
||||
typedef struct {
|
||||
mfxStructVersion Version; /*!< Version of the structure. */
|
||||
mfxU16 reserved[13]; /*!< Reserved for future use. */
|
||||
mfxU16 MaxBitDepth; /*!< Maximum supported bit depth. */
|
||||
mfxU16 NumChromaSubsamplings; /*!< Number of supported output chroma subsamplings. */
|
||||
mfxU16* ChromaSubsamplings; /*!< Pointer to the array of supported output chroma subsamplings. */
|
||||
} mfxDecMemExtDescription;
|
||||
MFX_PACK_END()
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
#define MFX_DECODERDESCRIPTION_VERSION MFX_STRUCT_VERSION(1, 1)
|
||||
#else
|
||||
#define MFX_DECODERDESCRIPTION_VERSION MFX_STRUCT_VERSION(1, 0)
|
||||
#endif
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*! The mfxDecoderDescription structure represents the description of a decoder. */
|
||||
typedef struct {
|
||||
mfxStructVersion Version; /*!< Version of the structure. */
|
||||
mfxU16 reserved[7]; /*!< Reserved for future use. */
|
||||
mfxU16 NumCodecs; /*!< Number of supported decoders. */
|
||||
/*! This structure represents the decoder description. */
|
||||
struct decoder {
|
||||
mfxU32 CodecID; /*!< Decoder ID in FourCC format. */
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
mfxU16 reserved[2]; /*!< Reserved for future use. */
|
||||
union {
|
||||
mfxDecExtDescription* DecExtDesc; /*!< Pointer to the extended descriptions of the decoder. */
|
||||
mfxU16 reserved2[4]; /*!< Reserved for future use. */
|
||||
};
|
||||
mfxU16 reserved3[2]; /*!< Reserved for future use. */
|
||||
#else
|
||||
mfxU16 reserved[8]; /*!< Reserved for future use. */
|
||||
#endif
|
||||
mfxU16 MaxcodecLevel; /*!< Maximum supported codec level. See the CodecProfile enumerator for possible values. */
|
||||
mfxU16 NumProfiles; /*!< Number of supported profiles. */
|
||||
/*! This structure represents the codec profile description. */
|
||||
struct decprofile {
|
||||
mfxU32 Profile; /*!< Profile ID. See the CodecProfile enumerator for possible values.*/
|
||||
mfxU16 reserved[7]; /*!< Reserved for future use. */
|
||||
mfxU16 NumMemTypes; /*!< Number of supported memory types. */
|
||||
/*! This structure represents the underlying details of the memory type. */
|
||||
struct decmemdesc {
|
||||
mfxResourceType MemHandleType; /*!< Memory handle type. */
|
||||
mfxRange32U Width; /*!< Range of supported image widths. */
|
||||
mfxRange32U Height; /*!< Range of supported image heights. */
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
mfxU16 reserved[2]; /*!< Reserved for future use. */
|
||||
union {
|
||||
mfxDecMemExtDescription* MemExtDesc; /*!< Pointer to the extended descriptions for decoder memory. */
|
||||
mfxU16 reserved2[4]; /*!< Reserved for future use. */
|
||||
};
|
||||
mfxU16 reserved3; /*!< Reserved for future use. */
|
||||
#else
|
||||
mfxU16 reserved[7]; /*!< Reserved for future use. */
|
||||
#endif
|
||||
mfxU16 NumColorFormats; /*!< Number of supported output color formats. */
|
||||
mfxU32* ColorFormats; /*!< Pointer to the array of supported output color formats (in FOURCC). */
|
||||
} * MemDesc; /*!< Pointer to the array of memory types. */
|
||||
} * Profiles; /*!< Pointer to the array of profiles supported by the codec. */
|
||||
} * Codecs; /*!< Pointer to the array of decoders. */
|
||||
} mfxDecoderDescription;
|
||||
MFX_PACK_END()
|
||||
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
|
||||
#define MFX_ENCEXTDESCRIPTION_VERSION MFX_STRUCT_VERSION(1, 0)
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*! The mfxEncExtDescription structure represents the extended description of an encoder. */
|
||||
typedef struct {
|
||||
mfxStructVersion Version; /*!< Version of the structure. */
|
||||
mfxU16 reserved[10]; /*!< Reserved for future use. */
|
||||
mfxU16 NumRateControlMethods; /*!< Number of supported bitrate control methods. */
|
||||
mfxU16* RateControlMethods; /*!< Pointer to the array of supported bitrate control methods. */
|
||||
mfxU16 reserved2[11]; /*!< Reserved for future use. */
|
||||
mfxU16 NumExtBufferIDs; /*!< Number of supported extended buffer IDs. */
|
||||
mfxU32* ExtBufferIDs; /*!< Pointer to the array of supported extended buffer IDs. */
|
||||
} mfxEncExtDescription;
|
||||
MFX_PACK_END()
|
||||
|
||||
#define MFX_ENCMEMEXTDESCRIPTION_VERSION MFX_STRUCT_VERSION(1, 0)
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*! The mfxEncMemExtDescription structure represents the extended description for encoder memory. */
|
||||
typedef struct {
|
||||
mfxStructVersion Version; /*!< Version of the structure. */
|
||||
mfxU16 reserved[13]; /*!< Reserved for future use. */
|
||||
mfxU16 TargetMaxBitDepth; /*!< Maximum supported bit depth. */
|
||||
mfxU16 NumTargetChromaSubsamplings; /*!< Number of supported target chroma subsamplings. */
|
||||
mfxU16* TargetChromaSubsamplings; /*!< Pointer to the array of supported target chroma subsamplings. */
|
||||
} mfxEncMemExtDescription;
|
||||
MFX_PACK_END()
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
#define MFX_ENCODERDESCRIPTION_VERSION MFX_STRUCT_VERSION(1, 1)
|
||||
#else
|
||||
#define MFX_ENCODERDESCRIPTION_VERSION MFX_STRUCT_VERSION(1, 0)
|
||||
#endif
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*! This structure represents an encoder description. */
|
||||
typedef struct {
|
||||
mfxStructVersion Version; /*!< Version of the structure. */
|
||||
mfxU16 reserved[7]; /*!< Reserved for future use. */
|
||||
mfxU16 NumCodecs; /*!< Number of supported encoders. */
|
||||
/*! This structure represents encoder description. */
|
||||
struct encoder {
|
||||
mfxU32 CodecID; /*!< Encoder ID in FourCC format. */
|
||||
mfxU16 MaxcodecLevel; /*!< Maximum supported codec level. See the CodecProfile enumerator for possible values. */
|
||||
mfxU16 BiDirectionalPrediction; /*!< Indicates B-frames support. */
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
union {
|
||||
mfxEncExtDescription* EncExtDesc; /*!< Pointer to the extended descriptions of the encoder. */
|
||||
mfxU16 reserved2[4]; /*!< Reserved for future use. */
|
||||
};
|
||||
mfxU16 reserved[3]; /*!< Reserved for future use. */
|
||||
#else
|
||||
mfxU16 reserved[7]; /*!< Reserved for future use. */
|
||||
#endif
|
||||
mfxU16 NumProfiles; /*!< Number of supported profiles. */
|
||||
/*! This structure represents the codec profile description. */
|
||||
struct encprofile {
|
||||
mfxU32 Profile; /*!< Profile ID. See the CodecProfile enumerator for possible values.*/
|
||||
mfxU16 reserved[7]; /*!< Reserved for future use. */
|
||||
mfxU16 NumMemTypes; /*!< Number of supported memory types. */
|
||||
/*! This structure represents the underlying details of the memory type. */
|
||||
struct encmemdesc {
|
||||
mfxResourceType MemHandleType; /*!< Memory handle type. */
|
||||
mfxRange32U Width; /*!< Range of supported image widths. */
|
||||
mfxRange32U Height; /*!< Range of supported image heights. */
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
mfxU16 reserved[2]; /*!< Reserved for future use. */
|
||||
union {
|
||||
mfxEncMemExtDescription* MemExtDesc; /*!< Pointer to the extended descriptions for encoder memory. */
|
||||
mfxU16 reserved2[4]; /*!< Reserved for future use. */
|
||||
};
|
||||
mfxU16 reserved3; /*!< Reserved for future use. */
|
||||
#else
|
||||
mfxU16 reserved[7]; /*!< Reserved for future use. */
|
||||
#endif
|
||||
mfxU16 NumColorFormats; /*!< Number of supported input color formats. */
|
||||
mfxU32* ColorFormats; /*!< Pointer to the array of supported input color formats (in FOURCC). */
|
||||
} * MemDesc; /*!< Pointer to the array of memory types. */
|
||||
} * Profiles; /*!< Pointer to the array of profiles supported by the codec. */
|
||||
} * Codecs; /*!< Pointer to the array of encoders. */
|
||||
} mfxEncoderDescription;
|
||||
MFX_PACK_END()
|
||||
|
||||
#define MFX_VPPDESCRIPTION_VERSION MFX_STRUCT_VERSION(1, 0)
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*! This structure represents VPP description. */
|
||||
typedef struct {
|
||||
mfxStructVersion Version; /*!< Version of the structure. */
|
||||
mfxU16 reserved[7]; /*!< Reserved for future use. */
|
||||
mfxU16 NumFilters; /*!< Number of supported VPP filters. */
|
||||
/*! This structure represents the VPP filters description. */
|
||||
struct filter {
|
||||
mfxU32 FilterFourCC; /*!< Filter ID in FourCC format. */
|
||||
mfxU16 MaxDelayInFrames; /*!< Introduced output delay in frames. */
|
||||
mfxU16 reserved[7]; /*!< Reserved for future use. */
|
||||
mfxU16 NumMemTypes; /*!< Number of supported memory types. */
|
||||
/*! This structure represents the underlying details of the memory type. */
|
||||
struct memdesc {
|
||||
mfxResourceType MemHandleType; /*!< Memory handle type. */
|
||||
mfxRange32U Width; /*!< Range of supported image widths. */
|
||||
mfxRange32U Height; /*!< Range of supported image heights. */
|
||||
mfxU16 reserved[7]; /*!< Reserved for future use. */
|
||||
mfxU16 NumInFormats; /*!< Number of supported input color formats. */
|
||||
/*! This structure represents the input color format description. */
|
||||
struct format {
|
||||
mfxU32 InFormat; /*!< Input color in FourCC format. */
|
||||
mfxU16 reserved[5]; /*!< Reserved for future use. */
|
||||
mfxU16 NumOutFormat; /*!< Number of supported output color formats. */
|
||||
mfxU32* OutFormats; /*!< Pointer to the array of supported output color formats (in FOURCC). */
|
||||
} * Formats; /*!< Pointer to the array of supported formats. */
|
||||
} * MemDesc; /*!< Pointer to the array of memory types. */
|
||||
} * Filters; /*!< Pointer to the array of supported filters. */
|
||||
} mfxVPPDescription;
|
||||
MFX_PACK_END()
|
||||
|
||||
/*! The current version of mfxDeviceDescription structure. */
|
||||
#define MFX_DEVICEDESCRIPTION_VERSION MFX_STRUCT_VERSION(1, 1)
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*! This structure represents device description. */
|
||||
typedef struct {
|
||||
mfxStructVersion Version; /*!< Version of the structure. */
|
||||
mfxU16 reserved[6]; /*!< reserved for future use. */
|
||||
mfxU16 MediaAdapterType; /*!< Graphics adapter type. See the mfxMediaAdapterType enumerator for a list of possible values. */
|
||||
mfxChar DeviceID[MFX_STRFIELD_LEN]; /*!< Null terminated string with device ID. */
|
||||
mfxU16 NumSubDevices; /*!< Number of available uniform sub-devices. Pure software implementation can report 0. */
|
||||
/*! This structure represents sub-device description. */
|
||||
struct subdevices {
|
||||
mfxU32 Index; /*!< Index of the sub-device, started from 0 and increased by 1.*/
|
||||
mfxChar SubDeviceID[MFX_STRFIELD_LEN]; /*!< Null terminated string with unique sub-device ID, mapped to the system ID. */
|
||||
mfxU32 reserved[7]; /*!< reserved for future use. */
|
||||
} * SubDevices; /*!< Pointer to the array of available sub-devices. */
|
||||
} mfxDeviceDescription;
|
||||
MFX_PACK_END()
|
||||
|
||||
/*! This enum itemizes implementation type. */
|
||||
typedef enum {
|
||||
MFX_IMPL_TYPE_SOFTWARE = 0x0001, /*!< Pure Software Implementation. */
|
||||
MFX_IMPL_TYPE_HARDWARE = 0x0002, /*!< Hardware Accelerated Implementation. */
|
||||
} mfxImplType;
|
||||
|
||||
/*! This enum itemizes hardware acceleration stack to use. */
|
||||
typedef enum {
|
||||
MFX_ACCEL_MODE_NA = 0, /*!< Hardware acceleration is not applicable. */
|
||||
MFX_ACCEL_MODE_VIA_D3D9 = 0x0200, /*!< Hardware acceleration goes through the Microsoft* Direct3D9* infrastructure. */
|
||||
MFX_ACCEL_MODE_VIA_D3D11 = 0x0300, /*!< Hardware acceleration goes through the Microsoft* Direct3D11* infrastructure. */
|
||||
MFX_ACCEL_MODE_VIA_VAAPI = 0x0400, /*!< Hardware acceleration goes through the Linux* VA-API infrastructure. */
|
||||
MFX_ACCEL_MODE_VIA_VAAPI_DRM_RENDER_NODE
|
||||
= MFX_ACCEL_MODE_VIA_VAAPI, /*!< Hardware acceleration goes through the Linux* VA-API infrastructure with DRM RENDER MODE as default acceleration access point. */
|
||||
MFX_ACCEL_MODE_VIA_VAAPI_DRM_MODESET = 0x0401, /*!< Hardware acceleration goes through the Linux* VA-API infrastructure with DRM MODESET as default acceleration access point. */
|
||||
MFX_ACCEL_MODE_VIA_VAAPI_GLX = 0x0402, /*!< Hardware acceleration goes through the Linux* VA-API infrastructure with OpenGL Extension to the X Window System
|
||||
as default acceleration access point. */
|
||||
MFX_ACCEL_MODE_VIA_VAAPI_X11 = 0x0403, /*!< Hardware acceleration goes through the Linux* VA-API infrastructure with X11 as default acceleration access point. */
|
||||
MFX_ACCEL_MODE_VIA_VAAPI_WAYLAND = 0x0404, /*!< Hardware acceleration goes through the Linux* VA-API infrastructure with Wayland as default acceleration access point. */
|
||||
MFX_ACCEL_MODE_VIA_HDDLUNITE = 0x0500, /*!< Hardware acceleration goes through the HDDL* Unite*. */
|
||||
} mfxAccelerationMode;
|
||||
|
||||
#define MFX_ACCELERATIONMODESCRIPTION_VERSION MFX_STRUCT_VERSION(1, 0)
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*! This structure represents acceleration modes description. */
|
||||
typedef struct {
|
||||
mfxStructVersion Version; /*!< Version of the structure. */
|
||||
mfxU16 reserved[2]; /*!< reserved for future use. */
|
||||
mfxU16 NumAccelerationModes; /*!< Number of supported acceleration modes. */
|
||||
mfxAccelerationMode* Mode; /*!< Pointer to the array of supported acceleration modes. */
|
||||
} mfxAccelerationModeDescription;
|
||||
MFX_PACK_END()
|
||||
|
||||
/*! Specifies the surface pool allocation policies. */
|
||||
typedef enum {
|
||||
/*! Recommends to limit max pool size by sum of requested surfaces asked by components. */
|
||||
MFX_ALLOCATION_OPTIMAL = 0,
|
||||
|
||||
/*! Dynamic allocation with no limit. */
|
||||
MFX_ALLOCATION_UNLIMITED = 1,
|
||||
|
||||
/*! Max pool size is limited by NumberToPreAllocate + DeltaToAllocateOnTheFly. */
|
||||
MFX_ALLOCATION_LIMITED = 2,
|
||||
|
||||
} mfxPoolAllocationPolicy;
|
||||
|
||||
/*! The current version of mfxPoolPolicyDescription structure. */
|
||||
#define MFX_POOLPOLICYDESCRIPTION_VERSION MFX_STRUCT_VERSION(1, 0)
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*! This structure represents pool policy description. */
|
||||
typedef struct {
|
||||
mfxStructVersion Version; /*!< Version of the structure. */
|
||||
mfxU16 reserved[2]; /*!< reserved for future use. */
|
||||
mfxU16 NumPoolPolicies; /*!< Number of supported pool policies. */
|
||||
mfxPoolAllocationPolicy* Policy; /*!< Pointer to the array of supported pool policies. */
|
||||
} mfxPoolPolicyDescription;
|
||||
MFX_PACK_END()
|
||||
|
||||
/*! The current version of mfxImplDescription structure. */
|
||||
#define MFX_IMPLDESCRIPTION_VERSION MFX_STRUCT_VERSION(1, 2)
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*! This structure represents the implementation description. */
|
||||
typedef struct {
|
||||
mfxStructVersion Version; /*!< Version of the structure. */
|
||||
mfxImplType Impl; /*!< Impl type: software/hardware. */
|
||||
mfxAccelerationMode AccelerationMode; /*!< Default Hardware acceleration stack to use. OS dependent parameter. Use VA for Linux* and DX* for Windows*. */
|
||||
mfxVersion ApiVersion; /*!< Supported API version. */
|
||||
mfxChar ImplName[MFX_IMPL_NAME_LEN]; /*!< Null-terminated string with implementation name given by vendor. */
|
||||
mfxChar License[MFX_STRFIELD_LEN]; /*!< Null-terminated string with comma-separated list of license names of the implementation. */
|
||||
mfxChar Keywords[MFX_STRFIELD_LEN]; /*!< Null-terminated string with comma-separated list of keywords specific to this implementation that dispatcher can search for. */
|
||||
mfxU32 VendorID; /*!< Standard vendor ID 0x8086 - Intel. */
|
||||
mfxU32 VendorImplID; /*!< Vendor specific number with given implementation ID. */
|
||||
mfxDeviceDescription Dev; /*!< Supported device. */
|
||||
mfxDecoderDescription Dec; /*!< Decoder configuration. */
|
||||
mfxEncoderDescription Enc; /*!< Encoder configuration. */
|
||||
mfxVPPDescription VPP; /*!< VPP configuration. */
|
||||
union
|
||||
{
|
||||
mfxAccelerationModeDescription AccelerationModeDescription; /*!< Supported acceleration modes. */
|
||||
mfxU32 reserved3[4];
|
||||
};
|
||||
mfxPoolPolicyDescription PoolPolicies; /*!< Supported surface pool polices. */
|
||||
mfxU32 reserved[8]; /*!< Reserved for future use. */
|
||||
mfxU32 NumExtParam; /*!< Number of extension buffers. Reserved for future use. Must be 0. */
|
||||
union {
|
||||
mfxExtBuffer **ExtParam; /*!< Array of extension buffers. */
|
||||
mfxU64 Reserved2; /*!< Reserved for future use. */
|
||||
} ExtParams; /*!< Extension buffers. Reserved for future. */
|
||||
} mfxImplDescription;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*! This structure represents the list of names of implemented functions. */
|
||||
typedef struct {
|
||||
mfxU16 NumFunctions; /*!< Number of function names in the FunctionsName array. */
|
||||
mfxChar** FunctionsName; /*!< Array of the null-terminated strings. Each string contains name of the implemented function. */
|
||||
} mfxImplementedFunctions;
|
||||
MFX_PACK_END()
|
||||
|
||||
|
||||
#define MFX_EXTENDEDDEVICEID_VERSION MFX_STRUCT_VERSION(1, 0)
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*! Specifies various physical device properties for device matching and identification outside of oneAPI Video Processing Library (oneVPL). */
|
||||
typedef struct {
|
||||
mfxStructVersion Version; /*!< Version of the structure. */
|
||||
mfxU16 VendorID; /*!< PCI vendor ID. */
|
||||
mfxU16 DeviceID; /*!< PCI device ID. */
|
||||
mfxU32 PCIDomain; /*!< PCI bus domain. Equals to '0' if OS doesn't support it or
|
||||
has sequential numbering of buses across domains. */
|
||||
mfxU32 PCIBus; /*!< The number of the bus that the physical device is located on. */
|
||||
mfxU32 PCIDevice; /*!< The index of the physical device on the bus. */
|
||||
mfxU32 PCIFunction; /*!< The function number of the device on the physical device. */
|
||||
mfxU8 DeviceLUID[8]; /*!< LUID of DXGI adapter. */
|
||||
mfxU32 LUIDDeviceNodeMask; /*!< Bitfield identifying the node within a linked
|
||||
device adapter corresponding to the device. */
|
||||
mfxU32 LUIDValid; /*!< Boolean value that will be 1 if DeviceLUID contains a valid LUID
|
||||
and LUIDDeviceNodeMask contains a valid node mask,
|
||||
and 0 if they do not. */
|
||||
mfxU32 DRMRenderNodeNum; /*!< Number of the DRM render node from the path /dev/dri/RenderD\<num\>.
|
||||
Value equals to 0 means that this field doesn't contain valid DRM Render
|
||||
Node number.*/
|
||||
mfxU32 DRMPrimaryNodeNum; /*!< Number of the DRM primary node from the path /dev/dri/card\<num\>.
|
||||
Value equals to 0x7FFFFFFF means that this field doesn't contain valid DRM Primary
|
||||
Node number.*/
|
||||
mfxU16 RevisionID; /*!< PCI revision ID. The value contains microarchitecture version. */
|
||||
mfxU8 reserved1[18]; /*!< Reserved for future use. */
|
||||
mfxChar DeviceName[MFX_STRFIELD_LEN]; /*!< Null-terminated string in utf-8 with the name of the device. */
|
||||
} mfxExtendedDeviceId;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*! Cross domain structure to define device UUID. It is defined here to check backward compatibility.*/
|
||||
typedef struct {
|
||||
mfxU16 vendor_id; /*!< PCI vendor ID. Same as mfxExtendedDeviceId::VendorID. */
|
||||
mfxU16 device_id; /*!< PCI device ID. Same as mfxExtendedDeviceId::DeviceID. */
|
||||
mfxU16 revision_id; /*!< PCI revision ID. Same as mfxExtendedDeviceId::RevisionID. */
|
||||
mfxU16 pci_domain; /*!< PCI bus domain. Same as mfxExtendedDeviceId::PCIDomain. */
|
||||
mfxU8 pci_bus; /*!< The number of the bus that the physical device is located on. Same as mfxExtendedDeviceId::PCIBus. */
|
||||
mfxU8 pci_dev; /*!< The index of the physical device on the bus. Same as mfxExtendedDeviceId::PCIDevice. */
|
||||
mfxU8 pci_func; /*!< The function number of the device on the physical device. Same as mfxExtendedDeviceId::PCIFunction. */
|
||||
mfxU8 reserved[4]; /*!< Reserved for future use. */
|
||||
mfxU8 sub_device_id; /*!< SubDevice ID.*/
|
||||
} extDeviceUUID;
|
||||
MFX_PACK_END()
|
||||
|
||||
|
||||
/*! The mfxImplCapsDeliveryFormat enumerator specifies delivery format of the implementation capability. */
|
||||
typedef enum {
|
||||
MFX_IMPLCAPS_IMPLDESCSTRUCTURE = 1, /*!< Deliver capabilities as mfxImplDescription structure. */
|
||||
MFX_IMPLCAPS_IMPLEMENTEDFUNCTIONS = 2, /*!< Deliver capabilities as mfxImplementedFunctions structure. */
|
||||
MFX_IMPLCAPS_IMPLPATH = 3, /*!< Deliver pointer to the null-terminated string with the path to the
|
||||
implementation. String is delivered in a form of buffer of
|
||||
mfxChar type. */
|
||||
MFX_IMPLCAPS_DEVICE_ID_EXTENDED = 4, /*!< Deliver extended device ID information as mfxExtendedDeviceId
|
||||
structure.*/
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
MFX_IMPLCAPS_SURFACE_TYPES = 5, /*!< Deliver capabilities as mfxSurfaceTypesSupported structure. */
|
||||
#endif
|
||||
} mfxImplCapsDeliveryFormat;
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*! Specifies initialization parameters for API version starting from 2.0.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxAccelerationMode AccelerationMode; /*!< Hardware acceleration stack to use. OS dependent parameter. Use VA for Linux*, DX* for Windows* or HDDL. */
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
mfxU16 DeviceCopy; /*!< Enables or disables device's accelerated copying between device and
|
||||
host. See the GPUCopy enumerator for a list of valid values.
|
||||
This parameter is the equivalent of mfxInitParam::GPUCopy. */
|
||||
mfxU16 reserved[2]; /*!< Reserved for future use. */
|
||||
#else
|
||||
mfxU16 reserved[3]; /*!< Reserved for future use. */
|
||||
#endif
|
||||
mfxU16 NumExtParam; /*!< The number of extra configuration structures attached to this
|
||||
structure. */
|
||||
mfxExtBuffer **ExtParam; /*!< Points to an array of pointers to the extra configuration structures;
|
||||
see the ExtendedBufferID enumerator for a list of extended
|
||||
configurations. */
|
||||
mfxU32 VendorImplID; /*!< Vendor specific number with given implementation ID. Represents
|
||||
the same field from mfxImplDescription. */
|
||||
mfxU32 reserved2[3]; /*!< Reserved for future use. */
|
||||
} mfxInitializationParam;
|
||||
MFX_PACK_END()
|
||||
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*! Represents a name/value pair to indicate requested properties. For use with MFXQueryImplsProperties() */
|
||||
typedef struct {
|
||||
mfxU8* PropName; /*!< Property name string to indicate the requested Property. */
|
||||
mfxVariant PropVar; /*!< Property value corresponding to the property name. */
|
||||
} mfxQueryProperty;
|
||||
MFX_PACK_END()
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
+349
@@ -0,0 +1,349 @@
|
||||
/*############################################################################
|
||||
# Copyright Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#ifndef __MFXDEFS_H__
|
||||
#define __MFXDEFS_H__
|
||||
|
||||
#define MFX_VERSION_MAJOR 2
|
||||
#define MFX_VERSION_MINOR 17
|
||||
|
||||
// MFX_VERSION - version of API that 'assumed' by build may be provided externally
|
||||
// if it omitted then latest stable API derived from Major.Minor is assumed
|
||||
|
||||
|
||||
#if !defined(MFX_VERSION)
|
||||
#define MFX_VERSION (MFX_VERSION_MAJOR * 1000 + MFX_VERSION_MINOR)
|
||||
#else
|
||||
#undef MFX_VERSION_MAJOR
|
||||
#define MFX_VERSION_MAJOR ((MFX_VERSION) / 1000)
|
||||
|
||||
#undef MFX_VERSION_MINOR
|
||||
#define MFX_VERSION_MINOR ((MFX_VERSION) % 1000)
|
||||
#endif
|
||||
|
||||
/*! The corresponding version of the Intel(r) Media SDK legacy API that is used as a basis
|
||||
for the current API. */
|
||||
|
||||
#define MFX_LEGACY_VERSION 1035
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* In preprocessor syntax # symbol has stringize meaning,
|
||||
so to expand some macro to preprocessor pragma we need to use
|
||||
special compiler dependent construction */
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define MFX_PRAGMA_IMPL(x) __pragma(x)
|
||||
#else
|
||||
#define MFX_PRAGMA_IMPL(x) _Pragma(#x)
|
||||
#endif
|
||||
|
||||
#define MFX_PACK_BEGIN_X(x) MFX_PRAGMA_IMPL(pack(push, x))
|
||||
#define MFX_PACK_END() MFX_PRAGMA_IMPL(pack(pop))
|
||||
|
||||
/* The general rule for alignment is following:
|
||||
- structures with pointers have 4/8 bytes alignment on 32/64 bit systems
|
||||
- structures with fields of type mfxU64/mfxF64 (unsigned long long / double)
|
||||
have alignment 8 bytes on 64 bit and 32 bit Windows, on Linux alignment is 4 bytes
|
||||
- all the rest structures are 4 bytes aligned
|
||||
- there are several exceptions: some structs which had 4-byte alignment were extended
|
||||
with pointer / long type fields; such structs have 4-byte alignment to keep binary
|
||||
compatibility with previously release API */
|
||||
|
||||
#define MFX_PACK_BEGIN_USUAL_STRUCT() MFX_PACK_BEGIN_X(4)
|
||||
|
||||
/* 64-bit LP64 data model */
|
||||
#if defined(_WIN64) || defined(__LP64__)
|
||||
#define MFX_PACK_BEGIN_STRUCT_W_PTR() MFX_PACK_BEGIN_X(8)
|
||||
#define MFX_PACK_BEGIN_STRUCT_W_L_TYPE() MFX_PACK_BEGIN_X(8)
|
||||
/* 32-bit ILP32 data model Windows* (Intel(r) architecture) */
|
||||
#elif defined(_WIN32) || defined(_M_IX86) && !defined(__linux__)
|
||||
#define MFX_PACK_BEGIN_STRUCT_W_PTR() MFX_PACK_BEGIN_X(4)
|
||||
#define MFX_PACK_BEGIN_STRUCT_W_L_TYPE() MFX_PACK_BEGIN_X(8)
|
||||
/* 32-bit ILP32 data model Linux* */
|
||||
#elif defined(__ILP32__) || defined(__arm__)
|
||||
#define MFX_PACK_BEGIN_STRUCT_W_PTR() MFX_PACK_BEGIN_X(4)
|
||||
#define MFX_PACK_BEGIN_STRUCT_W_L_TYPE() MFX_PACK_BEGIN_X(4)
|
||||
#else
|
||||
#error Unknown packing
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define MFX_CDECL __cdecl
|
||||
#define MFX_STDCALL __stdcall
|
||||
#else
|
||||
#define MFX_CDECL
|
||||
#define MFX_STDCALL
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#define MFX_INFINITE 0xFFFFFFFF
|
||||
|
||||
#ifndef MFX_DEPRECATED_OFF
|
||||
#if defined(__cplusplus) && __cplusplus >= 201402L
|
||||
#define MFX_DEPRECATED [[deprecated]]
|
||||
#define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg [[deprecated]]
|
||||
#define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg)
|
||||
#elif defined(__clang__)
|
||||
#define MFX_DEPRECATED __attribute__((deprecated))
|
||||
#define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg __attribute__((deprecated))
|
||||
#define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg)
|
||||
#elif defined(__INTEL_COMPILER)
|
||||
#if (defined(_WIN32) || defined(_WIN64))
|
||||
#define MFX_DEPRECATED __declspec(deprecated)
|
||||
#define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg
|
||||
#define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg) __pragma(deprecated(arg))
|
||||
#elif defined(__linux__)
|
||||
#define MFX_DEPRECATED __attribute__((deprecated))
|
||||
#if defined(__cplusplus)
|
||||
#define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg __attribute__((deprecated))
|
||||
#else
|
||||
#define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg
|
||||
#endif
|
||||
#define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg)
|
||||
#endif
|
||||
#elif defined(_MSC_VER) && _MSC_VER > 1200 // VS 6 doesn't support deprecation
|
||||
#define MFX_DEPRECATED __declspec(deprecated)
|
||||
#define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg
|
||||
#define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg) __pragma(deprecated(arg))
|
||||
#elif defined(__GNUC__)
|
||||
#define MFX_DEPRECATED __attribute__((deprecated))
|
||||
#define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg __attribute__((deprecated))
|
||||
#define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg)
|
||||
#else
|
||||
#define MFX_DEPRECATED
|
||||
#define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg
|
||||
#define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg)
|
||||
#endif
|
||||
#else
|
||||
#define MFX_DEPRECATED
|
||||
#define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg
|
||||
#define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg)
|
||||
#endif
|
||||
|
||||
typedef unsigned char mfxU8; /*!< Unsigned integer, 8 bit type. */
|
||||
typedef char mfxI8; /*!< Signed integer, 8 bit type. */
|
||||
typedef short mfxI16; /*!< Signed integer, 16 bit type. */
|
||||
typedef unsigned short mfxU16; /*!< Unsigned integer, 16 bit type. */
|
||||
typedef unsigned int mfxU32; /*!< Unsigned integer, 32 bit type. */
|
||||
typedef int mfxI32; /*!< Signed integer, 32 bit type. */
|
||||
#if defined( _WIN32 ) || defined ( _WIN64 )
|
||||
typedef unsigned long mfxUL32; /*!< Unsigned integer, 32 bit type. */
|
||||
typedef long mfxL32; /*!< Signed integer, 32 bit type. */
|
||||
#else
|
||||
typedef unsigned int mfxUL32; /*!< Unsigned integer, 32 bit type. */
|
||||
typedef int mfxL32; /*!< Signed integer, 32 bit type. */
|
||||
#endif
|
||||
typedef float mfxF32; /*!< Single-precision floating point, 32 bit type. */
|
||||
typedef double mfxF64; /*!< Double-precision floating point, 64 bit type. */
|
||||
typedef unsigned long long mfxU64; /*!< Unsigned integer, 64 bit type. */
|
||||
typedef long long mfxI64; /*!< Signed integer, 64 bit type. */
|
||||
typedef void* mfxHDL; /*!< Handle type. */
|
||||
typedef mfxHDL mfxMemId; /*!< Memory ID type. */
|
||||
typedef void* mfxThreadTask; /*!< Thread task type. */
|
||||
typedef char mfxChar; /*!< UTF-8 byte. */
|
||||
typedef unsigned short mfxFP16; /*!< Half precision floating point, 16 bit type. */
|
||||
|
||||
/* MFX structures version info */
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*! Introduce the field Version for any structure.
|
||||
Assumed that any structure changes are backward binary compatible.
|
||||
mfxStructVersion starts from {1,0} for any new API structures. If mfxStructVersion is
|
||||
added to the existent legacy structure (replacing reserved fields) it starts from {1, 1}.
|
||||
*/
|
||||
typedef union {
|
||||
/*! Structure with Major and Minor fields. */
|
||||
/*! @struct Anonymous */
|
||||
struct {
|
||||
/*! @{
|
||||
@name Major and Minor fields
|
||||
Anonymous structure with Major and Minor fields. Minor number is incremented when reserved fields are used. Major number is incremented when the size of structure is increased. */
|
||||
mfxU8 Minor; /*!< Minor number of the correspondent structure. */
|
||||
mfxU8 Major; /*!< Major number of the correspondent structure. */
|
||||
/*! @} */
|
||||
};
|
||||
mfxU16 Version; /*!< Structure version number. */
|
||||
} mfxStructVersion;
|
||||
MFX_PACK_END()
|
||||
|
||||
#define MFX_STRUCT_VERSION(MAJOR, MINOR) (256*(MAJOR) + (MINOR))
|
||||
|
||||
#define MFX_VARIANT_VERSION MFX_STRUCT_VERSION(1, 1)
|
||||
|
||||
/*! The mfxDataType enumerates data type for mfxDataType. */
|
||||
typedef enum {
|
||||
MFX_DATA_TYPE_UNSET = 0, /*!< Undefined type. */
|
||||
MFX_DATA_TYPE_U8, /*!< 8-bit unsigned integer. */
|
||||
MFX_DATA_TYPE_I8, /*!< 8-bit signed integer. */
|
||||
MFX_DATA_TYPE_U16, /*!< 16-bit unsigned integer. */
|
||||
MFX_DATA_TYPE_I16, /*!< 16-bit signed integer. */
|
||||
MFX_DATA_TYPE_U32, /*!< 32-bit unsigned integer. */
|
||||
MFX_DATA_TYPE_I32, /*!< 32-bit signed integer. */
|
||||
MFX_DATA_TYPE_U64, /*!< 64-bit unsigned integer. */
|
||||
MFX_DATA_TYPE_I64, /*!< 64-bit signed integer. */
|
||||
MFX_DATA_TYPE_F32, /*!< 32-bit single precision floating point. */
|
||||
MFX_DATA_TYPE_F64, /*!< 64-bit double precision floating point. */
|
||||
MFX_DATA_TYPE_PTR, /*!< Generic type pointer. */
|
||||
MFX_DATA_TYPE_FP16, /*!< 16-bit half precision floating point. */
|
||||
}mfxDataType;
|
||||
|
||||
/*! The mfxVariantType enumerator data types for mfxVariantType. */
|
||||
typedef enum {
|
||||
MFX_VARIANT_TYPE_UNSET = MFX_DATA_TYPE_UNSET, /*!< Undefined type. */
|
||||
MFX_VARIANT_TYPE_U8 = MFX_DATA_TYPE_U8, /*!< 8-bit unsigned integer. */
|
||||
MFX_VARIANT_TYPE_I8 = MFX_DATA_TYPE_I8, /*!< 8-bit signed integer. */
|
||||
MFX_VARIANT_TYPE_U16 = MFX_DATA_TYPE_U16, /*!< 16-bit unsigned integer. */
|
||||
MFX_VARIANT_TYPE_I16 = MFX_DATA_TYPE_I16, /*!< 16-bit signed integer. */
|
||||
MFX_VARIANT_TYPE_U32 = MFX_DATA_TYPE_U32, /*!< 32-bit unsigned integer. */
|
||||
MFX_VARIANT_TYPE_I32 = MFX_DATA_TYPE_I32, /*!< 32-bit signed integer. */
|
||||
MFX_VARIANT_TYPE_U64 = MFX_DATA_TYPE_U64, /*!< 64-bit unsigned integer. */
|
||||
MFX_VARIANT_TYPE_I64 = MFX_DATA_TYPE_I64, /*!< 64-bit signed integer. */
|
||||
MFX_VARIANT_TYPE_F32 = MFX_DATA_TYPE_F32, /*!< 32-bit single precision floating point. */
|
||||
MFX_VARIANT_TYPE_F64 = MFX_DATA_TYPE_F64, /*!< 64-bit double precision floating point. */
|
||||
MFX_VARIANT_TYPE_PTR = MFX_DATA_TYPE_PTR, /*!< Generic type pointer. */
|
||||
MFX_VARIANT_TYPE_FP16 = MFX_DATA_TYPE_FP16, /*!< 16-bit half precision floating point. */
|
||||
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
MFX_VARIANT_TYPE_QUERY = 0x00000100, /*!< Bitmask to OR with other variant types when using property-based query API */
|
||||
#endif
|
||||
} mfxVariantType;
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*! The mfxVariantType enumerator data types for mfxVariant type. */
|
||||
typedef struct {
|
||||
mfxStructVersion Version; /*!< Version of the structure. */
|
||||
mfxVariantType Type; /*!< Value type. */
|
||||
/*! Value data holder. */
|
||||
union data {
|
||||
mfxU8 U8; /*!< mfxU8 data. */
|
||||
mfxI8 I8; /*!< mfxI8 data. */
|
||||
mfxU16 U16; /*!< mfxU16 data. */
|
||||
mfxI16 I16; /*!< mfxI16 data. */
|
||||
mfxU32 U32; /*!< mfxU32 data. */
|
||||
mfxI32 I32; /*!< mfxI32 data. */
|
||||
mfxU64 U64; /*!< mfxU64 data. */
|
||||
mfxI64 I64; /*!< mfxI64 data. */
|
||||
mfxF32 F32; /*!< mfxF32 data. */
|
||||
mfxF64 F64; /*!< mfxF64 data. */
|
||||
mfxFP16 FP16; /*!< mfxFP16 data. */
|
||||
mfxHDL Ptr; /*!< Pointer. When this points to a string the string must be null terminated. */
|
||||
} Data; /*!< Value data member. */
|
||||
} mfxVariant;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*! Represents a range of unsigned values. */
|
||||
typedef struct {
|
||||
mfxU32 Min; /*!< Minimal value of the range. */
|
||||
mfxU32 Max; /*!< Maximal value of the range. */
|
||||
mfxU32 Step; /*!< Value increment. */
|
||||
} mfxRange32U;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*! Represents a pair of numbers of type mfxI16. */
|
||||
typedef struct {
|
||||
mfxI16 x; /*!< First number. */
|
||||
mfxI16 y; /*!< Second number. */
|
||||
} mfxI16Pair;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*! Represents pair of handles of type mfxHDL. */
|
||||
typedef struct {
|
||||
mfxHDL first; /*!< First handle. */
|
||||
mfxHDL second; /*!< Second handle. */
|
||||
} mfxHDLPair;
|
||||
MFX_PACK_END()
|
||||
|
||||
/*********************************************************************************\
|
||||
Error message
|
||||
\*********************************************************************************/
|
||||
/*! @enum mfxStatus Itemizes status codes returned by API functions. */
|
||||
typedef enum
|
||||
{
|
||||
/* no error */
|
||||
MFX_ERR_NONE = 0, /*!< No error. */
|
||||
/* reserved for unexpected errors */
|
||||
MFX_ERR_UNKNOWN = -1, /*!< Unknown error. */
|
||||
|
||||
/* error codes <0 */
|
||||
MFX_ERR_NULL_PTR = -2, /*!< Null pointer. */
|
||||
MFX_ERR_UNSUPPORTED = -3, /*!< Unsupported feature. */
|
||||
MFX_ERR_MEMORY_ALLOC = -4, /*!< Failed to allocate memory. */
|
||||
MFX_ERR_NOT_ENOUGH_BUFFER = -5, /*!< Insufficient buffer at input/output. */
|
||||
MFX_ERR_INVALID_HANDLE = -6, /*!< Invalid handle. */
|
||||
MFX_ERR_LOCK_MEMORY = -7, /*!< Failed to lock the memory block. */
|
||||
MFX_ERR_NOT_INITIALIZED = -8, /*!< Member function called before initialization. */
|
||||
MFX_ERR_NOT_FOUND = -9, /*!< The specified object is not found. */
|
||||
MFX_ERR_MORE_DATA = -10, /*!< Expect more data at input. */
|
||||
MFX_ERR_MORE_SURFACE = -11, /*!< Expect more surface at output. */
|
||||
MFX_ERR_ABORTED = -12, /*!< Operation aborted. */
|
||||
MFX_ERR_DEVICE_LOST = -13, /*!< Lose the hardware acceleration device. */
|
||||
MFX_ERR_INCOMPATIBLE_VIDEO_PARAM = -14, /*!< Incompatible video parameters. */
|
||||
MFX_ERR_INVALID_VIDEO_PARAM = -15, /*!< Invalid video parameters. */
|
||||
MFX_ERR_UNDEFINED_BEHAVIOR = -16, /*!< Undefined behavior. */
|
||||
MFX_ERR_DEVICE_FAILED = -17, /*!< Device operation failure. */
|
||||
MFX_ERR_MORE_BITSTREAM = -18, /*!< Expect more bitstream buffers at output. */
|
||||
MFX_ERR_GPU_HANG = -21, /*!< Device operation failure caused by GPU hang. */
|
||||
MFX_ERR_REALLOC_SURFACE = -22, /*!< Bigger output surface required. */
|
||||
MFX_ERR_RESOURCE_MAPPED = -23, /*!< Write access is already acquired and user requested
|
||||
another write access, or read access with MFX_MEMORY_NO_WAIT flag. */
|
||||
MFX_ERR_NOT_IMPLEMENTED = -24, /*!< Feature or function not implemented. */
|
||||
MFX_ERR_MORE_EXTBUFFER = -25, /*!< Expect additional extended configuration buffer. */
|
||||
|
||||
/* warnings >0 */
|
||||
MFX_WRN_IN_EXECUTION = 1, /*!< The previous asynchronous operation is in execution. */
|
||||
MFX_WRN_DEVICE_BUSY = 2, /*!< The hardware acceleration device is busy. */
|
||||
MFX_WRN_VIDEO_PARAM_CHANGED = 3, /*!< The video parameters are changed during decoding. */
|
||||
MFX_WRN_PARTIAL_ACCELERATION = 4, /*!< Software acceleration is used. */
|
||||
MFX_WRN_INCOMPATIBLE_VIDEO_PARAM = 5, /*!< Incompatible video parameters. */
|
||||
MFX_WRN_VALUE_NOT_CHANGED = 6, /*!< The value is saturated based on its valid range. */
|
||||
MFX_WRN_OUT_OF_RANGE = 7, /*!< The value is out of valid range. */
|
||||
MFX_WRN_FILTER_SKIPPED = 10, /*!< One of requested filters has been skipped. */
|
||||
/* low-delay partial output */
|
||||
MFX_ERR_NONE_PARTIAL_OUTPUT = 12, /*!< Frame is not ready, but bitstream contains partial output. */
|
||||
|
||||
MFX_WRN_ALLOC_TIMEOUT_EXPIRED = 13, /*!< Timeout expired for internal frame allocation. */
|
||||
|
||||
/* threading statuses */
|
||||
MFX_TASK_DONE = MFX_ERR_NONE, /*!< Task has been completed. */
|
||||
MFX_TASK_WORKING = 8, /*!< There is some more work to do. */
|
||||
MFX_TASK_BUSY = 9, /*!< Task is waiting for resources. */
|
||||
|
||||
/* plug-in statuses */
|
||||
MFX_ERR_MORE_DATA_SUBMIT_TASK = -10000, /*!< Return MFX_ERR_MORE_DATA but submit internal asynchronous task. */
|
||||
|
||||
} mfxStatus;
|
||||
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*! Represents Globally Unique Identifier (GUID) with memory layout
|
||||
compliant to RFC 4122. See https://www.rfc-editor.org/info/rfc4122 for details. */
|
||||
typedef struct
|
||||
{
|
||||
mfxU8 Data[16]; /*!< Array to keep GUID. */
|
||||
} mfxGUID;
|
||||
MFX_PACK_END()
|
||||
|
||||
|
||||
|
||||
// Application
|
||||
#if defined(MFX_DISPATCHER_EXPOSED_PREFIX)
|
||||
|
||||
#include "mfxdispatcherprefixedfunctions.h"
|
||||
|
||||
#endif // MFX_DISPATCHER_EXPOSED_PREFIX
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __MFXDEFS_H__ */
|
||||
@@ -0,0 +1,271 @@
|
||||
/*############################################################################
|
||||
# Copyright Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#ifndef __MFXDISPATCHER_H__
|
||||
#define __MFXDISPATCHER_H__
|
||||
|
||||
#include "mfxdefs.h"
|
||||
#include "mfxcommon.h"
|
||||
#include "mfxsession.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*! Loader handle. */
|
||||
typedef struct _mfxLoader *mfxLoader;
|
||||
|
||||
/*! Config handle. */
|
||||
typedef struct _mfxConfig *mfxConfig;
|
||||
|
||||
/*!
|
||||
@brief Creates the loader.
|
||||
@return Loader Loader handle or NULL if failed.
|
||||
|
||||
@since This function is available since API version 2.0.
|
||||
*/
|
||||
mfxLoader MFX_CDECL MFXLoad(void);
|
||||
|
||||
/*!
|
||||
@brief Destroys the dispatcher.
|
||||
@param[in] loader Loader handle.
|
||||
|
||||
@since This function is available since API version 2.0.
|
||||
*/
|
||||
void MFX_CDECL MFXUnload(mfxLoader loader);
|
||||
|
||||
/*!
|
||||
@brief Creates dispatcher configuration.
|
||||
@details Creates the dispatcher internal configuration, which is used to filter out available implementations.
|
||||
This configuration is used to walk through selected implementations to gather more details and select the appropriate
|
||||
implementation to load. The loader object remembers all created mfxConfig objects and destroys them during the mfxUnload
|
||||
function call.
|
||||
|
||||
Multiple configurations per single mfxLoader object are possible.
|
||||
|
||||
Usage example:
|
||||
@code
|
||||
mfxLoader loader = MFXLoad();
|
||||
mfxConfig cfg = MFXCreateConfig(loader);
|
||||
MFXCreateSession(loader,0,&session);
|
||||
@endcode
|
||||
@param[in] loader Loader handle.
|
||||
@return Config handle or NULL pointer is failed.
|
||||
|
||||
@since This function is available since API version 2.0.
|
||||
*/
|
||||
mfxConfig MFX_CDECL MFXCreateConfig(mfxLoader loader);
|
||||
|
||||
/*!
|
||||
@brief Adds additional filter properties (any fields of the mfxImplDescription structure) to the configuration of the loader object.
|
||||
@note Each new call with the same parameter name will overwrite the previously set value. This may invalidate other properties.
|
||||
|
||||
@param[in] config Config handle.
|
||||
@param[in] name Name of the parameter (see mfxImplDescription structure and example).
|
||||
@param[in] value Value of the parameter.
|
||||
@return
|
||||
MFX_ERR_NONE The function completed successfully.
|
||||
MFX_ERR_NULL_PTR If config is NULL. \n
|
||||
MFX_ERR_NULL_PTR If name is NULL. \n
|
||||
MFX_ERR_NOT_FOUND If name contains unknown parameter name.
|
||||
MFX_ERR_UNSUPPORTED If value data type does not equal the parameter with provided name.
|
||||
|
||||
@since This function is available since API version 2.0.
|
||||
*/
|
||||
mfxStatus MFX_CDECL MFXSetConfigFilterProperty(mfxConfig config, const mfxU8* name, mfxVariant value);
|
||||
|
||||
/*!
|
||||
@brief Iterates over filtered out implementations to gather their details. This function allocates memory to store
|
||||
a structure or string corresponding to the type specified by format. For example, if format is set to
|
||||
MFX_IMPLCAPS_IMPLDESCSTRUCTURE, then idesc will return a pointer to a structure of type mfxImplDescription.
|
||||
Use the MFXDispReleaseImplDescription function to free memory allocated to this structure or string.
|
||||
@param[in] loader Loader handle.
|
||||
@param[in] i Index of the implementation.
|
||||
@param[in] format Format in which capabilities need to be delivered. See the mfxImplCapsDeliveryFormat enumerator for more details.
|
||||
@param[out] idesc Pointer to the structure or string corresponding to the requested format.
|
||||
@return
|
||||
MFX_ERR_NONE The function completed successfully. The idesc contains valid information.\n
|
||||
MFX_ERR_NULL_PTR If loader is NULL. \n
|
||||
MFX_ERR_NULL_PTR If idesc is NULL. \n
|
||||
MFX_ERR_NOT_FOUND Provided index is out of possible range. \n
|
||||
MFX_ERR_UNSUPPORTED If requested format is not supported.
|
||||
|
||||
@since This function is available since API version 2.0.
|
||||
*/
|
||||
mfxStatus MFX_CDECL MFXEnumImplementations(mfxLoader loader, mfxU32 i, mfxImplCapsDeliveryFormat format, mfxHDL* idesc);
|
||||
|
||||
|
||||
/*!
|
||||
@brief Loads and initializes the implementation.
|
||||
@code
|
||||
mfxLoader loader = MFXLoad();
|
||||
int i=0;
|
||||
while(1) {
|
||||
mfxImplDescription *idesc;
|
||||
MFXEnumImplementations(loader, i, MFX_IMPLCAPS_IMPLDESCSTRUCTURE, (mfxHDL*)&idesc);
|
||||
if(is_good(idesc)) {
|
||||
MFXCreateSession(loader, i,&session);
|
||||
// ...
|
||||
MFXDispReleaseImplDescription(loader, idesc);
|
||||
}
|
||||
else
|
||||
{
|
||||
MFXDispReleaseImplDescription(loader, idesc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@endcode
|
||||
@param[in] loader Loader handle.
|
||||
@param[in] i Index of the implementation.
|
||||
@param[out] session Pointer to the session handle.
|
||||
@return
|
||||
MFX_ERR_NONE The function completed successfully. The session contains a pointer to the session handle.\n
|
||||
MFX_ERR_NULL_PTR If loader is NULL. \n
|
||||
MFX_ERR_NULL_PTR If session is NULL. \n
|
||||
MFX_ERR_NOT_FOUND Provided index is out of possible range.
|
||||
|
||||
@since This function is available since API version 2.0.
|
||||
*/
|
||||
mfxStatus MFX_CDECL MFXCreateSession(mfxLoader loader, mfxU32 i, mfxSession* session);
|
||||
|
||||
/*!
|
||||
@brief
|
||||
Destroys handle allocated by the MFXEnumImplementations function.
|
||||
|
||||
@param[in] loader Loader handle.
|
||||
@param[in] hdl Handle to destroy. Can be equal to NULL.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE The function completed successfully. \n
|
||||
MFX_ERR_NULL_PTR If loader is NULL. \n
|
||||
MFX_ERR_INVALID_HANDLE Provided hdl handle is not associated with this loader.
|
||||
|
||||
@since This function is available since API version 2.0.
|
||||
*/
|
||||
mfxStatus MFX_CDECL MFXDispReleaseImplDescription(mfxLoader loader, mfxHDL hdl);
|
||||
|
||||
/*!
|
||||
@brief
|
||||
Macro help to return UUID in the common oneAPI format.
|
||||
|
||||
@param[in] devinfo Handle to mfxExtendedDeviceId.
|
||||
@param[in] sub_dev_num SubDevice number. Can be obtained from mfxDeviceDescription::SubDevices::Index. Set to zero if no SubDevices.
|
||||
@param[out] uuid Pointer to UUID.
|
||||
|
||||
*/
|
||||
#define MFX_UUID_COMPUTE_DEVICE_ID(devinfo, sub_dev_num, uuid) \
|
||||
{ \
|
||||
extDeviceUUID t_uuid = { 0 }; \
|
||||
extDeviceUUID* shared_uuid = (extDeviceUUID*)(uuid); \
|
||||
t_uuid.vendor_id = (devinfo)->VendorID; \
|
||||
t_uuid.device_id = (devinfo)->DeviceID; \
|
||||
t_uuid.revision_id = (devinfo)->RevisionID; \
|
||||
t_uuid.pci_domain = (devinfo)->PCIDomain; \
|
||||
t_uuid.pci_bus = (mfxU8)(devinfo)->PCIBus; \
|
||||
t_uuid.pci_dev = (mfxU8)(devinfo)->PCIDevice; \
|
||||
t_uuid.pci_func = (mfxU8)(devinfo)->PCIFunction; \
|
||||
t_uuid.sub_device_id = (mfxU8)(sub_dev_num); \
|
||||
*shared_uuid = t_uuid; \
|
||||
}
|
||||
|
||||
/* Helper macro definitions to add config filter properties. */
|
||||
|
||||
/*! Adds single property of mfxU32 type.
|
||||
@param[in] loader Valid mfxLoader object
|
||||
@param[in] name Property name string
|
||||
@param[in] value Property value
|
||||
*/
|
||||
#define MFX_ADD_PROPERTY_U32(loader, name, value) \
|
||||
{ \
|
||||
mfxVariant impl_value; \
|
||||
mfxConfig cfg = MFXCreateConfig(loader); \
|
||||
impl_value.Version.Version = MFX_VARIANT_VERSION; \
|
||||
impl_value.Type = MFX_VARIANT_TYPE_U32; \
|
||||
impl_value.Data.U32 = value; \
|
||||
MFXSetConfigFilterProperty(cfg, (mfxU8 *)name, impl_value); \
|
||||
}
|
||||
|
||||
/*! Adds single property of mfxU16 type.
|
||||
@param[in] loader Valid mfxLoader object
|
||||
@param[in] name Property name string
|
||||
@param[in] value Property value
|
||||
*/
|
||||
#define MFX_ADD_PROPERTY_U16(loader, name, value) \
|
||||
{ \
|
||||
mfxVariant impl_value = { 0 }; \
|
||||
mfxConfig cfg = MFXCreateConfig(loader); \
|
||||
impl_value.Version.Version = MFX_VARIANT_VERSION; \
|
||||
impl_value.Type = MFX_VARIANT_TYPE_U16; \
|
||||
impl_value.Data.U16 = value; \
|
||||
MFXSetConfigFilterProperty(cfg, (mfxU8 *)name, impl_value); \
|
||||
}
|
||||
|
||||
/*! Adds single property of pointer type.
|
||||
@param[in] loader Valid mfxLoader object
|
||||
@param[in] name Property name string
|
||||
@param[in] value Property value
|
||||
*/
|
||||
#define MFX_ADD_PROPERTY_PTR(loader, name, value) \
|
||||
{ \
|
||||
mfxVariant impl_value = { 0 }; \
|
||||
mfxConfig cfg = MFXCreateConfig(loader); \
|
||||
impl_value.Version.Version = MFX_VARIANT_VERSION; \
|
||||
impl_value.Type = MFX_VARIANT_TYPE_PTR; \
|
||||
impl_value.Data.Ptr = (mfxHDL)value; \
|
||||
MFXSetConfigFilterProperty(cfg, (mfxU8 *)name, impl_value); \
|
||||
}
|
||||
|
||||
/*! Update existing property of mfxU32 type.
|
||||
@param[in] loader Valid mfxLoader object
|
||||
@param[in] config Valid mfxConfig object
|
||||
@param[in] name Property name string
|
||||
@param[in] value Property value
|
||||
*/
|
||||
#define MFX_UPDATE_PROPERTY_U32(loader, config, name, value) \
|
||||
{ \
|
||||
mfxVariant impl_value; \
|
||||
impl_value.Version.Version = MFX_VARIANT_VERSION; \
|
||||
impl_value.Type = MFX_VARIANT_TYPE_U32; \
|
||||
impl_value.Data.U32 = value; \
|
||||
MFXSetConfigFilterProperty(config, (mfxU8 *)name, impl_value); \
|
||||
}
|
||||
|
||||
/*! Update existing property of mfxU16 type.
|
||||
@param[in] loader Valid mfxLoader object
|
||||
@param[in] config Valid mfxConfig object
|
||||
@param[in] name Property name string
|
||||
@param[in] value Property value
|
||||
*/
|
||||
#define MFX_UPDATE_PROPERTY_U16(loader, config, name, value) \
|
||||
{ \
|
||||
mfxVariant impl_value; \
|
||||
impl_value.Version.Version = MFX_VARIANT_VERSION; \
|
||||
impl_value.Type = MFX_VARIANT_TYPE_U16; \
|
||||
impl_value.Data.U16 = value; \
|
||||
MFXSetConfigFilterProperty(config, (mfxU8 *)name, impl_value); \
|
||||
}
|
||||
|
||||
/*! Update existing property of pointer type.
|
||||
@param[in] loader Valid mfxLoader object
|
||||
@param[in] config Valid mfxConfig object
|
||||
@param[in] name Property name string
|
||||
@param[in] value Property value
|
||||
*/
|
||||
#define MFX_UPDATE_PROPERTY_PTR(loader, config, name, value) \
|
||||
{ \
|
||||
mfxVariant impl_value; \
|
||||
impl_value.Version.Version = MFX_VARIANT_VERSION; \
|
||||
impl_value.Type = MFX_VARIANT_TYPE_PTR; \
|
||||
impl_value.Data.Ptr = (mfxHDL)value; \
|
||||
MFXSetConfigFilterProperty(config, (mfxU8 *)name, impl_value); \
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
/*############################################################################
|
||||
# Copyright Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#ifndef __MFXDISPATCHERPREFIXEDFUNCTIONS_H__
|
||||
#define __MFXDISPATCHERPREFIXEDFUNCTIONS_H__
|
||||
|
||||
// API 1.0 functions
|
||||
#define MFXInit disp_MFXInit
|
||||
#define MFXClose disp_MFXClose
|
||||
#define MFXQueryIMPL disp_MFXQueryIMPL
|
||||
#define MFXQueryVersion disp_MFXQueryVersion
|
||||
|
||||
#define MFXJoinSession disp_MFXJoinSession
|
||||
#define MFXDisjoinSession disp_MFXDisjoinSession
|
||||
#define MFXCloneSession disp_MFXCloneSession
|
||||
#define MFXSetPriority disp_MFXSetPriority
|
||||
#define MFXGetPriority disp_MFXGetPriority
|
||||
|
||||
#define MFXVideoCORE_SetFrameAllocator disp_MFXVideoCORE_SetFrameAllocator
|
||||
#define MFXVideoCORE_SetHandle disp_MFXVideoCORE_SetHandle
|
||||
#define MFXVideoCORE_GetHandle disp_MFXVideoCORE_GetHandle
|
||||
#define MFXVideoCORE_SyncOperation disp_MFXVideoCORE_SyncOperation
|
||||
|
||||
#define MFXVideoENCODE_Query disp_MFXVideoENCODE_Query
|
||||
#define MFXVideoENCODE_QueryIOSurf disp_MFXVideoENCODE_QueryIOSurf
|
||||
#define MFXVideoENCODE_Init disp_MFXVideoENCODE_Init
|
||||
#define MFXVideoENCODE_Reset disp_MFXVideoENCODE_Reset
|
||||
#define MFXVideoENCODE_Close disp_MFXVideoENCODE_Close
|
||||
#define MFXVideoENCODE_GetVideoParam disp_MFXVideoENCODE_GetVideoParam
|
||||
#define MFXVideoENCODE_GetEncodeStat disp_MFXVideoENCODE_GetEncodeStat
|
||||
#define MFXVideoENCODE_EncodeFrameAsync disp_MFXVideoENCODE_EncodeFrameAsync
|
||||
|
||||
#define MFXVideoDECODE_Query disp_MFXVideoDECODE_Query
|
||||
#define MFXVideoDECODE_DecodeHeader disp_MFXVideoDECODE_DecodeHeader
|
||||
#define MFXVideoDECODE_QueryIOSurf disp_MFXVideoDECODE_QueryIOSurf
|
||||
#define MFXVideoDECODE_Init disp_MFXVideoDECODE_Init
|
||||
#define MFXVideoDECODE_Reset disp_MFXVideoDECODE_Reset
|
||||
#define MFXVideoDECODE_Close disp_MFXVideoDECODE_Close
|
||||
#define MFXVideoDECODE_GetVideoParam disp_MFXVideoDECODE_GetVideoParam
|
||||
#define MFXVideoDECODE_GetDecodeStat disp_MFXVideoDECODE_GetDecodeStat
|
||||
#define MFXVideoDECODE_SetSkipMode disp_MFXVideoDECODE_SetSkipMode
|
||||
#define MFXVideoDECODE_GetPayload disp_MFXVideoDECODE_GetPayload
|
||||
#define MFXVideoDECODE_DecodeFrameAsync disp_MFXVideoDECODE_DecodeFrameAsync
|
||||
|
||||
#define MFXVideoVPP_Query disp_MFXVideoVPP_Query
|
||||
#define MFXVideoVPP_QueryIOSurf disp_MFXVideoVPP_QueryIOSurf
|
||||
#define MFXVideoVPP_Init disp_MFXVideoVPP_Init
|
||||
#define MFXVideoVPP_Reset disp_MFXVideoVPP_Reset
|
||||
#define MFXVideoVPP_Close disp_MFXVideoVPP_Close
|
||||
|
||||
#define MFXVideoVPP_GetVideoParam disp_MFXVideoVPP_GetVideoParam
|
||||
#define MFXVideoVPP_GetVPPStat disp_MFXVideoVPP_GetVPPStat
|
||||
#define MFXVideoVPP_RunFrameVPPAsync disp_MFXVideoVPP_RunFrameVPPAsync
|
||||
|
||||
// API 1.1 functions
|
||||
#define MFXVideoUSER_Register disp_MFXVideoUSER_Register
|
||||
#define MFXVideoUSER_Unregister disp_MFXVideoUSER_Unregister
|
||||
#define MFXVideoUSER_ProcessFrameAsync disp_MFXVideoUSER_ProcessFrameAsync
|
||||
|
||||
// API 1.10 functions
|
||||
|
||||
#define MFXVideoENC_Query disp_MFXVideoENC_Query
|
||||
#define MFXVideoENC_QueryIOSurf disp_MFXVideoENC_QueryIOSurf
|
||||
#define MFXVideoENC_Init disp_MFXVideoENC_Init
|
||||
#define MFXVideoENC_Reset disp_MFXVideoENC_Reset
|
||||
#define MFXVideoENC_Close disp_MFXVideoENC_Close
|
||||
#define MFXVideoENC_ProcessFrameAsync disp_MFXVideoENC_ProcessFrameAsync
|
||||
#define MFXVideoVPP_RunFrameVPPAsyncEx disp_MFXVideoVPP_RunFrameVPPAsyncEx
|
||||
#define MFXVideoUSER_Load disp_MFXVideoUSER_Load
|
||||
#define MFXVideoUSER_UnLoad disp_MFXVideoUSER_UnLoad
|
||||
|
||||
// API 1.11 functions
|
||||
|
||||
#define MFXVideoPAK_Query disp_MFXVideoPAK_Query
|
||||
#define MFXVideoPAK_QueryIOSurf disp_MFXVideoPAK_QueryIOSurf
|
||||
#define MFXVideoPAK_Init disp_MFXVideoPAK_Init
|
||||
#define MFXVideoPAK_Reset disp_MFXVideoPAK_Reset
|
||||
#define MFXVideoPAK_Close disp_MFXVideoPAK_Close
|
||||
#define MFXVideoPAK_ProcessFrameAsync disp_MFXVideoPAK_ProcessFrameAsync
|
||||
|
||||
// API 1.13 functions
|
||||
|
||||
#define MFXVideoUSER_LoadByPath disp_MFXVideoUSER_LoadByPath
|
||||
|
||||
// API 1.14 functions
|
||||
#define MFXInitEx disp_MFXInitEx
|
||||
|
||||
// Audio library functions
|
||||
|
||||
// API 1.8 functions
|
||||
|
||||
#define MFXAudioCORE_SyncOperation disp_MFXAudioCORE_SyncOperation
|
||||
#define MFXAudioENCODE_Query disp_MFXAudioENCODE_Query
|
||||
#define MFXAudioENCODE_QueryIOSize disp_MFXAudioENCODE_QueryIOSize
|
||||
#define MFXAudioENCODE_Init disp_MFXAudioENCODE_Init
|
||||
#define MFXAudioENCODE_Reset disp_MFXAudioENCODE_Reset
|
||||
#define MFXAudioENCODE_Close disp_MFXAudioENCODE_Close
|
||||
#define MFXAudioENCODE_GetAudioParam disp_MFXAudioENCODE_GetAudioParam
|
||||
#define MFXAudioENCODE_EncodeFrameAsync disp_MFXAudioENCODE_EncodeFrameAsync
|
||||
|
||||
#define MFXAudioDECODE_Query disp_MFXAudioDECODE_Query
|
||||
#define MFXAudioDECODE_DecodeHeader disp_MFXAudioDECODE_DecodeHeader
|
||||
#define MFXAudioDECODE_Init disp_MFXAudioDECODE_Init
|
||||
#define MFXAudioDECODE_Reset disp_MFXAudioDECODE_Reset
|
||||
#define MFXAudioDECODE_Close disp_MFXAudioDECODE_Close
|
||||
#define MFXAudioDECODE_QueryIOSize disp_MFXAudioDECODE_QueryIOSize
|
||||
#define MFXAudioDECODE_GetAudioParam disp_MFXAudioDECODE_GetAudioParam
|
||||
#define MFXAudioDECODE_DecodeFrameAsync disp_MFXAudioDECODE_DecodeFrameAsync
|
||||
|
||||
// API 1.9 functions
|
||||
|
||||
#define MFXAudioUSER_Register disp_MFXAudioUSER_Register
|
||||
#define MFXAudioUSER_Unregister disp_MFXAudioUSER_Unregister
|
||||
#define MFXAudioUSER_ProcessFrameAsync disp_MFXAudioUSER_ProcessFrameAsync
|
||||
#define MFXAudioUSER_Load disp_MFXAudioUSER_Load
|
||||
#define MFXAudioUSER_UnLoad disp_MFXAudioUSER_UnLoad
|
||||
|
||||
// API 1.19 functions
|
||||
|
||||
#define MFXVideoENC_GetVideoParam disp_MFXVideoENC_GetVideoParam
|
||||
#define MFXVideoPAK_GetVideoParam disp_MFXVideoPAK_GetVideoParam
|
||||
#define MFXVideoCORE_QueryPlatform disp_MFXVideoCORE_QueryPlatform
|
||||
#define MFXVideoUSER_GetPlugin disp_MFXVideoUSER_GetPlugin
|
||||
|
||||
// API 2.0 functions
|
||||
#define MFXMemory_GetSurfaceForVPP disp_MFXMemory_GetSurfaceForVPP
|
||||
#define MFXMemory_GetSurfaceForEncode disp_MFXMemory_GetSurfaceForEncode
|
||||
#define MFXMemory_GetSurfaceForDecode disp_MFXMemory_GetSurfaceForDecode
|
||||
|
||||
#define MFXQueryImplsDescription disp_MFXQueryImplsDescription
|
||||
#define MFXReleaseImplDescription disp_MFXReleaseImplDescription
|
||||
|
||||
#define MFXInitialize disp_MFXInitialize
|
||||
|
||||
// API 2.1 functions
|
||||
#define MFXMemory_GetSurfaceForVPPOut disp_MFXMemory_GetSurfaceForVPPOut
|
||||
|
||||
#define MFXVideoDECODE_VPP_Init disp_MFXVideoDECODE_VPP_Init
|
||||
#define MFXVideoDECODE_VPP_DecodeFrameAsync disp_MFXVideoDECODE_VPP_DecodeFrameAsync
|
||||
#define MFXVideoDECODE_VPP_Reset disp_MFXVideoDECODE_VPP_Reset
|
||||
#define MFXVideoDECODE_VPP_GetChannelParam disp_MFXVideoDECODE_VPP_GetChannelParam
|
||||
#define MFXVideoDECODE_VPP_Close disp_MFXVideoDECODE_VPP_Close
|
||||
|
||||
#define MFXVideoVPP_ProcessFrameAsync disp_MFXVideoVPP_ProcessFrameAsync
|
||||
|
||||
// API 2.15 functions
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
#define MFXQueryImplsProperties disp_MFXQueryImplsProperties
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,458 @@
|
||||
/*############################################################################
|
||||
# Copyright Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
|
||||
|
||||
#ifndef __MFXENCODESTATS_H__
|
||||
#define __MFXENCODESTATS_H__
|
||||
#include "mfxcommon.h"
|
||||
#include "mfxstructures.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*!< The enum to specify memory layout for statistics. */
|
||||
typedef enum {
|
||||
MFX_ENCODESTATS_MEMORY_LAYOUT_DEFAULT = 0, /*!< The default memory layout for statistics. */
|
||||
} mfxEncodeBlkStatsMemLayout;
|
||||
|
||||
/*!< The enum to specify mode to gather statistics. */
|
||||
typedef enum {
|
||||
MFX_ENCODESTATS_MODE_DEFAULT = 0, /*!< Encode mode is selected by the implementation. */
|
||||
MFX_ENCODESTATS_MODE_ENCODE = 1, /*!< Full encode mode. */
|
||||
} mfxEncodeStatsMode;
|
||||
|
||||
/*!< Flags to specify what statistics will be reported by the implementation. */
|
||||
enum {
|
||||
MFX_ENCODESTATS_LEVEL_BLK = 0x1, /*!< Block level statistics. */
|
||||
MFX_ENCODESTATS_LEVEL_SLICE = 0x2, /*!< Slice level statistics. */
|
||||
MFX_ENCODESTATS_LEVEL_TILE = 0x4, /*!< Tile level statistics. */
|
||||
MFX_ENCODESTATS_LEVEL_FRAME = 0x8, /*!< Frame level statistics. */
|
||||
};
|
||||
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*!< Specifies H.265 CTU header. */
|
||||
typedef struct {
|
||||
union {
|
||||
struct {
|
||||
mfxU32 CUcountminus1 : 6; /*!< Number of CU per CTU. */
|
||||
mfxU32 MaxDepth : 2; /*!< Max quad-tree depth of CU in CTU. */
|
||||
mfxU32 reserved : 24;
|
||||
} bitfields0;
|
||||
mfxU32 dword0;
|
||||
};
|
||||
mfxU16 CurrXAddr; /*!< Horizontal address of CTU. */
|
||||
mfxU16 CurrYAddr; /*!< Vertical address of CTU. */
|
||||
mfxU32 reserved1;
|
||||
} mfxCTUHeader;
|
||||
MFX_PACK_END()
|
||||
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*!< Specifies H.265 CU info. */
|
||||
typedef struct {
|
||||
union {
|
||||
struct {
|
||||
mfxU32 CU_Size : 2; /*!< indicates the CU size of the current CU. 0: 8x8 1: 16x16 2: 32x32 3: 64x64 */
|
||||
mfxU32 CU_pred_mode : 1; /*!< indicates the prediction mode for the current CU. 0: intra 1: inter */
|
||||
/*!
|
||||
indicates the PU partition mode for the current CU.
|
||||
0: 2Nx2N
|
||||
1: 2NxN (inter)
|
||||
2: Nx2N (inter)
|
||||
3: NXN (intra only, CU Size=8x8 only. Luma Intra Mode indicates the intra prediction mode for 4x4_0. The additional prediction modes are overloaded on 4x4_1, 4x4_2, 4x4_3 below)
|
||||
4: 2NxnT (inter only)
|
||||
5: 2NxnB (inter only)
|
||||
6: nLx2N (inter only)
|
||||
7: nRx2N (inter only).
|
||||
*/
|
||||
mfxU32 CU_part_mode : 3;
|
||||
mfxU32 InterPred_IDC_MV0 : 2; /*!< indicates the prediction direction for PU0 of the current CU. 0: L0 1: L1 2: Bi 3: reserved */
|
||||
mfxU32 InterPred_IDC_MV1 : 2; /*!< indicates the prediction direction for PU1 of the current CU. 0: L0 1: L1 2: Bi 3: reserved */
|
||||
/*!
|
||||
Final explicit Luma Intra Mode 4x4_0 for NxN.
|
||||
Valid values 0..34
|
||||
Note: CU_part_mode==NxN.
|
||||
*/
|
||||
mfxU32 LumaIntraMode : 6;
|
||||
/*!
|
||||
indicates the final explicit Luma Intra Mode for the CU.
|
||||
0: DM (use Luma mode, from block 0 if NxN)
|
||||
1: reserved
|
||||
2: Planar
|
||||
3: Vertical
|
||||
4: Horizontal
|
||||
5: DC */
|
||||
mfxU32 ChromaIntraMode : 3;
|
||||
mfxU32 reserved : 13;
|
||||
} bitfields0;
|
||||
mfxU32 dword0;
|
||||
};
|
||||
|
||||
union {
|
||||
struct {
|
||||
/*!
|
||||
Final explicit Luma Intra Mode 4x4_1.
|
||||
Valid values 0..34
|
||||
Note: CU_part_mode==NxN.
|
||||
*/
|
||||
mfxU32 LumaIntraMode4x4_1 : 6;
|
||||
/*!
|
||||
Final explicit Luma Intra Mode 4x4_2.
|
||||
Valid values 0..34
|
||||
Note: CU_part_mode==NxN.
|
||||
*/
|
||||
mfxU32 LumaIntraMode4x4_2 : 6;
|
||||
/*!
|
||||
Final explicit Luma Intra Mode 4x4_3.
|
||||
Valid values 0..34
|
||||
Note: CU_part_mode==NxN.
|
||||
*/
|
||||
mfxU32 LumaIntraMode4x4_3 : 6;
|
||||
mfxU32 reserved1 : 14;
|
||||
} bitfields1;
|
||||
mfxU32 dword1;
|
||||
};
|
||||
|
||||
mfxI8 QP; // signed QP value
|
||||
mfxU8 reserved2[3];
|
||||
/*! distortion measure, approximation to SAD.
|
||||
Will deviate significantly (pre, post reconstruction) and due to variation in algorithm.
|
||||
*/
|
||||
mfxU32 SAD;
|
||||
|
||||
/*!
|
||||
These parameters indicate motion vectors that are associated with the PU0/PU1 winners
|
||||
range [-2048.00..2047.75].
|
||||
L0/PU0 - MV[0][0]
|
||||
L0/PU1 - MV[0][1]
|
||||
L1/PU0 - MV[1][0]
|
||||
L1/PU1 - MV[1][1]
|
||||
*/
|
||||
mfxI16Pair MV[2][2];
|
||||
|
||||
union {
|
||||
struct {
|
||||
/*!
|
||||
This parameter indicates the reference index associated with the MV X/Y
|
||||
that is populated in the L0_MV0.X and L0_MV0.Y fields. */
|
||||
mfxU32 L0_MV0_RefID : 4;
|
||||
/*!
|
||||
This parameter indicates the reference index associated with the MV X/Y
|
||||
that is populated in the L0_MV1.X and L0_MV1.Y fields. */
|
||||
mfxU32 L0_MV1_RefID : 4;
|
||||
/*!
|
||||
This parameter indicates the reference index associated with the MV X/Y
|
||||
that is populated in the L1_MV0.X and L1_MV0.Y fields. */
|
||||
mfxU32 L1_MV0_RefID : 4;
|
||||
/*!
|
||||
This parameter indicates the reference index associated with the MV X/Y
|
||||
that is populated in the L1_MV1.X and L1_MV1.Y fields. */
|
||||
mfxU32 L1_MV1_RefID : 4;
|
||||
|
||||
mfxU32 reserved3 : 16;
|
||||
} bitfields8;
|
||||
mfxU32 dword8;
|
||||
};
|
||||
mfxU32 reserved4[10];
|
||||
} mfxCUInfo;
|
||||
MFX_PACK_END()
|
||||
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*!< Specifies H.265 CTU. */
|
||||
typedef struct {
|
||||
mfxCTUHeader CtuHeader; /*!< H.265 CTU header. */
|
||||
mfxCUInfo CuInfo[64]; /*!< Array of CU. */
|
||||
mfxU32 reserved;
|
||||
} mfxCTUInfo;
|
||||
MFX_PACK_END()
|
||||
|
||||
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*!
|
||||
The structure describes H.264 stats per MB.
|
||||
*/
|
||||
typedef struct {
|
||||
union {
|
||||
struct {
|
||||
/*!
|
||||
Together with @p IntraMbFlag this parameter specifies macroblock type according to the
|
||||
ISO\*\/IEC\* 14496-10 with the following difference - it stores either intra or inter
|
||||
values according to @p IntraMbFlag, but not intra after inter.
|
||||
Values for P-slices are mapped to B-slice values. For example P_16x8 is coded with
|
||||
B_FWD_16x8 value.
|
||||
*/
|
||||
mfxU32 MBType : 5;
|
||||
/*!
|
||||
This field specifies inter macroblock mode and is ignored for intra MB. It is derived from @p MbType and has next values:
|
||||
@li 0 - 16x16 mode
|
||||
@li 1 - 16x8 mode
|
||||
@li 2 - 8x16 mode
|
||||
@li 3 - 8x8 mode
|
||||
*/
|
||||
mfxU32 InterMBMode : 2;
|
||||
/*!
|
||||
This field specifies intra macroblock mode and is ignored for inter MB. It is derived from @p MbType and has next values:
|
||||
@li 0 - 16x16 mode
|
||||
@li 1 - 8x8 mode
|
||||
@li 2 - 4x4 mode
|
||||
@li 3 - PCM
|
||||
*/
|
||||
mfxU32 IntraMBMode : 2;
|
||||
/*!
|
||||
This flag specifies intra/inter MB type and has next values:
|
||||
0 - Inter prediction MB type
|
||||
1 - Intra prediction MB type
|
||||
*/
|
||||
mfxU32 IntraMBFlag : 1;
|
||||
/*!
|
||||
This field specifies subblock shapes for the current MB. Each block is described by 2 bits starting from lower bits for block 0.
|
||||
|
||||
@li 0 - 8x8
|
||||
@li 1 - 8x4
|
||||
@li 2 - 4x8
|
||||
@li 3 - 4x4
|
||||
*/
|
||||
mfxU32 SubMBShapes : 8;
|
||||
/*!
|
||||
This field specifies prediction modes for the current MB partition blocks. Each block is described by 2 bits starting from lower bits for block 0.
|
||||
@li 0 - Pred_L0
|
||||
@li 1 - Pred_L1
|
||||
@li 2 - BiPred
|
||||
@li 3 - reserved
|
||||
|
||||
Only one prediction value for partition is reported, the rest values are set to zero. For example:
|
||||
@li 16x16 Pred_L1 - 0x01 (only 2 lower bits are used)
|
||||
@li 16x8 Pred_L1 / BiPred - 0x09 (1001b)
|
||||
@li 8x16 BiPred / BiPred - 0x0a (1010b)
|
||||
|
||||
For P MBs this value is always zero.
|
||||
*/
|
||||
mfxU32 SubMBShapeMode : 8;
|
||||
/*!
|
||||
This value specifies chroma intra prediction mode.
|
||||
@li 0 - DC
|
||||
@li 1 - Horizontal
|
||||
@li 2 - Vertical
|
||||
@li 3 - Plane
|
||||
*/
|
||||
mfxU32 ChromaIntraPredMode : 2;
|
||||
mfxU32 reserved : 4;
|
||||
} bitfields0;
|
||||
mfxU32 dword0;
|
||||
} ;
|
||||
/*!
|
||||
Distortion measure, approximation to SAD.
|
||||
Deviate significantly (pre, post reconstruction) and due to variation in algorithm.
|
||||
*/
|
||||
mfxU32 SAD;
|
||||
mfxI8 Qp; /*!< MB QP. */
|
||||
mfxU8 reserved1[3];
|
||||
|
||||
/*!
|
||||
These values specify luma intra prediction modes for current MB. Each element of the array
|
||||
corresponds to 8x8 block and each holds prediction modes for four 4x4 subblocks.
|
||||
Four bits per mode, lowest bits for left top subblock.
|
||||
All 16 prediction modes are always specified. For 8x8 case, block prediction mode is
|
||||
populated to all subblocks of the 8x8 block. For 16x16 case - to all subblocks of the MB.
|
||||
|
||||
Prediction directions for 4x4 and 8x8 blocks:
|
||||
@li 0 - Vertical
|
||||
@li 1 - Horizontal
|
||||
@li 2 - DC
|
||||
@li 3 - Diagonal Down Left
|
||||
@li 4 - Diagonal Down Right
|
||||
@li 5 - Vertical Right
|
||||
@li 6 - Horizontal Down
|
||||
@li 7 - Vertical Left
|
||||
@li 8 - Horizontal Up
|
||||
|
||||
Prediction directions for 16x16 blocks:
|
||||
@li 0 - Vertical
|
||||
@li 1 - Horizontal
|
||||
@li 2 - DC
|
||||
@li 3 - Plane
|
||||
*/
|
||||
mfxU16 LumaIntraMode[4];
|
||||
|
||||
mfxU32 reserved2;
|
||||
} mfxMBInfo;
|
||||
MFX_PACK_END()
|
||||
|
||||
/*!
|
||||
The enum specifies block size.
|
||||
*/
|
||||
typedef enum {
|
||||
MFX_BLOCK_4X4 = 0, /*!< 4x4 block size. */
|
||||
MFX_BLOCK_16X16 = 1, /*!< 16x16 block size. */
|
||||
} mfxBlockSize;
|
||||
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*!
|
||||
The structure describes H.264 and H.265 stats per MB or CTUs.
|
||||
*/
|
||||
typedef struct {
|
||||
union {
|
||||
mfxU32 NumMB; /*!< Number of MBs per frame for H.264. */
|
||||
mfxU32 NumCTU; /*!< number of CTUs per frame for H.265. */
|
||||
};
|
||||
union {
|
||||
mfxCTUInfo *HEVCCTUArray; /*!< Array of CTU statistics. */
|
||||
mfxMBInfo *AVCMBArray; /*!< Array of MB statistics. */
|
||||
};
|
||||
mfxU32 reserved[8];
|
||||
|
||||
} mfxEncodeBlkStats;
|
||||
MFX_PACK_END()
|
||||
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
|
||||
/*!
|
||||
The structure describes H.264/H.265 frame/slice/tile level statistics.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxF32 PSNRLuma; /*!< PSNR for LUMA samples. */
|
||||
mfxF32 PSNRCb; /*!< PSNR for Chroma (Cb) samples. */
|
||||
mfxF32 PSNRCr; /*!< PSNR for Chroma (Cr) samples. */
|
||||
/*! distortion measure, approximation to SAD.
|
||||
Will deviate significantly (pre, post reconstruction) and due to variation in algorithm.
|
||||
*/
|
||||
mfxU64 SADLuma;
|
||||
mfxF32 Qp; /*!< average frame QP, may have fractional part in case of MBQP. */
|
||||
|
||||
union {
|
||||
mfxU32 NumMB; /*!< Number of MBs per frame for H.264. */
|
||||
mfxU32 NumCTU; /*!< number of CTUs per frame for H.265. */
|
||||
};
|
||||
|
||||
mfxBlockSize BlockSize; /*! For H.264 it is always 16x16 corresponding to MB size.
|
||||
In H.265 it's normalized to 4x4, so for each CU we calculate number of 4x4 which belongs to the block. */
|
||||
|
||||
mfxU32 NumIntraBlock; /*! Number of intra blocks in the frame. The size of block is defined by BlockSize.
|
||||
For H.265 it can be more than number of intra CU. */
|
||||
mfxU32 NumInterBlock; /*! Number of inter blocks in the frame. The size of block is defined by BlockSize.
|
||||
For H.265 it can be more than number of inter CU. */
|
||||
mfxU32 NumSkippedBlock; /*! Number of skipped blocks in the frame. The size of block is defined by BlockSize.
|
||||
For H.265 it can be more than number of skipped CU. */
|
||||
|
||||
mfxU32 reserved[8];
|
||||
|
||||
} mfxEncodeHighLevelStats;
|
||||
MFX_PACK_END()
|
||||
|
||||
/*!
|
||||
Alias for the structure to describe H.264 and H.265 frame level stats.
|
||||
*/
|
||||
typedef mfxEncodeHighLevelStats mfxEncodeFrameStats;
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*!
|
||||
The structure describes H.264 and H.265 stats per Slice or Tile.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxU32 NumElements; /*!< Number of Slices or Tiles per frame for H.264/H.265. */
|
||||
mfxEncodeHighLevelStats *HighLevelStatsArray; /*!< Array of CTU statistics. */
|
||||
mfxU32 reserved[8];
|
||||
|
||||
} mfxEncodeSliceStats;
|
||||
MFX_PACK_END()
|
||||
|
||||
/*!
|
||||
Alias for the structure to describe H.264 and H.265 tile level stats.
|
||||
*/
|
||||
typedef mfxEncodeSliceStats mfxEncodeTileStats;
|
||||
|
||||
|
||||
#define MFX_ENCODESTATSCONTAINER_VERSION MFX_STRUCT_VERSION(1, 0)
|
||||
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*! The structure represents reference counted container for output after encoding operation which includes statistics
|
||||
and synchronization primitive for compressed bitstream.
|
||||
The memory is allocated and released by the library.
|
||||
*/
|
||||
typedef struct mfxEncodeStatsContainer {
|
||||
mfxStructVersion Version; /*!< The version of the structure. */
|
||||
mfxRefInterface RefInterface; /*! < Reference counting interface. */
|
||||
/*! @brief
|
||||
Guarantees readiness of the statistics after a function completes.
|
||||
Instead of MFXVideoCORE_SyncOperation which leads to the synchronization of all output objects,
|
||||
users may directly call the mfxEncodeStatsContainer::SynchronizeStatistics function to get output statistics.
|
||||
|
||||
|
||||
@param[in] ref_interface Valid interface.
|
||||
@param[out] wait Wait time in milliseconds.
|
||||
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE If no error. \n
|
||||
MFX_ERR_NULL_PTR If interface is NULL. \n
|
||||
MFX_ERR_INVALID_HANDLE If any of container is not valid object . \n
|
||||
MFX_WRN_IN_EXECUTION If the given timeout is expired and the container is not ready. \n
|
||||
MFX_ERR_ABORTED If the specified asynchronous function aborted due to data dependency on a previous asynchronous function that did not complete. \n
|
||||
MFX_ERR_UNKNOWN Any internal error.
|
||||
*/
|
||||
mfxStatus (MFX_CDECL *SynchronizeStatistics)(mfxRefInterface* ref_interface, mfxU32 wait);
|
||||
/*! @brief
|
||||
Guarantees readiness of associated compressed bitstream after a function completes.
|
||||
Instead of MFXVideoCORE_SyncOperation which leads to the synchronization of all output objects,
|
||||
users may directly call the mfxEncodeStatsContainer::SynchronizeStatistics function to get output bitstream.
|
||||
|
||||
|
||||
@param[in] ref_interface Valid interface.
|
||||
@param[out] wait Wait time in milliseconds.
|
||||
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE If no error. \n
|
||||
MFX_ERR_NULL_PTR If interface is NULL. \n
|
||||
MFX_ERR_INVALID_HANDLE If any of container is not valid object . \n
|
||||
MFX_WRN_IN_EXECUTION If the given timeout is expired and the container is not ready. \n
|
||||
MFX_ERR_ABORTED If the specified asynchronous function aborted due to data dependency on a previous asynchronous function that did not complete. \n
|
||||
MFX_ERR_UNKNOWN Any internal error.
|
||||
*/
|
||||
mfxStatus (MFX_CDECL *SynchronizeBitstream)(mfxRefInterface* ref_interface, mfxU32 wait);
|
||||
mfxHDL reserved[4];
|
||||
mfxU32 reserved1[2];
|
||||
mfxU32 DisplayOrder; /*!< To which frame number statistics belong. */
|
||||
mfxEncodeBlkStatsMemLayout MemLayout; /*!< Memory layout for statistics. */
|
||||
mfxEncodeBlkStats *EncodeBlkStats; /*!< Block level statistics. */
|
||||
mfxEncodeSliceStats *EncodeSliceStats; /*!< Slice level statistics. */
|
||||
mfxEncodeTileStats *EncodeTileStats; /*!< Tile level statistics. */
|
||||
mfxEncodeFrameStats *EncodeFrameStats; /*!< Frame level statistics. */
|
||||
mfxU32 reserved2[8];
|
||||
}mfxEncodeStatsContainer;
|
||||
MFX_PACK_END()
|
||||
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*! The extension buffer which should be attached by application for mfxBitstream buffer before
|
||||
encode operation. As result the encoder will allocate memory for statistics and fill appropriate structures.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_ENCODESTATS_BLK. */
|
||||
mfxU16 EncodeStatsFlags; /*!< What statistics is required: block/slice/tile/frame level or any combinations.
|
||||
In case of slice or tile output statistics for one slice or tile will be available only.*/
|
||||
mfxEncodeStatsMode Mode; /*!< What encoding mode should be used to gather statistics. */
|
||||
mfxEncodeStatsContainer *EncodeStatsContainer; /*!< encode output, filled by the implementation. */
|
||||
mfxU32 reserved[8];
|
||||
} mfxExtEncodeStatsOutput;
|
||||
MFX_PACK_END()
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,78 @@
|
||||
/*############################################################################
|
||||
# Copyright Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#include "mfxdefs.h"
|
||||
|
||||
#ifndef __MFXIMPLCAPS_H__
|
||||
#define __MFXIMPLCAPS_H__
|
||||
|
||||
#include "mfxstructures.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@brief
|
||||
Delivers implementation capabilities in the requested format according to the format value. Calling this
|
||||
function directly is not recommended. Instead, applications must call the MFXEnumImplementations function.
|
||||
|
||||
@param[in] format Format in which capabilities must be delivered. See mfxImplCapsDeliveryFormat for more details.
|
||||
@param[out] num_impls Number of the implementations.
|
||||
|
||||
@return
|
||||
Array of handles to the capability report or NULL in case of unsupported format or NULL num_impls pointer.
|
||||
Length of array is equal to num_impls.
|
||||
|
||||
@since This function is available since API version 2.0.
|
||||
*/
|
||||
mfxHDL* MFX_CDECL MFXQueryImplsDescription(mfxImplCapsDeliveryFormat format, mfxU32* num_impls);
|
||||
|
||||
/*!
|
||||
@brief
|
||||
Destroys the handle allocated by the MFXQueryImplsDescription function or the MFXQueryImplsProperties function.
|
||||
Implementation must remember which handles are released. Once the last handle is released, this function must release memory
|
||||
allocated for the array of handles. Calling this function directly is not recommended. Instead, applications must call
|
||||
the MFXDispReleaseImplDescription function.
|
||||
|
||||
@param[in] hdl Handle to destroy. Can be equal to NULL.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE The function completed successfully.
|
||||
|
||||
@since This function is available since API version 2.0.
|
||||
*/
|
||||
mfxStatus MFX_CDECL MFXReleaseImplDescription(mfxHDL hdl);
|
||||
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
/*!
|
||||
@brief
|
||||
Delivers implementation capabilities for configured properties.
|
||||
The returned capability report will be sparsely filled out, with only properties available which
|
||||
were set via MFXSetConfigFilterProperty(). Calling this function directly is not recommended.
|
||||
Instead, applications must call the MFXEnumImplementations function.
|
||||
|
||||
|
||||
@param[in] properties Array of property name/value pairs indicating which properties to populate in the capability report.
|
||||
@param[in] num_properties Number of property name/value pairs.
|
||||
@param[out] num_impls Number of the implementations.
|
||||
|
||||
@return
|
||||
Array of handles to the capability report or NULL in case of NULL properties pointer or zero num_properties or NULL num_impls pointer.
|
||||
Length of array is equal to num_impls.
|
||||
|
||||
@since This function is available since API version 2.15.
|
||||
*/
|
||||
mfxHDL* MFX_CDECL MFXQueryImplsProperties(mfxQueryProperty** properties, mfxU32 num_properties, mfxU32* num_impls);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // __MFXIMPLCAPS_H__
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
/*############################################################################
|
||||
# Copyright Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#ifndef __MFX_JPEG_H__
|
||||
#define __MFX_JPEG_H__
|
||||
|
||||
#include "mfxdefs.h"
|
||||
#include "mfxstructures.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* CodecId */
|
||||
enum {
|
||||
MFX_CODEC_JPEG = MFX_MAKEFOURCC('J','P','E','G') /*!< JPEG codec */
|
||||
};
|
||||
|
||||
/* CodecProfile, CodecLevel */
|
||||
enum
|
||||
{
|
||||
MFX_PROFILE_JPEG_BASELINE = 1 /*!< Baseline JPEG profile. */
|
||||
};
|
||||
|
||||
/*! The Rotation enumerator itemizes the JPEG rotation options. */
|
||||
enum
|
||||
{
|
||||
MFX_ROTATION_0 = 0, /*!< No rotation. */
|
||||
MFX_ROTATION_90 = 1, /*!< 90 degree rotation. */
|
||||
MFX_ROTATION_180 = 2, /*!< 180 degree rotation. */
|
||||
MFX_ROTATION_270 = 3 /*!< 270 degree rotation. */
|
||||
};
|
||||
|
||||
enum {
|
||||
MFX_EXTBUFF_JPEG_QT = MFX_MAKEFOURCC('J','P','G','Q'), /*!< This extended buffer defines quantization tables for JPEG encoder. */
|
||||
MFX_EXTBUFF_JPEG_HUFFMAN = MFX_MAKEFOURCC('J','P','G','H') /*!< This extended buffer defines Huffman tables for JPEG encoder. */
|
||||
};
|
||||
|
||||
/*! The JPEGColorFormat enumerator itemizes the JPEG color format options. */
|
||||
enum {
|
||||
MFX_JPEG_COLORFORMAT_UNKNOWN = 0, /*! Unknown color format. The decoder tries to determine color format from available in bitstream information.
|
||||
If such information is not present, then MFX_JPEG_COLORFORMAT_YCbCr color format is assumed. */
|
||||
MFX_JPEG_COLORFORMAT_YCbCr = 1, /*! Bitstream contains Y, Cb and Cr components. */
|
||||
MFX_JPEG_COLORFORMAT_RGB = 2 /*! Bitstream contains R, G and B components. */
|
||||
};
|
||||
|
||||
/*! The JPEGScanType enumerator itemizes the JPEG scan types. */
|
||||
enum {
|
||||
MFX_SCANTYPE_UNKNOWN = 0, /*!< Unknown scan type. */
|
||||
MFX_SCANTYPE_INTERLEAVED = 1, /*!< Interleaved scan. */
|
||||
MFX_SCANTYPE_NONINTERLEAVED = 2 /*!< Non-interleaved scan. */
|
||||
};
|
||||
|
||||
enum {
|
||||
MFX_CHROMAFORMAT_JPEG_SAMPLING = 6 /*!< Color sampling specified via mfxInfoMFX::SamplingFactorH and SamplingFactorV. */
|
||||
};
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*!
|
||||
Specifies quantization tables. The application may specify up to 4 quantization tables. The encoder assigns an ID to each table.
|
||||
That ID is equal to the table index in the Qm array. Table "0" is used for encoding of the Y component, table "1" for the U component, and table "2"
|
||||
for the V component. The application may specify fewer tables than the number of components in the image. If two tables are specified,
|
||||
then table "1" is used for both U and V components. If only one table is specified then it is used for all components in the image.
|
||||
The following table illustrates this behavior.
|
||||
|
||||
@internal
|
||||
+------------------+---------+------+---+
|
||||
| Table ID | 0 | 1 | 2 |
|
||||
+------------------+---------+------+---+
|
||||
| Number of tables | | | |
|
||||
+==================+=========+======+===+
|
||||
| 0 | Y, U, V | | |
|
||||
+------------------+---------+------+---+
|
||||
| 1 | Y | U, V | |
|
||||
+------------------+---------+------+---+
|
||||
| 2 | Y | U | V |
|
||||
+------------------+---------+------+---+
|
||||
@endinternal
|
||||
*/
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_JPEG_QT. */
|
||||
|
||||
mfxU16 reserved[7];
|
||||
mfxU16 NumTable; /*!< Number of quantization tables defined in Qm array. */
|
||||
|
||||
mfxU16 Qm[4][64]; /*!< Quantization table values. */
|
||||
} mfxExtJPEGQuantTables;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*!
|
||||
Specifies Huffman tables. The application may specify up to 2 quantization table pairs for baseline process. The encoder
|
||||
assigns an ID to each table. That ID is equal to the table index in the DCTables and ACTables arrays. Table "0" is used for encoding of the Y component and
|
||||
table "1" is used for encoding of the U and V component. The application may specify only one table, in which case the table will be used for all components in the image.
|
||||
The following table illustrates this behavior.
|
||||
|
||||
@internal
|
||||
+------------------+---------+------+
|
||||
| Table ID | 0 | 1 |
|
||||
+------------------+---------+------+
|
||||
| Number of tables | | |
|
||||
+==================+=========+======+
|
||||
| 0 | Y, U, V | |
|
||||
+------------------+---------+------+
|
||||
| 1 | Y | U, V |
|
||||
+------------------+---------+------+
|
||||
@endinternal
|
||||
*/
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_JPEG_HUFFMAN. */
|
||||
|
||||
mfxU16 reserved[2];
|
||||
mfxU16 NumDCTable; /*!< Number of DC quantization table in DCTables array. */
|
||||
mfxU16 NumACTable; /*!< Number of AC quantization table in ACTables array. */
|
||||
|
||||
struct {
|
||||
mfxU8 Bits[16]; /*!< Number of codes for each code length. */
|
||||
mfxU8 Values[12]; /*!< List of the 8-bit symbol values. */
|
||||
} DCTables[4]; /*!< Array of DC tables. */
|
||||
|
||||
struct {
|
||||
mfxU8 Bits[16]; /*!< Number of codes for each code length. */
|
||||
mfxU8 Values[162]; /*!< Array of AC tables. */
|
||||
} ACTables[4]; /*!< List of the 8-bit symbol values. */
|
||||
} mfxExtJPEGHuffmanTables;
|
||||
MFX_PACK_END()
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif // __MFX_JPEG_H__
|
||||
+348
@@ -0,0 +1,348 @@
|
||||
/*############################################################################
|
||||
# Copyright Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#ifndef __MFXMEMORY_H__
|
||||
#define __MFXMEMORY_H__
|
||||
#include "mfxsession.h"
|
||||
#include "mfxstructures.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@brief
|
||||
Returns surface which can be used as input for VPP.
|
||||
|
||||
VPP should be initialized before this call.
|
||||
Surface should be released with mfxFrameSurface1::FrameInterface.Release(...) after usage. The value of mfxFrameSurface1::Data.Locked for the returned surface is 0.
|
||||
|
||||
|
||||
@param[in] session Session handle.
|
||||
@param[out] surface Pointer is set to valid mfxFrameSurface1 object.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE The function completed successfully. \n
|
||||
MFX_ERR_NULL_PTR If double-pointer to the @p surface is NULL. \n
|
||||
MFX_ERR_INVALID_HANDLE If @p session was not initialized. \n
|
||||
MFX_ERR_NOT_INITIALIZED If VPP was not initialized (allocator needs to know surface size from somewhere). \n
|
||||
MFX_ERR_MEMORY_ALLOC In case of any other internal allocation error. \n
|
||||
MFX_WRN_ALLOC_TIMEOUT_EXPIRED In case of waiting timeout expired (if set with mfxExtAllocationHints).
|
||||
|
||||
@since This function is available since API version 2.0.
|
||||
|
||||
*/
|
||||
mfxStatus MFX_CDECL MFXMemory_GetSurfaceForVPP(mfxSession session, mfxFrameSurface1** surface);
|
||||
|
||||
/*!
|
||||
@brief
|
||||
Returns surface which can be used as output of VPP.
|
||||
|
||||
VPP should be initialized before this call.
|
||||
Surface should be released with mfxFrameSurface1::FrameInterface.Release(...) after usage. The value of mfxFrameSurface1::Data.Locked for the returned surface is 0.
|
||||
|
||||
|
||||
@param[in] session Session handle.
|
||||
@param[out] surface Pointer is set to valid mfxFrameSurface1 object.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE The function completed successfully. \n
|
||||
MFX_ERR_NULL_PTR If double-pointer to the @p surface is NULL. \n
|
||||
MFX_ERR_INVALID_HANDLE If @p session was not initialized. \n
|
||||
MFX_ERR_NOT_INITIALIZED If VPP was not initialized (allocator needs to know surface size from somewhere). \n
|
||||
MFX_ERR_MEMORY_ALLOC In case of any other internal allocation error. \n
|
||||
MFX_WRN_ALLOC_TIMEOUT_EXPIRED In case of waiting timeout expired (if set with mfxExtAllocationHints).
|
||||
|
||||
@since This function is available since API version 2.1.
|
||||
|
||||
*/
|
||||
mfxStatus MFX_CDECL MFXMemory_GetSurfaceForVPPOut(mfxSession session, mfxFrameSurface1** surface);
|
||||
|
||||
/*! Alias for MFXMemory_GetSurfaceForVPP function. */
|
||||
#define MFXMemory_GetSurfaceForVPPIn MFXMemory_GetSurfaceForVPP
|
||||
|
||||
/*!
|
||||
@brief
|
||||
Returns a surface which can be used as input for the encoder.
|
||||
|
||||
Encoder should be initialized before this call.
|
||||
Surface should be released with mfxFrameSurface1::FrameInterface.Release(...) after usage. The value of mfxFrameSurface1::Data.Locked for the returned surface is 0.
|
||||
|
||||
|
||||
|
||||
@param[in] session Session handle.
|
||||
@param[out] surface Pointer is set to valid mfxFrameSurface1 object.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE The function completed successfully.\n
|
||||
MFX_ERR_NULL_PTR If surface is NULL.\n
|
||||
MFX_ERR_INVALID_HANDLE If session was not initialized.\n
|
||||
MFX_ERR_NOT_INITIALIZED If the encoder was not initialized (allocator needs to know surface size from somewhere).\n
|
||||
MFX_ERR_MEMORY_ALLOC In case of any other internal allocation error. \n
|
||||
MFX_WRN_ALLOC_TIMEOUT_EXPIRED In case of waiting timeout expired (if set with mfxExtAllocationHints).
|
||||
|
||||
@since This function is available since API version 2.0.
|
||||
|
||||
*/
|
||||
mfxStatus MFX_CDECL MFXMemory_GetSurfaceForEncode(mfxSession session, mfxFrameSurface1** surface);
|
||||
|
||||
/*!
|
||||
@brief
|
||||
Returns a surface which can be used as output of the decoder.
|
||||
|
||||
Decoder should be initialized before this call.
|
||||
Surface should be released with mfxFrameSurface1::FrameInterface.Release(...) after usage. The value of mfxFrameSurface1::Data.Locked for the returned surface is 0.'
|
||||
|
||||
@note This function was added to simplify transition from legacy surface management to the proposed internal allocation approach.
|
||||
Previously, the user allocated surfaces for the working pool and fed them to the decoder using DecodeFrameAsync calls. With MFXMemory_GetSurfaceForDecode
|
||||
it is possible to change the existing pipeline by just changing the source of work surfaces.
|
||||
Newly developed applications should prefer direct usage of DecodeFrameAsync with internal allocation.
|
||||
|
||||
|
||||
@param[in] session Session handle.
|
||||
@param[out] surface Pointer is set to valid mfxFrameSurface1 object.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE The function completed successfully.\n
|
||||
MFX_ERR_NULL_PTR If surface is NULL.\n
|
||||
MFX_ERR_INVALID_HANDLE If session was not initialized.\n
|
||||
MFX_ERR_NOT_INITIALIZED If the decoder was not initialized (allocator needs to know surface size from somewhere).\n
|
||||
MFX_ERR_MEMORY_ALLOC Other internal allocation error. \n
|
||||
MFX_WRN_ALLOC_TIMEOUT_EXPIRED In case of waiting timeout expired (if set with mfxExtAllocationHints).
|
||||
|
||||
@since This function is available since API version 2.0.
|
||||
|
||||
*/
|
||||
mfxStatus MFX_CDECL MFXMemory_GetSurfaceForDecode(mfxSession session, mfxFrameSurface1** surface);
|
||||
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
typedef struct {
|
||||
mfxSurfaceInterface SurfaceInterface;
|
||||
|
||||
mfxHDL texture2D; /*!< Pointer to texture, type ID3D11Texture2D* */
|
||||
mfxHDL reserved[7];
|
||||
} mfxSurfaceD3D11Tex2D;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
typedef struct {
|
||||
mfxSurfaceInterface SurfaceInterface;
|
||||
|
||||
mfxHDL vaDisplay; /*!< Object of type VADisplay. */
|
||||
mfxU32 vaSurfaceID; /*!< Object of type VASurfaceID. */
|
||||
mfxU32 reserved1;
|
||||
|
||||
mfxHDL reserved[6];
|
||||
} mfxSurfaceVAAPI;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*!
|
||||
Optional extension buffer, which can be attached to mfxSurfaceHeader::ExtParam
|
||||
(second parameter of mfxFrameSurfaceInterface::Export) in order to pass OCL parameters
|
||||
during mfxFrameSurface1 exporting to OCL surface.
|
||||
If buffer is not provided all resources will be created by oneAPI Video Processing Library (oneVPL) RT internally.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_EXPORT_SHARING_DESC_OCL. */
|
||||
|
||||
mfxHDL ocl_context; /*!< Object of type cl_context (OpenCL context). */
|
||||
mfxHDL ocl_command_queue; /*!< Object of type cl_command_queue (OpenCL command queue). */
|
||||
|
||||
mfxHDL reserved[8];
|
||||
} mfxExtSurfaceOpenCLImg2DExportDescription;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
typedef struct {
|
||||
mfxSurfaceInterface SurfaceInterface;
|
||||
|
||||
mfxHDL ocl_context; /*!< Object of type cl_context (OpenCL context). */
|
||||
mfxHDL ocl_command_queue; /*!< Object of type cl_command_queue (OpenCL command queue). */
|
||||
|
||||
mfxHDL ocl_image[4]; /*!< Object of type cl_mem[4] (array of 4 OpenCL 2D images). */
|
||||
mfxU32 ocl_image_num; /*!< Number of valid images (planes), depends on color format. */
|
||||
|
||||
mfxHDL reserved[8];
|
||||
} mfxSurfaceOpenCLImg2D;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*!
|
||||
Optional extension buffer, which can be attached to mfxSurfaceHeader::ExtParam
|
||||
(second parameter of mfxFrameSurfaceInterface::Export) in order to pass D3D12 parameters
|
||||
during mfxFrameSurface1 exporting to D3D12 resource.
|
||||
If buffer is not provided all resources will be created by oneAPI Video Processing Library (oneVPL) RT internally.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_EXPORT_SHARING_DESC_D3D12. */
|
||||
|
||||
mfxHDL d3d12Device; /*!< Pointer to D3D12 Device, type ID3D12Device*. */
|
||||
|
||||
mfxHDL reserved[9];
|
||||
} mfxExtSurfaceD3D12Tex2DExportDescription;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
typedef struct {
|
||||
mfxSurfaceInterface SurfaceInterface;
|
||||
|
||||
mfxHDL texture2D; /*!< Pointer to D3D12 resource, type ID3D12Resource*. */
|
||||
|
||||
mfxHDL reserved[7];
|
||||
} mfxSurfaceD3D12Tex2D;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*!
|
||||
Optional extension buffer, which can be attached to mfxSurfaceHeader::ExtParam
|
||||
(second parameter of mfxFrameSurfaceInterface::Export) in order to pass Vulkan parameters
|
||||
during mfxFrameSurface1 exporting to Vulkan surface.
|
||||
If buffer is not provided all resources will be created by oneAPI Video Processing Library (oneVPL) RT internally.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_EXPORT_SHARING_DESC_VULKAN. */
|
||||
|
||||
mfxHDL instance; /*!< Object of type VkInstance (Vulkan instance). */
|
||||
mfxHDL physicalDevice; /*!< Object of type VkPhysicalDevice (Vulkan physical device). */
|
||||
mfxHDL device; /*!< Object of type VkDevice (Vulkan device). */
|
||||
|
||||
mfxHDL reserved[7];
|
||||
} mfxExtSurfaceVulkanImg2DExportDescription;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
typedef struct {
|
||||
mfxSurfaceInterface SurfaceInterface;
|
||||
|
||||
mfxHDL instance; /*!< Object of type VkInstance (Vulkan instance). */
|
||||
mfxHDL physicalDevice; /*!< Object of type VkPhysicalDevice (Vulkan physical device). */
|
||||
mfxHDL device; /*!< Object of type VkDevice (Vulkan device). */
|
||||
|
||||
mfxHDL image2D; /*!< Object of type VkImage (Vulkan 2D images). */
|
||||
mfxHDL image2DMemory; /*!< Object of type VkDeviceMemory (Vulkan device memory). */
|
||||
|
||||
mfxHDL reserved[10];
|
||||
} mfxSurfaceVulkanImg2D;
|
||||
MFX_PACK_END()
|
||||
|
||||
/*! The mfxSurfaceComponent enumerator specifies the internal surface pool to use when importing surfaces. */
|
||||
typedef enum {
|
||||
MFX_SURFACE_COMPONENT_UNKNOWN = 0, /*!< Unknown surface component. */
|
||||
|
||||
MFX_SURFACE_COMPONENT_ENCODE = 1, /*!< Shared surface for encoding. */
|
||||
MFX_SURFACE_COMPONENT_DECODE = 2, /*!< Shared surface for decoding. */
|
||||
MFX_SURFACE_COMPONENT_VPP_INPUT = 3, /*!< Shared surface for VPP input. */
|
||||
MFX_SURFACE_COMPONENT_VPP_OUTPUT = 4, /*!< Shared surface for VPP output. */
|
||||
} mfxSurfaceComponent;
|
||||
|
||||
/*! The current version of mfxSurfaceTypesSupported structure. */
|
||||
#define MFX_SURFACETYPESSUPPORTED_VERSION MFX_STRUCT_VERSION(1, 0)
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*! This structure describes the supported surface types and modes. */
|
||||
typedef struct {
|
||||
mfxStructVersion Version; /*!< Version of the structure. */
|
||||
|
||||
mfxU16 NumSurfaceTypes; /*!< Number of supported surface types. */
|
||||
struct surftype {
|
||||
mfxSurfaceType SurfaceType; /*!< Supported surface type. */
|
||||
mfxU32 reserved[6]; /*!< Reserved for future use. */
|
||||
mfxU16 NumSurfaceComponents; /*!< Number of supported surface components. */
|
||||
struct surfcomp {
|
||||
mfxSurfaceComponent SurfaceComponent; /*!< Supported surface component. */
|
||||
mfxU32 SurfaceFlags; /*!< Supported surface flags for this component (may be OR'd). */
|
||||
mfxU32 reserved[7]; /*!< Reserved for future use. */
|
||||
} *SurfaceComponents;
|
||||
} *SurfaceTypes;
|
||||
|
||||
mfxU32 reserved[4]; /*!< Reserved for future use. */
|
||||
} mfxSurfaceTypesSupported;
|
||||
MFX_PACK_END()
|
||||
|
||||
#define MFX_MEMORYINTERFACE_VERSION MFX_STRUCT_VERSION(1, 1)
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/* Specifies memory interface. */
|
||||
typedef struct mfxMemoryInterface {
|
||||
mfxHDL Context; /*!< The context of the memory interface. User should not touch (change, set, null) this pointer. */
|
||||
mfxStructVersion Version; /*!< The version of the structure. */
|
||||
|
||||
/*!
|
||||
@brief
|
||||
Imports an application-provided surface into mfxFrameSurface1 which may be used as input for encoding or video processing.
|
||||
|
||||
@param[in] memory_interface Valid memory interface.
|
||||
@param[in] surf_component Surface component type. Required for allocating new surfaces from the appropriate pool.
|
||||
@param[in,out] external_surface Pointer to the mfxSurfaceXXX object describing the surface to be imported. All fields in
|
||||
mfxSurfaceHeader must be set by the application. mfxSurfaceHeader::SurfaceType is
|
||||
read by oneVPL runtime to determine which particular mfxSurfaceXXX structure is supplied.
|
||||
For example, if mfxSurfaceXXX::SurfaceType == MFX_SURFACE_TYPE_D3D11_TEX2D, then the handle
|
||||
will be interpreted as an object of type mfxSurfaceD3D11Tex2D. The application should
|
||||
set or clear other fields as specified in the corresponding structure description.
|
||||
After successful import, the value of mfxSurfaceHeader::SurfaceFlags will be replaced with the actual
|
||||
import type. It can be used to determine which import type (with or without copy) took place in the case
|
||||
of initial default setting, or if multiple import flags were OR'ed.
|
||||
All external sync operations on the ext_surface must be completed before calling this function.
|
||||
@param[out] imported_surface Pointer to a valid mfxFrameSurface1 object containing the imported frame.
|
||||
imported_surface may be passed as an input to Encode or VPP processing operations.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE The function completed successfully.\n
|
||||
MFX_ERR_NULL_PTR If ext_surface or imported_surface are NULL.\n
|
||||
MFX_ERR_INVALID_HANDLE If the corresponding session was not initialized.\n
|
||||
MFX_ERR_UNSUPPORTED If surf_component is not one of [MFX_SURFACE_COMPONENT_ENCODE, MFX_SURFACE_COMPONENT_VPP_INPUT], or if
|
||||
mfxSurfaceHeader::SurfaceType is not supported by oneVPL runtime for this operation.\n
|
||||
|
||||
@since This function is available since API version 2.10.
|
||||
*/
|
||||
|
||||
/* For reference with Export flow please search for mfxFrameSurfaceInterface::Export. */
|
||||
mfxStatus (MFX_CDECL *ImportFrameSurface)(struct mfxMemoryInterface* memory_interface, mfxSurfaceComponent surf_component, mfxSurfaceHeader* external_surface, mfxFrameSurface1** imported_surface);
|
||||
|
||||
/*!
|
||||
@brief
|
||||
Get a buffer in video memory into mfxBitstream which is used to store bitstream data for video decoding.
|
||||
@param[in] memory_interface Valid memory interface.
|
||||
@param[in,out] queried_bsBuffer Pointer to a valid mfxBitstream object.
|
||||
When the call succeeds, the Data, DataOffset, DataLength, MaxLength, DataFlag of the queried_bsBuffer will be updated.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE The function completed successfully. The Data, DataOffset, DataLength, MaxLength, DataFlag of the queried_bsBuffer will be updated.\n
|
||||
MFX_ERR_NOT_INITIALIZED The function is called before MFXVideoDECODE_Init.\n
|
||||
MFX_ERR_INVALID_HANDLE The input memory_interface is an invalid interface.\n
|
||||
MFX_ERR_NULL_PTR The input queried_bsBuffer is a null pointer.\n
|
||||
MFX_ERR_UNSUPPORTED The function is not supported for this codec.\n
|
||||
MFX_ERR_DEVICE_FAILED The function fails to get the bitstream buffer in video memory.\n
|
||||
|
||||
@note This function should be called after MFXVideoDECODE_Init succeeds.
|
||||
The bitstream buffer returned in queried_bsBuffer will be managed by the runtime and has been mapped for CPU access. The application does not need to allocate or delete memory for this buffer.
|
||||
It will be allocated by runtime when the codec supports this function. It will be released automatically when the corresponding DecodeFrameAsync succeeds.
|
||||
The mfxBitstream::Data will be reset to nullptr by DecodeFrameAsync when the buffer is released internally.
|
||||
The MFX_BITSTREAM_IN_VIDEO_MEMORY bit of mfxBitstream::DataFlag will be set if this function succeeds, indicating the bitstream buffer is in video memory.
|
||||
It is required for app to ensure the bitstream is a single complete frame (set the MFX_BITSTREAM_COMPLETE_FRAME of queried_bsBuffer->DataFlag) when using this function.
|
||||
If the bitstream is not a complete frame, the mfxFrameData::Corrupted of the output surface will be set with MFX_CORRUPTION_MAJOR or MFX_CORRUPTION_MINOR according to the hardware decoding status.
|
||||
|
||||
@since This function is available since API version 2.17.
|
||||
*/
|
||||
mfxStatus (MFX_CDECL* GetBitstreamBuffer)(struct mfxMemoryInterface* memory_interface, mfxBitstream* queried_bsBuffer);
|
||||
mfxHDL reserved[15];
|
||||
} mfxMemoryInterface;
|
||||
MFX_PACK_END()
|
||||
|
||||
/*! Alias for returning interface of type mfxMemoryInterface. */
|
||||
#define MFXGetMemoryInterface(session, piface) MFXVideoCORE_GetHandle((session), MFX_HANDLE_MEMORY_INTERFACE, (mfxHDL *)(piface))
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
/*############################################################################
|
||||
# Copyright Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#ifndef __MFXMVC_H__
|
||||
#define __MFXMVC_H__
|
||||
|
||||
#include "mfxdefs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* CodecProfile, CodecLevel */
|
||||
enum {
|
||||
/* MVC profiles */
|
||||
MFX_PROFILE_AVC_MULTIVIEW_HIGH = 118, /*!< Multi-view high profile. The encoding of VDEnc or LowPower ON is not supported. */
|
||||
MFX_PROFILE_AVC_STEREO_HIGH = 128 /*!< Stereo high profile. The encoding of VDEnc or LowPower ON is not supported. */
|
||||
};
|
||||
|
||||
/* Extended Buffer Ids */
|
||||
enum {
|
||||
MFX_EXTBUFF_MVC_SEQ_DESC = MFX_MAKEFOURCC('M','V','C','D'), /*!< This extended buffer describes the MVC stream information of view dependencies, view identifiers, and operation points. See the ITU*-T H.264 specification chapter H.7.3.2.1.4 for details. */
|
||||
MFX_EXTBUFF_MVC_TARGET_VIEWS = MFX_MAKEFOURCC('M','V','C','T') /*!< This extended buffer defines target views at the decoder output.*/
|
||||
};
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*!
|
||||
Describes MVC view dependencies.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxU16 ViewId; /*!< View identifier of this dependency structure. */
|
||||
|
||||
mfxU16 NumAnchorRefsL0; /*!< Number of view components for inter-view prediction in the initial reference picture list RefPicList0 for anchor view components. */
|
||||
mfxU16 NumAnchorRefsL1; /*!< Number of view components for inter-view prediction in the initial reference picture list RefPicList1 for anchor view components. */
|
||||
mfxU16 AnchorRefL0[16]; /*!< View identifiers of the view components for inter-view prediction in the initial reference picture list RefPicList0 for anchor view components. */
|
||||
mfxU16 AnchorRefL1[16]; /*!< View identifiers of the view components for inter-view prediction in the initial reference picture list RefPicList1 for anchor view components. */
|
||||
|
||||
mfxU16 NumNonAnchorRefsL0; /*!< Number of view components for inter-view prediction in the initial reference picture list RefPicList0 for non-anchor view components. */
|
||||
mfxU16 NumNonAnchorRefsL1; /*!< Number of view components for inter-view prediction in the initial reference picture list RefPicList1 for non-anchor view components. */
|
||||
mfxU16 NonAnchorRefL0[16]; /*!< View identifiers of the view components for inter-view prediction in the initial reference picture list RefPicList0 for non-anchor view components. */
|
||||
mfxU16 NonAnchorRefL1[16]; /*!< View identifiers of the view components for inter-view prediction in the initial reference picture list RefPicList0 for non-anchor view components. */
|
||||
} mfxMVCViewDependency;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*!
|
||||
Describes the MVC operation point.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxU16 TemporalId; /*!< Temporal identifier of the operation point. */
|
||||
mfxU16 LevelIdc; /*!< Level value signaled for the operation point. */
|
||||
|
||||
mfxU16 NumViews; /*!< Number of views required for decoding the target output views that correspond to the operation point. */
|
||||
mfxU16 NumTargetViews; /*!< Number of target output views for the operation point. */
|
||||
mfxU16 *TargetViewId; /*!< Target output view identifiers for operation point. */
|
||||
} mfxMVCOperationPoint;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*!
|
||||
Describes the MVC stream information of view dependencies, view identifiers, and operation points. See the ITU*-T H.264 specification chapter H.7.3.2.1.4 for details.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_MVC_SEQUENCE_DESCRIPTION. */
|
||||
|
||||
mfxU32 NumView; /*!< Number of views. */
|
||||
mfxU32 NumViewAlloc; /*!< The allocated view dependency array size. */
|
||||
mfxMVCViewDependency *View; /*!< Pointer to a list of the mfxMVCViewDependency. */
|
||||
|
||||
mfxU32 NumViewId; /*!< Number of view identifiers. */
|
||||
mfxU32 NumViewIdAlloc; /*!< The allocated view identifier array size. */
|
||||
mfxU16 *ViewId; /*!< Pointer to the list of view identifier. */
|
||||
|
||||
mfxU32 NumOP; /*!< Number of operation points. */
|
||||
mfxU32 NumOPAlloc; /*!< The allocated operation point array size. */
|
||||
mfxMVCOperationPoint *OP; /*!< Pointer to a list of the mfxMVCOperationPoint structure. */
|
||||
|
||||
mfxU16 NumRefsTotal; /*!< Total number of reference frames in all views required to decode the stream. This value is returned from the MFXVideoDECODE_Decodeheader function. Do not modify this value. */
|
||||
mfxU32 Reserved[16];
|
||||
|
||||
} mfxExtMVCSeqDesc;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*!
|
||||
Configures views for the decoding output.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_MVC_TARGET_VIEWS. */
|
||||
|
||||
mfxU16 TemporalId; /*!< The temporal identifier to be decoded. */
|
||||
mfxU32 NumView; /*!< The number of views to be decoded. */
|
||||
mfxU16 ViewId[1024]; /*!< List of view identifiers to be decoded. */
|
||||
} mfxExtMVCTargetViews ;
|
||||
MFX_PACK_END()
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*############################################################################
|
||||
# Copyright Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#ifndef __MFXPCP_H__
|
||||
#define __MFXPCP_H__
|
||||
#include "mfxstructures.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*! The Protected enumerator describes the protection schemes. */
|
||||
enum {
|
||||
MFX_PROTECTION_CENC_WV_CLASSIC = 0x0004, /*!< The protection scheme is based on the Widevine* DRM from Google*. */
|
||||
MFX_PROTECTION_CENC_WV_GOOGLE_DASH = 0x0005, /*!< The protection scheme is based on the Widevine* Modular DRM* from Google*. */
|
||||
};
|
||||
|
||||
/* Extended Buffer Ids */
|
||||
enum {
|
||||
MFX_EXTBUFF_CENC_PARAM = MFX_MAKEFOURCC('C','E','N','P') /*!< This structure is used to pass decryption status report index for Common
|
||||
Encryption usage model. See the mfxExtCencParam structure for more details. */
|
||||
};
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*!
|
||||
Used to pass the decryption status report index for the Common Encryption usage model. The application can
|
||||
attach this extended buffer to the mfxBitstream structure at runtime.
|
||||
*/
|
||||
typedef struct _mfxExtCencParam{
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_CENC_PARAM. */
|
||||
|
||||
mfxU32 StatusReportIndex; /*!< Decryption status report index. */
|
||||
mfxU32 reserved[15];
|
||||
} mfxExtCencParam;
|
||||
MFX_PACK_END()
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,234 @@
|
||||
/*############################################################################
|
||||
# Copyright Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#ifndef __MFXSESSION_H__
|
||||
#define __MFXSESSION_H__
|
||||
#include "mfxcommon.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* Global Functions */
|
||||
|
||||
/*! Session handle. */
|
||||
typedef struct _mfxSession *mfxSession;
|
||||
|
||||
/*!
|
||||
@brief
|
||||
Creates and initializes a session in the legacy mode for compatibility with Intel(r) Media SDK applications.
|
||||
This function is deprecated starting from API version 2.0, applications must use MFXLoad with mfxCreateSession
|
||||
to select the implementation and initialize the session.
|
||||
|
||||
Call this function before calling
|
||||
any other API function. If the desired implementation specified by ``impl`` is MFX_IMPL_AUTO,
|
||||
the function will search for the platform-specific implementation.
|
||||
If the function cannot find the platform-specific implementation, it will use the software implementation instead.
|
||||
|
||||
The ``ver`` argument indicates the desired version of the library implementation.
|
||||
The loaded implementation will have an API version compatible to the specified version (equal in
|
||||
the major version number, and no less in the minor version number.) If the desired version
|
||||
is not specified, the default is to use the API version from the library release with
|
||||
which an application is built.
|
||||
|
||||
Production applications should always specify the minimum API version that meets the
|
||||
functional requirements. For example, if an application uses only H.264 decoding as described
|
||||
in API v1.0, the application should initialize the library with API v1.0. This ensures
|
||||
backward compatibility.
|
||||
|
||||
@param[in] impl mfxIMPL enumerator that indicates the desired legacy Intel(r) Media SDK implementation.
|
||||
@param[in] ver Pointer to the minimum library version or zero, if not specified.
|
||||
@param[out] session Pointer to the legacy Intel(r) Media SDK session handle.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE The function completed successfully. The output parameter contains the handle of the session.\n
|
||||
MFX_ERR_UNSUPPORTED The function cannot find the desired legacy Intel(r) Media SDK implementation or version.
|
||||
|
||||
@since This function is available since API version 1.0.
|
||||
|
||||
@deprecated Deprecated in API version 2.3. Use MFXLoad and MFXCreateSession to initialize the session.
|
||||
Use MFX_DEPRECATED_OFF macro to turn off the deprecation message visualization.
|
||||
*/
|
||||
MFX_DEPRECATED mfxStatus MFX_CDECL MFXInit(mfxIMPL impl, mfxVersion *ver, mfxSession *session);
|
||||
|
||||
/*!
|
||||
@brief
|
||||
Creates and initializes a session in the legacy mode for compatibility with Intel(r) Media SDK applications.
|
||||
This function is deprecated starting from API version 2.0, applications must use MFXLoad with mfxCreateSession
|
||||
to select the implementation and initialize the session.
|
||||
|
||||
Call this function before calling any other API functions.
|
||||
If the desired implementation specified by ``par`` is MFX_IMPL_AUTO, the function will search for
|
||||
the platform-specific implementation. If the function cannot find the platform-specific implementation, it will use the software implementation instead.
|
||||
|
||||
The argument ``par.Version`` indicates the desired version of the implementation. The loaded implementation will have an API
|
||||
version compatible to the specified version (equal in the major version number, and no less in the minor version number.)
|
||||
If the desired version is not specified, the default is to use the API version from the library release with
|
||||
which an application is built.
|
||||
|
||||
Production applications should always specify the minimum API version that meets the functional requirements.
|
||||
For example, if an application uses only H.264 decoding as described in API v1.0, the application should initialize the library with API v1.0. This ensures backward compatibility.
|
||||
|
||||
The argument ``par.ExternalThreads`` specifies threading mode. Value 0 means that the implementation should create and
|
||||
handle work threads internally (this is essentially the equivalent of the regular MFXInit).
|
||||
|
||||
@param[in] par mfxInitParam structure that indicates the desired implementation, minimum library version and desired threading mode.
|
||||
@param[out] session Pointer to the session handle.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE The function completed successfully. The output parameter contains the handle of the session.\n
|
||||
MFX_ERR_UNSUPPORTED The function cannot find the desired implementation or version.
|
||||
|
||||
@since This function is available since API version 1.14.
|
||||
|
||||
@deprecated Deprecated in API version 2.3. Use MFXLoad and MFXCreateSession to initialize the session.
|
||||
Use MFX_DEPRECATED_OFF macro to turn off the deprecation message visualization.
|
||||
*/
|
||||
MFX_DEPRECATED mfxStatus MFX_CDECL MFXInitEx(mfxInitParam par, mfxSession *session);
|
||||
|
||||
/*!
|
||||
@brief
|
||||
Creates and initializes a session starting from API version 2.0. This function is used by the dispatcher.
|
||||
The dispatcher creates and fills the mfxInitializationParam structure according to mfxConfig values set by an application.
|
||||
Calling this function directly is not recommended. Instead, applications must call the MFXCreateSession function.
|
||||
|
||||
|
||||
@param[in] par mfxInitializationParam structure that indicates the minimum library version and acceleration type.
|
||||
@param[out] session Pointer to the session handle.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE The function completed successfully. The output parameter contains the handle of the session.\n
|
||||
MFX_ERR_UNSUPPORTED The function cannot find the desired implementation or version.
|
||||
|
||||
@since This function is available since API version 2.0.
|
||||
*/
|
||||
mfxStatus MFX_CDECL MFXInitialize(mfxInitializationParam par, mfxSession *session);
|
||||
|
||||
/*!
|
||||
@brief Completes and deinitializes a session. Any active tasks in execution or
|
||||
in queue are aborted. The application cannot call any API function after calling this function.
|
||||
|
||||
All child sessions must be disjoined before closing a parent session.
|
||||
@param[in] session session handle.
|
||||
|
||||
@return MFX_ERR_NONE The function completed successfully.
|
||||
|
||||
@since This function is available since API version 1.0.
|
||||
*/
|
||||
mfxStatus MFX_CDECL MFXClose(mfxSession session);
|
||||
|
||||
/*!
|
||||
@brief Returns the implementation type of a given session.
|
||||
|
||||
@param[in] session Session handle.
|
||||
@param[out] impl Pointer to the implementation type
|
||||
|
||||
@return MFX_ERR_NONE The function completed successfully.
|
||||
|
||||
@since This function is available since API version 1.0.
|
||||
*/
|
||||
mfxStatus MFX_CDECL MFXQueryIMPL(mfxSession session, mfxIMPL *impl);
|
||||
|
||||
/*!
|
||||
@brief Returns the implementation version.
|
||||
|
||||
@param[in] session Session handle.
|
||||
@param[out] version Pointer to the returned implementation version.
|
||||
|
||||
@return MFX_ERR_NONE The function completed successfully.
|
||||
|
||||
@since This function is available since API version 1.0.
|
||||
*/
|
||||
mfxStatus MFX_CDECL MFXQueryVersion(mfxSession session, mfxVersion *version);
|
||||
|
||||
/*!
|
||||
@brief Joins the child session to the current session.
|
||||
|
||||
After joining, the two sessions share thread and resource scheduling for asynchronous
|
||||
operations. However, each session still maintains its own device manager and buffer/frame
|
||||
allocator. Therefore, the application must use a compatible device manager and buffer/frame
|
||||
allocator to share data between two joined sessions.
|
||||
|
||||
The application can join multiple sessions by calling this function multiple times. When joining
|
||||
the first two sessions, the current session becomes the parent responsible for thread and
|
||||
resource scheduling of any later joined sessions.
|
||||
|
||||
Joining of two parent sessions is not supported.
|
||||
|
||||
@param[in,out] session The current session handle.
|
||||
@param[in] child The child session handle to be joined
|
||||
|
||||
@return MFX_ERR_NONE The function completed successfully. \n
|
||||
MFX_WRN_IN_EXECUTION Active tasks are executing or in queue in one of the
|
||||
sessions. Call this function again after all tasks are completed. \n
|
||||
MFX_ERR_UNSUPPORTED The child session cannot be joined with the current session.
|
||||
|
||||
@since This function is available since API version 1.1.
|
||||
*/
|
||||
mfxStatus MFX_CDECL MFXJoinSession(mfxSession session, mfxSession child);
|
||||
|
||||
/*!
|
||||
@brief Removes the joined state of the current session.
|
||||
|
||||
After disjoining, the current session becomes independent. The application must ensure there is no active task running in the session before calling this API function.
|
||||
|
||||
@param[in,out] session The current session handle.
|
||||
|
||||
@return MFX_ERR_NONE The function completed successfully. \n
|
||||
MFX_WRN_IN_EXECUTION Active tasks are executing or in queue in one of the
|
||||
sessions. Call this function again after all tasks are completed. \n
|
||||
MFX_ERR_UNDEFINED_BEHAVIOR The session is independent, or this session is the parent of all joined sessions.
|
||||
|
||||
@since This function is available since API version 1.1.
|
||||
*/
|
||||
mfxStatus MFX_CDECL MFXDisjoinSession(mfxSession session);
|
||||
|
||||
/*!
|
||||
@brief Creates a clean copy of the current session.
|
||||
|
||||
The cloned session is an independent session and does not inherit any user-defined buffer, frame allocator, or device manager handles from the current session.
|
||||
This function is a light-weight equivalent of MFXJoinSession after MFXInit.
|
||||
|
||||
@param[in] session The current session handle.
|
||||
@param[out] clone Pointer to the cloned session handle.
|
||||
|
||||
@return MFX_ERR_NONE The function completed successfully.
|
||||
|
||||
@since This function is available since API version 1.1.
|
||||
*/
|
||||
mfxStatus MFX_CDECL MFXCloneSession(mfxSession session, mfxSession *clone);
|
||||
|
||||
/*!
|
||||
@brief Sets the current session priority.
|
||||
|
||||
@param[in] session The current session handle.
|
||||
@param[in] priority Priority value.
|
||||
|
||||
@return MFX_ERR_NONE The function completed successfully.
|
||||
|
||||
@since This function is available since API version 1.1.
|
||||
*/
|
||||
mfxStatus MFX_CDECL MFXSetPriority(mfxSession session, mfxPriority priority);
|
||||
|
||||
/*!
|
||||
@brief Returns the current session priority.
|
||||
|
||||
@param[in] session The current session handle.
|
||||
@param[out] priority Pointer to the priority value.
|
||||
|
||||
@return MFX_ERR_NONE The function completed successfully.
|
||||
|
||||
@since This function is available since API version 1.1.
|
||||
*/
|
||||
mfxStatus MFX_CDECL MFXGetPriority(mfxSession session, mfxPriority *priority);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
+5482
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,184 @@
|
||||
/*############################################################################
|
||||
# Copyright Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#ifndef __MFX_SURFACE_POOL_H__
|
||||
#define __MFX_SURFACE_POOL_H__
|
||||
|
||||
#include "mfxstructures.h"
|
||||
|
||||
/*! GUID to obtain mfxSurfacePoolInterface. */
|
||||
static const mfxGUID MFX_GUID_SURFACE_POOL = {{0x35, 0x24, 0xf3, 0xda, 0x96, 0x4e, 0x47, 0xf1, 0xaf, 0xb4, 0xec, 0xb1, 0x15, 0x08, 0x06, 0xb1}};
|
||||
|
||||
/*! Specifies type of pool for VPP component. */
|
||||
typedef enum {
|
||||
MFX_VPP_POOL_IN = 0, /*!< Input pool. */
|
||||
MFX_VPP_POOL_OUT = 1 /*!< Output pool. */
|
||||
} mfxVPPPoolType;
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*! The extension buffer specifies surface pool management policy.
|
||||
Absence of the attached buffer means MFX_ALLOCATION_UNLIMITED policy:
|
||||
each call of GetSurfaceForXXX leads to surface allocation.
|
||||
*/
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_ALLOCATION_HINTS. */
|
||||
mfxPoolAllocationPolicy AllocationPolicy; /*!< Allocation policy. */
|
||||
/*! How many surfaces to allocate during Init.
|
||||
It's applicable for any polices set by mfxPoolAllocationPolicy::AllocationPolicy
|
||||
even if the requested number exceeds recommended size of the pool. */
|
||||
mfxU32 NumberToPreAllocate;
|
||||
/*! DeltaToAllocateOnTheFly specifies how many surfaces are allocated
|
||||
in addition to NumberToPreAllocate in MFX_ALLOCATION_LIMITED mode.
|
||||
Maximum number of allocated frames will be
|
||||
NumberToPreAllocate + DeltaToAllocateOnTheFly.
|
||||
*/
|
||||
mfxU32 DeltaToAllocateOnTheFly;
|
||||
union {
|
||||
mfxVPPPoolType VPPPoolType; /*!< Defines what VPP pool is targeted - input or output. Ignored for other components. */
|
||||
mfxU32 reserved;
|
||||
};
|
||||
mfxU32 Wait; /*!< Time in milliseconds for GetSurfaceForXXX() and DecodeFrameAsync functions to wait until surface will be available. */
|
||||
mfxU32 reserved1[4]; /*!< Reserved for future use */
|
||||
} mfxExtAllocationHints;
|
||||
MFX_PACK_END()
|
||||
|
||||
MFX_PACK_BEGIN_STRUCT_W_PTR()
|
||||
/*! Specifies the surface pool interface. */
|
||||
typedef struct mfxSurfacePoolInterface
|
||||
{
|
||||
mfxHDL Context; /*!< The context of the surface pool interface. User should not touch (change, set, null) this pointer. */
|
||||
|
||||
/*! @brief
|
||||
Increments the internal reference counter of the mfxSurfacePoolInterface. The mfxSurfacePoolInterface is not destroyed until the
|
||||
mfxSurfacePoolInterface is destroyed with mfxSurfacePoolInterface::Release function. mfxSurfacePoolInterface::AddRef should be used each time a new link to the
|
||||
mfxSurfacePoolInterface is created for proper management.
|
||||
|
||||
@param[in] pool Valid pool.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE If no error. \n
|
||||
MFX_ERR_NULL_PTR If pool is NULL. \n
|
||||
MFX_ERR_INVALID_HANDLE If mfxSurfacePoolInterface->Context is invalid (for example NULL). \n
|
||||
MFX_ERR_UNKNOWN Any internal error.
|
||||
|
||||
*/
|
||||
mfxStatus (MFX_CDECL *AddRef)(struct mfxSurfacePoolInterface *pool);
|
||||
/*! @brief
|
||||
Decrements the internal reference counter of the mfxSurfacePoolInterface. mfxSurfacePoolInterface::Release
|
||||
should be called after using the mfxSurfacePoolInterface::AddRef function to add a mfxSurfacePoolInterface or when allocation logic requires it.
|
||||
For example, call mfxSurfacePoolInterface::Release to release a mfxSurfacePoolInterface obtained with
|
||||
the mfxFrameSurfaceInterface::QueryInterface function.
|
||||
|
||||
@param[in] pool Valid pool.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE If no error. \n
|
||||
MFX_ERR_NULL_PTR If pool is NULL. \n
|
||||
MFX_ERR_INVALID_HANDLE If mfxSurfacePoolInterface->Context is invalid (for example NULL). \n
|
||||
MFX_ERR_UNDEFINED_BEHAVIOR If Reference Counter of mfxSurfacePoolInterface is zero before call. \n
|
||||
MFX_ERR_UNKNOWN Any internal error.
|
||||
*/
|
||||
mfxStatus (MFX_CDECL *Release)(struct mfxSurfacePoolInterface *pool);
|
||||
/*! @brief
|
||||
Returns current reference counter of mfxSurfacePoolInterface structure.
|
||||
|
||||
@param[in] pool Valid pool.
|
||||
@param[out] counter Sets counter to the current reference counter value.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE If no error. \n
|
||||
MFX_ERR_NULL_PTR If pool or counter is NULL. \n
|
||||
MFX_ERR_INVALID_HANDLE If mfxSurfacePoolInterface->Context is invalid (for example NULL). \n
|
||||
MFX_ERR_UNKNOWN Any internal error.
|
||||
*/
|
||||
mfxStatus (MFX_CDECL *GetRefCounter)(struct mfxSurfacePoolInterface *pool, mfxU32* counter);
|
||||
/*! @brief
|
||||
The function should be called by oneAPI Video Processing Library (oneVPL) components or application to specify how many surfaces
|
||||
it will use concurrently.
|
||||
Internally, oneVPL allocates surfaces in the shared pool according to the component's policy set by mfxPoolAllocationPolicy.
|
||||
The exact moment of surfaces allocation is defined by the component and generally independent from that call.
|
||||
|
||||
@param[in] pool Valid pool.
|
||||
@param[in] num_surfaces The number of surfaces required by the component.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE If no error. \n
|
||||
MFX_ERR_NULL_PTR If pool is NULL. \n
|
||||
MFX_ERR_INVALID_HANDLE If mfxSurfacePoolInterface->Context is invalid (for example NULL). \n
|
||||
MFX_WRN_INCOMPATIBLE_VIDEO_PARAM If pool has MFX_ALLOCATION_UNLIMITED or MFX_ALLOCATION_LIMITED policy. \n
|
||||
MFX_ERR_UNKNOWN Any internal error.
|
||||
*/
|
||||
mfxStatus (MFX_CDECL *SetNumSurfaces)(struct mfxSurfacePoolInterface *pool, mfxU32 num_surfaces);
|
||||
|
||||
/*! @brief
|
||||
The function should be called by oneVPL components when component is closed or reset and doesn't need to use pool more. It helps
|
||||
to manage memory accordingly and release redundant memory. Important to specify the same number of surfaces which is requested
|
||||
during SetNumSurfaces call, otherwise it may lead to the pipeline stalls.
|
||||
|
||||
@param[in] pool Valid pool.
|
||||
@param[in] num_surfaces The number of surfaces used by the component.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE If no error. \n
|
||||
|
||||
MFX_WRN_OUT_OF_RANGE If num_surfaces doesn't equal to num_surfaces requested during SetNumSurfaces call. \n
|
||||
|
||||
MFX_ERR_NULL_PTR If pool is NULL. \n
|
||||
MFX_ERR_INVALID_HANDLE If mfxSurfacePoolInterface->Context is invalid (for example NULL). \n
|
||||
MFX_WRN_INCOMPATIBLE_VIDEO_PARAM If pool has MFX_ALLOCATION_UNLIMITED or MFX_ALLOCATION_LIMITED policy. \n
|
||||
MFX_ERR_UNKNOWN Any internal error.
|
||||
*/
|
||||
mfxStatus (MFX_CDECL *RevokeSurfaces)(struct mfxSurfacePoolInterface *pool, mfxU32 num_surfaces);
|
||||
/*! @brief
|
||||
Returns current allocation policy.
|
||||
|
||||
@param[in] pool Valid pool.
|
||||
@param[out] policy Sets policy to the current allocation policy value.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE If no error. \n
|
||||
MFX_ERR_NULL_PTR If pool or policy is NULL. \n
|
||||
MFX_ERR_INVALID_HANDLE If mfxSurfacePoolInterface->Context is invalid (for example NULL). \n
|
||||
MFX_ERR_UNKNOWN Any internal error.
|
||||
*/
|
||||
mfxStatus (MFX_CDECL *GetAllocationPolicy)(struct mfxSurfacePoolInterface *pool, mfxPoolAllocationPolicy *policy);
|
||||
|
||||
/*! @brief
|
||||
Returns maximum pool size. In case of mfxPoolAllocationPolicy::MFX_ALLOCATION_UNLIMITED policy 0xFFFFFFFF will be returned.
|
||||
|
||||
@param[in] pool Valid pool.
|
||||
@param[out] size Sets size to the maximum pool size value.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE If no error. \n
|
||||
MFX_ERR_NULL_PTR If pool or size is NULL. \n
|
||||
MFX_ERR_INVALID_HANDLE If mfxSurfacePoolInterface->Context is invalid (for example NULL). \n
|
||||
MFX_ERR_UNKNOWN Any internal error.
|
||||
*/
|
||||
mfxStatus (MFX_CDECL *GetMaximumPoolSize)(struct mfxSurfacePoolInterface *pool, mfxU32 *size);
|
||||
|
||||
/*! @brief
|
||||
Returns current pool size.
|
||||
|
||||
@param[in] pool Valid pool.
|
||||
@param[out] size Sets size to the current pool size value.
|
||||
|
||||
@return
|
||||
MFX_ERR_NONE If no error. \n
|
||||
MFX_ERR_NULL_PTR If pool or size is NULL. \n
|
||||
MFX_ERR_INVALID_HANDLE If mfxSurfacePoolInterface->Context is invalid (for example NULL). \n
|
||||
MFX_ERR_UNKNOWN Any internal error.
|
||||
*/
|
||||
mfxStatus (MFX_CDECL *GetCurrentPoolSize)(struct mfxSurfacePoolInterface *pool, mfxU32 *size);
|
||||
|
||||
mfxHDL reserved[4]; /*!< Reserved for future use. */
|
||||
|
||||
} mfxSurfacePoolInterface;
|
||||
MFX_PACK_END()
|
||||
|
||||
|
||||
#endif /* __MFX_SURFACE_POOL_H__ */
|
||||
|
||||
@@ -0,0 +1,594 @@
|
||||
/*###########################################################################
|
||||
# Copyright Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
###########################################################################*/
|
||||
|
||||
#ifndef __MFXVIDEOPLUSPLUS_H
|
||||
#define __MFXVIDEOPLUSPLUS_H
|
||||
|
||||
#ifdef MFXVIDEO_CPP_ENABLE_MFXLOAD
|
||||
#include "vpl/mfx.h"
|
||||
#define MFX_IMPL_ACCELMODE(x) (0xff00 & (x))
|
||||
#else
|
||||
#include "mfxvideo.h"
|
||||
#endif
|
||||
|
||||
class MFXVideoSessionBase {
|
||||
public:
|
||||
virtual ~MFXVideoSessionBase() {}
|
||||
|
||||
virtual mfxStatus Init(mfxIMPL impl, mfxVersion* ver) = 0;
|
||||
virtual mfxStatus InitEx(mfxInitParam par) = 0;
|
||||
virtual mfxStatus Close(void) = 0;
|
||||
|
||||
virtual mfxStatus QueryIMPL(mfxIMPL* impl) = 0;
|
||||
virtual mfxStatus QueryVersion(mfxVersion* version) = 0;
|
||||
|
||||
virtual mfxStatus JoinSession(mfxSession child_session) = 0;
|
||||
virtual mfxStatus DisjoinSession() = 0;
|
||||
virtual mfxStatus CloneSession(mfxSession* clone) = 0;
|
||||
virtual mfxStatus SetPriority(mfxPriority priority) = 0;
|
||||
virtual mfxStatus GetPriority(mfxPriority* priority) = 0;
|
||||
|
||||
virtual mfxStatus SetFrameAllocator(mfxFrameAllocator* allocator) = 0;
|
||||
virtual mfxStatus SetHandle(mfxHandleType type, mfxHDL hdl) = 0;
|
||||
virtual mfxStatus GetHandle(mfxHandleType type, mfxHDL* hdl) = 0;
|
||||
virtual mfxStatus QueryPlatform(mfxPlatform* platform) = 0;
|
||||
|
||||
virtual mfxStatus SyncOperation(mfxSyncPoint syncp, mfxU32 wait) = 0;
|
||||
|
||||
virtual mfxStatus GetSurfaceForEncode(mfxFrameSurface1** output_surf) = 0;
|
||||
virtual mfxStatus GetSurfaceForDecode(mfxFrameSurface1** output_surf) = 0;
|
||||
virtual mfxStatus GetSurfaceForVPP(mfxFrameSurface1** output_surf) = 0;
|
||||
virtual mfxStatus GetSurfaceForVPPOut(mfxFrameSurface1** output_surf) = 0;
|
||||
|
||||
virtual operator mfxSession(void) = 0;
|
||||
};
|
||||
|
||||
class MFXVideoENCODEBase {
|
||||
public:
|
||||
virtual ~MFXVideoENCODEBase() {}
|
||||
|
||||
virtual mfxStatus Query(mfxVideoParam* in, mfxVideoParam* out) = 0;
|
||||
virtual mfxStatus QueryIOSurf(mfxVideoParam* par, mfxFrameAllocRequest* request) = 0;
|
||||
virtual mfxStatus Init(mfxVideoParam* par) = 0;
|
||||
virtual mfxStatus Reset(mfxVideoParam* par) = 0;
|
||||
virtual mfxStatus Close(void) = 0;
|
||||
|
||||
virtual mfxStatus GetVideoParam(mfxVideoParam* par) = 0;
|
||||
virtual mfxStatus GetEncodeStat(mfxEncodeStat* stat) = 0;
|
||||
|
||||
virtual mfxStatus EncodeFrameAsync(mfxEncodeCtrl* ctrl,
|
||||
mfxFrameSurface1* surface,
|
||||
mfxBitstream* bs,
|
||||
mfxSyncPoint* syncp) = 0;
|
||||
|
||||
virtual mfxStatus GetSurface(mfxFrameSurface1** output_surf) = 0;
|
||||
};
|
||||
|
||||
class MFXVideoDECODEBase {
|
||||
public:
|
||||
virtual ~MFXVideoDECODEBase() {}
|
||||
|
||||
virtual mfxStatus Query(mfxVideoParam* in, mfxVideoParam* out) = 0;
|
||||
virtual mfxStatus DecodeHeader(mfxBitstream* bs, mfxVideoParam* par) = 0;
|
||||
virtual mfxStatus QueryIOSurf(mfxVideoParam* par, mfxFrameAllocRequest* request) = 0;
|
||||
virtual mfxStatus Init(mfxVideoParam* par) = 0;
|
||||
virtual mfxStatus Reset(mfxVideoParam* par) = 0;
|
||||
virtual mfxStatus Close(void) = 0;
|
||||
|
||||
virtual mfxStatus GetVideoParam(mfxVideoParam* par) = 0;
|
||||
|
||||
virtual mfxStatus GetDecodeStat(mfxDecodeStat* stat) = 0;
|
||||
virtual mfxStatus GetPayload(mfxU64* ts, mfxPayload* payload) = 0;
|
||||
virtual mfxStatus SetSkipMode(mfxSkipMode mode) = 0;
|
||||
virtual mfxStatus DecodeFrameAsync(mfxBitstream* bs,
|
||||
mfxFrameSurface1* surface_work,
|
||||
mfxFrameSurface1** surface_out,
|
||||
mfxSyncPoint* syncp) = 0;
|
||||
|
||||
virtual mfxStatus GetSurface(mfxFrameSurface1** output_surf) = 0;
|
||||
};
|
||||
|
||||
class MFXVideoVPPBase {
|
||||
public:
|
||||
virtual ~MFXVideoVPPBase() {}
|
||||
virtual mfxStatus Query(mfxVideoParam* in, mfxVideoParam* out) = 0;
|
||||
virtual mfxStatus QueryIOSurf(mfxVideoParam* par, mfxFrameAllocRequest request[2]) = 0;
|
||||
virtual mfxStatus Init(mfxVideoParam* par) = 0;
|
||||
virtual mfxStatus Reset(mfxVideoParam* par) = 0;
|
||||
virtual mfxStatus Close(void) = 0;
|
||||
|
||||
virtual mfxStatus GetVideoParam(mfxVideoParam* par) = 0;
|
||||
virtual mfxStatus GetVPPStat(mfxVPPStat* stat) = 0;
|
||||
virtual mfxStatus RunFrameVPPAsync(mfxFrameSurface1* in,
|
||||
mfxFrameSurface1* out,
|
||||
mfxExtVppAuxData* aux,
|
||||
mfxSyncPoint* syncp) = 0;
|
||||
|
||||
virtual mfxStatus GetSurfaceIn(mfxFrameSurface1** output_surf) = 0;
|
||||
virtual mfxStatus GetSurfaceOut(mfxFrameSurface1** output_surf) = 0;
|
||||
virtual mfxStatus ProcessFrameAsync(mfxFrameSurface1* in, mfxFrameSurface1** out) = 0;
|
||||
};
|
||||
|
||||
class MFXVideoSession : public MFXVideoSessionBase {
|
||||
public:
|
||||
MFXVideoSession(void) {
|
||||
m_session = (mfxSession)0;
|
||||
#ifdef MFXVIDEO_CPP_ENABLE_MFXLOAD
|
||||
m_loader = (mfxLoader)0;
|
||||
#endif
|
||||
}
|
||||
virtual ~MFXVideoSession(void) {
|
||||
Close();
|
||||
}
|
||||
|
||||
virtual mfxStatus Init(mfxIMPL impl, mfxVersion *ver) override {
|
||||
#ifdef MFXVIDEO_CPP_ENABLE_MFXLOAD
|
||||
mfxInitParam par = {};
|
||||
par.Implementation = impl;
|
||||
par.Version = *ver;
|
||||
return InitSession(par);
|
||||
#else
|
||||
return MFXInit(impl, ver, &m_session);
|
||||
#endif
|
||||
}
|
||||
virtual mfxStatus InitEx(mfxInitParam par) override {
|
||||
#ifdef MFXVIDEO_CPP_ENABLE_MFXLOAD
|
||||
return InitSession(par);
|
||||
#else
|
||||
return MFXInitEx(par, &m_session);
|
||||
#endif
|
||||
}
|
||||
virtual mfxStatus Close(void) override {
|
||||
#ifdef MFXVIDEO_CPP_ENABLE_MFXLOAD
|
||||
if (m_session) {
|
||||
mfxStatus mfxRes;
|
||||
mfxRes = MFXClose(m_session);
|
||||
m_session = (mfxSession)0;
|
||||
if (m_loader) {
|
||||
MFXUnload(m_loader);
|
||||
m_loader = (mfxLoader)0;
|
||||
}
|
||||
return mfxRes;
|
||||
}
|
||||
else {
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
#else
|
||||
mfxStatus mfxRes;
|
||||
mfxRes = MFXClose(m_session);
|
||||
m_session = (mfxSession)0;
|
||||
return mfxRes;
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual mfxStatus QueryIMPL(mfxIMPL *impl) override {
|
||||
return MFXQueryIMPL(m_session, impl);
|
||||
}
|
||||
virtual mfxStatus QueryVersion(mfxVersion *version) override {
|
||||
return MFXQueryVersion(m_session, version);
|
||||
}
|
||||
|
||||
virtual mfxStatus JoinSession(mfxSession child_session) override {
|
||||
return MFXJoinSession(m_session, child_session);
|
||||
}
|
||||
virtual mfxStatus DisjoinSession() override {
|
||||
return MFXDisjoinSession(m_session);
|
||||
}
|
||||
virtual mfxStatus CloneSession(mfxSession *clone) override {
|
||||
return MFXCloneSession(m_session, clone);
|
||||
}
|
||||
virtual mfxStatus SetPriority(mfxPriority priority) override {
|
||||
return MFXSetPriority(m_session, priority);
|
||||
}
|
||||
virtual mfxStatus GetPriority(mfxPriority *priority) override {
|
||||
return MFXGetPriority(m_session, priority);
|
||||
}
|
||||
|
||||
virtual mfxStatus SetFrameAllocator(mfxFrameAllocator *allocator) override {
|
||||
return MFXVideoCORE_SetFrameAllocator(m_session, allocator);
|
||||
}
|
||||
virtual mfxStatus SetHandle(mfxHandleType type, mfxHDL hdl) override {
|
||||
return MFXVideoCORE_SetHandle(m_session, type, hdl);
|
||||
}
|
||||
virtual mfxStatus GetHandle(mfxHandleType type, mfxHDL *hdl) override {
|
||||
return MFXVideoCORE_GetHandle(m_session, type, hdl);
|
||||
}
|
||||
virtual mfxStatus QueryPlatform(mfxPlatform *platform) override {
|
||||
return MFXVideoCORE_QueryPlatform(m_session, platform);
|
||||
}
|
||||
|
||||
virtual mfxStatus SyncOperation(mfxSyncPoint syncp, mfxU32 wait) override {
|
||||
return MFXVideoCORE_SyncOperation(m_session, syncp, wait);
|
||||
}
|
||||
|
||||
virtual mfxStatus GetSurfaceForEncode(mfxFrameSurface1** output_surf) override {
|
||||
return MFXMemory_GetSurfaceForEncode(m_session, output_surf);
|
||||
}
|
||||
virtual mfxStatus GetSurfaceForDecode(mfxFrameSurface1** output_surf) override {
|
||||
return MFXMemory_GetSurfaceForDecode(m_session, output_surf);
|
||||
}
|
||||
virtual mfxStatus GetSurfaceForVPP (mfxFrameSurface1** output_surf) override {
|
||||
return MFXMemory_GetSurfaceForVPP (m_session, output_surf);
|
||||
}
|
||||
virtual mfxStatus GetSurfaceForVPPOut(mfxFrameSurface1** output_surf) override {
|
||||
return MFXMemory_GetSurfaceForVPPOut(m_session, output_surf);
|
||||
}
|
||||
|
||||
virtual operator mfxSession(void) override {
|
||||
return m_session;
|
||||
}
|
||||
|
||||
protected:
|
||||
mfxSession m_session; // (mfxSession) handle to the owning session
|
||||
|
||||
#ifdef MFXVIDEO_CPP_ENABLE_MFXLOAD
|
||||
mfxLoader m_loader;
|
||||
|
||||
inline void InitVariant(mfxVariant *var, mfxU32 data) {
|
||||
var->Version.Version = (mfxU16)MFX_VARIANT_VERSION;
|
||||
var->Type = MFX_VARIANT_TYPE_U32;
|
||||
var->Data.U32 = data;
|
||||
}
|
||||
|
||||
inline void InitVariant(mfxVariant *var, mfxU16 data) {
|
||||
var->Version.Version = (mfxU16)MFX_VARIANT_VERSION;
|
||||
var->Type = MFX_VARIANT_TYPE_U16;
|
||||
var->Data.U16 = data;
|
||||
}
|
||||
|
||||
inline void InitVariant(mfxVariant *var, mfxHDL data) {
|
||||
var->Version.Version = (mfxU16)MFX_VARIANT_VERSION;
|
||||
var->Type = MFX_VARIANT_TYPE_PTR;
|
||||
var->Data.Ptr = data;
|
||||
}
|
||||
|
||||
template <typename varDataType>
|
||||
mfxStatus CreateConfig(varDataType data, const char *propertyName) {
|
||||
mfxConfig cfg = MFXCreateConfig(m_loader);
|
||||
if (cfg == nullptr)
|
||||
return MFX_ERR_NULL_PTR;
|
||||
|
||||
mfxVariant variant;
|
||||
InitVariant(&variant, data);
|
||||
|
||||
return MFXSetConfigFilterProperty(cfg, (mfxU8 *)propertyName, variant);
|
||||
}
|
||||
|
||||
mfxStatus InitSession(mfxInitParam par) {
|
||||
// already initialized
|
||||
if (m_session)
|
||||
return MFX_ERR_NONE;
|
||||
|
||||
m_loader = MFXLoad();
|
||||
if (!m_loader)
|
||||
return MFX_ERR_NOT_FOUND;
|
||||
|
||||
mfxStatus mfxRes = MFX_ERR_NONE;
|
||||
|
||||
mfxU32 implBaseType = MFX_IMPL_BASETYPE(par.Implementation);
|
||||
|
||||
// select implementation type
|
||||
switch (implBaseType) {
|
||||
case MFX_IMPL_AUTO:
|
||||
case MFX_IMPL_AUTO_ANY:
|
||||
break;
|
||||
|
||||
case MFX_IMPL_SOFTWARE:
|
||||
mfxRes = CreateConfig<mfxU32>(MFX_IMPL_TYPE_SOFTWARE, "mfxImplDescription.Impl");
|
||||
break;
|
||||
|
||||
case MFX_IMPL_HARDWARE:
|
||||
case MFX_IMPL_HARDWARE_ANY:
|
||||
case MFX_IMPL_HARDWARE2:
|
||||
case MFX_IMPL_HARDWARE3:
|
||||
case MFX_IMPL_HARDWARE4:
|
||||
mfxRes = CreateConfig<mfxU32>(MFX_IMPL_TYPE_HARDWARE, "mfxImplDescription.Impl");
|
||||
break;
|
||||
|
||||
default:
|
||||
mfxRes = MFX_ERR_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
|
||||
if (MFX_ERR_NONE != mfxRes)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
|
||||
// select adapter index (if specified)
|
||||
// see notes below about how VendorImplID is interpreted for each acceleration mode
|
||||
switch (implBaseType) {
|
||||
case MFX_IMPL_HARDWARE:
|
||||
mfxRes = CreateConfig<mfxU32>(0, "mfxImplDescription.VendorImplID");
|
||||
break;
|
||||
case MFX_IMPL_HARDWARE2:
|
||||
mfxRes = CreateConfig<mfxU32>(1, "mfxImplDescription.VendorImplID");
|
||||
break;
|
||||
case MFX_IMPL_HARDWARE3:
|
||||
mfxRes = CreateConfig<mfxU32>(2, "mfxImplDescription.VendorImplID");
|
||||
break;
|
||||
case MFX_IMPL_HARDWARE4:
|
||||
mfxRes = CreateConfig<mfxU32>(3, "mfxImplDescription.VendorImplID");
|
||||
break;
|
||||
}
|
||||
|
||||
if (MFX_ERR_NONE != mfxRes)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
|
||||
mfxU32 implAccelMode = MFX_IMPL_ACCELMODE(par.Implementation);
|
||||
if (implAccelMode == MFX_IMPL_VIA_D3D9) {
|
||||
// D3D9 - because VendorImplID corresponds to DXGI adapter index (DX11 enumeration),
|
||||
// this may not map directly to D3D9 index in multi-adapter/multi-monitor configurations
|
||||
mfxRes = CreateConfig<mfxU32>(MFX_ACCEL_MODE_VIA_D3D9,
|
||||
"mfxImplDescription.AccelerationMode");
|
||||
}
|
||||
else if (implAccelMode == MFX_IMPL_VIA_D3D11) {
|
||||
// D3D11 - VendorImplID corresponds to DXGI adapter index
|
||||
mfxRes = CreateConfig<mfxU32>(MFX_ACCEL_MODE_VIA_D3D11,
|
||||
"mfxImplDescription.AccelerationMode");
|
||||
}
|
||||
else if (implAccelMode == MFX_IMPL_VIA_VAAPI) {
|
||||
// VAAPI - in general MFXInitEx treats any HARDWAREn the same way (relies on application to pass
|
||||
// correct VADisplay via SetHandle), but 2.x RT only reports actual number of adapters
|
||||
mfxRes = CreateConfig<mfxU32>(MFX_ACCEL_MODE_VIA_VAAPI,
|
||||
"mfxImplDescription.AccelerationMode");
|
||||
}
|
||||
|
||||
if (MFX_ERR_NONE != mfxRes)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
|
||||
// set required API level
|
||||
mfxRes =
|
||||
CreateConfig<mfxU32>(par.Version.Version, "mfxImplDescription.ApiVersion.Version");
|
||||
if (MFX_ERR_NONE != mfxRes)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
|
||||
// set GPUCopy parameter
|
||||
if (par.GPUCopy) {
|
||||
mfxRes = CreateConfig<mfxU16>(par.GPUCopy, "DeviceCopy");
|
||||
if (MFX_ERR_NONE != mfxRes)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
// ExternalThreads was deprecated in API 2.x along with MFXDoWork()
|
||||
if (par.ExternalThreads) {
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
// pass extBufs
|
||||
if (par.NumExtParam) {
|
||||
for (mfxU32 idx = 0; idx < par.NumExtParam; idx++) {
|
||||
mfxRes = CreateConfig<mfxHDL>(par.ExtParam[idx], "ExtBuffer");
|
||||
if (MFX_ERR_NONE != mfxRes)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
// create session with highest priority implementation remaining after filters
|
||||
mfxRes = MFXCreateSession(m_loader, 0, &m_session);
|
||||
|
||||
return mfxRes;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
MFXVideoSession(const MFXVideoSession &);
|
||||
void operator=(MFXVideoSession &);
|
||||
};
|
||||
|
||||
class MFXVideoENCODE : public MFXVideoENCODEBase {
|
||||
public:
|
||||
explicit MFXVideoENCODE(mfxSession session) {
|
||||
m_session = session;
|
||||
}
|
||||
virtual ~MFXVideoENCODE(void) {
|
||||
Close();
|
||||
}
|
||||
|
||||
virtual mfxStatus Query(mfxVideoParam *in, mfxVideoParam *out) override {
|
||||
return MFXVideoENCODE_Query(m_session, in, out);
|
||||
}
|
||||
virtual mfxStatus QueryIOSurf(mfxVideoParam *par, mfxFrameAllocRequest *request) override {
|
||||
return MFXVideoENCODE_QueryIOSurf(m_session, par, request);
|
||||
}
|
||||
virtual mfxStatus Init(mfxVideoParam *par) override {
|
||||
return MFXVideoENCODE_Init(m_session, par);
|
||||
}
|
||||
virtual mfxStatus Reset(mfxVideoParam *par) override {
|
||||
return MFXVideoENCODE_Reset(m_session, par);
|
||||
}
|
||||
virtual mfxStatus Close(void) override {
|
||||
return MFXVideoENCODE_Close(m_session);
|
||||
}
|
||||
|
||||
virtual mfxStatus GetVideoParam(mfxVideoParam *par) override {
|
||||
return MFXVideoENCODE_GetVideoParam(m_session, par);
|
||||
}
|
||||
virtual mfxStatus GetEncodeStat(mfxEncodeStat *stat) override {
|
||||
return MFXVideoENCODE_GetEncodeStat(m_session, stat);
|
||||
}
|
||||
|
||||
virtual mfxStatus EncodeFrameAsync(mfxEncodeCtrl *ctrl,
|
||||
mfxFrameSurface1 *surface,
|
||||
mfxBitstream *bs,
|
||||
mfxSyncPoint *syncp) override {
|
||||
return MFXVideoENCODE_EncodeFrameAsync(m_session, ctrl, surface, bs, syncp);
|
||||
}
|
||||
|
||||
virtual mfxStatus GetSurface(mfxFrameSurface1** output_surf) override {
|
||||
return MFXMemory_GetSurfaceForEncode(m_session, output_surf);
|
||||
}
|
||||
|
||||
protected:
|
||||
mfxSession m_session; // (mfxSession) handle to the owning session
|
||||
private:
|
||||
MFXVideoENCODE(const MFXVideoENCODE& other);
|
||||
MFXVideoENCODE& operator=(const MFXVideoENCODE& other);
|
||||
};
|
||||
|
||||
class MFXVideoDECODE : public MFXVideoDECODEBase {
|
||||
public:
|
||||
explicit MFXVideoDECODE(mfxSession session) {
|
||||
m_session = session;
|
||||
}
|
||||
virtual ~MFXVideoDECODE(void) {
|
||||
Close();
|
||||
}
|
||||
|
||||
virtual mfxStatus Query(mfxVideoParam *in, mfxVideoParam *out) override {
|
||||
return MFXVideoDECODE_Query(m_session, in, out);
|
||||
}
|
||||
virtual mfxStatus DecodeHeader(mfxBitstream *bs, mfxVideoParam *par) override {
|
||||
return MFXVideoDECODE_DecodeHeader(m_session, bs, par);
|
||||
}
|
||||
virtual mfxStatus QueryIOSurf(mfxVideoParam *par, mfxFrameAllocRequest *request) override {
|
||||
return MFXVideoDECODE_QueryIOSurf(m_session, par, request);
|
||||
}
|
||||
virtual mfxStatus Init(mfxVideoParam *par) override {
|
||||
return MFXVideoDECODE_Init(m_session, par);
|
||||
}
|
||||
virtual mfxStatus Reset(mfxVideoParam *par) override {
|
||||
return MFXVideoDECODE_Reset(m_session, par);
|
||||
}
|
||||
virtual mfxStatus Close(void) override {
|
||||
return MFXVideoDECODE_Close(m_session);
|
||||
}
|
||||
|
||||
virtual mfxStatus GetVideoParam(mfxVideoParam *par) override {
|
||||
return MFXVideoDECODE_GetVideoParam(m_session, par);
|
||||
}
|
||||
|
||||
virtual mfxStatus GetDecodeStat(mfxDecodeStat *stat) override {
|
||||
return MFXVideoDECODE_GetDecodeStat(m_session, stat);
|
||||
}
|
||||
virtual mfxStatus GetPayload(mfxU64 *ts, mfxPayload *payload) override {
|
||||
return MFXVideoDECODE_GetPayload(m_session, ts, payload);
|
||||
}
|
||||
virtual mfxStatus SetSkipMode(mfxSkipMode mode) override {
|
||||
return MFXVideoDECODE_SetSkipMode(m_session, mode);
|
||||
}
|
||||
virtual mfxStatus DecodeFrameAsync(mfxBitstream *bs,
|
||||
mfxFrameSurface1 *surface_work,
|
||||
mfxFrameSurface1 **surface_out,
|
||||
mfxSyncPoint *syncp) override {
|
||||
return MFXVideoDECODE_DecodeFrameAsync(m_session, bs, surface_work, surface_out, syncp);
|
||||
}
|
||||
|
||||
virtual mfxStatus GetSurface(mfxFrameSurface1** output_surf) override {
|
||||
return MFXMemory_GetSurfaceForDecode(m_session, output_surf);
|
||||
}
|
||||
|
||||
protected:
|
||||
mfxSession m_session; // (mfxSession) handle to the owning session
|
||||
private:
|
||||
MFXVideoDECODE(const MFXVideoDECODE& other);
|
||||
MFXVideoDECODE& operator=(const MFXVideoDECODE& other);
|
||||
};
|
||||
|
||||
class MFXVideoVPP : public MFXVideoVPPBase {
|
||||
public:
|
||||
explicit MFXVideoVPP(mfxSession session) {
|
||||
m_session = session;
|
||||
}
|
||||
virtual ~MFXVideoVPP(void) {
|
||||
Close();
|
||||
}
|
||||
|
||||
virtual mfxStatus Query(mfxVideoParam *in, mfxVideoParam *out) override {
|
||||
return MFXVideoVPP_Query(m_session, in, out);
|
||||
}
|
||||
virtual mfxStatus QueryIOSurf(mfxVideoParam *par, mfxFrameAllocRequest request[2]) override {
|
||||
return MFXVideoVPP_QueryIOSurf(m_session, par, request);
|
||||
}
|
||||
virtual mfxStatus Init(mfxVideoParam *par) override {
|
||||
return MFXVideoVPP_Init(m_session, par);
|
||||
}
|
||||
virtual mfxStatus Reset(mfxVideoParam *par) override {
|
||||
return MFXVideoVPP_Reset(m_session, par);
|
||||
}
|
||||
virtual mfxStatus Close(void) override {
|
||||
return MFXVideoVPP_Close(m_session);
|
||||
}
|
||||
|
||||
virtual mfxStatus GetVideoParam(mfxVideoParam *par) override {
|
||||
return MFXVideoVPP_GetVideoParam(m_session, par);
|
||||
}
|
||||
virtual mfxStatus GetVPPStat(mfxVPPStat *stat) override {
|
||||
return MFXVideoVPP_GetVPPStat(m_session, stat);
|
||||
}
|
||||
virtual mfxStatus RunFrameVPPAsync(mfxFrameSurface1 *in,
|
||||
mfxFrameSurface1 *out,
|
||||
mfxExtVppAuxData *aux,
|
||||
mfxSyncPoint *syncp) override {
|
||||
return MFXVideoVPP_RunFrameVPPAsync(m_session, in, out, aux, syncp);
|
||||
}
|
||||
|
||||
virtual mfxStatus GetSurfaceIn(mfxFrameSurface1** output_surf) override {
|
||||
return MFXMemory_GetSurfaceForVPP(m_session, output_surf);
|
||||
}
|
||||
virtual mfxStatus GetSurfaceOut(mfxFrameSurface1** output_surf) override {
|
||||
return MFXMemory_GetSurfaceForVPPOut(m_session, output_surf);
|
||||
}
|
||||
|
||||
virtual mfxStatus ProcessFrameAsync(mfxFrameSurface1 *in, mfxFrameSurface1 **out) override {
|
||||
return MFXVideoVPP_ProcessFrameAsync(m_session, in, out);
|
||||
}
|
||||
|
||||
protected:
|
||||
mfxSession m_session; // (mfxSession) handle to the owning session
|
||||
private:
|
||||
MFXVideoVPP(const MFXVideoVPP& other);
|
||||
MFXVideoVPP& operator=(const MFXVideoVPP& other);
|
||||
};
|
||||
|
||||
class MFXVideoDECODE_VPP
|
||||
{
|
||||
public:
|
||||
explicit MFXVideoDECODE_VPP(mfxSession session) {
|
||||
m_session = session;
|
||||
}
|
||||
virtual ~MFXVideoDECODE_VPP(void) {
|
||||
Close();
|
||||
}
|
||||
|
||||
virtual mfxStatus Init(mfxVideoParam* decode_par, mfxVideoChannelParam** vpp_par_array, mfxU32 num_channel_par) {
|
||||
return MFXVideoDECODE_VPP_Init(m_session, decode_par, vpp_par_array, num_channel_par);
|
||||
}
|
||||
virtual mfxStatus Reset(mfxVideoParam* decode_par, mfxVideoChannelParam** vpp_par_array, mfxU32 num_channel_par) {
|
||||
return MFXVideoDECODE_VPP_Reset(m_session, decode_par, vpp_par_array, num_channel_par);
|
||||
}
|
||||
virtual mfxStatus GetChannelParam(mfxVideoChannelParam *par, mfxU32 channel_id) {
|
||||
return MFXVideoDECODE_VPP_GetChannelParam(m_session, par, channel_id);
|
||||
}
|
||||
virtual mfxStatus DecodeFrameAsync(mfxBitstream *bs, mfxU32* skip_channels, mfxU32 num_skip_channels, mfxSurfaceArray **surf_array_out) {
|
||||
return MFXVideoDECODE_VPP_DecodeFrameAsync(m_session, bs, skip_channels, num_skip_channels, surf_array_out);
|
||||
}
|
||||
|
||||
virtual mfxStatus DecodeHeader(mfxBitstream *bs, mfxVideoParam *par) {
|
||||
return MFXVideoDECODE_VPP_DecodeHeader(m_session, bs, par);
|
||||
}
|
||||
virtual mfxStatus Close(void) {
|
||||
return MFXVideoDECODE_VPP_Close(m_session);
|
||||
}
|
||||
virtual mfxStatus GetVideoParam(mfxVideoParam *par) {
|
||||
return MFXVideoDECODE_VPP_GetVideoParam(m_session, par);
|
||||
}
|
||||
virtual mfxStatus GetDecodeStat(mfxDecodeStat *stat) {
|
||||
return MFXVideoDECODE_VPP_GetDecodeStat(m_session, stat);
|
||||
}
|
||||
virtual mfxStatus GetPayload(mfxU64 *ts, mfxPayload *payload) {
|
||||
return MFXVideoDECODE_VPP_GetPayload(m_session, ts, payload);
|
||||
}
|
||||
virtual mfxStatus SetSkipMode(mfxSkipMode mode) {
|
||||
return MFXVideoDECODE_VPP_SetSkipMode(m_session, mode);
|
||||
}
|
||||
|
||||
protected:
|
||||
mfxSession m_session; // (mfxSession) handle to the owning session
|
||||
private:
|
||||
MFXVideoDECODE_VPP(const MFXVideoDECODE_VPP& other);
|
||||
MFXVideoDECODE_VPP& operator=(const MFXVideoDECODE_VPP& other);
|
||||
};
|
||||
|
||||
#endif //__MFXVIDEOPLUSPLUS_H
|
||||
+1095
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,65 @@
|
||||
/*############################################################################
|
||||
# Copyright Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#ifndef __MFXVP8_H__
|
||||
#define __MFXVP8_H__
|
||||
|
||||
#include "mfxdefs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
MFX_CODEC_VP8 = MFX_MAKEFOURCC('V','P','8',' '),
|
||||
};
|
||||
|
||||
/* VP8 CodecProfile*/
|
||||
enum {
|
||||
MFX_PROFILE_VP8_0 = 0+1,
|
||||
MFX_PROFILE_VP8_1 = 1+1,
|
||||
MFX_PROFILE_VP8_2 = 2+1,
|
||||
MFX_PROFILE_VP8_3 = 3+1,
|
||||
};
|
||||
|
||||
/* Extended Buffer Ids */
|
||||
enum {
|
||||
/*!
|
||||
This extended buffer describes VP8 encoder configuration parameters. See the mfxExtVP8CodingOption structure for details.
|
||||
The application can attach this buffer to the mfxVideoParam structure for encoding initialization.
|
||||
*/
|
||||
MFX_EXTBUFF_VP8_CODING_OPTION = MFX_MAKEFOURCC('V','P','8','E'),
|
||||
};
|
||||
|
||||
MFX_PACK_BEGIN_USUAL_STRUCT()
|
||||
/*! Describes VP8 coding options. */
|
||||
typedef struct {
|
||||
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VP8_CODING_OPTION. */
|
||||
|
||||
mfxU16 Version; /*!< Determines the bitstream version. Corresponds to the same VP8 syntax element in frame_tag. */
|
||||
mfxU16 EnableMultipleSegments; /*!< Set this option to ON to enable segmentation. This is tri-state option. See the CodingOptionValue
|
||||
enumerator for values of this option. */
|
||||
mfxU16 LoopFilterType; /*!< Select the type of filter (normal or simple). Corresponds to VP8 syntax element filter_type. */
|
||||
mfxU16 LoopFilterLevel[4]; /*!< Controls the filter strength. Corresponds to VP8 syntax element loop_filter_level. */
|
||||
mfxU16 SharpnessLevel; /*!< Controls the filter sensitivity. Corresponds to VP8 syntax element sharpness_level. */
|
||||
mfxU16 NumTokenPartitions; /*!< Specifies number of token partitions in the coded frame. */
|
||||
mfxI16 LoopFilterRefTypeDelta[4]; /*!< Loop filter level delta for reference type (intra, last, golden, altref). */
|
||||
mfxI16 LoopFilterMbModeDelta[4]; /*!< Loop filter level delta for MB modes. */
|
||||
mfxI16 SegmentQPDelta[4]; /*!< QP delta for segment. */
|
||||
mfxI16 CoeffTypeQPDelta[5]; /*!< QP delta for coefficient type (YDC, Y2AC, Y2DC, UVAC, UVDC). */
|
||||
mfxU16 WriteIVFHeaders; /*!< Set this option to ON to enable insertion of IVF container headers into bitstream. This is tri-state
|
||||
option. See the CodingOptionValue enumerator for values of this option */
|
||||
mfxU32 NumFramesForIVFHeader; /*!< Specifies number of frames for IVF header when WriteIVFHeaders is ON. */
|
||||
mfxU16 reserved[223];
|
||||
} mfxExtVP8CodingOption;
|
||||
MFX_PACK_END()
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
The files in this preview folder are provided as a preview of upcoming features.
|
||||
The content of this folder may be changed or removed without respect for backward compatibility.
|
||||
@@ -0,0 +1,25 @@
|
||||
The file preview/legacy/mfxvideo++.h is a preview implementation of "class
|
||||
MFXVideoSession" which takes advantage of API 2.0 functions of the
|
||||
Intel® Video Processing Library (Intel® VPL) for implementation selection and
|
||||
session creation.
|
||||
|
||||
Known limitations:
|
||||
|
||||
- The parameter mfxInitParam.ExternalThreads is not supported.
|
||||
|
||||
- The API version returned by MFXVideoSession::QueryVersion() may be different
|
||||
on platforms for which libmfx-gen is the default runtime implementation.
|
||||
|
||||
- On Windows, accelerators selected using MFX_IMPL_HARDWARE, MFX_IMPL_HARDWARE2,
|
||||
MFX_IMPL_HARDWARE3, or MFX_IMPL_HARDWARE4 are always enumerated according to
|
||||
IDXGIFactory::EnumAdapters (i.e. D3D11) indexes, regardless of the
|
||||
acceleration mode selected. On a multi-monitor or multi-adapter system, D3D9
|
||||
and D3D11 adapter indexing may not match. Applications needing to create a
|
||||
session on a specific D3D9 adapter should instead use the Dispatcher
|
||||
Configuration Property mfxExtendedDeviceId.DeviceLUID to select the desired
|
||||
adapter.
|
||||
|
||||
- Identical behavior between the production implementation of mfxvideo++.h and
|
||||
the preview is not guaranteed. Applications may however define
|
||||
MFXVIDEO_CPP_USE_DEPRECATED when compiling the preview application to build
|
||||
with the previous implementation.
|
||||
@@ -0,0 +1,581 @@
|
||||
/*###########################################################################
|
||||
# Copyright Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
###########################################################################*/
|
||||
|
||||
#ifndef __MFXVIDEOPLUSPLUS_H
|
||||
#define __MFXVIDEOPLUSPLUS_H
|
||||
|
||||
#include "vpl/mfx.h"
|
||||
|
||||
#define MFX_IMPL_ACCELMODE(x) (0xff00 & (x))
|
||||
|
||||
class MFXVideoSessionBase {
|
||||
public:
|
||||
virtual ~MFXVideoSessionBase() {}
|
||||
|
||||
virtual mfxStatus Init(mfxIMPL impl, mfxVersion* ver) = 0;
|
||||
virtual mfxStatus InitEx(mfxInitParam par) = 0;
|
||||
virtual mfxStatus Close(void) = 0;
|
||||
|
||||
virtual mfxStatus QueryIMPL(mfxIMPL* impl) = 0;
|
||||
virtual mfxStatus QueryVersion(mfxVersion* version) = 0;
|
||||
|
||||
virtual mfxStatus JoinSession(mfxSession child_session) = 0;
|
||||
virtual mfxStatus DisjoinSession() = 0;
|
||||
virtual mfxStatus CloneSession(mfxSession* clone) = 0;
|
||||
virtual mfxStatus SetPriority(mfxPriority priority) = 0;
|
||||
virtual mfxStatus GetPriority(mfxPriority* priority) = 0;
|
||||
|
||||
virtual mfxStatus SetFrameAllocator(mfxFrameAllocator* allocator) = 0;
|
||||
virtual mfxStatus SetHandle(mfxHandleType type, mfxHDL hdl) = 0;
|
||||
virtual mfxStatus GetHandle(mfxHandleType type, mfxHDL* hdl) = 0;
|
||||
virtual mfxStatus QueryPlatform(mfxPlatform* platform) = 0;
|
||||
|
||||
virtual mfxStatus SyncOperation(mfxSyncPoint syncp, mfxU32 wait) = 0;
|
||||
|
||||
virtual mfxStatus GetSurfaceForEncode(mfxFrameSurface1** output_surf) = 0;
|
||||
virtual mfxStatus GetSurfaceForDecode(mfxFrameSurface1** output_surf) = 0;
|
||||
virtual mfxStatus GetSurfaceForVPP(mfxFrameSurface1** output_surf) = 0;
|
||||
virtual mfxStatus GetSurfaceForVPPOut(mfxFrameSurface1** output_surf) = 0;
|
||||
|
||||
virtual operator mfxSession(void) = 0;
|
||||
};
|
||||
|
||||
class MFXVideoENCODEBase {
|
||||
public:
|
||||
virtual ~MFXVideoENCODEBase() {}
|
||||
|
||||
virtual mfxStatus Query(mfxVideoParam* in, mfxVideoParam* out) = 0;
|
||||
virtual mfxStatus QueryIOSurf(mfxVideoParam* par, mfxFrameAllocRequest* request) = 0;
|
||||
virtual mfxStatus Init(mfxVideoParam* par) = 0;
|
||||
virtual mfxStatus Reset(mfxVideoParam* par) = 0;
|
||||
virtual mfxStatus Close(void) = 0;
|
||||
|
||||
virtual mfxStatus GetVideoParam(mfxVideoParam* par) = 0;
|
||||
virtual mfxStatus GetEncodeStat(mfxEncodeStat* stat) = 0;
|
||||
|
||||
virtual mfxStatus EncodeFrameAsync(mfxEncodeCtrl* ctrl,
|
||||
mfxFrameSurface1* surface,
|
||||
mfxBitstream* bs,
|
||||
mfxSyncPoint* syncp) = 0;
|
||||
|
||||
virtual mfxStatus GetSurface(mfxFrameSurface1** output_surf) = 0;
|
||||
};
|
||||
|
||||
class MFXVideoDECODEBase {
|
||||
public:
|
||||
virtual ~MFXVideoDECODEBase() {}
|
||||
|
||||
virtual mfxStatus Query(mfxVideoParam* in, mfxVideoParam* out) = 0;
|
||||
virtual mfxStatus DecodeHeader(mfxBitstream* bs, mfxVideoParam* par) = 0;
|
||||
virtual mfxStatus QueryIOSurf(mfxVideoParam* par, mfxFrameAllocRequest* request) = 0;
|
||||
virtual mfxStatus Init(mfxVideoParam* par) = 0;
|
||||
virtual mfxStatus Reset(mfxVideoParam* par) = 0;
|
||||
virtual mfxStatus Close(void) = 0;
|
||||
|
||||
virtual mfxStatus GetVideoParam(mfxVideoParam* par) = 0;
|
||||
|
||||
virtual mfxStatus GetDecodeStat(mfxDecodeStat* stat) = 0;
|
||||
virtual mfxStatus GetPayload(mfxU64* ts, mfxPayload* payload) = 0;
|
||||
virtual mfxStatus SetSkipMode(mfxSkipMode mode) = 0;
|
||||
virtual mfxStatus DecodeFrameAsync(mfxBitstream* bs,
|
||||
mfxFrameSurface1* surface_work,
|
||||
mfxFrameSurface1** surface_out,
|
||||
mfxSyncPoint* syncp) = 0;
|
||||
|
||||
virtual mfxStatus GetSurface(mfxFrameSurface1** output_surf) = 0;
|
||||
};
|
||||
|
||||
class MFXVideoVPPBase {
|
||||
public:
|
||||
virtual ~MFXVideoVPPBase() {}
|
||||
|
||||
virtual mfxStatus Query(mfxVideoParam* in, mfxVideoParam* out) = 0;
|
||||
virtual mfxStatus QueryIOSurf(mfxVideoParam* par, mfxFrameAllocRequest request[2]) = 0;
|
||||
virtual mfxStatus Init(mfxVideoParam* par) = 0;
|
||||
virtual mfxStatus Reset(mfxVideoParam* par) = 0;
|
||||
virtual mfxStatus Close(void) = 0;
|
||||
|
||||
virtual mfxStatus GetVideoParam(mfxVideoParam* par) = 0;
|
||||
virtual mfxStatus GetVPPStat(mfxVPPStat* stat) = 0;
|
||||
virtual mfxStatus RunFrameVPPAsync(mfxFrameSurface1* in,
|
||||
mfxFrameSurface1* out,
|
||||
mfxExtVppAuxData* aux,
|
||||
mfxSyncPoint* syncp) = 0;
|
||||
|
||||
virtual mfxStatus GetSurfaceIn(mfxFrameSurface1** output_surf) = 0;
|
||||
virtual mfxStatus GetSurfaceOut(mfxFrameSurface1** output_surf) = 0;
|
||||
virtual mfxStatus ProcessFrameAsync(mfxFrameSurface1* in, mfxFrameSurface1** out) = 0;
|
||||
};
|
||||
|
||||
class MFXVideoSession : public MFXVideoSessionBase {
|
||||
public:
|
||||
MFXVideoSession(void) {
|
||||
m_session = (mfxSession)0;
|
||||
#ifndef MFXVIDEO_CPP_USE_DEPRECATED
|
||||
m_loader = (mfxLoader)0;
|
||||
#endif
|
||||
}
|
||||
virtual ~MFXVideoSession(void) {
|
||||
Close();
|
||||
}
|
||||
|
||||
virtual mfxStatus Init(mfxIMPL impl, mfxVersion *ver) override {
|
||||
#ifndef MFXVIDEO_CPP_USE_DEPRECATED
|
||||
mfxInitParam par = {};
|
||||
par.Implementation = impl;
|
||||
par.Version = *ver;
|
||||
return InitSession(par);
|
||||
#else
|
||||
return MFXInit(impl, ver, &m_session);
|
||||
#endif
|
||||
}
|
||||
virtual mfxStatus InitEx(mfxInitParam par) override {
|
||||
#ifndef MFXVIDEO_CPP_USE_DEPRECATED
|
||||
return InitSession(par);
|
||||
#else
|
||||
return MFXInitEx(par, &m_session);
|
||||
#endif
|
||||
}
|
||||
virtual mfxStatus Close(void) override {
|
||||
#ifndef MFXVIDEO_CPP_USE_DEPRECATED
|
||||
if (m_session) {
|
||||
mfxStatus mfxRes;
|
||||
mfxRes = MFXClose(m_session);
|
||||
m_session = (mfxSession)0;
|
||||
if (m_loader) {
|
||||
MFXUnload(m_loader);
|
||||
m_loader = (mfxLoader)0;
|
||||
}
|
||||
return mfxRes;
|
||||
}
|
||||
else {
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
#else
|
||||
mfxStatus mfxRes;
|
||||
mfxRes = MFXClose(m_session);
|
||||
m_session = (mfxSession)0;
|
||||
return mfxRes;
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual mfxStatus QueryIMPL(mfxIMPL *impl) override {
|
||||
return MFXQueryIMPL(m_session, impl);
|
||||
}
|
||||
virtual mfxStatus QueryVersion(mfxVersion *version) override {
|
||||
return MFXQueryVersion(m_session, version);
|
||||
}
|
||||
|
||||
virtual mfxStatus JoinSession(mfxSession child_session) override {
|
||||
return MFXJoinSession(m_session, child_session);
|
||||
}
|
||||
virtual mfxStatus DisjoinSession() override {
|
||||
return MFXDisjoinSession(m_session);
|
||||
}
|
||||
virtual mfxStatus CloneSession(mfxSession *clone) override {
|
||||
return MFXCloneSession(m_session, clone);
|
||||
}
|
||||
virtual mfxStatus SetPriority(mfxPriority priority) override {
|
||||
return MFXSetPriority(m_session, priority);
|
||||
}
|
||||
virtual mfxStatus GetPriority(mfxPriority *priority) override {
|
||||
return MFXGetPriority(m_session, priority);
|
||||
}
|
||||
|
||||
virtual mfxStatus SetFrameAllocator(mfxFrameAllocator *allocator) override {
|
||||
return MFXVideoCORE_SetFrameAllocator(m_session, allocator);
|
||||
}
|
||||
virtual mfxStatus SetHandle(mfxHandleType type, mfxHDL hdl) override {
|
||||
return MFXVideoCORE_SetHandle(m_session, type, hdl);
|
||||
}
|
||||
virtual mfxStatus GetHandle(mfxHandleType type, mfxHDL *hdl) override {
|
||||
return MFXVideoCORE_GetHandle(m_session, type, hdl);
|
||||
}
|
||||
virtual mfxStatus QueryPlatform(mfxPlatform *platform) override {
|
||||
return MFXVideoCORE_QueryPlatform(m_session, platform);
|
||||
}
|
||||
|
||||
virtual mfxStatus SyncOperation(mfxSyncPoint syncp, mfxU32 wait) override {
|
||||
return MFXVideoCORE_SyncOperation(m_session, syncp, wait);
|
||||
}
|
||||
|
||||
virtual mfxStatus GetSurfaceForEncode(mfxFrameSurface1** output_surf) override {
|
||||
return MFXMemory_GetSurfaceForEncode(m_session, output_surf);
|
||||
}
|
||||
virtual mfxStatus GetSurfaceForDecode(mfxFrameSurface1** output_surf) override {
|
||||
return MFXMemory_GetSurfaceForDecode(m_session, output_surf);
|
||||
}
|
||||
virtual mfxStatus GetSurfaceForVPP (mfxFrameSurface1** output_surf) override {
|
||||
return MFXMemory_GetSurfaceForVPP (m_session, output_surf);
|
||||
}
|
||||
virtual mfxStatus GetSurfaceForVPPOut(mfxFrameSurface1** output_surf) override {
|
||||
return MFXMemory_GetSurfaceForVPPOut(m_session, output_surf);
|
||||
}
|
||||
|
||||
virtual operator mfxSession(void) override {
|
||||
return m_session;
|
||||
}
|
||||
|
||||
protected:
|
||||
mfxSession m_session; // (mfxSession) handle to the owning session
|
||||
|
||||
#ifndef MFXVIDEO_CPP_USE_DEPRECATED
|
||||
mfxLoader m_loader;
|
||||
|
||||
inline void InitVariant(mfxVariant *var, mfxU32 data) {
|
||||
var->Version.Version = (mfxU16)MFX_VARIANT_VERSION;
|
||||
var->Type = MFX_VARIANT_TYPE_U32;
|
||||
var->Data.U32 = data;
|
||||
}
|
||||
|
||||
inline void InitVariant(mfxVariant *var, mfxU16 data) {
|
||||
var->Version.Version = (mfxU16)MFX_VARIANT_VERSION;
|
||||
var->Type = MFX_VARIANT_TYPE_U16;
|
||||
var->Data.U16 = data;
|
||||
}
|
||||
|
||||
inline void InitVariant(mfxVariant *var, mfxHDL data) {
|
||||
var->Version.Version = (mfxU16)MFX_VARIANT_VERSION;
|
||||
var->Type = MFX_VARIANT_TYPE_PTR;
|
||||
var->Data.Ptr = data;
|
||||
}
|
||||
|
||||
template <typename varDataType>
|
||||
mfxStatus CreateConfig(varDataType data, const char *propertyName) {
|
||||
mfxConfig cfg = MFXCreateConfig(m_loader);
|
||||
if (cfg == nullptr)
|
||||
return MFX_ERR_NULL_PTR;
|
||||
|
||||
mfxVariant variant;
|
||||
InitVariant(&variant, data);
|
||||
|
||||
return MFXSetConfigFilterProperty(cfg, (mfxU8 *)propertyName, variant);
|
||||
}
|
||||
|
||||
mfxStatus InitSession(mfxInitParam par) {
|
||||
// already initialized
|
||||
if (m_session)
|
||||
return MFX_ERR_NONE;
|
||||
|
||||
m_loader = MFXLoad();
|
||||
if (!m_loader)
|
||||
return MFX_ERR_NOT_FOUND;
|
||||
|
||||
mfxStatus mfxRes = MFX_ERR_NONE;
|
||||
|
||||
mfxU32 implBaseType = MFX_IMPL_BASETYPE(par.Implementation);
|
||||
|
||||
// select implementation type
|
||||
switch (implBaseType) {
|
||||
case MFX_IMPL_AUTO:
|
||||
case MFX_IMPL_AUTO_ANY:
|
||||
break;
|
||||
|
||||
case MFX_IMPL_SOFTWARE:
|
||||
mfxRes = CreateConfig<mfxU32>(MFX_IMPL_TYPE_SOFTWARE, "mfxImplDescription.Impl");
|
||||
break;
|
||||
|
||||
case MFX_IMPL_HARDWARE:
|
||||
case MFX_IMPL_HARDWARE_ANY:
|
||||
case MFX_IMPL_HARDWARE2:
|
||||
case MFX_IMPL_HARDWARE3:
|
||||
case MFX_IMPL_HARDWARE4:
|
||||
mfxRes = CreateConfig<mfxU32>(MFX_IMPL_TYPE_HARDWARE, "mfxImplDescription.Impl");
|
||||
break;
|
||||
|
||||
default:
|
||||
mfxRes = MFX_ERR_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
|
||||
if (MFX_ERR_NONE != mfxRes)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
|
||||
// select adapter index (if specified)
|
||||
// see notes below about how VendorImplID is interpreted for each acceleration mode
|
||||
switch (implBaseType) {
|
||||
case MFX_IMPL_HARDWARE:
|
||||
mfxRes = CreateConfig<mfxU32>(0, "mfxImplDescription.VendorImplID");
|
||||
break;
|
||||
case MFX_IMPL_HARDWARE2:
|
||||
mfxRes = CreateConfig<mfxU32>(1, "mfxImplDescription.VendorImplID");
|
||||
break;
|
||||
case MFX_IMPL_HARDWARE3:
|
||||
mfxRes = CreateConfig<mfxU32>(2, "mfxImplDescription.VendorImplID");
|
||||
break;
|
||||
case MFX_IMPL_HARDWARE4:
|
||||
mfxRes = CreateConfig<mfxU32>(3, "mfxImplDescription.VendorImplID");
|
||||
break;
|
||||
}
|
||||
|
||||
if (MFX_ERR_NONE != mfxRes)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
|
||||
mfxU32 implAccelMode = MFX_IMPL_ACCELMODE(par.Implementation);
|
||||
if (implAccelMode == MFX_IMPL_VIA_D3D9) {
|
||||
// D3D9 - because VendorImplID corresponds to DXGI adapter index (DX11 enumeration),
|
||||
// this may not map directly to D3D9 index in multi-adapter/multi-monitor configurations
|
||||
mfxRes = CreateConfig<mfxU32>(MFX_ACCEL_MODE_VIA_D3D9,
|
||||
"mfxImplDescription.AccelerationMode");
|
||||
}
|
||||
else if (implAccelMode == MFX_IMPL_VIA_D3D11) {
|
||||
// D3D11 - VendorImplID corresponds to DXGI adapter index
|
||||
mfxRes = CreateConfig<mfxU32>(MFX_ACCEL_MODE_VIA_D3D11,
|
||||
"mfxImplDescription.AccelerationMode");
|
||||
}
|
||||
else if (implAccelMode == MFX_IMPL_VIA_VAAPI) {
|
||||
// VAAPI - in general MFXInitEx treats any HARDWAREn the same way (relies on application to pass
|
||||
// correct VADisplay via SetHandle), but 2.x RT only reports actual number of adapters
|
||||
mfxRes = CreateConfig<mfxU32>(MFX_ACCEL_MODE_VIA_VAAPI,
|
||||
"mfxImplDescription.AccelerationMode");
|
||||
}
|
||||
|
||||
if (MFX_ERR_NONE != mfxRes)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
|
||||
// set required API level
|
||||
mfxRes =
|
||||
CreateConfig<mfxU32>(par.Version.Version, "mfxImplDescription.ApiVersion.Version");
|
||||
if (MFX_ERR_NONE != mfxRes)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
|
||||
// set GPUCopy parameter
|
||||
if (par.GPUCopy) {
|
||||
mfxRes = CreateConfig<mfxU16>(par.GPUCopy, "DeviceCopy");
|
||||
if (MFX_ERR_NONE != mfxRes)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
// set ExternalThreads parameter
|
||||
if (par.ExternalThreads) {
|
||||
// TO DO - need to add this as config filter property and member of mfxInitializationParam
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
// pass extBufs
|
||||
if (par.NumExtParam) {
|
||||
for (mfxU32 idx = 0; idx < par.NumExtParam; idx++) {
|
||||
mfxRes = CreateConfig<mfxHDL>(par.ExtParam[idx], "ExtBuffer");
|
||||
if (MFX_ERR_NONE != mfxRes)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
// create session with highest priority implementation remaining after filters
|
||||
mfxRes = MFXCreateSession(m_loader, 0, &m_session);
|
||||
|
||||
return mfxRes;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
MFXVideoSession(const MFXVideoSession &);
|
||||
void operator=(MFXVideoSession &);
|
||||
};
|
||||
|
||||
class MFXVideoENCODE : public MFXVideoENCODEBase {
|
||||
public:
|
||||
explicit MFXVideoENCODE(mfxSession session) {
|
||||
m_session = session;
|
||||
}
|
||||
virtual ~MFXVideoENCODE(void) {
|
||||
Close();
|
||||
}
|
||||
|
||||
virtual mfxStatus Query(mfxVideoParam *in, mfxVideoParam *out) override {
|
||||
return MFXVideoENCODE_Query(m_session, in, out);
|
||||
}
|
||||
virtual mfxStatus QueryIOSurf(mfxVideoParam *par, mfxFrameAllocRequest *request) override {
|
||||
return MFXVideoENCODE_QueryIOSurf(m_session, par, request);
|
||||
}
|
||||
virtual mfxStatus Init(mfxVideoParam *par) override {
|
||||
return MFXVideoENCODE_Init(m_session, par);
|
||||
}
|
||||
virtual mfxStatus Reset(mfxVideoParam *par) override {
|
||||
return MFXVideoENCODE_Reset(m_session, par);
|
||||
}
|
||||
virtual mfxStatus Close(void) override {
|
||||
return MFXVideoENCODE_Close(m_session);
|
||||
}
|
||||
|
||||
virtual mfxStatus GetVideoParam(mfxVideoParam *par) override {
|
||||
return MFXVideoENCODE_GetVideoParam(m_session, par);
|
||||
}
|
||||
virtual mfxStatus GetEncodeStat(mfxEncodeStat *stat) override {
|
||||
return MFXVideoENCODE_GetEncodeStat(m_session, stat);
|
||||
}
|
||||
|
||||
virtual mfxStatus EncodeFrameAsync(mfxEncodeCtrl *ctrl,
|
||||
mfxFrameSurface1 *surface,
|
||||
mfxBitstream *bs,
|
||||
mfxSyncPoint *syncp) override {
|
||||
return MFXVideoENCODE_EncodeFrameAsync(m_session, ctrl, surface, bs, syncp);
|
||||
}
|
||||
|
||||
virtual mfxStatus GetSurface(mfxFrameSurface1** output_surf) override {
|
||||
return MFXMemory_GetSurfaceForEncode(m_session, output_surf);
|
||||
}
|
||||
|
||||
protected:
|
||||
mfxSession m_session; // (mfxSession) handle to the owning session
|
||||
};
|
||||
|
||||
class MFXVideoDECODE : public MFXVideoDECODEBase {
|
||||
public:
|
||||
explicit MFXVideoDECODE(mfxSession session) {
|
||||
m_session = session;
|
||||
}
|
||||
virtual ~MFXVideoDECODE(void) {
|
||||
Close();
|
||||
}
|
||||
|
||||
virtual mfxStatus Query(mfxVideoParam *in, mfxVideoParam *out) override {
|
||||
return MFXVideoDECODE_Query(m_session, in, out);
|
||||
}
|
||||
virtual mfxStatus DecodeHeader(mfxBitstream *bs, mfxVideoParam *par) override {
|
||||
return MFXVideoDECODE_DecodeHeader(m_session, bs, par);
|
||||
}
|
||||
virtual mfxStatus QueryIOSurf(mfxVideoParam *par, mfxFrameAllocRequest *request) override {
|
||||
return MFXVideoDECODE_QueryIOSurf(m_session, par, request);
|
||||
}
|
||||
virtual mfxStatus Init(mfxVideoParam *par) override {
|
||||
return MFXVideoDECODE_Init(m_session, par);
|
||||
}
|
||||
virtual mfxStatus Reset(mfxVideoParam *par) override {
|
||||
return MFXVideoDECODE_Reset(m_session, par);
|
||||
}
|
||||
virtual mfxStatus Close(void) override {
|
||||
return MFXVideoDECODE_Close(m_session);
|
||||
}
|
||||
|
||||
virtual mfxStatus GetVideoParam(mfxVideoParam *par) override {
|
||||
return MFXVideoDECODE_GetVideoParam(m_session, par);
|
||||
}
|
||||
|
||||
virtual mfxStatus GetDecodeStat(mfxDecodeStat *stat) override {
|
||||
return MFXVideoDECODE_GetDecodeStat(m_session, stat);
|
||||
}
|
||||
virtual mfxStatus GetPayload(mfxU64 *ts, mfxPayload *payload) override {
|
||||
return MFXVideoDECODE_GetPayload(m_session, ts, payload);
|
||||
}
|
||||
virtual mfxStatus SetSkipMode(mfxSkipMode mode) override {
|
||||
return MFXVideoDECODE_SetSkipMode(m_session, mode);
|
||||
}
|
||||
virtual mfxStatus DecodeFrameAsync(mfxBitstream *bs,
|
||||
mfxFrameSurface1 *surface_work,
|
||||
mfxFrameSurface1 **surface_out,
|
||||
mfxSyncPoint *syncp) override {
|
||||
return MFXVideoDECODE_DecodeFrameAsync(m_session, bs, surface_work, surface_out, syncp);
|
||||
}
|
||||
|
||||
virtual mfxStatus GetSurface(mfxFrameSurface1** output_surf) override {
|
||||
return MFXMemory_GetSurfaceForDecode(m_session, output_surf);
|
||||
}
|
||||
|
||||
protected:
|
||||
mfxSession m_session; // (mfxSession) handle to the owning session
|
||||
};
|
||||
|
||||
class MFXVideoVPP : public MFXVideoVPPBase {
|
||||
public:
|
||||
explicit MFXVideoVPP(mfxSession session) {
|
||||
m_session = session;
|
||||
}
|
||||
virtual ~MFXVideoVPP(void) {
|
||||
Close();
|
||||
}
|
||||
|
||||
virtual mfxStatus Query(mfxVideoParam *in, mfxVideoParam *out) override {
|
||||
return MFXVideoVPP_Query(m_session, in, out);
|
||||
}
|
||||
virtual mfxStatus QueryIOSurf(mfxVideoParam *par, mfxFrameAllocRequest request[2]) override {
|
||||
return MFXVideoVPP_QueryIOSurf(m_session, par, request);
|
||||
}
|
||||
virtual mfxStatus Init(mfxVideoParam *par) override {
|
||||
return MFXVideoVPP_Init(m_session, par);
|
||||
}
|
||||
virtual mfxStatus Reset(mfxVideoParam *par) override {
|
||||
return MFXVideoVPP_Reset(m_session, par);
|
||||
}
|
||||
virtual mfxStatus Close(void) override {
|
||||
return MFXVideoVPP_Close(m_session);
|
||||
}
|
||||
|
||||
virtual mfxStatus GetVideoParam(mfxVideoParam *par) override {
|
||||
return MFXVideoVPP_GetVideoParam(m_session, par);
|
||||
}
|
||||
virtual mfxStatus GetVPPStat(mfxVPPStat *stat) override {
|
||||
return MFXVideoVPP_GetVPPStat(m_session, stat);
|
||||
}
|
||||
virtual mfxStatus RunFrameVPPAsync(mfxFrameSurface1 *in,
|
||||
mfxFrameSurface1 *out,
|
||||
mfxExtVppAuxData *aux,
|
||||
mfxSyncPoint *syncp) override {
|
||||
return MFXVideoVPP_RunFrameVPPAsync(m_session, in, out, aux, syncp);
|
||||
}
|
||||
|
||||
virtual mfxStatus GetSurfaceIn(mfxFrameSurface1** output_surf) override {
|
||||
return MFXMemory_GetSurfaceForVPP(m_session, output_surf);
|
||||
}
|
||||
virtual mfxStatus GetSurfaceOut(mfxFrameSurface1** output_surf) override {
|
||||
return MFXMemory_GetSurfaceForVPPOut(m_session, output_surf);
|
||||
}
|
||||
|
||||
virtual mfxStatus ProcessFrameAsync(mfxFrameSurface1 *in, mfxFrameSurface1 **out) override {
|
||||
return MFXVideoVPP_ProcessFrameAsync(m_session, in, out);
|
||||
}
|
||||
|
||||
protected:
|
||||
mfxSession m_session; // (mfxSession) handle to the owning session
|
||||
};
|
||||
|
||||
class MFXVideoDECODE_VPP
|
||||
{
|
||||
public:
|
||||
explicit MFXVideoDECODE_VPP(mfxSession session) {
|
||||
m_session = session;
|
||||
}
|
||||
virtual ~MFXVideoDECODE_VPP(void) {
|
||||
Close();
|
||||
}
|
||||
|
||||
virtual mfxStatus Init(mfxVideoParam* decode_par, mfxVideoChannelParam** vpp_par_array, mfxU32 num_channel_par) {
|
||||
return MFXVideoDECODE_VPP_Init(m_session, decode_par, vpp_par_array, num_channel_par);
|
||||
}
|
||||
virtual mfxStatus Reset(mfxVideoParam* decode_par, mfxVideoChannelParam** vpp_par_array, mfxU32 num_channel_par) {
|
||||
return MFXVideoDECODE_VPP_Reset(m_session, decode_par, vpp_par_array, num_channel_par);
|
||||
}
|
||||
virtual mfxStatus GetChannelParam(mfxVideoChannelParam *par, mfxU32 channel_id) {
|
||||
return MFXVideoDECODE_VPP_GetChannelParam(m_session, par, channel_id);
|
||||
}
|
||||
virtual mfxStatus DecodeFrameAsync(mfxBitstream *bs, mfxU32* skip_channels, mfxU32 num_skip_channels, mfxSurfaceArray **surf_array_out) {
|
||||
return MFXVideoDECODE_VPP_DecodeFrameAsync(m_session, bs, skip_channels, num_skip_channels, surf_array_out);
|
||||
}
|
||||
|
||||
virtual mfxStatus DecodeHeader(mfxBitstream *bs, mfxVideoParam *par) {
|
||||
return MFXVideoDECODE_VPP_DecodeHeader(m_session, bs, par);
|
||||
}
|
||||
virtual mfxStatus Close(void) {
|
||||
return MFXVideoDECODE_VPP_Close(m_session);
|
||||
}
|
||||
virtual mfxStatus GetVideoParam(mfxVideoParam *par) {
|
||||
return MFXVideoDECODE_VPP_GetVideoParam(m_session, par);
|
||||
}
|
||||
virtual mfxStatus GetDecodeStat(mfxDecodeStat *stat) {
|
||||
return MFXVideoDECODE_VPP_GetDecodeStat(m_session, stat);
|
||||
}
|
||||
virtual mfxStatus GetPayload(mfxU64 *ts, mfxPayload *payload) {
|
||||
return MFXVideoDECODE_VPP_GetPayload(m_session, ts, payload);
|
||||
}
|
||||
virtual mfxStatus SetSkipMode(mfxSkipMode mode) {
|
||||
return MFXVideoDECODE_VPP_SetSkipMode(m_session, mode);
|
||||
}
|
||||
|
||||
protected:
|
||||
mfxSession m_session; // (mfxSession) handle to the owning session
|
||||
};
|
||||
|
||||
#endif //__MFXVIDEOPLUSPLUS_H
|
||||
@@ -0,0 +1,111 @@
|
||||
# ##############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
# ##############################################################################
|
||||
|
||||
#
|
||||
# Set compilation options
|
||||
#
|
||||
if(MSVC)
|
||||
add_compile_options("$<$<CONFIG:Debug>:/D_DEBUG>")
|
||||
else()
|
||||
add_compile_options("$<$<CONFIG:Debug>:-D_DEBUG -O0 -g>")
|
||||
endif()
|
||||
|
||||
if(ENABLE_WARNING_AS_ERROR)
|
||||
message(STATUS "Warnings as errors enabled")
|
||||
set(MFX_DEPRECATED_OFF 1)
|
||||
endif()
|
||||
|
||||
if(DEFINED ENV{MFX_DEPRECATED_OFF})
|
||||
set(MFX_DEPRECATED_OFF 1)
|
||||
endif()
|
||||
|
||||
if(MFX_DEPRECATED_OFF)
|
||||
message(STATUS "Deprecation warnings disabled")
|
||||
add_definitions(-DMFX_DEPRECATED_OFF)
|
||||
endif()
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
if(MSVC)
|
||||
add_link_options("/guard:cf")
|
||||
add_link_options("/DYNAMICBASE")
|
||||
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
|
||||
add_link_options("/HIGHENTROPYVA")
|
||||
endif()
|
||||
add_link_options("/LARGEADDRESSAWARE")
|
||||
add_link_options("/NXCOMPAT")
|
||||
if(ENABLE_WARNING_AS_ERROR)
|
||||
add_compile_options("/WX")
|
||||
endif()
|
||||
add_compile_options("/GS")
|
||||
add_compile_options("/guard:cf")
|
||||
else()
|
||||
if(UNIX)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
|
||||
endif()
|
||||
add_compile_options("-Wformat")
|
||||
add_compile_options("-Wformat-security")
|
||||
add_compile_options("-Werror=format-security")
|
||||
if(NOT MINGW)
|
||||
string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
|
||||
if(NOT CMAKE_BUILD_TYPE MATCHES debug)
|
||||
add_definitions("-D_FORTIFY_SOURCE=2")
|
||||
endif()
|
||||
endif()
|
||||
if(NOT MINGW)
|
||||
add_compile_options("-fstack-protector-strong")
|
||||
endif()
|
||||
if(NOT MINGW)
|
||||
add_link_options("-Wl,-z,relro,-z,now,-z,noexecstack")
|
||||
endif()
|
||||
add_compile_options("-Wall")
|
||||
if(ENABLE_WARNING_AS_ERROR)
|
||||
add_compile_options("-Werror")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Define RelWithDebRT Build Mode
|
||||
if(MSVC)
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
set(CMAKE_RELWITHDEBRT_POSTFIX "d")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBRT
|
||||
"${CMAKE_CXX_FLAGS_RELEASE}"
|
||||
CACHE STRING "Flags used by the C++ compiler during RelWithDebRT builds."
|
||||
FORCE)
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBRT
|
||||
"${CMAKE_C_FLAGS_RELEASE}"
|
||||
CACHE STRING "Flags used by the C compiler during RelWithDebRT builds."
|
||||
FORCE)
|
||||
|
||||
foreach(build_flag CMAKE_CXX_FLAGS_RELWITHDEBRT CMAKE_C_FLAGS_RELWITHDEBRT)
|
||||
string(REPLACE "/MDd" "" ${build_flag} "${${build_flag}}")
|
||||
string(REPLACE "/MTd" "" ${build_flag} "${${build_flag}}")
|
||||
string(REPLACE "/MD" "" ${build_flag} "${${build_flag}}")
|
||||
string(REPLACE "/MT" "" ${build_flag} "${${build_flag}}")
|
||||
set(${build_flag} "${${build_flag}} /MDd /DEBUG:NONE")
|
||||
endforeach()
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBRT
|
||||
"${CMAKE_EXE_LINKER_FLAGS_RELEASE}"
|
||||
CACHE STRING
|
||||
"Flags used for linking binaries during RelWithDebRT builds." FORCE)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBRT
|
||||
"${CMAKE_SHARED_LINKER_FLAGS_RELEASE}"
|
||||
CACHE
|
||||
STRING
|
||||
"Flags used by the shared libraries linker during RelWithDebRT builds."
|
||||
FORCE)
|
||||
set(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBRT
|
||||
"${CMAKE_MODULE_LINKER_FLAGS_RELEASE}"
|
||||
CACHE STRING "Flags used by the linker during RelWithDebRT builds." FORCE)
|
||||
mark_as_advanced(
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBRT CMAKE_C_FLAGS_RELWITHDEBRT
|
||||
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBRT CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBRT)
|
||||
|
||||
# Add RelWithDebRT to avalible config types
|
||||
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES};RelWithDebRT")
|
||||
|
||||
endif()
|
||||
@@ -0,0 +1,101 @@
|
||||
# ##############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
# ##############################################################################
|
||||
|
||||
#
|
||||
# Set installation directories
|
||||
#
|
||||
|
||||
if(WIN32
|
||||
AND NOT CMAKE_CROSSCOMPILING
|
||||
AND CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
if(NOT CMAKE_INSTALL_BINDIR)
|
||||
set(BINARCH x86)
|
||||
endif()
|
||||
if(NOT CMAKE_INSTALL_LIBDIR)
|
||||
set(LIBARCH x86)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# See https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html for
|
||||
# variables GNUInstallDirs exposes. This project commonly uses:
|
||||
# CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_DOCDIR CMAKE_INSTALL_BINDIR
|
||||
# CMAKE_INSTALL_LIBDIR
|
||||
include(GNUInstallDirs)
|
||||
|
||||
set(CMAKE_INSTALL_DOCDIR ${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME})
|
||||
gnuinstalldirs_get_absolute_install_dir(CMAKE_INSTALL_FULL_DOCDIR
|
||||
CMAKE_INSTALL_DOCDIR DOCDIR)
|
||||
|
||||
if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(CMAKE_INSTALL_BINDIR
|
||||
${CMAKE_INSTALL_BINDIR}/${BINARCH}
|
||||
CACHE PATH "user executables" FORCE)
|
||||
set(CMAKE_INSTALL_LIBDIR
|
||||
${CMAKE_INSTALL_LIBDIR}/${LIBARCH}
|
||||
CACHE PATH "Object code libraries" FORCE)
|
||||
foreach(dir LIBDIR BINDIR)
|
||||
gnuinstalldirs_get_absolute_install_dir(CMAKE_INSTALL_FULL_${dir}
|
||||
CMAKE_INSTALL_${dir} ${dir})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(NOT VPL_INSTALL_PKGCONFIGDIR)
|
||||
set(VPL_INSTALL_PKGCONFIGDIR ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
set(VPL_INSTALL_FULL_PKGCONFIGDIR ${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig)
|
||||
else()
|
||||
gnuinstalldirs_get_absolute_install_dir(
|
||||
VPL_INSTALL_FULL_PKGCONFIGDIR VPL_INSTALL_PKGCONFIGDIR
|
||||
VPL_INSTALL_PKGCONFIGDIR)
|
||||
endif()
|
||||
|
||||
if(NOT VPL_INSTALL_CMAKEDIR)
|
||||
set(VPL_INSTALL_CMAKEDIR ${CMAKE_INSTALL_LIBDIR}/cmake)
|
||||
set(VPL_INSTALL_FULL_CMAKEDIR ${CMAKE_INSTALL_FULL_LIBDIR}/cmake)
|
||||
else()
|
||||
gnuinstalldirs_get_absolute_install_dir(
|
||||
VPL_INSTALL_FULL_CMAKEDIR VPL_INSTALL_CMAKEDIR VPL_INSTALL_CMAKEDIR)
|
||||
endif()
|
||||
|
||||
if(NOT VPL_INSTALL_ENVDIR)
|
||||
set(VPL_INSTALL_ENVDIR ${CMAKE_INSTALL_SYSCONFDIR}/${PROJECT_NAME})
|
||||
set(VPL_INSTALL_FULL_ENVDIR ${CMAKE_INSTALL_FULL_SYSCONFDIR}/${PROJECT_NAME})
|
||||
else()
|
||||
gnuinstalldirs_get_absolute_install_dir(VPL_INSTALL_FULL_ENVDIR
|
||||
VPL_INSTALL_ENVDIR VPL_INSTALL_ENVDIR)
|
||||
endif()
|
||||
|
||||
if(NOT VPL_INSTALL_MODFILEDIR)
|
||||
set(VPL_INSTALL_MODFILEDIR ${CMAKE_INSTALL_SYSCONFDIR}/modulefiles)
|
||||
set(VPL_INSTALL_FULL_MODFILEDIR ${CMAKE_INSTALL_FULL_SYSCONFDIR}/modulefiles)
|
||||
else()
|
||||
gnuinstalldirs_get_absolute_install_dir(
|
||||
VPL_INSTALL_FULL_MODFILEDIR VPL_INSTALL_MODFILEDIR VPL_INSTALL_MODFILEDIR)
|
||||
endif()
|
||||
|
||||
if(NOT VPL_INSTALL_EXAMPLEDIR)
|
||||
set(VPL_INSTALL_EXAMPLEDIR
|
||||
${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/examples)
|
||||
set(VPL_INSTALL_FULL_EXAMPLEDIR
|
||||
${CMAKE_INSTALL_FULL_DATAROOTDIR}/${PROJECT_NAME}/examples)
|
||||
else()
|
||||
gnuinstalldirs_get_absolute_install_dir(
|
||||
VPL_INSTALL_FULL_EXAMPLEDIR VPL_INSTALL_EXAMPLEDIR VPL_INSTALL_EXAMPLEDIR)
|
||||
endif()
|
||||
if(NOT VPL_INSTALL_LICENSEDIR)
|
||||
set(VPL_INSTALL_LICENSEDIR
|
||||
${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/licensing)
|
||||
set(VPL_INSTALL_FULL_LICENSEDIR
|
||||
${CMAKE_INSTALL_FULL_DATAROOTDIR}/${PROJECT_NAME}/licensing)
|
||||
else()
|
||||
gnuinstalldirs_get_absolute_install_dir(
|
||||
VPL_INSTALL_FULL_LICENSEDIR VPL_INSTALL_LICENSEDIR VPL_INSTALL_LICENSEDIR)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
else()
|
||||
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
@@ -0,0 +1,30 @@
|
||||
# ##############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
# ##############################################################################
|
||||
|
||||
#
|
||||
# Packaging
|
||||
#
|
||||
|
||||
set(CPACK_GENERATOR "ZIP")
|
||||
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
|
||||
|
||||
set(CPACK_PACKAGE_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
|
||||
|
||||
set(VPL_COMPONENT_DEV dev)
|
||||
set(VPL_COMPONENT_LIB lib)
|
||||
set(VPL_COMPONENT_TOOLS tools)
|
||||
|
||||
set(CPACK_COMPONENTS_ALL all ${VPL_COMPONENT_DEV} ${VPL_COMPONENT_LIB}
|
||||
${VPL_COMPONENT_TOOLS})
|
||||
set(CPACK_COMPONENTS_GROUPING IGNORE)
|
||||
|
||||
include(CPack)
|
||||
cpack_add_component(${VPL_COMPONENT_LIB})
|
||||
cpack_add_component(${VPL_COMPONENT_DEV} DEPENDS ${VPL_COMPONENT_LIB})
|
||||
cpack_add_component(${VPL_COMPONENT_TOOLS} DEPENDS ${VPL_COMPONENT_LIB})
|
||||
@@ -0,0 +1,204 @@
|
||||
# ##############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
# ##############################################################################
|
||||
cmake_minimum_required(VERSION 3.13.0)
|
||||
set(TARGET VPL)
|
||||
set(OUTPUT_NAME "vpl")
|
||||
set(DLL_PREFIX "lib")
|
||||
|
||||
if(WIN32)
|
||||
set(SOURCES
|
||||
src/windows/main.cpp
|
||||
src/windows/mfx_critical_section.cpp
|
||||
src/windows/mfx_dispatcher.cpp
|
||||
src/windows/mfx_dispatcher_log.cpp
|
||||
src/windows/mfx_driver_store_loader.cpp
|
||||
src/windows/mfx_dxva2_device.cpp
|
||||
src/windows/mfx_function_table.cpp
|
||||
src/windows/mfx_library_iterator.cpp
|
||||
src/windows/mfx_load_dll.cpp
|
||||
src/windows/mfx_win_reg_key.cpp
|
||||
src/windows/libmfx.def)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
configure_file(src/windows/version.rc.in src/windows/version.rc @ONLY)
|
||||
list(APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/src/windows/version.rc)
|
||||
endif()
|
||||
endif()
|
||||
if(UNIX)
|
||||
set(SOURCES src/linux/mfxloader.cpp)
|
||||
|
||||
if(NOT DEFINED MFX_MODULES_DIR)
|
||||
set(MFX_MODULES_DIR ${CMAKE_INSTALL_FULL_LIBDIR})
|
||||
endif()
|
||||
add_definitions(-DMFX_MODULES_DIR="${MFX_MODULES_DIR}")
|
||||
message(STATUS "MFX_MODULES_DIR=${MFX_MODULES_DIR}")
|
||||
endif()
|
||||
|
||||
if(BUILD_EXPERIMENTAL)
|
||||
add_definitions(-DONEVPL_EXPERIMENTAL)
|
||||
endif()
|
||||
|
||||
list(
|
||||
APPEND
|
||||
SOURCES
|
||||
src/mfx_dispatcher_vpl.cpp
|
||||
src/mfx_dispatcher_vpl_loader.cpp
|
||||
src/mfx_dispatcher_vpl_config.cpp
|
||||
src/mfx_dispatcher_vpl_lowlatency.cpp
|
||||
src/mfx_dispatcher_vpl_log.cpp
|
||||
src/mfx_dispatcher_vpl_msdk.cpp
|
||||
src/mfx_config_interface/mfx_config_interface.cpp
|
||||
src/mfx_config_interface/mfx_config_interface_string_api.cpp)
|
||||
|
||||
add_library(${TARGET} "")
|
||||
|
||||
# disable warnings for dispatcher library itself but not subprojects (unit
|
||||
# tests)
|
||||
set_target_properties(${TARGET} PROPERTIES COMPILE_DEFINITIONS
|
||||
"MFX_DEPRECATED_OFF")
|
||||
|
||||
# optionally include the install location of dispatcher dll in the runtime
|
||||
# search process
|
||||
if(UNIX)
|
||||
if(ENABLE_LIBDIR_IN_RUNTIME_SEARCH)
|
||||
file(TO_CMAKE_PATH "${CMAKE_INSTALL_FULL_LIBDIR}" _install_libdir_search)
|
||||
target_compile_definitions(
|
||||
${TARGET} PRIVATE INSTALL_LIBDIR_SEARCH=\"${_install_libdir_search}\")
|
||||
message(STATUS "Enabled install libdir search: ${_install_libdir_search}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
# force libxxx style sharedlib name on Windows
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set_target_properties(${TARGET} PROPERTIES PREFIX ${DLL_PREFIX})
|
||||
endif()
|
||||
set(SHLIB_FILE_NAME ${DLL_PREFIX}${OUTPUT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
set(SHLIB_FILE_NAME_DEBUG
|
||||
${DLL_PREFIX}${OUTPUT_NAME}${CMAKE_DEBUG_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
)
|
||||
|
||||
else()
|
||||
# use version script on Linux
|
||||
set_target_properties(
|
||||
${TARGET}
|
||||
PROPERTIES
|
||||
LINK_FLAGS
|
||||
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/linux/libvpl.map")
|
||||
set(SHLIB_FILE_NAME
|
||||
${CMAKE_SHARED_LIBRARY_PREFIX}${OUTPUT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}.${API_VERSION_MAJOR}
|
||||
)
|
||||
set(SHLIB_FILE_NAME_DEBUG ${SHLIB_FILE_NAME})
|
||||
endif()
|
||||
|
||||
set(LIB_FILE_NAME
|
||||
${CMAKE_STATIC_LIBRARY_PREFIX}${OUTPUT_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
set(IMPLIB_FILE_NAME
|
||||
${CMAKE_IMPORT_LIBRARY_PREFIX}${OUTPUT_NAME}${CMAKE_IMPORT_LIBRARY_SUFFIX})
|
||||
set(LIB_FILE_NAME_DEBUG
|
||||
${CMAKE_STATIC_LIBRARY_PREFIX}${OUTPUT_NAME}${CMAKE_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
)
|
||||
set(IMPLIB_FILE_NAME_DEBUG
|
||||
${CMAKE_IMPORT_LIBRARY_PREFIX}${OUTPUT_NAME}${CMAKE_DEBUG_POSTFIX}${CMAKE_IMPORT_LIBRARY_SUFFIX}
|
||||
)
|
||||
|
||||
set_target_properties(
|
||||
${TARGET}
|
||||
PROPERTIES OUTPUT_NAME ${OUTPUT_NAME} SOVERSION ${API_VERSION_MAJOR}
|
||||
VERSION ${API_VERSION_MAJOR}.${API_VERSION_MINOR})
|
||||
|
||||
target_sources(${TARGET} PRIVATE ${SOURCES})
|
||||
|
||||
if(UNIX)
|
||||
# require pthreads for loading legacy MSDK runtimes
|
||||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads REQUIRED)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
target_link_libraries(${TARGET} PRIVATE Threads::Threads)
|
||||
else()
|
||||
target_link_libraries(${TARGET} PUBLIC Threads::Threads)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_link_libraries(${TARGET} PUBLIC vpl-api)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
target_link_libraries(${TARGET} PRIVATE ${CMAKE_DL_LIBS})
|
||||
else()
|
||||
target_link_libraries(${TARGET} PUBLIC ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
|
||||
target_include_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
if(INSTALL_LIB)
|
||||
install(
|
||||
TARGETS ${TARGET}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
COMPONENT ${VPL_COMPONENT_LIB}
|
||||
NAMELINK_SKIP
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${VPL_COMPONENT_LIB})
|
||||
endif()
|
||||
|
||||
if(INSTALL_DEV)
|
||||
install(
|
||||
TARGETS ${TARGET}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
COMPONENT ${VPL_COMPONENT_DEV}
|
||||
NAMELINK_ONLY)
|
||||
if(WIN32)
|
||||
install(TARGETS ${TARGET} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
COMPONENT ${VPL_COMPONENT_DEV})
|
||||
endif()
|
||||
|
||||
file(RELATIVE_PATH cmake_rel_prefix ${CMAKE_INSTALL_FULL_LIBDIR}/cmake/vpl
|
||||
${CMAKE_INSTALL_PREFIX})
|
||||
file(RELATIVE_PATH cmake_rel_libdir ${CMAKE_INSTALL_FULL_LIBDIR}/cmake/vpl
|
||||
${CMAKE_INSTALL_FULL_LIBDIR})
|
||||
file(RELATIVE_PATH cmake_rel_incdir ${CMAKE_INSTALL_FULL_LIBDIR}/cmake/vpl
|
||||
${CMAKE_INSTALL_FULL_INCLUDEDIR})
|
||||
file(RELATIVE_PATH cmake_rel_bindir ${CMAKE_INSTALL_FULL_LIBDIR}/cmake/vpl
|
||||
${CMAKE_INSTALL_FULL_BINDIR})
|
||||
|
||||
configure_file(cmake/VPLConfig.cmake.in cmake/VPLConfig.cmake @ONLY)
|
||||
configure_file(cmake/VPLConfigVersion.cmake.in cmake/VPLConfigVersion.cmake
|
||||
@ONLY)
|
||||
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/VPLConfig.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/VPLConfigVersion.cmake"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/vpl"
|
||||
COMPONENT ${VPL_COMPONENT_DEV})
|
||||
|
||||
file(RELATIVE_PATH pc_rel_prefix ${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig
|
||||
${CMAKE_INSTALL_PREFIX})
|
||||
file(RELATIVE_PATH pc_rel_libdir ${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig
|
||||
${CMAKE_INSTALL_FULL_LIBDIR})
|
||||
file(RELATIVE_PATH pc_rel_incdir ${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig
|
||||
${CMAKE_INSTALL_FULL_INCLUDEDIR})
|
||||
set(pc_rel_prefix "$\{pcfiledir}/${pc_rel_prefix}")
|
||||
set(pc_rel_libdir "$\{pcfiledir}/${pc_rel_libdir}")
|
||||
set(pc_rel_incdir "$\{pcfiledir}/${pc_rel_incdir}")
|
||||
|
||||
if(CMAKE_DL_LIBS)
|
||||
set(DL_LIBS "-l${CMAKE_DL_LIBS}")
|
||||
endif()
|
||||
if(MINGW)
|
||||
# being conservative by restricting to MinGW, these are probably ok for
|
||||
# WIN32 in general
|
||||
set(MINGW_LIBS "-lole32 -lgdi32 -luuid")
|
||||
endif()
|
||||
set(VPL_PKGCONFIG_DEPENDENT_LIBS
|
||||
"${DL_LIBS} ${CMAKE_THREAD_LIBS_INIT} ${MINGW_LIBS} ${CXX_LIB}")
|
||||
configure_file("pkgconfig/vpl.pc.in" "pkgconfig/vpl.pc" @ONLY)
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/vpl.pc"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
|
||||
COMPONENT ${VPL_COMPONENT_DEV})
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
@@ -0,0 +1,146 @@
|
||||
# ##############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
# ##############################################################################
|
||||
|
||||
# * Config file for the VPL package It defines the following variables
|
||||
# VPL_<component>_FOUND VPL_IMPORTED_TARGETS
|
||||
#
|
||||
# VPLConfigVersion.cmake defines VPL_VERSION
|
||||
|
||||
option(VPL_SHARED "Use shared instead of static version of dispatcher."
|
||||
@BUILD_SHARED_LIBS@)
|
||||
|
||||
# Initialize to default values
|
||||
set(VPL_INTERFACE_VERSION @API_VERSION_MAJOR@)
|
||||
get_filename_component(_vpl_config_file
|
||||
"${CMAKE_CURRENT_LIST_DIR}/VPLConfig.cmake" REALPATH)
|
||||
get_filename_component(_vpl_config_dir "${_vpl_config_file}" DIRECTORY)
|
||||
get_filename_component(_vpl_install_prefix
|
||||
"${_vpl_config_dir}/@cmake_rel_prefix@" REALPATH)
|
||||
|
||||
get_filename_component(VPL_LIB_DIR "${_vpl_config_dir}/@cmake_rel_libdir@"
|
||||
ABSOLUTE)
|
||||
get_filename_component(VPL_INCLUDE_DIR "${_vpl_config_dir}/@cmake_rel_incdir@"
|
||||
ABSOLUTE)
|
||||
get_filename_component(VPL_BIN_DIR "${_vpl_config_dir}/@cmake_rel_bindir@"
|
||||
ABSOLUTE)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES Windows)
|
||||
set(VPL_SHLIB_DIR ${VPL_BIN_DIR})
|
||||
else()
|
||||
set(VPL_SHLIB_DIR ${VPL_LIB_DIR})
|
||||
endif()
|
||||
|
||||
if(NOT VPL_IMPORTED_TARGETS)
|
||||
set(VPL_IMPORTED_TARGETS "")
|
||||
endif()
|
||||
|
||||
if(NOT VPL_FIND_COMPONENTS)
|
||||
set(VPL_FIND_COMPONENTS "dispatcher;api")
|
||||
foreach(_vpl_component ${VPL_FIND_COMPONENTS})
|
||||
set(VPL_FIND_REQUIRED_${_vpl_component} 1)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# VPL::dispatcher
|
||||
set(VPL_dispatcher_FOUND 0)
|
||||
|
||||
get_filename_component(_dispatcher_shlib "${VPL_SHLIB_DIR}/@SHLIB_FILE_NAME@"
|
||||
ABSOLUTE)
|
||||
get_filename_component(_dispatcher_debug_shlib
|
||||
"${VPL_SHLIB_DIR}/@SHLIB_FILE_NAME_DEBUG@" ABSOLUTE)
|
||||
get_filename_component(_dispatcher_lib "${VPL_LIB_DIR}/@LIB_FILE_NAME@"
|
||||
ABSOLUTE)
|
||||
get_filename_component(_dispatcher_debug_lib
|
||||
"${VPL_LIB_DIR}/@LIB_FILE_NAME_DEBUG@" ABSOLUTE)
|
||||
get_filename_component(_dispatcher_implib "${VPL_LIB_DIR}/@LIB_FILE_NAME@"
|
||||
ABSOLUTE)
|
||||
get_filename_component(_dispatcher_debug_implib
|
||||
"${VPL_LIB_DIR}/@LIB_FILE_NAME_DEBUG@" ABSOLUTE)
|
||||
|
||||
if(TARGET VPL::dispatcher)
|
||||
list(APPEND VPL_IMPORTED_TARGETS VPL::dispatcher)
|
||||
set(VPL_dispatcher_FOUND 1)
|
||||
else()
|
||||
if(VPL_SHARED)
|
||||
if(EXISTS "${_dispatcher_shlib}" OR EXISTS "${_dispatcher_debug_shlib}")
|
||||
list(APPEND VPL_IMPORTED_TARGETS VPL::dispatcher)
|
||||
set(VPL_dispatcher_FOUND 1)
|
||||
|
||||
add_library(VPL::dispatcher SHARED IMPORTED)
|
||||
set_target_properties(
|
||||
VPL::dispatcher
|
||||
PROPERTIES IMPORTED_LOCATION_RELEASE ${_dispatcher_shlib}
|
||||
IMPORTED_LOCATION_RELWITHDEBINFO ${_dispatcher_shlib}
|
||||
IMPORTED_LOCATION_MINSIZEREL ${_dispatcher_shlib}
|
||||
IMPORTED_LOCATION_DEBUG ${_dispatcher_debug_shlib}
|
||||
IMPORTED_LOCATION_RELWITHDEBRT ${_dispatcher_debug_shlib})
|
||||
if(CMAKE_SYSTEM_NAME MATCHES Windows)
|
||||
set_target_properties(
|
||||
VPL::dispatcher
|
||||
PROPERTIES IMPORTED_IMPLIB_RELEASE ${_dispatcher_implib}
|
||||
IMPORTED_IMPLIB_RELWITHDEBINFO ${_dispatcher_implib}
|
||||
IMPORTED_IMPLIB_MINSIZEREL ${_dispatcher_implib}
|
||||
IMPORTED_IMPLIB_DEBUG ${_dispatcher_debug_implib}
|
||||
IMPORTED_IMPLIB_RELWITHDEBRT ${_dispatcher_debug_implib})
|
||||
endif()
|
||||
elseif(VPL_FIND_REQUIRED AND VPL_FIND_REQUIRED_dispatcher)
|
||||
message(STATUS "Unable to find required VPL component: dispatcher")
|
||||
set(VPL_FOUND FALSE)
|
||||
endif()
|
||||
else()
|
||||
if(EXISTS "${_dispatcher_lib}" OR EXISTS "${_dispatcher_debug_lib}")
|
||||
list(APPEND VPL_IMPORTED_TARGETS VPL::dispatcher)
|
||||
set(VPL_dispatcher_FOUND 1)
|
||||
add_library(VPL::dispatcher STATIC IMPORTED)
|
||||
set_target_properties(
|
||||
VPL::dispatcher
|
||||
PROPERTIES IMPORTED_LOCATION_RELEASE ${_dispatcher_lib}
|
||||
IMPORTED_LOCATION_RELWITHDEBINFO ${_dispatcher_lib}
|
||||
IMPORTED_LOCATION_MINSIZEREL ${_dispatcher_lib}
|
||||
IMPORTED_LOCATION_DEBUG ${_dispatcher_debug_lib}
|
||||
IMPORTED_LOCATION_RELWITHDEBRT ${_dispatcher_debug_lib})
|
||||
if(UNIX)
|
||||
# require pthreads for loading legacy MSDK runtimes
|
||||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(VPL::dispatcher INTERFACE Threads::Threads)
|
||||
endif()
|
||||
target_link_libraries(VPL::dispatcher INTERFACE ${CMAKE_DL_LIBS})
|
||||
elseif(VPL_FIND_REQUIRED AND VPL_FIND_REQUIRED_dispatcher)
|
||||
message(STATUS "Unable to find required VPL component: dispatcher")
|
||||
set(VPL_FOUND FALSE)
|
||||
endif()
|
||||
endif()
|
||||
set_target_properties(VPL::dispatcher PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${VPL_INCLUDE_DIR}")
|
||||
endif()
|
||||
|
||||
unset(_dispatcher_shlib)
|
||||
|
||||
# VPL::api
|
||||
set(VPL_api_FOUND 0)
|
||||
if(EXISTS ${VPL_INCLUDE_DIR})
|
||||
if(NOT TARGET VPL::api)
|
||||
add_library(VPL::api INTERFACE IMPORTED)
|
||||
set_target_properties(VPL::api PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${VPL_INCLUDE_DIR}")
|
||||
endif()
|
||||
list(APPEND VPL_IMPORTED_TARGETS VPL::api)
|
||||
set(VPL_api_FOUND 1)
|
||||
endif()
|
||||
|
||||
# VPL::cppapi
|
||||
set(VPL_cppapi_FOUND 0)
|
||||
if(EXISTS ${VPL_INCLUDE_DIR})
|
||||
if(NOT TARGET VPL::cppapi)
|
||||
add_library(VPL::cppapi INTERFACE IMPORTED)
|
||||
set_target_properties(VPL::cppapi PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${VPL_INCLUDE_DIR}")
|
||||
endif()
|
||||
list(APPEND VPL_IMPORTED_TARGETS VPL::cppapi)
|
||||
set(VPL_cppapi_FOUND 1)
|
||||
endif()
|
||||
@@ -0,0 +1,17 @@
|
||||
# ##############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
# ##############################################################################
|
||||
|
||||
set(PACKAGE_VERSION "@API_VERSION_MAJOR@.@API_VERSION_MINOR@")
|
||||
|
||||
# Check whether the requested PACKAGE_FIND_VERSION is compatible
|
||||
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
if("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
|
||||
set(PACKAGE_VERSION_EXACT TRUE)
|
||||
endif()
|
||||
endif()
|
||||
@@ -0,0 +1,12 @@
|
||||
prefix=@pc_rel_prefix@
|
||||
libdir=@pc_rel_libdir@
|
||||
includedir=@pc_rel_incdir@
|
||||
|
||||
Name: Intel(R) Video Processing Library
|
||||
Description: Accelerated video decode, encode, and frame processing capabilities on Intel(R) GPUs
|
||||
Version: @API_VERSION_MAJOR@.@API_VERSION_MINOR@
|
||||
URL: https://github.com/intel/libvpl
|
||||
|
||||
Libs: -L${libdir} -l@OUTPUT_NAME@ @VPL_PKGCONFIG_DEPENDENT_LIBS@
|
||||
Libs.private: @VPL_PKGCONFIG_PRIVATE_LIBS@
|
||||
Cflags: -I${includedir} -I${includedir}/vpl
|
||||
@@ -0,0 +1,448 @@
|
||||
/*############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#ifndef LIBVPL_SRC_LINUX_DEVICE_IDS_H_
|
||||
#define LIBVPL_SRC_LINUX_DEVICE_IDS_H_
|
||||
|
||||
// Tables from:
|
||||
// https://github.com/Intel-Media-SDK/MediaSDK/blob/master/_studio/shared/src/libmfx_core_vaapi.cpp
|
||||
// https://github.com/Intel-Media-SDK/MediaSDK/blob/master/_studio/shared/include/mfxstructures-int.h
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "vpl/mfxvideo.h"
|
||||
|
||||
enum eMFXHWType {
|
||||
MFX_HW_UNKNOWN = 0,
|
||||
MFX_HW_SNB = 0x300000,
|
||||
|
||||
MFX_HW_IVB = 0x400000,
|
||||
|
||||
MFX_HW_HSW = 0x500000,
|
||||
MFX_HW_HSW_ULT = 0x500001,
|
||||
|
||||
MFX_HW_VLV = 0x600000,
|
||||
|
||||
MFX_HW_BDW = 0x700000,
|
||||
|
||||
MFX_HW_CHT = 0x800000,
|
||||
|
||||
MFX_HW_SCL = 0x900000,
|
||||
|
||||
MFX_HW_APL = 0x1000000,
|
||||
|
||||
MFX_HW_KBL = 0x1100000,
|
||||
MFX_HW_GLK = MFX_HW_KBL + 1,
|
||||
MFX_HW_CFL = MFX_HW_KBL + 2,
|
||||
|
||||
MFX_HW_CNL = 0x1200000,
|
||||
MFX_HW_ICL = 0x1400000,
|
||||
MFX_HW_ICL_LP = MFX_HW_ICL + 1,
|
||||
|
||||
MFX_HW_JSL = 0x1500001,
|
||||
MFX_HW_EHL = 0x1500002,
|
||||
};
|
||||
|
||||
enum eMFXGTConfig { MFX_GT_UNKNOWN = 0, MFX_GT1 = 1, MFX_GT2 = 2, MFX_GT3 = 3, MFX_GT4 = 4 };
|
||||
|
||||
typedef struct {
|
||||
unsigned int device_id;
|
||||
eMFXHWType platform;
|
||||
eMFXGTConfig config;
|
||||
} mfx_device_item;
|
||||
|
||||
// list of legal dev ID for Intel's graphics
|
||||
static const mfx_device_item listLegalDevIDs[] = {
|
||||
/*IVB*/
|
||||
{ 0x0156, MFX_HW_IVB, MFX_GT1 }, /* GT1 mobile */
|
||||
{ 0x0166, MFX_HW_IVB, MFX_GT2 }, /* GT2 mobile */
|
||||
{ 0x0152, MFX_HW_IVB, MFX_GT1 }, /* GT1 desktop */
|
||||
{ 0x0162, MFX_HW_IVB, MFX_GT2 }, /* GT2 desktop */
|
||||
{ 0x015a, MFX_HW_IVB, MFX_GT1 }, /* GT1 server */
|
||||
{ 0x016a, MFX_HW_IVB, MFX_GT2 }, /* GT2 server */
|
||||
/*HSW*/
|
||||
{ 0x0402, MFX_HW_HSW, MFX_GT1 }, /* GT1 desktop */
|
||||
{ 0x0412, MFX_HW_HSW, MFX_GT2 }, /* GT2 desktop */
|
||||
{ 0x0422, MFX_HW_HSW, MFX_GT2 }, /* GT2 desktop */
|
||||
{ 0x041e, MFX_HW_HSW, MFX_GT2 }, /* Core i3-4130 */
|
||||
{ 0x040a, MFX_HW_HSW, MFX_GT1 }, /* GT1 server */
|
||||
{ 0x041a, MFX_HW_HSW, MFX_GT2 }, /* GT2 server */
|
||||
{ 0x042a, MFX_HW_HSW, MFX_GT2 }, /* GT2 server */
|
||||
{ 0x0406, MFX_HW_HSW, MFX_GT1 }, /* GT1 mobile */
|
||||
{ 0x0416, MFX_HW_HSW, MFX_GT2 }, /* GT2 mobile */
|
||||
{ 0x0426, MFX_HW_HSW, MFX_GT2 }, /* GT2 mobile */
|
||||
{ 0x0C02, MFX_HW_HSW, MFX_GT1 }, /* SDV GT1 desktop */
|
||||
{ 0x0C12, MFX_HW_HSW, MFX_GT2 }, /* SDV GT2 desktop */
|
||||
{ 0x0C22, MFX_HW_HSW, MFX_GT2 }, /* SDV GT2 desktop */
|
||||
{ 0x0C0A, MFX_HW_HSW, MFX_GT1 }, /* SDV GT1 server */
|
||||
{ 0x0C1A, MFX_HW_HSW, MFX_GT2 }, /* SDV GT2 server */
|
||||
{ 0x0C2A, MFX_HW_HSW, MFX_GT2 }, /* SDV GT2 server */
|
||||
{ 0x0C06, MFX_HW_HSW, MFX_GT1 }, /* SDV GT1 mobile */
|
||||
{ 0x0C16, MFX_HW_HSW, MFX_GT2 }, /* SDV GT2 mobile */
|
||||
{ 0x0C26, MFX_HW_HSW, MFX_GT2 }, /* SDV GT2 mobile */
|
||||
{ 0x0A02, MFX_HW_HSW, MFX_GT1 }, /* ULT GT1 desktop */
|
||||
{ 0x0A12, MFX_HW_HSW, MFX_GT2 }, /* ULT GT2 desktop */
|
||||
{ 0x0A22, MFX_HW_HSW, MFX_GT2 }, /* ULT GT2 desktop */
|
||||
{ 0x0A0A, MFX_HW_HSW, MFX_GT1 }, /* ULT GT1 server */
|
||||
{ 0x0A1A, MFX_HW_HSW, MFX_GT2 }, /* ULT GT2 server */
|
||||
{ 0x0A2A, MFX_HW_HSW, MFX_GT2 }, /* ULT GT2 server */
|
||||
{ 0x0A06, MFX_HW_HSW, MFX_GT1 }, /* ULT GT1 mobile */
|
||||
{ 0x0A16, MFX_HW_HSW, MFX_GT2 }, /* ULT GT2 mobile */
|
||||
{ 0x0A26, MFX_HW_HSW, MFX_GT2 }, /* ULT GT2 mobile */
|
||||
{ 0x0D02, MFX_HW_HSW, MFX_GT1 }, /* CRW GT1 desktop */
|
||||
{ 0x0D12, MFX_HW_HSW, MFX_GT2 }, /* CRW GT2 desktop */
|
||||
{ 0x0D22, MFX_HW_HSW, MFX_GT2 }, /* CRW GT2 desktop */
|
||||
{ 0x0D0A, MFX_HW_HSW, MFX_GT1 }, /* CRW GT1 server */
|
||||
{ 0x0D1A, MFX_HW_HSW, MFX_GT2 }, /* CRW GT2 server */
|
||||
{ 0x0D2A, MFX_HW_HSW, MFX_GT2 }, /* CRW GT2 server */
|
||||
{ 0x0D06, MFX_HW_HSW, MFX_GT1 }, /* CRW GT1 mobile */
|
||||
{ 0x0D16, MFX_HW_HSW, MFX_GT2 }, /* CRW GT2 mobile */
|
||||
{ 0x0D26, MFX_HW_HSW, MFX_GT2 }, /* CRW GT2 mobile */
|
||||
/* this dev IDs added per HSD 5264859 request */
|
||||
{ 0x040B, MFX_HW_HSW, MFX_GT1 },
|
||||
/*HASWELL_B_GT1 */ /* Reserved */
|
||||
{ 0x041B, MFX_HW_HSW, MFX_GT2 }, /*HASWELL_B_GT2*/
|
||||
{ 0x042B, MFX_HW_HSW, MFX_GT3 }, /*HASWELL_B_GT3*/
|
||||
{ 0x040E, MFX_HW_HSW, MFX_GT1 },
|
||||
/*HASWELL_E_GT1*/ /* Reserved */
|
||||
{ 0x041E, MFX_HW_HSW, MFX_GT2 }, /*HASWELL_E_GT2*/
|
||||
{ 0x042E, MFX_HW_HSW, MFX_GT3 }, /*HASWELL_E_GT3*/
|
||||
|
||||
{ 0x0C0B, MFX_HW_HSW, MFX_GT1 },
|
||||
/*HASWELL_SDV_B_GT1*/ /* Reserved */
|
||||
{ 0x0C1B, MFX_HW_HSW, MFX_GT2 }, /*HASWELL_SDV_B_GT2*/
|
||||
{ 0x0C2B, MFX_HW_HSW, MFX_GT3 }, /*HASWELL_SDV_B_GT3*/
|
||||
{ 0x0C0E, MFX_HW_HSW, MFX_GT1 },
|
||||
/*HASWELL_SDV_B_GT1*/ /* Reserved */
|
||||
{ 0x0C1E, MFX_HW_HSW, MFX_GT2 }, /*HASWELL_SDV_B_GT2*/
|
||||
{ 0x0C2E, MFX_HW_HSW, MFX_GT3 }, /*HASWELL_SDV_B_GT3*/
|
||||
|
||||
{ 0x0A0B, MFX_HW_HSW, MFX_GT1 },
|
||||
/*HASWELL_ULT_B_GT1*/ /* Reserved */
|
||||
{ 0x0A1B, MFX_HW_HSW, MFX_GT2 }, /*HASWELL_ULT_B_GT2*/
|
||||
{ 0x0A2B, MFX_HW_HSW, MFX_GT3 }, /*HASWELL_ULT_B_GT3*/
|
||||
{ 0x0A0E, MFX_HW_HSW, MFX_GT1 },
|
||||
/*HASWELL_ULT_E_GT1*/ /* Reserved */
|
||||
{ 0x0A1E, MFX_HW_HSW, MFX_GT2 }, /*HASWELL_ULT_E_GT2*/
|
||||
{ 0x0A2E, MFX_HW_HSW, MFX_GT3 }, /*HASWELL_ULT_E_GT3*/
|
||||
|
||||
{ 0x0D0B, MFX_HW_HSW, MFX_GT1 },
|
||||
/*HASWELL_CRW_B_GT1*/ /* Reserved */
|
||||
{ 0x0D1B, MFX_HW_HSW, MFX_GT2 }, /*HASWELL_CRW_B_GT2*/
|
||||
{ 0x0D2B, MFX_HW_HSW, MFX_GT3 }, /*HASWELL_CRW_B_GT3*/
|
||||
{ 0x0D0E, MFX_HW_HSW, MFX_GT1 },
|
||||
/*HASWELL_CRW_E_GT1*/ /* Reserved */
|
||||
{ 0x0D1E, MFX_HW_HSW, MFX_GT2 }, /*HASWELL_CRW_E_GT2*/
|
||||
{ 0x0D2E, MFX_HW_HSW, MFX_GT3 }, /*HASWELL_CRW_E_GT3*/
|
||||
|
||||
/* VLV */
|
||||
{ 0x0f30, MFX_HW_VLV, MFX_GT1 }, /* VLV mobile */
|
||||
{ 0x0f31, MFX_HW_VLV, MFX_GT1 }, /* VLV mobile */
|
||||
{ 0x0f32, MFX_HW_VLV, MFX_GT1 }, /* VLV mobile */
|
||||
{ 0x0f33, MFX_HW_VLV, MFX_GT1 }, /* VLV mobile */
|
||||
{ 0x0157, MFX_HW_VLV, MFX_GT1 },
|
||||
{ 0x0155, MFX_HW_VLV, MFX_GT1 },
|
||||
|
||||
/* BDW */
|
||||
/*GT3: */
|
||||
{ 0x162D, MFX_HW_BDW, MFX_GT3 },
|
||||
{ 0x162A, MFX_HW_BDW, MFX_GT3 },
|
||||
/*GT2: */
|
||||
{ 0x161D, MFX_HW_BDW, MFX_GT2 },
|
||||
{ 0x161A, MFX_HW_BDW, MFX_GT2 },
|
||||
/* GT1: */
|
||||
{ 0x160D, MFX_HW_BDW, MFX_GT1 },
|
||||
{ 0x160A, MFX_HW_BDW, MFX_GT1 },
|
||||
/* BDW-ULT */
|
||||
/* (16x2 - ULT, 16x6 - ULT, 16xB - Iris, 16xE - ULX) */
|
||||
/*GT3: */
|
||||
{ 0x162E, MFX_HW_BDW, MFX_GT3 },
|
||||
{ 0x162B, MFX_HW_BDW, MFX_GT3 },
|
||||
{ 0x1626, MFX_HW_BDW, MFX_GT3 },
|
||||
{ 0x1622, MFX_HW_BDW, MFX_GT3 },
|
||||
{ 0x1636, MFX_HW_BDW, MFX_GT3 }, /* ULT */
|
||||
{ 0x163B, MFX_HW_BDW, MFX_GT3 }, /* Iris */
|
||||
{ 0x163E, MFX_HW_BDW, MFX_GT3 }, /* ULX */
|
||||
{ 0x1632, MFX_HW_BDW, MFX_GT3 }, /* ULT */
|
||||
{ 0x163A, MFX_HW_BDW, MFX_GT3 }, /* Server */
|
||||
{ 0x163D, MFX_HW_BDW, MFX_GT3 }, /* Workstation */
|
||||
|
||||
/* GT2: */
|
||||
{ 0x161E, MFX_HW_BDW, MFX_GT2 },
|
||||
{ 0x161B, MFX_HW_BDW, MFX_GT2 },
|
||||
{ 0x1616, MFX_HW_BDW, MFX_GT2 },
|
||||
{ 0x1612, MFX_HW_BDW, MFX_GT2 },
|
||||
/* GT1: */
|
||||
{ 0x160E, MFX_HW_BDW, MFX_GT1 },
|
||||
{ 0x160B, MFX_HW_BDW, MFX_GT1 },
|
||||
{ 0x1606, MFX_HW_BDW, MFX_GT1 },
|
||||
{ 0x1602, MFX_HW_BDW, MFX_GT1 },
|
||||
|
||||
/* CHT */
|
||||
{ 0x22b0, MFX_HW_CHT, MFX_GT1 },
|
||||
{ 0x22b1, MFX_HW_CHT, MFX_GT1 },
|
||||
{ 0x22b2, MFX_HW_CHT, MFX_GT1 },
|
||||
{ 0x22b3, MFX_HW_CHT, MFX_GT1 },
|
||||
|
||||
/* SCL */
|
||||
/* GT1F */
|
||||
{ 0x1902, MFX_HW_SCL, MFX_GT1 }, // DT, 2x1F, 510
|
||||
{ 0x1906, MFX_HW_SCL, MFX_GT1 }, // U-ULT, 2x1F, 510
|
||||
{ 0x190A, MFX_HW_SCL, MFX_GT1 }, // Server, 4x1F
|
||||
{ 0x190B, MFX_HW_SCL, MFX_GT1 },
|
||||
{ 0x190E, MFX_HW_SCL, MFX_GT1 }, // Y-ULX 2x1F
|
||||
/*GT1.5*/
|
||||
{ 0x1913, MFX_HW_SCL, MFX_GT1 }, // U-ULT, 2x1.5
|
||||
{ 0x1915, MFX_HW_SCL, MFX_GT1 }, // Y-ULX, 2x1.5
|
||||
{ 0x1917, MFX_HW_SCL, MFX_GT1 }, // DT, 2x1.5
|
||||
/* GT2 */
|
||||
{ 0x1912, MFX_HW_SCL, MFX_GT2 }, // DT, 2x2, 530
|
||||
{ 0x1916, MFX_HW_SCL, MFX_GT2 }, // U-ULD 2x2, 520
|
||||
{ 0x191A, MFX_HW_SCL, MFX_GT2 }, // 2x2,4x2, Server
|
||||
{ 0x191B, MFX_HW_SCL, MFX_GT2 }, // DT, 2x2, 530
|
||||
{ 0x191D, MFX_HW_SCL, MFX_GT2 }, // 4x2, WKS, P530
|
||||
{ 0x191E, MFX_HW_SCL, MFX_GT2 }, // Y-ULX, 2x2, P510,515
|
||||
{ 0x1921, MFX_HW_SCL, MFX_GT2 }, // U-ULT, 2x2F, 540
|
||||
/* GT3 */
|
||||
{ 0x1923, MFX_HW_SCL, MFX_GT3 }, // U-ULT, 2x3, 535
|
||||
{ 0x1926, MFX_HW_SCL, MFX_GT3 }, // U-ULT, 2x3, 540 (15W)
|
||||
{ 0x1927, MFX_HW_SCL, MFX_GT3 }, // U-ULT, 2x3e, 550 (28W)
|
||||
{ 0x192A, MFX_HW_SCL, MFX_GT3 }, // Server, 2x3
|
||||
{ 0x192B, MFX_HW_SCL, MFX_GT3 }, // Halo 3e
|
||||
{ 0x192D, MFX_HW_SCL, MFX_GT3 },
|
||||
/* GT4e*/
|
||||
{ 0x1932, MFX_HW_SCL, MFX_GT4 }, // DT
|
||||
{ 0x193A, MFX_HW_SCL, MFX_GT4 }, // SRV
|
||||
{ 0x193B, MFX_HW_SCL, MFX_GT4 }, // Halo
|
||||
{ 0x193D, MFX_HW_SCL, MFX_GT4 }, // WKS
|
||||
|
||||
/* APL */
|
||||
{ 0x0A84, MFX_HW_APL, MFX_GT1 },
|
||||
{ 0x0A85, MFX_HW_APL, MFX_GT1 },
|
||||
{ 0x0A86, MFX_HW_APL, MFX_GT1 },
|
||||
{ 0x0A87, MFX_HW_APL, MFX_GT1 },
|
||||
{ 0x1A84, MFX_HW_APL, MFX_GT1 },
|
||||
{ 0x1A85, MFX_HW_APL, MFX_GT1 },
|
||||
{ 0x5A84, MFX_HW_APL, MFX_GT1 },
|
||||
{ 0x5A85, MFX_HW_APL, MFX_GT1 },
|
||||
|
||||
/* KBL */
|
||||
{ 0x5902, MFX_HW_KBL, MFX_GT1 }, // DT GT1
|
||||
{ 0x5906, MFX_HW_KBL, MFX_GT1 }, // ULT GT1
|
||||
{ 0x5908, MFX_HW_KBL, MFX_GT1 }, // HALO GT1F
|
||||
{ 0x590A, MFX_HW_KBL, MFX_GT1 }, // SERV GT1
|
||||
{ 0x590B, MFX_HW_KBL, MFX_GT1 }, // HALO GT1
|
||||
{ 0x590E, MFX_HW_KBL, MFX_GT1 }, // ULX GT1
|
||||
{ 0x5912, MFX_HW_KBL, MFX_GT2 }, // DT GT2
|
||||
{ 0x5913, MFX_HW_KBL, MFX_GT1 }, // ULT GT1 5
|
||||
{ 0x5915, MFX_HW_KBL, MFX_GT1 }, // ULX GT1 5
|
||||
{ 0x5916, MFX_HW_KBL, MFX_GT2 }, // ULT GT2
|
||||
{ 0x5917, MFX_HW_KBL, MFX_GT2 }, // ULT GT2 R
|
||||
{ 0x591A, MFX_HW_KBL, MFX_GT2 }, // SERV GT2
|
||||
{ 0x591B, MFX_HW_KBL, MFX_GT2 }, // HALO GT2
|
||||
{ 0x591C, MFX_HW_KBL, MFX_GT2 }, // ULX GT2
|
||||
{ 0x591D, MFX_HW_KBL, MFX_GT2 }, // WRK GT2
|
||||
{ 0x591E, MFX_HW_KBL, MFX_GT2 }, // ULX GT2
|
||||
{ 0x5921, MFX_HW_KBL, MFX_GT2 }, // ULT GT2F
|
||||
{ 0x5923, MFX_HW_KBL, MFX_GT3 }, // ULT GT3
|
||||
{ 0x5926, MFX_HW_KBL, MFX_GT3 }, // ULT GT3 15W
|
||||
{ 0x5927, MFX_HW_KBL, MFX_GT3 }, // ULT GT3 28W
|
||||
{ 0x592A, MFX_HW_KBL, MFX_GT3 }, // SERV GT3
|
||||
{ 0x592B, MFX_HW_KBL, MFX_GT3 }, // HALO GT3
|
||||
{ 0x5932, MFX_HW_KBL, MFX_GT4 }, // DT GT4
|
||||
{ 0x593A, MFX_HW_KBL, MFX_GT4 }, // SERV GT4
|
||||
{ 0x593B, MFX_HW_KBL, MFX_GT4 }, // HALO GT4
|
||||
{ 0x593D, MFX_HW_KBL, MFX_GT4 }, // WRK GT4
|
||||
{ 0x87C0, MFX_HW_KBL, MFX_GT2 }, // ULX GT2
|
||||
|
||||
/* GLK */
|
||||
{ 0x3184, MFX_HW_GLK, MFX_GT1 },
|
||||
{ 0x3185, MFX_HW_GLK, MFX_GT1 },
|
||||
|
||||
/* CFL */
|
||||
{ 0x3E90, MFX_HW_CFL, MFX_GT1 },
|
||||
{ 0x3E91, MFX_HW_CFL, MFX_GT2 },
|
||||
{ 0x3E92, MFX_HW_CFL, MFX_GT2 },
|
||||
{ 0x3E93, MFX_HW_CFL, MFX_GT1 },
|
||||
{ 0x3E94, MFX_HW_CFL, MFX_GT2 },
|
||||
{ 0x3E96, MFX_HW_CFL, MFX_GT2 },
|
||||
{ 0x3E98, MFX_HW_CFL, MFX_GT2 },
|
||||
{ 0x3E99, MFX_HW_CFL, MFX_GT1 },
|
||||
{ 0x3E9A, MFX_HW_CFL, MFX_GT2 },
|
||||
{ 0x3E9C, MFX_HW_CFL, MFX_GT1 },
|
||||
{ 0x3E9B, MFX_HW_CFL, MFX_GT2 },
|
||||
{ 0x3EA5, MFX_HW_CFL, MFX_GT3 },
|
||||
{ 0x3EA6, MFX_HW_CFL, MFX_GT3 },
|
||||
{ 0x3EA7, MFX_HW_CFL, MFX_GT3 },
|
||||
{ 0x3EA8, MFX_HW_CFL, MFX_GT3 },
|
||||
{ 0x3EA9, MFX_HW_CFL, MFX_GT2 },
|
||||
{ 0x87CA, MFX_HW_CFL, MFX_GT2 },
|
||||
|
||||
/* WHL */
|
||||
{ 0x3EA0, MFX_HW_CFL, MFX_GT2 },
|
||||
{ 0x3EA1, MFX_HW_CFL, MFX_GT1 },
|
||||
{ 0x3EA2, MFX_HW_CFL, MFX_GT3 },
|
||||
{ 0x3EA3, MFX_HW_CFL, MFX_GT2 },
|
||||
{ 0x3EA4, MFX_HW_CFL, MFX_GT1 },
|
||||
|
||||
/* CML GT1 */
|
||||
{ 0x9b21, MFX_HW_CFL, MFX_GT1 },
|
||||
{ 0x9baa, MFX_HW_CFL, MFX_GT1 },
|
||||
{ 0x9bab, MFX_HW_CFL, MFX_GT1 },
|
||||
{ 0x9bac, MFX_HW_CFL, MFX_GT1 },
|
||||
{ 0x9ba0, MFX_HW_CFL, MFX_GT1 },
|
||||
{ 0x9ba5, MFX_HW_CFL, MFX_GT1 },
|
||||
{ 0x9ba8, MFX_HW_CFL, MFX_GT1 },
|
||||
{ 0x9ba4, MFX_HW_CFL, MFX_GT1 },
|
||||
{ 0x9ba2, MFX_HW_CFL, MFX_GT1 },
|
||||
|
||||
/* CML GT2 */
|
||||
{ 0x9b41, MFX_HW_CFL, MFX_GT2 },
|
||||
{ 0x9bca, MFX_HW_CFL, MFX_GT2 },
|
||||
{ 0x9bcb, MFX_HW_CFL, MFX_GT2 },
|
||||
{ 0x9bcc, MFX_HW_CFL, MFX_GT2 },
|
||||
{ 0x9bc0, MFX_HW_CFL, MFX_GT2 },
|
||||
{ 0x9bc5, MFX_HW_CFL, MFX_GT2 },
|
||||
{ 0x9bc8, MFX_HW_CFL, MFX_GT2 },
|
||||
{ 0x9bc4, MFX_HW_CFL, MFX_GT2 },
|
||||
{ 0x9bc2, MFX_HW_CFL, MFX_GT2 },
|
||||
{ 0x9bc6, MFX_HW_CFL, MFX_GT2 },
|
||||
{ 0x9be6, MFX_HW_CFL, MFX_GT2 },
|
||||
{ 0x9bf6, MFX_HW_CFL, MFX_GT2 },
|
||||
|
||||
/* CNL */
|
||||
{ 0x5A51, MFX_HW_CNL, MFX_GT2 },
|
||||
{ 0x5A52, MFX_HW_CNL, MFX_GT2 },
|
||||
{ 0x5A5A, MFX_HW_CNL, MFX_GT2 },
|
||||
{ 0x5A40, MFX_HW_CNL, MFX_GT2 },
|
||||
{ 0x5A42, MFX_HW_CNL, MFX_GT2 },
|
||||
{ 0x5A4A, MFX_HW_CNL, MFX_GT2 },
|
||||
{ 0x5A4C, MFX_HW_CNL, MFX_GT1 },
|
||||
{ 0x5A50, MFX_HW_CNL, MFX_GT2 },
|
||||
{ 0x5A54, MFX_HW_CNL, MFX_GT1 },
|
||||
{ 0x5A59, MFX_HW_CNL, MFX_GT2 },
|
||||
{ 0x5A5C, MFX_HW_CNL, MFX_GT1 },
|
||||
{ 0x5A41, MFX_HW_CNL, MFX_GT2 },
|
||||
{ 0x5A44, MFX_HW_CNL, MFX_GT1 },
|
||||
{ 0x5A49, MFX_HW_CNL, MFX_GT2 },
|
||||
|
||||
/* ICL LP */
|
||||
{ 0xFF05, MFX_HW_ICL_LP, MFX_GT1 },
|
||||
{ 0x8A50, MFX_HW_ICL_LP, MFX_GT2 },
|
||||
{ 0x8A51, MFX_HW_ICL_LP, MFX_GT2 },
|
||||
{ 0x8A52, MFX_HW_ICL_LP, MFX_GT2 },
|
||||
{ 0x8A53, MFX_HW_ICL_LP, MFX_GT2 },
|
||||
{ 0x8A54, MFX_HW_ICL_LP, MFX_GT1 },
|
||||
{ 0x8A56, MFX_HW_ICL_LP, MFX_GT1 },
|
||||
{ 0x8A57, MFX_HW_ICL_LP, MFX_GT1 },
|
||||
{ 0x8A58, MFX_HW_ICL_LP, MFX_GT1 },
|
||||
{ 0x8A59, MFX_HW_ICL_LP, MFX_GT1 },
|
||||
{ 0x8A5A, MFX_HW_ICL_LP, MFX_GT1 },
|
||||
{ 0x8A5B, MFX_HW_ICL_LP, MFX_GT1 },
|
||||
{ 0x8A5C, MFX_HW_ICL_LP, MFX_GT1 },
|
||||
{ 0x8A5D, MFX_HW_ICL_LP, MFX_GT1 },
|
||||
{ 0x8A70, MFX_HW_ICL_LP, MFX_GT1 },
|
||||
{ 0x8A71, MFX_HW_ICL_LP, MFX_GT1 }, // GT05, but 1 ok in this context
|
||||
|
||||
/* JSL */
|
||||
{ 0x4E51, MFX_HW_JSL, MFX_GT2 },
|
||||
{ 0x4E55, MFX_HW_JSL, MFX_GT2 },
|
||||
{ 0x4E61, MFX_HW_JSL, MFX_GT2 },
|
||||
{ 0x4E71, MFX_HW_JSL, MFX_GT2 },
|
||||
|
||||
/* EHL */
|
||||
{ 0x4500, MFX_HW_EHL, MFX_GT2 },
|
||||
{ 0x4541, MFX_HW_EHL, MFX_GT2 },
|
||||
{ 0x4551, MFX_HW_EHL, MFX_GT2 },
|
||||
{ 0x4555, MFX_HW_EHL, MFX_GT2 },
|
||||
{ 0x4569, MFX_HW_EHL, MFX_GT2 },
|
||||
{ 0x4571, MFX_HW_EHL, MFX_GT2 },
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
unsigned int vendor_id;
|
||||
unsigned int device_id;
|
||||
eMFXHWType platform;
|
||||
} Device;
|
||||
|
||||
static inline eMFXHWType get_platform(unsigned int device_id) {
|
||||
for (unsigned i = 0; i < sizeof(listLegalDevIDs) / sizeof(listLegalDevIDs[0]); ++i) {
|
||||
if (listLegalDevIDs[i].device_id == device_id) {
|
||||
return listLegalDevIDs[i].platform;
|
||||
}
|
||||
}
|
||||
return MFX_HW_UNKNOWN;
|
||||
}
|
||||
|
||||
static mfxStatus get_devices(std::vector<Device> &allDevices) {
|
||||
const char *dir = "/sys/class/drm";
|
||||
const char *device_id_file = "/device/device";
|
||||
const char *vendor_id_file = "/device/vendor";
|
||||
|
||||
int i = 0;
|
||||
for (; i < 64; ++i) {
|
||||
Device device;
|
||||
std::string path = std::string(dir) + "/renderD" + std::to_string(128 + i) + vendor_id_file;
|
||||
std::string line;
|
||||
std::ifstream dev_str;
|
||||
|
||||
dev_str.open(path);
|
||||
if (!dev_str.is_open()) {
|
||||
continue;
|
||||
}
|
||||
std::getline(dev_str, line);
|
||||
dev_str.close();
|
||||
try {
|
||||
device.vendor_id = std::stoul(line, 0, 16);
|
||||
}
|
||||
catch (std::invalid_argument &) {
|
||||
continue;
|
||||
}
|
||||
catch (std::out_of_range &) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Filter out non-Intel devices
|
||||
if (device.vendor_id != 0x8086)
|
||||
continue;
|
||||
|
||||
path = std::string(dir) + "/renderD" + std::to_string(128 + i) + device_id_file;
|
||||
dev_str.open(path);
|
||||
if (!dev_str.is_open()) {
|
||||
continue;
|
||||
}
|
||||
std::getline(dev_str, line);
|
||||
dev_str.close();
|
||||
try {
|
||||
device.device_id = std::stoul(line, 0, 16);
|
||||
}
|
||||
catch (std::invalid_argument &) {
|
||||
continue;
|
||||
}
|
||||
catch (std::out_of_range &) {
|
||||
continue;
|
||||
}
|
||||
|
||||
device.platform = get_platform(device.device_id);
|
||||
|
||||
allDevices.emplace_back(device);
|
||||
}
|
||||
|
||||
// sort by platform, unknown will appear at beginning
|
||||
std::sort(allDevices.begin(), allDevices.end(), [](const Device &a, const Device &b) {
|
||||
return a.platform < b.platform;
|
||||
});
|
||||
|
||||
if (allDevices.size() == 0)
|
||||
return MFX_ERR_NOT_FOUND;
|
||||
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
|
||||
#endif // LIBVPL_SRC_LINUX_DEVICE_IDS_H_
|
||||
@@ -0,0 +1,81 @@
|
||||
LIBVPL_2.0 {
|
||||
global:
|
||||
MFXInit;
|
||||
MFXClose;
|
||||
MFXQueryIMPL;
|
||||
MFXQueryVersion;
|
||||
|
||||
MFXJoinSession;
|
||||
MFXDisjoinSession;
|
||||
MFXCloneSession;
|
||||
MFXSetPriority;
|
||||
MFXGetPriority;
|
||||
|
||||
MFXVideoCORE_SetFrameAllocator;
|
||||
MFXVideoCORE_SetHandle;
|
||||
MFXVideoCORE_GetHandle;
|
||||
MFXVideoCORE_QueryPlatform;
|
||||
MFXVideoCORE_SyncOperation;
|
||||
|
||||
MFXVideoENCODE_Query;
|
||||
MFXVideoENCODE_QueryIOSurf;
|
||||
MFXVideoENCODE_Init;
|
||||
MFXVideoENCODE_Reset;
|
||||
MFXVideoENCODE_Close;
|
||||
MFXVideoENCODE_GetVideoParam;
|
||||
MFXVideoENCODE_GetEncodeStat;
|
||||
MFXVideoENCODE_EncodeFrameAsync;
|
||||
|
||||
MFXVideoDECODE_Query;
|
||||
MFXVideoDECODE_DecodeHeader;
|
||||
MFXVideoDECODE_QueryIOSurf;
|
||||
MFXVideoDECODE_Init;
|
||||
MFXVideoDECODE_Reset;
|
||||
MFXVideoDECODE_Close;
|
||||
MFXVideoDECODE_GetVideoParam;
|
||||
MFXVideoDECODE_GetDecodeStat;
|
||||
MFXVideoDECODE_SetSkipMode;
|
||||
MFXVideoDECODE_GetPayload;
|
||||
MFXVideoDECODE_DecodeFrameAsync;
|
||||
|
||||
MFXVideoVPP_Query;
|
||||
MFXVideoVPP_QueryIOSurf;
|
||||
MFXVideoVPP_Init;
|
||||
MFXVideoVPP_Reset;
|
||||
MFXVideoVPP_Close;
|
||||
|
||||
MFXVideoVPP_GetVideoParam;
|
||||
MFXVideoVPP_GetVPPStat;
|
||||
MFXVideoVPP_RunFrameVPPAsync;
|
||||
|
||||
MFXInitEx;
|
||||
|
||||
MFXLoad;
|
||||
MFXUnload;
|
||||
MFXCreateConfig;
|
||||
MFXSetConfigFilterProperty;
|
||||
MFXEnumImplementations;
|
||||
MFXCreateSession;
|
||||
MFXDispReleaseImplDescription;
|
||||
|
||||
MFXMemory_GetSurfaceForVPP;
|
||||
MFXMemory_GetSurfaceForEncode;
|
||||
MFXMemory_GetSurfaceForDecode;
|
||||
|
||||
local:
|
||||
*;
|
||||
};
|
||||
|
||||
LIBVPL_2.1 {
|
||||
global:
|
||||
MFXMemory_GetSurfaceForVPPOut;
|
||||
MFXVideoDECODE_VPP_Init;
|
||||
MFXVideoDECODE_VPP_DecodeFrameAsync;
|
||||
MFXVideoDECODE_VPP_Reset;
|
||||
MFXVideoDECODE_VPP_GetChannelParam;
|
||||
MFXVideoDECODE_VPP_Close;
|
||||
MFXVideoVPP_ProcessFrameAsync;
|
||||
|
||||
local:
|
||||
*;
|
||||
} LIBVPL_2.0;
|
||||
@@ -0,0 +1,842 @@
|
||||
/*############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <dlfcn.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "vpl/mfxvideo.h"
|
||||
|
||||
// internal implementation of mfxConfigInterface
|
||||
#include "src/mfx_config_interface/mfx_config_interface.h"
|
||||
|
||||
#include "src/linux/device_ids.h"
|
||||
#include "src/linux/mfxloader.h"
|
||||
|
||||
namespace MFX {
|
||||
|
||||
#if defined(__x86_64__) || (INTPTR_MAX == INT64_MAX)
|
||||
#define LIBMFXSW "libmfxsw64.so.1"
|
||||
#define LIBMFXHW "libmfxhw64.so.1"
|
||||
|
||||
#define ONEVPLSW "libvplswref64.so.1"
|
||||
#define ONEVPLHW "libmfx-gen.so.1.2"
|
||||
#elif defined(__i386__) || (INTPTR_MAX == INT32_MAX)
|
||||
#define LIBMFXSW "libmfxsw32.so.1"
|
||||
#define LIBMFXHW "libmfxhw32.so.1"
|
||||
|
||||
#define ONEVPLSW "libvplswref32.so.1"
|
||||
#define ONEVPLHW "libmfx-gen.so.1.2"
|
||||
#else
|
||||
#error Unsupported architecture
|
||||
#endif
|
||||
|
||||
#undef FUNCTION
|
||||
#define FUNCTION(return_value, func_name, formal_param_list, actual_param_list) e##func_name,
|
||||
|
||||
enum Function {
|
||||
eMFXInit,
|
||||
eMFXInitEx,
|
||||
eMFXClose,
|
||||
eMFXJoinSession,
|
||||
eMFXVideoCORE_GetHandle,
|
||||
#include "src/linux/mfxvideo_functions.h"
|
||||
eFunctionsNum,
|
||||
eNoMoreFunctions = eFunctionsNum
|
||||
};
|
||||
|
||||
// new functions for API 2.x
|
||||
enum Function2 {
|
||||
// 2.0
|
||||
eMFXQueryImplsDescription = 0,
|
||||
eMFXReleaseImplDescription,
|
||||
eMFXMemory_GetSurfaceForVPP,
|
||||
eMFXMemory_GetSurfaceForEncode,
|
||||
eMFXMemory_GetSurfaceForDecode,
|
||||
eMFXInitialize,
|
||||
|
||||
// 2.1
|
||||
eMFXMemory_GetSurfaceForVPPOut,
|
||||
eMFXVideoDECODE_VPP_Init,
|
||||
eMFXVideoDECODE_VPP_DecodeFrameAsync,
|
||||
eMFXVideoDECODE_VPP_Reset,
|
||||
eMFXVideoDECODE_VPP_GetChannelParam,
|
||||
eMFXVideoDECODE_VPP_Close,
|
||||
eMFXVideoVPP_ProcessFrameAsync,
|
||||
|
||||
eFunctionsNum2,
|
||||
};
|
||||
|
||||
struct FunctionsTable {
|
||||
Function id;
|
||||
const char *name;
|
||||
mfxVersion version;
|
||||
};
|
||||
|
||||
struct FunctionsTable2 {
|
||||
Function2 id;
|
||||
const char *name;
|
||||
mfxVersion version;
|
||||
};
|
||||
|
||||
#define VERSION(major, minor) \
|
||||
{ \
|
||||
{ minor, major } \
|
||||
}
|
||||
|
||||
#undef FUNCTION
|
||||
#define FUNCTION(return_value, func_name, formal_param_list, actual_param_list) \
|
||||
{ e##func_name, #func_name, API_VERSION },
|
||||
|
||||
static const FunctionsTable g_mfxFuncTable[] = {
|
||||
{ eMFXInit, "MFXInit", VERSION(1, 0) },
|
||||
{ eMFXInitEx, "MFXInitEx", VERSION(1, 14) },
|
||||
{ eMFXClose, "MFXClose", VERSION(1, 0) },
|
||||
{ eMFXJoinSession, "MFXJoinSession", VERSION(1, 1) },
|
||||
{ eMFXVideoCORE_GetHandle, "MFXVideoCORE_GetHandle", VERSION(1, 0) },
|
||||
#include "src/linux/mfxvideo_functions.h" // NOLINT(build/include)
|
||||
{ eNoMoreFunctions }
|
||||
};
|
||||
|
||||
static const FunctionsTable2 g_mfxFuncTable2[] = {
|
||||
{ eMFXQueryImplsDescription, "MFXQueryImplsDescription", VERSION(2, 0) },
|
||||
{ eMFXReleaseImplDescription, "MFXReleaseImplDescription", VERSION(2, 0) },
|
||||
{ eMFXMemory_GetSurfaceForVPP, "MFXMemory_GetSurfaceForVPP", VERSION(2, 0) },
|
||||
{ eMFXMemory_GetSurfaceForEncode, "MFXMemory_GetSurfaceForEncode", VERSION(2, 0) },
|
||||
{ eMFXMemory_GetSurfaceForDecode, "MFXMemory_GetSurfaceForDecode", VERSION(2, 0) },
|
||||
{ eMFXInitialize, "MFXInitialize", VERSION(2, 0) },
|
||||
|
||||
{ eMFXMemory_GetSurfaceForVPPOut, "MFXMemory_GetSurfaceForVPPOut", VERSION(2, 1) },
|
||||
{ eMFXVideoDECODE_VPP_Init, "MFXVideoDECODE_VPP_Init", VERSION(2, 1) },
|
||||
{ eMFXVideoDECODE_VPP_DecodeFrameAsync, "MFXVideoDECODE_VPP_DecodeFrameAsync", VERSION(2, 1) },
|
||||
{ eMFXVideoDECODE_VPP_Reset, "MFXVideoDECODE_VPP_Reset", VERSION(2, 1) },
|
||||
{ eMFXVideoDECODE_VPP_GetChannelParam, "MFXVideoDECODE_VPP_GetChannelParam", VERSION(2, 1) },
|
||||
{ eMFXVideoDECODE_VPP_Close, "MFXVideoDECODE_VPP_Close", VERSION(2, 1) },
|
||||
{ eMFXVideoVPP_ProcessFrameAsync, "MFXVideoVPP_ProcessFrameAsync", VERSION(2, 1) },
|
||||
};
|
||||
|
||||
class LoaderCtx {
|
||||
public:
|
||||
mfxStatus Init(mfxInitParam &par,
|
||||
mfxInitializationParam &vplParam,
|
||||
mfxU16 *pDeviceID,
|
||||
char *dllName,
|
||||
bool bCloneSession = false);
|
||||
mfxStatus Close();
|
||||
|
||||
inline void *getFunction(Function func) const {
|
||||
return m_table[func];
|
||||
}
|
||||
|
||||
inline void *getFunction2(Function2 func) const {
|
||||
return m_table2[func];
|
||||
}
|
||||
|
||||
inline mfxSession getSession() const {
|
||||
return m_session;
|
||||
}
|
||||
|
||||
inline mfxIMPL getImpl() const {
|
||||
return m_implementation;
|
||||
}
|
||||
|
||||
inline mfxVersion getVersion() const {
|
||||
return m_version;
|
||||
}
|
||||
|
||||
inline void *getHandle() const {
|
||||
return m_dlh.get();
|
||||
}
|
||||
|
||||
inline const char *getLibPath() const {
|
||||
return m_libToLoad.c_str();
|
||||
}
|
||||
|
||||
// special operations to set session pointer and version from MFXCloneSession()
|
||||
inline void setSession(const mfxSession session) {
|
||||
m_session = session;
|
||||
}
|
||||
|
||||
inline void setVersion(const mfxVersion version) {
|
||||
m_version = version;
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<void> m_dlh;
|
||||
mfxVersion m_version{};
|
||||
mfxIMPL m_implementation{};
|
||||
mfxSession m_session = nullptr;
|
||||
void *m_table[eFunctionsNum]{};
|
||||
void *m_table2[eFunctionsNum2]{};
|
||||
std::string m_libToLoad;
|
||||
};
|
||||
|
||||
std::shared_ptr<void> make_dlopen(const char *filename, int flags) {
|
||||
return std::shared_ptr<void>(dlopen(filename, flags), [](void *handle) {
|
||||
if (handle)
|
||||
dlclose(handle);
|
||||
});
|
||||
}
|
||||
|
||||
mfxStatus LoaderCtx::Init(mfxInitParam &par,
|
||||
mfxInitializationParam &vplParam,
|
||||
mfxU16 *pDeviceID,
|
||||
char *dllName,
|
||||
bool bCloneSession) {
|
||||
mfxStatus mfx_res = MFX_ERR_NONE;
|
||||
|
||||
std::vector<std::string> libs;
|
||||
std::vector<Device> devices;
|
||||
eMFXHWType msdk_platform;
|
||||
|
||||
// query graphics device_id
|
||||
// if it is found on list of legacy devices, load MSDK RT
|
||||
// otherwise load Intel® Video Processing Library (Intel® VPL) RT
|
||||
mfxU16 deviceID = 0;
|
||||
mfx_res = get_devices(devices);
|
||||
if (mfx_res == MFX_ERR_NOT_FOUND) {
|
||||
// query failed
|
||||
msdk_platform = MFX_HW_UNKNOWN;
|
||||
}
|
||||
else {
|
||||
// query succeeded:
|
||||
// may be a valid platform from listLegalDevIDs[] or MFX_HW_UNKNOWN
|
||||
// if underlying device_id is unrecognized (i.e. new platform)
|
||||
msdk_platform = devices[0].platform;
|
||||
deviceID = devices[0].device_id;
|
||||
}
|
||||
|
||||
if (pDeviceID)
|
||||
*pDeviceID = deviceID;
|
||||
|
||||
if (dllName) {
|
||||
// attempt to load only this DLL, fail if unsuccessful
|
||||
// this may also be used later by MFXCloneSession()
|
||||
m_libToLoad = dllName;
|
||||
libs.emplace_back(m_libToLoad);
|
||||
}
|
||||
else {
|
||||
mfxIMPL implType = MFX_IMPL_BASETYPE(par.Implementation);
|
||||
// add HW lib
|
||||
if (implType == MFX_IMPL_AUTO || implType == MFX_IMPL_AUTO_ANY ||
|
||||
(implType & MFX_IMPL_HARDWARE) || (implType & MFX_IMPL_HARDWARE_ANY)) {
|
||||
if (msdk_platform == MFX_HW_UNKNOWN) {
|
||||
// if not on list of known MSDK platforms, prefer Intel® VPL
|
||||
libs.emplace_back(ONEVPLHW);
|
||||
libs.emplace_back(MFX_MODULES_DIR "/" ONEVPLHW);
|
||||
}
|
||||
|
||||
// use MSDK (fallback if Intel® VPL is not installed)
|
||||
libs.emplace_back(LIBMFXHW);
|
||||
libs.emplace_back(MFX_MODULES_DIR "/" LIBMFXHW);
|
||||
}
|
||||
|
||||
// add SW lib (Intel® VPL only)
|
||||
if (implType == MFX_IMPL_AUTO || implType == MFX_IMPL_AUTO_ANY ||
|
||||
(implType & MFX_IMPL_SOFTWARE)) {
|
||||
libs.emplace_back(ONEVPLSW);
|
||||
libs.emplace_back(MFX_MODULES_DIR "/" ONEVPLSW);
|
||||
}
|
||||
}
|
||||
|
||||
// fail if libs is empty (invalid Implementation)
|
||||
mfx_res = MFX_ERR_UNSUPPORTED;
|
||||
|
||||
for (auto &lib : libs) {
|
||||
std::shared_ptr<void> hdl = make_dlopen(lib.c_str(), RTLD_LOCAL | RTLD_NOW);
|
||||
if (hdl) {
|
||||
do {
|
||||
/* Loading functions table */
|
||||
bool wrong_version = false;
|
||||
for (int i = 0; i < eFunctionsNum; ++i) {
|
||||
assert(i == g_mfxFuncTable[i].id);
|
||||
m_table[i] = dlsym(hdl.get(), g_mfxFuncTable[i].name);
|
||||
if (!m_table[i] && ((g_mfxFuncTable[i].version <= par.Version))) {
|
||||
wrong_version = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if version >= 2.0, load these functions as well
|
||||
if (par.Version.Major >= 2) {
|
||||
for (int i = 0; i < eFunctionsNum2; ++i) {
|
||||
assert(i == g_mfxFuncTable2[i].id);
|
||||
m_table2[i] = dlsym(hdl.get(), g_mfxFuncTable2[i].name);
|
||||
if (!m_table2[i] && (g_mfxFuncTable2[i].version <= par.Version)) {
|
||||
wrong_version = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (wrong_version) {
|
||||
mfx_res = MFX_ERR_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
|
||||
if (bCloneSession == true) {
|
||||
// success - exit loop since caller will create session with MFXCloneSession()
|
||||
mfx_res = MFX_ERR_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (par.Version.Major >= 2) {
|
||||
// for API >= 2.0 call MFXInitialize instead of MFXInitEx
|
||||
mfx_res =
|
||||
((decltype(MFXInitialize) *)m_table2[eMFXInitialize])(vplParam, &m_session);
|
||||
}
|
||||
else {
|
||||
if (m_table[eMFXInitEx]) {
|
||||
// initialize with MFXInitEx if present (API >= 1.14)
|
||||
mfx_res = ((decltype(MFXInitEx) *)m_table[eMFXInitEx])(par, &m_session);
|
||||
}
|
||||
else {
|
||||
// initialize with MFXInit for API < 1.14
|
||||
mfx_res = ((decltype(MFXInit) *)m_table[eMFXInit])(par.Implementation,
|
||||
&(par.Version),
|
||||
&m_session);
|
||||
}
|
||||
}
|
||||
|
||||
if (MFX_ERR_NONE != mfx_res) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Below we just get some data and double check that we got what we have expected
|
||||
// to get. Some of these checks are done inside mediasdk init function
|
||||
mfx_res =
|
||||
((decltype(MFXQueryVersion) *)m_table[eMFXQueryVersion])(m_session, &m_version);
|
||||
if (MFX_ERR_NONE != mfx_res) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_version < par.Version) {
|
||||
mfx_res = MFX_ERR_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
|
||||
mfx_res = ((decltype(MFXQueryIMPL) *)m_table[eMFXQueryIMPL])(m_session,
|
||||
&m_implementation);
|
||||
if (MFX_ERR_NONE != mfx_res) {
|
||||
mfx_res = MFX_ERR_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
} while (false);
|
||||
|
||||
if (MFX_ERR_NONE == mfx_res) {
|
||||
m_dlh = std::move(hdl);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mfx_res;
|
||||
}
|
||||
|
||||
mfxStatus LoaderCtx::Close() {
|
||||
auto proc = (decltype(MFXClose) *)m_table[eMFXClose];
|
||||
mfxStatus mfx_res = (proc) ? (*proc)(m_session) : MFX_ERR_NONE;
|
||||
|
||||
m_implementation = {};
|
||||
m_version = {};
|
||||
m_session = nullptr;
|
||||
std::fill(std::begin(m_table), std::end(m_table), nullptr);
|
||||
return mfx_res;
|
||||
}
|
||||
|
||||
} // namespace MFX
|
||||
|
||||
// internal function - load a specific DLL, return unsupported if it fails
|
||||
// vplParam is required for API >= 2.0 (load via MFXInitialize)
|
||||
mfxStatus MFXInitEx2(mfxVersion version,
|
||||
mfxInitializationParam vplParam,
|
||||
mfxIMPL hwImpl,
|
||||
mfxSession *session,
|
||||
mfxU16 *deviceID,
|
||||
char *dllName) {
|
||||
if (!session)
|
||||
return MFX_ERR_NULL_PTR;
|
||||
|
||||
*deviceID = 0;
|
||||
|
||||
// fill minimal 1.x parameters for Init to choose correct initialization path
|
||||
mfxInitParam par = {};
|
||||
par.Version = version;
|
||||
|
||||
// select first adapter if not specified
|
||||
// only relevant for MSDK-via-MFXLoad path
|
||||
if (!hwImpl)
|
||||
hwImpl = MFX_IMPL_HARDWARE;
|
||||
|
||||
switch (vplParam.AccelerationMode) {
|
||||
case MFX_ACCEL_MODE_NA:
|
||||
par.Implementation = MFX_IMPL_SOFTWARE;
|
||||
break;
|
||||
case MFX_ACCEL_MODE_VIA_D3D9:
|
||||
par.Implementation = hwImpl | MFX_IMPL_VIA_D3D9;
|
||||
break;
|
||||
case MFX_ACCEL_MODE_VIA_D3D11:
|
||||
par.Implementation = hwImpl | MFX_IMPL_VIA_D3D11;
|
||||
break;
|
||||
case MFX_ACCEL_MODE_VIA_VAAPI:
|
||||
par.Implementation = hwImpl | MFX_IMPL_VIA_VAAPI;
|
||||
break;
|
||||
default:
|
||||
par.Implementation = hwImpl;
|
||||
break;
|
||||
}
|
||||
|
||||
// also pass extBuf array (if any) to MFXInitEx for 1.x API
|
||||
par.NumExtParam = vplParam.NumExtParam;
|
||||
par.ExtParam = (vplParam.NumExtParam ? vplParam.ExtParam : nullptr);
|
||||
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
// if GPUCopy is enabled via MFXSetConfigProperty(DeviceCopy), set corresponding
|
||||
// flag in mfxInitParam for legacy RTs
|
||||
par.GPUCopy = vplParam.DeviceCopy;
|
||||
#endif
|
||||
|
||||
try {
|
||||
std::unique_ptr<MFX::LoaderCtx> loader;
|
||||
|
||||
loader.reset(new MFX::LoaderCtx{});
|
||||
|
||||
mfxStatus mfx_res = loader->Init(par, vplParam, deviceID, dllName);
|
||||
if (MFX_ERR_NONE == mfx_res) {
|
||||
*session = (mfxSession)loader.release();
|
||||
}
|
||||
else {
|
||||
*session = nullptr;
|
||||
}
|
||||
|
||||
return mfx_res;
|
||||
}
|
||||
catch (...) {
|
||||
return MFX_ERR_MEMORY_ALLOC;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
mfxStatus MFXInit(mfxIMPL impl, mfxVersion *ver, mfxSession *session) {
|
||||
mfxInitParam par{};
|
||||
|
||||
par.Implementation = impl;
|
||||
if (ver) {
|
||||
par.Version = *ver;
|
||||
}
|
||||
else {
|
||||
par.Version = VERSION(MFX_VERSION_MAJOR, MFX_VERSION_MINOR);
|
||||
}
|
||||
|
||||
return MFXInitEx(par, session);
|
||||
}
|
||||
|
||||
mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session) {
|
||||
if (!session)
|
||||
return MFX_ERR_NULL_PTR;
|
||||
|
||||
const mfxIMPL implMethod = par.Implementation & (MFX_IMPL_VIA_ANY - 1);
|
||||
mfxInitializationParam vplParam = {};
|
||||
if (implMethod == MFX_IMPL_SOFTWARE) {
|
||||
vplParam.AccelerationMode = MFX_ACCEL_MODE_NA;
|
||||
}
|
||||
else {
|
||||
vplParam.AccelerationMode = MFX_ACCEL_MODE_VIA_VAAPI;
|
||||
}
|
||||
|
||||
try {
|
||||
std::unique_ptr<MFX::LoaderCtx> loader;
|
||||
|
||||
loader.reset(new MFX::LoaderCtx{});
|
||||
|
||||
mfxStatus mfx_res = loader->Init(par, vplParam, nullptr, nullptr);
|
||||
if (MFX_ERR_NONE == mfx_res) {
|
||||
*session = (mfxSession)loader.release();
|
||||
}
|
||||
else {
|
||||
*session = nullptr;
|
||||
}
|
||||
|
||||
return mfx_res;
|
||||
}
|
||||
catch (...) {
|
||||
return MFX_ERR_MEMORY_ALLOC;
|
||||
}
|
||||
}
|
||||
|
||||
mfxStatus MFXClose(mfxSession session) {
|
||||
if (!session)
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
|
||||
try {
|
||||
std::unique_ptr<MFX::LoaderCtx> loader((MFX::LoaderCtx *)session);
|
||||
mfxStatus mfx_res = loader->Close();
|
||||
|
||||
if (mfx_res == MFX_ERR_UNDEFINED_BEHAVIOR) {
|
||||
// It is possible, that there is an active child session.
|
||||
// Can't unload library in this case.
|
||||
loader.release();
|
||||
}
|
||||
return mfx_res;
|
||||
}
|
||||
catch (...) {
|
||||
return MFX_ERR_MEMORY_ALLOC;
|
||||
}
|
||||
}
|
||||
|
||||
// passthrough functions to implementation
|
||||
mfxStatus MFXMemory_GetSurfaceForVPP(mfxSession session, mfxFrameSurface1 **surface) {
|
||||
if (!session)
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
|
||||
MFX::LoaderCtx *loader = (MFX::LoaderCtx *)session;
|
||||
|
||||
auto proc = (decltype(MFXMemory_GetSurfaceForVPP) *)loader->getFunction2(
|
||||
MFX::eMFXMemory_GetSurfaceForVPP);
|
||||
if (!proc) {
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return (*proc)(loader->getSession(), surface);
|
||||
}
|
||||
|
||||
mfxStatus MFXMemory_GetSurfaceForVPPOut(mfxSession session, mfxFrameSurface1 **surface) {
|
||||
if (!session)
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
|
||||
MFX::LoaderCtx *loader = (MFX::LoaderCtx *)session;
|
||||
|
||||
auto proc = (decltype(MFXMemory_GetSurfaceForVPPOut) *)loader->getFunction2(
|
||||
MFX::eMFXMemory_GetSurfaceForVPPOut);
|
||||
if (!proc) {
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return (*proc)(loader->getSession(), surface);
|
||||
}
|
||||
|
||||
mfxStatus MFXMemory_GetSurfaceForEncode(mfxSession session, mfxFrameSurface1 **surface) {
|
||||
if (!session)
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
|
||||
MFX::LoaderCtx *loader = (MFX::LoaderCtx *)session;
|
||||
|
||||
auto proc = (decltype(MFXMemory_GetSurfaceForEncode) *)loader->getFunction2(
|
||||
MFX::eMFXMemory_GetSurfaceForEncode);
|
||||
if (!proc) {
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return (*proc)(loader->getSession(), surface);
|
||||
}
|
||||
|
||||
mfxStatus MFXMemory_GetSurfaceForDecode(mfxSession session, mfxFrameSurface1 **surface) {
|
||||
if (!session)
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
|
||||
MFX::LoaderCtx *loader = (MFX::LoaderCtx *)session;
|
||||
|
||||
auto proc = (decltype(MFXMemory_GetSurfaceForDecode) *)loader->getFunction2(
|
||||
MFX::eMFXMemory_GetSurfaceForDecode);
|
||||
if (!proc) {
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return (*proc)(loader->getSession(), surface);
|
||||
}
|
||||
|
||||
mfxStatus MFXVideoDECODE_VPP_Init(mfxSession session,
|
||||
mfxVideoParam *decode_par,
|
||||
mfxVideoChannelParam **vpp_par_array,
|
||||
mfxU32 num_vpp_par) {
|
||||
if (!session)
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
|
||||
MFX::LoaderCtx *loader = (MFX::LoaderCtx *)session;
|
||||
|
||||
auto proc =
|
||||
(decltype(MFXVideoDECODE_VPP_Init) *)loader->getFunction2(MFX::eMFXVideoDECODE_VPP_Init);
|
||||
if (!proc) {
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return (*proc)(loader->getSession(), decode_par, vpp_par_array, num_vpp_par);
|
||||
}
|
||||
|
||||
mfxStatus MFXVideoDECODE_VPP_DecodeFrameAsync(mfxSession session,
|
||||
mfxBitstream *bs,
|
||||
mfxU32 *skip_channels,
|
||||
mfxU32 num_skip_channels,
|
||||
mfxSurfaceArray **surf_array_out) {
|
||||
if (!session)
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
|
||||
MFX::LoaderCtx *loader = (MFX::LoaderCtx *)session;
|
||||
|
||||
auto proc = (decltype(MFXVideoDECODE_VPP_DecodeFrameAsync) *)loader->getFunction2(
|
||||
MFX::eMFXVideoDECODE_VPP_DecodeFrameAsync);
|
||||
if (!proc) {
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return (*proc)(loader->getSession(), bs, skip_channels, num_skip_channels, surf_array_out);
|
||||
}
|
||||
|
||||
mfxStatus MFXVideoDECODE_VPP_Reset(mfxSession session,
|
||||
mfxVideoParam *decode_par,
|
||||
mfxVideoChannelParam **vpp_par_array,
|
||||
mfxU32 num_vpp_par) {
|
||||
if (!session)
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
|
||||
MFX::LoaderCtx *loader = (MFX::LoaderCtx *)session;
|
||||
|
||||
auto proc =
|
||||
(decltype(MFXVideoDECODE_VPP_Reset) *)loader->getFunction2(MFX::eMFXVideoDECODE_VPP_Reset);
|
||||
if (!proc) {
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return (*proc)(loader->getSession(), decode_par, vpp_par_array, num_vpp_par);
|
||||
}
|
||||
|
||||
mfxStatus MFXVideoDECODE_VPP_GetChannelParam(mfxSession session,
|
||||
mfxVideoChannelParam *par,
|
||||
mfxU32 channel_id) {
|
||||
if (!session)
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
|
||||
MFX::LoaderCtx *loader = (MFX::LoaderCtx *)session;
|
||||
|
||||
auto proc = (decltype(MFXVideoDECODE_VPP_GetChannelParam) *)loader->getFunction2(
|
||||
MFX::eMFXVideoDECODE_VPP_GetChannelParam);
|
||||
if (!proc) {
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return (*proc)(loader->getSession(), par, channel_id);
|
||||
}
|
||||
|
||||
mfxStatus MFXVideoDECODE_VPP_Close(mfxSession session) {
|
||||
if (!session)
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
|
||||
MFX::LoaderCtx *loader = (MFX::LoaderCtx *)session;
|
||||
|
||||
auto proc =
|
||||
(decltype(MFXVideoDECODE_VPP_Close) *)loader->getFunction2(MFX::eMFXVideoDECODE_VPP_Close);
|
||||
if (!proc) {
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return (*proc)(loader->getSession());
|
||||
}
|
||||
|
||||
mfxStatus MFXVideoVPP_ProcessFrameAsync(mfxSession session,
|
||||
mfxFrameSurface1 *in,
|
||||
mfxFrameSurface1 **out) {
|
||||
if (!session)
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
|
||||
MFX::LoaderCtx *loader = (MFX::LoaderCtx *)session;
|
||||
|
||||
auto proc = (decltype(MFXVideoVPP_ProcessFrameAsync) *)loader->getFunction2(
|
||||
MFX::eMFXVideoVPP_ProcessFrameAsync);
|
||||
if (!proc) {
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return (*proc)(loader->getSession(), in, out);
|
||||
}
|
||||
|
||||
// implement as a non-passthrough function so that we can catch dispatcher-level interface query requests
|
||||
mfxStatus MFXVideoCORE_GetHandle(mfxSession session, mfxHandleType type, mfxHDL *hdl) {
|
||||
if (!session)
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
|
||||
MFX::LoaderCtx *loader = (MFX::LoaderCtx *)session;
|
||||
|
||||
// first check if handle type points to an interface implemented inside the dispatcher
|
||||
if (type == MFX_HANDLE_CONFIG_INTERFACE) {
|
||||
if (!hdl)
|
||||
return MFX_ERR_NULL_PTR;
|
||||
|
||||
*hdl = (mfxHDL)(&(MFX_CONFIG_INTERFACE::g_dispatcher_mfxConfigInterface));
|
||||
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
|
||||
// passthrough to runtime
|
||||
auto proc =
|
||||
(decltype(MFXVideoCORE_GetHandle) *)loader->getFunction(MFX::eMFXVideoCORE_GetHandle);
|
||||
if (!proc) {
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return (*proc)(loader->getSession(), type, hdl);
|
||||
}
|
||||
|
||||
mfxStatus MFXJoinSession(mfxSession session, mfxSession child_session) {
|
||||
if (!session || !child_session) {
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
MFX::LoaderCtx *loader = (MFX::LoaderCtx *)session;
|
||||
MFX::LoaderCtx *child_loader = (MFX::LoaderCtx *)child_session;
|
||||
|
||||
if (loader->getVersion().Version != child_loader->getVersion().Version) {
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
auto proc = (decltype(MFXJoinSession) *)loader->getFunction(MFX::eMFXJoinSession);
|
||||
if (!proc) {
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return (*proc)(loader->getSession(), child_loader->getSession());
|
||||
}
|
||||
|
||||
static mfxStatus AllocateCloneLoader(MFX::LoaderCtx *parentLoader, MFX::LoaderCtx **cloneLoader) {
|
||||
// initialization param structs are not used when bCloneSession == true
|
||||
mfxInitParam par = {};
|
||||
mfxInitializationParam vplParam = {};
|
||||
mfxU16 deviceID = 0;
|
||||
|
||||
// initialization extBufs are not saved at this level
|
||||
// the RT should save these when the parent session is created and may use
|
||||
// them when creating the cloned session
|
||||
par.NumExtParam = 0;
|
||||
|
||||
try {
|
||||
std::unique_ptr<MFX::LoaderCtx> cl;
|
||||
|
||||
cl.reset(new MFX::LoaderCtx{});
|
||||
|
||||
mfxStatus mfx_res =
|
||||
cl->Init(par, vplParam, &deviceID, (char *)parentLoader->getLibPath(), true);
|
||||
if (MFX_ERR_NONE == mfx_res) {
|
||||
*cloneLoader = cl.release();
|
||||
}
|
||||
else {
|
||||
*cloneLoader = nullptr;
|
||||
}
|
||||
|
||||
return mfx_res;
|
||||
}
|
||||
catch (...) {
|
||||
return MFX_ERR_MEMORY_ALLOC;
|
||||
}
|
||||
}
|
||||
|
||||
mfxStatus MFXCloneSession(mfxSession session, mfxSession *clone) {
|
||||
if (!session || !clone)
|
||||
return MFX_ERR_INVALID_HANDLE;
|
||||
|
||||
MFX::LoaderCtx *loader = (MFX::LoaderCtx *)session;
|
||||
mfxVersion version = loader->getVersion();
|
||||
*clone = nullptr;
|
||||
|
||||
// initialize the clone session
|
||||
// for runtimes with 1.x API, call MFXInit followed by MFXJoinSession
|
||||
// for runtimes with 2.x API, use RT implementation of MFXCloneSession (passthrough)
|
||||
if (version.Major == 1) {
|
||||
mfxStatus mfx_res = MFXInit(loader->getImpl(), &version, clone);
|
||||
if (MFX_ERR_NONE != mfx_res) {
|
||||
return mfx_res;
|
||||
}
|
||||
|
||||
// join the sessions
|
||||
mfx_res = MFXJoinSession(session, *clone);
|
||||
if (MFX_ERR_NONE != mfx_res) {
|
||||
MFXClose(*clone);
|
||||
*clone = nullptr;
|
||||
return mfx_res;
|
||||
}
|
||||
}
|
||||
else if (version.Major == 2) {
|
||||
MFX::LoaderCtx *loader = (MFX::LoaderCtx *)session;
|
||||
|
||||
// MFXCloneSession not included in function pointer search during init
|
||||
// for bwd-compat, check for it here and fail gracefully if missing
|
||||
void *libHandle = loader->getHandle();
|
||||
auto proc = (decltype(MFXCloneSession) *)(dlsym(libHandle, "MFXCloneSession"));
|
||||
if (!proc)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
|
||||
// allocate new dispatcher-level session object and copy
|
||||
// state from parent session (function pointer tables, impl type, etc.)
|
||||
MFX::LoaderCtx *cloneLoader;
|
||||
mfxStatus mfx_res = AllocateCloneLoader(loader, &cloneLoader);
|
||||
if (mfx_res != MFX_ERR_NONE)
|
||||
return mfx_res;
|
||||
|
||||
// call RT implementation of MFXCloneSession
|
||||
mfxSession cloneRT;
|
||||
mfx_res = (*proc)(loader->getSession(), &cloneRT);
|
||||
|
||||
if (mfx_res != MFX_ERR_NONE || cloneRT == NULL) {
|
||||
// RT call failed, delete cloned loader (no valid session created)
|
||||
delete cloneLoader;
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
cloneLoader->setSession(cloneRT);
|
||||
|
||||
// get version of cloned session
|
||||
mfxVersion cloneVersion = {};
|
||||
mfx_res = MFXQueryVersion((mfxSession)cloneLoader, &cloneVersion);
|
||||
cloneLoader->setVersion(cloneVersion);
|
||||
if (mfx_res != MFX_ERR_NONE) {
|
||||
MFXClose((mfxSession)cloneLoader);
|
||||
return mfx_res;
|
||||
}
|
||||
|
||||
*clone = (mfxSession)cloneLoader;
|
||||
}
|
||||
else {
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
|
||||
#undef FUNCTION
|
||||
#define FUNCTION(return_value, func_name, formal_param_list, actual_param_list) \
|
||||
return_value MFX_CDECL func_name formal_param_list { \
|
||||
/* get the function's address and make a call */ \
|
||||
if (!session) \
|
||||
return MFX_ERR_INVALID_HANDLE; \
|
||||
\
|
||||
MFX::LoaderCtx *loader = (MFX::LoaderCtx *)session; \
|
||||
\
|
||||
auto proc = (decltype(func_name) *)loader->getFunction(MFX::e##func_name); \
|
||||
if (!proc) \
|
||||
return MFX_ERR_INVALID_HANDLE; \
|
||||
\
|
||||
/* get the real session pointer */ \
|
||||
session = loader->getSession(); \
|
||||
/* pass down the call */ \
|
||||
return (*proc)actual_param_list; \
|
||||
}
|
||||
|
||||
#include "src/linux/mfxvideo_functions.h" // NOLINT(build/include)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,30 @@
|
||||
/*############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#ifndef LIBVPL_SRC_LINUX_MFXLOADER_H_
|
||||
#define LIBVPL_SRC_LINUX_MFXLOADER_H_
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include <list>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "vpl/mfxvideo.h"
|
||||
|
||||
inline bool operator<(const mfxVersion &lhs, const mfxVersion &rhs) {
|
||||
return (lhs.Major < rhs.Major || (lhs.Major == rhs.Major && lhs.Minor < rhs.Minor));
|
||||
}
|
||||
|
||||
inline bool operator<=(const mfxVersion &lhs, const mfxVersion &rhs) {
|
||||
return (lhs < rhs || (lhs.Major == rhs.Major && lhs.Minor == rhs.Minor));
|
||||
}
|
||||
|
||||
inline bool operator==(mfxGUID const &l, mfxGUID const &r) {
|
||||
return std::equal(l.Data, l.Data + 16, r.Data);
|
||||
}
|
||||
|
||||
#endif // LIBVPL_SRC_LINUX_MFXLOADER_H_
|
||||
@@ -0,0 +1,176 @@
|
||||
/*############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
//
|
||||
// WARNING:
|
||||
// this file doesn't contain an include guard by design.
|
||||
// The file may be included into a source file many times.
|
||||
// That is why this header doesn't contain any include directive.
|
||||
// Please, do no try to fix it.
|
||||
//
|
||||
// NOLINT(build/header_guard)
|
||||
|
||||
// Use define API_VERSION to set the API of functions listed further
|
||||
// When new functions are added new section with functions declarations must be started with updated define
|
||||
|
||||
//
|
||||
// API version 1.0 functions
|
||||
//
|
||||
|
||||
// API version where a function is added. Minor value should precedes the major value
|
||||
#define API_VERSION \
|
||||
{ \
|
||||
{ 0, 1 } \
|
||||
}
|
||||
|
||||
FUNCTION(mfxStatus, MFXQueryIMPL, (mfxSession session, mfxIMPL *impl), (session, impl))
|
||||
FUNCTION(mfxStatus, MFXQueryVersion, (mfxSession session, mfxVersion *version), (session, version))
|
||||
|
||||
// CORE interface functions
|
||||
FUNCTION(mfxStatus,
|
||||
MFXVideoCORE_SetFrameAllocator,
|
||||
(mfxSession session, mfxFrameAllocator *allocator),
|
||||
(session, allocator))
|
||||
FUNCTION(mfxStatus,
|
||||
MFXVideoCORE_SetHandle,
|
||||
(mfxSession session, mfxHandleType type, mfxHDL hdl),
|
||||
(session, type, hdl))
|
||||
|
||||
FUNCTION(mfxStatus,
|
||||
MFXVideoCORE_SyncOperation,
|
||||
(mfxSession session, mfxSyncPoint syncp, mfxU32 wait),
|
||||
(session, syncp, wait))
|
||||
|
||||
// ENCODE interface functions
|
||||
FUNCTION(mfxStatus,
|
||||
MFXVideoENCODE_Query,
|
||||
(mfxSession session, mfxVideoParam *in, mfxVideoParam *out),
|
||||
(session, in, out))
|
||||
FUNCTION(mfxStatus,
|
||||
MFXVideoENCODE_QueryIOSurf,
|
||||
(mfxSession session, mfxVideoParam *par, mfxFrameAllocRequest *request),
|
||||
(session, par, request))
|
||||
FUNCTION(mfxStatus, MFXVideoENCODE_Init, (mfxSession session, mfxVideoParam *par), (session, par))
|
||||
FUNCTION(mfxStatus, MFXVideoENCODE_Reset, (mfxSession session, mfxVideoParam *par), (session, par))
|
||||
FUNCTION(mfxStatus, MFXVideoENCODE_Close, (mfxSession session), (session))
|
||||
|
||||
FUNCTION(mfxStatus,
|
||||
MFXVideoENCODE_GetVideoParam,
|
||||
(mfxSession session, mfxVideoParam *par),
|
||||
(session, par))
|
||||
FUNCTION(mfxStatus,
|
||||
MFXVideoENCODE_GetEncodeStat,
|
||||
(mfxSession session, mfxEncodeStat *stat),
|
||||
(session, stat))
|
||||
FUNCTION(mfxStatus,
|
||||
MFXVideoENCODE_EncodeFrameAsync,
|
||||
(mfxSession session,
|
||||
mfxEncodeCtrl *ctrl,
|
||||
mfxFrameSurface1 *surface,
|
||||
mfxBitstream *bs,
|
||||
mfxSyncPoint *syncp),
|
||||
(session, ctrl, surface, bs, syncp))
|
||||
|
||||
// DECODE interface functions
|
||||
FUNCTION(mfxStatus,
|
||||
MFXVideoDECODE_Query,
|
||||
(mfxSession session, mfxVideoParam *in, mfxVideoParam *out),
|
||||
(session, in, out))
|
||||
FUNCTION(mfxStatus,
|
||||
MFXVideoDECODE_DecodeHeader,
|
||||
(mfxSession session, mfxBitstream *bs, mfxVideoParam *par),
|
||||
(session, bs, par))
|
||||
FUNCTION(mfxStatus,
|
||||
MFXVideoDECODE_QueryIOSurf,
|
||||
(mfxSession session, mfxVideoParam *par, mfxFrameAllocRequest *request),
|
||||
(session, par, request))
|
||||
FUNCTION(mfxStatus, MFXVideoDECODE_Init, (mfxSession session, mfxVideoParam *par), (session, par))
|
||||
FUNCTION(mfxStatus, MFXVideoDECODE_Reset, (mfxSession session, mfxVideoParam *par), (session, par))
|
||||
FUNCTION(mfxStatus, MFXVideoDECODE_Close, (mfxSession session), (session))
|
||||
|
||||
FUNCTION(mfxStatus,
|
||||
MFXVideoDECODE_GetVideoParam,
|
||||
(mfxSession session, mfxVideoParam *par),
|
||||
(session, par))
|
||||
FUNCTION(mfxStatus,
|
||||
MFXVideoDECODE_GetDecodeStat,
|
||||
(mfxSession session, mfxDecodeStat *stat),
|
||||
(session, stat))
|
||||
FUNCTION(mfxStatus,
|
||||
MFXVideoDECODE_SetSkipMode,
|
||||
(mfxSession session, mfxSkipMode mode),
|
||||
(session, mode))
|
||||
FUNCTION(mfxStatus,
|
||||
MFXVideoDECODE_GetPayload,
|
||||
(mfxSession session, mfxU64 *ts, mfxPayload *payload),
|
||||
(session, ts, payload))
|
||||
FUNCTION(mfxStatus,
|
||||
MFXVideoDECODE_DecodeFrameAsync,
|
||||
(mfxSession session,
|
||||
mfxBitstream *bs,
|
||||
mfxFrameSurface1 *surface_work,
|
||||
mfxFrameSurface1 **surface_out,
|
||||
mfxSyncPoint *syncp),
|
||||
(session, bs, surface_work, surface_out, syncp))
|
||||
|
||||
// VPP interface functions
|
||||
FUNCTION(mfxStatus,
|
||||
MFXVideoVPP_Query,
|
||||
(mfxSession session, mfxVideoParam *in, mfxVideoParam *out),
|
||||
(session, in, out))
|
||||
FUNCTION(mfxStatus,
|
||||
MFXVideoVPP_QueryIOSurf,
|
||||
(mfxSession session, mfxVideoParam *par, mfxFrameAllocRequest *request),
|
||||
(session, par, request))
|
||||
FUNCTION(mfxStatus, MFXVideoVPP_Init, (mfxSession session, mfxVideoParam *par), (session, par))
|
||||
FUNCTION(mfxStatus, MFXVideoVPP_Reset, (mfxSession session, mfxVideoParam *par), (session, par))
|
||||
FUNCTION(mfxStatus, MFXVideoVPP_Close, (mfxSession session), (session))
|
||||
|
||||
FUNCTION(mfxStatus,
|
||||
MFXVideoVPP_GetVideoParam,
|
||||
(mfxSession session, mfxVideoParam *par),
|
||||
(session, par))
|
||||
FUNCTION(mfxStatus, MFXVideoVPP_GetVPPStat, (mfxSession session, mfxVPPStat *stat), (session, stat))
|
||||
FUNCTION(mfxStatus,
|
||||
MFXVideoVPP_RunFrameVPPAsync,
|
||||
(mfxSession session,
|
||||
mfxFrameSurface1 *in,
|
||||
mfxFrameSurface1 *out,
|
||||
mfxExtVppAuxData *aux,
|
||||
mfxSyncPoint *syncp),
|
||||
(session, in, out, aux, syncp))
|
||||
|
||||
#undef API_VERSION
|
||||
|
||||
//
|
||||
// API version 1.1 functions
|
||||
//
|
||||
|
||||
#define API_VERSION \
|
||||
{ \
|
||||
{ 1, 1 } \
|
||||
}
|
||||
|
||||
FUNCTION(mfxStatus, MFXDisjoinSession, (mfxSession session), (session))
|
||||
FUNCTION(mfxStatus, MFXSetPriority, (mfxSession session, mfxPriority priority), (session, priority))
|
||||
FUNCTION(mfxStatus,
|
||||
MFXGetPriority,
|
||||
(mfxSession session, mfxPriority *priority),
|
||||
(session, priority))
|
||||
|
||||
#undef API_VERSION
|
||||
|
||||
#define API_VERSION \
|
||||
{ \
|
||||
{ 19, 1 } \
|
||||
}
|
||||
|
||||
FUNCTION(mfxStatus,
|
||||
MFXVideoCORE_QueryPlatform,
|
||||
(mfxSession session, mfxPlatform *platform),
|
||||
(session, platform))
|
||||
|
||||
#undef API_VERSION
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
---
|
||||
Language: Cpp
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: true
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignConsecutiveMacros: true
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: false
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: Empty
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: None
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: true
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: true
|
||||
BeforeElse: true
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: false
|
||||
SplitEmptyNamespace: false
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakStringLiterals: false
|
||||
ColumnLimit: 150
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 8
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: false
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^<ext/.*\.h>'
|
||||
Priority: 2
|
||||
- Regex: '^<.*\.h>'
|
||||
Priority: 1
|
||||
- Regex: '^<.*'
|
||||
Priority: 2
|
||||
- Regex: '.*'
|
||||
Priority: 3
|
||||
IncludeIsMainRegex: '([-_](test|unittest))?$'
|
||||
IndentCaseLabels: true
|
||||
IndentPPDirectives: BeforeHash
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 1
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 200
|
||||
PointerAlignment: Right
|
||||
RawStringFormats:
|
||||
- Language: Cpp
|
||||
Delimiters:
|
||||
- cc
|
||||
- CC
|
||||
- cpp
|
||||
- Cpp
|
||||
- CPP
|
||||
- 'c++'
|
||||
- 'C++'
|
||||
CanonicalDelimiter: ''
|
||||
BasedOnStyle: google
|
||||
- Language: TextProto
|
||||
Delimiters:
|
||||
- pb
|
||||
- PB
|
||||
- proto
|
||||
- PROTO
|
||||
EnclosingFunctions:
|
||||
- EqualsProto
|
||||
- EquivToProto
|
||||
- PARSE_PARTIAL_TEXT_PROTO
|
||||
- PARSE_TEST_PROTO
|
||||
- PARSE_TEXT_PROTO
|
||||
- ParseTextOrDie
|
||||
- ParseTextProtoOrDie
|
||||
CanonicalDelimiter: ''
|
||||
BasedOnStyle: google
|
||||
ReflowComments: false
|
||||
SortIncludes: true
|
||||
SortUsingDeclarations: false
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Cpp11
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 1
|
||||
UseTab: Never
|
||||
...
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
/*############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#include "src/mfx_config_interface/mfx_config_interface.h"
|
||||
|
||||
namespace MFX_CONFIG_INTERFACE {
|
||||
|
||||
// leave table formatting alone
|
||||
// clang-format off
|
||||
|
||||
// Dispatcher-level implementation of mfxConfigInterface.
|
||||
// Current implementation is stateless (string API only) so set Context to a special key.
|
||||
// We could replace Context with pointer to mfxSession (or some object within mfxSession)
|
||||
// if future extensions require access to the session state.
|
||||
// The application is not permitted to modify or dereference Context (see struct definition)
|
||||
// so we can set this to whatever we need.
|
||||
const mfxConfigInterface g_dispatcher_mfxConfigInterface = {
|
||||
MFX_CONFIG_INTERFACE_CONTEXT, // Context
|
||||
{ { 0, 1 } }, // Version
|
||||
|
||||
MFX_CONFIG_INTERFACE::ExtSetParameter, // SetParameter (callback function)
|
||||
|
||||
{}, // reserved
|
||||
};
|
||||
|
||||
// end table formatting
|
||||
// clang-format on
|
||||
|
||||
// callback function - set mfxConfigInterface::SetParameter to this
|
||||
// this has to be static since it's returned as function pointer, so cast session to _mfxSession
|
||||
// to access session-specific state (current implementation is stateless)
|
||||
mfxStatus ExtSetParameter(struct mfxConfigInterface *config_interface,
|
||||
const mfxU8 *key,
|
||||
const mfxU8 *value,
|
||||
mfxStructureType struct_type,
|
||||
mfxHDL structure,
|
||||
mfxExtBuffer *ext_buffer) {
|
||||
if (struct_type == MFX_STRUCTURE_TYPE_VIDEO_PARAM) {
|
||||
return SetParameter(key, value, (mfxVideoParam *)structure, ext_buffer);
|
||||
}
|
||||
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
// validate key and value input strings
|
||||
mfxStatus ValidateKVPair(const mfxU8 *key, const mfxU8 *value, KVPair &kvStr) {
|
||||
mfxU32 lengthKey, lengthValue;
|
||||
|
||||
// manually check length of key string
|
||||
for (lengthKey = 0; lengthKey < MAX_PARAM_STRING_LENGTH; lengthKey++) {
|
||||
if (!key[lengthKey])
|
||||
break;
|
||||
}
|
||||
if (lengthKey == 0 || lengthKey == MAX_PARAM_STRING_LENGTH)
|
||||
return MFX_ERR_INVALID_VIDEO_PARAM;
|
||||
|
||||
// manually check length of value string
|
||||
for (lengthValue = 0; lengthValue < MAX_PARAM_STRING_LENGTH; lengthValue++) {
|
||||
if (!value[lengthValue])
|
||||
break;
|
||||
}
|
||||
if (lengthValue == 0 || lengthValue == MAX_PARAM_STRING_LENGTH)
|
||||
return MFX_ERR_INVALID_VIDEO_PARAM;
|
||||
|
||||
kvStr.first = (const char *)key;
|
||||
kvStr.second = (const char *)value;
|
||||
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
|
||||
mfxStatus SetParameter(const mfxU8 *key, const mfxU8 *value, mfxVideoParam *videoParam, mfxExtBuffer *extBuf) {
|
||||
if (!key || !value || !videoParam || !extBuf)
|
||||
return MFX_ERR_NULL_PTR;
|
||||
|
||||
*extBuf = {}; // clear extBuf, will be filled in if new extBuf is required from caller
|
||||
|
||||
mfxStatus sts = MFX_ERR_NOT_FOUND; // default if no valid parameters
|
||||
|
||||
// validate C-style key and value strings
|
||||
// output is a pair of std::string's in kvStr
|
||||
KVPair kvStr;
|
||||
sts = ValidateKVPair(key, value, kvStr);
|
||||
if (sts != MFX_ERR_NONE)
|
||||
return sts;
|
||||
|
||||
if (IsExtBuf(kvStr)) {
|
||||
mfxExtBuffer extBufRequired = {};
|
||||
|
||||
// key maps to a parameter in an extension buffer
|
||||
sts = UpdateExtBufParam(kvStr, videoParam, &extBufRequired);
|
||||
|
||||
// if required extension buffer is not attached, we request the app to allocate it
|
||||
// and then call the SetParameter function again
|
||||
if (sts == MFX_ERR_MORE_EXTBUFFER) {
|
||||
extBuf->BufferId = extBufRequired.BufferId;
|
||||
extBuf->BufferSz = extBufRequired.BufferSz;
|
||||
}
|
||||
|
||||
return sts;
|
||||
}
|
||||
|
||||
// key maps to a parameter in mfxVideoParam
|
||||
sts = UpdateVideoParam(kvStr, videoParam);
|
||||
return sts;
|
||||
}
|
||||
|
||||
} // namespace MFX_CONFIG_INTERFACE
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/*############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#ifndef LIBVPL_SRC_MFX_CONFIG_INTERFACE_MFX_CONFIG_INTERFACE_H_
|
||||
#define LIBVPL_SRC_MFX_CONFIG_INTERFACE_MFX_CONFIG_INTERFACE_H_
|
||||
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "vpl/mfxvideo.h"
|
||||
|
||||
// special key to indicate Context is not a real context, as it is a stateless interface
|
||||
#define MFX_CONFIG_INTERFACE_CONTEXT ((mfxHDL)(-1))
|
||||
|
||||
namespace MFX_CONFIG_INTERFACE {
|
||||
|
||||
// dispatcher returns this interface from call to MFXVideoCORE_GetHandle(type = MFX_HANDLE_CONFIG_INTERFACE)
|
||||
extern const mfxConfigInterface g_dispatcher_mfxConfigInterface;
|
||||
|
||||
// string K-V pairs, each key may only have a single value
|
||||
typedef std::pair<std::string, std::string> KVPair;
|
||||
|
||||
mfxStatus MFX_CDECL ExtSetParameter(struct mfxConfigInterface *config_interface,
|
||||
const mfxU8 *key,
|
||||
const mfxU8 *value,
|
||||
mfxStructureType struct_type,
|
||||
mfxHDL structure,
|
||||
mfxExtBuffer *ext_buffer);
|
||||
|
||||
mfxStatus SetParameter(const mfxU8 *key, const mfxU8 *value, mfxVideoParam *videoParam, mfxExtBuffer *extBuf);
|
||||
|
||||
mfxStatus UpdateVideoParam(const KVPair &kvStr, mfxVideoParam *videoParam);
|
||||
mfxStatus UpdateExtBufParam(const KVPair &kvStr, mfxVideoParam *videoParam, mfxExtBuffer *extBufRequired);
|
||||
bool IsExtBuf(const KVPair &kvStr);
|
||||
|
||||
mfxStatus ValidateKVPair(const mfxU8 *key, const mfxU8 *value, KVPair &kvStr);
|
||||
mfxStatus SetExtBufParam(mfxExtBuffer *extBufActual, KVPair &kvStrParsed);
|
||||
mfxStatus GetExtBufType(const KVPair &kvStr, mfxExtBuffer *extBufHeader, KVPair &kvStrParsed);
|
||||
|
||||
}; // namespace MFX_CONFIG_INTERFACE
|
||||
|
||||
#endif // LIBVPL_SRC_MFX_CONFIG_INTERFACE_MFX_CONFIG_INTERFACE_H_
|
||||
Vendored
+1464
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,229 @@
|
||||
/*############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#include "src/mfx_dispatcher_vpl.h"
|
||||
|
||||
// exported functions for API >= 2.0
|
||||
|
||||
// create unique loader context
|
||||
mfxLoader MFXLoad() {
|
||||
LoaderCtxVPL *loaderCtx;
|
||||
|
||||
try {
|
||||
std::unique_ptr<LoaderCtxVPL> pLoaderCtx;
|
||||
pLoaderCtx.reset(new LoaderCtxVPL{});
|
||||
|
||||
// initialize logging if appropriate environment variables are set
|
||||
pLoaderCtx->InitDispatcherLog();
|
||||
|
||||
loaderCtx = (LoaderCtxVPL *)pLoaderCtx.release();
|
||||
}
|
||||
catch (...) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return (mfxLoader)loaderCtx;
|
||||
}
|
||||
|
||||
// unload libraries, destroy all created mfxConfig objects, free other memory
|
||||
void MFXUnload(mfxLoader loader) {
|
||||
try {
|
||||
if (!loader)
|
||||
return;
|
||||
|
||||
LoaderCtxVPL *loaderCtx = (LoaderCtxVPL *)loader;
|
||||
|
||||
loaderCtx->UnloadAllLibraries();
|
||||
|
||||
loaderCtx->FreeConfigFilters();
|
||||
|
||||
delete loaderCtx;
|
||||
}
|
||||
catch (...) {
|
||||
// nothing to return
|
||||
}
|
||||
}
|
||||
|
||||
// create config context
|
||||
// each loader may have more than one config context
|
||||
mfxConfig MFXCreateConfig(mfxLoader loader) {
|
||||
try {
|
||||
if (!loader)
|
||||
return nullptr;
|
||||
|
||||
LoaderCtxVPL *loaderCtx = (LoaderCtxVPL *)loader;
|
||||
ConfigCtxVPL *configCtx;
|
||||
|
||||
DispatcherLogVPL *dispLog = loaderCtx->GetLogger();
|
||||
DISP_LOG_FUNCTION(dispLog);
|
||||
|
||||
configCtx = loaderCtx->AddConfigFilter();
|
||||
|
||||
return (mfxConfig)(configCtx);
|
||||
}
|
||||
catch (...) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// set a config property to use in enumerating implementations
|
||||
mfxStatus MFXSetConfigFilterProperty(mfxConfig config, const mfxU8 *name, mfxVariant value) {
|
||||
try {
|
||||
if (!config)
|
||||
return MFX_ERR_NULL_PTR;
|
||||
|
||||
ConfigCtxVPL *configCtx = (ConfigCtxVPL *)config;
|
||||
LoaderCtxVPL *loaderCtx = configCtx->m_parentLoader;
|
||||
|
||||
if (!loaderCtx)
|
||||
return MFX_ERR_NULL_PTR; // should never happen - always set during MFXCreateConfig()
|
||||
|
||||
DispatcherLogVPL *dispLog = loaderCtx->GetLogger();
|
||||
DISP_LOG_FUNCTION(dispLog);
|
||||
|
||||
mfxStatus sts = configCtx->SetFilterProperty(name, value);
|
||||
if (sts)
|
||||
return sts;
|
||||
|
||||
loaderCtx->m_bNeedUpdateValidImpls = true;
|
||||
|
||||
sts = loaderCtx->UpdateLowLatency();
|
||||
if (sts)
|
||||
return sts;
|
||||
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
sts = loaderCtx->UpdatePropsQuery();
|
||||
#endif
|
||||
|
||||
return sts;
|
||||
}
|
||||
catch (...) {
|
||||
return MFX_ERR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
// iterate over available implementations
|
||||
// capabilities are returned in idesc
|
||||
mfxStatus MFXEnumImplementations(mfxLoader loader,
|
||||
mfxU32 i,
|
||||
mfxImplCapsDeliveryFormat format,
|
||||
mfxHDL *idesc) {
|
||||
try {
|
||||
if (!loader || !idesc)
|
||||
return MFX_ERR_NULL_PTR;
|
||||
|
||||
LoaderCtxVPL *loaderCtx = (LoaderCtxVPL *)loader;
|
||||
|
||||
DispatcherLogVPL *dispLog = loaderCtx->GetLogger();
|
||||
DISP_LOG_FUNCTION(dispLog);
|
||||
|
||||
mfxStatus sts = MFX_ERR_NONE;
|
||||
|
||||
// load and query all libraries
|
||||
if (loaderCtx->m_bNeedFullQuery) {
|
||||
// if a session was already created in low-latency mode, unload all implementations
|
||||
// before running full load and query
|
||||
if (loaderCtx->m_bLowLatency && !loaderCtx->m_bNeedLowLatencyQuery) {
|
||||
loaderCtx->UnloadAllLibraries();
|
||||
}
|
||||
|
||||
sts = loaderCtx->FullLoadAndQuery();
|
||||
if (sts)
|
||||
return MFX_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
// update list of valid libraries based on updated set of
|
||||
// mfxConfig properties
|
||||
if (loaderCtx->m_bNeedUpdateValidImpls) {
|
||||
sts = loaderCtx->UpdateValidImplList();
|
||||
if (sts)
|
||||
return MFX_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
sts = loaderCtx->QueryImpl(i, format, idesc);
|
||||
|
||||
return sts;
|
||||
}
|
||||
catch (...) {
|
||||
return MFX_ERR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
// create a new session with implementation i
|
||||
mfxStatus MFXCreateSession(mfxLoader loader, mfxU32 i, mfxSession *session) {
|
||||
try {
|
||||
if (!loader || !session)
|
||||
return MFX_ERR_NULL_PTR;
|
||||
|
||||
LoaderCtxVPL *loaderCtx = (LoaderCtxVPL *)loader;
|
||||
|
||||
DispatcherLogVPL *dispLog = loaderCtx->GetLogger();
|
||||
DISP_LOG_FUNCTION(dispLog);
|
||||
|
||||
mfxStatus sts = MFX_ERR_NONE;
|
||||
|
||||
if (loaderCtx->m_bLowLatency) {
|
||||
DISP_LOG_MESSAGE(dispLog, "message: low latency mode enabled");
|
||||
|
||||
if (loaderCtx->m_bNeedLowLatencyQuery) {
|
||||
// load low latency libraries
|
||||
sts = loaderCtx->LoadLibsLowLatency();
|
||||
if (sts != MFX_ERR_NONE)
|
||||
return MFX_ERR_NOT_FOUND;
|
||||
|
||||
// run limited query operations for low latency init
|
||||
sts = loaderCtx->QueryLibraryCaps();
|
||||
if (sts != MFX_ERR_NONE)
|
||||
return MFX_ERR_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
else {
|
||||
DISP_LOG_MESSAGE(dispLog, "message: low latency mode disabled");
|
||||
|
||||
// load and query all libraries
|
||||
if (loaderCtx->m_bNeedFullQuery) {
|
||||
sts = loaderCtx->FullLoadAndQuery();
|
||||
if (sts)
|
||||
return MFX_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
// update list of valid libraries based on updated set of
|
||||
// mfxConfig properties
|
||||
if (loaderCtx->m_bNeedUpdateValidImpls) {
|
||||
sts = loaderCtx->UpdateValidImplList();
|
||||
if (sts)
|
||||
return MFX_ERR_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
sts = loaderCtx->CreateSession(i, session);
|
||||
|
||||
return sts;
|
||||
}
|
||||
catch (...) {
|
||||
return MFX_ERR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
// release memory associated with implementation description hdl
|
||||
mfxStatus MFXDispReleaseImplDescription(mfxLoader loader, mfxHDL hdl) {
|
||||
try {
|
||||
if (!loader)
|
||||
return MFX_ERR_NULL_PTR;
|
||||
|
||||
LoaderCtxVPL *loaderCtx = (LoaderCtxVPL *)loader;
|
||||
|
||||
DispatcherLogVPL *dispLog = loaderCtx->GetLogger();
|
||||
DISP_LOG_FUNCTION(dispLog);
|
||||
|
||||
mfxStatus sts = loaderCtx->ReleaseImpl(hdl);
|
||||
|
||||
return sts;
|
||||
}
|
||||
catch (...) {
|
||||
return MFX_ERR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,669 @@
|
||||
/*############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#ifndef LIBVPL_SRC_MFX_DISPATCHER_VPL_H_
|
||||
#define LIBVPL_SRC_MFX_DISPATCHER_VPL_H_
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "vpl/mfxdispatcher.h"
|
||||
#include "vpl/mfxvideo.h"
|
||||
|
||||
#include "./mfx_dispatcher_vpl_log.h"
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#include <windows.h>
|
||||
|
||||
// use wide char on Windows
|
||||
#define MAKE_STRING(x) L##x
|
||||
typedef std::wstring STRING_TYPE;
|
||||
typedef wchar_t CHAR_TYPE;
|
||||
#else
|
||||
#include <dirent.h>
|
||||
#include <dlfcn.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// use standard char on Linux
|
||||
#define MAKE_STRING(x) x
|
||||
typedef std::string STRING_TYPE;
|
||||
typedef char CHAR_TYPE;
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#if defined _M_IX86
|
||||
// Windows x86
|
||||
#define MSDK_LIB_NAME L"libmfxhw32."
|
||||
#else
|
||||
// Windows x64
|
||||
#define MSDK_LIB_NAME L"libmfxhw64."
|
||||
#endif
|
||||
#define ONEVPL_PRIORITY_PATH_VAR L"ONEVPL_PRIORITY_PATH"
|
||||
#elif defined(__linux__)
|
||||
// Linux x64
|
||||
#define MSDK_LIB_NAME "libmfxhw64."
|
||||
#define ONEVPL_PRIORITY_PATH_VAR "ONEVPL_PRIORITY_PATH"
|
||||
#endif
|
||||
|
||||
#define MSDK_MIN_VERSION_MAJOR 1
|
||||
#define MSDK_MIN_VERSION_MINOR 0
|
||||
|
||||
#define MAX_MSDK_ACCEL_MODES 16 // see mfxcommon.h --> mfxAccelerationMode
|
||||
|
||||
#define MAX_WINDOWS_ADAPTER_ID 3 // check adapterID in range [0,3]
|
||||
|
||||
#define MAX_NUM_IMPL_MSDK 4
|
||||
|
||||
#define MAX_VPL_SEARCH_PATH 4096
|
||||
|
||||
#define MAX_ENV_VAR_LEN 32768
|
||||
|
||||
#define DEVICE_ID_UNKNOWN 0xffffffff
|
||||
#define ADAPTER_IDX_UNKNOWN 0xffffffff
|
||||
|
||||
#define TAB_SIZE(type, tab) (sizeof(tab) / sizeof(type))
|
||||
#define MAKE_MFX_VERSION(major, minor) \
|
||||
{ \
|
||||
{ (minor), (major) } \
|
||||
}
|
||||
|
||||
// internal function to load dll by full path, fail if unsuccessful
|
||||
mfxStatus MFXInitEx2(mfxVersion version,
|
||||
mfxInitializationParam vplParam,
|
||||
mfxIMPL hwImpl,
|
||||
mfxSession *session,
|
||||
mfxU16 *deviceID,
|
||||
CHAR_TYPE *dllName);
|
||||
|
||||
typedef void(MFX_CDECL *VPLFunctionPtr)(void);
|
||||
|
||||
extern const mfxIMPL msdkImplTab[MAX_NUM_IMPL_MSDK];
|
||||
|
||||
enum LibType {
|
||||
LibTypeUnknown = -1,
|
||||
|
||||
LibTypeVPL = 0,
|
||||
LibTypeMSDK,
|
||||
|
||||
NumLibTypes
|
||||
};
|
||||
|
||||
enum VPLFunctionIdx {
|
||||
// 2.0
|
||||
IdxMFXQueryImplsDescription = 0,
|
||||
IdxMFXReleaseImplDescription,
|
||||
IdxMFXMemory_GetSurfaceForVPP,
|
||||
IdxMFXMemory_GetSurfaceForEncode,
|
||||
IdxMFXMemory_GetSurfaceForDecode,
|
||||
IdxMFXInitialize,
|
||||
|
||||
// 2.1
|
||||
IdxMFXMemory_GetSurfaceForVPPOut,
|
||||
IdxMFXVideoDECODE_VPP_Init,
|
||||
IdxMFXVideoDECODE_VPP_DecodeFrameAsync,
|
||||
IdxMFXVideoDECODE_VPP_Reset,
|
||||
IdxMFXVideoDECODE_VPP_GetChannelParam,
|
||||
IdxMFXVideoDECODE_VPP_Close,
|
||||
IdxMFXVideoVPP_ProcessFrameAsync,
|
||||
|
||||
NumVPLFunctions
|
||||
};
|
||||
|
||||
enum VPLOptionalFunctionIdx {
|
||||
// 2.15
|
||||
IdxMFXQueryImplsProperties = 0,
|
||||
|
||||
NumVPLOptionalFunctions
|
||||
};
|
||||
|
||||
// select MSDK functions for 1.x style caps query
|
||||
enum MSDKCompatFunctionIdx {
|
||||
IdxMFXInitEx = 0,
|
||||
IdxMFXClose,
|
||||
|
||||
NumMSDKFunctions
|
||||
};
|
||||
|
||||
// both Windows and Linux use char* for function names
|
||||
struct VPLFunctionDesc {
|
||||
const char *pName;
|
||||
mfxVersion apiVersion;
|
||||
};
|
||||
|
||||
// DX adapter info
|
||||
struct DXGI1DeviceInfo {
|
||||
mfxU32 vendorID;
|
||||
mfxU32 deviceID;
|
||||
mfxU64 luid;
|
||||
};
|
||||
|
||||
// priority of runtime loading
|
||||
enum LibPriority {
|
||||
LIB_PRIORITY_SPECIAL = 0, // highest priority regardless of other priority rules
|
||||
|
||||
LIB_PRIORITY_01 = 1,
|
||||
LIB_PRIORITY_02 = 2,
|
||||
LIB_PRIORITY_03 = 3,
|
||||
LIB_PRIORITY_04 = 4,
|
||||
LIB_PRIORITY_05 = 5,
|
||||
|
||||
LIB_PRIORITY_9999 = 9999, // lowest priority for 2.x libs
|
||||
|
||||
LIB_PRIORITY_LEGACY_DRIVERSTORE = 10000,
|
||||
LIB_PRIORITY_LEGACY,
|
||||
};
|
||||
|
||||
enum CfgPropState {
|
||||
CFG_PROP_STATE_NOT_SET = 0,
|
||||
CFG_PROP_STATE_SUPPORTED,
|
||||
CFG_PROP_STATE_UNSUPPORTED,
|
||||
};
|
||||
|
||||
enum PropRanges {
|
||||
PROP_RANGE_DEC_W = 0,
|
||||
PROP_RANGE_DEC_H,
|
||||
PROP_RANGE_ENC_W,
|
||||
PROP_RANGE_ENC_H,
|
||||
PROP_RANGE_VPP_W,
|
||||
PROP_RANGE_VPP_H,
|
||||
|
||||
NUM_PROP_RANGES
|
||||
};
|
||||
|
||||
// must match eProp_TotalProps, is checked with static_assert in _config.cpp
|
||||
// (should throw error at compile time if !=)
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
#define NUM_TOTAL_FILTER_PROPS 62
|
||||
#else
|
||||
#define NUM_TOTAL_FILTER_PROPS 58
|
||||
#endif
|
||||
|
||||
// typedef child structures for easier reading
|
||||
typedef struct mfxDecoderDescription::decoder DecCodec;
|
||||
typedef struct mfxDecoderDescription::decoder::decprofile DecProfile;
|
||||
typedef struct mfxDecoderDescription::decoder::decprofile::decmemdesc DecMemDesc;
|
||||
|
||||
typedef struct mfxEncoderDescription::encoder EncCodec;
|
||||
typedef struct mfxEncoderDescription::encoder::encprofile EncProfile;
|
||||
typedef struct mfxEncoderDescription::encoder::encprofile::encmemdesc EncMemDesc;
|
||||
|
||||
typedef struct mfxVPPDescription::filter VPPFilter;
|
||||
typedef struct mfxVPPDescription::filter::memdesc VPPMemDesc;
|
||||
typedef struct mfxVPPDescription::filter::memdesc::format VPPFormat;
|
||||
|
||||
// flattened version of single enc/dec/vpp configs
|
||||
// each struct contains all _settable_ props
|
||||
// i.e. not implied values like NumCodecs
|
||||
struct DecConfig {
|
||||
mfxU32 CodecID;
|
||||
mfxU16 MaxcodecLevel;
|
||||
mfxU32 Profile;
|
||||
mfxResourceType MemHandleType;
|
||||
mfxRange32U Width;
|
||||
mfxRange32U Height;
|
||||
mfxU32 ColorFormat;
|
||||
};
|
||||
|
||||
struct EncConfig {
|
||||
mfxU32 CodecID;
|
||||
mfxU16 MaxcodecLevel;
|
||||
mfxU16 BiDirectionalPrediction;
|
||||
mfxU32 Profile;
|
||||
mfxResourceType MemHandleType;
|
||||
mfxRange32U Width;
|
||||
mfxRange32U Height;
|
||||
mfxU32 ColorFormat;
|
||||
};
|
||||
|
||||
struct VPPConfig {
|
||||
mfxU32 FilterFourCC;
|
||||
mfxU16 MaxDelayInFrames;
|
||||
mfxResourceType MemHandleType;
|
||||
mfxRange32U Width;
|
||||
mfxRange32U Height;
|
||||
mfxU32 InFormat;
|
||||
mfxU32 OutFormat;
|
||||
};
|
||||
|
||||
struct SurfaceConfig {
|
||||
mfxU32 SurfaceType;
|
||||
mfxU32 SurfaceComponent;
|
||||
mfxU32 SurfaceFlags;
|
||||
};
|
||||
|
||||
// special props which are passed in via MFXSetConfigProperty()
|
||||
// these are updated with every call to ValidateConfig() and may
|
||||
// be used in MFXCreateSession()
|
||||
struct SpecialConfig {
|
||||
bool bIsSet_deviceHandleType;
|
||||
mfxHandleType deviceHandleType;
|
||||
|
||||
bool bIsSet_deviceHandle;
|
||||
mfxHDL deviceHandle;
|
||||
|
||||
bool bIsSet_accelerationMode;
|
||||
mfxAccelerationMode accelerationMode;
|
||||
|
||||
bool bIsSet_ApiVersion;
|
||||
mfxVersion ApiVersion;
|
||||
|
||||
bool bIsSet_dxgiAdapterIdx;
|
||||
mfxU32 dxgiAdapterIdx;
|
||||
|
||||
bool bIsSet_NumThread;
|
||||
mfxU32 NumThread;
|
||||
|
||||
bool bIsSet_DeviceCopy;
|
||||
mfxU16 DeviceCopy;
|
||||
|
||||
bool bIsSet_ExtBuffer;
|
||||
std::vector<mfxExtBuffer *> ExtBuffers;
|
||||
};
|
||||
|
||||
struct mfxVariantWrapper : mfxVariant {
|
||||
public:
|
||||
bool bPropsQuery = false;
|
||||
};
|
||||
|
||||
// config class implementation
|
||||
class ConfigCtxVPL {
|
||||
public:
|
||||
ConfigCtxVPL();
|
||||
~ConfigCtxVPL();
|
||||
|
||||
// set a single filter property (KV pair)
|
||||
mfxStatus SetFilterProperty(const mfxU8 *name, mfxVariant value);
|
||||
|
||||
static bool CheckLowLatencyConfig(std::list<ConfigCtxVPL *> configCtxList,
|
||||
SpecialConfig *specialConfig);
|
||||
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
static bool UpdatePropsQueryConfig(std::list<ConfigCtxVPL *> configCtxList,
|
||||
std::vector<mfxQueryProperty> &queryProps);
|
||||
#endif
|
||||
|
||||
// compare library caps vs. set of configuration filters
|
||||
static mfxStatus ValidateConfig(const mfxImplDescription *libImplDesc,
|
||||
const mfxImplementedFunctions *libImplFuncs,
|
||||
const mfxExtendedDeviceId *libImplExtDevID,
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
const mfxSurfaceTypesSupported *libImplSurfTypes,
|
||||
#endif
|
||||
std::list<ConfigCtxVPL *> configCtxList,
|
||||
LibType libType,
|
||||
SpecialConfig *specialConfig);
|
||||
|
||||
// parse deviceID for x86 devices
|
||||
static bool ParseDeviceIDx86(mfxChar *cDeviceID, mfxU32 &deviceID, mfxU32 &adapterIdx);
|
||||
|
||||
// loader object this config is associated with - needed to
|
||||
// rebuild valid implementation list after each calling
|
||||
// MFXSetConfigFilterProperty()
|
||||
class LoaderCtxVPL *m_parentLoader;
|
||||
|
||||
private:
|
||||
static __inline std::string GetNextProp(std::list<std::string> &s) {
|
||||
if (s.empty())
|
||||
return "";
|
||||
std::string t = s.front();
|
||||
s.pop_front();
|
||||
return t;
|
||||
}
|
||||
|
||||
mfxStatus ValidateAndSetProp(mfxI32 idx, mfxVariant value);
|
||||
mfxStatus SetFilterPropertyDec(std::list<std::string> &propParsedString, mfxVariant value);
|
||||
mfxStatus SetFilterPropertyEnc(std::list<std::string> &propParsedString, mfxVariant value);
|
||||
mfxStatus SetFilterPropertyVPP(std::list<std::string> &propParsedString, mfxVariant value);
|
||||
mfxStatus SetFilterPropertySurface(std::list<std::string> &propParsedString, mfxVariant value);
|
||||
|
||||
static mfxStatus GetFlatDescriptionsDec(const mfxImplDescription *libImplDesc,
|
||||
std::list<DecConfig> &decConfigList);
|
||||
|
||||
static mfxStatus GetFlatDescriptionsEnc(const mfxImplDescription *libImplDesc,
|
||||
std::list<EncConfig> &encConfigList);
|
||||
|
||||
static mfxStatus GetFlatDescriptionsVPP(const mfxImplDescription *libImplDesc,
|
||||
std::list<VPPConfig> &vppConfigList);
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
static mfxStatus GetFlatDescriptionsSurface(const mfxSurfaceTypesSupported *libSurfaceTypes,
|
||||
std::list<SurfaceConfig> &surfaceConfigList);
|
||||
#endif
|
||||
|
||||
static mfxStatus CheckPropsGeneral(const mfxVariant cfgPropsAll[],
|
||||
const mfxImplDescription *libImplDesc);
|
||||
|
||||
static mfxStatus CheckPropsDec(const mfxVariant cfgPropsAll[],
|
||||
std::list<DecConfig> decConfigList);
|
||||
|
||||
static mfxStatus CheckPropsEnc(const mfxVariant cfgPropsAll[],
|
||||
std::list<EncConfig> encConfigList);
|
||||
|
||||
static mfxStatus CheckPropsVPP(const mfxVariant cfgPropsAll[],
|
||||
std::list<VPPConfig> vppConfigList);
|
||||
|
||||
static mfxStatus CheckPropString(const mfxChar *implString, const std::string filtString);
|
||||
|
||||
static mfxStatus CheckPropsExtDevID(const mfxVariant cfgPropsAll[],
|
||||
const mfxExtendedDeviceId *libImplExtDevID);
|
||||
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
static mfxStatus CheckPropsSurface(const mfxVariant cfgPropsAll[],
|
||||
std::list<SurfaceConfig> surfaceConfigList);
|
||||
#endif
|
||||
|
||||
mfxVariantWrapper m_propVar[NUM_TOTAL_FILTER_PROPS];
|
||||
|
||||
// special containers for properties which are passed by pointer
|
||||
// (save a copy of the whole object based on property name)
|
||||
mfxRange32U m_propRange32U[NUM_PROP_RANGES];
|
||||
std::string m_implName;
|
||||
std::string m_implLicense;
|
||||
std::string m_implKeywords;
|
||||
std::string m_deviceIdStr;
|
||||
std::string m_implFunctionName;
|
||||
|
||||
mfxU8 m_extDevLUID8U[8];
|
||||
std::string m_extDevNameStr;
|
||||
|
||||
std::vector<mfxU8> m_extBuf;
|
||||
|
||||
__inline bool SetExtBuf(mfxExtBuffer *extBuf) {
|
||||
if (!extBuf)
|
||||
return false;
|
||||
|
||||
mfxU32 BufferSz = extBuf->BufferSz;
|
||||
if (BufferSz > 0) {
|
||||
m_extBuf.resize(BufferSz);
|
||||
std::copy((mfxU8 *)extBuf, (mfxU8 *)extBuf + BufferSz, m_extBuf.begin());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
__inline bool GetExtBuf(mfxExtBuffer **extBuf) {
|
||||
if (!extBuf)
|
||||
return false;
|
||||
|
||||
*extBuf = nullptr;
|
||||
if (!m_extBuf.empty()) {
|
||||
*extBuf = (mfxExtBuffer *)m_extBuf.data();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
__inline void ClearExtBuf() {
|
||||
m_extBuf.clear();
|
||||
}
|
||||
};
|
||||
|
||||
// MSDK compatibility loader implementation
|
||||
class LoaderCtxMSDK {
|
||||
public:
|
||||
LoaderCtxMSDK();
|
||||
~LoaderCtxMSDK();
|
||||
|
||||
// public function to be called the dispatcher
|
||||
// do not allocate any new memory here, so no need for a matching Release functions
|
||||
mfxStatus QueryMSDKCaps(STRING_TYPE libNameFull,
|
||||
mfxImplDescription **implDesc,
|
||||
mfxImplementedFunctions **implFuncs,
|
||||
mfxU32 adapterID,
|
||||
bool bSkipD3D9Check);
|
||||
|
||||
static mfxStatus QueryAPIVersion(STRING_TYPE libNameFull, mfxVersion *msdkVersion);
|
||||
|
||||
static mfxStatus QueryExtDeviceID(mfxExtendedDeviceId *extDeviceID,
|
||||
mfxU32 adapterID,
|
||||
mfxU16 deviceID,
|
||||
mfxU64 luid);
|
||||
|
||||
// required by MFXCreateSession
|
||||
mfxIMPL m_msdkAdapter;
|
||||
mfxIMPL m_msdkAdapterD3D9;
|
||||
|
||||
mfxU16 m_deviceID;
|
||||
mfxU64 m_luid;
|
||||
mfxExtendedDeviceId m_extDeviceID;
|
||||
|
||||
private:
|
||||
// session management
|
||||
mfxStatus OpenSession(mfxSession *session,
|
||||
STRING_TYPE libNameFull,
|
||||
mfxAccelerationMode accelMode,
|
||||
mfxIMPL hwImpl);
|
||||
void CloseSession(mfxSession *session);
|
||||
|
||||
// utility functions
|
||||
static mfxAccelerationMode CvtAccelType(mfxIMPL implType, mfxIMPL implMethod);
|
||||
static mfxStatus GetDefaultAccelType(mfxU32 adapterID, mfxIMPL *implDefault, mfxU64 *luid);
|
||||
static mfxStatus CheckD3D9Support(mfxU64 luid, STRING_TYPE libNameFull, mfxIMPL *implD3D9);
|
||||
static mfxStatus GetRenderNodeDescription(mfxU32 adapterID, mfxU32 &vendorID, mfxU16 &deviceID);
|
||||
|
||||
// internal state variables
|
||||
STRING_TYPE m_libNameFull;
|
||||
mfxImplDescription m_id; // base description struct
|
||||
mfxAccelerationMode m_accelMode[MAX_MSDK_ACCEL_MODES];
|
||||
mfxU16 m_loaderDeviceID;
|
||||
|
||||
__inline bool IsVersionSupported(mfxVersion reqVersion, mfxVersion actualVersion) {
|
||||
if (actualVersion.Major > reqVersion.Major) {
|
||||
return true;
|
||||
}
|
||||
else if ((actualVersion.Major == reqVersion.Major) &&
|
||||
(actualVersion.Minor >= reqVersion.Minor)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
struct LibInfo {
|
||||
// during search store candidate file names
|
||||
// and priority based on rules in spec
|
||||
STRING_TYPE libNameFull;
|
||||
mfxU32 libPriority;
|
||||
LibType libType;
|
||||
|
||||
// if valid library, store file handle
|
||||
// and table of exported functions
|
||||
void *hModuleVPL;
|
||||
VPLFunctionPtr vplFuncTable[NumVPLFunctions]; // NOLINT
|
||||
|
||||
// optional functions which RT may or may not export
|
||||
VPLFunctionPtr vplOptionalFuncTable[NumVPLOptionalFunctions]; // NOLINT
|
||||
|
||||
// loader context for legacy MSDK
|
||||
LoaderCtxMSDK msdkCtx[MAX_NUM_IMPL_MSDK];
|
||||
|
||||
// API version of legacy MSDK
|
||||
mfxVersion msdkVersion;
|
||||
|
||||
// user-friendly version of path for MFX_IMPLCAPS_IMPLPATH query
|
||||
mfxChar implCapsPath[MAX_VPL_SEARCH_PATH];
|
||||
|
||||
// avoid warnings
|
||||
LibInfo()
|
||||
: libNameFull(),
|
||||
libPriority(0),
|
||||
libType(LibTypeUnknown),
|
||||
hModuleVPL(nullptr),
|
||||
vplFuncTable(),
|
||||
vplOptionalFuncTable(),
|
||||
msdkCtx(),
|
||||
msdkVersion(),
|
||||
implCapsPath() {}
|
||||
|
||||
virtual ~LibInfo() {}
|
||||
|
||||
private:
|
||||
// make this class non-copyable
|
||||
LibInfo(const LibInfo &);
|
||||
LibInfo &operator=(const LibInfo &);
|
||||
};
|
||||
|
||||
struct ImplInfo {
|
||||
// library containing this implementation
|
||||
LibInfo *libInfo;
|
||||
|
||||
// description of implementation
|
||||
mfxHDL implDesc;
|
||||
|
||||
// list of implemented functions
|
||||
mfxHDL implFuncs;
|
||||
|
||||
mfxHDL implExtDeviceID;
|
||||
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
mfxHDL implSurfTypes;
|
||||
#endif
|
||||
|
||||
// used for session initialization with this implementation
|
||||
mfxInitializationParam vplParam;
|
||||
mfxVersion version;
|
||||
|
||||
// if MSDK library, index of corresponding adapter (i.e. which LoaderCtxMSDK)
|
||||
mfxU32 msdkImplIdx;
|
||||
|
||||
// adapter index in multi-adapter systems
|
||||
mfxU32 adapterIdx;
|
||||
|
||||
// local index for libraries with more than one implementation
|
||||
mfxU32 libImplIdx;
|
||||
|
||||
// index of valid libraries - updates with every call to MFXSetConfigFilterProperty()
|
||||
mfxI32 validImplIdx;
|
||||
|
||||
// avoid warnings
|
||||
ImplInfo()
|
||||
: libInfo(nullptr),
|
||||
implDesc(nullptr),
|
||||
implFuncs(nullptr),
|
||||
implExtDeviceID(nullptr),
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
implSurfTypes(nullptr),
|
||||
#endif
|
||||
vplParam(),
|
||||
version(),
|
||||
msdkImplIdx(0),
|
||||
adapterIdx(ADAPTER_IDX_UNKNOWN),
|
||||
libImplIdx(0),
|
||||
validImplIdx(-1) {
|
||||
}
|
||||
};
|
||||
|
||||
// loader class implementation
|
||||
class LoaderCtxVPL {
|
||||
public:
|
||||
LoaderCtxVPL();
|
||||
~LoaderCtxVPL();
|
||||
|
||||
// manage library implementations
|
||||
mfxStatus BuildListOfCandidateLibs();
|
||||
mfxU32 CheckValidLibraries();
|
||||
mfxStatus QueryLibraryCaps();
|
||||
mfxStatus UnloadAllLibraries();
|
||||
|
||||
// query capabilities of each implementation
|
||||
mfxStatus FullLoadAndQuery();
|
||||
mfxStatus QueryImpl(mfxU32 idx, mfxImplCapsDeliveryFormat format, mfxHDL *idesc);
|
||||
mfxStatus ReleaseImpl(mfxHDL idesc);
|
||||
|
||||
// update list of valid implementations based on current filter props
|
||||
mfxStatus UpdateValidImplList(void);
|
||||
mfxStatus PrioritizeImplList(void);
|
||||
|
||||
// create mfxSession
|
||||
mfxStatus CreateSession(mfxU32 idx, mfxSession *session);
|
||||
|
||||
// manage configuration filters
|
||||
ConfigCtxVPL *AddConfigFilter();
|
||||
mfxStatus FreeConfigFilters();
|
||||
|
||||
// manage logging
|
||||
mfxStatus InitDispatcherLog();
|
||||
DispatcherLogVPL *GetLogger();
|
||||
|
||||
// low latency initialization
|
||||
mfxStatus LoadLibsLowLatency();
|
||||
mfxStatus UpdateLowLatency();
|
||||
|
||||
bool m_bLowLatency;
|
||||
bool m_bNeedUpdateValidImpls;
|
||||
bool m_bNeedFullQuery;
|
||||
bool m_bNeedLowLatencyQuery;
|
||||
bool m_bPriorityPathEnabled;
|
||||
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
bool m_bEnablePropsQuery;
|
||||
mfxStatus UpdatePropsQuery();
|
||||
#endif
|
||||
|
||||
private:
|
||||
// helper functions
|
||||
mfxStatus LoadSingleLibrary(LibInfo *libInfo);
|
||||
mfxStatus UnloadSingleLibrary(LibInfo *libInfo);
|
||||
mfxStatus UnloadSingleImplementation(ImplInfo *implInfo);
|
||||
VPLFunctionPtr GetFunctionAddr(void *hModuleVPL, const char *pName);
|
||||
|
||||
mfxU32 GetSearchPathsDriverStore(std::list<STRING_TYPE> &searchDirs, LibType libType);
|
||||
mfxU32 GetSearchPathsSystemDefault(std::list<STRING_TYPE> &searchDirs);
|
||||
mfxU32 GetSearchPathsCurrentExe(std::list<STRING_TYPE> &searchDirs);
|
||||
mfxU32 GetSearchPathsCurrentDir(std::list<STRING_TYPE> &searchDirs);
|
||||
mfxU32 GetSearchPathsLegacy(std::list<STRING_TYPE> &searchDirs);
|
||||
|
||||
#if defined INSTALL_LIBDIR_SEARCH
|
||||
mfxU32 GetSearchPathsInstallDir(std::list<STRING_TYPE> &searchDirs);
|
||||
#endif
|
||||
|
||||
mfxU32 ParseEnvSearchPaths(const CHAR_TYPE *envVarName, std::list<STRING_TYPE> &searchDirs);
|
||||
mfxU32 ParseLegacySearchPaths(std::list<STRING_TYPE> &searchDirs);
|
||||
|
||||
mfxStatus SearchDirForLibs(STRING_TYPE searchDir,
|
||||
std::list<LibInfo *> &libInfoList,
|
||||
mfxU32 priority,
|
||||
bool bLoadVPLOnly = false);
|
||||
|
||||
mfxU32 LoadAPIExports(LibInfo *libInfo, LibType libType);
|
||||
mfxStatus ValidateAPIExports(VPLFunctionPtr *vplFuncTable, mfxVersion reportedVersion);
|
||||
bool IsValidX86GPU(ImplInfo *implInfo, mfxU32 &deviceID, mfxU32 &adapterIdx);
|
||||
mfxStatus UpdateImplPath(LibInfo *libInfo);
|
||||
|
||||
mfxStatus LoadLibsFromDriverStore(mfxU32 numAdapters,
|
||||
const std::vector<DXGI1DeviceInfo> &adapterInfo,
|
||||
LibType libType);
|
||||
mfxStatus LoadLibsFromSystemDir(LibType libType);
|
||||
mfxStatus LoadLibsFromMultipleDirs(LibType libType);
|
||||
|
||||
LibInfo *AddSingleLibrary(STRING_TYPE libPath, LibType libType);
|
||||
mfxStatus QuerySessionLowLatency(LibInfo *libInfo, mfxU32 adapterID, mfxVersion *ver);
|
||||
|
||||
std::list<LibInfo *> m_libInfoList;
|
||||
std::list<ImplInfo *> m_implInfoList;
|
||||
std::list<ConfigCtxVPL *> m_configCtxList;
|
||||
std::vector<DXGI1DeviceInfo> m_gpuAdapterInfo;
|
||||
|
||||
#ifdef ONEVPL_EXPERIMENTAL
|
||||
std::vector<mfxQueryProperty> m_queryProps;
|
||||
#endif
|
||||
|
||||
SpecialConfig m_specialConfig;
|
||||
|
||||
mfxU32 m_implIdxNext;
|
||||
bool m_bKeepCapsUntilUnload;
|
||||
CHAR_TYPE m_envVar[MAX_ENV_VAR_LEN];
|
||||
|
||||
// logger object - enabled with ONEVPL_DISPATCHER_LOG environment variable
|
||||
DispatcherLogVPL m_dispLog;
|
||||
};
|
||||
|
||||
#endif // LIBVPL_SRC_MFX_DISPATCHER_VPL_H_
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,63 @@
|
||||
/*############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#include "src/mfx_dispatcher_vpl_log.h"
|
||||
|
||||
DispatcherLogVPL::DispatcherLogVPL() : m_logLevel(0), m_logFileName(), m_logFile(nullptr) {}
|
||||
|
||||
DispatcherLogVPL::~DispatcherLogVPL() {
|
||||
if (!m_logFileName.empty() && m_logFile)
|
||||
fclose(m_logFile);
|
||||
m_logFile = nullptr;
|
||||
}
|
||||
|
||||
mfxStatus DispatcherLogVPL::Init(mfxU32 logLevel, const std::string &logFileName) {
|
||||
// avoid leaking file handle if Init is accidentally called more than once
|
||||
if (m_logFile)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
|
||||
m_logLevel = logLevel;
|
||||
m_logFileName = logFileName;
|
||||
|
||||
// append to file if it already exists, otherwise create a new one
|
||||
// m_logFile will be closed in dtor
|
||||
if (m_logLevel) {
|
||||
if (m_logFileName.empty()) {
|
||||
m_logFile = stdout;
|
||||
}
|
||||
else {
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
fopen_s(&m_logFile, m_logFileName.c_str(), "a");
|
||||
#else
|
||||
m_logFile = fopen(m_logFileName.c_str(), "a");
|
||||
#endif
|
||||
if (!m_logFile) {
|
||||
m_logFile = stdout;
|
||||
fprintf(m_logFile,
|
||||
"Warning - unable to create logfile %s\n",
|
||||
m_logFileName.c_str());
|
||||
fprintf(m_logFile, "Log output will be sent to stdout\n");
|
||||
m_logFileName.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
|
||||
mfxStatus DispatcherLogVPL::LogMessage(const char *msg, ...) {
|
||||
if (!m_logLevel || !m_logFile)
|
||||
return MFX_ERR_NONE;
|
||||
|
||||
va_list args;
|
||||
va_start(args, msg);
|
||||
vfprintf(m_logFile, msg, args);
|
||||
va_end(args);
|
||||
|
||||
fprintf(m_logFile, "\n");
|
||||
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#ifndef LIBVPL_SRC_MFX_DISPATCHER_VPL_LOG_H_
|
||||
#define LIBVPL_SRC_MFX_DISPATCHER_VPL_LOG_H_
|
||||
|
||||
/* Intel® Video Processing Library (Intel® VPL) Dispatcher Debug Log
|
||||
* The debug output of the dispatcher is controlled with the ONEVPL_DISPATCHER_LOG environment variable.
|
||||
* To enable log output, set the ONEVPL_DISPATCHER_LOG environment variable value equals to "ON".
|
||||
*
|
||||
* By default, Intel® VPL dispatcher prints all log messages to the console.
|
||||
* To redirect log output to the desired file, set the ONEVPL_DISPATCHER_LOG_FILE environmental
|
||||
* variable with the file name of the log file.
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "vpl/mfxdispatcher.h"
|
||||
#include "vpl/mfxvideo.h"
|
||||
|
||||
#ifndef __FUNC_NAME__
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#define __FUNC_NAME__ __FUNCTION__
|
||||
#else
|
||||
#define __FUNC_NAME__ __PRETTY_FUNCTION__
|
||||
#endif
|
||||
#endif
|
||||
|
||||
class DispatcherLogVPL {
|
||||
public:
|
||||
DispatcherLogVPL();
|
||||
~DispatcherLogVPL();
|
||||
|
||||
mfxStatus Init(mfxU32 logLevel, const std::string &logFileName);
|
||||
mfxStatus LogMessage(const char *msdk, ...);
|
||||
|
||||
mfxU32 m_logLevel;
|
||||
|
||||
private:
|
||||
std::string m_logFileName;
|
||||
FILE *m_logFile;
|
||||
DispatcherLogVPL(const DispatcherLogVPL &other);
|
||||
DispatcherLogVPL &operator=(const DispatcherLogVPL &other);
|
||||
};
|
||||
|
||||
class DispatcherLogVPLFunction {
|
||||
public:
|
||||
DispatcherLogVPLFunction(DispatcherLogVPL *dispLog, const char *fnName)
|
||||
: m_dispLog(),
|
||||
m_fnName() {
|
||||
m_dispLog = dispLog;
|
||||
|
||||
if (m_dispLog && m_dispLog->m_logLevel) {
|
||||
m_fnName = fnName;
|
||||
m_dispLog->LogMessage("function: %s (enter)", m_fnName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
~DispatcherLogVPLFunction() {
|
||||
if (m_dispLog && m_dispLog->m_logLevel)
|
||||
m_dispLog->LogMessage("function: %s (return)", m_fnName.c_str());
|
||||
}
|
||||
|
||||
private:
|
||||
DispatcherLogVPL *m_dispLog;
|
||||
std::string m_fnName;
|
||||
DispatcherLogVPLFunction(const DispatcherLogVPLFunction &other);
|
||||
DispatcherLogVPLFunction &operator=(const DispatcherLogVPLFunction &other);
|
||||
};
|
||||
|
||||
#define DISP_LOG_FUNCTION(dispLog) DispatcherLogVPLFunction _dispLogFn(dispLog, __FUNC_NAME__);
|
||||
#define DISP_LOG_MESSAGE(dispLog, ...) \
|
||||
{ \
|
||||
if (dispLog) { \
|
||||
(dispLog)->LogMessage(__VA_ARGS__); \
|
||||
} \
|
||||
}
|
||||
|
||||
#endif // LIBVPL_SRC_MFX_DISPATCHER_VPL_LOG_H_
|
||||
+432
@@ -0,0 +1,432 @@
|
||||
/*############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#include "src/mfx_dispatcher_vpl.h"
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#include "src/mfx_dispatcher_vpl_win.h"
|
||||
|
||||
#if defined _M_IX86
|
||||
// Windows x86
|
||||
#define LIB_ONEVPL L"libmfx32-gen.dll"
|
||||
#define LIB_MSDK L"libmfxhw32.dll"
|
||||
#else
|
||||
// Windows x64
|
||||
#define LIB_ONEVPL L"libmfx64-gen.dll"
|
||||
#define LIB_MSDK L"libmfxhw64.dll"
|
||||
#endif
|
||||
#elif defined(__linux__)
|
||||
// Linux x64
|
||||
#define LIB_ONEVPL "libmfx-gen.so.1.2"
|
||||
#define LIB_MSDK "libmfxhw64.so.1"
|
||||
#endif
|
||||
|
||||
//Intel® Video Processing Library (Intel® VPL) low latency dispatcher
|
||||
|
||||
// For Windows:
|
||||
// Intel® VPL - load from Driver Store, look only for libmfx64-gen.dll (32)
|
||||
// MSDK - load from Driver Store, look only for libmfxhw64.dll (32)
|
||||
// MSDK - fallback, load from %windir%\system32 or %windir%\syswow64
|
||||
|
||||
// For Linux:
|
||||
// Intel® VPL - load from system paths in LoadLibsFromMultipleDirs(), look only for libmfx-gen.so.1.2
|
||||
// MSDK - load from system paths in LoadLibsFromMultipleDirs(), look only for libmfxhw64.so.1
|
||||
|
||||
// library names
|
||||
static const CHAR_TYPE *libNameVPL = LIB_ONEVPL;
|
||||
static const CHAR_TYPE *libNameMSDK = LIB_MSDK;
|
||||
|
||||
// required exports
|
||||
static const char *reqFuncVPL = "MFXInitialize";
|
||||
static const char *reqFuncMSDK = "MFXInitEx";
|
||||
|
||||
LibInfo *LoaderCtxVPL::AddSingleLibrary(STRING_TYPE libPath, LibType libType) {
|
||||
LibInfo *libInfo = nullptr;
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
// try to open library
|
||||
mfxModuleHandle hLib = MFX::mfx_dll_load(libPath.c_str());
|
||||
if (!hLib)
|
||||
return nullptr;
|
||||
|
||||
// check for required entrypoint function
|
||||
const char *reqFunc = (libType == LibTypeVPL ? reqFuncVPL : reqFuncMSDK);
|
||||
VPLFunctionPtr pProc = (VPLFunctionPtr)MFX::mfx_dll_get_addr(hLib, reqFunc);
|
||||
MFX::mfx_dll_free(hLib);
|
||||
|
||||
// entrypoint function missing - invalid library
|
||||
if (!pProc)
|
||||
return nullptr;
|
||||
#else
|
||||
// try to open library
|
||||
void *hLib = dlopen(libPath.c_str(), RTLD_LOCAL | RTLD_NOW);
|
||||
if (!hLib)
|
||||
return nullptr;
|
||||
|
||||
// check for required entrypoint function
|
||||
const char *reqFunc = (libType == LibTypeVPL ? reqFuncVPL : reqFuncMSDK);
|
||||
VPLFunctionPtr pProc = (VPLFunctionPtr)dlsym(hLib, reqFunc);
|
||||
dlclose(hLib);
|
||||
|
||||
// entrypoint function missing - invalid library
|
||||
if (!pProc)
|
||||
return nullptr;
|
||||
#endif
|
||||
|
||||
// create new LibInfo and add to list
|
||||
libInfo = new (std::nothrow) LibInfo;
|
||||
if (!libInfo)
|
||||
return nullptr;
|
||||
|
||||
libInfo->libNameFull = libPath;
|
||||
libInfo->libType = libType;
|
||||
libInfo->libPriority = (libType == LibTypeVPL ? LIB_PRIORITY_01 : LIB_PRIORITY_LEGACY);
|
||||
|
||||
return libInfo;
|
||||
}
|
||||
|
||||
mfxStatus LoaderCtxVPL::LoadLibsFromDriverStore(mfxU32 numAdapters,
|
||||
const std::vector<DXGI1DeviceInfo> &adapterInfo,
|
||||
LibType libType) {
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
mfxStatus sts = MFX_ERR_NONE;
|
||||
|
||||
mfxI32 storageID = MFX::MFX_UNKNOWN_KEY;
|
||||
const CHAR_TYPE *libName = nullptr;
|
||||
|
||||
if (libType == LibTypeVPL) {
|
||||
storageID = MFX::MFX_DRIVER_STORE_ONEVPL;
|
||||
libName = libNameVPL;
|
||||
}
|
||||
else if (libType == LibTypeMSDK) {
|
||||
storageID = MFX::MFX_DRIVER_STORE;
|
||||
libName = libNameMSDK;
|
||||
}
|
||||
else {
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
// get path to Windows driver store
|
||||
STRING_TYPE libPath;
|
||||
mfxU32 adapterID;
|
||||
for (adapterID = 0; adapterID < numAdapters; adapterID++) {
|
||||
// get driver store path for this adapter
|
||||
libPath.clear();
|
||||
sts = MFX::MFXLibraryIterator::GetDriverStoreDir(libPath,
|
||||
MAX_VPL_SEARCH_PATH,
|
||||
adapterInfo[adapterID].deviceID,
|
||||
storageID);
|
||||
if (sts != MFX_ERR_NONE || libPath.size() == 0)
|
||||
continue;
|
||||
|
||||
// try to open library
|
||||
libPath += libName;
|
||||
LibInfo *libInfo = AddSingleLibrary(libPath, libType);
|
||||
|
||||
// if successful, add to list and return (stop at first
|
||||
if (libInfo) {
|
||||
m_libInfoList.push_back(libInfo);
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
#else
|
||||
// Linux - not supported
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
mfxStatus LoaderCtxVPL::LoadLibsFromSystemDir(LibType libType) {
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
const CHAR_TYPE *libName = nullptr;
|
||||
|
||||
if (libType == LibTypeVPL) {
|
||||
libName = libNameVPL;
|
||||
}
|
||||
else if (libType == LibTypeMSDK) {
|
||||
libName = libNameMSDK;
|
||||
}
|
||||
else {
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
// get path to Windows system dir
|
||||
STRING_TYPE libPath;
|
||||
libPath.clear();
|
||||
|
||||
std::list<STRING_TYPE> winSysDir;
|
||||
ParseEnvSearchPaths(L"windir", winSysDir);
|
||||
|
||||
// should resolve to a single directory, otherwise something went wrong
|
||||
if (winSysDir.size() == 1) {
|
||||
#if defined _M_IX86
|
||||
libPath = winSysDir.front() + L"\\syswow64\\";
|
||||
#else
|
||||
libPath = winSysDir.front() + L"\\system32\\";
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
// try to open library
|
||||
libPath += libName;
|
||||
LibInfo *libInfo = AddSingleLibrary(libPath, libType);
|
||||
|
||||
// if successful, add to list and return (stop at first
|
||||
if (libInfo) {
|
||||
m_libInfoList.push_back(libInfo);
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
#else
|
||||
// Linux - not supported
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
mfxStatus LoaderCtxVPL::LoadLibsFromMultipleDirs(LibType libType) {
|
||||
#ifdef __linux__
|
||||
// clang-format off
|
||||
|
||||
// standard paths for RT installation on Linux
|
||||
std::vector<std::string> llSearchDir = {
|
||||
"/usr/lib/x86_64-linux-gnu",
|
||||
"/lib",
|
||||
"/usr/lib",
|
||||
"/lib64",
|
||||
"/usr/lib64",
|
||||
};
|
||||
|
||||
// clang-format on
|
||||
|
||||
const CHAR_TYPE *libName = nullptr;
|
||||
|
||||
if (libType == LibTypeVPL) {
|
||||
libName = libNameVPL;
|
||||
}
|
||||
else if (libType == LibTypeMSDK) {
|
||||
libName = libNameMSDK;
|
||||
|
||||
// additional search directories for MSDK
|
||||
llSearchDir.push_back("/opt/intel/mediasdk/lib");
|
||||
llSearchDir.push_back("/opt/intel/mediasdk/lib64");
|
||||
}
|
||||
else {
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
for (const auto &searchDir : llSearchDir) {
|
||||
STRING_TYPE libPath;
|
||||
libPath = searchDir;
|
||||
libPath += "/";
|
||||
libPath += libName;
|
||||
|
||||
// try to open library
|
||||
LibInfo *libInfo = AddSingleLibrary(libPath, libType);
|
||||
|
||||
// if successful, add to list and return (stop at first success)
|
||||
if (libInfo) {
|
||||
m_libInfoList.push_back(libInfo);
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
#else
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
mfxStatus LoaderCtxVPL::LoadLibsLowLatency() {
|
||||
DISP_LOG_FUNCTION(&m_dispLog);
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
mfxStatus sts = MFX_ERR_NONE;
|
||||
|
||||
// check driver store
|
||||
mfxU32 numAdapters = 0;
|
||||
|
||||
std::vector<DXGI1DeviceInfo> adapterInfo;
|
||||
bool bEnumSuccess = MFX::DXGI1Device::GetAdapterList(adapterInfo);
|
||||
numAdapters = (mfxU32)adapterInfo.size();
|
||||
|
||||
// error - no graphics adapters found
|
||||
if (!bEnumSuccess || numAdapters == 0)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
|
||||
// try loading Intel® VPL from driver store
|
||||
sts = LoadLibsFromDriverStore(numAdapters, adapterInfo, LibTypeVPL);
|
||||
if (sts == MFX_ERR_NONE) {
|
||||
LibInfo *libInfo = m_libInfoList.back();
|
||||
|
||||
sts = LoadSingleLibrary(libInfo);
|
||||
if (sts == MFX_ERR_NONE) {
|
||||
LoadAPIExports(libInfo, LibTypeVPL);
|
||||
m_bNeedLowLatencyQuery = false;
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
UnloadSingleLibrary(libInfo); // failed - unload and move to next location
|
||||
}
|
||||
|
||||
// try loading MSDK from driver store
|
||||
sts = LoadLibsFromDriverStore(numAdapters, adapterInfo, LibTypeMSDK);
|
||||
if (sts == MFX_ERR_NONE) {
|
||||
LibInfo *libInfo = m_libInfoList.back();
|
||||
|
||||
sts = LoadSingleLibrary(libInfo);
|
||||
if (sts == MFX_ERR_NONE) {
|
||||
mfxU32 numFunctions = LoadAPIExports(libInfo, LibTypeMSDK);
|
||||
|
||||
if (numFunctions == NumMSDKFunctions) {
|
||||
mfxVariant var = {};
|
||||
var.Type = MFX_VARIANT_TYPE_PTR;
|
||||
var.Data.Ptr = (mfxHDL) "mfxhw64";
|
||||
|
||||
auto it = m_configCtxList.begin();
|
||||
|
||||
while (it != m_configCtxList.end()) {
|
||||
ConfigCtxVPL *config = (*it);
|
||||
sts = config->SetFilterProperty((const mfxU8 *)"mfxImplDescription.ImplName",
|
||||
var);
|
||||
if (sts != MFX_ERR_NONE)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
it++;
|
||||
}
|
||||
|
||||
m_bNeedLowLatencyQuery = false;
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
}
|
||||
UnloadSingleLibrary(libInfo); // failed - unload and move to next location
|
||||
}
|
||||
|
||||
// try loading MSDK from sysdir %windir%\system32 and %windir%\syswow64
|
||||
sts = LoadLibsFromSystemDir(LibTypeMSDK);
|
||||
if (sts == MFX_ERR_NONE) {
|
||||
LibInfo *libInfo = m_libInfoList.front();
|
||||
|
||||
sts = LoadSingleLibrary(libInfo);
|
||||
if (sts == MFX_ERR_NONE) {
|
||||
mfxU32 numFunctions = LoadAPIExports(libInfo, LibTypeMSDK);
|
||||
|
||||
if (numFunctions == NumMSDKFunctions) {
|
||||
mfxVariant var = {};
|
||||
var.Type = MFX_VARIANT_TYPE_PTR;
|
||||
var.Data.Ptr = (mfxHDL) "mfxhw64";
|
||||
|
||||
auto it = m_configCtxList.begin();
|
||||
|
||||
while (it != m_configCtxList.end()) {
|
||||
ConfigCtxVPL *config = (*it);
|
||||
sts = config->SetFilterProperty((const mfxU8 *)"mfxImplDescription.ImplName",
|
||||
var);
|
||||
if (sts != MFX_ERR_NONE)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
it++;
|
||||
}
|
||||
m_bNeedLowLatencyQuery = false;
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
}
|
||||
UnloadSingleLibrary(libInfo); // failed - unload and move to next location
|
||||
}
|
||||
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
#else
|
||||
mfxStatus sts = MFX_ERR_NONE;
|
||||
|
||||
// try loading Intel® VPL from Linux system directories
|
||||
sts = LoadLibsFromMultipleDirs(LibTypeVPL);
|
||||
if (sts == MFX_ERR_NONE) {
|
||||
LibInfo *libInfo = m_libInfoList.back();
|
||||
|
||||
sts = LoadSingleLibrary(libInfo);
|
||||
if (sts == MFX_ERR_NONE) {
|
||||
LoadAPIExports(libInfo, LibTypeVPL);
|
||||
m_bNeedLowLatencyQuery = false;
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
UnloadSingleLibrary(libInfo); // failed - unload and move to next location
|
||||
}
|
||||
|
||||
// try loading MSDK from Linux system directories
|
||||
sts = LoadLibsFromMultipleDirs(LibTypeMSDK);
|
||||
if (sts == MFX_ERR_NONE) {
|
||||
LibInfo *libInfo = m_libInfoList.back();
|
||||
|
||||
sts = LoadSingleLibrary(libInfo);
|
||||
if (sts == MFX_ERR_NONE) {
|
||||
mfxU32 numFunctions = LoadAPIExports(libInfo, LibTypeMSDK);
|
||||
|
||||
if (numFunctions == NumMSDKFunctions) {
|
||||
mfxVariant var = {};
|
||||
var.Type = MFX_VARIANT_TYPE_PTR;
|
||||
var.Data.Ptr = (mfxHDL) "mfxhw64";
|
||||
|
||||
auto it = m_configCtxList.begin();
|
||||
|
||||
while (it != m_configCtxList.end()) {
|
||||
ConfigCtxVPL *config = (*it);
|
||||
sts = config->SetFilterProperty((const mfxU8 *)"mfxImplDescription.ImplName",
|
||||
var);
|
||||
if (sts != MFX_ERR_NONE)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
it++;
|
||||
}
|
||||
m_bNeedLowLatencyQuery = false;
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
}
|
||||
UnloadSingleLibrary(libInfo); // failed - unload and move to next location
|
||||
}
|
||||
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
// try creating a session in order to get runtime API version
|
||||
mfxStatus LoaderCtxVPL::QuerySessionLowLatency(LibInfo *libInfo,
|
||||
mfxU32 adapterID,
|
||||
mfxVersion *ver) {
|
||||
mfxStatus sts;
|
||||
mfxSession session = nullptr;
|
||||
|
||||
mfxVersion reqVersion;
|
||||
if (libInfo->libType == LibTypeVPL) {
|
||||
reqVersion.Major = 2;
|
||||
reqVersion.Minor = 0;
|
||||
}
|
||||
else {
|
||||
reqVersion.Major = 1;
|
||||
reqVersion.Minor = 0;
|
||||
}
|
||||
|
||||
// set acceleration mode
|
||||
mfxInitializationParam vplParam = {};
|
||||
vplParam.AccelerationMode = m_specialConfig.accelerationMode;
|
||||
|
||||
// set adapter ID for both MSDK and Intel® VPL
|
||||
vplParam.VendorImplID = adapterID;
|
||||
mfxIMPL hwImpl = msdkImplTab[adapterID];
|
||||
|
||||
mfxU16 deviceID;
|
||||
sts = MFXInitEx2(reqVersion,
|
||||
vplParam,
|
||||
hwImpl,
|
||||
&session,
|
||||
&deviceID,
|
||||
(CHAR_TYPE *)libInfo->libNameFull.c_str());
|
||||
|
||||
if (sts == MFX_ERR_NONE) {
|
||||
sts = MFXQueryVersion(session, ver);
|
||||
MFXClose(session);
|
||||
}
|
||||
|
||||
return sts;
|
||||
}
|
||||
@@ -0,0 +1,594 @@
|
||||
/*############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#include <fstream>
|
||||
#include "src/mfx_dispatcher_vpl.h"
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#include "src/mfx_dispatcher_vpl_win.h"
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#include <pthread.h>
|
||||
#define strncpy_s(dst, size, src, cnt) strncpy((dst), (src), (cnt)) // NOLINT
|
||||
#endif
|
||||
|
||||
// leave table formatting alone
|
||||
// clang-format off
|
||||
|
||||
static const mfxChar strImplName[MFX_IMPL_NAME_LEN] = "mfxhw64";
|
||||
static const mfxChar strLicense[MFX_STRFIELD_LEN] = "";
|
||||
|
||||
#if defined _M_IX86
|
||||
static const mfxChar strKeywords[MFX_STRFIELD_LEN] = "MSDK,x86";
|
||||
#else
|
||||
static const mfxChar strKeywords[MFX_STRFIELD_LEN] = "MSDK,x64";
|
||||
#endif
|
||||
|
||||
// also used in main loader routine
|
||||
const mfxIMPL msdkImplTab[MAX_NUM_IMPL_MSDK] = {
|
||||
MFX_IMPL_HARDWARE,
|
||||
MFX_IMPL_HARDWARE2,
|
||||
MFX_IMPL_HARDWARE3,
|
||||
MFX_IMPL_HARDWARE4,
|
||||
};
|
||||
|
||||
// not relevant for 1.x runtimes (no internal memory management)
|
||||
#define NUM_POOL_POLICIES_MSDK 0
|
||||
|
||||
static const mfxPoolPolicyDescription PoolPolicies = {
|
||||
{{ 0, 1 }}, // struct Version
|
||||
{}, // reserved
|
||||
NUM_POOL_POLICIES_MSDK, // NumPoolPolicies
|
||||
nullptr,
|
||||
};
|
||||
|
||||
// 1.x function names should match list in enum eFunc
|
||||
static const mfxChar* msdkImplFuncsNames[] = {
|
||||
"MFXInit",
|
||||
"MFXClose",
|
||||
"MFXQueryIMPL",
|
||||
"MFXQueryVersion",
|
||||
"MFXJoinSession",
|
||||
"MFXDisjoinSession",
|
||||
"MFXCloneSession",
|
||||
"MFXSetPriority",
|
||||
"MFXGetPriority",
|
||||
"MFXInitEx",
|
||||
"MFXVideoCORE_SetFrameAllocator",
|
||||
"MFXVideoCORE_SetHandle",
|
||||
"MFXVideoCORE_GetHandle",
|
||||
"MFXVideoCORE_SyncOperation",
|
||||
"MFXVideoENCODE_Query",
|
||||
"MFXVideoENCODE_QueryIOSurf",
|
||||
"MFXVideoENCODE_Init",
|
||||
"MFXVideoENCODE_Reset",
|
||||
"MFXVideoENCODE_Close",
|
||||
"MFXVideoENCODE_GetVideoParam",
|
||||
"MFXVideoENCODE_GetEncodeStat",
|
||||
"MFXVideoENCODE_EncodeFrameAsync",
|
||||
"MFXVideoDECODE_Query",
|
||||
"MFXVideoDECODE_DecodeHeader",
|
||||
"MFXVideoDECODE_QueryIOSurf",
|
||||
"MFXVideoDECODE_Init",
|
||||
"MFXVideoDECODE_Reset",
|
||||
"MFXVideoDECODE_Close",
|
||||
"MFXVideoDECODE_GetVideoParam",
|
||||
"MFXVideoDECODE_GetDecodeStat",
|
||||
"MFXVideoDECODE_SetSkipMode",
|
||||
"MFXVideoDECODE_GetPayload",
|
||||
"MFXVideoDECODE_DecodeFrameAsync",
|
||||
"MFXVideoVPP_Query",
|
||||
"MFXVideoVPP_QueryIOSurf",
|
||||
"MFXVideoVPP_Init",
|
||||
"MFXVideoVPP_Reset",
|
||||
"MFXVideoVPP_Close",
|
||||
"MFXVideoVPP_GetVideoParam",
|
||||
"MFXVideoVPP_GetVPPStat",
|
||||
"MFXVideoVPP_RunFrameVPPAsync",
|
||||
"MFXVideoCORE_QueryPlatform",
|
||||
};
|
||||
|
||||
static const mfxImplementedFunctions msdkImplFuncs = {
|
||||
sizeof(msdkImplFuncsNames) / sizeof(mfxChar*),
|
||||
(mfxChar**)msdkImplFuncsNames
|
||||
};
|
||||
|
||||
#ifdef __linux__
|
||||
// optional extBuf to limit threads created in MSDK session creation
|
||||
// to enable, set vplParam.NumExtParam and vplParam.ExtParam before calling MFXInitEx2()
|
||||
static const mfxExtThreadsParam extThreadParam = {
|
||||
{MFX_EXTBUFF_THREADS_PARAM, sizeof(mfxExtThreadsParam)},
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
{},
|
||||
};
|
||||
|
||||
static const mfxExtBuffer* extParams[1] = {
|
||||
(mfxExtBuffer *)&extThreadParam,
|
||||
};
|
||||
#endif
|
||||
|
||||
// end table formatting
|
||||
// clang-format on
|
||||
|
||||
LoaderCtxMSDK::LoaderCtxMSDK()
|
||||
: m_msdkAdapter(),
|
||||
m_msdkAdapterD3D9(),
|
||||
m_deviceID(0),
|
||||
m_luid(0),
|
||||
m_extDeviceID(),
|
||||
m_libNameFull(),
|
||||
m_id(),
|
||||
m_accelMode(),
|
||||
m_loaderDeviceID(0) {}
|
||||
|
||||
LoaderCtxMSDK::~LoaderCtxMSDK() {}
|
||||
|
||||
mfxStatus LoaderCtxMSDK::OpenSession(mfxSession *session,
|
||||
STRING_TYPE libNameFull,
|
||||
mfxAccelerationMode accelMode,
|
||||
mfxIMPL hwImpl) {
|
||||
// require API 1.0 or later (both MFXInit and MFXInitEx supported)
|
||||
mfxVersion reqVersion;
|
||||
reqVersion.Major = MSDK_MIN_VERSION_MAJOR;
|
||||
reqVersion.Minor = MSDK_MIN_VERSION_MINOR;
|
||||
|
||||
// set acceleration mode - will be mapped to 1.x API
|
||||
mfxInitializationParam vplParam = {};
|
||||
vplParam.AccelerationMode = accelMode;
|
||||
|
||||
#ifdef __linux__
|
||||
vplParam.ExtParam = (mfxExtBuffer **)&extParams;
|
||||
vplParam.NumExtParam = 1;
|
||||
#else
|
||||
vplParam.ExtParam = nullptr;
|
||||
vplParam.NumExtParam = 0;
|
||||
#endif
|
||||
|
||||
return MFXInitEx2(reqVersion,
|
||||
vplParam,
|
||||
hwImpl,
|
||||
session,
|
||||
&m_loaderDeviceID,
|
||||
(CHAR_TYPE *)libNameFull.c_str());
|
||||
}
|
||||
|
||||
// safe to call more than once (sets/checks for null session)
|
||||
void LoaderCtxMSDK::CloseSession(mfxSession *session) {
|
||||
if (*session)
|
||||
MFXClose(*session);
|
||||
|
||||
*session = nullptr;
|
||||
}
|
||||
|
||||
// map mfxIMPL (1.x) to mfxAccelerationMode (2.x)
|
||||
mfxAccelerationMode LoaderCtxMSDK::CvtAccelType(mfxIMPL implType, mfxIMPL implMethod) {
|
||||
if (implType == MFX_IMPL_HARDWARE) {
|
||||
switch (implMethod) {
|
||||
case MFX_IMPL_VIA_D3D9:
|
||||
return MFX_ACCEL_MODE_VIA_D3D9;
|
||||
case MFX_IMPL_VIA_D3D11:
|
||||
return MFX_ACCEL_MODE_VIA_D3D11;
|
||||
case MFX_IMPL_VIA_VAAPI:
|
||||
return MFX_ACCEL_MODE_VIA_VAAPI;
|
||||
}
|
||||
}
|
||||
|
||||
return MFX_ACCEL_MODE_NA;
|
||||
}
|
||||
|
||||
mfxStatus LoaderCtxMSDK::GetDefaultAccelType(mfxU32 adapterID, mfxIMPL *implDefault, mfxU64 *luid) {
|
||||
#ifdef __linux__
|
||||
// VAAPI only
|
||||
*implDefault = MFX_IMPL_VIA_VAAPI;
|
||||
*luid = 0;
|
||||
return MFX_ERR_NONE;
|
||||
#else
|
||||
// Windows - D3D11 only
|
||||
mfxU32 VendorID = 0, DeviceID = 0;
|
||||
mfxIMPL implTest;
|
||||
mfxStatus sts;
|
||||
|
||||
// check whether adapterID supports D3D11 and has correct VendorID
|
||||
implTest = MFX_IMPL_VIA_D3D11;
|
||||
sts = MFX::SelectImplementationType(adapterID, &implTest, &VendorID, &DeviceID, luid);
|
||||
|
||||
if (sts != MFX_ERR_NONE || VendorID != 0x8086) {
|
||||
implTest = MFX_IMPL_UNSUPPORTED;
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
*implDefault = implTest;
|
||||
|
||||
return MFX_ERR_NONE;
|
||||
#endif
|
||||
}
|
||||
|
||||
mfxStatus LoaderCtxMSDK::QueryAPIVersion(STRING_TYPE libNameFull, mfxVersion *msdkVersion) {
|
||||
mfxStatus sts;
|
||||
mfxSession session = nullptr;
|
||||
|
||||
mfxVersion reqVersion;
|
||||
reqVersion.Major = MSDK_MIN_VERSION_MAJOR;
|
||||
reqVersion.Minor = MSDK_MIN_VERSION_MINOR;
|
||||
|
||||
// try creating a session with each adapter in order to get MSDK API version
|
||||
// stop with first successful session creation
|
||||
for (mfxU32 adapterID = 0; adapterID < MAX_NUM_IMPL_MSDK; adapterID++) {
|
||||
// try HW session, default acceleration mode
|
||||
mfxIMPL hwImpl = msdkImplTab[adapterID];
|
||||
mfxIMPL implDefault = MFX_IMPL_UNSUPPORTED;
|
||||
mfxU64 luid;
|
||||
|
||||
// if not a valid HW device, try next adapter
|
||||
sts = GetDefaultAccelType(adapterID, &implDefault, &luid);
|
||||
if (sts != MFX_ERR_NONE)
|
||||
continue;
|
||||
|
||||
// set acceleration mode - will be mapped to 1.x API
|
||||
mfxInitializationParam vplParam = {};
|
||||
vplParam.AccelerationMode =
|
||||
(mfxAccelerationMode)CvtAccelType(MFX_IMPL_HARDWARE, implDefault & 0xFF00);
|
||||
|
||||
#ifdef __linux__
|
||||
vplParam.ExtParam = (mfxExtBuffer **)&extParams;
|
||||
vplParam.NumExtParam = 1;
|
||||
#else
|
||||
vplParam.ExtParam = nullptr;
|
||||
vplParam.NumExtParam = 0;
|
||||
#endif
|
||||
|
||||
mfxU16 deviceID;
|
||||
sts = MFXInitEx2(reqVersion,
|
||||
vplParam,
|
||||
hwImpl,
|
||||
&session,
|
||||
&deviceID,
|
||||
(CHAR_TYPE *)libNameFull.c_str());
|
||||
|
||||
if (sts == MFX_ERR_NONE) {
|
||||
sts = MFXQueryVersion(session, msdkVersion);
|
||||
MFXClose(session);
|
||||
|
||||
if (sts == MFX_ERR_NONE)
|
||||
return sts;
|
||||
}
|
||||
}
|
||||
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
mfxStatus LoaderCtxMSDK::QueryMSDKCaps(STRING_TYPE libNameFull,
|
||||
mfxImplDescription **implDesc,
|
||||
mfxImplementedFunctions **implFuncs,
|
||||
mfxU32 adapterID,
|
||||
bool bSkipD3D9Check) {
|
||||
#ifdef DISABLE_MSDK_COMPAT
|
||||
// disable support for legacy MSDK
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
#endif
|
||||
|
||||
mfxStatus sts;
|
||||
mfxSession session = nullptr;
|
||||
|
||||
m_libNameFull = libNameFull;
|
||||
m_deviceID = 0;
|
||||
|
||||
#ifdef __linux__
|
||||
// require pthreads to be linked in for MSDK RT to load
|
||||
pthread_key_t pkey;
|
||||
if (pthread_key_create(&pkey, NULL) == 0) {
|
||||
pthread_key_delete(pkey);
|
||||
}
|
||||
|
||||
mfxU32 vendorID = 0;
|
||||
mfxU16 deviceID = 0;
|
||||
sts = GetRenderNodeDescription(adapterID, vendorID, deviceID);
|
||||
if (sts != MFX_ERR_NONE)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
|
||||
// on Linux read deviceID from the render node path
|
||||
m_deviceID = deviceID;
|
||||
#endif
|
||||
|
||||
// try HW session, default acceleration mode
|
||||
mfxIMPL hwImpl = msdkImplTab[adapterID];
|
||||
mfxIMPL implDefault = MFX_IMPL_UNSUPPORTED;
|
||||
|
||||
sts = GetDefaultAccelType(adapterID, &implDefault, &m_luid);
|
||||
if (sts != MFX_ERR_NONE)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
|
||||
sts = OpenSession(&session,
|
||||
m_libNameFull,
|
||||
(mfxAccelerationMode)CvtAccelType(MFX_IMPL_HARDWARE, implDefault & 0xFF00),
|
||||
hwImpl);
|
||||
|
||||
// adapter unsupported
|
||||
if (sts != MFX_ERR_NONE)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
|
||||
// return list of implemented functions
|
||||
*implFuncs = (mfxImplementedFunctions *)(&msdkImplFuncs);
|
||||
|
||||
// clear new 2.0 style description struct
|
||||
memset(&m_id, 0, sizeof(mfxImplDescription));
|
||||
*implDesc = &m_id;
|
||||
|
||||
// fill in top-level capabilities
|
||||
m_id.Version.Version = MFX_IMPLDESCRIPTION_VERSION;
|
||||
m_id.Impl = MFX_IMPL_TYPE_HARDWARE;
|
||||
|
||||
// query API version
|
||||
sts = MFXQueryVersion(session, &m_id.ApiVersion);
|
||||
if (sts != MFX_ERR_NONE) {
|
||||
CloseSession(&session);
|
||||
return sts;
|
||||
}
|
||||
|
||||
// set default acceleration mode
|
||||
m_id.AccelerationMode = CvtAccelType(MFX_IMPL_HARDWARE, implDefault & 0xFF00);
|
||||
|
||||
// fill in acceleration description struct
|
||||
mfxAccelerationModeDescription *accelDesc = &(m_id.AccelerationModeDescription);
|
||||
accelDesc->Version.Version = MFX_ACCELERATIONMODESCRIPTION_VERSION;
|
||||
|
||||
// fill in mode description with just the single (default) mode
|
||||
accelDesc->NumAccelerationModes = 1;
|
||||
accelDesc->Mode = m_accelMode;
|
||||
accelDesc->Mode[0] = m_id.AccelerationMode;
|
||||
|
||||
// return HW accelerator - required by MFXCreateSession
|
||||
m_msdkAdapter = hwImpl;
|
||||
|
||||
// map MFX HW number to VendorImplID
|
||||
m_id.VendorImplID = 0;
|
||||
switch (hwImpl) {
|
||||
case MFX_IMPL_HARDWARE:
|
||||
m_id.VendorImplID = 0;
|
||||
break;
|
||||
case MFX_IMPL_HARDWARE2:
|
||||
m_id.VendorImplID = 1;
|
||||
break;
|
||||
case MFX_IMPL_HARDWARE3:
|
||||
m_id.VendorImplID = 2;
|
||||
break;
|
||||
case MFX_IMPL_HARDWARE4:
|
||||
m_id.VendorImplID = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
// fill in strings
|
||||
strncpy_s(m_id.ImplName, sizeof(m_id.ImplName), strImplName, sizeof(strImplName));
|
||||
m_id.ImplName[sizeof(m_id.ImplName) - 1] = 0;
|
||||
strncpy_s(m_id.License, sizeof(m_id.License), strLicense, sizeof(strLicense));
|
||||
m_id.License[sizeof(m_id.License) - 1] = 0;
|
||||
strncpy_s(m_id.Keywords, sizeof(m_id.Keywords), strKeywords, sizeof(strKeywords));
|
||||
m_id.Keywords[sizeof(m_id.Keywords) - 1] = 0;
|
||||
|
||||
m_id.VendorID = 0x8086;
|
||||
m_id.NumExtParam = 0;
|
||||
|
||||
// fill in pool policies
|
||||
m_id.PoolPolicies = PoolPolicies;
|
||||
|
||||
// fill in device description
|
||||
mfxDeviceDescription *Dev = &(m_id.Dev);
|
||||
memset(Dev, 0, sizeof(mfxDeviceDescription)); // initially empty
|
||||
Dev->MediaAdapterType = MFX_MEDIA_UNKNOWN;
|
||||
|
||||
// query for underlying deviceID (requires API >= 1.19)
|
||||
// for Linux, we may already have the deviceID from parsing render node path earlier
|
||||
if (m_deviceID == 0) {
|
||||
if (IsVersionSupported(MAKE_MFX_VERSION(1, 19), m_id.ApiVersion)) {
|
||||
mfxPlatform platform = {};
|
||||
|
||||
sts = MFXVideoCORE_QueryPlatform(session, &platform);
|
||||
if (sts == MFX_ERR_NONE)
|
||||
m_deviceID = platform.DeviceId;
|
||||
|
||||
// mfxPlatform::MediaAdapterType was added in API 1.31
|
||||
if (IsVersionSupported(MAKE_MFX_VERSION(1, 31), m_id.ApiVersion)) {
|
||||
Dev->MediaAdapterType = platform.MediaAdapterType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if QueryPlatform did not return deviceID, we may have received
|
||||
// it from the loader (MFXInitEx2)
|
||||
if (m_deviceID == 0)
|
||||
m_deviceID = m_loaderDeviceID;
|
||||
|
||||
// store DeviceID as "DevID" (hex) / "AdapterIdx" (dec) to match GPU RT
|
||||
Dev->Version.Version = MFX_DEVICEDESCRIPTION_VERSION;
|
||||
snprintf(Dev->DeviceID, sizeof(Dev->DeviceID), "%x/%d", m_deviceID, m_id.VendorImplID);
|
||||
Dev->NumSubDevices = 0;
|
||||
|
||||
CloseSession(&session);
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
if (bSkipD3D9Check == false) {
|
||||
mfxIMPL implD3D9;
|
||||
m_msdkAdapterD3D9 = MFX_IMPL_UNSUPPORTED;
|
||||
|
||||
sts = CheckD3D9Support(m_luid, libNameFull, &implD3D9);
|
||||
if (sts == MFX_ERR_NONE) {
|
||||
m_msdkAdapterD3D9 = implD3D9;
|
||||
|
||||
accelDesc->Mode[accelDesc->NumAccelerationModes] = MFX_ACCEL_MODE_VIA_D3D9;
|
||||
accelDesc->NumAccelerationModes++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
|
||||
mfxStatus LoaderCtxMSDK::CheckD3D9Support(mfxU64 luid, STRING_TYPE libNameFull, mfxIMPL *implD3D9) {
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
mfxU32 VendorID = 0, DeviceID = 0;
|
||||
mfxIMPL implTest = MFX_IMPL_VIA_D3D9;
|
||||
|
||||
mfxStatus sts;
|
||||
mfxSession session = nullptr;
|
||||
|
||||
mfxVersion reqVersion;
|
||||
reqVersion.Major = MSDK_MIN_VERSION_MAJOR;
|
||||
reqVersion.Minor = MSDK_MIN_VERSION_MINOR;
|
||||
|
||||
*implD3D9 = MFX_IMPL_UNSUPPORTED;
|
||||
|
||||
mfxU32 idx;
|
||||
for (idx = 0; idx < MAX_NUM_IMPL_MSDK; idx++) {
|
||||
mfxU64 luidD3D9 = 0;
|
||||
sts = MFX::SelectImplementationType(idx, &implTest, &VendorID, &DeviceID, &luidD3D9);
|
||||
|
||||
if (sts != MFX_ERR_NONE || VendorID != 0x8086 || luid != luidD3D9)
|
||||
continue;
|
||||
|
||||
// matching LUID - try creating a D3D9 session
|
||||
mfxInitializationParam vplParam = {};
|
||||
vplParam.AccelerationMode = MFX_ACCEL_MODE_VIA_D3D9;
|
||||
|
||||
// thread limit not enabled on Windows
|
||||
vplParam.ExtParam = nullptr;
|
||||
vplParam.NumExtParam = 0;
|
||||
|
||||
mfxU16 deviceID;
|
||||
sts = MFXInitEx2(reqVersion,
|
||||
vplParam,
|
||||
msdkImplTab[idx],
|
||||
&session,
|
||||
&deviceID,
|
||||
(CHAR_TYPE *)libNameFull.c_str());
|
||||
|
||||
if (sts == MFX_ERR_NONE) {
|
||||
*implD3D9 = msdkImplTab[idx];
|
||||
MFXClose(session);
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
|
||||
break; // D3D9 not supported
|
||||
}
|
||||
|
||||
// this adapter (input luid) does not support D3D9
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
#else
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
mfxU32 read_device_file(std::string &path) {
|
||||
mfxU32 result = 0;
|
||||
std::string line;
|
||||
std::ifstream dev_str(path);
|
||||
if (!dev_str.is_open()) {
|
||||
return 0;
|
||||
}
|
||||
std::getline(dev_str, line);
|
||||
dev_str.close();
|
||||
try {
|
||||
result = std::stoul(line, 0, 16);
|
||||
}
|
||||
catch (std::invalid_argument &) {
|
||||
return 0;
|
||||
}
|
||||
catch (std::out_of_range &) {
|
||||
return 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
mfxStatus LoaderCtxMSDK::GetRenderNodeDescription(mfxU32 adapterID,
|
||||
mfxU32 &vendorID,
|
||||
mfxU16 &deviceID) {
|
||||
vendorID = 0;
|
||||
deviceID = 0;
|
||||
|
||||
#if defined(__linux__)
|
||||
mfxU32 DRMRenderNodeNum = 128 + adapterID;
|
||||
std::string nodeStr = std::to_string(DRMRenderNodeNum);
|
||||
|
||||
std::string vendorPath = "/sys/class/drm/renderD" + nodeStr + "/device/vendor";
|
||||
std::string devPath = "/sys/class/drm/renderD" + nodeStr + "/device/device";
|
||||
|
||||
vendorID = read_device_file(vendorPath);
|
||||
|
||||
if (vendorID != 0x8086)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
|
||||
deviceID = read_device_file(devPath);
|
||||
|
||||
if (deviceID == 0)
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
|
||||
return MFX_ERR_NONE;
|
||||
#else
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
// avoid confusing #ifdef indentation
|
||||
// clang-format off
|
||||
|
||||
mfxStatus LoaderCtxMSDK::QueryExtDeviceID(mfxExtendedDeviceId *extDeviceID,
|
||||
mfxU32 adapterID,
|
||||
mfxU16 deviceID,
|
||||
mfxU64 luid) {
|
||||
// fill extended device ID struct (API >= 2.6)
|
||||
memset(extDeviceID, 0, sizeof(mfxExtendedDeviceId));
|
||||
|
||||
// common properties
|
||||
extDeviceID->Version.Version = MFX_EXTENDEDDEVICEID_VERSION;
|
||||
extDeviceID->VendorID = 0x8086;
|
||||
extDeviceID->DeviceID = deviceID;
|
||||
|
||||
// default - no PCI info
|
||||
// additional dependencies required to obtain these props
|
||||
extDeviceID->PCIDomain = 0xFFFFFFFF;
|
||||
extDeviceID->PCIBus = 0xFFFFFFFF;
|
||||
extDeviceID->PCIDevice = 0xFFFFFFFF;
|
||||
extDeviceID->PCIFunction = 0xFFFFFFFF;
|
||||
|
||||
// default - no LUID
|
||||
extDeviceID->LUIDDeviceNodeMask = 0;
|
||||
extDeviceID->LUIDValid = 0;
|
||||
for (mfxU32 idx = 0; idx < 8; idx++)
|
||||
extDeviceID->DeviceLUID[idx] = 0;
|
||||
|
||||
// default - no DRM node
|
||||
extDeviceID->DRMRenderNodeNum = 0;
|
||||
extDeviceID->DRMPrimaryNodeNum = 0x7FFFFFFF;
|
||||
|
||||
// default - no PCI RevisionID
|
||||
extDeviceID->RevisionID = 0xFFFF;
|
||||
|
||||
snprintf(extDeviceID->DeviceName, sizeof(extDeviceID->DeviceName), "%s", strImplName);
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
// fill in Windows-specific properties
|
||||
if (luid) {
|
||||
extDeviceID->LUIDDeviceNodeMask = 1;
|
||||
extDeviceID->LUIDValid = 1;
|
||||
|
||||
// map 64-bit LUID into mfxU8[8]
|
||||
mfxU64 luidArr = luid;
|
||||
for (mfxU32 idx = 0; idx < 8; idx++) {
|
||||
extDeviceID->DeviceLUID[idx] = mfxU8((luidArr)&0xFF);
|
||||
luidArr >>= 8;
|
||||
}
|
||||
}
|
||||
#elif defined(__linux__)
|
||||
extDeviceID->DRMPrimaryNodeNum = adapterID;
|
||||
extDeviceID->DRMRenderNodeNum = 128 + adapterID;
|
||||
#endif
|
||||
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
|
||||
// clang-format on
|
||||
@@ -0,0 +1,19 @@
|
||||
/*############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#ifndef LIBVPL_SRC_MFX_DISPATCHER_VPL_WIN_H_
|
||||
#define LIBVPL_SRC_MFX_DISPATCHER_VPL_WIN_H_
|
||||
|
||||
// headers for Windows legacy dispatcher
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#include "windows/mfx_dispatcher.h"
|
||||
#include "windows/mfx_dispatcher_defs.h"
|
||||
#include "windows/mfx_dxva2_device.h"
|
||||
#include "windows/mfx_library_iterator.h"
|
||||
#include "windows/mfx_load_dll.h"
|
||||
#endif
|
||||
|
||||
#endif // LIBVPL_SRC_MFX_DISPATCHER_VPL_WIN_H_
|
||||
@@ -0,0 +1,76 @@
|
||||
EXPORTS
|
||||
MFXInit
|
||||
MFXClose
|
||||
MFXQueryIMPL
|
||||
MFXQueryVersion
|
||||
|
||||
MFXJoinSession
|
||||
MFXDisjoinSession
|
||||
MFXCloneSession
|
||||
MFXSetPriority
|
||||
MFXGetPriority
|
||||
|
||||
MFXVideoCORE_SetFrameAllocator
|
||||
MFXVideoCORE_SetHandle
|
||||
MFXVideoCORE_GetHandle
|
||||
MFXVideoCORE_QueryPlatform
|
||||
MFXVideoCORE_SyncOperation
|
||||
|
||||
MFXVideoENCODE_Query
|
||||
MFXVideoENCODE_QueryIOSurf
|
||||
MFXVideoENCODE_Init
|
||||
MFXVideoENCODE_Reset
|
||||
MFXVideoENCODE_Close
|
||||
MFXVideoENCODE_GetVideoParam
|
||||
MFXVideoENCODE_GetEncodeStat
|
||||
MFXVideoENCODE_EncodeFrameAsync
|
||||
|
||||
MFXVideoDECODE_Query
|
||||
MFXVideoDECODE_DecodeHeader
|
||||
MFXVideoDECODE_QueryIOSurf
|
||||
MFXVideoDECODE_Init
|
||||
MFXVideoDECODE_Reset
|
||||
MFXVideoDECODE_Close
|
||||
MFXVideoDECODE_GetVideoParam
|
||||
MFXVideoDECODE_GetDecodeStat
|
||||
MFXVideoDECODE_SetSkipMode
|
||||
MFXVideoDECODE_GetPayload
|
||||
MFXVideoDECODE_DecodeFrameAsync
|
||||
|
||||
MFXVideoVPP_Query
|
||||
MFXVideoVPP_QueryIOSurf
|
||||
MFXVideoVPP_Init
|
||||
MFXVideoVPP_Reset
|
||||
MFXVideoVPP_Close
|
||||
|
||||
MFXVideoVPP_GetVideoParam
|
||||
MFXVideoVPP_GetVPPStat
|
||||
MFXVideoVPP_RunFrameVPPAsync
|
||||
|
||||
MFXInitEx
|
||||
|
||||
MFXQueryAdapters
|
||||
MFXQueryAdaptersNumber
|
||||
MFXQueryAdaptersDecode
|
||||
|
||||
MFXLoad
|
||||
MFXUnload
|
||||
MFXCreateConfig
|
||||
MFXSetConfigFilterProperty
|
||||
MFXEnumImplementations
|
||||
MFXCreateSession
|
||||
MFXDispReleaseImplDescription
|
||||
|
||||
MFXMemory_GetSurfaceForVPP
|
||||
MFXMemory_GetSurfaceForEncode
|
||||
MFXMemory_GetSurfaceForDecode
|
||||
|
||||
MFXMemory_GetSurfaceForVPPOut
|
||||
MFXVideoDECODE_VPP_Init
|
||||
MFXVideoDECODE_VPP_DecodeFrameAsync
|
||||
MFXVideoDECODE_VPP_Reset
|
||||
MFXVideoDECODE_VPP_GetChannelParam
|
||||
MFXVideoDECODE_VPP_Close
|
||||
MFXVideoVPP_ProcessFrameAsync
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,49 @@
|
||||
/*############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#include "src/windows/mfx_critical_section.h"
|
||||
|
||||
#include <windows.h>
|
||||
// SDK re-declares the following functions with different call declarator.
|
||||
// We don't need them. Just redefine them to nothing.
|
||||
#define _interlockedbittestandset fake_set
|
||||
#define _interlockedbittestandreset fake_reset
|
||||
#define _interlockedbittestandset64 fake_set64
|
||||
#define _interlockedbittestandreset64 fake_reset64
|
||||
#include <intrin.h>
|
||||
|
||||
#define MFX_WAIT() SwitchToThread()
|
||||
|
||||
// static section of the file
|
||||
namespace {
|
||||
|
||||
enum { MFX_SC_IS_FREE = 0, MFX_SC_IS_TAKEN = 1 };
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace MFX {
|
||||
|
||||
mfxU32 mfxInterlockedCas32(mfxCriticalSection *pCSection,
|
||||
mfxU32 value_to_exchange,
|
||||
mfxU32 value_to_compare) {
|
||||
return _InterlockedCompareExchange(pCSection, value_to_exchange, value_to_compare);
|
||||
}
|
||||
|
||||
mfxU32 mfxInterlockedXchg32(mfxCriticalSection *pCSection, mfxU32 value) {
|
||||
return _InterlockedExchange(pCSection, value);
|
||||
}
|
||||
|
||||
void mfxEnterCriticalSection(mfxCriticalSection *pCSection) {
|
||||
while (MFX_SC_IS_TAKEN == mfxInterlockedCas32(pCSection, MFX_SC_IS_TAKEN, MFX_SC_IS_FREE)) {
|
||||
MFX_WAIT();
|
||||
}
|
||||
} // void mfxEnterCriticalSection(mfxCriticalSection *pCSection)
|
||||
|
||||
void mfxLeaveCriticalSection(mfxCriticalSection *pCSection) {
|
||||
mfxInterlockedXchg32(pCSection, MFX_SC_IS_FREE);
|
||||
} // void mfxLeaveCriticalSection(mfxCriticalSection *pCSection)
|
||||
|
||||
} // namespace MFX
|
||||
@@ -0,0 +1,48 @@
|
||||
/*############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#ifndef LIBVPL_SRC_WINDOWS_MFX_CRITICAL_SECTION_H_
|
||||
#define LIBVPL_SRC_WINDOWS_MFX_CRITICAL_SECTION_H_
|
||||
|
||||
#include "vpl/mfxdefs.h"
|
||||
|
||||
namespace MFX {
|
||||
|
||||
// Just set "critical section" instance to zero for initialization.
|
||||
typedef volatile mfxL32 mfxCriticalSection;
|
||||
|
||||
// Enter the global critical section.
|
||||
void mfxEnterCriticalSection(mfxCriticalSection *pCSection);
|
||||
|
||||
// Leave the global critical section.
|
||||
void mfxLeaveCriticalSection(mfxCriticalSection *pCSection);
|
||||
|
||||
class MFXAutomaticCriticalSection {
|
||||
public:
|
||||
// Constructor
|
||||
explicit MFXAutomaticCriticalSection(mfxCriticalSection *pCSection) {
|
||||
m_pCSection = pCSection;
|
||||
mfxEnterCriticalSection(m_pCSection);
|
||||
}
|
||||
|
||||
// Destructor
|
||||
~MFXAutomaticCriticalSection() {
|
||||
mfxLeaveCriticalSection(m_pCSection);
|
||||
}
|
||||
|
||||
protected:
|
||||
// Pointer to a critical section
|
||||
mfxCriticalSection *m_pCSection;
|
||||
|
||||
private:
|
||||
// unimplemented by intent to make this class non-copyable
|
||||
MFXAutomaticCriticalSection(const MFXAutomaticCriticalSection &);
|
||||
void operator=(const MFXAutomaticCriticalSection &);
|
||||
};
|
||||
|
||||
} // namespace MFX
|
||||
|
||||
#endif // LIBVPL_SRC_WINDOWS_MFX_CRITICAL_SECTION_H_
|
||||
@@ -0,0 +1,594 @@
|
||||
/*############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#include "src/windows/mfx_dispatcher.h"
|
||||
#include "src/windows/mfx_dispatcher_log.h"
|
||||
#include "src/windows/mfx_load_dll.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include "src/windows/mfx_dxva2_device.h"
|
||||
#include "src/windows/mfx_vector.h"
|
||||
#include "src/windows/mfxvideo++.h"
|
||||
#include "vpl/mfxadapter.h"
|
||||
|
||||
#if _MSC_VER
|
||||
#pragma warning(disable : 4355)
|
||||
#endif
|
||||
|
||||
MFX_DISP_HANDLE::MFX_DISP_HANDLE(const mfxVersion requiredVersion)
|
||||
: _mfxSession(),
|
||||
apiVersion(requiredVersion) {
|
||||
actualApiVersion.Version = 0;
|
||||
implType = MFX_LIB_SOFTWARE;
|
||||
impl = MFX_IMPL_SOFTWARE;
|
||||
loadStatus = MFX_ERR_NOT_FOUND;
|
||||
dispVersion.Major = MFX_DISPATCHER_VERSION_MAJOR;
|
||||
dispVersion.Minor = MFX_DISPATCHER_VERSION_MINOR;
|
||||
storageID = 0;
|
||||
implInterface = MFX_IMPL_HARDWARE_ANY;
|
||||
|
||||
hModule = (mfxModuleHandle)0;
|
||||
|
||||
} // MFX_DISP_HANDLE::MFX_DISP_HANDLE(const mfxVersion requiredVersion)
|
||||
|
||||
MFX_DISP_HANDLE::~MFX_DISP_HANDLE(void) {
|
||||
Close();
|
||||
|
||||
} // MFX_DISP_HANDLE::~MFX_DISP_HANDLE(void)
|
||||
|
||||
mfxStatus MFX_DISP_HANDLE::Close(void) {
|
||||
mfxStatus mfxRes;
|
||||
|
||||
mfxRes = UnLoadSelectedDLL();
|
||||
|
||||
// need to reset dispatcher state after unloading dll
|
||||
if (MFX_ERR_NONE == mfxRes) {
|
||||
implType = MFX_LIB_SOFTWARE;
|
||||
impl = MFX_IMPL_SOFTWARE;
|
||||
loadStatus = MFX_ERR_NOT_FOUND;
|
||||
dispVersion.Major = MFX_DISPATCHER_VERSION_MAJOR;
|
||||
dispVersion.Minor = MFX_DISPATCHER_VERSION_MINOR;
|
||||
*static_cast<_mfxSession *>(this) = _mfxSession();
|
||||
hModule = (mfxModuleHandle)0;
|
||||
}
|
||||
|
||||
return mfxRes;
|
||||
|
||||
} // mfxStatus MFX_DISP_HANDLE::Close(void)
|
||||
|
||||
mfxStatus MFX_DISP_HANDLE::LoadSelectedDLL(const wchar_t *pPath,
|
||||
eMfxImplType reqImplType,
|
||||
mfxIMPL reqImpl,
|
||||
mfxIMPL reqImplInterface,
|
||||
mfxInitParam &par,
|
||||
mfxInitializationParam &vplParam,
|
||||
bool bCloneSession) {
|
||||
mfxStatus mfxRes = MFX_ERR_NONE;
|
||||
|
||||
// check error(s)
|
||||
if ((MFX_LIB_SOFTWARE != reqImplType) && (MFX_LIB_HARDWARE != reqImplType)) {
|
||||
DISPATCHER_LOG_ERROR(
|
||||
(("implType == %s, should be either MFX_LIB_SOFTWARE or MFX_LIB_HARDWARE\n"),
|
||||
DispatcherLog_GetMFXImplString(reqImplType).c_str()));
|
||||
loadStatus = MFX_ERR_ABORTED;
|
||||
return loadStatus;
|
||||
}
|
||||
// only exact types of implementation is allowed
|
||||
if ((MFX_IMPL_SOFTWARE != reqImpl) && (MFX_IMPL_HARDWARE != reqImpl) &&
|
||||
(MFX_IMPL_HARDWARE2 != reqImpl) && (MFX_IMPL_HARDWARE3 != reqImpl) &&
|
||||
(MFX_IMPL_HARDWARE4 != reqImpl)) {
|
||||
DISPATCHER_LOG_ERROR((("invalid implementation impl == %s\n"),
|
||||
DispatcherLog_GetMFXImplString(impl).c_str()));
|
||||
loadStatus = MFX_ERR_ABORTED;
|
||||
return loadStatus;
|
||||
}
|
||||
|
||||
// close the handle before initialization
|
||||
Close();
|
||||
|
||||
// save the library's type
|
||||
this->implType = reqImplType;
|
||||
this->impl = reqImpl;
|
||||
this->implInterface = reqImplInterface;
|
||||
|
||||
{
|
||||
assert(hModule == (mfxModuleHandle)0);
|
||||
DISPATCHER_LOG_BLOCK(("invoking LoadLibrary(%S)\n", pPath));
|
||||
|
||||
// load the DLL into the memory
|
||||
hModule = MFX::mfx_dll_load(pPath);
|
||||
|
||||
if (hModule) {
|
||||
int i;
|
||||
|
||||
DISPATCHER_LOG_OPERATION({
|
||||
wchar_t modulePath[1024];
|
||||
GetModuleFileNameW((HMODULE)hModule,
|
||||
modulePath,
|
||||
sizeof(modulePath) / sizeof(modulePath[0]));
|
||||
DISPATCHER_LOG_INFO((("loaded module %S\n"), modulePath))
|
||||
});
|
||||
|
||||
// load video functions: pointers to exposed functions
|
||||
for (i = 0; i < eVideoFuncTotal; i += 1) {
|
||||
mfxFunctionPointer pProc =
|
||||
(mfxFunctionPointer)MFX::mfx_dll_get_addr(hModule, APIFunc[i].pName);
|
||||
if (pProc) {
|
||||
// function exists in the library,
|
||||
// save the pointer.
|
||||
callTable[i] = pProc;
|
||||
}
|
||||
else {
|
||||
// The library doesn't contain the function
|
||||
DISPATCHER_LOG_WRN((("Can't find API function \"%s\"\n"), APIFunc[i].pName));
|
||||
if (apiVersion.Version >= APIFunc[i].apiVersion.Version) {
|
||||
DISPATCHER_LOG_ERROR((("\"%s\" is required for API %u.%u\n"),
|
||||
APIFunc[i].pName,
|
||||
apiVersion.Major,
|
||||
apiVersion.Minor));
|
||||
mfxRes = MFX_ERR_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if version >= 2.0, load these functions as well
|
||||
if (apiVersion.Major >= 2) {
|
||||
for (i = 0; i < eVideoFunc2Total; i += 1) {
|
||||
mfxFunctionPointer pProc =
|
||||
(mfxFunctionPointer)MFX::mfx_dll_get_addr(hModule, APIVideoFunc2[i].pName);
|
||||
if (pProc) {
|
||||
// function exists in the library,
|
||||
// save the pointer.
|
||||
callVideoTable2[i] = pProc;
|
||||
}
|
||||
else {
|
||||
// The library doesn't contain the function
|
||||
DISPATCHER_LOG_WRN(
|
||||
(("Can't find API function \"%s\"\n"), APIVideoFunc2[i].pName));
|
||||
if (apiVersion.Version >= APIVideoFunc2[i].apiVersion.Version) {
|
||||
DISPATCHER_LOG_ERROR((("\"%s\" is required for API %u.%u\n"),
|
||||
APIVideoFunc2[i].pName,
|
||||
apiVersion.Major,
|
||||
apiVersion.Minor));
|
||||
mfxRes = MFX_ERR_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
DISPATCHER_LOG_WRN((("can't find DLL: GetLastErr()=0x%x\n"), GetLastError()))
|
||||
mfxRes = MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
if (bCloneSession == true) {
|
||||
loadStatus = mfxRes;
|
||||
return mfxRes;
|
||||
}
|
||||
|
||||
// initialize the loaded DLL
|
||||
if (MFX_ERR_NONE == mfxRes) {
|
||||
mfxVersion version(apiVersion);
|
||||
|
||||
if (version.Major >= 2) {
|
||||
// for API >= 2.0 call MFXInitialize instead of MFXInitEx
|
||||
int tableIndex = eMFXInitialize;
|
||||
mfxFunctionPointer pFunc = callVideoTable2[tableIndex];
|
||||
|
||||
// filled-in mfxInitializationParam must be provided for MFXInitialize path
|
||||
mfxRes =
|
||||
(*(mfxStatus(MFX_CDECL *)(mfxInitializationParam, mfxSession *))pFunc)(vplParam,
|
||||
&session);
|
||||
}
|
||||
else {
|
||||
// Call old-style MFXInit init for older libraries
|
||||
bool callOldInit =
|
||||
!callTable[eMFXInitEx]; // if true call eMFXInit, if false - eMFXInitEx
|
||||
int tableIndex = (callOldInit) ? eMFXInit : eMFXInitEx;
|
||||
mfxFunctionPointer pFunc = callTable[tableIndex];
|
||||
|
||||
if (callOldInit) {
|
||||
DISPATCHER_LOG_BLOCK(("MFXInit(%s,ver=%u.%u,session=0x%p)\n",
|
||||
DispatcherLog_GetMFXImplString(impl | implInterface).c_str(),
|
||||
apiVersion.Major,
|
||||
apiVersion.Minor,
|
||||
&session));
|
||||
|
||||
mfxRes = (*(mfxStatus(MFX_CDECL *)(mfxIMPL, mfxVersion *, mfxSession *))pFunc)(
|
||||
impl | implInterface,
|
||||
&version,
|
||||
&session);
|
||||
}
|
||||
else {
|
||||
DISPATCHER_LOG_BLOCK(("MFXInitEx(%s,ver=%u.%u,ExtThreads=%d,session=0x%p)\n",
|
||||
DispatcherLog_GetMFXImplString(impl | implInterface).c_str(),
|
||||
apiVersion.Major,
|
||||
apiVersion.Minor,
|
||||
par.ExternalThreads,
|
||||
&session));
|
||||
|
||||
mfxInitParam initPar = par;
|
||||
// adjusting user parameters
|
||||
initPar.Implementation = impl | implInterface;
|
||||
initPar.Version = version;
|
||||
mfxRes =
|
||||
(*(mfxStatus(MFX_CDECL *)(mfxInitParam, mfxSession *))pFunc)(initPar, &session);
|
||||
}
|
||||
}
|
||||
|
||||
if (MFX_ERR_NONE != mfxRes) {
|
||||
DISPATCHER_LOG_WRN((("library can't be load. MFXInit returned %s \n"),
|
||||
DispatcherLog_GetMFXStatusString(mfxRes)))
|
||||
}
|
||||
else {
|
||||
mfxRes = MFXQueryVersion((mfxSession)this, &actualApiVersion);
|
||||
|
||||
if (MFX_ERR_NONE != mfxRes) {
|
||||
DISPATCHER_LOG_ERROR(
|
||||
(("MFXQueryVersion returned: %d, skipped this library\n"), mfxRes))
|
||||
}
|
||||
else {
|
||||
DISPATCHER_LOG_INFO((("MFXQueryVersion returned API: %d.%d\n"),
|
||||
actualApiVersion.Major,
|
||||
actualApiVersion.Minor))
|
||||
//special hook for applications that uses sink api to get loaded library path
|
||||
DISPATCHER_LOG_LIBRARY(("%p", hModule));
|
||||
DISPATCHER_LOG_INFO(("library loaded successfully\n"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loadStatus = mfxRes;
|
||||
return mfxRes;
|
||||
|
||||
} // mfxStatus MFX_DISP_HANDLE::LoadSelectedDLL(const wchar_t* pPath, eMfxImplType reqImplType, mfxIMPL reqImpl, mfxIMPL reqImplInterface, mfxInitParam& par, mfxInitializationParam &vplParam)
|
||||
|
||||
mfxStatus MFX_DISP_HANDLE::UnLoadSelectedDLL(void) {
|
||||
mfxStatus mfxRes = MFX_ERR_NONE;
|
||||
|
||||
// close the loaded DLL
|
||||
if (session) {
|
||||
/* check whether it is audio session or video */
|
||||
int tableIndex = eMFXClose;
|
||||
mfxFunctionPointer pFunc;
|
||||
pFunc = callTable[tableIndex];
|
||||
|
||||
mfxRes = (*(mfxStatus(MFX_CDECL *)(mfxSession))pFunc)(session);
|
||||
if (MFX_ERR_NONE == mfxRes) {
|
||||
session = (mfxSession)0;
|
||||
}
|
||||
|
||||
DISPATCHER_LOG_INFO((("MFXClose(0x%x) returned %d\n"), session, mfxRes));
|
||||
// actually, the return value is required to pass outside only.
|
||||
}
|
||||
|
||||
// it is possible, that there is an active child session.
|
||||
// can't unload library in that case.
|
||||
if ((MFX_ERR_UNDEFINED_BEHAVIOR != mfxRes) && (hModule)) {
|
||||
// unload the library.
|
||||
if (!MFX::mfx_dll_free(hModule)) {
|
||||
mfxRes = MFX_ERR_UNDEFINED_BEHAVIOR;
|
||||
}
|
||||
hModule = (mfxModuleHandle)0;
|
||||
}
|
||||
|
||||
return mfxRes;
|
||||
|
||||
} // mfxStatus MFX_DISP_HANDLE::UnLoadSelectedDLL(void)
|
||||
|
||||
MFX_DISP_HANDLE_EX::MFX_DISP_HANDLE_EX(const mfxVersion requiredVersion)
|
||||
: MFX_DISP_HANDLE(requiredVersion),
|
||||
mediaAdapterType(MFX_MEDIA_UNKNOWN) {}
|
||||
|
||||
#if (defined(_WIN64) || defined(_WIN32)) && (MFX_VERSION >= 1031)
|
||||
static mfxStatus InitDummySession(mfxU32 adapter_n, MFXVideoSession &dummy_session) {
|
||||
mfxInitParam initPar;
|
||||
memset(&initPar, 0, sizeof(initPar));
|
||||
|
||||
initPar.Version.Major = 1;
|
||||
initPar.Version.Minor = 0;
|
||||
|
||||
switch (adapter_n) {
|
||||
case 0:
|
||||
initPar.Implementation = MFX_IMPL_HARDWARE;
|
||||
break;
|
||||
case 1:
|
||||
initPar.Implementation = MFX_IMPL_HARDWARE2;
|
||||
break;
|
||||
case 2:
|
||||
initPar.Implementation = MFX_IMPL_HARDWARE3;
|
||||
break;
|
||||
case 3:
|
||||
initPar.Implementation = MFX_IMPL_HARDWARE4;
|
||||
break;
|
||||
|
||||
default:
|
||||
// try searching on all display adapters
|
||||
initPar.Implementation = MFX_IMPL_HARDWARE_ANY;
|
||||
break;
|
||||
}
|
||||
|
||||
initPar.Implementation |= MFX_IMPL_VIA_D3D11;
|
||||
|
||||
return dummy_session.InitEx(initPar);
|
||||
}
|
||||
|
||||
static inline bool is_iGPU(const mfxAdapterInfo &adapter_info) {
|
||||
return adapter_info.Platform.MediaAdapterType == MFX_MEDIA_INTEGRATED;
|
||||
}
|
||||
|
||||
static inline bool is_dGPU(const mfxAdapterInfo &adapter_info) {
|
||||
return adapter_info.Platform.MediaAdapterType == MFX_MEDIA_DISCRETE;
|
||||
}
|
||||
|
||||
// This function implies that iGPU has higher priority
|
||||
static inline mfxI32 iGPU_priority(const void *ll, const void *rr) {
|
||||
const mfxAdapterInfo &l = *(reinterpret_cast<const mfxAdapterInfo *>(ll));
|
||||
const mfxAdapterInfo &r = *(reinterpret_cast<const mfxAdapterInfo *>(rr));
|
||||
|
||||
if ((is_iGPU(l) && is_iGPU(r)) || (is_dGPU(l) && is_dGPU(r)))
|
||||
return 0;
|
||||
|
||||
if (is_iGPU(l) && is_dGPU(r))
|
||||
return -1;
|
||||
|
||||
// The only combination left is_dGPU(l) && is_iGPU(r))
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void RearrangeInPriorityOrder(const mfxComponentInfo &info,
|
||||
MFX::MFXVector<mfxAdapterInfo> &vec) {
|
||||
(void)info;
|
||||
{
|
||||
// Move iGPU to top priority
|
||||
qsort(vec.data(), vec.size(), sizeof(mfxAdapterInfo), &iGPU_priority);
|
||||
}
|
||||
}
|
||||
|
||||
static mfxStatus PrepareAdaptersInfo(const mfxComponentInfo *info,
|
||||
MFX::MFXVector<mfxAdapterInfo> &vec,
|
||||
mfxAdaptersInfo &adapters) {
|
||||
// No suitable adapters on system to handle user's workload
|
||||
if (vec.empty()) {
|
||||
adapters.NumActual = 0;
|
||||
return MFX_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (info) {
|
||||
RearrangeInPriorityOrder(*info, vec);
|
||||
}
|
||||
|
||||
mfxU32 num_to_copy = (std::min)(mfxU32(vec.size()), adapters.NumAlloc);
|
||||
for (mfxU32 i = 0; i < num_to_copy; ++i) {
|
||||
adapters.Adapters[i] = vec[i];
|
||||
}
|
||||
|
||||
adapters.NumActual = num_to_copy;
|
||||
|
||||
if (vec.size() > adapters.NumAlloc) {
|
||||
return MFX_WRN_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
|
||||
static inline bool QueryAdapterInfo(mfxU32 adapter_n, mfxU32 &VendorID, mfxU32 &DeviceID) {
|
||||
MFX::DXVA2Device dxvaDevice;
|
||||
|
||||
if (!dxvaDevice.InitDXGI1(adapter_n))
|
||||
return false;
|
||||
|
||||
VendorID = dxvaDevice.GetVendorID();
|
||||
DeviceID = dxvaDevice.GetDeviceID();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline mfxU32 MakeVersion(mfxU16 major, mfxU16 minor) {
|
||||
return major * 1000 + minor;
|
||||
}
|
||||
|
||||
mfxStatus MFXQueryAdaptersDecode(mfxBitstream *bitstream,
|
||||
mfxU32 codec_id,
|
||||
mfxAdaptersInfo *adapters) {
|
||||
if (!adapters || !bitstream)
|
||||
return MFX_ERR_NULL_PTR;
|
||||
|
||||
MFX::MFXVector<mfxAdapterInfo> obtained_info;
|
||||
|
||||
mfxU32 adapter_n = 0, VendorID, DeviceID;
|
||||
|
||||
mfxComponentInfo input_info;
|
||||
memset(&input_info, 0, sizeof(input_info));
|
||||
input_info.Type = mfxComponentType::MFX_COMPONENT_DECODE;
|
||||
input_info.Requirements.mfx.CodecId = codec_id;
|
||||
|
||||
for (;;) {
|
||||
if (!QueryAdapterInfo(adapter_n, VendorID, DeviceID))
|
||||
break;
|
||||
|
||||
++adapter_n;
|
||||
|
||||
if (VendorID != INTEL_VENDOR_ID)
|
||||
continue;
|
||||
|
||||
// Check if requested capabilities are supported
|
||||
MFXVideoSession dummy_session;
|
||||
|
||||
mfxStatus sts = InitDummySession(adapter_n - 1, dummy_session);
|
||||
if (sts != MFX_ERR_NONE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mfxVideoParam stream_params, out;
|
||||
memset(&out, 0, sizeof(out));
|
||||
memset(&stream_params, 0, sizeof(stream_params));
|
||||
out.mfx.CodecId = stream_params.mfx.CodecId = codec_id;
|
||||
|
||||
sts = MFXVideoDECODE_DecodeHeader(dummy_session.operator mfxSession(),
|
||||
bitstream,
|
||||
&stream_params);
|
||||
|
||||
if (sts != MFX_ERR_NONE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
sts = MFXVideoDECODE_Query(dummy_session.operator mfxSession(), &stream_params, &out);
|
||||
|
||||
if (sts !=
|
||||
MFX_ERR_NONE) // skip MFX_ERR_UNSUPPORTED as well as MFX_WRN_INCOMPATIBLE_VIDEO_PARAM
|
||||
continue;
|
||||
|
||||
mfxAdapterInfo info;
|
||||
memset(&info, 0, sizeof(info));
|
||||
|
||||
//WA for initialization when application built w/ new API, but lib w/ old one.
|
||||
mfxVersion apiVersion;
|
||||
sts = dummy_session.QueryVersion(&apiVersion);
|
||||
if (sts != MFX_ERR_NONE)
|
||||
continue;
|
||||
|
||||
mfxU32 version = MakeVersion(apiVersion.Major, apiVersion.Minor);
|
||||
|
||||
if (version >= 1019) {
|
||||
sts = MFXVideoCORE_QueryPlatform(dummy_session.operator mfxSession(), &info.Platform);
|
||||
|
||||
if (sts != MFX_ERR_NONE) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// for API versions greater than 1.19 Device id is set inside QueryPlatform call
|
||||
info.Platform.DeviceId = static_cast<mfxU16>(DeviceID);
|
||||
}
|
||||
|
||||
info.Number = adapter_n - 1;
|
||||
|
||||
obtained_info.push_back(info);
|
||||
}
|
||||
|
||||
return PrepareAdaptersInfo(&input_info, obtained_info, *adapters);
|
||||
}
|
||||
|
||||
mfxStatus MFXQueryAdapters(mfxComponentInfo *input_info, mfxAdaptersInfo *adapters) {
|
||||
if (!adapters)
|
||||
return MFX_ERR_NULL_PTR;
|
||||
|
||||
MFX::MFXVector<mfxAdapterInfo> obtained_info;
|
||||
//obtained_info.reserve(adapters->NumAdaptersAlloc);
|
||||
|
||||
mfxU32 adapter_n = 0, VendorID, DeviceID;
|
||||
|
||||
for (;;) {
|
||||
if (!QueryAdapterInfo(adapter_n, VendorID, DeviceID))
|
||||
break;
|
||||
|
||||
++adapter_n;
|
||||
|
||||
if (VendorID != INTEL_VENDOR_ID)
|
||||
continue;
|
||||
|
||||
// Check if requested capabilities are supported
|
||||
MFXVideoSession dummy_session;
|
||||
|
||||
mfxStatus sts = InitDummySession(adapter_n - 1, dummy_session);
|
||||
if (sts != MFX_ERR_NONE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If input_info is NULL just return all Intel adapters and information about them
|
||||
if (input_info) {
|
||||
mfxVideoParam out;
|
||||
memset(&out, 0, sizeof(out));
|
||||
|
||||
switch (input_info->Type) {
|
||||
case mfxComponentType::MFX_COMPONENT_ENCODE: {
|
||||
out.mfx.CodecId = input_info->Requirements.mfx.CodecId;
|
||||
|
||||
sts = MFXVideoENCODE_Query(dummy_session.operator mfxSession(),
|
||||
&input_info->Requirements,
|
||||
&out);
|
||||
} break;
|
||||
case mfxComponentType::MFX_COMPONENT_DECODE: {
|
||||
out.mfx.CodecId = input_info->Requirements.mfx.CodecId;
|
||||
|
||||
sts = MFXVideoDECODE_Query(dummy_session.operator mfxSession(),
|
||||
&input_info->Requirements,
|
||||
&out);
|
||||
} break;
|
||||
case mfxComponentType::MFX_COMPONENT_VPP: {
|
||||
sts = MFXVideoVPP_Query(dummy_session.operator mfxSession(),
|
||||
&input_info->Requirements,
|
||||
&out);
|
||||
} break;
|
||||
default:
|
||||
sts = MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
if (sts !=
|
||||
MFX_ERR_NONE) // skip MFX_ERR_UNSUPPORTED as well as MFX_WRN_INCOMPATIBLE_VIDEO_PARAM
|
||||
continue;
|
||||
|
||||
mfxAdapterInfo info;
|
||||
memset(&info, 0, sizeof(info));
|
||||
|
||||
//WA for initialization when application built w/ new API, but lib w/ old one.
|
||||
mfxVersion apiVersion;
|
||||
sts = dummy_session.QueryVersion(&apiVersion);
|
||||
if (sts != MFX_ERR_NONE)
|
||||
continue;
|
||||
|
||||
mfxU32 version = MakeVersion(apiVersion.Major, apiVersion.Minor);
|
||||
|
||||
if (version >= 1019) {
|
||||
sts = MFXVideoCORE_QueryPlatform(dummy_session.operator mfxSession(), &info.Platform);
|
||||
|
||||
if (sts != MFX_ERR_NONE) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// for API versions greater than 1.19 Device id is set inside QueryPlatform call
|
||||
info.Platform.DeviceId = static_cast<mfxU16>(DeviceID);
|
||||
}
|
||||
|
||||
info.Number = adapter_n - 1;
|
||||
|
||||
obtained_info.push_back(info);
|
||||
}
|
||||
|
||||
return PrepareAdaptersInfo(input_info, obtained_info, *adapters);
|
||||
}
|
||||
|
||||
mfxStatus MFXQueryAdaptersNumber(mfxU32 *num_adapters) {
|
||||
if (!num_adapters)
|
||||
return MFX_ERR_NULL_PTR;
|
||||
|
||||
mfxU32 intel_adapter_count = 0, VendorID, DeviceID;
|
||||
|
||||
for (mfxU32 cur_adapter = 0;; ++cur_adapter) {
|
||||
if (!QueryAdapterInfo(cur_adapter, VendorID, DeviceID))
|
||||
break;
|
||||
|
||||
if (VendorID == INTEL_VENDOR_ID)
|
||||
++intel_adapter_count;
|
||||
}
|
||||
|
||||
*num_adapters = intel_adapter_count;
|
||||
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
|
||||
#endif // (defined(_WIN64) || defined(_WIN32)) && (MFX_VERSION >= 1031)
|
||||
@@ -0,0 +1,218 @@
|
||||
/*############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#ifndef LIBVPL_SRC_WINDOWS_MFX_DISPATCHER_H_
|
||||
#define LIBVPL_SRC_WINDOWS_MFX_DISPATCHER_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "vpl/mfxdispatcher.h"
|
||||
#include "vpl/mfxvideo.h"
|
||||
|
||||
#include "src/windows/mfx_dispatcher_defs.h"
|
||||
|
||||
// internal implementation of mfxConfigInterface
|
||||
#include "src/mfx_config_interface/mfx_config_interface.h"
|
||||
|
||||
#define INTEL_VENDOR_ID 0x8086
|
||||
|
||||
mfxStatus MFXQueryVersion(mfxSession session, mfxVersion *version);
|
||||
|
||||
enum {
|
||||
// to avoid code changing versions are just inherited
|
||||
// from the API header file.
|
||||
DEFAULT_API_VERSION_MAJOR = MFX_VERSION_MAJOR,
|
||||
DEFAULT_API_VERSION_MINOR = MFX_VERSION_MINOR
|
||||
};
|
||||
|
||||
enum { VPL_MINIMUM_VERSION_MAJOR = 2, VPL_MINIMUM_VERSION_MINOR = 0 };
|
||||
|
||||
//
|
||||
// declare functions' integer identifiers.
|
||||
//
|
||||
|
||||
#undef FUNCTION
|
||||
#define FUNCTION(return_value, func_name, formal_param_list, actual_param_list) e##func_name,
|
||||
|
||||
enum eFunc {
|
||||
eMFXInit,
|
||||
eMFXClose,
|
||||
eMFXQueryIMPL,
|
||||
eMFXQueryVersion,
|
||||
eMFXVideoCORE_GetHandle,
|
||||
eMFXJoinSession,
|
||||
eMFXDisjoinSession,
|
||||
eMFXCloneSession,
|
||||
eMFXSetPriority,
|
||||
eMFXGetPriority,
|
||||
eMFXInitEx,
|
||||
#include "src/windows/mfx_exposed_functions_list.h"
|
||||
eVideoFuncTotal
|
||||
};
|
||||
|
||||
enum ePluginFunc {
|
||||
eMFXVideoUSER_Load,
|
||||
eMFXVideoUSER_LoadByPath,
|
||||
eMFXVideoUSER_UnLoad,
|
||||
eMFXAudioUSER_Load,
|
||||
eMFXAudioUSER_UnLoad,
|
||||
ePluginFuncTotal
|
||||
};
|
||||
|
||||
enum eVideoFunc2 {
|
||||
// 2.0
|
||||
eMFXQueryImplsDescription,
|
||||
eMFXReleaseImplDescription,
|
||||
eMFXMemory_GetSurfaceForVPP,
|
||||
eMFXMemory_GetSurfaceForEncode,
|
||||
eMFXMemory_GetSurfaceForDecode,
|
||||
eMFXInitialize,
|
||||
|
||||
// 2.1
|
||||
eMFXMemory_GetSurfaceForVPPOut,
|
||||
eMFXVideoDECODE_VPP_Init,
|
||||
eMFXVideoDECODE_VPP_DecodeFrameAsync,
|
||||
eMFXVideoDECODE_VPP_Reset,
|
||||
eMFXVideoDECODE_VPP_GetChannelParam,
|
||||
eMFXVideoDECODE_VPP_Close,
|
||||
eMFXVideoVPP_ProcessFrameAsync,
|
||||
|
||||
eVideoFunc2Total
|
||||
};
|
||||
|
||||
// declare max buffer length for regsitry key name
|
||||
enum { MFX_MAX_REGISTRY_KEY_NAME = 256 };
|
||||
|
||||
// declare the maximum DLL path
|
||||
enum { MFX_MAX_DLL_PATH = 1024 };
|
||||
|
||||
// declare library's implementation types
|
||||
enum eMfxImplType {
|
||||
MFX_LIB_HARDWARE = 0,
|
||||
MFX_LIB_SOFTWARE = 1,
|
||||
MFX_LIB_PSEUDO = 2,
|
||||
|
||||
MFX_LIB_IMPL_TYPES
|
||||
};
|
||||
|
||||
// declare dispatcher's version
|
||||
enum { MFX_DISPATCHER_VERSION_MAJOR = 1, MFX_DISPATCHER_VERSION_MINOR = 3 };
|
||||
|
||||
struct _mfxSession {
|
||||
// A real handle from MFX engine passed to a called function
|
||||
mfxSession session;
|
||||
|
||||
mfxFunctionPointer callTable[eVideoFuncTotal]; // NOLINT(runtime/arrays)
|
||||
mfxFunctionPointer callPlugInsTable[ePluginFuncTotal]; // NOLINT(runtime/arrays)
|
||||
mfxFunctionPointer callVideoTable2[eVideoFunc2Total]; // NOLINT(runtime/arrays)
|
||||
|
||||
// Current library's implementation (exact implementation)
|
||||
mfxIMPL impl;
|
||||
};
|
||||
|
||||
// declare a dispatcher's handle
|
||||
struct MFX_DISP_HANDLE : public _mfxSession {
|
||||
// Default constructor
|
||||
explicit MFX_DISP_HANDLE(const mfxVersion requiredVersion);
|
||||
// Destructor
|
||||
~MFX_DISP_HANDLE(void);
|
||||
|
||||
// Load the library's module
|
||||
mfxStatus LoadSelectedDLL(const wchar_t *pPath,
|
||||
eMfxImplType implType,
|
||||
mfxIMPL impl,
|
||||
mfxIMPL implInterface,
|
||||
mfxInitParam &par,
|
||||
mfxInitializationParam &vplParam,
|
||||
bool bCloneSession = false);
|
||||
// Unload the library's module
|
||||
mfxStatus UnLoadSelectedDLL(void);
|
||||
|
||||
// Close the handle
|
||||
mfxStatus Close(void);
|
||||
|
||||
// NOTE: changing order of struct's members can make different version of
|
||||
// dispatchers incompatible. Think of different modules (e.g. MFT filters)
|
||||
// within a single application.
|
||||
//
|
||||
// FOR THIS IMPLEMENTATION: order should not matter. Dispatcher is now built
|
||||
// as a DLL and installed in %WINDIR%\system32. Thus all applications on the
|
||||
// system should use same dispatcher. Even if an app loads a different
|
||||
// dispatcher version, initializing an mfxSession with one library then
|
||||
// using it in a different library is not a supported use case.
|
||||
|
||||
// Library's implementation type (hardware or software)
|
||||
eMfxImplType implType;
|
||||
// Current library's VIA interface
|
||||
mfxIMPL implInterface;
|
||||
// Dispatcher's version. If version is 1.1 or lower, then old dispatcher's
|
||||
// architecture is used. Otherwise it means current dispatcher's version.
|
||||
mfxVersion dispVersion;
|
||||
// Required API version of session initialized
|
||||
const mfxVersion apiVersion;
|
||||
// Actual library API version
|
||||
mfxVersion actualApiVersion;
|
||||
// Status of loaded dll
|
||||
mfxStatus loadStatus;
|
||||
// Resgistry subkey name for windows version
|
||||
wchar_t subkeyName[MFX_MAX_REGISTRY_KEY_NAME];
|
||||
// Storage ID for windows version
|
||||
int storageID;
|
||||
|
||||
// Library's module handle
|
||||
mfxModuleHandle hModule;
|
||||
|
||||
private:
|
||||
// Declare assignment operator and copy constructor to prevent occasional assignment
|
||||
MFX_DISP_HANDLE(const MFX_DISP_HANDLE &);
|
||||
MFX_DISP_HANDLE &operator=(const MFX_DISP_HANDLE &);
|
||||
};
|
||||
|
||||
// This struct extends MFX_DISP_HANDLE, we cannot extend MFX_DISP_HANDLE itself due to possible compatibility issues
|
||||
// This struct was added in dispatcher version 1.3
|
||||
// Check dispatcher handle's version when you cast session struct which came from outside of MSDK API function to this
|
||||
struct MFX_DISP_HANDLE_EX : public MFX_DISP_HANDLE {
|
||||
explicit MFX_DISP_HANDLE_EX(const mfxVersion requiredVersion);
|
||||
|
||||
mfxU16 mediaAdapterType;
|
||||
mfxU16 reserved[10];
|
||||
};
|
||||
|
||||
// declare comparison operator
|
||||
inline bool operator==(const mfxVersion &one, const mfxVersion &two) {
|
||||
return (one.Version == two.Version);
|
||||
}
|
||||
|
||||
inline bool operator<(const mfxVersion &one, const mfxVersion &two) {
|
||||
return (one.Major < two.Major) || ((one.Major == two.Major) && (one.Minor < two.Minor));
|
||||
}
|
||||
|
||||
inline bool operator<=(const mfxVersion &one, const mfxVersion &two) {
|
||||
return (one == two) || (one < two);
|
||||
}
|
||||
|
||||
inline bool operator==(mfxGUID const &l, mfxGUID const &r) {
|
||||
return std::equal(l.Data, l.Data + 16, r.Data);
|
||||
}
|
||||
|
||||
//
|
||||
// declare a table with functions descriptions
|
||||
//
|
||||
|
||||
typedef struct FUNCTION_DESCRIPTION {
|
||||
// Literal function's name
|
||||
const char *pName;
|
||||
// API version when function appeared first time
|
||||
mfxVersion apiVersion;
|
||||
} FUNCTION_DESCRIPTION;
|
||||
|
||||
extern const FUNCTION_DESCRIPTION APIFunc[eVideoFuncTotal];
|
||||
|
||||
extern const FUNCTION_DESCRIPTION APIVideoFunc2[eVideoFunc2Total];
|
||||
|
||||
#endif // LIBVPL_SRC_WINDOWS_MFX_DISPATCHER_H_
|
||||
@@ -0,0 +1,37 @@
|
||||
/*############################################################################
|
||||
# Copyright (C) Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
############################################################################*/
|
||||
|
||||
#pragma once
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include "vpl/mfxdefs.h"
|
||||
|
||||
#if defined(MFX_DISPATCHER_LOG)
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
#define MAX_PLUGIN_PATH 4096
|
||||
#define MAX_PLUGIN_NAME 4096
|
||||
|
||||
#if _MSC_VER < 1400
|
||||
#define wcscpy_s(to, to_size, from) \
|
||||
(void)(to_size); \
|
||||
wcscpy(to, from)
|
||||
#define wcscat_s(to, to_size, from) \
|
||||
(void)(to_size); \
|
||||
wcscat(to, from)
|
||||
#endif
|
||||
|
||||
// declare library module's handle
|
||||
typedef void *mfxModuleHandle;
|
||||
|
||||
typedef void(MFX_CDECL *mfxFunctionPointer)(void);
|
||||
|
||||
// Tracer uses lib loading from Program Files logic (via Dispatch reg key) to make dispatcher load tracer dll.
|
||||
// With DriverStore loading put at 1st place, dispatcher loads real lib before it finds tracer dll.
|
||||
// This workaround explicitly checks tracer presence in Dispatch reg key and loads tracer dll before the search for lib in all other places.
|
||||
#define MFX_TRACER_WA_FOR_DS 1
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user