mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-01-29 09:32:39 +00:00
AMF: add missing encoder tunables (#902)
This commit is contained in:
parent
ae12424279
commit
55a225d21c
@ -1081,6 +1081,68 @@ amd_rc
|
||||
|
||||
amd_rc = vbr_latency
|
||||
|
||||
amd_usage
|
||||
^^^^^^^^^
|
||||
|
||||
**Description**
|
||||
The encoder usage profile, used to balance latency with encoding quality.
|
||||
|
||||
.. Note:: This option only applies when using amdvce `encoder`_.
|
||||
|
||||
**Choices**
|
||||
|
||||
.. table::
|
||||
:widths: auto
|
||||
|
||||
=============== ===========
|
||||
Value Description
|
||||
=============== ===========
|
||||
transcoding transcoding (slowest)
|
||||
webcam webcam (slow)
|
||||
lowlatency low latency (fast)
|
||||
ultralowlatency ultra low latency (fastest)
|
||||
=============== ===========
|
||||
|
||||
**Default**
|
||||
``ultralowlatency``
|
||||
|
||||
**Example**
|
||||
.. code-block:: text
|
||||
|
||||
amd_usage = ultralowlatency
|
||||
|
||||
amd_preanalysis
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
**Description**
|
||||
Preanalysis can increase encoding quality at the cost of latency.
|
||||
|
||||
.. Note:: This option only applies when using amdvce `encoder`_.
|
||||
|
||||
**Default**
|
||||
``disabled``
|
||||
|
||||
**Example**
|
||||
.. code-block:: text
|
||||
|
||||
amd_preanalysis = disabled
|
||||
|
||||
amd_vbaq
|
||||
^^^^^^^^
|
||||
|
||||
**Description**
|
||||
Variance Based Adaptive Quantization (VBAQ) can increase subjective visual quality.
|
||||
|
||||
.. Note:: This option only applies when using amdvce `encoder`_.
|
||||
|
||||
**Default**
|
||||
``enabled``
|
||||
|
||||
**Example**
|
||||
.. code-block:: text
|
||||
|
||||
amd_vbaq = enabled
|
||||
|
||||
amd_coder
|
||||
^^^^^^^^^
|
||||
|
||||
|
@ -130,6 +130,14 @@ namespace amd {
|
||||
#define AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_CBR 1
|
||||
#define AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_PEAK_CONSTRAINED_VBR 2
|
||||
#define AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_LATENCY_CONSTRAINED_VBR 3
|
||||
#define AMF_VIDEO_ENCODER_HEVC_USAGE_TRANSCONDING 0
|
||||
#define AMF_VIDEO_ENCODER_HEVC_USAGE_ULTRA_LOW_LATENCY 1
|
||||
#define AMF_VIDEO_ENCODER_HEVC_USAGE_LOW_LATENCY 2
|
||||
#define AMF_VIDEO_ENCODER_HEVC_USAGE_WEBCAM 3
|
||||
#define AMF_VIDEO_ENCODER_USAGE_TRANSCONDING 0
|
||||
#define AMF_VIDEO_ENCODER_USAGE_ULTRA_LOW_LATENCY 1
|
||||
#define AMF_VIDEO_ENCODER_USAGE_LOW_LATENCY 2
|
||||
#define AMF_VIDEO_ENCODER_USAGE_WEBCAM 3
|
||||
#define AMF_VIDEO_ENCODER_UNDEFINED 0
|
||||
#define AMF_VIDEO_ENCODER_CABAC 1
|
||||
#define AMF_VIDEO_ENCODER_CALV 2
|
||||
@ -164,6 +172,20 @@ enum class rc_h264_e : int {
|
||||
cbr = AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_CBR
|
||||
};
|
||||
|
||||
enum class usage_hevc_e : int {
|
||||
transcoding = AMF_VIDEO_ENCODER_HEVC_USAGE_TRANSCONDING,
|
||||
webcam = AMF_VIDEO_ENCODER_HEVC_USAGE_WEBCAM,
|
||||
lowlatency = AMF_VIDEO_ENCODER_HEVC_USAGE_LOW_LATENCY,
|
||||
ultralowlatency = AMF_VIDEO_ENCODER_HEVC_USAGE_ULTRA_LOW_LATENCY
|
||||
};
|
||||
|
||||
enum class usage_h264_e : int {
|
||||
transcoding = AMF_VIDEO_ENCODER_USAGE_TRANSCONDING,
|
||||
webcam = AMF_VIDEO_ENCODER_USAGE_WEBCAM,
|
||||
lowlatency = AMF_VIDEO_ENCODER_USAGE_LOW_LATENCY,
|
||||
ultralowlatency = AMF_VIDEO_ENCODER_USAGE_ULTRA_LOW_LATENCY
|
||||
};
|
||||
|
||||
enum coder_e : int {
|
||||
_auto = AMF_VIDEO_ENCODER_UNDEFINED,
|
||||
cabac = AMF_VIDEO_ENCODER_CABAC,
|
||||
@ -191,6 +213,17 @@ std::optional<int> rc_from_view(const std::string_view &rc, int codec) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<int> usage_from_view(const std::string_view &rc, int codec) {
|
||||
#define _CONVERT_(x) \
|
||||
if(rc == #x##sv) return codec == 0 ? (int)usage_hevc_e::x : (int)usage_h264_e::x
|
||||
_CONVERT_(transcoding);
|
||||
_CONVERT_(webcam);
|
||||
_CONVERT_(lowlatency);
|
||||
_CONVERT_(ultralowlatency);
|
||||
#undef _CONVERT_
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
int coder_from_view(const std::string_view &coder) {
|
||||
if(coder == "auto"sv) return _auto;
|
||||
if(coder == "cabac"sv || coder == "ac"sv) return cabac;
|
||||
@ -300,12 +333,16 @@ video_t video {
|
||||
}, // qsv
|
||||
|
||||
{
|
||||
(int)amd::quality_h264_e::balanced, // quality (h264)
|
||||
(int)amd::quality_hevc_e::balanced, // quality (hevc)
|
||||
(int)amd::rc_h264_e::vbr_latency, // rate control (h264)
|
||||
(int)amd::rc_hevc_e::vbr_latency, // rate control (hevc)
|
||||
(int)amd::coder_e::_auto, // coder
|
||||
}, // amd
|
||||
(int)amd::quality_h264_e::balanced, // quality (h264)
|
||||
(int)amd::quality_hevc_e::balanced, // quality (hevc)
|
||||
(int)amd::rc_h264_e::vbr_latency, // rate control (h264)
|
||||
(int)amd::rc_hevc_e::vbr_latency, // rate control (hevc)
|
||||
(int)amd::usage_h264_e::ultralowlatency, // usage (h264)
|
||||
(int)amd::usage_hevc_e::ultralowlatency, // usage (hevc)
|
||||
0, // preanalysis
|
||||
1, // vbaq
|
||||
(int)amd::coder_e::_auto, // coder
|
||||
}, // amd
|
||||
|
||||
{
|
||||
0,
|
||||
@ -826,6 +863,16 @@ void apply_config(std::unordered_map<std::string, std::string> &&vars) {
|
||||
video.amd.rc_hevc = amd::rc_from_view(rc, 0);
|
||||
}
|
||||
|
||||
std::string usage;
|
||||
string_f(vars, "amd_usage", usage);
|
||||
if(!usage.empty()) {
|
||||
video.amd.usage_h264 = amd::usage_from_view(rc, 1);
|
||||
video.amd.usage_hevc = amd::usage_from_view(rc, 0);
|
||||
}
|
||||
|
||||
bool_f(vars, "amd_preanalysis", (bool &)video.amd.preanalysis);
|
||||
bool_f(vars, "amd_vbaq", (bool &)video.amd.vbaq);
|
||||
|
||||
int_f(vars, "vt_coder", video.vt.coder, vt::coder_from_view);
|
||||
int_f(vars, "vt_software", video.vt.allow_sw, vt::allow_software_from_view);
|
||||
int_f(vars, "vt_software", video.vt.require_sw, vt::force_software_from_view);
|
||||
|
@ -38,6 +38,10 @@ struct video_t {
|
||||
std::optional<int> quality_hevc;
|
||||
std::optional<int> rc_h264;
|
||||
std::optional<int> rc_hevc;
|
||||
std::optional<int> usage_h264;
|
||||
std::optional<int> usage_hevc;
|
||||
std::optional<int> preanalysis;
|
||||
std::optional<int> vbaq;
|
||||
int coder;
|
||||
} amd;
|
||||
|
||||
|
@ -539,15 +539,16 @@ static encoder_t amdvce {
|
||||
{
|
||||
// Common options
|
||||
{
|
||||
{ "enforce_hrd"s, true },
|
||||
{ "filler_data"s, true },
|
||||
{ "gops_per_idr"s, 1 },
|
||||
{ "header_insertion_mode"s, "idr"s },
|
||||
{ "preanalysis"s, &config::video.amd.preanalysis },
|
||||
{ "qmax"s, 51 },
|
||||
{ "qmin"s, 0 },
|
||||
{ "quality"s, &config::video.amd.quality_hevc },
|
||||
{ "rc"s, &config::video.amd.rc_hevc },
|
||||
{ "usage"s, "ultralowlatency"s },
|
||||
{ "vbaq"s, true },
|
||||
{ "usage"s, &config::video.amd.usage_hevc },
|
||||
{ "vbaq"s, &config::video.amd.vbaq },
|
||||
},
|
||||
{}, // SDR-specific options
|
||||
{}, // HDR-specific options
|
||||
@ -557,14 +558,15 @@ static encoder_t amdvce {
|
||||
{
|
||||
// Common options
|
||||
{
|
||||
{ "enforce_hrd"s, true },
|
||||
{ "filler_data"s, true },
|
||||
{ "log_to_dbg"s, "1"s },
|
||||
{ "preanalysis"s, &config::video.amd.preanalysis },
|
||||
{ "qmax"s, 51 },
|
||||
{ "qmin"s, 0 },
|
||||
{ "quality"s, &config::video.amd.quality_h264 },
|
||||
{ "rc"s, &config::video.amd.rc_h264 },
|
||||
{ "usage"s, "ultralowlatency"s },
|
||||
{ "vbaq"s, true },
|
||||
{ "usage"s, &config::video.amd.usage_h264 },
|
||||
{ "vbaq"s, &config::video.amd.vbaq },
|
||||
},
|
||||
{}, // SDR-specific options
|
||||
{}, // HDR-specific options
|
||||
|
@ -765,6 +765,29 @@
|
||||
<option value="cbr">cbr -- constant bitrate</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="amd_usage" class="form-label">AMF Usage</label>
|
||||
<select id="amd_usage" class="form-select" v-model="config.amd_usage">
|
||||
<option value="transcoding">transcoding -- transcoding (slowest)</option>
|
||||
<option value="webcam">webcam -- webcam (slow)</option>
|
||||
<option value="lowlatency">lowlatency - low latency (fast)</option>
|
||||
<option value="ultralowlatency">ultralowlatency - ultra low latency (fastest)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="amd_preanalysis" class="form-label">AMF Preanalysis</label>
|
||||
<select id="amd_preanalysis" class="form-select" v-model="config.amd_preanalysis">
|
||||
<option value="enabled">enabled</option>
|
||||
<option value="disabled">disabled (default)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="amd_vbaq" class="form-label">AMF Variance Based Adaptive Quantization (VBAQ)</label>
|
||||
<select id="amd_vbaq" class="form-select" v-model="config.amd_vbaq">
|
||||
<option value="enabled">enabled (default)</option>
|
||||
<option value="disabled">disabled</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="amd_coder" class="form-label">AMF Coder (H264)</label>
|
||||
<select id="amd_coder" class="form-select" v-model="config.amd_coder">
|
||||
@ -938,8 +961,11 @@
|
||||
this.config.qsv_preset = this.config.qsv_preset || "medium";
|
||||
this.config.qsv_coder = this.config.qsv_coder || "auto";
|
||||
this.config.amd_coder = this.config.amd_coder || "auto"
|
||||
this.config.amd_preanalysis = this.config.amd_preanalysis || "disabled";
|
||||
this.config.amd_quality = this.config.amd_quality || "balanced";
|
||||
this.config.amd_rc = this.config.amd_rc || "vbr_latency";
|
||||
this.config.amd_usage = this.config.amd_usage || "ultralowlatency";
|
||||
this.config.amd_vbaq = this.config.amd_vbaq || "enabled";
|
||||
this.config.vt_coder = this.config.vt_coder || "auto";
|
||||
this.config.vt_software = this.config.vt_software || "auto";
|
||||
this.config.vt_realtime = this.config.vt_realtime || "enabled";
|
||||
|
Loading…
x
Reference in New Issue
Block a user