From patchwork Sat Jan 16 14:55:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 24978 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 4947544A4B1 for ; Sat, 16 Jan 2021 17:26:00 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1CCAD68084B; Sat, 16 Jan 2021 17:26:00 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 655416805D1 for ; Sat, 16 Jan 2021 17:25:53 +0200 (EET) Received: by mail-wr1-f51.google.com with SMTP id d26so12195698wrb.12 for ; Sat, 16 Jan 2021 07:25:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=Mt58d1v7KSPAWp/hxBhwRsPS2Vx7ErJiOthSrHESgos=; b=id4qIzaykgApxwWNKMD+HkhbtAm8dBFnApk0RE7ruoxWmxj9QMF208DzT2dyCzdATS 7+8FJ1GMeWWwKGdYNIsORBV4sl429QIuwR4wL0VWi7YenVUn50ZnD0FbHFQ+kTIO+ZgQ Z9E8RqXqKWeDA3+qccBjX1NzPtdTuiAuCZfdlDq0Bq/81lRyEhOxSWST6b71cnO5PqH3 JXPSzWGZZ/C04Ip2t2LqOqBsxsWVgQVKyed3CFcJ0W7zShn5a+hI+qKGaHxYhSf8HjQj 8ROUqWMPH5EIGAe4Cs5ERmlNLVF44KbGZXi7Pz9Xqu7M8lR8Df2vaEgxgUJjqmg4tsKg DAjg== 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=Mt58d1v7KSPAWp/hxBhwRsPS2Vx7ErJiOthSrHESgos=; b=GZXUyTHU2xp26li4Cag0nMafzptrzpFY4fc8MJp0/Q3KMdzhrTNGRBTY60YFMYpRr8 7yMjTytEqWcz7R4MWshQYsXEf/OjTY+VC66nV8Ufsfgth8oQyzFN0KVWDptI0Bf/RLVu dezIJ3w1VvnQrjNviepDQiRSqi2PzEslQezYamTd9mnHAaxpN5+L0pJQkiop6C71nPKo bkibfZDhau0R6qlVxs3glV+m/Besbu5MvIGEIfckL86BebCf91ZtcWub7vmKJyKJU3k7 a3h/9aWuaqwT5IQSGyDz2fHRHM7HN+18QalIrWJtotwUX1rfZZpiO8AWYpBY17bYwooR rMRw== X-Gm-Message-State: AOAM530tMLQG+H2jWaF2/2yL5nTVbms7KO+7oPN2BtCp+H18i258Fapz hlyMx3sQp2KcrjeWn8O40eqzdhb2PMgeGA== X-Google-Smtp-Source: ABdhPJymwXM3HA1UB5F7djwfjqKhxsOXuOetMtNKQ6eGNqpJN7KUQZsg3uENYSNK2TTfKx8B4CHKzw== X-Received: by 2002:a17:906:fcce:: with SMTP id qx14mr1315766ejb.220.1610808957198; Sat, 16 Jan 2021 06:55:57 -0800 (PST) Received: from localhost.localdomain ([31.45.254.141]) by smtp.gmail.com with ESMTPSA id x17sm7221252edd.76.2021.01.16.06.55.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Jan 2021 06:55:56 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Sat, 16 Jan 2021 15:55:47 +0100 Message-Id: <20210116145547.31834-2-onemda@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210116145547.31834-1-onemda@gmail.com> References: <20210116145547.31834-1-onemda@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/2] avfilter/vsrc_testsrc: add complement mode to rgbtestsrc 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" Signed-off-by: Paul B Mahol --- libavfilter/vsrc_testsrc.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c index c047fe8e86..2cf33aadc9 100644 --- a/libavfilter/vsrc_testsrc.c +++ b/libavfilter/vsrc_testsrc.c @@ -77,6 +77,7 @@ typedef struct TestSourceContext { /* only used by rgbtest */ uint8_t rgba_map[4]; + int complement; int depth; /* only used by haldclut */ @@ -963,7 +964,13 @@ AVFilter ff_vsrc_testsrc2 = { #if CONFIG_RGBTESTSRC_FILTER -#define rgbtestsrc_options options +static const AVOption rgbtestsrc_options[] = { + COMMON_OPTIONS + { "complement", "set complement colors", OFFSET(complement), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS }, + { "co", "set complement colors", OFFSET(complement), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS }, + { NULL } +}; + AVFILTER_DEFINE_CLASS(rgbtestsrc); #define R 0 @@ -1024,6 +1031,29 @@ static void rgbtest_put_pixel(uint8_t *dstp[4], int dst_linesizep[4], } } +static void rgbtest_fill_picture_complement(AVFilterContext *ctx, AVFrame *frame) +{ + TestSourceContext *test = ctx->priv; + int x, y, w = frame->width, h = frame->height; + + for (y = 0; y < h; y++) { + for (x = 0; x < w; x++) { + int c = (1 << FFMAX(test->depth, 8))*x/w; + int r = 0, g = 0, b = 0; + + if (6*y < h ) r = c; + else if (6*y < 2*h) g = c, b = c; + else if (6*y < 3*h) g = c; + else if (6*y < 4*h) r = c, b = c; + else if (6*y < 5*h) b = c; + else r = c, g = c; + + rgbtest_put_pixel(frame->data, frame->linesize, x, y, r, g, b, + ctx->outputs[0]->format, test->rgba_map); + } + } +} + static void rgbtest_fill_picture(AVFilterContext *ctx, AVFrame *frame) { TestSourceContext *test = ctx->priv; @@ -1049,7 +1079,7 @@ static av_cold int rgbtest_init(AVFilterContext *ctx) TestSourceContext *test = ctx->priv; test->draw_once = 1; - test->fill_picture_fn = rgbtest_fill_picture; + test->fill_picture_fn = test->complement ? rgbtest_fill_picture_complement : rgbtest_fill_picture; return init(ctx); }