* [FFmpeg-devel] [PATCH 1/7] avutil/tests/imgutils: factorize basic tests to new function
@ 2023-12-03 0:27 Marton Balint
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 2/7] avutil/tests/imgutils: add tests for av_image_fill_black() Marton Balint
` (6 more replies)
0 siblings, 7 replies; 45+ messages in thread
From: Marton Balint @ 2023-12-03 0:27 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marton Balint
Signed-off-by: Marton Balint <cus@passwd.hu>
---
libavutil/tests/imgutils.c | 68 ++++++++++++++++++++++----------------
1 file changed, 39 insertions(+), 29 deletions(-)
diff --git a/libavutil/tests/imgutils.c b/libavutil/tests/imgutils.c
index 748bd6c9d2..f3a433ac4a 100644
--- a/libavutil/tests/imgutils.c
+++ b/libavutil/tests/imgutils.c
@@ -19,6 +19,41 @@
#include "libavutil/imgutils.c"
#undef printf
+static int basic_tests(enum AVPixelFormat pix_fmt, int w, int h) {
+ uint8_t *data[4];
+ size_t sizes[4];
+ ptrdiff_t linesizes1[4], offsets[3] = { 0 };
+ int i, total_size, linesizes[4];
+
+ if (av_image_fill_linesizes(linesizes, pix_fmt, w) < 0)
+ return -1;
+ for (i = 0; i < 4; i++)
+ linesizes1[i] = linesizes[i];
+ if (av_image_fill_plane_sizes(sizes, pix_fmt, h, linesizes1) < 0)
+ return -1;
+ total_size = av_image_fill_pointers(data, pix_fmt, h, (void *)1, linesizes);
+ if (total_size < 0)
+ return -1;
+ for (i = 0; i < 4 && data[i]; i++);
+ printf("planes: %d", i);
+ // Test the output of av_image_fill_linesizes()
+ printf(", linesizes:");
+ for (i = 0; i < 4; i++)
+ printf(" %3d", linesizes[i]);
+ // Test the output of av_image_fill_plane_sizes()
+ printf(", plane_sizes:");
+ for (i = 0; i < 4; i++)
+ printf(" %5"SIZE_SPECIFIER, sizes[i]);
+ // Test the output of av_image_fill_pointers()
+ for (i = 0; i < 3 && data[i + 1]; i++)
+ offsets[i] = data[i + 1] - data[i];
+ printf(", plane_offsets:");
+ for (i = 0; i < 3; i++)
+ printf(" %5"PTRDIFF_SPECIFIER, offsets[i]);
+ printf(", total_size: %d", total_size);
+
+ return 0;
+}
int main(void)
{
@@ -35,39 +70,14 @@ int main(void)
printf("\n");
while (desc = av_pix_fmt_desc_next(desc)) {
- uint8_t *data[4];
- size_t sizes[4];
- ptrdiff_t linesizes1[4], offsets[3] = { 0 };
- int i, total_size, w = 64, h = 48, linesizes[4];
+ int w = 64, h = 48;
enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(desc);
- if (av_image_fill_linesizes(linesizes, pix_fmt, w) < 0)
- continue;
- for (i = 0; i < 4; i++)
- linesizes1[i] = linesizes[i];
- if (av_image_fill_plane_sizes(sizes, pix_fmt, h, linesizes1) < 0)
- continue;
- total_size = av_image_fill_pointers(data, pix_fmt, h, (void *)1, linesizes);
- if (total_size < 0)
+ if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
continue;
printf("%-16s", desc->name);
- for (i = 0; i < 4 && data[i]; i++);
- printf("planes: %d", i);
- // Test the output of av_image_fill_linesizes()
- printf(", linesizes:");
- for (i = 0; i < 4; i++)
- printf(" %3d", linesizes[i]);
- // Test the output of av_image_fill_plane_sizes()
- printf(", plane_sizes:");
- for (i = 0; i < 4; i++)
- printf(" %5"SIZE_SPECIFIER, sizes[i]);
- // Test the output of av_image_fill_pointers()
- for (i = 0; i < 3 && data[i + 1]; i++)
- offsets[i] = data[i + 1] - data[i];
- printf(", plane_offsets:");
- for (i = 0; i < 3; i++)
- printf(" %5"PTRDIFF_SPECIFIER, offsets[i]);
- printf(", total_size: %d\n", total_size);
+ basic_tests(pix_fmt, w, h);
+ printf("\n");
}
return 0;
--
2.35.3
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* [FFmpeg-devel] [PATCH 2/7] avutil/tests/imgutils: add tests for av_image_fill_black()
2023-12-03 0:27 [FFmpeg-devel] [PATCH 1/7] avutil/tests/imgutils: factorize basic tests to new function Marton Balint
@ 2023-12-03 0:27 ` Marton Balint
2023-12-03 23:47 ` Stefano Sabatini
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 3/7] avutil/imgutils: fix av_image_fill_black() for some pixel formats Marton Balint
` (5 subsequent siblings)
6 siblings, 1 reply; 45+ messages in thread
From: Marton Balint @ 2023-12-03 0:27 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marton Balint
Signed-off-by: Marton Balint <cus@passwd.hu>
---
libavutil/tests/imgutils.c | 60 ++++++++--
tests/ref/fate/imgutils | 217 +++++++++++++++++++++++++++++++++++++
2 files changed, 268 insertions(+), 9 deletions(-)
diff --git a/libavutil/tests/imgutils.c b/libavutil/tests/imgutils.c
index f3a433ac4a..500d24fdb8 100644
--- a/libavutil/tests/imgutils.c
+++ b/libavutil/tests/imgutils.c
@@ -17,6 +17,7 @@
*/
#include "libavutil/imgutils.c"
+#include "libavutil/crc.h"
#undef printf
static int basic_tests(enum AVPixelFormat pix_fmt, int w, int h) {
@@ -55,9 +56,43 @@ static int basic_tests(enum AVPixelFormat pix_fmt, int w, int h) {
return 0;
}
+static int black_tests(const AVPixFmtDescriptor *desc, enum AVPixelFormat pix_fmt, int w, int h)
+{
+ uint8_t *data[4];
+ ptrdiff_t linesizes1[4];
+ int ret, total_size, linesizes[4];
+
+ if (av_image_fill_linesizes(linesizes, pix_fmt, w) < 0)
+ return -1;
+ total_size = av_image_alloc(data, linesizes, w, h, pix_fmt, 4);
+ if (total_size < 0) {
+ printf("alloc failure");
+ return -1;
+ }
+ printf("total_size: %6d", total_size);
+ if (desc->flags & AV_PIX_FMT_FLAG_PAL)
+ total_size -= 256 * 4;
+ // Make it non-black by default...
+ memset(data[0], 0xA3, total_size);
+ for (int i = 0; i < 4; i++)
+ linesizes1[i] = linesizes[i];
+ for (enum AVColorRange range = 0; range < AVCOL_RANGE_NB; range++) {
+ ret = av_image_fill_black(data, linesizes1, pix_fmt, range, w, h);
+ printf(", black_%s_crc: ", av_color_range_name(range));
+ if (ret < 0) {
+ printf("----------");
+ } else {
+ const AVCRC *ctx = av_crc_get_table(AV_CRC_32_IEEE_LE);
+ printf("0x%08"PRIx32, av_crc(ctx, 0, data[0], total_size));
+ }
+ }
+ av_freep(&data[0]);
+
+ return 0;
+}
+
int main(void)
{
- const AVPixFmtDescriptor *desc = NULL;
int64_t x, y;
for (y = -1; y<UINT_MAX; y+= y/2 + 1) {
@@ -69,15 +104,22 @@ int main(void)
}
printf("\n");
- while (desc = av_pix_fmt_desc_next(desc)) {
- int w = 64, h = 48;
- enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(desc);
+ for (int i = 0; i < 2; i++) {
+ printf(i ? "\nblack tests\n" : "basic tests\n");
+ for (const AVPixFmtDescriptor *desc = NULL; desc = av_pix_fmt_desc_next(desc);) {
+ int w = 64, h = 48;
+ enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(desc);
- if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
- continue;
- printf("%-16s", desc->name);
- basic_tests(pix_fmt, w, h);
- printf("\n");
+ if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
+ continue;
+
+ printf("%-16s", desc->name);
+ if (i == 0)
+ basic_tests(pix_fmt, w, h);
+ else
+ black_tests(desc, pix_fmt, w, h);
+ printf("\n");
+ }
}
return 0;
diff --git a/tests/ref/fate/imgutils b/tests/ref/fate/imgutils
index f166cb67fb..1a2aaa86c6 100644
--- a/tests/ref/fate/imgutils
+++ b/tests/ref/fate/imgutils
@@ -54,6 +54,7 @@
0000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000
+basic tests
yuv420p planes: 3, linesizes: 64 32 32 0, plane_sizes: 3072 768 768 0, plane_offsets: 3072 768 0, total_size: 4608
yuyv422 planes: 1, linesizes: 128 0 0 0, plane_sizes: 6144 0 0 0, plane_offsets: 0 0 0, total_size: 6144
rgb24 planes: 1, linesizes: 192 0 0 0, plane_sizes: 9216 0 0 0, plane_offsets: 0 0 0, total_size: 9216
@@ -268,3 +269,219 @@ p412be planes: 2, linesizes: 128 256 0 0, plane_sizes: 6144 12288
p412le planes: 2, linesizes: 128 256 0 0, plane_sizes: 6144 12288 0 0, plane_offsets: 6144 0 0, total_size: 18432
gbrap14be planes: 4, linesizes: 128 128 128 128, plane_sizes: 6144 6144 6144 6144, plane_offsets: 6144 6144 6144, total_size: 24576
gbrap14le planes: 4, linesizes: 128 128 128 128, plane_sizes: 6144 6144 6144 6144, plane_offsets: 6144 6144 6144, total_size: 24576
+
+black tests
+yuv420p total_size: 4608, black_unknown_crc: 0xd00f6cc6, black_tv_crc: 0xd00f6cc6, black_pc_crc: 0x234969af
+yuyv422 total_size: 6144, black_unknown_crc: 0xcb089fb0, black_tv_crc: 0xcb089fb0, black_pc_crc: 0xc9dc3ddf
+rgb24 total_size: 9216, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bgr24 total_size: 9216, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+yuv422p total_size: 6144, black_unknown_crc: 0x71fcc79c, black_tv_crc: 0x71fcc79c, black_pc_crc: 0xa9fa0192
+yuv444p total_size: 9216, black_unknown_crc: 0x1c302b58, black_tv_crc: 0x1c302b58, black_pc_crc: 0xdf792ea7
+yuv410p total_size: 3456, black_unknown_crc: 0x09f3e4b0, black_tv_crc: 0x09f3e4b0, black_pc_crc: 0xe4f4e553
+yuv411p total_size: 4608, black_unknown_crc: 0xd00f6cc6, black_tv_crc: 0xd00f6cc6, black_pc_crc: 0x234969af
+gray total_size: 3072, black_unknown_crc: 0x63e301a2, black_tv_crc: 0x63e301a2, black_pc_crc: 0x00000000
+monow total_size: 384, black_unknown_crc: 0x1ba3e150, black_tv_crc: 0x1ba3e150, black_pc_crc: 0x1ba3e150
+monob total_size: 384, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+pal8 total_size: 4096, black_unknown_crc: 0x63e301a2, black_tv_crc: 0x63e301a2, black_pc_crc: 0x00000000
+yuvj420p total_size: 4608, black_unknown_crc: 0xd00f6cc6, black_tv_crc: 0xd00f6cc6, black_pc_crc: 0x234969af
+yuvj422p total_size: 6144, black_unknown_crc: 0x71fcc79c, black_tv_crc: 0x71fcc79c, black_pc_crc: 0xa9fa0192
+yuvj444p total_size: 9216, black_unknown_crc: 0x1c302b58, black_tv_crc: 0x1c302b58, black_pc_crc: 0xdf792ea7
+uyvy422 total_size: 6144, black_unknown_crc: 0xaf9476bb, black_tv_crc: 0xaf9476bb, black_pc_crc: 0x16a51378
+uyyvyy411 total_size: 4608, black_unknown_crc: 0x6f8b7288, black_tv_crc: 0x6f8b7288, black_pc_crc: 0x9f9c5552
+bgr8 total_size: 3072, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bgr4 total_size: 1536, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bgr4_byte total_size: 3072, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgb8 total_size: 3072, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgb4 total_size: 1536, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgb4_byte total_size: 3072, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+nv12 total_size: 4608, black_unknown_crc: 0xd00f6cc6, black_tv_crc: 0xd00f6cc6, black_pc_crc: 0x234969af
+nv21 total_size: 4608, black_unknown_crc: 0xd00f6cc6, black_tv_crc: 0xd00f6cc6, black_pc_crc: 0x234969af
+argb total_size: 12288, black_unknown_crc: 0x97f3518e, black_tv_crc: 0x97f3518e, black_pc_crc: 0x97f3518e
+rgba total_size: 12288, black_unknown_crc: 0xf15ae524, black_tv_crc: 0xf15ae524, black_pc_crc: 0xf15ae524
+abgr total_size: 12288, black_unknown_crc: 0x97f3518e, black_tv_crc: 0x97f3518e, black_pc_crc: 0x97f3518e
+bgra total_size: 12288, black_unknown_crc: 0xf15ae524, black_tv_crc: 0xf15ae524, black_pc_crc: 0xf15ae524
+gray16be total_size: 6144, black_unknown_crc: 0x02d4a26f, black_tv_crc: 0x02d4a26f, black_pc_crc: 0x00000000
+gray16le total_size: 6144, black_unknown_crc: 0xb93165c3, black_tv_crc: 0xb93165c3, black_pc_crc: 0x00000000
+yuv440p total_size: 6144, black_unknown_crc: 0x71fcc79c, black_tv_crc: 0x71fcc79c, black_pc_crc: 0xa9fa0192
+yuvj440p total_size: 6144, black_unknown_crc: 0x71fcc79c, black_tv_crc: 0x71fcc79c, black_pc_crc: 0xa9fa0192
+yuva420p total_size: 7680, black_unknown_crc: 0x0bcc140f, black_tv_crc: 0x0bcc140f, black_pc_crc: 0xa724ab23
+rgb48be total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgb48le total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgb565be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgb565le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgb555be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgb555le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bgr565be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bgr565le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bgr555be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bgr555le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+yuv420p16le total_size: 9216, black_unknown_crc: 0xfff85b60, black_tv_crc: 0xfff85b60, black_pc_crc: 0xc03cff93
+yuv420p16be total_size: 9216, black_unknown_crc: 0x4d4d9903, black_tv_crc: 0x4d4d9903, black_pc_crc: 0x69c6fe01
+yuv422p16le total_size: 12288, black_unknown_crc: 0x6582d6cf, black_tv_crc: 0x6582d6cf, black_pc_crc: 0xc9dc3ddf
+yuv422p16be total_size: 12288, black_unknown_crc: 0x0bbe5df7, black_tv_crc: 0x0bbe5df7, black_pc_crc: 0x16a51378
+yuv444p16le total_size: 18432, black_unknown_crc: 0x4028ac30, black_tv_crc: 0x4028ac30, black_pc_crc: 0xab7c7698
+yuv444p16be total_size: 18432, black_unknown_crc: 0x26991800, black_tv_crc: 0x26991800, black_pc_crc: 0xfe7f6700
+rgb444le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgb444be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bgr444le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bgr444be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+ya8 total_size: 6144, black_unknown_crc: 0xcb089fb0, black_tv_crc: 0xcb089fb0, black_pc_crc: 0xc9dc3ddf
+bgr48be total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bgr48le total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+yuv420p9be total_size: 9216, black_unknown_crc: 0x9154a536, black_tv_crc: 0x9154a536, black_pc_crc: 0xeeddecd0
+yuv420p9le total_size: 9216, black_unknown_crc: 0x9a9b3206, black_tv_crc: 0x9a9b3206, black_pc_crc: 0xd38dfc02
+yuv420p10be total_size: 9216, black_unknown_crc: 0xf9d84c2d, black_tv_crc: 0xf9d84c2d, black_pc_crc: 0x06cadfe1
+yuv420p10le total_size: 9216, black_unknown_crc: 0xee47624d, black_tv_crc: 0xee47624d, black_pc_crc: 0x7c6afe45
+yuv422p10be total_size: 12288, black_unknown_crc: 0x7cb8d0b6, black_tv_crc: 0x7cb8d0b6, black_pc_crc: 0xa0507635
+yuv422p10le total_size: 12288, black_unknown_crc: 0x2ef977dc, black_tv_crc: 0x2ef977dc, black_pc_crc: 0x5a944de0
+yuv444p9be total_size: 18432, black_unknown_crc: 0x0c244ddf, black_tv_crc: 0x0c244ddf, black_pc_crc: 0x01fcfece
+yuv444p9le total_size: 18432, black_unknown_crc: 0x4d323000, black_tv_crc: 0x4d323000, black_pc_crc: 0x278fc841
+yuv444p10be total_size: 18432, black_unknown_crc: 0x18489bbe, black_tv_crc: 0x18489bbe, black_pc_crc: 0x03f9fd9c
+yuv444p10le total_size: 18432, black_unknown_crc: 0x9a646000, black_tv_crc: 0x9a646000, black_pc_crc: 0x4f1f9082
+yuv422p9be total_size: 12288, black_unknown_crc: 0x3e5c685b, black_tv_crc: 0x3e5c685b, black_pc_crc: 0xbd90b83a
+yuv422p9le total_size: 12288, black_unknown_crc: 0x177cbbee, black_tv_crc: 0x177cbbee, black_pc_crc: 0x2d4a26f0
+gbrp total_size: 9216, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+gbrp9be total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+gbrp9le total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+gbrp10be total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+gbrp10le total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+gbrp16be total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+gbrp16le total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+yuva422p total_size: 9216, black_unknown_crc: 0x6fa9db98, black_tv_crc: 0x6fa9db98, black_pc_crc: 0xace0de67
+yuva444p total_size: 12288, black_unknown_crc: 0x72114eba, black_tv_crc: 0x72114eba, black_pc_crc: 0x001deeda
+yuva420p9be total_size: 15360, black_unknown_crc: 0x47717974, black_tv_crc: 0x47717974, black_pc_crc: 0xf485b36d
+yuva420p9le total_size: 15360, black_unknown_crc: 0xe23950ad, black_tv_crc: 0xe23950ad, black_pc_crc: 0x86e10ca7
+yuva422p9be total_size: 18432, black_unknown_crc: 0x2f5a84da, black_tv_crc: 0x2f5a84da, black_pc_crc: 0x228237cb
+yuva422p9le total_size: 18432, black_unknown_crc: 0x3d7bba46, black_tv_crc: 0x3d7bba46, black_pc_crc: 0x57c64207
+yuva444p9be total_size: 24576, black_unknown_crc: 0x12aed20d, black_tv_crc: 0x12aed20d, black_pc_crc: 0x2f0c503b
+yuva444p9le total_size: 24576, black_unknown_crc: 0x7b4cbb96, black_tv_crc: 0x7b4cbb96, black_pc_crc: 0xb4cb8c8d
+yuva420p10be total_size: 15360, black_unknown_crc: 0x56f111dd, black_tv_crc: 0x56f111dd, black_pc_crc: 0xea6983ae
+yuva420p10le total_size: 15360, black_unknown_crc: 0xa2931f21, black_tv_crc: 0xa2931f21, black_pc_crc: 0x6b23a735
+yuva422p10be total_size: 18432, black_unknown_crc: 0x86a6ea81, black_tv_crc: 0x86a6ea81, black_pc_crc: 0x9d178ca3
+yuva422p10le total_size: 18432, black_unknown_crc: 0xc767ccb6, black_tv_crc: 0xc767ccb6, black_pc_crc: 0x121c3c34
+yuva444p10be total_size: 24576, black_unknown_crc: 0xfd4e472f, black_tv_crc: 0xfd4e472f, black_pc_crc: 0x860b4343
+yuva444p10le total_size: 24576, black_unknown_crc: 0x4b09cf16, black_tv_crc: 0x4b09cf16, black_pc_crc: 0x0f76a761
+yuva420p16be total_size: 15360, black_unknown_crc: 0xe112be6e, black_tv_crc: 0xe112be6e, black_pc_crc: 0xd37e906b
+yuva420p16le total_size: 15360, black_unknown_crc: 0xcbc146fa, black_tv_crc: 0xcbc146fa, black_pc_crc: 0x7f83a0d6
+yuva422p16be total_size: 18432, black_unknown_crc: 0x630b483b, black_tv_crc: 0x630b483b, black_pc_crc: 0xbbed373b
+yuva422p16le total_size: 18432, black_unknown_crc: 0xdac3d2ac, black_tv_crc: 0xdac3d2ac, black_pc_crc: 0x31970804
+yuva444p16be total_size: 24576, black_unknown_crc: 0x4010c8d3, black_tv_crc: 0x4010c8d3, black_pc_crc: 0xca6bd07e
+yuva444p16le total_size: 24576, black_unknown_crc: 0x1824855b, black_tv_crc: 0x1824855b, black_pc_crc: 0x06f5c440
+xyz12le total_size: 18432, black_unknown_crc: 0x24c4432b, black_tv_crc: 0x24c4432b, black_pc_crc: 0xfe5a7889
+xyz12be total_size: 18432, black_unknown_crc: 0xac983d03, black_tv_crc: 0xac983d03, black_pc_crc: 0x949a61fc
+nv16 total_size: 6144, black_unknown_crc: 0x71fcc79c, black_tv_crc: 0x71fcc79c, black_pc_crc: 0xa9fa0192
+nv20le total_size: 12288, black_unknown_crc: 0x2ef977dc, black_tv_crc: 0x2ef977dc, black_pc_crc: 0x5a944de0
+nv20be total_size: 12288, black_unknown_crc: 0x7cb8d0b6, black_tv_crc: 0x7cb8d0b6, black_pc_crc: 0xa0507635
+rgba64be total_size: 24576, black_unknown_crc: 0x0ab5caf6, black_tv_crc: 0x0ab5caf6, black_pc_crc: 0x0ab5caf6
+rgba64le total_size: 24576, black_unknown_crc: 0x0ab5caf6, black_tv_crc: 0x0ab5caf6, black_pc_crc: 0x0ab5caf6
+bgra64be total_size: 24576, black_unknown_crc: 0x0ab5caf6, black_tv_crc: 0x0ab5caf6, black_pc_crc: 0x0ab5caf6
+bgra64le total_size: 24576, black_unknown_crc: 0x0ab5caf6, black_tv_crc: 0x0ab5caf6, black_pc_crc: 0x0ab5caf6
+yvyu422 total_size: 6144, black_unknown_crc: 0xcb089fb0, black_tv_crc: 0xcb089fb0, black_pc_crc: 0xc9dc3ddf
+ya16be total_size: 12288, black_unknown_crc: 0x5483d935, black_tv_crc: 0x5483d935, black_pc_crc: 0x06397bf3
+ya16le total_size: 12288, black_unknown_crc: 0x5d8e1cf6, black_tv_crc: 0x5d8e1cf6, black_pc_crc: 0x8fceec45
+gbrap total_size: 12288, black_unknown_crc: 0xda63f152, black_tv_crc: 0xda63f152, black_pc_crc: 0xda63f152
+gbrap16be total_size: 24576, black_unknown_crc: 0x53374343, black_tv_crc: 0x53374343, black_pc_crc: 0x53374343
+gbrap16le total_size: 24576, black_unknown_crc: 0x53374343, black_tv_crc: 0x53374343, black_pc_crc: 0x53374343
+0rgb total_size: 12288, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgb0 total_size: 12288, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+0bgr total_size: 12288, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bgr0 total_size: 12288, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+yuv420p12be total_size: 9216, black_unknown_crc: 0x220de93c, black_tv_crc: 0x220de93c, black_pc_crc: 0x1b2b7f84
+yuv420p12le total_size: 9216, black_unknown_crc: 0x0fff85b6, black_tv_crc: 0x0fff85b6, black_pc_crc: 0x2adaff55
+yuv420p14be total_size: 9216, black_unknown_crc: 0x8837a4f0, black_tv_crc: 0x8837a4f0, black_pc_crc: 0x6cadfe10
+yuv420p14le total_size: 9216, black_unknown_crc: 0x3ffe16d8, black_tv_crc: 0x3ffe16d8, black_pc_crc: 0xab6bfd54
+yuv422p12be total_size: 12288, black_unknown_crc: 0x50be94e3, black_tv_crc: 0x50be94e3, black_pc_crc: 0xecd2d217
+yuv422p12le total_size: 12288, black_unknown_crc: 0xbbe5df70, black_tv_crc: 0xbbe5df70, black_pc_crc: 0xb12031c1
+yuv422p14be total_size: 12288, black_unknown_crc: 0x998b55cd, black_tv_crc: 0x998b55cd, black_pc_crc: 0x05a944de
+yuv422p14le total_size: 12288, black_unknown_crc: 0x82047703, black_tv_crc: 0x82047703, black_pc_crc: 0xa913cdc7
+yuv444p12be total_size: 18432, black_unknown_crc: 0x02699180, black_tv_crc: 0x02699180, black_pc_crc: 0x0fe7f670
+yuv444p12le total_size: 18432, black_unknown_crc: 0x04028ac3, black_tv_crc: 0x04028ac3, black_pc_crc: 0xe70f4449
+yuv444p14be total_size: 18432, black_unknown_crc: 0x09a64600, black_tv_crc: 0x09a64600, black_pc_crc: 0x3f9fd9c0
+yuv444p14le total_size: 18432, black_unknown_crc: 0x100a2b0c, black_tv_crc: 0x100a2b0c, black_pc_crc: 0x2adf1da6
+gbrp12be total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+gbrp12le total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+gbrp14be total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+gbrp14le total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+yuvj411p total_size: 4608, black_unknown_crc: 0xd00f6cc6, black_tv_crc: 0xd00f6cc6, black_pc_crc: 0x234969af
+bayer_bggr8 total_size: 3072, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bayer_rggb8 total_size: 3072, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bayer_gbrg8 total_size: 3072, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bayer_grbg8 total_size: 3072, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bayer_bggr16le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bayer_bggr16be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bayer_rggb16le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bayer_rggb16be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bayer_gbrg16le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bayer_gbrg16be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bayer_grbg16le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bayer_grbg16be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+yuv440p10le total_size: 12288, black_unknown_crc: 0x2ef977dc, black_tv_crc: 0x2ef977dc, black_pc_crc: 0x5a944de0
+yuv440p10be total_size: 12288, black_unknown_crc: 0x7cb8d0b6, black_tv_crc: 0x7cb8d0b6, black_pc_crc: 0xa0507635
+yuv440p12le total_size: 12288, black_unknown_crc: 0xbbe5df70, black_tv_crc: 0xbbe5df70, black_pc_crc: 0xb12031c1
+yuv440p12be total_size: 12288, black_unknown_crc: 0x50be94e3, black_tv_crc: 0x50be94e3, black_pc_crc: 0xecd2d217
+ayuv64le total_size: 24576, black_unknown_crc: 0xcb441ee4, black_tv_crc: 0xcb441ee4, black_pc_crc: 0x48ba1e8d
+ayuv64be total_size: 24576, black_unknown_crc: 0xe0be064e, black_tv_crc: 0xe0be064e, black_pc_crc: 0xd45321b2
+p010le total_size: 9216, black_unknown_crc: 0xfff85b60, black_tv_crc: 0xfff85b60, black_pc_crc: 0xc03cff93
+p010be total_size: 9216, black_unknown_crc: 0x4d4d9903, black_tv_crc: 0x4d4d9903, black_pc_crc: 0x69c6fe01
+gbrap12be total_size: 24576, black_unknown_crc: 0x49bd3f36, black_tv_crc: 0x49bd3f36, black_pc_crc: 0x49bd3f36
+gbrap12le total_size: 24576, black_unknown_crc: 0x039f4b57, black_tv_crc: 0x039f4b57, black_pc_crc: 0x039f4b57
+gbrap10be total_size: 24576, black_unknown_crc: 0x3ebe070a, black_tv_crc: 0x3ebe070a, black_pc_crc: 0x3ebe070a
+gbrap10le total_size: 24576, black_unknown_crc: 0x0797e156, black_tv_crc: 0x0797e156, black_pc_crc: 0x0797e156
+gray12be total_size: 6144, black_unknown_crc: 0xbd90b83a, black_tv_crc: 0xbd90b83a, black_pc_crc: 0x00000000
+gray12le total_size: 6144, black_unknown_crc: 0x2d4a26f0, black_tv_crc: 0x2d4a26f0, black_pc_crc: 0x00000000
+gray10be total_size: 6144, black_unknown_crc: 0x89569dcf, black_tv_crc: 0x89569dcf, black_pc_crc: 0x00000000
+gray10le total_size: 6144, black_unknown_crc: 0x0b5289bc, black_tv_crc: 0x0b5289bc, black_pc_crc: 0x00000000
+p016le total_size: 9216, black_unknown_crc: 0xfff85b60, black_tv_crc: 0xfff85b60, black_pc_crc: 0xc03cff93
+p016be total_size: 9216, black_unknown_crc: 0x4d4d9903, black_tv_crc: 0x4d4d9903, black_pc_crc: 0x69c6fe01
+gray9be total_size: 6144, black_unknown_crc: 0xa913cdc7, black_tv_crc: 0xa913cdc7, black_pc_crc: 0x00000000
+gray9le total_size: 6144, black_unknown_crc: 0x05a944de, black_tv_crc: 0x05a944de, black_pc_crc: 0x00000000
+gbrpf32be total_size: 36864, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+gbrpf32le total_size: 36864, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+gbrapf32be total_size: 49152, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+gbrapf32le total_size: 49152, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+gray14be total_size: 6144, black_unknown_crc: 0x9bd1ea2b, black_tv_crc: 0x9bd1ea2b, black_pc_crc: 0x00000000
+gray14le total_size: 6144, black_unknown_crc: 0xb5289bc0, black_tv_crc: 0xb5289bc0, black_pc_crc: 0x00000000
+grayf32be total_size: 12288, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+grayf32le total_size: 12288, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+yuva422p12be total_size: 18432, black_unknown_crc: 0xa7067ca1, black_tv_crc: 0xa7067ca1, black_pc_crc: 0xaa881b51
+yuva422p12le total_size: 18432, black_unknown_crc: 0xb6bdf055, black_tv_crc: 0xb6bdf055, black_pc_crc: 0x55b03edf
+yuva444p12be total_size: 24576, black_unknown_crc: 0x488f478f, black_tv_crc: 0x488f478f, black_pc_crc: 0xc6fb24d1
+yuva444p12le total_size: 24576, black_unknown_crc: 0xea96f416, black_tv_crc: 0xea96f416, black_pc_crc: 0x201a538b
+nv24 total_size: 9216, black_unknown_crc: 0x1c302b58, black_tv_crc: 0x1c302b58, black_pc_crc: 0xdf792ea7
+nv42 total_size: 9216, black_unknown_crc: 0x1c302b58, black_tv_crc: 0x1c302b58, black_pc_crc: 0xdf792ea7
+y210be total_size: 12288, black_unknown_crc: 0x5483d935, black_tv_crc: 0x5483d935, black_pc_crc: 0x06397bf3
+y210le total_size: 12288, black_unknown_crc: 0x5d8e1cf6, black_tv_crc: 0x5d8e1cf6, black_pc_crc: 0x8fceec45
+x2rgb10le total_size: 12288, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+x2rgb10be total_size: 12288, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+x2bgr10le total_size: 12288, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+x2bgr10be total_size: 12288, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+p210be total_size: 12288, black_unknown_crc: 0x0bbe5df7, black_tv_crc: 0x0bbe5df7, black_pc_crc: 0x16a51378
+p210le total_size: 12288, black_unknown_crc: 0x6582d6cf, black_tv_crc: 0x6582d6cf, black_pc_crc: 0xc9dc3ddf
+p410be total_size: 18432, black_unknown_crc: 0x26991800, black_tv_crc: 0x26991800, black_pc_crc: 0xfe7f6700
+p410le total_size: 18432, black_unknown_crc: 0x4028ac30, black_tv_crc: 0x4028ac30, black_pc_crc: 0xab7c7698
+p216be total_size: 12288, black_unknown_crc: 0x0bbe5df7, black_tv_crc: 0x0bbe5df7, black_pc_crc: 0x16a51378
+p216le total_size: 12288, black_unknown_crc: 0x6582d6cf, black_tv_crc: 0x6582d6cf, black_pc_crc: 0xc9dc3ddf
+p416be total_size: 18432, black_unknown_crc: 0x26991800, black_tv_crc: 0x26991800, black_pc_crc: 0xfe7f6700
+p416le total_size: 18432, black_unknown_crc: 0x4028ac30, black_tv_crc: 0x4028ac30, black_pc_crc: 0xab7c7698
+vuya total_size: 12288, black_unknown_crc: 0x60db2d2c, black_tv_crc: 0x60db2d2c, black_pc_crc: 0x2dae630a
+rgbaf16be total_size: 24576, black_unknown_crc: 0x0ab5caf6, black_tv_crc: 0x0ab5caf6, black_pc_crc: 0x0ab5caf6
+rgbaf16le total_size: 24576, black_unknown_crc: 0x0ab5caf6, black_tv_crc: 0x0ab5caf6, black_pc_crc: 0x0ab5caf6
+vuyx total_size: 12288, black_unknown_crc: 0x9181c808, black_tv_crc: 0x9181c808, black_pc_crc: 0xdcf4862e
+p012le total_size: 9216, black_unknown_crc: 0xfff85b60, black_tv_crc: 0xfff85b60, black_pc_crc: 0xc03cff93
+p012be total_size: 9216, black_unknown_crc: 0x4d4d9903, black_tv_crc: 0x4d4d9903, black_pc_crc: 0x69c6fe01
+y212be total_size: 12288, black_unknown_crc: 0x5483d935, black_tv_crc: 0x5483d935, black_pc_crc: 0x06397bf3
+y212le total_size: 12288, black_unknown_crc: 0x5d8e1cf6, black_tv_crc: 0x5d8e1cf6, black_pc_crc: 0x8fceec45
+xv30be total_size: 12288, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+xv30le total_size: 12288, black_unknown_crc: 0x4bb0b075, black_tv_crc: 0x4bb0b075, black_pc_crc: 0x02d585cf
+xv36be total_size: 24576, black_unknown_crc: 0x6ba828bd, black_tv_crc: 0x6ba828bd, black_pc_crc: 0x5f450f41
+xv36le total_size: 24576, black_unknown_crc: 0xc3794950, black_tv_crc: 0xc3794950, black_pc_crc: 0x40874939
+rgbf32be total_size: 36864, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+rgbf32le total_size: 36864, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+rgbaf32be total_size: 49152, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+rgbaf32le total_size: 49152, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+p212be total_size: 12288, black_unknown_crc: 0x0bbe5df7, black_tv_crc: 0x0bbe5df7, black_pc_crc: 0x16a51378
+p212le total_size: 12288, black_unknown_crc: 0x6582d6cf, black_tv_crc: 0x6582d6cf, black_pc_crc: 0xc9dc3ddf
+p412be total_size: 18432, black_unknown_crc: 0x26991800, black_tv_crc: 0x26991800, black_pc_crc: 0xfe7f6700
+p412le total_size: 18432, black_unknown_crc: 0x4028ac30, black_tv_crc: 0x4028ac30, black_pc_crc: 0xab7c7698
+gbrap14be total_size: 24576, black_unknown_crc: 0x4ec0d987, black_tv_crc: 0x4ec0d987, black_pc_crc: 0x4ec0d987
+gbrap14le total_size: 24576, black_unknown_crc: 0x13bde353, black_tv_crc: 0x13bde353, black_pc_crc: 0x13bde353
--
2.35.3
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* [FFmpeg-devel] [PATCH 3/7] avutil/imgutils: fix av_image_fill_black() for some pixel formats
2023-12-03 0:27 [FFmpeg-devel] [PATCH 1/7] avutil/tests/imgutils: factorize basic tests to new function Marton Balint
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 2/7] avutil/tests/imgutils: add tests for av_image_fill_black() Marton Balint
@ 2023-12-03 0:27 ` Marton Balint
2023-12-04 0:23 ` Stefano Sabatini
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 4/7] avutil/imgutils: add support for 32bit pixel format for av_image_fill_black() Marton Balint
` (4 subsequent siblings)
6 siblings, 1 reply; 45+ messages in thread
From: Marton Balint @ 2023-12-03 0:27 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marton Balint
- Fixes YA formats, because previous code always assumed alpha as the 4th
component.
- Fixes PAL format (as long as 0 is black, as in a systematic palette), because
previous code assumed it as limited Y.
- Fixes XYZ format because it does not need nonzero chroma components
- Fixes xv30be as the bitstream mode got merged to the non-bitstream mode.
Signed-off-by: Marton Balint <cus@passwd.hu>
---
libavutil/imgutils.c | 49 +++++++++++++++--------------------------
tests/ref/fate/imgutils | 14 ++++++------
2 files changed, 25 insertions(+), 38 deletions(-)
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index da3812698e..5e401139c8 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -590,35 +590,18 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
uint8_t clear_block[4][MAX_BLOCK_SIZE] = {{0}}; // clear padding with 0
int clear_block_size[4] = {0};
ptrdiff_t plane_line_bytes[4] = {0};
- int rgb, limited;
+ int rgb, xyz, pal, limited, alpha, bitstream;
int plane, c;
if (!desc || nb_planes < 1 || nb_planes > 4 || desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
return AVERROR(EINVAL);
rgb = !!(desc->flags & AV_PIX_FMT_FLAG_RGB);
- limited = !rgb && range != AVCOL_RANGE_JPEG;
-
- if (desc->flags & AV_PIX_FMT_FLAG_BITSTREAM) {
- ptrdiff_t bytewidth = av_image_get_linesize(pix_fmt, width, 0);
- uint8_t *data;
- int mono = pix_fmt == AV_PIX_FMT_MONOWHITE || pix_fmt == AV_PIX_FMT_MONOBLACK;
- int fill = pix_fmt == AV_PIX_FMT_MONOWHITE ? 0xFF : 0;
- if (nb_planes != 1 || !(rgb || mono) || bytewidth < 1)
- return AVERROR(EINVAL);
-
- if (!dst_data)
- return 0;
-
- data = dst_data[0];
-
- // (Bitstream + alpha will be handled incorrectly - it'll remain transparent.)
- for (;height > 0; height--) {
- memset(data, fill, bytewidth);
- data += dst_linesize[0];
- }
- return 0;
- }
+ xyz = !!(desc->flags & AV_PIX_FMT_FLAG_XYZ);
+ pal = !!(desc->flags & AV_PIX_FMT_FLAG_PAL);
+ limited = !rgb && !xyz && !pal && range != AVCOL_RANGE_JPEG;
+ alpha = !pal && !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA);
+ bitstream = !!(desc->flags & AV_PIX_FMT_FLAG_BITSTREAM);
for (c = 0; c < desc->nb_components; c++) {
const AVComponentDescriptor comp = desc->comp[c];
@@ -635,7 +618,7 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
for (c = 0; c < desc->nb_components; c++) {
const AVComponentDescriptor comp = desc->comp[c];
// (Multiple pixels happen e.g. with AV_PIX_FMT_UYVY422.)
- int w = clear_block_size[comp.plane] / comp.step;
+ int w = (bitstream ? 8 : 1) * clear_block_size[comp.plane] / comp.step;
uint8_t *c_data[4];
const int c_linesize[4] = {0};
uint16_t src_array[MAX_BLOCK_SIZE];
@@ -644,18 +627,22 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
if (comp.depth > 16)
return AVERROR(EINVAL);
- if (!rgb && comp.depth < 8)
- return AVERROR(EINVAL);
if (w < 1)
return AVERROR(EINVAL);
- if (c == 0 && limited) {
- src = 16 << (comp.depth - 8);
- } else if ((c == 1 || c == 2) && !rgb) {
- src = 128 << (comp.depth - 8);
- } else if (c == 3) {
+ if (pix_fmt == AV_PIX_FMT_MONOWHITE) {
+ src = 1;
+ } else if (c + 1 == desc->nb_components && alpha) {
// (Assume even limited YUV uses full range alpha.)
src = (1 << comp.depth) - 1;
+ } else if (c == 0 && limited && comp.depth > 1) {
+ if (comp.depth < 8)
+ return AVERROR(EINVAL);
+ src = 16 << (comp.depth - 8);
+ } else if ((c == 1 || c == 2) && !rgb && !xyz) {
+ if (comp.depth < 8)
+ return AVERROR(EINVAL);
+ src = 128 << (comp.depth - 8);
}
for (x = 0; x < w; x++)
diff --git a/tests/ref/fate/imgutils b/tests/ref/fate/imgutils
index 1a2aaa86c6..79ef5cdfc0 100644
--- a/tests/ref/fate/imgutils
+++ b/tests/ref/fate/imgutils
@@ -282,7 +282,7 @@ yuv411p total_size: 4608, black_unknown_crc: 0xd00f6cc6, black_tv_cr
gray total_size: 3072, black_unknown_crc: 0x63e301a2, black_tv_crc: 0x63e301a2, black_pc_crc: 0x00000000
monow total_size: 384, black_unknown_crc: 0x1ba3e150, black_tv_crc: 0x1ba3e150, black_pc_crc: 0x1ba3e150
monob total_size: 384, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
-pal8 total_size: 4096, black_unknown_crc: 0x63e301a2, black_tv_crc: 0x63e301a2, black_pc_crc: 0x00000000
+pal8 total_size: 4096, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
yuvj420p total_size: 4608, black_unknown_crc: 0xd00f6cc6, black_tv_crc: 0xd00f6cc6, black_pc_crc: 0x234969af
yuvj422p total_size: 6144, black_unknown_crc: 0x71fcc79c, black_tv_crc: 0x71fcc79c, black_pc_crc: 0xa9fa0192
yuvj444p total_size: 9216, black_unknown_crc: 0x1c302b58, black_tv_crc: 0x1c302b58, black_pc_crc: 0xdf792ea7
@@ -325,7 +325,7 @@ rgb444le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_cr
rgb444be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
bgr444le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
bgr444be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
-ya8 total_size: 6144, black_unknown_crc: 0xcb089fb0, black_tv_crc: 0xcb089fb0, black_pc_crc: 0xc9dc3ddf
+ya8 total_size: 6144, black_unknown_crc: 0x21aa6b6a, black_tv_crc: 0x21aa6b6a, black_pc_crc: 0x237ec905
bgr48be total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
bgr48le total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
yuv420p9be total_size: 9216, black_unknown_crc: 0x9154a536, black_tv_crc: 0x9154a536, black_pc_crc: 0xeeddecd0
@@ -367,8 +367,8 @@ yuva422p16be total_size: 18432, black_unknown_crc: 0x630b483b, black_tv_cr
yuva422p16le total_size: 18432, black_unknown_crc: 0xdac3d2ac, black_tv_crc: 0xdac3d2ac, black_pc_crc: 0x31970804
yuva444p16be total_size: 24576, black_unknown_crc: 0x4010c8d3, black_tv_crc: 0x4010c8d3, black_pc_crc: 0xca6bd07e
yuva444p16le total_size: 24576, black_unknown_crc: 0x1824855b, black_tv_crc: 0x1824855b, black_pc_crc: 0x06f5c440
-xyz12le total_size: 18432, black_unknown_crc: 0x24c4432b, black_tv_crc: 0x24c4432b, black_pc_crc: 0xfe5a7889
-xyz12be total_size: 18432, black_unknown_crc: 0xac983d03, black_tv_crc: 0xac983d03, black_pc_crc: 0x949a61fc
+xyz12le total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+xyz12be total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
nv16 total_size: 6144, black_unknown_crc: 0x71fcc79c, black_tv_crc: 0x71fcc79c, black_pc_crc: 0xa9fa0192
nv20le total_size: 12288, black_unknown_crc: 0x2ef977dc, black_tv_crc: 0x2ef977dc, black_pc_crc: 0x5a944de0
nv20be total_size: 12288, black_unknown_crc: 0x7cb8d0b6, black_tv_crc: 0x7cb8d0b6, black_pc_crc: 0xa0507635
@@ -377,8 +377,8 @@ rgba64le total_size: 24576, black_unknown_crc: 0x0ab5caf6, black_tv_cr
bgra64be total_size: 24576, black_unknown_crc: 0x0ab5caf6, black_tv_crc: 0x0ab5caf6, black_pc_crc: 0x0ab5caf6
bgra64le total_size: 24576, black_unknown_crc: 0x0ab5caf6, black_tv_crc: 0x0ab5caf6, black_pc_crc: 0x0ab5caf6
yvyu422 total_size: 6144, black_unknown_crc: 0xcb089fb0, black_tv_crc: 0xcb089fb0, black_pc_crc: 0xc9dc3ddf
-ya16be total_size: 12288, black_unknown_crc: 0x5483d935, black_tv_crc: 0x5483d935, black_pc_crc: 0x06397bf3
-ya16le total_size: 12288, black_unknown_crc: 0x5d8e1cf6, black_tv_crc: 0x5d8e1cf6, black_pc_crc: 0x8fceec45
+ya16be total_size: 12288, black_unknown_crc: 0x9f12f9d6, black_tv_crc: 0x9f12f9d6, black_pc_crc: 0xcda85b10
+ya16le total_size: 12288, black_unknown_crc: 0x1fe8aba3, black_tv_crc: 0x1fe8aba3, black_pc_crc: 0xcda85b10
gbrap total_size: 12288, black_unknown_crc: 0xda63f152, black_tv_crc: 0xda63f152, black_pc_crc: 0xda63f152
gbrap16be total_size: 24576, black_unknown_crc: 0x53374343, black_tv_crc: 0x53374343, black_pc_crc: 0x53374343
gbrap16le total_size: 24576, black_unknown_crc: 0x53374343, black_tv_crc: 0x53374343, black_pc_crc: 0x53374343
@@ -471,7 +471,7 @@ p012le total_size: 9216, black_unknown_crc: 0xfff85b60, black_tv_cr
p012be total_size: 9216, black_unknown_crc: 0x4d4d9903, black_tv_crc: 0x4d4d9903, black_pc_crc: 0x69c6fe01
y212be total_size: 12288, black_unknown_crc: 0x5483d935, black_tv_crc: 0x5483d935, black_pc_crc: 0x06397bf3
y212le total_size: 12288, black_unknown_crc: 0x5d8e1cf6, black_tv_crc: 0x5d8e1cf6, black_pc_crc: 0x8fceec45
-xv30be total_size: 12288, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+xv30be total_size: 12288, black_unknown_crc: 0x1c42115f, black_tv_crc: 0x1c42115f, black_pc_crc: 0x37bf2ef8
xv30le total_size: 12288, black_unknown_crc: 0x4bb0b075, black_tv_crc: 0x4bb0b075, black_pc_crc: 0x02d585cf
xv36be total_size: 24576, black_unknown_crc: 0x6ba828bd, black_tv_crc: 0x6ba828bd, black_pc_crc: 0x5f450f41
xv36le total_size: 24576, black_unknown_crc: 0xc3794950, black_tv_crc: 0xc3794950, black_pc_crc: 0x40874939
--
2.35.3
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* [FFmpeg-devel] [PATCH 4/7] avutil/imgutils: add support for 32bit pixel format for av_image_fill_black()
2023-12-03 0:27 [FFmpeg-devel] [PATCH 1/7] avutil/tests/imgutils: factorize basic tests to new function Marton Balint
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 2/7] avutil/tests/imgutils: add tests for av_image_fill_black() Marton Balint
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 3/7] avutil/imgutils: fix av_image_fill_black() for some pixel formats Marton Balint
@ 2023-12-03 0:27 ` Marton Balint
2023-12-04 0:52 ` Stefano Sabatini
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 5/7] avutil/imgutils: factorize a fill color function Marton Balint
` (3 subsequent siblings)
6 siblings, 1 reply; 45+ messages in thread
From: Marton Balint @ 2023-12-03 0:27 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marton Balint
Signed-off-by: Marton Balint <cus@passwd.hu>
---
libavutil/imgutils.c | 32 ++++++++++++++++++++++----------
tests/ref/fate/imgutils | 24 ++++++++++++------------
2 files changed, 34 insertions(+), 22 deletions(-)
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index 5e401139c8..26bb2f2c6f 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -590,7 +590,7 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
uint8_t clear_block[4][MAX_BLOCK_SIZE] = {{0}}; // clear padding with 0
int clear_block_size[4] = {0};
ptrdiff_t plane_line_bytes[4] = {0};
- int rgb, xyz, pal, limited, alpha, bitstream;
+ int rgb, xyz, pal, limited, alpha, bitstream, fltp;
int plane, c;
if (!desc || nb_planes < 1 || nb_planes > 4 || desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
@@ -602,6 +602,7 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
limited = !rgb && !xyz && !pal && range != AVCOL_RANGE_JPEG;
alpha = !pal && !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA);
bitstream = !!(desc->flags & AV_PIX_FMT_FLAG_BITSTREAM);
+ fltp = !!(desc->flags & AV_PIX_FMT_FLAG_FLOAT);
for (c = 0; c < desc->nb_components; c++) {
const AVComponentDescriptor comp = desc->comp[c];
@@ -621,11 +622,11 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
int w = (bitstream ? 8 : 1) * clear_block_size[comp.plane] / comp.step;
uint8_t *c_data[4];
const int c_linesize[4] = {0};
- uint16_t src_array[MAX_BLOCK_SIZE];
- uint16_t src = 0;
+ uint32_t src_array[MAX_BLOCK_SIZE];
+ uint32_t src = 0;
int x;
- if (comp.depth > 16)
+ if (comp.depth > 32)
return AVERROR(EINVAL);
if (w < 1)
return AVERROR(EINVAL);
@@ -634,15 +635,26 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
src = 1;
} else if (c + 1 == desc->nb_components && alpha) {
// (Assume even limited YUV uses full range alpha.)
- src = (1 << comp.depth) - 1;
+ if (fltp && comp.depth != 16 && comp.depth != 32)
+ return AVERROR(EINVAL);
+ if (fltp)
+ src = (comp.depth == 16 ? 0x3C00 : 0x3F800000); // 1.0
+ else
+ src = (comp.depth == 32 ? 0 : (1 << comp.depth)) - 1;
} else if (c == 0 && limited && comp.depth > 1) {
- if (comp.depth < 8)
+ if (comp.depth < 8 || fltp && comp.depth != 16 && comp.depth != 32)
return AVERROR(EINVAL);
- src = 16 << (comp.depth - 8);
+ if (fltp)
+ src = (comp.depth == 16 ? 0x3000 : 0x3D800000); // 0.0625
+ else
+ src = 16 << (comp.depth - 8);
} else if ((c == 1 || c == 2) && !rgb && !xyz) {
- if (comp.depth < 8)
+ if (comp.depth < 8 || fltp && comp.depth != 16 && comp.depth != 32)
return AVERROR(EINVAL);
- src = 128 << (comp.depth - 8);
+ if (fltp)
+ src = (comp.depth == 16 ? 0x3800 : 0x3F000000); // 0.5
+ else
+ src = 128 << (comp.depth - 8);
}
for (x = 0; x < w; x++)
@@ -651,7 +663,7 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
for (x = 0; x < 4; x++)
c_data[x] = &clear_block[x][0];
- av_write_image_line(src_array, c_data, c_linesize, desc, 0, 0, c, w);
+ av_write_image_line2(src_array, c_data, c_linesize, desc, 0, 0, c, w, 4);
}
for (plane = 0; plane < nb_planes; plane++) {
diff --git a/tests/ref/fate/imgutils b/tests/ref/fate/imgutils
index 79ef5cdfc0..b589c49473 100644
--- a/tests/ref/fate/imgutils
+++ b/tests/ref/fate/imgutils
@@ -435,14 +435,14 @@ p016le total_size: 9216, black_unknown_crc: 0xfff85b60, black_tv_cr
p016be total_size: 9216, black_unknown_crc: 0x4d4d9903, black_tv_crc: 0x4d4d9903, black_pc_crc: 0x69c6fe01
gray9be total_size: 6144, black_unknown_crc: 0xa913cdc7, black_tv_crc: 0xa913cdc7, black_pc_crc: 0x00000000
gray9le total_size: 6144, black_unknown_crc: 0x05a944de, black_tv_crc: 0x05a944de, black_pc_crc: 0x00000000
-gbrpf32be total_size: 36864, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
-gbrpf32le total_size: 36864, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
-gbrapf32be total_size: 49152, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
-gbrapf32le total_size: 49152, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+gbrpf32be total_size: 36864, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+gbrpf32le total_size: 36864, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+gbrapf32be total_size: 49152, black_unknown_crc: 0xda9c5af9, black_tv_crc: 0xda9c5af9, black_pc_crc: 0xda9c5af9
+gbrapf32le total_size: 49152, black_unknown_crc: 0xd2f28790, black_tv_crc: 0xd2f28790, black_pc_crc: 0xd2f28790
gray14be total_size: 6144, black_unknown_crc: 0x9bd1ea2b, black_tv_crc: 0x9bd1ea2b, black_pc_crc: 0x00000000
gray14le total_size: 6144, black_unknown_crc: 0xb5289bc0, black_tv_crc: 0xb5289bc0, black_pc_crc: 0x00000000
-grayf32be total_size: 12288, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
-grayf32le total_size: 12288, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+grayf32be total_size: 12288, black_unknown_crc: 0x4bafcc11, black_tv_crc: 0x4bafcc11, black_pc_crc: 0x00000000
+grayf32le total_size: 12288, black_unknown_crc: 0xca17685c, black_tv_crc: 0xca17685c, black_pc_crc: 0x00000000
yuva422p12be total_size: 18432, black_unknown_crc: 0xa7067ca1, black_tv_crc: 0xa7067ca1, black_pc_crc: 0xaa881b51
yuva422p12le total_size: 18432, black_unknown_crc: 0xb6bdf055, black_tv_crc: 0xb6bdf055, black_pc_crc: 0x55b03edf
yuva444p12be total_size: 24576, black_unknown_crc: 0x488f478f, black_tv_crc: 0x488f478f, black_pc_crc: 0xc6fb24d1
@@ -464,8 +464,8 @@ p216le total_size: 12288, black_unknown_crc: 0x6582d6cf, black_tv_cr
p416be total_size: 18432, black_unknown_crc: 0x26991800, black_tv_crc: 0x26991800, black_pc_crc: 0xfe7f6700
p416le total_size: 18432, black_unknown_crc: 0x4028ac30, black_tv_crc: 0x4028ac30, black_pc_crc: 0xab7c7698
vuya total_size: 12288, black_unknown_crc: 0x60db2d2c, black_tv_crc: 0x60db2d2c, black_pc_crc: 0x2dae630a
-rgbaf16be total_size: 24576, black_unknown_crc: 0x0ab5caf6, black_tv_crc: 0x0ab5caf6, black_pc_crc: 0x0ab5caf6
-rgbaf16le total_size: 24576, black_unknown_crc: 0x0ab5caf6, black_tv_crc: 0x0ab5caf6, black_pc_crc: 0x0ab5caf6
+rgbaf16be total_size: 24576, black_unknown_crc: 0x76fd69af, black_tv_crc: 0x76fd69af, black_pc_crc: 0x76fd69af
+rgbaf16le total_size: 24576, black_unknown_crc: 0x21283f40, black_tv_crc: 0x21283f40, black_pc_crc: 0x21283f40
vuyx total_size: 12288, black_unknown_crc: 0x9181c808, black_tv_crc: 0x9181c808, black_pc_crc: 0xdcf4862e
p012le total_size: 9216, black_unknown_crc: 0xfff85b60, black_tv_crc: 0xfff85b60, black_pc_crc: 0xc03cff93
p012be total_size: 9216, black_unknown_crc: 0x4d4d9903, black_tv_crc: 0x4d4d9903, black_pc_crc: 0x69c6fe01
@@ -475,10 +475,10 @@ xv30be total_size: 12288, black_unknown_crc: 0x1c42115f, black_tv_cr
xv30le total_size: 12288, black_unknown_crc: 0x4bb0b075, black_tv_crc: 0x4bb0b075, black_pc_crc: 0x02d585cf
xv36be total_size: 24576, black_unknown_crc: 0x6ba828bd, black_tv_crc: 0x6ba828bd, black_pc_crc: 0x5f450f41
xv36le total_size: 24576, black_unknown_crc: 0xc3794950, black_tv_crc: 0xc3794950, black_pc_crc: 0x40874939
-rgbf32be total_size: 36864, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
-rgbf32le total_size: 36864, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
-rgbaf32be total_size: 49152, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
-rgbaf32le total_size: 49152, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+rgbf32be total_size: 36864, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgbf32le total_size: 36864, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgbaf32be total_size: 49152, black_unknown_crc: 0x5eae6680, black_tv_crc: 0x5eae6680, black_pc_crc: 0x5eae6680
+rgbaf32le total_size: 49152, black_unknown_crc: 0x11d73f6d, black_tv_crc: 0x11d73f6d, black_pc_crc: 0x11d73f6d
p212be total_size: 12288, black_unknown_crc: 0x0bbe5df7, black_tv_crc: 0x0bbe5df7, black_pc_crc: 0x16a51378
p212le total_size: 12288, black_unknown_crc: 0x6582d6cf, black_tv_crc: 0x6582d6cf, black_pc_crc: 0xc9dc3ddf
p412be total_size: 18432, black_unknown_crc: 0x26991800, black_tv_crc: 0x26991800, black_pc_crc: 0xfe7f6700
--
2.35.3
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* [FFmpeg-devel] [PATCH 5/7] avutil/imgutils: factorize a fill color function
2023-12-03 0:27 [FFmpeg-devel] [PATCH 1/7] avutil/tests/imgutils: factorize basic tests to new function Marton Balint
` (2 preceding siblings ...)
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 4/7] avutil/imgutils: add support for 32bit pixel format for av_image_fill_black() Marton Balint
@ 2023-12-03 0:27 ` Marton Balint
2023-12-04 1:04 ` Stefano Sabatini
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 6/7] avutil/imgutils: add new function av_image_fill_color() Marton Balint
` (2 subsequent siblings)
6 siblings, 1 reply; 45+ messages in thread
From: Marton Balint @ 2023-12-03 0:27 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marton Balint
In preparation for making it public.
Signed-off-by: Marton Balint <cus@passwd.hu>
---
libavutil/imgutils.c | 101 +++++++++++++++++++++++++++----------------
1 file changed, 63 insertions(+), 38 deletions(-)
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index 26bb2f2c6f..959e6850ac 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -579,30 +579,24 @@ static void memset_bytes(uint8_t *dst, size_t dst_size, uint8_t *clear,
// if it's a subsampled packed format).
#define MAX_BLOCK_SIZE 32
-int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
- enum AVPixelFormat pix_fmt, enum AVColorRange range,
+static int image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
+ enum AVPixelFormat pix_fmt, const uint32_t color[4],
int width, int height)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
int nb_planes = av_pix_fmt_count_planes(pix_fmt);
- // A pixel or a group of pixels on each plane, with a value that represents black.
+ // A pixel or a group of pixels on each plane, with a value that represents the color.
// Consider e.g. AV_PIX_FMT_UYVY422 for non-trivial cases.
uint8_t clear_block[4][MAX_BLOCK_SIZE] = {{0}}; // clear padding with 0
int clear_block_size[4] = {0};
ptrdiff_t plane_line_bytes[4] = {0};
- int rgb, xyz, pal, limited, alpha, bitstream, fltp;
+ int bitstream;
int plane, c;
if (!desc || nb_planes < 1 || nb_planes > 4 || desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
return AVERROR(EINVAL);
- rgb = !!(desc->flags & AV_PIX_FMT_FLAG_RGB);
- xyz = !!(desc->flags & AV_PIX_FMT_FLAG_XYZ);
- pal = !!(desc->flags & AV_PIX_FMT_FLAG_PAL);
- limited = !rgb && !xyz && !pal && range != AVCOL_RANGE_JPEG;
- alpha = !pal && !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA);
bitstream = !!(desc->flags & AV_PIX_FMT_FLAG_BITSTREAM);
- fltp = !!(desc->flags & AV_PIX_FMT_FLAG_FLOAT);
for (c = 0; c < desc->nb_components; c++) {
const AVComponentDescriptor comp = desc->comp[c];
@@ -623,7 +617,6 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
uint8_t *c_data[4];
const int c_linesize[4] = {0};
uint32_t src_array[MAX_BLOCK_SIZE];
- uint32_t src = 0;
int x;
if (comp.depth > 32)
@@ -631,34 +624,8 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
if (w < 1)
return AVERROR(EINVAL);
- if (pix_fmt == AV_PIX_FMT_MONOWHITE) {
- src = 1;
- } else if (c + 1 == desc->nb_components && alpha) {
- // (Assume even limited YUV uses full range alpha.)
- if (fltp && comp.depth != 16 && comp.depth != 32)
- return AVERROR(EINVAL);
- if (fltp)
- src = (comp.depth == 16 ? 0x3C00 : 0x3F800000); // 1.0
- else
- src = (comp.depth == 32 ? 0 : (1 << comp.depth)) - 1;
- } else if (c == 0 && limited && comp.depth > 1) {
- if (comp.depth < 8 || fltp && comp.depth != 16 && comp.depth != 32)
- return AVERROR(EINVAL);
- if (fltp)
- src = (comp.depth == 16 ? 0x3000 : 0x3D800000); // 0.0625
- else
- src = 16 << (comp.depth - 8);
- } else if ((c == 1 || c == 2) && !rgb && !xyz) {
- if (comp.depth < 8 || fltp && comp.depth != 16 && comp.depth != 32)
- return AVERROR(EINVAL);
- if (fltp)
- src = (comp.depth == 16 ? 0x3800 : 0x3F000000); // 0.5
- else
- src = 128 << (comp.depth - 8);
- }
-
for (x = 0; x < w; x++)
- src_array[x] = src;
+ src_array[x] = color[c];
for (x = 0; x < 4; x++)
c_data[x] = &clear_block[x][0];
@@ -689,3 +656,61 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
return 0;
}
+
+int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
+ enum AVPixelFormat pix_fmt, enum AVColorRange range,
+ int width, int height)
+{
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
+ int nb_planes = av_pix_fmt_count_planes(pix_fmt);
+ int rgb, xyz, pal, limited, alpha, fltp;
+ uint32_t color[4] = {0};
+
+ if (!desc || nb_planes < 1 || nb_planes > 4 || desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
+ return AVERROR(EINVAL);
+
+ rgb = !!(desc->flags & AV_PIX_FMT_FLAG_RGB);
+ xyz = !!(desc->flags & AV_PIX_FMT_FLAG_XYZ);
+ pal = !!(desc->flags & AV_PIX_FMT_FLAG_PAL);
+ limited = !rgb && !xyz && !pal && range != AVCOL_RANGE_JPEG;
+ alpha = !pal && !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA);
+ fltp = !!(desc->flags & AV_PIX_FMT_FLAG_FLOAT);
+
+ for (int c = 0; c < desc->nb_components; c++) {
+ const AVComponentDescriptor comp = desc->comp[c];
+ uint32_t src = 0;
+
+ if (comp.depth > 32)
+ return AVERROR(EINVAL);
+
+ if (pix_fmt == AV_PIX_FMT_MONOWHITE) {
+ src = 1;
+ } else if (c + 1 == desc->nb_components && alpha) {
+ // (Assume even limited YUV uses full range alpha.)
+ if (fltp && comp.depth != 16 && comp.depth != 32)
+ return AVERROR(EINVAL);
+ if (fltp)
+ src = (comp.depth == 16 ? 0x3C00 : 0x3F800000); // 1.0
+ else
+ src = (comp.depth == 32 ? 0 : (1 << comp.depth)) - 1;
+ } else if (c == 0 && limited && comp.depth > 1) {
+ if (comp.depth < 8 || fltp && comp.depth != 16 && comp.depth != 32)
+ return AVERROR(EINVAL);
+ if (fltp)
+ src = (comp.depth == 16 ? 0x3000 : 0x3D800000); // 0.0625
+ else
+ src = 16 << (comp.depth - 8);
+ } else if ((c == 1 || c == 2) && !rgb && !xyz) {
+ if (comp.depth < 8 || fltp && comp.depth != 16 && comp.depth != 32)
+ return AVERROR(EINVAL);
+ if (fltp)
+ src = (comp.depth == 16 ? 0x3800 : 0x3F000000); // 0.5
+ else
+ src = 128 << (comp.depth - 8);
+ }
+
+ color[c] = src;
+ }
+
+ return image_fill_color(dst_data, dst_linesize, pix_fmt, color, width, height);
+}
--
2.35.3
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* [FFmpeg-devel] [PATCH 6/7] avutil/imgutils: add new function av_image_fill_color()
2023-12-03 0:27 [FFmpeg-devel] [PATCH 1/7] avutil/tests/imgutils: factorize basic tests to new function Marton Balint
` (3 preceding siblings ...)
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 5/7] avutil/imgutils: factorize a fill color function Marton Balint
@ 2023-12-03 0:27 ` Marton Balint
2023-12-04 1:07 ` Stefano Sabatini
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 7/7] avcodec: add AV_CODEC_FLAG_CLEAR Marton Balint
2023-12-03 21:31 ` [FFmpeg-devel] [PATCH 1/7] avutil/tests/imgutils: factorize basic tests to new function Stefano Sabatini
6 siblings, 1 reply; 45+ messages in thread
From: Marton Balint @ 2023-12-03 0:27 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marton Balint
Signed-off-by: Marton Balint <cus@passwd.hu>
---
doc/APIchanges | 3 +++
libavutil/imgutils.c | 4 ++--
libavutil/imgutils.h | 30 ++++++++++++++++++++++++++++++
libavutil/version.h | 2 +-
4 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 4a2dc1c44f..b6ac8e08e2 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09
API changes, most recent first:
+2023-12-xx - xxxxxxxxxxx - lavu 58.33.100 - imguils.h
+ Add av_image_fill_color()
+
2023-11-08 - b82957a66a7 - lavu 58.32.100 - channel_layout.h
Add AV_CH_LAYOUT_7POINT2POINT3 and AV_CHANNEL_LAYOUT_7POINT2POINT3.
Add AV_CH_LAYOUT_9POINT1POINT4_BACK and AV_CHANNEL_LAYOUT_9POINT1POINT4_BACK.
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index 959e6850ac..c09848a317 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -579,7 +579,7 @@ static void memset_bytes(uint8_t *dst, size_t dst_size, uint8_t *clear,
// if it's a subsampled packed format).
#define MAX_BLOCK_SIZE 32
-static int image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
+int av_image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
enum AVPixelFormat pix_fmt, const uint32_t color[4],
int width, int height)
{
@@ -712,5 +712,5 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
color[c] = src;
}
- return image_fill_color(dst_data, dst_linesize, pix_fmt, color, width, height);
+ return av_image_fill_color(dst_data, dst_linesize, pix_fmt, color, width, height);
}
diff --git a/libavutil/imgutils.h b/libavutil/imgutils.h
index fa3bb101b1..e047b3a693 100644
--- a/libavutil/imgutils.h
+++ b/libavutil/imgutils.h
@@ -339,6 +339,36 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
enum AVPixelFormat pix_fmt, enum AVColorRange range,
int width, int height);
+/**
+ * Overwrite the image data with a color. This is suitable for filling a
+ * sub-rectangle of an image, meaning the padding between the right most pixel
+ * and the left most pixel on the next line will not be overwritten. For some
+ * formats, the image size might be rounded up due to inherent alignment.
+ *
+ * If the pixel format has alpha, it is also replaced. Color component values
+ * are interpreted as native integers (or intfloats) regardless of actual pixel
+ * format endianness.
+ *
+ * This can return an error if the pixel format is not supported. Normally, all
+ * non-hwaccel pixel formats should be supported.
+ *
+ * Passing NULL for dst_data is allowed. Then the function returns whether the
+ * operation would have succeeded. (It can return an error if the pix_fmt is
+ * not supported.)
+ *
+ * @param dst_data data pointers to destination image
+ * @param dst_linesize linesizes for the destination image
+ * @param pix_fmt the pixel format of the image
+ * @param color the color components to be used for the fill
+ * @param width the width of the image in pixels
+ * @param height the height of the image in pixels
+ * @return 0 if the image data was cleared, a negative AVERROR code otherwise
+ */
+int av_image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
+ enum AVPixelFormat pix_fmt, const uint32_t color[4],
+ int width, int height);
+
+
/**
* @}
*/
diff --git a/libavutil/version.h b/libavutil/version.h
index c5fa7c3692..0684996bf2 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 58
-#define LIBAVUTIL_VERSION_MINOR 32
+#define LIBAVUTIL_VERSION_MINOR 33
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
--
2.35.3
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* [FFmpeg-devel] [PATCH 7/7] avcodec: add AV_CODEC_FLAG_CLEAR
2023-12-03 0:27 [FFmpeg-devel] [PATCH 1/7] avutil/tests/imgutils: factorize basic tests to new function Marton Balint
` (4 preceding siblings ...)
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 6/7] avutil/imgutils: add new function av_image_fill_color() Marton Balint
@ 2023-12-03 0:27 ` Marton Balint
2023-12-03 21:31 ` [FFmpeg-devel] [PATCH 1/7] avutil/tests/imgutils: factorize basic tests to new function Stefano Sabatini
6 siblings, 0 replies; 45+ messages in thread
From: Marton Balint @ 2023-12-03 0:27 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marton Balint
Signed-off-by: Marton Balint <cus@passwd.hu>
---
doc/APIchanges | 3 +++
doc/codecs.texi | 14 ++++++++++++++
libavcodec/avcodec.h | 4 ++++
libavcodec/decode.c | 6 ++++++
libavcodec/options_table.h | 1 +
libavcodec/version.h | 2 +-
6 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index b6ac8e08e2..e411aa0d91 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09
API changes, most recent first:
+2023-12-xx - xxxxxxxxxxx - lavc 60.36.100 - avcodec.h
+ Add AV_CODEC_FLAG_CLEAR.
+
2023-12-xx - xxxxxxxxxxx - lavu 58.33.100 - imguils.h
Add av_image_fill_color()
diff --git a/doc/codecs.texi b/doc/codecs.texi
index 5b950b4560..0504a535f2 100644
--- a/doc/codecs.texi
+++ b/doc/codecs.texi
@@ -76,6 +76,20 @@ Apply interlaced motion estimation.
Use closed gop.
@item output_corrupt
Output even potentially corrupted frames.
+@item clear
+Clear the contents of the video buffer before decoding the next picture to it.
+
+Usually if only a part of a picture is affected by a decode error then the
+decoder (if it implements error concealment) tries to hide it by interpolating
+pixels from neighbouring areas or in some cases from the previous frame. Even
+without error concealment it is quite likely that the affected area will
+contain pixels from an earlier frame, due to frame pooling.
+
+For quality checking this might not be desirable, because it makes the errors
+less noticable. By using this flag, and combining it with disabled error
+concealment (@code{-ec 0}) it is possible to ensure that no leftover data from
+an earlier frame is presented in areas affected by decode errors.
+
@end table
@item time_base @var{rational number}
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7fb44e28f4..97848e942f 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -312,6 +312,10 @@ typedef struct RcOverride{
* loop filter.
*/
#define AV_CODEC_FLAG_LOOP_FILTER (1 << 11)
+/**
+ * Clear frame buffer contents before decoding.
+ */
+#define AV_CODEC_FLAG_CLEAR (1 << 12)
/**
* Only decode/encode grayscale.
*/
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 2cfb3fcf97..f9b18a2c35 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1675,6 +1675,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
validate_avframe_allocation(avctx, frame);
+ if (avctx->flags & AV_CODEC_FLAG_CLEAR && avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
+ uint32_t color[4] = {0};
+ ptrdiff_t linesize[4] = {frame->linesize[0], frame->linesize[1], frame->linesize[2], frame->linesize[3]};
+ av_image_fill_color(frame->data, linesize, frame->format, color, frame->width, frame->height);
+ }
+
ret = ff_attach_decode_data(frame);
if (ret < 0)
goto fail;
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index ee243d9894..46a7d41c18 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -62,6 +62,7 @@ static const AVOption avcodec_options[] = {
{"frame_duration", "use frame durations", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_FRAME_DURATION}, .unit = "flags"},
{"pass1", "use internal 2-pass ratecontrol in first pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PASS1 }, INT_MIN, INT_MAX, 0, "flags"},
{"pass2", "use internal 2-pass ratecontrol in second pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PASS2 }, INT_MIN, INT_MAX, 0, "flags"},
+{"clear", "clear frames before decoding", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_CLEAR }, INT_MIN, INT_MAX, V|E|D, "flags"},
{"gray", "only decode/encode grayscale", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_GRAY }, INT_MIN, INT_MAX, V|E|D, "flags"},
{"psnr", "error[?] variables will be set during encoding", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PSNR }, INT_MIN, INT_MAX, V|E, "flags"},
{"ildct", "use interlaced DCT", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_INTERLACED_DCT }, INT_MIN, INT_MAX, V|E, "flags"},
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 1008fead27..34b059a8a9 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
#include "version_major.h"
-#define LIBAVCODEC_VERSION_MINOR 35
+#define LIBAVCODEC_VERSION_MINOR 36
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
--
2.35.3
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/7] avutil/tests/imgutils: factorize basic tests to new function
2023-12-03 0:27 [FFmpeg-devel] [PATCH 1/7] avutil/tests/imgutils: factorize basic tests to new function Marton Balint
` (5 preceding siblings ...)
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 7/7] avcodec: add AV_CODEC_FLAG_CLEAR Marton Balint
@ 2023-12-03 21:31 ` Stefano Sabatini
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 " Marton Balint
6 siblings, 1 reply; 45+ messages in thread
From: Stefano Sabatini @ 2023-12-03 21:31 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Marton Balint
On date Sunday 2023-12-03 01:27:20 +0100, Marton Balint wrote:
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> libavutil/tests/imgutils.c | 68 ++++++++++++++++++++++----------------
> 1 file changed, 39 insertions(+), 29 deletions(-)
>
> diff --git a/libavutil/tests/imgutils.c b/libavutil/tests/imgutils.c
> index 748bd6c9d2..f3a433ac4a 100644
> --- a/libavutil/tests/imgutils.c
> +++ b/libavutil/tests/imgutils.c
> @@ -19,6 +19,41 @@
> #include "libavutil/imgutils.c"
>
> #undef printf
> +static int basic_tests(enum AVPixelFormat pix_fmt, int w, int h) {
better be descriptive and follow the usual VERB_OBJECT convention,
this might be:
static inst check_image_fill(...)
[...]
LGTM otherwise.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/7] avutil/tests/imgutils: add tests for av_image_fill_black()
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 2/7] avutil/tests/imgutils: add tests for av_image_fill_black() Marton Balint
@ 2023-12-03 23:47 ` Stefano Sabatini
0 siblings, 0 replies; 45+ messages in thread
From: Stefano Sabatini @ 2023-12-03 23:47 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On date Sunday 2023-12-03 01:27:21 +0100, Marton Balint wrote:
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> libavutil/tests/imgutils.c | 60 ++++++++--
> tests/ref/fate/imgutils | 217 +++++++++++++++++++++++++++++++++++++
> 2 files changed, 268 insertions(+), 9 deletions(-)
>
> diff --git a/libavutil/tests/imgutils.c b/libavutil/tests/imgutils.c
> index f3a433ac4a..500d24fdb8 100644
> --- a/libavutil/tests/imgutils.c
> +++ b/libavutil/tests/imgutils.c
> @@ -17,6 +17,7 @@
> */
>
> #include "libavutil/imgutils.c"
> +#include "libavutil/crc.h"
>
> #undef printf
> static int basic_tests(enum AVPixelFormat pix_fmt, int w, int h) {
> @@ -55,9 +56,43 @@ static int basic_tests(enum AVPixelFormat pix_fmt, int w, int h) {
> return 0;
> }
>
> +static int black_tests(const AVPixFmtDescriptor *desc, enum AVPixelFormat pix_fmt, int w, int h)
nit: check_image_fill_black ?
> +{
> + uint8_t *data[4];
> + ptrdiff_t linesizes1[4];
> + int ret, total_size, linesizes[4];
> +
> + if (av_image_fill_linesizes(linesizes, pix_fmt, w) < 0)
> + return -1;
nit: maybe we could store and return ret to give more information
> + total_size = av_image_alloc(data, linesizes, w, h, pix_fmt, 4);
> + if (total_size < 0) {
> + printf("alloc failure");
> + return -1;
ditto
> + }
> + printf("total_size: %6d", total_size);
> + if (desc->flags & AV_PIX_FMT_FLAG_PAL)
> + total_size -= 256 * 4;
> + // Make it non-black by default...
> + memset(data[0], 0xA3, total_size);
> + for (int i = 0; i < 4; i++)
> + linesizes1[i] = linesizes[i];
> + for (enum AVColorRange range = 0; range < AVCOL_RANGE_NB; range++) {
> + ret = av_image_fill_black(data, linesizes1, pix_fmt, range, w, h);
> + printf(", black_%s_crc: ", av_color_range_name(range));
> + if (ret < 0) {
> + printf("----------");
> + } else {
> + const AVCRC *ctx = av_crc_get_table(AV_CRC_32_IEEE_LE);
nit: crc?
> + printf("0x%08"PRIx32, av_crc(ctx, 0, data[0], total_size));
> + }
> + }
> + av_freep(&data[0]);
> +
> + return 0;
> +}
> +
> int main(void)
> {
> - const AVPixFmtDescriptor *desc = NULL;
> int64_t x, y;
>
> for (y = -1; y<UINT_MAX; y+= y/2 + 1) {
> @@ -69,15 +104,22 @@ int main(void)
> }
> printf("\n");
>
> - while (desc = av_pix_fmt_desc_next(desc)) {
> - int w = 64, h = 48;
> - enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(desc);
> + for (int i = 0; i < 2; i++) {
> + printf(i ? "\nblack tests\n" : "basic tests\n");
> + for (const AVPixFmtDescriptor *desc = NULL; desc = av_pix_fmt_desc_next(desc);) {
> + int w = 64, h = 48;
> + enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(desc);
>
> - if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
> - continue;
> - printf("%-16s", desc->name);
> - basic_tests(pix_fmt, w, h);
> - printf("\n");
> + if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
> + continue;
> +
> + printf("%-16s", desc->name);
> + if (i == 0)
> + basic_tests(pix_fmt, w, h);
> + else
> + black_tests(desc, pix_fmt, w, h);
> + printf("\n");
> + }
> }
LGTM otherwise.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH 3/7] avutil/imgutils: fix av_image_fill_black() for some pixel formats
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 3/7] avutil/imgutils: fix av_image_fill_black() for some pixel formats Marton Balint
@ 2023-12-04 0:23 ` Stefano Sabatini
0 siblings, 0 replies; 45+ messages in thread
From: Stefano Sabatini @ 2023-12-04 0:23 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Marton Balint
On date Sunday 2023-12-03 01:27:22 +0100, Marton Balint wrote:
> - Fixes YA formats, because previous code always assumed alpha as the 4th
> component.
> - Fixes PAL format (as long as 0 is black, as in a systematic palette), because
> previous code assumed it as limited Y.
> - Fixes XYZ format because it does not need nonzero chroma components
> - Fixes xv30be as the bitstream mode got merged to the non-bitstream mode.
>
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> libavutil/imgutils.c | 49 +++++++++++++++--------------------------
> tests/ref/fate/imgutils | 14 ++++++------
> 2 files changed, 25 insertions(+), 38 deletions(-)
LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH 4/7] avutil/imgutils: add support for 32bit pixel format for av_image_fill_black()
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 4/7] avutil/imgutils: add support for 32bit pixel format for av_image_fill_black() Marton Balint
@ 2023-12-04 0:52 ` Stefano Sabatini
0 siblings, 0 replies; 45+ messages in thread
From: Stefano Sabatini @ 2023-12-04 0:52 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Marton Balint
On date Sunday 2023-12-03 01:27:23 +0100, Marton Balint wrote:
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> libavutil/imgutils.c | 32 ++++++++++++++++++++++----------
> tests/ref/fate/imgutils | 24 ++++++++++++------------
> 2 files changed, 34 insertions(+), 22 deletions(-)
>
> diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
> index 5e401139c8..26bb2f2c6f 100644
> --- a/libavutil/imgutils.c
> +++ b/libavutil/imgutils.c
> @@ -590,7 +590,7 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
> uint8_t clear_block[4][MAX_BLOCK_SIZE] = {{0}}; // clear padding with 0
> int clear_block_size[4] = {0};
> ptrdiff_t plane_line_bytes[4] = {0};
> - int rgb, xyz, pal, limited, alpha, bitstream;
> + int rgb, xyz, pal, limited, alpha, bitstream, fltp;
> int plane, c;
>
> if (!desc || nb_planes < 1 || nb_planes > 4 || desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
> @@ -602,6 +602,7 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
> limited = !rgb && !xyz && !pal && range != AVCOL_RANGE_JPEG;
> alpha = !pal && !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA);
> bitstream = !!(desc->flags & AV_PIX_FMT_FLAG_BITSTREAM);
> + fltp = !!(desc->flags & AV_PIX_FMT_FLAG_FLOAT);
>
> for (c = 0; c < desc->nb_components; c++) {
> const AVComponentDescriptor comp = desc->comp[c];
> @@ -621,11 +622,11 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
> int w = (bitstream ? 8 : 1) * clear_block_size[comp.plane] / comp.step;
> uint8_t *c_data[4];
> const int c_linesize[4] = {0};
> - uint16_t src_array[MAX_BLOCK_SIZE];
> - uint16_t src = 0;
> + uint32_t src_array[MAX_BLOCK_SIZE];
> + uint32_t src = 0;
> int x;
>
> - if (comp.depth > 16)
> + if (comp.depth > 32)
> return AVERROR(EINVAL);
> if (w < 1)
> return AVERROR(EINVAL);
> @@ -634,15 +635,26 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
> src = 1;
> } else if (c + 1 == desc->nb_components && alpha) {
> // (Assume even limited YUV uses full range alpha.)
> - src = (1 << comp.depth) - 1;
> + if (fltp && comp.depth != 16 && comp.depth != 32)
> + return AVERROR(EINVAL);
nit+: this might be merged in the if (fltp) branch below for clarity
and to avoid a branch
> + if (fltp)
> + src = (comp.depth == 16 ? 0x3C00 : 0x3F800000); // 1.0
> + else
> + src = (comp.depth == 32 ? 0 : (1 << comp.depth)) - 1;
> } else if (c == 0 && limited && comp.depth > 1) {
> - if (comp.depth < 8)
> + if (comp.depth < 8 || fltp && comp.depth != 16 && comp.depth != 32)
nit: use () to group the right hand part of the or, or this might
confuse the human reader
> return AVERROR(EINVAL);
> - src = 16 << (comp.depth - 8);
> + if (fltp)
> + src = (comp.depth == 16 ? 0x3000 : 0x3D800000); // 0.0625
> + else
> + src = 16 << (comp.depth - 8);
> } else if ((c == 1 || c == 2) && !rgb && !xyz) {
> - if (comp.depth < 8)
> + if (comp.depth < 8 || fltp && comp.depth != 16 && comp.depth != 32)
> return AVERROR(EINVAL);
> - src = 128 << (comp.depth - 8);
> + if (fltp)
> + src = (comp.depth == 16 ? 0x3800 : 0x3F000000); // 0.5
> + else
> + src = 128 << (comp.depth - 8);
> }
>
> for (x = 0; x < w; x++)
> @@ -651,7 +663,7 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
> for (x = 0; x < 4; x++)
> c_data[x] = &clear_block[x][0];
>
> - av_write_image_line(src_array, c_data, c_linesize, desc, 0, 0, c, w);
> + av_write_image_line2(src_array, c_data, c_linesize, desc, 0, 0, c, w, 4);
> }
>
LGTM otherwise.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH 5/7] avutil/imgutils: factorize a fill color function
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 5/7] avutil/imgutils: factorize a fill color function Marton Balint
@ 2023-12-04 1:04 ` Stefano Sabatini
0 siblings, 0 replies; 45+ messages in thread
From: Stefano Sabatini @ 2023-12-04 1:04 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Marton Balint
On date Sunday 2023-12-03 01:27:24 +0100, Marton Balint wrote:
> In preparation for making it public.
>
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> libavutil/imgutils.c | 101 +++++++++++++++++++++++++++----------------
> 1 file changed, 63 insertions(+), 38 deletions(-)
>
> diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
> index 26bb2f2c6f..959e6850ac 100644
> --- a/libavutil/imgutils.c
> +++ b/libavutil/imgutils.c
> @@ -579,30 +579,24 @@ static void memset_bytes(uint8_t *dst, size_t dst_size, uint8_t *clear,
> // if it's a subsampled packed format).
> #define MAX_BLOCK_SIZE 32
>
> -int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
> - enum AVPixelFormat pix_fmt, enum AVColorRange range,
> +static int image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
> + enum AVPixelFormat pix_fmt, const uint32_t color[4],
> int width, int height)
> {
> const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
> int nb_planes = av_pix_fmt_count_planes(pix_fmt);
> - // A pixel or a group of pixels on each plane, with a value that represents black.
> + // A pixel or a group of pixels on each plane, with a value that represents the color.
> // Consider e.g. AV_PIX_FMT_UYVY422 for non-trivial cases.
> uint8_t clear_block[4][MAX_BLOCK_SIZE] = {{0}}; // clear padding with 0
> int clear_block_size[4] = {0};
> ptrdiff_t plane_line_bytes[4] = {0};
> - int rgb, xyz, pal, limited, alpha, bitstream, fltp;
> + int bitstream;
> int plane, c;
>
> if (!desc || nb_planes < 1 || nb_planes > 4 || desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
> return AVERROR(EINVAL);
>
> - rgb = !!(desc->flags & AV_PIX_FMT_FLAG_RGB);
> - xyz = !!(desc->flags & AV_PIX_FMT_FLAG_XYZ);
> - pal = !!(desc->flags & AV_PIX_FMT_FLAG_PAL);
> - limited = !rgb && !xyz && !pal && range != AVCOL_RANGE_JPEG;
> - alpha = !pal && !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA);
> bitstream = !!(desc->flags & AV_PIX_FMT_FLAG_BITSTREAM);
> - fltp = !!(desc->flags & AV_PIX_FMT_FLAG_FLOAT);
>
> for (c = 0; c < desc->nb_components; c++) {
> const AVComponentDescriptor comp = desc->comp[c];
> @@ -623,7 +617,6 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
> uint8_t *c_data[4];
> const int c_linesize[4] = {0};
> uint32_t src_array[MAX_BLOCK_SIZE];
> - uint32_t src = 0;
> int x;
>
> if (comp.depth > 32)
> @@ -631,34 +624,8 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
> if (w < 1)
> return AVERROR(EINVAL);
>
> - if (pix_fmt == AV_PIX_FMT_MONOWHITE) {
> - src = 1;
> - } else if (c + 1 == desc->nb_components && alpha) {
> - // (Assume even limited YUV uses full range alpha.)
> - if (fltp && comp.depth != 16 && comp.depth != 32)
> - return AVERROR(EINVAL);
> - if (fltp)
> - src = (comp.depth == 16 ? 0x3C00 : 0x3F800000); // 1.0
> - else
> - src = (comp.depth == 32 ? 0 : (1 << comp.depth)) - 1;
> - } else if (c == 0 && limited && comp.depth > 1) {
> - if (comp.depth < 8 || fltp && comp.depth != 16 && comp.depth != 32)
> - return AVERROR(EINVAL);
> - if (fltp)
> - src = (comp.depth == 16 ? 0x3000 : 0x3D800000); // 0.0625
> - else
> - src = 16 << (comp.depth - 8);
> - } else if ((c == 1 || c == 2) && !rgb && !xyz) {
> - if (comp.depth < 8 || fltp && comp.depth != 16 && comp.depth != 32)
> - return AVERROR(EINVAL);
> - if (fltp)
> - src = (comp.depth == 16 ? 0x3800 : 0x3F000000); // 0.5
> - else
> - src = 128 << (comp.depth - 8);
> - }
> -
> for (x = 0; x < w; x++)
> - src_array[x] = src;
> + src_array[x] = color[c];
>
> for (x = 0; x < 4; x++)
> c_data[x] = &clear_block[x][0];
> @@ -689,3 +656,61 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
>
> return 0;
> }
> +
> +int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
> + enum AVPixelFormat pix_fmt, enum AVColorRange range,
> + int width, int height)
> +{
> + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
> + int nb_planes = av_pix_fmt_count_planes(pix_fmt);
> + int rgb, xyz, pal, limited, alpha, fltp;
> + uint32_t color[4] = {0};
> +
> + if (!desc || nb_planes < 1 || nb_planes > 4 || desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
> + return AVERROR(EINVAL);
> +
> + rgb = !!(desc->flags & AV_PIX_FMT_FLAG_RGB);
> + xyz = !!(desc->flags & AV_PIX_FMT_FLAG_XYZ);
> + pal = !!(desc->flags & AV_PIX_FMT_FLAG_PAL);
> + limited = !rgb && !xyz && !pal && range != AVCOL_RANGE_JPEG;
> + alpha = !pal && !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA);
> + fltp = !!(desc->flags & AV_PIX_FMT_FLAG_FLOAT);
> +
> + for (int c = 0; c < desc->nb_components; c++) {
> + const AVComponentDescriptor comp = desc->comp[c];
> + uint32_t src = 0;
might be renamed in this context, color (color_component)?
[...]
LGTM otherwise.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH 6/7] avutil/imgutils: add new function av_image_fill_color()
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 6/7] avutil/imgutils: add new function av_image_fill_color() Marton Balint
@ 2023-12-04 1:07 ` Stefano Sabatini
0 siblings, 0 replies; 45+ messages in thread
From: Stefano Sabatini @ 2023-12-04 1:07 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Marton Balint
On date Sunday 2023-12-03 01:27:25 +0100, Marton Balint wrote:
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> doc/APIchanges | 3 +++
> libavutil/imgutils.c | 4 ++--
> libavutil/imgutils.h | 30 ++++++++++++++++++++++++++++++
> libavutil/version.h | 2 +-
> 4 files changed, 36 insertions(+), 3 deletions(-)
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 4a2dc1c44f..b6ac8e08e2 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09
>
> API changes, most recent first:
>
> +2023-12-xx - xxxxxxxxxxx - lavu 58.33.100 - imguils.h
imguils typo
> + Add av_image_fill_color()
> +
> 2023-11-08 - b82957a66a7 - lavu 58.32.100 - channel_layout.h
> Add AV_CH_LAYOUT_7POINT2POINT3 and AV_CHANNEL_LAYOUT_7POINT2POINT3.
> Add AV_CH_LAYOUT_9POINT1POINT4_BACK and AV_CHANNEL_LAYOUT_9POINT1POINT4_BACK.
> diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
> index 959e6850ac..c09848a317 100644
> --- a/libavutil/imgutils.c
> +++ b/libavutil/imgutils.c
> @@ -579,7 +579,7 @@ static void memset_bytes(uint8_t *dst, size_t dst_size, uint8_t *clear,
> // if it's a subsampled packed format).
> #define MAX_BLOCK_SIZE 32
>
> -static int image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
> +int av_image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
> enum AVPixelFormat pix_fmt, const uint32_t color[4],
> int width, int height)
> {
> @@ -712,5 +712,5 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
> color[c] = src;
> }
>
> - return image_fill_color(dst_data, dst_linesize, pix_fmt, color, width, height);
> + return av_image_fill_color(dst_data, dst_linesize, pix_fmt, color, width, height);
> }
> diff --git a/libavutil/imgutils.h b/libavutil/imgutils.h
> index fa3bb101b1..e047b3a693 100644
> --- a/libavutil/imgutils.h
> +++ b/libavutil/imgutils.h
> @@ -339,6 +339,36 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
> enum AVPixelFormat pix_fmt, enum AVColorRange range,
> int width, int height);
>
> +/**
> + * Overwrite the image data with a color. This is suitable for filling a
> + * sub-rectangle of an image, meaning the padding between the right most pixel
> + * and the left most pixel on the next line will not be overwritten. For some
> + * formats, the image size might be rounded up due to inherent alignment.
> + *
> + * If the pixel format has alpha, it is also replaced. Color component values
> + * are interpreted as native integers (or intfloats) regardless of actual pixel
> + * format endianness.
> + *
> + * This can return an error if the pixel format is not supported. Normally, all
> + * non-hwaccel pixel formats should be supported.
> + *
> + * Passing NULL for dst_data is allowed. Then the function returns whether the
> + * operation would have succeeded. (It can return an error if the pix_fmt is
> + * not supported.)
> + *
> + * @param dst_data data pointers to destination image
> + * @param dst_linesize linesizes for the destination image
> + * @param pix_fmt the pixel format of the image
> + * @param color the color components to be used for the fill
> + * @param width the width of the image in pixels
> + * @param height the height of the image in pixels
> + * @return 0 if the image data was cleared, a negative AVERROR code otherwise
was filled
> + */
> +int av_image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
> + enum AVPixelFormat pix_fmt, const uint32_t color[4],
> + int width, int height);
LGTM otherwise.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* [FFmpeg-devel] [PATCH v2 1/7] avutil/tests/imgutils: factorize basic tests to new function
2023-12-03 21:31 ` [FFmpeg-devel] [PATCH 1/7] avutil/tests/imgutils: factorize basic tests to new function Stefano Sabatini
@ 2023-12-06 8:22 ` Marton Balint
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 2/7] avutil/tests/imgutils: add tests for av_image_fill_black() Marton Balint
` (6 more replies)
0 siblings, 7 replies; 45+ messages in thread
From: Marton Balint @ 2023-12-06 8:22 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marton Balint
Signed-off-by: Marton Balint <cus@passwd.hu>
---
libavutil/tests/imgutils.c | 68 ++++++++++++++++++++++----------------
1 file changed, 39 insertions(+), 29 deletions(-)
diff --git a/libavutil/tests/imgutils.c b/libavutil/tests/imgutils.c
index 748bd6c9d2..1e2bb3fa01 100644
--- a/libavutil/tests/imgutils.c
+++ b/libavutil/tests/imgutils.c
@@ -19,6 +19,41 @@
#include "libavutil/imgutils.c"
#undef printf
+static int check_image_fill(enum AVPixelFormat pix_fmt, int w, int h) {
+ uint8_t *data[4];
+ size_t sizes[4];
+ ptrdiff_t linesizes1[4], offsets[3] = { 0 };
+ int i, total_size, linesizes[4];
+
+ if (av_image_fill_linesizes(linesizes, pix_fmt, w) < 0)
+ return -1;
+ for (i = 0; i < 4; i++)
+ linesizes1[i] = linesizes[i];
+ if (av_image_fill_plane_sizes(sizes, pix_fmt, h, linesizes1) < 0)
+ return -1;
+ total_size = av_image_fill_pointers(data, pix_fmt, h, (void *)1, linesizes);
+ if (total_size < 0)
+ return -1;
+ for (i = 0; i < 4 && data[i]; i++);
+ printf("planes: %d", i);
+ // Test the output of av_image_fill_linesizes()
+ printf(", linesizes:");
+ for (i = 0; i < 4; i++)
+ printf(" %3d", linesizes[i]);
+ // Test the output of av_image_fill_plane_sizes()
+ printf(", plane_sizes:");
+ for (i = 0; i < 4; i++)
+ printf(" %5"SIZE_SPECIFIER, sizes[i]);
+ // Test the output of av_image_fill_pointers()
+ for (i = 0; i < 3 && data[i + 1]; i++)
+ offsets[i] = data[i + 1] - data[i];
+ printf(", plane_offsets:");
+ for (i = 0; i < 3; i++)
+ printf(" %5"PTRDIFF_SPECIFIER, offsets[i]);
+ printf(", total_size: %d", total_size);
+
+ return 0;
+}
int main(void)
{
@@ -35,39 +70,14 @@ int main(void)
printf("\n");
while (desc = av_pix_fmt_desc_next(desc)) {
- uint8_t *data[4];
- size_t sizes[4];
- ptrdiff_t linesizes1[4], offsets[3] = { 0 };
- int i, total_size, w = 64, h = 48, linesizes[4];
+ int w = 64, h = 48;
enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(desc);
- if (av_image_fill_linesizes(linesizes, pix_fmt, w) < 0)
- continue;
- for (i = 0; i < 4; i++)
- linesizes1[i] = linesizes[i];
- if (av_image_fill_plane_sizes(sizes, pix_fmt, h, linesizes1) < 0)
- continue;
- total_size = av_image_fill_pointers(data, pix_fmt, h, (void *)1, linesizes);
- if (total_size < 0)
+ if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
continue;
printf("%-16s", desc->name);
- for (i = 0; i < 4 && data[i]; i++);
- printf("planes: %d", i);
- // Test the output of av_image_fill_linesizes()
- printf(", linesizes:");
- for (i = 0; i < 4; i++)
- printf(" %3d", linesizes[i]);
- // Test the output of av_image_fill_plane_sizes()
- printf(", plane_sizes:");
- for (i = 0; i < 4; i++)
- printf(" %5"SIZE_SPECIFIER, sizes[i]);
- // Test the output of av_image_fill_pointers()
- for (i = 0; i < 3 && data[i + 1]; i++)
- offsets[i] = data[i + 1] - data[i];
- printf(", plane_offsets:");
- for (i = 0; i < 3; i++)
- printf(" %5"PTRDIFF_SPECIFIER, offsets[i]);
- printf(", total_size: %d\n", total_size);
+ check_image_fill(pix_fmt, w, h);
+ printf("\n");
}
return 0;
--
2.35.3
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* [FFmpeg-devel] [PATCH v2 2/7] avutil/tests/imgutils: add tests for av_image_fill_black()
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 " Marton Balint
@ 2023-12-06 8:22 ` Marton Balint
2023-12-06 22:46 ` Stefano Sabatini
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 3/7] avutil/imgutils: fix av_image_fill_black() for some pixel formats Marton Balint
` (5 subsequent siblings)
6 siblings, 1 reply; 45+ messages in thread
From: Marton Balint @ 2023-12-06 8:22 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marton Balint
Signed-off-by: Marton Balint <cus@passwd.hu>
---
libavutil/tests/imgutils.c | 61 +++++++++--
tests/ref/fate/imgutils | 217 +++++++++++++++++++++++++++++++++++++
2 files changed, 269 insertions(+), 9 deletions(-)
diff --git a/libavutil/tests/imgutils.c b/libavutil/tests/imgutils.c
index 1e2bb3fa01..582a358157 100644
--- a/libavutil/tests/imgutils.c
+++ b/libavutil/tests/imgutils.c
@@ -17,6 +17,7 @@
*/
#include "libavutil/imgutils.c"
+#include "libavutil/crc.h"
#undef printf
static int check_image_fill(enum AVPixelFormat pix_fmt, int w, int h) {
@@ -55,9 +56,44 @@ static int check_image_fill(enum AVPixelFormat pix_fmt, int w, int h) {
return 0;
}
+static int check_image_fill_black(const AVPixFmtDescriptor *desc, enum AVPixelFormat pix_fmt, int w, int h)
+{
+ uint8_t *data[4];
+ ptrdiff_t linesizes1[4];
+ int ret, total_size, linesizes[4];
+
+ ret = av_image_fill_linesizes(linesizes, pix_fmt, w);
+ if (ret < 0)
+ return ret;
+ total_size = av_image_alloc(data, linesizes, w, h, pix_fmt, 4);
+ if (total_size < 0) {
+ printf("alloc failure");
+ return total_size;
+ }
+ printf("total_size: %6d", total_size);
+ if (desc->flags & AV_PIX_FMT_FLAG_PAL)
+ total_size -= 256 * 4;
+ // Make it non-black by default...
+ memset(data[0], 0xA3, total_size);
+ for (int i = 0; i < 4; i++)
+ linesizes1[i] = linesizes[i];
+ for (enum AVColorRange range = 0; range < AVCOL_RANGE_NB; range++) {
+ ret = av_image_fill_black(data, linesizes1, pix_fmt, range, w, h);
+ printf(", black_%s_crc: ", av_color_range_name(range));
+ if (ret < 0) {
+ printf("----------");
+ } else {
+ const AVCRC *crc = av_crc_get_table(AV_CRC_32_IEEE_LE);
+ printf("0x%08"PRIx32, av_crc(crc, 0, data[0], total_size));
+ }
+ }
+ av_freep(&data[0]);
+
+ return 0;
+}
+
int main(void)
{
- const AVPixFmtDescriptor *desc = NULL;
int64_t x, y;
for (y = -1; y<UINT_MAX; y+= y/2 + 1) {
@@ -69,15 +105,22 @@ int main(void)
}
printf("\n");
- while (desc = av_pix_fmt_desc_next(desc)) {
- int w = 64, h = 48;
- enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(desc);
+ for (int i = 0; i < 2; i++) {
+ printf(i ? "\nimage_fill_black tests\n" : "image_fill tests\n");
+ for (const AVPixFmtDescriptor *desc = NULL; desc = av_pix_fmt_desc_next(desc);) {
+ int w = 64, h = 48;
+ enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(desc);
- if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
- continue;
- printf("%-16s", desc->name);
- check_image_fill(pix_fmt, w, h);
- printf("\n");
+ if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
+ continue;
+
+ printf("%-16s", desc->name);
+ if (i == 0)
+ check_image_fill(pix_fmt, w, h);
+ else
+ check_image_fill_black(desc, pix_fmt, w, h);
+ printf("\n");
+ }
}
return 0;
diff --git a/tests/ref/fate/imgutils b/tests/ref/fate/imgutils
index f166cb67fb..f12bef3fb5 100644
--- a/tests/ref/fate/imgutils
+++ b/tests/ref/fate/imgutils
@@ -54,6 +54,7 @@
0000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000
+image_fill tests
yuv420p planes: 3, linesizes: 64 32 32 0, plane_sizes: 3072 768 768 0, plane_offsets: 3072 768 0, total_size: 4608
yuyv422 planes: 1, linesizes: 128 0 0 0, plane_sizes: 6144 0 0 0, plane_offsets: 0 0 0, total_size: 6144
rgb24 planes: 1, linesizes: 192 0 0 0, plane_sizes: 9216 0 0 0, plane_offsets: 0 0 0, total_size: 9216
@@ -268,3 +269,219 @@ p412be planes: 2, linesizes: 128 256 0 0, plane_sizes: 6144 12288
p412le planes: 2, linesizes: 128 256 0 0, plane_sizes: 6144 12288 0 0, plane_offsets: 6144 0 0, total_size: 18432
gbrap14be planes: 4, linesizes: 128 128 128 128, plane_sizes: 6144 6144 6144 6144, plane_offsets: 6144 6144 6144, total_size: 24576
gbrap14le planes: 4, linesizes: 128 128 128 128, plane_sizes: 6144 6144 6144 6144, plane_offsets: 6144 6144 6144, total_size: 24576
+
+image_fill_black tests
+yuv420p total_size: 4608, black_unknown_crc: 0xd00f6cc6, black_tv_crc: 0xd00f6cc6, black_pc_crc: 0x234969af
+yuyv422 total_size: 6144, black_unknown_crc: 0xcb089fb0, black_tv_crc: 0xcb089fb0, black_pc_crc: 0xc9dc3ddf
+rgb24 total_size: 9216, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bgr24 total_size: 9216, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+yuv422p total_size: 6144, black_unknown_crc: 0x71fcc79c, black_tv_crc: 0x71fcc79c, black_pc_crc: 0xa9fa0192
+yuv444p total_size: 9216, black_unknown_crc: 0x1c302b58, black_tv_crc: 0x1c302b58, black_pc_crc: 0xdf792ea7
+yuv410p total_size: 3456, black_unknown_crc: 0x09f3e4b0, black_tv_crc: 0x09f3e4b0, black_pc_crc: 0xe4f4e553
+yuv411p total_size: 4608, black_unknown_crc: 0xd00f6cc6, black_tv_crc: 0xd00f6cc6, black_pc_crc: 0x234969af
+gray total_size: 3072, black_unknown_crc: 0x63e301a2, black_tv_crc: 0x63e301a2, black_pc_crc: 0x00000000
+monow total_size: 384, black_unknown_crc: 0x1ba3e150, black_tv_crc: 0x1ba3e150, black_pc_crc: 0x1ba3e150
+monob total_size: 384, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+pal8 total_size: 4096, black_unknown_crc: 0x63e301a2, black_tv_crc: 0x63e301a2, black_pc_crc: 0x00000000
+yuvj420p total_size: 4608, black_unknown_crc: 0xd00f6cc6, black_tv_crc: 0xd00f6cc6, black_pc_crc: 0x234969af
+yuvj422p total_size: 6144, black_unknown_crc: 0x71fcc79c, black_tv_crc: 0x71fcc79c, black_pc_crc: 0xa9fa0192
+yuvj444p total_size: 9216, black_unknown_crc: 0x1c302b58, black_tv_crc: 0x1c302b58, black_pc_crc: 0xdf792ea7
+uyvy422 total_size: 6144, black_unknown_crc: 0xaf9476bb, black_tv_crc: 0xaf9476bb, black_pc_crc: 0x16a51378
+uyyvyy411 total_size: 4608, black_unknown_crc: 0x6f8b7288, black_tv_crc: 0x6f8b7288, black_pc_crc: 0x9f9c5552
+bgr8 total_size: 3072, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bgr4 total_size: 1536, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bgr4_byte total_size: 3072, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgb8 total_size: 3072, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgb4 total_size: 1536, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgb4_byte total_size: 3072, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+nv12 total_size: 4608, black_unknown_crc: 0xd00f6cc6, black_tv_crc: 0xd00f6cc6, black_pc_crc: 0x234969af
+nv21 total_size: 4608, black_unknown_crc: 0xd00f6cc6, black_tv_crc: 0xd00f6cc6, black_pc_crc: 0x234969af
+argb total_size: 12288, black_unknown_crc: 0x97f3518e, black_tv_crc: 0x97f3518e, black_pc_crc: 0x97f3518e
+rgba total_size: 12288, black_unknown_crc: 0xf15ae524, black_tv_crc: 0xf15ae524, black_pc_crc: 0xf15ae524
+abgr total_size: 12288, black_unknown_crc: 0x97f3518e, black_tv_crc: 0x97f3518e, black_pc_crc: 0x97f3518e
+bgra total_size: 12288, black_unknown_crc: 0xf15ae524, black_tv_crc: 0xf15ae524, black_pc_crc: 0xf15ae524
+gray16be total_size: 6144, black_unknown_crc: 0x02d4a26f, black_tv_crc: 0x02d4a26f, black_pc_crc: 0x00000000
+gray16le total_size: 6144, black_unknown_crc: 0xb93165c3, black_tv_crc: 0xb93165c3, black_pc_crc: 0x00000000
+yuv440p total_size: 6144, black_unknown_crc: 0x71fcc79c, black_tv_crc: 0x71fcc79c, black_pc_crc: 0xa9fa0192
+yuvj440p total_size: 6144, black_unknown_crc: 0x71fcc79c, black_tv_crc: 0x71fcc79c, black_pc_crc: 0xa9fa0192
+yuva420p total_size: 7680, black_unknown_crc: 0x0bcc140f, black_tv_crc: 0x0bcc140f, black_pc_crc: 0xa724ab23
+rgb48be total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgb48le total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgb565be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgb565le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgb555be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgb555le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bgr565be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bgr565le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bgr555be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bgr555le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+yuv420p16le total_size: 9216, black_unknown_crc: 0xfff85b60, black_tv_crc: 0xfff85b60, black_pc_crc: 0xc03cff93
+yuv420p16be total_size: 9216, black_unknown_crc: 0x4d4d9903, black_tv_crc: 0x4d4d9903, black_pc_crc: 0x69c6fe01
+yuv422p16le total_size: 12288, black_unknown_crc: 0x6582d6cf, black_tv_crc: 0x6582d6cf, black_pc_crc: 0xc9dc3ddf
+yuv422p16be total_size: 12288, black_unknown_crc: 0x0bbe5df7, black_tv_crc: 0x0bbe5df7, black_pc_crc: 0x16a51378
+yuv444p16le total_size: 18432, black_unknown_crc: 0x4028ac30, black_tv_crc: 0x4028ac30, black_pc_crc: 0xab7c7698
+yuv444p16be total_size: 18432, black_unknown_crc: 0x26991800, black_tv_crc: 0x26991800, black_pc_crc: 0xfe7f6700
+rgb444le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgb444be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bgr444le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bgr444be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+ya8 total_size: 6144, black_unknown_crc: 0xcb089fb0, black_tv_crc: 0xcb089fb0, black_pc_crc: 0xc9dc3ddf
+bgr48be total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bgr48le total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+yuv420p9be total_size: 9216, black_unknown_crc: 0x9154a536, black_tv_crc: 0x9154a536, black_pc_crc: 0xeeddecd0
+yuv420p9le total_size: 9216, black_unknown_crc: 0x9a9b3206, black_tv_crc: 0x9a9b3206, black_pc_crc: 0xd38dfc02
+yuv420p10be total_size: 9216, black_unknown_crc: 0xf9d84c2d, black_tv_crc: 0xf9d84c2d, black_pc_crc: 0x06cadfe1
+yuv420p10le total_size: 9216, black_unknown_crc: 0xee47624d, black_tv_crc: 0xee47624d, black_pc_crc: 0x7c6afe45
+yuv422p10be total_size: 12288, black_unknown_crc: 0x7cb8d0b6, black_tv_crc: 0x7cb8d0b6, black_pc_crc: 0xa0507635
+yuv422p10le total_size: 12288, black_unknown_crc: 0x2ef977dc, black_tv_crc: 0x2ef977dc, black_pc_crc: 0x5a944de0
+yuv444p9be total_size: 18432, black_unknown_crc: 0x0c244ddf, black_tv_crc: 0x0c244ddf, black_pc_crc: 0x01fcfece
+yuv444p9le total_size: 18432, black_unknown_crc: 0x4d323000, black_tv_crc: 0x4d323000, black_pc_crc: 0x278fc841
+yuv444p10be total_size: 18432, black_unknown_crc: 0x18489bbe, black_tv_crc: 0x18489bbe, black_pc_crc: 0x03f9fd9c
+yuv444p10le total_size: 18432, black_unknown_crc: 0x9a646000, black_tv_crc: 0x9a646000, black_pc_crc: 0x4f1f9082
+yuv422p9be total_size: 12288, black_unknown_crc: 0x3e5c685b, black_tv_crc: 0x3e5c685b, black_pc_crc: 0xbd90b83a
+yuv422p9le total_size: 12288, black_unknown_crc: 0x177cbbee, black_tv_crc: 0x177cbbee, black_pc_crc: 0x2d4a26f0
+gbrp total_size: 9216, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+gbrp9be total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+gbrp9le total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+gbrp10be total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+gbrp10le total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+gbrp16be total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+gbrp16le total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+yuva422p total_size: 9216, black_unknown_crc: 0x6fa9db98, black_tv_crc: 0x6fa9db98, black_pc_crc: 0xace0de67
+yuva444p total_size: 12288, black_unknown_crc: 0x72114eba, black_tv_crc: 0x72114eba, black_pc_crc: 0x001deeda
+yuva420p9be total_size: 15360, black_unknown_crc: 0x47717974, black_tv_crc: 0x47717974, black_pc_crc: 0xf485b36d
+yuva420p9le total_size: 15360, black_unknown_crc: 0xe23950ad, black_tv_crc: 0xe23950ad, black_pc_crc: 0x86e10ca7
+yuva422p9be total_size: 18432, black_unknown_crc: 0x2f5a84da, black_tv_crc: 0x2f5a84da, black_pc_crc: 0x228237cb
+yuva422p9le total_size: 18432, black_unknown_crc: 0x3d7bba46, black_tv_crc: 0x3d7bba46, black_pc_crc: 0x57c64207
+yuva444p9be total_size: 24576, black_unknown_crc: 0x12aed20d, black_tv_crc: 0x12aed20d, black_pc_crc: 0x2f0c503b
+yuva444p9le total_size: 24576, black_unknown_crc: 0x7b4cbb96, black_tv_crc: 0x7b4cbb96, black_pc_crc: 0xb4cb8c8d
+yuva420p10be total_size: 15360, black_unknown_crc: 0x56f111dd, black_tv_crc: 0x56f111dd, black_pc_crc: 0xea6983ae
+yuva420p10le total_size: 15360, black_unknown_crc: 0xa2931f21, black_tv_crc: 0xa2931f21, black_pc_crc: 0x6b23a735
+yuva422p10be total_size: 18432, black_unknown_crc: 0x86a6ea81, black_tv_crc: 0x86a6ea81, black_pc_crc: 0x9d178ca3
+yuva422p10le total_size: 18432, black_unknown_crc: 0xc767ccb6, black_tv_crc: 0xc767ccb6, black_pc_crc: 0x121c3c34
+yuva444p10be total_size: 24576, black_unknown_crc: 0xfd4e472f, black_tv_crc: 0xfd4e472f, black_pc_crc: 0x860b4343
+yuva444p10le total_size: 24576, black_unknown_crc: 0x4b09cf16, black_tv_crc: 0x4b09cf16, black_pc_crc: 0x0f76a761
+yuva420p16be total_size: 15360, black_unknown_crc: 0xe112be6e, black_tv_crc: 0xe112be6e, black_pc_crc: 0xd37e906b
+yuva420p16le total_size: 15360, black_unknown_crc: 0xcbc146fa, black_tv_crc: 0xcbc146fa, black_pc_crc: 0x7f83a0d6
+yuva422p16be total_size: 18432, black_unknown_crc: 0x630b483b, black_tv_crc: 0x630b483b, black_pc_crc: 0xbbed373b
+yuva422p16le total_size: 18432, black_unknown_crc: 0xdac3d2ac, black_tv_crc: 0xdac3d2ac, black_pc_crc: 0x31970804
+yuva444p16be total_size: 24576, black_unknown_crc: 0x4010c8d3, black_tv_crc: 0x4010c8d3, black_pc_crc: 0xca6bd07e
+yuva444p16le total_size: 24576, black_unknown_crc: 0x1824855b, black_tv_crc: 0x1824855b, black_pc_crc: 0x06f5c440
+xyz12le total_size: 18432, black_unknown_crc: 0x24c4432b, black_tv_crc: 0x24c4432b, black_pc_crc: 0xfe5a7889
+xyz12be total_size: 18432, black_unknown_crc: 0xac983d03, black_tv_crc: 0xac983d03, black_pc_crc: 0x949a61fc
+nv16 total_size: 6144, black_unknown_crc: 0x71fcc79c, black_tv_crc: 0x71fcc79c, black_pc_crc: 0xa9fa0192
+nv20le total_size: 12288, black_unknown_crc: 0x2ef977dc, black_tv_crc: 0x2ef977dc, black_pc_crc: 0x5a944de0
+nv20be total_size: 12288, black_unknown_crc: 0x7cb8d0b6, black_tv_crc: 0x7cb8d0b6, black_pc_crc: 0xa0507635
+rgba64be total_size: 24576, black_unknown_crc: 0x0ab5caf6, black_tv_crc: 0x0ab5caf6, black_pc_crc: 0x0ab5caf6
+rgba64le total_size: 24576, black_unknown_crc: 0x0ab5caf6, black_tv_crc: 0x0ab5caf6, black_pc_crc: 0x0ab5caf6
+bgra64be total_size: 24576, black_unknown_crc: 0x0ab5caf6, black_tv_crc: 0x0ab5caf6, black_pc_crc: 0x0ab5caf6
+bgra64le total_size: 24576, black_unknown_crc: 0x0ab5caf6, black_tv_crc: 0x0ab5caf6, black_pc_crc: 0x0ab5caf6
+yvyu422 total_size: 6144, black_unknown_crc: 0xcb089fb0, black_tv_crc: 0xcb089fb0, black_pc_crc: 0xc9dc3ddf
+ya16be total_size: 12288, black_unknown_crc: 0x5483d935, black_tv_crc: 0x5483d935, black_pc_crc: 0x06397bf3
+ya16le total_size: 12288, black_unknown_crc: 0x5d8e1cf6, black_tv_crc: 0x5d8e1cf6, black_pc_crc: 0x8fceec45
+gbrap total_size: 12288, black_unknown_crc: 0xda63f152, black_tv_crc: 0xda63f152, black_pc_crc: 0xda63f152
+gbrap16be total_size: 24576, black_unknown_crc: 0x53374343, black_tv_crc: 0x53374343, black_pc_crc: 0x53374343
+gbrap16le total_size: 24576, black_unknown_crc: 0x53374343, black_tv_crc: 0x53374343, black_pc_crc: 0x53374343
+0rgb total_size: 12288, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgb0 total_size: 12288, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+0bgr total_size: 12288, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bgr0 total_size: 12288, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+yuv420p12be total_size: 9216, black_unknown_crc: 0x220de93c, black_tv_crc: 0x220de93c, black_pc_crc: 0x1b2b7f84
+yuv420p12le total_size: 9216, black_unknown_crc: 0x0fff85b6, black_tv_crc: 0x0fff85b6, black_pc_crc: 0x2adaff55
+yuv420p14be total_size: 9216, black_unknown_crc: 0x8837a4f0, black_tv_crc: 0x8837a4f0, black_pc_crc: 0x6cadfe10
+yuv420p14le total_size: 9216, black_unknown_crc: 0x3ffe16d8, black_tv_crc: 0x3ffe16d8, black_pc_crc: 0xab6bfd54
+yuv422p12be total_size: 12288, black_unknown_crc: 0x50be94e3, black_tv_crc: 0x50be94e3, black_pc_crc: 0xecd2d217
+yuv422p12le total_size: 12288, black_unknown_crc: 0xbbe5df70, black_tv_crc: 0xbbe5df70, black_pc_crc: 0xb12031c1
+yuv422p14be total_size: 12288, black_unknown_crc: 0x998b55cd, black_tv_crc: 0x998b55cd, black_pc_crc: 0x05a944de
+yuv422p14le total_size: 12288, black_unknown_crc: 0x82047703, black_tv_crc: 0x82047703, black_pc_crc: 0xa913cdc7
+yuv444p12be total_size: 18432, black_unknown_crc: 0x02699180, black_tv_crc: 0x02699180, black_pc_crc: 0x0fe7f670
+yuv444p12le total_size: 18432, black_unknown_crc: 0x04028ac3, black_tv_crc: 0x04028ac3, black_pc_crc: 0xe70f4449
+yuv444p14be total_size: 18432, black_unknown_crc: 0x09a64600, black_tv_crc: 0x09a64600, black_pc_crc: 0x3f9fd9c0
+yuv444p14le total_size: 18432, black_unknown_crc: 0x100a2b0c, black_tv_crc: 0x100a2b0c, black_pc_crc: 0x2adf1da6
+gbrp12be total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+gbrp12le total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+gbrp14be total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+gbrp14le total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+yuvj411p total_size: 4608, black_unknown_crc: 0xd00f6cc6, black_tv_crc: 0xd00f6cc6, black_pc_crc: 0x234969af
+bayer_bggr8 total_size: 3072, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bayer_rggb8 total_size: 3072, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bayer_gbrg8 total_size: 3072, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bayer_grbg8 total_size: 3072, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bayer_bggr16le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bayer_bggr16be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bayer_rggb16le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bayer_rggb16be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bayer_gbrg16le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bayer_gbrg16be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bayer_grbg16le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+bayer_grbg16be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+yuv440p10le total_size: 12288, black_unknown_crc: 0x2ef977dc, black_tv_crc: 0x2ef977dc, black_pc_crc: 0x5a944de0
+yuv440p10be total_size: 12288, black_unknown_crc: 0x7cb8d0b6, black_tv_crc: 0x7cb8d0b6, black_pc_crc: 0xa0507635
+yuv440p12le total_size: 12288, black_unknown_crc: 0xbbe5df70, black_tv_crc: 0xbbe5df70, black_pc_crc: 0xb12031c1
+yuv440p12be total_size: 12288, black_unknown_crc: 0x50be94e3, black_tv_crc: 0x50be94e3, black_pc_crc: 0xecd2d217
+ayuv64le total_size: 24576, black_unknown_crc: 0xcb441ee4, black_tv_crc: 0xcb441ee4, black_pc_crc: 0x48ba1e8d
+ayuv64be total_size: 24576, black_unknown_crc: 0xe0be064e, black_tv_crc: 0xe0be064e, black_pc_crc: 0xd45321b2
+p010le total_size: 9216, black_unknown_crc: 0xfff85b60, black_tv_crc: 0xfff85b60, black_pc_crc: 0xc03cff93
+p010be total_size: 9216, black_unknown_crc: 0x4d4d9903, black_tv_crc: 0x4d4d9903, black_pc_crc: 0x69c6fe01
+gbrap12be total_size: 24576, black_unknown_crc: 0x49bd3f36, black_tv_crc: 0x49bd3f36, black_pc_crc: 0x49bd3f36
+gbrap12le total_size: 24576, black_unknown_crc: 0x039f4b57, black_tv_crc: 0x039f4b57, black_pc_crc: 0x039f4b57
+gbrap10be total_size: 24576, black_unknown_crc: 0x3ebe070a, black_tv_crc: 0x3ebe070a, black_pc_crc: 0x3ebe070a
+gbrap10le total_size: 24576, black_unknown_crc: 0x0797e156, black_tv_crc: 0x0797e156, black_pc_crc: 0x0797e156
+gray12be total_size: 6144, black_unknown_crc: 0xbd90b83a, black_tv_crc: 0xbd90b83a, black_pc_crc: 0x00000000
+gray12le total_size: 6144, black_unknown_crc: 0x2d4a26f0, black_tv_crc: 0x2d4a26f0, black_pc_crc: 0x00000000
+gray10be total_size: 6144, black_unknown_crc: 0x89569dcf, black_tv_crc: 0x89569dcf, black_pc_crc: 0x00000000
+gray10le total_size: 6144, black_unknown_crc: 0x0b5289bc, black_tv_crc: 0x0b5289bc, black_pc_crc: 0x00000000
+p016le total_size: 9216, black_unknown_crc: 0xfff85b60, black_tv_crc: 0xfff85b60, black_pc_crc: 0xc03cff93
+p016be total_size: 9216, black_unknown_crc: 0x4d4d9903, black_tv_crc: 0x4d4d9903, black_pc_crc: 0x69c6fe01
+gray9be total_size: 6144, black_unknown_crc: 0xa913cdc7, black_tv_crc: 0xa913cdc7, black_pc_crc: 0x00000000
+gray9le total_size: 6144, black_unknown_crc: 0x05a944de, black_tv_crc: 0x05a944de, black_pc_crc: 0x00000000
+gbrpf32be total_size: 36864, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+gbrpf32le total_size: 36864, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+gbrapf32be total_size: 49152, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+gbrapf32le total_size: 49152, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+gray14be total_size: 6144, black_unknown_crc: 0x9bd1ea2b, black_tv_crc: 0x9bd1ea2b, black_pc_crc: 0x00000000
+gray14le total_size: 6144, black_unknown_crc: 0xb5289bc0, black_tv_crc: 0xb5289bc0, black_pc_crc: 0x00000000
+grayf32be total_size: 12288, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+grayf32le total_size: 12288, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+yuva422p12be total_size: 18432, black_unknown_crc: 0xa7067ca1, black_tv_crc: 0xa7067ca1, black_pc_crc: 0xaa881b51
+yuva422p12le total_size: 18432, black_unknown_crc: 0xb6bdf055, black_tv_crc: 0xb6bdf055, black_pc_crc: 0x55b03edf
+yuva444p12be total_size: 24576, black_unknown_crc: 0x488f478f, black_tv_crc: 0x488f478f, black_pc_crc: 0xc6fb24d1
+yuva444p12le total_size: 24576, black_unknown_crc: 0xea96f416, black_tv_crc: 0xea96f416, black_pc_crc: 0x201a538b
+nv24 total_size: 9216, black_unknown_crc: 0x1c302b58, black_tv_crc: 0x1c302b58, black_pc_crc: 0xdf792ea7
+nv42 total_size: 9216, black_unknown_crc: 0x1c302b58, black_tv_crc: 0x1c302b58, black_pc_crc: 0xdf792ea7
+y210be total_size: 12288, black_unknown_crc: 0x5483d935, black_tv_crc: 0x5483d935, black_pc_crc: 0x06397bf3
+y210le total_size: 12288, black_unknown_crc: 0x5d8e1cf6, black_tv_crc: 0x5d8e1cf6, black_pc_crc: 0x8fceec45
+x2rgb10le total_size: 12288, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+x2rgb10be total_size: 12288, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+x2bgr10le total_size: 12288, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+x2bgr10be total_size: 12288, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+p210be total_size: 12288, black_unknown_crc: 0x0bbe5df7, black_tv_crc: 0x0bbe5df7, black_pc_crc: 0x16a51378
+p210le total_size: 12288, black_unknown_crc: 0x6582d6cf, black_tv_crc: 0x6582d6cf, black_pc_crc: 0xc9dc3ddf
+p410be total_size: 18432, black_unknown_crc: 0x26991800, black_tv_crc: 0x26991800, black_pc_crc: 0xfe7f6700
+p410le total_size: 18432, black_unknown_crc: 0x4028ac30, black_tv_crc: 0x4028ac30, black_pc_crc: 0xab7c7698
+p216be total_size: 12288, black_unknown_crc: 0x0bbe5df7, black_tv_crc: 0x0bbe5df7, black_pc_crc: 0x16a51378
+p216le total_size: 12288, black_unknown_crc: 0x6582d6cf, black_tv_crc: 0x6582d6cf, black_pc_crc: 0xc9dc3ddf
+p416be total_size: 18432, black_unknown_crc: 0x26991800, black_tv_crc: 0x26991800, black_pc_crc: 0xfe7f6700
+p416le total_size: 18432, black_unknown_crc: 0x4028ac30, black_tv_crc: 0x4028ac30, black_pc_crc: 0xab7c7698
+vuya total_size: 12288, black_unknown_crc: 0x60db2d2c, black_tv_crc: 0x60db2d2c, black_pc_crc: 0x2dae630a
+rgbaf16be total_size: 24576, black_unknown_crc: 0x0ab5caf6, black_tv_crc: 0x0ab5caf6, black_pc_crc: 0x0ab5caf6
+rgbaf16le total_size: 24576, black_unknown_crc: 0x0ab5caf6, black_tv_crc: 0x0ab5caf6, black_pc_crc: 0x0ab5caf6
+vuyx total_size: 12288, black_unknown_crc: 0x9181c808, black_tv_crc: 0x9181c808, black_pc_crc: 0xdcf4862e
+p012le total_size: 9216, black_unknown_crc: 0xfff85b60, black_tv_crc: 0xfff85b60, black_pc_crc: 0xc03cff93
+p012be total_size: 9216, black_unknown_crc: 0x4d4d9903, black_tv_crc: 0x4d4d9903, black_pc_crc: 0x69c6fe01
+y212be total_size: 12288, black_unknown_crc: 0x5483d935, black_tv_crc: 0x5483d935, black_pc_crc: 0x06397bf3
+y212le total_size: 12288, black_unknown_crc: 0x5d8e1cf6, black_tv_crc: 0x5d8e1cf6, black_pc_crc: 0x8fceec45
+xv30be total_size: 12288, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+xv30le total_size: 12288, black_unknown_crc: 0x4bb0b075, black_tv_crc: 0x4bb0b075, black_pc_crc: 0x02d585cf
+xv36be total_size: 24576, black_unknown_crc: 0x6ba828bd, black_tv_crc: 0x6ba828bd, black_pc_crc: 0x5f450f41
+xv36le total_size: 24576, black_unknown_crc: 0xc3794950, black_tv_crc: 0xc3794950, black_pc_crc: 0x40874939
+rgbf32be total_size: 36864, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+rgbf32le total_size: 36864, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+rgbaf32be total_size: 49152, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+rgbaf32le total_size: 49152, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+p212be total_size: 12288, black_unknown_crc: 0x0bbe5df7, black_tv_crc: 0x0bbe5df7, black_pc_crc: 0x16a51378
+p212le total_size: 12288, black_unknown_crc: 0x6582d6cf, black_tv_crc: 0x6582d6cf, black_pc_crc: 0xc9dc3ddf
+p412be total_size: 18432, black_unknown_crc: 0x26991800, black_tv_crc: 0x26991800, black_pc_crc: 0xfe7f6700
+p412le total_size: 18432, black_unknown_crc: 0x4028ac30, black_tv_crc: 0x4028ac30, black_pc_crc: 0xab7c7698
+gbrap14be total_size: 24576, black_unknown_crc: 0x4ec0d987, black_tv_crc: 0x4ec0d987, black_pc_crc: 0x4ec0d987
+gbrap14le total_size: 24576, black_unknown_crc: 0x13bde353, black_tv_crc: 0x13bde353, black_pc_crc: 0x13bde353
--
2.35.3
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* [FFmpeg-devel] [PATCH v2 3/7] avutil/imgutils: fix av_image_fill_black() for some pixel formats
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 " Marton Balint
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 2/7] avutil/tests/imgutils: add tests for av_image_fill_black() Marton Balint
@ 2023-12-06 8:22 ` Marton Balint
2023-12-06 22:47 ` Stefano Sabatini
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 4/7] avutil/imgutils: add support for 32bit pixel format for av_image_fill_black() Marton Balint
` (4 subsequent siblings)
6 siblings, 1 reply; 45+ messages in thread
From: Marton Balint @ 2023-12-06 8:22 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marton Balint
- Fixes YA formats, because previous code always assumed alpha as the 4th
component.
- Fixes PAL format (as long as 0 is black, as in a systematic palette), because
previous code assumed it as limited Y.
- Fixes XYZ format because it does not need nonzero chroma components
- Fixes xv30be as the bitstream mode got merged to the non-bitstream mode.
Signed-off-by: Marton Balint <cus@passwd.hu>
---
libavutil/imgutils.c | 49 +++++++++++++++--------------------------
tests/ref/fate/imgutils | 14 ++++++------
2 files changed, 25 insertions(+), 38 deletions(-)
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index da3812698e..5e401139c8 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -590,35 +590,18 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
uint8_t clear_block[4][MAX_BLOCK_SIZE] = {{0}}; // clear padding with 0
int clear_block_size[4] = {0};
ptrdiff_t plane_line_bytes[4] = {0};
- int rgb, limited;
+ int rgb, xyz, pal, limited, alpha, bitstream;
int plane, c;
if (!desc || nb_planes < 1 || nb_planes > 4 || desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
return AVERROR(EINVAL);
rgb = !!(desc->flags & AV_PIX_FMT_FLAG_RGB);
- limited = !rgb && range != AVCOL_RANGE_JPEG;
-
- if (desc->flags & AV_PIX_FMT_FLAG_BITSTREAM) {
- ptrdiff_t bytewidth = av_image_get_linesize(pix_fmt, width, 0);
- uint8_t *data;
- int mono = pix_fmt == AV_PIX_FMT_MONOWHITE || pix_fmt == AV_PIX_FMT_MONOBLACK;
- int fill = pix_fmt == AV_PIX_FMT_MONOWHITE ? 0xFF : 0;
- if (nb_planes != 1 || !(rgb || mono) || bytewidth < 1)
- return AVERROR(EINVAL);
-
- if (!dst_data)
- return 0;
-
- data = dst_data[0];
-
- // (Bitstream + alpha will be handled incorrectly - it'll remain transparent.)
- for (;height > 0; height--) {
- memset(data, fill, bytewidth);
- data += dst_linesize[0];
- }
- return 0;
- }
+ xyz = !!(desc->flags & AV_PIX_FMT_FLAG_XYZ);
+ pal = !!(desc->flags & AV_PIX_FMT_FLAG_PAL);
+ limited = !rgb && !xyz && !pal && range != AVCOL_RANGE_JPEG;
+ alpha = !pal && !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA);
+ bitstream = !!(desc->flags & AV_PIX_FMT_FLAG_BITSTREAM);
for (c = 0; c < desc->nb_components; c++) {
const AVComponentDescriptor comp = desc->comp[c];
@@ -635,7 +618,7 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
for (c = 0; c < desc->nb_components; c++) {
const AVComponentDescriptor comp = desc->comp[c];
// (Multiple pixels happen e.g. with AV_PIX_FMT_UYVY422.)
- int w = clear_block_size[comp.plane] / comp.step;
+ int w = (bitstream ? 8 : 1) * clear_block_size[comp.plane] / comp.step;
uint8_t *c_data[4];
const int c_linesize[4] = {0};
uint16_t src_array[MAX_BLOCK_SIZE];
@@ -644,18 +627,22 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
if (comp.depth > 16)
return AVERROR(EINVAL);
- if (!rgb && comp.depth < 8)
- return AVERROR(EINVAL);
if (w < 1)
return AVERROR(EINVAL);
- if (c == 0 && limited) {
- src = 16 << (comp.depth - 8);
- } else if ((c == 1 || c == 2) && !rgb) {
- src = 128 << (comp.depth - 8);
- } else if (c == 3) {
+ if (pix_fmt == AV_PIX_FMT_MONOWHITE) {
+ src = 1;
+ } else if (c + 1 == desc->nb_components && alpha) {
// (Assume even limited YUV uses full range alpha.)
src = (1 << comp.depth) - 1;
+ } else if (c == 0 && limited && comp.depth > 1) {
+ if (comp.depth < 8)
+ return AVERROR(EINVAL);
+ src = 16 << (comp.depth - 8);
+ } else if ((c == 1 || c == 2) && !rgb && !xyz) {
+ if (comp.depth < 8)
+ return AVERROR(EINVAL);
+ src = 128 << (comp.depth - 8);
}
for (x = 0; x < w; x++)
diff --git a/tests/ref/fate/imgutils b/tests/ref/fate/imgutils
index f12bef3fb5..c31bc38d77 100644
--- a/tests/ref/fate/imgutils
+++ b/tests/ref/fate/imgutils
@@ -282,7 +282,7 @@ yuv411p total_size: 4608, black_unknown_crc: 0xd00f6cc6, black_tv_cr
gray total_size: 3072, black_unknown_crc: 0x63e301a2, black_tv_crc: 0x63e301a2, black_pc_crc: 0x00000000
monow total_size: 384, black_unknown_crc: 0x1ba3e150, black_tv_crc: 0x1ba3e150, black_pc_crc: 0x1ba3e150
monob total_size: 384, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
-pal8 total_size: 4096, black_unknown_crc: 0x63e301a2, black_tv_crc: 0x63e301a2, black_pc_crc: 0x00000000
+pal8 total_size: 4096, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
yuvj420p total_size: 4608, black_unknown_crc: 0xd00f6cc6, black_tv_crc: 0xd00f6cc6, black_pc_crc: 0x234969af
yuvj422p total_size: 6144, black_unknown_crc: 0x71fcc79c, black_tv_crc: 0x71fcc79c, black_pc_crc: 0xa9fa0192
yuvj444p total_size: 9216, black_unknown_crc: 0x1c302b58, black_tv_crc: 0x1c302b58, black_pc_crc: 0xdf792ea7
@@ -325,7 +325,7 @@ rgb444le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_cr
rgb444be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
bgr444le total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
bgr444be total_size: 6144, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
-ya8 total_size: 6144, black_unknown_crc: 0xcb089fb0, black_tv_crc: 0xcb089fb0, black_pc_crc: 0xc9dc3ddf
+ya8 total_size: 6144, black_unknown_crc: 0x21aa6b6a, black_tv_crc: 0x21aa6b6a, black_pc_crc: 0x237ec905
bgr48be total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
bgr48le total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
yuv420p9be total_size: 9216, black_unknown_crc: 0x9154a536, black_tv_crc: 0x9154a536, black_pc_crc: 0xeeddecd0
@@ -367,8 +367,8 @@ yuva422p16be total_size: 18432, black_unknown_crc: 0x630b483b, black_tv_cr
yuva422p16le total_size: 18432, black_unknown_crc: 0xdac3d2ac, black_tv_crc: 0xdac3d2ac, black_pc_crc: 0x31970804
yuva444p16be total_size: 24576, black_unknown_crc: 0x4010c8d3, black_tv_crc: 0x4010c8d3, black_pc_crc: 0xca6bd07e
yuva444p16le total_size: 24576, black_unknown_crc: 0x1824855b, black_tv_crc: 0x1824855b, black_pc_crc: 0x06f5c440
-xyz12le total_size: 18432, black_unknown_crc: 0x24c4432b, black_tv_crc: 0x24c4432b, black_pc_crc: 0xfe5a7889
-xyz12be total_size: 18432, black_unknown_crc: 0xac983d03, black_tv_crc: 0xac983d03, black_pc_crc: 0x949a61fc
+xyz12le total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+xyz12be total_size: 18432, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
nv16 total_size: 6144, black_unknown_crc: 0x71fcc79c, black_tv_crc: 0x71fcc79c, black_pc_crc: 0xa9fa0192
nv20le total_size: 12288, black_unknown_crc: 0x2ef977dc, black_tv_crc: 0x2ef977dc, black_pc_crc: 0x5a944de0
nv20be total_size: 12288, black_unknown_crc: 0x7cb8d0b6, black_tv_crc: 0x7cb8d0b6, black_pc_crc: 0xa0507635
@@ -377,8 +377,8 @@ rgba64le total_size: 24576, black_unknown_crc: 0x0ab5caf6, black_tv_cr
bgra64be total_size: 24576, black_unknown_crc: 0x0ab5caf6, black_tv_crc: 0x0ab5caf6, black_pc_crc: 0x0ab5caf6
bgra64le total_size: 24576, black_unknown_crc: 0x0ab5caf6, black_tv_crc: 0x0ab5caf6, black_pc_crc: 0x0ab5caf6
yvyu422 total_size: 6144, black_unknown_crc: 0xcb089fb0, black_tv_crc: 0xcb089fb0, black_pc_crc: 0xc9dc3ddf
-ya16be total_size: 12288, black_unknown_crc: 0x5483d935, black_tv_crc: 0x5483d935, black_pc_crc: 0x06397bf3
-ya16le total_size: 12288, black_unknown_crc: 0x5d8e1cf6, black_tv_crc: 0x5d8e1cf6, black_pc_crc: 0x8fceec45
+ya16be total_size: 12288, black_unknown_crc: 0x9f12f9d6, black_tv_crc: 0x9f12f9d6, black_pc_crc: 0xcda85b10
+ya16le total_size: 12288, black_unknown_crc: 0x1fe8aba3, black_tv_crc: 0x1fe8aba3, black_pc_crc: 0xcda85b10
gbrap total_size: 12288, black_unknown_crc: 0xda63f152, black_tv_crc: 0xda63f152, black_pc_crc: 0xda63f152
gbrap16be total_size: 24576, black_unknown_crc: 0x53374343, black_tv_crc: 0x53374343, black_pc_crc: 0x53374343
gbrap16le total_size: 24576, black_unknown_crc: 0x53374343, black_tv_crc: 0x53374343, black_pc_crc: 0x53374343
@@ -471,7 +471,7 @@ p012le total_size: 9216, black_unknown_crc: 0xfff85b60, black_tv_cr
p012be total_size: 9216, black_unknown_crc: 0x4d4d9903, black_tv_crc: 0x4d4d9903, black_pc_crc: 0x69c6fe01
y212be total_size: 12288, black_unknown_crc: 0x5483d935, black_tv_crc: 0x5483d935, black_pc_crc: 0x06397bf3
y212le total_size: 12288, black_unknown_crc: 0x5d8e1cf6, black_tv_crc: 0x5d8e1cf6, black_pc_crc: 0x8fceec45
-xv30be total_size: 12288, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+xv30be total_size: 12288, black_unknown_crc: 0x1c42115f, black_tv_crc: 0x1c42115f, black_pc_crc: 0x37bf2ef8
xv30le total_size: 12288, black_unknown_crc: 0x4bb0b075, black_tv_crc: 0x4bb0b075, black_pc_crc: 0x02d585cf
xv36be total_size: 24576, black_unknown_crc: 0x6ba828bd, black_tv_crc: 0x6ba828bd, black_pc_crc: 0x5f450f41
xv36le total_size: 24576, black_unknown_crc: 0xc3794950, black_tv_crc: 0xc3794950, black_pc_crc: 0x40874939
--
2.35.3
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* [FFmpeg-devel] [PATCH v2 4/7] avutil/imgutils: add support for 32bit pixel format for av_image_fill_black()
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 " Marton Balint
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 2/7] avutil/tests/imgutils: add tests for av_image_fill_black() Marton Balint
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 3/7] avutil/imgutils: fix av_image_fill_black() for some pixel formats Marton Balint
@ 2023-12-06 8:22 ` Marton Balint
2023-12-06 22:48 ` Stefano Sabatini
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 5/7] avutil/imgutils: factorize a fill color function Marton Balint
` (3 subsequent siblings)
6 siblings, 1 reply; 45+ messages in thread
From: Marton Balint @ 2023-12-06 8:22 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marton Balint
Signed-off-by: Marton Balint <cus@passwd.hu>
---
libavutil/imgutils.c | 33 +++++++++++++++++++++++----------
tests/ref/fate/imgutils | 24 ++++++++++++------------
2 files changed, 35 insertions(+), 22 deletions(-)
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index 5e401139c8..67119b0870 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -590,7 +590,7 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
uint8_t clear_block[4][MAX_BLOCK_SIZE] = {{0}}; // clear padding with 0
int clear_block_size[4] = {0};
ptrdiff_t plane_line_bytes[4] = {0};
- int rgb, xyz, pal, limited, alpha, bitstream;
+ int rgb, xyz, pal, limited, alpha, bitstream, fltp;
int plane, c;
if (!desc || nb_planes < 1 || nb_planes > 4 || desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
@@ -602,6 +602,7 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
limited = !rgb && !xyz && !pal && range != AVCOL_RANGE_JPEG;
alpha = !pal && !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA);
bitstream = !!(desc->flags & AV_PIX_FMT_FLAG_BITSTREAM);
+ fltp = !!(desc->flags & AV_PIX_FMT_FLAG_FLOAT);
for (c = 0; c < desc->nb_components; c++) {
const AVComponentDescriptor comp = desc->comp[c];
@@ -621,11 +622,11 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
int w = (bitstream ? 8 : 1) * clear_block_size[comp.plane] / comp.step;
uint8_t *c_data[4];
const int c_linesize[4] = {0};
- uint16_t src_array[MAX_BLOCK_SIZE];
- uint16_t src = 0;
+ uint32_t src_array[MAX_BLOCK_SIZE];
+ uint32_t src = 0;
int x;
- if (comp.depth > 16)
+ if (comp.depth > 32)
return AVERROR(EINVAL);
if (w < 1)
return AVERROR(EINVAL);
@@ -634,15 +635,27 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
src = 1;
} else if (c + 1 == desc->nb_components && alpha) {
// (Assume even limited YUV uses full range alpha.)
- src = (1 << comp.depth) - 1;
+ if (fltp) {
+ if (comp.depth != 16 && comp.depth != 32)
+ return AVERROR(EINVAL);
+ src = (comp.depth == 16 ? 0x3C00 : 0x3F800000); // 1.0
+ } else {
+ src = (comp.depth == 32 ? 0 : (1 << comp.depth)) - 1;
+ }
} else if (c == 0 && limited && comp.depth > 1) {
- if (comp.depth < 8)
+ if (comp.depth < 8 || (fltp && comp.depth != 16 && comp.depth != 32))
return AVERROR(EINVAL);
- src = 16 << (comp.depth - 8);
+ if (fltp)
+ src = (comp.depth == 16 ? 0x3000 : 0x3D800000); // 0.0625
+ else
+ src = 16 << (comp.depth - 8);
} else if ((c == 1 || c == 2) && !rgb && !xyz) {
- if (comp.depth < 8)
+ if (comp.depth < 8 || fltp && comp.depth != 16 && comp.depth != 32)
return AVERROR(EINVAL);
- src = 128 << (comp.depth - 8);
+ if (fltp)
+ src = (comp.depth == 16 ? 0x3800 : 0x3F000000); // 0.5
+ else
+ src = 128 << (comp.depth - 8);
}
for (x = 0; x < w; x++)
@@ -651,7 +664,7 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
for (x = 0; x < 4; x++)
c_data[x] = &clear_block[x][0];
- av_write_image_line(src_array, c_data, c_linesize, desc, 0, 0, c, w);
+ av_write_image_line2(src_array, c_data, c_linesize, desc, 0, 0, c, w, 4);
}
for (plane = 0; plane < nb_planes; plane++) {
diff --git a/tests/ref/fate/imgutils b/tests/ref/fate/imgutils
index c31bc38d77..fb2ed6d158 100644
--- a/tests/ref/fate/imgutils
+++ b/tests/ref/fate/imgutils
@@ -435,14 +435,14 @@ p016le total_size: 9216, black_unknown_crc: 0xfff85b60, black_tv_cr
p016be total_size: 9216, black_unknown_crc: 0x4d4d9903, black_tv_crc: 0x4d4d9903, black_pc_crc: 0x69c6fe01
gray9be total_size: 6144, black_unknown_crc: 0xa913cdc7, black_tv_crc: 0xa913cdc7, black_pc_crc: 0x00000000
gray9le total_size: 6144, black_unknown_crc: 0x05a944de, black_tv_crc: 0x05a944de, black_pc_crc: 0x00000000
-gbrpf32be total_size: 36864, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
-gbrpf32le total_size: 36864, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
-gbrapf32be total_size: 49152, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
-gbrapf32le total_size: 49152, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+gbrpf32be total_size: 36864, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+gbrpf32le total_size: 36864, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+gbrapf32be total_size: 49152, black_unknown_crc: 0xda9c5af9, black_tv_crc: 0xda9c5af9, black_pc_crc: 0xda9c5af9
+gbrapf32le total_size: 49152, black_unknown_crc: 0xd2f28790, black_tv_crc: 0xd2f28790, black_pc_crc: 0xd2f28790
gray14be total_size: 6144, black_unknown_crc: 0x9bd1ea2b, black_tv_crc: 0x9bd1ea2b, black_pc_crc: 0x00000000
gray14le total_size: 6144, black_unknown_crc: 0xb5289bc0, black_tv_crc: 0xb5289bc0, black_pc_crc: 0x00000000
-grayf32be total_size: 12288, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
-grayf32le total_size: 12288, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+grayf32be total_size: 12288, black_unknown_crc: 0x4bafcc11, black_tv_crc: 0x4bafcc11, black_pc_crc: 0x00000000
+grayf32le total_size: 12288, black_unknown_crc: 0xca17685c, black_tv_crc: 0xca17685c, black_pc_crc: 0x00000000
yuva422p12be total_size: 18432, black_unknown_crc: 0xa7067ca1, black_tv_crc: 0xa7067ca1, black_pc_crc: 0xaa881b51
yuva422p12le total_size: 18432, black_unknown_crc: 0xb6bdf055, black_tv_crc: 0xb6bdf055, black_pc_crc: 0x55b03edf
yuva444p12be total_size: 24576, black_unknown_crc: 0x488f478f, black_tv_crc: 0x488f478f, black_pc_crc: 0xc6fb24d1
@@ -464,8 +464,8 @@ p216le total_size: 12288, black_unknown_crc: 0x6582d6cf, black_tv_cr
p416be total_size: 18432, black_unknown_crc: 0x26991800, black_tv_crc: 0x26991800, black_pc_crc: 0xfe7f6700
p416le total_size: 18432, black_unknown_crc: 0x4028ac30, black_tv_crc: 0x4028ac30, black_pc_crc: 0xab7c7698
vuya total_size: 12288, black_unknown_crc: 0x60db2d2c, black_tv_crc: 0x60db2d2c, black_pc_crc: 0x2dae630a
-rgbaf16be total_size: 24576, black_unknown_crc: 0x0ab5caf6, black_tv_crc: 0x0ab5caf6, black_pc_crc: 0x0ab5caf6
-rgbaf16le total_size: 24576, black_unknown_crc: 0x0ab5caf6, black_tv_crc: 0x0ab5caf6, black_pc_crc: 0x0ab5caf6
+rgbaf16be total_size: 24576, black_unknown_crc: 0x76fd69af, black_tv_crc: 0x76fd69af, black_pc_crc: 0x76fd69af
+rgbaf16le total_size: 24576, black_unknown_crc: 0x21283f40, black_tv_crc: 0x21283f40, black_pc_crc: 0x21283f40
vuyx total_size: 12288, black_unknown_crc: 0x9181c808, black_tv_crc: 0x9181c808, black_pc_crc: 0xdcf4862e
p012le total_size: 9216, black_unknown_crc: 0xfff85b60, black_tv_crc: 0xfff85b60, black_pc_crc: 0xc03cff93
p012be total_size: 9216, black_unknown_crc: 0x4d4d9903, black_tv_crc: 0x4d4d9903, black_pc_crc: 0x69c6fe01
@@ -475,10 +475,10 @@ xv30be total_size: 12288, black_unknown_crc: 0x1c42115f, black_tv_cr
xv30le total_size: 12288, black_unknown_crc: 0x4bb0b075, black_tv_crc: 0x4bb0b075, black_pc_crc: 0x02d585cf
xv36be total_size: 24576, black_unknown_crc: 0x6ba828bd, black_tv_crc: 0x6ba828bd, black_pc_crc: 0x5f450f41
xv36le total_size: 24576, black_unknown_crc: 0xc3794950, black_tv_crc: 0xc3794950, black_pc_crc: 0x40874939
-rgbf32be total_size: 36864, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
-rgbf32le total_size: 36864, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
-rgbaf32be total_size: 49152, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
-rgbaf32le total_size: 49152, black_unknown_crc: ----------, black_tv_crc: ----------, black_pc_crc: ----------
+rgbf32be total_size: 36864, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgbf32le total_size: 36864, black_unknown_crc: 0x00000000, black_tv_crc: 0x00000000, black_pc_crc: 0x00000000
+rgbaf32be total_size: 49152, black_unknown_crc: 0x5eae6680, black_tv_crc: 0x5eae6680, black_pc_crc: 0x5eae6680
+rgbaf32le total_size: 49152, black_unknown_crc: 0x11d73f6d, black_tv_crc: 0x11d73f6d, black_pc_crc: 0x11d73f6d
p212be total_size: 12288, black_unknown_crc: 0x0bbe5df7, black_tv_crc: 0x0bbe5df7, black_pc_crc: 0x16a51378
p212le total_size: 12288, black_unknown_crc: 0x6582d6cf, black_tv_crc: 0x6582d6cf, black_pc_crc: 0xc9dc3ddf
p412be total_size: 18432, black_unknown_crc: 0x26991800, black_tv_crc: 0x26991800, black_pc_crc: 0xfe7f6700
--
2.35.3
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* [FFmpeg-devel] [PATCH v2 5/7] avutil/imgutils: factorize a fill color function
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 " Marton Balint
` (2 preceding siblings ...)
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 4/7] avutil/imgutils: add support for 32bit pixel format for av_image_fill_black() Marton Balint
@ 2023-12-06 8:22 ` Marton Balint
2023-12-06 22:52 ` Stefano Sabatini
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 6/7] avutil/imgutils: add new function av_image_fill_color() Marton Balint
` (2 subsequent siblings)
6 siblings, 1 reply; 45+ messages in thread
From: Marton Balint @ 2023-12-06 8:22 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marton Balint
In preparation for making it public.
Signed-off-by: Marton Balint <cus@passwd.hu>
---
libavutil/imgutils.c | 103 +++++++++++++++++++++++++++----------------
1 file changed, 64 insertions(+), 39 deletions(-)
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index 67119b0870..278e30ee0f 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -579,30 +579,24 @@ static void memset_bytes(uint8_t *dst, size_t dst_size, uint8_t *clear,
// if it's a subsampled packed format).
#define MAX_BLOCK_SIZE 32
-int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
- enum AVPixelFormat pix_fmt, enum AVColorRange range,
+static int image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
+ enum AVPixelFormat pix_fmt, const uint32_t color[4],
int width, int height)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
int nb_planes = av_pix_fmt_count_planes(pix_fmt);
- // A pixel or a group of pixels on each plane, with a value that represents black.
+ // A pixel or a group of pixels on each plane, with a value that represents the color.
// Consider e.g. AV_PIX_FMT_UYVY422 for non-trivial cases.
uint8_t clear_block[4][MAX_BLOCK_SIZE] = {{0}}; // clear padding with 0
int clear_block_size[4] = {0};
ptrdiff_t plane_line_bytes[4] = {0};
- int rgb, xyz, pal, limited, alpha, bitstream, fltp;
+ int bitstream;
int plane, c;
if (!desc || nb_planes < 1 || nb_planes > 4 || desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
return AVERROR(EINVAL);
- rgb = !!(desc->flags & AV_PIX_FMT_FLAG_RGB);
- xyz = !!(desc->flags & AV_PIX_FMT_FLAG_XYZ);
- pal = !!(desc->flags & AV_PIX_FMT_FLAG_PAL);
- limited = !rgb && !xyz && !pal && range != AVCOL_RANGE_JPEG;
- alpha = !pal && !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA);
bitstream = !!(desc->flags & AV_PIX_FMT_FLAG_BITSTREAM);
- fltp = !!(desc->flags & AV_PIX_FMT_FLAG_FLOAT);
for (c = 0; c < desc->nb_components; c++) {
const AVComponentDescriptor comp = desc->comp[c];
@@ -623,7 +617,6 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
uint8_t *c_data[4];
const int c_linesize[4] = {0};
uint32_t src_array[MAX_BLOCK_SIZE];
- uint32_t src = 0;
int x;
if (comp.depth > 32)
@@ -631,35 +624,8 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
if (w < 1)
return AVERROR(EINVAL);
- if (pix_fmt == AV_PIX_FMT_MONOWHITE) {
- src = 1;
- } else if (c + 1 == desc->nb_components && alpha) {
- // (Assume even limited YUV uses full range alpha.)
- if (fltp) {
- if (comp.depth != 16 && comp.depth != 32)
- return AVERROR(EINVAL);
- src = (comp.depth == 16 ? 0x3C00 : 0x3F800000); // 1.0
- } else {
- src = (comp.depth == 32 ? 0 : (1 << comp.depth)) - 1;
- }
- } else if (c == 0 && limited && comp.depth > 1) {
- if (comp.depth < 8 || (fltp && comp.depth != 16 && comp.depth != 32))
- return AVERROR(EINVAL);
- if (fltp)
- src = (comp.depth == 16 ? 0x3000 : 0x3D800000); // 0.0625
- else
- src = 16 << (comp.depth - 8);
- } else if ((c == 1 || c == 2) && !rgb && !xyz) {
- if (comp.depth < 8 || fltp && comp.depth != 16 && comp.depth != 32)
- return AVERROR(EINVAL);
- if (fltp)
- src = (comp.depth == 16 ? 0x3800 : 0x3F000000); // 0.5
- else
- src = 128 << (comp.depth - 8);
- }
-
for (x = 0; x < w; x++)
- src_array[x] = src;
+ src_array[x] = color[c];
for (x = 0; x < 4; x++)
c_data[x] = &clear_block[x][0];
@@ -690,3 +656,62 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
return 0;
}
+
+int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
+ enum AVPixelFormat pix_fmt, enum AVColorRange range,
+ int width, int height)
+{
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
+ int nb_planes = av_pix_fmt_count_planes(pix_fmt);
+ int rgb, xyz, pal, limited, alpha, fltp;
+ uint32_t colors[4] = {0};
+
+ if (!desc || nb_planes < 1 || nb_planes > 4 || desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
+ return AVERROR(EINVAL);
+
+ rgb = !!(desc->flags & AV_PIX_FMT_FLAG_RGB);
+ xyz = !!(desc->flags & AV_PIX_FMT_FLAG_XYZ);
+ pal = !!(desc->flags & AV_PIX_FMT_FLAG_PAL);
+ limited = !rgb && !xyz && !pal && range != AVCOL_RANGE_JPEG;
+ alpha = !pal && !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA);
+ fltp = !!(desc->flags & AV_PIX_FMT_FLAG_FLOAT);
+
+ for (int c = 0; c < desc->nb_components; c++) {
+ const AVComponentDescriptor comp = desc->comp[c];
+ uint32_t color = 0;
+
+ if (comp.depth > 32)
+ return AVERROR(EINVAL);
+
+ if (pix_fmt == AV_PIX_FMT_MONOWHITE) {
+ color = 1;
+ } else if (c + 1 == desc->nb_components && alpha) {
+ // (Assume even limited YUV uses full range alpha.)
+ if (fltp) {
+ if (comp.depth != 16 && comp.depth != 32)
+ return AVERROR(EINVAL);
+ color = (comp.depth == 16 ? 0x3C00 : 0x3F800000); // 1.0
+ } else {
+ color = (comp.depth == 32 ? 0 : (1 << comp.depth)) - 1;
+ }
+ } else if (c == 0 && limited && comp.depth > 1) {
+ if (comp.depth < 8 || (fltp && comp.depth != 16 && comp.depth != 32))
+ return AVERROR(EINVAL);
+ if (fltp)
+ color = (comp.depth == 16 ? 0x3000 : 0x3D800000); // 0.0625
+ else
+ color = 16 << (comp.depth - 8);
+ } else if ((c == 1 || c == 2) && !rgb && !xyz) {
+ if (comp.depth < 8 || fltp && comp.depth != 16 && comp.depth != 32)
+ return AVERROR(EINVAL);
+ if (fltp)
+ color = (comp.depth == 16 ? 0x3800 : 0x3F000000); // 0.5
+ else
+ color = 128 << (comp.depth - 8);
+ }
+
+ colors[c] = color;
+ }
+
+ return image_fill_color(dst_data, dst_linesize, pix_fmt, colors, width, height);
+}
--
2.35.3
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* [FFmpeg-devel] [PATCH v2 6/7] avutil/imgutils: add new function av_image_fill_color()
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 " Marton Balint
` (3 preceding siblings ...)
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 5/7] avutil/imgutils: factorize a fill color function Marton Balint
@ 2023-12-06 8:22 ` Marton Balint
2023-12-06 22:53 ` Stefano Sabatini
2023-12-07 16:15 ` Anton Khirnov
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR Marton Balint
2023-12-06 22:43 ` [FFmpeg-devel] [PATCH v2 1/7] avutil/tests/imgutils: factorize basic tests to new function Stefano Sabatini
6 siblings, 2 replies; 45+ messages in thread
From: Marton Balint @ 2023-12-06 8:22 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marton Balint
Signed-off-by: Marton Balint <cus@passwd.hu>
---
doc/APIchanges | 3 +++
libavutil/imgutils.c | 4 ++--
libavutil/imgutils.h | 30 ++++++++++++++++++++++++++++++
libavutil/version.h | 2 +-
4 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 4a2dc1c44f..416e2bec5e 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09
API changes, most recent first:
+2023-12-xx - xxxxxxxxxxx - lavu 58.33.100 - imgutils.h
+ Add av_image_fill_color()
+
2023-11-08 - b82957a66a7 - lavu 58.32.100 - channel_layout.h
Add AV_CH_LAYOUT_7POINT2POINT3 and AV_CHANNEL_LAYOUT_7POINT2POINT3.
Add AV_CH_LAYOUT_9POINT1POINT4_BACK and AV_CHANNEL_LAYOUT_9POINT1POINT4_BACK.
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index 278e30ee0f..e1eefcdd70 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -579,7 +579,7 @@ static void memset_bytes(uint8_t *dst, size_t dst_size, uint8_t *clear,
// if it's a subsampled packed format).
#define MAX_BLOCK_SIZE 32
-static int image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
+int av_image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
enum AVPixelFormat pix_fmt, const uint32_t color[4],
int width, int height)
{
@@ -713,5 +713,5 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
colors[c] = color;
}
- return image_fill_color(dst_data, dst_linesize, pix_fmt, colors, width, height);
+ return av_image_fill_color(dst_data, dst_linesize, pix_fmt, colors, width, height);
}
diff --git a/libavutil/imgutils.h b/libavutil/imgutils.h
index fa3bb101b1..6e744b0cac 100644
--- a/libavutil/imgutils.h
+++ b/libavutil/imgutils.h
@@ -339,6 +339,36 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
enum AVPixelFormat pix_fmt, enum AVColorRange range,
int width, int height);
+/**
+ * Overwrite the image data with a color. This is suitable for filling a
+ * sub-rectangle of an image, meaning the padding between the right most pixel
+ * and the left most pixel on the next line will not be overwritten. For some
+ * formats, the image size might be rounded up due to inherent alignment.
+ *
+ * If the pixel format has alpha, it is also replaced. Color component values
+ * are interpreted as native integers (or intfloats) regardless of actual pixel
+ * format endianness.
+ *
+ * This can return an error if the pixel format is not supported. Normally, all
+ * non-hwaccel pixel formats should be supported.
+ *
+ * Passing NULL for dst_data is allowed. Then the function returns whether the
+ * operation would have succeeded. (It can return an error if the pix_fmt is
+ * not supported.)
+ *
+ * @param dst_data data pointers to destination image
+ * @param dst_linesize linesizes for the destination image
+ * @param pix_fmt the pixel format of the image
+ * @param color the color components to be used for the fill
+ * @param width the width of the image in pixels
+ * @param height the height of the image in pixels
+ * @return 0 if the image data was filled, a negative AVERROR code otherwise
+ */
+int av_image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
+ enum AVPixelFormat pix_fmt, const uint32_t color[4],
+ int width, int height);
+
+
/**
* @}
*/
diff --git a/libavutil/version.h b/libavutil/version.h
index c5fa7c3692..0684996bf2 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 58
-#define LIBAVUTIL_VERSION_MINOR 32
+#define LIBAVUTIL_VERSION_MINOR 33
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
--
2.35.3
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 " Marton Balint
` (4 preceding siblings ...)
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 6/7] avutil/imgutils: add new function av_image_fill_color() Marton Balint
@ 2023-12-06 8:22 ` Marton Balint
2023-12-06 22:57 ` Stefano Sabatini
` (3 more replies)
2023-12-06 22:43 ` [FFmpeg-devel] [PATCH v2 1/7] avutil/tests/imgutils: factorize basic tests to new function Stefano Sabatini
6 siblings, 4 replies; 45+ messages in thread
From: Marton Balint @ 2023-12-06 8:22 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marton Balint
Signed-off-by: Marton Balint <cus@passwd.hu>
---
doc/APIchanges | 3 +++
doc/codecs.texi | 14 ++++++++++++++
libavcodec/avcodec.h | 4 ++++
libavcodec/decode.c | 6 ++++++
libavcodec/options_table.h | 1 +
libavcodec/version.h | 2 +-
6 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 416e2bec5e..f839504a64 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09
API changes, most recent first:
+2023-12-xx - xxxxxxxxxxx - lavc 60.36.100 - avcodec.h
+ Add AV_CODEC_FLAG_CLEAR.
+
2023-12-xx - xxxxxxxxxxx - lavu 58.33.100 - imgutils.h
Add av_image_fill_color()
diff --git a/doc/codecs.texi b/doc/codecs.texi
index 5b950b4560..0504a535f2 100644
--- a/doc/codecs.texi
+++ b/doc/codecs.texi
@@ -76,6 +76,20 @@ Apply interlaced motion estimation.
Use closed gop.
@item output_corrupt
Output even potentially corrupted frames.
+@item clear
+Clear the contents of the video buffer before decoding the next picture to it.
+
+Usually if only a part of a picture is affected by a decode error then the
+decoder (if it implements error concealment) tries to hide it by interpolating
+pixels from neighbouring areas or in some cases from the previous frame. Even
+without error concealment it is quite likely that the affected area will
+contain pixels from an earlier frame, due to frame pooling.
+
+For quality checking this might not be desirable, because it makes the errors
+less noticable. By using this flag, and combining it with disabled error
+concealment (@code{-ec 0}) it is possible to ensure that no leftover data from
+an earlier frame is presented in areas affected by decode errors.
+
@end table
@item time_base @var{rational number}
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7fb44e28f4..97848e942f 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -312,6 +312,10 @@ typedef struct RcOverride{
* loop filter.
*/
#define AV_CODEC_FLAG_LOOP_FILTER (1 << 11)
+/**
+ * Clear frame buffer contents before decoding.
+ */
+#define AV_CODEC_FLAG_CLEAR (1 << 12)
/**
* Only decode/encode grayscale.
*/
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 2cfb3fcf97..f9b18a2c35 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1675,6 +1675,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
validate_avframe_allocation(avctx, frame);
+ if (avctx->flags & AV_CODEC_FLAG_CLEAR && avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
+ uint32_t color[4] = {0};
+ ptrdiff_t linesize[4] = {frame->linesize[0], frame->linesize[1], frame->linesize[2], frame->linesize[3]};
+ av_image_fill_color(frame->data, linesize, frame->format, color, frame->width, frame->height);
+ }
+
ret = ff_attach_decode_data(frame);
if (ret < 0)
goto fail;
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index ee243d9894..23ff4cddf8 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -62,6 +62,7 @@ static const AVOption avcodec_options[] = {
{"frame_duration", "use frame durations", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_FRAME_DURATION}, .unit = "flags"},
{"pass1", "use internal 2-pass ratecontrol in first pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PASS1 }, INT_MIN, INT_MAX, 0, "flags"},
{"pass2", "use internal 2-pass ratecontrol in second pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PASS2 }, INT_MIN, INT_MAX, 0, "flags"},
+{"clear", "clear frames before decoding", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_CLEAR }, INT_MIN, INT_MAX, V|D, "flags"},
{"gray", "only decode/encode grayscale", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_GRAY }, INT_MIN, INT_MAX, V|E|D, "flags"},
{"psnr", "error[?] variables will be set during encoding", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PSNR }, INT_MIN, INT_MAX, V|E, "flags"},
{"ildct", "use interlaced DCT", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_INTERLACED_DCT }, INT_MIN, INT_MAX, V|E, "flags"},
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 1008fead27..34b059a8a9 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
#include "version_major.h"
-#define LIBAVCODEC_VERSION_MINOR 35
+#define LIBAVCODEC_VERSION_MINOR 36
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
--
2.35.3
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 1/7] avutil/tests/imgutils: factorize basic tests to new function
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 " Marton Balint
` (5 preceding siblings ...)
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR Marton Balint
@ 2023-12-06 22:43 ` Stefano Sabatini
6 siblings, 0 replies; 45+ messages in thread
From: Stefano Sabatini @ 2023-12-06 22:43 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Marton Balint
On date Wednesday 2023-12-06 09:22:14 +0100, Marton Balint wrote:
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> libavutil/tests/imgutils.c | 68 ++++++++++++++++++++++----------------
> 1 file changed, 39 insertions(+), 29 deletions(-)
LGTM, thanks.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 2/7] avutil/tests/imgutils: add tests for av_image_fill_black()
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 2/7] avutil/tests/imgutils: add tests for av_image_fill_black() Marton Balint
@ 2023-12-06 22:46 ` Stefano Sabatini
0 siblings, 0 replies; 45+ messages in thread
From: Stefano Sabatini @ 2023-12-06 22:46 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Marton Balint
On date Wednesday 2023-12-06 09:22:15 +0100, Marton Balint wrote:
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> libavutil/tests/imgutils.c | 61 +++++++++--
> tests/ref/fate/imgutils | 217 +++++++++++++++++++++++++++++++++++++
> 2 files changed, 269 insertions(+), 9 deletions(-)
LGTM, thanks.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 3/7] avutil/imgutils: fix av_image_fill_black() for some pixel formats
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 3/7] avutil/imgutils: fix av_image_fill_black() for some pixel formats Marton Balint
@ 2023-12-06 22:47 ` Stefano Sabatini
0 siblings, 0 replies; 45+ messages in thread
From: Stefano Sabatini @ 2023-12-06 22:47 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Marton Balint
On date Wednesday 2023-12-06 09:22:16 +0100, Marton Balint wrote:
> - Fixes YA formats, because previous code always assumed alpha as the 4th
> component.
> - Fixes PAL format (as long as 0 is black, as in a systematic palette), because
> previous code assumed it as limited Y.
> - Fixes XYZ format because it does not need nonzero chroma components
> - Fixes xv30be as the bitstream mode got merged to the non-bitstream mode.
>
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> libavutil/imgutils.c | 49 +++++++++++++++--------------------------
> tests/ref/fate/imgutils | 14 ++++++------
> 2 files changed, 25 insertions(+), 38 deletions(-)
Still LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 4/7] avutil/imgutils: add support for 32bit pixel format for av_image_fill_black()
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 4/7] avutil/imgutils: add support for 32bit pixel format for av_image_fill_black() Marton Balint
@ 2023-12-06 22:48 ` Stefano Sabatini
0 siblings, 0 replies; 45+ messages in thread
From: Stefano Sabatini @ 2023-12-06 22:48 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Marton Balint
On date Wednesday 2023-12-06 09:22:17 +0100, Marton Balint wrote:
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> libavutil/imgutils.c | 33 +++++++++++++++++++++++----------
> tests/ref/fate/imgutils | 24 ++++++++++++------------
> 2 files changed, 35 insertions(+), 22 deletions(-)
LGTM, thanks.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 5/7] avutil/imgutils: factorize a fill color function
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 5/7] avutil/imgutils: factorize a fill color function Marton Balint
@ 2023-12-06 22:52 ` Stefano Sabatini
0 siblings, 0 replies; 45+ messages in thread
From: Stefano Sabatini @ 2023-12-06 22:52 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Marton Balint
On date Wednesday 2023-12-06 09:22:18 +0100, Marton Balint wrote:
> In preparation for making it public.
>
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> libavutil/imgutils.c | 103 +++++++++++++++++++++++++++----------------
> 1 file changed, 64 insertions(+), 39 deletions(-)
LGTM, thanks.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 6/7] avutil/imgutils: add new function av_image_fill_color()
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 6/7] avutil/imgutils: add new function av_image_fill_color() Marton Balint
@ 2023-12-06 22:53 ` Stefano Sabatini
2023-12-07 16:15 ` Anton Khirnov
1 sibling, 0 replies; 45+ messages in thread
From: Stefano Sabatini @ 2023-12-06 22:53 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Marton Balint
On date Wednesday 2023-12-06 09:22:19 +0100, Marton Balint wrote:
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> doc/APIchanges | 3 +++
> libavutil/imgutils.c | 4 ++--
> libavutil/imgutils.h | 30 ++++++++++++++++++++++++++++++
> libavutil/version.h | 2 +-
> 4 files changed, 36 insertions(+), 3 deletions(-)
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 4a2dc1c44f..416e2bec5e 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09
>
> API changes, most recent first:
>
> +2023-12-xx - xxxxxxxxxxx - lavu 58.33.100 - imgutils.h
> + Add av_image_fill_color()
nit++: add missing dot?
[...]
LGTM otherwise (no need to send another patch).
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR Marton Balint
@ 2023-12-06 22:57 ` Stefano Sabatini
2023-12-07 1:44 ` Ronald S. Bultje
` (2 subsequent siblings)
3 siblings, 0 replies; 45+ messages in thread
From: Stefano Sabatini @ 2023-12-06 22:57 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Marton Balint
On date Wednesday 2023-12-06 09:22:20 +0100, Marton Balint wrote:
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> doc/APIchanges | 3 +++
> doc/codecs.texi | 14 ++++++++++++++
> libavcodec/avcodec.h | 4 ++++
> libavcodec/decode.c | 6 ++++++
> libavcodec/options_table.h | 1 +
> libavcodec/version.h | 2 +-
> 6 files changed, 29 insertions(+), 1 deletion(-)
LGTM but I'll let someone with more familiarity of the lavc internals
comment on this.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR Marton Balint
2023-12-06 22:57 ` Stefano Sabatini
@ 2023-12-07 1:44 ` Ronald S. Bultje
2023-12-07 16:19 ` Anton Khirnov
2023-12-07 2:37 ` Vittorio Giovara
2023-12-07 16:30 ` Anton Khirnov
3 siblings, 1 reply; 45+ messages in thread
From: Ronald S. Bultje @ 2023-12-07 1:44 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Marton Balint
Hi,
On Wed, Dec 6, 2023 at 3:23 AM Marton Balint <cus@passwd.hu> wrote:
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> doc/APIchanges | 3 +++
> doc/codecs.texi | 14 ++++++++++++++
> libavcodec/avcodec.h | 4 ++++
> libavcodec/decode.c | 6 ++++++
> libavcodec/options_table.h | 1 +
> libavcodec/version.h | 2 +-
> 6 files changed, 29 insertions(+), 1 deletion(-)
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 416e2bec5e..f839504a64 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -2,6 +2,9 @@ The last version increases of all libraries were on
> 2023-02-09
>
> API changes, most recent first:
>
> +2023-12-xx - xxxxxxxxxxx - lavc 60.36.100 - avcodec.h
> + Add AV_CODEC_FLAG_CLEAR.
> +
> 2023-12-xx - xxxxxxxxxxx - lavu 58.33.100 - imgutils.h
> Add av_image_fill_color()
>
> diff --git a/doc/codecs.texi b/doc/codecs.texi
> index 5b950b4560..0504a535f2 100644
> --- a/doc/codecs.texi
> +++ b/doc/codecs.texi
> @@ -76,6 +76,20 @@ Apply interlaced motion estimation.
> Use closed gop.
> @item output_corrupt
> Output even potentially corrupted frames.
> +@item clear
> +Clear the contents of the video buffer before decoding the next picture
> to it.
> +
> +Usually if only a part of a picture is affected by a decode error then the
> +decoder (if it implements error concealment) tries to hide it by
> interpolating
> +pixels from neighbouring areas or in some cases from the previous frame.
> Even
> +without error concealment it is quite likely that the affected area will
> +contain pixels from an earlier frame, due to frame pooling.
>
No comment on the patch itself, but wouldn't our users (and the C standard
itself) consider it a security issue to return stale (or worse:
uninitialized) data while pretending that it's safe to access?
I thought touching uninitialized data was UB.
Ronald
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR Marton Balint
2023-12-06 22:57 ` Stefano Sabatini
2023-12-07 1:44 ` Ronald S. Bultje
@ 2023-12-07 2:37 ` Vittorio Giovara
2023-12-07 16:30 ` Anton Khirnov
3 siblings, 0 replies; 45+ messages in thread
From: Vittorio Giovara @ 2023-12-07 2:37 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Marton Balint
On Wed, Dec 6, 2023 at 3:23 AM Marton Balint <cus@passwd.hu> wrote:
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index 2cfb3fcf97..f9b18a2c35 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -1675,6 +1675,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
>
> validate_avframe_allocation(avctx, frame);
>
> + if (avctx->flags & AV_CODEC_FLAG_CLEAR && avctx->codec_type ==
> AVMEDIA_TYPE_VIDEO) {
> + uint32_t color[4] = {0};
> + ptrdiff_t linesize[4] = {frame->linesize[0], frame->linesize[1],
> frame->linesize[2], frame->linesize[3]};
> + av_image_fill_color(frame->data, linesize, frame->format, color,
> frame->width, frame->height);
>
I think it's be safer to add a return check here
--
Vittorio
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 6/7] avutil/imgutils: add new function av_image_fill_color()
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 6/7] avutil/imgutils: add new function av_image_fill_color() Marton Balint
2023-12-06 22:53 ` Stefano Sabatini
@ 2023-12-07 16:15 ` Anton Khirnov
2023-12-09 19:25 ` [FFmpeg-devel] [PATCH v3 " Marton Balint
1 sibling, 1 reply; 45+ messages in thread
From: Anton Khirnov @ 2023-12-07 16:15 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Marton Balint
Quoting Marton Balint (2023-12-06 09:22:19)
> +int av_image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
> + enum AVPixelFormat pix_fmt, const uint32_t color[4],
> + int width, int height);
Might want to add a flags argument for future extensions.
--
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR
2023-12-07 1:44 ` Ronald S. Bultje
@ 2023-12-07 16:19 ` Anton Khirnov
2023-12-07 22:47 ` Marton Balint
0 siblings, 1 reply; 45+ messages in thread
From: Anton Khirnov @ 2023-12-07 16:19 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Marton Balint
Quoting Ronald S. Bultje (2023-12-07 02:44:36)
> Hi,
>
> On Wed, Dec 6, 2023 at 3:23 AM Marton Balint <cus@passwd.hu> wrote:
>
> > Signed-off-by: Marton Balint <cus@passwd.hu>
> > ---
> > doc/APIchanges | 3 +++
> > doc/codecs.texi | 14 ++++++++++++++
> > libavcodec/avcodec.h | 4 ++++
> > libavcodec/decode.c | 6 ++++++
> > libavcodec/options_table.h | 1 +
> > libavcodec/version.h | 2 +-
> > 6 files changed, 29 insertions(+), 1 deletion(-)
> >
> > diff --git a/doc/APIchanges b/doc/APIchanges
> > index 416e2bec5e..f839504a64 100644
> > --- a/doc/APIchanges
> > +++ b/doc/APIchanges
> > @@ -2,6 +2,9 @@ The last version increases of all libraries were on
> > 2023-02-09
> >
> > API changes, most recent first:
> >
> > +2023-12-xx - xxxxxxxxxxx - lavc 60.36.100 - avcodec.h
> > + Add AV_CODEC_FLAG_CLEAR.
> > +
> > 2023-12-xx - xxxxxxxxxxx - lavu 58.33.100 - imgutils.h
> > Add av_image_fill_color()
> >
> > diff --git a/doc/codecs.texi b/doc/codecs.texi
> > index 5b950b4560..0504a535f2 100644
> > --- a/doc/codecs.texi
> > +++ b/doc/codecs.texi
> > @@ -76,6 +76,20 @@ Apply interlaced motion estimation.
> > Use closed gop.
> > @item output_corrupt
> > Output even potentially corrupted frames.
> > +@item clear
> > +Clear the contents of the video buffer before decoding the next picture
> > to it.
> > +
> > +Usually if only a part of a picture is affected by a decode error then the
> > +decoder (if it implements error concealment) tries to hide it by
> > interpolating
> > +pixels from neighbouring areas or in some cases from the previous frame.
> > Even
> > +without error concealment it is quite likely that the affected area will
> > +contain pixels from an earlier frame, due to frame pooling.
> >
>
> No comment on the patch itself, but wouldn't our users (and the C standard
> itself) consider it a security issue to return stale
I don't see the security issue in returning previously-returned frame
data.
--
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR Marton Balint
` (2 preceding siblings ...)
2023-12-07 2:37 ` Vittorio Giovara
@ 2023-12-07 16:30 ` Anton Khirnov
2023-12-07 23:11 ` Marton Balint
3 siblings, 1 reply; 45+ messages in thread
From: Anton Khirnov @ 2023-12-07 16:30 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Marton Balint
Quoting Marton Balint (2023-12-06 09:22:20)
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> doc/APIchanges | 3 +++
> doc/codecs.texi | 14 ++++++++++++++
> libavcodec/avcodec.h | 4 ++++
> libavcodec/decode.c | 6 ++++++
> libavcodec/options_table.h | 1 +
> libavcodec/version.h | 2 +-
> 6 files changed, 29 insertions(+), 1 deletion(-)
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 416e2bec5e..f839504a64 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09
>
> API changes, most recent first:
>
> +2023-12-xx - xxxxxxxxxxx - lavc 60.36.100 - avcodec.h
> + Add AV_CODEC_FLAG_CLEAR.
I'm not a huge fan of calling it just 'clear'. How about something more
descriptive like 'wipe_frames'.
> +
> 2023-12-xx - xxxxxxxxxxx - lavu 58.33.100 - imgutils.h
> Add av_image_fill_color()
>
> diff --git a/doc/codecs.texi b/doc/codecs.texi
> index 5b950b4560..0504a535f2 100644
> --- a/doc/codecs.texi
> +++ b/doc/codecs.texi
> @@ -76,6 +76,20 @@ Apply interlaced motion estimation.
> Use closed gop.
> @item output_corrupt
> Output even potentially corrupted frames.
> +@item clear
> +Clear the contents of the video buffer before decoding the next picture to it.
> +
> +Usually if only a part of a picture is affected by a decode error then the
> +decoder (if it implements error concealment) tries to hide it by interpolating
> +pixels from neighbouring areas or in some cases from the previous frame. Even
> +without error concealment it is quite likely that the affected area will
> +contain pixels from an earlier frame, due to frame pooling.
> +
> +For quality checking this might not be desirable, because it makes the errors
> +less noticable. By using this flag, and combining it with disabled error
> +concealment (@code{-ec 0}) it is possible to ensure that no leftover data from
> +an earlier frame is presented in areas affected by decode errors.
> +
> @end table
>
> @item time_base @var{rational number}
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 7fb44e28f4..97848e942f 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -312,6 +312,10 @@ typedef struct RcOverride{
> * loop filter.
> */
> #define AV_CODEC_FLAG_LOOP_FILTER (1 << 11)
> +/**
> + * Clear frame buffer contents before decoding.
Clear the contents of each frame buffer after it is allocated with
AVCodecContext.get_buffer2() and before anything is decoded into it.
Note that this may have a significant performance cost.
> + */
> +#define AV_CODEC_FLAG_CLEAR (1 << 12)
> /**
> * Only decode/encode grayscale.
> */
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index 2cfb3fcf97..f9b18a2c35 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -1675,6 +1675,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
>
> validate_avframe_allocation(avctx, frame);
>
> + if (avctx->flags & AV_CODEC_FLAG_CLEAR && avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
> + uint32_t color[4] = {0};
> + ptrdiff_t linesize[4] = {frame->linesize[0], frame->linesize[1], frame->linesize[2], frame->linesize[3]};
> + av_image_fill_color(frame->data, linesize, frame->format, color, frame->width, frame->height);
Should this check for errors?
--
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR
2023-12-07 16:19 ` Anton Khirnov
@ 2023-12-07 22:47 ` Marton Balint
2023-12-08 5:12 ` Rémi Denis-Courmont
0 siblings, 1 reply; 45+ messages in thread
From: Marton Balint @ 2023-12-07 22:47 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Thu, 7 Dec 2023, Anton Khirnov wrote:
> Quoting Ronald S. Bultje (2023-12-07 02:44:36)
>> Hi,
>>
>> On Wed, Dec 6, 2023 at 3:23 AM Marton Balint <cus@passwd.hu> wrote:
>>
>> > Signed-off-by: Marton Balint <cus@passwd.hu>
>> > ---
>> > doc/APIchanges | 3 +++
>> > doc/codecs.texi | 14 ++++++++++++++
>> > libavcodec/avcodec.h | 4 ++++
>> > libavcodec/decode.c | 6 ++++++
>> > libavcodec/options_table.h | 1 +
>> > libavcodec/version.h | 2 +-
>> > 6 files changed, 29 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/doc/APIchanges b/doc/APIchanges
>> > index 416e2bec5e..f839504a64 100644
>> > --- a/doc/APIchanges
>> > +++ b/doc/APIchanges
>> > @@ -2,6 +2,9 @@ The last version increases of all libraries were on
>> > 2023-02-09
>> >
>> > API changes, most recent first:
>> >
>> > +2023-12-xx - xxxxxxxxxxx - lavc 60.36.100 - avcodec.h
>> > + Add AV_CODEC_FLAG_CLEAR.
>> > +
>> > 2023-12-xx - xxxxxxxxxxx - lavu 58.33.100 - imgutils.h
>> > Add av_image_fill_color()
>> >
>> > diff --git a/doc/codecs.texi b/doc/codecs.texi
>> > index 5b950b4560..0504a535f2 100644
>> > --- a/doc/codecs.texi
>> > +++ b/doc/codecs.texi
>> > @@ -76,6 +76,20 @@ Apply interlaced motion estimation.
>> > Use closed gop.
>> > @item output_corrupt
>> > Output even potentially corrupted frames.
>> > +@item clear
>> > +Clear the contents of the video buffer before decoding the next picture
>> > to it.
>> > +
>> > +Usually if only a part of a picture is affected by a decode error then the
>> > +decoder (if it implements error concealment) tries to hide it by
>> > interpolating
>> > +pixels from neighbouring areas or in some cases from the previous frame.
>> > Even
>> > +without error concealment it is quite likely that the affected area will
>> > +contain pixels from an earlier frame, due to frame pooling.
>> >
>>
>> No comment on the patch itself, but wouldn't our users (and the C standard
>> itself) consider it a security issue to return stale
>
> I don't see the security issue in returning previously-returned frame
> data.
I guess what Ronald means that it is possible that the decoder frame
pool allocates data in heap previously containing sensitive data,
and that might never get overwritten in case of faulty input before
passing it to the user.
The simple fix for that is to clear frame pool buffers on creation?
I am not sure if it is actually UB to read uninitialzied data from the
heap though.
Regards,
Marton
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR
2023-12-07 16:30 ` Anton Khirnov
@ 2023-12-07 23:11 ` Marton Balint
2023-12-11 20:49 ` Mark Thompson
2023-12-12 11:23 ` Anton Khirnov
0 siblings, 2 replies; 45+ messages in thread
From: Marton Balint @ 2023-12-07 23:11 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Thu, 7 Dec 2023, Anton Khirnov wrote:
> Quoting Marton Balint (2023-12-06 09:22:20)
>> Signed-off-by: Marton Balint <cus@passwd.hu>
>> ---
>> doc/APIchanges | 3 +++
>> doc/codecs.texi | 14 ++++++++++++++
>> libavcodec/avcodec.h | 4 ++++
>> libavcodec/decode.c | 6 ++++++
>> libavcodec/options_table.h | 1 +
>> libavcodec/version.h | 2 +-
>> 6 files changed, 29 insertions(+), 1 deletion(-)
>>
>> diff --git a/doc/APIchanges b/doc/APIchanges
>> index 416e2bec5e..f839504a64 100644
>> --- a/doc/APIchanges
>> +++ b/doc/APIchanges
>> @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09
>>
>> API changes, most recent first:
>>
>> +2023-12-xx - xxxxxxxxxxx - lavc 60.36.100 - avcodec.h
>> + Add AV_CODEC_FLAG_CLEAR.
>
> I'm not a huge fan of calling it just 'clear'. How about something more
> descriptive like 'wipe_frames'.
Wipe reminds me of the wipe effect. How about 'predecode_clear'?
>> +
>> 2023-12-xx - xxxxxxxxxxx - lavu 58.33.100 - imgutils.h
>> Add av_image_fill_color()
>>
>> diff --git a/doc/codecs.texi b/doc/codecs.texi
>> index 5b950b4560..0504a535f2 100644
>> --- a/doc/codecs.texi
>> +++ b/doc/codecs.texi
>> @@ -76,6 +76,20 @@ Apply interlaced motion estimation.
>> Use closed gop.
>> @item output_corrupt
>> Output even potentially corrupted frames.
>> +@item clear
>> +Clear the contents of the video buffer before decoding the next picture to it.
>> +
>> +Usually if only a part of a picture is affected by a decode error then the
>> +decoder (if it implements error concealment) tries to hide it by interpolating
>> +pixels from neighbouring areas or in some cases from the previous frame. Even
>> +without error concealment it is quite likely that the affected area will
>> +contain pixels from an earlier frame, due to frame pooling.
>> +
>> +For quality checking this might not be desirable, because it makes the errors
>> +less noticable. By using this flag, and combining it with disabled error
>> +concealment (@code{-ec 0}) it is possible to ensure that no leftover data from
>> +an earlier frame is presented in areas affected by decode errors.
>> +
>> @end table
>>
>> @item time_base @var{rational number}
>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>> index 7fb44e28f4..97848e942f 100644
>> --- a/libavcodec/avcodec.h
>> +++ b/libavcodec/avcodec.h
>> @@ -312,6 +312,10 @@ typedef struct RcOverride{
>> * loop filter.
>> */
>> #define AV_CODEC_FLAG_LOOP_FILTER (1 << 11)
>> +/**
>> + * Clear frame buffer contents before decoding.
>
> Clear the contents of each frame buffer after it is allocated with
> AVCodecContext.get_buffer2() and before anything is decoded into it.
>
> Note that this may have a significant performance cost.
ok.
>
>> + */
>> +#define AV_CODEC_FLAG_CLEAR (1 << 12)
>> /**
>> * Only decode/encode grayscale.
>> */
>> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
>> index 2cfb3fcf97..f9b18a2c35 100644
>> --- a/libavcodec/decode.c
>> +++ b/libavcodec/decode.c
>> @@ -1675,6 +1675,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>
>> validate_avframe_allocation(avctx, frame);
>>
>> + if (avctx->flags & AV_CODEC_FLAG_CLEAR && avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
>> + uint32_t color[4] = {0};
>> + ptrdiff_t linesize[4] = {frame->linesize[0], frame->linesize[1], frame->linesize[2], frame->linesize[3]};
>> + av_image_fill_color(frame->data, linesize, frame->format, color, frame->width, frame->height);
>
> Should this check for errors?
Lack of error checking is intentional. av_image_fill_color might not
support all pixel formats, definitely not support hwaccel formats. It
might make sense to warn the user once, but I don't think propagating the
error back is needed here.
I primarily thought of this as a QC feature (even thought about making the
color fill green by default to make it more noticeable (YUV green happens
to be 0,0,0), but for that I'd need similar checks for colorspaces to
what I have for fill_black())...
Regards,
Marton
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR
2023-12-07 22:47 ` Marton Balint
@ 2023-12-08 5:12 ` Rémi Denis-Courmont
0 siblings, 0 replies; 45+ messages in thread
From: Rémi Denis-Courmont @ 2023-12-08 5:12 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Hi,
Le 8 décembre 2023 00:47:13 GMT+02:00, Marton Balint <cus@passwd.hu> a écrit :
>
>
>On Thu, 7 Dec 2023, Anton Khirnov wrote:
>
>> Quoting Ronald S. Bultje (2023-12-07 02:44:36)
>>> Hi,
>>>
>>> On Wed, Dec 6, 2023 at 3:23 AM Marton Balint <cus@passwd.hu> wrote:
>>>
>>> > Signed-off-by: Marton Balint <cus@passwd.hu>
>>> > ---
>>> > doc/APIchanges | 3 +++
>>> > doc/codecs.texi | 14 ++++++++++++++
>>> > libavcodec/avcodec.h | 4 ++++
>>> > libavcodec/decode.c | 6 ++++++
>>> > libavcodec/options_table.h | 1 +
>>> > libavcodec/version.h | 2 +-
>>> > 6 files changed, 29 insertions(+), 1 deletion(-)
>>> >
>>> > diff --git a/doc/APIchanges b/doc/APIchanges
>>> > index 416e2bec5e..f839504a64 100644
>>> > --- a/doc/APIchanges
>>> > +++ b/doc/APIchanges
>>> > @@ -2,6 +2,9 @@ The last version increases of all libraries were on
>>> > 2023-02-09
>>> >
>>> > API changes, most recent first:
>>> >
>>> > +2023-12-xx - xxxxxxxxxxx - lavc 60.36.100 - avcodec.h
>>> > + Add AV_CODEC_FLAG_CLEAR.
>>> > +
>>> > 2023-12-xx - xxxxxxxxxxx - lavu 58.33.100 - imgutils.h
>>> > Add av_image_fill_color()
>>> >
>>> > diff --git a/doc/codecs.texi b/doc/codecs.texi
>>> > index 5b950b4560..0504a535f2 100644
>>> > --- a/doc/codecs.texi
>>> > +++ b/doc/codecs.texi
>>> > @@ -76,6 +76,20 @@ Apply interlaced motion estimation.
>>> > Use closed gop.
>>> > @item output_corrupt
>>> > Output even potentially corrupted frames.
>>> > +@item clear
>>> > +Clear the contents of the video buffer before decoding the next picture
>>> > to it.
>>> > +
>>> > +Usually if only a part of a picture is affected by a decode error then the
>>> > +decoder (if it implements error concealment) tries to hide it by
>>> > interpolating
>>> > +pixels from neighbouring areas or in some cases from the previous frame.
>>> > Even
>>> > +without error concealment it is quite likely that the affected area will
>>> > +contain pixels from an earlier frame, due to frame pooling.
>>> >
>>>
>>> No comment on the patch itself, but wouldn't our users (and the C standard
>>> itself) consider it a security issue to return stale
>>
>> I don't see the security issue in returning previously-returned frame
>> data.
>
>I guess what Ronald means that it is possible that the decoder frame pool allocates data in heap previously containing sensitive data, and that might never get overwritten in case of faulty input before passing it to the user.
>
>The simple fix for that is to clear frame pool buffers on creation?
>
>I am not sure if it is actually UB to read uninitialzied data from the heap though.
Reading uninitialised data is UB if the type representation is not surjective (e.g. bool, and potentially compound types with padding). Of course there are all sorts of other problems that could indirectly cause UB such as implicitly assuming that an integer fits a certain range and triggering an undefined overflow otherwise.
>
>Regards,
>Marton
>_______________________________________________
>ffmpeg-devel mailing list
>ffmpeg-devel@ffmpeg.org
>https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>To unsubscribe, visit link above, or email
>ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* [FFmpeg-devel] [PATCH v3 6/7] avutil/imgutils: add new function av_image_fill_color()
2023-12-07 16:15 ` Anton Khirnov
@ 2023-12-09 19:25 ` Marton Balint
2023-12-11 23:05 ` Stefano Sabatini
0 siblings, 1 reply; 45+ messages in thread
From: Marton Balint @ 2023-12-09 19:25 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marton Balint
v3: added flags argument.
Signed-off-by: Marton Balint <cus@passwd.hu>
---
doc/APIchanges | 3 +++
libavutil/imgutils.c | 6 +++---
libavutil/imgutils.h | 31 +++++++++++++++++++++++++++++++
libavutil/version.h | 2 +-
4 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 4a2dc1c44f..2b0326165e 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09
API changes, most recent first:
+2023-12-xx - xxxxxxxxxxx - lavu 58.33.100 - imgutils.h
+ Add av_image_fill_color().
+
2023-11-08 - b82957a66a7 - lavu 58.32.100 - channel_layout.h
Add AV_CH_LAYOUT_7POINT2POINT3 and AV_CHANNEL_LAYOUT_7POINT2POINT3.
Add AV_CH_LAYOUT_9POINT1POINT4_BACK and AV_CHANNEL_LAYOUT_9POINT1POINT4_BACK.
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index 278e30ee0f..aae40ba59a 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -579,9 +579,9 @@ static void memset_bytes(uint8_t *dst, size_t dst_size, uint8_t *clear,
// if it's a subsampled packed format).
#define MAX_BLOCK_SIZE 32
-static int image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
+int av_image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
enum AVPixelFormat pix_fmt, const uint32_t color[4],
- int width, int height)
+ int width, int height, int flags)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
int nb_planes = av_pix_fmt_count_planes(pix_fmt);
@@ -713,5 +713,5 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
colors[c] = color;
}
- return image_fill_color(dst_data, dst_linesize, pix_fmt, colors, width, height);
+ return av_image_fill_color(dst_data, dst_linesize, pix_fmt, colors, width, height, 0);
}
diff --git a/libavutil/imgutils.h b/libavutil/imgutils.h
index fa3bb101b1..a29ed46a39 100644
--- a/libavutil/imgutils.h
+++ b/libavutil/imgutils.h
@@ -339,6 +339,37 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
enum AVPixelFormat pix_fmt, enum AVColorRange range,
int width, int height);
+/**
+ * Overwrite the image data with a color. This is suitable for filling a
+ * sub-rectangle of an image, meaning the padding between the right most pixel
+ * and the left most pixel on the next line will not be overwritten. For some
+ * formats, the image size might be rounded up due to inherent alignment.
+ *
+ * If the pixel format has alpha, it is also replaced. Color component values
+ * are interpreted as native integers (or intfloats) regardless of actual pixel
+ * format endianness.
+ *
+ * This can return an error if the pixel format is not supported. Normally, all
+ * non-hwaccel pixel formats should be supported.
+ *
+ * Passing NULL for dst_data is allowed. Then the function returns whether the
+ * operation would have succeeded. (It can return an error if the pix_fmt is
+ * not supported.)
+ *
+ * @param dst_data data pointers to destination image
+ * @param dst_linesize linesizes for the destination image
+ * @param pix_fmt the pixel format of the image
+ * @param color the color components to be used for the fill
+ * @param width the width of the image in pixels
+ * @param height the height of the image in pixels
+ * @param flags currently unused
+ * @return 0 if the image data was filled, a negative AVERROR code otherwise
+ */
+int av_image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
+ enum AVPixelFormat pix_fmt, const uint32_t color[4],
+ int width, int height, int flags);
+
+
/**
* @}
*/
diff --git a/libavutil/version.h b/libavutil/version.h
index c5fa7c3692..0684996bf2 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 58
-#define LIBAVUTIL_VERSION_MINOR 32
+#define LIBAVUTIL_VERSION_MINOR 33
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
--
2.35.3
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR
2023-12-07 23:11 ` Marton Balint
@ 2023-12-11 20:49 ` Mark Thompson
2023-12-12 11:23 ` Anton Khirnov
1 sibling, 0 replies; 45+ messages in thread
From: Mark Thompson @ 2023-12-11 20:49 UTC (permalink / raw)
To: ffmpeg-devel
On 07/12/2023 23:11, Marton Balint wrote:
> On Thu, 7 Dec 2023, Anton Khirnov wrote:
>> Quoting Marton Balint (2023-12-06 09:22:20)
>>> Signed-off-by: Marton Balint <cus@passwd.hu>
>>> ---
>>> doc/APIchanges | 3 +++
>>> doc/codecs.texi | 14 ++++++++++++++
>>> libavcodec/avcodec.h | 4 ++++
>>> libavcodec/decode.c | 6 ++++++
>>> libavcodec/options_table.h | 1 +
>>> libavcodec/version.h | 2 +-
>>> 6 files changed, 29 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/doc/APIchanges b/doc/APIchanges
>>> index 416e2bec5e..f839504a64 100644
>>> --- a/doc/APIchanges
>>> +++ b/doc/APIchanges
>>> @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09
>>>
>>> API changes, most recent first:
>>>
>>> +2023-12-xx - xxxxxxxxxxx - lavc 60.36.100 - avcodec.h
>>> + Add AV_CODEC_FLAG_CLEAR.
>>
>> I'm not a huge fan of calling it just 'clear'. How about something more
>> descriptive like 'wipe_frames'.
>
> Wipe reminds me of the wipe effect. How about 'predecode_clear'?
>
>>> +
>>> 2023-12-xx - xxxxxxxxxxx - lavu 58.33.100 - imgutils.h
>>> Add av_image_fill_color()
>>>
>>> diff --git a/doc/codecs.texi b/doc/codecs.texi
>>> index 5b950b4560..0504a535f2 100644
>>> --- a/doc/codecs.texi
>>> +++ b/doc/codecs.texi
>>> @@ -76,6 +76,20 @@ Apply interlaced motion estimation.
>>> Use closed gop.
>>> @item output_corrupt
>>> Output even potentially corrupted frames.
>>> +@item clear
>>> +Clear the contents of the video buffer before decoding the next picture to it.
>>> +
>>> +Usually if only a part of a picture is affected by a decode error then the
>>> +decoder (if it implements error concealment) tries to hide it by interpolating
>>> +pixels from neighbouring areas or in some cases from the previous frame. Even
>>> +without error concealment it is quite likely that the affected area will
>>> +contain pixels from an earlier frame, due to frame pooling.
>>> +
>>> +For quality checking this might not be desirable, because it makes the errors
>>> +less noticable. By using this flag, and combining it with disabled error
>>> +concealment (@code{-ec 0}) it is possible to ensure that no leftover data from
>>> +an earlier frame is presented in areas affected by decode errors.
>>> +
>>> @end table
>>>
>>> @item time_base @var{rational number}
>>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>>> index 7fb44e28f4..97848e942f 100644
>>> --- a/libavcodec/avcodec.h
>>> +++ b/libavcodec/avcodec.h
>>> @@ -312,6 +312,10 @@ typedef struct RcOverride{
>>> * loop filter.
>>> */
>>> #define AV_CODEC_FLAG_LOOP_FILTER (1 << 11)
>>> +/**
>>> + * Clear frame buffer contents before decoding.
>>
>> Clear the contents of each frame buffer after it is allocated with
>> AVCodecContext.get_buffer2() and before anything is decoded into it.
>>
>> Note that this may have a significant performance cost.
>
> ok.
>
>>
>>> + */
>>> +#define AV_CODEC_FLAG_CLEAR (1 << 12)
>>> /**
>>> * Only decode/encode grayscale.
>>> */
>>> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
>>> index 2cfb3fcf97..f9b18a2c35 100644
>>> --- a/libavcodec/decode.c
>>> +++ b/libavcodec/decode.c
>>> @@ -1675,6 +1675,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>>
>>> validate_avframe_allocation(avctx, frame);
>>>
>>> + if (avctx->flags & AV_CODEC_FLAG_CLEAR && avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
>>> + uint32_t color[4] = {0};
>>> + ptrdiff_t linesize[4] = {frame->linesize[0], frame->linesize[1], frame->linesize[2], frame->linesize[3]};
>>> + av_image_fill_color(frame->data, linesize, frame->format, color, frame->width, frame->height);
>>
>> Should this check for errors?
>
> Lack of error checking is intentional. av_image_fill_color might not support all pixel formats, definitely not support hwaccel formats. It might make sense to warn the user once, but I don't think propagating the error back is needed here.
I don't think I agree with this? Even if you say it isn't, it still looks like a privacy and security feature and so people may treat it as such.
Consider a transcoding application with user-supplied ingest - without something like this, a malformed input from the user could leak random previously-deallocated memory, which could contain anything (frames from other users, private keys, etc.).
So, if the user has explicitly requested that frames are cleared then IMO it should either clear them or fail.
(I do think the feature is a good idea. Supporting hardware formats there is probably straightforward in at least some cases if useful.)
Thanks,
- Mark
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3 6/7] avutil/imgutils: add new function av_image_fill_color()
2023-12-09 19:25 ` [FFmpeg-devel] [PATCH v3 " Marton Balint
@ 2023-12-11 23:05 ` Stefano Sabatini
2023-12-12 18:45 ` Marton Balint
0 siblings, 1 reply; 45+ messages in thread
From: Stefano Sabatini @ 2023-12-11 23:05 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Marton Balint
On date Saturday 2023-12-09 20:25:07 +0100, Marton Balint wrote:
> v3: added flags argument.
>
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> doc/APIchanges | 3 +++
> libavutil/imgutils.c | 6 +++---
> libavutil/imgutils.h | 31 +++++++++++++++++++++++++++++++
> libavutil/version.h | 2 +-
> 4 files changed, 38 insertions(+), 4 deletions(-)
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 4a2dc1c44f..2b0326165e 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09
>
> API changes, most recent first:
>
> +2023-12-xx - xxxxxxxxxxx - lavu 58.33.100 - imgutils.h
> + Add av_image_fill_color().
> +
> 2023-11-08 - b82957a66a7 - lavu 58.32.100 - channel_layout.h
> Add AV_CH_LAYOUT_7POINT2POINT3 and AV_CHANNEL_LAYOUT_7POINT2POINT3.
> Add AV_CH_LAYOUT_9POINT1POINT4_BACK and AV_CHANNEL_LAYOUT_9POINT1POINT4_BACK.
> diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
> index 278e30ee0f..aae40ba59a 100644
> --- a/libavutil/imgutils.c
> +++ b/libavutil/imgutils.c
> @@ -579,9 +579,9 @@ static void memset_bytes(uint8_t *dst, size_t dst_size, uint8_t *clear,
> // if it's a subsampled packed format).
> #define MAX_BLOCK_SIZE 32
>
> -static int image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
> +int av_image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
> enum AVPixelFormat pix_fmt, const uint32_t color[4],
> - int width, int height)
> + int width, int height, int flags)
> {
> const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
> int nb_planes = av_pix_fmt_count_planes(pix_fmt);
> @@ -713,5 +713,5 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
> colors[c] = color;
> }
>
> - return image_fill_color(dst_data, dst_linesize, pix_fmt, colors, width, height);
> + return av_image_fill_color(dst_data, dst_linesize, pix_fmt, colors, width, height, 0);
> }
> diff --git a/libavutil/imgutils.h b/libavutil/imgutils.h
> index fa3bb101b1..a29ed46a39 100644
> --- a/libavutil/imgutils.h
> +++ b/libavutil/imgutils.h
> @@ -339,6 +339,37 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
> enum AVPixelFormat pix_fmt, enum AVColorRange range,
> int width, int height);
>
> +/**
> + * Overwrite the image data with a color. This is suitable for filling a
> + * sub-rectangle of an image, meaning the padding between the right most pixel
> + * and the left most pixel on the next line will not be overwritten. For some
> + * formats, the image size might be rounded up due to inherent alignment.
> + *
> + * If the pixel format has alpha, it is also replaced. Color component values
> + * are interpreted as native integers (or intfloats) regardless of actual pixel
> + * format endianness.
> + *
> + * This can return an error if the pixel format is not supported. Normally, all
> + * non-hwaccel pixel formats should be supported.
> + *
> + * Passing NULL for dst_data is allowed. Then the function returns whether the
> + * operation would have succeeded. (It can return an error if the pix_fmt is
> + * not supported.)
> + *
> + * @param dst_data data pointers to destination image
> + * @param dst_linesize linesizes for the destination image
> + * @param pix_fmt the pixel format of the image
> + * @param color the color components to be used for the fill
> + * @param width the width of the image in pixels
> + * @param height the height of the image in pixels
> + * @param flags currently unused
> + * @return 0 if the image data was filled, a negative AVERROR code otherwise
> + */
> +int av_image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
> + enum AVPixelFormat pix_fmt, const uint32_t color[4],
> + int width, int height, int flags);
> +
> +
ni+++: drop the duplicated empty line
Still LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR
2023-12-07 23:11 ` Marton Balint
2023-12-11 20:49 ` Mark Thompson
@ 2023-12-12 11:23 ` Anton Khirnov
2023-12-12 18:37 ` Marton Balint
2023-12-12 22:18 ` Michael Niedermayer
1 sibling, 2 replies; 45+ messages in thread
From: Anton Khirnov @ 2023-12-12 11:23 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Quoting Marton Balint (2023-12-08 00:11:21)
> Wipe reminds me of the wipe effect. How about 'predecode_clear'?
Fine with me I guess.
> >
> >> + */
> >> +#define AV_CODEC_FLAG_CLEAR (1 << 12)
> >> /**
> >> * Only decode/encode grayscale.
> >> */
> >> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> >> index 2cfb3fcf97..f9b18a2c35 100644
> >> --- a/libavcodec/decode.c
> >> +++ b/libavcodec/decode.c
> >> @@ -1675,6 +1675,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
> >>
> >> validate_avframe_allocation(avctx, frame);
> >>
> >> + if (avctx->flags & AV_CODEC_FLAG_CLEAR && avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
> >> + uint32_t color[4] = {0};
> >> + ptrdiff_t linesize[4] = {frame->linesize[0], frame->linesize[1], frame->linesize[2], frame->linesize[3]};
> >> + av_image_fill_color(frame->data, linesize, frame->format, color, frame->width, frame->height);
> >
> > Should this check for errors?
>
> Lack of error checking is intentional. av_image_fill_color might not
> support all pixel formats, definitely not support hwaccel formats. It
> might make sense to warn the user once, but I don't think propagating the
> error back is needed here.
>
> I primarily thought of this as a QC feature (even thought about making the
> color fill green by default to make it more noticeable (YUV green happens
> to be 0,0,0), but for that I'd need similar checks for colorspaces to
> what I have for fill_black())...
As Mark said, I expect people to want to use it as a security feature.
So either it should work reliably, or it should be made very clear that
it's for debugging only.
For non-hwaccel pixel formats, you can fall back on memsetting the
buffer to 0.
--
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR
2023-12-12 11:23 ` Anton Khirnov
@ 2023-12-12 18:37 ` Marton Balint
2023-12-13 8:59 ` Anton Khirnov
2023-12-12 22:18 ` Michael Niedermayer
1 sibling, 1 reply; 45+ messages in thread
From: Marton Balint @ 2023-12-12 18:37 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Tue, 12 Dec 2023, Anton Khirnov wrote:
> Quoting Marton Balint (2023-12-08 00:11:21)
>> Wipe reminds me of the wipe effect. How about 'predecode_clear'?
>
> Fine with me I guess.
>
>>>
>>>> + */
>>>> +#define AV_CODEC_FLAG_CLEAR (1 << 12)
>>>> /**
>>>> * Only decode/encode grayscale.
>>>> */
>>>> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
>>>> index 2cfb3fcf97..f9b18a2c35 100644
>>>> --- a/libavcodec/decode.c
>>>> +++ b/libavcodec/decode.c
>>>> @@ -1675,6 +1675,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>>>
>>>> validate_avframe_allocation(avctx, frame);
>>>>
>>>> + if (avctx->flags & AV_CODEC_FLAG_CLEAR && avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
>>>> + uint32_t color[4] = {0};
>>>> + ptrdiff_t linesize[4] = {frame->linesize[0], frame->linesize[1], frame->linesize[2], frame->linesize[3]};
>>>> + av_image_fill_color(frame->data, linesize, frame->format, color, frame->width, frame->height);
>>>
>>> Should this check for errors?
>>
>> Lack of error checking is intentional. av_image_fill_color might not
>> support all pixel formats, definitely not support hwaccel formats. It
>> might make sense to warn the user once, but I don't think propagating the
>> error back is needed here.
>>
>> I primarily thought of this as a QC feature (even thought about making the
>> color fill green by default to make it more noticeable (YUV green happens
>> to be 0,0,0), but for that I'd need similar checks for colorspaces to
>> what I have for fill_black())...
>
> As Mark said, I expect people to want to use it as a security feature.
> So either it should work reliably, or it should be made very clear that
> it's for debugging only.
>
> For non-hwaccel pixel formats, you can fall back on memsetting the
> buffer to 0.
IMHO for security you don't need to clear every frame, only new ones in
the buffer pool. Considering that it only affects the first few
frames, we might want to do that unconditionally, and not based on a
flag. And it is better to do this on the buffer level (because you might
not overwrite some bytes because of alignment with a color fill).
So for this flag, I'd rather make it clear it is not security-related, and
also that it has performance impact.
Regards,
Marton
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3 6/7] avutil/imgutils: add new function av_image_fill_color()
2023-12-11 23:05 ` Stefano Sabatini
@ 2023-12-12 18:45 ` Marton Balint
0 siblings, 0 replies; 45+ messages in thread
From: Marton Balint @ 2023-12-12 18:45 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Tue, 12 Dec 2023, Stefano Sabatini wrote:
> On date Saturday 2023-12-09 20:25:07 +0100, Marton Balint wrote:
>> v3: added flags argument.
>>
>> Signed-off-by: Marton Balint <cus@passwd.hu>
>> ---
>> doc/APIchanges | 3 +++
>> libavutil/imgutils.c | 6 +++---
>> libavutil/imgutils.h | 31 +++++++++++++++++++++++++++++++
>> libavutil/version.h | 2 +-
>> 4 files changed, 38 insertions(+), 4 deletions(-)
>>
[...]
>> +int av_image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
>> + enum AVPixelFormat pix_fmt, const uint32_t color[4],
>> + int width, int height, int flags);
>
>> +
>> +
>
> ni+++: drop the duplicated empty line
>
Ok, will apply patches 1-6 with that fixed.
Thanks,
Marton
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR
2023-12-12 11:23 ` Anton Khirnov
2023-12-12 18:37 ` Marton Balint
@ 2023-12-12 22:18 ` Michael Niedermayer
1 sibling, 0 replies; 45+ messages in thread
From: Michael Niedermayer @ 2023-12-12 22:18 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 2814 bytes --]
On Tue, Dec 12, 2023 at 12:23:38PM +0100, Anton Khirnov wrote:
> Quoting Marton Balint (2023-12-08 00:11:21)
> > Wipe reminds me of the wipe effect. How about 'predecode_clear'?
>
> Fine with me I guess.
>
> > >
> > >> + */
> > >> +#define AV_CODEC_FLAG_CLEAR (1 << 12)
> > >> /**
> > >> * Only decode/encode grayscale.
> > >> */
> > >> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> > >> index 2cfb3fcf97..f9b18a2c35 100644
> > >> --- a/libavcodec/decode.c
> > >> +++ b/libavcodec/decode.c
> > >> @@ -1675,6 +1675,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
> > >>
> > >> validate_avframe_allocation(avctx, frame);
> > >>
> > >> + if (avctx->flags & AV_CODEC_FLAG_CLEAR && avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
> > >> + uint32_t color[4] = {0};
> > >> + ptrdiff_t linesize[4] = {frame->linesize[0], frame->linesize[1], frame->linesize[2], frame->linesize[3]};
> > >> + av_image_fill_color(frame->data, linesize, frame->format, color, frame->width, frame->height);
> > >
> > > Should this check for errors?
> >
> > Lack of error checking is intentional. av_image_fill_color might not
> > support all pixel formats, definitely not support hwaccel formats. It
> > might make sense to warn the user once, but I don't think propagating the
> > error back is needed here.
> >
> > I primarily thought of this as a QC feature (even thought about making the
> > color fill green by default to make it more noticeable (YUV green happens
> > to be 0,0,0), but for that I'd need similar checks for colorspaces to
> > what I have for fill_black())...
>
> As Mark said, I expect people to want to use it as a security feature.
> So either it should work reliably, or it should be made very clear that
> it's for debugging only.
>
> For non-hwaccel pixel formats, you can fall back on memsetting the
> buffer to 0.
For security, there may be other less vissible things that should be cleared too
for example B frames in some codecs can use motion vectors from surrounding frames.
Also the correct thing is to apply error concealment to replace all parts which
have not been filled in. Not to leave them uninitialized.
Not only does that preserve privacy it also produces much better looking frames
We have error concealment code, it should be used.
Not arguing against this feature here. Just saying for security/privacy it has
a price as it needs to be done before we know if a frame is damaged, while error
concealment is done only on actually damaged frames
Of course you may want to do both to be really "sure" ...
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Nations do behave wisely once they have exhausted all other alternatives.
-- Abba Eban
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR
2023-12-12 18:37 ` Marton Balint
@ 2023-12-13 8:59 ` Anton Khirnov
2023-12-13 17:09 ` Marton Balint
0 siblings, 1 reply; 45+ messages in thread
From: Anton Khirnov @ 2023-12-13 8:59 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Quoting Marton Balint (2023-12-12 19:37:57)
>
>
> On Tue, 12 Dec 2023, Anton Khirnov wrote:
>
> > Quoting Marton Balint (2023-12-08 00:11:21)
> >> Wipe reminds me of the wipe effect. How about 'predecode_clear'?
> >
> > Fine with me I guess.
> >
> >>>
> >>>> + */
> >>>> +#define AV_CODEC_FLAG_CLEAR (1 << 12)
> >>>> /**
> >>>> * Only decode/encode grayscale.
> >>>> */
> >>>> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> >>>> index 2cfb3fcf97..f9b18a2c35 100644
> >>>> --- a/libavcodec/decode.c
> >>>> +++ b/libavcodec/decode.c
> >>>> @@ -1675,6 +1675,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
> >>>>
> >>>> validate_avframe_allocation(avctx, frame);
> >>>>
> >>>> + if (avctx->flags & AV_CODEC_FLAG_CLEAR && avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
> >>>> + uint32_t color[4] = {0};
> >>>> + ptrdiff_t linesize[4] = {frame->linesize[0], frame->linesize[1], frame->linesize[2], frame->linesize[3]};
> >>>> + av_image_fill_color(frame->data, linesize, frame->format, color, frame->width, frame->height);
> >>>
> >>> Should this check for errors?
> >>
> >> Lack of error checking is intentional. av_image_fill_color might not
> >> support all pixel formats, definitely not support hwaccel formats. It
> >> might make sense to warn the user once, but I don't think propagating the
> >> error back is needed here.
> >>
> >> I primarily thought of this as a QC feature (even thought about making the
> >> color fill green by default to make it more noticeable (YUV green happens
> >> to be 0,0,0), but for that I'd need similar checks for colorspaces to
> >> what I have for fill_black())...
> >
> > As Mark said, I expect people to want to use it as a security feature.
> > So either it should work reliably, or it should be made very clear that
> > it's for debugging only.
> >
> > For non-hwaccel pixel formats, you can fall back on memsetting the
> > buffer to 0.
>
> IMHO for security you don't need to clear every frame, only new ones in
> the buffer pool. Considering that it only affects the first few
> frames, we might want to do that unconditionally, and not based on a
> flag. And it is better to do this on the buffer level (because you might
> not overwrite some bytes because of alignment with a color fill).
>
> So for this flag, I'd rather make it clear it is not security-related, and
> also that it has performance impact.
So then maybe make a FF_EC flag?
--
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR
2023-12-13 8:59 ` Anton Khirnov
@ 2023-12-13 17:09 ` Marton Balint
2023-12-14 8:03 ` Anton Khirnov
0 siblings, 1 reply; 45+ messages in thread
From: Marton Balint @ 2023-12-13 17:09 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Wed, 13 Dec 2023, Anton Khirnov wrote:
> Quoting Marton Balint (2023-12-12 19:37:57)
>>
>>
>> On Tue, 12 Dec 2023, Anton Khirnov wrote:
>>
>>> Quoting Marton Balint (2023-12-08 00:11:21)
>>>> Wipe reminds me of the wipe effect. How about 'predecode_clear'?
>>>
>>> Fine with me I guess.
>>>
>>>>>
>>>>>> + */
>>>>>> +#define AV_CODEC_FLAG_CLEAR (1 << 12)
>>>>>> /**
>>>>>> * Only decode/encode grayscale.
>>>>>> */
>>>>>> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
>>>>>> index 2cfb3fcf97..f9b18a2c35 100644
>>>>>> --- a/libavcodec/decode.c
>>>>>> +++ b/libavcodec/decode.c
>>>>>> @@ -1675,6 +1675,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>>>>>
>>>>>> validate_avframe_allocation(avctx, frame);
>>>>>>
>>>>>> + if (avctx->flags & AV_CODEC_FLAG_CLEAR && avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
>>>>>> + uint32_t color[4] = {0};
>>>>>> + ptrdiff_t linesize[4] = {frame->linesize[0], frame->linesize[1], frame->linesize[2], frame->linesize[3]};
>>>>>> + av_image_fill_color(frame->data, linesize, frame->format, color, frame->width, frame->height);
>>>>>
>>>>> Should this check for errors?
>>>>
>>>> Lack of error checking is intentional. av_image_fill_color might not
>>>> support all pixel formats, definitely not support hwaccel formats. It
>>>> might make sense to warn the user once, but I don't think propagating the
>>>> error back is needed here.
>>>>
>>>> I primarily thought of this as a QC feature (even thought about making the
>>>> color fill green by default to make it more noticeable (YUV green happens
>>>> to be 0,0,0), but for that I'd need similar checks for colorspaces to
>>>> what I have for fill_black())...
>>>
>>> As Mark said, I expect people to want to use it as a security feature.
>>> So either it should work reliably, or it should be made very clear that
>>> it's for debugging only.
>>>
>>> For non-hwaccel pixel formats, you can fall back on memsetting the
>>> buffer to 0.
>>
>> IMHO for security you don't need to clear every frame, only new ones in
>> the buffer pool. Considering that it only affects the first few
>> frames, we might want to do that unconditionally, and not based on a
>> flag. And it is better to do this on the buffer level (because you might
>> not overwrite some bytes because of alignment with a color fill).
>>
>> So for this flag, I'd rather make it clear it is not security-related, and
>> also that it has performance impact.
>
> So then maybe make a FF_EC flag?
I thought about using that, but there are plenty of error concealment
code which only checks if avctx->error_concealment is nonzero or zero, and
not specific EC flags. So unless that is fixed (which might break existing
behaviour) one cannot introduce a new EC flag and disable error
concealment at the same time...
Regards,
Marton
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR
2023-12-13 17:09 ` Marton Balint
@ 2023-12-14 8:03 ` Anton Khirnov
0 siblings, 0 replies; 45+ messages in thread
From: Anton Khirnov @ 2023-12-14 8:03 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Quoting Marton Balint (2023-12-13 18:09:45)
> On Wed, 13 Dec 2023, Anton Khirnov wrote:
> > Quoting Marton Balint (2023-12-12 19:37:57)
> >>
> >> So for this flag, I'd rather make it clear it is not security-related, and
> >> also that it has performance impact.
> >
> > So then maybe make a FF_EC flag?
>
> I thought about using that, but there are plenty of error concealment
> code which only checks if avctx->error_concealment is nonzero or zero, and
> not specific EC flags. So unless that is fixed (which might break existing
> behaviour) one cannot introduce a new EC flag and disable error
> concealment at the same time...
If you don't feel like fixing all the places that do such checks, you
could instead
* add a flag in DecodeContext
* in ff_decode_preinit(), map your new FF_EC_PREDECODE_CLEAR to the
internal flag
* clear FF_EC_PREDECODE_CLEAR in AVCodecContext
That should avoid breaking any existing behavior.
--
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 45+ messages in thread
end of thread, other threads:[~2023-12-14 8:03 UTC | newest]
Thread overview: 45+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-03 0:27 [FFmpeg-devel] [PATCH 1/7] avutil/tests/imgutils: factorize basic tests to new function Marton Balint
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 2/7] avutil/tests/imgutils: add tests for av_image_fill_black() Marton Balint
2023-12-03 23:47 ` Stefano Sabatini
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 3/7] avutil/imgutils: fix av_image_fill_black() for some pixel formats Marton Balint
2023-12-04 0:23 ` Stefano Sabatini
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 4/7] avutil/imgutils: add support for 32bit pixel format for av_image_fill_black() Marton Balint
2023-12-04 0:52 ` Stefano Sabatini
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 5/7] avutil/imgutils: factorize a fill color function Marton Balint
2023-12-04 1:04 ` Stefano Sabatini
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 6/7] avutil/imgutils: add new function av_image_fill_color() Marton Balint
2023-12-04 1:07 ` Stefano Sabatini
2023-12-03 0:27 ` [FFmpeg-devel] [PATCH 7/7] avcodec: add AV_CODEC_FLAG_CLEAR Marton Balint
2023-12-03 21:31 ` [FFmpeg-devel] [PATCH 1/7] avutil/tests/imgutils: factorize basic tests to new function Stefano Sabatini
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 " Marton Balint
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 2/7] avutil/tests/imgutils: add tests for av_image_fill_black() Marton Balint
2023-12-06 22:46 ` Stefano Sabatini
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 3/7] avutil/imgutils: fix av_image_fill_black() for some pixel formats Marton Balint
2023-12-06 22:47 ` Stefano Sabatini
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 4/7] avutil/imgutils: add support for 32bit pixel format for av_image_fill_black() Marton Balint
2023-12-06 22:48 ` Stefano Sabatini
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 5/7] avutil/imgutils: factorize a fill color function Marton Balint
2023-12-06 22:52 ` Stefano Sabatini
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 6/7] avutil/imgutils: add new function av_image_fill_color() Marton Balint
2023-12-06 22:53 ` Stefano Sabatini
2023-12-07 16:15 ` Anton Khirnov
2023-12-09 19:25 ` [FFmpeg-devel] [PATCH v3 " Marton Balint
2023-12-11 23:05 ` Stefano Sabatini
2023-12-12 18:45 ` Marton Balint
2023-12-06 8:22 ` [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR Marton Balint
2023-12-06 22:57 ` Stefano Sabatini
2023-12-07 1:44 ` Ronald S. Bultje
2023-12-07 16:19 ` Anton Khirnov
2023-12-07 22:47 ` Marton Balint
2023-12-08 5:12 ` Rémi Denis-Courmont
2023-12-07 2:37 ` Vittorio Giovara
2023-12-07 16:30 ` Anton Khirnov
2023-12-07 23:11 ` Marton Balint
2023-12-11 20:49 ` Mark Thompson
2023-12-12 11:23 ` Anton Khirnov
2023-12-12 18:37 ` Marton Balint
2023-12-13 8:59 ` Anton Khirnov
2023-12-13 17:09 ` Marton Balint
2023-12-14 8:03 ` Anton Khirnov
2023-12-12 22:18 ` Michael Niedermayer
2023-12-06 22:43 ` [FFmpeg-devel] [PATCH v2 1/7] avutil/tests/imgutils: factorize basic tests to new function Stefano Sabatini
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git