LCOV - code coverage report
Current view: top level - lib_isar - isar_PredDecoder.c (source / functions) Hit Total Coverage
Test: Coverage on main -- conformance test test_26252.py @ a21f94bc6bac334fe001a5bad2f7b32b79038097 Lines: 160 188 85.1 %
Date: 2025-11-01 05:07:43 Functions: 7 8 87.5 %

          Line data    Source code
       1             : /******************************************************************************************************
       2             : 
       3             :    (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
       4             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
       5             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
       6             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
       7             :    contributors to this repository. All Rights Reserved.
       8             : 
       9             :    This software is protected by copyright law and by international treaties.
      10             :    The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
      11             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
      12             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
      13             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
      14             :    contributors to this repository retain full ownership rights in their respective contributions in
      15             :    the software. This notice grants no license of any kind, including but not limited to patent
      16             :    license, nor is any license granted by implication, estoppel or otherwise.
      17             : 
      18             :    Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
      19             :    contributions.
      20             : 
      21             :    This software is provided "AS IS", without any express or implied warranties. The software is in the
      22             :    development stage. It is intended exclusively for experts who have experience with such software and
      23             :    solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
      24             :    and fitness for a particular purpose are hereby disclaimed and excluded.
      25             : 
      26             :    Any dispute, controversy or claim arising under or in relation to providing this software shall be
      27             :    submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
      28             :    accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
      29             :    the United Nations Convention on Contracts on the International Sales of Goods.
      30             : 
      31             : *******************************************************************************************************/
      32             : 
      33             : #include <stdint.h>
      34             : #include "options.h"
      35             : #include <math.h>
      36             : #include "prot.h"
      37             : #include "isar_prot.h"
      38             : #include "isar_lcld_prot.h"
      39             : #include "isar_rom_lcld_tables.h"
      40             : #include "wmc_auto.h"
      41             : 
      42             : 
      43             : /*-------------------------------------------------------------------*
      44             :  * Function CreatePredictionDecoder()
      45             :  *
      46             :  *
      47             :  *-------------------------------------------------------------------*/
      48             : 
      49         664 : ivas_error CreatePredictionDecoder(
      50             :     PredictionDecoder **psPredictionDecoder_out,
      51             :     const int32_t iChannels,
      52             :     const int32_t iNumBlocks )
      53             : {
      54             :     int16_t n;
      55             :     int16_t m;
      56         664 :     PredictionDecoder *psPredictionDecoder = NULL;
      57             : 
      58         664 :     if ( ( psPredictionDecoder = (PredictionDecoder *) malloc( sizeof( PredictionDecoder ) ) ) == NULL )
      59             :     {
      60           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
      61             :     }
      62             : 
      63         664 :     psPredictionDecoder->iChannels = iChannels;
      64         664 :     psPredictionDecoder->iNumBlocks = iNumBlocks;
      65         664 :     psPredictionDecoder->iNumSubSets = LCLD_BLOCKS_PER_FRAME / psPredictionDecoder->iNumBlocks;
      66         664 :     psPredictionDecoder->iSubSetId = 0;
      67             : 
      68             :     /* PLC_IMPROVEMENT */
      69         664 :     if ( ( psPredictionDecoder->ppiDecodingFailedPrev = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL )
      70             :     {
      71           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) );
      72             :     }
      73         664 :     if ( ( psPredictionDecoder->ppiDecodingFailed = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL )
      74             :     {
      75           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) );
      76             :     }
      77         664 :     if ( ( psPredictionDecoder->ppiDecodingUnresolved = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL )
      78             :     {
      79           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) );
      80             :     }
      81             : 
      82        1992 :     for ( n = 0; n < iChannels; n++ )
      83             :     {
      84             :         int32_t k;
      85        1328 :         if ( ( psPredictionDecoder->ppiDecodingUnresolved[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_MAX_NUM_PRED_SUBSETS ) ) == NULL )
      86             :         {
      87           0 :             return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) );
      88             :         }
      89        1328 :         if ( ( psPredictionDecoder->ppiDecodingFailed[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_MAX_NUM_PRED_SUBSETS ) ) == NULL )
      90             :         {
      91           0 :             return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) );
      92             :         }
      93        1328 :         if ( ( psPredictionDecoder->ppiDecodingFailedPrev[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_MAX_NUM_PRED_SUBSETS ) ) == NULL )
      94             :         {
      95           0 :             return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) );
      96             :         }
      97       11952 :         for ( k = 0; k < LCLD_MAX_NUM_PRED_SUBSETS; k++ )
      98             :         {
      99       10624 :             psPredictionDecoder->ppiDecodingUnresolved[n][k] = 0;
     100       10624 :             psPredictionDecoder->ppiDecodingFailed[n][k] = 0;
     101       10624 :             psPredictionDecoder->ppiDecodingFailedPrev[n][k] = 0;
     102             :         }
     103             :     }
     104             : 
     105         664 :     if ( ( psPredictionDecoder->piPredChanEnable = (int32_t *) malloc( sizeof( int32_t ) * iChannels ) ) == NULL )
     106             :     {
     107           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
     108             :     }
     109         664 :     if ( ( psPredictionDecoder->ppiPredBandEnable = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL )
     110             :     {
     111           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
     112             :     }
     113         664 :     if ( ( psPredictionDecoder->ppfA1Real = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL )
     114             :     {
     115           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
     116             :     }
     117         664 :     if ( ( psPredictionDecoder->ppfA1Imag = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL )
     118             :     {
     119           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
     120             :     }
     121         664 :     if ( ( psPredictionDecoder->ppiA1Mag = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL )
     122             :     {
     123           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
     124             :     }
     125         664 :     if ( ( psPredictionDecoder->ppiA1Phase = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL )
     126             :     {
     127           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
     128             :     }
     129         664 :     if ( ( psPredictionDecoder->ppfPredStateReal = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL )
     130             :     {
     131           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) );
     132             :     }
     133         664 :     if ( ( psPredictionDecoder->ppfPredStateImag = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL )
     134             :     {
     135           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) );
     136             :     }
     137             : 
     138        1992 :     for ( n = 0; n < psPredictionDecoder->iChannels; n++ )
     139             :     {
     140        1328 :         psPredictionDecoder->piPredChanEnable[n] = 0;
     141        1328 :         if ( ( psPredictionDecoder->ppiPredBandEnable[n] = (int32_t *) malloc( LCLD_BANDS * sizeof( int32_t ) ) ) == NULL )
     142             :         {
     143           0 :             return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
     144             :         }
     145       81008 :         for ( m = 0; m < LCLD_BANDS; m++ )
     146             :         {
     147       79680 :             psPredictionDecoder->ppiPredBandEnable[n][m] = 0;
     148             :         }
     149        1328 :         if ( ( psPredictionDecoder->ppfA1Real[n] = (float *) malloc( sizeof( float ) * LCLD_BANDS ) ) == NULL )
     150             :         {
     151           0 :             return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
     152             :         }
     153        1328 :         if ( ( psPredictionDecoder->ppfA1Imag[n] = (float *) malloc( sizeof( float ) * LCLD_BANDS ) ) == NULL )
     154             :         {
     155           0 :             return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
     156             :         }
     157        1328 :         if ( ( psPredictionDecoder->ppiA1Mag[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_BANDS ) ) == NULL )
     158             :         {
     159           0 :             return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
     160             :         }
     161        1328 :         if ( ( psPredictionDecoder->ppiA1Phase[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_BANDS ) ) == NULL )
     162             :         {
     163           0 :             return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
     164             :         }
     165        1328 :         if ( ( psPredictionDecoder->ppfPredStateReal[n] = (float *) malloc( LCLD_BANDS * sizeof( float ) ) ) == NULL )
     166             :         {
     167           0 :             return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionDecoder Module \n" ) );
     168             :         }
     169        1328 :         if ( ( psPredictionDecoder->ppfPredStateImag[n] = (float *) malloc( LCLD_BANDS * sizeof( float ) ) ) == NULL )
     170             :         {
     171           0 :             return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionDecoder Module \n" ) );
     172             :         }
     173       81008 :         for ( m = 0; m < LCLD_BANDS; m++ )
     174             :         {
     175       79680 :             psPredictionDecoder->ppfPredStateReal[n][m] = 0;
     176       79680 :             psPredictionDecoder->ppfPredStateImag[n][m] = 0;
     177             :         }
     178             :     }
     179             : 
     180             :     /* pre-define these tables? */
     181        5976 :     for ( n = 0; n < ( 1 << PRED_QUNAT_FILTER_MAG_BITS ); n++ )
     182             :     {
     183        5312 :         const float fInvMagScale = M_PI / ( 2.0f * (float) ( 1 << ( PRED_QUNAT_FILTER_MAG_BITS ) ) + 1.0f );
     184        5312 :         psPredictionDecoder->pfMagLUT[n] = sinf( fInvMagScale * (float) n );
     185             :     }
     186             : 
     187       21912 :     for ( n = 0; n < ( 1 << PRED_QUANT_FILTER_PHASE_BITS ); n++ )
     188             :     {
     189       21248 :         const float fInvPhaseScale = M_PI / (float) ( 1 << ( PRED_QUANT_FILTER_PHASE_BITS - 1 ) );
     190             :         int16_t iVal;
     191             : 
     192       21248 :         iVal = n + PRED_QUANT_FILTER_PHASE_MIN;
     193       21248 :         psPredictionDecoder->pfP2RRealLUT[n] = cosf( fInvPhaseScale * (float) iVal );
     194       21248 :         psPredictionDecoder->pfP2RImagLUT[n] = sinf( fInvPhaseScale * (float) iVal );
     195             :     }
     196             : 
     197         664 :     *psPredictionDecoder_out = psPredictionDecoder;
     198             : 
     199         664 :     return IVAS_ERR_OK;
     200             : }
     201             : 
     202             : 
     203             : /*-------------------------------------------------------------------*
     204             :  * Function DeletePredictionDecoder()
     205             :  *
     206             :  *
     207             :  *-------------------------------------------------------------------*/
     208             : 
     209         664 : void DeletePredictionDecoder(
     210             :     PredictionDecoder *psPredictionDecoder )
     211             : {
     212             :     int32_t n;
     213             : 
     214        1992 :     for ( n = 0; n < psPredictionDecoder->iChannels; n++ )
     215             :     {
     216        1328 :         free( psPredictionDecoder->ppiPredBandEnable[n] );
     217        1328 :         free( psPredictionDecoder->ppfA1Real[n] );
     218        1328 :         free( psPredictionDecoder->ppfA1Imag[n] );
     219        1328 :         free( psPredictionDecoder->ppiA1Mag[n] );
     220        1328 :         free( psPredictionDecoder->ppiA1Phase[n] );
     221        1328 :         free( psPredictionDecoder->ppfPredStateReal[n] );
     222        1328 :         free( psPredictionDecoder->ppfPredStateImag[n] );
     223             :         /* PLC_IMPROVEMENT */
     224        1328 :         free( psPredictionDecoder->ppiDecodingUnresolved[n] );
     225        1328 :         free( psPredictionDecoder->ppiDecodingFailed[n] );
     226        1328 :         free( psPredictionDecoder->ppiDecodingFailedPrev[n] );
     227             :     }
     228         664 :     free( psPredictionDecoder->piPredChanEnable );
     229         664 :     free( psPredictionDecoder->ppiPredBandEnable );
     230         664 :     free( psPredictionDecoder->ppfA1Real );
     231         664 :     free( psPredictionDecoder->ppfA1Imag );
     232         664 :     free( psPredictionDecoder->ppiA1Mag );
     233         664 :     free( psPredictionDecoder->ppiA1Phase );
     234         664 :     free( psPredictionDecoder->ppfPredStateReal );
     235         664 :     free( psPredictionDecoder->ppfPredStateImag );
     236             :     /* PLC_IMPROVEMENT */
     237         664 :     free( psPredictionDecoder->ppiDecodingUnresolved );
     238         664 :     free( psPredictionDecoder->ppiDecodingFailed );
     239         664 :     free( psPredictionDecoder->ppiDecodingFailedPrev );
     240             : 
     241         664 :     free( psPredictionDecoder );
     242         664 :     psPredictionDecoder = NULL;
     243             : 
     244         664 :     return;
     245             : }
     246             : 
     247             : 
     248             : /*-------------------------------------------------------------------*
     249             :  * Function ReadPredictors()
     250             :  *
     251             :  *
     252             :  *-------------------------------------------------------------------*/
     253             : 
     254      133227 : int16_t ReadPredictors(
     255             :     PredictionDecoder *psPredictionDecoder,
     256             :     ISAR_SPLIT_REND_BITS_HANDLE pBits )
     257             : {
     258      133227 :     int16_t iBitsRead = 0;
     259             :     int32_t c;
     260             :     int32_t b;
     261      133227 :     int16_t iNumPredBandBits = 6;
     262      133227 :     const int16_t iSubSetBits = ( LCLD_MAX_NUM_PRED_SUBSETS > 4 ? 3 : 2 );
     263             : 
     264      133227 :     psPredictionDecoder->iNumSubSets = ISAR_SPLIT_REND_BITStream_read_int32( pBits, iSubSetBits ) + 1;
     265      133227 :     iBitsRead += iSubSetBits;
     266             : 
     267      133227 :     if ( psPredictionDecoder->iNumSubSets > 1 )
     268             :     {
     269        8049 :         psPredictionDecoder->iSubSetId = ISAR_SPLIT_REND_BITStream_read_int32( pBits, iSubSetBits );
     270        8049 :         iBitsRead += iSubSetBits;
     271        8049 :         iNumPredBandBits = ( psPredictionDecoder->iNumSubSets >= 4 ? 4 : 5 );
     272             :     }
     273             :     else
     274             :     {
     275      125178 :         psPredictionDecoder->iSubSetId = 0;
     276             :     }
     277             : 
     278      399681 :     for ( c = 0; c < psPredictionDecoder->iChannels; c++ )
     279             :     {
     280      266454 :         psPredictionDecoder->piPredChanEnable[c] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, psPredictionDecoder->iNumSubSets );
     281      266454 :         iBitsRead += (int16_t) psPredictionDecoder->iNumSubSets;
     282             : 
     283      266454 :         if ( get_bit( psPredictionDecoder->piPredChanEnable[c], psPredictionDecoder->iSubSetId ) )
     284             :         {
     285      133430 :             int32_t b0 = psPredictionDecoder->iSubSetId;
     286      133430 :             int32_t bstep = psPredictionDecoder->iNumSubSets;
     287             :             int32_t iNumPredBands;
     288             : 
     289     7980125 :             for ( b = b0; b < LCLD_BANDS; b += bstep )
     290             :             {
     291     7846695 :                 psPredictionDecoder->ppiPredBandEnable[c][b] = 0;
     292             :             }
     293      133430 :             iNumPredBands = ISAR_SPLIT_REND_BITStream_read_int32( pBits, iNumPredBandBits );
     294      133430 :             iBitsRead += iNumPredBandBits;
     295      133430 :             iNumPredBands = iNumPredBands * psPredictionDecoder->iNumSubSets + b0;
     296             : 
     297     1748466 :             for ( b = b0; b < iNumPredBands; b += bstep )
     298             :             {
     299     1615036 :                 psPredictionDecoder->ppiPredBandEnable[c][b] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 );
     300     1615036 :                 iBitsRead += 1;
     301             : 
     302     1615036 :                 if ( psPredictionDecoder->ppiPredBandEnable[c][b] == 1 )
     303             :                 {
     304             :                     int32_t iA1Mag;
     305             :                     int32_t iA1Phase;
     306             :                     float fA1Real;
     307             :                     float fA1Imag;
     308      732637 :                     iA1Mag = ISAR_SPLIT_REND_BITStream_read_int32( pBits, PRED_QUNAT_FILTER_MAG_BITS );
     309      732637 :                     iBitsRead += PRED_QUNAT_FILTER_MAG_BITS;
     310      732637 :                     iA1Phase = ISAR_SPLIT_REND_BITStream_read_int32( pBits, PRED_QUANT_FILTER_PHASE_BITS );
     311      732637 :                     iBitsRead += PRED_QUANT_FILTER_PHASE_BITS;
     312             : 
     313      732637 :                     psPredictionDecoder->ppiA1Mag[c][b] = iA1Mag;
     314      732637 :                     psPredictionDecoder->ppiA1Phase[c][b] = iA1Phase + PRED_QUANT_FILTER_PHASE_MIN;
     315             : 
     316      732637 :                     fA1Real = psPredictionDecoder->pfMagLUT[iA1Mag] * psPredictionDecoder->pfP2RRealLUT[iA1Phase];
     317      732637 :                     fA1Imag = psPredictionDecoder->pfMagLUT[iA1Mag] * psPredictionDecoder->pfP2RImagLUT[iA1Phase];
     318             : 
     319      732637 :                     psPredictionDecoder->ppfA1Real[c][b] = fA1Real;
     320      732637 :                     psPredictionDecoder->ppfA1Imag[c][b] = fA1Imag;
     321             :                 }
     322             :             }
     323             :         }
     324             :     }
     325             : 
     326             :     /* disable any inactive prediction bands */
     327      399681 :     for ( c = 0; c < psPredictionDecoder->iChannels; c++ )
     328             :     {
     329             :         int32_t set;
     330      565106 :         for ( set = 0; set < psPredictionDecoder->iNumSubSets; set++ )
     331             :         {
     332      298652 :             if ( !get_bit( psPredictionDecoder->piPredChanEnable[c], set ) )
     333             :             {
     334     8139533 :                 for ( b = set; b < LCLD_BANDS; b += psPredictionDecoder->iNumSubSets )
     335             :                 {
     336     7981725 :                     psPredictionDecoder->ppiPredBandEnable[c][b] = 0;
     337             :                 }
     338             :             }
     339             :         }
     340             :     }
     341             : 
     342      133227 :     return iBitsRead;
     343             : }
     344             : 
     345             : 
     346             : /*-------------------------------------------------------------------*
     347             :  * Function SetDecodingPassed()
     348             :  *
     349             :  *
     350             :  *-------------------------------------------------------------------*/
     351             : 
     352           0 : void SetDecodingPassed(
     353             :     PredictionDecoder *psPredictionDecoder )
     354             : {
     355             :     int32_t n, ch;
     356           0 :     for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ )
     357             :     {
     358           0 :         for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ )
     359             :         {
     360           0 :             psPredictionDecoder->ppiDecodingFailed[ch][n] = 0;
     361             :         }
     362             :     }
     363             : 
     364           0 :     return;
     365             : }
     366             : 
     367             : 
     368             : /*-------------------------------------------------------------------*
     369             :  * Function AnyDecodingUnresolved()
     370             :  *
     371             :  *
     372             :  *-------------------------------------------------------------------*/
     373             : 
     374      133227 : int32_t AnyDecodingUnresolved(
     375             :     PredictionDecoder *psPredictionDecoder )
     376             : {
     377             :     int32_t n, ch;
     378      399681 :     for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ )
     379             :     {
     380      565106 :         for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ )
     381             :         {
     382      298652 :             if ( psPredictionDecoder->ppiDecodingUnresolved[ch][n] == 1 )
     383             :             {
     384           0 :                 return 1;
     385             :             }
     386             :         }
     387             :     }
     388      133227 :     return 0;
     389             : }
     390             : 
     391             : 
     392             : /*-------------------------------------------------------------------*
     393             :  * Function UpdateDecodingFailedStatus()
     394             :  *
     395             :  *
     396             :  *-------------------------------------------------------------------*/
     397             : 
     398      133227 : void UpdateDecodingFailedStatus(
     399             :     PredictionDecoder *psPredictionDecoder )
     400             : {
     401             :     int32_t n, ch;
     402             : 
     403      399681 :     for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ )
     404             :     {
     405      565106 :         for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ )
     406             :         {
     407      298652 :             psPredictionDecoder->ppiDecodingFailedPrev[ch][n] = psPredictionDecoder->ppiDecodingFailed[ch][n];
     408             :         }
     409             :     }
     410             : 
     411      133227 :     return;
     412             : }
     413             : 
     414             : 
     415             : /*-------------------------------------------------------------------*
     416             :  * Function UpdateDecodingUnresolved()
     417             :  *
     418             :  *
     419             :  *-------------------------------------------------------------------*/
     420             : 
     421      133227 : void UpdateDecodingUnresolved(
     422             :     PredictionDecoder *psPredictionDecoder )
     423             : {
     424             :     int32_t n, ch;
     425             : 
     426      133227 :     int32_t iCurrentSubSet = psPredictionDecoder->iSubSetId;
     427             : 
     428      399681 :     for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ )
     429             :     {
     430             :         /* Prediction data always available for current subset */
     431      266454 :         psPredictionDecoder->ppiDecodingUnresolved[ch][iCurrentSubSet] = 0;
     432             : 
     433      565106 :         for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ )
     434             :         {
     435      298652 :             int32_t iSubSetActive = get_bit( psPredictionDecoder->piPredChanEnable[ch], n );
     436      298652 :             if ( iSubSetActive == 0 )
     437             :             {
     438             :                 /* Prediction information available inactive subsets (e.g. no Prediction) */
     439      157808 :                 psPredictionDecoder->ppiDecodingUnresolved[ch][n] = 0;
     440             :             }
     441             :         }
     442             :     }
     443             : 
     444      133227 :     return;
     445             : }
     446             : 
     447             : 
     448             : /*-------------------------------------------------------------------*
     449             :  * Function ApplyInversePredictors()
     450             :  *
     451             :  *
     452             :  *-------------------------------------------------------------------*/
     453             : 
     454      133227 : void ApplyInversePredictors(
     455             :     PredictionDecoder *psPredictionDecoder,
     456             :     float ***pppfReal,
     457             :     float ***pppfImag )
     458             : {
     459             :     int32_t c;
     460             : 
     461      399681 :     for ( c = 0; c < psPredictionDecoder->iChannels; c++ )
     462             :     {
     463      266454 :         if ( psPredictionDecoder->piPredChanEnable[c] > 0 )
     464             :         {
     465             :             int32_t b;
     466     8445694 :             for ( b = 0; b < LCLD_BANDS; b++ )
     467             :             {
     468     8307240 :                 if ( psPredictionDecoder->ppiPredBandEnable[c][b] == 1 )
     469             :                 {
     470             :                     int32_t n;
     471             :                     float fA1Real;
     472             :                     float fA1Imag;
     473      750462 :                     float fPrevReal = 0.0f;
     474      750462 :                     float fPrevImag = 0.0f;
     475      750462 :                     int32_t iSubset = b % psPredictionDecoder->iNumSubSets;
     476             : 
     477      750462 :                     if ( iSubset != psPredictionDecoder->iSubSetId )
     478             :                     {
     479       17825 :                         fPrevReal = psPredictionDecoder->ppfPredStateReal[c][b];
     480       17825 :                         fPrevImag = psPredictionDecoder->ppfPredStateImag[c][b];
     481             :                     }
     482             : 
     483      750462 :                     fA1Real = psPredictionDecoder->ppfA1Real[c][b];
     484      750462 :                     fA1Imag = psPredictionDecoder->ppfA1Imag[c][b];
     485    12472522 :                     for ( n = 0; n < psPredictionDecoder->iNumBlocks; n++ )
     486             :                     {
     487             :                         float fReal;
     488             :                         float fImag;
     489             : 
     490    11722060 :                         fReal = pppfReal[c][n][b] - fA1Real * fPrevReal + fA1Imag * fPrevImag;
     491    11722060 :                         fImag = pppfImag[c][n][b] - fA1Real * fPrevImag - fA1Imag * fPrevReal;
     492             : 
     493    11722060 :                         pppfReal[c][n][b] = fReal;
     494    11722060 :                         pppfImag[c][n][b] = fImag;
     495             : 
     496    11722060 :                         fPrevReal = fReal;
     497    11722060 :                         fPrevImag = fImag;
     498             :                     }
     499      750462 :                     psPredictionDecoder->ppfPredStateReal[c][b] = fPrevReal;
     500      750462 :                     psPredictionDecoder->ppfPredStateImag[c][b] = fPrevImag;
     501             :                 }
     502             :             }
     503             :         }
     504             :     }
     505             : 
     506      133227 :     return;
     507             : }

Generated by: LCOV version 1.14