shithub: aacenc

Download patch

ref: ac65a6d1c9ee98b587a701c106dedac3cbbbfaf6
parent: b5680ddc71a2f0047878d028dc80c671be149c6a
author: Krzysztof Nikiel <knik@users.sourceforge.net>
date: Mon Aug 28 09:43:59 EDT 2017

LTP and Main object types removed

--- a/frontend/main.c
+++ b/frontend/main.c
@@ -79,7 +79,6 @@
 {
     SHORTCTL_FLAG = 300,
     MPEGVERS_FLAG,
-    OBJTYPE_FLAG,
     ARTIST_FLAG,
     TITLE_FLAG,
     GENRE_FLAG,
@@ -186,9 +185,7 @@
     {"--no-tns\tDisable coding of TNS, temporal noise shaping.\n"},
     {"--no-midside\tDon\'t use mid/side coding.\n"},
     {"--mpeg-vers X\tForce AAC MPEG version, X can be 2 or 4\n"},
-    {"--obj-type X\tAAC object type. (LC (Low Complexity, default), Main or LTP\n"
-    "\t\t(Long Term Prediction)\n"},
-    {" --shortctl X\tEnforce block type (0 = both (default); 1 = no short; 2 = no\n"
+    {"--shortctl X\tEnforce block type (0 = both (default); 1 = no short; 2 = no\n"
     "\t\tlong).\n"},
     {0}
 };
@@ -525,7 +522,6 @@
             {"tns", 0, &useTns, 1},
             {"no-tns", 0, &useTns, 0},
             {"mpeg-version", 1, 0, MPEGVERS_FLAG},
-            {"obj-type", 1, 0, OBJTYPE_FLAG},
             {"license", 0, 0, 'L'},
             {"createmp4", 0, 0, 'w'},
             {"artist", 1, 0, ARTIST_FLAG},
@@ -740,21 +736,6 @@
                 dieMessage = "Unrecognised MPEG version!\n";
             }
             break;
-#if 0
-        case OBJTYPE_FLAG:
-            if (!strcasecmp(optarg, "LC"))
-                objectType = LOW;
-            else if (!strcasecmp(optarg, "Main"))
-                objectType = MAIN;
-            else if (!strcasecmp(optarg, "LTP"))
-            {
-                mpegVersion = MPEG4;
-                objectType = LTP;
-            }
-            else
-                dieMessage = "Unrecognised object type!\n";
-            break;
-#endif
         case 'L':
             fprintf(stderr, "%s", faac_copyright_string);
             dieMessage = license;
--- a/libfaac/Makefile.am
+++ b/libfaac/Makefile.am
@@ -1,5 +1,5 @@
-common_SOURCES = aacquant.c bitstream.c fft.c frame.c midside.c blockswitch.c util.c backpred.c channels.c filtbank.c huffman.c ltp.c tns.c
-common_INCLUDES = aacquant.h channels.h filtbank.h hufftab.h blockswitch.h backpred.h coder.h frame.h midside.h tns.h bitstream.h fft.h huffman.h ltp.h util.h
+common_SOURCES = aacquant.c bitstream.c fft.c frame.c midside.c blockswitch.c util.c channels.c filtbank.c huffman.c tns.c quantize.c
+common_INCLUDES = aacquant.h channels.h filtbank.h hufftab.h blockswitch.h coder.h frame.h midside.h tns.h bitstream.h fft.h huffman.h util.h quantize.h
 common_LIBADD = -lm
 common_CFLAGS = -fvisibility=hidden
 
--- a/libfaac/aacquant.c
+++ b/libfaac/aacquant.c
@@ -27,62 +27,30 @@
 #include "coder.h"
 #include "huffman.h"
 #include "util.h"
+#include "quantize.h"
 
-#include "quantize.c"
 
-
 void AACQuantizeInit(CoderInfo *coderInfo, unsigned int numChannels,
                      AACQuantCfg *aacquantCfg)
 {
-    unsigned int channel, i;
+    unsigned int i;
 
-
     aacquantCfg->pow43 = (double*)AllocMemory(PRECALC_SIZE*sizeof(double));
     aacquantCfg->pow43[0] = 0.0;
     for(i=1;i<PRECALC_SIZE;i++)
         aacquantCfg->pow43[i] = pow((double)i, 4.0/3.0);
-
-    for (channel = 0; channel < numChannels; channel++) {
-        coderInfo[channel].requantFreq = (double*)AllocMemory(BLOCK_LEN_LONG*sizeof(double));
-    }
 }
 
 void AACQuantizeEnd(CoderInfo *coderInfo, unsigned int numChannels,
                     AACQuantCfg *aacquantCfg)
 {
-    unsigned int channel;
-
-
     if (aacquantCfg->pow43)
     {
         FreeMemory(aacquantCfg->pow43);
         aacquantCfg->pow43 = NULL;
     }
-
-    for (channel = 0; channel < numChannels; channel++) {
-        if (coderInfo[channel].requantFreq) FreeMemory(coderInfo[channel].requantFreq);
-    }
 }
 
-static void UpdateRequant(CoderInfo *coderInfo, int *xi,
-                          double *pow43)
-{
-  double *requant_xr = coderInfo->requantFreq;
-  int sb;
-  int i;
-
-  for (sb = 0; sb < coderInfo->nr_of_sfb; sb++)
-  {
-    double invQuantFac =
-      pow(2.0, -0.25*(coderInfo->scale_factor[sb] - coderInfo->global_gain));
-    int start = coderInfo->sfb_offset[sb];
-    int end = coderInfo->sfb_offset[sb + 1];
-
-    for (i = start; i < end; i++)
-      requant_xr[i] = pow43[xi[i]] * invQuantFac;
-  }
-}
-
 int AACQuantize(CoderInfo *coderInfo,
                 int *cb_width,
                 int num_cb,
@@ -103,12 +71,9 @@
 
     if (BlocQuant(coderInfo, xr, xi, aacquantCfg))
     {
-        UpdateRequant(coderInfo, xi, aacquantCfg->pow43);
-
         for ( i = 0; i < FRAME_LEN; i++ )  {
             sign = (xr[i] < 0) ? -1 : 1;
             xi[i] *= sign;
-            coderInfo->requantFreq[i] *= sign;
         }
     }
 
--- a/libfaac/backpred.c
+++ /dev/null
@@ -1,381 +1,0 @@
-/**********************************************************************
-
-This software module was originally developed by
-and edited by Nokia in the course of
-development of the MPEG-2 NBC/MPEG-4 Audio standard
-ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an
-implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools
-as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives
-users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this
-software module or modifications thereof for use in hardware or
-software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio
-standards. Those intending to use this software module in hardware or
-software products are advised that this use may infringe existing
-patents. The original developer of this software module and his/her
-company, the subsequent editors and their companies, and ISO/IEC have
-no liability for use of this software module or modifications thereof
-in an implementation. Copyright is not released for non MPEG-2
-NBC/MPEG-4 Audio conforming products. The original developer retains
-full right to use the code for his/her own purpose, assign or donate
-the code to a third party and to inhibit third party from using the
-code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This
-copyright notice must be included in all copies or derivative works.
-
-Copyright (c) 1997.
-**********************************************************************/
-/*
- * $Id: backpred.c,v 1.6 2012/03/01 18:34:17 knik Exp $
- */
-
-#include <math.h>
-#include "frame.h"
-#include "coder.h"
-#include "channels.h"
-#include "backpred.h"
-
-
-void PredInit(faacEncStruct* hEncoder)
-{
-    unsigned int channel;
-
-    for (channel = 0; channel < hEncoder->numChannels; channel++) {
-        BwpInfo *bwpInfo = &(hEncoder->coderInfo[channel].bwpInfo);
-
-        bwpInfo->psy_init_mc = 0;
-        bwpInfo->reset_count_mc = 0;
-    }
-}
-
-void PredCalcPrediction(double *act_spec, double *last_spec, int btype,
-                        int nsfb,
-                        int *isfb_width,
-                        CoderInfo *coderInfo,
-                        ChannelInfo *channelInfo,
-                        int chanNum)
-{
-    int i, k, j, cb_long;
-    int leftChanNum;
-    int isRightWithCommonWindow;
-    double num_bit, snr[SBMAX_L];
-    double energy[BLOCK_LEN_LONG], snr_p[BLOCK_LEN_LONG], temp1, temp2;
-    ChannelInfo *thisChannel;
-
-    /* Set pointers for specified channel number */
-    /* int psy_init; */
-    int *psy_init;
-    double (*dr)[BLOCK_LEN_LONG],(*e)[BLOCK_LEN_LONG];
-    double (*K)[BLOCK_LEN_LONG], (*R)[BLOCK_LEN_LONG];
-    double (*VAR)[BLOCK_LEN_LONG], (*KOR)[BLOCK_LEN_LONG];
-    double *sb_samples_pred;
-    int *thisLineNeedsResetting;
-    /* int reset_count; */
-    int *reset_count;
-    int *pred_global_flag;
-    int *pred_sfb_flag;
-    int *reset_group;
-
-    /* Set pointers for this chanNum */
-    pred_global_flag = &(coderInfo[chanNum].pred_global_flag);
-    pred_sfb_flag = coderInfo[chanNum].pred_sfb_flag;
-    reset_group = &(coderInfo[chanNum].reset_group_number);
-    psy_init = &coderInfo[chanNum].bwpInfo.psy_init_mc;
-    dr = &coderInfo[chanNum].bwpInfo.dr_mc[0];
-    e = &coderInfo[chanNum].bwpInfo.e_mc[0];
-    K = &coderInfo[chanNum].bwpInfo.K_mc[0];
-    R = &coderInfo[chanNum].bwpInfo.R_mc[0];
-    VAR = &coderInfo[chanNum].bwpInfo.VAR_mc[0];
-    KOR = &coderInfo[chanNum].bwpInfo.KOR_mc[0];
-    sb_samples_pred = &coderInfo[chanNum].bwpInfo.sb_samples_pred_mc[0];
-    thisLineNeedsResetting = &coderInfo[chanNum].bwpInfo.thisLineNeedsResetting_mc[0];
-    reset_count = &coderInfo[chanNum].bwpInfo.reset_count_mc;
-
-    thisChannel = &(channelInfo[chanNum]);
-    *psy_init = (*psy_init && (btype!=2));
-
-    if((*psy_init) == 0) {
-        for (j=0; j<BLOCK_LEN_LONG; j++) {
-            thisLineNeedsResetting[j]=1;
-        }
-        *psy_init = 1;
-    }
-
-    if (btype==2) {
-        pred_global_flag[0]=0;
-        /* SHORT WINDOWS reset all the co-efficients    */
-        if (thisChannel->ch_is_left) {
-            (*reset_count)++;
-            if (*reset_count >= 31 * RESET_FRAME)
-                *reset_count = RESET_FRAME;
-        }
-        return;
-    }
-
-
-    /**************************************************/
-    /*  Compute state using last_spec                 */
-    /**************************************************/
-    for (i=0;i<BLOCK_LEN_LONG;i++)
-    {
-        /* e[0][i]=last_spec[i]; */
-        e[0][i]=last_spec[i]+sb_samples_pred[i];
-
-        for(j=1;j<=LPC;j++)
-            e[j][i] = e[j-1][i]-K[j][i]*R[j-1][i];
-
-        for(j=1;j<LPC;j++)
-            dr[j][i] = K[j][i]*e[j-1][i];
-
-        for(j=1;j<=LPC;j++) {
-            VAR[j][i] = ALPHA*VAR[j][i]+.5*(R[j-1][i]*R[j-1][i]+e[j-1][i]*e[j-1][i]);
-            KOR[j][i] = ALPHA*KOR[j][i]+R[j-1][i]*e[j-1][i];
-        }
-
-        for(j=LPC-1;j>=1;j--)
-            R[j][i] = A*(R[j-1][i]-dr[j][i]);
-        R[0][i] = A*e[0][i];
-    }
-
-
-    /**************************************************/
-    /* Reset state here if resets were sent           */
-    /**************************************************/
-    for (i=0;i<BLOCK_LEN_LONG;i++) {
-        if (thisLineNeedsResetting[i]) {
-            for (j = 0; j <= LPC; j++)
-            {
-                K[j][i] = 0.0;
-                e[j][i] = 0.0;
-                R[j][i] = 0.0;
-                VAR[j][i] = 1.0;
-                KOR[j][i] = 0.0;
-                dr[j][i] = 0.0;
-            }
-        }
-    }
-
-
-
-    /**************************************************/
-    /* Compute predictor coefficients, predicted data */
-    /**************************************************/
-    for (i=0;i<BLOCK_LEN_LONG;i++)
-    {
-        for(j=1;j<=LPC;j++) {
-            if(VAR[j][i]>MINVAR)
-                K[j][i] = KOR[j][i]/VAR[j][i]*B;
-            else
-                K[j][i] = 0;
-        }
-    }
-
-
-    for (k=0; k<BLOCK_LEN_LONG; k++)
-    {
-        sb_samples_pred[k]=0.0;
-        for (i=1; i<=LPC; i++)
-            sb_samples_pred[k]+=K[i][k]*R[i-1][k];
-    }
-
-
-    /***********************************************************/
-    /* If this is the right channel of a channel_pair_element, */
-    /* AND common_window is 1 in this channel_pair_element,    */
-    /* THEN copy predictor data to use from the left channel.  */
-    /* ELSE determine independent predictor data and resets.   */
-    /***********************************************************/
-    /* BE CAREFUL HERE, this assumes that predictor data has   */
-    /* already been determined for the left channel!!          */
-    /***********************************************************/
-    isRightWithCommonWindow = 0;     /* Is this a right channel with common_window?*/
-    if ((thisChannel->cpe)&&( !(thisChannel->ch_is_left))) {
-        leftChanNum = thisChannel->paired_ch;
-        if (channelInfo[leftChanNum].common_window) {
-            isRightWithCommonWindow = 1;
-        }
-    }
-
-    if (isRightWithCommonWindow) {
-
-        /**************************************************/
-        /* Use predictor data from the left channel.      */
-        /**************************************************/
-        CopyPredInfo(&(coderInfo[chanNum]),&(coderInfo[leftChanNum]));
-
-        /* Make sure to turn off bands with intensity stereo */
-#if 0
-        if (thisChannel->is_info.is_present) {
-            for (i=0; i<nsfb; i++) {
-                if (thisChannel->is_info.is_used[i]) {
-                    pred_sfb_flag[i] = 0;
-                }
-            }
-        }
-#endif
-
-        cb_long=0;
-        for (i=0; i<nsfb; i++)
-        {
-            if (!pred_sfb_flag[i]) {
-                for (j=cb_long; j<cb_long+isfb_width[i]; j++)
-                    sb_samples_pred[j]=0.0;
-            }
-            cb_long+=isfb_width[i];
-        }
-
-        /* Disable prediction for bands nsfb through SBMAX_L */
-        for (i=j;i<BLOCK_LEN_LONG;i++) {
-            sb_samples_pred[i]=0.0;
-        }
-        for (i=nsfb;i<SBMAX_L;i++) {
-            pred_sfb_flag[i]=0;
-        }
-
-        /* Is global enable set, if not enabled predicted samples are zeroed */
-        if(!pred_global_flag[0]) {
-            for (j=0; j<BLOCK_LEN_LONG; j++)
-                sb_samples_pred[j]=0.0;
-        }
-        for (j=0; j<BLOCK_LEN_LONG; j++)
-            act_spec[j]-=sb_samples_pred[j];
-
-    } else {
-
-        /**************************************************/
-        /* Determine whether to enable/disable prediction */
-        /**************************************************/
-
-        for (k=0; k<BLOCK_LEN_LONG; k++) {
-            energy[k]=act_spec[k]*act_spec[k];
-            snr_p[k]=(act_spec[k]-sb_samples_pred[k])*(act_spec[k]-sb_samples_pred[k]);
-        }
-
-        cb_long=0;
-        for (i=0; i<nsfb; i++) {
-            pred_sfb_flag[i]=1;
-            temp1=0.0;
-            temp2=0.0;
-            for (j=cb_long; j<cb_long+isfb_width[i]; j++) {
-                temp1+=energy[j];
-                temp2+=snr_p[j];
-            }
-            if(temp2<1.e-20)
-                temp2=1.e-20;
-            if(temp1!=0.0)
-                snr[i]=-10.*log10((double ) temp2/temp1);
-            else
-                snr[i]=0.0;
-
-            if(snr[i]<=0.0) {
-                pred_sfb_flag[i]=0;
-                for (j=cb_long; j<cb_long+isfb_width[i]; j++)
-                    sb_samples_pred[j]=0.0;
-            }
-            cb_long+=isfb_width[i];
-        }
-
-        /* Disable prediction for bands nsfb through SBMAX_L */
-        for (i=j;i<BLOCK_LEN_LONG;i++) {
-            sb_samples_pred[i]=0.0;
-        }
-        for (i=nsfb;i<SBMAX_L;i++) {
-            pred_sfb_flag[i]=0;
-        }
-
-        num_bit=0.0;
-        for (i=0; i<nsfb; i++)
-            if(snr[i]>0.0)
-                num_bit+=snr[i]/6.*isfb_width[i];
-
-        /* Determine global enable, if not enabled predicted samples are zeroed */
-        pred_global_flag[0]=1;
-        if(num_bit<50) {
-            pred_global_flag[0]=0; num_bit=0.0;
-            for (j=0; j<BLOCK_LEN_LONG; j++)
-                sb_samples_pred[j]=0.0;
-        }
-        for (j=0; j<BLOCK_LEN_LONG; j++)
-            act_spec[j]-=sb_samples_pred[j];
-
-    }
-
-    /**********************************************************/
-    /* If this is a left channel, determine pred resets.      */
-    /* If this is a right channel, using pred reset data from */
-    /* left channel.  Keep left and right resets in sync.     */
-    /**********************************************************/
-    if ((thisChannel->cpe)&&( !(thisChannel->ch_is_left))) {
-        /*  if (!thisChannel->ch_is_left) {*/
-        /**********************************************************/
-        /* Using predictor reset data from the left channel.      */
-        /**********************************************************/
-        reset_count = &coderInfo[leftChanNum].bwpInfo.reset_count_mc;
-        /* Reset the frame counter */
-        for (i=0;i<BLOCK_LEN_LONG;i++) {
-            thisLineNeedsResetting[i]=0;
-        }
-        reset_group = &(coderInfo[chanNum].reset_group_number);
-        if (*reset_count % RESET_FRAME == 0)
-        { /* Send a reset in this frame */
-            *reset_group = *reset_count / 8;
-            for (i = *reset_group - 1; i < BLOCK_LEN_LONG; i += 30)
-            {
-                thisLineNeedsResetting[i]=1;
-            }
-        }
-        else
-            *reset_group = -1;
-    } else {
-        /******************************************************************/
-        /* Determine whether a prediction reset is required - if so, then */
-        /* set reset flag for the appropriate group.                      */
-        /******************************************************************/
-
-        /* Increase counter on left channel, keep left and right resets in sync */
-        (*reset_count)++;
-
-        /* Reset the frame counter */
-        for (i=0;i<BLOCK_LEN_LONG;i++) {
-            thisLineNeedsResetting[i]=0;
-        }
-        if (*reset_count >= 31 * RESET_FRAME)
-            *reset_count = RESET_FRAME;
-        if (*reset_count % RESET_FRAME == 0)
-        { /* Send a reset in this frame */
-            *reset_group = *reset_count / 8;
-            for (i = *reset_group - 1; i < BLOCK_LEN_LONG; i += 30)
-            {
-                thisLineNeedsResetting[i]=1;
-            }
-        }
-        else
-            *reset_group = -1;
-    }
-
-
-    /* Ensure that prediction data is sent when there is a prediction
-    * reset.
-    */
-    if (*reset_group != -1 && pred_global_flag[0] == 0)
-    {
-        pred_global_flag[0] = 1;
-        for (i = 0; i < nsfb; i++)
-            pred_sfb_flag[i] = 0;
-    }
-}
-
-
-void CopyPredInfo(CoderInfo *right, CoderInfo *left)
-{
-    int band;
-
-    right->pred_global_flag = left->pred_global_flag;
-    right->reset_group_number = left->reset_group_number;
-
-    for (band = 0; band<MAX_SCFAC_BANDS; band++) {
-        right->pred_sfb_flag[band] = left->pred_sfb_flag[band];
-    }
-}
-
-
-
-
--- a/libfaac/backpred.h
+++ /dev/null
@@ -1,51 +1,0 @@
-/*
- * FAAC - Freeware Advanced Audio Coder
- * Copyright (C) 2001 Menno Bakker
- *
- * This library 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.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * $Id: backpred.h,v 1.6 2012/03/01 18:34:17 knik Exp $
- */
-
-#ifndef _AAC_BACK_H_INCLUDED
-#define _AAC_BACK_H_INCLUDED
-
-#define PRED_ALPHA  0.90625
-#define PRED_A      0.953125
-#define PRED_B      0.953125
-
-#define ALPHA PRED_ALPHA
-#define A PRED_A
-#define B PRED_B
-#define MINVAR 1.e-10
-
-/* Reset every RESET_FRAME frames. */
-#define RESET_FRAME 8
-
-void PredCalcPrediction(double *act_spec,
-                        double *last_spec,
-                        int btype,
-                        int nsfb,
-                        int *isfb_width,
-                        CoderInfo *coderInfo,
-                        ChannelInfo *channelInfo,
-                        int chanNum);
-
-void PredInit(faacEncStruct* hEncoder);
-
-void CopyPredInfo(CoderInfo *right, CoderInfo *left);
-
-
-#endif
--- a/libfaac/bitstream.c
+++ b/libfaac/bitstream.c
@@ -34,7 +34,6 @@
 #include "channels.h"
 #include "huffman.h"
 #include "bitstream.h"
-#include "ltp.h"
 #include "util.h"
 
 static int CountBitstream(faacEncStruct* hEncoder,
@@ -71,12 +70,6 @@
                     int commonWindow,
                     int objectType,
                     int writeFlag);
-static int WriteLTPPredictorData(CoderInfo *coderInfo,
-                                 BitStream *bitStream,
-                                 int writeFlag);
-static int WritePredictorData(CoderInfo *coderInfo,
-                              BitStream *bitStream,
-                              int writeFlag);
 static int WritePulseData(CoderInfo *coderInfo,
                           BitStream *bitStream,
                           int writeFlag);
@@ -537,22 +530,9 @@
     }
     bits += LEN_TNS_PRES;
 #endif
-        if (objectType == LTP)
-        {
             bits++;
-            if(writeFlag)
-                PutBit(bitStream, coderInfo->ltpInfo.global_pred_flag, 1); /* Prediction Global used */
-
-            bits += WriteLTPPredictorData(coderInfo, bitStream, writeFlag);
-            if (common_window)
-                bits += WriteLTPPredictorData(coderInfo, bitStream, writeFlag);
-        } else {
-            bits++;
             if (writeFlag)
-                PutBit(bitStream, coderInfo->pred_global_flag, LEN_PRED_PRES);  /* predictor_data_present */
-
-            bits += WritePredictorData(coderInfo, bitStream, writeFlag);
-        }
+                PutBit(bitStream, 0, LEN_PRED_PRES);  /* predictor_data_present */
 #ifndef DRM
     }
 #endif
@@ -619,86 +599,6 @@
 #endif
 
     /* Return number of bits */
-    return bits;
-}
-
-static int WriteLTPPredictorData(CoderInfo *coderInfo, BitStream *bitStream, int writeFlag)
-{
-    int i, last_band;
-    int bits;
-    LtpInfo *ltpInfo = &coderInfo->ltpInfo;
-
-    bits = 0;
-
-    if (ltpInfo->global_pred_flag)
-    {
-
-        if(writeFlag)
-            PutBit(bitStream, 1, 1); /* LTP used */
-        bits++;
-
-        switch(coderInfo->block_type)
-        {
-        case ONLY_LONG_WINDOW:
-        case LONG_SHORT_WINDOW:
-        case SHORT_LONG_WINDOW:
-            bits += LEN_LTP_LAG;
-            bits += LEN_LTP_COEF;
-            if(writeFlag)
-            {
-                PutBit(bitStream, ltpInfo->delay[0], LEN_LTP_LAG);
-                PutBit(bitStream, ltpInfo->weight_idx,  LEN_LTP_COEF);
-            }
-
-            last_band = ((coderInfo->nr_of_sfb < MAX_LT_PRED_LONG_SFB) ?
-                coderInfo->nr_of_sfb : MAX_LT_PRED_LONG_SFB);
-//            last_band = coderInfo->nr_of_sfb;
-
-            bits += last_band;
-            if(writeFlag)
-                for (i = 0; i < last_band; i++)
-                    PutBit(bitStream, ltpInfo->sfb_prediction_used[i], LEN_LTP_LONG_USED);
-            break;
-
-        default:
-            break;
-        }
-    }
-
-    return (bits);
-}
-
-static int WritePredictorData(CoderInfo *coderInfo,
-                              BitStream *bitStream,
-                              int writeFlag)
-{
-    int bits = 0;
-
-    /* Write global predictor data present */
-    short predictorDataPresent = coderInfo->pred_global_flag;
-    int numBands = min(coderInfo->max_pred_sfb, coderInfo->nr_of_sfb);
-
-    if (writeFlag) {
-        if (predictorDataPresent) {
-            int b;
-            if (coderInfo->reset_group_number == -1) {
-                PutBit(bitStream, 0, LEN_PRED_RST); /* No prediction reset */
-            } else {
-                PutBit(bitStream, 1, LEN_PRED_RST);
-                PutBit(bitStream, (unsigned long)coderInfo->reset_group_number,
-                    LEN_PRED_RSTGRP);
-            }
-
-            for (b=0;b<numBands;b++) {
-                PutBit(bitStream, coderInfo->pred_sfb_flag[b], LEN_PRED_ENAB);
-            }
-        }
-    }
-    bits += (predictorDataPresent) ?
-        (LEN_PRED_RST +
-        ((coderInfo->reset_group_number)!=-1)*LEN_PRED_RSTGRP +
-        numBands*LEN_PRED_ENAB) : 0;
-
     return bits;
 }
 
--- a/libfaac/coder.h
+++ b/libfaac/coder.h
@@ -70,22 +70,6 @@
 #define LEN_TNS_NFILTL 2
 #define LEN_TNS_NFILTS 1
 
-#define DELAY 2048
-#define LEN_LTP_DATA_PRESENT 1
-#define LEN_LTP_LAG 11
-#define LEN_LTP_COEF 3
-#define LEN_LTP_SHORT_USED 1
-#define LEN_LTP_SHORT_LAG_PRESENT 1
-#define LEN_LTP_SHORT_LAG 5
-#define LTP_LAG_OFFSET 16
-#define LEN_LTP_LONG_USED 1
-#define MAX_LT_PRED_LONG_SFB 40
-#define MAX_LT_PRED_SHORT_SFB 13
-#define SHORT_SQ_OFFSET (BLOCK_LEN_LONG-(BLOCK_LEN_SHORT*4+BLOCK_LEN_SHORT/2))
-#define CODESIZE 8
-#define NOK_LT_BLEN (3 * BLOCK_LEN_LONG)
-
-#define SBMAX_L 49
 #define LPC 2
 
 typedef struct {
@@ -117,22 +101,6 @@
 
 typedef struct
 {
-    int weight_idx;
-    double weight;
-    int sbk_prediction_used[MAX_SHORT_WINDOWS];
-    int sfb_prediction_used[MAX_SCFAC_BANDS];
-    int delay[MAX_SHORT_WINDOWS];
-    int global_pred_flag;
-    int side_info;
-    double *buffer;
-    double *mdct_predicted;
-
-    double *time_buffer;
-    double *ltp_overlap_buffer;
-} LtpInfo;
-
-typedef struct
-{
     int psy_init_mc;
     double dr_mc[LPC][BLOCK_LEN_LONG],e_mc[LPC+1+1][BLOCK_LEN_LONG];
     double K_mc[LPC+1][BLOCK_LEN_LONG], R_mc[LPC+1][BLOCK_LEN_LONG];
@@ -181,18 +149,8 @@
     int iLenReordSpData;
 #endif
 
-    /* Holds the requantized spectrum */
-    double *requantFreq;
-
     TnsInfo tnsInfo;
-    LtpInfo ltpInfo;
     BwpInfo bwpInfo;
-
-    int max_pred_sfb;
-    int pred_global_flag;
-    int pred_sfb_flag[MAX_SCFAC_BANDS];
-    int reset_group_number;
-
 } CoderInfo;
 
 typedef struct {
--- a/libfaac/frame.c
+++ b/libfaac/frame.c
@@ -42,8 +42,6 @@
 #include "util.h"
 #include "huffman.h"
 #include "tns.h"
-#include "ltp.h"
-#include "backpred.h"
 #include "version.h"
 
 #if FAAC_RELEASE
@@ -151,14 +149,9 @@
             break;
     }
 
-    /* No SSR supported for now */
-    if (hEncoder->config.aacObjectType == SSR)
+    if (hEncoder->config.aacObjectType != LOW)
         return 0;
 
-    /* LTP only with MPEG4 */
-    if ((hEncoder->config.aacObjectType == LTP) && (hEncoder->config.mpegVersion != MPEG4))
-        return 0;
-
     /* Re-init TNS for new profile */
     TnsInit(hEncoder);
 
@@ -322,7 +315,7 @@
     hEncoder->config.name = libfaacName;
     hEncoder->config.copyright = libCopyright;
     hEncoder->config.mpegVersion = MPEG4;
-    hEncoder->config.aacObjectType = LTP;
+    hEncoder->config.aacObjectType = LOW;
     hEncoder->config.allowMidside = 1;
     hEncoder->config.useLfe = 1;
     hEncoder->config.useTns = 0;
@@ -362,14 +355,9 @@
         hEncoder->coderInfo[channel].num_window_groups = 1;
         hEncoder->coderInfo[channel].window_group_length[0] = 1;
 
-        /* FIXME: Use sr_idx here */
-        hEncoder->coderInfo[channel].max_pred_sfb = GetMaxPredSfb(hEncoder->sampleRateIdx);
-
         hEncoder->sampleBuff[channel] = NULL;
         hEncoder->nextSampleBuff[channel] = NULL;
         hEncoder->next2SampleBuff[channel] = NULL;
-        hEncoder->ltpTimeBuff[channel] = (double*)AllocMemory(2*BLOCK_LEN_LONG*sizeof(double));
-        SetMemory(hEncoder->ltpTimeBuff[channel], 0, 2*BLOCK_LEN_LONG*sizeof(double));
     }
 
     /* Initialize coder functions */
@@ -384,10 +372,6 @@
 
     TnsInit(hEncoder);
 
-    LtpInit(hEncoder);
-
-    PredInit(hEncoder);
-
     AACQuantizeInit(hEncoder->coderInfo, hEncoder->numChannels,
 		    &(hEncoder->aacquantCfg));
 
@@ -409,8 +393,6 @@
 
     FilterBankEnd(hEncoder);
 
-    LtpEnd(hEncoder);
-
     AACQuantizeEnd(hEncoder->coderInfo, hEncoder->numChannels,
 			&(hEncoder->aacquantCfg));
 
@@ -421,8 +403,6 @@
     /* Free remaining buffer memory */
     for (channel = 0; channel < hEncoder->numChannels; channel++) 
 	{
-		if (hEncoder->ltpTimeBuff[channel])
-			FreeMemory(hEncoder->ltpTimeBuff[channel]);
 		if (hEncoder->sampleBuff[channel])
 			FreeMemory(hEncoder->sampleBuff[channel]);
 		if (hEncoder->nextSampleBuff[channel])
@@ -452,8 +432,6 @@
     int sb, frameBytes;
     unsigned int offset;
     BitStream *bitStream; /* bitstream used for writing the frame to */
-    TnsInfo *tnsInfo_for_LTP;
-    TnsInfo *tnsDecInfo;
 #ifdef DRM
     int desbits, diff;
     double fix;
@@ -463,9 +441,6 @@
     ChannelInfo *channelInfo = hEncoder->channelInfo;
     CoderInfo *coderInfo = hEncoder->coderInfo;
     unsigned int numChannels = hEncoder->numChannels;
-    unsigned int sampleRate = hEncoder->sampleRate;
-    unsigned int aacObjectType = hEncoder->config.aacObjectType;
-    unsigned int mpegVersion = hEncoder->config.mpegVersion;
     unsigned int useLfe = hEncoder->config.useLfe;
     unsigned int useTns = hEncoder->config.useTns;
     unsigned int allowMidside = hEncoder->config.allowMidside;
@@ -492,17 +467,6 @@
 	{
 		double *tmp;
 
-        if (hEncoder->sampleBuff[channel]) {
-            for(i = 0; i < FRAME_LEN; i++) {
-                hEncoder->ltpTimeBuff[channel][i] = hEncoder->sampleBuff[channel][i];
-            }
-        }
-        if (hEncoder->nextSampleBuff[channel]) {
-            for(i = 0; i < FRAME_LEN; i++) {
-                hEncoder->ltpTimeBuff[channel][FRAME_LEN + i] =
-						hEncoder->nextSampleBuff[channel][i];
-            }
-        }
 
 		if (!hEncoder->sampleBuff[channel])
 			hEncoder->sampleBuff[channel] = (double*)AllocMemory(FRAME_LEN*sizeof(double));
@@ -693,46 +657,6 @@
         }
     }
 
-    for(channel = 0; channel < numChannels; channel++)
-    {
-        if((coderInfo[channel].tnsInfo.tnsDataPresent != 0) && (useTns))
-            tnsInfo_for_LTP = &(coderInfo[channel].tnsInfo);
-        else
-            tnsInfo_for_LTP = NULL;
-
-        if(channelInfo[channel].present && (!channelInfo[channel].lfe) &&
-            (coderInfo[channel].block_type != ONLY_SHORT_WINDOW) &&
-            (mpegVersion == MPEG4) && (aacObjectType == LTP))
-        {
-            LtpEncode(hEncoder,
-					&coderInfo[channel],
-					&(coderInfo[channel].ltpInfo),
-					tnsInfo_for_LTP,
-					hEncoder->freqBuff[channel],
-					hEncoder->ltpTimeBuff[channel]);
-        } else {
-            coderInfo[channel].ltpInfo.global_pred_flag = 0;
-        }
-    }
-
-    for(channel = 0; channel < numChannels; channel++)
-    {
-        if ((aacObjectType == MAIN) && (!channelInfo[channel].lfe)) {
-            int numPredBands = min(coderInfo[channel].max_pred_sfb, coderInfo[channel].nr_of_sfb);
-            PredCalcPrediction(hEncoder->freqBuff[channel],
-					coderInfo[channel].requantFreq,
-					coderInfo[channel].block_type,
-					numPredBands,
-					(coderInfo[channel].block_type==ONLY_SHORT_WINDOW)?
-					hEncoder->srInfo->cb_width_short:hEncoder->srInfo->cb_width_long,
-					coderInfo,
-					channelInfo,
-					channel);
-        } else {
-            coderInfo[channel].pred_global_flag = 0;
-        }
-    }
-
     for (channel = 0; channel < numChannels; channel++) {
 		if (coderInfo[channel].block_type == ONLY_SHORT_WINDOW) {
 			SortForGrouping(&coderInfo[channel],
@@ -821,48 +745,6 @@
 			cil->nr_of_sfb = cir->nr_of_sfb = cil->max_sfb;
 		}
     }
-
-    MSReconstruct(coderInfo, channelInfo, numChannels);
-
-    for (channel = 0; channel < numChannels; channel++)
-    {
-        /* If short window, reconstruction not needed for prediction */
-        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
-            int sind;
-            for (sind = 0; sind < BLOCK_LEN_LONG; sind++) {
-				coderInfo[channel].requantFreq[sind] = 0.0;
-            }
-        } else {
-
-            if((coderInfo[channel].tnsInfo.tnsDataPresent != 0) && (useTns))
-                tnsDecInfo = &(coderInfo[channel].tnsInfo);
-            else
-                tnsDecInfo = NULL;
-
-            if ((!channelInfo[channel].lfe) && (aacObjectType == LTP)) {  /* no reconstruction needed for LFE channel*/
-
-                LtpReconstruct(&coderInfo[channel], &(coderInfo[channel].ltpInfo),
-						coderInfo[channel].requantFreq);
-
-                if(tnsDecInfo != NULL)
-                    TnsDecodeFilterOnly(&(coderInfo[channel].tnsInfo), coderInfo[channel].nr_of_sfb,
-							coderInfo[channel].max_sfb, coderInfo[channel].block_type,
-							coderInfo[channel].sfb_offset, coderInfo[channel].requantFreq);
-
-                IFilterBank(hEncoder, &coderInfo[channel],
-						coderInfo[channel].requantFreq,
-						coderInfo[channel].ltpInfo.time_buffer,
-						coderInfo[channel].ltpInfo.ltp_overlap_buffer,
-						MOVERLAPPED);
-
-                LtpUpdate(&(coderInfo[channel].ltpInfo),
-						coderInfo[channel].ltpInfo.time_buffer,
-						coderInfo[channel].ltpInfo.ltp_overlap_buffer,
-						BLOCK_LEN_LONG);
-            }
-        }
-    }
-
 #ifndef DRM
     /* Write the AAC bitstream */
     bitStream = OpenBitStream(bufferSize, outputBuffer);
--- a/libfaac/frame.h
+++ b/libfaac/frame.h
@@ -78,7 +78,6 @@
     double *nextSampleBuff[MAX_CHANNELS];
     double *next2SampleBuff[MAX_CHANNELS];
     double *next3SampleBuff[MAX_CHANNELS];
-    double *ltpTimeBuff[MAX_CHANNELS];
 
     /* Filterbank buffers */
     double *sin_window_long;
--- a/libfaac/ltp.c
+++ /dev/null
@@ -1,420 +1,0 @@
-/**************************************************************************
-
-This software module was originally developed by
-Nokia in the course of development of the MPEG-2 AAC/MPEG-4
-Audio standard ISO/IEC13818-7, 14496-1, 2 and 3.
-This software module is an implementation of a part
-of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the
-MPEG-2 aac/MPEG-4 Audio standard. ISO/IEC  gives users of the
-MPEG-2aac/MPEG-4 Audio standards free license to this software module
-or modifications thereof for use in hardware or software products
-claiming conformance to the MPEG-2 aac/MPEG-4 Audio  standards. Those
-intending to use this software module in hardware or software products
-are advised that this use may infringe existing patents. The original
-developer of this software module, the subsequent
-editors and their companies, and ISO/IEC have no liability for use of
-this software module or modifications thereof in an
-implementation. Copyright is not released for non MPEG-2 aac/MPEG-4
-Audio conforming products. The original developer retains full right to
-use the code for the developer's own purpose, assign or donate the code to a
-third party and to inhibit third party from using the code for non
-MPEG-2 aac/MPEG-4 Audio conforming products. This copyright notice
-must be included in all copies or derivative works.
-Copyright (c)1997.
-
-***************************************************************************/
-/*
- * $Id: ltp.c,v 1.10 2012/03/01 18:34:17 knik Exp $
- */
-
-#include <stdio.h>
-#include <math.h>
-
-#include "frame.h"
-#include "coder.h"
-#include "ltp.h"
-#include "tns.h"
-#include "filtbank.h"
-#include "util.h"
-
-
-/* short double_to_int(double sig_in); */
-#define double_to_int(sig_in) \
-   ((sig_in) > 32767 ? 32767 : ( \
-       (sig_in) < -32768 ? -32768 : (sig_in)))
-
-#define _MDCT_SCALE		512
-
-/*  Purpose:    Codebook for LTP weight coefficients.  */
-static double codebook[CODESIZE] =
-{
-    0.570829,
-    0.696616,
-    0.813004,
-    0.911304,
-    0.984900,
-    1.067894,
-    1.194601,
-    1.369533
-};
-
-
-static double snr_pred(double *mdct_in, double *mdct_pred, int *sfb_flag, int *sfb_offset,
-                int block_type, int side_info, int num_of_sfb)
-{
-    int i, j, flen;
-    double snr_limit;
-    double num_bit, snr[NSFB_LONG];
-    double temp1, temp2;
-    double energy[BLOCK_LEN_LONG], snr_p[BLOCK_LEN_LONG];
-
-    if (block_type != ONLY_SHORT_WINDOW)
-    {
-        flen = BLOCK_LEN_LONG;
-        snr_limit = 1.e-30;
-    } else {
-        flen = BLOCK_LEN_SHORT;
-        snr_limit = 1.e-20;
-    }
-
-    for (i = 0; i < flen; i++)
-    {
-        energy[i] = mdct_in[i] * mdct_in[i];
-        snr_p[i] = (mdct_in[i] - mdct_pred[i]) * (mdct_in[i] - mdct_pred[i]);
-    }
-
-    num_bit = 0.0;
-
-    for (i = 0; i < num_of_sfb; i++)
-    {
-        temp1 = 0.0;
-        temp2 = 0.0;
-        for (j = sfb_offset[i]; j < sfb_offset[i + 1]; j++)
-        {
-            temp1 += energy[j];
-            temp2 += snr_p[j];
-        }
-
-        if (temp2 < snr_limit)
-            temp2 = snr_limit;
-
-        if (temp1 > 1.e-20)
-            snr[i] = -10. * log10 (temp2 / temp1);
-        else
-            snr[i] = 0.0;
-
-        sfb_flag[i] = 1;
-
-        if (block_type != ONLY_SHORT_WINDOW)
-        {
-            if (snr[i] <= 0.0)
-            {
-                sfb_flag[i] = 0;
-                for (j = sfb_offset[i]; j < sfb_offset[i + 1]; j++)
-                    mdct_pred[j] = 0.0;
-            } else {
-                num_bit += snr[i] / 6. * (sfb_offset[i + 1] - sfb_offset[i]);
-            }
-        }
-    }
-
-    if (num_bit < side_info)
-    {
-//      printf("LTP not used!, num_bit: %f    ", num_bit);
-        num_bit = 0.0;
-        for (j = 0; j < flen; j++)
-            mdct_pred[j] = 0.0;
-        for (i = 0; i < num_of_sfb; i++)
-            sfb_flag[i] = 0;
-    } else {
-        num_bit -= side_info;
-//      printf("LTP used!, num_bit: %f    ", num_bit);
-    }
-
-    return (num_bit);
-}
-
-static void prediction(double *buffer, double *predicted_samples, double *weight, int lag,
-                int flen)
-{
-    int i, offset;
-    int num_samples;
-
-    offset = NOK_LT_BLEN - flen / 2 - lag;
-
-    num_samples = flen;
-    if(NOK_LT_BLEN - offset < flen)
-        num_samples = NOK_LT_BLEN - offset;
-
-    for(i = 0; i < num_samples; i++)
-        predicted_samples[i] = *weight * _MDCT_SCALE*buffer[offset++];
-    for( ; i < flen; i++)
-        predicted_samples[i] = 0.0;
-
-	
-}
-
-static void w_quantize(double *freq, int *ltp_idx)
-{
-    int i;
-    double dist, low;
-
-    low = 1.0e+10;
-    dist = 0.0;
-    for (i = 0; i < CODESIZE; i++)
-    {
-        dist = (*freq - codebook[i]) * (*freq - codebook[i]);
-        if (dist < low)
-        {
-            low = dist;
-            *ltp_idx = i;
-        }
-    }
-
-    *freq = codebook[*ltp_idx];
-}
-
-static int pitch(double *sb_samples, double *x_buffer, int flen, int lag0, int lag1,
-          double *predicted_samples, double *gain, int *cb_idx)
-{
-    int i, j, delay;
-    double corr1, corr2, lag_corr;
-    double p_max, energy, lag_energy;
-
-    /*
-     * Below is a figure illustrating how the lag and the
-     * samples in the buffer relate to each other.
-     *
-     * ------------------------------------------------------------------
-     * |              |               |                |                 |
-     * |    slot 1    |      2        |       3        |       4         |
-     * |              |               |                |                 |
-     * ------------------------------------------------------------------
-     *
-     * lag = 0 refers to the end of slot 4 and lag = DELAY refers to the end
-     * of slot 2. The start of the predicted frame is then obtained by
-     * adding the length of the frame to the lag. Remember that slot 4 doesn't
-     * actually exist, since it is always filled with zeros.
-     *
-     * The above short explanation was for long blocks. For short blocks the
-     * zero lag doesn't refer to the end of slot 4 but to the start of slot
-     * 4 - the frame length of a short block.
-     *
-     * Some extra code is then needed to handle those lag values that refer
-     * to slot 4.
-     */
-
-    p_max = 0.0;
-    lag_corr = lag_energy = 0.0;
-    delay = lag0;
-
-
-	for (i = lag0; i<lag1; i++)
-	{
-		energy	= 0.0;
-		corr1	= 0.0;
-		for (j=0; j < flen; j++)
-		{
-			if (j < i+BLOCK_LEN_LONG)
-			{
-				corr1  += sb_samples[j] * _MDCT_SCALE * x_buffer[NOK_LT_BLEN - flen/2 - i + j];
-				energy += _MDCT_SCALE * x_buffer[NOK_LT_BLEN - flen/2 - i + j] * _MDCT_SCALE * x_buffer[NOK_LT_BLEN - flen/2 - i + j];
-			}
-		}
-        if (energy != 0.0)
-            corr2 = corr1 / sqrt(energy);
-        else
-            corr2 = 0.0;
-		
-        if (p_max < corr2)
-        {
-            p_max = corr2;
-            delay = i;
-            lag_corr = corr1;
-            lag_energy = energy;
-        }
-	}		
-    /* Compute the gain. */
-    if(lag_energy != 0.0)
-        *gain =  lag_corr / (1.010 * lag_energy);
-    else
-        *gain = 0.0;
-
-    /* Quantize the gain. */
-    w_quantize(gain, cb_idx);
-//  printf("Delay: %d, Coeff: %f", delay, *gain);
-	
-    /* Get the predicted signal. */
-    prediction(x_buffer, predicted_samples, gain, delay, flen);
-
-	
-    return (delay);
-}
-
-static double ltp_enc_tf(faacEncHandle hEncoder,
-                CoderInfo *coderInfo, double *p_spectrum, double *predicted_samples,
-                         double *mdct_predicted, int *sfb_offset,
-                         int num_of_sfb, int last_band, int side_info,
-                         int *sfb_prediction_used, TnsInfo *tnsInfo)
-{
-    double bit_gain;
-
-    /* Transform prediction to frequency domain. */
-    FilterBank(hEncoder, coderInfo, predicted_samples, mdct_predicted,
-        NULL, MNON_OVERLAPPED);
-	
-    /* Apply TNS analysis filter to the predicted spectrum. */
-    if(tnsInfo != NULL)
-        TnsEncodeFilterOnly(tnsInfo, num_of_sfb, num_of_sfb, coderInfo->block_type, sfb_offset,
-        mdct_predicted);
-	
-    /* Get the prediction gain. */
-    bit_gain = snr_pred(p_spectrum, mdct_predicted, sfb_prediction_used,
-        sfb_offset, side_info, last_band, coderInfo->nr_of_sfb);
-
-    return (bit_gain);
-}
-
-void LtpInit(faacEncStruct* hEncoder)
-{
-    int i;
-    unsigned int channel;
-
-    for (channel = 0; channel < hEncoder->numChannels; channel++) {
-        LtpInfo *ltpInfo = &(hEncoder->coderInfo[channel].ltpInfo);
-
-        ltpInfo->buffer = AllocMemory(NOK_LT_BLEN * sizeof(double));
-        ltpInfo->mdct_predicted = AllocMemory(2*BLOCK_LEN_LONG*sizeof(double));
-        ltpInfo->time_buffer = AllocMemory(BLOCK_LEN_LONG*sizeof(double));
-        ltpInfo->ltp_overlap_buffer = AllocMemory(BLOCK_LEN_LONG*sizeof(double));
-
-        for (i = 0; i < NOK_LT_BLEN; i++)
-            ltpInfo->buffer[i] = 0;
-
-        ltpInfo->weight_idx = 0;
-        for(i = 0; i < MAX_SHORT_WINDOWS; i++)
-            ltpInfo->sbk_prediction_used[i] = ltpInfo->delay[i] = 0;
-
-        for(i = 0; i < MAX_SCFAC_BANDS; i++)
-            ltpInfo->sfb_prediction_used[i] = 0;
-
-        ltpInfo->side_info = LEN_LTP_DATA_PRESENT;
-
-        for(i = 0; i < 2 * BLOCK_LEN_LONG; i++)
-            ltpInfo->mdct_predicted[i] = 0.0;
-
-	}
-}
-
-void LtpEnd(faacEncStruct* hEncoder)
-{
-    unsigned int channel;
-
-    for (channel = 0; channel < hEncoder->numChannels; channel++) {
-        LtpInfo *ltpInfo = &(hEncoder->coderInfo[channel].ltpInfo);
-
-	if (ltpInfo->buffer)
-	  FreeMemory(ltpInfo->buffer);
-	if (ltpInfo->mdct_predicted)
-	  FreeMemory(ltpInfo->mdct_predicted);
-	if (ltpInfo->time_buffer)
-	  FreeMemory(ltpInfo->time_buffer);
-	if (ltpInfo->ltp_overlap_buffer)
-	  FreeMemory(ltpInfo->ltp_overlap_buffer);
-    }
-}
-
-int LtpEncode(faacEncHandle hEncoder,
-                CoderInfo *coderInfo,
-                LtpInfo *ltpInfo,
-                TnsInfo *tnsInfo,
-                double *p_spectrum,
-                double *p_time_signal)
-{
-    int i, last_band;
-    double num_bit[MAX_SHORT_WINDOWS];
-    double *predicted_samples;
-
-    ltpInfo->global_pred_flag = 0;
-    ltpInfo->side_info = 0;
-
-    predicted_samples = (double*)AllocMemory(2*BLOCK_LEN_LONG*sizeof(double));
-
-    switch(coderInfo->block_type)
-    {
-    case ONLY_LONG_WINDOW:
-    case LONG_SHORT_WINDOW:
-    case SHORT_LONG_WINDOW:
-        last_band = (coderInfo->nr_of_sfb < MAX_LT_PRED_LONG_SFB) ? coderInfo->nr_of_sfb : MAX_LT_PRED_LONG_SFB;
-
-        ltpInfo->delay[0] =
-            pitch(p_time_signal, ltpInfo->buffer, 2 * BLOCK_LEN_LONG,
-                0, 2 * BLOCK_LEN_LONG, predicted_samples, &ltpInfo->weight,
-                &ltpInfo->weight_idx);
-
-		
-        num_bit[0] =
-            ltp_enc_tf(hEncoder, coderInfo, p_spectrum, predicted_samples,
-                ltpInfo->mdct_predicted,
-                coderInfo->sfb_offset, coderInfo->nr_of_sfb,
-                last_band, ltpInfo->side_info, ltpInfo->sfb_prediction_used,
-                tnsInfo);
-
-
-		ltpInfo->global_pred_flag = (num_bit[0] == 0.0) ? 0 : 1;
-
-        if(ltpInfo->global_pred_flag)
-            for (i = 0; i < coderInfo->sfb_offset[last_band]; i++)
-                p_spectrum[i] -= ltpInfo->mdct_predicted[i];
-            else
-                ltpInfo->side_info = 1;
-
-            break;
-
-    default:
-        break;
-    }
-
-    if (predicted_samples) FreeMemory(predicted_samples);
-
-    return (ltpInfo->global_pred_flag);
-}
-
-void LtpReconstruct(CoderInfo *coderInfo, LtpInfo *ltpInfo, double *p_spectrum)
-{
-    int i, last_band;
-
-    if(ltpInfo->global_pred_flag)
-    {
-        switch(coderInfo->block_type)
-        {
-        case ONLY_LONG_WINDOW:
-        case LONG_SHORT_WINDOW:
-        case SHORT_LONG_WINDOW:
-            last_band = (coderInfo->nr_of_sfb < MAX_LT_PRED_LONG_SFB) ?
-                coderInfo->nr_of_sfb : MAX_LT_PRED_LONG_SFB;
-
-            for (i = 0; i < coderInfo->sfb_offset[last_band]; i++)
-                p_spectrum[i] += ltpInfo->mdct_predicted[i];
-            break;
-
-        default:
-            break;
-        }
-    }
-}
-
-void  LtpUpdate(LtpInfo *ltpInfo, double *time_signal,
-                     double *overlap_signal, int block_size_long)
-{
-    int i;
-
-    for(i = 0; i < NOK_LT_BLEN - 2 * block_size_long; i++)
-        ltpInfo->buffer[i] = ltpInfo->buffer[i + block_size_long];
-
-    for(i = 0; i < block_size_long; i++)
-    {
-        ltpInfo->buffer[NOK_LT_BLEN - 2 * block_size_long + i] = time_signal[i];
-        ltpInfo->buffer[NOK_LT_BLEN - block_size_long + i] = overlap_signal[i];
-    }
-}
--- a/libfaac/ltp.h
+++ /dev/null
@@ -1,42 +1,0 @@
-/*
- * FAAC - Freeware Advanced Audio Coder
- * Copyright (C) 2001 Menno Bakker
- *
- * This library 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.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * $Id: ltp.h,v 1.4 2012/03/01 18:34:17 knik Exp $
- */
-
-#ifndef LTP_H
-#define LTP_H
-
-#include "coder.h"
-
-
-
-void LtpInit(faacEncStruct* hEncoder);
-void LtpEnd(faacEncStruct* hEncoder);
-int LtpEncode(faacEncHandle hEncoder,
-                CoderInfo *coderInfo,
-                LtpInfo *ltpInfo,
-                TnsInfo *tnsInfo,
-                double *p_spectrum,
-                double *p_time_signal);
-void LtpReconstruct(CoderInfo *coderInfo, LtpInfo *ltpInfo, double *p_spectrum);
-void  LtpUpdate(LtpInfo *ltpInfo, double *time_signal,
-                     double *overlap_signal, int block_size_long);
-
-#endif /* not defined LTP_H */
-
--- a/libfaac/midside.c
+++ b/libfaac/midside.c
@@ -121,49 +121,3 @@
     }
   }
 }
-
-void MSReconstruct(CoderInfo *coderInfo,
-		   ChannelInfo *channelInfo,
-		   int maxchan)
-{
-  int chn;
-
-  for (chn = 0; chn < maxchan; chn++)
-  {
-    if (channelInfo[chn].present)
-    {
-      if (channelInfo[chn].cpe && channelInfo[chn].ch_is_left)
-      {
-	int rch = channelInfo[chn].paired_ch;
-
-	MSInfo *msInfoL = &(channelInfo[chn].msInfo);
-
-	if (msInfoL->is_present) {
-	  int nsfb = coderInfo[chn].nr_of_sfb;
-	  int sfb;
-
-	  for (sfb = 0; sfb < nsfb; sfb++)
-	  {
-	    int l, start, end;
-
-	    start = coderInfo[chn].sfb_offset[sfb];
-	    end = coderInfo[chn].sfb_offset[sfb + 1];
-
-	    if (msInfoL->ms_used[sfb])
-	    {
-	      for (l = start; l < end; l++)
-	      {
-		double sum, diff;
-
-		sum = coderInfo[chn].requantFreq[l];
-		diff = coderInfo[rch].requantFreq[l];
-		coderInfo[chn].requantFreq[l] = sum + diff;
-		coderInfo[rch].requantFreq[l] = sum - diff;
-	      }
-	    }
-	  }
-	}
-      }
-    }
-  }
-}
--- a/libfaac/midside.h
+++ b/libfaac/midside.h
@@ -31,7 +31,6 @@
 
 void MSEncode(CoderInfo *coderInfo, ChannelInfo *channelInfo, double *spectrum[MAX_CHANNELS],
               unsigned int numberOfChannels, unsigned int msenable);
-void MSReconstruct(CoderInfo *coderInfo, ChannelInfo *channelInfo, int numberOfChannels);
 
 #ifdef __cplusplus
 }
--- a/libfaac/quantize.c
+++ b/libfaac/quantize.c
@@ -20,6 +20,7 @@
 
 #include <math.h>
 #include "util.h"
+#include "quantize.h"
 
 #define MAGIC_NUMBER  0.4054
 
--- a/libfaac/quantize.h
+++ b/libfaac/quantize.h
@@ -22,6 +22,7 @@
 #define QUANTIZE_H
 
 #include "aacquant.h"
+#include "coder.h"
 
 int BlocQuant(CoderInfo *coderInfo, double *xr, int *xi, AACQuantCfg *aacquantCfg);
 void BandLimit(unsigned *bw, int rate, SR_INFO *sr, AACQuantCfg *aacquantCfg);
--- a/libfaac/util.c
+++ b/libfaac/util.c
@@ -57,17 +57,6 @@
     return 8000;
 }
 
-
-/* Max prediction band for backward predictionas function of fs index */
-const int MaxPredSfb[] = { 33, 33, 38, 40, 40, 40, 41, 41, 37, 37, 37, 34, 0 };
-
-int GetMaxPredSfb(int samplingRateIdx)
-{
-    return MaxPredSfb[samplingRateIdx];
-}
-
-
-
 /* Calculate bit_allocation based on PE */
 unsigned int BitAllocation(double pe, int short_block)
 {