[FFmpeg-devel] [PATCH 1/3] avutil/pixfmt: add YAF16 and YAF32 pixel formats
James Almer
jamrial at gmail.com
Wed Mar 5 22:44:11 EET 2025
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavutil/pixdesc.c | 44 ++++++++++++++++++++++++++++++++
libavutil/pixfmt.h | 9 +++++++
tests/ref/fate/imgutils | 8 ++++++
tests/ref/fate/sws-pixdesc-query | 20 +++++++++++++++
4 files changed, 81 insertions(+)
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 7ffc8f3b2e..1917ae74d8 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -2543,6 +2543,50 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
},
.flags = AV_PIX_FMT_FLAG_FLOAT,
},
+ [AV_PIX_FMT_YAF32BE] = {
+ .name = "yaf32be",
+ .nb_components = 2,
+ .log2_chroma_w = 0,
+ .log2_chroma_h = 0,
+ .comp = {
+ { 0, 8, 0, 0, 32 }, /* Y */
+ { 0, 8, 4, 0, 32 }, /* A */
+ },
+ .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_FLOAT | AV_PIX_FMT_FLAG_ALPHA,
+ },
+ [AV_PIX_FMT_YAF32LE] = {
+ .name = "yaf32le",
+ .nb_components = 2,
+ .log2_chroma_w = 0,
+ .log2_chroma_h = 0,
+ .comp = {
+ { 0, 8, 0, 0, 32 }, /* Y */
+ { 0, 8, 4, 0, 32 }, /* A */
+ },
+ .flags = AV_PIX_FMT_FLAG_FLOAT | AV_PIX_FMT_FLAG_ALPHA,
+ },
+ [AV_PIX_FMT_YAF16BE] = {
+ .name = "yaf16be",
+ .nb_components = 2,
+ .log2_chroma_w = 0,
+ .log2_chroma_h = 0,
+ .comp = {
+ { 0, 4, 0, 0, 16 }, /* Y */
+ { 0, 4, 2, 0, 16 }, /* A */
+ },
+ .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_FLOAT | AV_PIX_FMT_FLAG_ALPHA,
+ },
+ [AV_PIX_FMT_YAF16LE] = {
+ .name = "yaf16le",
+ .nb_components = 2,
+ .log2_chroma_w = 0,
+ .log2_chroma_h = 0,
+ .comp = {
+ { 0, 4, 0, 0, 16 }, /* Y */
+ { 0, 4, 2, 0, 16 }, /* A */
+ },
+ .flags = AV_PIX_FMT_FLAG_FLOAT | AV_PIX_FMT_FLAG_ALPHA,
+ },
[AV_PIX_FMT_YUVA422P12BE] = {
.name = "yuva422p12be",
.nb_components = 4,
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index ca1b22762b..6f343cb026 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -479,6 +479,12 @@ enum AVPixelFormat {
AV_PIX_FMT_GRAY32BE, ///< Y , 32bpp, big-endian
AV_PIX_FMT_GRAY32LE, ///< Y , 32bpp, little-endian
+ AV_PIX_FMT_YAF32BE, ///< IEEE-754 half precision packed YA, 32 bits gray, 32 bits alpha, 64bpp, big-endian
+ AV_PIX_FMT_YAF32LE, ///< IEEE-754 half precision packed YA, 32 bits gray, 32 bits alpha, 64bpp, little-endian
+
+ AV_PIX_FMT_YAF16BE, ///< IEEE-754 half precision packed YA, 16 bits gray, 16 bits alpha, 32bpp, big-endian
+ AV_PIX_FMT_YAF16LE, ///< IEEE-754 half precision packed YA, 16 bits gray, 16 bits alpha, 32bpp, 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
};
@@ -554,6 +560,9 @@ enum AVPixelFormat {
#define AV_PIX_FMT_GRAYF16 AV_PIX_FMT_NE(GRAYF16BE, GRAYF16LE)
#define AV_PIX_FMT_GRAYF32 AV_PIX_FMT_NE(GRAYF32BE, GRAYF32LE)
+#define AV_PIX_FMT_YAF16 AV_PIX_FMT_NE(YAF16BE, YAF16LE)
+#define AV_PIX_FMT_YAF32 AV_PIX_FMT_NE(YAF32BE, YAF32LE)
+
#define AV_PIX_FMT_YUVA420P9 AV_PIX_FMT_NE(YUVA420P9BE , YUVA420P9LE)
#define AV_PIX_FMT_YUVA422P9 AV_PIX_FMT_NE(YUVA422P9BE , YUVA422P9LE)
#define AV_PIX_FMT_YUVA444P9 AV_PIX_FMT_NE(YUVA444P9BE , YUVA444P9LE)
diff --git a/tests/ref/fate/imgutils b/tests/ref/fate/imgutils
index 0951bab161..79e31e80ac 100644
--- a/tests/ref/fate/imgutils
+++ b/tests/ref/fate/imgutils
@@ -292,6 +292,10 @@ grayf16be planes: 1, linesizes: 128 0 0 0, plane_sizes: 6144 0
grayf16le planes: 1, linesizes: 128 0 0 0, plane_sizes: 6144 0 0 0, plane_offsets: 0 0 0, total_size: 6144
gray32be planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288
gray32le planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288
+yaf32be planes: 1, linesizes: 512 0 0 0, plane_sizes: 24576 0 0 0, plane_offsets: 0 0 0, total_size: 24576
+yaf32le planes: 1, linesizes: 512 0 0 0, plane_sizes: 24576 0 0 0, plane_offsets: 0 0 0, total_size: 24576
+yaf16be planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288
+yaf16le 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
@@ -531,3 +535,7 @@ grayf16be total_size: 6144, black_unknown_crc: 0x72aa7ce2, black_tv_cr
grayf16le total_size: 6144, black_unknown_crc: 0xad1b67c6, black_tv_crc: 0xad1b67c6, black_pc_crc: 0x00000000
gray32be total_size: 12288, black_unknown_crc: 0x52baa2c6, black_tv_crc: 0x52baa2c6, black_pc_crc: 0x00000000
gray32le total_size: 12288, black_unknown_crc: 0xc72f7e60, black_tv_crc: 0xc72f7e60, black_pc_crc: 0x00000000
+yaf32be total_size: 24576, black_unknown_crc: 0xa3dc1529, black_tv_crc: 0xa3dc1529, black_pc_crc: 0x0bbcb13e
+yaf32le total_size: 24576, black_unknown_crc: 0xfd900236, black_tv_crc: 0xfd900236, black_pc_crc: 0xdcaf0cb1
+yaf16be total_size: 12288, black_unknown_crc: 0x7afe9aae, black_tv_crc: 0x7afe9aae, black_pc_crc: 0x0fc0a5d0
+yaf16le total_size: 12288, black_unknown_crc: 0x94c0068b, black_tv_crc: 0x94c0068b, black_pc_crc: 0xc05ce449
diff --git a/tests/ref/fate/sws-pixdesc-query b/tests/ref/fate/sws-pixdesc-query
index 9a1d0d4b52..426794b7f2 100644
--- a/tests/ref/fate/sws-pixdesc-query
+++ b/tests/ref/fate/sws-pixdesc-query
@@ -37,6 +37,8 @@ is16BPS:
y216le
ya16be
ya16le
+ yaf16be
+ yaf16le
yuv420p16be
yuv420p16le
yuv422p16be
@@ -212,6 +214,8 @@ isBE:
y212be
y216be
ya16be
+ yaf16be
+ yaf32be
yuv420p10be
yuv420p12be
yuv420p14be
@@ -295,6 +299,10 @@ isYUV:
ya16be
ya16le
ya8
+ yaf16be
+ yaf16le
+ yaf32be
+ yaf32le
yuv410p
yuv411p
yuv420p
@@ -607,6 +615,10 @@ Gray:
ya16be
ya16le
ya8
+ yaf16be
+ yaf16le
+ yaf32be
+ yaf32le
RGBinInt:
monob
@@ -795,6 +807,10 @@ ALPHA:
ya16be
ya16le
ya8
+ yaf16be
+ yaf16le
+ yaf32be
+ yaf32le
yuva420p
yuva420p10be
yuva420p10le
@@ -917,6 +933,10 @@ Packed:
ya16be
ya16le
ya8
+ yaf16be
+ yaf16le
+ yaf32be
+ yaf32le
yuyv422
yvyu422
--
2.48.1
More information about the ffmpeg-devel
mailing list