From 0c272ca1af856f9cb21619b14fdf57f182a3c15b Mon Sep 17 00:00:00 2001 From: aikiriao Date: Mon, 15 Jul 2024 21:19:17 +0900 Subject: [PATCH] =?UTF-8?q?Revert=20"avoid=20quantize=20error=20variance.?= =?UTF-8?q?=20=EF=BC=88=E5=B9=BE=E4=BD=95=E5=88=86=E5=B8=83=E3=81=AE?= =?UTF-8?q?=E3=82=A8=E3=83=B3=E3=83=88=E3=83=AD=E3=83=94=E3=83=BC=E5=9F=BA?= =?UTF-8?q?=E6=BA=96=E3=81=A7=E3=81=AF=E3=80=81=E5=8D=B4=E3=81=A3=E3=81=A6?= =?UTF-8?q?=E6=82=AA=E5=8C=96=EF=BC=89"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 6660a1aa4b23523f52100040c9f05167c6680620. --- libs/srla_encoder/src/srla_encoder.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/srla_encoder/src/srla_encoder.c b/libs/srla_encoder/src/srla_encoder.c index 722e6e0..205305d 100644 --- a/libs/srla_encoder/src/srla_encoder.c +++ b/libs/srla_encoder/src/srla_encoder.c @@ -939,9 +939,13 @@ static SRLAError SRLAEncoder_SelectBestLPCOrder( uint32_t order, tmp_best_order = 0; double len, mabse, minlen = FLT_MAX; + /* 次数あたり係数量子化誤差分散 */ + const double qerr_var_unit = pow(2.0, -2.0 * SRLA_LPC_COEFFICIENT_BITWIDTH) * error_vars[0] / 12.0; for (order = 1; order <= max_coef_order; order++) { + /* 係数量子化誤差分散を加えた誤差分散 */ + const double err_var = error_vars[order] + order * qerr_var_unit; /* Laplace分布の仮定で残差分散から平均絶対値を推定 */ - mabse = 2.0 * sqrt(error_vars[order] / 2.0); /* 符号化で非負整数化するため2倍 */ + mabse = 2.0 * sqrt(err_var / 2.0); /* 符号化で非負整数化するため2倍 */ /* 残差符号のサイズ */ len = SRLAEncoder_CalculateGeometricDistributionEntropy(mabse, header->bits_per_sample) * num_samples; /* 係数のサイズ */