From patchwork Tue Jan 17 22:31:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 2240 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp739485vsb; Tue, 17 Jan 2017 14:31:58 -0800 (PST) X-Received: by 10.28.94.8 with SMTP id s8mr17355169wmb.117.1484692318479; Tue, 17 Jan 2017 14:31:58 -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 c63si17483951wmf.97.2017.01.17.14.31.58; Tue, 17 Jan 2017 14:31:58 -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=@jkqxz-net.20150623.gappssmtp.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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2C3C268A2D9; Wed, 18 Jan 2017 00:31:46 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 75DC1689A6F for ; Wed, 18 Jan 2017 00:31:40 +0200 (EET) Received: by mail-wm0-f51.google.com with SMTP id c85so220604120wmi.1 for ; Tue, 17 Jan 2017 14:31:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=8K0DAeWpa2kLlvfQXL3BexFsFdt6p6DMrX9hNFtPwHY=; b=b+rZlHtzNOWuB6jdZzDNtz9H0Au2e10hGu+1R3FebWsYdVYhZhoWLeqx8uKeynLJ5F FwBZtK+QHRvzdbM9P6OQqiGiV9+yRC4cclBnbj/fihEKiVoNqkK5OjJ6AWeEXbpu1Fjz OdpC1prqnt0iO3zECZRx3dtc48ZwPlnK5MmD9ruDxGAlMpYEJNFyiRuRUml90is+m6iX W4BTylVi/0cLsiB4nxBhQ4FRBLpRh5Ded8iwXTjEhkG3pt270vHBAA4bmhDtA/KbhK2C Sz+L8IGLrJP27theco99vUVz0q5Z5EzSZkonY4blMVigZhlUQREaZ68T9Kcr4k0JFNqu Fs4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=8K0DAeWpa2kLlvfQXL3BexFsFdt6p6DMrX9hNFtPwHY=; b=RSxxcS/u21DlFYAtk/wV2ZOgHEXNDScdcvYilf2boO/3fuqPgk6QRe6Y8/CR6+hapQ 20a5Hr55Rvl8DtYm9/QPPSBM2+ctuhh5ifxjHhRZFfJ2gkiczz7uJG6h5ALSO6vaUZVE ty87aJuMPVkxgP3TAQMFbvr7n8iXeTBRYyKSTTCJ9CbcwDc/bML2LouFMRH3PDZzcGX+ 80b4K+JntKbwq1tJ4LWl+3w++bMxwHFe056rJGA3uF2M2MWzwBA8f6ihyveFiEEcfvBe p3Tbful9DJyqdbvAdC0yHkcyAzQpKjAVO0gnFZ6WY44SCV9esBD7d4smkZ0MqZ45hIex q7tg== X-Gm-Message-State: AIkVDXLerBcNCBeJynswTBFA2yZhs9OBPneKjo5xh1NY9IWzXmr/I5yp0YBaQZ5Z9vFk0Q== X-Received: by 10.28.137.211 with SMTP id l202mr315627wmd.88.1484692310014; Tue, 17 Jan 2017 14:31:50 -0800 (PST) Received: from [192.168.0.8] (cpc91242-cmbg18-2-0-cust650.5-4.cable.virginm.net. [82.8.130.139]) by smtp.gmail.com with ESMTPSA id y65sm36841747wmb.5.2017.01.17.14.31.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Jan 2017 14:31:49 -0800 (PST) To: FFmpeg development discussions and patches References: <6b40ed0b-4faf-1591-1a47-e8ad6bd12952@jkqxz.net> From: Mark Thompson Message-ID: <2e242e2c-ae6f-4fc9-aadb-6bfe007d68b2@jkqxz.net> Date: Tue, 17 Jan 2017 22:31:48 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0 MIME-Version: 1.0 In-Reply-To: <6b40ed0b-4faf-1591-1a47-e8ad6bd12952@jkqxz.net> Subject: [FFmpeg-devel] [PATCH 5/6] ffmpeg: Always make the qsv device if the option is set 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Previously it was only created if the decode hwaccel was requested; this makes it unconditionally so we can use it without the hwaccel. --- ffmpeg.h | 4 +--- ffmpeg_opt.c | 13 ++++++++++++- ffmpeg_qsv.c | 14 ++++++-------- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/ffmpeg.h b/ffmpeg.h index 75bf50e..7362c2d 100644 --- a/ffmpeg.h +++ b/ffmpeg.h @@ -604,9 +604,6 @@ extern const OptionDef options[]; extern const HWAccel hwaccels[]; extern int hwaccel_lax_profile_check; extern AVBufferRef *hw_device_ctx; -#if CONFIG_QSV -extern char *qsv_device; -#endif void term_init(void); @@ -641,6 +638,7 @@ int vdpau_init(AVCodecContext *s); int dxva2_init(AVCodecContext *s); int vda_init(AVCodecContext *s); int videotoolbox_init(AVCodecContext *s); +int qsv_device_init(const char *device); int qsv_init(AVCodecContext *s); int qsv_transcode_init(OutputStream *ost); int vaapi_decode_init(AVCodecContext *avctx); diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index a1c02fc..49397be 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -462,6 +462,17 @@ static int opt_vaapi_device(void *optctx, const char *opt, const char *arg) } #endif +#if CONFIG_QSV +static int opt_qsv_device(void *optctx, const char *opt, const char *arg) +{ + int err; + err = qsv_device_init(arg); + if (err < 0) + exit_program(1); + return 0; +} +#endif + /** * Parse a metadata specifier passed as 'arg' parameter. * @param arg metadata string to parse @@ -3694,7 +3705,7 @@ const OptionDef options[] = { #endif #if CONFIG_QSV - { "qsv_device", HAS_ARG | OPT_STRING | OPT_EXPERT, { &qsv_device }, + { "qsv_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_qsv_device }, "set QSV hardware device (DirectX adapter index, DRM path or X11 display name)", "device"}, #endif diff --git a/ffmpeg_qsv.c b/ffmpeg_qsv.c index 86824b6..9356f05 100644 --- a/ffmpeg_qsv.c +++ b/ffmpeg_qsv.c @@ -28,8 +28,6 @@ #include "ffmpeg.h" -char *qsv_device = NULL; - static int qsv_get_buffer(AVCodecContext *s, AVFrame *frame, int flags) { InputStream *ist = s->opaque; @@ -43,19 +41,19 @@ static void qsv_uninit(AVCodecContext *s) av_buffer_unref(&ist->hw_frames_ctx); } -static int qsv_device_init(InputStream *ist) +int qsv_device_init(const char *device) { int err; AVDictionary *dict = NULL; - if (qsv_device) { - err = av_dict_set(&dict, "child_device", qsv_device, 0); + if (device) { + err = av_dict_set(&dict, "child_device", device, 0); if (err < 0) return err; } err = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_QSV, - ist->hwaccel_device, dict, 0); + device, dict, 0); if (err < 0) { av_log(NULL, AV_LOG_ERROR, "Error creating a QSV device\n"); goto err_out; @@ -76,7 +74,7 @@ int qsv_init(AVCodecContext *s) int ret; if (!hw_device_ctx) { - ret = qsv_device_init(ist); + ret = qsv_device_init(ist->hwaccel_device); if (ret < 0) return ret; } @@ -148,7 +146,7 @@ int qsv_transcode_init(OutputStream *ost) av_log(NULL, AV_LOG_VERBOSE, "Setting up QSV transcoding\n"); if (!hw_device_ctx) { - err = qsv_device_init(ist); + err = qsv_device_init(ist->hwaccel_device); if (err < 0) goto fail; }