static int qsv_device_init(AVHWDeviceContext *ctx) { AVQSVDeviceContext *hwctx = ctx->hwctx; QSVDeviceContext *s = ctx->internal->priv; mfxStatus err; int i; for (i = 0; supported_handle_types[i].handle_type; i++) { err = MFXVideoCORE_GetHandle(hwctx->session, supported_handle_types[i].handle_type, &s->handle); if (err == MFX_ERR_NONE) { s->handle_type = supported_handle_types[i].handle_type; s->child_device_type = supported_handle_types[i].device_type; s->child_pix_fmt = supported_handle_types[i].pix_fmt; break; } } if (!s->handle) { av_log(ctx, AV_LOG_VERBOSE, "No supported hw handle could be retrieved " "from the session\n"); } err = MFXQueryIMPL(hwctx->session, &s->impl); if (err == MFX_ERR_NONE) err = MFXQueryVersion(hwctx->session, &s->ver); if (err != MFX_ERR_NONE) { av_log(ctx, AV_LOG_ERROR, "Error querying the session attributes\n"); return AVERROR_UNKNOWN; } return 0; }
bool IntelH264Decoder::Init() { mfxVersion ver; ver.Major = 1; ver.Minor = 0; //auto err = MFXInit(MFX_IMPL_HARDWARE_ANY, &ver, &Session); //auto err = MFXInit(MFX_IMPL_SOFTWARE, &ver, &Session); auto err = MFXInit(MFX_IMPL_AUTO_ANY, &ver, &Session); if (err != MFX_ERR_NONE) return false; mfxIMPL impl; MFXQueryIMPL(Session, &impl); return true; }
int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session, const char *load_plugins) { mfxIMPL impl = MFX_IMPL_AUTO_ANY; mfxVersion ver = { { QSV_VERSION_MINOR, QSV_VERSION_MAJOR } }; const char *desc; int ret; ret = MFXInit(impl, &ver, session); if (ret < 0) return ff_qsv_print_error(avctx, ret, "Error initializing an internal MFX session"); ret = qsv_load_plugins(*session, load_plugins, avctx); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error loading plugins\n"); return ret; } MFXQueryIMPL(*session, &impl); switch (MFX_IMPL_BASETYPE(impl)) { case MFX_IMPL_SOFTWARE: desc = "software"; break; case MFX_IMPL_HARDWARE: case MFX_IMPL_HARDWARE2: case MFX_IMPL_HARDWARE3: case MFX_IMPL_HARDWARE4: desc = "hardware accelerated"; break; default: desc = "unknown"; } av_log(avctx, AV_LOG_VERBOSE, "Initialized an internal MFX session using %s implementation\n", desc); return 0; }
STDMETHODIMP CDecMSDKMVC::Init() { mfxIMPL impl = MFX_IMPL_SOFTWARE; mfxVersion version = { 8, 1 }; mfxStatus sts = MFXInit(impl, &version, &m_mfxSession); if (sts != MFX_ERR_NONE) { DbgLog((LOG_TRACE, 10, L"CDevMSDKMVC::Init(): MSDK not available")); return E_NOINTERFACE; } // query actual API version MFXQueryVersion(m_mfxSession, &m_mfxVersion); #ifdef DEBUG MFXQueryIMPL(m_mfxSession, &impl); DbgLog((LOG_TRACE, 10, L"CDevMSDKMVC::Init(): MSDK Initialized, version %d.%d, impl 0x%04x", m_mfxVersion.Major, m_mfxVersion.Minor, impl)); #endif return S_OK; }
static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession session) { if (!session) { if (!q->internal_session) { mfxIMPL impl = MFX_IMPL_AUTO_ANY; mfxVersion ver = { { QSV_VERSION_MINOR, QSV_VERSION_MAJOR } }; const char *desc; int ret; ret = MFXInit(impl, &ver, &q->internal_session); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error initializing an internal MFX session\n"); return ff_qsv_error(ret); } MFXQueryIMPL(q->internal_session, &impl); if (impl & MFX_IMPL_SOFTWARE) desc = "software"; else if (impl & MFX_IMPL_HARDWARE) desc = "hardware accelerated"; else desc = "unknown"; av_log(avctx, AV_LOG_VERBOSE, "Initialized an internal MFX session using %s implementation\n", desc); } q->session = q->internal_session; } else { q->session = session; } /* make sure the decoder is uninitialized */ MFXVideoDECODE_Close(q->session); return 0; }
/* create the QSV session */ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) { AVFilterLink *inlink = avctx->inputs[0]; AVFilterLink *outlink = avctx->outputs[0]; AVQSVFramesContext *in_frames_hwctx = NULL; AVQSVFramesContext *out_frames_hwctx = NULL; AVBufferRef *device_ref; AVHWDeviceContext *device_ctx; AVQSVDeviceContext *device_hwctx; mfxHDL handle; mfxHandleType handle_type; mfxVersion ver; mfxIMPL impl; int ret, i; if (inlink->hw_frames_ctx) { AVHWFramesContext *frames_ctx = (AVHWFramesContext *)inlink->hw_frames_ctx->data; device_ref = frames_ctx->device_ref; in_frames_hwctx = frames_ctx->hwctx; s->in_mem_mode = in_frames_hwctx->frame_type; s->surface_ptrs_in = av_mallocz_array(in_frames_hwctx->nb_surfaces, sizeof(*s->surface_ptrs_in)); if (!s->surface_ptrs_in) return AVERROR(ENOMEM); for (i = 0; i < in_frames_hwctx->nb_surfaces; i++) s->surface_ptrs_in[i] = in_frames_hwctx->surfaces + i; s->nb_surface_ptrs_in = in_frames_hwctx->nb_surfaces; } else if (avctx->hw_device_ctx) { device_ref = avctx->hw_device_ctx; s->in_mem_mode = MFX_MEMTYPE_SYSTEM_MEMORY; } else { av_log(avctx, AV_LOG_ERROR, "No hw context provided.\n"); return AVERROR(EINVAL); } device_ctx = (AVHWDeviceContext *)device_ref->data; device_hwctx = device_ctx->hwctx; if (outlink->format == AV_PIX_FMT_QSV) { AVHWFramesContext *out_frames_ctx; AVBufferRef *out_frames_ref = av_hwframe_ctx_alloc(device_ref); if (!out_frames_ref) return AVERROR(ENOMEM); s->out_mem_mode = IS_OPAQUE_MEMORY(s->in_mem_mode) ? MFX_MEMTYPE_OPAQUE_FRAME : MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET; out_frames_ctx = (AVHWFramesContext *)out_frames_ref->data; out_frames_hwctx = out_frames_ctx->hwctx; out_frames_ctx->format = AV_PIX_FMT_QSV; out_frames_ctx->width = FFALIGN(outlink->w, 32); out_frames_ctx->height = FFALIGN(outlink->h, 32); out_frames_ctx->sw_format = s->out_sw_format; out_frames_ctx->initial_pool_size = 64; out_frames_hwctx->frame_type = s->out_mem_mode; ret = av_hwframe_ctx_init(out_frames_ref); if (ret < 0) { av_buffer_unref(&out_frames_ref); av_log(avctx, AV_LOG_ERROR, "Error creating frames_ctx for output pad.\n"); return ret; } s->surface_ptrs_out = av_mallocz_array(out_frames_hwctx->nb_surfaces, sizeof(*s->surface_ptrs_out)); if (!s->surface_ptrs_out) { av_buffer_unref(&out_frames_ref); return AVERROR(ENOMEM); } for (i = 0; i < out_frames_hwctx->nb_surfaces; i++) s->surface_ptrs_out[i] = out_frames_hwctx->surfaces + i; s->nb_surface_ptrs_out = out_frames_hwctx->nb_surfaces; av_buffer_unref(&outlink->hw_frames_ctx); outlink->hw_frames_ctx = out_frames_ref; } else s->out_mem_mode = MFX_MEMTYPE_SYSTEM_MEMORY; /* extract the properties of the "master" session given to us */ ret = MFXQueryIMPL(device_hwctx->session, &impl); if (ret == MFX_ERR_NONE) ret = MFXQueryVersion(device_hwctx->session, &ver); if (ret != MFX_ERR_NONE) { av_log(avctx, AV_LOG_ERROR, "Error querying the session attributes\n"); return AVERROR_UNKNOWN; } for (i = 0; i < FF_ARRAY_ELEMS(handle_types); i++) { ret = MFXVideoCORE_GetHandle(device_hwctx->session, handle_types[i], &handle); if (ret == MFX_ERR_NONE) { handle_type = handle_types[i]; break; } } if (ret != MFX_ERR_NONE) { av_log(avctx, AV_LOG_ERROR, "Error getting the session handle\n"); return AVERROR_UNKNOWN; } /* create a "slave" session with those same properties, to be used for vpp */ ret = MFXInit(impl, &ver, &s->session); if (ret != MFX_ERR_NONE) { av_log(avctx, AV_LOG_ERROR, "Error initializing a session for scaling\n"); return AVERROR_UNKNOWN; } if (handle) { ret = MFXVideoCORE_SetHandle(s->session, handle_type, handle); if (ret != MFX_ERR_NONE) return AVERROR_UNKNOWN; } if (QSV_RUNTIME_VERSION_ATLEAST(ver, 1, 25)) { ret = MFXJoinSession(device_hwctx->session, s->session); if (ret != MFX_ERR_NONE) return AVERROR_UNKNOWN; } if (IS_OPAQUE_MEMORY(s->in_mem_mode) || IS_OPAQUE_MEMORY(s->out_mem_mode)) { s->opaque_alloc.In.Surfaces = s->surface_ptrs_in; s->opaque_alloc.In.NumSurface = s->nb_surface_ptrs_in; s->opaque_alloc.In.Type = s->in_mem_mode; s->opaque_alloc.Out.Surfaces = s->surface_ptrs_out; s->opaque_alloc.Out.NumSurface = s->nb_surface_ptrs_out; s->opaque_alloc.Out.Type = s->out_mem_mode; s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION; s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc); } else if (IS_VIDEO_MEMORY(s->in_mem_mode) || IS_VIDEO_MEMORY(s->out_mem_mode)) { mfxFrameAllocator frame_allocator = { .pthis = s, .Alloc = frame_alloc, .Lock = frame_lock, .Unlock = frame_unlock, .GetHDL = frame_get_hdl, .Free = frame_free, }; ret = MFXVideoCORE_SetFrameAllocator(s->session, &frame_allocator); if (ret != MFX_ERR_NONE) return AVERROR_UNKNOWN; }
static int init_out_session(AVFilterContext *ctx) { QSVScaleContext *s = ctx->priv; AVHWFramesContext *in_frames_ctx = (AVHWFramesContext*)ctx->inputs[0]->hw_frames_ctx->data; AVHWFramesContext *out_frames_ctx = (AVHWFramesContext*)ctx->outputs[0]->hw_frames_ctx->data; AVQSVFramesContext *in_frames_hwctx = in_frames_ctx->hwctx; AVQSVFramesContext *out_frames_hwctx = out_frames_ctx->hwctx; AVQSVDeviceContext *device_hwctx = in_frames_ctx->device_ctx->hwctx; int opaque = !!(in_frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME); mfxHDL handle = NULL; mfxHandleType handle_type; mfxVersion ver; mfxIMPL impl; mfxVideoParam par; mfxStatus err; int i; /* extract the properties of the "master" session given to us */ err = MFXQueryIMPL(device_hwctx->session, &impl); if (err == MFX_ERR_NONE) err = MFXQueryVersion(device_hwctx->session, &ver); if (err != MFX_ERR_NONE) { av_log(ctx, AV_LOG_ERROR, "Error querying the session attributes\n"); return AVERROR_UNKNOWN; } for (i = 0; i < FF_ARRAY_ELEMS(handle_types); i++) { err = MFXVideoCORE_GetHandle(device_hwctx->session, handle_types[i], &handle); if (err == MFX_ERR_NONE) { handle_type = handle_types[i]; break; } } /* create a "slave" session with those same properties, to be used for * actual scaling */ err = MFXInit(impl, &ver, &s->session); if (err != MFX_ERR_NONE) { av_log(ctx, AV_LOG_ERROR, "Error initializing a session for scaling\n"); return AVERROR_UNKNOWN; } if (handle) { err = MFXVideoCORE_SetHandle(s->session, handle_type, handle); if (err != MFX_ERR_NONE) return AVERROR_UNKNOWN; } memset(&par, 0, sizeof(par)); if (opaque) { s->surface_ptrs_in = av_mallocz_array(in_frames_hwctx->nb_surfaces, sizeof(*s->surface_ptrs_in)); if (!s->surface_ptrs_in) return AVERROR(ENOMEM); for (i = 0; i < in_frames_hwctx->nb_surfaces; i++) s->surface_ptrs_in[i] = in_frames_hwctx->surfaces + i; s->nb_surface_ptrs_in = in_frames_hwctx->nb_surfaces; s->surface_ptrs_out = av_mallocz_array(out_frames_hwctx->nb_surfaces, sizeof(*s->surface_ptrs_out)); if (!s->surface_ptrs_out) return AVERROR(ENOMEM); for (i = 0; i < out_frames_hwctx->nb_surfaces; i++) s->surface_ptrs_out[i] = out_frames_hwctx->surfaces + i; s->nb_surface_ptrs_out = out_frames_hwctx->nb_surfaces; s->opaque_alloc.In.Surfaces = s->surface_ptrs_in; s->opaque_alloc.In.NumSurface = s->nb_surface_ptrs_in; s->opaque_alloc.In.Type = in_frames_hwctx->frame_type; s->opaque_alloc.Out.Surfaces = s->surface_ptrs_out; s->opaque_alloc.Out.NumSurface = s->nb_surface_ptrs_out; s->opaque_alloc.Out.Type = out_frames_hwctx->frame_type; s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION; s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc); s->ext_buffers[0] = (mfxExtBuffer*)&s->opaque_alloc; par.ExtParam = s->ext_buffers; par.NumExtParam = FF_ARRAY_ELEMS(s->ext_buffers); par.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | MFX_IOPATTERN_OUT_OPAQUE_MEMORY; } else { mfxFrameAllocator frame_allocator = { .pthis = ctx, .Alloc = frame_alloc, .Lock = frame_lock, .Unlock = frame_unlock, .GetHDL = frame_get_hdl, .Free = frame_free, }; s->mem_ids_in = av_mallocz_array(in_frames_hwctx->nb_surfaces, sizeof(*s->mem_ids_in)); if (!s->mem_ids_in) return AVERROR(ENOMEM); for (i = 0; i < in_frames_hwctx->nb_surfaces; i++) s->mem_ids_in[i] = in_frames_hwctx->surfaces[i].Data.MemId; s->nb_mem_ids_in = in_frames_hwctx->nb_surfaces; s->mem_ids_out = av_mallocz_array(out_frames_hwctx->nb_surfaces, sizeof(*s->mem_ids_out)); if (!s->mem_ids_out) return AVERROR(ENOMEM); for (i = 0; i < out_frames_hwctx->nb_surfaces; i++) s->mem_ids_out[i] = out_frames_hwctx->surfaces[i].Data.MemId; s->nb_mem_ids_out = out_frames_hwctx->nb_surfaces; err = MFXVideoCORE_SetFrameAllocator(s->session, &frame_allocator); if (err != MFX_ERR_NONE) return AVERROR_UNKNOWN; par.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY | MFX_IOPATTERN_OUT_VIDEO_MEMORY; } par.AsyncDepth = 1; // TODO async par.vpp.In = in_frames_hwctx->surfaces[0].Info; par.vpp.Out = out_frames_hwctx->surfaces[0].Info; /* Apparently VPP requires the frame rate to be set to some value, otherwise * init will fail (probably for the framerate conversion filter). Since we * are only doing scaling here, we just invent an arbitrary * value */ par.vpp.In.FrameRateExtN = 25; par.vpp.In.FrameRateExtD = 1; par.vpp.Out.FrameRateExtN = 25; par.vpp.Out.FrameRateExtD = 1; err = MFXVideoVPP_Init(s->session, &par); if (err != MFX_ERR_NONE) { av_log(ctx, AV_LOG_ERROR, "Error opening the VPP for scaling\n"); return AVERROR_UNKNOWN; } return 0; }
extern "C" __declspec(dllexport) void *openEncoder(int *pErrorCode, int width, int height, int bitRate, int gop) { *pErrorCode = 0; IntelEncoderHandle *pHandle = (IntelEncoderHandle *) malloc(sizeof(IntelEncoderHandle)); mfxStatus sts = MFX_ERR_NONE; mfxIMPL impl = MFX_IMPL_AUTO_ANY; mfxVersion ver; ver.Major = 1; ver.Minor = 0; sts = MFXInit(impl, &ver, &pHandle->session); if (MFX_ERR_NONE != sts) { // TODO: *pErrorCode = -1; } MFXQueryIMPL(pHandle->session, &impl); mfxVersion verTemp; MFXQueryVersion(pHandle->session, &verTemp); mfxVideoParam mfxEncParams; memset(&mfxEncParams, 0, sizeof(mfxEncParams)); mfxEncParams.mfx.CodecId = MFX_CODEC_AVC; // mfxEncParams.mfx.CodecProfile = MFX_PROFILE_AVC_CONSTRAINED_BASELINE; mfxEncParams.mfx.TargetUsage = MFX_TARGETUSAGE_BALANCED; if (0 == bitRate) bitRate = 128 * 8; mfxEncParams.mfx.TargetKbps = bitRate; mfxEncParams.mfx.RateControlMethod = MFX_RATECONTROL_VBR; mfxEncParams.mfx.FrameInfo.FrameRateExtN = 30; mfxEncParams.mfx.FrameInfo.FrameRateExtD = 1; mfxEncParams.mfx.FrameInfo.FourCC = MFX_FOURCC_NV12; mfxEncParams.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420; mfxEncParams.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE; mfxEncParams.mfx.FrameInfo.CropX = 0; mfxEncParams.mfx.FrameInfo.CropY = 0; mfxEncParams.mfx.FrameInfo.CropW = width; mfxEncParams.mfx.FrameInfo.CropH = height; // Width must be a multiple of 16 // Height must be a multiple of 16 in case of frame picture and a multiple of 32 in case of field picture mfxEncParams.mfx.FrameInfo.Width = MSDK_ALIGN16(width); mfxEncParams.mfx.FrameInfo.Height = (MFX_PICSTRUCT_PROGRESSIVE == mfxEncParams.mfx.FrameInfo.PicStruct) ? MSDK_ALIGN16(width) : MSDK_ALIGN32(height); mfxEncParams.IOPattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY; sts = MFXVideoENCODE_Query(pHandle->session, &mfxEncParams, &mfxEncParams); if (MFX_ERR_NONE != sts) { // TODO: *pErrorCode = -2; } mfxFrameAllocRequest EncRequest; memset(&EncRequest, 0, sizeof(EncRequest)); sts = MFXVideoENCODE_QueryIOSurf(pHandle->session, &mfxEncParams, &EncRequest); if (MFX_ERR_NONE != sts) { // TODO: *pErrorCode = -3; } pHandle->nEncSurfNum = EncRequest.NumFrameSuggested; mfxU16 w = (mfxU16)MSDK_ALIGN32(EncRequest.Info.Width); mfxU16 h = (mfxU16)MSDK_ALIGN32(EncRequest.Info.Height); mfxU8 bitsPerPixel = 12; // NV12 format is a 12 bits per pixel format mfxU32 surfaceSize = w * h * bitsPerPixel / 8; pHandle->pSurfaceBuffers = (mfxU8 *)malloc(surfaceSize * pHandle->nEncSurfNum * sizeof(mfxU8)); pHandle->ppEncSurfaces = (mfxFrameSurface1 **)malloc(sizeof(mfxFrameSurface1*)* pHandle->nEncSurfNum); for (int i = 0; i < pHandle->nEncSurfNum; i++) { pHandle->ppEncSurfaces[i] = (mfxFrameSurface1 *)malloc(sizeof(mfxFrameSurface1)); memset(pHandle->ppEncSurfaces[i], 0, sizeof(mfxFrameSurface1)); memcpy(&(pHandle->ppEncSurfaces[i]->Info), &(mfxEncParams.mfx.FrameInfo), sizeof(mfxFrameInfo)); pHandle->ppEncSurfaces[i]->Data.Y = &pHandle->pSurfaceBuffers[surfaceSize * i]; pHandle->ppEncSurfaces[i]->Data.U = pHandle->ppEncSurfaces[i]->Data.Y + w * h; pHandle->ppEncSurfaces[i]->Data.V = pHandle->ppEncSurfaces[i]->Data.U + 1; pHandle->ppEncSurfaces[i]->Data.Pitch = w; // In case simulating direct access to frames we initialize the allocated surfaces with default pattern // - For true benchmark comparisons to async workloads all surfaces must have the same data memset(pHandle->ppEncSurfaces[i]->Data.Y, 100, w * h); // Y plane memset(pHandle->ppEncSurfaces[i]->Data.U, 50, (w * h) / 2); // UV plane } sts = MFXVideoENCODE_Init(pHandle->session, &mfxEncParams); MSDK_IGNORE_MFX_STS(sts, MFX_WRN_PARTIAL_ACCELERATION); if (MFX_ERR_NONE != sts) { // TODO: *pErrorCode = -4; } mfxVideoParam par; memset(&par, 0, sizeof(par)); sts = MFXVideoENCODE_GetVideoParam(pHandle->session, &par); if (MFX_ERR_NONE != sts) { // TODO: *pErrorCode = -5; } memset(&pHandle->mfxBS, 0, sizeof(pHandle->mfxBS)); pHandle->mfxBS.MaxLength = par.mfx.BufferSizeInKB * 1024; pHandle->mfxBS.Data = (mfxU8 *)malloc(sizeof(mfxU8)* pHandle->mfxBS.MaxLength); return pHandle; }
int ff_qsv_init_session_device(AVCodecContext *avctx, mfxSession *psession, AVBufferRef *device_ref, const char *load_plugins) { static const mfxHandleType handle_types[] = { MFX_HANDLE_VA_DISPLAY, MFX_HANDLE_D3D9_DEVICE_MANAGER, MFX_HANDLE_D3D11_DEVICE, }; AVHWDeviceContext *device_ctx = (AVHWDeviceContext*)device_ref->data; AVQSVDeviceContext *device_hwctx = device_ctx->hwctx; mfxSession parent_session = device_hwctx->session; mfxSession session; mfxVersion ver; mfxIMPL impl; mfxHDL handle = NULL; mfxHandleType handle_type; mfxStatus err; int i, ret; err = MFXQueryIMPL(parent_session, &impl); if (err == MFX_ERR_NONE) err = MFXQueryVersion(parent_session, &ver); if (err != MFX_ERR_NONE) return ff_qsv_print_error(avctx, err, "Error querying the session attributes"); for (i = 0; i < FF_ARRAY_ELEMS(handle_types); i++) { err = MFXVideoCORE_GetHandle(parent_session, handle_types[i], &handle); if (err == MFX_ERR_NONE) { handle_type = handle_types[i]; break; } handle = NULL; } if (!handle) { av_log(avctx, AV_LOG_VERBOSE, "No supported hw handle could be retrieved " "from the session\n"); } err = MFXInit(impl, &ver, &session); if (err != MFX_ERR_NONE) return ff_qsv_print_error(avctx, err, "Error initializing a child MFX session"); if (handle) { err = MFXVideoCORE_SetHandle(session, handle_type, handle); if (err != MFX_ERR_NONE) return ff_qsv_print_error(avctx, err, "Error setting a HW handle"); } if (QSV_RUNTIME_VERSION_ATLEAST(ver, 1, 25)) { err = MFXJoinSession(parent_session, session); if (err != MFX_ERR_NONE) return ff_qsv_print_error(avctx, err, "Error joining session"); } ret = qsv_load_plugins(session, load_plugins, avctx); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error loading plugins\n"); return ret; } *psession = session; return 0; }