avcodec/aacsbr: Split pre dequantization noise factors table
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 19 Nov 2015 11:03:22 +0000 (12:03 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 19 Nov 2015 12:12:20 +0000 (13:12 +0100)
This allows removing a special case for the fixed point decoder and will
make error checks simpler

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/aacsbr.c
libavcodec/aacsbr_fixed.c
libavcodec/aacsbr_template.c
libavcodec/sbr.h

index 81f1902..7fb21cc 100644 (file)
@@ -93,8 +93,8 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
         }
         for (e = 1; e <= sbr->data[0].bs_num_noise; e++) {
             for (k = 0; k < sbr->n_q; k++) {
-                float temp1 = exp2f(NOISE_FLOOR_OFFSET - sbr->data[0].noise_facs[e][k] + 1);
-                float temp2 = exp2f(12 - sbr->data[1].noise_facs[e][k]);
+                float temp1 = exp2f(NOISE_FLOOR_OFFSET - sbr->data[0].noise_facs_q[e][k] + 1);
+                float temp2 = exp2f(12 - sbr->data[1].noise_facs_q[e][k]);
                 float fac;
                 if (temp1 > 1E20) {
                     av_log(NULL, AV_LOG_ERROR, "envelope scalefactor overflow in dequant\n");
@@ -121,7 +121,7 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
             for (e = 1; e <= sbr->data[ch].bs_num_noise; e++)
                 for (k = 0; k < sbr->n_q; k++)
                     sbr->data[ch].noise_facs[e][k] =
-                        exp2f(NOISE_FLOOR_OFFSET - sbr->data[ch].noise_facs[e][k]);
+                        exp2f(NOISE_FLOOR_OFFSET - sbr->data[ch].noise_facs_q[e][k]);
         }
     }
 }
index b4e3ac7..6ec39c1 100644 (file)
@@ -190,13 +190,13 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
                 SoftFloat temp1, temp2, fac;
 
                 temp1.exp = NOISE_FLOOR_OFFSET - \
-                    sbr->data[0].noise_facs[e][k].mant + 2;
+                    sbr->data[0].noise_facs_q[e][k] + 2;
                 temp1.mant = 0x20000000;
                 if (temp1.exp > 66) { // temp1 > 1E20
                     av_log(NULL, AV_LOG_ERROR, "envelope scalefactor overflow in dequant\n");
                     temp1 = FLOAT_1;
                 }
-                temp2.exp = 12 - sbr->data[1].noise_facs[e][k].mant + 1;
+                temp2.exp = 12 - sbr->data[1].noise_facs_q[e][k] + 1;
                 temp2.mant = 0x20000000;
                 fac   = av_div_sf(temp1, av_add_sf(FLOAT_1, temp2));
                 sbr->data[0].noise_facs[e][k] = fac;
@@ -225,7 +225,7 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
             for (e = 1; e <= sbr->data[ch].bs_num_noise; e++)
                 for (k = 0; k < sbr->n_q; k++){
                     sbr->data[ch].noise_facs[e][k].exp = NOISE_FLOOR_OFFSET - \
-                        sbr->data[ch].noise_facs[e][k].mant + 1;
+                        sbr->data[ch].noise_facs_q[e][k] + 1;
                     sbr->data[ch].noise_facs[e][k].mant = 0x20000000;
                 }
         }
index 66f4159..906823a 100644 (file)
@@ -906,33 +906,20 @@ static void read_sbr_noise(SpectralBandReplication *sbr, GetBitContext *gb,
         f_lav  = vlc_sbr_lav[F_HUFFMAN_ENV_3_0DB];
     }
 
-#if USE_FIXED
-    for (i = 0; i < ch_data->bs_num_noise; i++) {
-        if (ch_data->bs_df_noise[i]) {
-            for (j = 0; j < sbr->n_q; j++)
-                ch_data->noise_facs[i + 1][j].mant = ch_data->noise_facs[i][j].mant + delta * (get_vlc2(gb, t_huff, 9, 2) - t_lav);
-        } else {
-            ch_data->noise_facs[i + 1][0].mant = delta * get_bits(gb, 5); // bs_noise_start_value_balance or bs_noise_start_value_level
-            for (j = 1; j < sbr->n_q; j++)
-                ch_data->noise_facs[i + 1][j].mant = ch_data->noise_facs[i + 1][j - 1].mant + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav);
-        }
-    }
-#else
     for (i = 0; i < ch_data->bs_num_noise; i++) {
         if (ch_data->bs_df_noise[i]) {
             for (j = 0; j < sbr->n_q; j++)
-                ch_data->noise_facs[i + 1][j] = ch_data->noise_facs[i][j] + delta * (get_vlc2(gb, t_huff, 9, 2) - t_lav);
+                ch_data->noise_facs_q[i + 1][j] = ch_data->noise_facs_q[i][j] + delta * (get_vlc2(gb, t_huff, 9, 2) - t_lav);
         } else {
-            ch_data->noise_facs[i + 1][0] = delta * get_bits(gb, 5); // bs_noise_start_value_balance or bs_noise_start_value_level
+            ch_data->noise_facs_q[i + 1][0] = delta * get_bits(gb, 5); // bs_noise_start_value_balance or bs_noise_start_value_level
             for (j = 1; j < sbr->n_q; j++)
-                ch_data->noise_facs[i + 1][j] = ch_data->noise_facs[i + 1][j - 1] + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav);
+                ch_data->noise_facs_q[i + 1][j] = ch_data->noise_facs_q[i + 1][j - 1] + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav);
         }
     }
-#endif /* USE_FIXED */
 
-    //assign 0th elements of noise_facs from last elements
-    memcpy(ch_data->noise_facs[0], ch_data->noise_facs[ch_data->bs_num_noise],
-           sizeof(ch_data->noise_facs[0]));
+    //assign 0th elements of noise_facs_q from last elements
+    memcpy(ch_data->noise_facs_q[0], ch_data->noise_facs_q[ch_data->bs_num_noise],
+           sizeof(ch_data->noise_facs_q[0]));
 }
 
 static void read_sbr_extension(AACContext *ac, SpectralBandReplication *sbr,
index 66a88a2..f22c475 100644 (file)
@@ -96,8 +96,10 @@ typedef struct SBRData {
     AAC_FLOAT          q_temp[42][48];
     uint8_t            s_indexmapped[8][48];
     ///Envelope scalefactors
+    uint8_t            env_facs_q[6][48];
     AAC_FLOAT          env_facs[6][48];
     ///Noise scalefactors
+    uint8_t            noise_facs_q[6][48];
     AAC_FLOAT          noise_facs[3][5];
     ///Envelope time borders
     uint8_t            t_env[8];