D3C0D3R
23rd November 2022, 00:14
Libaom is a great codec, but it has one annoying weakness: it cant preserve fine detail and sharp textures like x264 did.
Even when one lower QPs and boost bitrate into sky.
So I want to share patch which slightly fixes that. I using this quite of time on top of libaom.
I experimented a lot with more complex patches, and simplify results of some experiments into couple lines of very simple code.
But even in this simplest form it already helps across wide range QPs (32-63 test) cpu-used (1,2,3 tested) and video content.
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index 0334962021..895db71798 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -423,7 +423,13 @@ int av1_compute_rd_mult(const int qindex, const aom_bit_depth_t bit_depth,
// ARF boost adjustment
rdmult += ((rdmult * rd_boost_factor[boost_index]) >> 7);
}
- return (int)rdmult;
+ double rm =(double) qindex;
+ rm /= 35*4;
+ rm = pow(rm, 0.75);
+ rm *= (double) rdmult;
+ return (int)rm;
}
int av1_get_deltaq_offset(aom_bit_depth_t bit_depth, int qindex, double beta) {
It slighlty hurts PSNR. But considerably improves SSIM metrics AND texture retention (less smothing).
cpu-used=3
Metric BD-Rate (%)
-------- ----------
PSNRy 0.99
PSNRavg 0.64
SSIMy -2.47
SSIMavg -2.93
PSNR 0.08
SSIM -1.56
MS-SSIM -1.98
cpu-used=2
Metric BD-Rate (%)
-------- ----------
PSNRy 1.23
PSNRavg 0.80
SSIMy -2.42
SSIMavg -3.02
PSNR 0.25
SSIM -1.53
MS-SSIM -1.90
Even when one lower QPs and boost bitrate into sky.
So I want to share patch which slightly fixes that. I using this quite of time on top of libaom.
I experimented a lot with more complex patches, and simplify results of some experiments into couple lines of very simple code.
But even in this simplest form it already helps across wide range QPs (32-63 test) cpu-used (1,2,3 tested) and video content.
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index 0334962021..895db71798 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -423,7 +423,13 @@ int av1_compute_rd_mult(const int qindex, const aom_bit_depth_t bit_depth,
// ARF boost adjustment
rdmult += ((rdmult * rd_boost_factor[boost_index]) >> 7);
}
- return (int)rdmult;
+ double rm =(double) qindex;
+ rm /= 35*4;
+ rm = pow(rm, 0.75);
+ rm *= (double) rdmult;
+ return (int)rm;
}
int av1_get_deltaq_offset(aom_bit_depth_t bit_depth, int qindex, double beta) {
It slighlty hurts PSNR. But considerably improves SSIM metrics AND texture retention (less smothing).
cpu-used=3
Metric BD-Rate (%)
-------- ----------
PSNRy 0.99
PSNRavg 0.64
SSIMy -2.47
SSIMavg -2.93
PSNR 0.08
SSIM -1.56
MS-SSIM -1.98
cpu-used=2
Metric BD-Rate (%)
-------- ----------
PSNRy 1.23
PSNRavg 0.80
SSIMy -2.42
SSIMavg -3.02
PSNR 0.25
SSIM -1.53
MS-SSIM -1.90