LCOV - code coverage report
Current view: top level - lib_isar - isar_lcld_prot.h (source / functions) Hit Total Coverage
Test: Coverage on main -- conformance test test_26252.py @ a21f94bc6bac334fe001a5bad2f7b32b79038097 Lines: 0 5 0.0 %
Date: 2025-11-01 05:07:43 Functions: 0 1 0.0 %

          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             : #ifndef ISAR_LCLD_PROT_H
      34             : #define ISAR_LCLD_PROT_H
      35             : 
      36             : #include "options.h"
      37             : #include "common_api_types.h"
      38             : #include "isar_rom_lcld_tables.h"
      39             : 
      40             : /* clang-format off */
      41             : 
      42             : typedef struct LCLD_ENCODER LCLDEncoder;
      43             : 
      44             : ivas_error CreateLCLDEncoder(
      45             :     LCLDEncoder **psLCLDEncoder_out,
      46             :     const int32_t iSampleRate,
      47             :     const int32_t iChannels,
      48             :     const int32_t iTargetBitRate,
      49             :     const int32_t iAllowSidePred,
      50             :     const int16_t iNumBlocks,
      51             :     const int16_t iNumSubSets,
      52             :     const int32_t iRealOnlyOut
      53             :    );
      54             : 
      55             : void DeleteLCLDEncoder(
      56             :     LCLDEncoder *psLCLDEncoder 
      57             : );
      58             : 
      59             : int32_t EncodeLCLDFrame(
      60             :     LCLDEncoder *psLCLDEncoder,
      61             :     float ***pppfLCLDReal,
      62             :     float ***pppfLCLDImag,
      63             :     int32_t *piNumiBites,
      64             :     const int32_t available_bits,
      65             :     ISAR_SPLIT_REND_BITS_HANDLE pBits );
      66             : 
      67             : 
      68             : typedef struct LCLD_DECODER LCLDDecoder;
      69             : 
      70             : ivas_error CreateLCLDDecoder(
      71             :     LCLDDecoder **psLCLDDecoder_out,
      72             :     const int32_t iSampleRate,
      73             :     const int32_t iChannels,
      74             :     const int32_t iNumBlocks,
      75             :     const int32_t iRealOnlyOut);
      76             : 
      77             : void DeleteLCLDDecoder(
      78             :     LCLDDecoder *psLCLDDecoder 
      79             : );
      80             : 
      81             : int32_t DecodeLCLDFrame(
      82             :     LCLDDecoder *psLCLDDecoder,
      83             :     ISAR_SPLIT_REND_BITS_HANDLE pBits,
      84             :     float ***pppfLCLDReal,
      85             :     float ***pppfLCLDImag 
      86             : );
      87             : 
      88             : 
      89             : /*----------------------------------------------------------------------------------*
      90             :  * MSPred prototypes
      91             :  *----------------------------------------------------------------------------------*/
      92             : 
      93             : int32_t quantPhase(
      94             :     float phase 
      95             : );
      96             : 
      97             : void cplxmult_lcld(
      98             :     float *pr1,
      99             :     float *pi1,
     100             :     const float r2,
     101             :     const float i2 
     102             : );
     103             : 
     104             : 
     105             : int32_t requantPhase(
     106             :     int32_t phaseQ 
     107             : );
     108             : 
     109             : int32_t quantPred(
     110             :     const float pred 
     111             : );
     112             : 
     113             : float dequantPhase(
     114             :     const int32_t phaseQ 
     115             : );
     116             : 
     117             : float dequantPred(
     118             :     int32_t predQ 
     119             : );
     120             : 
     121             : int32_t PrepEncode(
     122             :     int32_t *piQuant,
     123             :     const int32_t *piMSFlags,
     124             :     const int32_t numBands 
     125             : );
     126             : 
     127             : void EncodePhase(
     128             :     int32_t *phaseQuant,
     129             :     const int32_t numMSBands,
     130             :     const int32_t diffDim
     131             : );
     132             : 
     133             : void DecodePhase(
     134             :     int32_t *phaseQuant,
     135             :     const int32_t numMSBands,
     136             :     const int32_t diffDim 
     137             : );
     138             : 
     139             : int32_t EncodePredCoef(
     140             :     int32_t *predQuant,
     141             :     const int32_t numMSBands 
     142             : );
     143             : 
     144             : void DecodePredCoef(
     145             :     int32_t *phaseQuant,
     146             :     const int32_t numMSBands 
     147             : );
     148             : 
     149             : void writeMSPred(
     150             :     int32_t *phaseQuant,
     151             :     int32_t *predQuant,
     152             :     const int32_t MSMode,
     153             :     const int32_t numMSBands,
     154             :     int32_t numBands,
     155             :     void *fid,
     156             :     int32_t *piMsFlags 
     157             : );
     158             : 
     159             : int32_t CountMSBits(
     160             :     int32_t iNumBands,
     161             :     const int32_t iMSMode,
     162             :     const int32_t *piMSFlags,
     163             :     const int32_t *piLRPhaseDiff,
     164             :     const int32_t *piMSPredCoef 
     165             : );
     166             : 
     167             : 
     168             : /*----------------------------------------------------------------------------------*
     169             :  * NoiseGen prototypes
     170             :  *----------------------------------------------------------------------------------*/
     171             : 
     172             : typedef struct NOISE_GEN
     173             : {
     174             :     int32_t iNoiseBufferLength;
     175             :     int32_t iNoiseBufferMask;
     176             :     int32_t iNoiseBufferIndex;
     177             :     float *pfNoiseBuffer;
     178             : } NoiseGen;
     179             : 
     180             : void DeleteNoiseGen( 
     181             :     NoiseGen *psNoiseGen 
     182             : );
     183             : 
     184           0 : inline float GetNoise( NoiseGen *psNoiseGen )
     185             : {
     186             :     float fNoiseSample;
     187             : 
     188           0 :     fNoiseSample = psNoiseGen->pfNoiseBuffer[psNoiseGen->iNoiseBufferIndex];
     189           0 :     psNoiseGen->iNoiseBufferIndex++;
     190           0 :     psNoiseGen->iNoiseBufferIndex &= psNoiseGen->iNoiseBufferMask;
     191             : 
     192           0 :     return fNoiseSample;
     193             : }
     194             : 
     195             : 
     196             : /*----------------------------------------------------------------------------------*
     197             :  * PereptualModel prototypes
     198             :  *----------------------------------------------------------------------------------*/
     199             : 
     200             : extern void PerceptualModel(
     201             :     const int32_t iMaxQuantBands,
     202             :     const int32_t *piRMSEnvelope,
     203             :     int32_t *piExcitation,
     204             :     int32_t *piSMR 
     205             : );
     206             : 
     207             : extern void PerceptualModelStereo(
     208             :     const int32_t iMaxQuantBands,
     209             :     const int32_t *piMSFlags,
     210             :     const int32_t *piRMSEnvelope0,
     211             :     const int32_t *piRMSEnvelope1,
     212             :     int32_t *piExcitation0,
     213             :     int32_t *piExcitation1,
     214             :     int32_t *piSMR0,
     215             :     int32_t *piSMR1 
     216             : );
     217             : 
     218             : 
     219             : /*----------------------------------------------------------------------------------*
     220             :  * PredEncoder/PredDecoder prototypes
     221             :  *----------------------------------------------------------------------------------*/
     222             : 
     223             : typedef struct PREDICTION_ENCODER
     224             : {
     225             :     int32_t iChannels;
     226             :     int32_t iNumBlocks;
     227             : 
     228             :     int32_t iSubSetId;
     229             :     int32_t iNumSubSets;
     230             :     int32_t iMaxNumPredBands;
     231             :     float   ***pppfInpBufReal; /* channels, LCLD_PRED_WIN_LEN, bands */
     232             :     float   ***pppfInpBufImag;
     233             :     float   **ppfPredStateReal; /* channels, bands */
     234             :     float   **ppfPredStateImag;
     235             :     float   **ppfPredStateRealTmp;
     236             :     float   **ppfPredStateImagTmp;
     237             :     float   **ppfInpPrevReal; /* channels, bands */
     238             :     float   **ppfInpPrevImag;
     239             :     float pfRxxReal[2];
     240             :     float pfRxxImag[2];
     241             : 
     242             :     int32_t *piPredChanEnable;
     243             :     int32_t *piNumPredBands;
     244             :     int32_t **ppiPredBandEnable;
     245             : 
     246             :     float **ppfA1Real;
     247             :     float **ppfA1Imag;
     248             : 
     249             :     int32_t **ppiA1Mag;
     250             :     int32_t **ppiA1Phase;
     251             : 
     252             : } PredictionEncoder;
     253             : 
     254             : ivas_error CreatePredictionEncoder(
     255             :     PredictionEncoder **psPredictionEncoder_out,
     256             :     const int32_t iChannels,
     257             :     const int32_t iNumBlocks,
     258             :     const int32_t iNumSubSets,
     259             :     const int32_t iMaxNumPredBands 
     260             : );
     261             : 
     262             : void DeletePredictionEncoder(
     263             :     PredictionEncoder *psPredictionEncoder 
     264             : );
     265             : 
     266             : void ComputePredictors(
     267             :     PredictionEncoder *psPredictionEncoder,
     268             :     float ***pppfReal,
     269             :     float ***pppfImag 
     270             : );
     271             : 
     272             : 
     273             : int32_t WritePredictors(
     274             :     PredictionEncoder *psPredictionEncoder,
     275             :     ISAR_SPLIT_REND_BITS_HANDLE pBits 
     276             : );
     277             : 
     278             : typedef struct PREDICTION_DECODER
     279             : {
     280             :     int32_t iChannels;
     281             :     int32_t iNumBlocks;
     282             :     int32_t iSubSetId;
     283             :     int32_t iNumSubSets;
     284             :     float   **ppfPredStateReal;
     285             :     float   **ppfPredStateImag;
     286             : 
     287             :     int32_t *piPredChanEnable;
     288             :     int32_t **ppiPredBandEnable;
     289             : 
     290             :     /* PLC_IMPROVEMENT */
     291             :     int32_t **ppiDecodingUnresolved;
     292             :     int32_t **ppiDecodingFailed;
     293             :     int32_t **ppiDecodingFailedPrev;
     294             : 
     295             :     float **ppfA1Real;
     296             :     float **ppfA1Imag;
     297             : 
     298             :     int32_t **ppiA1Mag;
     299             :     int32_t **ppiA1Phase;
     300             : 
     301             :     float pfMagLUT[1 << PRED_QUNAT_FILTER_MAG_BITS];
     302             :     float pfP2RRealLUT[1 << PRED_QUANT_FILTER_PHASE_BITS];
     303             :     float pfP2RImagLUT[1 << PRED_QUANT_FILTER_PHASE_BITS];
     304             : 
     305             : } PredictionDecoder;
     306             : 
     307             : ivas_error CreatePredictionDecoder(
     308             :     PredictionDecoder **psPredictionDecoder_out,
     309             :     const int32_t iChannels,
     310             :     const int32_t iNumBlocks 
     311             : );
     312             : 
     313             : void DeletePredictionDecoder(
     314             :     PredictionDecoder *psPredictionDecoder 
     315             : );
     316             : 
     317             : int16_t ReadPredictors(
     318             :     PredictionDecoder *psPredictionDecoder,
     319             :     ISAR_SPLIT_REND_BITS_HANDLE pBits 
     320             : );
     321             : 
     322             : /* PLC_IMPROVEMENT */
     323             : void UpdatePredictionSubSetId(
     324             :     PredictionEncoder *psPredictionEncoder);
     325             : 
     326             : void SetDecodingUnresolved(
     327             :     LCLDDecoder *psLCLDDecoder);
     328             : 
     329             : int16_t AnyDecodingFailedPrev(
     330             :     LCLDDecoder *psLCLDDecoder);
     331             : 
     332             : int16_t AnyDecodingFailed(
     333             :     LCLDDecoder *psLCLDDecoder);
     334             : 
     335             : int32_t **GetDecodingFailedStatus(
     336             :     LCLDDecoder *psLCLDDecoder);
     337             : 
     338             : int16_t GetNumSubSets(
     339             :     LCLDDecoder *psLCLDDecoder);
     340             : 
     341             : int32_t **GetDecodingFailedPrevStatus(
     342             :     LCLDDecoder *psLCLDDecoder);
     343             : 
     344             : void SetDecodingPassed(
     345             :     PredictionDecoder *psPredictionDecoder);
     346             : 
     347             : void UpdateDecodingUnresolved(
     348             :     PredictionDecoder *psPredictionDecoder);
     349             : 
     350             : void UpdateDecodingFailedStatus(
     351             :     PredictionDecoder *psPredictionDecoder);
     352             : 
     353             : int32_t AnyDecodingUnresolved(
     354             :     PredictionDecoder *psPredictionDecoder);
     355             : 
     356             : void ApplyInversePredictors(
     357             :     PredictionDecoder *psPredictionDecoder,
     358             :     float ***pppfReal,
     359             :     float ***pppfImag 
     360             : );
     361             : 
     362             : 
     363             : /*----------------------------------------------------------------------------------*
     364             :  * RMSEnvGrouping prototypes
     365             :  *----------------------------------------------------------------------------------*/
     366             : 
     367             : typedef struct RMS_ENVELOPE_GROUPING RMSEnvelopeGrouping;
     368             : 
     369             : RMSEnvelopeGrouping *CreateRMSEnvelopeGrouping(
     370             :     const int32_t iNumBlocks 
     371             : );
     372             : 
     373             : void DeleteRMSEnvelopeGrouping(
     374             :     RMSEnvelopeGrouping *psRMSEnvelopeGrouping 
     375             : );
     376             : 
     377             : void ComputeEnvelopeGrouping(
     378             :     RMSEnvelopeGrouping *psRMSEnvelopeGrouping,
     379             :     const int32_t iChannels,
     380             :     const int32_t iNumBands,
     381             :     const int32_t *piBandwidths,
     382             :     float ***pppfReal,
     383             :     float ***pppfImag,
     384             :     int32_t *piNumGroups,
     385             :     int32_t *piGroupLengths,
     386             :     int32_t ***pppiRMSEnvelope 
     387             : );
     388             : 
     389             : 
     390             : /* clang-format on */
     391             : 
     392             : #endif /* _LCLD_ENCODER_H_ */

Generated by: LCOV version 1.14