From c0d1d54bed051af17f0d8416a900d917748e7785 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Sat, 8 Nov 2025 02:04:11 +0900 Subject: [PATCH] TAD: more tuning --- video_encoder/decoder_tad.c | 42 ++++++++++++++++++------------------- video_encoder/encoder_tad.c | 40 +++++++++++++++++------------------ video_encoder/encoder_tad.h | 4 ++-- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/video_encoder/decoder_tad.c b/video_encoder/decoder_tad.c index 7d8b166..3a00021 100644 --- a/video_encoder/decoder_tad.c +++ b/video_encoder/decoder_tad.c @@ -172,28 +172,28 @@ static int calculate_dwt_levels(int chunk_size) { // Deadband thresholds (must match encoder) static const float DEADBANDS[2][10] = { { // mid channel - 0.10f, // LL (L9) DC - 0.03f, // H (L9) 31.25 hz - 0.03f, // H (L8) 62.5 hz - 0.03f, // H (L7) 125 hz - 0.03f, // H (L6) 250 hz - 0.02f, // H (L5) 500 hz - 0.02f, // H (L4) 1 khz - 0.005f, // H (L3) 2 khz - 0.005f, // H (L2) 4 khz - 0.005f // H (L1) 8 khz + 0.20f, // LL (L9) DC + 0.06f, // H (L9) 31.25 hz + 0.06f, // H (L8) 62.5 hz + 0.06f, // H (L7) 125 hz + 0.06f, // H (L6) 250 hz + 0.04f, // H (L5) 500 hz + 0.04f, // H (L4) 1 khz + 0.01f, // H (L3) 2 khz + 0.01f, // H (L2) 4 khz + 0.01f // H (L1) 8 khz }, { // side channel - 0.10f, // LL (L9) DC - 0.03f, // H (L9) 31.25 hz - 0.03f, // H (L8) 62.5 hz - 0.03f, // H (L7) 125 hz - 0.03f, // H (L6) 250 hz - 0.02f, // H (L5) 500 hz - 0.02f, // H (L4) 1 khz - 0.005f, // H (L3) 2 khz - 0.005f, // H (L2) 4 khz - 0.005f // H (L1) 8 khz + 0.20f, // LL (L9) DC + 0.06f, // H (L9) 31.25 hz + 0.06f, // H (L8) 62.5 hz + 0.06f, // H (L7) 125 hz + 0.06f, // H (L6) 250 hz + 0.04f, // H (L5) 500 hz + 0.04f, // H (L4) 1 khz + 0.01f, // H (L3) 2 khz + 0.01f, // H (L2) 4 khz + 0.01f // H (L1) 8 khz }}; // Fast PRNG state (xorshift32) for stochastic reconstruction @@ -604,7 +604,7 @@ static void dequantize_dwt_coefficients(int channel, const int8_t *quantized, fl // Generate Laplacian-distributed noise scaled to deadband width // Use scale = threshold/3 to keep ~99% of samples within [-threshold, +threshold] - float noise = laplacian_noise(deadband_threshold / 3.0f); + float noise = tpdf1() * deadband_threshold / 10.0f; // Clamp to deadband range if (noise > deadband_threshold) noise = deadband_threshold; diff --git a/video_encoder/encoder_tad.c b/video_encoder/encoder_tad.c index 0eb011f..878b10e 100644 --- a/video_encoder/encoder_tad.c +++ b/video_encoder/encoder_tad.c @@ -49,28 +49,28 @@ static const float BASE_QUANTISER_WEIGHTS[2][10] = { // target: before quantisation static const float DEADBANDS[2][10] = { { // mid channel - 0.10f, // LL (L9) DC - 0.03f, // H (L9) 31.25 hz - 0.03f, // H (L8) 62.5 hz - 0.03f, // H (L7) 125 hz - 0.03f, // H (L6) 250 hz - 0.02f, // H (L5) 500 hz - 0.02f, // H (L4) 1 khz - 0.005f, // H (L3) 2 khz - 0.005f, // H (L2) 4 khz - 0.005f // H (L1) 8 khz + 0.20f, // LL (L9) DC + 0.06f, // H (L9) 31.25 hz + 0.06f, // H (L8) 62.5 hz + 0.06f, // H (L7) 125 hz + 0.06f, // H (L6) 250 hz + 0.04f, // H (L5) 500 hz + 0.04f, // H (L4) 1 khz + 0.01f, // H (L3) 2 khz + 0.01f, // H (L2) 4 khz + 0.01f // H (L1) 8 khz }, { // side channel - 0.10f, // LL (L9) DC - 0.03f, // H (L9) 31.25 hz - 0.03f, // H (L8) 62.5 hz - 0.03f, // H (L7) 125 hz - 0.03f, // H (L6) 250 hz - 0.02f, // H (L5) 500 hz - 0.02f, // H (L4) 1 khz - 0.005f, // H (L3) 2 khz - 0.005f, // H (L2) 4 khz - 0.005f // H (L1) 8 khz + 0.20f, // LL (L9) DC + 0.06f, // H (L9) 31.25 hz + 0.06f, // H (L8) 62.5 hz + 0.06f, // H (L7) 125 hz + 0.06f, // H (L6) 250 hz + 0.04f, // H (L5) 500 hz + 0.04f, // H (L4) 1 khz + 0.01f, // H (L3) 2 khz + 0.01f, // H (L2) 4 khz + 0.01f // H (L1) 8 khz }}; static inline float FCLAMP(float x, float min, float max) { diff --git a/video_encoder/encoder_tad.h b/video_encoder/encoder_tad.h index 3b318b7..d42c27d 100644 --- a/video_encoder/encoder_tad.h +++ b/video_encoder/encoder_tad.h @@ -21,9 +21,9 @@ static inline int tad32_quality_to_max_index(int quality) { - static const int quality_map[7] = {31, 35, 39, 47, 56, 89, 127}; + static const int quality_map[6] = {21, 31, 44, 63, 89, 127}; if (quality < 0) quality = 0; - if (quality > 6) quality = 6; + if (quality > 5) quality = 5; return quality_map[quality]; }