|
|
|
@@ -160,7 +160,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) |
|
|
|
q->extco.PicTimingSEI = q->pic_timing_sei ? |
|
|
|
MFX_CODINGOPTION_ON : MFX_CODINGOPTION_UNKNOWN; |
|
|
|
|
|
|
|
q->extparam[0] = (mfxExtBuffer *)&q->extco; |
|
|
|
q->extparam_internal[0] = (mfxExtBuffer *)&q->extco; |
|
|
|
|
|
|
|
#if QSV_VERSION_ATLEAST(1,6) |
|
|
|
q->extco2.Header.BufferId = MFX_EXTBUFF_CODING_OPTION2; |
|
|
|
@@ -175,11 +175,9 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) |
|
|
|
q->extco2.LookAheadDS = q->look_ahead_downsampling; |
|
|
|
#endif |
|
|
|
|
|
|
|
q->extparam[1] = (mfxExtBuffer *)&q->extco2; |
|
|
|
q->extparam_internal[1] = (mfxExtBuffer *)&q->extco2; |
|
|
|
|
|
|
|
#endif |
|
|
|
q->param.ExtParam = q->extparam; |
|
|
|
q->param.NumExtParam = FF_ARRAY_ELEMS(q->extparam); |
|
|
|
} |
|
|
|
|
|
|
|
return 0; |
|
|
|
@@ -278,6 +276,35 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q) |
|
|
|
return ff_qsv_error(ret); |
|
|
|
} |
|
|
|
|
|
|
|
if (avctx->hwaccel_context) { |
|
|
|
AVQSVContext *qsv = avctx->hwaccel_context; |
|
|
|
int i, j; |
|
|
|
|
|
|
|
q->extparam = av_mallocz_array(qsv->nb_ext_buffers + FF_ARRAY_ELEMS(q->extparam_internal), |
|
|
|
sizeof(*q->extparam)); |
|
|
|
if (!q->extparam) |
|
|
|
return AVERROR(ENOMEM); |
|
|
|
|
|
|
|
q->param.ExtParam = q->extparam; |
|
|
|
for (i = 0; i < qsv->nb_ext_buffers; i++) |
|
|
|
q->param.ExtParam[i] = qsv->ext_buffers[i]; |
|
|
|
q->param.NumExtParam = qsv->nb_ext_buffers; |
|
|
|
|
|
|
|
for (i = 0; i < FF_ARRAY_ELEMS(q->extparam_internal); i++) { |
|
|
|
for (j = 0; j < qsv->nb_ext_buffers; j++) { |
|
|
|
if (qsv->ext_buffers[j]->BufferId == q->extparam_internal[i]->BufferId) |
|
|
|
break; |
|
|
|
} |
|
|
|
if (j < qsv->nb_ext_buffers) |
|
|
|
continue; |
|
|
|
|
|
|
|
q->param.ExtParam[q->param.NumExtParam++] = q->extparam_internal[i]; |
|
|
|
} |
|
|
|
} else { |
|
|
|
q->param.ExtParam = q->extparam_internal; |
|
|
|
q->param.NumExtParam = FF_ARRAY_ELEMS(q->extparam_internal); |
|
|
|
} |
|
|
|
|
|
|
|
ret = MFXVideoENCODE_Init(q->session, &q->param); |
|
|
|
if (MFX_WRN_PARTIAL_ACCELERATION==ret) { |
|
|
|
av_log(avctx, AV_LOG_WARNING, "Encoder will work with partial HW acceleration\n"); |
|
|
|
@@ -574,5 +601,7 @@ int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q) |
|
|
|
av_fifo_free(q->async_fifo); |
|
|
|
q->async_fifo = NULL; |
|
|
|
|
|
|
|
av_freep(&q->extparam); |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |