obs-qsv11: Add latency mode to QSV settings
Simplify UI options by combining LookAhead Depth and Async Depth into latency mode option. Ultra-low, low, and normal will set these two encode parameters accordingly.master
parent
f23d04b67f
commit
8e0e2dd3e9
|
@ -78,7 +78,8 @@ static const char *const qsv_usage_names[] = {"quality", "balanced", "speed",
|
|||
"veryslow", "slower", "slow",
|
||||
"medium", "fast", "faster",
|
||||
"veryfast", 0};
|
||||
|
||||
static const char *const qsv_latency_names[] = {"ultra-low", "low", "normal",
|
||||
0};
|
||||
typedef struct qsv_t qsv_t;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -4,8 +4,8 @@ MaxBitrate="Max Bitrate"
|
|||
RateControl="Rate Control"
|
||||
KeyframeIntervalSec="Keyframe Interval (seconds, 0=auto)"
|
||||
Profile="Profile"
|
||||
AsyncDepth="Async Depth"
|
||||
Accuracy="Accuracy"
|
||||
Convergence="Convergence"
|
||||
ICQQuality="ICQ Quality"
|
||||
LookAheadDepth="Lookahead Depth"
|
||||
Latency="Latency"
|
||||
Latency.ToolTip="There is trade-off between latency and quality.\nIf your case prefers on quality, please select 'normal' mode, which may get > 2s end-to-end latency.\nIf your case requires < 500ms end-to-end latency, please select 'ultra-low' mode."
|
||||
|
|
|
@ -160,6 +160,7 @@ static void obs_qsv_defaults(obs_data_t *settings)
|
|||
obs_data_set_default_int(settings, "la_depth", 15);
|
||||
|
||||
obs_data_set_default_int(settings, "keyint_sec", 3);
|
||||
obs_data_set_default_string(settings, "latency", "normal");
|
||||
obs_data_set_default_int(settings, "bframes", 3);
|
||||
obs_data_set_default_bool(settings, "mbbrc", true);
|
||||
}
|
||||
|
@ -176,12 +177,11 @@ static inline void add_strings(obs_property_t *list, const char *const *strings)
|
|||
#define TEXT_TARGET_BITRATE obs_module_text("Bitrate")
|
||||
#define TEXT_MAX_BITRATE obs_module_text("MaxBitrate")
|
||||
#define TEXT_PROFILE obs_module_text("Profile")
|
||||
#define TEXT_ASYNC_DEPTH obs_module_text("AsyncDepth")
|
||||
#define TEXT_LATENCY obs_module_text("Latency")
|
||||
#define TEXT_RATE_CONTROL obs_module_text("RateControl")
|
||||
#define TEXT_ACCURACY obs_module_text("Accuracy")
|
||||
#define TEXT_CONVERGENCE obs_module_text("Convergence")
|
||||
#define TEXT_ICQ_QUALITY obs_module_text("ICQQuality")
|
||||
#define TEXT_LA_DEPTH obs_module_text("LookAheadDepth")
|
||||
#define TEXT_KEYINT_SEC obs_module_text("KeyframeIntervalSec")
|
||||
#define TEXT_BFRAMES obs_module_text("B Frames")
|
||||
#define TEXT_MBBRC obs_module_text("Content Adaptive Quantization")
|
||||
|
@ -191,6 +191,42 @@ static inline bool is_skl_or_greater_platform()
|
|||
enum qsv_cpu_platform plat = qsv_get_cpu_platform();
|
||||
return (plat >= QSV_CPU_PLATFORM_SKL);
|
||||
}
|
||||
|
||||
static bool update_latency(obs_data_t *settings)
|
||||
{
|
||||
int async_depth = (int)obs_data_get_int(settings, "async_depth");
|
||||
int la_depth = (int)obs_data_get_int(settings, "la_depth");
|
||||
|
||||
if (async_depth > 0 || la_depth > 0) {
|
||||
const char *rate_control =
|
||||
obs_data_get_string(settings, "rate_control");
|
||||
|
||||
bool lookahead = astrcmpi(rate_control, "LA_CBR") == 0 ||
|
||||
astrcmpi(rate_control, "LA_VBR") == 0 ||
|
||||
astrcmpi(rate_control, "LA_ICQ") == 0;
|
||||
|
||||
if (lookahead) {
|
||||
if (la_depth == 0 || la_depth >= 15)
|
||||
obs_data_set_string(settings, "latency",
|
||||
"normal");
|
||||
else
|
||||
obs_data_set_string(settings, "latency", "low");
|
||||
} else {
|
||||
if (async_depth != 1)
|
||||
obs_data_set_string(settings, "latency",
|
||||
"normal");
|
||||
else
|
||||
obs_data_set_string(settings, "latency",
|
||||
"ultra-low");
|
||||
}
|
||||
|
||||
obs_data_erase(settings, "async_depth");
|
||||
obs_data_erase(settings, "la_depth");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool rate_control_modified(obs_properties_t *ppts, obs_property_t *p,
|
||||
obs_data_t *settings)
|
||||
{
|
||||
|
@ -227,18 +263,14 @@ static bool rate_control_modified(obs_properties_t *ppts, obs_property_t *p,
|
|||
p = obs_properties_get(ppts, "icq_quality");
|
||||
obs_property_set_visible(p, bVisible);
|
||||
|
||||
bVisible = astrcmpi(rate_control, "LA_ICQ") == 0 ||
|
||||
astrcmpi(rate_control, "LA_CBR") == 0 ||
|
||||
astrcmpi(rate_control, "LA_VBR") == 0;
|
||||
p = obs_properties_get(ppts, "la_depth");
|
||||
obs_property_set_visible(p, bVisible);
|
||||
|
||||
bVisible = astrcmpi(rate_control, "CBR") == 0 ||
|
||||
astrcmpi(rate_control, "VBR") == 0 ||
|
||||
astrcmpi(rate_control, "AVBR") == 0;
|
||||
p = obs_properties_get(ppts, "mbbrc");
|
||||
obs_property_set_visible(p, bVisible);
|
||||
|
||||
update_latency(settings);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -285,7 +317,6 @@ static obs_properties_t *obs_qsv_props(void *unused)
|
|||
obs_property_set_modified_callback(list, profile_modified);
|
||||
|
||||
obs_properties_add_int(props, "keyint_sec", TEXT_KEYINT_SEC, 1, 20, 1);
|
||||
obs_properties_add_int(props, "async_depth", TEXT_ASYNC_DEPTH, 1, 7, 1);
|
||||
|
||||
list = obs_properties_add_list(props, "rate_control", TEXT_RATE_CONTROL,
|
||||
OBS_COMBO_TYPE_LIST,
|
||||
|
@ -310,7 +341,13 @@ static obs_properties_t *obs_qsv_props(void *unused)
|
|||
obs_properties_add_int(props, "qpb", "QPB", 1, 51, 1);
|
||||
obs_properties_add_int(props, "icq_quality", TEXT_ICQ_QUALITY, 1, 51,
|
||||
1);
|
||||
obs_properties_add_int(props, "la_depth", TEXT_LA_DEPTH, 10, 100, 1);
|
||||
list = obs_properties_add_list(props, "latency", TEXT_LATENCY,
|
||||
OBS_COMBO_TYPE_LIST,
|
||||
OBS_COMBO_FORMAT_STRING);
|
||||
add_strings(list, qsv_latency_names);
|
||||
obs_property_set_long_description(list,
|
||||
obs_module_text("Latency.ToolTip"));
|
||||
|
||||
obs_properties_add_int(props, "bframes", TEXT_BFRAMES, 0, 3, 1);
|
||||
|
||||
if (is_skl_or_greater_platform())
|
||||
|
@ -325,13 +362,14 @@ static void update_params(struct obs_qsv *obsqsv, obs_data_t *settings)
|
|||
{
|
||||
video_t *video = obs_encoder_video(obsqsv->encoder);
|
||||
const struct video_output_info *voi = video_output_get_info(video);
|
||||
update_latency(settings);
|
||||
|
||||
const char *target_usage =
|
||||
obs_data_get_string(settings, "target_usage");
|
||||
const char *profile = obs_data_get_string(settings, "profile");
|
||||
const char *rate_control =
|
||||
obs_data_get_string(settings, "rate_control");
|
||||
int async_depth = (int)obs_data_get_int(settings, "async_depth");
|
||||
const char *latency = obs_data_get_string(settings, "latency");
|
||||
int target_bitrate = (int)obs_data_get_int(settings, "bitrate");
|
||||
int max_bitrate = (int)obs_data_get_int(settings, "max_bitrate");
|
||||
int accuracy = (int)obs_data_get_int(settings, "accuracy");
|
||||
|
@ -340,7 +378,6 @@ static void update_params(struct obs_qsv *obsqsv, obs_data_t *settings)
|
|||
int qpp = (int)obs_data_get_int(settings, "qpp");
|
||||
int qpb = (int)obs_data_get_int(settings, "qpb");
|
||||
int icq_quality = (int)obs_data_get_int(settings, "icq_quality");
|
||||
int la_depth = (int)obs_data_get_int(settings, "la_depth");
|
||||
int keyint_sec = (int)obs_data_get_int(settings, "keyint_sec");
|
||||
bool cbr_override = obs_data_get_bool(settings, "cbr");
|
||||
int bFrames = (int)obs_data_get_int(settings, "bframes");
|
||||
|
@ -413,13 +450,30 @@ static void update_params(struct obs_qsv *obsqsv, obs_data_t *settings)
|
|||
else if (astrcmpi(rate_control, "LA_CBR") == 0)
|
||||
obsqsv->params.nRateControl = MFX_RATECONTROL_LA_HRD;
|
||||
|
||||
obsqsv->params.nAsyncDepth = (mfxU16)async_depth;
|
||||
if (astrcmpi(latency, "ultra-low") == 0) {
|
||||
obsqsv->params.nAsyncDepth = 1;
|
||||
obsqsv->params.nLADEPTH = (mfxU16)0;
|
||||
} else if (astrcmpi(latency, "low") == 0) {
|
||||
obsqsv->params.nAsyncDepth = 4;
|
||||
obsqsv->params.nLADEPTH =
|
||||
(mfxU16)(voi->fps_num / voi->fps_den / 2);
|
||||
} else if (astrcmpi(latency, "normal") == 0) {
|
||||
obsqsv->params.nAsyncDepth = 4;
|
||||
obsqsv->params.nLADEPTH = (mfxU16)(voi->fps_num / voi->fps_den);
|
||||
}
|
||||
|
||||
if (obsqsv->params.nLADEPTH > 0) {
|
||||
if (obsqsv->params.nLADEPTH > 100)
|
||||
obsqsv->params.nLADEPTH = 100;
|
||||
else if (obsqsv->params.nLADEPTH < 10)
|
||||
obsqsv->params.nLADEPTH = 10;
|
||||
}
|
||||
|
||||
obsqsv->params.nAccuracy = (mfxU16)accuracy;
|
||||
obsqsv->params.nConvergence = (mfxU16)convergence;
|
||||
obsqsv->params.nQPI = (mfxU16)qpi;
|
||||
obsqsv->params.nQPP = (mfxU16)qpp;
|
||||
obsqsv->params.nQPB = (mfxU16)qpb;
|
||||
obsqsv->params.nLADEPTH = (mfxU16)la_depth;
|
||||
obsqsv->params.nTargetBitRate = (mfxU16)target_bitrate;
|
||||
obsqsv->params.nMaxBitRate = (mfxU16)max_bitrate;
|
||||
obsqsv->params.nWidth = (mfxU16)width;
|
||||
|
|
Loading…
Reference in New Issue