diff options
Diffstat (limited to 'libhb/enc_qsv.c')
-rw-r--r-- | libhb/enc_qsv.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/libhb/enc_qsv.c b/libhb/enc_qsv.c index 7ff3e1489..45e6e8f15 100644 --- a/libhb/enc_qsv.c +++ b/libhb/enc_qsv.c @@ -42,10 +42,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "libavutil/hwcontext.h" #include <mfx/mfxvideo.h> -extern int qsv_filters_are_enabled; extern AVBufferRef *hb_hw_device_ctx; -HBQSVFramesContext hb_dec_qsv_frames_ctx; -extern HBQSVFramesContext hb_vpp_qsv_frames_ctx; /* * The frame info struct remembers information about each frame across calls to @@ -797,7 +794,7 @@ int qsv_enc_init(hb_work_private_t *pv) // reuse parent session qsv->mfx_session = parent_session; mfxFrameAllocator frame_allocator = { - .pthis = &hb_dec_qsv_frames_ctx, + .pthis = pv->job->qsv.ctx->hb_dec_qsv_frames_ctx, .Alloc = hb_qsv_frame_alloc, .Lock = hb_qsv_frame_lock, .Unlock = hb_qsv_frame_unlock, @@ -805,9 +802,9 @@ int qsv_enc_init(hb_work_private_t *pv) .Free = hb_qsv_frame_free, }; - if (qsv_filters_are_enabled) + if (pv->job->qsv.ctx->qsv_filters_are_enabled) { - frame_allocator.pthis = &hb_vpp_qsv_frames_ctx; + frame_allocator.pthis = pv->job->qsv.ctx->hb_vpp_qsv_frames_ctx; } err = MFXVideoCORE_SetFrameAllocator(qsv->mfx_session, &frame_allocator); @@ -1771,6 +1768,8 @@ void encqsvClose(hb_work_object_t *w) hb_qsv_unload_plugins(&pv->loaded_plugins, qsv_ctx->mfx_session, version); } + hb_qsv_uninit_enc(pv->job); + /* QSV context cleanup and MFXClose */ hb_qsv_context_clean(qsv_ctx,hb_qsv_full_path_is_enabled(pv->job)); @@ -1822,8 +1821,6 @@ void encqsvClose(hb_work_object_t *w) av_freep(&qsv_ctx); } } - - hb_qsv_uninit_enc(); } if (pv != NULL) @@ -2162,13 +2159,13 @@ static int qsv_enc_work(hb_work_private_t *pv, mfxFrameSurface1 *surface = task->stage->in.p_surface; if(!pv->is_sys_mem && surface) { - if (qsv_filters_are_enabled) + if (pv->job->qsv.ctx->qsv_filters_are_enabled) { - hb_qsv_release_surface_from_pool(&hb_vpp_qsv_frames_ctx, surface->Data.MemId); + hb_qsv_release_surface_from_pool(pv->job->qsv.ctx->hb_vpp_qsv_frames_ctx, surface->Data.MemId); } else { - hb_qsv_release_surface_from_pool(&hb_dec_qsv_frames_ctx, surface->Data.MemId); + hb_qsv_release_surface_from_pool(pv->job->qsv.ctx->hb_dec_qsv_frames_ctx, surface->Data.MemId); } } @@ -2252,28 +2249,28 @@ int encqsvWork(hb_work_object_t *w, hb_buffer_t **buf_in, hb_buffer_t **buf_out) if(in->qsv_details.frame) { surface = ((mfxFrameSurface1*)in->qsv_details.frame->data[3]); - if (qsv_filters_are_enabled) + if (pv->job->qsv.ctx->qsv_filters_are_enabled) { - hb_qsv_get_mid_by_surface_from_pool(&hb_vpp_qsv_frames_ctx, surface, &mid); + hb_qsv_get_mid_by_surface_from_pool(pv->job->qsv.ctx->hb_vpp_qsv_frames_ctx, surface, &mid); } else { - hb_qsv_get_mid_by_surface_from_pool(&hb_dec_qsv_frames_ctx, surface, &mid); + hb_qsv_get_mid_by_surface_from_pool(pv->job->qsv.ctx->hb_dec_qsv_frames_ctx, surface, &mid); } } else { // Create black buffer in the begining of the encoding, usually first 2 frames - hb_qsv_get_free_surface_from_pool_with_range(&hb_dec_qsv_frames_ctx, HB_POOL_SURFACE_SIZE - HB_POOL_ENCODER_SIZE, HB_POOL_SURFACE_SIZE, &mid, &surface); + hb_qsv_get_free_surface_from_pool_with_range(pv->job->qsv.ctx->hb_dec_qsv_frames_ctx, HB_POOL_SURFACE_SIZE - HB_POOL_ENCODER_SIZE, HB_POOL_SURFACE_SIZE, &mid, &surface); } - if (qsv_filters_are_enabled) + if (pv->job->qsv.ctx->qsv_filters_are_enabled) { - hb_qsv_replace_surface_mid(&hb_vpp_qsv_frames_ctx, mid, surface); + hb_qsv_replace_surface_mid(pv->job->qsv.ctx->hb_vpp_qsv_frames_ctx, mid, surface); } else { - hb_qsv_replace_surface_mid(&hb_dec_qsv_frames_ctx, mid, surface); + hb_qsv_replace_surface_mid(pv->job->qsv.ctx->hb_dec_qsv_frames_ctx, mid, surface); } #endif // At this point, enc_qsv takes ownership of the QSV resources |