From patchwork Fri Feb 3 15:53:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Tomas_H=C3=A4rdin?= X-Patchwork-Id: 40237 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:5494:b0:bf:7b3a:fd32 with SMTP id i20csp1297363pzk; Fri, 3 Feb 2023 07:53:30 -0800 (PST) X-Google-Smtp-Source: AK7set/sxi9axMnqDyjfZGqfJT/iv0+IBZWo7vAlVKPxmDMpZxr0nnQg0GbQHonRFr5jSmqY9A3V X-Received: by 2002:a17:907:3e82:b0:885:8f79:d6d7 with SMTP id hs2-20020a1709073e8200b008858f79d6d7mr14336409ejc.61.1675439609743; Fri, 03 Feb 2023 07:53:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675439609; cv=none; d=google.com; s=arc-20160816; b=HxTTPstyoq4uj3i0djP4+01cnEi/JVlPZsL5PcwyrMEJXo/is8d7FgKSDyDWAX7aaB mQwFBA3e7T6T4XPWR66LZZDI10sr5IANyarWKc3qRqIh4t12vJ2gHvQe+3COeqTbi4qV LDH1STSPXnzs+rR6r03Mxxm7W/4DcuroBQZuhnthj+zW8E43S0Jn1I2plHIXzokoL2nf z4UfpO5nI0mFKV2OugB3h/QH5a+FRIzLtdLKJAEWcPSATIUSzlkph0UNYaGj41knWJjh aofTKLIYgUj/PqyoZ0vsWaLu0vDqZOLxtVFS107wIRHsojLSDqbnsAGWBxfwfgBj+3Pu PZjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:user-agent:date:to:from:message-id:delivered-to; bh=t/t8D2zbDBESxFB6gtNl4tTnJPuy5FXokP5RGzmAMdA=; b=O3sHobhptJogSZxDKFz119CLTb6big7DxQzUnT583UUjn+7IB9TeCWaXr0sZ2rBE0N 5dkzNxn+EUzsXae/e1joko7qEHVVZfMwQaYjoDG6HwNWOmY1fMwX+/qSd8VSx6h37Aag sTbGb22cGm0NpZFid94fSSs2YYgZrmV+EqavWCETcA+aNemsB6HTLZJxivTuGuOTVFz7 mcguVW9W5kifROZZHoL4Qvt4mCvm2WNkTpvKgYGTOb3kNVu5hkYt7pTHEv7HBHheXkYZ nXoemLGRHZZqq6o6e3VqzUvL+IlPebPwLRPzUvTKzR07ewRsD6UsU27gjppnigd7eb7E /Wqw== ARC-Authentication-Results: i=1; mx.google.com; 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 14-20020a170906024e00b0087879f8c291si3670032ejl.703.2023.02.03.07.53.29; Fri, 03 Feb 2023 07:53:29 -0800 (PST) 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; 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 2E70568BDA1; Fri, 3 Feb 2023 17:53:26 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.frobbit.se (mail.frobbit.se [85.30.129.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 90D9368BA48 for ; Fri, 3 Feb 2023 17:53:19 +0200 (EET) Received: from [10.10.150.68] (1346516434.ip.84grams.net [134.65.164.34]) by mail.frobbit.se (Postfix) with ESMTPSA id 1D79321C6C for ; Fri, 3 Feb 2023 16:53:19 +0100 (CET) Message-ID: From: Tomas =?iso-8859-1?q?H=E4rdin?= To: FFmpeg development discussions and patches Date: Fri, 03 Feb 2023 16:53:18 +0100 User-Agent: Evolution 3.38.3-1+deb11u1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] lavfi/vf_colorspace: Add support for 14- and 16-bit YUV X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: BI5uydierLn9 From 33c0ff957b5a37c1d59069ee414282bb45d21298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Fri, 3 Feb 2023 15:00:05 +0100 Subject: [PATCH 1/2] lavfi/vf_colorspace: Add support for 14- and 16-bit YUV --- libavfilter/colorspacedsp.c | 36 +++++++++++++++++++++++++++- libavfilter/colorspacedsp.h | 2 ++ libavfilter/colorspacedsp_template.c | 8 +++++++ libavfilter/vf_colorspace.c | 10 +++++++- 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/libavfilter/colorspacedsp.c b/libavfilter/colorspacedsp.c index 72207ffaf3..75a442fb66 100644 --- a/libavfilter/colorspacedsp.c +++ b/libavfilter/colorspacedsp.c @@ -39,6 +39,14 @@ #define BIT_DEPTH 12 #include "colorspacedsp_template.c" +#undef BIT_DEPTH +#define BIT_DEPTH 14 +#include "colorspacedsp_template.c" + +#undef BIT_DEPTH +#define BIT_DEPTH 16 +#include "colorspacedsp_template.c" + #undef SS_W #undef SS_H @@ -57,6 +65,14 @@ #define BIT_DEPTH 12 #include "colorspacedsp_template.c" +#undef BIT_DEPTH +#define BIT_DEPTH 14 +#include "colorspacedsp_template.c" + +#undef BIT_DEPTH +#define BIT_DEPTH 16 +#include "colorspacedsp_template.c" + #undef SS_W #undef SS_H @@ -75,6 +91,14 @@ #define BIT_DEPTH 12 #include "colorspacedsp_template.c" +#undef BIT_DEPTH +#define BIT_DEPTH 14 +#include "colorspacedsp_template.c" + +#undef BIT_DEPTH +#define BIT_DEPTH 16 +#include "colorspacedsp_template.c" + static void multiply3x3_c(int16_t *buf[3], ptrdiff_t stride, int w, int h, const int16_t m[3][3][8]) { @@ -109,6 +133,8 @@ void ff_colorspacedsp_init(ColorSpaceDSPContext *dsp) init_yuv2rgb_fn( 8); init_yuv2rgb_fn(10); init_yuv2rgb_fn(12); + init_yuv2rgb_fn(14); + init_yuv2rgb_fn(16); #define init_rgb2yuv_fn(bit) \ dsp->rgb2yuv[BPP_##bit][SS_444] = rgb2yuv_444p##bit##_c; \ @@ -118,6 +144,8 @@ void ff_colorspacedsp_init(ColorSpaceDSPContext *dsp) init_rgb2yuv_fn( 8); init_rgb2yuv_fn(10); init_rgb2yuv_fn(12); + init_rgb2yuv_fn(14); + init_rgb2yuv_fn(16); #define init_rgb2yuv_fsb_fn(bit) \ dsp->rgb2yuv_fsb[BPP_##bit][SS_444] = rgb2yuv_fsb_444p##bit##_c; \ @@ -127,6 +155,8 @@ void ff_colorspacedsp_init(ColorSpaceDSPContext *dsp) init_rgb2yuv_fsb_fn( 8); init_rgb2yuv_fsb_fn(10); init_rgb2yuv_fsb_fn(12); + init_rgb2yuv_fsb_fn(14); + init_rgb2yuv_fsb_fn(16); #define init_yuv2yuv_fn(idx1, bit1, bit2) \ dsp->yuv2yuv[idx1][BPP_##bit2][SS_444] = yuv2yuv_444p##bit1##to##bit2##_c; \ @@ -135,11 +165,15 @@ void ff_colorspacedsp_init(ColorSpaceDSPContext *dsp) #define init_yuv2yuv_fns(bit1) \ init_yuv2yuv_fn(BPP_##bit1, bit1, 8); \ init_yuv2yuv_fn(BPP_##bit1, bit1, 10); \ - init_yuv2yuv_fn(BPP_##bit1, bit1, 12) + init_yuv2yuv_fn(BPP_##bit1, bit1, 12); \ + init_yuv2yuv_fn(BPP_##bit1, bit1, 14); \ + init_yuv2yuv_fn(BPP_##bit1, bit1, 16) init_yuv2yuv_fns( 8); init_yuv2yuv_fns(10); init_yuv2yuv_fns(12); + init_yuv2yuv_fns(14); + init_yuv2yuv_fns(16); dsp->multiply3x3 = multiply3x3_c; diff --git a/libavfilter/colorspacedsp.h b/libavfilter/colorspacedsp.h index a81e4f0a52..c994bcfe67 100644 --- a/libavfilter/colorspacedsp.h +++ b/libavfilter/colorspacedsp.h @@ -46,6 +46,8 @@ enum BitDepthIndex { BPP_8, BPP_10, BPP_12, + BPP_14, + BPP_16, NB_BPP, }; diff --git a/libavfilter/colorspacedsp_template.c b/libavfilter/colorspacedsp_template.c index 53ac0d7224..08d809979f 100644 --- a/libavfilter/colorspacedsp_template.c +++ b/libavfilter/colorspacedsp_template.c @@ -340,3 +340,11 @@ static void fn(rgb2yuv_fsb)(uint8_t *_yuv[3], const ptrdiff_t yuv_stride[3], #undef IN_BIT_DEPTH #define IN_BIT_DEPTH 12 #include "colorspacedsp_yuv2yuv_template.c" + +#undef IN_BIT_DEPTH +#define IN_BIT_DEPTH 14 +#include "colorspacedsp_yuv2yuv_template.c" + +#undef IN_BIT_DEPTH +#define IN_BIT_DEPTH 16 +#include "colorspacedsp_yuv2yuv_template.c" diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c index 21916b7b7a..1e1ab5fb34 100644 --- a/libavfilter/vf_colorspace.c +++ b/libavfilter/vf_colorspace.c @@ -402,7 +402,7 @@ static int create_filtergraph(AVFilterContext *ctx, const AVPixFmtDescriptor *out_desc = av_pix_fmt_desc_get(out->format); int emms = 0, m, n, o, res, fmt_identical, redo_yuv2rgb = 0, redo_rgb2yuv = 0; -#define supported_depth(d) ((d) == 8 || (d) == 10 || (d) == 12) +#define supported_depth(d) ((d) == 8 || (d) == 10 || (d) == 12 || (d) == 14 || (d) == 16) #define supported_subsampling(lcw, lch) \ (((lcw) == 0 && (lch) == 0) || ((lcw) == 1 && (lch) == 0) || ((lcw) == 1 && (lch) == 1)) #define supported_format(d) \ @@ -842,6 +842,8 @@ static int query_formats(AVFilterContext *ctx) AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12, + AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14, + AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_NONE }; @@ -961,12 +963,18 @@ static const AVOption colorspace_options[] = { ENUM("yuv420p", AV_PIX_FMT_YUV420P, "fmt"), ENUM("yuv420p10", AV_PIX_FMT_YUV420P10, "fmt"), ENUM("yuv420p12", AV_PIX_FMT_YUV420P12, "fmt"), + ENUM("yuv420p14", AV_PIX_FMT_YUV420P14, "fmt"), + ENUM("yuv420p16", AV_PIX_FMT_YUV420P16, "fmt"), ENUM("yuv422p", AV_PIX_FMT_YUV422P, "fmt"), ENUM("yuv422p10", AV_PIX_FMT_YUV422P10, "fmt"), ENUM("yuv422p12", AV_PIX_FMT_YUV422P12, "fmt"), + ENUM("yuv422p14", AV_PIX_FMT_YUV422P14, "fmt"), + ENUM("yuv422p16", AV_PIX_FMT_YUV422P16, "fmt"), ENUM("yuv444p", AV_PIX_FMT_YUV444P, "fmt"), ENUM("yuv444p10", AV_PIX_FMT_YUV444P10, "fmt"), ENUM("yuv444p12", AV_PIX_FMT_YUV444P12, "fmt"), + ENUM("yuv444p14", AV_PIX_FMT_YUV444P14, "fmt"), + ENUM("yuv444p16", AV_PIX_FMT_YUV444P16, "fmt"), { "fast", "Ignore primary chromaticity and gamma correction", OFFSET(fast_mode), AV_OPT_TYPE_BOOL, { .i64 = 0 }, -- 2.30.2