未验证 提交 636f0bfd 编写于 作者: J Jim 提交者: GitHub

Merge pull request #2993 from brittneysclark/enable_vdenc

obs-qsv11: Simplify QSV settings in UI and Enable AVC VDEnc on ICL+ 
......@@ -320,6 +320,8 @@ enum qsv_cpu_platform qsv_get_cpu_platform()
case 0x8e:
case 0x9e:
return QSV_CPU_PLATFORM_KBL;
case 0x66:
return QSV_CPU_PLATFORM_CNL;
case 0x7d:
case 0x7e:
return QSV_CPU_PLATFORM_ICL;
......
......@@ -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 {
......@@ -117,6 +118,7 @@ enum qsv_cpu_platform {
QSV_CPU_PLATFORM_BDW,
QSV_CPU_PLATFORM_SKL,
QSV_CPU_PLATFORM_KBL,
QSV_CPU_PLATFORM_CNL,
QSV_CPU_PLATFORM_ICL,
QSV_CPU_PLATFORM_INTEL
};
......
......@@ -211,6 +211,17 @@ bool QSV_Encoder_Internal::InitParams(qsv_param_t *pParams)
m_mfxEncParams.mfx.FrameInfo.CropH = pParams->nHeight;
m_mfxEncParams.mfx.GopRefDist = pParams->nbFrames + 1;
enum qsv_cpu_platform qsv_platform = qsv_get_cpu_platform();
if ((qsv_platform >= QSV_CPU_PLATFORM_ICL) &&
(pParams->nbFrames == 0) &&
(m_ver.Major == 1 && m_ver.Minor >= 31)) {
m_mfxEncParams.mfx.LowPower = MFX_CODINGOPTION_ON;
if (pParams->nRateControl == MFX_RATECONTROL_LA_ICQ ||
pParams->nRateControl == MFX_RATECONTROL_LA_HRD ||
pParams->nRateControl == MFX_RATECONTROL_LA)
pParams->nRateControl = MFX_RATECONTROL_VBR;
}
m_mfxEncParams.mfx.RateControlMethod = pParams->nRateControl;
switch (pParams->nRateControl) {
......@@ -268,10 +279,23 @@ bool QSV_Encoder_Internal::InitParams(qsv_param_t *pParams)
m_co2.MBBRC = MFX_CODINGOPTION_ON;
if (pParams->nbFrames > 1)
m_co2.BRefType = MFX_B_REF_PYRAMID;
if (m_mfxEncParams.mfx.LowPower == MFX_CODINGOPTION_ON) {
m_co2.RepeatPPS = MFX_CODINGOPTION_OFF;
if (pParams->nRateControl == MFX_RATECONTROL_CBR ||
pParams->nRateControl == MFX_RATECONTROL_VBR) {
m_co2.LookAheadDepth = pParams->nLADEPTH;
}
}
extendedBuffers[iBuffers++] = (mfxExtBuffer *)&m_co2;
}
if (pParams->bCQM) {
if (m_mfxEncParams.mfx.LowPower == MFX_CODINGOPTION_ON) {
memset(&m_co3, 0, sizeof(mfxExtCodingOption3));
m_co3.Header.BufferId = MFX_EXTBUFF_CODING_OPTION3;
m_co3.Header.BufferSz = sizeof(m_co3);
m_co3.ScenarioInfo = MFX_SCENARIO_GAME_STREAMING;
extendedBuffers[iBuffers++] = (mfxExtBuffer *)&m_co3;
} else if (pParams->bCQM) {
if (m_ver.Major == 1 && m_ver.Minor >= 16) {
memset(&m_co3, 0, sizeof(mfxExtCodingOption3));
m_co3.Header.BufferId = MFX_EXTBUFF_CODING_OPTION3;
......@@ -297,6 +321,11 @@ bool QSV_Encoder_Internal::InitParams(qsv_param_t *pParams)
else
m_mfxEncParams.IOPattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY;
mfxStatus sts = m_pmfxENC->Query(&m_mfxEncParams, &m_mfxEncParams);
if (sts == MFX_ERR_UNSUPPORTED || sts == MFX_ERR_UNDEFINED_BEHAVIOR) {
m_mfxEncParams.mfx.LowPower = MFX_CODINGOPTION_OFF;
}
return true;
}
......
......@@ -642,7 +642,10 @@ enum {
MFX_SCENARIO_VIDEO_CONFERENCE = 2,
MFX_SCENARIO_ARCHIVE = 3,
MFX_SCENARIO_LIVE_STREAMING = 4,
MFX_SCENARIO_CAMERA_CAPTURE = 5
MFX_SCENARIO_CAMERA_CAPTURE = 5,
MFX_SCENARIO_VIDEO_SURVEILLANCE = 6,
MFX_SCENARIO_GAME_STREAMING = 7,
MFX_SCENARIO_REMOTE_GAMING = 8
};
/* ContentInfo */
......
......@@ -148,7 +148,6 @@ static void obs_qsv_defaults(obs_data_t *settings)
obs_data_set_default_int(settings, "bitrate", 2500);
obs_data_set_default_int(settings, "max_bitrate", 3000);
obs_data_set_default_string(settings, "profile", "high");
obs_data_set_default_int(settings, "async_depth", 4);
obs_data_set_default_string(settings, "rate_control", "CBR");
obs_data_set_default_int(settings, "accuracy", 1000);
......@@ -157,11 +156,11 @@ static void obs_qsv_defaults(obs_data_t *settings)
obs_data_set_default_int(settings, "qpp", 23);
obs_data_set_default_int(settings, "qpb", 23);
obs_data_set_default_int(settings, "icq_quality", 23);
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);
obs_data_set_default_bool(settings, "enhancements", false);
}
static inline void add_strings(obs_property_t *list, const char *const *strings)
......@@ -176,15 +175,15 @@ 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")
#define TEXT_SUBJECTIVE_ENHANCEMENTS \
obs_module_text("Subjective Video Enhancements")
static inline bool is_skl_or_greater_platform()
{
......@@ -227,16 +226,9 @@ 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");
astrcmpi(rate_control, "VBR") == 0;
p = obs_properties_get(ppts, "enhancements");
obs_property_set_visible(p, bVisible);
return true;
......@@ -285,7 +277,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,13 +301,16 @@ 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_properties_add_int(props, "bframes", TEXT_BFRAMES, 0, 3, 1);
if (is_skl_or_greater_platform())
obs_properties_add_bool(props, "mbbrc", TEXT_MBBRC);
obs_properties_add_bool(props, "CQM", "Customized quantization matrix");
obs_properties_add_bool(props, "enhancements",
TEXT_SUBJECTIVE_ENHANCEMENTS);
return props;
}
......@@ -331,7 +325,7 @@ static void update_params(struct obs_qsv *obsqsv, obs_data_t *settings)
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,11 +334,10 @@ 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");
bool mbbrc = obs_data_get_bool(settings, "mbbrc");
bool enhancements = obs_data_get_bool(settings, "enhancements");
if (obs_data_has_user_value(settings, "bf"))
bFrames = (int)obs_data_get_int(settings, "bf");
......@@ -413,13 +406,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;
......@@ -429,7 +439,8 @@ static void update_params(struct obs_qsv *obsqsv, obs_data_t *settings)
obsqsv->params.nbFrames = (mfxU16)bFrames;
obsqsv->params.nKeyIntSec = (mfxU16)keyint_sec;
obsqsv->params.nICQQuality = (mfxU16)icq_quality;
obsqsv->params.bMBBRC = mbbrc;
obsqsv->params.bMBBRC = enhancements;
obsqsv->params.bCQM = enhancements;
info("settings:\n\trate_control: %s", rate_control);
......@@ -469,8 +480,6 @@ static void update_params(struct obs_qsv *obsqsv, obs_data_t *settings)
"\theight: %d",
voi->fps_num, voi->fps_den, width, height);
obsqsv->params.bCQM = (bool)obs_data_get_bool(settings, "CQM");
info("debug info:");
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册