* [FFmpeg-devel] [PATCH 2/7] swscale/tests/swscale: Split sws_getContext()
2024-02-14 22:06 [FFmpeg-devel] [PATCH 1/7] swscale/tests/swscale: Implement isALPHA() using AVPixFmtDescriptor Michael Niedermayer
@ 2024-02-14 22:06 ` Michael Niedermayer
2024-02-14 22:06 ` [FFmpeg-devel] [PATCH 3/7] swscale/tests/swscale: Compute chroma and alpha between gray and opaque frames too Michael Niedermayer
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Michael Niedermayer @ 2024-02-14 22:06 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libswscale/tests/swscale.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index f853bc4c913..6792fcaa3dc 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -30,6 +30,7 @@
#include "libavutil/mem.h"
#include "libavutil/avutil.h"
#include "libavutil/crc.h"
+#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/lfg.h"
@@ -165,10 +166,26 @@ static int doTest(const uint8_t * const ref[4], int refStride[4], int w, int h,
}
}
- dstContext = sws_getContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat,
- flags, NULL, NULL, NULL);
+ dstContext = sws_alloc_context();
if (!dstContext) {
- fprintf(stderr, "Failed to get %s ---> %s\n",
+ fprintf(stderr, "Failed to alloc %s ---> %s\n",
+ desc_src->name, desc_dst->name);
+ res = -1;
+ goto end;
+ }
+
+ av_opt_set_int(dstContext, "sws_flags", flags, 0);
+ av_opt_set_int(dstContext, "srcw", srcW, 0);
+ av_opt_set_int(dstContext, "srch", srcH, 0);
+ av_opt_set_int(dstContext, "dstw", dstW, 0);
+ av_opt_set_int(dstContext, "dsth", dstH, 0);
+ av_opt_set_int(dstContext, "src_format", srcFormat, 0);
+ av_opt_set_int(dstContext, "dst_format", dstFormat, 0);
+ av_opt_set(dstContext, "alphablend", "none", 0);
+
+ if (sws_init_context(dstContext, NULL, NULL) < 0) {
+ sws_freeContext(dstContext);
+ fprintf(stderr, "Failed to init %s ---> %s\n",
desc_src->name, desc_dst->name);
res = -1;
goto end;
--
2.17.1
_______________________________________________
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] 9+ messages in thread
* [FFmpeg-devel] [PATCH 3/7] swscale/tests/swscale: Compute chroma and alpha between gray and opaque frames too
2024-02-14 22:06 [FFmpeg-devel] [PATCH 1/7] swscale/tests/swscale: Implement isALPHA() using AVPixFmtDescriptor Michael Niedermayer
2024-02-14 22:06 ` [FFmpeg-devel] [PATCH 2/7] swscale/tests/swscale: Split sws_getContext() Michael Niedermayer
@ 2024-02-14 22:06 ` Michael Niedermayer
2024-02-14 22:06 ` [FFmpeg-devel] [PATCH 4/7] swscale/tests/swscale: Test a wider range of flag combinations Michael Niedermayer
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Michael Niedermayer @ 2024-02-14 22:06 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libswscale/tests/swscale.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index 6792fcaa3dc..facdbbae481 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -71,6 +71,21 @@ static uint64_t getSSD(const uint8_t *src1, const uint8_t *src2,
return ssd;
}
+static uint64_t getSSD0(int ref, const uint8_t *src1, int stride1,
+ int w, int h)
+{
+ int x, y;
+ uint64_t ssd = 0;
+
+ for (y = 0; y < h; y++) {
+ for (x = 0; x < w; x++) {
+ int d = src1[x + y * stride1] - ref;
+ ssd += d * d;
+ }
+ }
+ return ssd;
+}
+
struct Results {
uint64_t ssdY;
uint64_t ssdU;
@@ -239,9 +254,17 @@ static int doTest(const uint8_t * const ref[4], int refStride[4], int w, int h,
(w + 1) >> 1, (h + 1) >> 1);
ssdV = getSSD(ref[2], out[2], refStride[2], refStride[2],
(w + 1) >> 1, (h + 1) >> 1);
+ } else {
+ ssdU = getSSD0(128, out[1], refStride[1],
+ (w + 1) >> 1, (h + 1) >> 1);
+ ssdV = getSSD0(128, out[2], refStride[2],
+ (w + 1) >> 1, (h + 1) >> 1);
}
- if (isALPHA(srcFormat) && isALPHA(dstFormat))
+ if (isALPHA(srcFormat) && isALPHA(dstFormat)) {
ssdA = getSSD(ref[3], out[3], refStride[3], refStride[3], w, h);
+ } else {
+ ssdA = getSSD0(0xFF, out[3], refStride[3], w, h);
+ }
ssdY /= w * h;
ssdU /= w * h / 4;
--
2.17.1
_______________________________________________
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] 9+ messages in thread
* [FFmpeg-devel] [PATCH 4/7] swscale/tests/swscale: Test a wider range of flag combinations
2024-02-14 22:06 [FFmpeg-devel] [PATCH 1/7] swscale/tests/swscale: Implement isALPHA() using AVPixFmtDescriptor Michael Niedermayer
2024-02-14 22:06 ` [FFmpeg-devel] [PATCH 2/7] swscale/tests/swscale: Split sws_getContext() Michael Niedermayer
2024-02-14 22:06 ` [FFmpeg-devel] [PATCH 3/7] swscale/tests/swscale: Compute chroma and alpha between gray and opaque frames too Michael Niedermayer
@ 2024-02-14 22:06 ` Michael Niedermayer
2024-02-14 22:06 ` [FFmpeg-devel] [PATCH 5/7] swscale/tests/swscale: Allow comparing a subset of cases to a reference file Michael Niedermayer
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Michael Niedermayer @ 2024-02-14 22:06 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libswscale/tests/swscale.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index facdbbae481..07d0af4377e 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -296,8 +296,10 @@ static void selfTest(const uint8_t * const ref[4], int refStride[4],
enum AVPixelFormat srcFormat_in,
enum AVPixelFormat dstFormat_in)
{
- const int flags[] = { SWS_FAST_BILINEAR, SWS_BILINEAR, SWS_BICUBIC,
- SWS_X, SWS_POINT, SWS_AREA, 0 };
+ const int flags[] = { SWS_FAST_BILINEAR,
+ SWS_BILINEAR, SWS_BICUBIC,
+ SWS_X|SWS_BITEXACT , SWS_POINT , SWS_AREA|SWS_ACCURATE_RND,
+ SWS_BICUBIC|SWS_FULL_CHR_H_INT|SWS_FULL_CHR_H_INP, 0};
const int srcW = w;
const int srcH = h;
const int dstW[] = { srcW - srcW / 3, srcW, srcW + srcW / 3, 0 };
--
2.17.1
_______________________________________________
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] 9+ messages in thread
* [FFmpeg-devel] [PATCH 5/7] swscale/tests/swscale: Allow comparing a subset of cases to a reference file
2024-02-14 22:06 [FFmpeg-devel] [PATCH 1/7] swscale/tests/swscale: Implement isALPHA() using AVPixFmtDescriptor Michael Niedermayer
` (2 preceding siblings ...)
2024-02-14 22:06 ` [FFmpeg-devel] [PATCH 4/7] swscale/tests/swscale: Test a wider range of flag combinations Michael Niedermayer
@ 2024-02-14 22:06 ` Michael Niedermayer
2024-02-14 22:06 ` [FFmpeg-devel] [PATCH 6/7] swscale/tests/swscale: Highlight cases that worsened Michael Niedermayer
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Michael Niedermayer @ 2024-02-14 22:06 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Testing all cases exhaustively is slow
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libswscale/tests/swscale.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index 07d0af4377e..68434fb7baf 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -33,6 +33,7 @@
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/lfg.h"
+#include "libavutil/sfc64.h"
#include "libswscale/swscale.h"
@@ -56,6 +57,9 @@ static av_always_inline int isALPHA(enum AVPixelFormat pix_fmt)
return desc->flags & AV_PIX_FMT_FLAG_ALPHA;
}
+static double prob = 1;
+FFSFC64 prng_state;
+
static uint64_t getSSD(const uint8_t *src1, const uint8_t *src2,
int stride1, int stride2, int w, int h)
{
@@ -117,6 +121,9 @@ static int doTest(const uint8_t * const ref[4], int refStride[4], int w, int h,
uint32_t crc = 0;
int res = 0;
+ if (ff_sfc64_get(&prng_state) > UINT64_MAX * prob)
+ return 0;
+
if (cur_srcFormat != srcFormat || cur_srcW != srcW || cur_srcH != srcH) {
struct SwsContext *srcContext = NULL;
int p;
@@ -449,6 +456,8 @@ int main(int argc, char **argv)
fprintf(stderr, "invalid pixel format %s\n", argv[i + 1]);
return -1;
}
+ } else if (!strcmp(argv[i], "-p")) {
+ prob = atof(argv[i + 1]);
} else {
bad_option:
fprintf(stderr, "bad option or argument missing (%s)\n", argv[i]);
@@ -456,6 +465,8 @@ bad_option:
}
}
+ ff_sfc64_init(&prng_state, 0, 0, 0, 12);
+
sws = sws_getContext(W / 12, H / 12, AV_PIX_FMT_RGB32, W, H,
AV_PIX_FMT_YUVA420P, SWS_BILINEAR, NULL, NULL, NULL);
--
2.17.1
_______________________________________________
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] 9+ messages in thread
* [FFmpeg-devel] [PATCH 6/7] swscale/tests/swscale: Highlight cases that worsened
2024-02-14 22:06 [FFmpeg-devel] [PATCH 1/7] swscale/tests/swscale: Implement isALPHA() using AVPixFmtDescriptor Michael Niedermayer
` (3 preceding siblings ...)
2024-02-14 22:06 ` [FFmpeg-devel] [PATCH 5/7] swscale/tests/swscale: Allow comparing a subset of cases to a reference file Michael Niedermayer
@ 2024-02-14 22:06 ` Michael Niedermayer
2024-02-14 22:06 ` [FFmpeg-devel] [PATCH 7/7] swscale/tests/swscale: Add help text Michael Niedermayer
2024-02-15 6:20 ` [FFmpeg-devel] [PATCH 1/7] swscale/tests/swscale: Implement isALPHA() using AVPixFmtDescriptor Anton Khirnov
6 siblings, 0 replies; 9+ messages in thread
From: Michael Niedermayer @ 2024-02-14 22:06 UTC (permalink / raw)
To: FFmpeg development discussions and patches
also highlight cases that worsened alot in uppercase
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libswscale/tests/swscale.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index 68434fb7baf..32e1f96be2b 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -285,6 +285,15 @@ static int doTest(const uint8_t * const ref[4], int refStride[4], int w, int h,
av_free(out[i]);
}
+ if(r){
+ if(ssdY>r->ssdY*1.02+1 || ssdU>r->ssdU*1.02+1 || ssdV>r->ssdV*1.02+1|| ssdA>r->ssdA*1.02+1)
+ printf("WORSE SSD=%5"PRId64",%5"PRId64",%5"PRId64",%5"PRId64"",
+ r->ssdY, r->ssdU, r->ssdV, r->ssdA);
+ else if(ssdY>r->ssdY || ssdU>r->ssdU || ssdV>r->ssdV|| ssdA>r->ssdA)
+ printf("worse SSD=%5"PRId64",%5"PRId64",%5"PRId64",%5"PRId64"",
+ r->ssdY, r->ssdU, r->ssdV, r->ssdA);
+ }
+
printf(" CRC=%08x SSD=%5"PRId64 ",%5"PRId64 ",%5"PRId64 ",%5"PRId64 "\n",
crc, ssdY, ssdU, ssdV, ssdA);
--
2.17.1
_______________________________________________
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] 9+ messages in thread
* [FFmpeg-devel] [PATCH 7/7] swscale/tests/swscale: Add help text
2024-02-14 22:06 [FFmpeg-devel] [PATCH 1/7] swscale/tests/swscale: Implement isALPHA() using AVPixFmtDescriptor Michael Niedermayer
` (4 preceding siblings ...)
2024-02-14 22:06 ` [FFmpeg-devel] [PATCH 6/7] swscale/tests/swscale: Highlight cases that worsened Michael Niedermayer
@ 2024-02-14 22:06 ` Michael Niedermayer
2024-02-15 6:20 ` [FFmpeg-devel] [PATCH 1/7] swscale/tests/swscale: Implement isALPHA() using AVPixFmtDescriptor Anton Khirnov
6 siblings, 0 replies; 9+ messages in thread
From: Michael Niedermayer @ 2024-02-14 22:06 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libswscale/tests/swscale.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index 32e1f96be2b..cf8d04de898 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -437,6 +437,25 @@ int main(int argc, char **argv)
return -1;
for (i = 1; i < argc; i += 2) {
+ if (!strcmp(argv[i], "-help") || !strcmp(argv[i], "--help")) {
+ fprintf(stderr,
+ "swscale [options...]\n"
+ " -help\n"
+ " This text\n"
+ " -ref <file>\n"
+ " Uses file as reference to compae tests againsts. Tests that have become worse will contain the string worse or WORSE\n"
+ " -p <number between 0.0 and 1.0>\n"
+ " The percentage of tests or comparissions to perform. Doing all tests will take long and generate over a hundread MB text output\n"
+ " It is often convenient to perform a random subset\n"
+ " -dst <pixfmt>\n"
+ " Only test the specified destination pixel format\n"
+ " -src <pixfmt>\n"
+ " Only test the specified source pixel format\n"
+ " -cpuflags <cpuflags>\n"
+ " Uses the specified cpuflags in teh tests\n"
+ );
+ goto error;
+ }
if (argv[i][0] != '-' || i + 1 == argc)
goto bad_option;
if (!strcmp(argv[i], "-ref")) {
@@ -469,7 +488,7 @@ int main(int argc, char **argv)
prob = atof(argv[i + 1]);
} else {
bad_option:
- fprintf(stderr, "bad option or argument missing (%s)\n", argv[i]);
+ fprintf(stderr, "bad option or argument missing (%s) see -help\n", argv[i]);
goto error;
}
}
--
2.17.1
_______________________________________________
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] 9+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/7] swscale/tests/swscale: Implement isALPHA() using AVPixFmtDescriptor
2024-02-14 22:06 [FFmpeg-devel] [PATCH 1/7] swscale/tests/swscale: Implement isALPHA() using AVPixFmtDescriptor Michael Niedermayer
` (5 preceding siblings ...)
2024-02-14 22:06 ` [FFmpeg-devel] [PATCH 7/7] swscale/tests/swscale: Add help text Michael Niedermayer
@ 2024-02-15 6:20 ` Anton Khirnov
2024-02-15 17:55 ` Michael Niedermayer
6 siblings, 1 reply; 9+ messages in thread
From: Anton Khirnov @ 2024-02-15 6:20 UTC (permalink / raw)
To: FFmpeg development discussions and patches
I remember wondering why was this not run as a FATE test.
--
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] 9+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/7] swscale/tests/swscale: Implement isALPHA() using AVPixFmtDescriptor
2024-02-15 6:20 ` [FFmpeg-devel] [PATCH 1/7] swscale/tests/swscale: Implement isALPHA() using AVPixFmtDescriptor Anton Khirnov
@ 2024-02-15 17:55 ` Michael Niedermayer
0 siblings, 0 replies; 9+ messages in thread
From: Michael Niedermayer @ 2024-02-15 17:55 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 504 bytes --]
On Thu, Feb 15, 2024 at 07:20:32AM +0100, Anton Khirnov wrote:
> I remember wondering why was this not run as a FATE test.
the full reference file is > 100mb and the full test takes longer than the
full fate test.
This patchset makes it possibly to run random subsets of the test
so its a step toward enabling this for fate
i will apply it
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
You can kill me, but you cannot change the truth.
[-- 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] 9+ messages in thread