From patchwork Mon May 18 20:29:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: galinart X-Patchwork-Id: 19758 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 0E69A44B999 for ; Mon, 18 May 2020 23:31:04 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E675C68AAA0; Mon, 18 May 2020 23:31:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E586968AABE for ; Mon, 18 May 2020 23:30:57 +0300 (EEST) Received: by mail-wr1-f53.google.com with SMTP id e16so13362635wra.7 for ; Mon, 18 May 2020 13:30:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o3bD31JcMTkeRtYb38PH9wQO7yDSaQXf6zOYWbBbDQY=; b=Fy7nfNoe0VnWZWx8H4cY1LhTR44Wksgb0Pwj8SirywcG2GkWOvgPeC8wttihQVnf48 jSqsm9k/bGyLvyTfbJE2sJU7VOO6UGiBXS5bRaSJMbyybAbipCICFvNkbzkdCioboJ8f Q0Z0H9LZCkT/vvr1TB6gqBV/2DY8kTqUx22Tyqaje/ryyDgqbYYZTeV2yjtcVseDcOwZ nI11FboN/7QjF3/Ejtxh8d7XVY6+X5YVhcG2ics+qEDctagTU+u1ZcyNBdayA4H5yLM/ tmuGKnBg0PWtmJr0yDJjIE/PU5oJIQmtfmWxhY3E5LkjA9jy/Yc9/cjjIGPKKjYrIYgT f6sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o3bD31JcMTkeRtYb38PH9wQO7yDSaQXf6zOYWbBbDQY=; b=OqqciHOnaGZ8uzn2oy6U0lmehkAfh084Rip2WmrpKGchK1V0lQ1dMmsBRRGS6nvnct Z5KGV0ydVcYa834fnRMXc4HLUQsDIupetgCarftZDRvQarASSq6nTLZX3rjSQEmXzm6z 5w8TsTdMQ9qiR/OgCXj15izKugvafV6o+S2OQ4VBs1kIyzwvjdxxW6nwC+A4NQGTGXdD BO3ef+y7E7L9UFlXPje0TWAQzJA28DTUcGqqjf40KpxInJR91d45KSdayG9QzNKr04LV Rb6FceIYPXiXz4pNNWmldJOeCgYgm2vPa+JeI2Au7YNDC1qDGC1MZqIi7eOshomP6U7z NquA== X-Gm-Message-State: AOAM533aOFt7szuSnL1jTQz6E6xSKM4g0AwXsy/NAVXXCy17RT7MrBqK 3wW8mDDAkI8K37aHFqwR1IaOecsIX+6iAw== X-Google-Smtp-Source: ABdhPJws5/2dAKs4Z5ace91w67qlA3qnRpCD5mbVyfKPW6XQZLnOqnklVnoj/6MqgUygdypc8z8QoA== X-Received: by 2002:a5d:5492:: with SMTP id h18mr21345270wrv.35.1589833856665; Mon, 18 May 2020 13:30:56 -0700 (PDT) Received: from localhost.localdomain ([2a02:c7d:3e2e:7400:bc2c:26b1:105a:3e19]) by smtp.googlemail.com with ESMTPSA id q4sm884330wma.9.2020.05.18.13.30.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 13:30:56 -0700 (PDT) From: artem.galin@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Mon, 18 May 2020 21:29:28 +0100 Message-Id: <20200518202934.49601-3-artem.galin@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200518202934.49601-1-artem.galin@gmail.com> References: <20200415130741.27263-1-artem.galin@gmail.com> <20200518202934.49601-1-artem.galin@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v6 3/9] libavutil/hwcontext_d3d11va: adding the vendor option to d3d11va device creation X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Cc: Artem Galin , robux4@ycbcr.xyz Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Artem Galin Example: --init_hw_device d3d11va:,vendor=0x8086 qsv_device option is still works and has higher priority over vendor option. Signed-off-by: Artem Galin hwctx; HRESULT hr; + AVDictionaryEntry *e; IDXGIAdapter *pAdapter = NULL; ID3D10Multithread *pMultithread; UINT creationFlags = D3D11_CREATE_DEVICE_VIDEO_SUPPORT; + int adapter = -1; + long int vendor_id = -1; int is_debug = !!av_dict_get(opts, "debug", NULL, 0); int ret; @@ -539,13 +542,45 @@ static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device, return AVERROR_UNKNOWN; } + e = av_dict_get(opts, "vendor", NULL, 0); + if (e) { + vendor_id = strtol(e->value, NULL, 0); + } + if (device) { + adapter = atoi(device); + } + + if (adapter >= 0 || vendor_id != -1) { IDXGIFactory2 *pDXGIFactory; hr = mCreateDXGIFactory(&IID_IDXGIFactory2, (void **)&pDXGIFactory); if (SUCCEEDED(hr)) { - int adapter = atoi(device); - if (FAILED(IDXGIFactory2_EnumAdapters(pDXGIFactory, adapter, &pAdapter))) + if (adapter < 0) { + int adapter_cnt = 0; + while (IDXGIFactory2_EnumAdapters(pDXGIFactory, adapter_cnt++, &pAdapter) != DXGI_ERROR_NOT_FOUND) { + DXGI_ADAPTER_DESC adapter_desc; + hr = IDXGIAdapter2_GetDesc(pAdapter, &adapter_desc); + if (FAILED(hr)) { + av_log(ctx, AV_LOG_ERROR, "IDXGIAdapter2_GetDesc returned error with adapter id %d\n", adapter_cnt); + continue; + } + + if (adapter_desc.VendorId == vendor_id) { + break; + } + + if (adapter) + IDXGIAdapter_Release(pAdapter); + } + if (adapter_cnt < 0) { + av_log(ctx, AV_LOG_ERROR, "Failed to find d3d11va adapter by vendor id %ld\n", vendor_id); + IDXGIFactory2_Release(pDXGIFactory); + return AVERROR_UNKNOWN; + } + } else { + if (FAILED(IDXGIFactory2_EnumAdapters(pDXGIFactory, adapter, &pAdapter))) pAdapter = NULL; + } IDXGIFactory2_Release(pDXGIFactory); } }