mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
Merge commit '772c87c5a658f36d7c0612f5da583fc2bfa54f79'
* commit '772c87c5a658f36d7c0612f5da583fc2bfa54f79': qsvenc: support passing arbitrary external buffers to the encoder Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
This commit is contained in:
commit
760dbdd3c5
@ -160,7 +160,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
|
|||||||
q->extco.PicTimingSEI = q->pic_timing_sei ?
|
q->extco.PicTimingSEI = q->pic_timing_sei ?
|
||||||
MFX_CODINGOPTION_ON : MFX_CODINGOPTION_UNKNOWN;
|
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)
|
#if QSV_VERSION_ATLEAST(1,6)
|
||||||
q->extco2.Header.BufferId = MFX_EXTBUFF_CODING_OPTION2;
|
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;
|
q->extco2.LookAheadDS = q->look_ahead_downsampling;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
q->extparam[1] = (mfxExtBuffer *)&q->extco2;
|
q->extparam_internal[1] = (mfxExtBuffer *)&q->extco2;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
q->param.ExtParam = q->extparam;
|
|
||||||
q->param.NumExtParam = FF_ARRAY_ELEMS(q->extparam);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -278,6 +276,35 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q)
|
|||||||
return ff_qsv_error(ret);
|
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);
|
ret = MFXVideoENCODE_Init(q->session, &q->param);
|
||||||
if (MFX_WRN_PARTIAL_ACCELERATION==ret) {
|
if (MFX_WRN_PARTIAL_ACCELERATION==ret) {
|
||||||
av_log(avctx, AV_LOG_WARNING, "Encoder will work with partial HW acceleration\n");
|
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);
|
av_fifo_free(q->async_fifo);
|
||||||
q->async_fifo = NULL;
|
q->async_fifo = NULL;
|
||||||
|
|
||||||
|
av_freep(&q->extparam);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -52,10 +52,11 @@ typedef struct QSVEncContext {
|
|||||||
mfxExtCodingOption extco;
|
mfxExtCodingOption extco;
|
||||||
#if QSV_VERSION_ATLEAST(1,6)
|
#if QSV_VERSION_ATLEAST(1,6)
|
||||||
mfxExtCodingOption2 extco2;
|
mfxExtCodingOption2 extco2;
|
||||||
mfxExtBuffer *extparam[2];
|
mfxExtBuffer *extparam_internal[2];
|
||||||
#else
|
#else
|
||||||
mfxExtBuffer *extparam[1];
|
mfxExtBuffer *extparam_internal[1];
|
||||||
#endif
|
#endif
|
||||||
|
mfxExtBuffer **extparam;
|
||||||
|
|
||||||
AVFifoBuffer *async_fifo;
|
AVFifoBuffer *async_fifo;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user