From patchwork Mon Jan 16 15:44:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wm4 X-Patchwork-Id: 2225 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp86986vsb; Mon, 16 Jan 2017 07:51:40 -0800 (PST) X-Received: by 10.223.162.10 with SMTP id p10mr23901418wra.160.1484581900598; Mon, 16 Jan 2017 07:51:40 -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 l143si12863845wmg.74.2017.01.16.07.51.39; Mon, 16 Jan 2017 07:51:40 -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=@googlemail.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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 58FED689F96; Mon, 16 Jan 2017 17:51:27 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf0-f66.google.com (mail-lf0-f66.google.com [209.85.215.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2B36E689F8B for ; Mon, 16 Jan 2017 17:51:21 +0200 (EET) Received: by mail-lf0-f66.google.com with SMTP id x1so7825350lff.0 for ; Mon, 16 Jan 2017 07:51:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ujWIEQasXTzMIcJ5sDqzq9kpfaUiv8TWeZri4OC5pCI=; b=nKrIOSB5iO8VVQHmGq3M/WrTKETQt0TZ9wNgw+LI7dxdOvur3x+05/MEbTS5Lge8kE gm/mxRSWSAigHc3rSXGbYJaiUkDa6jJuLof7iyszCylAP4z702HZo17wIb3TL9Yj3rR7 2alfkfVS9Q+0fuS06jWekkM9TOb76kigPZo1uQ3sDkhTDXYAmCUV6xB+5YFGfTZOdK2U Bbt7yv7NAwqb8T8uPtf77eaKKR8m63ioa3mDYS2g+cIWCM3xHs0V+5dl8GfBrM5yJJAC yWfSVhV/RCGigkARWjlngrX+gLfNku3oM4T4UxtU06ZOZAWooJXMrQwP5v3UBPAwXdGF l9vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ujWIEQasXTzMIcJ5sDqzq9kpfaUiv8TWeZri4OC5pCI=; b=fysaLy5d/96uuC62bQYktbkme1YszNvXfxiZtnChnNQLdHfkyG838wRxIErb8VH5k2 w1EY7CpKRiug9vjMNcsLPbaiOiy1kxWj/Kc8jDTuPlMYTESOXVQ0h41s2KWcqJnV9j0B VrccNcbNFRXn0ydgALvUofZ1yBRNcpzBfZxBCq/vg4EQ0Jx+ZgmJZTjSU8LVdaI+luu4 K8NOZX9AE6oZHYnm48YNqNZpCnIe9yR0aM1msK0Ri1ECjBPpd8kgmxIl1ieWww7e5U8c G9LKGb68YLz8XBealSPUHHCwq6gv9r+OJpjQimSmO1xL6+TGd4WEHoWst1rjXUAsD9/C usRw== X-Gm-Message-State: AIkVDXLujJ9O7fuShq5WPp7EAVonc+FoAqzk5aRIO9ieg3UrwP0SIRYNiOODk7kqeRylmw== X-Received: by 10.25.20.66 with SMTP id k63mr12926281lfi.111.1484581465681; Mon, 16 Jan 2017 07:44:25 -0800 (PST) Received: from localhost.localdomain (p4FF00F06.dip0.t-ipconnect.de. [79.240.15.6]) by smtp.googlemail.com with ESMTPSA id q19sm7634547lfi.1.2017.01.16.07.44.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jan 2017 07:44:24 -0800 (PST) From: wm4 To: ffmpeg-devel@ffmpeg.org Date: Mon, 16 Jan 2017 16:44:16 +0100 Message-Id: <20170116154416.19116-1-nfxjfg@googlemail.com> X-Mailer: git-send-email 2.11.0 Subject: [FFmpeg-devel] [PATCH] hwcontext_cuda: implement frames_get_constraints 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 Cc: wm4 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Copied and modified from hwcontext_qsv.c. --- libavutil/hwcontext_cuda.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/libavutil/hwcontext_cuda.c b/libavutil/hwcontext_cuda.c index 5dd0d99272..ed595c3e0f 100644 --- a/libavutil/hwcontext_cuda.c +++ b/libavutil/hwcontext_cuda.c @@ -39,6 +39,31 @@ static const enum AVPixelFormat supported_formats[] = { AV_PIX_FMT_P016, }; +static int cuda_frames_get_constraints(AVHWDeviceContext *ctx, + const void *hwconfig, + AVHWFramesConstraints *constraints) +{ + int i; + + constraints->valid_sw_formats = av_malloc_array(FF_ARRAY_ELEMS(supported_formats) + 1, + sizeof(*constraints->valid_sw_formats)); + if (!constraints->valid_sw_formats) + return AVERROR(ENOMEM); + + for (i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++) + constraints->valid_sw_formats[i] = supported_formats[i]; + constraints->valid_sw_formats[FF_ARRAY_ELEMS(supported_formats)] = AV_PIX_FMT_NONE; + + constraints->valid_hw_formats = av_malloc_array(2, sizeof(*constraints->valid_hw_formats)); + if (!constraints->valid_hw_formats) + return AVERROR(ENOMEM); + + constraints->valid_hw_formats[0] = AV_PIX_FMT_CUDA; + constraints->valid_hw_formats[1] = AV_PIX_FMT_NONE; + + return 0; +} + static void cuda_buffer_free(void *opaque, uint8_t *data) { AVHWFramesContext *ctx = opaque; @@ -376,6 +401,7 @@ const HWContextType ff_hwcontext_type_cuda = { .device_create = cuda_device_create, .device_init = cuda_device_init, .device_uninit = cuda_device_uninit, + .frames_get_constraints = cuda_frames_get_constraints, .frames_init = cuda_frames_init, .frames_get_buffer = cuda_get_buffer, .transfer_get_formats = cuda_transfer_get_formats,