From patchwork Tue Jan 17 22:32:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 2241 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp739655vsb; Tue, 17 Jan 2017 14:32:26 -0800 (PST) X-Received: by 10.28.145.3 with SMTP id t3mr351125wmd.47.1484692346178; Tue, 17 Jan 2017 14:32:26 -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 t19si26587557wrb.187.2017.01.17.14.32.25; Tue, 17 Jan 2017 14:32:26 -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 B028968A311; Wed, 18 Jan 2017 00:32:13 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3727968A2B0 for ; Wed, 18 Jan 2017 00:32:07 +0200 (EET) Received: by mail-wm0-f46.google.com with SMTP id c206so246465187wme.0 for ; Tue, 17 Jan 2017 14:32:17 -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=OCJNrTAl33qGfhLk5KnTeA1nK/1qhHBcTlfPylyKwdU=; b=iCmqoBUNIyTNjAz7QT+276G7ywtlCKSRt5kXivGM2iTbSwKZTAS7FgVqz/aEsYrCxU sG1aZFMhjk9oqgsLwou8UKu46MqJcVuGIeqWJNXgz615Oeu6V4IXB7c/PlrtQjqTYZvG iZ2AS540r8G7zldiQmUagVvGIApy1hzfrZE/U5UEogaKhOPSFLxz2fTNYFXJYNQy1Y+8 SunGuDM8BmFm9aqyU6plTG4bkNC6ensdNSMebVvNqRY6PucNIw9lqSyggcm0SymsZmYZ SDIOaIDyAVcnsMGRbrkqCLZeNfoZwgMIFyKXnxSrgNOL032RzSAILs4sQzABCF7gO9FM L6Gw== 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=OCJNrTAl33qGfhLk5KnTeA1nK/1qhHBcTlfPylyKwdU=; b=NJ3qTK1jD5XcQF8Cq+G7RTi0zqMnaf49gfzyRTVn4EslUDbOpfElvbUTNLAW/18wp2 6gWTr4fg50Lcd6rjMjq2MN9qFwDuNmSxIef8HV6LesFlPOXDWevcJC1LbMelPTLpzJE0 hZcjmaoJS10CLA4sD4NvbqNcjC1pJoB76LWdX19tn4amQ0E8uTjSC2CScwJQZjedXB+5 I+UQ2FVgydHFWkWYPsxjpBMBLDhUOLQfm0vlOhYgNL6oPwxqZPZpC6v5Z+YWwjqNWsNU kvdlHjiM4vgugOKZd/ERyaCZsUQ4Ik7NTYM4ieGRoP5NsL1M4tdlmrdHld2HV/laHrgr GfYg== X-Gm-Message-State: AIkVDXJSoO5M4gmgvEHvf6DWA5nvRUAsJDmfdkGZu9EqbDSM2ty09s/Fil4t/DqP3gynqA== X-Received: by 10.28.189.135 with SMTP id n129mr316591wmf.92.1484692336813; Tue, 17 Jan 2017 14:32:16 -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 63sm40217226wmg.2.2017.01.17.14.32.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Jan 2017 14:32:16 -0800 (PST) To: FFmpeg development discussions and patches References: <6b40ed0b-4faf-1591-1a47-e8ad6bd12952@jkqxz.net> From: Mark Thompson Message-ID: Date: Tue, 17 Jan 2017 22:32:15 +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 6/6] ffmpeg: Pass the global device context to encoder and decoder instances 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" --- ffmpeg.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ffmpeg.c b/ffmpeg.c index 6d1e358..781c0a4 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2748,6 +2748,12 @@ static int init_input_stream(int ist_index, char *error, int error_len) * audio, and video decoders such as cuvid or mediacodec */ av_codec_set_pkt_timebase(ist->dec_ctx, ist->st->time_base); + if (hw_device_ctx) { + ist->dec_ctx->hw_device_ctx = av_buffer_ref(hw_device_ctx); + if (!ist->dec_ctx->hw_device_ctx) + return AVERROR(ENOMEM); + } + if (!av_dict_get(ist->decoder_opts, "threads", NULL, 0)) av_dict_set(&ist->decoder_opts, "threads", "auto", 0); if ((ret = avcodec_open2(ist->dec_ctx, codec, &ist->decoder_opts)) < 0) { @@ -3271,6 +3277,12 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len) !av_dict_get(ost->encoder_opts, "ab", NULL, 0)) av_dict_set(&ost->encoder_opts, "b", "128000", 0); + if (hw_device_ctx) { + ost->enc_ctx->hw_device_ctx = av_buffer_ref(hw_device_ctx); + if (!ost->enc_ctx->hw_device_ctx) + return AVERROR(ENOMEM); + } + if (ost->filter && av_buffersink_get_hw_frames_ctx(ost->filter->filter)) { ost->enc_ctx->hw_frames_ctx = av_buffer_ref(av_buffersink_get_hw_frames_ctx(ost->filter->filter)); if (!ost->enc_ctx->hw_frames_ctx)