aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/aaccoder.c
diff options
context:
space:
mode:
authorRostislav Pehlivanov <atomnuker@gmail.com>2015-08-29 06:47:31 +0100
committerRostislav Pehlivanov <atomnuker@gmail.com>2015-08-29 06:47:31 +0100
commitf20b67173ca6a05b8c3dee02dad3b7243b96292b (patch)
tree8d5a735d2ffc64117119a63b1b84f9e946d74c75 /libavcodec/aaccoder.c
parent1cd5daee20602e1fa271bd38b3aa47c9bc30ac67 (diff)
downloadffmpeg-f20b67173ca6a05b8c3dee02dad3b7243b96292b.tar.gz
aacenc_tns: rework the way coefficients are calculated
This commit abandons the way the specifications state to quantize the coefficients, makes use of the new LPC float functions and is much better. The original way of converting non-normalized float samples to int32_t which out LPC system expects was wrong and it was wrong to assume the coefficients that are generated are also valid. It was essentially a full garbage-in, garbage-out system and it definitely shows when looking at spectrals and listening. The high frequencies were very overattenuated. The new LPC function performs the analysis directly. The specifications state to quantize the coefficients into four bit index values using an asin() function which of course had to have ugly ternary operators because the function turns negative if the coefficients are negative which when encoding causes invalid bitstream to get generated. This deviates from this by using the direct TNS tables, which are fairly small since you only have 4 bits at most for index values. The LPC values are directly quantized against the tables and are then used to perform filtering after the requantization, which simply fetches the array values. The end result is that TNS works much better now and doesn't attenuate anything but the actual signal, e.g. TNS removes quantization errors and does it's job correctly now. It might be enabled by default soon since it doesn't hurt and helps reduce nastyness at low bitrates. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Diffstat (limited to 'libavcodec/aaccoder.c')
-rw-r--r--libavcodec/aaccoder.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
index 8256f961c0..86d598f021 100644
--- a/libavcodec/aaccoder.c
+++ b/libavcodec/aaccoder.c
@@ -964,6 +964,7 @@ AACCoefficientsEncoder ff_aac_coders[AAC_CODER_NB] = {
ff_aac_encode_main_pred,
ff_aac_adjust_common_prediction,
ff_aac_apply_main_pred,
+ ff_aac_apply_tns,
set_special_band_scalefactors,
search_for_pns,
ff_aac_search_for_tns,
@@ -979,6 +980,7 @@ AACCoefficientsEncoder ff_aac_coders[AAC_CODER_NB] = {
ff_aac_encode_main_pred,
ff_aac_adjust_common_prediction,
ff_aac_apply_main_pred,
+ ff_aac_apply_tns,
set_special_band_scalefactors,
search_for_pns,
ff_aac_search_for_tns,
@@ -994,6 +996,7 @@ AACCoefficientsEncoder ff_aac_coders[AAC_CODER_NB] = {
ff_aac_encode_main_pred,
ff_aac_adjust_common_prediction,
ff_aac_apply_main_pred,
+ ff_aac_apply_tns,
set_special_band_scalefactors,
search_for_pns,
ff_aac_search_for_tns,
@@ -1009,6 +1012,7 @@ AACCoefficientsEncoder ff_aac_coders[AAC_CODER_NB] = {
ff_aac_encode_main_pred,
ff_aac_adjust_common_prediction,
ff_aac_apply_main_pred,
+ ff_aac_apply_tns,
set_special_band_scalefactors,
search_for_pns,
ff_aac_search_for_tns,