From patchwork Fri Feb 14 10:41:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 17784 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 34E2244A594 for ; Fri, 14 Feb 2020 12:41:50 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1407C68AF17; Fri, 14 Feb 2020 12:41:50 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A9DCC68A636 for ; Fri, 14 Feb 2020 12:41:43 +0200 (EET) Received: by mail-wr1-f68.google.com with SMTP id g3so10314929wrs.12 for ; Fri, 14 Feb 2020 02:41:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=lEU4aVz9ZyVpu2OjK78M4559qLHsQBZop5Kms0OBf78=; b=HH2c5pwlHyt5VoJlvm1558yrsIB8SY3cb0nEDG/vfdIJt25W/NLnYbDtQPN/DR+M0V KMgJRDKwFleiFbDy5OlC5fgrkNJ2gOWRpeExRNxjqQijnJBzcPBDA9zvlRGWGx9RwLr7 /9qtUDBP79LboMrJ7BWPTRhtUfVjqPM56b6KZCZjA6qUp0Yk2cc8FbdCcEnUyZZyfR/b 48irIFfOqZ+6VTOjVZVzBDOI2Hjjg6FdtBTQjHeYbeopc9BiYpGA3bC1DTq3iIFBQyXS WIN1ZmsLNRkkoY9vzyw6dFkj4w97k4Wbr4WxLk1P8HPWTAxmUEgmVPGrUOHyJq6fK4tZ d9mw== 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=lEU4aVz9ZyVpu2OjK78M4559qLHsQBZop5Kms0OBf78=; b=SwihtbCI7/gxLqiJdZPSC4m49RB2a0h/d/FvaTDx/WoxfuFazTkqGCTDGvHwUzfBE5 1balWQbUlBOZG4bZ/JNIOLBB5Dnn9rVzlgdMh1K4A8mK85OBXZf1pSKqZP19a+O1wCK5 bS75iiM6Q4WBFbaG6Urnlech/FdJ/Sj1eCGatyuFlqp0iLtLRUc6q+j3p3NXCBbC3efs yssENC7TtRJVfc8mVeLbrryWYphM4OMoqseZ166v8uXZsCZPLbtZIP8tbaZoqwlR3cU4 A1d2YxDjmACAYhIexJcb14rLjXD14XLC/oefoubzsM4CfmgL7zW2r7lxlt1Myco+7NTZ kt5w== X-Gm-Message-State: APjAAAU0IKfooqZ5q7IJIk+4KmwpQhf1wGNsbxmulbKjGqGjB6o8JwWA kcU3U7E176Ct7RWaoYjKQvc0i025 X-Google-Smtp-Source: APXvYqzGFvBrWV02hWdcJjMPTexI5eP2ow6DFCCZYGfc8CIB8BmJv0Os4ViFuKLILCl9yHfRSW337Q== X-Received: by 2002:adf:8b59:: with SMTP id v25mr3449363wra.419.1581676902808; Fri, 14 Feb 2020 02:41:42 -0800 (PST) Received: from localhost.localdomain ([37.244.235.245]) by smtp.gmail.com with ESMTPSA id l132sm7010959wmf.16.2020.02.14.02.41.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Feb 2020 02:41:42 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Fri, 14 Feb 2020 11:41:34 +0100 Message-Id: <20200214104134.27392-1-onemda@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH] avfilter/vf_program_opencl: make it possible to pass plane as argument to kernel 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" Fixes #7190 Signed-off-by: Paul B Mahol --- doc/filters.texi | 4 ++++ libavfilter/vf_program_opencl.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/doc/filters.texi b/doc/filters.texi index b957b9302e..5bd0e44b67 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -21297,6 +21297,8 @@ Number of inputs to the filter. Defaults to 1. @item size, s Size of output frames. Defaults to the same as the first input. +@item plane +Currently processed plane number is set as last kernel argument. @end table The program source file must contain a kernel function with the given name, @@ -22483,6 +22485,8 @@ Pixel format to use for the generated frames. This must be set. @item rate, r Number of frames generated every second. Default value is '25'. +@item plane +Currently processed plane number is set as last kernel argument. @end table For details of how the program loading works, see the @ref{program_opencl} diff --git a/libavfilter/vf_program_opencl.c b/libavfilter/vf_program_opencl.c index ec25e931f5..3cf93464ba 100644 --- a/libavfilter/vf_program_opencl.c +++ b/libavfilter/vf_program_opencl.c @@ -42,6 +42,7 @@ typedef struct ProgramOpenCLContext { const char *source_file; const char *kernel_name; int nb_inputs; + int plane_is_arg; int width, height; enum AVPixelFormat source_format; AVRational source_rate; @@ -138,6 +139,16 @@ static int program_opencl_run(AVFilterContext *avctx) } } + if (ctx->plane_is_arg) { + cle = clSetKernelArg(ctx->kernel, 2 + ctx->nb_inputs, sizeof(cl_int), &plane); + if (cle != CL_SUCCESS) { + av_log(avctx, AV_LOG_ERROR, "Failed to set kernel " + "plane argument %d: %d.\n", plane, cle); + err = AVERROR_UNKNOWN; + goto fail; + } + } + err = ff_opencl_filter_work_size_from_image(avctx, global_work, output, plane, 0); if (err < 0) @@ -348,6 +359,9 @@ static const AVOption program_opencl_options[] = { { "s", "Video size", OFFSET(width), AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, 0, FLAGS }, + { "plane", "Pass currently processed plane as argument", OFFSET(plane_is_arg), + AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, + { NULL }, }; @@ -400,6 +414,9 @@ static const AVOption openclsrc_options[] = { { "r", "Video frame rate", OFFSET(source_rate), AV_OPT_TYPE_VIDEO_RATE, { .str = "25" }, 0, INT_MAX, FLAGS }, + { "plane", "Pass currently processed plane as argument", OFFSET(plane_is_arg), + AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, + { NULL }, };