summaryrefslogtreecommitdiff
path: root/libavcodec/aacenc_tns.h
diff options
context:
space:
mode:
authorRostislav Pehlivanov <atomnuker@gmail.com>2015-09-05 09:08:30 +0100
committerRostislav Pehlivanov <atomnuker@gmail.com>2015-09-05 09:08:30 +0100
commite3faad811e429002d549562db4e0fc30c08dc6a4 (patch)
treeee640ac53850c7e1f2f1131fdb2af67b05afdfe1 /libavcodec/aacenc_tns.h
parent7591f8319b06d7ac6cfc16a852f24a46063f0595 (diff)
aacenc_tns: adjust coefficient calculation, add double filter support
This commit improves the TNS implementation to the point where it's actually usable and very rarely results in nastyness (in all bitrates except extremely low bitrates it's increasing the quality and prevents some distortions from the coder being audiable). Also adds a double filter support which is only used if the energy difference between the top and bottom of the SFBs is above the thresholds defined in the header file. Looking at the bitstream that fdk_aac generates it sometimes used a double filter despite the specs stating that a single filter should be enough for almost all cases and purposes. Unlike FAAC or fdk_aac we sometimes use a reverse filter in case the energy difference isn't enought to use a double filter. This actually works better. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Diffstat (limited to 'libavcodec/aacenc_tns.h')
-rw-r--r--libavcodec/aacenc_tns.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/libavcodec/aacenc_tns.h b/libavcodec/aacenc_tns.h
index 812deeac8c..f0e75569ae 100644
--- a/libavcodec/aacenc_tns.h
+++ b/libavcodec/aacenc_tns.h
@@ -37,11 +37,13 @@
#define TNS_GAIN_THRESHOLD_LOW 1.395f
#define TNS_GAIN_THRESHOLD_HIGH 11.19f
-/* Do not use TNS if the psy band spread is below this value */
-#define TNS_SPREAD_THRESHOLD 20.081512f
+/* If the energy ratio between the low SFBs vs the high SFBs is not between
+ * those two values, use 2 filters instead */
+#define TNS_E_RATIO_LOW 0.77
+#define TNS_E_RATIO_HIGH 1.23
-/* Allows to reverse the filter direction if the band energy is uneven */
-#define TNS_DIRECTION_VARY 1
+/* Do not use TNS if the psy band spread is below this value */
+#define TNS_SPREAD_THRESHOLD 37.081512f
void ff_aac_encode_tns_info(AACEncContext *s, SingleChannelElement *sce);
void ff_aac_apply_tns(AACEncContext *s, SingleChannelElement *sce);