From patchwork Tue Jan 17 22:28:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 2242 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp741373vsb; Tue, 17 Jan 2017 14:37:14 -0800 (PST) X-Received: by 10.223.160.83 with SMTP id l19mr32912wrl.16.1484692634037; Tue, 17 Jan 2017 14:37:14 -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 g29si26605130wra.149.2017.01.17.14.37.13; Tue, 17 Jan 2017 14:37:13 -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 93FFE68A323; Wed, 18 Jan 2017 00:37:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f50.google.com (mail-wm0-f50.google.com [74.125.82.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4C5C1680A80 for ; Wed, 18 Jan 2017 00:36:55 +0200 (EET) Received: by mail-wm0-f50.google.com with SMTP id r126so221545136wmr.0 for ; Tue, 17 Jan 2017 14:37:05 -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=KDjU4yYmniXYSTPBYQCJtkimuwx87P5elvEY20mbikg=; b=jUu33r8ltxCcQDMWI5gSe2qpPvy+nLYduRBgKfYqnorDZJHZuyNqCEyh4J/uFAujm6 +8nUVWj0t4y7vdGd60qYT1UTS+4AnK7EoO/iqeDDAOmVUyVTgEZpZIDvnHffRtCbfZ36 I9oE4fxIrTHgyp2BcEDAqdwmjFI/g8huVOh9O+yAkaauUe4BX7d2zfbS6Ndj0fQjCIv8 qLKU3Jc3fNenXG6nqTNC8zhrBAa6qVAz4jytBwPOUGPZWo4qMQiVqyC8FLu0nD+p7Cmm 41++LEe9psFjLEJFExuyDCc1/R/Wr+8w+Fa/4C7Rz0v34vITVa1ZTseZnorlWP8CirXs szNg== 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=KDjU4yYmniXYSTPBYQCJtkimuwx87P5elvEY20mbikg=; b=l3wLmRL2Np/4lqQVyRBQtGju0ckp7QEIfS+ip4Tozk5WzVHy9FDccWA8/VN7OAiwMC CL8A+KNCPuTVnUHEg1Cu7/gPpPYSI7Twnn9GX32cAJ5Qe7qyx8XnCD2bIfwMl5lH82gv IPlff6Hv5FAqG+q4RuzkUen21mkWWViJ+wa0OYCh5ieInSqLCPLIeWThSoZwh81vAFFP 21lR+jQHH1QghveoCesyynYQ+rrtZDtDCNlv2SKkssouO5TOP6qAQV2hJzDN79nyNnz7 DFd4ZPyme1mlF88wRSVlRxWBW6/dnghfj3yFsXFoWcJtN0cAcIVoxVw3bJmjRQ7Hmne/ 7XNg== X-Gm-Message-State: AIkVDXL9YnjtNEumeF+ZwAHgNwiT965bS3P2fncKWFEIUsrwYSTYpApENpcps+DSZTUCwg== X-Received: by 10.28.55.73 with SMTP id e70mr16871870wma.99.1484692124463; Tue, 17 Jan 2017 14:28:44 -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 81sm40134144wmw.7.2017.01.17.14.28.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Jan 2017 14:28:43 -0800 (PST) To: FFmpeg development discussions and patches From: Mark Thompson Message-ID: <6b40ed0b-4faf-1591-1a47-e8ad6bd12952@jkqxz.net> Date: Tue, 17 Jan 2017 22:28:43 +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 1/6] 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 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(-) diff --git a/doc/APIchanges b/doc/APIchanges index c0ed711..d1d9a14 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.74.100- avcodec.h + Add AVCodecContext.hw_device_ctx. + 2017-01-12 - xxxxxxx - lavfi 6.69.100- buffersink.h Add av_buffersink_get_*() functions. diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 4d26d14..9758bb8 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3532,8 +3532,13 @@ 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. + * or output (decoding) frames which will be used by a hardware codec. + * + * It can be set by the user if they wish to supply the frames used, or it + * can be set automatically by libavcodec for decoding when get_format() + * indicates that it should output hardware frames. + * + * If set by the user: * * - decoding: This field should be set by the caller from the get_format() * callback. The previous reference (if any) will always be @@ -3550,6 +3555,20 @@ typedef struct AVCodecContext { * AVCodecContext.pix_fmt. * * This field should be set before avcodec_open2() is called. + * + * If set by libavcodec: + * + * - decoding: The hw_device_ctx field should be set by the user before + * calling avcodec_open2(). If at some later point a hardware + * pixel format is selected by get_format(), then a new + * AVHWFramesContext will be created by the decoder and put + * in this field. + * + * It will be valid when get_buffer2() is called (which must + * then return a buffer from the given context). + * + * - encoding: Unused. In this case the user must not supply hardware + * frames to the encoder. */ AVBufferRef *hw_frames_ctx; @@ -3583,6 +3602,21 @@ 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 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 frames may be supplied by the user, then + * hw_frames_ctx must be used instead. + * + * If a device is to be supplied, this field should be set before + * avcodec_open2() is called. + */ + 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 1263306..0d1f87e 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -3060,6 +3060,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 b0dd46d..33b3bcb 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 73 +#define LIBAVCODEC_VERSION_MINOR 74 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \