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;
q->param.mfx.BufferSizeInKB = 0;
q->param.mfx.FrameInfo.FourCC = MFX_FOURCC_NV12;
- q->param.mfx.FrameInfo.Width = FFALIGN(avctx->width, 16);
+ q->param.mfx.FrameInfo.Width = FFALIGN(avctx->width, q->width_align);
q->param.mfx.FrameInfo.Height = FFALIGN(avctx->height, 32);
q->param.mfx.FrameInfo.CropX = 0;
q->param.mfx.FrameInfo.CropY = 0;
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;
}
(mfxExtBuffer*)&extradata,
};
+ int need_pps = avctx->codec_id != AV_CODEC_ID_MPEG2VIDEO;
int ret;
q->param.ExtParam = ext_buffers;
q->packet_size = q->param.mfx.BufferSizeInKB * 1000;
- if (!extradata.SPSBufSize || !extradata.PPSBufSize) {
+ if (!extradata.SPSBufSize || (need_pps && !extradata.PPSBufSize)) {
av_log(avctx, AV_LOG_ERROR, "No extradata returned from libmfx.\n");
return AVERROR_UNKNOWN;
}
- avctx->extradata = av_malloc(extradata.SPSBufSize + extradata.PPSBufSize +
+ avctx->extradata = av_malloc(extradata.SPSBufSize + need_pps * extradata.PPSBufSize +
FF_INPUT_BUFFER_PADDING_SIZE);
if (!avctx->extradata)
return AVERROR(ENOMEM);
memcpy(avctx->extradata, sps_buf, extradata.SPSBufSize);
- memcpy(avctx->extradata + extradata.SPSBufSize, pps_buf, extradata.PPSBufSize);
- avctx->extradata_size = extradata.SPSBufSize + extradata.PPSBufSize;
+ if (need_pps)
+ memcpy(avctx->extradata + extradata.SPSBufSize, pps_buf, extradata.PPSBufSize);
+ avctx->extradata_size = extradata.SPSBufSize + need_pps * extradata.PPSBufSize;
memset(avctx->extradata + avctx->extradata_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
return 0;
}
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;
}
/* 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)