Coverage Report

Created: 2026-09-04 07:02

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/aac/libAACdec/src/channel.cpp
Line
Count
Source
1
/* -----------------------------------------------------------------------------
2
Software License for The Fraunhofer FDK AAC Codec Library for Android
3
4
© Copyright  1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten
5
Forschung e.V. All rights reserved.
6
7
 1.    INTRODUCTION
8
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
9
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
10
scheme for digital audio. This FDK AAC Codec software is intended to be used on
11
a wide variety of Android devices.
12
13
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
14
general perceptual audio codecs. AAC-ELD is considered the best-performing
15
full-bandwidth communications codec by independent studies and is widely
16
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
17
specifications.
18
19
Patent licenses for necessary patent claims for the FDK AAC Codec (including
20
those of Fraunhofer) may be obtained through Via Licensing
21
(www.vialicensing.com) or through the respective patent owners individually for
22
the purpose of encoding or decoding bit streams in products that are compliant
23
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
24
Android devices already license these patent claims through Via Licensing or
25
directly from the patent owners, and therefore FDK AAC Codec software may
26
already be covered under those patent licenses when it is used for those
27
licensed purposes only.
28
29
Commercially-licensed AAC software libraries, including floating-point versions
30
with enhanced sound quality, are also available from Fraunhofer. Users are
31
encouraged to check the Fraunhofer website for additional applications
32
information and documentation.
33
34
2.    COPYRIGHT LICENSE
35
36
Redistribution and use in source and binary forms, with or without modification,
37
are permitted without payment of copyright license fees provided that you
38
satisfy the following conditions:
39
40
You must retain the complete text of this software license in redistributions of
41
the FDK AAC Codec or your modifications thereto in source code form.
42
43
You must retain the complete text of this software license in the documentation
44
and/or other materials provided with redistributions of the FDK AAC Codec or
45
your modifications thereto in binary form. You must make available free of
46
charge copies of the complete source code of the FDK AAC Codec and your
47
modifications thereto to recipients of copies in binary form.
48
49
The name of Fraunhofer may not be used to endorse or promote products derived
50
from this library without prior written permission.
51
52
You may not charge copyright license fees for anyone to use, copy or distribute
53
the FDK AAC Codec software or your modifications thereto.
54
55
Your modified versions of the FDK AAC Codec must carry prominent notices stating
56
that you changed the software and the date of any change. For modified versions
57
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
58
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
59
AAC Codec Library for Android."
60
61
3.    NO PATENT LICENSE
62
63
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
64
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
65
Fraunhofer provides no warranty of patent non-infringement with respect to this
66
software.
67
68
You may use this FDK AAC Codec software or modifications thereto only for
69
purposes that are authorized by appropriate patent licenses.
70
71
4.    DISCLAIMER
72
73
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
74
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
75
including but not limited to the implied warranties of merchantability and
76
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
77
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
78
or consequential damages, including but not limited to procurement of substitute
79
goods or services; loss of use, data, or profits, or business interruption,
80
however caused and on any theory of liability, whether in contract, strict
81
liability, or tort (including negligence), arising in any way out of the use of
82
this software, even if advised of the possibility of such damage.
83
84
5.    CONTACT INFORMATION
85
86
Fraunhofer Institute for Integrated Circuits IIS
87
Attention: Audio and Multimedia Departments - FDK AAC LL
88
Am Wolfsmantel 33
89
91058 Erlangen, Germany
90
91
www.iis.fraunhofer.de/amm
92
amm-info@iis.fraunhofer.de
93
----------------------------------------------------------------------------- */
94
95
/**************************** AAC decoder library ******************************
96
97
   Author(s):   Josef Hoepfl
98
99
   Description:
100
101
*******************************************************************************/
102
103
#include "channel.h"
104
#include "aacdecoder.h"
105
#include "block.h"
106
#include "aacdec_tns.h"
107
#include "FDK_bitstream.h"
108
109
#include "conceal.h"
110
111
#include "rvlc.h"
112
113
#include "aacdec_hcr.h"
114
115
#include "usacdec_lpd.h"
116
#include "usacdec_fac.h"
117
118
static void MapMidSideMaskToPnsCorrelation(
119
8.24k
    CAacDecoderChannelInfo *pAacDecoderChannelInfo[2]) {
120
8.24k
  int group;
121
122
40.6k
  for (group = 0; group < pAacDecoderChannelInfo[L]->icsInfo.WindowGroups;
123
32.4k
       group++) {
124
32.4k
    UCHAR groupMask = 1 << group;
125
126
148k
    for (UCHAR band = 0; band < pAacDecoderChannelInfo[L]->icsInfo.MaxSfBands;
127
116k
         band++) {
128
116k
      if (pAacDecoderChannelInfo[L]->pComData->jointStereoData.MsUsed[band] &
129
116k
          groupMask) { /* channels are correlated */
130
9.87k
        CPns_SetCorrelation(&pAacDecoderChannelInfo[L]->data.aac.PnsData, group,
131
9.87k
                            band, 0);
132
133
9.87k
        if (CPns_IsPnsUsed(&pAacDecoderChannelInfo[L]->data.aac.PnsData, group,
134
9.87k
                           band) &&
135
2.11k
            CPns_IsPnsUsed(&pAacDecoderChannelInfo[R]->data.aac.PnsData, group,
136
2.11k
                           band))
137
1.25k
          pAacDecoderChannelInfo[L]->pComData->jointStereoData.MsUsed[band] ^=
138
1.25k
              groupMask; /* clear the groupMask-bit */
139
9.87k
      }
140
116k
    }
141
32.4k
  }
142
8.24k
}
143
144
static void Clean_Complex_Prediction_coefficients(
145
    CJointStereoPersistentData *pJointStereoPersistentData, int windowGroups,
146
0
    const int low_limit, const int high_limit) {
147
0
  for (int group = 0; group < windowGroups; group++) {
148
0
    for (int sfb = low_limit; sfb < high_limit; sfb++) {
149
0
      pJointStereoPersistentData->alpha_q_re_prev[group][sfb] = 0;
150
0
      pJointStereoPersistentData->alpha_q_im_prev[group][sfb] = 0;
151
0
    }
152
0
  }
153
0
}
154
155
/*!
156
  \brief Decode channel pair element
157
158
  The function decodes a channel pair element.
159
160
  \return  none
161
*/
162
void CChannelElement_Decode(
163
    CAacDecoderChannelInfo
164
        *pAacDecoderChannelInfo[2], /*!< pointer to aac decoder channel info */
165
    CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[2],
166
    SamplingRateInfo *pSamplingRateInfo, UINT flags, UINT elFlags,
167
401k
    int el_channels) {
168
401k
  int ch = 0;
169
170
401k
  int maxSfBandsL = 0, maxSfBandsR = 0;
171
401k
  int maybe_jstereo = (el_channels > 1);
172
173
401k
  if (flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA) && el_channels == 2) {
174
73.9k
    if (pAacDecoderChannelInfo[L]->data.usac.core_mode ||
175
66.5k
        pAacDecoderChannelInfo[R]->data.usac.core_mode) {
176
10.4k
      maybe_jstereo = 0;
177
10.4k
    }
178
73.9k
  }
179
180
401k
  if (maybe_jstereo) {
181
151k
    maxSfBandsL =
182
151k
        GetScaleFactorBandsTransmitted(&pAacDecoderChannelInfo[L]->icsInfo);
183
151k
    maxSfBandsR =
184
151k
        GetScaleFactorBandsTransmitted(&pAacDecoderChannelInfo[R]->icsInfo);
185
186
    /* apply ms */
187
151k
    if (pAacDecoderChannelInfo[L]->pDynData->RawDataInfo.CommonWindow) {
188
135k
      if (!(flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA))) {
189
85.6k
        if (pAacDecoderChannelInfo[L]->data.aac.PnsData.PnsActive ||
190
78.1k
            pAacDecoderChannelInfo[R]->data.aac.PnsData.PnsActive) {
191
8.24k
          MapMidSideMaskToPnsCorrelation(pAacDecoderChannelInfo);
192
8.24k
        }
193
85.6k
      }
194
      /* if tns_on_lr == 1 run MS */ /* &&
195
                                        (pAacDecoderChannelInfo[L]->pDynData->specificTo.usac.tns_active
196
                                        == 1) */
197
135k
      if (((flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA)) &&
198
49.6k
           (pAacDecoderChannelInfo[L]->pDynData->specificTo.usac.tns_on_lr ==
199
49.6k
            1)) ||
200
117k
          ((flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA)) == 0)) {
201
117k
        int max_sfb_ste = (INT)(pAacDecoderChannelInfo[L]->icsInfo.max_sfb_ste);
202
203
117k
        CJointStereo_ApplyMS(
204
117k
            pAacDecoderChannelInfo, pAacDecoderStaticChannelInfo,
205
117k
            pAacDecoderChannelInfo[L]->pSpectralCoefficient,
206
117k
            pAacDecoderChannelInfo[R]->pSpectralCoefficient,
207
117k
            pAacDecoderChannelInfo[L]->pDynData->aSfbScale,
208
117k
            pAacDecoderChannelInfo[R]->pDynData->aSfbScale,
209
117k
            pAacDecoderChannelInfo[L]->specScale,
210
117k
            pAacDecoderChannelInfo[R]->specScale,
211
117k
            GetScaleFactorBandOffsets(&pAacDecoderChannelInfo[L]->icsInfo,
212
117k
                                      pSamplingRateInfo),
213
117k
            GetWindowGroupLengthTable(&pAacDecoderChannelInfo[L]->icsInfo),
214
117k
            GetWindowGroups(&pAacDecoderChannelInfo[L]->icsInfo), max_sfb_ste,
215
117k
            maxSfBandsL, maxSfBandsR,
216
117k
            pAacDecoderChannelInfo[L]
217
117k
                ->pComData->jointStereoData.store_dmx_re_prev,
218
117k
            &(pAacDecoderChannelInfo[L]
219
117k
                  ->pComData->jointStereoData.store_dmx_re_prev_e),
220
117k
            1);
221
222
117k
      } /* if ( ((elFlags & AC_EL_USAC_CP_POSSIBLE).... */
223
135k
    }   /* if (pAacDecoderChannelInfo[L]->pDynData->RawDataInfo.CommonWindow)*/
224
225
    /* apply intensity stereo */ /* modifies pAacDecoderChannelInfo[]->aSpecSfb
226
                                  */
227
151k
    if (!(flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA))) {
228
87.7k
      if ((pAacDecoderChannelInfo[L]->pDynData->RawDataInfo.CommonWindow ==
229
87.7k
           1) &&
230
85.6k
          (el_channels == 2)) {
231
85.6k
        CJointStereo_ApplyIS(
232
85.6k
            pAacDecoderChannelInfo,
233
85.6k
            GetScaleFactorBandOffsets(&pAacDecoderChannelInfo[L]->icsInfo,
234
85.6k
                                      pSamplingRateInfo),
235
85.6k
            GetWindowGroupLengthTable(&pAacDecoderChannelInfo[L]->icsInfo),
236
85.6k
            GetWindowGroups(&pAacDecoderChannelInfo[L]->icsInfo),
237
85.6k
            GetScaleFactorBandsTransmitted(
238
85.6k
                &pAacDecoderChannelInfo[L]->icsInfo));
239
85.6k
      }
240
87.7k
    }
241
151k
  } /* maybe_stereo */
242
243
964k
  for (ch = 0; ch < el_channels; ch++) {
244
563k
    if (pAacDecoderChannelInfo[ch]->renderMode == AACDEC_RENDER_LPD) {
245
      /* Decode LPD data */
246
42.8k
      CLpdChannelStream_Decode(pAacDecoderChannelInfo[ch],
247
42.8k
                               pAacDecoderStaticChannelInfo[ch], flags);
248
520k
    } else {
249
520k
      UCHAR noSfbs =
250
520k
          GetScaleFactorBandsTransmitted(&pAacDecoderChannelInfo[ch]->icsInfo);
251
      /* For USAC common window: max_sfb of both channels may differ
252
       * (common_max_sfb == 0). */
253
520k
      if ((maybe_jstereo == 1) &&
254
302k
          (pAacDecoderChannelInfo[L]->pDynData->RawDataInfo.CommonWindow ==
255
302k
           1)) {
256
270k
        noSfbs = fMax(maxSfBandsL, maxSfBandsR);
257
270k
      }
258
520k
      int CP_active = 0;
259
520k
      if (elFlags & AC_EL_USAC_CP_POSSIBLE) {
260
102k
        CP_active = pAacDecoderChannelInfo[ch]
261
102k
                        ->pComData->jointStereoData.cplx_pred_flag;
262
102k
      }
263
264
      /* Omit writing of pAacDecoderChannelInfo[ch]->specScale for complex
265
         stereo prediction since scaling has already been carried out. */
266
520k
      int max_sfb_ste = (INT)(pAacDecoderChannelInfo[L]->icsInfo.max_sfb_ste);
267
268
520k
      if (!(CP_active && (max_sfb_ste == noSfbs)) ||
269
83.4k
          !(CP_active &&
270
83.4k
            !(pAacDecoderChannelInfo[ch]->pDynData->TnsData.Active)) ||
271
17.4k
          ((flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA)) &&
272
17.4k
           (pAacDecoderChannelInfo[L]->pDynData->specificTo.usac.tns_on_lr ==
273
511k
            0))) {
274
511k
        CBlock_ScaleSpectralData(pAacDecoderChannelInfo[ch], noSfbs,
275
511k
                                 pSamplingRateInfo);
276
277
        /*Active for the case of TNS applied before MS/CP*/
278
511k
        if ((flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA)) &&
279
240k
            (pAacDecoderChannelInfo[L]->pDynData->specificTo.usac.tns_on_lr ==
280
240k
             0)) {
281
158k
          if (IsLongBlock(&pAacDecoderChannelInfo[ch]->icsInfo)) {
282
1.21M
            for (int i = 0; i < noSfbs; i++) {
283
1.06M
              pAacDecoderChannelInfo[ch]->pDynData->aSfbScale[i] =
284
1.06M
                  pAacDecoderChannelInfo[ch]->specScale[0];
285
1.06M
            }
286
148k
          } else {
287
93.2k
            for (int i = 0; i < 8; i++) {
288
592k
              for (int j = 0; j < noSfbs; j++) {
289
509k
                pAacDecoderChannelInfo[ch]->pDynData->aSfbScale[i * 16 + j] =
290
509k
                    pAacDecoderChannelInfo[ch]->specScale[i];
291
509k
              }
292
82.8k
            }
293
10.3k
          }
294
158k
        }
295
511k
      }
296
520k
    }
297
563k
  } /* End "for (ch = 0; ch < el_channels; ch++)" */
298
299
401k
  if (maybe_jstereo) {
300
    /* apply ms */
301
151k
    if (pAacDecoderChannelInfo[L]->pDynData->RawDataInfo.CommonWindow) {
302
135k
    } /* CommonWindow */
303
15.8k
    else {
304
15.8k
      if (elFlags & AC_EL_USAC_CP_POSSIBLE) {
305
2.57k
        FDKmemclear(
306
2.57k
            pAacDecoderStaticChannelInfo[L]
307
2.57k
                ->pCpeStaticData->jointStereoPersistentData.alpha_q_re_prev,
308
2.57k
            JointStereoMaximumGroups * JointStereoMaximumBands * sizeof(SHORT));
309
2.57k
        FDKmemclear(
310
2.57k
            pAacDecoderStaticChannelInfo[L]
311
2.57k
                ->pCpeStaticData->jointStereoPersistentData.alpha_q_im_prev,
312
2.57k
            JointStereoMaximumGroups * JointStereoMaximumBands * sizeof(SHORT));
313
2.57k
      }
314
15.8k
    }
315
316
151k
  } /* if (maybe_jstereo) */
317
318
964k
  for (ch = 0; ch < el_channels; ch++) {
319
563k
    if (pAacDecoderChannelInfo[ch]->renderMode == AACDEC_RENDER_LPD) {
320
520k
    } else {
321
520k
      if (!(flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA))) {
322
        /* Use same seed for coupled channels (CPE) */
323
270k
        int pnsCh = (ch > 0) ? L : ch;
324
270k
        CPns_UpdateNoiseState(
325
270k
            &pAacDecoderChannelInfo[ch]->data.aac.PnsData,
326
270k
            pAacDecoderChannelInfo[pnsCh]->data.aac.PnsData.currentSeed,
327
270k
            pAacDecoderChannelInfo[ch]->pComData->pnsRandomSeed);
328
270k
      }
329
330
520k
      if ((!(flags & (AC_USAC))) ||
331
249k
          ((flags & (AC_USAC)) &&
332
249k
           (pAacDecoderChannelInfo[L]->pDynData->specificTo.usac.tns_active ==
333
249k
            1)) ||
334
470k
          (maybe_jstereo == 0)) {
335
470k
        ApplyTools(
336
470k
            pAacDecoderChannelInfo, pSamplingRateInfo, flags, elFlags, ch,
337
470k
            pAacDecoderChannelInfo[L]->pDynData->RawDataInfo.CommonWindow);
338
470k
      }
339
520k
    } /* End "} else" */
340
563k
  }   /* End "for (ch = 0; ch < el_channels; ch++)" */
341
342
401k
  if (maybe_jstereo) {
343
    /* apply ms */
344
151k
    if (pAacDecoderChannelInfo[L]->pDynData->RawDataInfo.CommonWindow) {
345
      /* if tns_on_lr == 0 run MS */
346
135k
      if ((flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA)) &&
347
49.6k
          (pAacDecoderChannelInfo[L]->pDynData->specificTo.usac.tns_on_lr ==
348
49.6k
           0)) {
349
18.0k
        int max_sfb_ste = (INT)(pAacDecoderChannelInfo[L]->icsInfo.max_sfb_ste);
350
351
18.0k
        CJointStereo_ApplyMS(
352
18.0k
            pAacDecoderChannelInfo, pAacDecoderStaticChannelInfo,
353
18.0k
            pAacDecoderChannelInfo[L]->pSpectralCoefficient,
354
18.0k
            pAacDecoderChannelInfo[R]->pSpectralCoefficient,
355
18.0k
            pAacDecoderChannelInfo[L]->pDynData->aSfbScale,
356
18.0k
            pAacDecoderChannelInfo[R]->pDynData->aSfbScale,
357
18.0k
            pAacDecoderChannelInfo[L]->specScale,
358
18.0k
            pAacDecoderChannelInfo[R]->specScale,
359
18.0k
            GetScaleFactorBandOffsets(&pAacDecoderChannelInfo[L]->icsInfo,
360
18.0k
                                      pSamplingRateInfo),
361
18.0k
            GetWindowGroupLengthTable(&pAacDecoderChannelInfo[L]->icsInfo),
362
18.0k
            GetWindowGroups(&pAacDecoderChannelInfo[L]->icsInfo), max_sfb_ste,
363
18.0k
            maxSfBandsL, maxSfBandsR,
364
18.0k
            pAacDecoderChannelInfo[L]
365
18.0k
                ->pComData->jointStereoData.store_dmx_re_prev,
366
18.0k
            &(pAacDecoderChannelInfo[L]
367
18.0k
                  ->pComData->jointStereoData.store_dmx_re_prev_e),
368
18.0k
            1);
369
18.0k
      }
370
371
135k
    } /* if (pAacDecoderChannelInfo[L]->pDynData->RawDataInfo.CommonWindow) */
372
373
151k
  } /* if (maybe_jstereo) */
374
375
964k
  for (ch = 0; ch < el_channels; ch++) {
376
563k
    if (elFlags & AC_EL_USAC_CP_POSSIBLE) {
377
115k
      pAacDecoderStaticChannelInfo[L]
378
115k
          ->pCpeStaticData->jointStereoPersistentData.clearSpectralCoeffs = 0;
379
115k
    }
380
563k
  }
381
382
401k
  CRvlc_ElementCheck(pAacDecoderChannelInfo, pAacDecoderStaticChannelInfo,
383
401k
                     flags, el_channels);
384
401k
}
385
386
void CChannel_CodebookTableInit(
387
251k
    CAacDecoderChannelInfo *pAacDecoderChannelInfo) {
388
251k
  int b, w, maxBands, maxWindows;
389
251k
  int maxSfb = GetScaleFactorBandsTransmitted(&pAacDecoderChannelInfo->icsInfo);
390
251k
  UCHAR *pCodeBook = pAacDecoderChannelInfo->pDynData->aCodeBook;
391
392
251k
  if (IsLongBlock(&pAacDecoderChannelInfo->icsInfo)) {
393
190k
    maxBands = 64;
394
190k
    maxWindows = 1;
395
190k
  } else {
396
60.8k
    maxBands = 16;
397
60.8k
    maxWindows = 8;
398
60.8k
  }
399
400
927k
  for (w = 0; w < maxWindows; w++) {
401
2.31M
    for (b = 0; b < maxSfb; b++) {
402
1.64M
      pCodeBook[b] = ESCBOOK;
403
1.64M
    }
404
18.9M
    for (; b < maxBands; b++) {
405
18.3M
      pCodeBook[b] = ZERO_HCB;
406
18.3M
    }
407
676k
    pCodeBook += maxBands;
408
676k
  }
409
251k
}
410
411
/*
412
 * Arbitrary order bitstream parser
413
 */
414
AAC_DECODER_ERROR CChannelElement_Read(
415
    HANDLE_FDK_BITSTREAM hBs, CAacDecoderChannelInfo *pAacDecoderChannelInfo[],
416
    CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[],
417
    const AUDIO_OBJECT_TYPE aot, SamplingRateInfo *pSamplingRateInfo,
418
    const UINT flags, const UINT elFlags, const UINT frame_length,
419
    const UCHAR numberOfChannels, const SCHAR epConfig,
420
411k
    HANDLE_TRANSPORTDEC pTpDec) {
421
411k
  AAC_DECODER_ERROR error = AAC_DEC_OK;
422
411k
  const element_list_t *list;
423
411k
  int i, ch, decision_bit;
424
411k
  int crcReg1 = -1, crcReg2 = -1;
425
411k
  int cplxPred;
426
411k
  int ind_sw_cce_flag = 0, num_gain_element_lists = 0;
427
428
411k
  FDK_ASSERT((numberOfChannels == 1) || (numberOfChannels == 2));
429
430
  /* Get channel element sequence table */
431
411k
  list = getBitstreamElementList(aot, epConfig, numberOfChannels, 0, elFlags);
432
411k
  if (list == NULL) {
433
0
    error = AAC_DEC_UNSUPPORTED_FORMAT;
434
0
    goto bail;
435
0
  }
436
437
411k
  CTns_Reset(&pAacDecoderChannelInfo[0]->pDynData->TnsData);
438
  /* Set common window to 0 by default. If signalized in the bit stream it will
439
   * be overwritten later explicitely */
440
411k
  pAacDecoderChannelInfo[0]->pDynData->RawDataInfo.CommonWindow = 0;
441
411k
  if (flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA)) {
442
221k
    pAacDecoderChannelInfo[0]->pDynData->specificTo.usac.tns_active = 0;
443
221k
    pAacDecoderChannelInfo[0]->pDynData->specificTo.usac.tns_on_lr = 0;
444
221k
  }
445
411k
  if (numberOfChannels == 2) {
446
164k
    CTns_Reset(&pAacDecoderChannelInfo[1]->pDynData->TnsData);
447
164k
    pAacDecoderChannelInfo[1]->pDynData->RawDataInfo.CommonWindow = 0;
448
164k
  }
449
450
411k
  cplxPred = 0;
451
411k
  if (pAacDecoderStaticChannelInfo != NULL) {
452
409k
    if (elFlags & AC_EL_USAC_CP_POSSIBLE) {
453
58.2k
      pAacDecoderChannelInfo[0]->pComData->jointStereoData.cplx_pred_flag = 0;
454
58.2k
      cplxPred = 1;
455
58.2k
    }
456
409k
  }
457
458
411k
  if (0 || (flags & (AC_ELD | AC_SCALABLE))) {
459
164k
    pAacDecoderChannelInfo[0]->pDynData->RawDataInfo.CommonWindow = 1;
460
164k
    if (numberOfChannels == 2) {
461
86.4k
      pAacDecoderChannelInfo[1]->pDynData->RawDataInfo.CommonWindow =
462
86.4k
          pAacDecoderChannelInfo[0]->pDynData->RawDataInfo.CommonWindow;
463
86.4k
    }
464
164k
  }
465
466
  /* Iterate through sequence table */
467
411k
  i = 0;
468
411k
  ch = 0;
469
411k
  decision_bit = 0;
470
6.34M
  do {
471
6.34M
    switch (list->id[i]) {
472
25.5k
      case element_instance_tag:
473
25.5k
        pAacDecoderChannelInfo[0]->ElementInstanceTag = FDKreadBits(hBs, 4);
474
25.5k
        if (numberOfChannels == 2) {
475
3.63k
          pAacDecoderChannelInfo[1]->ElementInstanceTag =
476
3.63k
              pAacDecoderChannelInfo[0]->ElementInstanceTag;
477
3.63k
        }
478
25.5k
        break;
479
67.6k
      case common_window:
480
67.6k
        decision_bit =
481
67.6k
            pAacDecoderChannelInfo[ch]->pDynData->RawDataInfo.CommonWindow =
482
67.6k
                FDKreadBits(hBs, 1);
483
67.6k
        if (numberOfChannels == 2) {
484
67.6k
          pAacDecoderChannelInfo[1]->pDynData->RawDataInfo.CommonWindow =
485
67.6k
              pAacDecoderChannelInfo[0]->pDynData->RawDataInfo.CommonWindow;
486
67.6k
        }
487
67.6k
        break;
488
394k
      case ics_info:
489
        /* store last window sequence (utilized in complex stereo prediction)
490
         * before reading new channel-info */
491
394k
        if (cplxPred) {
492
57.6k
          if (pAacDecoderChannelInfo[0]->pDynData->RawDataInfo.CommonWindow) {
493
44.9k
            pAacDecoderStaticChannelInfo[0]
494
44.9k
                ->pCpeStaticData->jointStereoPersistentData.winSeqPrev =
495
44.9k
                pAacDecoderChannelInfo[0]->icsInfo.WindowSequence;
496
44.9k
            pAacDecoderStaticChannelInfo[0]
497
44.9k
                ->pCpeStaticData->jointStereoPersistentData.winShapePrev =
498
44.9k
                pAacDecoderChannelInfo[0]->icsInfo.WindowShape;
499
44.9k
          }
500
57.6k
        }
501
        /* Read individual channel info */
502
394k
        error = IcsRead(hBs, &pAacDecoderChannelInfo[ch]->icsInfo,
503
394k
                        pSamplingRateInfo, flags);
504
505
394k
        if (elFlags & AC_EL_LFE &&
506
0
            GetWindowSequence(&pAacDecoderChannelInfo[ch]->icsInfo) !=
507
0
                BLOCK_LONG) {
508
0
          error = AAC_DEC_PARSE_ERROR;
509
0
          break;
510
0
        }
511
512
394k
        if (numberOfChannels == 2 &&
513
177k
            pAacDecoderChannelInfo[0]->pDynData->RawDataInfo.CommonWindow) {
514
137k
          pAacDecoderChannelInfo[1]->icsInfo =
515
137k
              pAacDecoderChannelInfo[0]->icsInfo;
516
137k
        }
517
394k
        break;
518
519
49.8k
      case common_max_sfb:
520
49.8k
        if (FDKreadBit(hBs) == 0) {
521
22.2k
          error = IcsReadMaxSfb(hBs, &pAacDecoderChannelInfo[1]->icsInfo,
522
22.2k
                                pSamplingRateInfo);
523
22.2k
        }
524
49.8k
        break;
525
526
54.5k
      case ltp_data_present:
527
54.5k
        if (FDKreadBits(hBs, 1) != 0) {
528
62
          error = AAC_DEC_UNSUPPORTED_PREDICTION;
529
62
        }
530
54.5k
        break;
531
532
137k
      case ms:
533
534
137k
        INT max_sfb_ste;
535
137k
        INT max_sfb_ste_clear;
536
537
137k
        max_sfb_ste = GetScaleMaxFactorBandsTransmitted(
538
137k
            &pAacDecoderChannelInfo[0]->icsInfo,
539
137k
            &pAacDecoderChannelInfo[1]->icsInfo);
540
541
137k
        max_sfb_ste_clear = 64;
542
543
137k
        pAacDecoderChannelInfo[0]->icsInfo.max_sfb_ste = (UCHAR)max_sfb_ste;
544
137k
        pAacDecoderChannelInfo[1]->icsInfo.max_sfb_ste = (UCHAR)max_sfb_ste;
545
546
137k
        if (flags & (AC_USAC | AC_RSV603DA) &&
547
49.8k
            pAacDecoderChannelInfo[ch]->pDynData->RawDataInfo.CommonWindow ==
548
49.8k
                0) {
549
0
          Clean_Complex_Prediction_coefficients(
550
0
              &pAacDecoderStaticChannelInfo[0]
551
0
                   ->pCpeStaticData->jointStereoPersistentData,
552
0
              GetWindowGroups(&pAacDecoderChannelInfo[0]->icsInfo), 0, 64);
553
0
        }
554
555
137k
        if (CJointStereo_Read(
556
137k
                hBs, &pAacDecoderChannelInfo[0]->pComData->jointStereoData,
557
137k
                GetWindowGroups(&pAacDecoderChannelInfo[0]->icsInfo),
558
137k
                max_sfb_ste, max_sfb_ste_clear,
559
                /* jointStereoPersistentData and cplxPredictionData are only
560
                   available/allocated if cplxPred is active. */
561
137k
                ((cplxPred == 0) || (pAacDecoderStaticChannelInfo == NULL))
562
137k
                    ? NULL
563
137k
                    : &pAacDecoderStaticChannelInfo[0]
564
44.9k
                           ->pCpeStaticData->jointStereoPersistentData,
565
137k
                ((cplxPred == 0) || (pAacDecoderChannelInfo[0] == NULL))
566
137k
                    ? NULL
567
137k
                    : pAacDecoderChannelInfo[0]
568
44.9k
                          ->pComStaticData->cplxPredictionData,
569
137k
                cplxPred,
570
137k
                GetScaleFactorBandsTotal(&pAacDecoderChannelInfo[0]->icsInfo),
571
137k
                GetWindowSequence(&pAacDecoderChannelInfo[0]->icsInfo),
572
137k
                flags)) {
573
6
          error = AAC_DEC_PARSE_ERROR;
574
6
        }
575
576
137k
        break;
577
578
531k
      case global_gain:
579
531k
        pAacDecoderChannelInfo[ch]->pDynData->RawDataInfo.GlobalGain =
580
531k
            (UCHAR)FDKreadBits(hBs, 8);
581
531k
        break;
582
583
279k
      case section_data:
584
279k
        error = CBlock_ReadSectionData(hBs, pAacDecoderChannelInfo[ch],
585
279k
                                       pSamplingRateInfo, flags);
586
279k
        break;
587
588
251k
      case scale_factor_data_usac:
589
251k
        pAacDecoderChannelInfo[ch]->currAliasingSymmetry = 0;
590
        /* Set active sfb codebook indexes to HCB_ESC to make them "active" */
591
251k
        CChannel_CodebookTableInit(
592
251k
            pAacDecoderChannelInfo[ch]); /*  equals ReadSectionData(self,
593
                                            bs) in float soft. block.c
594
                                            line: ~599 */
595
        /* Note: The missing "break" is intentional here, since we need to call
596
         * CBlock_ReadScaleFactorData(). */
597
251k
        FDK_FALLTHROUGH;
598
599
530k
      case scale_factor_data:
600
530k
        if (flags & AC_ER_RVLC) {
601
          /* read RVLC data from bitstream (error sens. cat. 1) */
602
110k
          CRvlc_Read(pAacDecoderChannelInfo[ch], hBs);
603
420k
        } else {
604
420k
          error = CBlock_ReadScaleFactorData(pAacDecoderChannelInfo[ch], hBs,
605
420k
                                             flags);
606
420k
        }
607
530k
        break;
608
609
28.8k
      case pulse:
610
28.8k
        if (CPulseData_Read(
611
28.8k
                hBs,
612
28.8k
                &pAacDecoderChannelInfo[ch]->pDynData->specificTo.aac.PulseData,
613
28.8k
                pSamplingRateInfo->ScaleFactorBands_Long, /* pulse data is only
614
                                                             allowed to be
615
                                                             present in long
616
                                                             blocks! */
617
28.8k
                (void *)&pAacDecoderChannelInfo[ch]->icsInfo,
618
28.8k
                frame_length) != 0) {
619
61
          error = AAC_DEC_DECODE_FRAME_ERROR;
620
61
        }
621
28.8k
        break;
622
403k
      case tns_data_present:
623
403k
        CTns_ReadDataPresentFlag(
624
403k
            hBs, &pAacDecoderChannelInfo[ch]->pDynData->TnsData);
625
403k
        if (elFlags & AC_EL_LFE &&
626
0
            pAacDecoderChannelInfo[ch]->pDynData->TnsData.DataPresent) {
627
0
          error = AAC_DEC_PARSE_ERROR;
628
0
        }
629
403k
        break;
630
530k
      case tns_data:
631
        /* tns_data_present is checked inside CTns_Read(). */
632
530k
        error = CTns_Read(hBs, &pAacDecoderChannelInfo[ch]->pDynData->TnsData,
633
530k
                          &pAacDecoderChannelInfo[ch]->icsInfo, flags);
634
635
530k
        break;
636
637
240
      case gain_control_data:
638
240
        break;
639
640
28.7k
      case gain_control_data_present:
641
28.7k
        if (FDKreadBits(hBs, 1)) {
642
35
          error = AAC_DEC_UNSUPPORTED_GAIN_CONTROL_DATA;
643
35
        }
644
28.7k
        break;
645
646
201k
      case tw_data:
647
201k
        break;
648
63.9k
      case common_tw:
649
63.9k
        break;
650
63.9k
      case tns_data_present_usac:
651
63.9k
        if (pAacDecoderChannelInfo[0]->pDynData->specificTo.usac.tns_active) {
652
38.8k
          CTns_ReadDataPresentUsac(
653
38.8k
              hBs, &pAacDecoderChannelInfo[0]->pDynData->TnsData,
654
38.8k
              &pAacDecoderChannelInfo[1]->pDynData->TnsData,
655
38.8k
              &pAacDecoderChannelInfo[0]->pDynData->specificTo.usac.tns_on_lr,
656
38.8k
              &pAacDecoderChannelInfo[0]->icsInfo, flags, elFlags,
657
38.8k
              pAacDecoderChannelInfo[0]->pDynData->RawDataInfo.CommonWindow);
658
38.8k
        } else {
659
25.1k
          pAacDecoderChannelInfo[0]->pDynData->specificTo.usac.tns_on_lr =
660
25.1k
              (UCHAR)1;
661
25.1k
        }
662
63.9k
        break;
663
295k
      case core_mode:
664
295k
        decision_bit = FDKreadBits(hBs, 1);
665
295k
        pAacDecoderChannelInfo[ch]->data.usac.core_mode = decision_bit;
666
295k
        if ((ch == 1) && (pAacDecoderChannelInfo[0]->data.usac.core_mode !=
667
74.7k
                          pAacDecoderChannelInfo[1]->data.usac.core_mode)) {
668
          /* StereoCoreToolInfo(core_mode[ch] ) */
669
7.55k
          pAacDecoderChannelInfo[0]->pDynData->RawDataInfo.CommonWindow = 0;
670
7.55k
          pAacDecoderChannelInfo[1]->pDynData->RawDataInfo.CommonWindow = 0;
671
7.55k
        }
672
295k
        break;
673
63.9k
      case tns_active:
674
63.9k
        pAacDecoderChannelInfo[0]->pDynData->specificTo.usac.tns_active =
675
63.9k
            FDKreadBit(hBs);
676
63.9k
        break;
677
251k
      case noise:
678
251k
        if (elFlags & AC_EL_USAC_NOISE) {
679
10.4k
          pAacDecoderChannelInfo[ch]
680
10.4k
              ->pDynData->specificTo.usac.fd_noise_level_and_offset =
681
10.4k
              FDKreadBits(hBs, 3 + 5); /* Noise level */
682
10.4k
        }
683
251k
        break;
684
43.9k
      case lpd_channel_stream:
685
686
43.9k
      {
687
43.9k
        error = CLpdChannelStream_Read(/* = lpd_channel_stream() */
688
43.9k
                                       hBs, pAacDecoderChannelInfo[ch],
689
43.9k
                                       pAacDecoderStaticChannelInfo[ch],
690
43.9k
                                       pSamplingRateInfo, flags);
691
43.9k
      }
692
693
43.9k
        pAacDecoderChannelInfo[ch]->renderMode = AACDEC_RENDER_LPD;
694
43.9k
        break;
695
250k
      case fac_data: {
696
250k
        int fFacDatPresent = FDKreadBit(hBs);
697
698
        /* Wee need a valid fac_data[0] even if no FAC data is present (as
699
         * temporal buffer) */
700
250k
        pAacDecoderChannelInfo[ch]->data.usac.fac_data[0] =
701
250k
            pAacDecoderChannelInfo[ch]->data.usac.fac_data0;
702
703
250k
        if (fFacDatPresent) {
704
36.8k
          if (elFlags & AC_EL_LFE) {
705
0
            error = AAC_DEC_PARSE_ERROR;
706
0
            break;
707
0
          }
708
          /* FAC data present, this frame is FD, so the last mode had to be
709
           * ACELP. */
710
36.8k
          if (pAacDecoderStaticChannelInfo[ch]->last_core_mode != LPD ||
711
30.5k
              pAacDecoderStaticChannelInfo[ch]->last_lpd_mode != 0) {
712
30.5k
            pAacDecoderChannelInfo[ch]->data.usac.core_mode_last = LPD;
713
30.5k
            pAacDecoderChannelInfo[ch]->data.usac.lpd_mode_last = 0;
714
            /* We can't change the past! So look to the future and go ahead! */
715
30.5k
          }
716
36.8k
          CLpd_FAC_Read(hBs, pAacDecoderChannelInfo[ch]->data.usac.fac_data[0],
717
36.8k
                        pAacDecoderChannelInfo[ch]->data.usac.fac_data_e,
718
36.8k
                        CLpd_FAC_getLength(
719
36.8k
                            IsLongBlock(&pAacDecoderChannelInfo[ch]->icsInfo),
720
36.8k
                            pAacDecoderChannelInfo[ch]->granuleLength),
721
36.8k
                        1, 0);
722
213k
        } else {
723
213k
          if (pAacDecoderStaticChannelInfo[ch]->last_core_mode == LPD &&
724
13.0k
              pAacDecoderStaticChannelInfo[ch]->last_lpd_mode == 0) {
725
            /* ACELP to FD transitons without FAC are possible. That is why we
726
            zero it out (i.e FAC will not be considered in the subsequent
727
            calculations */
728
9.64k
            FDKmemclear(pAacDecoderChannelInfo[ch]->data.usac.fac_data0,
729
9.64k
                        LFAC * sizeof(FIXP_DBL));
730
9.64k
          }
731
213k
        }
732
250k
      } break;
733
250k
      case esc2_rvlc:
734
247k
        if (flags & AC_ER_RVLC) {
735
110k
          CRvlc_Decode(pAacDecoderChannelInfo[ch],
736
110k
                       pAacDecoderStaticChannelInfo[ch], hBs);
737
110k
        }
738
247k
        break;
739
740
251k
      case esc1_hcr:
741
251k
        if (flags & AC_ER_HCR) {
742
8.92k
          CHcr_Read(hBs, pAacDecoderChannelInfo[ch],
743
8.92k
                    numberOfChannels == 2 ? ID_CPE : ID_SCE);
744
8.92k
        }
745
251k
        break;
746
747
279k
      case spectral_data:
748
279k
        error = CBlock_ReadSpectralData(hBs, pAacDecoderChannelInfo[ch],
749
279k
                                        pSamplingRateInfo, flags);
750
279k
        if (flags & AC_ELD) {
751
196k
          pAacDecoderChannelInfo[ch]->renderMode = AACDEC_RENDER_ELDFB;
752
196k
        } else {
753
82.8k
          if (flags & AC_HDAAC) {
754
0
            pAacDecoderChannelInfo[ch]->renderMode = AACDEC_RENDER_INTIMDCT;
755
82.8k
          } else {
756
82.8k
            pAacDecoderChannelInfo[ch]->renderMode = AACDEC_RENDER_IMDCT;
757
82.8k
          }
758
82.8k
        }
759
279k
        break;
760
761
251k
      case ac_spectral_data:
762
251k
        error = CBlock_ReadAcSpectralData(
763
251k
            hBs, pAacDecoderChannelInfo[ch], pAacDecoderStaticChannelInfo[ch],
764
251k
            pSamplingRateInfo, frame_length, flags);
765
251k
        pAacDecoderChannelInfo[ch]->renderMode = AACDEC_RENDER_IMDCT;
766
251k
        break;
767
768
1.51k
      case coupled_elements: {
769
1.51k
        int num_coupled_elements, c;
770
771
1.51k
        ind_sw_cce_flag = FDKreadBit(hBs);
772
1.51k
        num_coupled_elements = FDKreadBits(hBs, 3);
773
774
7.38k
        for (c = 0; c < (num_coupled_elements + 1); c++) {
775
5.87k
          int cc_target_is_cpe;
776
777
5.87k
          num_gain_element_lists++;
778
5.87k
          cc_target_is_cpe = FDKreadBit(hBs); /* cc_target_is_cpe[c] */
779
5.87k
          FDKreadBits(hBs, 4);                /* cc_target_tag_select[c] */
780
781
5.87k
          if (cc_target_is_cpe) {
782
1.41k
            int cc_l, cc_r;
783
784
1.41k
            cc_l = FDKreadBit(hBs); /* cc_l[c] */
785
1.41k
            cc_r = FDKreadBit(hBs); /* cc_r[c] */
786
787
1.41k
            if (cc_l && cc_r) {
788
460
              num_gain_element_lists++;
789
460
            }
790
1.41k
          }
791
5.87k
        }
792
1.51k
        FDKreadBit(hBs);     /* cc_domain */
793
1.51k
        FDKreadBit(hBs);     /* gain_element_sign  */
794
1.51k
        FDKreadBits(hBs, 2); /* gain_element_scale */
795
1.51k
      } break;
796
797
1.48k
      case gain_element_lists: {
798
1.48k
        const CodeBookDescription *hcb;
799
1.48k
        UCHAR *pCodeBook;
800
1.48k
        int c;
801
802
1.48k
        hcb = &AACcodeBookDescriptionTable[BOOKSCL];
803
1.48k
        pCodeBook = pAacDecoderChannelInfo[ch]->pDynData->aCodeBook;
804
805
6.17k
        for (c = 1; c < num_gain_element_lists; c++) {
806
4.69k
          int cge;
807
4.69k
          if (ind_sw_cce_flag) {
808
805
            cge = 1;
809
3.88k
          } else {
810
3.88k
            cge = FDKreadBits(hBs, 1); /* common_gain_element_present[c] */
811
3.88k
          }
812
4.69k
          if (cge) {
813
            /* Huffman */
814
1.54k
            CBlock_DecodeHuffmanWord(
815
1.54k
                hBs, hcb); /* hcod_sf[common_gain_element[c]] 1..19 */
816
3.14k
          } else {
817
3.14k
            int g, sfb;
818
3.14k
            for (g = 0;
819
7.32k
                 g < GetWindowGroups(&pAacDecoderChannelInfo[ch]->icsInfo);
820
4.17k
                 g++) {
821
10.8k
              for (sfb = 0; sfb < GetScaleFactorBandsTransmitted(
822
10.8k
                                      &pAacDecoderChannelInfo[ch]->icsInfo);
823
6.69k
                   sfb++) {
824
6.69k
                if (pCodeBook[sfb] != ZERO_HCB) {
825
                  /* Huffman */
826
5.62k
                  CBlock_DecodeHuffmanWord(
827
5.62k
                      hBs,
828
5.62k
                      hcb); /* hcod_sf[dpcm_gain_element[c][g][sfb]] 1..19 */
829
5.62k
                }
830
6.69k
              }
831
4.17k
            }
832
3.14k
          }
833
4.69k
        }
834
1.48k
      } break;
835
836
        /* CRC handling */
837
24.7k
      case adtscrc_start_reg1:
838
24.7k
        if (pTpDec != NULL) {
839
24.7k
          crcReg1 = transportDec_CrcStartReg(pTpDec, 192);
840
24.7k
        }
841
24.7k
        break;
842
3.05k
      case adtscrc_start_reg2:
843
3.05k
        if (pTpDec != NULL) {
844
3.05k
          crcReg2 = transportDec_CrcStartReg(pTpDec, 128);
845
3.05k
        }
846
3.05k
        break;
847
24.1k
      case adtscrc_end_reg1:
848
24.1k
      case drmcrc_end_reg:
849
24.1k
        if (pTpDec != NULL) {
850
24.1k
          transportDec_CrcEndReg(pTpDec, crcReg1);
851
24.1k
          crcReg1 = -1;
852
24.1k
        }
853
24.1k
        break;
854
3.03k
      case adtscrc_end_reg2:
855
3.03k
        if (crcReg1 != -1) {
856
0
          error = AAC_DEC_DECODE_FRAME_ERROR;
857
3.03k
        } else if (pTpDec != NULL) {
858
3.03k
          transportDec_CrcEndReg(pTpDec, crcReg2);
859
3.03k
          crcReg2 = -1;
860
3.03k
        }
861
3.03k
        break;
862
0
      case drmcrc_start_reg:
863
0
        if (pTpDec != NULL) {
864
0
          crcReg1 = transportDec_CrcStartReg(pTpDec, 0);
865
0
        }
866
0
        break;
867
868
        /* Non data cases */
869
537k
      case next_channel:
870
537k
        ch = (ch + 1) % numberOfChannels;
871
537k
        break;
872
427k
      case link_sequence:
873
427k
        list = list->next[decision_bit];
874
427k
        i = -1;
875
427k
        break;
876
877
0
      default:
878
0
        error = AAC_DEC_UNSUPPORTED_FORMAT;
879
0
        break;
880
6.34M
    }
881
882
6.34M
    if (error != AAC_DEC_OK) {
883
2.86k
      goto bail;
884
2.86k
    }
885
886
6.34M
    i++;
887
888
6.34M
  } while (list->id[i] != end_of_sequence);
889
890
980k
  for (ch = 0; ch < numberOfChannels; ch++) {
891
572k
    if (pAacDecoderChannelInfo[ch]->renderMode == AACDEC_RENDER_IMDCT ||
892
528k
        pAacDecoderChannelInfo[ch]->renderMode == AACDEC_RENDER_ELDFB) {
893
      /* Shows which bands are empty. */
894
528k
      UCHAR *band_is_noise =
895
528k
          pAacDecoderChannelInfo[ch]->pDynData->band_is_noise;
896
528k
      FDKmemset(band_is_noise, (UCHAR)1, sizeof(UCHAR) * (8 * 16));
897
898
528k
      error = CBlock_InverseQuantizeSpectralData(
899
528k
          pAacDecoderChannelInfo[ch], pSamplingRateInfo, band_is_noise, 1);
900
528k
      if (error != AAC_DEC_OK) {
901
24
        return error;
902
24
      }
903
904
528k
      if (elFlags & AC_EL_USAC_NOISE) {
905
10.2k
        CBlock_ApplyNoise(pAacDecoderChannelInfo[ch], pSamplingRateInfo,
906
10.2k
                          &pAacDecoderStaticChannelInfo[ch]->nfRandomSeed,
907
10.2k
                          band_is_noise);
908
909
10.2k
      } /* if (elFlags & AC_EL_USAC_NOISE) */
910
528k
    }
911
572k
  }
912
913
411k
bail:
914
411k
  if (crcReg1 != -1 || crcReg2 != -1) {
915
0
    if (error == AAC_DEC_OK) {
916
0
      error = AAC_DEC_DECODE_FRAME_ERROR;
917
0
    }
918
0
    if (crcReg1 != -1) {
919
0
      transportDec_CrcEndReg(pTpDec, crcReg1);
920
0
    }
921
0
    if (crcReg2 != -1) {
922
0
      transportDec_CrcEndReg(pTpDec, crcReg2);
923
0
    }
924
0
  }
925
411k
  return error;
926
408k
}