Signed-off-by: nablet developer <s...@nablet.com> --- libavcodec/qsvdec.c | 29 ++++++++++++++++++++++------- libavcodec/qsvdec.h | 4 +--- 2 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 5253a57..e21ed20 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -31,6 +31,8 @@ #include "libavutil/log.h" #include "libavutil/pixfmt.h" #include "libavutil/time.h" +#include "libavutil/hwcontext.h" +#include "libavutil/hwcontext_qsv.h" #include "avcodec.h" #include "internal.h" @@ -75,14 +77,27 @@ static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q, AVPacket *avpkt q->nb_ext_buffers = qsv->nb_ext_buffers; } if (!q->session) { - if (!q->internal_qs.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; } if (avpkt->size) { @@ -596,7 +611,7 @@ int ff_qsv_decode_close(QSVContext *q) q->session = NULL; - ff_qsv_close_internal_session(&q->internal_qs); + av_buffer_unref(&q->hwdevice); av_fifo_free(q->async_fifo); q->async_fifo = NULL; diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h index 97a3315..eba1d05 100644 --- a/libavcodec/qsvdec.h +++ b/libavcodec/qsvdec.h @@ -39,9 +39,7 @@ typedef struct QSVContext { // the session used for decoding mfxSession session; - // the session we allocated internally, in case the caller did not provide - // one - QSVSession internal_qs; + AVBufferRef *hwdevice; /** * a linked list of frames currently being used by QSV -- 1.8.3.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel