From patchwork Sat May 21 19:31:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Trystan Mata X-Patchwork-Id: 35887 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:9992:b0:82:461d:f3b with SMTP id ve18csp1192302pzb; Sat, 21 May 2022 12:31:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxi4tXVdbbRhWo9vclf6i9wU+zN547CMUGelJZGMHk7ESn+JXMYltrSOQEQlcmEaonYUiyP X-Received: by 2002:a50:9b0d:0:b0:42a:4bda:c70 with SMTP id o13-20020a509b0d000000b0042a4bda0c70mr17030942edi.287.1653161483650; Sat, 21 May 2022 12:31:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653161483; cv=none; d=google.com; s=arc-20160816; b=sY5hmcK0yhYVC4AKgeTCg8t9QJv2IYBFNZAbO1UxobSagCEPHW7GU5m8YG8q7pneU4 mipJ3yZScgp4tbnsHpZG9OuYPyyzwkNiZ2qLpBI+g+0zDlV4D9l/eropaKjbJQl15qM8 zLJStFQpl1/EpeU//RTrWz6DVRgOvGuol3DTJr6ZKngaOn0zNDWQis6yPvdAv4Qey1Pz skbLr5ztYOVXrZQgOix4R8v2ljNu2sxsDUhMtW25QP5LH0uBXqSb5Pu3naKBPJA/l6Wn y8EyZB6vErxD4NIv5nqeFcCaciWUL0/xNxxxhdDFHlUL+YP/eZq9AA/KtwEvE0/3tthK LPYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :content-language:to:from:mime-version:date:message-id :dkim-signature:delivered-to; bh=6wepuVNU3Enfw75OREpSg2RRQc7dtadwwKmXzYqdzE0=; b=zzeXAwjoTh0WvyvRwEEnZ2QnGnfPVMO2Qs6seW3zRoV24oTGsZ1PHK1BKgRaDkFfSL JWXuIcAowfaqiBXcYmEY9Q7SdwlAaMCLIFEw/o1njhN6bHe/5Lk7UONmD8Zi8XkYRbg6 6781lQie3Qc4L8EFJ4bckDKtX2B+Chc+GOrjrJk/DkVQukrl7tOxKmjowE8KLJSv7S60 OnYZssK8M5jPcVh9xyWiBDm0RBJOxSnbY0s0LhkMQPmqckB3oTooXt8zA6bFpPDDMTUO jeNq6y/GEnK8C48QSB4luQELrAF3sPo3pS+4/4tUrL4RCSQGMiG3zhb8IXDGokYBkobe utxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@tytanium.xyz header.s=mail header.b=q9Yft2mZ; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=tytanium.xyz Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q18-20020a056402041200b00427d81514ebsi7443570edv.14.2022.05.21.12.31.22; Sat, 21 May 2022 12:31:23 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@tytanium.xyz header.s=mail header.b=q9Yft2mZ; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=tytanium.xyz Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 212D968B4A2; Sat, 21 May 2022 22:31:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from tytanium.xyz (82-64-195-121.subs.proxad.net [82.64.195.121]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 91F7168B346 for ; Sat, 21 May 2022 22:31:12 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tytanium.xyz; s=mail; t=1653161471; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references; bh=/YIXz1GAp5ua7SxMVItF7EHSWFSd7Feu06N8yWp45zM=; b=q9Yft2mZ7to63LO62Vzobz6PXB9QE/ntbXikmiW10UwLN9BHTPdKYQ9Phyn/tgu6Q24534 4BMYpknTFBilkTiv29RFslNcVPO8EWeVu9VgH3RpHJHc3FVLgtkM9ZRuaKuDAZpp4OnN6h 6i5kDeT8WfhrT4OyZoVRfkGHYuJhhRI= Message-ID: Date: Sat, 21 May 2022 21:31:10 +0200 MIME-Version: 1.0 From: Trystan Mata To: ffmpeg-devel@ffmpeg.org Content-Language: en-US Subject: [FFmpeg-devel] [PATCH v5] avcodec/mfenc: Dynamically load MFPlat.DLL X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: YRkd2wdiUNMr Changes since the v4: - Avoid having two mf_init function declared (missing #if !HAVE_UWP) - Better commit message about linking with UWP Changes since the v3: - Library handle and function pointer are no longer in MFContext. - If UWP is enabled, avcodec will be linked directly against MFPlat.DLL. - MediaFoundation functions are now called like MFTEnumEx, like Martin Storsjö suggested in his review of the v3. I forgot to mention it on earlier versions, this patch addresses https://trac.ffmpeg.org/ticket/9788. // Trystan From 9115df2346e23d2e3eff4fb78cbd80419267eb7d Mon Sep 17 00:00:00 2001 From: Trystan Mata Date: Sat, 21 May 2022 16:26:56 +0200 Subject: [PATCH] avcodec/mfenc: Dynamically load MediaFoundation library Allows non-UWP builds of FFmpeg with MediaFoundation to work on N editions of Windows which are without MediaFoundation by default. On UWP target, avcodec is link directly against MediaFoundation since LoadLibrary is not available. This commit adresses https://trac.ffmpeg.org/ticket/9788 Signed-off-by: Trystan Mata --- configure | 5 +- libavcodec/mf_utils.c | 106 ++++++++++++++++++++++++++++++++++-------- libavcodec/mf_utils.h | 19 ++++++-- libavcodec/mfenc.c | 25 +++++++++- 4 files changed, 131 insertions(+), 24 deletions(-) diff --git a/configure b/configure index f115b21064..432a0d163d 100755 --- a/configure +++ b/configure @@ -3130,7 +3130,6 @@ wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel" # hardware-accelerated codecs mediafoundation_deps="mftransform_h MFCreateAlignedMemoryBuffer" -mediafoundation_extralibs="-lmfplat -lmfuuid -lole32 -lstrmiids" omx_deps="libdl pthreads" omx_rpi_select="omx" qsv_deps="libmfx" @@ -6876,6 +6875,10 @@ test_cpp <priv_data; HRESULT hr; @@ -1134,6 +1138,10 @@ static int mf_close(AVCodecContext *avctx) ff_free_mf(&c->mft); +#if !HAVE_UWP + ff_mf_unload_library(); +#endif + av_frame_free(&c->frame); av_freep(&avctx->extradata); @@ -1142,6 +1150,21 @@ static int mf_close(AVCodecContext *avctx) return 0; } +#if !HAVE_UWP +static int mf_init(AVCodecContext *avctx) +{ + int ret; + + if ((ret = ff_mf_load_library(avctx)) == 0) { + if ((ret = mf_init_encoder(avctx)) == 0) { + return 0; + } + } + mf_close(avctx); + return ret; +} +#endif + #define OFFSET(x) offsetof(MFContext, x) #define MF_ENCODER(MEDIATYPE, NAME, ID, OPTS, EXTRA) \ -- 2.36.1