From patchwork Wed Feb 1 21:47:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 2405 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp2641446vsb; Wed, 1 Feb 2017 13:48:05 -0800 (PST) X-Received: by 10.28.141.78 with SMTP id p75mr23432710wmd.114.1485985685294; Wed, 01 Feb 2017 13:48:05 -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 i30si26091959wra.217.2017.02.01.13.48.04; Wed, 01 Feb 2017 13:48:05 -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 1A4E968098F; Wed, 1 Feb 2017 23:48:02 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BD12D680468 for ; Wed, 1 Feb 2017 23:47:55 +0200 (EET) Received: by mail-wm0-f48.google.com with SMTP id c85so60210149wmi.1 for ; Wed, 01 Feb 2017 13:47:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=from:subject:to:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=7Bad8M5Aezmic5VXI09eW8ludOUuC/T0IdRUtBzlsbE=; b=quA9m2/EJCjJrjxRH8GYRsJHVpmXe6GFSK2gcZTSKHnWz6E71nY8LZ430ut9bbkwPC c0eFkwHo3/W/V/Mn1GjjFNYrYSZSmGFN6MohFsB72claLt1JKIlpjCv6ksPKdaEKry/d GukK7K1xi4EjhBKTysRpz3E1S5ouKEapp5gctjExpWNNVix0ts5RbEytZvyhpWR9/eqG Xh4Vs0IxvUCwSCcyIrqNJNLtpm443d9iYzXa4wRdo4+IaNcTXSX4EXMKHK0/GDAqbzPA smnNQijAsqwep4mOPHCoSp5gV6GQYF+EesWpkMUchUv3W4fNI2kXfxr7Ka9MGj5boRWH Q3Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=7Bad8M5Aezmic5VXI09eW8ludOUuC/T0IdRUtBzlsbE=; b=mZ7d6FigNEwKN5soogX3H0ptF2CasO43pPj7fdqBJ4MCzki7iS2s5P7u+aBj2VfEGX dDCqoGJVzj2TxkUMELrH8syHFKxIWVTRqRng76DJkwzvBuU7nrQYuyDx544kti7FJ6f1 uNg0BFV2cu3IFjyL+doCUHA6PTbT6XIrnZwocHK1dUEHFZmZ3g7V4h+ZJg+1nq6yvDSx tZxyCzq4dD75g1TkYrYXazecJ3k+LQqocwauWY5gr/zAt3XTW09b8Cjuow1BiKfRLNDU sG4r7zGHQ7HxJTsGZcPS2Ljy/A93YbVrKeT0/S94zOQfORMkh6MB3jY0OGZgxTCXZN66 mkHQ== X-Gm-Message-State: AIkVDXL3O3lcl4CdA+KUpBtY9aO7e5BKJILhnOt0H7bUbZV1vA2T++8H2hkrXTgfJnk0Mw== X-Received: by 10.28.206.199 with SMTP id e190mr4934546wmg.98.1485985674740; Wed, 01 Feb 2017 13:47:54 -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 198sm31760795wmn.11.2017.02.01.13.47.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Feb 2017 13:47:54 -0800 (PST) From: Mark Thompson To: FFmpeg development discussions and patches Message-ID: <80771da0-8e35-83b5-10cb-f2506dd78f2a@jkqxz.net> Date: Wed, 1 Feb 2017 21:47:53 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavc: Add device context field to AVCodecContext 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" For use by codec implementations which can allocate frames internally. --- On 01/02/17 14:03, Timo Rothenpieler wrote: > Am 17.01.2017 um 23:28 schrieb Mark Thompson: >> For use by codec implementations which require a device to operation >> but will allocate frames internally. >> --- >> The following patches make use of it for qsv. Is this definition appropriate to solve the issues with cuvid device setup as well? >> >> >> doc/APIchanges | 3 +++ >> libavcodec/avcodec.h | 38 ++++++++++++++++++++++++++++++++++++-- >> libavcodec/utils.c | 1 + >> libavcodec/version.h | 2 +- >> 4 files changed, 41 insertions(+), 3 deletions(-) > > ping about this. > I'd really like to use it for cuvid and get rid of some hackery. This got more discussion in libav, see below for a patch expressing the currently-proposed semantics. (See also for a full implementation for VAAPI, I haven't ported it here yet.) Thanks, - Mark libavcodec/avcodec.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 1e681e989b..cd83e6b27f 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3533,7 +3533,8 @@ typedef struct AVCodecContext { /** * A reference to the AVHWFramesContext describing the input (for encoding) * or output (decoding) frames. The reference is set by the caller and - * afterwards owned (and freed) by libavcodec. + * afterwards owned (and freed) by libavcodec - it should never be read by + * the caller after being set. * * - decoding: This field should be set by the caller from the get_format() * callback. The previous reference (if any) will always be @@ -3583,6 +3584,25 @@ typedef struct AVCodecContext { */ int64_t max_pixels; + /** + * A reference to the AVHWDeviceContext describing the device which will + * be used by a hardware encoder/decoder. The reference is set by the + * caller and afterwards owned (and freed) by libavcodec - it should never + * be read by the caller after being set. + * + * This should only be used if either the codec device does not require + * hardware frames or any that are used are allocated internally by + * libavcodec. If the user wishes to supply any of the frames used as + * encoder input or decoder output then hw_frames_ctx should be used + * instead. + * + * - decoding: This field should be set by the caller from the get_format() + * callback. The previous reference (if any) will always be + * unreffed by libavcodec before the get_format() call. + * + * - encoding: This field should be set before avcodec_open2() is called. + */ + AVBufferRef *hw_device_ctx; } AVCodecContext; AVRational av_codec_get_pkt_timebase (const AVCodecContext *avctx);