Coverage Report

Created: 2025-11-24 06:13

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