Merge pull request #1982 from brittneysclark/qsv_reverted_ft_fix
obs-qsv: Fix QSV reverted features
This commit is contained in:
commit
a8fc576678
@ -293,6 +293,15 @@ enum qsv_cpu_platform qsv_get_cpu_platform()
|
||||
case 0x45:
|
||||
case 0x46:
|
||||
return QSV_CPU_PLATFORM_HSW;
|
||||
case 0x3d:
|
||||
case 0x47:
|
||||
case 0x4f:
|
||||
case 0x56:
|
||||
return QSV_CPU_PLATFORM_BDW;
|
||||
|
||||
case 0x4e:
|
||||
case 0x5e:
|
||||
return QSV_CPU_PLATFORM_SKL;
|
||||
}
|
||||
|
||||
//assume newer revisions are at least as capable as Haswell
|
||||
|
@ -70,9 +70,9 @@ struct qsv_rate_control_info {
|
||||
};
|
||||
|
||||
static const struct qsv_rate_control_info qsv_ratecontrols[] = {
|
||||
{"CBR", false}, {"VBR", false}, {"VCM", true},
|
||||
{"CQP", false}, {"AVBR", false}, {"ICQ", true},
|
||||
{"LA_ICQ", true}, {"LA", true}, {0, false}};
|
||||
{"CBR", false}, {"VBR", false}, {"VCM", true}, {"CQP", false},
|
||||
{"AVBR", false}, {"ICQ", true}, {"LA_ICQ", true}, {"LA_CBR", true},
|
||||
{"LA_VBR", true}, {0, false}};
|
||||
static const char *const qsv_profile_names[] = {"high", "main", "baseline", 0};
|
||||
static const char *const qsv_usage_names[] = {"quality", "balanced", "speed",
|
||||
0};
|
||||
@ -100,6 +100,7 @@ typedef struct {
|
||||
mfxU16 nKeyIntSec;
|
||||
mfxU16 nbFrames;
|
||||
mfxU16 nICQQuality;
|
||||
bool bMBBRC;
|
||||
} qsv_param_t;
|
||||
|
||||
enum qsv_cpu_platform {
|
||||
@ -110,6 +111,8 @@ enum qsv_cpu_platform {
|
||||
QSV_CPU_PLATFORM_SLM,
|
||||
QSV_CPU_PLATFORM_CHT,
|
||||
QSV_CPU_PLATFORM_HSW,
|
||||
QSV_CPU_PLATFORM_BDW,
|
||||
QSV_CPU_PLATFORM_SKL,
|
||||
QSV_CPU_PLATFORM_INTEL
|
||||
};
|
||||
|
||||
|
@ -209,6 +209,7 @@ bool QSV_Encoder_Internal::InitParams(qsv_param_t *pParams)
|
||||
m_mfxEncParams.mfx.FrameInfo.CropY = 0;
|
||||
m_mfxEncParams.mfx.FrameInfo.CropW = pParams->nWidth;
|
||||
m_mfxEncParams.mfx.FrameInfo.CropH = pParams->nHeight;
|
||||
m_mfxEncParams.mfx.GopRefDist = pParams->nbFrames + 1;
|
||||
|
||||
m_mfxEncParams.mfx.RateControlMethod = pParams->nRateControl;
|
||||
|
||||
@ -239,6 +240,9 @@ bool QSV_Encoder_Internal::InitParams(qsv_param_t *pParams)
|
||||
break;
|
||||
case MFX_RATECONTROL_LA_ICQ:
|
||||
m_mfxEncParams.mfx.ICQQuality = pParams->nICQQuality;
|
||||
case MFX_RATECONTROL_LA_HRD:
|
||||
m_mfxEncParams.mfx.TargetKbps = pParams->nTargetBitRate;
|
||||
m_mfxEncParams.mfx.MaxKbps = pParams->nTargetBitRate;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -251,25 +255,18 @@ bool QSV_Encoder_Internal::InitParams(qsv_param_t *pParams)
|
||||
|
||||
static mfxExtBuffer *extendedBuffers[2];
|
||||
int iBuffers = 0;
|
||||
if (pParams->nAsyncDepth == 1) {
|
||||
m_mfxEncParams.mfx.NumRefFrame = 1;
|
||||
// low latency, I and P frames only
|
||||
m_mfxEncParams.mfx.GopRefDist = 1;
|
||||
memset(&m_co, 0, sizeof(mfxExtCodingOption));
|
||||
m_co.Header.BufferId = MFX_EXTBUFF_CODING_OPTION;
|
||||
m_co.Header.BufferSz = sizeof(mfxExtCodingOption);
|
||||
m_co.MaxDecFrameBuffering = 1;
|
||||
extendedBuffers[iBuffers++] = (mfxExtBuffer *)&m_co;
|
||||
} else
|
||||
m_mfxEncParams.mfx.GopRefDist = pParams->nbFrames + 1;
|
||||
|
||||
if (pParams->nRateControl == MFX_RATECONTROL_LA_ICQ ||
|
||||
pParams->nRateControl == MFX_RATECONTROL_LA) {
|
||||
|
||||
if (m_ver.Major == 1 && m_ver.Minor >= 8) {
|
||||
memset(&m_co2, 0, sizeof(mfxExtCodingOption2));
|
||||
m_co2.Header.BufferId = MFX_EXTBUFF_CODING_OPTION;
|
||||
m_co2.Header.BufferId = MFX_EXTBUFF_CODING_OPTION2;
|
||||
m_co2.Header.BufferSz = sizeof(m_co2);
|
||||
m_co2.LookAheadDepth = pParams->nLADEPTH;
|
||||
if (pParams->nRateControl == MFX_RATECONTROL_LA_ICQ ||
|
||||
pParams->nRateControl == MFX_RATECONTROL_LA)
|
||||
m_co2.LookAheadDepth = pParams->nLADEPTH;
|
||||
if (pParams->bMBBRC)
|
||||
m_co2.MBBRC = MFX_CODINGOPTION_ON;
|
||||
if (pParams->nbFrames > 1)
|
||||
m_co2.BRefType = MFX_B_REF_PYRAMID;
|
||||
extendedBuffers[iBuffers++] = (mfxExtBuffer *)&m_co2;
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ static void obs_qsv_defaults(obs_data_t *settings)
|
||||
obs_data_set_default_string(settings, "target_usage", "balanced");
|
||||
obs_data_set_default_int(settings, "bitrate", 2500);
|
||||
obs_data_set_default_int(settings, "max_bitrate", 3000);
|
||||
obs_data_set_default_string(settings, "profile", "main");
|
||||
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");
|
||||
|
||||
@ -155,9 +155,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", 40);
|
||||
obs_data_set_default_int(settings, "la_depth", 15);
|
||||
|
||||
obs_data_set_default_int(settings, "keyint_sec", 3);
|
||||
obs_data_set_default_int(settings, "bframes", 3);
|
||||
obs_data_set_default_bool(settings, "mbbrc", true);
|
||||
}
|
||||
|
||||
static inline void add_strings(obs_property_t *list, const char *const *strings)
|
||||
@ -179,7 +181,14 @@ static inline void add_strings(obs_property_t *list, const char *const *strings)
|
||||
#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")
|
||||
|
||||
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 rate_control_modified(obs_properties_t *ppts, obs_property_t *p,
|
||||
obs_data_t *settings)
|
||||
{
|
||||
@ -217,10 +226,17 @@ static bool rate_control_modified(obs_properties_t *ppts, obs_property_t *p,
|
||||
obs_property_set_visible(p, bVisible);
|
||||
|
||||
bVisible = astrcmpi(rate_control, "LA_ICQ") == 0 ||
|
||||
astrcmpi(rate_control, "LA") == 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);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -279,6 +295,10 @@ static obs_properties_t *obs_qsv_props(void *unused)
|
||||
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);
|
||||
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);
|
||||
|
||||
return props;
|
||||
}
|
||||
@ -305,7 +325,8 @@ static void update_params(struct obs_qsv *obsqsv, obs_data_t *settings)
|
||||
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 = 7;
|
||||
int bFrames = (int)obs_data_get_int(settings, "bframes");
|
||||
bool mbbrc = obs_data_get_bool(settings, "mbbrc");
|
||||
|
||||
if (obs_data_has_user_value(settings, "bf"))
|
||||
bFrames = (int)obs_data_get_int(settings, "bf");
|
||||
@ -351,8 +372,10 @@ static void update_params(struct obs_qsv *obsqsv, obs_data_t *settings)
|
||||
obsqsv->params.nRateControl = MFX_RATECONTROL_ICQ;
|
||||
else if (astrcmpi(rate_control, "LA_ICQ") == 0)
|
||||
obsqsv->params.nRateControl = MFX_RATECONTROL_LA_ICQ;
|
||||
else if (astrcmpi(rate_control, "LA") == 0)
|
||||
else if (astrcmpi(rate_control, "LA_VBR") == 0)
|
||||
obsqsv->params.nRateControl = MFX_RATECONTROL_LA;
|
||||
else if (astrcmpi(rate_control, "LA_CBR") == 0)
|
||||
obsqsv->params.nRateControl = MFX_RATECONTROL_LA_HRD;
|
||||
|
||||
obsqsv->params.nAsyncDepth = (mfxU16)async_depth;
|
||||
obsqsv->params.nAccuracy = (mfxU16)accuracy;
|
||||
@ -370,6 +393,7 @@ 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;
|
||||
|
||||
info("settings:\n\trate_control: %s", rate_control);
|
||||
|
||||
@ -390,7 +414,8 @@ static void update_params(struct obs_qsv *obsqsv, obs_data_t *settings)
|
||||
(int)obsqsv->params.nICQQuality);
|
||||
|
||||
if (obsqsv->params.nRateControl == MFX_RATECONTROL_LA_ICQ ||
|
||||
obsqsv->params.nRateControl == MFX_RATECONTROL_LA)
|
||||
obsqsv->params.nRateControl == MFX_RATECONTROL_LA ||
|
||||
obsqsv->params.nRateControl == MFX_RATECONTROL_LA_HRD)
|
||||
blog(LOG_INFO, "\tLookahead Depth:%d",
|
||||
(int)obsqsv->params.nLADEPTH);
|
||||
|
||||
@ -611,8 +636,20 @@ static void parse_packet(struct obs_qsv *obsqsv, struct encoder_packet *packet,
|
||||
packet->size = obsqsv->packet_data.num;
|
||||
packet->type = OBS_ENCODER_VIDEO;
|
||||
packet->pts = pBS->TimeStamp * fps_num / 90000;
|
||||
packet->keyframe =
|
||||
(pBS->FrameType & (MFX_FRAMETYPE_I | MFX_FRAMETYPE_REF));
|
||||
packet->keyframe = (pBS->FrameType & MFX_FRAMETYPE_IDR);
|
||||
|
||||
uint16_t frameType = pBS->FrameType;
|
||||
uint8_t priority;
|
||||
|
||||
if (frameType & MFX_FRAMETYPE_I)
|
||||
priority = OBS_NAL_PRIORITY_HIGHEST;
|
||||
else if ((frameType & MFX_FRAMETYPE_P) ||
|
||||
(frameType & MFX_FRAMETYPE_REF))
|
||||
priority = OBS_NAL_PRIORITY_HIGH;
|
||||
else
|
||||
priority = 0;
|
||||
|
||||
packet->priority = priority;
|
||||
|
||||
/* ------------------------------------ */
|
||||
|
||||
@ -629,15 +666,10 @@ static void parse_packet(struct obs_qsv *obsqsv, struct encoder_packet *packet,
|
||||
|
||||
type = start[0] & 0x1F;
|
||||
if (type == OBS_NAL_SLICE_IDR || type == OBS_NAL_SLICE) {
|
||||
uint8_t prev_type = (start[0] >> 5) & 0x3;
|
||||
start[0] &= ~(3 << 5);
|
||||
|
||||
if (pBS->FrameType & MFX_FRAMETYPE_I)
|
||||
start[0] |= OBS_NAL_PRIORITY_HIGHEST << 5;
|
||||
else if (pBS->FrameType & MFX_FRAMETYPE_P)
|
||||
start[0] |= OBS_NAL_PRIORITY_HIGH << 5;
|
||||
else
|
||||
start[0] |= prev_type << 5;
|
||||
start[0] |=
|
||||
priority
|
||||
<< 5; //0 for non-ref frames and not equal to 0 for ref frames
|
||||
}
|
||||
|
||||
start = (uint8_t *)obs_avc_find_startcode(start, end);
|
||||
|
Loading…
x
Reference in New Issue
Block a user