Signed-off-by: nablet developer <s...@nablet.com> --- libavcodec/qsvenc.c | 29 +++++++++++++++++++++++------ libavcodec/qsvenc.h | 3 +-- 2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 6145121..8eefa06 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -30,6 +30,8 @@ #include "libavutil/log.h" #include "libavutil/time.h" #include "libavutil/imgutils.h" +#include "libavutil/hwcontext.h" +#include "libavutil/hwcontext_qsv.h" #include "libavcodec/bytestream.h" #include "avcodec.h" @@ -697,12 +699,27 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q) } if (!q->session) { - ret = ff_qsv_init_internal_session(avctx, &q->internal_qs, - q->load_plugins); - if (ret < 0) - return ret; + AVHWDeviceContext *device_ctx; + AVQSVDeviceContext *device_hwctx; + + if (!q->hwdevice) { + q->hwdevice = av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_QSV); + if (!q->hwdevice) { + return AVERROR(ENOMEM); + } + } + device_ctx = (AVHWDeviceContext*)q->hwdevice->data; + device_hwctx = device_ctx->hwctx; - q->session = q->internal_qs.session; + if (!device_hwctx->session) { + device_hwctx->load_plugins = q->load_plugins; + + ret = av_hwdevice_ctx_init(q->hwdevice); + if (ret < 0) { + return ret; + } + } + q->session = device_hwctx->session; } ret = init_video_param(avctx, q); @@ -1084,7 +1101,7 @@ int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q) MFXVideoENCODE_Close(q->session); q->session = NULL; - ff_qsv_close_internal_session(&q->internal_qs); + av_buffer_unref(&q->hwdevice); cur = q->work_frames; while (cur) { diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 2d7bd32..7c9c1e2 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -79,8 +79,7 @@ typedef struct QSVEncContext { QSVFrame *work_frames; mfxSession session; - QSVSession internal_qs; - + AVBufferRef *hwdevice; int packet_size; int width_align; int height_align; -- 1.8.3.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel