Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,20 @@ jobs:
cmake --build build --target all -j "$(nproc)"
echo "::remove-matcher owner=gcc::"

- name: Test native AMF lifecycle behavior
shell: msys2 {0}
run: |
set -euo pipefail
c++ \
-std=gnu++23 \
-O2 \
-pthread \
-DSUNSHINE_AMF_LIFECYCLE_STANDALONE \
-I. \
tests/unit/platform/windows/test_native_amf_review.cpp \
-o build/native-amf-lifecycle-test.exe
./build/native-amf-lifecycle-test.exe

- name: Install cv2pdb
if: startsWith(github.ref, 'refs/tags/') || inputs.publish_symbols || inputs.upload_symbols_artifact
shell: pwsh
Expand Down
8 changes: 8 additions & 0 deletions cmake/compile_definitions/windows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,14 @@ set(PLATFORM_TARGET_FILES
"${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/include/ViGEm/Common.h"
"${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/include/ViGEm/Util.h"
"${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/include/ViGEm/km/BusShared.h"
# Native AMD AMF encoder (D3D11). AMF SDK headers are provided by the
# bundled FFmpeg build-deps (include/AMF), so no extra dependency is
# required - the runtime (amfrt64.dll) is loaded dynamically.
"${CMAKE_SOURCE_DIR}/src/amf/amf_config.h"
"${CMAKE_SOURCE_DIR}/src/amf/amf_encoded_frame.h"
"${CMAKE_SOURCE_DIR}/src/amf/amf_encoder.h"
"${CMAKE_SOURCE_DIR}/src/amf/amf_d3d11.h"
"${CMAKE_SOURCE_DIR}/src/amf/amf_d3d11.cpp"
${NVPREFS_FILES})

set(OPENSSL_LIBRARIES
Expand Down
168 changes: 161 additions & 7 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2647,7 +2647,7 @@ editing the `conf` file in a text editor. Use the examples as reference.
@endcode</td>
</tr>
<tr>
<td rowspan="5">Choices</td>
<td rowspan="7">Choices</td>
<td>nvenc</td>
<td>For NVIDIA graphics cards</td>
</tr>
Expand All @@ -2657,7 +2657,13 @@ editing the `conf` file in a text editor. Use the examples as reference.
</tr>
<tr>
<td>amdvce</td>
<td>For AMD graphics cards</td>
<td>For AMD graphics cards (native AMF encoder)</td>
</tr>
<tr>
<td>amdvce_legacy</td>
<td>Explicit rollback to the FFmpeg-based AMD AMF encoder. Never selected automatically —
automatic probing and `amdvce` fail closed instead of silently falling back.
@note{Applies to Windows only.}</td>
</tr>
<tr>
<td>vaapi</td>
Expand Down Expand Up @@ -3420,7 +3426,7 @@ version is written to the log on every AMD HDR HEVC attempt (search for @code{AM
@endcode</td>
</tr>
<tr>
<td rowspan="4">Choices</td>
<td rowspan="7">Choices</td>
<td>cqp</td>
<td>constant qp mode</td>
</tr>
Expand All @@ -3436,6 +3442,48 @@ version is written to the log on every AMD HDR HEVC attempt (search for @code{AM
<td>vbr_peak</td>
<td>variable bitrate, peak constrained</td>
</tr>
<tr>
<td>qvbr</td>
<td>quality-defined variable bitrate (see amd_qvbr_quality_level)</td>
</tr>
<tr>
<td>hqvbr</td>
<td>high quality variable bitrate</td>
</tr>
<tr>
<td>hqcbr</td>
<td>high quality constant bitrate</td>
</tr>
</table>

### amd_qvbr_quality_level

<table>
<tr>
<td>Description</td>
<td colspan="2">
The target quality level used by the `qvbr` rate control method, where 1 is the lowest quality and 51
is the highest. Higher values spend more bits to preserve quality.
@note{This option only applies to AMD [encoders](#encoder) with `amd_rc` set to `qvbr`. Native `amdvce` automatically enables PreAnalysis with a one-frame low-latency lookahead for `qvbr`, `hqvbr`, and `hqcbr`.}
@note{Leave this at `0` to keep the encoder default.}
</td>
</tr>
<tr>
<td>Default</td>
<td colspan="2">@code{}
0
@endcode</td>
</tr>
<tr>
<td>Range</td>
<td colspan="2">1-51 (0 to use the encoder default)</td>
</tr>
<tr>
<td>Example</td>
<td colspan="2">@code{}
amd_qvbr_quality_level = 18
@endcode</td>
</tr>
</table>

### amd_enforce_hrd
Expand Down Expand Up @@ -3470,6 +3518,7 @@ version is written to the log on every AMD HDR HEVC attempt (search for @code{AM
<td>Description</td>
<td colspan="2">
The quality profile controls the tradeoff between speed and quality of encoding.
`auto` leaves the quality property unset so the selected AMF usage preset can choose it.
@note{This option only applies when using amdvce [encoder](#encoder).}
</td>
</tr>
Expand All @@ -3486,7 +3535,11 @@ version is written to the log on every AMD HDR HEVC attempt (search for @code{AM
@endcode</td>
</tr>
<tr>
<td rowspan="3">Choices</td>
<td rowspan="4">Choices</td>
<td>auto</td>
<td>follow the selected AMF usage preset</td>
</tr>
<tr>
<td>speed</td>
<td>prefer speed</td>
</tr>
Expand All @@ -3506,8 +3559,9 @@ version is written to the log on every AMD HDR HEVC attempt (search for @code{AM
<tr>
<td>Description</td>
<td colspan="2">
Preanalysis can increase encoding quality at the cost of latency.
@note{This option only applies when using amdvce [encoder](#encoder).}
Preanalysis can increase encoding quality at the cost of latency. Native `amdvce` uses a one-frame
low-latency lookahead; it is enabled automatically by `qvbr`, `hqvbr`, and `hqcbr`. The setting is
also forwarded to `amdvce_legacy`.
</td>
</tr>
<tr>
Expand All @@ -3532,6 +3586,8 @@ version is written to the log on every AMD HDR HEVC attempt (search for @code{AM
<td colspan="2">
Variance Based Adaptive Quantization (VBAQ) can increase subjective visual quality by prioritizing
allocation of more bits to smooth areas compared to more textured areas.
`auto` leaves the property unset so the selected AMF usage preset can choose it. VBAQ is enabled
by default.
@note{This option only applies when using amdvce [encoder](#encoder).}
</td>
</tr>
Expand All @@ -3547,6 +3603,19 @@ version is written to the log on every AMD HDR HEVC attempt (search for @code{AM
amd_vbaq = enabled
@endcode</td>
</tr>
<tr>
<td rowspan="3">Choices</td>
<td>auto</td>
<td>follow the selected AMF usage preset</td>
</tr>
<tr>
<td>enabled</td>
<td>enable VBAQ</td>
</tr>
<tr>
<td>disabled</td>
<td>disable VBAQ</td>
</tr>
</table>

### amd_coder
Expand Down Expand Up @@ -3575,7 +3644,7 @@ version is written to the log on every AMD HDR HEVC attempt (search for @code{AM
<tr>
<td rowspan="3">Choices</td>
<td>auto</td>
<td>let ffmpeg decide</td>
<td>leave the encoder default</td>
</tr>
<tr>
<td>cabac</td>
Expand All @@ -3587,6 +3656,91 @@ version is written to the log on every AMD HDR HEVC attempt (search for @code{AM
</tr>
</table>

### amd_av1_screen_content

<table>
<tr>
<td>Description</td>
<td colspan="2">
Enable AV1 screen-content coding tools, which can improve efficiency and text/UI clarity for desktop and
screen-heavy content.
@note{AV1 only. This option only applies to the native amdvce [encoder](#encoder) (not amdvce_legacy).}
@note{Leave at `auto` to use the driver default.}
</td>
</tr>
<tr>
<td>Default</td>
<td colspan="2">@code{}
auto
@endcode</td>
</tr>
<tr>
<td>Example</td>
<td colspan="2">@code{}
amd_av1_screen_content = enabled
@endcode</td>
</tr>
<tr>
<td rowspan="3">Choices</td>
<td>auto</td>
<td>leave the driver default</td>
</tr>
<tr>
<td>enabled</td>
<td>force screen-content tools on</td>
</tr>
<tr>
<td>disabled</td>
<td>force screen-content tools off</td>
</tr>
</table>

### amd_av1_latency_mode

<table>
<tr>
<td>Description</td>
<td colspan="2">
AV1 encoding-latency tier. Lower tiers finish each frame faster at the cost of higher power draw.
@note{AV1 only. This option only applies to the native amdvce [encoder](#encoder) (not amdvce_legacy).}
@note{Leave at `auto` to use the driver default.}
</td>
</tr>
<tr>
<td>Default</td>
<td colspan="2">@code{}
auto
@endcode</td>
</tr>
<tr>
<td>Example</td>
<td colspan="2">@code{}
amd_av1_latency_mode = lowest
@endcode</td>
</tr>
<tr>
<td rowspan="5">Choices</td>
<td>auto</td>
<td>leave the driver default</td>
</tr>
<tr>
<td>none</td>
<td>balance latency and power</td>
</tr>
<tr>
<td>power_saving</td>
<td>real-time with lower power</td>
</tr>
<tr>
<td>realtime</td>
<td>real-time</td>
</tr>
<tr>
<td>lowest</td>
<td>lowest latency (highest power)</td>
</tr>
</table>

## VideoToolbox Encoder

### vt_coder
Expand Down
Loading