f20b67173c
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>
41 lines
1.3 KiB
C
41 lines
1.3 KiB
C
/*
|
|
* AAC encoder TNS
|
|
* Copyright (C) 2015 Rostislav Pehlivanov
|
|
*
|
|
* This file is part of FFmpeg.
|
|
*
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
/**
|
|
* @file
|
|
* AAC encoder temporal noise shaping
|
|
* @author Rostislav Pehlivanov ( atomnuker gmail com )
|
|
*/
|
|
|
|
#ifndef AVCODEC_AACENC_TNS_H
|
|
#define AVCODEC_AACENC_TNS_H
|
|
|
|
#include "aacenc.h"
|
|
|
|
/** Lower limit of TNS in SFBs **/
|
|
#define TNS_LOW_LIMIT 24
|
|
|
|
void ff_aac_encode_tns_info(AACEncContext *s, SingleChannelElement *sce);
|
|
void ff_aac_apply_tns(SingleChannelElement *sce);
|
|
void ff_aac_search_for_tns(AACEncContext *s, SingleChannelElement *sce);
|
|
|
|
#endif /* AVCODEC_AACENC_TNS_H */
|