From patchwork Tue Jan 3 07:13:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Zhengxu" X-Patchwork-Id: 2030 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp4253737vsb; Mon, 2 Jan 2017 23:20:31 -0800 (PST) X-Received: by 10.28.109.29 with SMTP id i29mr43446127wmc.124.1483428031085; Mon, 02 Jan 2017 23:20:31 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id r17si72336128wmg.149.2017.01.02.23.20.30; Mon, 02 Jan 2017 23:20:31 -0800 (PST) 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=@gmail.com; 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 dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9E139689CE8; Tue, 3 Jan 2017 09:20:23 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg0-f65.google.com (mail-pg0-f65.google.com [74.125.83.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B0E7C689A50 for ; Tue, 3 Jan 2017 09:20:16 +0200 (EET) Received: by mail-pg0-f65.google.com with SMTP id g1so32694668pgn.0 for ; Mon, 02 Jan 2017 23:20:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:from:subject:message-id:date:user-agent:mime-version; bh=IS2Zf4ogUwTpf58VFh3/I8NbsAk404C/sjmrJzG/u5w=; b=lIEZ4A/rN564wRNG+l08xPdMqIBVfaFkujpfzX4U5iS3y02xZoSSKFPbCbgR+e5Dwc HDPk1iO8LNzRbH2oxcT2yTYFDMHoRKPu5YDaVRzVNs4kbKwgJ99j24DJgxZMa7YCdNIV DQxSqPNFJ2BpilUJwSH5dU4USH705Ofj9ycpH1adRf+lrjiftETPFIQ/ON5KLgH7WkUw cRyWK7LgD2PaOeDt3mjigTGbEiKkc1iBkrf4zdbjgy8Lz52/GeKYBcg92H9IzkFOJ+kW EonFvmJXhusYFnsoxVn9t9ZyKKEdeNYRNoLH/vCWQG4pEYdStHK3p3Ep4bUA1u3LV96s AYAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version; bh=IS2Zf4ogUwTpf58VFh3/I8NbsAk404C/sjmrJzG/u5w=; b=VUeSh2JecSQQL2jXvRib4ePefsSjyZksn7db7I+uxfm/tbwSivuXiIJCmw6iiVzmEr W89oQ35Nzck6zDNkb9sI4Twm7l4GRn2N0pXowbMbOCosrTKNPdJbRd+HCBfcL8ojqM1P 6V9/9oaaUX0O+cw9ZmMrS6SX23jxW9+sQWzpbzedX7+1i4nI2QS4Me1VSx72DRf+pBjk P7NPQNwLK7eMC0JQnfpNmoU/XcR+d1HnP/oqC5Ut+AYKRwxG6HAoatDDUA5De6Gj5Iru +2jBAnCqXlZbAtVpRyeMT8iqFVxJQ7U36BU/AK+KpLrN68w6LFKVBtXhy8rdixngY5QH uCLA== X-Gm-Message-State: AIkVDXJH6tcH5KWuLbbb0p3oFDvdVeeelLqbcqBxhmgQZWS3+4Zs8eHv43G+o/aFo/0COw== X-Received: by 10.99.253.85 with SMTP id m21mr114719238pgj.38.1483427593830; Mon, 02 Jan 2017 23:13:13 -0800 (PST) Received: from [10.239.205.27] (fmdmzpr03-ext.fm.intel.com. [192.55.54.38]) by smtp.gmail.com with ESMTPSA id p5sm124383583pgk.23.2017.01.02.23.13.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jan 2017 23:13:13 -0800 (PST) To: sw@jkqxz.net, zhengxu.maxwell@gmail.com, FFmpeg development discussions and patches From: "Huang, Zhengxu" Message-ID: Date: Tue, 3 Jan 2017 15:13:09 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] libavutil/hwcontext_qsv: Command line using hwaccel 'QSV' doesn't work 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: chaox.a.liu@gmail.com, mypopydev@gmail.com, huazh407@gmail.com Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From 687ce9c804b2618f021100235c46a33b48fa522c Mon Sep 17 00:00:00 2001 From: Zhengxu Date: Wed, 14 Dec 2016 11:55:31 +0800 Subject: [PATCH] libavutil/hwcontext_qsv: Command line using hwaccel 'QSV' doesn't work. Command: ffmpeg -hwaccel qsv -c:v h264_qsv -i test.264 -c:v h264_qsv out.264 Reason: hwcontext_qsv will create a child hwcontext_vaapi. VAAPI will open X11 display ":0.0" defaultly. However, MSDK doesn't support X11 so far. This results in the failure of this command. Fix: When using VAAPI, let VAAPI try to create DRM display handle by scanning device nodes under '/dev/dri/'. Signed-off-by: ChaoX A Liu Signed-off-by: Huang, Zhengxu Signed-off-by: Andrew, Zhang --- libavutil/hwcontext_qsv.c | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 2dc9aca..2701b5a 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -707,12 +707,41 @@ static mfxIMPL choose_implementation(const char *device) return impl; } +static int create_proper_child_device(AVBufferRef **ctx, const char *device, int flags) +{ + enum AVHWDeviceType child_device_type; + char adapter[256]; + int adapter_num; + + if (CONFIG_VAAPI) + child_device_type = AV_HWDEVICE_TYPE_VAAPI; + else if (CONFIG_DXVA2) + child_device_type = AV_HWDEVICE_TYPE_DXVA2; + else + return AVERROR(ENOSYS); + + if (device || CONFIG_DXVA2) + return av_hwdevice_ctx_create(ctx, child_device_type, device, NULL, flags); + + for (adapter_num = 0; adapter_num < 6; adapter_num++) { + if (adapter_num < 3) + snprintf(adapter,sizeof(adapter), + "/dev/dri/renderD%d", adapter_num+128); + else + snprintf(adapter,sizeof(adapter), + "/dev/dri/card%d", adapter_num-3); + if (av_hwdevice_ctx_create(ctx, child_device_type, adapter, NULL, flags) == 0) + return 0; + } + + return AVERROR(ENOSYS); +} + static int qsv_device_create(AVHWDeviceContext *ctx, const char *device, AVDictionary *opts, int flags) { AVQSVDeviceContext *hwctx = ctx->hwctx; QSVDevicePriv *priv; - enum AVHWDeviceType child_device_type; AVDictionaryEntry *e; mfxVersion ver = { { 3, 1 } }; @@ -730,18 +759,7 @@ static int qsv_device_create(AVHWDeviceContext *ctx, const char *device, ctx->free = qsv_device_free; e = av_dict_get(opts, "child_device", NULL, 0); - - if (CONFIG_VAAPI) - child_device_type = AV_HWDEVICE_TYPE_VAAPI; - else if (CONFIG_DXVA2) - child_device_type = AV_HWDEVICE_TYPE_DXVA2; - else { - av_log(ctx, AV_LOG_ERROR, "No supported child device type is enabled\n"); - return AVERROR(ENOSYS); - } - - ret = av_hwdevice_ctx_create(&priv->child_device_ctx, child_device_type, - e ? e->value : NULL, NULL, 0); + ret = create_proper_child_device(&priv->child_device_ctx, e ? e->value : NULL, 0); if (ret < 0) return ret;