From 46ba3676b854acbc69a4c7845f578d4c2886377b Mon Sep 17 00:00:00 2001 From: Jean-Michel Trivi Date: Fri, 8 Apr 2016 10:52:42 -0700 Subject: AAC/SBR encoder improvements * AAC-Encoder - AAC-ELD core encoder audio quality tuning. Update tuning tables, configure bitreservoir size and adapt afterburner iteration value. Modified file(s): libAACenc/src/aacenc.h libAACenc/src/aacenc_lib.cpp libAACenc/src/adj_thr.cpp libAACenc/src/adj_thr.h libAACenc/src/adj_thr_data.h libAACenc/src/bandwidth.cpp libAACenc/src/pnsparam.cpp libAACenc/src/qc_main.cpp - Introduze dead zone quantizer for ELD to improve audio quality at certain configurations. Modified file(s): libAACenc/src/aacenc_lib.cpp libAACenc/src/adj_thr.cpp libAACenc/src/adj_thr.h libAACenc/src/qc_data.h libAACenc/src/qc_main.cpp libAACenc/src/quantize.cpp libAACenc/src/quantize.h libAACenc/src/sf_estim.cpp libAACenc/src/sf_estim.h - Revise TNS module to improve ELD audio quality. - Use new window function and separate prediction gain according TNS filters. - Add missing memory initilization to TNS configuration. Modified file(s): libAACenc/src/aacenc_lib.cpp libAACenc/src/aacenc_tns.cpp libAACenc/src/aacenc_tns.h libAACenc/src/psy_main.cpp libAACenc/src/tns_func.h * SBR-Encoder - Revise frequency resolution calculation and handle differently depending on number of envelopes and split frames decision. - Add and adjust ELD SBR tuning tables. Modified file(s): libSBRenc/include/sbr_encoder.h libSBRenc/src/bit_sbr.h libSBRenc/src/env_est.cpp libSBRenc/src/fram_gen.cpp libSBRenc/src/fram_gen.h libSBRenc/src/mh_det.cpp libSBRenc/src/sbr_def.h libSBRenc/src/sbr_encoder.cpp libSBRenc/src/sbr_rom.cpp libSBRenc/src/tran_det.cpp - Replace ELD transient detector with fast implementation. Modified file(s): libSBRenc/src/env_est.cpp libSBRenc/src/env_est.h libSBRenc/src/fram_gen.cpp libSBRenc/src/sbr_def.h libSBRenc/src/sbr_encoder.cpp libSBRenc/src/tran_det.cpp libSBRenc/src/tran_det.h * FDK-Library - Introduce generic compare function in tools library. Modified file(s): libFDK/include/fixpoint_math.h libFDK/src/FDK_core.cpp * SBR-Encoder - Revise ELD frame splitter to improve bit distribution. Modified file(s): libSBRenc/include/sbr_encoder.h libSBRenc/src/bit_sbr.h libSBRenc/src/env_est.cpp libSBRenc/src/fram_gen.cpp libSBRenc/src/fram_gen.h libSBRenc/src/sbr_encoder.cpp libSBRenc/src/tran_det.cpp libSBRenc/src/tran_det.h - Configure amplitude resolution according the tonality of the audio signal. Modified file(s): libSBRenc/include/sbr_encoder.h libSBRenc/src/bit_sbr.h libSBRenc/src/env_est.cpp libSBRenc/src/nf_est.cpp libSBRenc/src/nf_est.h libSBRenc/src/sbr_def.h libSBRenc/src/sbr_encoder.cpp libSBRenc/src/ton_corr.cpp libSBRenc/src/ton_corr.h libSBRenc/src/tran_det.cpp libSBRenc/src/tran_det.h Change-Id: Ie0672b989a06ee63b50240616b8d1d4b790b6cb2 --- libAACenc/src/sf_estim.cpp | 73 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 22 deletions(-) (limited to 'libAACenc/src/sf_estim.cpp') diff --git a/libAACenc/src/sf_estim.cpp b/libAACenc/src/sf_estim.cpp index 72b75a6..1cb243b 100644 --- a/libAACenc/src/sf_estim.cpp +++ b/libAACenc/src/sf_estim.cpp @@ -2,7 +2,7 @@ /* ----------------------------------------------------------------------------------------------------------- Software License for The Fraunhofer FDK AAC Codec Library for Android -© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +© Copyright 1995 - 2015 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. All rights reserved. 1. INTRODUCTION @@ -363,7 +363,8 @@ static INT FDKaacEnc_improveScf(FIXP_DBL *spec, INT scf, INT minScf, FIXP_DBL *distLdData, - INT *minScfCalculated + INT *minScfCalculated, + INT dZoneQuantEnable ) { FIXP_DBL sfbDistLdData; @@ -375,7 +376,8 @@ static INT FDKaacEnc_improveScf(FIXP_DBL *spec, sfbDistLdData = FDKaacEnc_calcSfbDist(spec, quantSpec, sfbWidth, - scf); + scf, + dZoneQuantEnable); *minScfCalculated = scf; /* nmr > 1.25 -> try to improve nmr */ if (sfbDistLdData > (threshLdData-distFactorLdData)) { @@ -390,7 +392,8 @@ static INT FDKaacEnc_improveScf(FIXP_DBL *spec, sfbDistLdData = FDKaacEnc_calcSfbDist(spec, quantSpecTmp, sfbWidth, - scf); + scf, + dZoneQuantEnable); if (sfbDistLdData < sfbDistBestLdData) { scfBest = scf; @@ -408,7 +411,8 @@ static INT FDKaacEnc_improveScf(FIXP_DBL *spec, sfbDistLdData = FDKaacEnc_calcSfbDist(spec, quantSpecTmp, sfbWidth, - scf); + scf, + dZoneQuantEnable); if (sfbDistLdData < sfbDistBestLdData) { scfBest = scf; @@ -429,7 +433,8 @@ static INT FDKaacEnc_improveScf(FIXP_DBL *spec, sfbDistLdData = FDKaacEnc_calcSfbDist(spec, quantSpecTmp, sfbWidth, - scf); + scf, + dZoneQuantEnable); if (sfbDistLdData < sfbDistAllowedLdData) { *minScfCalculated = scfBest+1; @@ -454,6 +459,7 @@ static void FDKaacEnc_assimilateSingleScf(PSY_OUT_CHANNEL *psyOutChan, QC_OUT_CHANNEL *qcOutChannel, SHORT *quantSpec, SHORT *quantSpecTmp, + INT dZoneQuantEnable, INT *scf, INT *minScf, FIXP_DBL *sfbDist, @@ -570,7 +576,8 @@ static void FDKaacEnc_assimilateSingleScf(PSY_OUT_CHANNEL *psyOutChan, sfbDistNew = FDKaacEnc_calcSfbDist(qcOutChannel->mdctSpectrum+sfbOffs, quantSpecTmp+sfbOffs, sfbWidth, - scfAct); + scfAct, + dZoneQuantEnable); if (sfbDistNew < sfbDist[sfbAct]) { /* success, replace scf by new one */ @@ -629,6 +636,7 @@ static void FDKaacEnc_assimilateMultipleScf(PSY_OUT_CHANNEL *psyOutChan, QC_OUT_CHANNEL *qcOutChannel, SHORT *quantSpec, SHORT *quantSpecTmp, + INT dZoneQuantEnable, INT *scf, INT *minScf, FIXP_DBL *sfbDist, @@ -724,7 +732,8 @@ static void FDKaacEnc_assimilateMultipleScf(PSY_OUT_CHANNEL *psyOutChan, sfbDistNew[sfb] = FDKaacEnc_calcSfbDist(qcOutChannel->mdctSpectrum+sfbOffs, quantSpecTmp+sfbOffs, sfbWidth, - scfAct); + scfAct, + dZoneQuantEnable); if (sfbDistNew[sfb] >qcOutChannel->sfbThresholdLdData[sfb]) { /* no improvement, skip further dist. calculations */ @@ -768,6 +777,7 @@ static void FDKaacEnc_FDKaacEnc_assimilateMultipleScf2(PSY_OUT_CHANNEL *psyOutCh QC_OUT_CHANNEL *qcOutChannel, SHORT *quantSpec, SHORT *quantSpecTmp, + INT dZoneQuantEnable, INT *scf, INT *minScf, FIXP_DBL *sfbDist, @@ -883,7 +893,8 @@ static void FDKaacEnc_FDKaacEnc_assimilateMultipleScf2(PSY_OUT_CHANNEL *psyOutCh sfbDistNew[sfb] = FDKaacEnc_calcSfbDist(qcOutChannel->mdctSpectrum+sfbOffs[sfb], quantSpecTmp+sfbOffs[sfb], sfbOffs[sfb+1]-sfbOffs[sfb], - scfNew); + scfNew, + dZoneQuantEnable); if (sfbDistNew[sfb] > sfbDistMax[sfb]) { /* no improvement, skip further dist. calculations */ @@ -963,7 +974,8 @@ static void FDKaacEnc_FDKaacEnc_assimilateMultipleScf2(PSY_OUT_CHANNEL *psyOutCh sfbDistNew[sfb] = FDKaacEnc_calcSfbDist(qcOutChannel->mdctSpectrum+sfbOffs[sfb], quantSpecTmp+sfbOffs[sfb], sfbOffs[sfb+1]-sfbOffs[sfb], - scfNew); + scfNew, + dZoneQuantEnable); if (sfbDistNew[sfb] > qcOutChannel->sfbThresholdLdData[sfb]) { /* no improvement, skip further dist. calculations */ @@ -1058,7 +1070,8 @@ FDKaacEnc_FDKaacEnc_EstimateScaleFactorsChannel(QC_OUT_CHANNEL *qcOutChannel, INT *RESTRICT globalGain, FIXP_DBL *RESTRICT sfbFormFactorLdData ,const INT invQuant, - SHORT *RESTRICT quantSpec + SHORT *RESTRICT quantSpec, + const INT dZoneQuantEnable ) { INT i, j, sfb, sfbOffs; @@ -1160,7 +1173,8 @@ FDKaacEnc_FDKaacEnc_EstimateScaleFactorsChannel(QC_OUT_CHANNEL *qcOutChannel, quantSpecTmp+psyOutChannel->sfbOffsets[sfbOffs+sfb], psyOutChannel->sfbOffsets[sfbOffs+sfb+1]-psyOutChannel->sfbOffsets[sfbOffs+sfb], threshLdData, scfInt, minSfMaxQuant[sfbOffs+sfb], - &sfbDistLdData[sfbOffs+sfb], &minScfCalculated[sfbOffs+sfb] + &sfbDistLdData[sfbOffs+sfb], &minScfCalculated[sfbOffs+sfb], + dZoneQuantEnable ); } scf[sfbOffs+sfb] = scfInt; @@ -1187,20 +1201,32 @@ FDKaacEnc_FDKaacEnc_EstimateScaleFactorsChannel(QC_OUT_CHANNEL *qcOutChannel, sfbNRelevantLines); - FDKaacEnc_assimilateSingleScf(psyOutChannel, qcOutChannel, quantSpec, quantSpecTmp, scf, + FDKaacEnc_assimilateSingleScf(psyOutChannel, qcOutChannel, quantSpec, quantSpecTmp, + dZoneQuantEnable, + scf, minSfMaxQuant, sfbDistLdData, sfbConstPePart, sfbFormFactorLdData, sfbNRelevantLines, minScfCalculated, 1); + if(invQuant > 1) { + FDKaacEnc_assimilateMultipleScf(psyOutChannel, qcOutChannel, quantSpec, quantSpecTmp, + dZoneQuantEnable, + scf, + minSfMaxQuant, sfbDistLdData, sfbConstPePart, + sfbFormFactorLdData, sfbNRelevantLines); - FDKaacEnc_assimilateMultipleScf(psyOutChannel, qcOutChannel, quantSpec, quantSpecTmp, scf, - minSfMaxQuant, sfbDistLdData, sfbConstPePart, - sfbFormFactorLdData, sfbNRelevantLines); - + FDKaacEnc_assimilateMultipleScf(psyOutChannel, qcOutChannel, quantSpec, quantSpecTmp, + dZoneQuantEnable, + scf, + minSfMaxQuant, sfbDistLdData, sfbConstPePart, + sfbFormFactorLdData, sfbNRelevantLines); - FDKaacEnc_FDKaacEnc_assimilateMultipleScf2(psyOutChannel, qcOutChannel, quantSpec, quantSpecTmp, scf, - minSfMaxQuant, sfbDistLdData, sfbConstPePart, - sfbFormFactorLdData, sfbNRelevantLines); + FDKaacEnc_FDKaacEnc_assimilateMultipleScf2(psyOutChannel, qcOutChannel, quantSpec, quantSpecTmp, + dZoneQuantEnable, + scf, + minSfMaxQuant, sfbDistLdData, sfbConstPePart, + sfbFormFactorLdData, sfbNRelevantLines); + } } @@ -1223,7 +1249,8 @@ FDKaacEnc_FDKaacEnc_EstimateScaleFactorsChannel(QC_OUT_CHANNEL *qcOutChannel, FDKaacEnc_calcSfbDist(qcOutChannel->mdctSpectrum+psyOutChannel->sfbOffsets[sfbOffs+sfb], quantSpec+psyOutChannel->sfbOffsets[sfbOffs+sfb], psyOutChannel->sfbOffsets[sfbOffs+sfb+1]-psyOutChannel->sfbOffsets[sfbOffs+sfb], - scf[sfbOffs+sfb] + scf[sfbOffs+sfb], + dZoneQuantEnable ); } } @@ -1281,6 +1308,7 @@ void FDKaacEnc_EstimateScaleFactors(PSY_OUT_CHANNEL *psyOutChannel[], QC_OUT_CHANNEL* qcOutChannel[], const int invQuant, + const INT dZoneQuantEnable, const int nChannels) { int ch; @@ -1293,7 +1321,8 @@ FDKaacEnc_EstimateScaleFactors(PSY_OUT_CHANNEL *psyOutChannel[], &qcOutChannel[ch]->globalGain, qcOutChannel[ch]->sfbFormFactorLdData ,invQuant, - qcOutChannel[ch]->quantSpec + qcOutChannel[ch]->quantSpec, + dZoneQuantEnable ); } -- cgit v1.2.3