summaryrefslogtreecommitdiff
path: root/libavcodec/qsvenc.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/qsvenc.c')
-rw-r--r--libavcodec/qsvenc.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 2e147b75c0..29f0386d46 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -49,6 +49,8 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
return AVERROR_BUG;
q->param.mfx.CodecId = ret;
+ q->width_align = avctx->codec_id == AV_CODEC_ID_HEVC ? 32 : 16;
+
if (avctx->level > 0)
q->param.mfx.CodecLevel = avctx->level;
@@ -74,7 +76,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
q->param.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420;
q->param.mfx.FrameInfo.BitDepthLuma = 8;
q->param.mfx.FrameInfo.BitDepthChroma = 8;
- q->param.mfx.FrameInfo.Width = FFALIGN(avctx->width, 16);
+ q->param.mfx.FrameInfo.Width = FFALIGN(avctx->width, q->width_align);
if (avctx->flags & CODEC_FLAG_INTERLACED_DCT) {
/* A true field layout (TFF or BFF) is not important here,
@@ -86,7 +88,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
q->param.mfx.FrameInfo.Height = FFALIGN(avctx->height, 32);
} else {
q->param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
- q->param.mfx.FrameInfo.Height = FFALIGN(avctx->height, 16);
+ q->param.mfx.FrameInfo.Height = FFALIGN(avctx->height, avctx->codec_id == AV_CODEC_ID_HEVC ? 32 : 16);
}
if (avctx->framerate.den > 0 && avctx->framerate.num > 0) {
@@ -135,15 +137,19 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
break;
}
- q->extco.Header.BufferId = MFX_EXTBUFF_CODING_OPTION;
- q->extco.Header.BufferSz = sizeof(q->extco);
- q->extco.CAVLC = avctx->coder_type == FF_CODER_TYPE_VLC ?
- MFX_CODINGOPTION_ON : MFX_CODINGOPTION_UNKNOWN;
+ // the HEVC encoder plugin currently fails if coding options
+ // are provided
+ if (avctx->codec_id != AV_CODEC_ID_HEVC) {
+ q->extco.Header.BufferId = MFX_EXTBUFF_CODING_OPTION;
+ q->extco.Header.BufferSz = sizeof(q->extco);
+ q->extco.CAVLC = avctx->coder_type == FF_CODER_TYPE_VLC ?
+ MFX_CODINGOPTION_ON : MFX_CODINGOPTION_UNKNOWN;
- q->extparam[0] = (mfxExtBuffer *)&q->extco;
+ q->extparam[0] = (mfxExtBuffer *)&q->extco;
- q->param.ExtParam = q->extparam;
- q->param.NumExtParam = FF_ARRAY_ELEMS(q->extparam);
+ q->param.ExtParam = q->extparam;
+ q->param.NumExtParam = FF_ARRAY_ELEMS(q->extparam);
+ }
return 0;
}
@@ -210,7 +216,8 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q)
}
if (!q->session) {
- ret = ff_qsv_init_internal_session(avctx, &q->internal_session);
+ ret = ff_qsv_init_internal_session(avctx, &q->internal_session,
+ q->load_plugins);
if (ret < 0)
return ret;
@@ -316,9 +323,9 @@ static int submit_frame(QSVEncContext *q, const AVFrame *frame,
}
/* make a copy if the input is not padded as libmfx requires */
- if (frame->height & 31 || frame->linesize[0] & 15) {
+ if (frame->height & 31 || frame->linesize[0] & (q->width_align - 1)) {
qf->frame->height = FFALIGN(frame->height, 32);
- qf->frame->width = FFALIGN(frame->width, 16);
+ qf->frame->width = FFALIGN(frame->width, q->width_align);
ret = ff_get_buffer(q->avctx, qf->frame, AV_GET_BUFFER_FLAG_REF);
if (ret < 0)