From patchwork Mon May 21 22:35:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 9043 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp805796jad; Mon, 21 May 2018 15:35:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqk58xGInlwHM5c8/FSFx3VNQr3Z3EINqLN5ZtCBwfT+9GwvTwTAv5lpe70l/EP30520Yle X-Received: by 2002:adf:ec44:: with SMTP id w4-v6mr4627429wrn.275.1526942124800; Mon, 21 May 2018 15:35:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526942124; cv=none; d=google.com; s=arc-20160816; b=ZCVlQikzr2MqFV0au4gVUZIWbbAIlLlvFtO1EfWnXyGrqU+vcRZSPiDIVnxrGFsvnL bgiG4x1V5VUGBBfVwty59sVfbByM3k9bru6e4SI7Ek48OMF8uldWSm4T/JihxS5rUe/U hwFbSti04pwZPe2YIbNaoGMgvv0S3qpnuxmFXmtcbpHPHtqEN3OQ9DxDktWGcRW3cDpN 0YzAnlwaqrJQHxl7b90oJ124ecznHVkwt2h/6UjryZMRPum1YjQnq+7Apm0KTGJ9Ipwe ZGkzDrHbchwUrL3DiNMff8xQd3XWrE4YWte5nw7J0zULHzuMTxl9MOnzJem3TIqJ1/g6 sttA== 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:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=jLuX9IYWmBTztrPRyTOCE0obAcoDrxtiJ/NJwtFhCew=; b=OAGlBBcs9LoO5gsMEwPhdaWqZjabcMzNB5s1678RsduQyfUu1UEduQSunRGV1HWI8W xJrcd95qpWD8tO45K0wJ2VKvucFX5H1YKgqn/P9o7VPtABYREWconTMH+FnOfCVXsvyd yv02LhOewcCV4Bqwm08hfCoqP7dS6Gbtf4AHvZEcxlRmG1zYY7tXXcnrq4uJj4jgMckV jbTb6u4H0j5Yae3CB7nIXgC57saaR+f3g9OB10vBu9aGLfp96Cg8xbLvnNT/ZkqoY0xj cbc+SIwtIFdIZpmXi+vNjqu4xM0xMbqFGK4ViJyr5susUOcWyHUAKX0v6Iim7mqowcCL B3hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@jkqxz-net.20150623.gappssmtp.com header.s=20150623 header.b=A8k6UpFG; 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 f124-v6si10502470wma.188.2018.05.21.15.35.24; Mon, 21 May 2018 15:35:24 -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.s=20150623 header.b=A8k6UpFG; 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 A8521689CB4; Tue, 22 May 2018 01:34:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8042F680527 for ; Tue, 22 May 2018 01:34:35 +0300 (EEST) Received: by mail-wm0-f52.google.com with SMTP id t11-v6so27869429wmt.0 for ; Mon, 21 May 2018 15:35:16 -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; bh=nQbGclzf8ggA6cwIRi2vOCGk9hbfj1R5WX51giWT7/4=; b=A8k6UpFGtOOhGPLpMqDqvYVY3Zc7BEez1zGUwtf8N/y2wtf/0lXgB95mi+h9K/fKzL Tw/ftKWIvBnMpfg6SRBtMtruwM+ktCpDBpT7dtLDMSPZCYYGObjUYPiKVmh9+xMiE4be c63kAGgM5jGYffUpz+F9hC4naneqrsYU9gceOZFbFtfhuaGAPGHeNn8ohJurCaVQLhfY Zn1Dr50qXSJRK2HdG1aq6eCNnkYlIGfQyW8i8S0XLWQiJTc96aI3Rb8ogyT8AROCwqYL XKhBvjatHVgHSbMtcvjbhobEwwOs8S0ALnRSzQvmY2bBTmBbtGnkrdRl0UHLGH1G/U0F hxYw== 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; bh=nQbGclzf8ggA6cwIRi2vOCGk9hbfj1R5WX51giWT7/4=; b=K9F9hpdFCnZKtNVeJ/3hZ99Kc4QXMZzoQsUmpuJ8NzHNj55dosGF4BbA5QMcxpWCpt K/Lzu1PXY0EXbp6PBIx/EuG3RzbK/l+jWUxX2W2PGlUZJZaC3RCEBB54j0z2hZGxez3f Fjj11D6EvUOhCMGzu8C+wOZypNdvqF+dCT4u+Y7C5HXMJajq7c3aYetdbuYa+1qkIaCF wFB61WVYxpW8x8VeHKZxOO1C5D2sTrPZ5UxfN70A+UGKktP3Iwl+Uxj9LhlnozPKebU4 +wQW1gA2aP5f/nkHfNFaOutF9Y7XZXvHKFkHkcdL0LRW3arWcZOM6FdtuJTZjX+VmuVH S8FQ== X-Gm-Message-State: ALKqPwdboMZvf6h9ct5lEUeT5r7ibN1vfoQey7cvSE3zPGXeW+e//YA0 7HNrforyp7xbVX7suR5ESxyjLevd X-Received: by 2002:a1c:d546:: with SMTP id m67-v6mr387847wmg.117.1526942115608; Mon, 21 May 2018 15:35:15 -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 e7-v6sm15995209wrn.88.2018.05.21.15.35.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 May 2018 15:35:14 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Mon, 21 May 2018 23:35:08 +0100 Message-Id: <20180521223511.20395-1-sw@jkqxz.net> X-Mailer: git-send-email 2.16.3 Subject: [FFmpeg-devel] [PATCH 1/4] hwcontext_opencl: Allocate a test image in frames_init 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" This ensures that the format and dimensions are actually valid - previously this wasn't checked, so we would only fail when the user actually attempted to allocate an image. --- libavutil/hwcontext_opencl.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c index 43b5c5ae0c..c29a521f07 100644 --- a/libavutil/hwcontext_opencl.c +++ b/libavutil/hwcontext_opencl.c @@ -1696,11 +1696,23 @@ static int opencl_frames_init_command_queue(AVHWFramesContext *hwfc) static int opencl_frames_init(AVHWFramesContext *hwfc) { if (!hwfc->pool) { + AVBufferRef *test_ref; + hwfc->internal->pool_internal = av_buffer_pool_init2(sizeof(cl_mem), hwfc, &opencl_pool_alloc, NULL); if (!hwfc->internal->pool_internal) return AVERROR(ENOMEM); + + test_ref = av_buffer_pool_get(hwfc->internal->pool_internal); + if (!test_ref) { + av_log(hwfc, AV_LOG_ERROR, "Unable to create %dx%d images " + "with format %s.\n", hwfc->width, hwfc->height, + av_get_pix_fmt_name(hwfc->sw_format)); + return AVERROR(EINVAL); + } + + av_buffer_unref(&test_ref); } return opencl_frames_init_command_queue(hwfc);