LCOV - code coverage report
Current view: top level - lib_isar - isar_PredDecoder.c (source / functions) Hit Total Coverage
Test: Coverage on main -- merged total coverage @ a21f94bc6bac334fe001a5bad2f7b32b79038097 Lines: 160 188 85.1 %
Date: 2025-11-01 08:50:45 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        2098 : 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        2098 :     PredictionDecoder *psPredictionDecoder = NULL;
      57             : 
      58        2098 :     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        2098 :     psPredictionDecoder->iChannels = iChannels;
      64        2098 :     psPredictionDecoder->iNumBlocks = iNumBlocks;
      65        2098 :     psPredictionDecoder->iNumSubSets = LCLD_BLOCKS_PER_FRAME / psPredictionDecoder->iNumBlocks;
      66        2098 :     psPredictionDecoder->iSubSetId = 0;
      67             : 
      68             :     /* PLC_IMPROVEMENT */
      69        2098 :     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        2098 :     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        2098 :     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        6294 :     for ( n = 0; n < iChannels; n++ )
      83             :     {
      84             :         int32_t k;
      85        4196 :         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        4196 :         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        4196 :         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       37764 :         for ( k = 0; k < LCLD_MAX_NUM_PRED_SUBSETS; k++ )
      98             :         {
      99       33568 :             psPredictionDecoder->ppiDecodingUnresolved[n][k] = 0;
     100       33568 :             psPredictionDecoder->ppiDecodingFailed[n][k] = 0;
     101       33568 :             psPredictionDecoder->ppiDecodingFailedPrev[n][k] = 0;
     102             :         }
     103             :     }
     104             : 
     105        2098 :     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        2098 :     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        2098 :     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        2098 :     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        2098 :     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        2098 :     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        2098 :     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        2098 :     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        6294 :     for ( n = 0; n < psPredictionDecoder->iChannels; n++ )
     139             :     {
     140        4196 :         psPredictionDecoder->piPredChanEnable[n] = 0;
     141        4196 :         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      255956 :         for ( m = 0; m < LCLD_BANDS; m++ )
     146             :         {
     147      251760 :             psPredictionDecoder->ppiPredBandEnable[n][m] = 0;
     148             :         }
     149        4196 :         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        4196 :         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        4196 :         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        4196 :         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        4196 :         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        4196 :         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      255956 :         for ( m = 0; m < LCLD_BANDS; m++ )
     174             :         {
     175      251760 :             psPredictionDecoder->ppfPredStateReal[n][m] = 0;
     176      251760 :             psPredictionDecoder->ppfPredStateImag[n][m] = 0;
     177             :         }
     178             :     }
     179             : 
     180             :     /* pre-define these tables? */
     181       18882 :     for ( n = 0; n < ( 1 << PRED_QUNAT_FILTER_MAG_BITS ); n++ )
     182             :     {
     183       16784 :         const float fInvMagScale = M_PI / ( 2.0f * (float) ( 1 << ( PRED_QUNAT_FILTER_MAG_BITS ) ) + 1.0f );
     184       16784 :         psPredictionDecoder->pfMagLUT[n] = sinf( fInvMagScale * (float) n );
     185             :     }
     186             : 
     187       69234 :     for ( n = 0; n < ( 1 << PRED_QUANT_FILTER_PHASE_BITS ); n++ )
     188             :     {
     189       67136 :         const float fInvPhaseScale = M_PI / (float) ( 1 << ( PRED_QUANT_FILTER_PHASE_BITS - 1 ) );
     190             :         int16_t iVal;
     191             : 
     192       67136 :         iVal = n + PRED_QUANT_FILTER_PHASE_MIN;
     193       67136 :         psPredictionDecoder->pfP2RRealLUT[n] = cosf( fInvPhaseScale * (float) iVal );
     194       67136 :         psPredictionDecoder->pfP2RImagLUT[n] = sinf( fInvPhaseScale * (float) iVal );
     195             :     }
     196             : 
     197        2098 :     *psPredictionDecoder_out = psPredictionDecoder;
     198             : 
     199        2098 :     return IVAS_ERR_OK;
     200             : }
     201             : 
     202             : 
     203             : /*-------------------------------------------------------------------*
     204             :  * Function DeletePredictionDecoder()
     205             :  *
     206             :  *
     207             :  *-------------------------------------------------------------------*/
     208             : 
     209        2098 : void DeletePredictionDecoder(
     210             :     PredictionDecoder *psPredictionDecoder )
     211             : {
     212             :     int32_t n;
     213             : 
     214        6294 :     for ( n = 0; n < psPredictionDecoder->iChannels; n++ )
     215             :     {
     216        4196 :         free( psPredictionDecoder->ppiPredBandEnable[n] );
     217        4196 :         free( psPredictionDecoder->ppfA1Real[n] );
     218        4196 :         free( psPredictionDecoder->ppfA1Imag[n] );
     219        4196 :         free( psPredictionDecoder->ppiA1Mag[n] );
     220        4196 :         free( psPredictionDecoder->ppiA1Phase[n] );
     221        4196 :         free( psPredictionDecoder->ppfPredStateReal[n] );
     222        4196 :         free( psPredictionDecoder->ppfPredStateImag[n] );
     223             :         /* PLC_IMPROVEMENT */
     224        4196 :         free( psPredictionDecoder->ppiDecodingUnresolved[n] );
     225        4196 :         free( psPredictionDecoder->ppiDecodingFailed[n] );
     226        4196 :         free( psPredictionDecoder->ppiDecodingFailedPrev[n] );
     227             :     }
     228        2098 :     free( psPredictionDecoder->piPredChanEnable );
     229        2098 :     free( psPredictionDecoder->ppiPredBandEnable );
     230        2098 :     free( psPredictionDecoder->ppfA1Real );
     231        2098 :     free( psPredictionDecoder->ppfA1Imag );
     232        2098 :     free( psPredictionDecoder->ppiA1Mag );
     233        2098 :     free( psPredictionDecoder->ppiA1Phase );
     234        2098 :     free( psPredictionDecoder->ppfPredStateReal );
     235        2098 :     free( psPredictionDecoder->ppfPredStateImag );
     236             :     /* PLC_IMPROVEMENT */
     237        2098 :     free( psPredictionDecoder->ppiDecodingUnresolved );
     238        2098 :     free( psPredictionDecoder->ppiDecodingFailed );
     239        2098 :     free( psPredictionDecoder->ppiDecodingFailedPrev );
     240             : 
     241        2098 :     free( psPredictionDecoder );
     242        2098 :     psPredictionDecoder = NULL;
     243             : 
     244        2098 :     return;
     245             : }
     246             : 
     247             : 
     248             : /*-------------------------------------------------------------------*
     249             :  * Function ReadPredictors()
     250             :  *
     251             :  *
     252             :  *-------------------------------------------------------------------*/
     253             : 
     254      324649 : int16_t ReadPredictors(
     255             :     PredictionDecoder *psPredictionDecoder,
     256             :     ISAR_SPLIT_REND_BITS_HANDLE pBits )
     257             : {
     258      324649 :     int16_t iBitsRead = 0;
     259             :     int32_t c;
     260             :     int32_t b;
     261      324649 :     int16_t iNumPredBandBits = 6;
     262      324649 :     const int16_t iSubSetBits = ( LCLD_MAX_NUM_PRED_SUBSETS > 4 ? 3 : 2 );
     263             : 
     264      324649 :     psPredictionDecoder->iNumSubSets = ISAR_SPLIT_REND_BITStream_read_int32( pBits, iSubSetBits ) + 1;
     265      324649 :     iBitsRead += iSubSetBits;
     266             : 
     267      324649 :     if ( psPredictionDecoder->iNumSubSets > 1 )
     268             :     {
     269       20522 :         psPredictionDecoder->iSubSetId = ISAR_SPLIT_REND_BITStream_read_int32( pBits, iSubSetBits );
     270       20522 :         iBitsRead += iSubSetBits;
     271       20522 :         iNumPredBandBits = ( psPredictionDecoder->iNumSubSets >= 4 ? 4 : 5 );
     272             :     }
     273             :     else
     274             :     {
     275      304127 :         psPredictionDecoder->iSubSetId = 0;
     276             :     }
     277             : 
     278      973947 :     for ( c = 0; c < psPredictionDecoder->iChannels; c++ )
     279             :     {
     280      649298 :         psPredictionDecoder->piPredChanEnable[c] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, psPredictionDecoder->iNumSubSets );
     281      649298 :         iBitsRead += (int16_t) psPredictionDecoder->iNumSubSets;
     282             : 
     283      649298 :         if ( get_bit( psPredictionDecoder->piPredChanEnable[c], psPredictionDecoder->iSubSetId ) )
     284             :         {
     285      316622 :             int32_t b0 = psPredictionDecoder->iSubSetId;
     286      316622 :             int32_t bstep = psPredictionDecoder->iNumSubSets;
     287             :             int32_t iNumPredBands;
     288             : 
     289    18949592 :             for ( b = b0; b < LCLD_BANDS; b += bstep )
     290             :             {
     291    18632970 :                 psPredictionDecoder->ppiPredBandEnable[c][b] = 0;
     292             :             }
     293      316622 :             iNumPredBands = ISAR_SPLIT_REND_BITStream_read_int32( pBits, iNumPredBandBits );
     294      316622 :             iBitsRead += iNumPredBandBits;
     295      316622 :             iNumPredBands = iNumPredBands * psPredictionDecoder->iNumSubSets + b0;
     296             : 
     297     4476578 :             for ( b = b0; b < iNumPredBands; b += bstep )
     298             :             {
     299     4159956 :                 psPredictionDecoder->ppiPredBandEnable[c][b] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 );
     300     4159956 :                 iBitsRead += 1;
     301             : 
     302     4159956 :                 if ( psPredictionDecoder->ppiPredBandEnable[c][b] == 1 )
     303             :                 {
     304             :                     int32_t iA1Mag;
     305             :                     int32_t iA1Phase;
     306             :                     float fA1Real;
     307             :                     float fA1Imag;
     308     1963560 :                     iA1Mag = ISAR_SPLIT_REND_BITStream_read_int32( pBits, PRED_QUNAT_FILTER_MAG_BITS );
     309     1963560 :                     iBitsRead += PRED_QUNAT_FILTER_MAG_BITS;
     310     1963560 :                     iA1Phase = ISAR_SPLIT_REND_BITStream_read_int32( pBits, PRED_QUANT_FILTER_PHASE_BITS );
     311     1963560 :                     iBitsRead += PRED_QUANT_FILTER_PHASE_BITS;
     312             : 
     313     1963560 :                     psPredictionDecoder->ppiA1Mag[c][b] = iA1Mag;
     314     1963560 :                     psPredictionDecoder->ppiA1Phase[c][b] = iA1Phase + PRED_QUANT_FILTER_PHASE_MIN;
     315             : 
     316     1963560 :                     fA1Real = psPredictionDecoder->pfMagLUT[iA1Mag] * psPredictionDecoder->pfP2RRealLUT[iA1Phase];
     317     1963560 :                     fA1Imag = psPredictionDecoder->pfMagLUT[iA1Mag] * psPredictionDecoder->pfP2RImagLUT[iA1Phase];
     318             : 
     319     1963560 :                     psPredictionDecoder->ppfA1Real[c][b] = fA1Real;
     320     1963560 :                     psPredictionDecoder->ppfA1Imag[c][b] = fA1Imag;
     321             :                 }
     322             :             }
     323             :         }
     324             :     }
     325             : 
     326             :     /* disable any inactive prediction bands */
     327      973947 :     for ( c = 0; c < psPredictionDecoder->iChannels; c++ )
     328             :     {
     329             :         int32_t set;
     330     1380688 :         for ( set = 0; set < psPredictionDecoder->iNumSubSets; set++ )
     331             :         {
     332      731390 :             if ( !get_bit( psPredictionDecoder->piPredChanEnable[c], set ) )
     333             :             {
     334    20358918 :                 for ( b = set; b < LCLD_BANDS; b += psPredictionDecoder->iNumSubSets )
     335             :                 {
     336    19961250 :                     psPredictionDecoder->ppiPredBandEnable[c][b] = 0;
     337             :                 }
     338             :             }
     339             :         }
     340             :     }
     341             : 
     342      324649 :     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      324649 : int32_t AnyDecodingUnresolved(
     375             :     PredictionDecoder *psPredictionDecoder )
     376             : {
     377             :     int32_t n, ch;
     378      973947 :     for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ )
     379             :     {
     380     1380688 :         for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ )
     381             :         {
     382      731390 :             if ( psPredictionDecoder->ppiDecodingUnresolved[ch][n] == 1 )
     383             :             {
     384           0 :                 return 1;
     385             :             }
     386             :         }
     387             :     }
     388      324649 :     return 0;
     389             : }
     390             : 
     391             : 
     392             : /*-------------------------------------------------------------------*
     393             :  * Function UpdateDecodingFailedStatus()
     394             :  *
     395             :  *
     396             :  *-------------------------------------------------------------------*/
     397             : 
     398      324649 : void UpdateDecodingFailedStatus(
     399             :     PredictionDecoder *psPredictionDecoder )
     400             : {
     401             :     int32_t n, ch;
     402             : 
     403      973947 :     for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ )
     404             :     {
     405     1380688 :         for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ )
     406             :         {
     407      731390 :             psPredictionDecoder->ppiDecodingFailedPrev[ch][n] = psPredictionDecoder->ppiDecodingFailed[ch][n];
     408             :         }
     409             :     }
     410             : 
     411      324649 :     return;
     412             : }
     413             : 
     414             : 
     415             : /*-------------------------------------------------------------------*
     416             :  * Function UpdateDecodingUnresolved()
     417             :  *
     418             :  *
     419             :  *-------------------------------------------------------------------*/
     420             : 
     421      324649 : void UpdateDecodingUnresolved(
     422             :     PredictionDecoder *psPredictionDecoder )
     423             : {
     424             :     int32_t n, ch;
     425             : 
     426      324649 :     int32_t iCurrentSubSet = psPredictionDecoder->iSubSetId;
     427             : 
     428      973947 :     for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ )
     429             :     {
     430             :         /* Prediction data always available for current subset */
     431      649298 :         psPredictionDecoder->ppiDecodingUnresolved[ch][iCurrentSubSet] = 0;
     432             : 
     433     1380688 :         for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ )
     434             :         {
     435      731390 :             int32_t iSubSetActive = get_bit( psPredictionDecoder->piPredChanEnable[ch], n );
     436      731390 :             if ( iSubSetActive == 0 )
     437             :             {
     438             :                 /* Prediction information available inactive subsets (e.g. no Prediction) */
     439      397668 :                 psPredictionDecoder->ppiDecodingUnresolved[ch][n] = 0;
     440             :             }
     441             :         }
     442             :     }
     443             : 
     444      324649 :     return;
     445             : }
     446             : 
     447             : 
     448             : /*-------------------------------------------------------------------*
     449             :  * Function ApplyInversePredictors()
     450             :  *
     451             :  *
     452             :  *-------------------------------------------------------------------*/
     453             : 
     454      324649 : void ApplyInversePredictors(
     455             :     PredictionDecoder *psPredictionDecoder,
     456             :     float ***pppfReal,
     457             :     float ***pppfImag )
     458             : {
     459             :     int32_t c;
     460             : 
     461      973947 :     for ( c = 0; c < psPredictionDecoder->iChannels; c++ )
     462             :     {
     463      649298 :         if ( psPredictionDecoder->piPredChanEnable[c] > 0 )
     464             :         {
     465             :             int32_t b;
     466    20040696 :             for ( b = 0; b < LCLD_BANDS; b++ )
     467             :             {
     468    19712160 :                 if ( psPredictionDecoder->ppiPredBandEnable[c][b] == 1 )
     469             :                 {
     470             :                     int32_t n;
     471             :                     float fA1Real;
     472             :                     float fA1Imag;
     473     2003395 :                     float fPrevReal = 0.0f;
     474     2003395 :                     float fPrevImag = 0.0f;
     475     2003395 :                     int32_t iSubset = b % psPredictionDecoder->iNumSubSets;
     476             : 
     477     2003395 :                     if ( iSubset != psPredictionDecoder->iSubSetId )
     478             :                     {
     479       39835 :                         fPrevReal = psPredictionDecoder->ppfPredStateReal[c][b];
     480       39835 :                         fPrevImag = psPredictionDecoder->ppfPredStateImag[c][b];
     481             :                     }
     482             : 
     483     2003395 :                     fA1Real = psPredictionDecoder->ppfA1Real[c][b];
     484     2003395 :                     fA1Imag = psPredictionDecoder->ppfA1Imag[c][b];
     485    33420027 :                     for ( n = 0; n < psPredictionDecoder->iNumBlocks; n++ )
     486             :                     {
     487             :                         float fReal;
     488             :                         float fImag;
     489             : 
     490    31416632 :                         fReal = pppfReal[c][n][b] - fA1Real * fPrevReal + fA1Imag * fPrevImag;
     491    31416632 :                         fImag = pppfImag[c][n][b] - fA1Real * fPrevImag - fA1Imag * fPrevReal;
     492             : 
     493    31416632 :                         pppfReal[c][n][b] = fReal;
     494    31416632 :                         pppfImag[c][n][b] = fImag;
     495             : 
     496    31416632 :                         fPrevReal = fReal;
     497    31416632 :                         fPrevImag = fImag;
     498             :                     }
     499     2003395 :                     psPredictionDecoder->ppfPredStateReal[c][b] = fPrevReal;
     500     2003395 :                     psPredictionDecoder->ppfPredStateImag[c][b] = fPrevImag;
     501             :                 }
     502             :             }
     503             :         }
     504             :     }
     505             : 
     506      324649 :     return;
     507             : }

Generated by: LCOV version 1.14