From patchwork Thu Feb 9 00:28:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 2460 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp74880vsb; Wed, 8 Feb 2017 16:34:51 -0800 (PST) X-Received: by 10.28.63.5 with SMTP id m5mr545657wma.95.1486600490948; Wed, 08 Feb 2017 16:34:50 -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 p10si4181593wmb.167.2017.02.08.16.34.50; Wed, 08 Feb 2017 16:34:50 -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 9B80A689CE2; Thu, 9 Feb 2017 02:34:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f179.google.com (mail-wr0-f179.google.com [209.85.128.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D26A4689C54 for ; Thu, 9 Feb 2017 02:34:38 +0200 (EET) Received: by mail-wr0-f179.google.com with SMTP id o16so71829608wra.1 for ; Wed, 08 Feb 2017 16:34:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=9F2vRxrlyYu8YW3IJQlWvHaf/5kA59ouchXchdoCeB4=; b=Cc8B5A2dnhnAmW4ecy2m4ssfNkouGoxeNnGiLHUOdI188kEICfIlCI0sGhjaFfeXKq gXtyi/zUQ+no2HK81DjzXPB9vF5XC5y4JHmsb8TRXLRI/3fp6ks95USPWfvjwj/woNDd wZSMssIi816xCZ80ZBjOADTBG/xSKSJfylJX7Eyi7yn1n/gE5zTnEZbxdzTuvHidH4fJ IzhJ9H3heJSZ9WrnqFZoaVY7juWS4IK5I5v0J7ozVyQmkrSAPbp7TcZw/G2s+itt1HLE fMPzABVWpxIHoQtNtN44A0KdM/WGlC+mAuhthecTowSohLI3mvk5NVx0eQ1S+S5r50a+ 6SuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=9F2vRxrlyYu8YW3IJQlWvHaf/5kA59ouchXchdoCeB4=; b=HDRB9k234CwGfKs8usQM/XtlEVUl3FacGEEH6af19t8Hak/pYVBx8JwEJkaB73Jlzr u7SkIa1owZKrrHjtCqMSiQYfnpzYeNHyg7JpLBc67Dm2ObRxY5Bx52yTmexa3B6MlB9Z C0ruz/LuiHVr0vCHu88onmM/xyrbFASrk+8OXRGMnSvdbl882eHjdWLPjbwMgQBtaVdV eVB4sSnVOZzE5985UD3HvKIuN0rdvyFCzSYcp9mr/VxrWi6b8NamQz7DXEp/bhLdw27m A1VTUVQm0N7qVprfaR/LHVi1/FdgHixBzX2Fv/ihXlKkr+RF+txgNXUaDViFbAbj+GgH vEPg== X-Gm-Message-State: AMke39n1RbJr2SPZd3qFliztGFZNFlCACdLiI/+LFic+dJb4uYHrgekBYQGo+1u8vIHsaw== X-Received: by 10.223.170.79 with SMTP id q15mr267093wrd.36.1486600090811; Wed, 08 Feb 2017 16:28:10 -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 o2sm15542634wra.42.2017.02.08.16.28.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Feb 2017 16:28:10 -0800 (PST) To: FFmpeg development discussions and patches From: Mark Thompson Message-ID: Date: Thu, 9 Feb 2017 00:28:09 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.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. --- This seems to have reached agreement in libav. If there are no more comments here, I will commit this to both tines soon. Thanks, - Mark doc/APIchanges | 3 +++ libavcodec/avcodec.h | 24 +++++++++++++++++++++++- libavcodec/utils.c | 1 + libavcodec/version.h | 2 +- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 8bca71ef36..f7cf79e960 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2015-08-28 API changes, most recent first: +2017-xx-xx - xxxxxxx - lavc 57.76.100 - avcodec.h + Add AVCodecContext.hw_device_ctx. + 2017-01-31 - xxxxxxx - lavu 55.46.100 / 55.20.0 - cpu.h Add AV_CPU_FLAG_SSSE3SLOW. diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 1e681e989b..3fc69ecc53 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,27 @@ 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. + * + * This should be used if either the codec device does not require + * hardware frames or any that are used are to be 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. When hw_frames_ctx is set in get_format() for a decoder, this + * field will be ignored while decoding the associated stream segment, but + * may again be used on a following one after another get_format() call. + * + * For both encoders and decoders this field should be set before + * avcodec_open2() is called and must not be written to thereafter. + * + * Note that some decoders may require this field to be set initially in + * order to support hw_frames_ctx at all - in that case, all frames + * contexts used must be created on the same device. + */ + AVBufferRef *hw_device_ctx; } AVCodecContext; AVRational av_codec_get_pkt_timebase (const AVCodecContext *avctx); diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 4ae752ff2f..43e0365033 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -3065,6 +3065,7 @@ av_cold int avcodec_close(AVCodecContext *avctx) avctx->nb_coded_side_data = 0; av_buffer_unref(&avctx->hw_frames_ctx); + av_buffer_unref(&avctx->hw_device_ctx); if (avctx->priv_data && avctx->codec && avctx->codec->priv_class) av_opt_free(avctx->priv_data); diff --git a/libavcodec/version.h b/libavcodec/version.h index c038e4b093..82a89f9c42 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -28,7 +28,7 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 57 -#define LIBAVCODEC_VERSION_MINOR 75 +#define LIBAVCODEC_VERSION_MINOR 76 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \