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); }