From patchwork Sat Jan 16 14:55:46 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: 24980 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 F1CC1449925 for ; Sat, 16 Jan 2021 17:53:35 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B98EF68091F; Sat, 16 Jan 2021 17:53:35 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6302768089B for ; Sat, 16 Jan 2021 17:53:28 +0200 (EET) Received: by mail-lf1-f53.google.com with SMTP id s26so17673149lfc.8 for ; Sat, 16 Jan 2021 07:53:28 -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=nbCDVfpGa7bx/bDW9q/a2DcJj9lmveNd+lLaXtHE33I=; b=sAFP72vbd9jCNrVFDKf351e1HraGQFn2pLEPC3OdqiZcToH5MJa27UIfaSltVrttaO F0i5prJtLXOCfnubA8y4cCsXufKAIY7lpLnsmhn8JZ0RYWbP0TX7ctDJuBi6EGLJcVAM JSFdO/mKMoigNbLv+fKez8VGGPhnbjp5WpbPSErjaAcyHHa3Q5OINTkGd99qLxp6/71g rkbPEvYp4wpeG70Jjc1u46tf+9K8s0xO7oqvxCt6oIWNn0lTsxP+LtNvnfM/U3cJ/3F1 tgXMzlrdomrLQgJiZ9QEhFrrA60RCHTp4ER0Uxq1zZH6LnzAQduHwPVnF1Tmfg+c5rpy Fl2A== 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=nbCDVfpGa7bx/bDW9q/a2DcJj9lmveNd+lLaXtHE33I=; b=FsEeAXBCcG4xTyZeQizmWxECR3Av/PIYYl4EI1Z0WnO57ENaPAdut7s6R1YmY1uPQg iGKMW7BK6/Wi579QgsXBk4NHY76yGwVR/TionZemr/XeZyn2+ODhRqf4L2OGFjJruEB1 XZWnuZ1BNU8QTJFN+QkFpc4f37Zbmkg6Ge/Mhad7SmPKlh/7QgDgiitzdfaWmTyXLryJ dTu2XnuW959U4rMbDywvZvxnHrncJwjKTUPeoxtbGTD2j6gm3GRnUci2i+Hjks2ZCxYZ 5uHsv39yEL58aCvqIsXZkugKuur9T8PAyfMeAplDfEeBALdHHmNJQNFltfDODTf75fZg YK4g== X-Gm-Message-State: AOAM530f5UdMlTkjcZE4mKw2QkiEeajuFKGS/Z51t2RfijQdj18J0ruN ALMOjuJcJmtBtbutxPvxxUQm8hvsXzL3Kg== X-Google-Smtp-Source: ABdhPJzQqRHbUtbYPmNzUBcQB5o8QDvkCz2M2o7KJBF7NqgSPnvc0hkWqkM4VruyAHK9UmXbkLp/aQ== X-Received: by 2002:a17:907:d8e:: with SMTP id go14mr12355609ejc.472.1610808956329; Sat, 16 Jan 2021 06:55:56 -0800 (PST) Received: from localhost.localdomain ([31.45.254.141]) by smtp.gmail.com with ESMTPSA id x17sm7221252edd.76.2021.01.16.06.55.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Jan 2021 06:55:55 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Sat, 16 Jan 2021 15:55:46 +0100 Message-Id: <20210116145547.31834-1-onemda@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH 1/2] avfilter/vsrc_testsrc: add planar support 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 | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c index 7001f9ba16..c047fe8e86 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 depth; /* only used by haldclut */ int level; @@ -970,12 +971,15 @@ AVFILTER_DEFINE_CLASS(rgbtestsrc); #define B 2 #define A 3 -static void rgbtest_put_pixel(uint8_t *dst, int dst_linesize, +static void rgbtest_put_pixel(uint8_t *dstp[4], int dst_linesizep[4], int x, int y, unsigned r, unsigned g, unsigned b, enum AVPixelFormat fmt, uint8_t rgba_map[4]) { + uint8_t *dst = dstp[0]; + int dst_linesize = dst_linesizep[0]; uint32_t v; uint8_t *p; + uint16_t *p16; switch (fmt) { case AV_PIX_FMT_BGR444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r >> 4) << 8) | ((g >> 4) << 4) | (b >> 4); break; @@ -998,6 +1002,25 @@ static void rgbtest_put_pixel(uint8_t *dst, int dst_linesize, p = dst + 4*x + y*dst_linesize; AV_WL32(p, v); break; + case AV_PIX_FMT_GBRP: + p = dstp[0] + x + y * dst_linesizep[0]; + p[0] = g; + p = dstp[1] + x + y * dst_linesizep[1]; + p[0] = b; + p = dstp[2] + x + y * dst_linesizep[2]; + p[0] = r; + case AV_PIX_FMT_GBRP9: + case AV_PIX_FMT_GBRP10: + case AV_PIX_FMT_GBRP12: + case AV_PIX_FMT_GBRP14: + case AV_PIX_FMT_GBRP16: + p16 = (uint16_t *)(dstp[0] + x*2 + y * dst_linesizep[0]); + p16[0] = g; + p16 = (uint16_t *)(dstp[1] + x*2 + y * dst_linesizep[1]); + p16[0] = b; + p16 = (uint16_t *)(dstp[2] + x*2 + y * dst_linesizep[2]); + p16[0] = r; + break; } } @@ -1008,14 +1031,14 @@ static void rgbtest_fill_picture(AVFilterContext *ctx, AVFrame *frame) for (y = 0; y < h; y++) { for (x = 0; x < w; x++) { - int c = 256*x/w; + int c = (1 << FFMAX(test->depth, 8))*x/w; int r = 0, g = 0, b = 0; if (3*y < h ) r = c; else if (3*y < 2*h) g = c; else b = c; - rgbtest_put_pixel(frame->data[0], frame->linesize[0], x, y, r, g, b, + rgbtest_put_pixel(frame->data, frame->linesize, x, y, r, g, b, ctx->outputs[0]->format, test->rgba_map); } } @@ -1038,6 +1061,8 @@ static int rgbtest_query_formats(AVFilterContext *ctx) AV_PIX_FMT_RGB444, AV_PIX_FMT_BGR444, AV_PIX_FMT_RGB565, AV_PIX_FMT_BGR565, AV_PIX_FMT_RGB555, AV_PIX_FMT_BGR555, + AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, + AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16, AV_PIX_FMT_NONE }; @@ -1050,7 +1075,9 @@ static int rgbtest_query_formats(AVFilterContext *ctx) static int rgbtest_config_props(AVFilterLink *outlink) { TestSourceContext *test = outlink->src->priv; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format); + test->depth = desc->comp[0].depth; ff_fill_rgba_map(test->rgba_map, outlink->format); return config_props(outlink); } 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); }