From patchwork Mon Oct 21 19:57:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: martin schitter X-Patchwork-Id: 52431 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:143:b0:48e:c0f8:d0de with SMTP id h3csp2920851vqi; Mon, 21 Oct 2024 13:18:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXkYVVft+DUL0HnmCoZ1smSHiGgTA+3Ui+T2WFI+DQjnLu+V9KGkCXPOdMSBwtXxkxZKOFmxsHgLhUxpN2MU6NQ@gmail.com X-Google-Smtp-Source: AGHT+IF1kRVM9eRgU0b8mdyJE12xWJeKDvhddaWD0kgEz0aDjxVC7q1BcZh19QZiixP5N+5gqIWP X-Received: by 2002:a05:6402:42c2:b0:5cb:6158:cae9 with SMTP id 4fb4d7f45d1cf-5cb7fcd8dbamr115711a12.6.1729541893035; Mon, 21 Oct 2024 13:18:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729541893; cv=none; d=google.com; s=arc-20240605; b=VSITUuh0yMXbW456fJQmvvmGk4JAXSyge3SYLXlpZUb9Xst/rLfw9af2NkMt6kThvJ VvaXA1/m7Yp/FvBk7slLJpiVQrWfJAdXo6in5085+JpvwUMAQ8siVEUhNdawyWzb+a/f igSplloW72wp9067Cwqb6wUSlWaIE9PxjTnt1YYzzQyHjZeW5QVYnm2G1wXgeu1lZZ4f 8e51WRbPjfSnNdfEJa3wc3hNJQ/ZTGMBvxmSXWFrhtpJWexlwKTr/75Y54eDWKigyEVR UcYkG+YrTSb0K83pxxjAfBUbM7los+WrMB8UjA+URA0kjwaxRdkZy3eccnuhmk36SOoD xwyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=ydLui7ls2QX/8BGs+fivucRx7yfgM5qLESziLbes8xM=; fh=igg3JDwkSkAbPTwY6V0OsEq0RUkG4DKWC8fVJg4GhMY=; b=j7kWUkmo1eOvXe4gaWY+W1dH+Ymx985VMzmy/iJlhpKC162FUO8CYI9RBpDy8UM5GP 2Vl8yJOb/z2m9G6rCCHAqiMpScA3fi192u/r7ODXTYBkR6bF4P94yoIVM3krTqOMSwIy Ys9qDi6iMBdmQdD6YQNMpK0jMdGKaNKRU4AZmmVhl4iMBkvC6rbqyf5aDIv1uigN3lhM Z+TE41Z/8x4gPxLRpiuyJAmVmCxh4/k9kLbmJfudekrikjLdZ6Pbl9zhbM1mR6l8HfLS W9u0XL/MrbXY9e79NpuLPAOi/z+Wf5RzCZyU9Ts0trgH7vD2gRxrcnfQEc8XzcuIJWOl XFMA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mur.at header.s=dkim2 header.b="c66f/1hN"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mur.at Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-5cb66c7e69asi3100988a12.481.2024.10.21.13.18.12; Mon, 21 Oct 2024 13:18:13 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@mur.at header.s=dkim2 header.b="c66f/1hN"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mur.at Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 29DAB68DDDA; Mon, 21 Oct 2024 23:18:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from efeu.mur.at (efeu.mur.at [89.106.208.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DE17468DB94 for ; Mon, 21 Oct 2024 23:18:00 +0300 (EEST) Received: from localhost.localdomain (lan1.raspi.ma39.ffgraz.net [10.12.1.243]) by efeu.mur.at (Postfix) with ESMTPSA id 68417462DE; Mon, 21 Oct 2024 22:18:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mur.at; s=dkim2; t=1729541880; bh=pqpXYs+ioHxYkI2BAlDR+fr1OsfQ9fOuUX1syGJZLSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c66f/1hNqmP5OxrhWHj16g4JFLtGs3P7Iq1M1kKkeq9m5Oipf2+lct0Lcco+oP8ZS yKP26QIkpvETcHDv6uY6HionrJLjjmI+9jJE7RUFsWM/AqPIFjATi3QZgMHLw/5mWv D3FfT/bWdbDjM0wNgulj9gQYsjm1Sa/I5lE7EXXxKNoK172bliDYbNY9Cj3ALfMhj1 QBlsklZPn+YpFZV+r+BRHAdPCjWrG8UFzsHWo09acyhnRN9KGK6qDUnm28m9rcDXjD 0wDG/DaEpu8YAsPlj/dE5e2rGBzHJ9k53XtFEGQrIAsQz7LEqn17E1bHFF/0s1breg tYOxGT8hhkHTWEo8sbQSmYsCbIQT4V8sEIC+RN61WkI8FbtaOn3QNxPs8ZCgm/rJ5a lgGsNmaE/0XX4iuucu0f73MEaWuy7xnvN7veICuaZzaI5OgRJyM+9ndx9V/yLu3Qao mdef5oNR3GETzaQLAAjTb3Xjr7m+s44Igf8P3Uxyve+ceFYimI1 From: Martin Schitter To: ffmpeg-devel@ffmpeg.org Date: Mon, 21 Oct 2024 21:57:14 +0200 Message-ID: <20241021195721.892544-3-ms+git@mur.at> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241021195721.892544-2-ms+git@mur.at> References: <20241021195721.892544-2-ms+git@mur.at> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v12 1/9] avutil/swscale: add PIX_FMT_YUV444 and input support 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 Cc: Martin Schitter Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: FFaJcSzqFk31 --- libavutil/pixdesc.c | 11 +++++++++++ libavutil/pixfmt.h | 2 ++ libswscale/input.c | 22 ++++++++++++++++++++++ libswscale/utils.c | 1 + tests/ref/fate/imgutils | 2 ++ tests/ref/fate/sws-pixdesc-query | 2 ++ 6 files changed, 40 insertions(+) diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index e15105e..c6a9b85 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -346,6 +346,17 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, + [AV_PIX_FMT_YUV444] = { + .name = "yuv444", + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 3, 0, 0, 8 }, /* Y */ + { 0, 3, 1, 0, 8 }, /* U */ + { 0, 3, 2, 0, 8 }, /* V */ + }, + }, [AV_PIX_FMT_YUV444P] = { .name = "yuv444p", .nb_components = 3, diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index 0dc4abc..0c7f909 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -457,6 +457,8 @@ enum AVPixelFormat { AV_PIX_FMT_RGB96BE, ///< packed RGBA 32:32:32, 96bpp, RGBRGB..., big-endian AV_PIX_FMT_RGB96LE, ///< packed RGBA 32:32:32, 96bpp, RGBRGB..., little-endian + AV_PIX_FMT_YUV444, ///< packed YUV 4:4:4, 24bpp (1 Cr & Cb sample per 1x1 Y), YUVYUV... + AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions }; diff --git a/libswscale/input.c b/libswscale/input.c index bb5e31a..79376b9 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -771,6 +771,22 @@ static void read_uyva_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, } } +static void yuv444ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width, + uint32_t *unused2, void *opq) +{ + for (int i = 0; i < width; i++) + dst[i] = src[i * 3]; +} + +static void yuv444ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src, + const uint8_t *unused1, int width, uint32_t *unused2, void *opq) +{ + for (int i = 0; i < width; i++) { + dstU[i] = src[i * 3 + 1]; + dstV[i] = src[i * 3 + 2]; + } +} + static void vyuToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width, uint32_t *unused2, void *opq) { @@ -1562,6 +1578,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c, case AV_PIX_FMT_VYU444: *chrToYV12 = vyuToUV_c; break; + case AV_PIX_FMT_YUV444: + *chrToYV12 = yuv444ToUV_c; + break; case AV_PIX_FMT_NV12: case AV_PIX_FMT_NV16: case AV_PIX_FMT_NV24: @@ -2164,6 +2183,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c, case AV_PIX_FMT_VYU444: *lumToYV12 = vyuToY_c; break; + case AV_PIX_FMT_YUV444: + *lumToYV12 = yuv444ToY_c; + break; case AV_PIX_FMT_BGR24: *lumToYV12 = bgr24ToY_c; break; diff --git a/libswscale/utils.c b/libswscale/utils.c index 9b23df4..36d9738 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -73,6 +73,7 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_BGR24] = { 1, 1 }, [AV_PIX_FMT_YUV422P] = { 1, 1 }, [AV_PIX_FMT_YUV444P] = { 1, 1 }, + [AV_PIX_FMT_YUV444] = { 1, 0 }, [AV_PIX_FMT_YUV410P] = { 1, 1 }, [AV_PIX_FMT_YUV411P] = { 1, 1 }, [AV_PIX_FMT_GRAY8] = { 1, 1 }, diff --git a/tests/ref/fate/imgutils b/tests/ref/fate/imgutils index 8639baa..62a52be 100644 --- a/tests/ref/fate/imgutils +++ b/tests/ref/fate/imgutils @@ -280,6 +280,7 @@ rgba128be planes: 1, linesizes: 1024 0 0 0, plane_sizes: 49152 0 rgba128le planes: 1, linesizes: 1024 0 0 0, plane_sizes: 49152 0 0 0, plane_offsets: 0 0 0, total_size: 49152 rgb96be planes: 1, linesizes: 768 0 0 0, plane_sizes: 36864 0 0 0, plane_offsets: 0 0 0, total_size: 36864 rgb96le planes: 1, linesizes: 768 0 0 0, plane_sizes: 36864 0 0 0, plane_offsets: 0 0 0, total_size: 36864 +yuv444 planes: 1, linesizes: 192 0 0 0, plane_sizes: 9216 0 0 0, plane_offsets: 0 0 0, total_size: 9216 image_fill_black tests yuv420p total_size: 4608, black_unknown_crc: 0xd00f6cc6, black_tv_crc: 0xd00f6cc6, black_pc_crc: 0x234969af @@ -507,3 +508,4 @@ rgba128be total_size: 49152, black_unknown_crc: 0x59ef499b, black_tv_cr rgba128le total_size: 49152, black_unknown_crc: 0x59ef499b, black_tv_crc: 0x59ef499b, black_pc_crc: 0x59ef499b rgb96be total_size: 36864, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000 rgb96le total_size: 36864, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000 +yuv444 total_size: 9216, black_unknown_crc: 0x32a4be0b, black_tv_crc: 0x32a4be0b, black_pc_crc: 0x07501edb diff --git a/tests/ref/fate/sws-pixdesc-query b/tests/ref/fate/sws-pixdesc-query index aa2edcf..6e80565 100644 --- a/tests/ref/fate/sws-pixdesc-query +++ b/tests/ref/fate/sws-pixdesc-query @@ -304,6 +304,7 @@ isYUV: yuv440p10le yuv440p12be yuv440p12le + yuv444 yuv444p yuv444p10be yuv444p10le @@ -879,6 +880,7 @@ Packed: ya16be ya16le ya8 + yuv444 yuyv422 yvyu422 From patchwork Mon Oct 21 19:57:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: martin schitter X-Patchwork-Id: 52436 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:143:b0:48e:c0f8:d0de with SMTP id h3csp2926142vqi; Mon, 21 Oct 2024 13:29:04 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV4dfwWhG5TQiPSRXhV7g805Ea+pMuhq6+DhjQmGYknWyWmaA/xyjt4wqr42JG3kCdeP10g5nf5xZI9E/pYptTX@gmail.com X-Google-Smtp-Source: AGHT+IE3otwN9m5uET36cnorFfchxr3D5ZwQf18p9Ogh9R8ScAzKRgBaxQFlLirmGLPWxKSKIXbC X-Received: by 2002:a17:907:7204:b0:a9a:1dc3:d5b9 with SMTP id a640c23a62f3a-a9a69c98c5dmr656253866b.11.1729542544274; Mon, 21 Oct 2024 13:29:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729542544; cv=none; d=google.com; s=arc-20240605; b=XumZdY9/78x5zE09w2lvEV0HLzA46zjEXw366+UZUc0ihPStSlM4BnnQp/rTTRWxRm jL19UPOdoCMS3KaNjNYiB7QOtO0pmKxVA2ndF9oGopgeKbeemcGdIiRi4swCL+ybRJEl dw7g42bIBCz3Ik896zT4WQ67Ir1NvR1ByDanJn/80tw5TBXl0GFrfWIBBUaqzxivQjzW vSfQcnYcEVsiYi9SlFtl3howl7rqkPHoHvQQywQPXoGj0haXt+mvT/RbUMypFWcfz0TH 6wLmY6Zy9TwWEBrLvysF5dScomgJtiLb7kpRbH5vPkTEIpkByLy45iAsWPVYBEyQ06K9 g50w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=g6WL3kz5ZHxfYUOExJZ1xLMQvu/t/EnMTvo3TPfCFfs=; fh=igg3JDwkSkAbPTwY6V0OsEq0RUkG4DKWC8fVJg4GhMY=; b=eRcof7abCQ2JSi8j6YL+KNtgQ9lpFVRuAtbPjl2WO/ihhng14+LKXcCsutnlwMHFTF /p/eUJWUCbVpflBJY5On11fzSXye63771KEQpom2iiT822x7Vchqwdv9afHsYDf9VuuD yW6gaoQAAnHHLXvPIj2XgO7nOKX6R3xYR14hDyK7//h4M4UWw+sMTf7cu+uHYRsPv+vt bM8wTF0+jpBDxo2QSmxjf1ABz2D4P2rO6WwI6lU/pP4nJSIVId5QOcZeYJ0+SsydutY7 WxekVZ7srZyiDOg+HZmvClBWmec9vVXoFxKAG9kQgBwAEWj3EvoYvZVazs0CUBOdYLao L9LA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mur.at header.s=dkim2 header.b=SYJVUutI; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mur.at Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a9a91333d19si315410866b.457.2024.10.21.13.29.03; Mon, 21 Oct 2024 13:29:04 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@mur.at header.s=dkim2 header.b=SYJVUutI; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mur.at Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 556F668DDF8; Mon, 21 Oct 2024 23:18:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from efeu.mur.at (efeu.mur.at [89.106.208.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F0E8D68DBC1 for ; Mon, 21 Oct 2024 23:18:00 +0300 (EEST) Received: from localhost.localdomain (lan1.raspi.ma39.ffgraz.net [10.12.1.243]) by efeu.mur.at (Postfix) with ESMTPSA id 8FE54462DF; Mon, 21 Oct 2024 22:18:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mur.at; s=dkim2; t=1729541880; bh=CqLGN3lRDrDAXz7yAsLu/cUtE9zj6WiX0b2WBRJtqGk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SYJVUutIXSLxVpIowLtJ/TD5CDlC21hpu9gigKDgQzOYpTzXHb+O9Ql2N7IAYWFoJ qLmx/i0WHRG7YJQWD42csTzymNcWM521zu5iqHz0njgDuWsoqOHoIvi8zeiBDoTpCi Y/8rDMbAf6N2+uU0pIMKQ6Cs4yY0lwNoYbn3zcbcn4tv8NeVsOfy0HznsZh0aB8RyH /f7J+CABdJceb/rYVvnhDG62p28nIhZ3m+/FgPpGqWxAXMdKBaSgvq5SxhpAtbsPXU uUnUyXz7SfbIz1OlcNJ1Z+/K3Vj6lrVE1nylpEXtm4dN2qlryQt5hZdVQbohbyDoRz GbyNjuIasAxy+yZYnAQicTl5Slwcox//zuN+SgOclh9nG4/Uc72u0I555+zFiHwuvL kSDB/QGTC5IR9DDh9jREWoAv7qfIrVqXPtehcqhWdnTXlEfoc6MAQ+vXtpEQHWLpiZ uoxNWqEBvSRlKmK8HhOikok8mCOLvaAvF6roxFZtcsS7HFZCtt2 From: Martin Schitter To: ffmpeg-devel@ffmpeg.org Date: Mon, 21 Oct 2024 21:57:15 +0200 Message-ID: <20241021195721.892544-4-ms+git@mur.at> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241021195721.892544-2-ms+git@mur.at> References: <20241021195721.892544-2-ms+git@mur.at> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v12 2/9] avutil/swscale: add YUV444_16 and UYVY_16 pixel format and input support 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 Cc: Martin Schitter Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ASnAvvMviF1A --- libavutil/pixdesc.c | 46 ++++++++++++++++ libavutil/pixfmt.h | 8 +++ libswscale/input.c | 90 ++++++++++++++++++++++++++++++++ libswscale/utils.c | 4 ++ tests/ref/fate/imgutils | 8 +++ tests/ref/fate/sws-pixdesc-query | 14 +++++ 6 files changed, 170 insertions(+) diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index c6a9b85..96b9fbe 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -492,6 +492,29 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { { 0, 4, 2, 0, 8 }, /* V */ }, }, + [AV_PIX_FMT_UYVY422_16LE] = { + .name = "uyvy422_16le", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, + .comp = { + { 0, 4, 2, 0, 16 }, /* Y */ + { 0, 8, 0, 0, 16 }, /* U */ + { 0, 8, 4, 0, 16 }, /* V */ + }, + }, + [AV_PIX_FMT_UYVY422_16BE] = { + .name = "uyvy422_16be", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, + .comp = { + { 0, 4, 2, 0, 16 }, /* Y */ + { 0, 8, 0, 0, 16 }, /* U */ + { 0, 8, 4, 0, 16 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_BE, + }, [AV_PIX_FMT_UYYVYY411] = { .name = "uyyvyy411", .nb_components = 3, @@ -1667,6 +1690,29 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR, }, + [AV_PIX_FMT_YUV444_16LE] = { + .name = "yuv444_16le", + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 6, 0, 0, 16 }, /* Y */ + { 0, 6, 2, 0, 16 }, /* U */ + { 0, 6, 4, 0, 16 }, /* V */ + }, + }, + [AV_PIX_FMT_YUV444_16BE] = { + .name = "yuv444_16be", + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 6, 0, 0, 16 }, /* Y */ + { 0, 6, 2, 0, 16 }, /* U */ + { 0, 6, 4, 0, 16 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_BE, + }, [AV_PIX_FMT_YUV444P10LE] = { .name = "yuv444p10le", .nb_components = 3, diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index 0c7f909..fde8dbb 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -458,6 +458,11 @@ enum AVPixelFormat { AV_PIX_FMT_RGB96LE, ///< packed RGBA 32:32:32, 96bpp, RGBRGB..., little-endian AV_PIX_FMT_YUV444, ///< packed YUV 4:4:4, 24bpp (1 Cr & Cb sample per 1x1 Y), YUVYUV... + AV_PIX_FMT_YUV444_16BE, ///< packed YUV 4:4:4, 48bpp (1 Cr & Cb sample per 1x1 Y), YUVYUV..., big-endian + AV_PIX_FMT_YUV444_16LE, ///< packed YUV 4:4:4, 48bpp (1 Cr & Cb sample per 1x1 Y), YUVYUV..., little-endian + + AV_PIX_FMT_UYVY422_16BE, ///< packed UYVU 4:2:2, 32bpp, Cb Y0 Cr Y1, big-endian + AV_PIX_FMT_UYVY422_16LE, ///< packed UYVU 4:2:2, 32bpp, Cb Y0 Cr Y1, little-endian AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions }; @@ -509,6 +514,7 @@ enum AVPixelFormat { #define AV_PIX_FMT_YUV420P16 AV_PIX_FMT_NE(YUV420P16BE, YUV420P16LE) #define AV_PIX_FMT_YUV422P16 AV_PIX_FMT_NE(YUV422P16BE, YUV422P16LE) #define AV_PIX_FMT_YUV444P16 AV_PIX_FMT_NE(YUV444P16BE, YUV444P16LE) +#define AV_PIX_FMT_YUV444_16 AV_PIX_FMT_NE(YUV444_16BE, YUV444_16LE) #define AV_PIX_FMT_GBRP9 AV_PIX_FMT_NE(GBRP9BE , GBRP9LE) #define AV_PIX_FMT_GBRP10 AV_PIX_FMT_NE(GBRP10BE, GBRP10LE) @@ -542,6 +548,8 @@ enum AVPixelFormat { #define AV_PIX_FMT_YUVA422P16 AV_PIX_FMT_NE(YUVA422P16BE, YUVA422P16LE) #define AV_PIX_FMT_YUVA444P16 AV_PIX_FMT_NE(YUVA444P16BE, YUVA444P16LE) +#define AV_PIX_FMT_UYVY422_16 AV_PIX_FMT_NE(UYVY422_16BE, UYVY422_16LE) + #define AV_PIX_FMT_XYZ12 AV_PIX_FMT_NE(XYZ12BE, XYZ12LE) #define AV_PIX_FMT_NV20 AV_PIX_FMT_NE(NV20BE, NV20LE) #define AV_PIX_FMT_AYUV64 AV_PIX_FMT_NE(AYUV64BE, AYUV64LE) diff --git a/libswscale/input.c b/libswscale/input.c index 79376b9..e23b59e 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -805,6 +805,39 @@ static void vyuToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, cons } } +static void read_yuv444_16le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, + const uint8_t *unused1, int width, uint32_t *unused2, void *opq) +{ + int i; + for (i = 0; i < width; i++) + AV_WN16(dst + i * 2, AV_RL16(src + i * 6)); +} + +static void read_yuv444_16le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src, + const uint8_t *unused1, int width, uint32_t *unused2, void *opq) +{ + for (int i = 0; i < width; i++) { + AV_WN16(dstU + i * 2, AV_RL16(src + i * 6 + 2)); + AV_WN16(dstV + i * 2, AV_RL16(src + i * 6 + 4)); + } +} + +static void read_yuv444_16be_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, + const uint8_t *unused1, int width, uint32_t *unused2, void *opq) +{ + for (int i = 0; i < width; i++) + AV_WN16(dst + i * 2, AV_RB16(src + i * 6)); +} + +static void read_yuv444_16be_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src, + const uint8_t *unused1, int width, uint32_t *unused2, void *opq) +{ + for (int i = 0; i < width; i++) { + AV_WN16(dstU + i * 2, AV_RB16(src + i * 6 + 2)); + AV_WN16(dstV + i * 2, AV_RB16(src + i * 6 + 4)); + } +} + static void read_v30xle_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width, uint32_t *unused2, void *opq) { @@ -903,6 +936,39 @@ static void uyvyToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, con av_assert1(src1 == src2); } +static void uyvy16le_ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, + const uint8_t *unused2, int width, uint32_t *unused, void *opq) +{ + for (int i = 0; i < width; i++) + AV_WN16(dst + i * 2, AV_RL16(src + 4 * i + 2)); +} + +static void uyvy16le_ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1, + const uint8_t *src2, int width, uint32_t *unused, void *opq) +{ + for (int i = 0; i < width; i++) { + AV_WN16(dstU + i * 2, AV_RL16(src1 + 8 * i)); + AV_WN16(dstV + i * 2, AV_RL16(src1 + 8 * i + 4)); + } +} + +static void uyvy16be_ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, + const uint8_t *unused2, int width, uint32_t *unused, void *opq) +{ + for (int i = 0; i < width; i++) + AV_WN16(dst + i * 2, AV_RB16(src + 4 * i + 2)); +} + +static void uyvy16be_ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1, + const uint8_t *src2, int width, uint32_t *unused, void *opq) +{ + for (int i = 0; i < width; i++) { + AV_WN16(dstU + i * 2, AV_RB16(src1 + 8 * i)); + AV_WN16(dstV + i * 2, AV_RB16(src1 + 8 * i + 4)); + } +} + + static av_always_inline void nvXXtoUV_c(uint8_t *dst1, uint8_t *dst2, const uint8_t *src, int width) { @@ -1575,12 +1641,24 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c, case AV_PIX_FMT_UYVY422: *chrToYV12 = uyvyToUV_c; break; + case AV_PIX_FMT_UYVY422_16LE: + *chrToYV12 = uyvy16le_ToUV_c; + break; + case AV_PIX_FMT_UYVY422_16BE: + *chrToYV12 = uyvy16be_ToUV_c; + break; case AV_PIX_FMT_VYU444: *chrToYV12 = vyuToUV_c; break; case AV_PIX_FMT_YUV444: *chrToYV12 = yuv444ToUV_c; break; + case AV_PIX_FMT_YUV444_16LE: + *chrToYV12 = read_yuv444_16le_UV_c; + break; + case AV_PIX_FMT_YUV444_16BE: + *chrToYV12 = read_yuv444_16be_UV_c; + break; case AV_PIX_FMT_NV12: case AV_PIX_FMT_NV16: case AV_PIX_FMT_NV24: @@ -2180,12 +2258,24 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c, case AV_PIX_FMT_UYVY422: *lumToYV12 = uyvyToY_c; break; + case AV_PIX_FMT_UYVY422_16LE: + *lumToYV12 = uyvy16le_ToY_c; + break; + case AV_PIX_FMT_UYVY422_16BE: + *lumToYV12 = uyvy16be_ToY_c; + break; case AV_PIX_FMT_VYU444: *lumToYV12 = vyuToY_c; break; case AV_PIX_FMT_YUV444: *lumToYV12 = yuv444ToY_c; break; + case AV_PIX_FMT_YUV444_16LE: + *lumToYV12 = read_yuv444_16le_Y_c; + break; + case AV_PIX_FMT_YUV444_16BE: + *lumToYV12 = read_yuv444_16be_Y_c; + break; case AV_PIX_FMT_BGR24: *lumToYV12 = bgr24ToY_c; break; diff --git a/libswscale/utils.c b/libswscale/utils.c index 36d9738..623e826 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -74,6 +74,8 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_YUV422P] = { 1, 1 }, [AV_PIX_FMT_YUV444P] = { 1, 1 }, [AV_PIX_FMT_YUV444] = { 1, 0 }, + [AV_PIX_FMT_YUV444_16BE] = { 1, 0 }, + [AV_PIX_FMT_YUV444_16LE] = { 1, 0 }, [AV_PIX_FMT_YUV410P] = { 1, 1 }, [AV_PIX_FMT_YUV411P] = { 1, 1 }, [AV_PIX_FMT_GRAY8] = { 1, 1 }, @@ -86,6 +88,8 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_YUVJ444P] = { 1, 1 }, [AV_PIX_FMT_YVYU422] = { 1, 1 }, [AV_PIX_FMT_UYVY422] = { 1, 1 }, + [AV_PIX_FMT_UYVY422_16BE]= { 1, 0 }, + [AV_PIX_FMT_UYVY422_16LE]= { 1, 0 }, [AV_PIX_FMT_UYYVYY411] = { 0, 0 }, [AV_PIX_FMT_BGR8] = { 1, 1 }, [AV_PIX_FMT_BGR4] = { 0, 1 }, diff --git a/tests/ref/fate/imgutils b/tests/ref/fate/imgutils index 62a52be..b4d98f4 100644 --- a/tests/ref/fate/imgutils +++ b/tests/ref/fate/imgutils @@ -281,6 +281,10 @@ rgba128le planes: 1, linesizes: 1024 0 0 0, plane_sizes: 49152 0 rgb96be planes: 1, linesizes: 768 0 0 0, plane_sizes: 36864 0 0 0, plane_offsets: 0 0 0, total_size: 36864 rgb96le planes: 1, linesizes: 768 0 0 0, plane_sizes: 36864 0 0 0, plane_offsets: 0 0 0, total_size: 36864 yuv444 planes: 1, linesizes: 192 0 0 0, plane_sizes: 9216 0 0 0, plane_offsets: 0 0 0, total_size: 9216 +yuv444_16be planes: 1, linesizes: 384 0 0 0, plane_sizes: 18432 0 0 0, plane_offsets: 0 0 0, total_size: 18432 +yuv444_16le planes: 1, linesizes: 384 0 0 0, plane_sizes: 18432 0 0 0, plane_offsets: 0 0 0, total_size: 18432 +uyvy422_16be planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 +uyvy422_16le planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 image_fill_black tests yuv420p total_size: 4608, black_unknown_crc: 0xd00f6cc6, black_tv_crc: 0xd00f6cc6, black_pc_crc: 0x234969af @@ -509,3 +513,7 @@ rgba128le total_size: 49152, black_unknown_crc: 0x59ef499b, black_tv_cr rgb96be total_size: 36864, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000 rgb96le total_size: 36864, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000 yuv444 total_size: 9216, black_unknown_crc: 0x32a4be0b, black_tv_crc: 0x32a4be0b, black_pc_crc: 0x07501edb +yuv444_16be total_size: 18432, black_unknown_crc: 0xac983d03, black_tv_crc: 0xac983d03, black_pc_crc: 0x949a61fc +yuv444_16le total_size: 18432, black_unknown_crc: 0x24c4432b, black_tv_crc: 0x24c4432b, black_pc_crc: 0xfe5a7889 +uyvy422_16be total_size: 12288, black_unknown_crc: 0xb53352d5, black_tv_crc: 0xb53352d5, black_pc_crc: 0xf8461cf3 +uyvy422_16le total_size: 12288, black_unknown_crc: 0xe39de4bd, black_tv_crc: 0xe39de4bd, black_pc_crc: 0x24b29add diff --git a/tests/ref/fate/sws-pixdesc-query b/tests/ref/fate/sws-pixdesc-query index 6e80565..5c2a4bd 100644 --- a/tests/ref/fate/sws-pixdesc-query +++ b/tests/ref/fate/sws-pixdesc-query @@ -25,12 +25,16 @@ is16BPS: rgbaf16le rgbf16be rgbf16le + uyvy422_16be + uyvy422_16le ya16be ya16le yuv420p16be yuv420p16le yuv422p16be yuv422p16le + yuv444_16be + yuv444_16le yuv444p16be yuv444p16le yuva420p16be @@ -187,6 +191,7 @@ isBE: rgbaf32be rgbf16be rgbf32be + uyvy422_16be v30xbe x2bgr10be x2rgb10be @@ -208,6 +213,7 @@ isBE: yuv422p9be yuv440p10be yuv440p12be + yuv444_16be yuv444p10be yuv444p12be yuv444p14be @@ -256,6 +262,8 @@ isYUV: p416le uyva uyvy422 + uyvy422_16be + uyvy422_16le uyyvyy411 v30xbe v30xle @@ -305,6 +313,8 @@ isYUV: yuv440p12be yuv440p12le yuv444 + yuv444_16be + yuv444_16le yuv444p yuv444p10be yuv444p10le @@ -857,6 +867,8 @@ Packed: rgbf32le uyva uyvy422 + uyvy422_16be + uyvy422_16le uyyvyy411 v30xbe v30xle @@ -881,6 +893,8 @@ Packed: ya16le ya8 yuv444 + yuv444_16be + yuv444_16le yuyv422 yvyu422 From patchwork Mon Oct 21 19:57:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: martin schitter X-Patchwork-Id: 52437 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:143:b0:48e:c0f8:d0de with SMTP id h3csp2926141vqi; Mon, 21 Oct 2024 13:29:04 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW3yYwoakzxOpGheB9AFqOkVoLmf/ZH5LtOo0Y9a4KNRLvxRdpoI1Vb1q/FX9uXWbGs9WYUmRJzNx4Sd95J4dtf@gmail.com X-Google-Smtp-Source: AGHT+IG+KjmDh1ERkbHdNrrwfau1gvQRKI/DsT7Ti61wlB4MKTyNSVCgyGTzYfQpZVWmRdZboXeH X-Received: by 2002:a17:907:6d0c:b0:a8d:2281:94d9 with SMTP id a640c23a62f3a-a9aaa620d72mr104860466b.23.1729542544276; Mon, 21 Oct 2024 13:29:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729542544; cv=none; d=google.com; s=arc-20240605; b=G4B/INTaBYjsXXjEE6e/IJVu8LNxAX7DdhKrHel0oVWrICAjiKUC5x28jW6tbleeJs zverIydH/LqLKjtax6c0b9I1wxZ8ocHhVNXXaRa/5e9pPU44FXXMXDE0a9WZgo+Sndvv V9Ak1wKpsIgbUiT06OlXflGKmjDmtwkszfsS2yT4Gw6ZfBq92VZ3YBihFVN9akf4wBmH xKhDzb49FCqTD47i72KqO+356WOUQDlYhyJk3OotpM73miCpRJLG3ArUpvhwHZI2/TGz CiSxS5lSe/NWsZm2yq8gB9HnKzKfAJdTkN8FZPCv5IQl2uhr8YYNU6W5/djwa/QAbAId 9uuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=GF+zQ+jizT9L3Qk5ImkVxIarsOEX6FpgZIZOWnDNYT4=; fh=igg3JDwkSkAbPTwY6V0OsEq0RUkG4DKWC8fVJg4GhMY=; b=kVYiZ3CRaoLpo/qJ/nBdE3ZfNXNL5Tj4HdFO+w7TUiqYGNDPErV/t0bOrDxZjbqOQ9 oO8n882EmnUawKKoxT8Fw6J8AOiIpH1O7o6/jbJ9Jpo3hOs0E/s2SMHDgOaqNbvF++I2 ZID/x/VOIdsgm5Yl5obc4G31lAeZeW7RTSFZGOoKILw+txN+smoEyCBAuO2ngfTsF8sl jEgyoZNk9j0CBTURHHOwbHl+fGCNdleATVeWKe3UZ5uQ0VNM16HYqGG9WoV1ArMGN7Cw hAKcMXsO+lxXotKWJhrglEHuJ49R/G/rKIVlneyuK02BMXRqPQXtCGSp5zojE9n9VPWJ DXEA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mur.at header.s=dkim2 header.b=EVt68z7s; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mur.at Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a9a9136f568si305412166b.711.2024.10.21.13.29.03; Mon, 21 Oct 2024 13:29:04 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@mur.at header.s=dkim2 header.b=EVt68z7s; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mur.at Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5EA1A68DDFC; Mon, 21 Oct 2024 23:18:11 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from efeu.mur.at (efeu.mur.at [89.106.208.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 158F668DBE8 for ; Mon, 21 Oct 2024 23:18:01 +0300 (EEST) Received: from localhost.localdomain (lan1.raspi.ma39.ffgraz.net [10.12.1.243]) by efeu.mur.at (Postfix) with ESMTPSA id ACEC7462E0; Mon, 21 Oct 2024 22:18:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mur.at; s=dkim2; t=1729541880; bh=XeLUVxGTAfa5H949g00akLOeB+T+gejZv29JZlN236E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EVt68z7sp1Z4O+49FM23Km0B6OcfCHH1yWDLE23Sb4a6V6p2350DCekTJakbhPjpE tch4SXFxvlyGAb4X8mOFVwq92IKU5g58/kGzeUlG/R0oCzKWrsVe2jZX7QZjGUYx01 KZSktfyDrs+OkCM391RuW1s6qaPDBK1JKY8yDgDydKOgT7W5Vr+Y5XKv+TT5f6BJb1 ScOVy3klwLmjGvzQPrAAX0pFPeQvUgg8+dNpYbZ+j06ZaA6cj445F8M5SQiMSy1x/r aXWinysxRdfwlYEeARMK+qgAievbtH/X8Nz/q31AeY2I/BS2jrfNYSR2O+6l/HoTsF QGF/++qgWVg5wjknUOdFOVv91Mo3GX5WcsiD4MV+bdlHZWui3mW6UqlF5zl0C3WUSm l09i8fP9d/7Ou03OmL9A2jad7uKllnTdrKlE/4ilyjTAWuITl5BMsaoRVN4aAa62Ip rcrtA9dldBOrQ2RTpI+yys+2dkLBxKgJ/7SjhqNVAJKx9zzqBRU From: Martin Schitter To: ffmpeg-devel@ffmpeg.org Date: Mon, 21 Oct 2024 21:57:16 +0200 Message-ID: <20241021195721.892544-5-ms+git@mur.at> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241021195721.892544-2-ms+git@mur.at> References: <20241021195721.892544-2-ms+git@mur.at> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v12 3/9] avutil/swscale: add YUV444F16 and UYVYF16 pixel format and input support 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 Cc: Martin Schitter Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: gPITcSau9cML --- libavutil/pixdesc.c | 48 ++++++++++++++++ libavutil/pixfmt.h | 6 ++ libswscale/input.c | 99 ++++++++++++++++++++++++++++++++ libswscale/utils.c | 4 ++ tests/ref/fate/imgutils | 8 +++ tests/ref/fate/sws-pixdesc-query | 14 +++++ 6 files changed, 179 insertions(+) diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index 96b9fbe..609f07a 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -515,6 +515,30 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { }, .flags = AV_PIX_FMT_FLAG_BE, }, + [AV_PIX_FMT_UYVY422F16LE] = { + .name = "uyvy422f16le", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, + .comp = { + { 0, 4, 2, 0, 16 }, /* Y */ + { 0, 8, 0, 0, 16 }, /* U */ + { 0, 8, 4, 0, 16 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_FLOAT, + }, + [AV_PIX_FMT_UYVY422F16BE] = { + .name = "uyvy422f16be", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, + .comp = { + { 0, 4, 2, 0, 16 }, /* Y */ + { 0, 8, 0, 0, 16 }, /* U */ + { 0, 8, 4, 0, 16 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_FLOAT, + }, [AV_PIX_FMT_UYYVYY411] = { .name = "uyyvyy411", .nb_components = 3, @@ -1713,6 +1737,30 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { }, .flags = AV_PIX_FMT_FLAG_BE, }, + [AV_PIX_FMT_YUV444F16LE] = { + .name = "yuv444f16le", + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 6, 0, 0, 16 }, /* Y */ + { 0, 6, 2, 0, 16 }, /* U */ + { 0, 6, 4, 0, 16 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_FLOAT, + }, + [AV_PIX_FMT_YUV444F16BE] = { + .name = "yuv444f16be", + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 6, 0, 0, 16 }, /* Y */ + { 0, 6, 2, 0, 16 }, /* U */ + { 0, 6, 4, 0, 16 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_FLOAT, + }, [AV_PIX_FMT_YUV444P10LE] = { .name = "yuv444p10le", .nb_components = 3, diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index fde8dbb..67f568f 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -460,9 +460,13 @@ enum AVPixelFormat { AV_PIX_FMT_YUV444, ///< packed YUV 4:4:4, 24bpp (1 Cr & Cb sample per 1x1 Y), YUVYUV... AV_PIX_FMT_YUV444_16BE, ///< packed YUV 4:4:4, 48bpp (1 Cr & Cb sample per 1x1 Y), YUVYUV..., big-endian AV_PIX_FMT_YUV444_16LE, ///< packed YUV 4:4:4, 48bpp (1 Cr & Cb sample per 1x1 Y), YUVYUV..., little-endian + AV_PIX_FMT_YUV444F16BE, ///< IEEE-754 half precision packed YUV 4:4:4, 48bpp (1 Cr & Cb sample per 1x1 Y), YUVYUV..., big-endian + AV_PIX_FMT_YUV444F16LE, ///< IEEE-754 half precision packed YUV 4:4:4, 48bpp (1 Cr & Cb sample per 1x1 Y), YUVYUV..., little-endian AV_PIX_FMT_UYVY422_16BE, ///< packed UYVU 4:2:2, 32bpp, Cb Y0 Cr Y1, big-endian AV_PIX_FMT_UYVY422_16LE, ///< packed UYVU 4:2:2, 32bpp, Cb Y0 Cr Y1, little-endian + AV_PIX_FMT_UYVY422F16BE, ///< IEEE-754 half precision packed UYVU 4:2:2, 32bpp, Cb Y0 Cr Y1, big-endian + AV_PIX_FMT_UYVY422F16LE, ///< IEEE-754 half precision packed UYVU 4:2:2, 32bpp, Cb Y0 Cr Y1, little-endian AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions }; @@ -515,6 +519,7 @@ enum AVPixelFormat { #define AV_PIX_FMT_YUV422P16 AV_PIX_FMT_NE(YUV422P16BE, YUV422P16LE) #define AV_PIX_FMT_YUV444P16 AV_PIX_FMT_NE(YUV444P16BE, YUV444P16LE) #define AV_PIX_FMT_YUV444_16 AV_PIX_FMT_NE(YUV444_16BE, YUV444_16LE) +#define AV_PIX_FMT_YUV444F16 AV_PIX_FMT_NE(YUV444F16BE, YUV444F16LE) #define AV_PIX_FMT_GBRP9 AV_PIX_FMT_NE(GBRP9BE , GBRP9LE) #define AV_PIX_FMT_GBRP10 AV_PIX_FMT_NE(GBRP10BE, GBRP10LE) @@ -549,6 +554,7 @@ enum AVPixelFormat { #define AV_PIX_FMT_YUVA444P16 AV_PIX_FMT_NE(YUVA444P16BE, YUVA444P16LE) #define AV_PIX_FMT_UYVY422_16 AV_PIX_FMT_NE(UYVY422_16BE, UYVY422_16LE) +#define AV_PIX_FMT_UYVY422F16 AV_PIX_FMT_NE(UYVY422F16BE, UYVY422F16LE) #define AV_PIX_FMT_XYZ12 AV_PIX_FMT_NE(XYZ12BE, XYZ12LE) #define AV_PIX_FMT_NV20 AV_PIX_FMT_NE(NV20BE, NV20LE) diff --git a/libswscale/input.c b/libswscale/input.c index e23b59e..685b2ea 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -838,6 +838,44 @@ static void read_yuv444_16be_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *u } } +static void read_yuv444f16le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, + const uint8_t *unused1, int width, uint32_t *unused2, void *h2f_tbl) +{ + for (int i = 0; i < width; i++) + AV_WN16(dst + i * 2, lrintf(av_clipf(65535.0f * av_int2float( + half2float(AV_RL16(src + i * 6), h2f_tbl)), 0.0f, 65535.0f))); +} + +static void read_yuv444f16le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src, + const uint8_t *unused1, int width, uint32_t *unused2, void *h2f_tbl) +{ + for (int i = 0; i < width; i++) { + AV_WN16(dstU + i * 2, lrintf(av_clipf(65535.0f * (av_int2float( + half2float(AV_RL16(src + i * 6 + 2), h2f_tbl)) + 0.5f), 0.0f, 65535.0f))); + AV_WN16(dstV + i * 2, lrintf(av_clipf(65535.0f * (av_int2float( + half2float(AV_RL16(src + i * 6 + 4), h2f_tbl)) + 0.5f), 0.0f, 65535.0f))); + } +} + +static void read_yuv444f16be_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, + const uint8_t *unused1, int width, uint32_t *unused2, void *h2f_tbl) +{ + for (int i = 0; i < width; i++) + AV_WN16(dst + i * 2, lrintf(av_clipf(65535.0f * av_int2float( + half2float(AV_RB16(src + i * 6), h2f_tbl)), 0.0f, 65535.0f))); +} + +static void read_yuv444f16be_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src, + const uint8_t *unused1, int width, uint32_t *unused2, void *h2f_tbl) +{ + for (int i = 0; i < width; i++) { + AV_WN16(dstU + i * 2, lrintf(av_clipf(65535.0f * (av_int2float( + half2float(AV_RB16(src + i * 6 + 2), h2f_tbl)) + 0.5f), 0.0f, 65535.0f))); + AV_WN16(dstV + i * 2, lrintf(av_clipf(65535.0f * (av_int2float( + half2float(AV_RB16(src + i * 6 + 4), h2f_tbl)) + 0.5f), 0.0f, 65535.0f))); + } +} + static void read_v30xle_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width, uint32_t *unused2, void *opq) { @@ -968,6 +1006,43 @@ static void uyvy16be_ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0 } } +static void uyvyf16le_ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, + uint32_t *unused, void *h2f_tbl) +{ + for (int i = 0; i < width; i++) + AV_WN16(dst + i * 2, lrintf(av_clipf(65535.0f * av_int2float( + half2float(AV_RL16(src + i * 4 + 2), h2f_tbl)), 0.0f, 65535.0f))); +} + +static void uyvyf16le_ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1, + const uint8_t *src2, int width, uint32_t *unused, void *h2f_tbl) +{ + for (int i = 0; i < width; i++) { + AV_WN16(dstU + i * 2, lrintf(av_clipf(65535.0f * (av_int2float( + half2float(AV_RL16(src1 + i * 8), h2f_tbl)) + 0.5f), 0.0f, 65535.0f))); + AV_WN16(dstV + i * 2, lrintf(av_clipf(65535.0f * (av_int2float( + half2float(AV_RL16(src1 + i * 8 + 4), h2f_tbl)) + 0.5f), 0.0f, 65535.0f))); + } +} + +static void uyvyf16be_ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, + uint32_t *unused, void *h2f_tbl) +{ + for (int i = 0; i < width; i++) + AV_WN16(dst + i * 2, lrintf(av_clipf(65535.0f * av_int2float( + half2float(AV_RB16(src + i * 4 + 2), h2f_tbl)), 0.0f, 65535.0f))); +} + +static void uyvyf16be_ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1, + const uint8_t *src2, int width, uint32_t *unused, void *h2f_tbl) +{ + for (int i = 0; i < width; i++) { + AV_WN16(dstU + i * 2, lrintf(av_clipf(65535.0f * (av_int2float( + half2float(AV_RB16(src1 + i * 8), h2f_tbl)) + 0.5f), 0.0f, 65535.0f))); + AV_WN16(dstV + i * 2, lrintf(av_clipf(65535.0f * (av_int2float( + half2float(AV_RB16(src1 + i * 8 + 4), h2f_tbl)) + 0.5f), 0.0f, 65535.0f))); + } +} static av_always_inline void nvXXtoUV_c(uint8_t *dst1, uint8_t *dst2, const uint8_t *src, int width) @@ -1647,6 +1722,12 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c, case AV_PIX_FMT_UYVY422_16BE: *chrToYV12 = uyvy16be_ToUV_c; break; + case AV_PIX_FMT_UYVY422F16LE: + *chrToYV12 = uyvyf16le_ToUV_c; + break; + case AV_PIX_FMT_UYVY422F16BE: + *chrToYV12 = uyvyf16be_ToUV_c; + break; case AV_PIX_FMT_VYU444: *chrToYV12 = vyuToUV_c; break; @@ -1659,6 +1740,12 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c, case AV_PIX_FMT_YUV444_16BE: *chrToYV12 = read_yuv444_16be_UV_c; break; + case AV_PIX_FMT_YUV444F16LE: + *chrToYV12 = read_yuv444f16le_UV_c; + break; + case AV_PIX_FMT_YUV444F16BE: + *chrToYV12 = read_yuv444f16be_UV_c; + break; case AV_PIX_FMT_NV12: case AV_PIX_FMT_NV16: case AV_PIX_FMT_NV24: @@ -2264,6 +2351,12 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c, case AV_PIX_FMT_UYVY422_16BE: *lumToYV12 = uyvy16be_ToY_c; break; + case AV_PIX_FMT_UYVY422F16LE: + *lumToYV12 = uyvyf16le_ToY_c; + break; + case AV_PIX_FMT_UYVY422F16BE: + *lumToYV12 = uyvyf16be_ToY_c; + break; case AV_PIX_FMT_VYU444: *lumToYV12 = vyuToY_c; break; @@ -2276,6 +2369,12 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c, case AV_PIX_FMT_YUV444_16BE: *lumToYV12 = read_yuv444_16be_Y_c; break; + case AV_PIX_FMT_YUV444F16LE: + *lumToYV12 = read_yuv444f16le_Y_c; + break; + case AV_PIX_FMT_YUV444F16BE: + *lumToYV12 = read_yuv444f16be_Y_c; + break; case AV_PIX_FMT_BGR24: *lumToYV12 = bgr24ToY_c; break; diff --git a/libswscale/utils.c b/libswscale/utils.c index 623e826..4573355 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -76,6 +76,8 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_YUV444] = { 1, 0 }, [AV_PIX_FMT_YUV444_16BE] = { 1, 0 }, [AV_PIX_FMT_YUV444_16LE] = { 1, 0 }, + [AV_PIX_FMT_YUV444F16BE] = { 1, 0 }, + [AV_PIX_FMT_YUV444F16LE] = { 1, 0 }, [AV_PIX_FMT_YUV410P] = { 1, 1 }, [AV_PIX_FMT_YUV411P] = { 1, 1 }, [AV_PIX_FMT_GRAY8] = { 1, 1 }, @@ -90,6 +92,8 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_UYVY422] = { 1, 1 }, [AV_PIX_FMT_UYVY422_16BE]= { 1, 0 }, [AV_PIX_FMT_UYVY422_16LE]= { 1, 0 }, + [AV_PIX_FMT_UYVY422F16BE]= { 1, 0 }, + [AV_PIX_FMT_UYVY422F16LE]= { 1, 0 }, [AV_PIX_FMT_UYYVYY411] = { 0, 0 }, [AV_PIX_FMT_BGR8] = { 1, 1 }, [AV_PIX_FMT_BGR4] = { 0, 1 }, diff --git a/tests/ref/fate/imgutils b/tests/ref/fate/imgutils index b4d98f4..bebd540 100644 --- a/tests/ref/fate/imgutils +++ b/tests/ref/fate/imgutils @@ -283,8 +283,12 @@ rgb96le planes: 1, linesizes: 768 0 0 0, plane_sizes: 36864 0 yuv444 planes: 1, linesizes: 192 0 0 0, plane_sizes: 9216 0 0 0, plane_offsets: 0 0 0, total_size: 9216 yuv444_16be planes: 1, linesizes: 384 0 0 0, plane_sizes: 18432 0 0 0, plane_offsets: 0 0 0, total_size: 18432 yuv444_16le planes: 1, linesizes: 384 0 0 0, plane_sizes: 18432 0 0 0, plane_offsets: 0 0 0, total_size: 18432 +yuv444f16be planes: 1, linesizes: 384 0 0 0, plane_sizes: 18432 0 0 0, plane_offsets: 0 0 0, total_size: 18432 +yuv444f16le planes: 1, linesizes: 384 0 0 0, plane_sizes: 18432 0 0 0, plane_offsets: 0 0 0, total_size: 18432 uyvy422_16be planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 uyvy422_16le planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 +uyvy422f16be planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 +uyvy422f16le planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 image_fill_black tests yuv420p total_size: 4608, black_unknown_crc: 0xd00f6cc6, black_tv_crc: 0xd00f6cc6, black_pc_crc: 0x234969af @@ -515,5 +519,9 @@ rgb96le total_size: 36864, black_unknown_crc: 0x00000000, black_tv_cr yuv444 total_size: 9216, black_unknown_crc: 0x32a4be0b, black_tv_crc: 0x32a4be0b, black_pc_crc: 0x07501edb yuv444_16be total_size: 18432, black_unknown_crc: 0xac983d03, black_tv_crc: 0xac983d03, black_pc_crc: 0x949a61fc yuv444_16le total_size: 18432, black_unknown_crc: 0x24c4432b, black_tv_crc: 0x24c4432b, black_pc_crc: 0xfe5a7889 +yuv444f16be total_size: 18432, black_unknown_crc: 0x5cf972e1, black_tv_crc: 0x5cf972e1, black_pc_crc: 0x482033cf +yuv444f16le total_size: 18432, black_unknown_crc: 0x4a18e5bb, black_tv_crc: 0x4a18e5bb, black_pc_crc: 0x920584a7 uyvy422_16be total_size: 12288, black_unknown_crc: 0xb53352d5, black_tv_crc: 0xb53352d5, black_pc_crc: 0xf8461cf3 uyvy422_16le total_size: 12288, black_unknown_crc: 0xe39de4bd, black_tv_crc: 0xe39de4bd, black_pc_crc: 0x24b29add +uyvy422f16be total_size: 12288, black_unknown_crc: 0x9c275ddf, black_tv_crc: 0x9c275ddf, black_pc_crc: 0xde92b629 +uyvy422f16le total_size: 12288, black_unknown_crc: 0x2e5b76c4, black_tv_crc: 0x2e5b76c4, black_pc_crc: 0x2928eced diff --git a/tests/ref/fate/sws-pixdesc-query b/tests/ref/fate/sws-pixdesc-query index 5c2a4bd..0d564c8 100644 --- a/tests/ref/fate/sws-pixdesc-query +++ b/tests/ref/fate/sws-pixdesc-query @@ -27,6 +27,8 @@ is16BPS: rgbf16le uyvy422_16be uyvy422_16le + uyvy422f16be + uyvy422f16le ya16be ya16le yuv420p16be @@ -35,6 +37,8 @@ is16BPS: yuv422p16le yuv444_16be yuv444_16le + yuv444f16be + yuv444f16le yuv444p16be yuv444p16le yuva420p16be @@ -192,6 +196,7 @@ isBE: rgbf16be rgbf32be uyvy422_16be + uyvy422f16be v30xbe x2bgr10be x2rgb10be @@ -214,6 +219,7 @@ isBE: yuv440p10be yuv440p12be yuv444_16be + yuv444f16be yuv444p10be yuv444p12be yuv444p14be @@ -264,6 +270,8 @@ isYUV: uyvy422 uyvy422_16be uyvy422_16le + uyvy422f16be + uyvy422f16le uyyvyy411 v30xbe v30xle @@ -315,6 +323,8 @@ isYUV: yuv444 yuv444_16be yuv444_16le + yuv444f16be + yuv444f16le yuv444p yuv444p10be yuv444p10le @@ -869,6 +879,8 @@ Packed: uyvy422 uyvy422_16be uyvy422_16le + uyvy422f16be + uyvy422f16le uyyvyy411 v30xbe v30xle @@ -895,6 +907,8 @@ Packed: yuv444 yuv444_16be yuv444_16le + yuv444f16be + yuv444f16le yuyv422 yvyu422 From patchwork Mon Oct 21 19:57:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: martin schitter X-Patchwork-Id: 52432 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:143:b0:48e:c0f8:d0de with SMTP id h3csp2921238vqi; Mon, 21 Oct 2024 13:18:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWYlrwR2mpNFAbIKj6xIoNGsk/yDOFuyjtcIlAE2gdZ2So2oK/DLbEVRGHrWPYmia9f6e8oXoxmttsZX5Didm78@gmail.com X-Google-Smtp-Source: AGHT+IGvTLOmdxY/vtEryuqGGz1pDyS+BZl0dWFCB6oKpKcmcXN0G9qqgkGDwmD0GUzPu3xasZnw X-Received: by 2002:a2e:be9c:0:b0:2fb:56c1:c4 with SMTP id 38308e7fff4ca-2fb82e9314dmr17239791fa.3.1729541937488; Mon, 21 Oct 2024 13:18:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729541937; cv=none; d=google.com; s=arc-20240605; b=k2frpRJfwrV0UnjsxeD/ekibTNsNpQDmBy6BjoekI9oPZCDz47yEIBk+rY2uTwA4g6 yo+OJGqk2m1zde3Le3nh/PSYjTXsQK0f1TwiSkvsNQ/kpGRkMFuTPHT2a0oZ2qgfD8as BbL8rWTb+DYkbTapfgUaedGgSO6R5gIG0ZmMk/31Mf5k4CiQcly82FxjebvDwjWwb5pf 3U9nKfk9DGZenQxduX3pdxpLKehkOk6FMMGMFGQ+9Tq9YtIgDgHv8RCEAcuxz7lRvVj6 H1gLC/aw7chynNTyF2oTJ0ZqgQsaqSuecEIEqec8uH8ozr6hHQsWEb90mGQ8asm723gL eAmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=Ut/lwyONVhwbOITBLeUUIuQhrq8adRm1q/u/CS3px10=; fh=igg3JDwkSkAbPTwY6V0OsEq0RUkG4DKWC8fVJg4GhMY=; b=MqQDsekS4+luP2HejGoDyzAFdGOz65pMdLSED5CXhrsFweQyuIg3x24o14XXmGKy9A /SUwCvmQpbLWtxzzh5ywxpdUYXoYys2hog6imtrDPV/wO8ZsLFNenIhyngISZxSm35Wm 9t1h0tbJfpY+WnTcnu7HF6xDQ1k6eSnoghEDWnZdvbhklhV8PkXmNT3dSHPcoS1FVnT7 He+Ep2GJsOWF5LAqO0/OFF/fRPXouWxIsGFszW/KTnVhyjut/GVjvMHg4OYEc0Nouyek 5K3oezFniFIBn89h7P4trmLs4cJWE5OT7jX8GW3xUATdY/ZxKkBhs2MAgVY/P7rFIdHs cD0g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mur.at header.s=dkim2 header.b=mXEcu1rU; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mur.at Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 38308e7fff4ca-2fb9ade6bf0si11707951fa.146.2024.10.21.13.18.56; Mon, 21 Oct 2024 13:18:57 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@mur.at header.s=dkim2 header.b=mXEcu1rU; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mur.at Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 84EFE68DDFB; Mon, 21 Oct 2024 23:18:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from efeu.mur.at (efeu.mur.at [89.106.208.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3124F68DA3F for ; Mon, 21 Oct 2024 23:18:01 +0300 (EEST) Received: from localhost.localdomain (lan1.raspi.ma39.ffgraz.net [10.12.1.243]) by efeu.mur.at (Postfix) with ESMTPSA id C8D7E462E2; Mon, 21 Oct 2024 22:18:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mur.at; s=dkim2; t=1729541880; bh=UfpkYwzqQZivDAZvCqUL6jx3q7wWjcuXVh8y6p2NyWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mXEcu1rU83m1xKNI9ziHH915hkvxvbkhbej0yOB810Q792L+utRc8W2mWuBbgwvpu SxxyBp1e/NCgWBnda+p3EJPT33utMFQbypbuM/jDFoK7woeEOOApk9T6dD8ABUDihm BKP1xzqa7FcdsQ+mqBIrEGRWQEyyI4HdxJfKLkuL8vNLjmKSQm1zVmG3/ixScS5TzU LKQrXAaJDoKies6hxRKTpR+ZPyw+LPJV7XHx5CvAHlXyYMrqotKy0T+oWreEZW6BXZ WXZAidA25YWJNTtH0Jsz/5C1yyk2Di9DOvBJmMjle6X6RNNVL03UUMb6EoHWTLUfv1 Fw40NINrv9/Gx1pRqpS9jqVlIDhe9bRiwJfCt1RvAAddHYMltvrYWlXrQl5wp6d+58 EWd7qdRqFQrI8DNXnWaM4bEX/4YixvgyH804EPT5eK+Fhvk/pJKZEy2LDEZjEy0BHd bd0UpeodDBPZ5DyO+VBbuDspsl3IoWsvUA15k3vLLZg4aX6v27j From: Martin Schitter To: ffmpeg-devel@ffmpeg.org Date: Mon, 21 Oct 2024 21:57:17 +0200 Message-ID: <20241021195721.892544-6-ms+git@mur.at> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241021195721.892544-2-ms+git@mur.at> References: <20241021195721.892544-2-ms+git@mur.at> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v12 4/9] avutil/swscale: add YUV444F32 and UYVYF32 pixel format and input support 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 Cc: Martin Schitter Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: glOi1RUy9dQU --- libavutil/pixdesc.c | 48 +++++++++++++++ libavutil/pixfmt.h | 6 ++ libswscale/input.c | 100 +++++++++++++++++++++++++++++++ libswscale/utils.c | 6 +- tests/ref/fate/imgutils | 8 +++ tests/ref/fate/sws-pixdesc-query | 10 ++++ 6 files changed, 177 insertions(+), 1 deletion(-) diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index 609f07a..f69c9b2 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -539,6 +539,30 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_FLOAT, }, + [AV_PIX_FMT_UYVY422F32LE] = { + .name = "uyvy422f32le", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, + .comp = { + { 0, 8, 4, 0, 32 }, /* Y */ + { 0, 16, 0, 0, 32 }, /* U */ + { 0, 16, 8, 0, 32 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_FLOAT, + }, + [AV_PIX_FMT_UYVY422F32BE] = { + .name = "uyvy422f32be", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, + .comp = { + { 0, 8, 4, 0, 32 }, /* Y */ + { 0, 16, 0, 0, 32 }, /* U */ + { 0, 16, 8, 0, 32 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_FLOAT, + }, [AV_PIX_FMT_UYYVYY411] = { .name = "uyyvyy411", .nb_components = 3, @@ -1761,6 +1785,30 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_FLOAT, }, + [AV_PIX_FMT_YUV444F32LE] = { + .name = "yuv444f32le", + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 12, 0, 0, 32 }, /* Y */ + { 0, 12, 4, 0, 32 }, /* U */ + { 0, 12, 8, 0, 32 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_FLOAT, + }, + [AV_PIX_FMT_YUV444F32BE] = { + .name = "yuv444f32be", + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 12, 0, 0, 32 }, /* Y */ + { 0, 12, 4, 0, 32 }, /* U */ + { 0, 12, 8, 0, 32 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_FLOAT, + }, [AV_PIX_FMT_YUV444P10LE] = { .name = "yuv444p10le", .nb_components = 3, diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index 67f568f..b946b8d 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -462,11 +462,15 @@ enum AVPixelFormat { AV_PIX_FMT_YUV444_16LE, ///< packed YUV 4:4:4, 48bpp (1 Cr & Cb sample per 1x1 Y), YUVYUV..., little-endian AV_PIX_FMT_YUV444F16BE, ///< IEEE-754 half precision packed YUV 4:4:4, 48bpp (1 Cr & Cb sample per 1x1 Y), YUVYUV..., big-endian AV_PIX_FMT_YUV444F16LE, ///< IEEE-754 half precision packed YUV 4:4:4, 48bpp (1 Cr & Cb sample per 1x1 Y), YUVYUV..., little-endian + AV_PIX_FMT_YUV444F32BE, ///< IEEE-754 single precision packed YUV 4:4:4, 96bpp (1 Cr & Cb sample per 1x1 Y), YUVYUV..., big-endian + AV_PIX_FMT_YUV444F32LE, ///< IEEE-754 single precision packed YUV 4:4:4, 96bpp (1 Cr & Cb sample per 1x1 Y), YUVYUV..., little-endian AV_PIX_FMT_UYVY422_16BE, ///< packed UYVU 4:2:2, 32bpp, Cb Y0 Cr Y1, big-endian AV_PIX_FMT_UYVY422_16LE, ///< packed UYVU 4:2:2, 32bpp, Cb Y0 Cr Y1, little-endian AV_PIX_FMT_UYVY422F16BE, ///< IEEE-754 half precision packed UYVU 4:2:2, 32bpp, Cb Y0 Cr Y1, big-endian AV_PIX_FMT_UYVY422F16LE, ///< IEEE-754 half precision packed UYVU 4:2:2, 32bpp, Cb Y0 Cr Y1, little-endian + AV_PIX_FMT_UYVY422F32BE, ///< IEEE-754 single precision packed UYVU 4:2:2, 64bpp, Cb Y0 Cr Y1, big-endian + AV_PIX_FMT_UYVY422F32LE, ///< IEEE-754 single precision packed UYVU 4:2:2, 64bpp, Cb Y0 Cr Y1, little-endian AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions }; @@ -520,6 +524,7 @@ enum AVPixelFormat { #define AV_PIX_FMT_YUV444P16 AV_PIX_FMT_NE(YUV444P16BE, YUV444P16LE) #define AV_PIX_FMT_YUV444_16 AV_PIX_FMT_NE(YUV444_16BE, YUV444_16LE) #define AV_PIX_FMT_YUV444F16 AV_PIX_FMT_NE(YUV444F16BE, YUV444F16LE) +#define AV_PIX_FMT_YUV444F32 AV_PIX_FMT_NE(YUV444F32BE, YUV444F32LE) #define AV_PIX_FMT_GBRP9 AV_PIX_FMT_NE(GBRP9BE , GBRP9LE) #define AV_PIX_FMT_GBRP10 AV_PIX_FMT_NE(GBRP10BE, GBRP10LE) @@ -555,6 +560,7 @@ enum AVPixelFormat { #define AV_PIX_FMT_UYVY422_16 AV_PIX_FMT_NE(UYVY422_16BE, UYVY422_16LE) #define AV_PIX_FMT_UYVY422F16 AV_PIX_FMT_NE(UYVY422F16BE, UYVY422F16LE) +#define AV_PIX_FMT_UYVY422F32 AV_PIX_FMT_NE(UYVY422F32BE, UYVY422F32LE) #define AV_PIX_FMT_XYZ12 AV_PIX_FMT_NE(XYZ12BE, XYZ12LE) #define AV_PIX_FMT_NV20 AV_PIX_FMT_NE(NV20BE, NV20LE) diff --git a/libswscale/input.c b/libswscale/input.c index 685b2ea..f9d7c39 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -876,6 +876,44 @@ static void read_yuv444f16be_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *u } } +static void read_yuv444f32le_Y_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused0, + const uint8_t *unused1, int width, uint32_t *unused2, void *opq) +{ + uint16_t *dst = (uint16_t *) _dst; + for (int i = 0; i < width; i++) + dst[i] = lrintf(av_clipf(65535.0f * av_int2float(AV_RL32(src + i * 12)), 0.0f, 65535.0f)); +} + +static void read_yuv444f32le_UV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src, + const uint8_t *unused1, int width, uint32_t *unused2, void *opq) +{ + uint16_t *dstU = (uint16_t *) _dstU; + uint16_t *dstV = (uint16_t *) _dstV; + for (int i = 0; i < width; i++) { + dstU[i] = lrintf(av_clipf(65535.0f * (av_int2float(AV_RL32(src + i * 12 + 4)) + 0.5f), 0.0f, 65535.0f)); + dstV[i] = lrintf(av_clipf(65535.0f * (av_int2float(AV_RL32(src + i * 12 + 8)) + 0.5f), 0.0f, 65535.0f)); + } +} + +static void read_yuv444f32be_Y_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused0, + const uint8_t *unused1, int width, uint32_t *unused2, void *opq) +{ + uint16_t *dst = (uint16_t *) _dst; + for (int i = 0; i < width; i++) + dst[i] = lrintf(av_clipf(65535.0f * av_int2float(AV_RB32(src + i * 12)), 0.0f, 65535.0f)); +} + +static void read_yuv444f32be_UV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src, + const uint8_t *unused1, int width, uint32_t *unused2, void *opq) +{ + uint16_t *dstU = (uint16_t *) _dstU; + uint16_t *dstV = (uint16_t *) _dstV; + for (int i = 0; i < width; i++) { + dstU[i] = lrintf(av_clipf(65535.0f * (av_int2float(AV_RB32(src + i * 12 + 4)) + 0.5f), 0.0f, 65535.0f)); + dstV[i] = lrintf(av_clipf(65535.0f * (av_int2float(AV_RB32(src + i * 12 + 8)) + 0.5f), 0.0f, 65535.0f)); + } +} + static void read_v30xle_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width, uint32_t *unused2, void *opq) { @@ -1044,6 +1082,44 @@ static void uyvyf16be_ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused } } +static void uyvyf32le_ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, + uint32_t *unused, void *obl) +{ + uint16_t *dst = (uint16_t *) _dst; + for (int i = 0; i < width; i++) + dst[i] = lrintf(av_clipf(65535.0f * av_int2float(AV_RL32(src + i * 8 + 4)), 0.0f, 65535.0f)); +} + +static void uyvyf32le_ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1, + const uint8_t *src2, int width, uint32_t *unused, void *obl) +{ + uint16_t *dstU = (uint16_t *) _dstU; + uint16_t *dstV = (uint16_t *) _dstV; + for (int i = 0; i < width; i++) { + dstU[i] = lrintf(av_clipf(65535.0f * (av_int2float(AV_RL32(src1 + i * 16)) + 0.5f), 0.0f, 65535.0f)); + dstV[i] = lrintf(av_clipf(65535.0f * (av_int2float(AV_RL32(src1 + i * 16 + 8)) + 0.5f), 0.0f, 65535.0f)); + } +} + +static void uyvyf32be_ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, + uint32_t *unused, void *obl) +{ + uint16_t *dst = (uint16_t *) _dst; + for (int i = 0; i < width; i++) + dst[i] = lrintf(av_clipf(65535.0f * av_int2float(AV_RB32(src + i * 8 + 4)), 0.0f, 65535.0f)); +} + +static void uyvyf32be_ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1, + const uint8_t *src2, int width, uint32_t *unused, void *obl) +{ + uint16_t *dstU = (uint16_t *) _dstU; + uint16_t *dstV = (uint16_t *) _dstV; + for (int i = 0; i < width; i++) { + dstU[i] = lrintf(av_clipf(65535.0f * (av_int2float(AV_RB32(src1 + i * 16)) + 0.5f), 0.0f, 65535.0f)); + dstV[i] = lrintf(av_clipf(65535.0f * (av_int2float(AV_RB32(src1 + i * 16 + 8)) + 0.5f), 0.0f, 65535.0f)); + } +} + static av_always_inline void nvXXtoUV_c(uint8_t *dst1, uint8_t *dst2, const uint8_t *src, int width) { @@ -1728,6 +1804,12 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c, case AV_PIX_FMT_UYVY422F16BE: *chrToYV12 = uyvyf16be_ToUV_c; break; + case AV_PIX_FMT_UYVY422F32LE: + *chrToYV12 = uyvyf32le_ToUV_c; + break; + case AV_PIX_FMT_UYVY422F32BE: + *chrToYV12 = uyvyf32be_ToUV_c; + break; case AV_PIX_FMT_VYU444: *chrToYV12 = vyuToUV_c; break; @@ -1746,6 +1828,12 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c, case AV_PIX_FMT_YUV444F16BE: *chrToYV12 = read_yuv444f16be_UV_c; break; + case AV_PIX_FMT_YUV444F32LE: + *chrToYV12 = read_yuv444f32le_UV_c; + break; + case AV_PIX_FMT_YUV444F32BE: + *chrToYV12 = read_yuv444f32be_UV_c; + break; case AV_PIX_FMT_NV12: case AV_PIX_FMT_NV16: case AV_PIX_FMT_NV24: @@ -2357,6 +2445,12 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c, case AV_PIX_FMT_UYVY422F16BE: *lumToYV12 = uyvyf16be_ToY_c; break; + case AV_PIX_FMT_UYVY422F32LE: + *lumToYV12 = uyvyf32le_ToY_c; + break; + case AV_PIX_FMT_UYVY422F32BE: + *lumToYV12 = uyvyf32be_ToY_c; + break; case AV_PIX_FMT_VYU444: *lumToYV12 = vyuToY_c; break; @@ -2375,6 +2469,12 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c, case AV_PIX_FMT_YUV444F16BE: *lumToYV12 = read_yuv444f16be_Y_c; break; + case AV_PIX_FMT_YUV444F32LE: + *lumToYV12 = read_yuv444f32le_Y_c; + break; + case AV_PIX_FMT_YUV444F32BE: + *lumToYV12 = read_yuv444f32be_Y_c; + break; case AV_PIX_FMT_BGR24: *lumToYV12 = bgr24ToY_c; break; diff --git a/libswscale/utils.c b/libswscale/utils.c index 4573355..5318ae8 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -78,6 +78,8 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_YUV444_16LE] = { 1, 0 }, [AV_PIX_FMT_YUV444F16BE] = { 1, 0 }, [AV_PIX_FMT_YUV444F16LE] = { 1, 0 }, + [AV_PIX_FMT_YUV444F32BE] = { 1, 0 }, + [AV_PIX_FMT_YUV444F32LE] = { 1, 0 }, [AV_PIX_FMT_YUV410P] = { 1, 1 }, [AV_PIX_FMT_YUV411P] = { 1, 1 }, [AV_PIX_FMT_GRAY8] = { 1, 1 }, @@ -94,6 +96,8 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_UYVY422_16LE]= { 1, 0 }, [AV_PIX_FMT_UYVY422F16BE]= { 1, 0 }, [AV_PIX_FMT_UYVY422F16LE]= { 1, 0 }, + [AV_PIX_FMT_UYVY422F32BE]= { 1, 0 }, + [AV_PIX_FMT_UYVY422F32LE]= { 1, 0 }, [AV_PIX_FMT_UYYVYY411] = { 0, 0 }, [AV_PIX_FMT_BGR8] = { 1, 1 }, [AV_PIX_FMT_BGR4] = { 0, 1 }, @@ -1717,7 +1721,7 @@ static av_cold int sws_init_single_context(SwsContext *c, SwsFilter *srcFilter, } // float will be converted to uint16_t - if ((srcFormat == AV_PIX_FMT_GRAYF32BE || srcFormat == AV_PIX_FMT_GRAYF32LE) && + if (isFloat(srcFormat) && (!unscaled || unscaled && dstFormat != srcFormat && (srcFormat != AV_PIX_FMT_GRAYF32 || dstFormat != AV_PIX_FMT_GRAY8))){ c->srcBpc = 16; diff --git a/tests/ref/fate/imgutils b/tests/ref/fate/imgutils index bebd540..f0ac9d2 100644 --- a/tests/ref/fate/imgutils +++ b/tests/ref/fate/imgutils @@ -285,10 +285,14 @@ yuv444_16be planes: 1, linesizes: 384 0 0 0, plane_sizes: 18432 0 yuv444_16le planes: 1, linesizes: 384 0 0 0, plane_sizes: 18432 0 0 0, plane_offsets: 0 0 0, total_size: 18432 yuv444f16be planes: 1, linesizes: 384 0 0 0, plane_sizes: 18432 0 0 0, plane_offsets: 0 0 0, total_size: 18432 yuv444f16le planes: 1, linesizes: 384 0 0 0, plane_sizes: 18432 0 0 0, plane_offsets: 0 0 0, total_size: 18432 +yuv444f32be planes: 1, linesizes: 768 0 0 0, plane_sizes: 36864 0 0 0, plane_offsets: 0 0 0, total_size: 36864 +yuv444f32le planes: 1, linesizes: 768 0 0 0, plane_sizes: 36864 0 0 0, plane_offsets: 0 0 0, total_size: 36864 uyvy422_16be planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 uyvy422_16le planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 uyvy422f16be planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 uyvy422f16le planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 +uyvy422f32be planes: 1, linesizes: 512 0 0 0, plane_sizes: 24576 0 0 0, plane_offsets: 0 0 0, total_size: 24576 +uyvy422f32le planes: 1, linesizes: 512 0 0 0, plane_sizes: 24576 0 0 0, plane_offsets: 0 0 0, total_size: 24576 image_fill_black tests yuv420p total_size: 4608, black_unknown_crc: 0xd00f6cc6, black_tv_crc: 0xd00f6cc6, black_pc_crc: 0x234969af @@ -521,7 +525,11 @@ yuv444_16be total_size: 18432, black_unknown_crc: 0xac983d03, black_tv_cr yuv444_16le total_size: 18432, black_unknown_crc: 0x24c4432b, black_tv_crc: 0x24c4432b, black_pc_crc: 0xfe5a7889 yuv444f16be total_size: 18432, black_unknown_crc: 0x5cf972e1, black_tv_crc: 0x5cf972e1, black_pc_crc: 0x482033cf yuv444f16le total_size: 18432, black_unknown_crc: 0x4a18e5bb, black_tv_crc: 0x4a18e5bb, black_pc_crc: 0x920584a7 +yuv444f32be total_size: 36864, black_unknown_crc: 0x1ea7a984, black_tv_crc: 0x1ea7a984, black_pc_crc: 0x63cf67b9 +yuv444f32le total_size: 36864, black_unknown_crc: 0x63d60c2d, black_tv_crc: 0x63d60c2d, black_pc_crc: 0x2d5f6a04 uyvy422_16be total_size: 12288, black_unknown_crc: 0xb53352d5, black_tv_crc: 0xb53352d5, black_pc_crc: 0xf8461cf3 uyvy422_16le total_size: 12288, black_unknown_crc: 0xe39de4bd, black_tv_crc: 0xe39de4bd, black_pc_crc: 0x24b29add uyvy422f16be total_size: 12288, black_unknown_crc: 0x9c275ddf, black_tv_crc: 0x9c275ddf, black_pc_crc: 0xde92b629 uyvy422f16le total_size: 12288, black_unknown_crc: 0x2e5b76c4, black_tv_crc: 0x2e5b76c4, black_pc_crc: 0x2928eced +uyvy422f32be total_size: 24576, black_unknown_crc: 0x04614e4a, black_tv_crc: 0x04614e4a, black_pc_crc: 0xaa67a8ce +uyvy422f32le total_size: 24576, black_unknown_crc: 0x3bf0427e, black_tv_crc: 0x3bf0427e, black_pc_crc: 0x7636d7e3 diff --git a/tests/ref/fate/sws-pixdesc-query b/tests/ref/fate/sws-pixdesc-query index 0d564c8..d19007f 100644 --- a/tests/ref/fate/sws-pixdesc-query +++ b/tests/ref/fate/sws-pixdesc-query @@ -197,6 +197,7 @@ isBE: rgbf32be uyvy422_16be uyvy422f16be + uyvy422f32be v30xbe x2bgr10be x2rgb10be @@ -220,6 +221,7 @@ isBE: yuv440p12be yuv444_16be yuv444f16be + yuv444f32be yuv444p10be yuv444p12be yuv444p14be @@ -272,6 +274,8 @@ isYUV: uyvy422_16le uyvy422f16be uyvy422f16le + uyvy422f32be + uyvy422f32le uyyvyy411 v30xbe v30xle @@ -325,6 +329,8 @@ isYUV: yuv444_16le yuv444f16be yuv444f16le + yuv444f32be + yuv444f32le yuv444p yuv444p10be yuv444p10le @@ -881,6 +887,8 @@ Packed: uyvy422_16le uyvy422f16be uyvy422f16le + uyvy422f32be + uyvy422f32le uyyvyy411 v30xbe v30xle @@ -909,6 +917,8 @@ Packed: yuv444_16le yuv444f16be yuv444f16le + yuv444f32be + yuv444f32le yuyv422 yvyu422 From patchwork Mon Oct 21 19:57:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: martin schitter X-Patchwork-Id: 52439 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:143:b0:48e:c0f8:d0de with SMTP id h3csp2948476vqi; Mon, 21 Oct 2024 14:14:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWzxBmxWcmYOj3pz88Gf3PhgrM+Smo17h9+uUuAp3b/BDwwfjxqjOVN2joOuVIQbHCq7gppTt0xaTspjfXnYyy5@gmail.com X-Google-Smtp-Source: AGHT+IFlZ+4pnzlL3gj4q+nzqKlFa13I0TETsJuvK0YyN03i0SdYFRljoZjnrJ8WLeFRIMhbugSn X-Received: by 2002:a17:907:7d90:b0:a9a:2a56:91f with SMTP id a640c23a62f3a-a9a699699d7mr1254695766b.2.1729545247667; Mon, 21 Oct 2024 14:14:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729545247; cv=none; d=google.com; s=arc-20240605; b=TBchtePDOikiN6P2xUU5IQxqE+lqIqqOdAKOHLK7Y8MlRGQfbCM15vNuZeL/ZZjQoE CofEbLbuhgRfmeRwKQeEQZmmGc0kv5/UJf9XKDRrIjzSbkWWzrTVZ4cRbS1BKEMBN5fH /xQ4K+OXe5kXHtLyqhMiGDmj9yj9UZMPLVa6D+xraEsBHxaPDIyidv/ihs3cPCOjj/ov 5Q4vJPRPH9/IA9AkgWT4m3Hq92AZksSWkgpZGdDEnMa0bQt9brTO2hows74z5k+Tq4IE UW771GXZC+KXSqGtwa+qazzvTm4RzWFr3/kM06xGoPPb1d625e2nkeT3j3awm0+VSE67 cIPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=RUtuCdykUUge41Fv7ukgJLVO85pB7QybUD/me9smhOM=; fh=igg3JDwkSkAbPTwY6V0OsEq0RUkG4DKWC8fVJg4GhMY=; b=F5tDKYUdWZS7+3rOVvz/AZpDxARmi+CrYQquUM13Xs7hkBV5y3urUvhAw+3OrsXd/o B2/lWcMe7UfIL4HyXDtdhczBrMvZzjg7U6Ra7S6U7YGMtg+YnB2AB9PMX30sgamnvmlv CBd4b7Jq2L85qxXZPZ1i+rE8UEbwmsl+mK9xLtzFyuqEGIF63mkHFCFaRbBNc036cMJL YlQ80rDXlz4ZIQLHCoJaYpQSagN74n8ogGbhTIQuJXVDjqOfyCCz23+6hDK3Q9e/euGv HnxTa6rM0ZxJV+D8SeLsdqzaJOAnzTGPFsUgTLzj7CMWRw0aaR0pwK359MwydPE19wPC K0ZA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mur.at header.s=dkim2 header.b=ttHMG3wY; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mur.at Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a9a91559db9si296146166b.827.2024.10.21.14.14.07; Mon, 21 Oct 2024 14:14:07 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@mur.at header.s=dkim2 header.b=ttHMG3wY; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mur.at Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BF7B268DE1C; Mon, 21 Oct 2024 23:18:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from efeu.mur.at (efeu.mur.at [89.106.208.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 69E0A68DCE4 for ; Mon, 21 Oct 2024 23:18:06 +0300 (EEST) Received: from localhost.localdomain (lan1.raspi.ma39.ffgraz.net [10.12.1.243]) by efeu.mur.at (Postfix) with ESMTPSA id E709B462E3; Mon, 21 Oct 2024 22:18:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mur.at; s=dkim2; t=1729541880; bh=J3nYZbSWszYztQzE+LrSlhtsLH29KpkP8hCHu4znQNA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ttHMG3wYo4eUJHlaynYgWeEFACtvWOLDX9qNfEoPEl49e2CkTP9RpWAPCz8xrFDJU xf63FdJ/OIUruhxeayzoXFeaVNugPOkdKKCmHuJfzqHkZXa6wJUgUPGs9Q+CX1BLEn vfHWFZ7JtpNYsuh7EOliftsf3ZyICey5fqXQer96n8eXLsx2JMYJCMWgEfBNwZvJs5 D4Ydw8oZib+6CKavTsvMAjludFa+S/1UwKPrO8hnwqYvrCgcFZToCAGXEqfFWoUfZ6 OfJQATbNmZm6nwYwGME/oQ85+boRRjFkVnlZZJQ3IpCyEwWE6G3tboclO+l23TiWj7 TykZUZ04CfYNN+e3+k+4Oi/NFISAZbEOtwsEZCE0wIgYwwK+V3ohEpaFMRM+37wJND xhMvu97y/ge9DthEOWFoeQkgpAwNvWOdr3FvAYnQ5+wYb5AEYc0fyXw3XjM7MmiVtu CIU8fz+Lml06GQkkexuUp9SnMSxBajMYeKjHvpTxaXlxFVlCJwP From: Martin Schitter To: ffmpeg-devel@ffmpeg.org Date: Mon, 21 Oct 2024 21:57:18 +0200 Message-ID: <20241021195721.892544-7-ms+git@mur.at> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241021195721.892544-2-ms+git@mur.at> References: <20241021195721.892544-2-ms+git@mur.at> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v12 5/9] libavcodec/dnxucdec: DNxUncompressed decoder 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 Cc: Martin Schitter Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: PT/6qOq0HrCV --- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/dnxucdec.c | 338 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 340 insertions(+) create mode 100644 libavcodec/dnxucdec.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index dd5d0de..e13b127 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -328,6 +328,7 @@ OBJS-$(CONFIG_DFPWM_DECODER) += dfpwmdec.o OBJS-$(CONFIG_DFPWM_ENCODER) += dfpwmenc.o OBJS-$(CONFIG_DNXHD_DECODER) += dnxhddec.o dnxhddata.o OBJS-$(CONFIG_DNXHD_ENCODER) += dnxhdenc.o dnxhddata.o +OBJS-$(CONFIG_DNXUC_DECODER) += dnxucdec.o OBJS-$(CONFIG_DOLBY_E_DECODER) += dolby_e.o dolby_e_parse.o kbdwin.o OBJS-$(CONFIG_DPX_DECODER) += dpx.o OBJS-$(CONFIG_DPX_ENCODER) += dpxenc.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index c7e5f99..ccca2ad 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -93,6 +93,7 @@ extern const FFCodec ff_dfa_decoder; extern const FFCodec ff_dirac_decoder; extern const FFCodec ff_dnxhd_encoder; extern const FFCodec ff_dnxhd_decoder; +extern const FFCodec ff_dnxuc_decoder; extern const FFCodec ff_dpx_encoder; extern const FFCodec ff_dpx_decoder; extern const FFCodec ff_dsicinvideo_decoder; diff --git a/libavcodec/dnxucdec.c b/libavcodec/dnxucdec.c new file mode 100644 index 0000000..9d5847d --- /dev/null +++ b/libavcodec/dnxucdec.c @@ -0,0 +1,338 @@ +/* + * Avid DNxUncomressed / SMPTE RDD 50 decoder + * Copyright (c) 2024 Martin Schitter + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* + This decoder for DNxUncompressed video data is mostly based on + reverse engineering of output generated by DaVinci Resolve 19 + but was later also checked against the SMPTE RDD 50 specification. + + Not all DNxUncompressed pixel format variants are supported, + but at least an elementary base set is already usable: + + - YUV 4:2:2 8/10/12/16bit/half/float (16bit untested) + YUV 4:4:4 8/16bit/half/float (all untested!) + - RGB 8/10/12/16bit/half/float (16bit untested) + Alpha/Y 8/16bit (all untested!) + + TODO: Compositions of multiple components aren't supportet until now. + TODO: This also hinders Image+Alpha use in one file. + +*/ + +#include "avcodec.h" +#include "codec_internal.h" +#include "decode.h" +#include "libavutil/imgutils.h" +#include "libavutil/intreadwrite.h" +#include "thread.h" + +static int pass_through(AVCodecContext *avctx, AVFrame *frame, const AVPacket *avpkt) +{ + /* there is no need to copy as the data already match + * a known pixel format */ + + frame->buf[0] = av_buffer_ref(avpkt->buf); + + if (!frame->buf[0]) { + return AVERROR(ENOMEM); + } + + return av_image_fill_arrays(frame->data, frame->linesize, avpkt->data, + avctx->pix_fmt, avctx->width, avctx->height, 1); +} + +/// Unpack 10bit value +static av_always_inline +uint16_t get10(uint8_t *line_data, uint32_t pos, int msb_bytes) +{ + return (line_data[pos] << 2) | + ((line_data[msb_bytes + (pos >> 2)] >> ((pos & 0x3u) << 1)) & 0x3u); +} + +/// Unpack 12bit value +static av_always_inline +uint16_t get12(uint8_t *line_data, uint32_t pos, int msb_bytes) +{ + return (line_data[pos] << 4) | + ((line_data[msb_bytes + (pos >> 1)] >> ((pos & 0x1u) << 2)) & 0xfu); +} + +static int unpack_rg10(AVCodecContext *avctx, AVFrame *frame, const AVPacket *pkt) +{ + uint8_t *data = &pkt->data[0]; + int lw = frame->width; + int msb_bytes = lw * 3; + int line_offset = lw * 3 + (lw * 3 + 3) / 4; + int pos = 0, pos_in = 0; + for(int y = 0; y < frame->height; y++){ + for(int x = 0; x < lw; x++){ + AV_WL16(&frame->data[2][pos], get10(data, pos_in++, msb_bytes)); // r + AV_WL16(&frame->data[0][pos], get10(data, pos_in++, msb_bytes)); // g + AV_WL16(&frame->data[1][pos], get10(data, pos_in++, msb_bytes)); // b + pos += 2; + } + data += line_offset; + pos_in = 0; + } + return pkt->size; +} + +static int unpack_y410(AVCodecContext *avctx, AVFrame *frame, const AVPacket *pkt) +{ + uint8_t *data = &pkt->data[0]; + int lw = frame->width; + int msb_bytes = lw * 3; + int line_offset = lw * 3 + (lw * 3 + 3) / 4; + int pos = 0, pos_in = 0; + for(int y = 0; y < frame->height; y++){ + for(int x = 0; x < lw; x++){ + AV_WL16(&frame->data[0][pos], get10(data, pos_in++, msb_bytes)); // y + AV_WL16(&frame->data[1][pos], get10(data, pos_in++, msb_bytes)); // u + AV_WL16(&frame->data[2][pos], get10(data, pos_in++, msb_bytes)); // v + pos += 2; + } + data += line_offset; + pos_in = 0; + } + return pkt->size; +} + +static int unpack_rg12(AVCodecContext *avctx, AVFrame *frame, const AVPacket *pkt) +{ + uint8_t *data = &pkt->data[0]; + int lw = frame->width; + int msb_bytes = lw * 3; + int line_offset = lw * 3 + (lw * 3 + 1) / 2; + int pos = 0, pos_in = 0; + for(int y = 0; y < frame->height; y++){ + for(int x = 0; x < lw; x++){ + AV_WL16(&frame->data[2][pos], get12(data, pos_in++, msb_bytes)); // r + AV_WL16(&frame->data[0][pos], get12(data, pos_in++, msb_bytes)); // g + AV_WL16(&frame->data[1][pos], get12(data, pos_in++, msb_bytes)); // b + pos += 2; + } + data += line_offset; + pos_in = 0; + } + return pkt->size; +} + +static int unpack_y412(AVCodecContext *avctx, AVFrame *frame, const AVPacket *pkt) +{ + uint8_t *data = &pkt->data[0]; + int lw = frame->width; + int msb_bytes = lw * 3; + int line_offset = lw * 3 + (lw * 3 + 1) / 2; + int pos = 0, pos_in = 0; + for(int y = 0; y < frame->height; y++){ + for(int x = 0; x < lw; x++){ + AV_WL16(&frame->data[0][pos], get12(data, pos_in++, msb_bytes)); // y + AV_WL16(&frame->data[1][pos], get12(data, pos_in++, msb_bytes)); // u + AV_WL16(&frame->data[2][pos], get12(data, pos_in++, msb_bytes)); // v + pos += 2; + } + data += line_offset; + pos_in = 0; + } + return pkt->size; +} + +static int unpack_y210(AVCodecContext *avctx, AVFrame *frame, const AVPacket *pkt) +{ + uint8_t *data = &pkt->data[0]; + int lw = frame->width; + int msb_bytes = lw * 2; + int line_offset = lw/2 * 5; + int pos_uv = 0, pos_y = 0, pos_in = 0; + for(int y = 0; y < frame->height; y++){ + for(int x = 0; x < lw/2; x++){ + AV_WL16(&frame->data[1][pos_uv], get10(data, pos_in++, msb_bytes)); // u + AV_WL16(&frame->data[0][pos_y], get10(data, pos_in++, msb_bytes)); // y + AV_WL16(&frame->data[2][pos_uv], get10(data, pos_in++, msb_bytes)); // v + AV_WL16(&frame->data[0][pos_y + 2], get10(data, pos_in++, msb_bytes)); // y + pos_uv += 2; + pos_y += 4; + } + data += line_offset; + pos_in = 0; + } + return pkt->size; +} + +static int unpack_y212(AVCodecContext *avctx, AVFrame *frame, const AVPacket *pkt) +{ + uint8_t *data = &pkt->data[0]; + int lw = frame->width; + int msb_bytes = lw * 2; + int line_offset = lw * 3; + int pos_uv = 0, pos_y = 0, pos_in = 0; + for(int y = 0; y < frame->height; y++){ + for(int x = 0; x < lw/2; x++){ + AV_WL16(&frame->data[1][pos_uv], get12(data, pos_in++, msb_bytes)); // u + AV_WL16(&frame->data[0][pos_y], get12(data, pos_in++, msb_bytes)); // y + AV_WL16(&frame->data[2][pos_uv], get12(data, pos_in++, msb_bytes)); // v + AV_WL16(&frame->data[0][pos_y + 2],get12(data, pos_in++, msb_bytes)); // y + pos_uv += 2; + pos_y += 4; + } + data += line_offset; + pos_in = 0; + } + return pkt->size; +} + +static int check_pkt_size(AVCodecContext *avctx, AVPacket *avpkt, int bpp) +{ + int needed = ((avctx->width * bpp + 7) / 8) * avctx->height; + if (avpkt->size < needed){ + av_log(avctx, AV_LOG_ERROR, + "Insufficient size of AVPacket data (pkg size: %d needed: %d)\n", avpkt->size, needed); + return AVERROR_INVALIDDATA; + } + return 0; +} + +static int fmt_frame(AVCodecContext *avctx, AVFrame *frame, AVPacket *avpkt, + enum AVPixelFormat pix_fmt, int src_bpp, + int (*frame_handler)(AVCodecContext *avctx, AVFrame *frame, const AVPacket *avpkt)) +{ + int ret; + avctx->pix_fmt = pix_fmt; + + ret = check_pkt_size(avctx, avpkt, src_bpp); + if (ret) + return ret; + + ret = ff_thread_get_buffer(avctx, frame, 0); + if (ret < 0) + return ret; + + return frame_handler(avctx, frame, avpkt); +} + +static int dnxuc_decode_frame(AVCodecContext *avctx, AVFrame *frame, + int *got_frame, AVPacket *avpkt) +{ + char fourcc_buf[AV_FOURCC_MAX_STRING_SIZE]; + int ret; + + av_fourcc_make_string(fourcc_buf, avctx->codec_tag); + if ((avctx->width % 2) && ((fourcc_buf[0] == 'y' && fourcc_buf[1] == '2') + ||(fourcc_buf[1] == 'y' && fourcc_buf[2] == '2'))){ + av_log(avctx, AV_LOG_ERROR, + "Image width must be a multiple of 2 for YUV 4:2:2 DNxUncompressed!\n"); + return AVERROR_INVALIDDATA; + } + + switch (avctx->codec_tag) { + case MKTAG('y','2','0','8'): + ret = fmt_frame(avctx, frame, avpkt, AV_PIX_FMT_UYVY422, 16, pass_through); + break; + case MKTAG('y','4','0','8'): + ret = fmt_frame(avctx, frame, avpkt, AV_PIX_FMT_YUV444, 24, pass_through); + break; + case MKTAG('y','2','1','0'): + ret = fmt_frame(avctx, frame, avpkt, AV_PIX_FMT_YUV422P10LE, 20, unpack_y210); + break; + case MKTAG('y','4','1','0'): + ret = fmt_frame(avctx, frame, avpkt, AV_PIX_FMT_YUV444P10LE, 20, unpack_y410); + break; + case MKTAG('y','2','1','2'): + ret = fmt_frame(avctx, frame, avpkt, AV_PIX_FMT_YUV422P12LE, 24, unpack_y212); + break; + case MKTAG('y','4','1','2'): + ret = fmt_frame(avctx, frame, avpkt, AV_PIX_FMT_YUV444P12LE, 24, unpack_y412); + break; + case MKTAG('y','2','1','6'): + ret = fmt_frame(avctx, frame, avpkt, AV_PIX_FMT_UYVY422_16LE, 32, pass_through); + break; + case MKTAG('y','4','1','6'): + ret = fmt_frame(avctx, frame, avpkt, AV_PIX_FMT_YUV444_16LE, 48, pass_through); + break; + case MKTAG(' ','y','2','h'): + ret = fmt_frame(avctx, frame, avpkt, AV_PIX_FMT_UYVY422F16LE, 32, pass_through); + break; + case MKTAG(' ','y','4','h'): + ret = fmt_frame(avctx, frame, avpkt, AV_PIX_FMT_YUV444F16LE, 48, pass_through); + break; + case MKTAG(' ','y','2','f'): + ret = fmt_frame(avctx, frame, avpkt, AV_PIX_FMT_UYVY422F32LE, 64, pass_through); + break; + case MKTAG(' ','y','4','f'): + ret = fmt_frame(avctx, frame, avpkt, AV_PIX_FMT_YUV444F32LE, 96, pass_through); + break; + + case MKTAG('r','g','0','8'): + ret = fmt_frame(avctx, frame, avpkt, AV_PIX_FMT_RGB24, 24, pass_through); + break; + case MKTAG('r','g','1','0'): + ret = fmt_frame(avctx, frame, avpkt, AV_PIX_FMT_GBRP10LE, 30, unpack_rg10); + break; + case MKTAG('r','g','1','2'): + ret = fmt_frame(avctx, frame, avpkt, AV_PIX_FMT_GBRP12LE, 36, unpack_rg12); + break; + case MKTAG('r','g','1','6'): + ret = fmt_frame(avctx, frame, avpkt, AV_PIX_FMT_RGB48LE, 48, pass_through); + break; + case MKTAG(' ','r','g','h'): + ret = fmt_frame(avctx, frame, avpkt, AV_PIX_FMT_RGBF16LE, 48, pass_through); + break; + case MKTAG(' ','r','g','f'): + ret = fmt_frame(avctx, frame, avpkt, AV_PIX_FMT_RGBF32LE, 96, pass_through); + break; + + case MKTAG(' ','a','0','8'): + case MKTAG(' ','y','0','8'): + ret = fmt_frame(avctx, frame, avpkt, AV_PIX_FMT_GRAY8, 8, pass_through); + break; + case MKTAG(' ','a','1','6'): + case MKTAG(' ','y','1','6'): + ret = fmt_frame(avctx, frame, avpkt, AV_PIX_FMT_GRAY16LE, 16, pass_through); + break; + + // case MKTAG('r','l','0','8'): TODO: RLE encoded 8bit alpha + // case MKTAG('r','l','1','6'): TODO: RLE encoded 16bit alpha + + default: + av_log(avctx, AV_LOG_ERROR, + "Unsupported DNxUncompressed pixel format variant: '%s'\n", + fourcc_buf); + return AVERROR_PATCHWELCOME; + } + + if (ret < 0) { + av_buffer_unref(&frame->buf[0]); + return ret; + } + + *got_frame = 1; + + return avpkt->size; +} + +const FFCodec ff_dnxuc_decoder = { + .p.name = "dnxuc", + CODEC_LONG_NAME("DNxUncompressed (SMPTE RDD 50)"), + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_DNXUC, + FF_CODEC_DECODE_CB(dnxuc_decode_frame), + .p.capabilities = AV_CODEC_CAP_FRAME_THREADS, +}; From patchwork Mon Oct 21 19:57:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: martin schitter X-Patchwork-Id: 52434 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:143:b0:48e:c0f8:d0de with SMTP id h3csp2921451vqi; Mon, 21 Oct 2024 13:19:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXJK5Nog2DPr/6fSM4VWlpeM8GyEsM1xlY+Ue1n1P62ziPPhAyJgGvTs6c1+gnNN7JOrLN0zGNBIdKdRoSaPUPN@gmail.com X-Google-Smtp-Source: AGHT+IGXJ1TNFKP46QE1MZi28qGVODOqZvXzSmmYADqz6TgZ7a4LsJuCJCL690nrNy0DDq0X3Uj9 X-Received: by 2002:a17:907:94c2:b0:a9a:6314:40e7 with SMTP id a640c23a62f3a-a9aa890a27fmr100102866b.17.1729541956323; Mon, 21 Oct 2024 13:19:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729541956; cv=none; d=google.com; s=arc-20240605; b=fGR2jm/BfSFXIYY4NB8FWSHFXLvf3KysOjDYb5hYzKZh8hXluwJHCGLy8cq7pcsB6x KYXiu/ozNBMll9ytd7IjysTiJ5qxDnRxATdoG18OVKyvP86pMNgVLtLjPtWLVjkpOq5R AOD262FQW3TbSTx7tuqeWHNFpNDUUXsJqgIZF+zMWiJHw4AxmFfO/Jw8GvGoJaP4ogAq BeuJPC5TLh5MKhl0tePA5D6R44GDzp/FOCFNOu9PBr7DEm+AvBP5Exi5R3H40CceOmOh 4jSTJT1PBj+NexhErgs2NqvG7wEMpFKjU2ZdKz6rGFlF43CgzGcnI12sGK/ST15Qxq5y dw5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=WKp3iPr/b9Ej94ahA1MrFm/MvSlrRMxPHLxbae36CwU=; fh=igg3JDwkSkAbPTwY6V0OsEq0RUkG4DKWC8fVJg4GhMY=; b=ZTwEpdBjNTG1MEa1VFXacsRBMMS+q7mEJxutg2sGmLJpRrrDhAdcsvTgNq4DDzLkCV fRgSJbXimNSDW/gOV6sBxYEYlQpNq811hf2J9yOLQI4lWXg1cKJ/UvwumQnJSy2vMLHl gCkgQf9th9tFizrnE9jPuvbqySXoFoeZtJlIEY9X9FnO+gxo1jxXKPpEvE82ksw4TdfT rxSRpPXYVdP/nWvPVXdqTi+943wOv5B7chgnPj6QKL1F1S9vDfNun1nUYFvlG1rQbytI oklQUqIj9fiwtUmoAY5qVe32leu/KdqRdNXUx61f6yc7WnAPY/4CrHv56kosSqp67G3N AJ/w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mur.at header.s=dkim2 header.b="bSw9Nl7/"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mur.at Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a9a913352f6si299698266b.426.2024.10.21.13.19.15; Mon, 21 Oct 2024 13:19:16 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@mur.at header.s=dkim2 header.b="bSw9Nl7/"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mur.at Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4D8A768DBE8; Mon, 21 Oct 2024 23:18:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from efeu.mur.at (efeu.mur.at [89.106.208.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 647BA68DBE8 for ; Mon, 21 Oct 2024 23:18:06 +0300 (EEST) Received: from localhost.localdomain (lan1.raspi.ma39.ffgraz.net [10.12.1.243]) by efeu.mur.at (Postfix) with ESMTPSA id 0E743462E6; Mon, 21 Oct 2024 22:18:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mur.at; s=dkim2; t=1729541881; bh=YkP6N8TMvaf82hBLWDRmVHh701fymy/CCb5+0AdOxcc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bSw9Nl7/Sn8F6tvAXwZsQmTUWL6TUch+MUAOaT+4JCO/05tsVAzo6jHmr4u7PnAT5 hOSmmi2GSnb0mThS8HW+bPCNcKjRBU1puf1g+36sde6No3GXf7E7suMBJrybSLhHV5 Z3onw4s6wNDIrG0Uhe3PDSkNsKP4UT4j3QA9Nac8mnYwgj93FOV6kJIadP8fCWaDSl pUpqBJWUKAqi/oy0WjY2P9JCb1d/ngBXbO5JDefRNlQC6S5alBQ0fKV09i1/T4s/8T Kkj50Bu4j9OvDnOnjG0u/A9RiH1SU/T06rQisWCMz8GwLf5jx796Ig5OWL7pCGaBxN dd06b/sMLVmP6kPbF+pZM5ro90HE0NuuNAmq6wuULVbMJF/BmG054oFZzjo06nuJXJ 32NnbxWwYo6WepUqs7LTxSUPiaVMj6FllskPGne7no20vcq4+mdv6TcrOtIhizl39F uSGJ17Ee22Fmx0I/T4hMRus2eGd6vOHfmx2jiviwH5FlK8JuWdF From: Martin Schitter To: ffmpeg-devel@ffmpeg.org Date: Mon, 21 Oct 2024 21:57:19 +0200 Message-ID: <20241021195721.892544-8-ms+git@mur.at> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241021195721.892544-2-ms+git@mur.at> References: <20241021195721.892544-2-ms+git@mur.at> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v12 6/9] doc: DNxUncompressed Changelog and doc entries 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 Cc: Martin Schitter Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: LMcal1DBkUtd --- Changelog | 2 ++ doc/general_contents.texi | 1 + 2 files changed, 3 insertions(+) diff --git a/Changelog b/Changelog index 7963e09..75b8e15 100644 --- a/Changelog +++ b/Changelog @@ -3,6 +3,8 @@ releases are sorted from youngest to oldest. version : - yasm support dropped, users need to use nasm +- DNxUncompressed (SMPTE RDD 50) decoder + version 7.1: - Raw Captions with Time (RCWT) closed caption demuxer diff --git a/doc/general_contents.texi b/doc/general_contents.texi index 5980ac6..76e1d34 100644 --- a/doc/general_contents.texi +++ b/doc/general_contents.texi @@ -632,6 +632,7 @@ library: @item raw DFPWM @tab X @tab X @item raw Dirac @tab X @tab X @item raw DNxHD @tab X @tab X +@item raw DNxUncompressed @tab @tab X @item raw DTS @tab X @tab X @item raw DTS-HD @tab @tab X @item raw E-AC-3 @tab X @tab X From patchwork Mon Oct 21 19:57:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: martin schitter X-Patchwork-Id: 52438 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:143:b0:48e:c0f8:d0de with SMTP id h3csp2933597vqi; Mon, 21 Oct 2024 13:44:04 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWHPV4xcujMz1pn9Hx6sZoZ3+mWtIqI2CM/wkZ4SpnowBAVfOojMCxmhjN5nPeByUlqkcONz1ichc0vQob80Hfu@gmail.com X-Google-Smtp-Source: AGHT+IFyCeETAtNgQilV+hu8JzsmCNQMHWbhIJt54jkfkOqHP4c3w+r2H00zRD9JsV/acBixpw1J X-Received: by 2002:a05:6512:1390:b0:53a:125:8fa1 with SMTP id 2adb3069b0e04-53b12bfc597mr864281e87.14.1729543443992; Mon, 21 Oct 2024 13:44:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729543443; cv=none; d=google.com; s=arc-20240605; b=fC8OAP3i3TEzO6x84SuenMSFVRvWqnSLOO/hOHF/2gsmNm02V8iy2k/GYqtZF0Shun pf91N6gce+wL9sT2A389prIROBmrPSVB6nFTQj1O1W4udA9oy8hkSsm1i2N33F3Op/+n UlH2JMvtX3a2M4lGdz7r0fbl9C6JHEZe842JuxqvF7x5KTqi3pzGEdg5IdQ6kjgGyPuO JQq1KXyqQDTVDPh4ztjnlaq6KdZW8doo0sifRQEJto9yLW7w1ojf93yPGhg/eXVrbgB3 Xf75PYlU/F82hfB2vy+nH68NL1KRr+8puYzVPTV/YB169hAMezbgBsuutKk21oYPYZFK hL8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=PjM3hxyEFeKpWBaVzgzafvbjwTHYn8fQ23+iXPDohM4=; fh=igg3JDwkSkAbPTwY6V0OsEq0RUkG4DKWC8fVJg4GhMY=; b=EC0mE2dwOh3zW8RUZG/ImusMB8tQx0LbnymToD9Xkl3I/x39JLu1B96Ulie1S/rwlZ ItqowP6Ho+tUfA7II92r91+OT/sLI+/yME8Hnpnn6mS7/ALlZ1ME2GPW2g9g2lfA4/8U TEEEhjo+UdWnPxpJPocFqsa7tJPXF02WWUqkVrPmvnHIF5vmPVvZFjekp9gQXz0/WSHU Uw9JIRSRNY1dJ+iYfSNI7ZAVnW8z5S4lm/sDoNsqusb5KMgLsACWtLblKgmOuwKbYgbC Lr/vn/72luIvDj8DmOGN5o8PdvFJ7f1AWzGrztsYAl8rbAeLVki38gOplNusTNhrx075 SWSA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mur.at header.s=dkim2 header.b=KFULxUHn; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mur.at Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 2adb3069b0e04-53a223f0247si1423441e87.157.2024.10.21.13.44.03; Mon, 21 Oct 2024 13:44:03 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@mur.at header.s=dkim2 header.b=KFULxUHn; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mur.at Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9051968DE36; Mon, 21 Oct 2024 23:18:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from efeu.mur.at (efeu.mur.at [89.106.208.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6C87068DCEC for ; Mon, 21 Oct 2024 23:18:06 +0300 (EEST) Received: from localhost.localdomain (lan1.raspi.ma39.ffgraz.net [10.12.1.243]) by efeu.mur.at (Postfix) with ESMTPSA id 271B8462E7; Mon, 21 Oct 2024 22:18:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mur.at; s=dkim2; t=1729541881; bh=drfE90Sf3HLdfU+53DYQ5bodZc0TkL2OOBMmM85ExTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KFULxUHnrgzeYSORdt7qjjnNHQTvIQPdqpp7ALJPmmhSRFDouDK2WIqcW68bzMCk6 CTkFmjhnf4OisT6/zvXgewlbM15PcEvunlLmH9dEUdB/Y+/c2o5ouJ4dmToWUiHaFY o2uwFDP+8lF5tohKMNsFaebm+FebzdpvC72jmiaW6ILhaSSqbrEuLEITmKH+f+SLFq lQlcXeSEjFAMDdpzvPO9RW8tb/wZqoYfmNMPpVeRNfyMNtz+3QiYfbJXLHsbuOtWJ0 k3q5pBSsEB5eNZv813Fy9WgUkHRuJ7gAhtifgx9M3b5MnnhDmjuemmp4Wvf1O4SMlc SnqFt6osUGtSGpcIt5z88uvbu/FqCM3TRYSP3YhlGfmLKhWEBnDfRH7qob9UOuhjek fM74t5leA26nUnFZw1coGNFB9Xp+L1SAYCiprqZYesd2d+ICz7LKW3ubhyLJlT540T 4yCCtCxsWERsqmQToWmnDniOHPdODkWThgMnWcdtciBDxT3nQIt From: Martin Schitter To: ffmpeg-devel@ffmpeg.org Date: Mon, 21 Oct 2024 21:57:20 +0200 Message-ID: <20241021195721.892544-9-ms+git@mur.at> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241021195721.892544-2-ms+git@mur.at> References: <20241021195721.892544-2-ms+git@mur.at> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v12 7/9] tests: Fate sample tests for DNxUncompressed 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 Cc: Martin Schitter Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Njaq/vzICGss --- tests/Makefile | 1 + tests/fate/dnxuc.mak | 40 +++++++++++++++++++++++++++++ tests/ref/fate/dnxuc-cb-rgb-10 | 8 ++++++ tests/ref/fate/dnxuc-cb-rgb-12 | 8 ++++++ tests/ref/fate/dnxuc-cb-rgb-8 | 8 ++++++ tests/ref/fate/dnxuc-cb-rgb-float | 8 ++++++ tests/ref/fate/dnxuc-cb-rgb-half | 8 ++++++ tests/ref/fate/dnxuc-cb-yuv422-10 | 8 ++++++ tests/ref/fate/dnxuc-cb-yuv422-12 | 8 ++++++ tests/ref/fate/dnxuc-cb-yuv422-8 | 8 ++++++ tests/ref/fate/dnxuc-ramp-rgb-10 | 8 ++++++ tests/ref/fate/dnxuc-ramp-rgb-12 | 8 ++++++ tests/ref/fate/dnxuc-ramp-rgb-8 | 8 ++++++ tests/ref/fate/dnxuc-ramp-rgb-float | 8 ++++++ tests/ref/fate/dnxuc-ramp-rgb-half | 8 ++++++ tests/ref/fate/dnxuc-ramp-yuv422-10 | 8 ++++++ tests/ref/fate/dnxuc-ramp-yuv422-12 | 8 ++++++ tests/ref/fate/dnxuc-ramp-yuv422-8 | 8 ++++++ 18 files changed, 169 insertions(+) create mode 100644 tests/fate/dnxuc.mak create mode 100644 tests/ref/fate/dnxuc-cb-rgb-10 create mode 100644 tests/ref/fate/dnxuc-cb-rgb-12 create mode 100644 tests/ref/fate/dnxuc-cb-rgb-8 create mode 100644 tests/ref/fate/dnxuc-cb-rgb-float create mode 100644 tests/ref/fate/dnxuc-cb-rgb-half create mode 100644 tests/ref/fate/dnxuc-cb-yuv422-10 create mode 100644 tests/ref/fate/dnxuc-cb-yuv422-12 create mode 100644 tests/ref/fate/dnxuc-cb-yuv422-8 create mode 100644 tests/ref/fate/dnxuc-ramp-rgb-10 create mode 100644 tests/ref/fate/dnxuc-ramp-rgb-12 create mode 100644 tests/ref/fate/dnxuc-ramp-rgb-8 create mode 100644 tests/ref/fate/dnxuc-ramp-rgb-float create mode 100644 tests/ref/fate/dnxuc-ramp-rgb-half create mode 100644 tests/ref/fate/dnxuc-ramp-yuv422-10 create mode 100644 tests/ref/fate/dnxuc-ramp-yuv422-12 create mode 100644 tests/ref/fate/dnxuc-ramp-yuv422-8 diff --git a/tests/Makefile b/tests/Makefile index 9b70145..e073915 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -172,6 +172,7 @@ include $(SRC_PATH)/tests/fate/dca.mak include $(SRC_PATH)/tests/fate/demux.mak include $(SRC_PATH)/tests/fate/dfa.mak include $(SRC_PATH)/tests/fate/dnxhd.mak +include $(SRC_PATH)/tests/fate/dnxuc.mak include $(SRC_PATH)/tests/fate/dpcm.mak include $(SRC_PATH)/tests/fate/dvvideo.mak include $(SRC_PATH)/tests/fate/ea.mak diff --git a/tests/fate/dnxuc.mak b/tests/fate/dnxuc.mak new file mode 100644 index 0000000..80ff0e9 --- /dev/null +++ b/tests/fate/dnxuc.mak @@ -0,0 +1,40 @@ +FATE_DNXUC_CB = fate-dnxuc-cb-rgb-8 \ + fate-dnxuc-cb-rgb-10 \ + fate-dnxuc-cb-rgb-12 \ + fate-dnxuc-cb-rgb-half \ + fate-dnxuc-cb-rgb-float \ + fate-dnxuc-cb-yuv422-8 \ + fate-dnxuc-cb-yuv422-10 \ + fate-dnxuc-cb-yuv422-12 + +FATE_DNXUC_RAMP = fate-dnxuc-ramp-rgb-8 \ + fate-dnxuc-ramp-rgb-10 \ + fate-dnxuc-ramp-rgb-12 \ + fate-dnxuc-ramp-rgb-half \ + fate-dnxuc-ramp-rgb-float \ + fate-dnxuc-ramp-yuv422-8 \ + fate-dnxuc-ramp-yuv422-10 \ + fate-dnxuc-ramp-yuv422-12 + +FATE_DNXUC-$(call FRAMECRC, MXF, DNXUC) += $(FATE_DNXUC_CB) $(FATE_DNXUC_RAMP) + +FATE_SAMPLES_FFMPEG += $(FATE_DNXUC-yes) +fate-dnxuc: $(FATE_DNXUC-yes) + +fate-dnxuc-cb-rgb-8: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/cb_rgb_8.mxf +fate-dnxuc-cb-rgb-10: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/cb_rgb_10.mxf +fate-dnxuc-cb-rgb-12: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/cb_rgb_12.mxf +fate-dnxuc-cb-rgb-half: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/cb_rgb_half.mxf +fate-dnxuc-cb-rgb-float: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/cb_rgb_float.mxf +fate-dnxuc-cb-yuv422-8: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/cb_yuv422_8.mxf +fate-dnxuc-cb-yuv422-10: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/cb_yuv422_10.mxf +fate-dnxuc-cb-yuv422-12: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/cb_yuv422_12.mxf + +fate-dnxuc-ramp-rgb-8: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/ramp_rgb_8.mxf +fate-dnxuc-ramp-rgb-10: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/ramp_rgb_10.mxf +fate-dnxuc-ramp-rgb-12: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/ramp_rgb_12.mxf +fate-dnxuc-ramp-rgb-half: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/ramp_rgb_half.mxf +fate-dnxuc-ramp-rgb-float: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/ramp_rgb_float.mxf +fate-dnxuc-ramp-yuv422-8: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/ramp_yuv422_8.mxf +fate-dnxuc-ramp-yuv422-10: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/ramp_yuv422_10.mxf +fate-dnxuc-ramp-yuv422-12: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/ramp_yuv422_12.mxf diff --git a/tests/ref/fate/dnxuc-cb-rgb-10 b/tests/ref/fate/dnxuc-cb-rgb-10 new file mode 100644 index 0000000..398e0da --- /dev/null +++ b/tests/ref/fate/dnxuc-cb-rgb-10 @@ -0,0 +1,8 @@ +#tb 0: 1/24 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 512x256 +#sar 0: 1/1 +0, 0, 0, 1, 786432, 0x2e402ec2 +0, 1, 1, 1, 786432, 0x2e402ec2 +0, 2, 2, 1, 786432, 0x2e402ec2 diff --git a/tests/ref/fate/dnxuc-cb-rgb-12 b/tests/ref/fate/dnxuc-cb-rgb-12 new file mode 100644 index 0000000..4e3235f --- /dev/null +++ b/tests/ref/fate/dnxuc-cb-rgb-12 @@ -0,0 +1,8 @@ +#tb 0: 1/24 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 512x256 +#sar 0: 1/1 +0, 0, 0, 1, 786432, 0x6fb11356 +0, 1, 1, 1, 786432, 0x6fb11356 +0, 2, 2, 1, 786432, 0x6fb11356 diff --git a/tests/ref/fate/dnxuc-cb-rgb-8 b/tests/ref/fate/dnxuc-cb-rgb-8 new file mode 100644 index 0000000..189babc --- /dev/null +++ b/tests/ref/fate/dnxuc-cb-rgb-8 @@ -0,0 +1,8 @@ +#tb 0: 1/24 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 512x256 +#sar 0: 1/1 +0, 0, 0, 1, 393216, 0xc1f6a4cc +0, 1, 1, 1, 393216, 0xc1f6a4cc +0, 2, 2, 1, 393216, 0xc1f6a4cc diff --git a/tests/ref/fate/dnxuc-cb-rgb-float b/tests/ref/fate/dnxuc-cb-rgb-float new file mode 100644 index 0000000..f6571ba --- /dev/null +++ b/tests/ref/fate/dnxuc-cb-rgb-float @@ -0,0 +1,8 @@ +#tb 0: 1/24 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 512x256 +#sar 0: 1/1 +0, 0, 0, 1, 1572864, 0x535c1923 +0, 1, 1, 1, 1572864, 0x535c1923 +0, 2, 2, 1, 1572864, 0x535c1923 diff --git a/tests/ref/fate/dnxuc-cb-rgb-half b/tests/ref/fate/dnxuc-cb-rgb-half new file mode 100644 index 0000000..838b84b --- /dev/null +++ b/tests/ref/fate/dnxuc-cb-rgb-half @@ -0,0 +1,8 @@ +#tb 0: 1/24 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 512x256 +#sar 0: 1/1 +0, 0, 0, 1, 786432, 0xec588a41 +0, 1, 1, 1, 786432, 0xec588a41 +0, 2, 2, 1, 786432, 0xec588a41 diff --git a/tests/ref/fate/dnxuc-cb-yuv422-10 b/tests/ref/fate/dnxuc-cb-yuv422-10 new file mode 100644 index 0000000..6e7c537 --- /dev/null +++ b/tests/ref/fate/dnxuc-cb-yuv422-10 @@ -0,0 +1,8 @@ +#tb 0: 1/24 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 512x256 +#sar 0: 1/1 +0, 0, 0, 1, 524288, 0xad829843 +0, 1, 1, 1, 524288, 0xad829843 +0, 2, 2, 1, 524288, 0xad829843 diff --git a/tests/ref/fate/dnxuc-cb-yuv422-12 b/tests/ref/fate/dnxuc-cb-yuv422-12 new file mode 100644 index 0000000..01e5976 --- /dev/null +++ b/tests/ref/fate/dnxuc-cb-yuv422-12 @@ -0,0 +1,8 @@ +#tb 0: 1/24 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 512x256 +#sar 0: 1/1 +0, 0, 0, 1, 524288, 0x70277284 +0, 1, 1, 1, 524288, 0x70277284 +0, 2, 2, 1, 524288, 0x70277284 diff --git a/tests/ref/fate/dnxuc-cb-yuv422-8 b/tests/ref/fate/dnxuc-cb-yuv422-8 new file mode 100644 index 0000000..1e4bb3e --- /dev/null +++ b/tests/ref/fate/dnxuc-cb-yuv422-8 @@ -0,0 +1,8 @@ +#tb 0: 1/24 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 512x256 +#sar 0: 1/1 +0, 0, 0, 1, 262144, 0x12299f3f +0, 1, 1, 1, 262144, 0x12299f3f +0, 2, 2, 1, 262144, 0x12299f3f diff --git a/tests/ref/fate/dnxuc-ramp-rgb-10 b/tests/ref/fate/dnxuc-ramp-rgb-10 new file mode 100644 index 0000000..99a2eb9 --- /dev/null +++ b/tests/ref/fate/dnxuc-ramp-rgb-10 @@ -0,0 +1,8 @@ +#tb 0: 1/24 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 512x256 +#sar 0: 1/1 +0, 0, 0, 1, 786432, 0xe4d06700 +0, 1, 1, 1, 786432, 0xe4d06700 +0, 2, 2, 1, 786432, 0xe4d06700 diff --git a/tests/ref/fate/dnxuc-ramp-rgb-12 b/tests/ref/fate/dnxuc-ramp-rgb-12 new file mode 100644 index 0000000..19eb687 --- /dev/null +++ b/tests/ref/fate/dnxuc-ramp-rgb-12 @@ -0,0 +1,8 @@ +#tb 0: 1/24 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 512x256 +#sar 0: 1/1 +0, 0, 0, 1, 786432, 0xb8c802a4 +0, 1, 1, 1, 786432, 0xb8c802a4 +0, 2, 2, 1, 786432, 0xb8c802a4 diff --git a/tests/ref/fate/dnxuc-ramp-rgb-8 b/tests/ref/fate/dnxuc-ramp-rgb-8 new file mode 100644 index 0000000..2c1caae --- /dev/null +++ b/tests/ref/fate/dnxuc-ramp-rgb-8 @@ -0,0 +1,8 @@ +#tb 0: 1/24 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 512x256 +#sar 0: 1/1 +0, 0, 0, 1, 393216, 0xd1f001f2 +0, 1, 1, 1, 393216, 0xd1f001f2 +0, 2, 2, 1, 393216, 0xd1f001f2 diff --git a/tests/ref/fate/dnxuc-ramp-rgb-float b/tests/ref/fate/dnxuc-ramp-rgb-float new file mode 100644 index 0000000..1a929fa --- /dev/null +++ b/tests/ref/fate/dnxuc-ramp-rgb-float @@ -0,0 +1,8 @@ +#tb 0: 1/24 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 512x256 +#sar 0: 1/1 +0, 0, 0, 1, 1572864, 0xfebf5914 +0, 1, 1, 1, 1572864, 0xfebf5914 +0, 2, 2, 1, 1572864, 0xfebf5914 diff --git a/tests/ref/fate/dnxuc-ramp-rgb-half b/tests/ref/fate/dnxuc-ramp-rgb-half new file mode 100644 index 0000000..93d39c7 --- /dev/null +++ b/tests/ref/fate/dnxuc-ramp-rgb-half @@ -0,0 +1,8 @@ +#tb 0: 1/24 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 512x256 +#sar 0: 1/1 +0, 0, 0, 1, 786432, 0x6b0900ff +0, 1, 1, 1, 786432, 0x6b0900ff +0, 2, 2, 1, 786432, 0x6b0900ff diff --git a/tests/ref/fate/dnxuc-ramp-yuv422-10 b/tests/ref/fate/dnxuc-ramp-yuv422-10 new file mode 100644 index 0000000..ef158a5 --- /dev/null +++ b/tests/ref/fate/dnxuc-ramp-yuv422-10 @@ -0,0 +1,8 @@ +#tb 0: 1/24 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 512x256 +#sar 0: 1/1 +0, 0, 0, 1, 524288, 0xb86e482d +0, 1, 1, 1, 524288, 0xb86e482d +0, 2, 2, 1, 524288, 0xb86e482d diff --git a/tests/ref/fate/dnxuc-ramp-yuv422-12 b/tests/ref/fate/dnxuc-ramp-yuv422-12 new file mode 100644 index 0000000..4596dc8 --- /dev/null +++ b/tests/ref/fate/dnxuc-ramp-yuv422-12 @@ -0,0 +1,8 @@ +#tb 0: 1/24 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 512x256 +#sar 0: 1/1 +0, 0, 0, 1, 524288, 0x9bbd5677 +0, 1, 1, 1, 524288, 0x9bbd5677 +0, 2, 2, 1, 524288, 0x9bbd5677 diff --git a/tests/ref/fate/dnxuc-ramp-yuv422-8 b/tests/ref/fate/dnxuc-ramp-yuv422-8 new file mode 100644 index 0000000..bb6fd38 --- /dev/null +++ b/tests/ref/fate/dnxuc-ramp-yuv422-8 @@ -0,0 +1,8 @@ +#tb 0: 1/24 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 512x256 +#sar 0: 1/1 +0, 0, 0, 1, 262144, 0x386e0fa6 +0, 1, 1, 1, 262144, 0x386e0fa6 +0, 2, 2, 1, 262144, 0x386e0fa6 From patchwork Mon Oct 21 19:57:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: martin schitter X-Patchwork-Id: 52435 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:143:b0:48e:c0f8:d0de with SMTP id h3csp2926134vqi; Mon, 21 Oct 2024 13:29:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUGuF9pWQBu24EjMG69k6wHb+RO5C2ZNxdiLnONSeDUButiMNB8867E8t5jHG/EL4Hp4gsHulQvpUwTTg9V5kR0@gmail.com X-Google-Smtp-Source: AGHT+IGDb+VcC0iXpr0HYE8zVREpvmfrDGV0Qbs+estjg9mx6o9Ck7zBDKh9my1wJ810Ob21BS7k X-Received: by 2002:a05:651c:2127:b0:2fa:ce3f:b57d with SMTP id 38308e7fff4ca-2fb831e65c5mr18287491fa.9.1729542543559; Mon, 21 Oct 2024 13:29:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729542543; cv=none; d=google.com; s=arc-20240605; b=FD0UV+My77aobXnrhUPaDGbU9bGV1tyvIu2lI/TL/kOd9Bhv197WpBpnToWEAXMRdV Kc/ysmXw8poA2hkcQ4pjAznGpYomdF0ZikEUfUO3M/UNVtCB0i58JQn3XrTFicCneOPE qM5gGB3D1EmbhCAUmo6hXh3VGM5RAIebamkiI3UbCV48RtwkqMeVR+MQIkTvZp1HMXqr VUOAnpQ8gd2MKq5ek8mE7hFrdtzye+k6uPoTKwpYblZAy548FEAjz/2CQvT0KG3AQjBJ yipquNgVQuKcvRt/9xqpY7i9FHQOo3zbxYhY10p9Mu5pJB+VsiE1MsJV3TGQCd4N0Y0z YiAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=gCUYO+qOejVfwdTbUBIvszIXqzAjRXU4Qlolk1SyGj0=; fh=igg3JDwkSkAbPTwY6V0OsEq0RUkG4DKWC8fVJg4GhMY=; b=UIXj2M2450vuCUA9aY1Fu6e94L1my2t2yxl3dkrwzUoALj5nBU8WEe05x1ofzvvEyI zq/a3oHzhxvchGeL/1Shq+7BzreihITc9qfIks6bsrpzhVI/THW4X12pjfSL6W8ELC6y dyA/sgQ/DN2quqnLVP4ZNbd7toIVWeJbawRhb04NLWAF9EzBQHs3R9Et51yp155IfA5y RT7+V1EAIozP1TDzEYObt0SX08FfoBwsFgGkV26wE0RUleDhKpzRGvA5hbEg3OfKazTX j3wnU8g84oGGiEzDl5azUU6Cw5sZodAi3Pj/ZvCILfLlNBciwkZfHmexqfP+Qr8u9qDb pEGA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mur.at header.s=dkim2 header.b=lhCl+3pK; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mur.at Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 38308e7fff4ca-2fb9ae7d680si11272491fa.411.2024.10.21.13.29.03; Mon, 21 Oct 2024 13:29:03 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@mur.at header.s=dkim2 header.b=lhCl+3pK; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mur.at Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 24E2C68DE2B; Mon, 21 Oct 2024 23:18:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from efeu.mur.at (efeu.mur.at [89.106.208.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6820B68DCE1 for ; Mon, 21 Oct 2024 23:18:06 +0300 (EEST) Received: from localhost.localdomain (lan1.raspi.ma39.ffgraz.net [10.12.1.243]) by efeu.mur.at (Postfix) with ESMTPSA id 4E04B462EE; Mon, 21 Oct 2024 22:18:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mur.at; s=dkim2; t=1729541881; bh=a4pC868kjgaZIQIMeQlXhSuSddTKNWIOrLk4fmsYJQ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lhCl+3pK0OU1LoAA42bgzKsHj5XY5Ns1ESnYGZGY/5cKoM9QnxY937faGwrVk4xcC CGHqivJUOtDL/I4D5ctBfLDa+DVoO7iKqxP105NdXDXBc/X+bIZtr+NfLsvBGlv63v POUPmLxOoGPm4AyhE9iS6tydNikJNJEFBu+BGVC8PAUdpwrirDFzYLLs4a85WGyTjP TVlhea7UnhZuPDqE64nGIdYTdI7he4VQDAzUXwbWWu5xVbOe14OuC7Kwf18f3Mqniy uLRfJCkcSF2veVnPy4W9F/wk7YYgtATbo4GUV6a/6ViDLMcepMyVDLuj4gcZO6bNUc 6jhSG5hhtNKT5ia61mHebHLu2gfikRFaGkw0nUWvzCsMncI/NpKzWOrZu5lDEC8It/ oicGSRifs9PERfcVOfSRUU3azEofoGI71ZVVMzdzjYou+W/QwkGw+P24CDSPza5966 z1H3FDSqD0XbYp3m42bfyqcGleEGjex5SzgG3OfeuLiAqFaMata From: Martin Schitter To: ffmpeg-devel@ffmpeg.org Date: Mon, 21 Oct 2024 21:57:21 +0200 Message-ID: <20241021195721.892544-10-ms+git@mur.at> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241021195721.892544-2-ms+git@mur.at> References: <20241021195721.892544-2-ms+git@mur.at> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v12 8/9] avformat/mxfdec: Workaround for RGB pc/video level detection. 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 Cc: Martin Schitter Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: sONwSOEmvpF6 In case of RGB content wrapped in MXF containers we can not use CDCIDescriptor fields for the video level detection. The corresponding information in RGBA Descriptors uses a significant differnt structure. As a workaround we pick the first found channel depth info value of the RGBALayout array and us it instead of the more general CDCI component_depth. --- libavformat/mxfdec.c | 51 +++++++++++++++++++++++++++++------- tests/ref/fate/mxf-probe-j2k | 2 +- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 27e8e0c..eb51585 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -212,6 +212,9 @@ typedef struct MXFDescriptor { unsigned int component_depth; unsigned int black_ref_level; unsigned int white_ref_level; + uint32_t component_max_ref; + uint32_t component_min_ref; + uint8_t red_component_depth; unsigned int color_range; unsigned int horiz_subsampling; unsigned int vert_subsampling; @@ -1316,6 +1319,9 @@ static void mxf_read_pixel_layout(AVIOContext *pb, MXFDescriptor *descriptor) value = avio_r8(pb); av_log(NULL, AV_LOG_TRACE, "pixel layout: code %#x\n", code); + if (code == 'R') + descriptor->red_component_depth = value; + if (ofs <= 14) { layout[ofs++] = code; layout[ofs++] = value; @@ -1424,6 +1430,12 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int case 0x3401: mxf_read_pixel_layout(pb, descriptor); break; + case 0x3406: + descriptor->component_max_ref = avio_rb32(pb); + break; + case 0x3407: + descriptor->component_min_ref = avio_rb32(pb); + break; default: /* Private uid used by SONY C0023S01.mxf */ if (IS_KLV_KEY(uid, mxf_sony_mpeg4_extradata)) { @@ -2511,19 +2523,38 @@ static int mxf_add_metadata_stream(MXFContext *mxf, MXFTrack *track) static enum AVColorRange mxf_get_color_range(MXFContext *mxf, MXFDescriptor *descriptor) { - if (descriptor->black_ref_level || descriptor->white_ref_level || descriptor->color_range) { + unsigned int depth, black_ref_level, white_ref_level; + + // The red channel component depth value of the + // RGBALayout array is used as component_depth indicator + // for the pc/tv level detection in case of RGB content + // and their RGBA Descriptors instead of CDCI entries. + + if (descriptor->red_component_depth) { // RGBA Descriptor + depth = descriptor->red_component_depth; + black_ref_level = descriptor->component_min_ref; + white_ref_level = descriptor->component_max_ref; + } else { // CDCI Descriptor + depth = descriptor->component_depth; + black_ref_level = descriptor->black_ref_level; + white_ref_level = descriptor->white_ref_level; + } + + if (black_ref_level || white_ref_level) { /* CDCI range metadata */ - if (!descriptor->component_depth) + if (!depth) return AVCOL_RANGE_UNSPECIFIED; - if (descriptor->black_ref_level == 0 && descriptor->component_depth < 31 && - descriptor->white_ref_level == ((1<component_depth) - 1) && - (descriptor->color_range == (1<component_depth) || - descriptor->color_range == ((1<component_depth) - 1))) + if (black_ref_level == 0 && depth < 31 && + white_ref_level == ((1 << depth) - 1) && + (descriptor->red_component_depth || + descriptor->color_range == (1 << descriptor->component_depth) || + descriptor->color_range == ((1 << descriptor->component_depth) - 1))) return AVCOL_RANGE_JPEG; - if (descriptor->component_depth >= 8 && descriptor->component_depth < 31 && - descriptor->black_ref_level == (1 <<(descriptor->component_depth - 4)) && - descriptor->white_ref_level == (235<<(descriptor->component_depth - 8)) && - descriptor->color_range == ((14<<(descriptor->component_depth - 4)) + 1)) + if (depth >= 8 && depth < 31 && + black_ref_level == (1 << (depth - 4)) && + white_ref_level == (235 << (depth - 8)) && + ( descriptor->red_component_depth || + descriptor->color_range == ((14 << (descriptor->component_depth - 4))) + 1)) return AVCOL_RANGE_MPEG; avpriv_request_sample(mxf->fc, "Unrecognized CDCI color range (color diff range %d, b %d, w %d, depth %d)", descriptor->color_range, descriptor->black_ref_level, diff --git a/tests/ref/fate/mxf-probe-j2k b/tests/ref/fate/mxf-probe-j2k index f1dadf4..6287980 100644 --- a/tests/ref/fate/mxf-probe-j2k +++ b/tests/ref/fate/mxf-probe-j2k @@ -16,7 +16,7 @@ sample_aspect_ratio=1:1 display_aspect_ratio=16:9 pix_fmt=rgb48 level=-99 -color_range=unknown +color_range=pc color_space=unknown color_transfer=bt709 color_primaries=bt709 From patchwork Mon Oct 21 19:57:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: martin schitter X-Patchwork-Id: 52433 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:143:b0:48e:c0f8:d0de with SMTP id h3csp2921339vqi; Mon, 21 Oct 2024 13:19:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUn3i2J3Ort1lfeYSiifwq7RVsoP4tFZAIp/0zQi64PDHnApRrDrXf6zqceRYEfpUJeTLYAGN5X1t+Cb6nthQJE@gmail.com X-Google-Smtp-Source: AGHT+IEOSqPcxiOPLf/o4N7Y5htdAGKKcGSi5pGH5YqpUpdHMP5aA5y27Mj+yyjuqqwaWGY9X+zv X-Received: by 2002:a2e:a9a2:0:b0:2fb:6465:3183 with SMTP id 38308e7fff4ca-2fc9044130emr8682001fa.3.1729541947050; Mon, 21 Oct 2024 13:19:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729541947; cv=none; d=google.com; s=arc-20240605; b=Qbzy/dEf2/RuWrE8H4nLtKwJans2hRJ+KNqxBfitEhm0nv8Ckdh3o4JiKptxcKNtfQ 79HoVDsrVN10ZYIPVP9G5DcZ545HA0P0Y7RRc7C2OmuQf8JpEvLCr1KXBYdbk/9jDUce t8VVXQ9xyMB4a2BcFSCgsPULr0vAcVKHoS7786NVq4HumPVDS8KgY23gp5De5ow1HTlp OoIDgJVDdb505iGzsXBI6tA7+1rn5P/Ykve7dtgpO0d6vDniLMjlq8CMwnVsSF9+J/7U hRLyBRqfDP8xC4OO6r0zbKp0kVYfA+Xqu4ZmqrzNmAt7urChQdbMfuVJ/VVPhefu60q8 1nyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=OqeFLEpHnIW6YoDF264nrHjC2sr5T+a6Aqm01/TvNA0=; fh=igg3JDwkSkAbPTwY6V0OsEq0RUkG4DKWC8fVJg4GhMY=; b=HKu7qiDQgozijr8z/lH27f8sjFbUPEIrHB2c4VMyerOCcnqEmfzFRcinwWEHjXLc2J ux4f3JSVOxYc6K6P0+eTgkQixrZ8jSbaRpb2G8+BiElawdsuhyNBwEWK8RYX0RwG2+uA M59Gokrl5HGl+RaA2Ww6mvO6NDo31UYnn9OOyouTWgZ6RlBEtCtyyjVLkLrif3Keg373 5FYzasEKf3PKyC3M6pftN6g86OKfCrKVGw3nRI02/9lR5pJXXFxvQzLA4eEnFldLpEWu I5b2iUV0u+TYcEbK/XXh0oh0fPmhaT2kPo8B5h8lniCuY8fssGtuk25XQO7wWyYW3AbC 8yZQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mur.at header.s=dkim2 header.b=QPgsXrnc; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mur.at Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 38308e7fff4ca-2fb9ae8c2easi12948741fa.445.2024.10.21.13.19.06; Mon, 21 Oct 2024 13:19:07 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@mur.at header.s=dkim2 header.b=QPgsXrnc; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mur.at Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F05BC68DE0D; Mon, 21 Oct 2024 23:18:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from efeu.mur.at (efeu.mur.at [89.106.208.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 63A2168DA3F for ; Mon, 21 Oct 2024 23:18:06 +0300 (EEST) Received: from localhost.localdomain (lan1.raspi.ma39.ffgraz.net [10.12.1.243]) by efeu.mur.at (Postfix) with ESMTPSA id 68962462EF; Mon, 21 Oct 2024 22:18:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mur.at; s=dkim2; t=1729541881; bh=CrpELF7lM8AQ9eWWTwvtiupDgd+zJL1cSXglkTdAl4c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QPgsXrnc9CiPozsN5Y0EzjuyYyCgWQMjNyGy2BCND5MbXL250giZJwKgLPrZm+hS6 PGx93FA36/KiBQWVZhgfxMeb+DJ1vg/IYeZrXBnQYrr7Z45Ip4vN1rj70gUODgtplP n7X0rgv5rbSImXoxejGMMqUf8KZSjh3t98QSNhhnQ/V7v8R6J/FFSP3Xyvbom4Hzmn knljXwOlSkQ7T6JXqwdK4kppBvWb8VMLaHWMw/yyl4rcKQR/91XMzdtFjDWuSVD5os hB+Kj9BbfcffFokhxgLsxXjYvdxhmQvE0+Kya8O5i5ILpP9gp8w4jJmErHUSSmu0nI xhZCgROnU5wdTFHmIVKhYwYJJcuu8acP+q5/PtoeA3jIbJl2EC93ZT270Tey9x2Oqw TT2eje6sMe+CwAYmHL7mckl00FsLlhtsLHQ+rqVEFRkPWNm9tiDsD4UimI6UF5Mbze zjUoEaei22iYGcRXPR6KQbCdnbYZROqJGtkZUJHG25gf7tRbbL1 From: Martin Schitter To: ffmpeg-devel@ffmpeg.org Date: Mon, 21 Oct 2024 21:57:22 +0200 Message-ID: <20241021195721.892544-11-ms+git@mur.at> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241021195721.892544-2-ms+git@mur.at> References: <20241021195721.892544-2-ms+git@mur.at> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v12 9/9] swscale/input: color subsampling input support for RGBF32 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 Cc: Martin Schitter Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: TcfjzORXCIPc --- libswscale/input.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/libswscale/input.c b/libswscale/input.c index f9d7c39..ba7e3c4 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -1447,6 +1447,30 @@ static av_always_inline void planar_rgbf32_to_y(uint8_t *_dst, const uint8_t *_s } } +static av_always_inline void rgbf32_to_uv_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused1, + const uint8_t *_src, const uint8_t *unused2, + int width, int is_be, int32_t *rgb2yuv) +{ + int i; + const float *src = (const float *)_src; + uint16_t *dstU = (uint16_t *)_dstU; + uint16_t *dstV = (uint16_t *)_dstV; + int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX]; + int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX]; + + for (i = 0; i < width; i++) { + int r = (lrintf(av_clipf(65535.0f * rdpx(&src[6*i]), 0.0f, 65535.0f)) + + lrintf(av_clipf(65535.0f * rdpx(&src[6*i+3]), 0.0f, 65535.0f))) >> 1; + int g = (lrintf(av_clipf(65535.0f * rdpx(&src[6*i+1]), 0.0f, 65535.0f)) + + lrintf(av_clipf(65535.0f * rdpx(&src[6*i+4]), 0.0f, 65535.0f))) >> 1; + int b = (lrintf(av_clipf(65535.0f * rdpx(&src[6*i+2]), 0.0f, 65535.0f)) + + lrintf(av_clipf(65535.0f * rdpx(&src[6*i+5]), 0.0f, 65535.0f))) >> 1; + + dstU[i] = (ru*r + gu*g + bu*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT; + dstV[i] = (rv*r + gv*g + bv*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT; + } +} + static av_always_inline void rgbf32_to_uv_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused1, const uint8_t *_src, const uint8_t *unused2, int width, int is_be, int32_t *rgb2yuv) @@ -1574,6 +1598,13 @@ static void rgbf32##endian_name##_to_uv_c(uint8_t *dstU, uint8_t *dstV, { \ rgbf32_to_uv_c(dstU, dstV, unused1, src, unused2, w, endian, rgb2yuv); \ } \ +static void rgbf32##endian_name##_to_uv_half_c(uint8_t *dstU, uint8_t *dstV, \ + const uint8_t *unused1, \ + const uint8_t *src, const uint8_t *unused2, \ + int w, uint32_t *rgb2yuv, void *opq) \ +{ \ + rgbf32_to_uv_half_c(dstU, dstV, unused1, src, unused2, w, endian, rgb2yuv); \ +} \ static void grayf32##endian_name##ToY16_c(uint8_t *dst, const uint8_t *src, \ const uint8_t *unused1, const uint8_t *unused2, \ int width, uint32_t *unused, void *opq) \ @@ -2138,6 +2169,12 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c, case AV_PIX_FMT_RGBF16LE: *chrToYV12 = rgbf16leToUV_half_c; break; + case AV_PIX_FMT_RGBF32BE: + *chrToYV12 = rgbf32be_to_uv_half_c; + break; + case AV_PIX_FMT_RGBF32LE: + *chrToYV12 = rgbf32le_to_uv_half_c; + break; } } else { switch (srcFormat) {