Coverage Report

Created: 2025-10-28 06:45

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