* Re: [FFmpeg-devel] [PATCH] fate: add rpza encoder tests
2023-09-07 8:10 [FFmpeg-devel] [PATCH] fate: add rpza encoder tests Paul B Mahol
2023-09-07 8:23 ` Andreas Rheinhardt
@ 2023-09-07 9:11 ` Paul B Mahol
1 sibling, 0 replies; 3+ messages in thread
From: Paul B Mahol @ 2023-09-07 9:11 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1: Type: text/plain, Size: 125 bytes --]
Attached. Now without floats.
On Thu, Sep 7, 2023 at 10:10 AM Paul B Mahol <onemda@gmail.com> wrote:
> Attached.
>
[-- Attachment #2: 0002-fate-add-rpza-encoder-tests.patch --]
[-- Type: text/x-patch, Size: 2578 bytes --]
From 5e9d20d393659c1c94ac328237699c3aa65f3ac9 Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Thu, 7 Sep 2023 10:08:30 +0200
Subject: [PATCH 2/2] fate: add rpza encoder tests
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
tests/fate/vcodec.mak | 4 ++++
tests/ref/vsynth/vsynth1-rpza | 4 ++++
tests/ref/vsynth/vsynth2-rpza | 4 ++++
tests/ref/vsynth/vsynth3-rpza | 4 ++++
4 files changed, 16 insertions(+)
create mode 100644 tests/ref/vsynth/vsynth1-rpza
create mode 100644 tests/ref/vsynth/vsynth2-rpza
create mode 100644 tests/ref/vsynth/vsynth3-rpza
diff --git a/tests/fate/vcodec.mak b/tests/fate/vcodec.mak
index e32d28c556..45ed88da96 100644
--- a/tests/fate/vcodec.mak
+++ b/tests/fate/vcodec.mak
@@ -396,6 +396,10 @@ fate-vsynth%-roqvideo: ENCOPTS = -frames 5
fate-vsynth%-roqvideo: RAWDECOPTS = -r 30
fate-vsynth%-roqvideo: FMT = roq
+FATE_VCODEC_SCALE-$(call ENCDEC, RPZA, MOV) += rpza
+fate-vsynth%-rpza: CODEC = rpza
+fate-vsynth%-rpza: FMT = mov
+
FATE_VCODEC-$(call ENCDEC, RV10, RM) += rv10
fate-vsynth%-rv10: ENCOPTS = -qscale 10
fate-vsynth%-rv10: FMT = rm
diff --git a/tests/ref/vsynth/vsynth1-rpza b/tests/ref/vsynth/vsynth1-rpza
new file mode 100644
index 0000000000..b238b245d3
--- /dev/null
+++ b/tests/ref/vsynth/vsynth1-rpza
@@ -0,0 +1,4 @@
+e4e9660c4a13709b277aac42419b9a23 *tests/data/fate/vsynth1-rpza.mov
+10138529 tests/data/fate/vsynth1-rpza.mov
+99bece160cfb0da47f446b60d42fa3ae *tests/data/fate/vsynth1-rpza.out.rawvideo
+stddev: 4.06 PSNR: 35.94 MAXDIFF: 47 bytes: 7603200/ 7603200
diff --git a/tests/ref/vsynth/vsynth2-rpza b/tests/ref/vsynth/vsynth2-rpza
new file mode 100644
index 0000000000..847844f384
--- /dev/null
+++ b/tests/ref/vsynth/vsynth2-rpza
@@ -0,0 +1,4 @@
+e7c5b381214556507f64052ba26ccb68 *tests/data/fate/vsynth2-rpza.mov
+9975182 tests/data/fate/vsynth2-rpza.mov
+eb3f0c974ed17ede7cd3ce30ce417d8d *tests/data/fate/vsynth2-rpza.out.rawvideo
+stddev: 2.81 PSNR: 39.14 MAXDIFF: 19 bytes: 7603200/ 7603200
diff --git a/tests/ref/vsynth/vsynth3-rpza b/tests/ref/vsynth/vsynth3-rpza
new file mode 100644
index 0000000000..c933a44c4b
--- /dev/null
+++ b/tests/ref/vsynth/vsynth3-rpza
@@ -0,0 +1,4 @@
+791ad5931c5d54eff406c639be0c79e2 *tests/data/fate/vsynth3-rpza.mov
+130493 tests/data/fate/vsynth3-rpza.mov
+19f61c34cbdef98b0f4aca6c19f59ed4 *tests/data/fate/vsynth3-rpza.out.rawvideo
+stddev: 4.35 PSNR: 35.35 MAXDIFF: 46 bytes: 86700/ 86700
--
2.39.1
[-- Attachment #3: 0001-avcodec-rpzaenc-replace-float-point-calculations-wit.patch --]
[-- Type: text/x-patch, Size: 3687 bytes --]
From 8c2df35828b5b15a1c9915b118a8f8ad6ba08ee6 Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Thu, 7 Sep 2023 11:00:38 +0200
Subject: [PATCH 1/2] avcodec/rpzaenc: replace float-point calculations with
integer ones
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
libavcodec/rpzaenc.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/libavcodec/rpzaenc.c b/libavcodec/rpzaenc.c
index a399d55c93..9da929718a 100644
--- a/libavcodec/rpzaenc.c
+++ b/libavcodec/rpzaenc.c
@@ -30,6 +30,7 @@
#include "avcodec.h"
#include "codec_internal.h"
#include "encode.h"
+#include "mathops.h"
#include "put_bits.h"
typedef struct RpzaContext {
@@ -266,9 +267,9 @@ static int compare_blocks(const uint16_t *block1, const uint16_t *block2,
*/
static int leastsquares(const uint16_t *block_ptr, const BlockInfo *bi,
channel_offset xchannel, channel_offset ychannel,
- double *slope, double *y_intercept, double *correlation_coef)
+ int *slope, int *y_intercept, int *correlation_coef)
{
- double sumx = 0, sumy = 0, sumx2 = 0, sumy2 = 0, sumxy = 0,
+ int sumx = 0, sumy = 0, sumx2 = 0, sumy2 = 0, sumxy = 0,
sumx_sq = 0, sumy_sq = 0, tmp, tmp2;
int i, j, count;
uint8_t x, y;
@@ -305,10 +306,10 @@ static int leastsquares(const uint16_t *block_ptr, const BlockInfo *bi,
tmp2 = count * sumy2 - sumy_sq;
if (tmp2 == 0) {
- *correlation_coef = 0.0;
+ *correlation_coef = 0;
} else {
*correlation_coef = (count * sumxy - sumx * sumy) /
- sqrt(tmp * tmp2);
+ ff_sqrt(tmp * tmp2);
}
return 0; // success
@@ -332,18 +333,18 @@ static int calc_lsq_max_fit_error(const uint16_t *block_ptr, const BlockInfo *bi
y = GET_CHAN(block_ptr[j], ychannel);
/* calculate x_inc as the 4-color index (0..3) */
- x_inc = floor( (x - min) * 3.0 / (max - min) + 0.5);
+ x_inc = (x - min) * 3 / (max - min) + 1;
x_inc = FFMAX(FFMIN(3, x_inc), 0);
/* calculate lin_y corresponding to x_inc */
- lin_y = (int)(tmp_min + (tmp_max - tmp_min) * x_inc / 3.0 + 0.5);
+ lin_y = tmp_min + (tmp_max - tmp_min) * x_inc / 3 + 1;
err = FFABS(lin_y - y);
if (err > max_err)
max_err = err;
/* calculate lin_x corresponding to x_inc */
- lin_x = (int)(min + (max - min) * x_inc / 3.0 + 0.5);
+ lin_x = min + (max - min) * x_inc / 3 + 1;
err = FFABS(lin_x - x);
if (err > max_err)
@@ -577,7 +578,7 @@ static void rpza_encode_stream(RpzaContext *s, const AVFrame *pict)
uint8_t avg_color[3];
int pixel_count;
uint8_t min_color[3], max_color[3];
- double slope, y_intercept, correlation_coef;
+ int slope, y_intercept, correlation_coef;
const uint16_t *src_pixels = (const uint16_t *)pict->data[0];
uint16_t *prev_pixels = (uint16_t *)s->prev_frame->data[0];
@@ -730,8 +731,8 @@ post_skip :
min_color[i] = GET_CHAN(src_pixels[block_offset], i);
max_color[i] = GET_CHAN(src_pixels[block_offset], i);
} else {
- tmp_min = (int)(0.5 + min * slope + y_intercept);
- tmp_max = (int)(0.5 + max * slope + y_intercept);
+ tmp_min = 1 + min * slope + y_intercept;
+ tmp_max = 1 + max * slope + y_intercept;
av_assert0(tmp_min <= tmp_max);
// clamp min and max color values
--
2.39.1
[-- Attachment #4: 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] 3+ messages in thread