From patchwork Mon Jun 12 22:40:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 3947 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.22.4 with SMTP id 4csp78279vsw; Mon, 12 Jun 2017 15:43:49 -0700 (PDT) X-Received: by 10.28.71.91 with SMTP id u88mr661203wma.9.1497307429558; Mon, 12 Jun 2017 15:43:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497307429; cv=none; d=google.com; s=arc-20160816; b=mdHXCIKQjRDiFbj4acahnlGbhO/pm1HndxsAsZ2Bc0GLj0twiqqUqDSU8hq0jkQGUE TAFhVLzfM9CYQOynyS/33vAH9251GBanMwpDq6TG7JnIaQWIZRxsiaE9hQGq6zN0QP2i tE0Jt+1U1/IN3Fou1h8UE/DmbK1g6KuqAXmMYbBnT07ccakS2vPeWeLxxyVFhlRrpGhX 4cgWICBA8q2CXEVTBp9zthZnkgRYbWtIwhfEWW8lXdLWv2FTtQ3MwqvtpmoSgXyzSF72 wdBT5/2XGofd6eQbZYUlL5MNF8VRdc8Ap9sWpgUbXWBU0Wceq9j4QFyG7eCzMFUsrzbi KjSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=C7jcTs/h1EGhpowZrGxaR3KBgdr0Faj4eJi4pwYE7Lg=; b=eVGZqQA9VqaIxk5Tn/l/Nq5d1pJoxSEHWwAZrb+3E7qdtuyWLj0iriU+4ZOSRcbDl1 Rt4WX2U6yzvTDbwFv/NZfc7lqQMZz7lchdINPyRm+KcggaJ+vPsk8H2mYf/4RoFyDA8s XU7Ias6zRvSdxvRfw+8qVh4/SbNawDehiHOIZY6n8Bb58/3EB7RExBp7U++ppMnMbI3f hrhHThkzZ1vKK/qH/vxmRmJpPr1DLcOijVcw1wOsXqeqLekqYGXKnUrnn8nxXhILOBhM oXcqkHVZ5wTSx6BEZMM+nZ7KcwugmZQTsbaSEBGLWXiX/3PfAkCpVYg41D7DoS0z2hD6 Mb/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@jkqxz-net.20150623.gappssmtp.com header.b=tupegfNC; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y6si1683175wmy.53.2017.06.12.15.43.48; Mon, 12 Jun 2017 15:43:49 -0700 (PDT) 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 header.b=tupegfNC; 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 EBBBB68A0B2; Tue, 13 Jun 2017 01:41:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f176.google.com (mail-wr0-f176.google.com [209.85.128.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2395C68A03E for ; Tue, 13 Jun 2017 01:41:12 +0300 (EEST) Received: by mail-wr0-f176.google.com with SMTP id q97so116892412wrb.2 for ; Mon, 12 Jun 2017 15:41:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=w269DjTdg7DqcxBRJXlZv5FkIpnruBxqrI0Mow0Uf+s=; b=tupegfNC+e/AwgtLj+cBDdfUqrudy011pxWUk+FFox2radLaouaXBCHI7Z/X97Qqm/ y40Y4R5gaLpSmmofAlqFauVyp644sBds/PkvdaYvXjf4C3eqfUAWc1coqh2B3KuUfw/f XfdXZGOZ4hEDCrVP213XgrrWUggJp1uLPIGbepmiViMPTeU2iruDLkeKi8hG3Se678Qx RkN2aHUPf9EgEgwiWQlGBtKDmJK9FuvWAwM9nEaOXDz6YlXX5D344UC24HhTwNduBdHc 75Tjh0UrRjJBe3VrwhF4b50IYBC1/ftSnQ+E7vx78XdZ5tozfPxhnfo9YZwSJlYD0zB7 S1Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=w269DjTdg7DqcxBRJXlZv5FkIpnruBxqrI0Mow0Uf+s=; b=ASPlddh3sbgp2axniT11y2+MNuHXXFCOLrjNLL+dhweAeKX4jbMs4NP0JL4I7iSA93 vShcZbe+vlnSxjGa6wvBLFF5NsHpgJ0/9N4LFUAfh/79IZ/IUe87kfTbWT97n1RDs1ql MFsMzBrFLouzCCVPL+0rYyUtLsOJo70Y51FHu6aoPTZPfRsJL5ukJvhcUF7ku7dN0txG 8JtuIZ5tNhDNF38pIlF+oijREWypJn/0YkDb9QH8J09MzNf8Lff87/6DztBFd0oHoBqT /pp10Ois7fkfaQgWXpOlYHM6sM932MfT3QNfFJGj4wU3m1iBTKwt18H3MqhOf+mUy6p4 8kTA== X-Gm-Message-State: AKS2vOzbA+DHHpfAVnO7pasCN1BlM4DihQP8iVU2I+9Ool+Yxf90wKMO zg31cvpzW7Dl/mxIko0= X-Received: by 10.223.169.138 with SMTP id b10mr685318wrd.29.1497307274368; Mon, 12 Jun 2017 15:41:14 -0700 (PDT) Received: from rywe.jkqxz.net (cpc91242-cmbg18-2-0-cust650.5-4.cable.virginm.net. [82.8.130.139]) by smtp.gmail.com with ESMTPSA id m191sm13098233wmg.30.2017.06.12.15.41.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Jun 2017 15:41:13 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Mon, 12 Jun 2017 23:40:35 +0100 Message-Id: <20170612224041.6750-19-sw@jkqxz.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170612224041.6750-1-sw@jkqxz.net> References: <20170612224041.6750-1-sw@jkqxz.net> Subject: [FFmpeg-devel] [PATCH 18/24] hwcontext: Add frame context mapping for nontrivial contexts 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Some frames contexts are not usable without additional format-specific state in hwctx. This change adds new functions frames_derive_from and frames_derive_to to initialise this state appropriately when deriving a frames context which will require it to be set. (cherry picked from commit 27978155bc661eec9f22bcf82c9cfc099cff4365) --- libavutil/hwcontext.c | 9 ++++++++- libavutil/hwcontext_internal.h | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c index 7f9b1d33e3..ba7ffd1951 100644 --- a/libavutil/hwcontext.c +++ b/libavutil/hwcontext.c @@ -819,7 +819,14 @@ int av_hwframe_ctx_create_derived(AVBufferRef **derived_frame_ctx, goto fail; } - ret = av_hwframe_ctx_init(dst_ref); + ret = AVERROR(ENOSYS); + if (src->internal->hw_type->frames_derive_from) + ret = src->internal->hw_type->frames_derive_from(dst, src, flags); + if (ret == AVERROR(ENOSYS) && + dst->internal->hw_type->frames_derive_to) + ret = dst->internal->hw_type->frames_derive_to(dst, src, flags); + if (ret == AVERROR(ENOSYS)) + ret = 0; if (ret) goto fail; diff --git a/libavutil/hwcontext_internal.h b/libavutil/hwcontext_internal.h index 6451c0e2c5..0a0c4e86ce 100644 --- a/libavutil/hwcontext_internal.h +++ b/libavutil/hwcontext_internal.h @@ -92,6 +92,11 @@ typedef struct HWContextType { const AVFrame *src, int flags); int (*map_from)(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src, int flags); + + int (*frames_derive_to)(AVHWFramesContext *dst_ctx, + AVHWFramesContext *src_ctx, int flags); + int (*frames_derive_from)(AVHWFramesContext *dst_ctx, + AVHWFramesContext *src_ctx, int flags); } HWContextType; struct AVHWDeviceInternal {