Signed-off-by: Zhong Li <zhong...@intel.com> --- libavcodec/qsvenc.c | 17 ++++++++--------- libavcodec/qsvenc.h | 2 ++ 2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index afeb0f7b10..7903235db9 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -477,13 +477,6 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) int target_bitrate_kbps, max_bitrate_kbps, brc_param_multiplier; int buffer_size_in_kilobytes, initial_delay_in_kilobytes; int ret; - mfxVersion ver; - - ret = MFXQueryVersion(q->session,&ver); - if (ret != MFX_ERR_NONE) { - av_log(avctx, AV_LOG_ERROR, "Error getting the session handle\n"); - return AVERROR_UNKNOWN; - } ret = ff_qsv_codec_id_to_mfx(avctx->codec_id); if (ret < 0) @@ -539,7 +532,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) // If the minor version is greater than or equal to 19, // then can use the same alignment settings as H.264 for HEVC q->width_align = (avctx->codec_id != AV_CODEC_ID_HEVC || - QSV_RUNTIME_VERSION_ATLEAST(ver, 1, 19)) ? 16 : 32; + QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 19)) ? 16 : 32; q->param.mfx.FrameInfo.Width = FFALIGN(avctx->width, q->width_align); if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) { @@ -738,7 +731,7 @@ FF_ENABLE_DEPRECATION_WARNINGS #endif #if QSV_HAVE_MF - if (QSV_RUNTIME_VERSION_ATLEAST(ver, 1, 25)) { + if (QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 25)) { q->extmfp.Header.BufferId = MFX_EXTBUFF_MULTI_FRAME_PARAM; q->extmfp.Header.BufferSz = sizeof(q->extmfp); @@ -1005,6 +998,12 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q) if (ret < 0) return ret; + ret = MFXQueryVersion(q->session,&q->ver); + if (ret < 0) { + return ff_qsv_print_error(avctx, ret, + "Error querying mfx version"); + } + // in the mfxInfoMFX struct, JPEG is different from other codecs switch (avctx->codec_id) { case AV_CODEC_ID_MJPEG: diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index ca1bb44c62..28d873210f 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -135,6 +135,8 @@ typedef struct QSVEncContext { QSVFramesContext frames_ctx; + mfxVersion ver; + // options set by the caller int async_depth; int idr_interval; -- 2.17.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".