Coverage Report

Created: 2026-09-07 07:09

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
9.59k
    CAacDecoderChannelInfo *pAacDecoderChannelInfo[2]) {
120
9.59k
  int group;
121
122
44.2k
  for (group = 0; group < pAacDecoderChannelInfo[L]->icsInfo.WindowGroups;
123
34.6k
       group++) {
124
34.6k
    UCHAR groupMask = 1 << group;
125
126
165k
    for (UCHAR band = 0; band < pAacDecoderChannelInfo[L]->icsInfo.MaxSfBands;
127
130k
         band++) {
128
130k
      if (pAacDecoderChannelInfo[L]->pComData->jointStereoData.MsUsed[band] &
129
130k
          groupMask) { /* channels are correlated */
130
9.41k
        CPns_SetCorrelation(&pAacDecoderChannelInfo[L]->data.aac.PnsData, group,
131
9.41k
                            band, 0);
132
133
9.41k
        if (CPns_IsPnsUsed(&pAacDecoderChannelInfo[L]->data.aac.PnsData, group,
134
9.41k
                           band) &&
135
2.02k
            CPns_IsPnsUsed(&pAacDecoderChannelInfo[R]->data.aac.PnsData, group,
136
2.02k
                           band))
137
1.09k
          pAacDecoderChannelInfo[L]->pComData->jointStereoData.MsUsed[band] ^=
138
1.09k
              groupMask; /* clear the groupMask-bit */
139
9.41k
      }
140
130k
    }
141
34.6k
  }
142
9.59k
}
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
421k
    int el_channels) {
168
421k
  int ch = 0;
169
170
421k
  int maxSfBandsL = 0, maxSfBandsR = 0;
171
421k
  int maybe_jstereo = (el_channels > 1);
172
173
421k
  if (flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA) && el_channels == 2) {
174
72.0k
    if (pAacDecoderChannelInfo[L]->data.usac.core_mode ||
175
64.5k
        pAacDecoderChannelInfo[R]->data.usac.core_mode) {
176
10.2k
      maybe_jstereo = 0;
177
10.2k
    }
178
72.0k
  }
179
180
421k
  if (maybe_jstereo) {
181
153k
    maxSfBandsL =
182
153k
        GetScaleFactorBandsTransmitted(&pAacDecoderChannelInfo[L]->icsInfo);
183
153k
    maxSfBandsR =
184
153k
        GetScaleFactorBandsTransmitted(&pAacDecoderChannelInfo[R]->icsInfo);
185
186
    /* apply ms */
187
153k
    if (pAacDecoderChannelInfo[L]->pDynData->RawDataInfo.CommonWindow) {
188
136k
      if (!(flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA))) {
189
89.1k
        if (pAacDecoderChannelInfo[L]->data.aac.PnsData.PnsActive ||
190
80.5k
            pAacDecoderChannelInfo[R]->data.aac.PnsData.PnsActive) {
191
9.59k
          MapMidSideMaskToPnsCorrelation(pAacDecoderChannelInfo);
192
9.59k
        }
193
89.1k
      }
194
      /* if tns_on_lr == 1 run MS */ /* &&
195
                                        (pAacDecoderChannelInfo[L]->pDynData->specificTo.usac.tns_active
196
                                        == 1) */
197
136k
      if (((flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA)) &&
198
47.2k
           (pAacDecoderChannelInfo[L]->pDynData->specificTo.usac.tns_on_lr ==
199
47.2k
            1)) ||
200
119k
          ((flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA)) == 0)) {
201
119k
        int max_sfb_ste = (INT)(pAacDecoderChannelInfo[L]->icsInfo.max_sfb_ste);
202
203
119k
        CJointStereo_ApplyMS(
204
119k
            pAacDecoderChannelInfo, pAacDecoderStaticChannelInfo,
205
119k
            pAacDecoderChannelInfo[L]->pSpectralCoefficient,
206
119k
            pAacDecoderChannelInfo[R]->pSpectralCoefficient,
207
119k
            pAacDecoderChannelInfo[L]->pDynData->aSfbScale,
208
119k
            pAacDecoderChannelInfo[R]->pDynData->aSfbScale,
209
119k
            pAacDecoderChannelInfo[L]->specScale,
210
119k
            pAacDecoderChannelInfo[R]->specScale,
211
119k
            GetScaleFactorBandOffsets(&pAacDecoderChannelInfo[L]->icsInfo,
212
119k
                                      pSamplingRateInfo),
213
119k
            GetWindowGroupLengthTable(&pAacDecoderChannelInfo[L]->icsInfo),
214
119k
            GetWindowGroups(&pAacDecoderChannelInfo[L]->icsInfo), max_sfb_ste,
215
119k
            maxSfBandsL, maxSfBandsR,
216
119k
            pAacDecoderChannelInfo[L]
217
119k
                ->pComData->jointStereoData.store_dmx_re_prev,
218
119k
            &(pAacDecoderChannelInfo[L]
219
119k
                  ->pComData->jointStereoData.store_dmx_re_prev_e),
220
119k
            1);
221
222
119k
      } /* if ( ((elFlags & AC_EL_USAC_CP_POSSIBLE).... */
223
136k
    }   /* if (pAacDecoderChannelInfo[L]->pDynData->RawDataInfo.CommonWindow)*/
224
225
    /* apply intensity stereo */ /* modifies pAacDecoderChannelInfo[]->aSpecSfb
226
                                  */
227
153k
    if (!(flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA))) {
228
91.3k
      if ((pAacDecoderChannelInfo[L]->pDynData->RawDataInfo.CommonWindow ==
229
91.3k
           1) &&
230
89.1k
          (el_channels == 2)) {
231
89.1k
        CJointStereo_ApplyIS(
232
89.1k
            pAacDecoderChannelInfo,
233
89.1k
            GetScaleFactorBandOffsets(&pAacDecoderChannelInfo[L]->icsInfo,
234
89.1k
                                      pSamplingRateInfo),
235
89.1k
            GetWindowGroupLengthTable(&pAacDecoderChannelInfo[L]->icsInfo),
236
89.1k
            GetWindowGroups(&pAacDecoderChannelInfo[L]->icsInfo),
237
89.1k
            GetScaleFactorBandsTransmitted(
238
89.1k
                &pAacDecoderChannelInfo[L]->icsInfo));
239
89.1k
      }
240
91.3k
    }
241
153k
  } /* maybe_stereo */
242
243
1.00M
  for (ch = 0; ch < el_channels; ch++) {
244
585k
    if (pAacDecoderChannelInfo[ch]->renderMode == AACDEC_RENDER_LPD) {
245
      /* Decode LPD data */
246
45.7k
      CLpdChannelStream_Decode(pAacDecoderChannelInfo[ch],
247
45.7k
                               pAacDecoderStaticChannelInfo[ch], flags);
248
539k
    } else {
249
539k
      UCHAR noSfbs =
250
539k
          GetScaleFactorBandsTransmitted(&pAacDecoderChannelInfo[ch]->icsInfo);
251
      /* For USAC common window: max_sfb of both channels may differ
252
       * (common_max_sfb == 0). */
253
539k
      if ((maybe_jstereo == 1) &&
254
306k
          (pAacDecoderChannelInfo[L]->pDynData->RawDataInfo.CommonWindow ==
255
306k
           1)) {
256
272k
        noSfbs = fMax(maxSfBandsL, maxSfBandsR);
257
272k
      }
258
539k
      int CP_active = 0;
259
539k
      if (elFlags & AC_EL_USAC_CP_POSSIBLE) {
260
94.6k
        CP_active = pAacDecoderChannelInfo[ch]
261
94.6k
                        ->pComData->jointStereoData.cplx_pred_flag;
262
94.6k
      }
263
264
      /* Omit writing of pAacDecoderChannelInfo[ch]->specScale for complex
265
         stereo prediction since scaling has already been carried out. */
266
539k
      int max_sfb_ste = (INT)(pAacDecoderChannelInfo[L]->icsInfo.max_sfb_ste);
267
268
539k
      if (!(CP_active && (max_sfb_ste == noSfbs)) ||
269
76.5k
          !(CP_active &&
270
76.5k
            !(pAacDecoderChannelInfo[ch]->pDynData->TnsData.Active)) ||
271
18.0k
          ((flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA)) &&
272
18.0k
           (pAacDecoderChannelInfo[L]->pDynData->specificTo.usac.tns_on_lr ==
273
529k
            0))) {
274
529k
        CBlock_ScaleSpectralData(pAacDecoderChannelInfo[ch], noSfbs,
275
529k
                                 pSamplingRateInfo);
276
277
        /*Active for the case of TNS applied before MS/CP*/
278
529k
        if ((flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA)) &&
279
243k
            (pAacDecoderChannelInfo[L]->pDynData->specificTo.usac.tns_on_lr ==
280
243k
             0)) {
281
163k
          if (IsLongBlock(&pAacDecoderChannelInfo[ch]->icsInfo)) {
282
1.31M
            for (int i = 0; i < noSfbs; i++) {
283
1.16M
              pAacDecoderChannelInfo[ch]->pDynData->aSfbScale[i] =
284
1.16M
                  pAacDecoderChannelInfo[ch]->specScale[0];
285
1.16M
            }
286
154k
          } else {
287
82.5k
            for (int i = 0; i < 8; i++) {
288
530k
              for (int j = 0; j < noSfbs; j++) {
289
456k
                pAacDecoderChannelInfo[ch]->pDynData->aSfbScale[i * 16 + j] =
290
456k
                    pAacDecoderChannelInfo[ch]->specScale[i];
291
456k
              }
292
73.4k
            }
293
9.17k
          }
294
163k
        }
295
529k
      }
296
539k
    }
297
585k
  } /* End "for (ch = 0; ch < el_channels; ch++)" */
298
299
421k
  if (maybe_jstereo) {
300
    /* apply ms */
301
153k
    if (pAacDecoderChannelInfo[L]->pDynData->RawDataInfo.CommonWindow) {
302
136k
    } /* CommonWindow */
303
16.7k
    else {
304
16.7k
      if (elFlags & AC_EL_USAC_CP_POSSIBLE) {
305
2.39k
        FDKmemclear(
306
2.39k
            pAacDecoderStaticChannelInfo[L]
307
2.39k
                ->pCpeStaticData->jointStereoPersistentData.alpha_q_re_prev,
308
2.39k
            JointStereoMaximumGroups * JointStereoMaximumBands * sizeof(SHORT));
309
2.39k
        FDKmemclear(
310
2.39k
            pAacDecoderStaticChannelInfo[L]
311
2.39k
                ->pCpeStaticData->jointStereoPersistentData.alpha_q_im_prev,
312
2.39k
            JointStereoMaximumGroups * JointStereoMaximumBands * sizeof(SHORT));
313
2.39k
      }
314
16.7k
    }
315
316
153k
  } /* if (maybe_jstereo) */
317
318
1.00M
  for (ch = 0; ch < el_channels; ch++) {
319
585k
    if (pAacDecoderChannelInfo[ch]->renderMode == AACDEC_RENDER_LPD) {
320
539k
    } else {
321
539k
      if (!(flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA))) {
322
        /* Use same seed for coupled channels (CPE) */
323
285k
        int pnsCh = (ch > 0) ? L : ch;
324
285k
        CPns_UpdateNoiseState(
325
285k
            &pAacDecoderChannelInfo[ch]->data.aac.PnsData,
326
285k
            pAacDecoderChannelInfo[pnsCh]->data.aac.PnsData.currentSeed,
327
285k
            pAacDecoderChannelInfo[ch]->pComData->pnsRandomSeed);
328
285k
      }
329
330
539k
      if ((!(flags & (AC_USAC))) ||
331
253k
          ((flags & (AC_USAC)) &&
332
253k
           (pAacDecoderChannelInfo[L]->pDynData->specificTo.usac.tns_active ==
333
253k
            1)) ||
334
484k
          (maybe_jstereo == 0)) {
335
484k
        ApplyTools(
336
484k
            pAacDecoderChannelInfo, pSamplingRateInfo, flags, elFlags, ch,
337
484k
            pAacDecoderChannelInfo[L]->pDynData->RawDataInfo.CommonWindow);
338
484k
      }
339
539k
    } /* End "} else" */
340
585k
  }   /* End "for (ch = 0; ch < el_channels; ch++)" */
341
342
421k
  if (maybe_jstereo) {
343
    /* apply ms */
344
153k
    if (pAacDecoderChannelInfo[L]->pDynData->RawDataInfo.CommonWindow) {
345
      /* if tns_on_lr == 0 run MS */
346
136k
      if ((flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA)) &&
347
47.2k
          (pAacDecoderChannelInfo[L]->pDynData->specificTo.usac.tns_on_lr ==
348
47.2k
           0)) {
349
16.4k
        int max_sfb_ste = (INT)(pAacDecoderChannelInfo[L]->icsInfo.max_sfb_ste);
350
351
16.4k
        CJointStereo_ApplyMS(
352
16.4k
            pAacDecoderChannelInfo, pAacDecoderStaticChannelInfo,
353
16.4k
            pAacDecoderChannelInfo[L]->pSpectralCoefficient,
354
16.4k
            pAacDecoderChannelInfo[R]->pSpectralCoefficient,
355
16.4k
            pAacDecoderChannelInfo[L]->pDynData->aSfbScale,
356
16.4k
            pAacDecoderChannelInfo[R]->pDynData->aSfbScale,
357
16.4k
            pAacDecoderChannelInfo[L]->specScale,
358
16.4k
            pAacDecoderChannelInfo[R]->specScale,
359
16.4k
            GetScaleFactorBandOffsets(&pAacDecoderChannelInfo[L]->icsInfo,
360
16.4k
                                      pSamplingRateInfo),
361
16.4k
            GetWindowGroupLengthTable(&pAacDecoderChannelInfo[L]->icsInfo),
362
16.4k
            GetWindowGroups(&pAacDecoderChannelInfo[L]->icsInfo), max_sfb_ste,
363
16.4k
            maxSfBandsL, maxSfBandsR,
364
16.4k
            pAacDecoderChannelInfo[L]
365
16.4k
                ->pComData->jointStereoData.store_dmx_re_prev,
366
16.4k
            &(pAacDecoderChannelInfo[L]
367
16.4k
                  ->pComData->jointStereoData.store_dmx_re_prev_e),
368
16.4k
            1);
369
16.4k
      }
370
371
136k
    } /* if (pAacDecoderChannelInfo[L]->pDynData->RawDataInfo.CommonWindow) */
372
373
153k
  } /* if (maybe_jstereo) */
374
375
1.00M
  for (ch = 0; ch < el_channels; ch++) {
376
585k
    if (elFlags & AC_EL_USAC_CP_POSSIBLE) {
377
108k
      pAacDecoderStaticChannelInfo[L]
378
108k
          ->pCpeStaticData->jointStereoPersistentData.clearSpectralCoeffs = 0;
379
108k
    }
380
585k
  }
381
382
421k
  CRvlc_ElementCheck(pAacDecoderChannelInfo, pAacDecoderStaticChannelInfo,
383
421k
                     flags, el_channels);
384
421k
}
385
386
void CChannel_CodebookTableInit(
387
255k
    CAacDecoderChannelInfo *pAacDecoderChannelInfo) {
388
255k
  int b, w, maxBands, maxWindows;
389
255k
  int maxSfb = GetScaleFactorBandsTransmitted(&pAacDecoderChannelInfo->icsInfo);
390
255k
  UCHAR *pCodeBook = pAacDecoderChannelInfo->pDynData->aCodeBook;
391
392
255k
  if (IsLongBlock(&pAacDecoderChannelInfo->icsInfo)) {
393
200k
    maxBands = 64;
394
200k
    maxWindows = 1;
395
200k
  } else {
396
55.6k
    maxBands = 16;
397
55.6k
    maxWindows = 8;
398
55.6k
  }
399
400
901k
  for (w = 0; w < maxWindows; w++) {
401
2.36M
    for (b = 0; b < maxSfb; b++) {
402
1.72M
      pCodeBook[b] = ESCBOOK;
403
1.72M
    }
404
18.8M
    for (; b < maxBands; b++) {
405
18.2M
      pCodeBook[b] = ZERO_HCB;
406
18.2M
    }
407
645k
    pCodeBook += maxBands;
408
645k
  }
409
255k
}
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
432k
    HANDLE_TRANSPORTDEC pTpDec) {
421
432k
  AAC_DECODER_ERROR error = AAC_DEC_OK;
422
432k
  const element_list_t *list;
423
432k
  int i, ch, decision_bit;
424
432k
  int crcReg1 = -1, crcReg2 = -1;
425
432k
  int cplxPred;
426
432k
  int ind_sw_cce_flag = 0, num_gain_element_lists = 0;
427
428
432k
  FDK_ASSERT((numberOfChannels == 1) || (numberOfChannels == 2));
429
430
  /* Get channel element sequence table */
431
432k
  list = getBitstreamElementList(aot, epConfig, numberOfChannels, 0, elFlags);
432
432k
  if (list == NULL) {
433
0
    error = AAC_DEC_UNSUPPORTED_FORMAT;
434
0
    goto bail;
435
0
  }
436
437
432k
  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
432k
  pAacDecoderChannelInfo[0]->pDynData->RawDataInfo.CommonWindow = 0;
441
432k
  if (flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA)) {
442
230k
    pAacDecoderChannelInfo[0]->pDynData->specificTo.usac.tns_active = 0;
443
230k
    pAacDecoderChannelInfo[0]->pDynData->specificTo.usac.tns_on_lr = 0;
444
230k
  }
445
432k
  if (numberOfChannels == 2) {
446
166k
    CTns_Reset(&pAacDecoderChannelInfo[1]->pDynData->TnsData);
447
166k
    pAacDecoderChannelInfo[1]->pDynData->RawDataInfo.CommonWindow = 0;
448
166k
  }
449
450
432k
  cplxPred = 0;
451
432k
  if (pAacDecoderStaticChannelInfo != NULL) {
452
430k
    if (elFlags & AC_EL_USAC_CP_POSSIBLE) {
453
54.9k
      pAacDecoderChannelInfo[0]->pComData->jointStereoData.cplx_pred_flag = 0;
454
54.9k
      cplxPred = 1;
455
54.9k
    }
456
430k
  }
457
458
432k
  if (0 || (flags & (AC_ELD | AC_SCALABLE))) {
459
174k
    pAacDecoderChannelInfo[0]->pDynData->RawDataInfo.CommonWindow = 1;
460
174k
    if (numberOfChannels == 2) {
461
90.0k
      pAacDecoderChannelInfo[1]->pDynData->RawDataInfo.CommonWindow =
462
90.0k
          pAacDecoderChannelInfo[0]->pDynData->RawDataInfo.CommonWindow;
463
90.0k
    }
464
174k
  }
465
466
  /* Iterate through sequence table */
467
432k
  i = 0;
468
432k
  ch = 0;
469
432k
  decision_bit = 0;
470
6.57M
  do {
471
6.57M
    switch (list->id[i]) {
472
27.0k
      case element_instance_tag:
473
27.0k
        pAacDecoderChannelInfo[0]->ElementInstanceTag = FDKreadBits(hBs, 4);
474
27.0k
        if (numberOfChannels == 2) {
475
3.82k
          pAacDecoderChannelInfo[1]->ElementInstanceTag =
476
3.82k
              pAacDecoderChannelInfo[0]->ElementInstanceTag;
477
3.82k
        }
478
27.0k
        break;
479
66.1k
      case common_window:
480
66.1k
        decision_bit =
481
66.1k
            pAacDecoderChannelInfo[ch]->pDynData->RawDataInfo.CommonWindow =
482
66.1k
                FDKreadBits(hBs, 1);
483
66.1k
        if (numberOfChannels == 2) {
484
66.1k
          pAacDecoderChannelInfo[1]->pDynData->RawDataInfo.CommonWindow =
485
66.1k
              pAacDecoderChannelInfo[0]->pDynData->RawDataInfo.CommonWindow;
486
66.1k
        }
487
66.1k
        break;
488
412k
      case ics_info:
489
        /* store last window sequence (utilized in complex stereo prediction)
490
         * before reading new channel-info */
491
412k
        if (cplxPred) {
492
53.2k
          if (pAacDecoderChannelInfo[0]->pDynData->RawDataInfo.CommonWindow) {
493
41.9k
            pAacDecoderStaticChannelInfo[0]
494
41.9k
                ->pCpeStaticData->jointStereoPersistentData.winSeqPrev =
495
41.9k
                pAacDecoderChannelInfo[0]->icsInfo.WindowSequence;
496
41.9k
            pAacDecoderStaticChannelInfo[0]
497
41.9k
                ->pCpeStaticData->jointStereoPersistentData.winShapePrev =
498
41.9k
                pAacDecoderChannelInfo[0]->icsInfo.WindowShape;
499
41.9k
          }
500
53.2k
        }
501
        /* Read individual channel info */
502
412k
        error = IcsRead(hBs, &pAacDecoderChannelInfo[ch]->icsInfo,
503
412k
                        pSamplingRateInfo, flags);
504
505
412k
        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
412k
        if (numberOfChannels == 2 &&
513
179k
            pAacDecoderChannelInfo[0]->pDynData->RawDataInfo.CommonWindow) {
514
138k
          pAacDecoderChannelInfo[1]->icsInfo =
515
138k
              pAacDecoderChannelInfo[0]->icsInfo;
516
138k
        }
517
412k
        break;
518
519
47.4k
      case common_max_sfb:
520
47.4k
        if (FDKreadBit(hBs) == 0) {
521
21.8k
          error = IcsReadMaxSfb(hBs, &pAacDecoderChannelInfo[1]->icsInfo,
522
21.8k
                                pSamplingRateInfo);
523
21.8k
        }
524
47.4k
        break;
525
526
61.1k
      case ltp_data_present:
527
61.1k
        if (FDKreadBits(hBs, 1) != 0) {
528
64
          error = AAC_DEC_UNSUPPORTED_PREDICTION;
529
64
        }
530
61.1k
        break;
531
532
138k
      case ms:
533
534
138k
        INT max_sfb_ste;
535
138k
        INT max_sfb_ste_clear;
536
537
138k
        max_sfb_ste = GetScaleMaxFactorBandsTransmitted(
538
138k
            &pAacDecoderChannelInfo[0]->icsInfo,
539
138k
            &pAacDecoderChannelInfo[1]->icsInfo);
540
541
138k
        max_sfb_ste_clear = 64;
542
543
138k
        pAacDecoderChannelInfo[0]->icsInfo.max_sfb_ste = (UCHAR)max_sfb_ste;
544
138k
        pAacDecoderChannelInfo[1]->icsInfo.max_sfb_ste = (UCHAR)max_sfb_ste;
545
546
138k
        if (flags & (AC_USAC | AC_RSV603DA) &&
547
47.4k
            pAacDecoderChannelInfo[ch]->pDynData->RawDataInfo.CommonWindow ==
548
47.4k
                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
138k
        if (CJointStereo_Read(
556
138k
                hBs, &pAacDecoderChannelInfo[0]->pComData->jointStereoData,
557
138k
                GetWindowGroups(&pAacDecoderChannelInfo[0]->icsInfo),
558
138k
                max_sfb_ste, max_sfb_ste_clear,
559
                /* jointStereoPersistentData and cplxPredictionData are only
560
                   available/allocated if cplxPred is active. */
561
138k
                ((cplxPred == 0) || (pAacDecoderStaticChannelInfo == NULL))
562
138k
                    ? NULL
563
138k
                    : &pAacDecoderStaticChannelInfo[0]
564
41.9k
                           ->pCpeStaticData->jointStereoPersistentData,
565
138k
                ((cplxPred == 0) || (pAacDecoderChannelInfo[0] == NULL))
566
138k
                    ? NULL
567
138k
                    : pAacDecoderChannelInfo[0]
568
41.9k
                          ->pComStaticData->cplxPredictionData,
569
138k
                cplxPred,
570
138k
                GetScaleFactorBandsTotal(&pAacDecoderChannelInfo[0]->icsInfo),
571
138k
                GetWindowSequence(&pAacDecoderChannelInfo[0]->icsInfo),
572
138k
                flags)) {
573
3
          error = AAC_DEC_PARSE_ERROR;
574
3
        }
575
576
138k
        break;
577
578
551k
      case global_gain:
579
551k
        pAacDecoderChannelInfo[ch]->pDynData->RawDataInfo.GlobalGain =
580
551k
            (UCHAR)FDKreadBits(hBs, 8);
581
551k
        break;
582
583
294k
      case section_data:
584
294k
        error = CBlock_ReadSectionData(hBs, pAacDecoderChannelInfo[ch],
585
294k
                                       pSamplingRateInfo, flags);
586
294k
        break;
587
588
255k
      case scale_factor_data_usac:
589
255k
        pAacDecoderChannelInfo[ch]->currAliasingSymmetry = 0;
590
        /* Set active sfb codebook indexes to HCB_ESC to make them "active" */
591
255k
        CChannel_CodebookTableInit(
592
255k
            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
255k
        FDK_FALLTHROUGH;
598
599
550k
      case scale_factor_data:
600
550k
        if (flags & AC_ER_RVLC) {
601
          /* read RVLC data from bitstream (error sens. cat. 1) */
602
105k
          CRvlc_Read(pAacDecoderChannelInfo[ch], hBs);
603
445k
        } else {
604
445k
          error = CBlock_ReadScaleFactorData(pAacDecoderChannelInfo[ch], hBs,
605
445k
                                             flags);
606
445k
        }
607
550k
        break;
608
609
30.5k
      case pulse:
610
30.5k
        if (CPulseData_Read(
611
30.5k
                hBs,
612
30.5k
                &pAacDecoderChannelInfo[ch]->pDynData->specificTo.aac.PulseData,
613
30.5k
                pSamplingRateInfo->ScaleFactorBands_Long, /* pulse data is only
614
                                                             allowed to be
615
                                                             present in long
616
                                                             blocks! */
617
30.5k
                (void *)&pAacDecoderChannelInfo[ch]->icsInfo,
618
30.5k
                frame_length) != 0) {
619
64
          error = AAC_DEC_DECODE_FRAME_ERROR;
620
64
        }
621
30.5k
        break;
622
426k
      case tns_data_present:
623
426k
        CTns_ReadDataPresentFlag(
624
426k
            hBs, &pAacDecoderChannelInfo[ch]->pDynData->TnsData);
625
426k
        if (elFlags & AC_EL_LFE &&
626
0
            pAacDecoderChannelInfo[ch]->pDynData->TnsData.DataPresent) {
627
0
          error = AAC_DEC_PARSE_ERROR;
628
0
        }
629
426k
        break;
630
550k
      case tns_data:
631
        /* tns_data_present is checked inside CTns_Read(). */
632
550k
        error = CTns_Read(hBs, &pAacDecoderChannelInfo[ch]->pDynData->TnsData,
633
550k
                          &pAacDecoderChannelInfo[ch]->icsInfo, flags);
634
635
550k
        break;
636
637
255
      case gain_control_data:
638
255
        break;
639
640
30.5k
      case gain_control_data_present:
641
30.5k
        if (FDKreadBits(hBs, 1)) {
642
27
          error = AAC_DEC_UNSUPPORTED_GAIN_CONTROL_DATA;
643
27
        }
644
30.5k
        break;
645
646
208k
      case tw_data:
647
208k
        break;
648
62.3k
      case common_tw:
649
62.3k
        break;
650
62.3k
      case tns_data_present_usac:
651
62.3k
        if (pAacDecoderChannelInfo[0]->pDynData->specificTo.usac.tns_active) {
652
34.2k
          CTns_ReadDataPresentUsac(
653
34.2k
              hBs, &pAacDecoderChannelInfo[0]->pDynData->TnsData,
654
34.2k
              &pAacDecoderChannelInfo[1]->pDynData->TnsData,
655
34.2k
              &pAacDecoderChannelInfo[0]->pDynData->specificTo.usac.tns_on_lr,
656
34.2k
              &pAacDecoderChannelInfo[0]->icsInfo, flags, elFlags,
657
34.2k
              pAacDecoderChannelInfo[0]->pDynData->RawDataInfo.CommonWindow);
658
34.2k
        } else {
659
28.0k
          pAacDecoderChannelInfo[0]->pDynData->specificTo.usac.tns_on_lr =
660
28.0k
              (UCHAR)1;
661
28.0k
        }
662
62.3k
        break;
663
303k
      case core_mode:
664
303k
        decision_bit = FDKreadBits(hBs, 1);
665
303k
        pAacDecoderChannelInfo[ch]->data.usac.core_mode = decision_bit;
666
303k
        if ((ch == 1) && (pAacDecoderChannelInfo[0]->data.usac.core_mode !=
667
72.9k
                          pAacDecoderChannelInfo[1]->data.usac.core_mode)) {
668
          /* StereoCoreToolInfo(core_mode[ch] ) */
669
6.48k
          pAacDecoderChannelInfo[0]->pDynData->RawDataInfo.CommonWindow = 0;
670
6.48k
          pAacDecoderChannelInfo[1]->pDynData->RawDataInfo.CommonWindow = 0;
671
6.48k
        }
672
303k
        break;
673
62.3k
      case tns_active:
674
62.3k
        pAacDecoderChannelInfo[0]->pDynData->specificTo.usac.tns_active =
675
62.3k
            FDKreadBit(hBs);
676
62.3k
        break;
677
256k
      case noise:
678
256k
        if (elFlags & AC_EL_USAC_NOISE) {
679
11.8k
          pAacDecoderChannelInfo[ch]
680
11.8k
              ->pDynData->specificTo.usac.fd_noise_level_and_offset =
681
11.8k
              FDKreadBits(hBs, 3 + 5); /* Noise level */
682
11.8k
        }
683
256k
        break;
684
46.8k
      case lpd_channel_stream:
685
686
46.8k
      {
687
46.8k
        error = CLpdChannelStream_Read(/* = lpd_channel_stream() */
688
46.8k
                                       hBs, pAacDecoderChannelInfo[ch],
689
46.8k
                                       pAacDecoderStaticChannelInfo[ch],
690
46.8k
                                       pSamplingRateInfo, flags);
691
46.8k
      }
692
693
46.8k
        pAacDecoderChannelInfo[ch]->renderMode = AACDEC_RENDER_LPD;
694
46.8k
        break;
695
254k
      case fac_data: {
696
254k
        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
254k
        pAacDecoderChannelInfo[ch]->data.usac.fac_data[0] =
701
254k
            pAacDecoderChannelInfo[ch]->data.usac.fac_data0;
702
703
254k
        if (fFacDatPresent) {
704
34.4k
          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
34.4k
          if (pAacDecoderStaticChannelInfo[ch]->last_core_mode != LPD ||
711
27.7k
              pAacDecoderStaticChannelInfo[ch]->last_lpd_mode != 0) {
712
27.7k
            pAacDecoderChannelInfo[ch]->data.usac.core_mode_last = LPD;
713
27.7k
            pAacDecoderChannelInfo[ch]->data.usac.lpd_mode_last = 0;
714
            /* We can't change the past! So look to the future and go ahead! */
715
27.7k
          }
716
34.4k
          CLpd_FAC_Read(hBs, pAacDecoderChannelInfo[ch]->data.usac.fac_data[0],
717
34.4k
                        pAacDecoderChannelInfo[ch]->data.usac.fac_data_e,
718
34.4k
                        CLpd_FAC_getLength(
719
34.4k
                            IsLongBlock(&pAacDecoderChannelInfo[ch]->icsInfo),
720
34.4k
                            pAacDecoderChannelInfo[ch]->granuleLength),
721
34.4k
                        1, 0);
722
220k
        } else {
723
220k
          if (pAacDecoderStaticChannelInfo[ch]->last_core_mode == LPD &&
724
13.7k
              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.53k
            FDKmemclear(pAacDecoderChannelInfo[ch]->data.usac.fac_data0,
729
9.53k
                        LFAC * sizeof(FIXP_DBL));
730
9.53k
          }
731
220k
        }
732
254k
      } break;
733
260k
      case esc2_rvlc:
734
260k
        if (flags & AC_ER_RVLC) {
735
104k
          CRvlc_Decode(pAacDecoderChannelInfo[ch],
736
104k
                       pAacDecoderStaticChannelInfo[ch], hBs);
737
104k
        }
738
260k
        break;
739
740
265k
      case esc1_hcr:
741
265k
        if (flags & AC_ER_HCR) {
742
9.56k
          CHcr_Read(hBs, pAacDecoderChannelInfo[ch],
743
9.56k
                    numberOfChannels == 2 ? ID_CPE : ID_SCE);
744
9.56k
        }
745
265k
        break;
746
747
294k
      case spectral_data:
748
294k
        error = CBlock_ReadSpectralData(hBs, pAacDecoderChannelInfo[ch],
749
294k
                                        pSamplingRateInfo, flags);
750
294k
        if (flags & AC_ELD) {
751
203k
          pAacDecoderChannelInfo[ch]->renderMode = AACDEC_RENDER_ELDFB;
752
203k
        } else {
753
91.2k
          if (flags & AC_HDAAC) {
754
0
            pAacDecoderChannelInfo[ch]->renderMode = AACDEC_RENDER_INTIMDCT;
755
91.2k
          } else {
756
91.2k
            pAacDecoderChannelInfo[ch]->renderMode = AACDEC_RENDER_IMDCT;
757
91.2k
          }
758
91.2k
        }
759
294k
        break;
760
761
255k
      case ac_spectral_data:
762
255k
        error = CBlock_ReadAcSpectralData(
763
255k
            hBs, pAacDecoderChannelInfo[ch], pAacDecoderStaticChannelInfo[ch],
764
255k
            pSamplingRateInfo, frame_length, flags);
765
255k
        pAacDecoderChannelInfo[ch]->renderMode = AACDEC_RENDER_IMDCT;
766
255k
        break;
767
768
1.79k
      case coupled_elements: {
769
1.79k
        int num_coupled_elements, c;
770
771
1.79k
        ind_sw_cce_flag = FDKreadBit(hBs);
772
1.79k
        num_coupled_elements = FDKreadBits(hBs, 3);
773
774
8.59k
        for (c = 0; c < (num_coupled_elements + 1); c++) {
775
6.80k
          int cc_target_is_cpe;
776
777
6.80k
          num_gain_element_lists++;
778
6.80k
          cc_target_is_cpe = FDKreadBit(hBs); /* cc_target_is_cpe[c] */
779
6.80k
          FDKreadBits(hBs, 4);                /* cc_target_tag_select[c] */
780
781
6.80k
          if (cc_target_is_cpe) {
782
1.52k
            int cc_l, cc_r;
783
784
1.52k
            cc_l = FDKreadBit(hBs); /* cc_l[c] */
785
1.52k
            cc_r = FDKreadBit(hBs); /* cc_r[c] */
786
787
1.52k
            if (cc_l && cc_r) {
788
448
              num_gain_element_lists++;
789
448
            }
790
1.52k
          }
791
6.80k
        }
792
1.79k
        FDKreadBit(hBs);     /* cc_domain */
793
1.79k
        FDKreadBit(hBs);     /* gain_element_sign  */
794
1.79k
        FDKreadBits(hBs, 2); /* gain_element_scale */
795
1.79k
      } break;
796
797
1.76k
      case gain_element_lists: {
798
1.76k
        const CodeBookDescription *hcb;
799
1.76k
        UCHAR *pCodeBook;
800
1.76k
        int c;
801
802
1.76k
        hcb = &AACcodeBookDescriptionTable[BOOKSCL];
803
1.76k
        pCodeBook = pAacDecoderChannelInfo[ch]->pDynData->aCodeBook;
804
805
7.13k
        for (c = 1; c < num_gain_element_lists; c++) {
806
5.37k
          int cge;
807
5.37k
          if (ind_sw_cce_flag) {
808
766
            cge = 1;
809
4.60k
          } else {
810
4.60k
            cge = FDKreadBits(hBs, 1); /* common_gain_element_present[c] */
811
4.60k
          }
812
5.37k
          if (cge) {
813
            /* Huffman */
814
1.65k
            CBlock_DecodeHuffmanWord(
815
1.65k
                hBs, hcb); /* hcod_sf[common_gain_element[c]] 1..19 */
816
3.71k
          } else {
817
3.71k
            int g, sfb;
818
3.71k
            for (g = 0;
819
8.49k
                 g < GetWindowGroups(&pAacDecoderChannelInfo[ch]->icsInfo);
820
4.77k
                 g++) {
821
11.8k
              for (sfb = 0; sfb < GetScaleFactorBandsTransmitted(
822
11.8k
                                      &pAacDecoderChannelInfo[ch]->icsInfo);
823
7.10k
                   sfb++) {
824
7.10k
                if (pCodeBook[sfb] != ZERO_HCB) {
825
                  /* Huffman */
826
5.97k
                  CBlock_DecodeHuffmanWord(
827
5.97k
                      hBs,
828
5.97k
                      hcb); /* hcod_sf[dpcm_gain_element[c][g][sfb]] 1..19 */
829
5.97k
                }
830
7.10k
              }
831
4.77k
            }
832
3.71k
          }
833
5.37k
        }
834
1.76k
      } break;
835
836
        /* CRC handling */
837
26.2k
      case adtscrc_start_reg1:
838
26.2k
        if (pTpDec != NULL) {
839
26.2k
          crcReg1 = transportDec_CrcStartReg(pTpDec, 192);
840
26.2k
        }
841
26.2k
        break;
842
3.24k
      case adtscrc_start_reg2:
843
3.24k
        if (pTpDec != NULL) {
844
3.24k
          crcReg2 = transportDec_CrcStartReg(pTpDec, 128);
845
3.24k
        }
846
3.24k
        break;
847
25.7k
      case adtscrc_end_reg1:
848
25.7k
      case drmcrc_end_reg:
849
25.7k
        if (pTpDec != NULL) {
850
25.7k
          transportDec_CrcEndReg(pTpDec, crcReg1);
851
25.7k
          crcReg1 = -1;
852
25.7k
        }
853
25.7k
        break;
854
3.22k
      case adtscrc_end_reg2:
855
3.22k
        if (crcReg1 != -1) {
856
0
          error = AAC_DEC_DECODE_FRAME_ERROR;
857
3.22k
        } else if (pTpDec != NULL) {
858
3.22k
          transportDec_CrcEndReg(pTpDec, crcReg2);
859
3.22k
          crcReg2 = -1;
860
3.22k
        }
861
3.22k
        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
564k
      case next_channel:
870
564k
        ch = (ch + 1) % numberOfChannels;
871
564k
        break;
872
431k
      case link_sequence:
873
431k
        list = list->next[decision_bit];
874
431k
        i = -1;
875
431k
        break;
876
877
0
      default:
878
0
        error = AAC_DEC_UNSUPPORTED_FORMAT;
879
0
        break;
880
6.57M
    }
881
882
6.57M
    if (error != AAC_DEC_OK) {
883
2.96k
      goto bail;
884
2.96k
    }
885
886
6.57M
    i++;
887
888
6.57M
  } while (list->id[i] != end_of_sequence);
889
890
1.02M
  for (ch = 0; ch < numberOfChannels; ch++) {
891
594k
    if (pAacDecoderChannelInfo[ch]->renderMode == AACDEC_RENDER_IMDCT ||
892
548k
        pAacDecoderChannelInfo[ch]->renderMode == AACDEC_RENDER_ELDFB) {
893
      /* Shows which bands are empty. */
894
548k
      UCHAR *band_is_noise =
895
548k
          pAacDecoderChannelInfo[ch]->pDynData->band_is_noise;
896
548k
      FDKmemset(band_is_noise, (UCHAR)1, sizeof(UCHAR) * (8 * 16));
897
898
548k
      error = CBlock_InverseQuantizeSpectralData(
899
548k
          pAacDecoderChannelInfo[ch], pSamplingRateInfo, band_is_noise, 1);
900
548k
      if (error != AAC_DEC_OK) {
901
32
        return error;
902
32
      }
903
904
548k
      if (elFlags & AC_EL_USAC_NOISE) {
905
11.5k
        CBlock_ApplyNoise(pAacDecoderChannelInfo[ch], pSamplingRateInfo,
906
11.5k
                          &pAacDecoderStaticChannelInfo[ch]->nfRandomSeed,
907
11.5k
                          band_is_noise);
908
909
11.5k
      } /* if (elFlags & AC_EL_USAC_NOISE) */
910
548k
    }
911
594k
  }
912
913
432k
bail:
914
432k
  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
432k
  return error;
926
429k
}