Correct pulse amplitude application - a negative or 0 coefficient implies the
[ffmpeg.git] / libavcodec / aac.c
index 94f27ac..cc069ed 100644 (file)
@@ -635,7 +635,7 @@ static int decode_tns(AACContext * ac, TemporalNoiseShaping * tns,
                 tmp2_idx = 2*coef_compress + coef_res;
 
                 for (i = 0; i < tns->order[w][filt]; i++)
-                    tns->coef[w][filt][i] = -tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)];
+                    tns->coef[w][filt][i] = tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)];
             }
         }
     }
@@ -753,7 +753,9 @@ static int decode_spectrum_and_dequant(AACContext * ac, float coef[1024], GetBit
     if (pulse_present) {
         for(i = 0; i < pulse->num_pulse; i++){
             float co  = coef_base[ pulse->pos[i] ];
-            float ico = co / sqrtf(sqrtf(fabsf(co))) + pulse->amp[i];
+            float ico = -pulse->amp[i];
+            if (co)
+                ico = co / sqrtf(sqrtf(fabsf(co))) + (co > 0 ? -ico : ico);
             coef_base[ pulse->pos[i] ] = cbrtf(fabsf(ico)) * ico;
         }
     }