|
|
|
@@ -637,7 +637,8 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) |
|
|
|
// The HEVC encoder plugin currently fails with some old libmfx version if coding options |
|
|
|
// are provided. Can't find the extract libmfx version which fixed it, just enable it from |
|
|
|
// V1.28 in order to keep compatibility security. |
|
|
|
if ((avctx->codec_id != AV_CODEC_ID_HEVC) || QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 28)) { |
|
|
|
if (((avctx->codec_id != AV_CODEC_ID_HEVC) || QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 28)) |
|
|
|
&& (avctx->codec_id != AV_CODEC_ID_VP9)) { |
|
|
|
q->extco.Header.BufferId = MFX_EXTBUFF_CODING_OPTION; |
|
|
|
q->extco.Header.BufferSz = sizeof(q->extco); |
|
|
|
|
|
|
|
@@ -761,6 +762,15 @@ FF_ENABLE_DEPRECATION_WARNINGS |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
#if QSV_HAVE_EXT_VP9_PARAM |
|
|
|
if (avctx->codec_id == AV_CODEC_ID_VP9) { |
|
|
|
q->extvp9param.Header.BufferId = MFX_EXTBUFF_VP9_PARAM; |
|
|
|
q->extvp9param.Header.BufferSz = sizeof(q->extvp9param); |
|
|
|
q->extvp9param.WriteIVFHeaders = MFX_CODINGOPTION_OFF; |
|
|
|
q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->extvp9param; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
if (!check_enc_param(avctx,q)) { |
|
|
|
av_log(avctx, AV_LOG_ERROR, |
|
|
|
"some encoding parameters are not supported by the QSV " |
|
|
|
@@ -789,6 +799,53 @@ static int qsv_retrieve_enc_jpeg_params(AVCodecContext *avctx, QSVEncContext *q) |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
static int qsv_retrieve_enc_vp9_params(AVCodecContext *avctx, QSVEncContext *q) |
|
|
|
{ |
|
|
|
int ret = 0; |
|
|
|
#if QSV_HAVE_EXT_VP9_PARAM |
|
|
|
mfxExtVP9Param vp9_extend_buf = { |
|
|
|
.Header.BufferId = MFX_EXTBUFF_VP9_PARAM, |
|
|
|
.Header.BufferSz = sizeof(vp9_extend_buf), |
|
|
|
}; |
|
|
|
#endif |
|
|
|
|
|
|
|
#if QSV_HAVE_CO2 |
|
|
|
mfxExtCodingOption2 co2 = { |
|
|
|
.Header.BufferId = MFX_EXTBUFF_CODING_OPTION2, |
|
|
|
.Header.BufferSz = sizeof(co2), |
|
|
|
}; |
|
|
|
#endif |
|
|
|
|
|
|
|
#if QSV_HAVE_CO3 |
|
|
|
mfxExtCodingOption3 co3 = { |
|
|
|
.Header.BufferId = MFX_EXTBUFF_CODING_OPTION3, |
|
|
|
.Header.BufferSz = sizeof(co3), |
|
|
|
}; |
|
|
|
#endif |
|
|
|
|
|
|
|
mfxExtBuffer *ext_buffers[] = { |
|
|
|
(mfxExtBuffer*)&vp9_extend_buf, |
|
|
|
#if QSV_HAVE_CO2 |
|
|
|
(mfxExtBuffer*)&co2, |
|
|
|
#endif |
|
|
|
#if QSV_HAVE_CO3 |
|
|
|
(mfxExtBuffer*)&co3, |
|
|
|
#endif |
|
|
|
}; |
|
|
|
|
|
|
|
q->param.ExtParam = ext_buffers; |
|
|
|
q->param.NumExtParam = FF_ARRAY_ELEMS(ext_buffers); |
|
|
|
|
|
|
|
ret = MFXVideoENCODE_GetVideoParam(q->session, &q->param); |
|
|
|
if (ret < 0) |
|
|
|
return ff_qsv_print_error(avctx, ret, |
|
|
|
"Error calling GetVideoParam"); |
|
|
|
|
|
|
|
q->packet_size = q->param.mfx.BufferSizeInKB * q->param.mfx.BRCParamMultiplier * 1000; |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q) |
|
|
|
{ |
|
|
|
AVCPBProperties *cpb_props; |
|
|
|
@@ -1112,6 +1169,9 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q) |
|
|
|
case AV_CODEC_ID_MJPEG: |
|
|
|
ret = qsv_retrieve_enc_jpeg_params(avctx, q); |
|
|
|
break; |
|
|
|
case AV_CODEC_ID_VP9: |
|
|
|
ret = qsv_retrieve_enc_vp9_params(avctx, q); |
|
|
|
break; |
|
|
|
default: |
|
|
|
ret = qsv_retrieve_enc_params(avctx, q); |
|
|
|
break; |
|
|
|
|