]> git.sesse.net Git - ffmpeg/commitdiff
opus: simplify coarse energy beta coefficients
authorRostislav Pehlivanov <atomnuker@gmail.com>
Tue, 18 Jul 2017 19:47:30 +0000 (20:47 +0100)
committerRostislav Pehlivanov <atomnuker@gmail.com>
Tue, 18 Jul 2017 19:52:06 +0000 (20:52 +0100)
Just put the subtraction in the table.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
libavcodec/opus_celt.c
libavcodec/opusenc.c
libavcodec/opustab.c

index 0177b123b10927554ea873e80c8dc8d0b7ff4c84..84d484753b361fe9292d3941a2510a0f771ace51 100644 (file)
 #include "opustab.h"
 #include "opus_pvq.h"
 
+/* Use the 2D z-transform to apply prediction in both the time domain (alpha)
+ * and the frequency domain (beta) */
 static void celt_decode_coarse_energy(CeltFrame *f, OpusRangeCoder *rc)
 {
     int i, j;
-    float prev[2] = {0};
-    float alpha, beta;
-    const uint8_t *model;
-
-    /* use the 2D z-transform to apply prediction in both */
-    /* the time domain (alpha) and the frequency domain (beta) */
-
-    if (opus_rc_tell(rc)+3 <= f->framebits && ff_opus_rc_dec_log(rc, 3)) {
-        /* intra frame */
-        alpha = 0;
-        beta  = 1.0f - 4915.0f/32768.0f;
+    float prev[2] = { 0 };
+    float alpha = ff_celt_alpha_coef[f->size];
+    float beta  = ff_celt_beta_coef[f->size];
+    const uint8_t *model = ff_celt_coarse_energy_dist[f->size][0];
+
+    /* intra frame */
+    if (opus_rc_tell(rc) + 3 <= f->framebits && ff_opus_rc_dec_log(rc, 3)) {
+        alpha = 0.0f;
+        beta  = 1.0f - (4915.0f/32768.0f);
         model = ff_celt_coarse_energy_dist[f->size][1];
-    } else {
-        alpha = ff_celt_alpha_coef[f->size];
-        beta  = 1.0f - ff_celt_beta_coef[f->size];
-        model = ff_celt_coarse_energy_dist[f->size][0];
     }
 
     for (i = 0; i < CELT_MAX_BANDS; i++) {
index c54df8c0605bb6e35c0aecc1ab21d53cba96b41b..8f2da4a7ba3cc260f6d202279e98d8fb1e5a3a88 100644 (file)
@@ -644,10 +644,10 @@ static void exp_quant_coarse(OpusRangeCoder *rc, CeltFrame *f,
 
     if (intra) {
         alpha = 0.0f;
-        beta  = 1.0f - 4915.0f/32768.0f;
+        beta  = 1.0f - (4915.0f/32768.0f);
     } else {
         alpha = ff_celt_alpha_coef[f->size];
-        beta  = 1.0f - ff_celt_beta_coef[f->size];
+        beta  = ff_celt_beta_coef[f->size];
     }
 
     for (i = f->start_band; i < f->end_band; i++) {
index b31705297e12e49573c1037e96ab3f80f146d1d9..fb340e07e8ee2bc5ef358c83a39d957593fc1c5a 100644 (file)
@@ -796,8 +796,8 @@ const float ff_celt_alpha_coef[] = {
     29440.0f/32768.0f,    26112.0f/32768.0f,    21248.0f/32768.0f,    16384.0f/32768.0f
 };
 
-const float ff_celt_beta_coef[] = { /* TODO: precompute 1 minus this if the code ends up neater */
-    30147.0f/32768.0f,    22282.0f/32768.0f,    12124.0f/32768.0f,     6554.0f/32768.0f
+const float ff_celt_beta_coef[] = {
+    1.0f - (30147.0f/32768.0f), 1.0f - (22282.0f/32768.0f), 1.0f - (12124.0f/32768.0f), 1.0f - (6554.0f/32768.0f),
 };
 
 const uint8_t ff_celt_coarse_energy_dist[4][2][42] = {