[FFmpeg-devel] [PATCH v12 1/9] avutil/swscale: add PIX_FMT_YUV444 and input support
Martin Schitter
ms+git at mur.at
Mon Oct 21 22:57:14 EEST 2024
---
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
--
2.45.2
More information about the ffmpeg-devel
mailing list